ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/benhoob/HWW/Classify_HWW.C
(Generate patch)

Comparing UserCode/benhoob/HWW/Classify_HWW.C (file contents):
Revision 1.1 by benhoob, Thu Feb 10 13:40:34 2011 UTC vs.
Revision 1.3 by benhoob, Mon Feb 14 12:49:15 2011 UTC

# Line 139 | Line 139 | void Classify_HWW( TString myMethodList
139  
140    vector<char*> samples;
141    samples.push_back("WWTo2L2Nu");
142 <  //   samples.push_back("GluGluToWWTo4L");
143 <  //   samples.push_back("WZ");
144 <  //   samples.push_back("ZZ");
145 <  //   samples.push_back("TTJets");
146 <  //   samples.push_back("tW");
147 <  //   samples.push_back("WJetsToLNu");
148 <  //   samples.push_back("DY");
149 <  //   samples.push_back("Higgs130");
142 >  samples.push_back("GluGluToWWTo4L");
143 >  samples.push_back("WZ");
144 >  samples.push_back("ZZ");
145 >  samples.push_back("TTJets");
146 >  samples.push_back("tW");
147 >  samples.push_back("WJetsToLNu");
148 >  samples.push_back("DY");
149 >  samples.push_back("Higgs130");
150    //   samples.push_back("Higgs160");
151    //   samples.push_back("Higgs200");
152  
# Line 192 | Line 192 | void Classify_HWW( TString myMethodList
192  
193      // --- Book the MVA methods
194  
195 +    //--------------------------------------------------------------------------------------
196 +    // tell Classify_HWW where to find the weights dir, which contains the trained MVA's.
197 +    // In this example, the weights dir is located at [path]/[dir]
198 +    // and the output root file is written to [path]/[output]
199 +    //--------------------------------------------------------------------------------------
200 +
201      //TString dir    = "weights/";
202 <    TString path   = "Trainings/H130_WWTo2L2Nu/";
202 >    //TString path   = "Trainings/H130_WWTo2L2Nu/";
203 >    //TString path   = "Trainings/H130_WWTo2L2Nu_WJetsToLNu/";
204 >    TString path   = "Trainings/H130_allbkg/";
205      TString dir    = path + "weights/";
206      TString outdir = path + "output/";
207  
# Line 209 | Line 217 | void Classify_HWW( TString myMethodList
217      }
218    
219      // Book output histograms
220 <    UInt_t nbin = 100;
220 >    UInt_t nbin = 1000;
221      TH1F   *histLk(0), *histLkD(0), *histLkPCA(0), *histLkKDE(0), *histLkMIX(0), *histPD(0), *histPDD(0);
222      TH1F   *histPDPCA(0), *histPDEFoam(0), *histPDEFoamErr(0), *histPDEFoamSig(0), *histKNN(0), *histHm(0);
223      TH1F   *histFi(0), *histFiG(0), *histFiB(0), *histLD(0), *histNn(0),*histNnbfgs(0),*histNnbnn(0);
# Line 265 | Line 273 | void Classify_HWW( TString myMethodList
273      // in this example, there is a toy tree with signal and one with background events
274      // we'll later on use only the "signal" events for the test in this example.
275      //  
268    //    TFile *input(0);
269    //    TString fname = "./tmva_example.root";  
270    //    if (!gSystem->AccessPathName( fname ))
271    //       input = TFile::Open( fname ); // check if file in local directory exists
272    //    else    
273    //       input = TFile::Open( "http://root.cern.ch/files/tmva_class_example.root" ); // if not: download from ROOT server
274  
275    //    if (!input) {
276    //       std::cout << "ERROR: could not open data file" << std::endl;
277    //       exit(1);
278    //    }
279    //    std::cout << "--- TMVAClassificationApp    : Using input file: " << input->GetName() << std::endl;
280  
276  
277 <    char* iter = "v2";
277 >    char* prefix = "babies/v3";
278      TChain *ch = new TChain("Events");
279  
280      if( strcmp( samples.at(i) , "DY" ) == 0 ){
281 <      ch -> Add( Form("babies/%s/DYToMuMuM20_PU_testFinal_baby.root",iter) );
282 <      ch -> Add( Form("babies/%s/DYToMuMuM10To20_PU_testFinal_baby.root",iter) );
283 <      ch -> Add( Form("babies/%s/DYToEEM20_PU_testFinal_baby.root",iter) );
284 <      ch -> Add( Form("babies/%s/DYToEEM10To20_PU_testFinal_baby.root",iter) );
285 <      ch -> Add( Form("babies/%s/DYToTauTauM20_PU_testFinal_baby.root",iter) );
286 <      ch -> Add( Form("babies/%s/DYToTauTauM10To20_PU_testFinal_baby.root",iter) );
281 >      ch -> Add( Form("%s/DYToMuMuM20_PU_testFinal_baby.root",prefix) );
282 >      ch -> Add( Form("%s/DYToMuMuM10To20_PU_testFinal_baby.root",prefix) );
283 >      ch -> Add( Form("%s/DYToEEM20_PU_testFinal_baby.root",prefix) );
284 >      ch -> Add( Form("%s/DYToEEM10To20_PU_testFinal_baby.root",prefix) );
285 >      ch -> Add( Form("%s/DYToTauTauM20_PU_testFinal_baby.root",prefix) );
286 >      ch -> Add( Form("%s/DYToTauTauM10To20_PU_testFinal_baby.root",prefix) );
287      }
288      else if( strcmp( samples.at(i) , "Higgs130" ) == 0 ){
289 <      ch -> Add( Form("babies/%s/HToWWTo2L2NuM130_PU_testFinal_baby.root",iter) );
290 <      ch -> Add( Form("babies/%s/HToWWToLNuTauNuM130_PU_testFinal_baby.root",iter) );
291 <      ch -> Add( Form("babies/%s/HToWWTo2Tau2NuM130_PU_testFinal_baby.root",iter) );
289 >      ch -> Add( Form("%s/HToWWTo2L2NuM130_PU_testFinal_baby.root",prefix) );
290 >      ch -> Add( Form("%s/HToWWToLNuTauNuM130_PU_testFinal_baby.root",prefix) );
291 >      ch -> Add( Form("%s/HToWWTo2Tau2NuM130_PU_testFinal_baby.root",prefix) );
292      }
293      else if( strcmp( samples.at(i) , "Higgs160" ) == 0 ){
294 <      ch -> Add( Form("babies/%s/HToWWTo2L2NuM160_PU_testFinal_baby.root",iter) );
295 <      ch -> Add( Form("babies/%s/HToWWToLNuTauNuM160_PU_testFinal_baby.root",iter) );
296 <      ch -> Add( Form("babies/%s/HToWWTo2Tau2NuM160_PU_testFinal_baby.root",iter) );
294 >      ch -> Add( Form("%s/HToWWTo2L2NuM160_PU_testFinal_baby.root",prefix) );
295 >      ch -> Add( Form("%s/HToWWToLNuTauNuM160_PU_testFinal_baby.root",prefix) );
296 >      ch -> Add( Form("%s/HToWWTo2Tau2NuM160_PU_testFinal_baby.root",prefix) );
297      }
298      else if( strcmp( samples.at(i) , "Higgs200" ) == 0 ){
299 <      ch -> Add( Form("babies/%s/HToWWTo2L2NuM200_PU_testFinal_baby.root",iter) );
300 <      ch -> Add( Form("babies/%s/HToWWToLNuTauNuM200_PU_testFinal_baby.root",iter) );
301 <      ch -> Add( Form("babies/%s/HToWWTo2Tau2NuM200_PU_testFinal_baby.root",iter) );
299 >      ch -> Add( Form("%s/HToWWTo2L2NuM200_PU_testFinal_baby.root",prefix) );
300 >      ch -> Add( Form("%s/HToWWToLNuTauNuM200_PU_testFinal_baby.root",prefix) );
301 >      ch -> Add( Form("%s/HToWWTo2Tau2NuM200_PU_testFinal_baby.root",prefix) );
302      }
303      else{
304 <      ch -> Add( Form("babies/%s/%s_PU_testFinal_baby.root",iter,samples.at(i)) );
304 >      ch -> Add( Form("%s/%s_PU_testFinal_baby.root",prefix,samples.at(i)) );
305      }
306  
307  
313    //    TChain *chbackground = new TChain("Events");
314    //    if( sample == "WW" ) chbackground->Add(Form("babies/%s/WWTo2L2Nu_PU_testFinal_baby.root",iter));
315    //    chbackground->Add(Form("babies/%s/GluGluToWWTo4L_PU_testFinal_baby.root",iter));
316    //    chbackground->Add(Form("babies/%s/WZ_PU_testFinal_baby.root",iter));
317    //    chbackground->Add(Form("babies/%s/ZZ_PU_testFinal_baby.root",iter));
318    //    chbackground->Add(Form("babies/%s/TTJets_PU_testFinal_baby.root",iter));
319    //    chbackground->Add(Form("babies/%s/tW_PU_testFinal_baby.root",iter));
320    //    chbackground->Add(Form("babies/%s/WJetsToLNu_PU_testFinal_baby.root",iter));
321    //    chbackground->Add(Form("babies/%s/DYToMuMuM20_PU_testFinal_baby.root",iter) );
322    //    chbackground->Add(Form("babies/%s/DYToMuMuM10To20_PU_testFinal_baby.root",iter) );
323    //    chbackground->Add(Form("babies/%s/DYToEEM20_PU_testFinal_baby.root",iter) );
324    //    chbackground->Add(Form("babies/%s/DYToEEM10To20_PU_testFinal_baby.root",iter) );
325    //    chbackground->Add(Form("babies/%s/DYToTauTauM20_PU_testFinal_baby.root",iter) );
326    //    chbackground->Add(Form("babies/%s/DYToTauTauM10To20_PU_testFinal_baby.root",iter) );
327
328    //    int mH = 130;
329    //    //int mH = 160;
330    //    //int mH = 200;
331
332    //    TChain *chsignal = new TChain("Events");
333
334    //    if( mH == 130 ){
335    //      chsignal->Add(Form("babies/%s/HToWWTo2L2NuM130_PU_testFinal_baby.root",iter));
336    //      chsignal->Add(Form("babies/%s/HToWWToLNuTauNuM130_PU_testFinal_baby.root",iter));
337    //      chsignal->Add(Form("babies/%s/HToWWTo2Tau2NuM130_PU_testFinal_baby.root",iter));
338    //    }
339    //    else if( mH == 160 ){
340    //      chsignal->Add(Form("babies/%s/HToWWTo2L2NuM160_PU_testFinal_baby.root",iter));
341    //      chsignal->Add(Form("babies/%s/HToWWToLNuTauNuM160_PU_testFinal_baby.root",iter));
342    //      chsignal->Add(Form("babies/%s/HToWWTo2Tau2NuM160_PU_testFinal_baby.root",iter));
343    //    }
344    //    else if( mH == 200 ){
345    //      chsignal->Add(Form("babies/%s/HToWWTo2L2NuM200_PU_testFinal_baby.root",iter));
346    //      chsignal->Add(Form("babies/%s/HToWWToLNuTauNuM200_PU_testFinal_baby.root",iter));
347    //      chsignal->Add(Form("babies/%s/HToWWTo2Tau2NuM200_PU_testFinal_baby.root",iter));
348    //    }
349    //    else{
350    //      std::cout << "Error, unrecognized higgs mass " << mH << " GeV, quitting" << std::endl;
351    //      exit(0);
352    //}
353
354
355
308  
309      // --- Event loop
310  
# Line 362 | Line 314 | void Classify_HWW( TString myMethodList
314      //   but of course you can use different ones and copy the values inside the event loop
315      //
316    
365  
366
367
368    //    TTree* theTree = (TTree*)input->Get("TreeS");
369    //    Float_t userVar1, userVar2;
370    //    theTree->SetBranchAddress( "var1", &userVar1 );
371    //    theTree->SetBranchAddress( "var2", &userVar2 );
372    //    theTree->SetBranchAddress( "var3", &var3 );
373    //    theTree->SetBranchAddress( "var4", &var4 );
374
317      TTree *theTree     = (TTree*) ch;
318  
319      std::cout << "--- Using input files: -------------------" <<  std::endl;
# Line 384 | Line 326 | void Classify_HWW( TString myMethodList
326        std::cout << currentFile->GetTitle() << std::endl;
327      }
328  
387    //TTree *theTree     = (TTree*) chsignal;
388    //TTree *theTree     = (TTree*) chbackground;
329      Float_t lephard_pt_;
330      Float_t lepsoft_pt_;
331      Float_t dil_dphi_;
# Line 428 | Line 368 | void Classify_HWW( TString myMethodList
368  
369        theTree->GetEntry(ievt);
370  
371 <      if( event_type_ == 2 && met_projpt_ < 20. )   continue;
372 <      if( event_type_ != 2 && met_projpt_ < 35. )   continue;
371 >      //-------------------------------------------------------
372 >      // event selection
373 >      //-------------------------------------------------------
374 >
375 >      //em
376 >      if( event_type_ == 1 || event_type == 2 ){
377 >        if( met_projpt_ < 20. )   continue;
378 >      }
379 >      //ee/mm
380 >      if( event_type_ == 0 || event_type == 3 ){
381 >        if( met_projpt_ < 35. )   continue;
382 >      }
383 >
384        if( lephard_pt_ < 20.    )                    continue;
385 <      if( lepsoft_pt_ < 10.    )                    continue;
385 >      //if( lepsoft_pt_ < 10.    )                    continue;
386 >      if( lepsoft_pt_ < 20.    )                    continue;
387        if( jets_num_ > 0        )                    continue;
388        if( extralep_num_ > 0    )                    continue;
389        if( lowptbtags_num_ > 0  )                    continue;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines