StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
GainAnalysis.cxx
1 #include <TMultiGraph.h>
2 #include <TStyle.h>
3 #include <TMinuit.h>
4 #include <TTree.h>
5 #include <TF1.h>
6 #include <TFile.h>
7 #include <TCanvas.h>
8 #include <TVector3.h>
9 #include <Riostream.h>
10 #include <TMath.h>
11 
12 #include <StEmcPool/StPhotonCommon/MyEvent.h>
13 #include <StEmcPool/StPhotonCommon/MyPoint.h>
14 //#include <StEmcPool/StPhotonCommon/MyMcTrack.h>
15 
16 #include "GainAnalysis.h"
17 using namespace std;
18 
19 ClassImp(GainAnalysis)
20 
21 GainAnalysis::GainAnalysis(const char *psout,const char * /*flag*/)
22 {
23  gStyle->SetOptDate(0);
24  ps=new TPostScript(psout,-111);
25  cout<<"DEFAULT CONSTRUCTOR FOR PI0ANALYSIS!!!!"<<endl;
26  cout<<"storing ps in: "<<psout<<endl;
27 }
28 GainAnalysis::~GainAnalysis()
29 {
30  cout<<endl<<"GainAnalysis destructed!"<<endl<<endl;
31 }
32 Int_t GainAnalysis::init(const char *output)
33 {
34 
35  mFileOut=new TFile(output,"RECREATE");
36  h_minvPt=new TH2F("h_minvPt","invariant mass vs pT",40,0.,10.,200,0.,1.);
37  h_minvId=new TH2F("h_minvId","inv. mass vs ID",2400,0.5,2400.5,200,0.,1.);
38 
39  return 1;
40 }
41 Int_t GainAnalysis::make(Int_t evmax,const char *input)
42 {
43  mFile=new TFile(input,"OPEN");
44  myEventTree=(TTree*)mFile->Get("mEventTree");
45  ev=new MyEvent();
46  myEventTree->SetBranchAddress("branch",&ev);
47 
48  Int_t i=0;
49  while(myEventTree->GetEntry(i)){
50  if(evmax&&i>evmax){
51  cout<<"reached evmax,"<<endl;
52  cout<<"abort loop!"<<endl;
53  break;
54  }
55  if(i%100000==0) cout<<"processing "<<input<<" evt: "<<i<<endl;
56 
57  TVector3 vPos=ev->vertex();
58  //just mb:
59  if(!(ev->trigger()&1)&&!(ev->trigger()&8)){
60  i++;
61  continue;
62  }
63  //select vertex:
64  if(TMath::Abs(vPos.Z())<0.0000001 || TMath::Abs(vPos.Z())>50.){
65  i++;
66  continue;
67  }
68  //loop on points
69  MyPoint *p;
70  MyPoint *pp;
71  TClonesArray *clA=(TClonesArray*)ev->getPointArray();
72  for(Int_t j=0;j<clA->GetEntries();j++){
73  p=(MyPoint*)clA->At(j);
74  TVector3 pPos=p->position();
75  TVector3 pMom=pPos - vPos;
76  pMom.SetMag(p->energy());
77 
78  if(!isPointOK(p)) continue;
79 
80  for(Int_t jj=0;jj<clA->GetEntries();jj++){
81  if(jj<=j) continue;
82  pp=(MyPoint*)clA->At(jj);
83  TVector3 ppPos=pp->position();
84  TVector3 ppMom=ppPos - vPos;
85  ppMom.SetMag(pp->energy());
86 
87  if(!isPointOK(pp)) continue;
88 
89  //two neutrals
90  TVector3 pi0Mom=pMom+ppMom;
91  Float_t angle=pMom.Angle(ppMom);
92 
93 
94  //Float_t Epion=p->energy()+pp->energy();
95  //Float_t asymm=TMath::Abs(p->energy()-pp->energy())/Epion;
96  Float_t minv=TMath::Sqrt(2.*p->energy()*pp->energy()*(1. - TMath::Cos(angle)));
97  Float_t pTpion=pi0Mom.Pt();
98 
99  if(ev->trigger()&1||ev->trigger()&8){
100 
101  //get id:
102  Int_t ID=0;
103  Float_t EN=0.;
104  for(Int_t i_id=0;i_id<4;i_id++){
105  if(p->towerClusterEnergy(i_id)>EN){
106  EN=p->towerClusterEnergy(i_id);
107  ID=p-> towerClusterId(i_id);
108  }
109  }
110  //get id2:
111  Int_t ID2=0;
112  Float_t EN2=0.;
113  for(Int_t i_id=0;i_id<4;i_id++){
114  if(pp->towerClusterEnergy(i_id)>EN2){
115  EN2=p->towerClusterEnergy(i_id);
116  ID2=p-> towerClusterId(i_id);
117  }
118  }
119 
120  //if(asymm>0.7) continue;
121 
122  h_minvPt->Fill(pTpion,minv);
123  if(pTpion>.75){
124  h_minvId->Fill(ID,minv);
125  if(ID!=ID2) h_minvId->Fill(ID2,minv);
126  }
127  }
128 
129 
130  }
131  }
132 
133 
134  i++;
135  }
136 
137  return 1;
138 }
139 Bool_t GainAnalysis::isPointOK(MyPoint *p)
140 {
141  Bool_t ret=kTRUE;
142  if(p->nHitsEta()<1 && p->nHitsPhi()<1) ret=kFALSE;
143  return ret;
144 }
145 
146 
147 Int_t GainAnalysis::finish()
148 {
149  mFileOut->Write();
150 
151  return 1;
152 }
Definition: MyPoint.h:7