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>
14 #include "StEmcRawMaker/defines.h"
15 #include "StEmcUtil/database/StBemcTables.h"
17 #include "StEEmcUtil/database/StEEmcDb.h"
18 #include "StEEmcUtil/database/EEmcDbItem.h"
20 #include "StEmcUtil/geometry/StEmcGeom.h"
21 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
23 #include "St2009WMaker.h"
27 St2009WMaker::accessTrig(){
36 if (!passes_L0())
return -1;
37 hA[0]->Fill(
"BHT3Id",1.);
38 if(!passes_L2())
return -2;
39 hA[0]->Fill(
"L2wId",1.);
44 wEve.bx48=trig->bunchCrossingId();
45 wEve.bx7=trig->bunchCrossingId7bit(par_inpRunNo);
57 for (
int m=0;m<300;m++)
59 int myT=muEve->emcTriggerDetector().highTower(m);
66 int highestPhi, tempPhi, tempEta;
69 for (
int i=0;i<16;i++) awaySum[i]=0;
71 patchToEtaPhi(highestM,&tempEta,&highestPhi);
73 for (
int m=0;m<300;m++)
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))
81 awaySum[away_width]+=myT;
85 for (
int i=0;i<16;i++) wEve.trigAwaySum[i]=awaySum[i];
86 wEve.trigTotalSum=totalSum;
92 vector<unsigned int> idL=l1.triggerIds();
95 for(
unsigned int i=0;i<idL.size(); i++){
97 sprintf(txt,
"%d",idL[i]);
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.);
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();
111 const int BEMCW_off=20;
115 wEve.l2bitET=(wEve.l2algo->trigger&2)>0;
116 wEve.l2bitRnd=(wEve.l2algo->trigger&1)>0;
118 wEve.bx48=trig->bunchCrossingId();
119 wEve.bx7=trig->bunchCrossingId7bit(mRunNo);
121 if( (wEve.l2bitRnd || wEve.l2bitET)==0)
return -3;
122 hA[0]->Fill(
"L2wBits",1.);
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);
134 if(!wEve.l2bitET)
return -3;
135 if(wEve.l2bitET) hA[0]->Fill(
"L2wET",1.);
138 hA[2]->Fill(wEve.bx48);
139 hA[3]->Fill(wEve.bx7);
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);
156 St2009WMaker::accessVertex(){
157 int nInpPrimV=mMuDstMaker->
muDst()->numberOfPrimaryVertices();
158 if(nInpPrimV <par_minPileupVert)
return -1;
159 hA[0]->Fill(
"tpcOn",1.);
162 for(
int iv=0;iv<nInpPrimV;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;
178 hA[190]->Fill(r.z(),hReweight->GetBinContent(hReweight->FindBin(r.z())));
181 if(fabs(r.z()) > par_vertexZ)
continue;
186 wEve.vertex.push_back(wv);
188 if(nVer<=0)
return -2;
189 hA[0]->Fill(
"primVert",1.);
190 hA[4]->Fill(wEve.bx48);
191 hA[5]->Fill(wEve.bx7);
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);
201 hA[12]->Fill(wEve.vertex.size());
202 if(wEve.vertex.size()<=0)
return -3;
203 hA[0]->Fill(
"vertZ",1.);
212 St2009WMaker::accessTracks(){
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());
223 float rank=V->ranking();
225 Int_t nPrimTrAll=mMuDstMaker->
muDst()->GetNPrimaryTrack();
226 for(
int itr=0;itr<nPrimTrAll;itr++) {
228 if(prTr->
flag()<=0)
continue;
230 if(glTr==0)
continue;
231 if(prTr->
flag()!=301)
continue;
232 hA[20]->Fill(
"101",1.);
235 hA[20]->Fill(
"pt1",1.);
239 int secID=WtpcFilter::getTpcSec(ro.phi(),ro.pseudoRapidity());
240 if ( mTpcFilter[secID-1].accept(prTr)==
false)
continue;
242 if (secID==20)
continue;
248 hA[22]->Fill(hitFrac);
250 hA[24]->Fill(ro.perp());
252 hA[25]->Fill(glTr->
p().perp());
253 if(glTr->
charge()<0) hA[27]->Fill(glTr->
p().perp());
256 if(prTr->
charge()<0)hA[30]->Fill(pt);
258 hA[26]->Fill(ro.pseudoRapidity(),ro.phi());
260 hA[57]->Fill(ro.pseudoRapidity(),ro.phi());
265 float globChi2dof=glTr->
chi2();
266 hA[35]->Fill(globChi2dof);
269 if(ri.z()>0 && ro.z()>0) hA[58]->Fill(globChi2dof);
270 if(ri.z()<0 && ro.z()<0) hA[59]->Fill(globChi2dof);
273 hA[36]->Fill(globChi2dof,ro.pseudoRapidity());
275 float dedx=prTr->
dEdx()*1e6;
277 hA[28]->Fill(prTr->
p().mag(),dedx);
279 if(pt<par_trackPt)
continue;
280 hA[20]->Fill(
"ptOK",1.);
287 wTr.primP=TVector3(prPvect.x(),prPvect.y(),prPvect.z());
289 wEve.vertex[iv].eleTrack.push_back(wTr);
292 if(nTrOK<=0)
return -1;
293 hA[0]->Fill(
"Pt10",1.);
349 St2009WMaker::accessBTOW(){
353 gMessMgr->Warning() <<
"No EMC data for this event"<<endm;
return -4;
358 int n5=0,n0=0,n1=0,n2=0,n3=0,n4=0;
360 double maxADC=0,adcSum=0;
361 for (
int softID=1; softID <=mxBtow ; softID++) {
362 float rawAdc= emc->getTowerADC(softID);
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");
371 wEve.bemc.statTile[ibp][softID-1]=1;
374 wEve.bemc.statTile[ibp][softID-1]=2;
377 wEve.bemc.statTile[ibp][softID-1]=4;
380 wEve.bemc.statTile[ibp][softID-1]=0 ;
383 float ped,sigPed,gain;
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];
393 gain=gain*par_btowScale;
395 float adc=rawAdc-ped;
397 if(adc<par_kSigPed*sigPed)
continue;
398 if(adc<par_AdcThres)
continue;
400 wEve.bemc.adcTile[ibp][softID-1]=adc;
401 wEve.bemc.eneTile[ibp][softID-1]=adc*gain;
403 if(maxADC<adc) { maxID=softID; maxADC=adc;}
407 if(isMC>0 && isMC<20) assert(n1==0);
409 if(n0==mxBtow)
return -1 ;
411 wEve.bemc.tileIn[ibp]=1;
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,
419 hA[31]->Fill(maxADC);
420 hA[32]->Fill(adcSum);
422 if(maxADC<par_maxADC)
return -2 ;
431 St2009WMaker::accessETOW(){
435 LOG_WARN <<
"No EMC data for this event"<<endm;
return -4;
439 for (
int i=0; i< emc->getNEndcapTowerADC(); i++) {
440 int sec,eta,sub,rawAdc;
441 emc->getEndcapTowerADC(i,rawAdc,sec,sub,eta);
443 const EEmcDbItem *x=mDbE->getTile(sec,
'A'+sub-1,eta,
'T');
445 if(x->fail )
continue;
450 assert(isec>=0 && isec<mxEtowSec);
451 assert(isub>=0 && isub<mxEtowSub);
452 assert(ieta>=0 && ieta<mxEtowEta);
454 float adc=rawAdc-x->ped;
455 if(adc<par_kSigPed*x->sigPed)
continue;
457 wEve.etow.adc[isec*mxEtowSub+isub][ieta]=adc;
459 if(x->gain<=0)
continue;
460 float ene=adc/x->gain;
464 wEve.etow.ene[isec*mxEtowSub+isub][ieta]=ene;
465 wEve.etow.stat[isec*mxEtowSub+isub][ieta]=0;
475 St2009WMaker::sumTpcCone(
int vertID, TVector3 refAxis,
int flag,
int &nTrCnt){
483 assert(vertID<(
int)mMuDstMaker->
muDst()->numberOfPrimaryVertices());
488 float rank=V->ranking();
491 Int_t nPrimTrAll=mMuDstMaker->
muDst()->GetNPrimaryTrack();
492 for(
int itr=0;itr<nPrimTrAll;itr++) {
494 if(prTr->
flag()<=0)
continue;
495 if(prTr->
flag()!=301)
continue;
497 if(hitFrac<par_nHitFrac)
continue;
499 TVector3 primP=TVector3(prPvect.x(),prPvect.y(),prPvect.z());
502 float deltaPhi=refAxis.DeltaPhi(primP);
503 if(fabs(deltaPhi)> par_awayDeltaPhi)
continue;
505 if(flag==2 || flag==3) {
506 float deltaR=refAxis.DeltaR(primP);
508 if(flag==2 && deltaR>par_nearDeltaR)
continue;
509 if(flag==3 && deltaR>par_smallNearDeltaR)
continue;
513 if(pT>par_countTrPt) nTR++;
514 if(pT>par_trackPt) ptSum+=par_trackPt;
526 St2009WMaker::accessBSMD(){
527 const char cPlane[ mxBSmd]={
'E',
'P'};
531 gMessMgr->Warning() <<
"No EMC data for this muDst event"<<endm;
return;
535 for(
int iEP=bsmde; iEP<=bsmdp;iEP++) {
536 int iep=iEP-3; assert(bsmde==3);
537 int nh= emc->getNSmdHits(iEP);
539 int n5=0,n1=0,n2=0,n3=0,n4=0;
540 for (
int i=0; i < nh; i++) {
543 int softID=hit->
getId();
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");
551 wEve.bemc.statBsmd[iep][softID-1]=1;
554 wEve.bemc.statBsmd[iep][softID-1]=2;
556 if(statGain<1 || statGain>19) {
557 wEve.bemc.statBsmd[iep][softID-1]=4;
560 float pedRes,sigPed,gain;
562 mBarrelTables->
getPedestal(iEP,softID,capID,pedRes,sigPed);
563 mBarrelTables->
getCalib(iEP, softID, 1, gain);
566 float par_bsmdAbsGain=6e6;
568 adc=de*par_bsmdAbsGain;
572 if(adc<par_kSigPed*sigPed)
continue;
577 assert(softID>=1); assert(softID<=mxBStrips);
579 wEve.bemc.adcBsmd[ iep][id0]=adc;
580 hA[70+10*iep]->Fill(adc);
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;
595 St2009WMaker::hadronicRecoil(){
597 for(
unsigned int iv=0;iv<wEve.vertex.size();iv++) {
599 for(
unsigned int it=0;it<V.eleTrack.size();it++) {
601 if(T.isMatch2Cl==
false)
continue;
606 for(
int i=0;i< mxBtow;i++) {
607 float ene=wEve.bemc.eneTile[kBTow][i];
609 TVector3 primP=positionBtow[i]-TVector3(0,0,V.z);
611 float deltaR=T.primP.DeltaR(primP);
612 if(deltaR< par_nearDeltaR)
continue;
617 for(
int iphi=0; iphi<mxEtowPhiBin; iphi++){
618 for(
int ieta=0; ieta<mxEtowEta; ieta++){
619 float ene=wEve.etow.ene[iphi][ieta];
621 TVector3 primP=positionEtow[iphi][ieta]-TVector3(0,0,V.z);
623 float deltaR=T.primP.DeltaR(primP);
624 if(deltaR< par_nearDeltaR)
continue;
632 assert(vertID<(
int)mMuDstMaker->
muDst()->numberOfPrimaryVertices());
637 float rank=V->ranking();
639 Int_t nPrimTrAll=mMuDstMaker->
muDst()->GetNPrimaryTrack();
640 for(
int itr=0;itr<nPrimTrAll;itr++) {
642 if(prTr->
flag()<=0)
continue;
643 if(prTr->
flag()!=301)
continue;
645 if(hitFrac<par_nHitFrac)
continue;
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;
654 T.hadronicRecoil=recoil;
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
int getId() const
Return Module number.
float getEnergy() const
Return Hit energy.
Double_t pt() const
Returns pT at point of dca to primary vertex.
Double_t chi2() const
Returns chi2 of fit.
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.
UShort_t nHitsFit() const
Return total number of hits used in fit.
short flag() const
Returns flag, (see StEvent manual for type information)
Short_t charge() const
Returns charge.
const StThreeVectorF & p() const
Returns 3-momentum at dca to primary vertex.
const StThreeVectorF & firstPoint() const
Returns positions of first measured point.
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
UShort_t nHitsPoss() const
Return number of possible hits on track.
static StMuEmcCollection * muEmcCollection()
returns pointer to current StMuEmcCollection
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
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.
Double_t dEdx() const
Returns measured dE/dx value.
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.
static void setVertexIndex(Int_t vtx_id)
Set the index number of the current primary vertex (used by both primaryTracks() functions and for St...
Collection of trigger ids as stored in MuDst.