13 #include "StEventTypes.h"
16 #include "StMcEvent/StMcCalorimeterHit.hh"
17 #include "StMcEvent/StMcEmcModuleHitCollection.hh"
18 #include "StMcEvent/StMcEmcHitCollection.hh"
19 #include "StMcEvent/StMcEvent.hh"
20 #include "StMcEvent/StMcVertex.hh"
23 #include "StEmcClusterCollection.h"
24 #include "StEmcPoint.h"
25 #include "StEmcUtil/geometry/StEmcGeom.h"
26 #include "StEmcUtil/projection/StEmcPosition.h"
27 #include "StEmcUtil/others/emcDetectorName.h"
30 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
31 #include "StEEmcSimulatorMaker/StEEmcFastMaker.h"
34 #include "StEemcGammaFilterMaker.h"
36 #include "tables/St_eemcGammaFilterMakerParams_Table.h"
46 LOG_DEBUG <<
"StEemcGammaFilterMaker()" << endm;
52 mSeedEnergyThreshold = 3.8;
53 mClusterEtThreshold = 5.0;
54 mEemcSamplingFraction = StEEmcFastMaker::getSamplingFraction();
57 mMomentum =
new TVector3();
78 LOG_INFO <<
" StEemcGammaFilterMaker is running in test mode.";
79 LOG_INFO <<
" set mFilterMode to 1 to run in analysis mode."<<endm;
87 StEemcGammaFilterMaker::~StEemcGammaFilterMaker()
89 LOG_DEBUG <<
"~StEemcGammaFilterMaker()" << endm;
100 Int_t StEemcGammaFilterMaker::Init()
103 LOG_DEBUG <<
"Init()" << endm;
106 SetAttr(
".Privilege", 1);
110 if (this->getUseDbParams())
112 LOG_INFO <<
"Getting parameters from the database" << endm;
113 TDataSet *DB = this->GetInputDB(
"Calibrations/emc");
116 St_eemcGammaFilterMakerParams*
params = (St_eemcGammaFilterMakerParams*)DB->
Find(
"eemcGammaFilterMakerParams");
119 eemcGammaFilterMakerParams_st *p = params->GetTable();
122 this->mEemcSamplingFraction = p->eemcSamplingFraction;
123 this->mSeedEnergyThreshold = p->seedEnergyThreshold;
124 this->mClusterEtThreshold = p->clusterEtThreshold;
125 this->mMaxVertex = p->maxVertexZ;
126 this->mFilterMode = p->filterMode;
127 LOG_DEBUG <<
"Successfully read parameters from the database table" << endm;
131 LOG_ERROR <<
"The database table has no entry!" << endl;
137 LOG_ERROR <<
"Cannot find the table in the database!" << endm;
143 LOG_ERROR <<
"Cannot read the database!" << endm;
148 LOG_INFO <<
"StEEmcDbMaker::Init() : Using gamma filter on the EEMC" << endm;
149 LOG_INFO <<
"StEEmcDbMaker::Init() : EEMC Sampling Fraction = " << mEemcSamplingFraction << endm;
151 LOG_INFO <<
"StEEmcDbMaker::Init() : Seed energy threshold = " << mSeedEnergyThreshold <<
" GeV " << endm;
152 LOG_INFO <<
"StEEmcDbMaker::Init() : Cluster eT threshold = " << mClusterEtThreshold <<
" GeV " << endm;
153 LOG_INFO <<
"StEEmcDbMaker::Init() : Maximum vertex = +/- " << mMaxVertex <<
" cm" << endm;
155 LOG_INFO <<
"StEEmcDbMaker::Init() : Running the TEST mode (accepting all events). Set mFilterMode=1 to actually reject events in BFC"<< endm;
161 if (mEemcSamplingFraction != StEEmcFastMaker::getSamplingFraction())
163 LOG_WARN <<
"StEEmcDbMaker::Init() : EEMC Sampling fraction (" << mEemcSamplingFraction <<
") is different from what is in the Fast Simulator (" << StEEmcFastMaker::getSamplingFraction() <<
")" << endm;
174 void StEemcGammaFilterMaker::Clear(
const Option_t*)
176 LOG_DEBUG <<
"Clear()" << endm;
180 double *point2 = mEemcTowerHits;
181 for(
unsigned int i = 0; i < nEemcTowers; ++i)
196 void StEemcGammaFilterMaker::setMaxVertex(
double maxVertex)
198 LOG_DEBUG <<
"setMaxVertex()" << endm;
199 mMaxVertex = maxVertex;
205 void StEemcGammaFilterMaker::setThresholds(
double seed,
double cluster)
208 LOG_DEBUG <<
"setThresholds()" << endm;
210 if(seed > 0) mSeedEnergyThreshold = seed;
211 if(cluster > 0) mClusterEtThreshold = cluster;
218 void StEemcGammaFilterMaker::setEEMCSamplingFraction(
double f)
220 mEemcSamplingFraction = f;
230 LOG_DEBUG <<
"Make()" << endm;
253 LOG_WARN <<
"Reject() : Bad StMcEvent!" << endm;
259 double zVertex = mMcEvent->primaryVertex()->position().z();
261 if(fabs(zVertex) > mMaxVertex)
263 LOG_INFO <<
"Reject() : Aborting Event " << mEvent->id()
264 <<
" due to extreme geant vertex of " << zVertex <<
" cm " << endm;
280 status = makeEEMC(emcCollection, zVertex);
286 LOG_INFO <<
"Make() : Aborting Event " << mEvent->id() <<
" due to gamma filter rejection" << endm;
287 LOG_DEBUG <<
"Make() : Vertex = " << zVertex <<
" (cm)" << endm;
296 if (mFilterMode==0) status =
kStOK;
307 Int_t StEemcGammaFilterMaker::makeEEMC(
StEmcCollection *emcCollection,
double zVertex)
310 LOG_DEBUG <<
"makeEEMC()" << endm;
316 unsigned int nSub = 5;
320 double clusterEnergy = 0;
321 double clusterEt = 0;
322 double seedEnergy = 0;
328 StEmcDetector* eemc = emcCollection ? emcCollection->detector(kEndcapEmcTowerId) : 0;
335 for(
unsigned int m = 1; m < eemc->numberOfModules() + 1; ++m)
340 StSPtrVecEmcRawHit &rawHits = module->hits();
342 for(
unsigned int l = 0 ; l < rawHits.size(); ++l)
347 eta = tempHit->eta() - 1;
348 phi = (m - 1) * nSub + tempHit->sub() - 1;
349 mEemcTowerHits[eta * nEemcPhiBins + phi] = tempHit->energy() / mEemcSamplingFraction;
360 for(
unsigned int e = 0; e < nEemcEtaBins; ++e)
363 for(
unsigned int p = 0; p < nEemcPhiBins; ++p)
368 seedEnergy = mEemcTowerHits[e * nEemcPhiBins + p];
371 if(seedEnergy > mSeedEnergyThreshold)
374 clusterEnergy = seedEnergy;
377 for(
int i = -1; i < 2; ++i)
380 for(
int j = -1; j < 2; ++j)
385 LOG_DEBUG <<
"\t\tTower (eta, phi) = (" << e <<
", " << p
386 <<
"), E = " << seedEnergy <<
" (Seed)" << endm;
391 if(neighborEta < 0)
continue;
392 if(neighborEta >
int(nEemcEtaBins - 1))
continue;
394 neighborPhi = (p + j) % nEemcPhiBins;
396 LOG_DEBUG <<
"\t\tTower (eta, phi) = (" << neighborEta <<
", " << neighborPhi
397 <<
"), E = " << mEemcTowerHits[neighborEta * nEemcPhiBins + neighborPhi] << endm;
398 clusterEnergy += mEemcTowerHits[neighborEta * nEemcPhiBins + neighborPhi];
405 if (mMomentum && mEemcGeom) {
407 mMomentum->SetZ(mMomentum->Z() - zVertex);
408 mMomentum->SetX(mMomentum->X() * clusterEnergy / mMomentum->Mag() );
409 mMomentum->SetY(mMomentum->Y() * clusterEnergy / mMomentum->Mag() );
410 mMomentum->SetZ(mMomentum->Z() * clusterEnergy / mMomentum->Mag() );
411 clusterEt = mMomentum->Perp();
413 LOG_DEBUG <<
"\tCluster Energy = " << clusterEnergy <<
" GeV" << endm;
414 LOG_DEBUG <<
"\tCluster eT (corrected for vertex) = " << clusterEt <<
" GeV" << endm;
415 LOG_DEBUG <<
"\tCluster eta (corrected for vertex) = " << mMomentum->Eta() << endm;
416 LOG_DEBUG <<
"\tCluster phi = " << mMomentum->Phi() << endm;
417 LOG_DEBUG <<
"" << endm;
421 if(clusterEt > mClusterEtThreshold)
442 LOG_DEBUG <<
"::Finish()" << endm;
444 LOG_INFO <<
"Finish() : " <<
GetName() <<
" finishing with " << endm;
445 LOG_INFO <<
"Finish() : \t" << mAccepted <<
" of " << mTotal <<
" events passing the filter" << endm;
446 LOG_INFO <<
"Finish() : \t" << mVertexRejected <<
" rejected for bad vertex" << endm;
447 LOG_INFO <<
"Finish() : \t" << mFilterRejected <<
" rejected for no clusters" << endm;
TVector3 getTowerCenter(const UInt_t sec, const UInt_t sub, const UInt_t etabin) const
BFC level Endcap EMC gamma filter.
virtual const char * GetName() const
special overload
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...
virtual TDataSet * Find(const char *path) const