Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:00

0001 {
0002 gSystem->Load("libFWCoreFWLite.so");
0003 FWLiteEnabler::enable();
0004 TFile file("RefittedTracks.root");
0005 /////////SET THESE VALUES///////////////
0006 float intervals[] = {0,0.8,1.4,2.0,2.5};
0007 int bins = 4;
0008 ////////////////////////////////////////
0009 vector<float> ptrms;
0010 vector<float> effic;
0011 TTree * tree = (TTree *) gROOT->FindObject("Events");
0012 TFile outFile("refitgraphs.root","recreate");
0013 
0014 string title, title2;
0015 for (int i=1;i<(bins+1);i++){
0016   cout << i << endl;
0017   ostringstream str0, str1, str2, str3;
0018   str1 <<"ptres"<<intervals[i];
0019   title=str1.str();
0020   str0 <<"Pt residue (Tracks&refTracks) 4.99<Pt<5.01 "<< intervals[i-1] << "<eta<"<<intervals[i];
0021   title2=str0.str();
0022   TH1F ptres2(title.c_str(),title2.c_str(),100,-0.5,0.5);
0023   str2 << "recoTracks_TrackProducer__Refit.obj.pt()-recoTracks_TrackRefitter__Refit.obj.pt() >> " << title;
0024   str3 << "fabs(EmbdSimTracks_SimG4Object__test.obj.momentum().pseudoRapidity())>"<< intervals[i-1] <<"&&fabs(EmbdSimTracks_SimG4Object__test.obj.momentum().pseudoRapidity())<"<<intervals[i];
0025   tree->Draw(str2.str().c_str(),str3.str().c_str(),"goff");
0026   ptrms.push_back(ptres2.GetRMS());
0027   ptres2.Write();
0028 
0029   str0.str("");
0030   str1.str("");
0031   str2.str("");
0032   str3.str("");
0033   str1 <<"missingtracks_vs_eta"<<intervals[i];
0034   title=str1.str();
0035   str0 <<"(Missing RefittedTracks)/(Tracks) 4.99<Pt<5.01 "<< intervals[i-1] << "<eta<"<<intervals[i];
0036   title2=str0.str();
0037   str3 << "fabs(EmbdSimTracks_SimG4Object__test.obj.momentum().pseudoRapidity())>"<< intervals[i-1] <<"&&fabs(EmbdSimTracks_SimG4Object__test.obj.momentum().pseudoRapidity())<"<<intervals[i];
0038   //str3 << intervals[i-1]<<"<fabs(EmbdSimTracks_SimG4Object__test.obj.momentum().pseudoRapidity())<"<<intervals[i];
0039   ostringstream str4, str5;
0040   str4 << "generatedtracks_vs_eta" << intervals[i];
0041   str5 << "EmbdSimTracks_SimG4Object__test.@obj.size() >> " << str4.str();
0042   TH1F prod(str4.str().c_str(),str4.str().c_str(),10,0,10);
0043   tree->Draw(str5.str().c_str(),str3.str().c_str(),"goff");
0044   float tot=prod.GetEntries(); 
0045   str2 << "(recoTracks_TrackProducer__Refit.@obj.size()-recoTracks_TrackRefitter__Refit.@obj.size()) >> " << title;
0046   TH1F eff(title.c_str(),title2.c_str(),3,-1.5,1.5);
0047   tree->Draw(str2.str().c_str(),str3.str().c_str(),"goff");
0048   if (tot!=0) eff.Scale(1/tot);
0049 //   cout <<  eff.GetBinContent(eff.FindBin(0)) << endl;
0050   effic.push_back( eff.GetBinContent( eff.FindBin(0) ) );
0051   eff.Write();
0052 }
0053 
0054 TH1F  ptres("ptres_distrib",  "Pt residue (Tracks&refTracks) 4.99<Pt<5.01",100,-0.0001,0.0001);
0055 tree->Draw("recoTracks_TrackProducer__Refit.obj.pt()-recoTracks_TrackRefitter__Refit.obj.pt() >> ptres_distrib","","goff");
0056 TH1F etares("etaresidue_distrib","Eta residue (Tracks&refTracks) 4.99<Pt<5.01",100,-0.00001,0.00001);
0057 tree->Draw("recoTracks_TrackProducer__Refit.obj.eta()-recoTracks_TrackRefitter__Refit.obj.eta() >> etaresidue_distrib","","goff");
0058 TH1F chi2histo("chi2_distrib","NChi2 distribution (refTracks) 4.99<Pt<5.01",100,0,10);
0059 tree->Draw("recoTracks_TrackRefitter__Refit.obj.normalizedChi2() >> chi2_distrib","","goff");
0060 // TH1F  ptresV("ptres_distrib_noinvalid",  "Pt residue (Tracks&refTracks) 4.99<Pt<5.01 Tracks without invalid hits",100,-0.0004,0.0004);
0061 TH1F  ptresV("ptres_distrib_noinvalid",  "Pt residue (Tracks&refTracks) 4.99<Pt<5.01 Tracks without invalid hits",100,-0.03,0.03);
0062 tree->Draw("recoTracks_TrackProducer__Refit.obj.pt()-recoTracks_TrackRefitter__Refit.obj.pt() >> ptres_distrib_noinvalid","(recoTracks_TrackProducer__Refit.obj.invalid_-recoTracks_TrackRefitter__Refit.obj.invalid_)==0","goff");
0063 TH1F  ptresI("ptres_distrib_invalid",  "Pt residue (Tracks&refTracks) 4.99<Pt<5.01 Tracks with invalid hits",100,-0.03,0.03);
0064 tree->Draw("recoTracks_TrackProducer__Refit.obj.pt()-recoTracks_TrackRefitter__Refit.obj.pt() >> ptres_distrib_invalid","(recoTracks_TrackProducer__Refit.obj.invalid_-recoTracks_TrackRefitter__Refit.obj.invalid_)!=0","goff");
0065 TH1F  found("found_hits",  "Found Hits difference (Tracks-refTracks) 4.99<Pt<5.01",10,-5,5);
0066 tree->Draw("recoTracks_TrackProducer__Refit.obj.found_-recoTracks_TrackRefitter__Refit.obj.found_ >> found_hits","","goff");
0067 TH1F  invalid("invalid_hits",  "Invalid Hits difference (Tracks-refTracks) 4.99<Pt<5.01",10,-5,5);
0068 tree->Draw("recoTracks_TrackProducer__Refit.obj.invalid_-recoTracks_TrackRefitter__Refit.obj.invalid_ >> invalid_hits","","goff");
0069 
0070 TH1F ptrmsh("PtRMS_vs_eta","PtRMS vs eta (Tracks&refTracks) 4.99<Pt<5.01",bins,intervals);
0071 TH1F effh("eff_vs_eta","efficiency vs eta (refTracks) 4.99<Pt<5.01",bins,intervals);
0072 //TH1F ptrmsh("ptrmsh","ptrmsh",3,0,2.5);
0073 float binfix=0.0001;
0074 for (int i=1;i<(bins+1);i++){
0075   ptrmsh.Fill(intervals[i]-binfix,ptrms[i-1]);
0076   effh.Fill(intervals[i]-binfix,effic[i-1]);
0077 }
0078 // ptresI.SetLineColor(2);
0079 // ptresI.GetYaxis().SetRangeUser(0,1000);
0080 // ptresI.Draw();
0081 // ptresV.Draw("SAME");
0082 // TLegend * ll = new TLegend(0.6,0.6,0.89,0.79);
0083 // ll->AddEntry("ptres_distrib_invalid","track with invalid hit","L");
0084 // ll->AddEntry("ptres_distrib_valid"  ,"track without invalid hit","L");
0085 // ll->Draw();
0086 
0087 // ptres.Write();
0088 // ptresV.Write();
0089 // ptresI.Write();
0090 // etares.Write();
0091 // ptrmsh.Write();
0092 // effh.Write();
0093 // chi2histo.Write();
0094 // found.Write();
0095 // invalid.Write();
0096 // outFile.Close();
0097 }