00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <TH1.h>
00010 #include <TH2.h>
00011 #include <StMessMgr.h>
00012 #include <StThreeVectorF.hh>
00013
00014
00015 #include <StMuDSTMaker/COMMON/StMuDstMaker.h>
00016 #include <StMuDSTMaker/COMMON/StMuDst.h>
00017 #include <StMuDSTMaker/COMMON/StMuEvent.h>
00018
00019 #include "StEmcUtil/database/StBemcTables.h"
00020 #include "StEmcUtil/geometry/StEmcGeom.h"
00021
00022 #include "StEEmcUtil/database/StEEmcDb.h"
00023 #include "StEEmcUtil/database/EEmcDbItem.h"
00024 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
00025
00026
00027 #include "StSpinPool/StJets/StJet.h"
00028 #include "StSpinPool/StJets/StJets.h"
00029 #include "StJetMaker/StJetMaker.h"
00030 #include "StSpinPool/StSpinDbMaker/StSpinDbMaker.h"
00031 #include "StJetMaker/StJetReader.h"
00032 #include "StJetMaker/StJetSkimEventMaker.h"
00033
00034
00035 #include "WeventDisplay.h"
00036 #include "St2009WMaker.h"
00037
00038 ClassImp(St2009WMaker)
00039
00040
00041
00042 St2009WMaker::St2009WMaker(const char *name):StMaker(name){
00043 char muDstMakerName[]="MuDst";
00044 mMuDstMaker= (StMuDstMaker*)GetMaker(muDstMakerName); assert(mMuDstMaker);
00045 mJetReaderMaker = (StJetReader*)GetMaker("JetReader");
00046 if(mJetReaderMaker ==0) {
00047 LOG_WARN<<GetName()<<Form("::constructor() NO JETS , W-algo is not working properly, continue")<<endm;
00048 }
00049
00050
00051 par_bht3TrgID= par_l2wTrgID=0;
00052 setHList(0);
00053 setMC(0);
00054 nInpEve= nTrigEve= nAccEve=0;
00055
00056
00057 par_l0emulAdcThresh=31;
00058 par_l2emulSeedThresh=5.0;
00059 par_l2emulClusterThresh=13.0;
00060
00061
00062 par_minPileupVert=3;
00063 par_vertexZ=100;
00064
00065
00066 par_nFitPts=15;
00067 par_nHitFrac=0.51;
00068 par_trackRin=90; par_trackRout=160;
00069 par_trackPt=10.;
00070
00071
00072 par_kSigPed=3;
00073 par_AdcThres=8;
00074 par_maxADC=200.;
00075 par_clustET=15.;
00076 par_clustFrac24=0.95;
00077 par_nearDeltaR=0.7;
00078 par_nearTotEtFrac=0.88;
00079 par_smallNearDeltaR=0.1;
00080
00081
00082 par_delR3D=7.;
00083
00084
00085 par_countTrPt=1.;
00086 par_countTowEt=1.;
00087
00088
00089 par_awayDeltaPhi=0.7;
00090 par_highET=25.;
00091 par_ptBalance=15.;
00092 par_leptonEta=1.0;
00093
00094 par_useEtow=1;
00095
00096
00097
00098
00099 setEtowScale(1.0);
00100 setBtowScale(1.0);
00101
00102 setJetNeutScaleMC(1.0);
00103 setJetChrgScaleMC(1.0);
00104
00105 mRunNo=0;
00106
00107
00108 par_DsmThres=28;
00109 par_maxDisplEve=1;
00110
00111 use_gains_file = 0;
00112
00113 }
00114
00115
00116
00117
00118 Int_t
00119 St2009WMaker::Init(){
00120 assert(HList);
00121 initHistos();
00122
00123 mBarrelTables = new StBemcTables();
00124 mBtowGeom = StEmcGeom::instance("bemc");
00125 mBSmdGeom[kBSE] = StEmcGeom::instance("bsmde");
00126 mBSmdGeom[kBSP] = StEmcGeom::instance("bsmdp");
00127 wDisaply= new WeventDisplay(this,par_maxDisplEve);
00128
00129 mDbE = (StEEmcDb*)GetDataSet("StEEmcDb");
00130 assert(mDbE);
00131 geomE= new EEmcGeomSimple();
00132 mRand = new TRandom3(0);
00133
00134 initGeom();
00135
00136 if (use_gains_file == 1) {
00137 fstream f1; f1.open(gains_file,ios::in);
00138 cout << "Opening gains file " << gains_file << endl;
00139 char str[200];
00140 while (f1 >> str) {
00141 int softID = atoi(str);
00142 f1 >> str; gains_BTOW[softID] = atof(str);
00143 f1 >> str; f1 >> str;
00144 }
00145 }
00146
00147 if(isMC >= 350){
00148 TString filename="/star/u/stevens4/wAnalysis/efficXsec/zVertReweight.root";
00149 TFile* reweightFile = new TFile(filename);
00150 cout<<"Re-weighting vertex z distribution with '"<<nameReweight<<"' histo from file "<<endl<<filename<<endl;
00151 hReweight = (TH1F*) reweightFile->Get(nameReweight);
00152 }
00153
00154 if(isMC) par_minPileupVert=1;
00155
00156
00157 for(int isec=0;isec<mxTpcSec;isec++) {
00158 int sec=isec+1;
00159 float Rin=par_trackRin,Rout=par_trackRout;
00160
00161 if(sec==4 && par_inpRunNo>=10090089) Rin=125.;
00162 if(sec==11 && par_inpRunNo>=10083013) Rin=125.;
00163 if(sec==15 && par_inpRunNo>=10088096 && par_inpRunNo<=10090112 ) Rin=125.;
00164
00165 if(sec==5 && par_inpRunNo>=10098029) Rout=140.;
00166 if(sec==6 ) Rout=140.;
00167 if(sec==20 && par_inpRunNo>=10095120 && par_inpRunNo<=10099078 ) Rout=140.;
00168
00169 mTpcFilter[isec].setCuts(par_nFitPts,par_nHitFrac,Rin,Rout);
00170 mTpcFilter[isec].init("sec",sec,HList);
00171 }
00172
00173 return StMaker::Init();
00174 }
00175
00176
00177
00178 Int_t
00179 St2009WMaker::InitRun(int runNo){
00180 LOG_INFO<<Form("::InitRun(%d) start",runNo)<<endm;
00181 mBarrelTables->loadTables(this );
00182
00183
00184 if(isMC>=350){
00185 const char *file = mMuDstMaker->GetFile();
00186 const char *p1=strstr(file,"adc_");
00187 int run=atoi(p1+4);
00188 par_inpRunNo=run;
00189
00190 LOG_INFO<<Form("::InitRun(%d) reset TPC cuts",par_inpRunNo)<<endm;
00191 for(int isec=0;isec<mxTpcSec;isec++) {
00192 int sec=isec+1;
00193 float Rin=par_trackRin,Rout=par_trackRout;
00194
00195 if(sec==4 && par_inpRunNo>=10090089) Rin=125.;
00196 if(sec==11 && par_inpRunNo>=10083013) Rin=125.;
00197 if(sec==15 && par_inpRunNo>=10088096 && par_inpRunNo<=10090112 ) Rin=125.;
00198
00199 if(sec==5 && par_inpRunNo>=10098029) Rout=140.;
00200 if(sec==6 ) Rout=140.;
00201 if(sec==20 && par_inpRunNo>=10095120 && par_inpRunNo<=10099078 ) Rout=140.;
00202
00203
00204 if(Rin != par_trackRin || Rout!=par_trackRout)
00205 LOG_INFO<<"Sector "<<sec<<" cuts aren't default: Rin="<<Rin<<" and Rout="<<Rout<<endl;
00206 mTpcFilter[isec].setCuts(par_nFitPts,par_nHitFrac,Rin,Rout);
00207 }
00208 }
00209
00210 mRunNo=runNo;
00211 if(runNo>1000000) assert(mRunNo==par_inpRunNo);
00212
00213 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",
00214 par_inpRunNo,par_bht3TrgID, par_l2wTrgID,isMC,
00215 par_minPileupVert,par_vertexZ,
00216 par_nFitPts,par_nHitFrac, par_trackRin, par_trackRout, par_trackPt,
00217 par_kSigPed, par_AdcThres,par_maxADC,par_clustET,par_clustFrac24,par_nearTotEtFrac,
00218 par_delR3D,par_nearDeltaR,
00219 par_countTrPt,par_countTowEt,par_useEtow,par_etowScale,
00220 par_btowScale,
00221 par_highET,par_awayDeltaPhi,par_ptBalance,par_leptonEta
00222 )<<endm;
00223
00224 return kStOK;
00225 }
00226
00227
00228
00229 Int_t
00230 St2009WMaker::FinishRun(int runNo){
00231 LOG_INFO<<Form("::FinishRun(%d)",runNo)<<endm;
00232 return kStOK;
00233 }
00234
00235
00236
00237 void
00238 St2009WMaker::Clear(const Option_t*){
00239 wEve.clear();
00240 }
00241
00242
00243
00244
00245 Int_t
00246 St2009WMaker::Make(){
00247 nInpEve++;
00248 wEve.id=mMuDstMaker->muDst()->event()->eventId();
00249 const char *afile = mMuDstMaker->GetFile();
00250
00251 if(nInpEve%2000==1) printf("\n-----in---- %s, nEve: inp=%d trig=%d accpt=%d daqFile=%s\n", GetName(),nInpEve,nTrigEve, nAccEve,afile);
00252 hA[0]->Fill("inp",1.);
00253
00254 int btowStat=accessBTOW();
00255
00256 if( accessTrig()) return kStOK;
00257 nTrigEve++;
00258
00259 accessBSMD();
00260 if( accessVertex()) return kStOK;
00261
00262 if(mJetReaderMaker) {
00263 mJets = getJets(mJetTreeBranch);
00264 for (int i_jet=0; i_jet< nJets; ++i_jet){
00265 StJet* jet = getJet(i_jet);
00266 float jet_pt = jet->Pt();
00267 float jet_eta = jet->Eta();
00268 float jet_phi = jet->Phi();
00269 hA[117]->Fill(jet_eta,jet_phi);
00270 hA[118]->Fill(jet_pt);
00271 }
00272 }
00273
00274 if( accessTracks()) return kStOK;
00275
00276 if(wEve.bemc.tileIn[0]==1)
00277 hA[0]->Fill("B-in",1.0);
00278 if( btowStat ) return kStOK;
00279 hA[0]->Fill("B200",1.0);
00280
00281 accessETOW();
00282
00283 if( extendTrack2Barrel()) return kStOK;
00284 if( matchTrack2Cluster()) return kStOK;
00285
00286 nAccEve++;
00287
00288
00289
00290 findNearJet();
00291 findAwayJet();
00292
00293 if(mJetReaderMaker) findPtBalance();
00294
00295 hadronicRecoil();
00296
00297 if(mJetReaderMaker) tag_Z_boson();
00298
00299 find_W_boson();
00300 if(nAccEve<2 ||nAccEve%1000==1 ) wEve.print(0x0,isMC);
00301
00302 return kStOK;
00303 }
00304
00305
00306
00307
00308 void
00309 St2009WMaker::initGeom(){
00310
00311
00312 memset(mapBtowIJ2ID,0,sizeof(mapBtowIJ2ID));
00313 for(int softID=1; softID<=mxBtow; softID++) {
00314
00315 int m,e,s;
00316 mBtowGeom->getBin(softID,m,e,s);
00317 float etaF,phiF;
00318 mBtowGeom->getEta(m,e,etaF);
00319 mBtowGeom->getPhi(m,s,phiF);
00320
00321 int iEta, iPhi;
00322 assert(L2algoEtaPhi2IJ(etaF,phiF,iEta, iPhi)==0);
00323 int IJ=iEta+ iPhi*mxBTetaBin;
00324 assert(mapBtowIJ2ID[IJ ]==0);
00325 mapBtowIJ2ID[IJ ]=softID;
00326
00327 Float_t x,y,z;
00328 assert( mBtowGeom->getXYZ(softID,x,y,z)==0);
00329 positionBtow[softID-1]=TVector3(x,y,z);
00330 }
00331
00332
00333
00334 for(int iep=0;iep<mxBSmd;iep++) {
00335 for(int softID=1; softID<=mxBStrips; softID++) {
00336 Float_t x,y,z;
00337 assert( mBSmdGeom[iep]->getXYZ(softID,x,y,z)==0);
00338 positionBsmd[iep][softID-1]=TVector3(x,y,z);
00339 }
00340 }
00341
00342 #if 0
00343 const Float_t* A=mSmdEGeom->EtaB();
00344 for(int i=0;i<mxBetaStrMod+1;i++) {
00345 float etaF,phiF;
00346 mSmdEGeom->getEta(i+1,etaF);
00347 printf("i=%d A=%f str=%f del=%f\n",i,A[i],etaF,A[i]-etaF);
00348 }
00349 #endif
00350
00351
00352 for(int isec=0;isec<mxEtowSec;isec++){
00353 for(int isub=0;isub<mxEtowSub;isub++){
00354 for(int ieta=0;ieta<mxEtowEta;ieta++){
00355 positionEtow[isec*mxEtowSub+isub][ieta]=geomE->getTowerCenter(isec,isub,ieta);
00356 #if 0 // trash
00357 if(isec==0 && isub==0) {
00358 float x=positionEtow[isec*mxEtowSub+isub][ieta].x();
00359 float y=positionEtow[isec*mxEtowSub+isub][ieta].y();
00360 etowR[ieta] = x*x+y*y;
00361 }
00362 #endif
00363 }
00364 }
00365 }
00366
00367 }
00368
00369
00370
00371
00372 int
00373 St2009WMaker::L2algoEtaPhi2IJ(float etaF,float phiF,int &iEta, int &iPhi) {
00374 if( phiF<0) phiF+=2*C_PI;
00375 if(fabs(etaF)>=0.99) return -1;
00376 int kEta=1+(int)((etaF+1.)/0.05);
00377 iPhi=24-(int)( phiF/C_PI*60.);
00378 if(iPhi<0) iPhi+=120;
00379
00380 iEta=kEta-1;
00381
00382 if(iEta<0 || iEta>=mxBTetaBin) return -2;
00383 if(iPhi<0 || iPhi>=mxBTphiBin) return -3;
00384 return 0;
00385 }
00386
00387
00388
00389
00390 TClonesArray*
00391 St2009WMaker::getJets(TString branchName){
00392 if(mJetReaderMaker ==0) {
00393 nJets=-1; return 0;
00394 }
00395 assert(mJetReaderMaker->getStJets(branchName)->eventId()==wEve.id);
00396 assert(mJetReaderMaker->getStJets(branchName)->runId()==mRunNo);
00397 nJets = mJetReaderMaker->getStJets(branchName)->nJets();
00398 return mJetReaderMaker->getStJets(branchName)->jets();
00399
00400 }
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505