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 "StBFChain/StBFChain.h"
31 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
34 #include "tables/St_g2t_event_Table.h"
35 #include "tables/St_g2t_pythia_Table.h"
36 #include "tables/St_g2t_vertex_Table.h"
37 #include "tables/St_particle_Table.h"
38 #include "StSpinPool/StJetSkimEvent/StPythiaEvent.h"
41 #include "StGammaFilterMaker.h"
49 StMaker(name), mPythiaFile(0), mPythiaTree(0), mPythiaEvent(0)
52 LOG_DEBUG <<
"StGammaFilterMaker()" << endm;
55 mPythiaName =
"pythia.root";
58 mSeedEnergyThreshold = 5.0;
59 mClusterEtThreshold = 6.55;
67 mMomentum =
new TVector3();
70 mBemcGeom = StEmcGeom::instance(
"bemc");
76 for (
int ii=0;ii< nBemcTowers+1;ii++ )
78 mBemcTowerHits[ii] = 0;
87 StGammaFilterMaker::~StGammaFilterMaker()
89 LOG_DEBUG <<
"~StGammaFilterMaker()" << endm;
100 Int_t StGammaFilterMaker::Init()
103 LOG_DEBUG <<
"Init()" << endm;
106 SetAttr(
".Privilege", 1);
108 LOG_INFO <<
"Init() - Using gamma filter on the BEMC" << endm;
110 LOG_INFO <<
"Init() : Seed energy threshold = " << mSeedEnergyThreshold <<
" GeV " << endm;
111 LOG_INFO <<
"Init() : Cluster eT threshold = " << mClusterEtThreshold <<
" GeV " << endm;
117 TString name(bfChain->GetFileOut());
118 name.ReplaceAll(
".root",
".pythia.root");
122 LOG_INFO <<
"Init() : Storing pythia event information in " << mPythiaName << endm;
124 mPythiaFile =
new TFile(mPythiaName,
"recreate");
125 mPythiaTree =
new TTree(
"pythiaTree",
"Pythia Tree");
126 mPythiaTree->Branch(
"PythiaEvents",
"StPythiaEvent", &mPythiaEvent);
135 void StGammaFilterMaker::Clear(
const Option_t*)
137 LOG_DEBUG <<
"Clear()" << endm;
141 for(
unsigned int i = 0; i < nBemcTowers + 1; ++i)
147 mPythiaEvent->Clear();
154 void StGammaFilterMaker::setThresholds(
double seed,
double cluster)
157 LOG_DEBUG <<
"setThresholds()" << endm;
159 if(seed > 0) mSeedEnergyThreshold = seed;
160 if(cluster > 0) mClusterEtThreshold = cluster;
174 double StGammaFilterMaker::BEMCSamplingMultiplier(
double eta)
177 double x = fabs(eta);
182 return c0 + c1 * x + c2 * x * x;
191 LOG_DEBUG <<
"Make()" << endm;
197 LOG_WARN <<
"Make() - StEvent not found!" << endm;
214 LOG_INFO <<
"Make() : Storing first event without applying filter" << endm;
225 LOG_WARN <<
"Make() - Bad StMcEvent!" << endm;
231 double zVertex = mMcEvent->primaryVertex()->position().z();
238 assert(mcEmcCollection);
239 status = makeBEMC(mcEmcCollection, zVertex);
243 LOG_INFO <<
"Make() : Aborting Event " << mEvent->id() <<
" due to gamma filter rejection" << endm;
249 LOG_INFO <<
"Make() : Event " << mEvent->id() <<
" accepted!" << endm;
265 LOG_DEBUG <<
"makeBEMC()" << endm;
290 for(
unsigned int m = 1; m < mcEmcCollection->numberOfModules() + 1; ++m)
294 const vector<StMcCalorimeterHit*> hits = module->detectorHits();
296 for(
unsigned int l = 0; l < hits.size(); ++l)
298 mBemcGeom->getId(hits[l]->module(), hits[l]->eta(), hits[l]->sub(), bemcId);
299 mBemcTowerHits[bemcId] = hits[l];
307 double seedEnergy = 0;
308 double clusterEnergy = 0;
309 double clusterEt = 0;
310 unsigned int neighborId = 0;
313 for(
unsigned int n = 1; n < nBemcTowers + 1; ++n)
319 mBemcGeom->getEta(n, eta);
321 seedEnergy = hit->dE() * BEMCSamplingMultiplier(eta);
324 if(seedEnergy > mSeedEnergyThreshold)
327 clusterEnergy = seedEnergy;
334 for(
int i = -1; i < 2; ++i)
336 for(
int j = -1; j < 2; ++j)
341 LOG_DEBUG <<
"\t\tTower " << n <<
", E = " << seedEnergy <<
" (Seed)" << endm;
345 neighborId = mPosition->
getNextId(1, m, (
int)e, s, i, j);
346 if(neighborId < 1)
continue;
347 if(neighborId > 4800)
continue;
349 neighborHit = mBemcTowerHits[neighborId];
351 if(!neighborHit)
continue;
352 mBemcGeom->getEta(neighborId, eta);
353 LOG_DEBUG <<
"\t\tTower " << neighborId <<
", E = " << neighborHit->dE() * BEMCSamplingMultiplier(eta) << endm;
354 clusterEnergy += neighborHit->dE() * BEMCSamplingMultiplier(eta);
361 mBemcGeom->getXYZ((
int)n, x, y, z);
363 r = sqrt(x * x + y * y + z * z);
364 x *= clusterEnergy / r;
365 y *= clusterEnergy / r;
366 z *= clusterEnergy / r;
367 mMomentum->SetXYZ(x, y, z);
368 clusterEt = mMomentum->Perp();
370 LOG_DEBUG <<
"\tCluster Energy = " << clusterEnergy <<
" GeV" << endm;
371 LOG_DEBUG <<
"\tCluster eT (corrected for vertex) = " << clusterEt <<
" GeV" << endm;
372 LOG_DEBUG <<
"\tCluster eta (corrected for vertex) = " << mMomentum->Eta() << endm;
373 LOG_DEBUG <<
"\tCluster phi = " << mMomentum->Phi() << endm;
374 LOG_DEBUG <<
"" << endm;
377 if(clusterEt > mClusterEtThreshold)
396 LOG_DEBUG <<
"::Finish()" << endm;
398 mPythiaFile->Write();
399 mPythiaFile->Close();
401 LOG_INFO <<
"Finish() : " <<
GetName() <<
" finishing with " << endm;
402 LOG_INFO <<
"Finish() : \t" << mAccepted <<
" of " << mTotal <<
" events passing the filter" << endm;
411 void StGammaFilterMaker::fStorePythia()
414 TDataSet* geant = GetDataSet(
"geant");
422 St_g2t_event* g2tEvent = (St_g2t_event*)iter(
"g2t_event");
426 g2t_event_st* eventTable = (g2t_event_st*)g2tEvent->GetTable();
429 mPythiaEvent->setRunId(eventTable->n_run);
430 mPythiaEvent->setEventId(eventTable->n_event);
436 St_g2t_pythia* pythiaEvent = (St_g2t_pythia*)iter(
"g2t_pythia");
440 g2t_pythia_st* pythiaTable = (g2t_pythia_st*)pythiaEvent->GetTable();
444 mPythiaEvent->setProcessId(pythiaTable->subprocess_id);
445 mPythiaEvent->setS(pythiaTable->mand_s);
446 mPythiaEvent->setT(pythiaTable->mand_t);
447 mPythiaEvent->setU(pythiaTable->mand_u);
448 mPythiaEvent->setPt(pythiaTable->hard_p);
449 mPythiaEvent->setCosTheta(pythiaTable->cos_th);
450 mPythiaEvent->setX1(pythiaTable->bjor_1);
451 mPythiaEvent->setX2(pythiaTable->bjor_2);
458 St_g2t_vertex* vertexEvent = (St_g2t_vertex*)iter(
"g2t_vertex");
462 g2t_vertex_st* vertexTable = (g2t_vertex_st*)vertexEvent->GetTable();
463 if(vertexTable) mPythiaEvent->setVertex(TVector3(vertexTable[0].ge_x));
467 St_particle* particleEvent = (St_particle*)iter(
"particle");
471 particle_st* particleTable = (particle_st*)particleEvent->GetTable();
475 for(
int i = 0; i < particleEvent->GetNRows(); ++i)
477 mPythiaEvent->addParticle(TParticle(particleTable[i].idhep,
478 particleTable[i].isthep,
479 particleTable[i].jmohep[0],
480 particleTable[i].jmohep[1],
481 particleTable[i].jdahep[0],
482 particleTable[i].jdahep[1],
483 TLorentzVector(particleTable[i].phep),
484 TLorentzVector(particleTable[i].vhep)));
Int_t getNextId(Int_t det, Int_t m, Int_t e, Int_t s, Int_t nEta, Int_t nPhi) const
Return neighbor id (works for all detectors 1=bemc, 2=bprs, 3=bsmde, 4=bsmdp)
virtual const char * GetName() const
special overload
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...