StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEmcTriggerSimu.cxx
1 //
2 // Pibero Djawotho <pibero@comp.tamu.edu>
3 // Texas A&M University Cyclotron Institute
4 // 12 Jan 2009
5 //
6 
7 // STAR
8 #include "StMaker.h"
9 
10 // Local
11 #include "StTriggerUtilities/Bemc/StBemcTriggerSimu.h"
12 #include "StTriggerUtilities/Eemc/StEemcTriggerSimu.h"
13 #include "StTriggerUtilities/StDSMUtilities/StDSM2009Utilities.hh"
14 #include "StEmcTriggerSimu.h"
15 
16 ClassImp(StEmcTriggerSimu);
17 
18 StEmcTriggerSimu::StEmcTriggerSimu()
19  : mBemc(0)
20  , mEemc(0)
21  , mTcu(new TCU)
22 {
23 }
24 
25 StEmcTriggerSimu::~StEmcTriggerSimu()
26 {
27  delete mEM201; mEM201 = 0;
28  delete mLD301; mLD301 = 0;
29  delete mTcu; mTcu = 0;
30 }
31 
32 void StEmcTriggerSimu::setBemc(StBemcTriggerSimu* bemc)
33 {
34  mBemc = bemc;
35 }
36 
37 void StEmcTriggerSimu::setEemc(StEemcTriggerSimu* eemc)
38 {
39  mEemc = eemc;
40 }
41 
42 void StEmcTriggerSimu::InitRun(int runNumber)
43 {
44  // Get DB timestamp
45  StMaker* chain = StMaker::GetChain();
46  assert(chain);
47  mDBTime = chain->GetDBTime();
48  mYear = mDBTime.GetYear();
49 
50  mLD301 = new DSMLayer_LD301_2009;
51 
52  if(mYear == 2009 || mYear == 2010 || mYear == 2011 || mYear == 2012){
53  mEM201 = new DSMLayer_EM201_2009;
54  }else if(mYear == 2013){
55  if(runNumber < 14081067){
56  mEM201 = new DSMLayer_EM201_2009;
57  }else if(runNumber < 14084042){
58  mEM201 = new DSMLayer_EM201_2013_A;
59  }else{
60  mEM201 = new DSMLayer_EM201_2013;
61  }
62 
63  }else if(mYear == 2015){
64  mEM201 = new DSMLayer_EM201_2015;
65  }else if(mYear == 2016){
66  mEM201 = new DSMLayer_EM201_2014_B;
67  }else if(mYear == 2017){
68  mEM201 = new DSMLayer_EM201_2017;
69  }else
70  mEM201 = new DSMLayer_EM201_2009;
71 }
72 
73 void StEmcTriggerSimu::Make()
74 {
75  if (mYear >= 2009) {
76  if (mBemc) mBemc->get2009_DSMLayer1_Result()->write(*mEM201);
77  if (mEemc) mEemc->get2009_DSMLayer1_Result()->write(*mEM201);
78 
79  TString EM201String = "EM201: ";
80  for (int ch = 0; ch < 8; ++ch) EM201String += Form("%04x ",(*mEM201)[0].channels[ch]);
81  LOG_DEBUG << EM201String << endm;
82 
83  mEM201->run();
84 
85  if(mYear == 2013){
86  LOG_INFO << Form("EM201: BHT0=%d BHT1=%d BHT2=%d BHT3=%d EHT0=%d EHT1=%d JP1=%d JP2=%d BJP1=%d EEMCdijet=%d EJP1=%d JP1dijet=%d JP0dijet=%d BAJP=%d DAQ10k=%d JP0=%d",
87  BHT0(),BHT1(),BHT2(),BHT3(),EHT0(),EHT1(),JP1(),JP2(),BJP1(),EEMCdijet(),EJP1(),JP1dijet(),JP0dijet(),BAJP(),DAQ10k(),JP0()) << endm;
88  }else if(mYear == 2015){
89  LOG_INFO << Form("EM201: BHT0=%d BHT1=%d BHT2=%d HTTP=%d EHT0=%d EHT1=%d JP1=%d JP2=%d BJP1=%d BJP2=%d EJP1=%d EJP2=%d AJP=%d BAJP=%d EB2B=%d JP0=%d",
90  BHT0(),BHT1(),BHT2(),HTTP(),EHT0(), EHT1(), JP1(), JP2(), BJP1(),BJP2(), EJP1(),EJP2(),AJP(), BAJP(), EB2B(), JP0()) << endm;
91  }else if(mYear == 2016){
92  LOG_INFO << Form("EM201: BHT0=%d BHT1=%d BHT2=%d BHT3=%d BHT4=%d BHTUPC=%d BTP=%d BHTTP=%d BTPtopo=%d BHTTPtopo=%d BHT4topo=%d EHT0=%d EHT1=%d DAQ10k=%d",
93  BHT0(),BHT1(),BHT2(),BHT3(),BHT4(), BHTUPC(), BTP(), BHTTP(),BTPtopo(),BHTTPtopo(),BHT4topo(),EHT0_2014(),EHT1_2014(),DAQ10k_2014()) << endm;
94  }else if(mYear == 2017){
95  LOG_INFO << Form("EM201: BHT1=%d BHT2=%d BHT3=%d HTTP=%d EHT0=%d EHT1=%d BJP1=%d BJP2=%d JP0=%d JP1=%d JP2=%d EJP1=%d EJP2=%d",
96  BHT1_2017(),BHT2_2017(),BHT3_2017(),HTTP(), EHT0(), EHT1(), BJP1_2017(),BJP2_2017(), JP0_2017(), JP1_2017(),JP2_2017(),EJP1_2017(), EJP2_2017()) << endm;
97  }else{
98  LOG_INFO << Form("EM201: BHT0=%d BHT1=%d BHT2=%d BHT3=%d EHT0=%d EHT1=%d JP1=%d JP2=%d BJP1=%d BJP2=%d EJP1=%d EJP2=%d AJP=%d BAJP=%d EAJP=%d JP0=%d",
99  BHT0(),BHT1(),BHT2(),BHT3(),EHT0(),EHT1(),JP1(),JP2(),BJP1(),BJP2(),EJP1(),EJP2(),AJP(),BAJP(),EAJP(),JP0()) << endm;
100  }
101 
102  //for year 2009 set EM201 to LD301 then to TCU
103  if(mYear == 2009)
104  {
105  mEM201->write(*mLD301);
106 
107  TString LD301String = "LD301: ";
108 
109  for (int ch = 0; ch < 8; ++ch) LD301String += Form("%04x ",(*mLD301)[0].channels[ch]);
110  LOG_DEBUG << LD301String << endm; //changed this line LOG_INFO
111 
112  mLD301->run();
113 
114  mTcu->setInput((*mLD301)[0].output); //Run9 TCU setup
115  }else if(mYear > 2010)
116  {
117  mTcu->setInput((*mEM201)[0].output); //Run11 and Run12 TCU EM201 part -- zchang
118  }
119  LOG_DEBUG << Form("TCU: 0x%04x",mTcu->input() & 0xffff) << endm;
120  }
121 }
122 
123 bool StEmcTriggerSimu::isTrigger(int trigId)
124 {
125  return mTcu->isTrigger(trigId);
126 }
127 
128 set<int> StEmcTriggerSimu::triggerIds() const
129 {
130  return mTcu->triggerIds();
131 }
132 
133 StTriggerSimuDecision StEmcTriggerSimu::triggerDecision(int trigId)
134 {
135  return isTrigger(trigId) ? kYes : kNo;}
136 
137 void StEmcTriggerSimu::defineTrigger(TriggerDefinition& trigdef)
138 {
139  // Run11 and Run12 move EM201 output(onbit1 higher 16 bits) to onbits -- zchang
140  // LOG_INFO<<Form("use year %d trigger definition", mYear)<<endm;
141  if(mYear > 2010)
142  {
143  trigdef.onbits = trigdef.onbits1;
144  trigdef.onbits = trigdef.onbits >> 16;
145  }
146  mTcu->defineTrigger(trigdef);
147 }
148 
149 void StEmcTriggerSimu::defineTrigger(int triggerIndex, const char* name, int triggerId, unsigned int onbits, unsigned int offbits, unsigned int onbits1, unsigned int onbits2, unsigned int onbits3, unsigned int offbits1, unsigned int offbits2, unsigned int offbits3)
150 {
151  TriggerDefinition triggerDefinition;
152  triggerDefinition.triggerIndex = triggerIndex;
153  strcpy(triggerDefinition.name,name);
154  triggerDefinition.triggerId = triggerId;
155  triggerDefinition.onbits = onbits;
156  triggerDefinition.offbits = offbits;
157  triggerDefinition.onbits1 = onbits1;
158  triggerDefinition.onbits2 = onbits2;
159  triggerDefinition.onbits3 = onbits3;
160  triggerDefinition.offbits1 = offbits1;
161  triggerDefinition.offbits2 = offbits2;
162  triggerDefinition.offbits3 = offbits3;
163  LOG_INFO <<"New Defined Trigger: "
164  << Form("triggerIndex=%d name=%s triggerId=%d onbits=0x%04x offbits=0x%04x onbit1=0x%04x onbits2=0x%04x onbits3=0x%04x offbits1=0x%04x offbits2=0x%04x offbits3=0x%04x\n", triggerDefinition.triggerIndex,triggerDefinition.name,triggerDefinition.triggerId,triggerDefinition.onbits, triggerDefinition.offbits, triggerDefinition.onbits1, triggerDefinition.onbits2, triggerDefinition.onbits3, triggerDefinition.offbits1, triggerDefinition.offbits2, triggerDefinition.offbits3) << endm;
165 
166  defineTrigger(triggerDefinition);
167 }
168 
169 int StEmcTriggerSimu::EM201output() const { return (*mEM201)[0].output; }
170 
171 int StEmcTriggerSimu::overlapJetPatchTh(int i) const { return mEM201->getRegister(i); }
172 
173 void StEmcTriggerSimu::getOverlapJetPatchAdc(int i, int& jp, int& adc) const
174 {
175  int jp_partial = (*mEM201)[0].channels[6+i] >> 12 & 0x3;
176  jp = (1-i)*3+jp_partial-1;
177  adc = (*mEM201)[0].info[i];
178 }
179 int StEmcTriggerSimu::overlapJetPatchAdc(int jp) const
180 {
181  int adc = 0;
182  if(mBemc && mEemc){
183  adc = mBemc->barrelPartialJetPatchAdc(jp) + mEemc->endcapPartialJetPatchAdc(jp);
184  }
185  return adc;
186 }
Definition: TCU.hh:18
StTriggerSimuDecision triggerDecision(int trigId)
like isTrigger(), but returns kDoNotCare if detector isn&#39;t a part of the given trigId ...