StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
St2011W_acessMuDst.cxx
1 // $Id: St2011W_acessMuDst.cxx,v 1.17 2016/01/08 02:08:49 jlzhang 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 "StEmcUtil/geometry/StEmcGeom.h"
18 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
19 
20 #include "StSpinPool/StSpinDbMaker/StSpinDbMaker.h"
21 
22 #include "St2011WMaker.h"
23 //--------------------------------------
24 //--------------------------------------
25 int
26 St2011WMaker::accessBarrelTrig(){ // return non-zero on abort
27 
28  if (isMC){
29 
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  if(!passes_L2()) return -2;
38  hA[0]->Fill("L2bwET",1.);
39 
40  wEve->l2bitET=true;
41  return 0; // we haven't set everything, but it should be good enough for simu.
42  }
43 
44  StMuEvent* muEve = mMuDstMaker->muDst()->event();
45 
46  //collect info for the luminosity monitor
47  int highestT=0;
48  int highestM=0;
49  for (int m=0;m<300;m++)
50  {
51  int myT=muEve->emcTriggerDetector().highTower(m);
52  if (myT>highestT)
53  {
54  highestT=myT;
55  highestM=m;
56  }
57  }
58  int highestPhi, tempPhi, tempEta;
59  int awaySum[16];
60  int totalSum=0;
61  for (int i=0;i<16;i++) awaySum[i]=0;
62 
63  patchToEtaPhi(highestM,&tempEta,&highestPhi);
64 
65  for (int m=0;m<300;m++)
66  {
67  int myT=muEve->emcTriggerDetector().highTower(m);
68  patchToEtaPhi(m,&tempEta,&tempPhi);
69  for (int away_width=0;away_width<16;away_width++)
70  if ((highestPhi+30-tempPhi)%30>(15-away_width) && (highestPhi+30-tempPhi)%30<(15+away_width))
71  {
72  //printf("==> adding %d to awaySum",myT);
73  awaySum[away_width]+=myT;
74  }
75  totalSum+=myT;
76  }
77  for (int i=0;i<16;i++) wEve->trigAwaySum[i]=awaySum[i];
78  wEve->trigTotalSum=totalSum;
79 
80  StMuTriggerIdCollection *tic=&(muEve->triggerIdCollection());
81  assert(tic);
82  const StTriggerId &l1=tic->l1();
83  vector<unsigned int> idL=l1.triggerIds();
84 
85  //printf("nTrig=%d, trigID: ",idL.size());
86  for(unsigned int i=0;i<idL.size(); i++){
87  char txt[100];
88  sprintf(txt,"%d",idL[i]);
89  //printf("%d, ",idL[i]);
90  hA[1]->Fill(txt,1.);
91  }
92  //printf("\n isTrg=%d trgId=%d\n",tic->nominal().isTrigger(par_l2bwTrgID),par_l2bwTrgID);
93 
94  //get bX info
95  StL0Trigger *trig=&(muEve->l0Trigger());
96  wEve->bx48=trig->bunchCrossingId();
97  wEve->bx7=trig->bunchCrossingId7bit(mRunNo);
98 
99  // store spin info
100  int bxStar48=-2, bxStar7=-2, spin4=-2;
101  if(spinDb && spinDb->isValid() && // all 3 DB records exist
102  spinDb->isPolDirLong()) { // you do not want mix Long & Trans by accident
103  bxStar48= spinDb->BXstarUsingBX48(wEve->bx48);
104  bxStar7=spinDb->BXstarUsingBX7(wEve->bx7);
105  spin4=spinDb->spin4usingBX48(wEve->bx48);
106  }
107  wEve->bxStar48=bxStar48;
108  wEve->bxStar7=bxStar7;
109  wEve->spin4=spin4;
110 
111  //check trigger ID
112  if(!tic->nominal().isTrigger(par_l2bwTrgID)) return -2;
113  hA[0]->Fill("L2bwId",1.);
114 
115  TArrayI& l2Array = muEve->L2Result();
116  LOG_DEBUG <<Form("AccessL2Decision() from regular muDst: L2Ar-size=%d",l2Array.GetSize())<<endm;
117  unsigned int *l2res=(unsigned int *)l2Array.GetArray();
118  const int BEMCW_off=20; // valid only for 2009 & 2011 run
119  L2wResult2009 *l2algo= ( L2wResult2009 *) &l2res[BEMCW_off];
120 
121  wEve->l2bitET=(l2algo->trigger&2)>0; // bit1=ET>thr
122  wEve->l2bitRnd=(l2algo->trigger&1)>0; // bit0=rnd,
123 
124  if( (wEve->l2bitRnd || wEve->l2bitET)==0) return -3; // L2W-algo did not accept this event
125  hA[0]->Fill("L2bwBits",1.); // confirmation bits were set properly
126 
127  if(wEve->l2bitRnd) {
128  hA[0]->Fill("L2bwRnd",1.);
129  for (int m=0;m<300;m++){
130  int val=muEve->emcTriggerDetector().highTower(m);
131  hA[7]->Fill(val);
132  }
133  hA[61]->Fill(wEve->bx7);
134  }
135 
136  if(!wEve->l2bitET) return -3; // drop L2W-random accepts
137  if(wEve->l2bitET) hA[0]->Fill("L2bwET",1.);
138 
139  //.... only monitor below ....
140  hA[2]->Fill(wEve->bx48);
141  hA[3]->Fill(wEve->bx7);
142 
143  // access L0-HT data
144  int mxVal=-1;
145  for (int m=0;m<300;m++) {
146  int val=muEve->emcTriggerDetector().highTower(m);
147  if(mxVal<val) mxVal=val;
148  if(wEve->l2bitET) hA[6]->Fill(val);
149  if(val<par_DsmThres) continue;
150  if(wEve->l2bitET) hA[8]->Fill(m);
151  //printf("Fired L0 HT m=%d val=%d\n",m,val);
152  }
153  wEve->bemc.maxHtDsm=mxVal;
154  return 0;
155 }
156 
157 
158 //--------------------------------------
159 //--------------------------------------
160 int
161 St2011WMaker::accessVertex(){ // return non-zero on abort
162  int nInpPrimV=mMuDstMaker->muDst()->numberOfPrimaryVertices();
163 
164  if(nInpPrimV <par_minPileupVert) return -1;
165  //separate histos for barrel and endcap triggers
166  if(wEve->l2bitET) hA[0]->Fill("tpcOn",1.);
167  if(wEve->l2EbitET) hE[0]->Fill("tpcOn",1.);
168 
169  int nVer=0; int nVerR=0;
170  for(int iv=0;iv<nInpPrimV;iv++) {
171  StMuPrimaryVertex* V= mMuDstMaker->muDst()->primaryVertex(iv);
172  assert(V);
173  mMuDstMaker->muDst()->setVertexIndex(iv);
174  float rank=V->ranking(), funnyR=999;
175  if(rank>1e6) funnyR=log(rank-1e6)+10;
176  else if(rank>0) funnyR=log(rank);
177  else funnyR=log(rank+1e6)-10;
178  if(wEve->l2bitET) hA[10]->Fill(funnyR);
179  if(wEve->l2EbitET) hE[10]->Fill(funnyR);
180  if (rank<=0) continue;
181  const StThreeVectorF &r=V->position();
182  // StThreeVectorF &er=V->posError();
183  if(wEve->l2bitET) hA[11]->Fill(r.z());
184  if(wEve->l2EbitET) hE[11]->Fill(r.z());
185  nVer++; // count valid vertices
186  if(fabs(r.z()) > par_vertexZ) continue;
187  if(rank>0) nVerR++; //count vertices with rank>0
188  WeveVertex wv;
189  wv.id=iv;
190  wv.z=r.z();
191  wv.rank=rank;
192  wv.funnyRank=funnyR;
193  wv.nEEMCMatch=V->nEEMCMatch();
194  wEve->vertex.push_back(wv);
195  }
196  if(nVer<=0) return -2;
197  if(wEve->l2bitET) {
198  hA[0]->Fill("primVert",1.);
199  hA[4]->Fill(wEve->bx48);
200  hA[5]->Fill(wEve->bx7);
201  }
202  if(wEve->l2EbitET) {
203  hE[0]->Fill("primVert",1.);
204  hE[4]->Fill(wEve->bx48);
205  hE[5]->Fill(wEve->bx7);
206  }
207 
208  // access L0-HT data
209  StMuEvent* muEve = mMuDstMaker->muDst()->event();
210  for (int m=0;m<300;m++) {
211  int val=muEve->emcTriggerDetector().highTower(m);
212  if(val<par_DsmThres) continue;
213  if(wEve->l2bitET && nVerR>0) hA[9]->Fill(m);
214  }
215  for (int m=0;m<90;m++) {
216  int val=muEve->emcTriggerDetector().highTowerEndcap(m);
217  if(val<parE_DsmThres) continue;
218  if(wEve->l2EbitET) hE[9]->Fill(m);
219  }
220 
221  if(wEve->l2bitET) hA[12]->Fill(nVerR);
222  if(wEve->l2EbitET) hE[12]->Fill(nVer);
223 
224  if(wEve->vertex.size()<=0) return -3;
225  if(wEve->l2bitET && nVerR>0) hA[0]->Fill("vertZ",1.);
226  if(wEve->l2EbitET) hE[0]->Fill("vertZ",1.);
227  return 0;
228 }
229 
230 
231 
232 //--------------------------------------
233 //--------------------------------------
234 int
235 St2011WMaker::accessTracks(){ // return non-zero on abort
236  int nTrOK=0;
237  // printf("\n nInp=%d eveID=%d nPVer=%d nAnyV= %d\n",nInpEve,mMuDstMaker->muDst()->event()->eventId(),wEve->vertex.size(),mMuDstMaker->muDst()->numberOfPrimaryVertices());
238  for(unsigned int iv=0;iv<wEve->vertex.size(); iv++) {
239  unsigned int vertID=wEve->vertex[iv].id;
240  assert(vertID<mMuDstMaker->muDst()->numberOfPrimaryVertices());
241  assert(vertID>=0);
242  StMuPrimaryVertex* V= mMuDstMaker->muDst()->primaryVertex(vertID);
243  assert(V);
244  mMuDstMaker->muDst()->setVertexIndex(vertID);
245  float rank=V->ranking();
246  assert(rank>0);
247  Int_t nPrimTrAll=mMuDstMaker->muDst()->GetNPrimaryTrack();
248  for(int itr=0;itr<nPrimTrAll;itr++) {
249  StMuTrack *prTr=mMuDstMaker->muDst()->primaryTracks(itr);
250  if(prTr->flag()<=0) continue;
251  const StMuTrack *glTr=prTr->globalTrack();
252  if(glTr==0) continue; // see the reason at the end of this method
253  //keep list of all tracks for TPC cone sum in tree ana
254  wEve->vertex[iv].prTrList.push_back(prTr);
255  StThreeVectorF ro=glTr->lastPoint();
256 
257  // TPC+prim vertex tracks and short EEMC tracks
258  if(prTr->flag()!=301 && prTr->flag()!=311) continue;
259  if(wEve->l2bitET && prTr->flag()==301)
260  hA[20]->Fill("flag",1.);
261  if(wEve->l2EbitET && ro.pseudoRapidity()>parE_trackEtaMin)
262  hE[20]->Fill("flag",1.);
263 
264  float pt=prTr->pt();
265  if(pt<1.0) continue;
266  if(wEve->l2bitET && prTr->flag()==301)
267  hA[20]->Fill("pt1",1.);
268  if(wEve->l2EbitET && ro.pseudoRapidity()>parE_trackEtaMin)
269  hE[20]->Fill("pt1",1.);
270 
271  //accepted tracks......
272  float hitFrac=1.*prTr->nHitsFit()/prTr->nHitsPoss();
273  StThreeVectorF ri=glTr->firstPoint();
274  /* Victor: in reality mChiSqXY is a normal Xi2 for track and mChiSqZ is Xi2 of fit to primary vertex */
275  float globChi2dof=glTr->chi2();
276  float dedx=prTr->dEdx()*1e6;
277 
278  //barrel algo track monitors
279  if(wEve->l2bitET && prTr->flag()==301){
280  hA[21]->Fill(prTr->nHitsFit());
281  hA[22]->Fill(hitFrac);
282  hA[23]->Fill(ri.perp());
283  hA[24]->Fill(ro.perp());
284 
285  //TPC sector dependent filter
286  int secID=WtpcFilter::getTpcSec(ro.phi(),ro.pseudoRapidity());
287  if (mTpcFilter[secID-1].accept(prTr)==false) continue;
288  if (secID==20) continue; //poorly calibrated sector for Run 9+11+12
289 
290  hA[25]->Fill(glTr->p().perp());
291  if(glTr->charge()<0) hA[27]->Fill(glTr->p().perp());
292  hA[29]->Fill(pt);
293  if(prTr->charge()<0)hA[30]->Fill(pt);
294  hA[26]->Fill(ro.pseudoRapidity(),ro.phi());
295  if(pt>5) //estimate TPC inefficiency in data
296  hA[57]->Fill(ro.pseudoRapidity(),ro.phi());
297  hA[35]->Fill(globChi2dof);
298  // monitor chi2 for east/west TPC separately
299  if(ri.z()>0 && ro.z()>0) hA[58]->Fill(globChi2dof);
300  if(ri.z()<0 && ro.z()<0) hA[59]->Fill(globChi2dof);
301  hA[36]->Fill(globChi2dof,ro.pseudoRapidity());
302  hA[28]->Fill(prTr->p().mag(),dedx);
303 
304  if(pt>10)
305  hA[197]->Fill(ro.pseudoRapidity(),ro.phi());
306  hA[198]->Fill(ro.pseudoRapidity(),prTr->pt());
307  }
308 
309  //endcap algo track monitors
310  if(wEve->l2EbitET && ro.pseudoRapidity()>parE_trackEtaMin){
311  hE[20]->Fill("#eta>0.7",1.);
312  hE[21]->Fill(prTr->nHitsFit());
313  hE[22]->Fill(hitFrac);
314  hE[23]->Fill(ri.perp());
315  hE[24]->Fill(ro.perp());
316 
317  // TPC sector dependent filter
318  int secID=WtpcFilter::getTpcSec(ro.phi(),ro.pseudoRapidity());
319  if ( mTpcFilterE[secID-1].accept(prTr)==false) continue;
320 
321  hE[25]->Fill(glTr->p().perp());
322  if(glTr->charge()<0)hE[27]->Fill(glTr->p().perp());
323  hE[29]->Fill(pt);
324  if(prTr->charge()<0)hE[30]->Fill(pt);
325 
326  hE[26]->Fill(ro.pseudoRapidity(),ro.phi());
327  if(pt>5) //estimate TPC inefficiency in data
328  hE[57]->Fill(ro.pseudoRapidity(),ro.phi());
329  hE[35]->Fill(globChi2dof);
330  hE[36]->Fill(globChi2dof,ro.pseudoRapidity());
331  hE[28]->Fill(prTr->p().mag(),dedx);
332  }
333 
334 
335  bool barrelTrack=(wEve->l2bitET && prTr->flag()==301 && pt>par_trackPt);
336  if(barrelTrack) hA[20]->Fill("ptOK",1.);//good barrel candidate
337  bool endcapTrack=(wEve->l2EbitET && ro.pseudoRapidity()>parE_trackEtaMin && pt>parE_trackPt);
338  if(endcapTrack) hE[20]->Fill("ptOK",1.);//good endcap candidate
339 
340  if(!barrelTrack && !endcapTrack) continue;
341 
342  //keep all tracks in one container
343  nTrOK++;
344  WeveEleTrack wTr;
345 
346  wTr.prMuTrack=prTr;
347  wTr.glMuTrack=glTr;
348  StThreeVectorF prPvect=prTr->p();
349  wTr.primP=TVector3(prPvect.x(),prPvect.y(),prPvect.z());
350 
351  wEve->vertex[iv].eleTrack.push_back(wTr);
352  }// loop over tracks
353  }// loop over vertices
354  if(nTrOK<=0) return -1;
355  if(wEve->l2bitET) hA[0]->Fill("Pt10",1.);
356  if(wEve->l2EbitET) hE[0]->Fill("Pt10",1.);
357  return 0;
358 }
359 
360 /* from Pibero:
361  It looks like your global track is null. See this post:
362 
363 http://www.star.bnl.gov/HyperNews-star/get/mudst/53.html
364 
365 My reading of this hypernews says its just the way ITTF/MuDst
366 works. You can get a good primary track, but its global track
367 fails the chi2 fit. So the primary track is kept in the MuDst
368 but the global track is dropped. I would suggest you skip those
369 rare primary tracks that have no global tracks, that way you
370 still use most of the tracks in the MuDst. You don't need to
371 skip the entire event, just that track. I guess the down side
372 is you couldn't make a global DCA cut on those rare tracks, right?
373 I guess you could also request S&C to change ITTF/MuDst not to drop
374 the global track for every good primary track regardless of chi2.
375 */
376 
377 
378 
379 /* $STAR/StRoot/StEvent/StTrack.h
380  * mFlag=zxyy, where z = 1 for pile up track in TPC (otherwise 0)
381  * x indicates the detectors included in the fit and
382  * yy indicates the status of the fit.
383  * Positive mFlag values are good fits, negative values are bad fits.
384  *
385  * The first digit indicates which detectors were used in the refit:
386  *
387  * x=1 -> TPC only
388  * x=3 -> TPC + primary vertex
389  * x=5 -> SVT + TPC
390  * x=6 -> SVT + TPC + primary vertex
391  * x=7 -> FTPC only
392  * x=8 -> FTPC + primary
393  * x=9 -> TPC beam background tracks
394  *
395  * The last two digits indicate the status of the refit:
396  * = +x01 -> good track
397  *
398  * = -x01 -> Bad fit, outlier removal eliminated too many points
399  * = -x02 -> Bad fit, not enough points to fit
400  * = -x03 -> Bad fit, too many fit iterations
401  * = -x04 -> Bad Fit, too many outlier removal iterations
402  * = -x06 -> Bad fit, outlier could not be identified
403  * = -x10 -> Bad fit, not enough points to start
404  *
405  * = +x11 -> Short track pointing to EEMC
406  */
407 
408 
409 //________________________________________________
410 //________________________________________________
411 int
412 St2011WMaker::accessBTOW(){
413 
414  StMuEmcCollection* emc = mMuDstMaker->muDst()->muEmcCollection();
415  if (!emc) {
416  gMessMgr->Warning() <<"No EMC data for this event"<<endm; return -4;
417  }
418 
419  int ibp=kBTow; // my index for tower & preshower set to BTOW
420  int jBP=BTOW; // official BTOW detector ID
421  int n5=0,n0=0,n1=0,n2=0,n3=0,n4=0;
422  int maxID=0;
423  double maxADC=0,adcSum=0;
424  for (int softID=1; softID <=mxBtow ; softID++) {
425  float rawAdc= emc->getTowerADC(softID);
426  if(rawAdc==0) n0++;
427 
428  int statPed,statOfl,statGain;
429  mBarrelTables->getStatus(jBP, softID, statPed,"pedestal");
430  mBarrelTables->getStatus(jBP, softID, statOfl);
431  mBarrelTables->getStatus(jBP, softID, statGain,"calib");
432 
433  if(statPed!=1) {
434  wEve->bemc.statTile[ibp][softID-1]=1;
435  n1++; continue;
436  }
437  if(statOfl!=1) {
438  wEve->bemc.statTile[ibp][softID-1]=2;
439  n2++; continue;
440  }
441  if(statGain!=1) {
442  wEve->bemc.statTile[ibp][softID-1]=4;
443  n3++; continue;
444  }
445 
446  wEve->bemc.statTile[ibp][softID-1]=0 ;
447 
448 
449  float ped,sigPed,gain;
450  int capID=0;// just one value for btow
451  mBarrelTables->getPedestal(jBP,softID,capID,ped,sigPed);
452  mBarrelTables->getCalib(jBP, softID, 1, gain);
453  //printf("id=%d gain=%f\n",softID,gain);
454 
455  //method for shifting energy scale
456  gain=gain*par_btowScale;//(default is par_btowScale=1)
457 
458  float adc=rawAdc-ped;
459  if(adc>0) n4++;
460  if(adc<par_kSigPed*sigPed) continue;
461  if(adc<par_AdcThres) continue;
462  n5++;
463  wEve->bemc.adcTile[ibp][softID-1]=adc;
464  wEve->bemc.eneTile[ibp][softID-1]=adc*gain;
465 
466  if(adc>200){ hA[390]->SetBinContent(softID,adc+hA[390]->GetBinContent(softID));
467  hA[391]->SetBinContent(softID/40+1,softID%40+1,adc+hA[391]->GetBinContent(softID/40+1,softID%40+1));
468  }
469 
470  if(maxADC<adc) { maxID=softID; maxADC=adc;}
471  adcSum+=adc;
472  }
473 
474  //printf("NNN %d %d %d %d %d %d id=%d\n",n0,n1,n2,n3,n4,n5,maxID);
475  if(n0==mxBtow) return -1 ; // BTOW was not present in this events
476 
477  wEve->bemc.tileIn[ibp]=1; //tag usable data
478 
479  if(nInpEve%5000==1) {
480  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",
481  wEve->bemc.tileIn[ibp],n1,n2,n3,n4,n5,
482  maxADC,maxID,adcSum
483  )<<endm;
484  }
485  hA[31]->Fill(maxADC);
486  hA[32]->Fill(adcSum);
487  wEve->bemc.maxAdc=maxADC;
488 
489  if(maxID<=2400) hA[195]->Fill(maxADC);
490  else hA[196]->Fill(maxADC);
491 
492  if(maxADC<par_maxADC) return -2 ; // not enough energy
493 
494  return 0;
495 }
496 
497 //________________________________________________
498 //________________________________________________
499 float
500 St2011WMaker::sumTpcCone(int vertID, TVector3 refAxis, int flag, int pointTowId){
501 
502  // flag=2 use 2D cut, 1= only delta phi
503 
504  // printf("******* sumTpcCone, flag=%d eveId=%d vertID=%d eta0=%.2f phi0/rad=%.2f \n",flag,wEve->id,vertID,refAxis.PseudoRapidity() ,refAxis.Phi());
505 
506  assert(vertID>=0);
507  assert(vertID<(int)mMuDstMaker->muDst()->numberOfPrimaryVertices());
508 
509  StMuPrimaryVertex* V= mMuDstMaker->muDst()->primaryVertex(vertID);
510  assert(V);
511  mMuDstMaker->muDst()->setVertexIndex(vertID);
512  float rank=V->ranking();
513  assert(rank>0);
514  double ptSum=0;
515  Int_t nPrimTrAll=mMuDstMaker->muDst()->GetNPrimaryTrack();
516  for(int itr=0;itr<nPrimTrAll;itr++) {
517  StMuTrack *prTr=mMuDstMaker->muDst()->primaryTracks(itr);
518  if(prTr->flag()<=0) continue;
519  if(prTr->flag()!=301 && pointTowId>0) continue;// TPC-only regular tracks for barrel candidate
520  if(prTr->flag()!=301 && pointTowId<0) continue;// TPC-only regular tracks for endcap candidate
521  float hitFrac=1.*prTr->nHitsFit()/prTr->nHitsPoss();
522  if(hitFrac<par_nHitFrac) continue;
523  StThreeVectorF prPvect=prTr->p();
524  TVector3 primP=TVector3(prPvect.x(),prPvect.y(),prPvect.z());
525  // 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());
526  if(flag==1) {
527  float deltaPhi=refAxis.DeltaPhi(primP);
528  if(fabs(deltaPhi)> par_awayDeltaPhi) continue;
529  }
530  if(flag==2) {
531  float deltaR=refAxis.DeltaR(primP);
532  if(deltaR>par_nearDeltaR) continue;
533  }
534  float pT=prTr->pt();
535  // printf(" passed pt=%.1f\n",pT);
536 
537  //separate quench for barrel and endcap candidates
538  if(pT>par_trackPt && pointTowId>0) ptSum+=par_trackPt;
539  else if(pT>parE_trackPt && pointTowId<0) ptSum+=parE_trackPt;
540  else ptSum+=pT;
541  }
542  return ptSum;
543 }
544 
545 
546 
547 //________________________________________________
548 void
549 St2011WMaker::accessBSMD(){
550  //const char cPlane[ mxBSmd]={'E','P'};
551  // Access to muDst .......................
552  StMuEmcCollection* emc = mMuDstMaker->muDst()->muEmcCollection();
553  if (!emc) {
554  gMessMgr->Warning() <<"No EMC data for this muDst event"<<endm; return;
555  }
556 
557  //....................... B S M D .........................
558  for(int iEP=bsmde; iEP<=bsmdp;iEP++) { // official BSMD plane IDs
559  int iep=iEP-3; assert(bsmde==3);// what a hack
560  int nh= emc->getNSmdHits(iEP);
561  //printf("muDst BSMD-%c nHit=%d\n",cPlane[iep],nh);
562  int n5=0,n1=0,n2=0,n3=0,n4=0;
563  for (int i=0; i < nh; i++) {
564  StMuEmcHit *hit=emc->getSmdHit(i,iEP);
565  float adc=hit->getAdc();
566  int softID=hit->getId();
567 
568  int statPed,statOfl,statGain;
569  mBarrelTables->getStatus(iEP, softID, statPed,"pedestal");
570  mBarrelTables->getStatus(iEP, softID, statOfl);
571  mBarrelTables->getStatus(iEP, softID, statGain,"calib");
572 
573  if(statPed!=1) {
574  wEve->bemc.statBsmd[iep][softID-1]=1;
575  n1++; continue;
576  }
577  if(statOfl!=1) {
578  wEve->bemc.statBsmd[iep][softID-1]=2;
579  n2++; continue;
580  }
581  if(statGain<1 || statGain>19) {
582  wEve->bemc.statBsmd[iep][softID-1]=4;
583  n3++; continue;
584  }
585 
586  float pedRes,sigPed,gain;
587  int capID=0;// just one value for ped residua in pp500, 2009 run
588  mBarrelTables->getPedestal(iEP,softID,capID,pedRes,sigPed);
589  mBarrelTables->getCalib(iEP, softID, 1, gain);
590 
591  if(isMC) { // overwrite it based on genat DE & private calibration
592  float par_bsmdAbsGain=6e6;// tmp arbitrary absolute calib of bsmd, was 3e6
593  float de = hit->getEnergy();// Geant energy deposit (GeV)
594  adc=de*par_bsmdAbsGain;
595  } else { // correct for pedestal residua
596  adc-=pedRes;
597  if(adc>0) n4++;
598  if(adc<par_kSigPed*sigPed) continue;
599  }
600 
601  n5++;
602  assert(softID>=1); assert(softID<=mxBStrips);
603  int id0=softID-1;
604  wEve->bemc.adcBsmd[ iep][id0]=adc;
605  hA[70+10*iep]->Fill(adc);
606 
607  //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);
608  }// end of hit list
609  }// end of E-, P-plane loop
610 
611 }
612 
613 
614 
615 //$Log: St2011W_acessMuDst.cxx,v $
616 //Revision 1.17 2016/01/08 02:08:49 jlzhang
617 //added couples histograms and fixed a small bug
618 //
619 //Revision 1.16 2013/09/13 19:33:13 stevens4
620 //Updates to code for combined 2011+2012 result presented to spin PWG 9.12.13
621 //
622 //Revision 1.15 2012/09/18 21:10:06 stevens4
623 //Include all rank>0 vertex again (new jet format coming next), and remove rank<0 endcap vertices.
624 //
625 //Revision 1.14 2012/09/17 03:29:30 stevens4
626 //Updates to Endcap algo and Q*ET/PT charge separation
627 //
628 //Revision 1.13 2012/08/21 18:29:16 stevens4
629 //Updates to endcap W selection using ESMD strip ratio
630 //
631 //Revision 1.12 2012/08/21 17:40:09 stevens4
632 //Revert to previous version
633 //
634 //Revision 1.10 2012/07/24 14:59:24 stevens4
635 //enable running without spinDb
636 //
637 //Revision 1.9 2012/07/13 20:53:16 stevens4
638 //Add filling of empty events in W tree
639 //Minor modifications to histograms
640 //
641 //Revision 1.8 2012/07/12 20:49:21 balewski
642 //added spin info(star: bx48, bx7, spin4) and maxHtDSM & BTOW to Wtree
643 //removed dependence of spinSortingMaker from muDst
644 //Now Wtree can be spin-sorted w/o DB
645 //rdMu.C & readWtree.C macros modified
646 //tested so far on real data run 11
647 //lot of misc. code shuffling
648 //
649 //Revision 1.7 2012/06/18 18:28:01 stevens4
650 //Updates for Run 9+11+12 AL analysis
651 //
652 //Revision 1.6 2011/02/25 06:03:45 stevens4
653 //addes some histos and enabled running on MC
654 //
655 //Revision 1.5 2011/02/17 04:16:20 stevens4
656 //move sector dependent track QA cuts before track pt>10 cut and lower par_clustET and par_ptBalance thresholds to 14 GeV
657 //
658 //Revision 1.4 2011/02/16 15:25:16 stevens4
659 //remove relative gain correction for BSMD adc
660 //
661 //Revision 1.3 2011/02/15 17:39:12 stevens4
662 //remove accept-all for L2btowW bits
663 //
664 //Revision 1.2 2011/02/14 01:36:17 stevens4
665 //*** empty log message ***
666 //
667 //Revision 1.1 2011/02/10 20:33:22 balewski
668 //start
669 //
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
Definition: StMuDst.h:322
int getId() const
Return Module number.
Definition: StMuEmcHit.h:18
bool isValid()
dump spinDb content for current time stamp
Definition: StSpinDbMaker.h:53
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
int spin4usingBX48(int bx48)
8bit spin information
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.
int BXstarUsingBX7(int bx7)
bXing at STAR IP, [0,119]
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.
bool isPolDirLong()
Returns true if beams are transversely polarized, false otherwise.
Definition: StSpinDbMaker.h:55