readNtuple.C
Go to the documentation of this file.
1 #define readNtuple_cxx
2 #include "readNtuple.h"
3 #include <TH2.h>
4 #include <TStyle.h>
5 #include <TCanvas.h>
6 #include "TLorentzVector.h"
7 #include <iostream>
8 #include "TH3F.h"
9 #include "TProfile.h"
10 #include "TProfile2D.h"
11 #include "TTree.h"
12 #include "string.h"
13 
14 using namespace std;
15 using namespace TMVA;
16 
17 void readNtuple::Loop(const char* TypeNameOut)
18 {
19  if (fChain == 0) return;
20 
21  Int_t nentries = fChain->GetEntries();
22  cout<<"Total events are "<<nentries<<endl;
23 
24  int Nevts=0;
25  int Ngood=0;
26  int Nbad=0;
27  double pot_total=0.;
28  double pot_good=0.;
29  double pot_bad=0.;
30 
31  double pot_nonslip=0.;
32  double pot_slip=0.;
33 
34  double pot_cuts[4]={0.};
35  TString cutnames[4]={"Total","beam quality","spill quality","POT/spill>22E12"};
36 
37  for( int ii=0; ii<nentries; ii++)
38  {
39  fChain->GetEntry(ii);
40  ++Nevts;
41  if( Nevts%100000==0 ) cout<<Nevts<<" processed ..."<<endl;
42 
43  pot_cuts[0] += spillPOT;
44 
45 /*
46  if( horncurrent<-202 || horncurrent>-198 ) continue;
47  if( posX<0.02 || posX>2. ) continue;
48  if( posY<0.02 || posY>2. ) continue;
49  if( widthX<0.57 || widthX>1.58 ) continue;
50  if( widthY<0.57 || widthY>1.58 ) continue;
51  if( spillPOT<2. ) continue;
52 */
53  pot_cuts[1] += spillPOT;
54  if( Ndeaddcm > 0 ) continue;//no dead dcm
55  pot_cuts[2] += spillPOT;
56 /*
57  if( runnum <= 10799 && spillPOT>26. ) continue;
58  if( runnum >= 10801 && spillPOT<26. ) continue;
59 */
60 
61  myhists->potspill->Fill(spillPOT);
62  myhists->nslices->Fill(Nslices);
63  myhists->nslices_potspill->Fill(spillPOT,Nslices);
64  myhists->nslices_potspill_th2f->Fill(spillPOT,Nslices);
65 
66  if( spillPOT<22. ) continue;
67  pot_cuts[3] += spillPOT;
68 
69 // if( runnum <= 10799 ) myhists->potspill_nonslip->Fill(spillPOT);
70 // if( runnum >= 10801 ) myhists->potspill_slip->Fill(spillPOT);
71 
72  myhists->nslices_good->Fill(Nslices);
73 
74 // if( runnum <= 10799 ) pot_nonslip += spillPOT;
75 // if( runnum >= 10801 ) pot_slip += spillPOT;
76 
77  pot_total += spillPOT;
78 
79  if( goodSpill ){
80  ++Ngood;
81  pot_good += spillPOT;
82  }
83  else {
84  ++Nbad;
85  pot_bad += spillPOT;
86  }
87 
88  }//loop all events
89 
90  cout<<"*** check goodbeam flag ***"<<endl;
91  cout<<"Total spill is "<<Nevts<<endl;
92  cout<<"Good spill is "<<Ngood<<endl;
93  cout<<"Bad spill is "<<Nbad<<endl;
94  cout<<"Total POT is "<<pot_total<<endl;
95  cout<<"Good POT is "<<pot_good<<endl;
96  cout<<"Bad POT is "<<pot_bad<<endl;
97  cout<<"***************************"<<endl;
98  cout<<endl;
99  cout<<"POT for different cuts: "<<endl;
100  for( int i=0; i<4; ++i )
101  cout<<cutnames[i]<<": "<<pot_cuts[i]<<"E12"<<endl;
102 
103  cout<<"Total POT for non-slip-stacked "<<pot_nonslip<<endl;
104  cout<<"Total POT for slip-stacked "<<pot_slip<<endl;
105 }
106 
const std::string cutnames[ncuts]
Long64_t nentries
TChain * fChain
OStream cout
Definition: OStream.cxx:6
Definition: tmvaglob.h:28
virtual void Loop(const char *TypeNameNu, const char *TypeNameInt)
Definition: readNtuple.C:18