StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
St2009W_accessMuDst.cxx
1 // $Id: St2009W_accessMuDst.cxx,v 1.18 2011/09/14 14:23:20 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 "StEmcRawMaker/defines.h"
15 #include "StEmcUtil/database/StBemcTables.h"
16 
17 #include "StEEmcUtil/database/StEEmcDb.h"
18 #include "StEEmcUtil/database/EEmcDbItem.h"
19 
20 #include "StEmcUtil/geometry/StEmcGeom.h"
21 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
22 
23 #include "St2009WMaker.h"
24 //--------------------------------------
25 //--------------------------------------
26 int
27 St2009WMaker::accessTrig(){ // return non-zero on abort
28 
29  if (isMC){
30  /*
31  When the trigger emulator is ready, this should hook into that
32  instead of the two functions used below. For now, check that is passes both
33  L0 and L2, and set the l2bitET flag to true if so.
34  */
35 
36  if (!passes_L0()) return -1;
37  hA[0]->Fill("BHT3Id",1.);
38  if(!passes_L2()) return -2;
39  hA[0]->Fill("L2wId",1.);
40 
41  if(isMC>300){
42  StMuEvent* muEve = mMuDstMaker->muDst()->event();
43  StL0Trigger *trig=&(muEve->l0Trigger());
44  wEve.bx48=trig->bunchCrossingId();
45  wEve.bx7=trig->bunchCrossingId7bit(par_inpRunNo);
46  }
47 
48  wEve.l2bitET=true;
49  return 0; // we haven't set everything, but it should be good enough for simu.
50  }
51 
52  StMuEvent* muEve = mMuDstMaker->muDst()->event();
53 
54  //collect info for the luminosity monitor
55  int highestT=0;
56  int highestM=0;
57  for (int m=0;m<300;m++)
58  {
59  int myT=muEve->emcTriggerDetector().highTower(m);
60  if (myT>highestT)
61  {
62  highestT=myT;
63  highestM=m;
64  }
65  }
66  int highestPhi, tempPhi, tempEta;
67  int awaySum[16];
68  int totalSum=0;
69  for (int i=0;i<16;i++) awaySum[i]=0;
70 
71  patchToEtaPhi(highestM,&tempEta,&highestPhi);
72 
73  for (int m=0;m<300;m++)
74  {
75  int myT=muEve->emcTriggerDetector().highTower(m);
76  patchToEtaPhi(m,&tempEta,&tempPhi);
77  for (int away_width=0;away_width<16;away_width++)
78  if ((highestPhi+30-tempPhi)%30>(15-away_width) && (highestPhi+30-tempPhi)%30<(15+away_width))
79  {
80  //printf("==> adding %d to awaySum",myT);
81  awaySum[away_width]+=myT;
82  }
83  totalSum+=myT;
84  }
85  for (int i=0;i<16;i++) wEve.trigAwaySum[i]=awaySum[i];
86  wEve.trigTotalSum=totalSum;
87  //
88 
89  StMuTriggerIdCollection *tic=&(muEve->triggerIdCollection());
90  assert(tic);
91  const StTriggerId &l1=tic->l1();
92  vector<unsigned int> idL=l1.triggerIds();
93 
94  // printf("nTrig=%d, trigID: ",idL.size());
95  for(unsigned int i=0;i<idL.size(); i++){
96  char txt[100];
97  sprintf(txt,"%d",idL[i]);
98  hA[1]->Fill(txt,1.);
99  }
100  // printf("\n");
101 
102  if(!tic->nominal().isTrigger(par_bht3TrgID)) return -1;
103  hA[0]->Fill("BHT3Id",1.);
104  if(!tic->nominal().isTrigger(par_l2wTrgID)) return -2;
105  hA[0]->Fill("L2wId",1.);
106 
107  TArrayI& l2Array = muEve->L2Result();
108  LOG_DEBUG <<Form("AccessL2Decision() from regular muDst: L2Ar-size=%d",l2Array.GetSize())<<endm;
109  unsigned int *l2res=(unsigned int *)l2Array.GetArray();
110  //printf(" L2-jet online results below:\n");
111  const int BEMCW_off=20; // valid only for 2009 run
112  //int k; for (k=0;k<32;k++) printf("k=%2d val=0x%04x\n",k,l2res[k]);
113  wEve.l2algo= ( L2wResult2009 *) &l2res[BEMCW_off];
114  // L2wResult2009_print(wEve.l2algo);
115  wEve.l2bitET=(wEve.l2algo->trigger&2)>0; // bit1=ET>thr
116  wEve.l2bitRnd=(wEve.l2algo->trigger&1)>0; // bit0=rnd,
117  StL0Trigger *trig=&(muEve->l0Trigger());
118  wEve.bx48=trig->bunchCrossingId();
119  wEve.bx7=trig->bunchCrossingId7bit(mRunNo);
120 
121  if( (wEve.l2bitRnd || wEve.l2bitET)==0) return -3; // L2W-algo did not accept this event
122  hA[0]->Fill("L2wBits",1.); // confirmation bits were set properly
123 
124 
125  if(wEve.l2bitRnd) {
126  hA[0]->Fill("L2wRnd",1.);
127  hA[61]->Fill(wEve.bx7);
128  for (int m=0;m<300;m++){
129  int val=muEve->emcTriggerDetector().highTower(m);
130  hA[7]->Fill(val);
131  }
132  }
133 
134  if(!wEve.l2bitET) return -3; // drop L2W-random accepts
135  if(wEve.l2bitET) hA[0]->Fill("L2wET",1.);
136 
137  //.... only monitor below ....
138  hA[2]->Fill(wEve.bx48);
139  hA[3]->Fill(wEve.bx7);
140 
141  // access L0-HT data
142  for (int m=0;m<300;m++) {
143  int val=muEve->emcTriggerDetector().highTower(m);
144  if(wEve.l2bitET) hA[6]->Fill(val);
145  if(val<par_DsmThres) continue;
146  if(wEve.l2bitET) hA[8]->Fill(m);
147  //printf("Fired L0 HT m=%d val=%d\n",m,val);
148  }
149  return 0;
150 }
151 
152 
153 //--------------------------------------
154 //--------------------------------------
155 int
156 St2009WMaker::accessVertex(){ // return non-zero on abort
157  int nInpPrimV=mMuDstMaker->muDst()->numberOfPrimaryVertices();
158  if(nInpPrimV <par_minPileupVert) return -1;
159  hA[0]->Fill("tpcOn",1.);
160 
161  int nVer=0;
162  for(int iv=0;iv<nInpPrimV;iv++) {
163  StMuPrimaryVertex* V= mMuDstMaker->muDst()->primaryVertex(iv);
164  assert(V);
165  mMuDstMaker->muDst()->setVertexIndex(iv);
166  float rank=V->ranking(), funnyR=999;
167  if(rank>1e6) funnyR=log(rank-1e6)+10;
168  else if(rank>0) funnyR=log(rank);
169  else funnyR=log(rank+1e6)-10;
170  hA[10]->Fill(funnyR);
171  if (rank<=0) continue;
172  const StThreeVectorF &r=V->position();
173  // StThreeVectorF &er=V->posError();
174  hA[11]->Fill(r.z());
175 
176  //add vertex weighting here to get quick turnaround
177  if(isMC>=350)
178  hA[190]->Fill(r.z(),hReweight->GetBinContent(hReweight->FindBin(r.z())));
179 
180  nVer++; // count valid vertices
181  if(fabs(r.z()) > par_vertexZ) continue;
182  WeveVertex wv;
183  wv.id=iv;
184  wv.z=r.z();
185  wv.funnyRank=funnyR;
186  wEve.vertex.push_back(wv);
187  }
188  if(nVer<=0) return -2;
189  hA[0]->Fill("primVert",1.);
190  hA[4]->Fill(wEve.bx48);
191  hA[5]->Fill(wEve.bx7);
192 
193  // access L0-HT data
194  StMuEvent* muEve = mMuDstMaker->muDst()->event();
195  for (int m=0;m<300;m++) {
196  int val=muEve->emcTriggerDetector().highTower(m);
197  if(val<par_DsmThres) continue;
198  if(wEve.l2bitET) hA[9]->Fill(m);
199  }
200 
201  hA[12]->Fill(wEve.vertex.size());
202  if(wEve.vertex.size()<=0) return -3;
203  hA[0]->Fill("vertZ",1.);
204  return 0;
205 }
206 
207 
208 
209 //--------------------------------------
210 //--------------------------------------
211 int
212 St2009WMaker::accessTracks(){ // return non-zero on abort
213  int nTrOK=0;
214  // printf("\n nInp=%d eveID=%d nPVer=%d nAnyV= %d\n",nInpEve,mMuDstMaker->muDst()->event()->eventId(),wEve.vertex.size(),mMuDstMaker->muDst()->numberOfPrimaryVertices());
215  for(unsigned int iv=0;iv<wEve.vertex.size(); iv++) {
216  unsigned int vertID=wEve.vertex[iv].id;
217  assert(vertID<mMuDstMaker->muDst()->numberOfPrimaryVertices());
218  assert(vertID>=0);
219  StMuPrimaryVertex* V= mMuDstMaker->muDst()->primaryVertex(vertID);
220  assert(V);
221  //int nTrUse= V->nTracksUsed();
222  mMuDstMaker->muDst()->setVertexIndex(vertID);
223  float rank=V->ranking();
224  assert(rank>0);
225  Int_t nPrimTrAll=mMuDstMaker->muDst()->GetNPrimaryTrack();
226  for(int itr=0;itr<nPrimTrAll;itr++) {
227  StMuTrack *prTr=mMuDstMaker->muDst()->primaryTracks(itr);
228  if(prTr->flag()<=0) continue;
229  const StMuTrack *glTr=prTr->globalTrack();
230  if(glTr==0) continue; // see the reason at the end of this method
231  if(prTr->flag()!=301) continue;// TPC+prim vertex tracks
232  hA[20]->Fill("101",1.);
233  float pt=prTr->pt();
234  if(pt<1.0) continue;
235  hA[20]->Fill("pt1",1.);
236 
237  // TPC sector dependent filter
238  StThreeVectorF ro=glTr->lastPoint();
239  int secID=WtpcFilter::getTpcSec(ro.phi(),ro.pseudoRapidity());
240  if ( mTpcFilter[secID-1].accept(prTr)==false) continue;
241 
242  if (secID==20) continue; //remove poorly calibrated sector
243 
244  //accepted ......
245 
246  hA[21]->Fill(prTr->nHitsFit());
247  float hitFrac=1.*prTr->nHitsFit()/prTr->nHitsPoss();
248  hA[22]->Fill(hitFrac);
249  hA[23]->Fill(glTr->firstPoint().perp());
250  hA[24]->Fill(ro.perp());
251 
252  hA[25]->Fill(glTr->p().perp());
253  if(glTr->charge()<0) hA[27]->Fill(glTr->p().perp());
254 
255  hA[29]->Fill(pt);
256  if(prTr->charge()<0)hA[30]->Fill(pt);
257 
258  hA[26]->Fill(ro.pseudoRapidity(),ro.phi());
259  if(pt>5) //estimate TPC inefficiency in data
260  hA[57]->Fill(ro.pseudoRapidity(),ro.phi());
261 
262  /* Victor: in reality mChiSqXY is a normal Xi2 for track and
263  mChiSqZ is Xi2 of fit to primary vertex
264  */
265  float globChi2dof=glTr->chi2();
266  hA[35]->Fill(globChi2dof);
267  {// monitor chi2 for east/west TPC separately
268  StThreeVectorF ri=glTr->firstPoint();
269  if(ri.z()>0 && ro.z()>0) hA[58]->Fill(globChi2dof);
270  if(ri.z()<0 && ro.z()<0) hA[59]->Fill(globChi2dof);
271  }
272 
273  hA[36]->Fill(globChi2dof,ro.pseudoRapidity());
274 
275  float dedx=prTr->dEdx()*1e6;
276  //printf("%f %f\n",glTr->p().mag(),dedx);
277  hA[28]->Fill(prTr->p().mag(),dedx);
278 
279  if(pt<par_trackPt) continue;
280  hA[20]->Fill("ptOK",1.);
281  nTrOK++;
282  WeveEleTrack wTr;
283 
284  wTr.prMuTrack=prTr;
285  wTr.glMuTrack=glTr;
286  StThreeVectorF prPvect=prTr->p();
287  wTr.primP=TVector3(prPvect.x(),prPvect.y(),prPvect.z());
288 
289  wEve.vertex[iv].eleTrack.push_back(wTr);
290  }// loop over tracks
291  }// loop over vertices
292  if(nTrOK<=0) return -1;
293  hA[0]->Fill("Pt10",1.);
294  return 0;
295 }
296 
297 /* from Pibero:
298  It looks like your global track is null. See this post:
299 
300  http://www.star.bnl.gov/HyperNews-star/get/mudst/53.html
301 
302  My reading of this hypernews says its just the way ITTF/MuDst
303  works. You can get a good primary track, but its global track
304  fails the chi2 fit. So the primary track is kept in the MuDst
305  but the global track is dropped. I would suggest you skip those
306  rare primary tracks that have no global tracks, that way you
307  still use most of the tracks in the MuDst. You don't need to
308  skip the entire event, just that track. I guess the down side
309  is you couldn't make a global DCA cut on those rare tracks, right?
310  I guess you could also request S&C to change ITTF/MuDst not to drop
311  the global track for every good primary track regardless of chi2.
312 */
313 
314 
315 
316 /* $STAR/StRoot/StEvent/StTrack.h
317  * mFlag=zxyy, where z = 1 for pile up track in TPC (otherwise 0)
318  * x indicates the detectors included in the fit and
319  * yy indicates the status of the fit.
320  * Positive mFlag values are good fits, negative values are bad fits.
321  *
322  * The first digit indicates which detectors were used in the refit:
323  *
324  * x=1 -> TPC only
325  * x=3 -> TPC + primary vertex
326  * x=5 -> SVT + TPC
327  * x=6 -> SVT + TPC + primary vertex
328  * x=7 -> FTPC only
329  * x=8 -> FTPC + primary
330  * x=9 -> TPC beam background tracks
331  *
332  * The last two digits indicate the status of the refit:
333  * = +x01 -> good track
334  *
335  * = -x01 -> Bad fit, outlier removal eliminated too many points
336  * = -x02 -> Bad fit, not enough points to fit
337  * = -x03 -> Bad fit, too many fit iterations
338  * = -x04 -> Bad Fit, too many outlier removal iterations
339  * = -x06 -> Bad fit, outlier could not be identified
340  * = -x10 -> Bad fit, not enough points to start
341  *
342  * = +x11 -> Short track pointing to EEMC
343 */
344 
345 
346 //________________________________________________
347 //________________________________________________
348 int
349 St2009WMaker::accessBTOW(){
350 
351  StMuEmcCollection* emc = mMuDstMaker->muDst()->muEmcCollection();
352  if (!emc) {
353  gMessMgr->Warning() <<"No EMC data for this event"<<endm; return -4;
354  }
355 
356  int ibp=kBTow; // my index for tower & preshower set to BTOW
357  int jBP=BTOW; // official BTOW detector ID
358  int n5=0,n0=0,n1=0,n2=0,n3=0,n4=0;
359  int maxID=0;
360  double maxADC=0,adcSum=0;
361  for (int softID=1; softID <=mxBtow ; softID++) {
362  float rawAdc= emc->getTowerADC(softID);
363  if(rawAdc==0) n0++;
364 
365  int statPed,statOfl,statGain;
366  mBarrelTables->getStatus(jBP, softID, statPed,"pedestal");
367  mBarrelTables->getStatus(jBP, softID, statOfl);
368  mBarrelTables->getStatus(jBP, softID, statGain,"calib");
369 
370  if(statPed!=1) {
371  wEve.bemc.statTile[ibp][softID-1]=1;
372  n1++; continue;}
373  if(statOfl!=1) {
374  wEve.bemc.statTile[ibp][softID-1]=2;
375  n2++; continue;}
376  if(statGain!=1) {
377  wEve.bemc.statTile[ibp][softID-1]=4;
378  n3++; continue;}
379 
380  wEve.bemc.statTile[ibp][softID-1]=0 ;
381 
382 
383  float ped,sigPed,gain;
384  int capID=0;// just one value for btow
385  mBarrelTables->getPedestal(jBP,softID,capID,ped,sigPed);
386  mBarrelTables->getCalib(jBP, softID, 1, gain);
387  if (use_gains_file == 1) {
388  gain = gains_BTOW[softID];
389  }
390  //printf("id=%d gain=%f\n",softID,gain);
391 
392  //method for shifting energy scale
393  gain=gain*par_btowScale;//(default is par_btowScale=1)
394 
395  float adc=rawAdc-ped;
396  if(adc>0) n4++;
397  if(adc<par_kSigPed*sigPed) continue;
398  if(adc<par_AdcThres) continue;
399  n5++;
400  wEve.bemc.adcTile[ibp][softID-1]=adc;
401  wEve.bemc.eneTile[ibp][softID-1]=adc*gain;
402 
403  if(maxADC<adc) { maxID=softID; maxADC=adc;}
404  adcSum+=adc;
405  }
406 
407  if(isMC>0 && isMC<20) assert(n1==0);//prevent using real peds for private MC
408  //printf("NNN %d %d %d %d %d %d id=%d\n",n0,n1,n2,n3,n4,n5,maxID);
409  if(n0==mxBtow) return -1 ; // BTOW was not present in this events
410 
411  wEve.bemc.tileIn[ibp]=1; //tag usable data
412 
413  if(nInpEve%5000==1) {
414  LOG_INFO << Form("unpackMuBTOW() dataIn=%d, nBbad: ped=%d stat=%d gain=%d ; nAdc: %d>0, %d>thres\n maxADC=%.0f softID=%d adcSum=%.0f",
415  wEve.bemc.tileIn[ibp],n1,n2,n3,n4,n5,
416  maxADC,maxID,adcSum
417  )<<endm;
418  }
419  hA[31]->Fill(maxADC);
420  hA[32]->Fill(adcSum);
421 
422  if(maxADC<par_maxADC) return -2 ; // not enough energy
423 
424  return 0;
425 }
426 
427 
428 //________________________________________________
429 //________________________________________________
430 int
431 St2009WMaker::accessETOW(){
432 
433  StMuEmcCollection* emc = mMuDstMaker->muDst()->muEmcCollection();
434  if (!emc) {
435  LOG_WARN <<"No EMC data for this event"<<endm; return -4;
436  }
437 
438  //loop over all towers
439  for (int i=0; i< emc->getNEndcapTowerADC(); i++) {
440  int sec,eta,sub,rawAdc; //muDst ranges:sec:1-12, sub:1-5, eta:1-12
441  emc->getEndcapTowerADC(i,rawAdc,sec,sub,eta);
442 
443  const EEmcDbItem *x=mDbE->getTile(sec,'A'+sub-1,eta,'T');
444  assert(x); // it should never happened for muDst
445  if(x->fail ) continue; // drop not working channels
446  int isec=x->sec-1;
447  int isub=x->sub-'A';
448  int ieta=x->eta-1;
449 
450  assert(isec>=0 && isec<mxEtowSec); // check input is ok
451  assert(isub>=0 && isub<mxEtowSub);
452  assert(ieta>=0 && ieta<mxEtowEta);
453 
454  float adc=rawAdc-x->ped; // ped subtracted ADC
455  if(adc<par_kSigPed*x->sigPed) continue;
456 
457  wEve.etow.adc[isec*mxEtowSub+isub][ieta]=adc;
458 
459  if(x->gain<=0) continue;// drop channels w/o gains
460  float ene=adc/x->gain;
461 
462  //method for shifting energy scale
463  ene*=par_etowScale;//(default is par_etowScale=1)
464  wEve.etow.ene[isec*mxEtowSub+isub][ieta]=ene;
465  wEve.etow.stat[isec*mxEtowSub+isub][ieta]=0;
466 
467  }
468 
469  return 0;
470 }
471 
472 //________________________________________________
473 //________________________________________________
474 float
475 St2009WMaker::sumTpcCone(int vertID, TVector3 refAxis, int flag, int &nTrCnt){
476 
477  // flag=2 use 2D cut, 1= only delta phi
478 
479  // printf("******* sumTpcCone, flag=%d eveId=%d vertID=%d eta0=%.2f phi0/rad=%.2f \n",flag,wEve.id,vertID,refAxis.PseudoRapidity() ,refAxis.Phi());
480 
481  int nTR=0;
482  assert(vertID>=0);
483  assert(vertID<(int)mMuDstMaker->muDst()->numberOfPrimaryVertices());
484 
485  StMuPrimaryVertex* V= mMuDstMaker->muDst()->primaryVertex(vertID);
486  assert(V);
487  mMuDstMaker->muDst()->setVertexIndex(vertID);
488  float rank=V->ranking();
489  assert(rank>0);
490  double ptSum=0;
491  Int_t nPrimTrAll=mMuDstMaker->muDst()->GetNPrimaryTrack();
492  for(int itr=0;itr<nPrimTrAll;itr++) {
493  StMuTrack *prTr=mMuDstMaker->muDst()->primaryTracks(itr);
494  if(prTr->flag()<=0) continue;
495  if(prTr->flag()!=301) continue;// TPC-only regular tracks
496  float hitFrac=1.*prTr->nHitsFit()/prTr->nHitsPoss();
497  if(hitFrac<par_nHitFrac) continue;
498  StThreeVectorF prPvect=prTr->p();
499  TVector3 primP=TVector3(prPvect.x(),prPvect.y(),prPvect.z());
500  // printf(" prTrID=%4d prTrEta=%.3f prTrPhi/deg=%.1f prPT=%.1f nFitPts=%d\n", prTr->id(),prTr->eta(),prTr->phi()/3.1416*180.,prTr->pt(),prTr->nHitsFit());
501  if(flag==1) {
502  float deltaPhi=refAxis.DeltaPhi(primP);
503  if(fabs(deltaPhi)> par_awayDeltaPhi) continue;
504  }
505  if(flag==2 || flag==3) {
506  float deltaR=refAxis.DeltaR(primP);
507  //printf("delR=%.3f\n",deltaR);
508  if(flag==2 && deltaR>par_nearDeltaR) continue;
509  if(flag==3 && deltaR>par_smallNearDeltaR) continue;
510  }
511  float pT=prTr->pt();
512  // printf(" passed pt=%.1f\n",pT);
513  if(pT>par_countTrPt) nTR++; //count tracks in "jet"
514  if(pT>par_trackPt) ptSum+=par_trackPt;
515  else ptSum+=pT;
516  }
517  //printf("TPCJet sum: nTR=%d, ptSum=%.1f\n", nTR,ptSum);
518  nTrCnt=nTR;
519  return ptSum;
520 }
521 
522 
523 
524 //________________________________________________
525 void
526 St2009WMaker::accessBSMD(){
527  const char cPlane[ mxBSmd]={'E','P'};
528  // Access to muDst .......................
529  StMuEmcCollection* emc = mMuDstMaker->muDst()->muEmcCollection();
530  if (!emc) {
531  gMessMgr->Warning() <<"No EMC data for this muDst event"<<endm; return;
532  }
533 
534  //....................... B S M D .........................
535  for(int iEP=bsmde; iEP<=bsmdp;iEP++) { // official BSMD plane IDs
536  int iep=iEP-3; assert(bsmde==3);// what a hack
537  int nh= emc->getNSmdHits(iEP);
538  //printf("muDst BSMD-%c nHit=%d\n",cPlane[iep],nh);
539  int n5=0,n1=0,n2=0,n3=0,n4=0;
540  for (int i=0; i < nh; i++) {
541  StMuEmcHit *hit=emc->getSmdHit(i,iEP);
542  float adc=hit->getAdc();
543  int softID=hit->getId();
544 
545  int statPed,statOfl,statGain;
546  mBarrelTables->getStatus(iEP, softID, statPed,"pedestal");
547  mBarrelTables->getStatus(iEP, softID, statOfl);
548  mBarrelTables->getStatus(iEP, softID, statGain,"calib");
549 
550  if(statPed!=1) {
551  wEve.bemc.statBsmd[iep][softID-1]=1;
552  n1++; continue;}
553  if(statOfl!=1) {
554  wEve.bemc.statBsmd[iep][softID-1]=2;
555  n2++; continue;}
556  if(statGain<1 || statGain>19) {
557  wEve.bemc.statBsmd[iep][softID-1]=4;
558  n3++; continue;}
559 
560  float pedRes,sigPed,gain;
561  int capID=0;// just one value for ped residua in pp500, 2009 run
562  mBarrelTables->getPedestal(iEP,softID,capID,pedRes,sigPed);
563  mBarrelTables->getCalib(iEP, softID, 1, gain);
564 
565  if(isMC) { // overwrite it based on genat DE & private calibration
566  float par_bsmdAbsGain=6e6;// tmp arbitrary absolute calib of bsmd, was 3e6
567  float de = hit->getEnergy();// Geant energy deposit (GeV)
568  adc=de*par_bsmdAbsGain;
569  } else { // correct for pedestal residua
570  adc-=pedRes;
571  if(adc>0) n4++;
572  if(adc<par_kSigPed*sigPed) continue;
573  adc*=gain; // use Willie's relative gains for run9 data
574  }
575 
576  n5++;
577  assert(softID>=1); assert(softID<=mxBStrips);
578  int id0=softID-1;
579  wEve.bemc.adcBsmd[ iep][id0]=adc;
580  hA[70+10*iep]->Fill(adc);
581 
582  //if(nInpEve<3 || i <20 )printf(" i=%d, smd%c id=%d, m=%d adc=%.3f pedRes=%.1f, sigP=%.1f stat: O=%d P=%d G=%d gain=%.2f\n",i,cPlane[iep],softID,1+id0/150,adc,pedRes,sigPed, statOfl,statPed,statGain, gain);
583  }// end of hit list
584  if(nTrigEve%5000==1) {
585  LOG_INFO << Form("unpackMuBSMD-%c() nBbad: ped=%d stat=%d gain=%d ; nAdc: %d>0, %d>thres", cPlane[iep],n1,n2,n3,n4,n5)<<endm;
586  }
587  }// end of E-, P-plane loop
588 
589 }
590 
591 
592 //________________________________________________
593 //________________________________________________
594 void
595 St2009WMaker::hadronicRecoil(){ //add up all vector pt outside of 'nearJet' region to get 'hadronic recoil' pt vector
596 
597  for(unsigned int iv=0;iv<wEve.vertex.size();iv++) {
598  WeveVertex &V=wEve.vertex[iv];
599  for(unsigned int it=0;it<V.eleTrack.size();it++) {
600  WeveEleTrack &T=V.eleTrack[it];
601  if(T.isMatch2Cl==false) continue;
602 
603  TVector3 recoil;
604 
605  //.... process BTOW hits
606  for(int i=0;i< mxBtow;i++) {
607  float ene=wEve.bemc.eneTile[kBTow][i];
608  if(ene<=0) continue;
609  TVector3 primP=positionBtow[i]-TVector3(0,0,V.z);
610  primP.SetMag(ene); // it is 3D momentum in the event ref frame
611  float deltaR=T.primP.DeltaR(primP);
612  if(deltaR< par_nearDeltaR) continue;
613  recoil+=primP;
614  }
615 
616  //....process ETOW hits
617  for(int iphi=0; iphi<mxEtowPhiBin; iphi++){
618  for(int ieta=0; ieta<mxEtowEta; ieta++){
619  float ene=wEve.etow.ene[iphi][ieta];
620  if(ene<=0) continue; //skip towers with no energy
621  TVector3 primP=positionEtow[iphi][ieta]-TVector3(0,0,V.z);
622  primP.SetMag(ene); // it is 3D momentum in the event ref frame
623  float deltaR=T.primP.DeltaR(primP);
624  if(deltaR< par_nearDeltaR) continue;
625  recoil+=primP;
626  }
627  }
628 
629  //....process TPC tracks
630  int vertID=V.id;
631  assert(vertID>=0);
632  assert(vertID<(int)mMuDstMaker->muDst()->numberOfPrimaryVertices());
633 
634  StMuPrimaryVertex* V= mMuDstMaker->muDst()->primaryVertex(vertID);
635  assert(V);
636  mMuDstMaker->muDst()->setVertexIndex(vertID);
637  float rank=V->ranking();
638  assert(rank>0);
639  Int_t nPrimTrAll=mMuDstMaker->muDst()->GetNPrimaryTrack();
640  for(int itr=0;itr<nPrimTrAll;itr++) {
641  StMuTrack *prTr=mMuDstMaker->muDst()->primaryTracks(itr);
642  if(prTr->flag()<=0) continue;
643  if(prTr->flag()!=301) continue;// TPC-only regular tracks
644  float hitFrac=1.*prTr->nHitsFit()/prTr->nHitsPoss();
645  if(hitFrac<par_nHitFrac) continue;
646  StThreeVectorF prPvect=prTr->p();
647  TVector3 primP=TVector3(prPvect.x(),prPvect.y(),prPvect.z());
648  float deltaR=T.primP.DeltaR(primP);
649  if(deltaR< par_nearDeltaR) continue;
650  if(primP.Perp()<0.15) continue; //lower threshold on pT < 150 MeV
651  recoil+=primP;
652  }
653 
654  T.hadronicRecoil=recoil;
655 
656  }
657  }
658 }
659 
660 //$Log: St2009W_accessMuDst.cxx,v $
661 //Revision 1.18 2011/09/14 14:23:20 stevens4
662 //update used for cross section PRD paper
663 //
664 //Revision 1.17 2010/12/02 18:31:43 rcorliss
665 //updated lumi code to match the starnote version
666 //
667 //Revision 1.16 2010/11/09 23:06:46 balewski
668 //small change
669 //
670 //Revision 1.14 2010/06/30 19:00:03 rcorliss
671 //passes_L0() now works for simulation, using trigger simu in new macro
672 //
673 //Revision 1.13 2010/05/21 19:57:59 stevens4
674 //remove L0 check for MC until passes_L0() is fixed
675 //
676 //Revision 1.12 2010/03/23 15:33:55 seelej
677 //Edit to files to allow the use of a text file for the gains instead of using the DB.
678 //
679 //Revision 1.11 2010/02/18 22:34:50 stevens4
680 //add tpc effic study and allow energy scaling for data and MC
681 //
682 //Revision 1.10 2010/01/29 01:56:01 stevens4
683 //disable lepton track reco in TPC sector 20
684 //
685 //Revision 1.9 2010/01/23 20:07:03 stevens4
686 //fix use of real btow peds for rcf mc
687 //
688 //Revision 1.8 2010/01/23 20:01:00 stevens4
689 //fix real peds for rcf mc
690 //
691 //Revision 1.7 2010/01/23 02:35:38 stevens4
692 //add ability to scale jet et and use real btow peds for rcf mc
693 //
694 //Revision 1.6 2010/01/18 03:26:15 balewski
695 //expanded TPC track filtering, not finished
696 //
697 //Revision 1.5 2010/01/13 03:34:20 stevens4
698 //give trig emulator access to barrel hits
699 //
700 //Revision 1.4 2010/01/06 19:16:47 stevens4
701 //track cuts now on primary component, cleanup
702 //
703 //Revision 1.3 2010/01/05 03:22:55 balewski
704 //change logic for filling btow status tables, added printout to Z-code
705 //
706 //Revision 1.2 2009/12/08 04:48:35 balewski
707 //*** empty log message ***
708 //
709 //Revision 1.1 2009/11/23 23:00:18 balewski
710 //code moved spin-pool
711 //
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
Definition: StMuDst.h:322
int getId() const
Return Module number.
Definition: StMuEmcHit.h:18
float getEnergy() const
Return Hit energy.
Definition: StMuEmcHit.h:21
StMuDst * muDst()
Definition: StMuDstMaker.h:425
Double_t pt() const
Returns pT at point of dca to primary vertex.
Definition: StMuTrack.h:256
Double_t chi2() const
Returns chi2 of fit.
Definition: StMuTrack.h:251
void getPedestal(Int_t det, Int_t softId, Int_t cap, Float_t &ped, Float_t &rms) const
Return pedestal mean and rms.
int getAdc() const
Return ADC value.
Definition: StMuEmcHit.h:19
UShort_t nHitsFit() const
Return total number of hits used in fit.
Definition: StMuTrack.h:239
short flag() const
Returns flag, (see StEvent manual for type information)
Definition: StMuTrack.h:230
Short_t charge() const
Returns charge.
Definition: StMuTrack.h:255
const StThreeVectorF & p() const
Returns 3-momentum at dca to primary vertex.
Definition: StMuTrack.h:259
const StThreeVectorF & firstPoint() const
Returns positions of first measured point.
Definition: StMuTrack.h:261
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
Definition: StMuDst.h:301
UShort_t nHitsPoss() const
Return number of possible hits on track.
Definition: StMuTrack.cxx:242
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
void getCalib(Int_t det, Int_t softId, Int_t power, Float_t &calib) const
Return calibration constant.
const StThreeVectorF & lastPoint() const
Returns positions of last measured point.
Definition: StMuTrack.h:262
Double_t dEdx() const
Returns measured dE/dx value.
Definition: StMuTrack.h:248
void getStatus(Int_t det, Int_t softId, Int_t &status, const char *option="") const
Return status.
const StMuTrack * globalTrack() const
Returns pointer to associated global track. Null pointer if no global track available.
Definition: StMuTrack.h:272
static void setVertexIndex(Int_t vtx_id)
Set the index number of the current primary vertex (used by both primaryTracks() functions and for St...
Definition: StMuDst.cxx:273
Collection of trigger ids as stored in MuDst.