00001 #include <TMultiGraph.h>
00002 #include <TStyle.h>
00003 #include <TMinuit.h>
00004 #include <TTree.h>
00005 #include <TF1.h>
00006 #include <TFile.h>
00007 #include <TCanvas.h>
00008 #include <TVector3.h>
00009 #include <Riostream.h>
00010 #include <TMath.h>
00011
00012 #include <StEmcPool/StPhotonCommon/MyEvent.h>
00013 #include <StEmcPool/StPhotonCommon/MyPoint.h>
00014
00015
00016 #include "GainAnalysis.h"
00017
00018 ClassImp(GainAnalysis)
00019
00020 GainAnalysis::GainAnalysis(const char *psout,const char * )
00021 {
00022 gStyle->SetOptDate(0);
00023 ps=new TPostScript(psout,-111);
00024 cout<<"DEFAULT CONSTRUCTOR FOR PI0ANALYSIS!!!!"<<endl;
00025 cout<<"storing ps in: "<<psout<<endl;
00026 }
00027 GainAnalysis::~GainAnalysis()
00028 {
00029 cout<<endl<<"GainAnalysis destructed!"<<endl<<endl;
00030 }
00031 Int_t GainAnalysis::init(const char *output)
00032 {
00033
00034 mFileOut=new TFile(output,"RECREATE");
00035 h_minvPt=new TH2F("h_minvPt","invariant mass vs pT",40,0.,10.,200,0.,1.);
00036 h_minvId=new TH2F("h_minvId","inv. mass vs ID",2400,0.5,2400.5,200,0.,1.);
00037
00038 return 1;
00039 }
00040 Int_t GainAnalysis::make(Int_t evmax,const char *input)
00041 {
00042 mFile=new TFile(input,"OPEN");
00043 myEventTree=(TTree*)mFile->Get("mEventTree");
00044 ev=new MyEvent();
00045 myEventTree->SetBranchAddress("branch",&ev);
00046
00047 Int_t i=0;
00048 while(myEventTree->GetEntry(i)){
00049 if(evmax&&i>evmax){
00050 cout<<"reached evmax,"<<endl;
00051 cout<<"abort loop!"<<endl;
00052 break;
00053 }
00054 if(i%100000==0) cout<<"processing "<<input<<" evt: "<<i<<endl;
00055
00056 TVector3 vPos=ev->vertex();
00057
00058 if(!(ev->trigger()&1)&&!(ev->trigger()&8)){
00059 i++;
00060 continue;
00061 }
00062
00063 if(TMath::Abs(vPos.Z())<0.0000001 || TMath::Abs(vPos.Z())>50.){
00064 i++;
00065 continue;
00066 }
00067
00068 MyPoint *p;
00069 MyPoint *pp;
00070 TClonesArray *clA=(TClonesArray*)ev->getPointArray();
00071 for(Int_t j=0;j<clA->GetEntries();j++){
00072 p=(MyPoint*)clA->At(j);
00073 TVector3 pPos=p->position();
00074 TVector3 pMom=pPos - vPos;
00075 pMom.SetMag(p->energy());
00076
00077 if(!isPointOK(p)) continue;
00078
00079 for(Int_t jj=0;jj<clA->GetEntries();jj++){
00080 if(jj<=j) continue;
00081 pp=(MyPoint*)clA->At(jj);
00082 TVector3 ppPos=pp->position();
00083 TVector3 ppMom=ppPos - vPos;
00084 ppMom.SetMag(pp->energy());
00085
00086 if(!isPointOK(pp)) continue;
00087
00088
00089 TVector3 pi0Mom=pMom+ppMom;
00090 Float_t angle=pMom.Angle(ppMom);
00091
00092
00093
00094
00095 Float_t minv=TMath::Sqrt(2.*p->energy()*pp->energy()*(1. - TMath::Cos(angle)));
00096 Float_t pTpion=pi0Mom.Pt();
00097
00098 if(ev->trigger()&1||ev->trigger()&8){
00099
00100
00101 Int_t ID=0;
00102 Float_t EN=0.;
00103 for(Int_t i_id=0;i_id<4;i_id++){
00104 if(p->towerClusterEnergy(i_id)>EN){
00105 EN=p->towerClusterEnergy(i_id);
00106 ID=p-> towerClusterId(i_id);
00107 }
00108 }
00109
00110 Int_t ID2=0;
00111 Float_t EN2=0.;
00112 for(Int_t i_id=0;i_id<4;i_id++){
00113 if(pp->towerClusterEnergy(i_id)>EN2){
00114 EN2=p->towerClusterEnergy(i_id);
00115 ID2=p-> towerClusterId(i_id);
00116 }
00117 }
00118
00119
00120
00121 h_minvPt->Fill(pTpion,minv);
00122 if(pTpion>.75){
00123 h_minvId->Fill(ID,minv);
00124 if(ID!=ID2) h_minvId->Fill(ID2,minv);
00125 }
00126 }
00127
00128
00129 }
00130 }
00131
00132
00133 i++;
00134 }
00135
00136 return 1;
00137 }
00138 Bool_t GainAnalysis::isPointOK(MyPoint *p)
00139 {
00140 Bool_t ret=kTRUE;
00141 if(p->nHitsEta()<1 && p->nHitsPhi()<1) ret=kFALSE;
00142 return ret;
00143 }
00144
00145
00146 Int_t GainAnalysis::finish()
00147 {
00148 mFileOut->Write();
00149
00150 return 1;
00151 }