00001 #!/usr/local/bin/python 00002 # 00003 # Copyright 2004 00004 # by 00005 # The Board of Trustees of the 00006 # Leland Stanford Junior University. 00007 # All rights reserved. 00008 # 00009 00010 __facility__ = "Online" 00011 __abstract__ = "GLAST LAT Coincidence based Trigger System Interface classes" 00012 __author__ = "Jim Panetta <panetta@slac.stanford.edu> SLAC - GLAST I&T" 00013 __date__ = "2/14/04" 00014 __version__ = "$Revision: 1.4 $" 00015 __release__ = "$Name: R04-12-00 $" 00016 __credits__ = "SLAC" 00017 00018 import LATTE.copyright_SLAC 00019 00020 # This class uses 00021 from LATTE.trigger.TrgUsingTiles import TrgUsingTiles 00022 from LATTE.trigger.NullObjects import NoInputsEnabled 00023 from LATTE.trigger.rcTrgFunctions import rcTrgEngines 00024 from LATTE.trigger.TrgEngines import * 00025 from LATTE.trigger.TrgConditionsValue import TrgConditionsValue 00026 00027 """\brief Interface for Coincidence based Trigger System""" 00028 00029 class SimpleGasuExample(TrgUsingTiles): 00030 """\brief SimpleGASU example interface to GEM 00031 """ 00032 def __init__(self): 00033 """\brief SimpleGasuExample constructor 00034 """ 00035 TrgUsingTiles.__init__(self) 00036 self.__inputEnables = SGETrgInputEnables() 00037 self.__engines = SGETrgEngines() 00038 self.__conditions = SolicitedCondition() 00039 00040 # Pure Virtual function implementation 00041 def conditions(self): 00042 return self.__conditions 00043 00044 def coincidences(self): 00045 """\brief Implementation of coincdences 'pure virtual' method from TrgUsingTiles 00046 """ 00047 # it just so happens that the roi is exactly the same as the coincidences object 00048 return self.roi() 00049 00050 def inputEnables(self): 00051 """\brief Implementation of inputEnables 'pure virtual' method from TrgAbstract 00052 """ 00053 return self.__inputEnables 00054 00055 def engines(self): 00056 """\brief Implementation of engines 'pure virtual' method from TrgAbstract 00057 """ 00058 return self.__engines 00059 00060 def useAcdAsTrigger(self): 00061 """Use ACD as a trigger source. 00062 """ 00063 return True 00064 00065 # implementaions of user-level trigger classes 00066 00067 class SGETrgInputEnables(NoInputsEnabled): 00068 """Class SGETrgInputEnables: 00069 Empty Input enables. 00070 """ 00071 def __init__(self): 00072 NoInputsEnabled.__init__(self) 00073 def towerBusy(self): 00074 # Use NotImplementedError exception to force TrgGemRegisters to 00075 # enable all tower_busy signals by default 00076 raise NotImplementedError 00077 pass 00078 00079 00080 # class MiniTowerEnabled(TrgTowerEnables): 00081 # """ One tower enabled 00082 # """ 00083 # def __init__(self): 00084 # TrgTowerEnables.__init__(self) 00085 # self.__towers = [MiniTower()] + [NullTower()] * 15 00086 # def tower(self,towerNumber): 00087 # return self.__towers[towerNumber] 00088 # 00089 # class MiniTower(TrgTower): 00090 # """ One tower enabled, tracker and calorimeter 00091 # """ 00092 # def __init__(self): 00093 # TrgTower.__init__(self) 00094 # self.__cal = MiniTowerCal() 00095 # self.__tkr = MiniTowerTkr() 00096 # def calorimeter(self): 00097 # return self.__cal 00098 # def tracker(self): 00099 # return self.__tkr 00100 # 00101 # class MiniTowerCal(TrgCalorimeter): 00102 # def __init__(self): 00103 # TrgCalorimeter.__init__(self) 00104 # def useHighEnergy(self): 00105 # return True 00106 # def useLowEnergy(self): 00107 # return True 00108 # 00109 # class MiniTowerTkr(TrgTracker): 00110 # def __init__(self): 00111 # TrgTracker.__init__(self) 00112 # def use(self): 00113 # return True 00114 # 00115 00116 # class AllConditions(TrgConditionsValue): 00117 # def __init__(self): 00118 # TrgConditionsValue.__init__(self) 00119 # def roi(self): 00120 # return True 00121 # def calLow(self): 00122 # return True 00123 # def calHigh(self): 00124 # return True 00125 # def tkr(self): 00126 # return True 00127 # def periodic(self): 00128 # return True 00129 # def solicited(self): 00130 # return True 00131 # def cno(self): 00132 # return True 00133 00134 class SGETrgEngines(rcTrgEngines): 00135 """Class MyTrgEngines: 00136 Initialize the trigger engines list class. 00137 """ 00138 def __init__(self): 00139 rcTrgEngines.__init__(self) 00140 eng1 = SolicitedEngine() 00141 self.replaceEngine(0,eng1) 00142 00143 class SolicitedEngine(TrgEngine): 00144 """This class defines an engine which reads out the detector 00145 whenever there is a solicited trigger. 00146 This engine is not prescaled. 00147 """ 00148 def __init__(self): 00149 TrgEngine.__init__(self) 00150 self.__request = TrgReadout() 00151 def participate(self,conditionsValue): 00152 # This function relies on the programmer's knowledge that the 00153 # conditionsValue is a bitfield. 00154 cond = SolicitedCondition() 00155 if conditionsValue & cond.value(): 00156 return True 00157 return False 00158 def prescale(self): 00159 return 0 00160 def request(self): 00161 return self.__request 00162 00163 class SolicitedCondition(TrgConditionsValue): 00164 """ Define a condition where only the solicited trigger is asserted 00165 """ 00166 def __init__(self): 00167 TrgConditionsValue.__init__(self) 00168 def solicited(self): 00169 return True 00170 00171 class ZsupTrgReadout(TrgReadout): 00172 """\brief ZsupTrgReadout class definition 00173 00174 Directs a module to send to its Front-End Electronics a command sequence 00175 which is composed only of the TACK command. This command will trigger 00176 a readout of the module's Front-End Electronics. 00177 Zero suppression is turned on. 00178 """ 00179 def __init__(self): 00180 """\brief TrgReadout constructor 00181 """ 00182 TrgReadout.__init__(self) 00183 00184 def zeroSuppress(self): 00185 return True 00186 00187 # class PeriodicEngine(TrgEngine): 00188 # """This class defines an engine which reads out the detector 00189 # whenever there is a solicited trigger. 00190 # This engine is not prescaled. 00191 # """ 00192 # def __init__(self): 00193 # TrgEngine.__init__(self) 00194 # self.__request = TrgReadout() 00195 # def participate(self,conditionsValue): 00196 # # This function relies on the programmer's knowledge that the 00197 # # conditionsValue is a bitfield. 00198 # cond = PeriodicCondition() 00199 # if conditionsValue == cond.value(): 00200 # return True 00201 # return False 00202 # def prescale(self): 00203 # return 0 00204 # def request(self): 00205 # return self.__request 00206 # 00207 # class PeriodicCondition(TrgConditionsValue): 00208 # """ Define a condition where only the solicited trigger is asserted 00209 # """ 00210 # def __init__(self): 00211 # TrgConditionsValue.__init__(self) 00212 # def periodic(self): 00213 # return True 00214 # 00215 00216 00217