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 "StEmcUtil/geometry/StEmcGeom.h"
18 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
20 #include "StSpinPool/StSpinDbMaker/StSpinDbMaker.h"
22 #include "St2011WMaker.h"
26 St2011WMaker::accessBarrelTrig(){
37 if(!passes_L2())
return -2;
38 hA[0]->Fill(
"L2bwET",1.);
49 for (
int m=0;m<300;m++)
51 int myT=muEve->emcTriggerDetector().highTower(m);
58 int highestPhi, tempPhi, tempEta;
61 for (
int i=0;i<16;i++) awaySum[i]=0;
63 patchToEtaPhi(highestM,&tempEta,&highestPhi);
65 for (
int m=0;m<300;m++)
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))
73 awaySum[away_width]+=myT;
77 for (
int i=0;i<16;i++) wEve->trigAwaySum[i]=awaySum[i];
78 wEve->trigTotalSum=totalSum;
83 vector<unsigned int> idL=l1.triggerIds();
86 for(
unsigned int i=0;i<idL.size(); i++){
88 sprintf(txt,
"%d",idL[i]);
96 wEve->bx48=trig->bunchCrossingId();
97 wEve->bx7=trig->bunchCrossingId7bit(mRunNo);
100 int bxStar48=-2, bxStar7=-2, spin4=-2;
101 if(spinDb && spinDb->
isValid() &&
103 bxStar48= spinDb->BXstarUsingBX48(wEve->bx48);
107 wEve->bxStar48=bxStar48;
108 wEve->bxStar7=bxStar7;
112 if(!tic->nominal().isTrigger(par_l2bwTrgID))
return -2;
113 hA[0]->Fill(
"L2bwId",1.);
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;
121 wEve->l2bitET=(l2algo->trigger&2)>0;
122 wEve->l2bitRnd=(l2algo->trigger&1)>0;
124 if( (wEve->l2bitRnd || wEve->l2bitET)==0)
return -3;
125 hA[0]->Fill(
"L2bwBits",1.);
128 hA[0]->Fill(
"L2bwRnd",1.);
129 for (
int m=0;m<300;m++){
130 int val=muEve->emcTriggerDetector().highTower(m);
133 hA[61]->Fill(wEve->bx7);
136 if(!wEve->l2bitET)
return -3;
137 if(wEve->l2bitET) hA[0]->Fill(
"L2bwET",1.);
140 hA[2]->Fill(wEve->bx48);
141 hA[3]->Fill(wEve->bx7);
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);
153 wEve->bemc.maxHtDsm=mxVal;
161 St2011WMaker::accessVertex(){
162 int nInpPrimV=mMuDstMaker->
muDst()->numberOfPrimaryVertices();
164 if(nInpPrimV <par_minPileupVert)
return -1;
166 if(wEve->l2bitET) hA[0]->Fill(
"tpcOn",1.);
167 if(wEve->l2EbitET) hE[0]->Fill(
"tpcOn",1.);
169 int nVer=0;
int nVerR=0;
170 for(
int iv=0;iv<nInpPrimV;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;
183 if(wEve->l2bitET) hA[11]->Fill(r.z());
184 if(wEve->l2EbitET) hE[11]->Fill(r.z());
186 if(fabs(r.z()) > par_vertexZ)
continue;
193 wv.nEEMCMatch=V->nEEMCMatch();
194 wEve->vertex.push_back(wv);
196 if(nVer<=0)
return -2;
198 hA[0]->Fill(
"primVert",1.);
199 hA[4]->Fill(wEve->bx48);
200 hA[5]->Fill(wEve->bx7);
203 hE[0]->Fill(
"primVert",1.);
204 hE[4]->Fill(wEve->bx48);
205 hE[5]->Fill(wEve->bx7);
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);
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);
221 if(wEve->l2bitET) hA[12]->Fill(nVerR);
222 if(wEve->l2EbitET) hE[12]->Fill(nVer);
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.);
235 St2011WMaker::accessTracks(){
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());
245 float rank=V->ranking();
247 Int_t nPrimTrAll=mMuDstMaker->
muDst()->GetNPrimaryTrack();
248 for(
int itr=0;itr<nPrimTrAll;itr++) {
250 if(prTr->
flag()<=0)
continue;
252 if(glTr==0)
continue;
254 wEve->vertex[iv].prTrList.push_back(prTr);
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.);
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.);
275 float globChi2dof=glTr->
chi2();
276 float dedx=prTr->
dEdx()*1e6;
279 if(wEve->l2bitET && prTr->
flag()==301){
281 hA[22]->Fill(hitFrac);
282 hA[23]->Fill(ri.perp());
283 hA[24]->Fill(ro.perp());
286 int secID=WtpcFilter::getTpcSec(ro.phi(),ro.pseudoRapidity());
287 if (mTpcFilter[secID-1].accept(prTr)==
false)
continue;
288 if (secID==20)
continue;
290 hA[25]->Fill(glTr->
p().perp());
291 if(glTr->
charge()<0) hA[27]->Fill(glTr->
p().perp());
293 if(prTr->
charge()<0)hA[30]->Fill(pt);
294 hA[26]->Fill(ro.pseudoRapidity(),ro.phi());
296 hA[57]->Fill(ro.pseudoRapidity(),ro.phi());
297 hA[35]->Fill(globChi2dof);
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);
305 hA[197]->Fill(ro.pseudoRapidity(),ro.phi());
306 hA[198]->Fill(ro.pseudoRapidity(),prTr->
pt());
310 if(wEve->l2EbitET && ro.pseudoRapidity()>parE_trackEtaMin){
311 hE[20]->Fill(
"#eta>0.7",1.);
313 hE[22]->Fill(hitFrac);
314 hE[23]->Fill(ri.perp());
315 hE[24]->Fill(ro.perp());
318 int secID=WtpcFilter::getTpcSec(ro.phi(),ro.pseudoRapidity());
319 if ( mTpcFilterE[secID-1].accept(prTr)==
false)
continue;
321 hE[25]->Fill(glTr->
p().perp());
322 if(glTr->
charge()<0)hE[27]->Fill(glTr->
p().perp());
324 if(prTr->
charge()<0)hE[30]->Fill(pt);
326 hE[26]->Fill(ro.pseudoRapidity(),ro.phi());
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);
335 bool barrelTrack=(wEve->l2bitET && prTr->
flag()==301 && pt>par_trackPt);
336 if(barrelTrack) hA[20]->Fill(
"ptOK",1.);
337 bool endcapTrack=(wEve->l2EbitET && ro.pseudoRapidity()>parE_trackEtaMin && pt>parE_trackPt);
338 if(endcapTrack) hE[20]->Fill(
"ptOK",1.);
340 if(!barrelTrack && !endcapTrack)
continue;
349 wTr.primP=TVector3(prPvect.x(),prPvect.y(),prPvect.z());
351 wEve->vertex[iv].eleTrack.push_back(wTr);
354 if(nTrOK<=0)
return -1;
355 if(wEve->l2bitET) hA[0]->Fill(
"Pt10",1.);
356 if(wEve->l2EbitET) hE[0]->Fill(
"Pt10",1.);
412 St2011WMaker::accessBTOW(){
416 gMessMgr->Warning() <<
"No EMC data for this event"<<endm;
return -4;
421 int n5=0,n0=0,n1=0,n2=0,n3=0,n4=0;
423 double maxADC=0,adcSum=0;
424 for (
int softID=1; softID <=mxBtow ; softID++) {
425 float rawAdc= emc->getTowerADC(softID);
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");
434 wEve->bemc.statTile[ibp][softID-1]=1;
438 wEve->bemc.statTile[ibp][softID-1]=2;
442 wEve->bemc.statTile[ibp][softID-1]=4;
446 wEve->bemc.statTile[ibp][softID-1]=0 ;
449 float ped,sigPed,gain;
451 mBarrelTables->
getPedestal(jBP,softID,capID,ped,sigPed);
452 mBarrelTables->
getCalib(jBP, softID, 1, gain);
456 gain=gain*par_btowScale;
458 float adc=rawAdc-ped;
460 if(adc<par_kSigPed*sigPed)
continue;
461 if(adc<par_AdcThres)
continue;
463 wEve->bemc.adcTile[ibp][softID-1]=adc;
464 wEve->bemc.eneTile[ibp][softID-1]=adc*gain;
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));
470 if(maxADC<adc) { maxID=softID; maxADC=adc;}
475 if(n0==mxBtow)
return -1 ;
477 wEve->bemc.tileIn[ibp]=1;
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,
485 hA[31]->Fill(maxADC);
486 hA[32]->Fill(adcSum);
487 wEve->bemc.maxAdc=maxADC;
489 if(maxID<=2400) hA[195]->Fill(maxADC);
490 else hA[196]->Fill(maxADC);
492 if(maxADC<par_maxADC)
return -2 ;
500 St2011WMaker::sumTpcCone(
int vertID, TVector3 refAxis,
int flag,
int pointTowId){
507 assert(vertID<(
int)mMuDstMaker->
muDst()->numberOfPrimaryVertices());
512 float rank=V->ranking();
515 Int_t nPrimTrAll=mMuDstMaker->
muDst()->GetNPrimaryTrack();
516 for(
int itr=0;itr<nPrimTrAll;itr++) {
518 if(prTr->
flag()<=0)
continue;
519 if(prTr->
flag()!=301 && pointTowId>0)
continue;
520 if(prTr->
flag()!=301 && pointTowId<0)
continue;
522 if(hitFrac<par_nHitFrac)
continue;
524 TVector3 primP=TVector3(prPvect.x(),prPvect.y(),prPvect.z());
527 float deltaPhi=refAxis.DeltaPhi(primP);
528 if(fabs(deltaPhi)> par_awayDeltaPhi)
continue;
531 float deltaR=refAxis.DeltaR(primP);
532 if(deltaR>par_nearDeltaR)
continue;
538 if(pT>par_trackPt && pointTowId>0) ptSum+=par_trackPt;
539 else if(pT>parE_trackPt && pointTowId<0) ptSum+=parE_trackPt;
549 St2011WMaker::accessBSMD(){
554 gMessMgr->Warning() <<
"No EMC data for this muDst event"<<endm;
return;
558 for(
int iEP=bsmde; iEP<=bsmdp;iEP++) {
559 int iep=iEP-3; assert(bsmde==3);
560 int nh= emc->getNSmdHits(iEP);
562 int n5=0,n1=0,n2=0,n3=0,n4=0;
563 for (
int i=0; i < nh; i++) {
566 int softID=hit->
getId();
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");
574 wEve->bemc.statBsmd[iep][softID-1]=1;
578 wEve->bemc.statBsmd[iep][softID-1]=2;
581 if(statGain<1 || statGain>19) {
582 wEve->bemc.statBsmd[iep][softID-1]=4;
586 float pedRes,sigPed,gain;
588 mBarrelTables->
getPedestal(iEP,softID,capID,pedRes,sigPed);
589 mBarrelTables->
getCalib(iEP, softID, 1, gain);
592 float par_bsmdAbsGain=6e6;
594 adc=de*par_bsmdAbsGain;
598 if(adc<par_kSigPed*sigPed)
continue;
602 assert(softID>=1); assert(softID<=mxBStrips);
604 wEve->bemc.adcBsmd[ iep][id0]=adc;
605 hA[70+10*iep]->Fill(adc);
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
int getId() const
Return Module number.
bool isValid()
dump spinDb content for current time stamp
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.
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.
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.
int BXstarUsingBX7(int bx7)
bXing at STAR IP, [0,119]
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.
bool isPolDirLong()
Returns true if beams are transversely polarized, false otherwise.