StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMcOutputMaker.cxx
1 //*-- Author :Weihong He
2 //
3 // $Id: StMcOutputMaker.cxx,v 1.3 2011/04/11 19:35:41 fisyak Exp $
4 #include <TH2.h>
5 
6 #include "StMcOutputMaker.h"
7 #include "StChain.h"
8 #include "St_DataSetIter.h"
9 #include "StMcEventMaker/StMcEventMaker.h"
10 #include "StMcEvent/StMcEvent.hh"
11 #include "StMcEvent/StMcVertex.hh"
12 #include "StMcEvent/StMcTrack.hh"
13 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
14 //MuDst
15 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
16 #include "StMuDSTMaker/COMMON/StMuDst.h"
17 #include "StMuDSTMaker/COMMON/StMuTrack.h"
18 
19 #include "StarClassLibrary/StParticleDefinition.hh"
20 
21 
22 
23 ClassImp(StMcOutputMaker)
24 
25 
26 StMcOutputMaker::StMcOutputMaker(const char *name):StMaker(name){
27  memset(hA,0,sizeof(hA));
28  HList=0;
29  geomE= new EEmcGeomSimple();
30 
31 }
32 
33 
34 StMcOutputMaker::~StMcOutputMaker(){
35  //
36 }
37 
38 
39 //_____________________________________________________________________________
40 //
41 Int_t
42 StMcOutputMaker::Init(){
43 
44 
45  memset(hA,0,sizeof(hA));
46  hA[0]=new TH2F("gEEmcEtaPhi", "Generated pi0 track; phi / deg;EEmc Eta",360,-180.,180,20,1.,2.);
47  //hA[1]=new TH2F("rEtaPhi", "Recon pi0; track eta; phi / deg",20,0.5,2.5,20,0,90);
48  hA[1]=new TH1F("gPt", "Generated pi0 Pt ",50,0.,25.);
49  hA[2]=new TH1F("gEta", "Generated pi0 eta ",50,0.,2.5);
50  hA[3]=new TH1F("gEnergy","generated Mc pi0 energy",80,0.,80.);
51  hA[4]=new TH1F("gZgg","generated Mc pi0 energy sharing",100,0.,1.);
52  hA[5]=new TH1F("gZgg01","generated Mc pi0 energy sharing[5,10]",100,0.,1.);
53  hA[6]=new TH1F("gZgg02","generated Mc pi0 energy sharing[10,15]",100,0.,1.);
54  hA[7]=new TH1F("gZgg03","generated Mc pi0 energy sharing[15,20]",100,0.,1.);
55  hA[8]=new TH1F("gZgg04","generated Mc pi0 energy sharing[20,30]",100,0.,1.);
56  hA[9]=new TH1F("gZgg05","generated Mc pi0 energy sharing[30,60]",100,0.,1.);
57  hA[10]=new TH1F("gPhi", "Generated pi0 Phi ",360,-180.,180.);
58  hA[11]=new TH1F("gEEmcEta", "Generated pi0 eta in EEMC ",50,0.,2.5);
59  hA[12]=new TH1F("DeltaEta", "genEta - EEmcEta ",40,-2.,2.);
60  hA[13]=new TH1F("gZvert", "generated Z vertex ",300,-150.,150.);
61  //hA[3]=new TH1F("rEta", "Recon pi0 eta ",40,0.5,2.5);
62  //hA[4]=new TH1F("rNP", "nFitPoints, Recon pi0; nFitP ",50,-0.5,49.5);
63  //hA[5]=new TH1F("rrpt", "Pt resolution, ptGen=6 GeV ; gen-reco/gen",100,-0.5,0.5);
64 
65  assert(HList);
66  int i;
67  for(i=0;i<mxHa;i++) if(hA[i]) HList->Add(hA[i]);
68 
69  return StMaker::Init();
70 }
71 
72 //________________________________________________
73 //________________________________________________
74 void
75 StMcOutputMaker::Clear(const Option_t*){
76  gTr.clear();
77  geemcEta.clear();
78  genZZ.clear();
79  genXX.clear();
80  genYY.clear();
81 }
82 
83 //________________________________________________
84 //________________________________________________
85 Int_t
87  //
88  //PrintInfo();
89  //
90  int fflag=0;
91  float hlow=270.0*tan(15.0*3.14159265/180.0);
92  float hhigh=270.0*tan(40.0*3.14159265/180.0);
93  //std::cout<<"hlow="<<hlow<<"hhigh="<<hhigh<<std::endl;
94 
95 
96  probTr= StLorentzVectorF();
97 
98  // **************************************
99  // get pointer to mcEventMaker, Event *
100  // **************************************
101  StMcEvent* mMcEvent = 0;
102  mMcEvent = (StMcEvent*) StMaker::GetChain()->GetDataSet("StMcEvent");
103  assert(mMcEvent);
104 
105  //#if 0
106  //StMcVertex* PV= mMcEvent-> primaryVertex();
107  //printf("%s:: nPrimV=%p\n", GetName(), (void*)V);
108  //assert(PV);
109  //int nPD=PV-> numberOfDaughters();
110  //#endif
111  //printf("n prim Doughters=%d\n",nPD);
112  //all vertices
113  const StSPtrVecMcVertex &VL=mMcEvent->vertices();
114  //printf("%s::nVert=%d\n",GetName(),VL.size());
115  // int ipr=1;
116  UInt_t i;
117  zgg=0;
118  for( i=0;i<VL.size();i++) {
119  StMcVertex* V=VL[i];
120 
121  // Rxy vx z vertex to remove fake electrons
122  float x=V->position().x();
123  float y=V->position().y();
124  float zz=V->position().z();
125  float Rxy=TMath::Sqrt(x*x+y*y);
126 
127  //printf("vx=%f,vy=%f,vz=%f Rxy=%f\n",x,y,z,Rxy);
128  //cout<<*V<<endl<<endl;
129  int nD=V-> numberOfDaughters();
130  //cout <<Form("#daughters=%d\n",nD)<<endl;
131  for(int it=0; it<nD;it++ ) {
132  StMcTrack* tr=V->daughter(it);
133  int gid=tr->geantId();
134  if(gid!=7)
135  {continue;}
136  float hHeight=0.0;
137  StLorentzVectorF p4=tr->fourMomentum();
138  float psRap=tr->pseudoRapidity();
139  if( psRap<0 || psRap>3.) continue; // reject sputnik-muons
140  // cout<<*tr<<endl;
141  probTr=p4;
142  float ppt=p4.perp();
143  if(ppt<=3.0) continue;
144  float ppz=p4.pz();
145  hHeight=ppt*(270.0-zz)/ppz+Rxy;
146 
147  if(hHeight<=hlow || hHeight >=hhigh) continue;
148  fflag++;
149  float etatheta=TMath::ATan(hHeight/270.0);
150  //printf("theta=%f etatheta=%f\n",p4.theta(), etatheta);
151  float mideta=tan(etatheta/2.0);
152  float eemceta=-log(mideta);
153  //printf("geta=%f eemceta=%f zv=%f\n",tr->pseudoRapidity(),eemceta,zz);
154  //printf(" GEANT prob: gid=%d E/GeV=%.1f theta/deg=%.1f phi/deg=%.1f eta=%.2f\n",gid,p4.e(),p4.theta()/3.1416*180,p4.phi()/3.1416*180 ,tr->pseudoRapidity());
155  hA[0]->Fill(p4.phi()/3.1416*180,eemceta);
156  hA[2]->Fill(tr->pseudoRapidity());
157  hA[10]->Fill(p4.phi()/3.1416*180);
158  hA[1]->Fill(p4.perp());
159  hA[3]->Fill(p4.e());
160  hA[11]->Fill(eemceta);
161  hA[12]->Fill(tr->pseudoRapidity()-eemceta);
162  hA[13]->Fill(zz);
163  //printf("eta=%f eta2=%f\n",p4.pseudoRapidity(),tr->pseudoRapidity());
164  genE=0;
165  genEta=0;
166  genPhi=0;
167  if(p4.e()>=0)
168  {
169  genEta=tr->pseudoRapidity();
170  genE=p4.e();
171  genPhi=p4.phi()/3.1416*180;
172  }
173  gTr.push_back(tr);
174  geemcEta.push_back(eemceta);
175  genZZ.push_back(zz);
176  genXX.push_back(x);
177  genYY.push_back(y);
178  //printf("zvertex=%f pt=%f pz=%f height=%f size=%d\n",zz,ppt,ppz,hHeight,gTr.size());
179  }
180  if(nD==2)
181  {
182  StMcTrack* tr1=V->daughter(0);
183  int geid1=tr1->geantId();
184  StMcTrack* tr2=V->daughter(1);
185  int geid2=tr2->geantId();
186  float Etot=0,Edif=0;
187  if((geid1==1)&&(geid2==1))
188  {
189  for(int it=0; it<nD;it++ ) { // primary tracks
190  StMcTrack* tr=V->daughter(it);
191  //int geid=tr->geantId();
192  //float phi=tr->momentum().phi();
193  //float eta=tr->pseudoRapidity();
194  //float pt=tr->pt();
195  float ener=tr->fourMomentum().e();
196  //printf("geid=%d eta=%f phi=%f pt=%f e=%f\n",geid,eta,phi,pt,ener);
197  Etot+=ener;
198  Edif=ener-Edif;
199  }
200  zgg=fabs(Edif)/Etot;
201  //printf("zgg=%f\n",zgg);
202  hA[4]->Fill(zgg);
203  if(Etot>=5.0 && Etot<=10.0)
204  {
205  hA[5]->Fill(zgg);
206  }
207  if(Etot>=10.0 && Etot<=15.0)
208  {
209  hA[6]->Fill(zgg);
210  }
211  if(Etot>=15.0 && Etot<=20.0)
212  {
213  hA[7]->Fill(zgg);
214  }
215  if(Etot>=20.0 && Etot<=30.0)
216  {
217  hA[8]->Fill(zgg);
218  }
219  if(Etot>=30.0 && Etot<=60.0)
220  {
221  hA[9]->Fill(zgg);
222  }
223  }
224  }
225  }
226  // printf("x=%f,y=%f,z=%f,Rxy=%f\n",x,y,z,Rxy);
227 
228  //printf("found %d pi0\n",gTr.size());
229  return kStOK;
230 }
231 
232 
233 
234 
235 
236 
237 
238 
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
Definition: StMcTrack.hh:144
virtual Int_t Make()
EEMC simple geometry.
Definition: Stypes.h:40
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...
Definition: StMcEvent.hh:169