00001
00002
00003
00004
00005 #include <TFile.h>
00006
00007 #include "StEEsoloPi0Maker.h"
00008
00009 #include "TChain.h"
00010 #include "TClonesArray.h"
00011 #include "StL0Trigger.h"
00012 #include "StEventInfo.h"
00013 #include "StEventSummary.h"
00014 #include "StarClassLibrary/StThreeVectorF.hh"
00015 #include "StMuDSTMaker/COMMON/StMuEvent.h"
00016 #include "StMuDSTMaker/COMMON/StMuTrack.h"
00017 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
00018 #include "StMuDSTMaker/COMMON/StMuTriggerIdCollection.h"
00019 #include "StEvent/StTriggerId.h"
00020
00021
00022 #include "StEEmcUtil/database/EEmcDbItem.h"
00023 #include "StEEmcUtil/database/StEEmcDb.h"
00024
00025 #include <StMessMgr.h>
00026
00027 ClassImp(StEEsoloPi0Maker)
00028
00029
00030
00031 StEEsoloPi0Maker::StEEsoloPi0Maker(const char* self ,const char* muDstMakerName) : StMaker(self){
00032 mMuDstMaker = (StMuDstMaker*)GetMaker(muDstMakerName);
00033 assert(mMuDstMaker);
00034 MCflag=0;
00035
00036 }
00037
00038
00039
00040
00041 StEEsoloPi0Maker::~StEEsoloPi0Maker(){
00042
00043
00044 }
00045
00046
00047
00048 Int_t StEEsoloPi0Maker::InitRun(int runNo){
00049
00050
00051 if( !MCflag) initRun(runNo);
00052 static int first=1;
00053 if(first) return kStOK;
00054 initRun(runNo);
00055 first=0;
00056 return kStOK;
00057 }
00058
00059
00060
00061 Int_t StEEsoloPi0Maker::Init(){
00062 eeDb = (StEEmcDb*)this->GetDataSet("StEEmcDb");
00063 EEsoloPi0::init();
00064 LOG_INFO << "has MCflag="<< MCflag<<endm;
00065 return StMaker::Init();
00066 }
00067
00068
00069
00070 Int_t StEEsoloPi0Maker::Finish(){
00071 finish();
00072 return kStOK;
00073 }
00074
00075
00076
00077
00078
00079
00080 Int_t StEEsoloPi0Maker::Make(){
00081 clear();
00082 static int n0=0,n1=0,n2=0,n3=0;
00083
00084 n0++;
00085
00086 if( !MCflag&& !unpackMuTrig()) return kStOK;
00087 n1++;
00088
00089
00090 float sum=getCtbSum(); sum=sum;
00091
00092 n2++;
00093
00094
00095 if(!unpackMuEemc()) return kStOK;
00096 n3++;
00097
00098 findTowerClust();
00099 findTowerPi0();
00100
00101 return kStOK;
00102 }
00103
00104
00105
00106
00107
00108 bool StEEsoloPi0Maker::unpackMuTrig(){
00109
00110
00111
00112
00113 StMuEvent* muEve = mMuDstMaker->muDst()->event();
00114
00115 StMuTriggerIdCollection& trgIdColl=muEve->triggerIdCollection();
00116
00117 const StTriggerId& oflTrgId=trgIdColl.nominal();
00118 vector<unsigned int> trgId=oflTrgId.triggerIds();
00119
00120 #if 0
00121 StEventInfo &info=muEve->eventInfo();
00122 int nPrim = mMuDstMaker->muDst()->primaryTracks()->GetEntries();
00123 printf("\n\n ==================== processing eventID %d nPrim=%d nTrig=%d==============\n", info.id(),nPrim, trgId.size());
00124 #endif
00125
00126 bool isGood=false;
00127 UInt_t i;
00128 for(i = 0; i < trgId.size() ; i++){
00129
00130 #if 0
00131
00132 if(trgId[i]==10) isGood=true;
00133 if(trgId[i]==45010) isGood=true;
00134 if(trgId[i]==45020) isGood=true;
00135 #endif
00136
00137 if(trgId[i]==127641) isGood=true;
00138
00139
00140 }
00141
00142 #if 0 // TPC vertex, not used (yet)
00143 StEventSummary &smry=muEve->eventSummary();
00144 StThreeVectorF ver=smry.primaryVertexPosition();
00145
00146 b.zTpc=ver.z();
00147 if( fabs(ver.x())<0.000001 &&fabs(ver.y())<0.000001 &&fabs(ver.z())<0.000001 ) b.zTpc=999;
00148 #endif
00149
00150 return isGood;
00151 }
00152
00153
00154
00155 bool StEEsoloPi0Maker::unpackMuEemc(){
00156
00157 nInpEve++;
00158 gMessMgr->Debug() <<GetName()<<"::unpackMuDst() is called "<<endm;
00159
00160
00161 StMuEmcCollection* emc = mMuDstMaker->muDst()->muEmcCollection();
00162 if (!emc) {
00163 gMessMgr->Warning() <<"No EMC data for this event"<<endm; return false;
00164 }
00165
00166 int i, n1=0;
00167
00168
00169 for (i=0; i< emc->getNEndcapTowerADC(); i++) {
00170 int sec,eta,sub,val;
00171
00172 emc->getEndcapTowerADC(i,val,sec,sub,eta);
00173 assert(sec>0 && sec<=MaxSectors);
00174
00175
00176 if(sec<eeDb->getFirstSector() || sec>eeDb->getLastSector()) continue;
00177
00178 const EEmcDbItem *x=eeDb->getTile(sec,'A'+sub-1,eta,'T');
00179 assert(x);
00180
00181 if(x->fail ) continue;
00182
00183 int iphi=(x->sec-1)*MaxSubSec+(x->sub-'A');
00184 int ieta=x->eta-1;
00185 assert(iphi>=0 && iphi<MaxPhiBins);
00186 assert(ieta>=0 && ieta<MaxEtaBins);
00187 int irad=iphi*MaxEtaBins+ieta;
00188 assert(irad>=0 && irad<EEsoloPi0::MxTw);
00189
00190 float ene=-102;
00191
00192 float rawAdc=val;
00193 if(rawAdc<x->thr) continue;
00194 float adc=rawAdc-x->ped;
00195 if(x->gain) ene=adc/x->gain;
00196
00197 if(MCflag) ene/=0.8;
00198
00199 int ii=(x->sec-1)*60+(x->sub-'A')*12+x->eta-1;
00200 assert(ii==irad);
00201
00202
00203
00204
00205
00206
00207
00208 n1++;
00209
00210 float recoEner=ene/scaleFactor;
00211
00212 soloMip[irad].e= recoEner;
00213
00214 }
00215
00216 gMessMgr->Debug() <<GetName()<<"::unpackMuDst(), found total" <<n1<<" towers with ADC>thr"<<endm;
00217
00218 return true;
00219 }
00220
00221
00222
00223 float StEEsoloPi0Maker::getCtbSum(){
00224
00225
00226
00227
00228 StMuEvent* muEve = mMuDstMaker->muDst()->event();
00229 StCtbTriggerDetector* ctbDet = &(muEve->ctbTriggerDetector());
00230
00231 assert(ctbDet);
00232 float ctbSum = 0;
00233 int nHit=0;
00234 for (UInt_t slat = 0; slat < ctbDet->numberOfSlats(); slat++) {
00235 for (UInt_t tray = 0; tray < ctbDet->numberOfTrays(); tray++) {
00236 float adc = ctbDet->mips(tray,slat,0);
00237 ctbSum += adc;
00238 if(adc > 5) nHit++;
00239 }
00240 }
00241
00242 hA[7]->Fill(ctbSum);
00243 return ctbSum;
00244 }
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291