ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/Selection/src/applySelection.cc
(Generate patch)

Comparing UserCode/MitHzz4l/Selection/src/applySelection.cc (file contents):
Revision 1.3 by khahn, Wed Sep 14 21:43:21 2011 UTC vs.
Revision 1.10 by dkralph, Sun Oct 23 11:52:41 2011 UTC

# Line 37 | Line 37 | using namespace std;
37   #include "TElectron.hh"
38   #include "TMuon.hh"
39   #include "TJet.hh"
40 + #include "SiMVAElectronSelection.h"
41   #include "RunLumiRangeMap.h"
42  
43   //
# Line 46 | Line 47 | using namespace std;
47   #include "SampleWeight.h"
48   #include "Selection.h"
49   #include "HZZCiCElectronSelection.h"
50 + #include "HZZLikelihoodElectronSelection.h"
51 + #include "HZZBDTElectronSelection.h"
52   #include "SampleWeight.h"
53  
54 + //#define BDTFAIL_THEIR_EVENTS
55   //#define THEIR_EVENTS
56  
57   //=== MAIN =================================================================================================
# Line 72 | Line 76 | int main(int argc, char** argv)
76    }
77    ctrl.dump();
78  
79 +  map<string,double> entrymap; // number of unskimmed entries in each file
80 +
81    //
82    // File I/O
83    //--------------------------------------------------------------------------------------------------------------
# Line 79 | Line 85 | int main(int argc, char** argv)
85    ifstream f(ctrl.inputfile.c_str());
86    string fname;
87    while (f >> fname) {
88 <    if( !(strncmp( fname.c_str(), "#", 1 ) ) ) continue; // skip commented lines  
88 >    if( !(strncmp( fname.c_str(), "#", 1 ) ) ) continue; // skip commented lines
89      cout << "adding inputfile : " << fname.c_str() << endl;
90 +    entrymap[string(fname.c_str())] = unskimmedEntries(fname.c_str());
91      chain->AddFile(fname.c_str());
92    }
93  
# Line 90 | Line 97 | int main(int argc, char** argv)
97    //
98    // Setup
99    //--------------------------------------------------------------------------------------------------------------
100 +  const char * ofname;
101 +  if( strcmp( ctrl.outputfile.c_str(), "") ) {
102 +    ofname = ctrl.outputfile.c_str();
103 +  } else {
104 +    ofname = "tmp.root";
105 +  }
106 +  TFile *file = new TFile(ofname, "RECREATE");
107    TH1F * h_evt = new TH1F("hevt", "hevt", 2, 0, 2 );
108 <  TH1F * h_evtfail = new TH1F("hevtfail", "hevtfail", 1024, 0, 1024 );
109 <  TNtuple * passtuple = new TNtuple( "passtuple", "passtuple", "run:evt:lumi:channel:mZ1:mZ2:m4l:pt4l:w" );
108 >  TH1F * h_evtfail = new TH1F("hevtfail", "hevtfail", 1024, 0, 1024 );
109 >  //  TNtuple * passtuple = new TNtuple( "passtuple", "passtuple", "run:evt:lumi:channel:mZ1:mZ2:m4l:pt4l:w" );
110 >  TTree * passtuple = new TTree("passtuple", "passtuple" );
111 >  unsigned run, evt, lumi, channel;
112 >  float mZ1, mZ2, m4l, pt4l;
113 >  unsigned tZ1, tZ2;
114 >  double w;
115 >  passtuple->Branch("run", &run);
116 >  passtuple->Branch("evt", &evt);
117 >  passtuple->Branch("lumi", &lumi);
118 >  passtuple->Branch("mZ1", &mZ1);
119 >  passtuple->Branch("mZ2", &mZ2);
120 >  passtuple->Branch("tZ1", &tZ1);
121 >  passtuple->Branch("tZ2", &tZ2);
122 >  passtuple->Branch("m4l", &m4l);
123 >  passtuple->Branch("pt4l", &pt4l);
124 >  passtuple->Branch("w", &w);
125    initCiCSelection();
126 +  if(ctrl.eleSele=="lik") initLikSelection();
127 +  if(ctrl.eleSele=="bdt") initBDTSelection();
128 +  // if(ctrl.eleSele=="si" ) initSiMVAElectronSelection();
129    initRunLumiRangeMap();
130  
99
131    //
132    // Loop
133    //--------------------------------------------------------------------------------------------------------------
134 +  if(ctrl.fakeScheme!="none") {cout << "wrong executable!" << endl; assert(0);}
135    
136    //
137    // Access samples and fill histograms
# Line 126 | Line 158 | int main(int argc, char** argv)
158    chain->SetBranchAddress("Muon", &muonArr);
159  
160  
161 <
161 >  int count=0, pass=0;
162    cout << "nEntries: " << chain->GetEntries() << endl;
163 <  for(UInt_t ientry=0; ientry<chain->GetEntries(); ientry++) {          
164 <    
163 >  cerr << "nEntries: " << chain->GetEntries() << endl;
164 >  UInt_t imax = chain->GetEntries();
165 >  for(UInt_t ientry=0; ientry<imax; ientry++) {
166      chain->GetEntry(ientry);
167 +    if(!(ientry%100000)) cerr << "entry: " << ientry << endl;
168  
169      // get event weight for this file                                                    
170 <    double xs=1,eventweight=1;                                                            
171 <    if(ctrl.mc) eventweight = xstab.Get(getname(chain).c_str()) / chain->GetEntries();    
170 >    double eventweight=1;
171 >    if(ctrl.mc) eventweight = getWeight(xstab,entrymap,chain);
172  
173   #ifdef THEIR_EVENTS
174      if( !( info->evtNum == 504867308  ||
175             info->evtNum == 368148849  ||
176 <           info->evtNum == 129514273  ||
176 >           //      info->evtNum == 129514273  ||
177             info->evtNum == 286336207  ||
178             info->evtNum == 344708580  ||
179             info->evtNum == 30998576   ||
# Line 147 | Line 181 | int main(int argc, char** argv)
181             info->evtNum == 394010457  ||
182             info->evtNum == 917379387  ||
183             info->evtNum == 78213037   ||
184 <           info->evtNum == 337493970  ||
184 >           info->evtNum == 862270386  ||
185 >           info->evtNum == 337493970  ||  // not baseline anymore?
186             info->evtNum == 1491724484 ||
187             info->evtNum == 480301165  ||
188             info->evtNum == 1038911933 ||
# Line 158 | Line 193 | int main(int argc, char** argv)
193             info->evtNum == 191231387  ||
194             info->evtNum == 66033190   ||
195             info->evtNum == 10347106   ||
196 <           info->evtNum == 107360878  ) ) continue;
196 >           info->evtNum == 107360878  ||
197 >           info->evtNum == 2554393033 ||
198 >           info->evtNum == 933807102  ||
199 >           info->evtNum == 1188043146 ||
200 >           info->evtNum == 559839432  ||
201 >           info->evtNum == 16706390   ||
202 >           info->evtNum == 65557571   ||
203 >           info->evtNum == 389185367  ||
204 >           info->evtNum == 2722114329 ) ) continue;
205   #endif
206 +
207 +
208 + #ifdef BDTFAIL_THEIR_EVENTS
209 +    if( !( info->evtNum == 78213037   ||
210 +           info->evtNum == 876658967  ) ) continue;
211 +          
212 + #endif
213 +
214 +    unsigned evtfail = fails_HZZ4L_selection(ctrl, info, electronArr, muonArr, eventweight, passtuple);
215  
216 <    unsigned evtfail = fails_HZZ4L_selection(ctrl, info, electronArr, muonArr, eventweight, passtuple );    
216 > #ifdef THEIR_EVENTS
217 >    if(evtfail!=0) cout << "Failed!" << endl;
218 > #endif
219 >    
220      h_evtfail->Fill( evtfail, eventweight );
221 <    cout << endl << endl;  
221 >
222 >    count++;
223 >    if( !evtfail ) pass++;
224            
225    } //end loop over data    
226  
227 <
227 >  if( ctrl.mc ) {
228 >    cout << "--------------" << endl;
229 >    cout << "denom: " << count << endl;
230 >    cout << "pass: " << pass << endl;
231 >    cout << "axe: " << (float)pass/count << endl;
232 >    cout << "--------------" << endl;
233 >  }
234  
235    delete info;
236    delete electronArr;
# Line 178 | Line 241 | int main(int argc, char** argv)
241    //--------------------------------------------------------------------------------------------------------------
242    // Save Histograms;
243    //==============================================================================================================
244 <  const char * ofname;
245 <  if( strcmp( ctrl.outputfile.c_str(), "") ) {
246 <    ofname = ctrl.outputfile.c_str();
247 <  } else {
248 <    ofname = "tmp.root";
249 <  }
244 >  // const char * ofname;
245 >  // if( strcmp( ctrl.outputfile.c_str(), "") ) {
246 >  //   ofname = ctrl.outputfile.c_str();
247 >  // } else {
248 >  //   ofname = "tmp.root";
249 >  // }
250  
251 <  TFile *file = new TFile(ofname, "RECREATE");
251 >  // TFile *file = new TFile(ofname, "RECREATE");
252 >  gROOT->cd(file->GetPath());
253    h_evt->Write();
254    h_evtfail->Write();
255    passtuple->Write();
256    file->Close();
257    delete file;
258  
259 +  // map<TString,TMVA::Reader*>::iterator it;
260 +  // for(it=readers.begin(); it!=readers.end(); it++) delete (*it).second;
261 +
262    cerr << "done!" << endl;
263   }
264  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines