42 #include "StMCFilter.h"
44 #include "StHepParticle.h"
45 #include "StG3Particle.h"
50 myMap_t *StMCFilter::mgMap=0;
52 extern void *gStarFiltAction;
53 extern void *gStarFiltConfig;
56 StMCFilter::StMCFilter(
const char *name)
58 if(!mgMap) mgMap =
new myMap_t;
59 memset(fBeg,0,fEnd-fBeg+1);
61 std::string myName(fName);
62 for (
int i=0;i<(int)myName.size();i++) { myName[i]=tolower(myName[i]);}
65 myMap_t::iterator it = mgMap->find(myName);
66 assert (it == mgMap->end() &&
"Filter name must be unique");
67 (*mgMap)[myName] =
this;
68 gStarFiltAction=(
void*)&StMCFilter::Action;
69 gStarFiltConfig=(
void*)&StMCFilter::Config;
70 std::cout <<
"*** StMCFilter::StMCFilter(" << myName.c_str() <<
") CREATED ***" << std::endl;
73 StMCFilter::~StMCFilter()
76 delete fgHepParticle; fgHepParticle=0;
77 delete fgG3Particle ; fgG3Particle =0;
81 int StMCFilter::Select(
const char *name)
84 std::string myName(name);
85 for (
int i=0;i<(int)myName.size();i++) { myName[i]=tolower(myName[i]);}
86 myMap_t::iterator it = mgMap->find(std::string(myName));
87 assert (it != mgMap->end() &&
"Filter MUST be found");
88 if (it == mgMap->end())
return 1;
89 fgSelected = (*it).second;
90 std::cout <<
"*** StMCFilter::Select(" << myName.c_str() <<
") SELCTED ***" << std::endl;
94 void StMCFilter::SetEG(
void *hepEvt)
96 if (fgHepParticle)
return;
100 void StMCFilter::SetG3(
void *gfKine,
void *gfVert)
102 if (fgG3Particle)
return;
106 int StMCFilter::REJECTEG()
108 if (!fgSelected || !fgHepParticle)
return 0;
109 fgSelected->fCnt[0][0]++;
110 fgHepParticle->Update();
111 int ans =fgSelected->
RejectEG(*fgHepParticle);
112 if (ans) fgSelected->fCnt[0][1]++;
116 int StMCFilter::REJECTGT()
118 if (!fgSelected || !fgG3Particle)
return 0;
119 fgSelected->fCnt[1][0]++;
120 fgG3Particle->Update();
121 int ans = fgSelected->
RejectGT(*fgG3Particle);
122 if (ans) fgSelected->fCnt[1][1]++;
126 int StMCFilter::REJECTGE()
129 if (!fgSelected || !fgG3Particle)
return 0;
130 fgG3Particle->Update();
131 fgSelected->fCnt[2][0]++;
132 int ans = fgSelected->
RejectGE(*fgG3Particle);
133 if (ans) fgSelected->fCnt[2][1]++;
140 int StMCFilter::Action(
int kase,
void *par1,
void *par2)
142 enum { kSelect=0,kEGInit=1, kEGReje=2
143 ,kGTInit=3, kGTReje=4
144 ,kGEInit=5, kGEReje=6,kFinish=7};
148 case kSelect:
return StMCFilter::Select((
char*)par1);
150 case kEGInit: StMCFilter::SetEG(par1 );
return 0;
151 case kGTInit: StMCFilter::SetG3(par1,par2);
return 0;
152 case kGEInit:
return 0;
154 case kEGReje:
return StMCFilter::REJECTEG();
155 case kGTReje:
return StMCFilter::REJECTGT();
156 case kGEReje:
return StMCFilter::REJECTGE();
158 default: assert(0 &&
"StMCFilter::Action Wrong case");
163 int StMCFilter::Config( std::string key,
const float value )
165 if ( !fgSelected )
return 0;
174 static const char *filtName[] = {
"RejectEG",
"RejectGT",
"RejectGE"};
175 if (!fgSelected)
return;
176 std::cout <<
"*** Filter Finish(" << fgSelected->GetName().c_str() <<
") ***" << std::endl;
177 for (
int i=0; i<3; i++)
179 if (!fgSelected->fCnt[i][0])
continue;
180 std::cout <<
"*** Filter " << filtName[i] <<
" nTot=" << fgSelected->fCnt[i][0]
181 <<
"\tnRej=" << fgSelected->fCnt[i][1] << std::endl;
Master class for StGimParticle filled from GEANT3 internal structures.
virtual int RejectGT(const StGenParticleMaster &ptl) const
Rejection of GEANT Tracking.
virtual int RejectGE(const StGenParticleMaster &ptl) const
Rejection at GEANT End, No GEANT output.
virtual void parseConfig(std::string key, float value)
virtual int RejectEG(const StGenParticleMaster &ptl) const
Rejection inside of EventGenerator (Pythia)
virtual void Finish() const
Finish called at the end of GEANT.
static void FINISH()
Print of numbers above at the end of STARSIM.