11 #include <StMessMgr.h>
12 #include <StThreeVectorF.hh>
15 #include <StMuDSTMaker/COMMON/StMuDstMaker.h>
16 #include <StMuDSTMaker/COMMON/StMuDst.h>
17 #include <StMuDSTMaker/COMMON/StMuEvent.h>
19 #include "StEmcUtil/database/StBemcTables.h"
20 #include "StEmcUtil/geometry/StEmcGeom.h"
22 #include "StEEmcUtil/database/StEEmcDb.h"
23 #include "StEEmcUtil/database/EEmcDbItem.h"
24 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
27 #include "StSpinPool/StJets/StJet.h"
28 #include "StSpinPool/StJets/StJets.h"
29 #include "StJetMaker/StJetMaker.h"
30 #include "StSpinPool/StSpinDbMaker/StSpinDbMaker.h"
31 #include "StJetMaker/StJetReader.h"
32 #include "StJetMaker/StJetSkimEventMaker.h"
35 #include "WeventDisplay.h"
36 #include "St2009WMaker.h"
43 char muDstMakerName[]=
"MuDst";
44 mMuDstMaker= (
StMuDstMaker*)GetMaker(muDstMakerName); assert(mMuDstMaker);
45 mJetReaderMaker = (
StJetReader*)GetMaker(
"JetReader");
46 if(mJetReaderMaker ==0) {
47 LOG_WARN<<GetName()<<Form(
"::constructor() NO JETS , W-algo is not working properly, continue")<<endm;
51 par_bht3TrgID= par_l2wTrgID=0;
54 nInpEve= nTrigEve= nAccEve=0;
57 par_l0emulAdcThresh=31;
58 par_l2emulSeedThresh=5.0;
59 par_l2emulClusterThresh=13.0;
68 par_trackRin=90; par_trackRout=160;
78 par_nearTotEtFrac=0.88;
79 par_smallNearDeltaR=0.1;
102 setJetNeutScaleMC(1.0);
103 setJetChrgScaleMC(1.0);
119 St2009WMaker::Init(){
124 mBtowGeom = StEmcGeom::instance(
"bemc");
125 mBSmdGeom[kBSE] = StEmcGeom::instance(
"bsmde");
126 mBSmdGeom[kBSP] = StEmcGeom::instance(
"bsmdp");
129 mDbE = (
StEEmcDb*)GetDataSet(
"StEEmcDb");
132 mRand =
new TRandom3(0);
136 if (use_gains_file == 1) {
137 fstream f1; f1.open(gains_file,ios::in);
138 cout <<
"Opening gains file " << gains_file << endl;
141 int softID = atoi(str);
142 f1 >> str; gains_BTOW[softID] = atof(str);
143 f1 >> str; f1 >> str;
148 TString filename=
"/star/u/stevens4/wAnalysis/efficXsec/zVertReweight.root";
149 TFile* reweightFile =
new TFile(filename);
150 cout<<
"Re-weighting vertex z distribution with '"<<nameReweight<<
"' histo from file "<<endl<<filename<<endl;
151 hReweight = (TH1F*) reweightFile->Get(nameReweight);
154 if(isMC) par_minPileupVert=1;
157 for(
int isec=0;isec<mxTpcSec;isec++) {
159 float Rin=par_trackRin,Rout=par_trackRout;
161 if(sec==4 && par_inpRunNo>=10090089) Rin=125.;
162 if(sec==11 && par_inpRunNo>=10083013) Rin=125.;
163 if(sec==15 && par_inpRunNo>=10088096 && par_inpRunNo<=10090112 ) Rin=125.;
165 if(sec==5 && par_inpRunNo>=10098029) Rout=140.;
166 if(sec==6 ) Rout=140.;
167 if(sec==20 && par_inpRunNo>=10095120 && par_inpRunNo<=10099078 ) Rout=140.;
169 mTpcFilter[isec].setCuts(par_nFitPts,par_nHitFrac,Rin,Rout);
170 mTpcFilter[isec].init(
"sec",sec,HList);
173 return StMaker::Init();
179 St2009WMaker::InitRun(
int runNo){
180 LOG_INFO<<Form(
"::InitRun(%d) start",runNo)<<endm;
185 const char *file = mMuDstMaker->
GetFile();
186 const char *p1=strstr(file,
"adc_");
190 LOG_INFO<<Form(
"::InitRun(%d) reset TPC cuts",par_inpRunNo)<<endm;
191 for(
int isec=0;isec<mxTpcSec;isec++) {
193 float Rin=par_trackRin,Rout=par_trackRout;
195 if(sec==4 && par_inpRunNo>=10090089) Rin=125.;
196 if(sec==11 && par_inpRunNo>=10083013) Rin=125.;
197 if(sec==15 && par_inpRunNo>=10088096 && par_inpRunNo<=10090112 ) Rin=125.;
199 if(sec==5 && par_inpRunNo>=10098029) Rout=140.;
200 if(sec==6 ) Rout=140.;
201 if(sec==20 && par_inpRunNo>=10095120 && par_inpRunNo<=10099078 ) Rout=140.;
204 if(Rin != par_trackRin || Rout!=par_trackRout)
205 LOG_INFO<<
"Sector "<<sec<<
" cuts aren't default: Rin="<<Rin<<
" and Rout="<<Rout<<endl;
206 mTpcFilter[isec].setCuts(par_nFitPts,par_nHitFrac,Rin,Rout);
211 if(runNo>1000000) assert(mRunNo==par_inpRunNo);
213 LOG_INFO<<Form(
"::InitRun(%d) done, W-algo params: trigID: bht3=%d L2W=%d isMC=%d\n TPC: nPileupVert>%d, vertex |Z|<%.1fcm, primEleTrack: nFit>%d, hitFrac>%.2f Rin<%.1fcm, Rout>%.1fcm, PT>%.1fGeV/c\n BTOW ADC: kSigPed=%d AdcThr>%d maxAdc>%.0f clustET>%.1f GeV ET2x2/ET4x4>%0.2f ET2x2/nearTotET>%0.2f\n dist(track-clust)<%.1fcm, nearDelR<%.1f\n Counters Thresholds: track>%.1f GeV, tower>%.1f GeV Use ETOW: flag=%d ScaleFact=%.2f\nBtowScaleFacor=%.2f\n W selection highET>%.1f awayDelPhi<%.1frad ptBalance>%.1fGeV |leptonEta|<%.1f",
214 par_inpRunNo,par_bht3TrgID, par_l2wTrgID,isMC,
215 par_minPileupVert,par_vertexZ,
216 par_nFitPts,par_nHitFrac, par_trackRin, par_trackRout, par_trackPt,
217 par_kSigPed, par_AdcThres,par_maxADC,par_clustET,par_clustFrac24,par_nearTotEtFrac,
218 par_delR3D,par_nearDeltaR,
219 par_countTrPt,par_countTowEt,par_useEtow,par_etowScale,
221 par_highET,par_awayDeltaPhi,par_ptBalance,par_leptonEta
230 St2009WMaker::FinishRun(
int runNo){
231 LOG_INFO<<Form(
"::FinishRun(%d)",runNo)<<endm;
238 St2009WMaker::Clear(
const Option_t*){
248 wEve.id=mMuDstMaker->
muDst()->
event()->eventId();
249 const char *afile = mMuDstMaker->
GetFile();
251 if(nInpEve%2000==1) printf(
"\n-----in---- %s, nEve: inp=%d trig=%d accpt=%d daqFile=%s\n",
GetName(),nInpEve,nTrigEve, nAccEve,afile);
252 hA[0]->Fill(
"inp",1.);
254 int btowStat=accessBTOW();
256 if( accessTrig())
return kStOK;
260 if( accessVertex())
return kStOK;
262 if(mJetReaderMaker) {
263 mJets = getJets(mJetTreeBranch);
264 for (
int i_jet=0; i_jet< nJets; ++i_jet){
265 StJet* jet = getJet(i_jet);
266 float jet_pt = jet->Pt();
267 float jet_eta = jet->Eta();
268 float jet_phi = jet->Phi();
269 hA[117]->Fill(jet_eta,jet_phi);
270 hA[118]->Fill(jet_pt);
274 if( accessTracks())
return kStOK;
276 if(wEve.bemc.tileIn[0]==1)
277 hA[0]->Fill(
"B-in",1.0);
278 if( btowStat )
return kStOK;
279 hA[0]->Fill(
"B200",1.0);
283 if( extendTrack2Barrel())
return kStOK;
284 if( matchTrack2Cluster())
return kStOK;
293 if(mJetReaderMaker) findPtBalance();
297 if(mJetReaderMaker) tag_Z_boson();
300 if(nAccEve<2 ||nAccEve%1000==1 ) wEve.print(0x0,isMC);
309 St2009WMaker::initGeom(){
312 memset(mapBtowIJ2ID,0,
sizeof(mapBtowIJ2ID));
313 for(
int softID=1; softID<=mxBtow; softID++) {
316 mBtowGeom->
getBin(softID,m,e,s);
318 mBtowGeom->getEta(m,e,etaF);
319 mBtowGeom->getPhi(m,s,phiF);
322 assert(L2algoEtaPhi2IJ(etaF,phiF,iEta, iPhi)==0);
323 int IJ=iEta+ iPhi*mxBTetaBin;
324 assert(mapBtowIJ2ID[IJ ]==0);
325 mapBtowIJ2ID[IJ ]=softID;
328 assert( mBtowGeom->getXYZ(softID,x,y,z)==0);
329 positionBtow[softID-1]=TVector3(x,y,z);
334 for(
int iep=0;iep<mxBSmd;iep++) {
335 for(
int softID=1; softID<=mxBStrips; softID++) {
337 assert( mBSmdGeom[iep]->getXYZ(softID,x,y,z)==0);
338 positionBsmd[iep][softID-1]=TVector3(x,y,z);
343 const Float_t* A=mSmdEGeom->EtaB();
344 for(
int i=0;i<mxBetaStrMod+1;i++) {
346 mSmdEGeom->getEta(i+1,etaF);
347 printf(
"i=%d A=%f str=%f del=%f\n",i,A[i],etaF,A[i]-etaF);
352 for(
int isec=0;isec<mxEtowSec;isec++){
353 for(
int isub=0;isub<mxEtowSub;isub++){
354 for(
int ieta=0;ieta<mxEtowEta;ieta++){
355 positionEtow[isec*mxEtowSub+isub][ieta]=geomE->
getTowerCenter(isec,isub,ieta);
357 if(isec==0 && isub==0) {
358 float x=positionEtow[isec*mxEtowSub+isub][ieta].x();
359 float y=positionEtow[isec*mxEtowSub+isub][ieta].y();
360 etowR[ieta] = x*x+y*y;
373 St2009WMaker::L2algoEtaPhi2IJ(
float etaF,
float phiF,
int &iEta,
int &iPhi) {
374 if( phiF<0) phiF+=2*C_PI;
375 if(fabs(etaF)>=0.99)
return -1;
376 int kEta=1+(int)((etaF+1.)/0.05);
377 iPhi=24-(int)( phiF/C_PI*60.);
378 if(iPhi<0) iPhi+=120;
382 if(iEta<0 || iEta>=mxBTetaBin)
return -2;
383 if(iPhi<0 || iPhi>=mxBTphiBin)
return -3;
391 St2009WMaker::getJets(TString branchName){
392 if(mJetReaderMaker ==0) {
395 assert(mJetReaderMaker->getStJets(branchName)->
eventId()==wEve.id);
396 assert(mJetReaderMaker->getStJets(branchName)->runId()==mRunNo);
397 nJets = mJetReaderMaker->getStJets(branchName)->
nJets();
398 return mJetReaderMaker->getStJets(branchName)->
jets();
TVector3 getTowerCenter(const UInt_t sec, const UInt_t sub, const UInt_t etabin) const
muDst based extraction of W-signal from pp500 data from 2009
virtual const char * GetFile() const
Returns name of current input or output file, depending on mode (GetFileName does the same...
TClonesArray * jets()
Access to the jets in this event.
int nJets() const
The number of jets found in this event.
int eventId() const
access to event numbers, used to synchronize with StMuDstMaker for simultaneous reading ...
void loadTables(StMaker *anyMaker)
load tables.
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
virtual const char * GetName() const
special overload
Int_t getBin(const Float_t phi, const Float_t eta, Int_t &m, Int_t &e, Int_t &s) const