StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StL2_2006EmulatorMaker.cxx
1 //
3 // StL2_2006EmulatorMaker Jan Balewski (Fall, 2007)
4 //
5 // Goal:
6 //
7 //
9 // StEvent
10 #include "StEventTypes.h"
11 #include "StEvent/StEvent.h"
12 
13 //MuDst
14 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
15 #include "StMuDSTMaker/COMMON/StMuDst.h"
16 #include "StMuDSTMaker/COMMON/StMuTriggerIdCollection.h"
17 #include "StMuDSTMaker/COMMON/StMuEvent.h"
18 
19 //trg stuff
20 #include "StTriggerData2005.h"
21 #include "StDaqLib/TRG/L2jetResults2006.h"
22 #include "StDaqLib/TRG/trgStructures2005.h"
23 #include "StDaqLib/TRG/trgStructures.h"
24 
25 //L2 stuff
26 #include "L2algoUtil/L2EmcDb.h"
27 #include "L2jetAlgo/L2jetAlgo2006.h"
28 #include "L2pedAlgo/L2pedAlgo.h"
29 #include "L2gammaAlgo/L2gammaAlgo.h"
30 #include "L2upsilon/L2upsilon2006.hh"
31 
32 #include "StL2_2006EmulatorMaker.h"
33 
34 ClassImp(StL2_2006EmulatorMaker)
35 
36 StL2_2006EmulatorMaker::StL2_2006EmulatorMaker(const char *name):StMaker(name) {
37  mL2pedAlgo=0;
38  mL2jetAlgo2006=0;
39  mL2gammaEEmc=mL2gammaBEmc=0;
40  mL2upsilon2006=0;
41 }
42 
43 //========================================
44 StL2_2006EmulatorMaker::~StL2_2006EmulatorMaker(){
45 }
46 
47 
48 //========================================
49 //========================================
50 Int_t
51 StL2_2006EmulatorMaker::InitRun(int runNo){
52  //WARN: do NOT use runNo for any setup - it woul dberak for M-C
53  //WARN: do NOT use run# to controll setup of L2-algos
54 
55  initRun1();
56  LOG_INFO << Form("::setupL2Algos2006(), dbDate=%d ", mYearMonthDay)<<endm;
57 
58 
59  assert(mYearMonthDay>20060000);
60  assert(mYearMonthDay<20060700);
61 
62  mL2algoN=5; // total # of L2 algos (ped, jet)
63  mL2algo =new L2VirtualAlgo *[mL2algoN]; // not cleared memeory leak
64  memset(mL2algo,0,mL2algoN*sizeof(void*));
65  //setup every algo one by one, params may be time dependent
66 
67  // ----------- L2 ped algo ---------------- slot 0
68  mL2algo[0]=mL2pedAlgo=new L2pedAlgo("ped-algo",mL2EmcDb,mL2EmcDb->logPath,L2RESULTS_OFFSET_EMC_PED);
69 
70  // ----------- L2 jet algo ---------------- slot 1
71  //time dependent L2jet cuts are below
72  assert( mYearMonthDay>20060316); // before L2jet was not used
73  assert( mYearMonthDay<20060620); // after L2jet was not used
74 
75  mL2algo[1]=mL2jetAlgo2006=new L2jetAlgo2006("jet06-algo",mL2EmcDb,mL2EmcDb->logPath,L2RESULTS_OFFSET_DIJET);
76 
77  // ----------- L2 gamma algo ----------------uses slots 2 & 3
78  assert( mYearMonthDay >= 20060406 ); // before ppTrans
79  assert( mYearMonthDay <= 20060607 ); // after ppLong2
80 
81  mL2algo[2]=mL2gammaEEmc=new L2gammaAlgo("etow_gamma",mL2EmcDb,mL2EmcDb->logPath,L2RESULTS_OFFSET_PIG+2);
82  mL2algo[3]=mL2gammaBEmc=new L2gammaAlgo("btow_gamma",mL2EmcDb,mL2EmcDb->logPath,L2RESULTS_OFFSET_PIG);
83 
84  // ----------- L2 Upsilon algo ---------------- slot 4
85  assert( mYearMonthDay >= 20060406 ); // before ppTrans
86  assert( mYearMonthDay <= 20060607 ); // after ppLong2
87 
88  mL2algo[4]=mL2upsilon2006=new L2upsilon2006("upsilon", mL2EmcDb, mL2EmcDb->logPath,L2RESULTS_OFFSET_UPS);
89  TString fullPath=Form("%sL2/%d/algos/btowXYZ.dat", mSetupPath.Data(), mYear);
90  mL2upsilon2006->readGeomXYZ(fullPath.Data());
91 
92  // ----------- L2 J/Psi algo ---------------- slot 5
93  // add here
94 
95  initRun2(runNo);
96 
97  LOG_INFO << "::InitRun() done, run=" <<runNo<<" isMC="<<mMCflag<<endm;
98  return kStOK;
99 }
100 
101 
102 //_____________________________________________________________________________
103 Int_t
104 StL2_2006EmulatorMaker::Init() {
105  init();
106  LOG_INFO <<Form("Init()")<<endm;
107  // initHistoA("spj_");
108 
109  return StMaker::Init();
110 }
111 
112 //========================================
113 void
114 StL2_2006EmulatorMaker::Clear(const Option_t*){
115  clear();
116  // LOG_DEBUG<<"StL2_2006EmulatorMaker::Clear()"<<endm;
117 }
118 
119 
120 //========================================
121 Int_t
123  if( mMCflag==0) getTriggerData(); // for monitoring only
124 
125  make();
126 
127 
128 #if 0
129  //---------------- ONLY debugging is below ------------
130  int l2jetOff=-1;
131  if(mYear==2006) l2jetOff=L2RESULTS_OFFSET_DIJET;
132  //dump L2jet results calculated by offline-algo
133  const unsigned int *l2res=( (TrgDataType*)mTrigData)->TrgSum.L2Result;
134  printf(" L2-jet off-line results below:\n");
135  // int k; for (k=0;k<32;k++) printf("k=%2d val=0x%04x\n",k,l2res[k]);
136  L2jetResults2006 *out1= ( L2jetResults2006 *) &l2res[l2jetOff];
137 
138  L2jetResults2006_print(out1);
139  unsigned char cSum=L2jetResults2006_doCheckSum(out1);
140  assert(cSum==0);
141 
142 #endif // end of debuging
143 
144  return kStOK;
145 }
146 
147 //========================================
148 Int_t
150  finish();
151  return kStOK;
152 }
153 
154 
155 
156 
157 //========================================
158 //========================================
159 bool
160 StL2_2006EmulatorMaker::getTriggerData(){
161  const StTriggerId *L1=0;
162  //play with trigID
163 
164  int runId=0;
165  int l2jetOff=0;
166  if(mYear==2006) l2jetOff=L2RESULTS_OFFSET_DIJET;
167 
168  const unsigned int *l2res=0;
169 
170  if(mUseMuDst) {
171  StMuDstMaker *muMk = (StMuDstMaker*)StMaker::GetChain()-> GetMaker("MuDst");
172  assert(muMk);
173  // use muDst first, in JetReader StEvent also exist -but w/o trigger data
174  StMuEvent *muEve = muMk -> muDst() -> event();
175  assert(muEve);
176  StMuTriggerIdCollection ticB = muEve -> triggerIdCollection();
177  L1 = &ticB.nominal();
178  StEventInfo &info=muEve->eventInfo();
179  runId=info.runId();
180 
181 #if 0 // read ezTree
182  printf("AccessL2Decision() from ezTree:\n");
183  EztTrigBlob *eTrig=muMk->muDst()->eztTrig();
184  assert(eTrig);
185  const TrgDataType2005 * trgDB=(TrgDataType2005 *)eTrig->trgd->GetArray();
186 
187  StTriggerData2005 trgAkio5(trgDB , runId);
188  l2jetOff=trgAkio5.L2ResultsOffset(idJ);
189  l2res=trgDB->TrgSum.L2Result;
190 #endif
191 
192  // read regular muDst
193  if(mMCflag==0) {
194  TArrayI& l2Array = muMk->muDst()->event()->L2Result();
195  LOG_DEBUG <<Form("AccessL2Decision() from regular muDst: L2Ar-size=%d",l2Array.GetSize())<<endm;
196  l2res=(unsigned int *)l2Array.GetArray();
197  }
198 
199  } else { // try StEvent
200  StEvent *mEvent = (StEvent *)StMaker::GetChain()-> GetInputDS("StEvent");
201  assert(mEvent); // no other choises (except ezTree)
202  StTriggerIdCollection *ticA=mEvent->triggerIdCollection();
203  assert(ticA); L1=ticA->nominal(); //was: l1();
204  StEventInfo *info=mEvent->info();
205  runId=info->runId();
206  //?? trgD=(StTriggerData2005*) mEvent->triggerData(); assert(trgD);
207  //not working
208  assert(1==2);
209  }
210 
211 #if 0
212  if( !(L1->isTrigger(127622) || L1->isTrigger(127652)) ) {
213  printf("Discard none-L2jet triggered events\n");
214  return false; // discard events
215  }
216 #endif
217 
218 #if 0 // just debugging & cross check
219  if(mMCflag==0) {
220  printf(" L2-jet online results below:\n");
221  // int k; for (k=0;k<32;k++) printf("k=%2d val=0x%04x\n",k,l2res[k]);
222  L2jetResults2006 *out1= ( L2jetResults2006 *) &l2res[l2jetOff];
223  // printf("pp=%p %d %d \n",out1,sizeof(L2jetResults2006), sizeof(L2jetOutInt0));
224  L2jetResults2006_print(out1);
225  unsigned char cSum=L2jetResults2006_doCheckSum(out1);
226  assert(cSum==0);
227  } // only for real data
228 #endif // end of debugging
229 
230 #if 0
231  vector<unsigned int> trgL=L1->triggerIds();
232  printf("trigL len=%d totEve=%d\n",trgL.size(),mTotInpEve);
233  unsigned int ii;
234  for(ii=0;ii<trgL.size();ii++){
235  printf("ii=%d trigID=%d\n",ii,trgL[ii]);
236  }
237 #endif
238 
239  // int id1=96300; printf("is zeroBias=%d -->%d\n",id1,L1->isTrigger(id1));
240  // if(totInpEve>15) assert(L1->isTrigger(id1)==0 || trgL.size()>1);
241  //if(mTrigId && L1->isTrigger(mTrigId)==0) return false;
242 
243 
244  //........get decision in 2006.......................
245  // bool isDijet = (jetRes->int0.decision) & 0x80;
246  // bool isMonojet= (jetRes->int0.decision) & 0x40;
247  //bool isRandom = (jetRes->int0.decision) & 0x20;
248 
249 
250  return true;
251 
252 }
253 
254 
255 // $Id: StL2_2006EmulatorMaker.cxx,v 1.13 2010/08/13 00:44:16 rfatemi Exp $
256 //
257 
258 
259 #if 0
260 //_____________________________________________________________________________
261 void
262 StL2_2006EmulatorMaker::initHistoA(TString core) {
263  LOG_INFO <<Form("initHistoA(),")<<endm;
264 
265  assert(mHList);
266  memset(hA,0,sizeof(hA));
267 
268  hA[0]=0;
269  hA[1]=new TH1F(core+"trgID", "event counter for Jan",10,1,11);
270 
271  //.... add histos to the list
272  int i;
273  for(i=0;i<mxAH;i++) {
274  if( hA[i]==0) continue;
275  mHList->Add( hA[i]);
276  }
277 }
278 #endif
StMuDst * muDst()
Definition: StMuDstMaker.h:425
static EztTrigBlob * eztTrig()
returns pointer to eztTrig
Definition: StMuDst.h:448
Collection of trigger ids as stored in StEvent.
A level-2 &quot;cluster&quot; based trigger.
Definition: L2gammaAlgo.h:57
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
Definition: Stypes.h:40
Collection of trigger ids as stored in MuDst.