StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFmsFastSimMaker.cxx
1 // \class StFmsFastSimMaker
2 // \author Akio Ogawa
3 //
4 // $Id: StFmsFastSimMaker.cxx,v 1.1 2016/06/09 12:17:42 akio Exp $
5 // $Log: StFmsFastSimMaker.cxx,v $
6 // Revision 1.1 2016/06/09 12:17:42 akio
7 // First version
8 //
9 //
10 
11 #include "StFmsFastSimMaker.h"
12 
13 #include "StMessMgr.h"
14 //#include "Stypes.h"
15 
16 #include "StThreeVectorF.hh"
17 #include "StEnumerations.h"
18 //#include "StEventTypes.h"
19 #include "StEvent/StEvent.h"
20 #include "StEvent/StFmsCollection.h"
21 #include "StEvent/StFmsPoint.h"
22 
23 #include "StarGenerator/BASE/StarPrimaryMaker.h"
24 #include "StarGenerator/EVENT/StarGenEvent.h"
25 #include "StarGenerator/EVENT/StarGenParticle.h"
26 
27 #include "TRandom2.h"
28 
29 float projectFMS(float x, float z, float zp, float vz){
30  //LOG_INFO << Form("x=%f z=%f zp=%f vz=%f x/z=%f xp=%f",x,z,zp,vz,x/z,x/z*zp)<<endm;
31  return x/z*(zp-vz);
32 }
33 
34 static const float ZFMS=720.0;
35 static const float XMINFMS=20.0;
36 static const float XMAXFMS=100.0;
37 int fmsAcceptance(StarGenParticle *p){
38  //LOG_INFO << Form("pz=%f",p->GetPz())<<endm;
39  if(p->GetPz()<1.0) return 0; //cut at +1GeV
40  float x=fabs(projectFMS(p->GetPx(),p->GetPz(),ZFMS,p->GetVz()));
41  float y=fabs(projectFMS(p->GetPy(),p->GetPz(),ZFMS,p->GetVz()));
42  //LOG_INFO << Form("x=%f y=%f",x,y)<<endm;
43  if(x<XMINFMS && y<XMINFMS) return 0;
44  if(x>XMAXFMS || y>XMAXFMS) return 0;
45  return 1;
46 }
47 
48 ClassImp(StFmsFastSimMaker);
49 
50 StFmsFastSimMaker::StFmsFastSimMaker(const Char_t* name):StMaker(name),mPrint(0) {}
51 
52 StFmsFastSimMaker::~StFmsFastSimMaker(){}
53 
54 Int_t StFmsFastSimMaker::Init(){
55  return kStOK;
56 }
57 
58 void StFmsFastSimMaker::Clear(Option_t *option){
59  int n=mRealPi0.size();
60  for(int i=0; i<n; i++) delete mRealPi0[i];
61  mRealPi0.clear();
62 }
63 
64 Float_t StFmsFastSimMaker::hadronResponse(float e, float &f){
65  static TRandom2 RND;
66  if(e<0.3) {f=1.0; return e;}
67  f=0.3/e;
68  if(RND.Rndm()<0.5) {
69  return 0.3;
70  }else{
71  while(f<=0.3/e || f>0.95) f = RND.Gaus()*0.3 + 0.35;
72  return e*f;
73  }
74 }
75 
77  StarPrimaryMaker* primary=(StarPrimaryMaker*)GetMaker("PrimaryMaker");
78  if(!primary) {LOG_INFO << "StFmsFastSimMaker cannot find PrimaryMaker"<<endm; return kStErr;}
79  StarGenEvent* pevent = primary->event();
80  if(!pevent) {LOG_INFO << "StFmsFastSimMaker cannot find PrimaryMaker->event"<<endm; return kStErr;}
81 
82  StEvent* stEvent = (StEvent*) GetInputDS("StEvent");
83  if(!stEvent){
84  stEvent = new StEvent();
85  AddData(stEvent);
86  }
87  StFmsCollection* fmsColl = new StFmsCollection();
88  stEvent->setFmsCollection(fmsColl);
89  StSPtrVecFmsPoint& points = fmsColl->points();
90 
91  int n=pevent->GetNumberOfParticles();
92  float etot=0.0, emeas=0.0;
93  for(int j=0; j<n; j++){
94  StarGenParticle *p = (*pevent)[j];
95  int flag=0;
96  int pid=p->GetId();
97  int stat=p->GetStatus();
98  float f=1.0;
99  float hadres=0.0;
100  if(fmsAcceptance(p)==0) {
101  flag=1;
102  }else if(pid==111){ //pi0
103  mRealPi0.push_back(new StLorentzVectorF(p->GetPx(),p->GetPy(),p->GetPz(),p->GetEnergy()));
104  flag=2;
105  }else if(stat==1){
106  float ene=p->GetEnergy();
107  if(abs(pid)==22 || abs(pid)==11){ //photon & electron
108  StFmsPoint* point = new StFmsPoint();
109  point->setId(j);
110  point->setEnergy(ene);
111  point->setFourMomentum(StLorentzVectorF(p->GetPx(),p->GetPy(),p->GetPz(),ene));
112  points.push_back(point);
113  etot+=ene;
114  emeas+=ene;
115  flag=3;
116  }else if(abs(pid)==211 || abs(pid)==321 || abs(pid)==2212 || abs(pid)==2112){
117  // /*
118  StFmsPoint* point = new StFmsPoint();
119  hadres = hadronResponse(ene,f);
120  point->setId(j);
121  point->setEnergy(hadres);
122  point->setFourMomentum(StLorentzVectorF(f*p->GetPx(),f*p->GetPy(),f*p->GetPz(),hadres));
123  points.push_back(point);
124  etot+=ene;
125  emeas+=hadres;
126  // */
127  flag=4;
128  }else{
129  etot+=ene;
130  flag=5;
131  }
132  }else{
133  flag=6;
134  }
135  if(flag==1 || flag==6) continue;
136  if(flag>0 && mPrint>1) {
137  cout << Form("%3d Pid=%5d Stat=%3d m=%8.3f p=%7.3f %7.3f %7.3f eta=%6.2f e=%7.2f meas=%7.2f zvtx=%7.2f",
138  j,pid,stat,p->GetMass(),p->GetPx(),p->GetPy(),p->GetPz(),
139  p->momentum().PseudoRapidity(),
140  p->GetEnergy(), f*p->GetEnergy(), p->GetVz());
141  switch(flag){
142  case 1: cout << " Not heading to FMS" << endl; break;
143  case 2: cout << " pi0" << endl; break;
144  case 3: cout << " photon/electron" << endl; break;
145  case 4: cout << Form(" pi/K/P/N f=%4.2f",f) << endl; break;
146  case 5: cout << " Something else pid=" << pid << endl; break;
147  case 6: cout << " Unstable" << endl; break;
148  default: cout << endl;
149  }
150  }
151  }
152 
153  //sort real pi0 in pT order
154  std::sort(mRealPi0.begin(), mRealPi0.end(), [](StLorentzVectorF* a, StLorentzVectorF* b) {
155  return b->perp() < a->perp();
156  });
157 
158  //merging points
159 
160  int np=fmsColl->numberOfPoints();
161  LOG_INFO << Form("Etot=%f Emeasured=%f Created %d StFmsPoints, and NRealPi0=%d",etot,emeas,np,mRealPi0.size()) << endm;
162 
163  return kStOK;
164 }
Float_t GetVz()
Get the z-component of the start vertex.
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
Definition: StMaker.cxx:332
Int_t GetNumberOfParticles()
Obtain the number of particles in the event record.
Definition: StarGenEvent.h:187
Yet another particle class.
Int_t GetStatus()
Get the status code of the particle according to the HEPEVT standard.
Float_t GetPz()
Get the z-component of the momentum.
Float_t GetEnergy()
Get the energy.
void Clear(Option_t *option="")
User defined functions.
Int_t GetId()
Get the id code of the particle according to the PDG standard.
Float_t GetPx()
Get the x-component of the momentum.
TLorentzVector momentum()
Return the 4-momentum of the particle.
Float_t GetPy()
Get the y-component of the momentum.
Base class for event records.
Definition: StarGenEvent.h:81
StarGenEvent * event()
Return a pointer to the event.
Definition: Stypes.h:40
Main steering class for event generation.
Definition: Stypes.h:44
Float_t GetMass()
Get the mass.