StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
St2011W_EacessMuDst.cxx
1 // $Id: St2011W_EacessMuDst.cxx,v 1.7 2013/09/13 19:33:13 stevens4 Exp $
2 //
3 //*-- Author : Jan Balewski, MIT
4 //*-- Author for Endcap: Justin Stevens, IUCF
5 
6 //MuDst
7 #include <StMuDSTMaker/COMMON/StMuDstMaker.h>
8 #include <StMuDSTMaker/COMMON/StMuDst.h>
9 #include <StMuDSTMaker/COMMON/StMuTriggerIdCollection.h>
10 #include <StMuDSTMaker/COMMON/StMuEvent.h>
11 #include <StMuDSTMaker/COMMON/StMuTrack.h>
12 #include <StMuDSTMaker/COMMON/StMuPrimaryVertex.h>
13 
14 #include "StEEmcUtil/database/StEEmcDb.h"
15 #include "StEEmcUtil/database/EEmcDbItem.h"
16 
17 #include "St2011WMaker.h"
18 
19 //--------------------------------------
20 //--------------------------------------
21 int
22 St2011WMaker::accessEndcapTrig(){ // return non-zero on abort
23  if (isMC){
24  if(wEve->etow.maxAdc<10./60.*4096) return -1; //L2 is HT
25  hE[0]->Fill("L2ewET",1.);
26  wEve->l2EbitET=true;
27  return 0;
28  }
29 
30  StMuEvent* muEve = mMuDstMaker->muDst()->event();
31  StMuTriggerIdCollection *tic=&(muEve->triggerIdCollection());
32  assert(tic);
33  const StTriggerId &l1=tic->l1();
34  vector<unsigned int> idL=l1.triggerIds();
35 
36  //printf("nTrig=%d, trigID: ",idL.size());
37  for(unsigned int i=0;i<idL.size(); i++){
38  char txt[100];
39  sprintf(txt,"%d",idL[i]);
40  hE[1]->Fill(txt,1.);
41  }
42 
43  //check trigger ID
44  if(!tic->nominal().isTrigger(parE_l2ewTrgID)) return -2;
45  hE[0]->Fill("L2ewId",1.);
46 
47  //need to get offset for 2011 run for EEMC, done, hacked by Jan
48  struct L2weResult2011 {
49  unsigned char trigger; // bit0=rnd, bit1=ET>thr
50  unsigned char highestEt; // cluster Et with 60Gev Max. bits=Et*256/60
51  unsigned short highestRDO;
52  };
53 
54  TArrayI& l2Array = muEve->L2Result();
55  LOG_DEBUG <<Form("AccessL2Decision() from regular muDst: L2Ar-size=%d",l2Array.GetSize())<<endm;
56  unsigned int *l2res=(unsigned int *)l2Array.GetArray();
57  const int EEMCW_off=35; // valid only for 2011 run
58 
59  L2weResult2011 *l2algo= ( L2weResult2011 *) &l2res[EEMCW_off];
60  wEve->l2EbitET=(l2algo->trigger&2)>0; // bit1=ET>thr
61  wEve->l2EbitRnd=(l2algo->trigger&1)>0; // bit0=rnd,
62 
63 #if 0
64  if(l2algo->trigger==0) return -3;
65  printf(" L2-jet online results below:\n");
66  for (int k=0;k<64;k++)
67  if(l2res[k]) printf("k=%2d val=0x%04x\n",k,l2res[k]);
68  printf("L2WE_Result 4-bytes: trg bitET=%d, bitRnd=%d, highets: ET/GeV=%.2f, RDO=%d hex=0x%08x\n",wEve->l2EbitET,wEve->l2EbitRnd,l2algo->highestEt/256.*60,l2algo->highestRDO,l2res[EEMCW_off]);
69 #endif
70 
71  // hack to make the code work also for run 9 and early run 12
72  if (mRunNo<11000111 || mRunNo>13000000) {
73  wEve->l2EbitET=1;
74  wEve->l2EbitRnd=1;
75  }
76 
77  if( (wEve->l2EbitRnd || wEve->l2EbitET)==0) return -3; // L2W-algo did not accept this event
78  hE[0]->Fill("L2ewBits",1.); // confirmation bits were set properly
79 
80  if(wEve->l2EbitRnd) {
81  hE[0]->Fill("L2ewRnd",1.);
82  for (int m=0;m<90;m++){
83  int val=muEve->emcTriggerDetector().highTowerEndcap(m);
84  hE[7]->Fill(val);
85  }
86  hE[61]->Fill(wEve->bx7);
87  }
88 
89  if(!wEve->l2EbitET) return -3; // drop L2W-random accepts
90  if(wEve->l2EbitET) hE[0]->Fill("L2ewET",1.);
91 
92  //.... only monitor below ....
93  hE[2]->Fill(wEve->bx48);
94  hE[3]->Fill(wEve->bx7);
95 
96  // access L0-HT data
97  int mxVal=-1;
98  for (int m=0;m<90;m++) {
99  int val=muEve->emcTriggerDetector().highTowerEndcap(m);
100  if(mxVal<val) mxVal=val;
101  if(wEve->l2EbitET) hE[6]->Fill(val);
102  if(val<parE_DsmThres) continue;
103  if(wEve->l2EbitET) hE[8]->Fill(m);
104  //printf("Fired L0 EHT m=%d val=%d\n",m,val);
105  }
106  wEve->etow.maxHtDsm=mxVal;
107  return 0;
108 }
109 
110 //________________________________________________
111 //________________________________________________
112 int
113 St2011WMaker::accessETOW(){
114 
115  StMuEmcCollection* emc = mMuDstMaker->muDst()->muEmcCollection();
116  if (!emc) {
117  LOG_WARN <<"No EMC data for this event"<<endm; return -4;
118  }
119 
120  wEve->etow.etowIn=1; //tag usable ETOW data
121  const char *maxIdName=0;
122  double maxADC=0,adcSum=0;
123  int maxSec=-1,maxSub=-1,maxEta=-1;
124 
125  //loop over all towers
126  for (int i=0; i< emc->getNEndcapTowerADC(); i++) {
127  int sec,eta,sub,rawAdc; //muDst ranges:sec:1-12, sub:1-5, eta:1-12
128  emc->getEndcapTowerADC(i,rawAdc,sec,sub,eta);
129 
130  const EEmcDbItem *x=mDbE->getTile(sec,'A'+sub-1,eta,'T');
131  assert(x); // it should never happened for muDst
132  if(x->fail ) continue; // drop not working channels
133  int isec=x->sec-1;
134  int isub=x->sub-'A';
135  int ieta=x->eta-1;
136 
137  assert(isec>=0 && isec<mxEtowSec); // check input is ok
138  assert(isub>=0 && isub<mxEtowSub);
139  assert(ieta>=0 && ieta<mxEtowEta);
140 
141  float adc=rawAdc-x->ped; // ped subtracted ADC
142  if(adc<par_kSigPed*x->sigPed) continue;
143 
144  wEve->etow.adc[isec*mxEtowSub+isub][ieta]=adc;
145 
146  if(x->gain<=0) continue;// drop channels w/o gains
147  float ene=adc/x->gain;
148 
149  //method for shifting energy scale
150  ene*=par_etowScale;//(default is par_etowScale=1)
151  wEve->etow.ene[isec*mxEtowSub+isub][ieta]=ene;
152  wEve->etow.stat[isec*mxEtowSub+isub][ieta]=0;
153 
154  if(maxADC<adc) { maxIdName=x->name; maxADC=adc; maxSec=isec; maxSub=isub; maxEta=ieta;}
155  adcSum+=adc;
156 
157  }
158 
159  wEve->etow.maxAdc=maxADC;
160  wEve->etow.maxSec=maxSec; wEve->etow.maxSub=maxSub; wEve->etow.maxEta=maxEta;
161  hE[31]->Fill(maxADC);
162  hE[32]->Fill(adcSum);
163 
164  if(maxADC<par_maxADC) return -2 ; // not enough energy
165 
166  return 0;
167 }
168 
169 //________________________________________________
170 //________________________________________________
171 void
172 St2011WMaker::accessEPRS(){
173  StMuEmcCollection* emc = mMuDstMaker->muDst()->muEmcCollection();
174  if (!emc) {
175  LOG_WARN <<"No EMC data for this event"<<endm;
176  }
177 
178  int i ;
179  int pNh= emc->getNEndcapPrsHits();
180  for (i=0; i < pNh; i++) {
181  int pre,sec,eta,sub; //muDst ranges: sec:1-12, sub:1-5, eta:1-12 ,pre:1-3==>pre1/pre2/post
182 
183  StMuEmcHit *hit=emc->getEndcapPrsHit(i,sec,sub,eta,pre);
184  float rawAdc=hit->getAdc();
185  //Db ranges: sec=1-12,sub=A-E,eta=1-12,type=T,P-R ; slow method
186  const EEmcDbItem *x=mDbE->getTile(sec,sub-1+'A',eta,pre-1+'P');
187  assert(x); // it should never happened for muDst
188  if(x->fail ) continue; // drop not working channels
189 
190  int isec=x->sec-1;
191  int isub=x->sub-'A';
192  int ieta=x->eta-1;
193  int ipre=pre-1;
194  int iphi=isec*mxEtowSub+isub;
195 
196  assert(isec>=0 && isec<mxEtowSec); // check input is ok
197  assert(isub>=0 && isub<mxEtowSub);
198  assert(ieta>=0 && ieta<mxEtowEta);
199 
200  float adc=rawAdc-x->ped; // ped subtracted ADC
201  if(adc<par_kSigPed*x->sigPed) continue;
202 
203  wEve->eprs.adc[iphi][ieta][ipre]=adc;
204 
205  if(x->gain<=0) continue;// drop channels w/o gains
206 
207  wEve->eprs.ene[isec*mxEtowSub+isub][ieta][ipre]=adc/x->gain;
208  wEve->eprs.stat[isec*mxEtowSub+isub][ieta][ipre]=0;
209 
210  }
211 }
212 
213 //________________________________________________
214 //________________________________________________
215 void
216 St2011WMaker::accessESMD(){
217  StMuEmcCollection* emc = mMuDstMaker->muDst()->muEmcCollection();
218  if (!emc) {
219  LOG_WARN <<"No EMC data for this event"<<endm;
220  }
221 
222  char uv='U';
223  for(uv='U'; uv <='V'; uv++) {
224  int sec,strip;
225  int nh= emc->getNEndcapSmdHits(uv);
226  int i;
227  for (i=0; i < nh; i++) {
228  StMuEmcHit *hit=emc->getEndcapSmdHit(uv,i,sec,strip);
229  float rawAdc=hit->getAdc();
230  const EEmcDbItem *x=mDbE->getByStrip(sec,uv,strip);
231  assert(x); // it should never happened for muDst
232 
233  if(x->fail ) continue; // drop broken channels
234  if(x->ped<0) continue; // drop channels without peds
235 
236  float adc=rawAdc-x->ped; // ped subtracted ADC
237 
238  float sigPed=x->sigPed;
239  // x->print(); printf("adc=%f\n",adc);
240  int isec=sec-1;
241  int iuv=x->plane-'U';
242  int istr=x->strip -1;
243 
244  assert(isec>=0 && isec<mxEtowSec);//never trust the input
245  assert(iuv>=0 && iuv<mxEsmdPlane);
246  assert(istr>=0 && istr<mxEsmdStrip);
247  if(x->gain<=0)continue; // drop channels w/o gains
248  if(adc<par_kSigPed*sigPed) continue; //drop noise
249 
250  wEve->esmd.adc[isec][iuv][istr]=adc;
251  wEve->esmd.ene[isec][iuv][istr]=adc/x->gain;
252  }
253  }
254 }
255 
256 
257 //$Log: St2011W_EacessMuDst.cxx,v $
258 //Revision 1.7 2013/09/13 19:33:13 stevens4
259 //Updates to code for combined 2011+2012 result presented to spin PWG 9.12.13
260 //
261 //Revision 1.6 2012/07/12 20:49:21 balewski
262 //added spin info(star: bx48, bx7, spin4) and maxHtDSM & BTOW to Wtree
263 //removed dependence of spinSortingMaker from muDst
264 //Now Wtree can be spin-sorted w/o DB
265 //rdMu.C & readWtree.C macros modified
266 //tested so far on real data run 11
267 //lot of misc. code shuffling
268 //
269 //Revision 1.5 2012/06/26 20:30:23 stevens4
270 //Updates ZMaker for mixing barrel and endcap arms
271 //
272 //Revision 1.4 2012/06/18 18:28:00 stevens4
273 //Updates for Run 9+11+12 AL analysis
274 //
275 //Revision 1.3 2011/02/25 06:03:37 stevens4
276 //addes some histos and enabled running on MC
277 //
278 //Revision 1.2 2011/02/14 01:36:17 stevens4
279 //*** empty log message ***
280 //
281 //Revision 1.1 2011/02/10 20:33:22 balewski
282 //start
283 //
StMuDst * muDst()
Definition: StMuDstMaker.h:425
char name[StEEmcNameLen]
ASCII name of the channel, see Readme.
Definition: EEmcDbItem.h:20
int getAdc() const
Return ADC value.
Definition: StMuEmcHit.h:19
static StMuEmcCollection * muEmcCollection()
returns pointer to current StMuEmcCollection
Definition: StMuDst.h:389
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
Collection of trigger ids as stored in MuDst.