StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
readPi02.C
1 //This macro reads into the EEMC pi0 trees with an input directory, and produce an output root file. Users can design their output accordingly.
2 //Author: Weihong He
3 
4 class StChain;
6 class StEEmcIUMixEvent;
7 
8 StChain *chain = 0;
9 StEEmcIUPi0Reader *reader = 0;
10 StEEmcIUMixEvent *realEvent = 0;
11 
12 Long64_t nevents = 0;
13 
14 
15 
16 void readPi02(Int_t nevents=-1,
17  const Char_t *mydir="/star/institutions/iucf/hew/7863/7136033/",
18  const Char_t *ofile="/star/u/hew/pionCVS/7136033.root")
19 {
20 
21  const Double_t ptbins[]={0.0,2.5,4.5,5.5,6.5,8.5,10.5,14.5,20.0};
22  Int_t nptbins=sizeof(ptbins)/sizeof(Double_t) - 1;
23 
24  TFile *file=new TFile(ofile,"RECREATE");
25  hEtavsMass = new TH2F("hEtavsMass","Detector #eta of #pi^{0} candidates vs Mass;Mass; #eta",120,0.,1.2,180,1.,2.5);
26  hPhivsMass = new TH2F("hPhivsMass","#Phi of #pi^{0} candidates vs Mass; Mass, #Phi",120,0.,1.2,360,-180.,180.);
27  hPhi= new TH1F("hPhi","#Phi",30,0.,30.);
28  hPhiEta1= new TH1F("hPhiEta1","#Phi with #eta at [1.089,1.268)",30,0.,30.);
29  hPhiEta2= new TH1F("hPhiEta2","#Phi with #eta at [1.268,1.476)",30,0.,30.);
30  hPhiEta3= new TH1F("hPhiEta3","#Phi with #eta at [1.476,1.718)",30,0.,30.);
31  hPhiEta4= new TH1F("hPhiEta4","#Phi with #eta at [1.718,2.000)",30,0.,30.);
32  hZggPt= new TH2F("hZggPt","Pi0 Zgg vs Pt;pT[Gev/c];Zgg",50,0.,25.,50,0.,1.);
33  // load shared libraries
34  LoadLibs();
35 
36  // create analysis chain
37  chain = new StChain("chain");
38 
39  // add the pi0 reader and add all root files in specified directory
40  reader = new StEEmcIUPi0Reader();
41  chainFiles(mydir);
42 
43  nevents = reader->getNumberOfEvents();
44 
45  chain->ls(3);
46  chain->Init();
47 
48  Int_t stat = 0;
49  Int_t event = 0;
50  while ( !stat )
51  {
52 
53  if ( nevents>=0 )
54  if ( event>=nevents ) break;
55 
56  chain -> Clear();
57  stat = chain->Make();
58 
59  realEvent = reader->event();
60 
61  Int_t nPairs = reader -> event() -> nPairs;
62  for ( Int_t i=0;i<nPairs;i++ )
63  {
64 
65  Float_t mass = reader->event()->mMass[i];
66  Float_t pt = reader->event()->mPT[i];
67  Float_t zgg = reader->event()->mZgg[i];
68  Float_t meta = reader->event()->mEEmcEta[i];
69  Float_t mphi = reader->event()->mPhi[i];
70 
71  hEtavsMass->Fill(mass,meta);
72  hPhivsMass->Fill(mass,mphi*180./3.14159265);
73  Int_t mod_phi=int(mphi*180./3.14159265+180.)%30;
74  hPhi->Fill(mod_phi);
75  if(meta>=1.089 && meta<1.268) hPhiEta1->Fill(mod_phi);
76  if(meta>=1.268 && meta<1.476) hPhiEta2->Fill(mod_phi);
77  if(meta>=1.476 && meta<1.718) hPhiEta3->Fill(mod_phi);
78  if(meta>=1.718 && meta<2.) hPhiEta4->Fill(mod_phi);
79 
80 
81  Float_t diff = realEvent->mEsmdu[i] - realEvent->mEsmdv[i];
82  Float_t sum = realEvent->mEsmdu[i] + realEvent->mEsmdv[i];
83  Float_t zuv = TMath::Abs(diff)/sum;
84 
85 
86  }
87  event++;
88 
89 
90 
91  }
92 
93  file->cd();
94  hEtavsMass->Write();
95  hPhivsMass->Write();
96  hPhi->Write();
97  hPhiEta1->Write();
98  hPhiEta2->Write();
99  hPhiEta3->Write();
100  hPhiEta4->Write();
101  hZggPt->Write();
102  delete file;
103 
104 
105 }
106 // ----------------------------------------------------------------------------
107 void chainFiles(const Char_t *path)
108 {
109 
110  std::cout << "chaining files " << path << std::endl;
111 
112  TSystemDirectory *dir = new TSystemDirectory("dir",path);
113 
114  TIter next( dir->GetListOfFiles() );
115  TObject *file = 0;
116  while ( file = (TObject*)next() )
117  {
118  TString name=file->GetName();
119 
120  if ( name.Contains("root") ) {
121  reader->chainFile(name);
122 
123  }
124 
125  }
126 
127  delete dir;
128 
129 
130 }
131 
132 // ----------------------------------------------------------------------------
133 void LoadLibs()
134 {
135  //-- Load muDst shared libraries --
136  gROOT -> LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
137  loadSharedLibraries();
138 
139  gSystem->Load("StDbLib");
140  gSystem->Load("StDbBroker");
141  gSystem->Load("St_db_Maker");
142  gSystem->Load("StEEmcUtil");
143  gSystem->Load("StEEmcDbMaker");
144  gSystem->Load("StEEmcSimulatorMaker");
145 
146  gSystem->Load("StEEmcA2EMaker");
147  gSystem->Load("StEEmcIUPi0");
148  gSystem->Load("StSpinDbMaker");
149 
150 }
Int_t nPairs
From EEMC point-maker.
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
virtual Int_t Make()
Definition: StChain.cxx:110