9 #include "StGeant2LcpTreeMaker.h"
12 #include "TClonesArray.h"
14 #include "StEventInfo.h"
15 #include "StMuDSTMaker/COMMON/StMuEvent.h"
16 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
18 #include "St_DataSet.h"
19 #include "St_DataSetIter.h"
20 #include "tables/St_g2t_event_Table.h"
21 #include "tables/St_particle_Table.h"
23 #include "StMuDSTMaker/COMMON/StMuTrack.h"
43 StGeant2LcpTreeMaker::~StGeant2LcpTreeMaker(){
44 if(tree) tree->Print();
54 Int_t StGeant2LcpTreeMaker::Init(){
56 return StMaker::Init();
62 void StGeant2LcpTreeMaker::clearLCP(){
63 lcp_eta=lcp_phi=lcp_pt=lcp_e=0;
69 void StGeant2LcpTreeMaker::InitRunFromMake (
int runNumber){
70 if(runID==runNumber) return ;
71 if(runID==888999) return ;
75 printf(
"\n\n FATAL %s::InitRunFromMake() runID=%d changed to %d, (not implemented),STOP \n",
GetName(),runID,runNumber);
76 assert(runID==runNumber);
83 treeName+=
".tree.root";
85 printf(
"%s::Init() \n runID=%d Setup output tree & histo to '%s' , CUTS: maxEta=%.2f minPt/GeV/c=%.2f\n",
GetName(),runID,treeName.Data(),C_maxEta,C_minPt);
87 hfile=
new TFile(treeName,
"RECREATE",
" histograms & trees with LCP ");
88 assert(hfile->IsOpen());
96 h[5] =
new TH1F(
"nPKpi",
"No. of stable p,pbar,K+/-,pi+/- with |eta|<1 and pT>0.4",50,-0.5,49.5);
97 h[6] =
new TH1F(
"eta",
"eta of LCP",100,-2.,2.);
99 h[7] =
new TH1F(
"phi",
" phi/rad of LCP", 240,-Pi,Pi);
100 h[8] =
new TH1F(
"pT",
"pT/GeV of LCP",100,0,10.);
107 tree =
new TTree(
"G-LCP",
"LCP selected from Geant data");
108 tree->Branch(
"id", &eve_id,
"id/I");
109 tree->Branch(
"sub", &eve_sub,
"sub/I");
110 tree->Branch(
"nPKPi",&eve_nPKPi,
"nPKPi/I");
111 tree->Branch(
"pt",&lcp_pt ,
"pt/F");
112 tree->Branch(
"phi",&lcp_phi ,
"phi/F");
113 tree->Branch(
"eta",&lcp_eta ,
"eta/F");
114 tree->Branch(
"e", &lcp_e ,
"e/F");
116 printf(
" %s::Init(RunNumber=%d) WARN : TTRee NOT created\n",
GetName(),runID);
130 printf(
"%s::Make() is called ..........\n",
GetName());
137 if(runID>100) InitRunFromMake(info.runId());
139 printf(
" eve ID=%d\n",info.id());
149 St_g2t_event *Pg2t_event=(St_g2t_event *) geantDstI(
"g2t_event");
151 g2t_event_st *g2t_event1=Pg2t_event->GetTable();
152 printf(
"nr=%d \n",(
int)Pg2t_event->GetNRows());
153 int k1= g2t_event1->eg_label;
154 int k2= g2t_event1->n_event;
155 int k3= g2t_event1->subprocess_id;
157 printf(
"eg_label=%d n_event=%d subprocess_id=%d\n", k1,k2,k3);
159 assert(info.id()==g2t_event1->n_event);
161 eve_sub=g2t_event1->subprocess_id;
164 St_particle *particleTabPtr = (St_particle *) geantDstI(
"particle");
166 findGeantLcp( particleTabPtr);
168 if(tree)tree->Fill();
171 printf(
"#%s::Make(%d) nPKPi=%d lcp: pt=%f idHep=%d \n",
GetName(),kEve,eve_nPKPi, lcp_pt,lcp_idhep);
180 void StGeant2LcpTreeMaker::printTrack( particle_st* part) {
181 cout <<
" ist = " << part->isthep;
182 cout <<
" id = " << part->idhep << endl;
183 cout <<
" px = " << part->phep[0];
184 cout <<
" py = " << part->phep[1];
185 cout <<
" pz = " << part->phep[2] << endl;
186 cout <<
" e = " << part->phep[3];
187 cout <<
" m = " << part->phep[4] << endl;
195 particle_st* StGeant2LcpTreeMaker::findGeantLcp( St_particle *tab) {
197 particle_st* part = tab->GetTable();
198 printf(
"tab dim=%d\n", (
int)tab->GetNRows());
204 int ns=0, np=0,n2=0,n3=0,npkpi=0;
205 for(i=0;i<tab->GetNRows();i++) {
206 if(part[i].isthep!=1)
continue;
208 int id=part[i].idhep;
209 int idM=
id>0 ?
id : -id ;
210 if(idM!=211 && idM!=321 && idM!=2212)
continue;
214 float px=part[i].phep[0];
215 float py=part[i].phep[1];
216 float pz=part[i].phep[2];
218 float pt=sqrt(px*px+py*py);
219 if(pt<0.001)
continue;
220 float eta= TMath::ASinH(pz/pt);
224 float phi=atan2(part[i].phep[1],part[i].phep[0]);
225 printf(
"i=%d pT=%f phi/deg=%f eta=%f pz=%f idHep=%d\n",i,pt,phi/3.1416*180,eta,pz,
id);
229 if(pt>0.4 && fabs(eta)<1) npkpi++;
230 if(pt<maxPt)
continue;
233 if(fabs(eta)>maxEta)
continue;
242 printf(
"#total %3d stable particles, np=%3d n2=%3d n3=%3d maxPt=%f iMax=%d eta=%f npkpi=%d\n",ns,np,n2,n3,maxPt,iMax,etaI,npkpi);
245 h[5]->Fill( eve_nPKPi);
248 printTrack(part+iMax);
250 lcp_phi=atan2(part[iMax].phep[1],part[iMax].phep[0]);
252 lcp_idhep=part[iMax].idhep;
253 lcp_e=part[iMax].phep[3];
This commented block at the top ...
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
virtual const char * GetName() const
special overload