Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:32:23

0001 #include <TFile.h>
0002 
0003 int loadme  = gSystem->Load("libRooFit.so");
0004 int loadme2 = gSystem->Load("libPhysicsToolsFWLite.so");
0005 #include "PhysicsTools/FWLite/interface/Scanner.h"
0006 
0007 void testScanner_CINT() {
0008     gROOT->SetStyle ("Plain");
0009     gStyle->SetPalette(1);
0010     gStyle->SetHistMinimumZero(1);
0011 
0012     fwlite::Event ev(gFile);
0013     fwlite::Scanner<std::vector<reco::Track> > sc(&ev, "generalTracks");
0014 
0015     TCanvas *c1 = new TCanvas("c1", "c1");
0016     sc.scan("pt:eta","quality('highPurity')",2);
0017   
0018     sc.setMaxEvents(200); 
0019     double c = sc.count("quality('highPurity')");
0020     std::cout << "Found " << c << " highPurity tracks." << std::endl;
0021     double ce = sc.countEvents();
0022     std::cout << "Found " << ce << " events." << std::endl;
0023 
0024     TH1 *heta = sc.draw("eta");
0025     heta->Sumw2(); heta->Scale(1.0/sc.countEvents());
0026     c1->Print("eta.png");
0027     heta->SetLineColor(kBlue);
0028     TH1 *hp = sc.draw("eta", "quality('highPurity')", "SAME");
0029     hp->Sumw2(); hp->Scale(1.0/sc.countEvents());
0030     c1->Print("eta_and_hp.png");
0031 
0032     TH1 *hb = sc.draw("pt", "abs(eta)<1 && pt < 5", "", "hbarrel");
0033     TH1 *he = sc.draw("pt", "abs(eta)>1 && pt < 5", "", "hendcaps");
0034     hb->Draw();
0035     c1->Print("barrel_1.png");
0036     hbarrel->Draw();
0037     c1->Print("barrel_2.png");
0038     he->Draw();
0039     c1->Print("endcaps_1.png");
0040     hendcaps->Draw();
0041     c1->Print("endcaps_2.png");
0042 
0043     hb = sc.draw("pt", "abs(eta)<1 && pt < 5", "NORM");
0044     hb->SetLineColor(2);
0045     c1->Print("normalized_pt.png");
0046     he = sc.draw("pt", "abs(eta)>1 && pt < 5", "NORM SAME");
0047     he->SetLineColor(4);
0048     c1->Print("normalized_pts.png");
0049 
0050     sc.draw("eta", 5, -2.5, 2.5);
0051     c1->Print("eta_binned.png");
0052 
0053     double etabins[4] = { -2.5, -1, 1, 2.5 };
0054     sc.draw("eta", 3, etabins, "quality('loose')");
0055     c1->Print("eta_specialbins.png");
0056 
0057     TProfile *p = sc.drawProf("eta", 5, -2.5, 2.5, "pt",  "quality('loose')");
0058     p->SetLineColor(kRed);
0059     c1->Print("eta_prof_pt.png");
0060 
0061     sc.drawProf("eta", "pt", "quality('highPurity')", "SAME");
0062     c1->Print("eta_prof_pt_same.png");
0063 
0064     sc.draw2D("pt", 5, 0, 5, "eta", 4, -2.5, 2.5, "quality('highPurity')", "COLZ");
0065     c1->Print("pt_eta_2d_manual.png");
0066     sc.draw2D("pt", "eta", "quality('highPurity') && pt <= 5", "COLZ");
0067     c1->Print("pt_eta_2d_auto.png");
0068 
0069     TGraph *g = sc.drawGraph("pt","eta", "quality('highPurity') && pt <= 5");
0070     g->SetMarkerStyle(8);
0071     c1->Print("pt_eta_2d_graph.png");
0072 
0073     // Now make dN/deta only for events that have two tracks with |eta|<1, pt > 500 MeV
0074     fwlite::ObjectCountSelector<vector<reco::Track> > ntracks("generalTracks","","", "pt > 0.5 && abs(eta)<1", 2);
0075     sc.addEventSelector(&ntracks);
0076     TH1 *heta2 = sc.draw("eta",5,-2.5,2.5);
0077     heta2->Sumw2(); heta2->Scale(1.0/sc.countEvents()); heta2->SetLineColor(4);
0078     ntracks.setMin(0);
0079     heta = sc.draw("eta","","SAME");
0080     heta->Sumw2(); heta->Scale(1.0/sc.countEvents());
0081     c1->Print("eta_twotracks.png");
0082 
0083     sc.setMaxEvents(20); 
0084     RooDataSet *ds = sc.fillDataSet("pt:eta:@hits=hitPattern.numberOfValidHits", "@highPurity=quality('highPurity'):@highPt=pt>2", "pt > 0.5");
0085     ds->Print("v");
0086     delete ds;
0087 }