We present an automated laser tracking and optogenetic manipulation system (ALTOMS) for studying social memory in fruit flies (Drosophila melanogaster). ALTOMS comprises an intelligent central control module for high-speed fly behavior analysis and feedback laser scanning (∼40 frames per second) for targeting two lasers (a 473-nm blue laser and a 593.5-nm yellow laser) independently on any specified body parts of two freely moving Drosophila adults. By using ALTOMS to monitor and compute the locations, orientations, wing postures, and relative distance between two flies in real time and using high-intensity laser irradiation as an aversive stimulus, this laser tracking system can be used for an operant conditioning assay in which a courting male quickly learns and forms a long-lasting memory to stay away from a freely moving virgin female. With the equipped lasers, channelrhodopsin-2 and/or halorhodopsin expressed in selected neurons can be triggered on the basis of interactive behaviors between two flies. Given its capacity for optogenetic manipulation to transiently and independently activate/inactivate selective neurons, ALTOMS offers opportunities to systematically map brain circuits that orchestrate specific Drosophila behaviors.operant learning | restraining order | restraining conditioning S ocial interactions are an important part of human life because they help us learn how to behave in a society. However, the mechanisms by which the neuron circuitry controls and modifies our behavior on the basis of previous experiences of interactions with others remain unclear. Drosophila courtship conditioning has been widely used for studying how genes and brain circuits control and modify a specific type of social interaction (1-6). In this behavioral assay, individual male fruit flies learn to suppress their courtship activity after several hours of exposure to an unreceptive female. Specific cuticular pheromones, such as 9-pentacosene, have been shown to potentially serve as conditioned stimuli (4, 7-9). Visual inputs act as conditioned stimuli for courtship through modulation of Ca 2+ /calmodulin-dependent protein kinase activity in the brain circuitry (4). An aversive male pheromone, cis-vaccenyl acetate, which is transferred to the female during copulation, may act as a punishment so that the rejected male forms a generalized memory that suppresses its subsequent courtship behavior (10). However, little is known about where and how the neural activities that represent the antecedent conditions and aversive consequence are associated in the brain-knowledge that is crucial for understanding courtship memory and decision making-because controlling female rejection behaviors (11) and acutely manipulating target neurons in courting males during social interaction are difficult. Here, we present an automated laser tracking system for real-time analysis and perturbation of social interactions between two freely moving adult flies that is equipped with highenergy laser irradiation as a controllable punishment source ...