Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:48

0001 #include "L1Trigger/CSCTrackFinder/test/src/EffHistogramList.h"
0002 #include "L1Trigger/CSCTrackFinder/test/src/TrackHistogramList.h"
0003 #include <TMath.h>
0004 #include <iostream>
0005 
0006 namespace csctf_analysis
0007 {
0008 
0009 EffHistogramList::EffHistogramList(const std::string dirname, const edm::ParameterSet* parameters)
0010 {
0011     TFileDirectory dir = fs->mkdir(dirname);
0012     TFileDirectory ptSubdir = dir.mkdir("Pt_Efficiencies");
0013     TFileDirectory ptSubdirOverall = ptSubdir.mkdir("Overall");
0014     TFileDirectory ptSubdirCSCOnly = ptSubdir.mkdir("CSCOnly");
0015     TFileDirectory ptSubdirCSCRestricted = ptSubdir.mkdir("CSCRestricted");
0016     TFileDirectory ptSubdirDTOnly = ptSubdir.mkdir("DTOnly");
0017     TFileDirectory ptSubdirOverlap = ptSubdir.mkdir("Overlap");
0018     TFileDirectory ptSubdirHighEta = ptSubdir.mkdir("HighEta");
0019     
0020     TFileDirectory etaSubdir = dir.mkdir("Eta_Efficiency");
0021     TFileDirectory phiSubdir = dir.mkdir("Phi_Efficiency");
0022         
0023     double maxpt=parameters->getUntrackedParameter<double>("MaxPtHist");
0024     double minpt=parameters->getUntrackedParameter<double>("MinPtHist");
0025     int ptbins=parameters->getUntrackedParameter<double>("BinsPtHist");
0026     PtEffStatsFilename=parameters->getUntrackedParameter<std::string>("PtEffStatsFilename");
0027     
0028     std::string histoDescription = parameters->getUntrackedParameter<std::string>("HistoDescription");
0029     latexDescription = new TLatex(0.121,0.883,histoDescription.c_str());
0030 
0031     latexDescription->SetTextAlign(13);
0032     latexDescription->SetNDC();
0033 
0034         EffPhi = phiSubdir.make<TH1F>("EffPhi","Efficiency v #phi",144,0,6.283);
0035         EffPhi_mod_10_Q2_endcap1 = phiSubdir.make<TH1F>("EffPhi_mod_10_Q2_endcap1","Efficiency v #phi mod 10,Q>=2, Endcap 1",140,-2,12);
0036         EffPhi_mod_10_Q3_endcap1 = phiSubdir.make<TH1F>("EffPhi_mod_10_Q3_endcap1","Efficiency v #phi mod 10,Q>=3, Endcap 1",140,-2,12);
0037         EffPhi_mod_10_Q2_endcap2 = phiSubdir.make<TH1F>("EffPhi_mod_10_Q2_endcap2","Efficiency v #phi mod 10,Q>=2, Endcap 2",140,-2,12);
0038         EffPhi_mod_10_Q3_endcap2 = phiSubdir.make<TH1F>("EffPhi_mod_10_Q3_endcap2","Efficiency v #phi mod 10,Q>=3, Endcap 2",140,-2,12);
0039         //EffPt = dir.make<TH1F>("EffPt","Efficiency v Pt; 1.2 <= #eta <= 2.1",ptbins, minpt, maxpt);
0040         EffPtDTOnly = ptSubdirDTOnly.make<TH1F>("EffPtDTOnly","Efficiency v Pt; 0<= #eta <=0.9",ptbins, minpt, maxpt);
0041         EffPtCSCOnly = ptSubdirCSCOnly.make<TH1F>("EffPtCSCOnly","Efficiency v Pt; 1.2<= #eta <=2.4",ptbins, minpt, maxpt);
0042         EffPtCSCRestricted = ptSubdirCSCRestricted.make<TH1F>("EffPtCSCRestricted","Efficiency v Pt; 1.2<= #eta <=2.1",ptbins, minpt, maxpt);
0043     EffPtOverall = ptSubdirOverall.make<TH1F>("EffPtOverall","Efficiency v Overall Pt",ptbins, minpt, maxpt);
0044         EffPtOverlap = ptSubdirOverlap.make<TH1F>("EffPtOverlap","Efficiency v Pt; 0.9<= #eta <=1.2",ptbins, minpt, maxpt);
0045         EffPtHighEta = ptSubdirHighEta.make<TH1F>("EffPtHighEta","Efficiency v Pt; 2.1<= #eta",ptbins, minpt, maxpt);
0046         EffTFPt10Overall = ptSubdirOverall.make<TH1F>("EffTFPt10Overall","Efficiency v Overall Pt Tf > 10",ptbins, minpt, maxpt);
0047     EffTFPt12Overall = ptSubdirOverall.make<TH1F>("EffTFPt12Overall","Efficiency v Overall Pt Tf > 12",ptbins, minpt, maxpt);
0048         EffTFPt16Overall = ptSubdirOverall.make<TH1F>("EffTFPt16Overall","Efficiency v Overall Pt Tf > 16",ptbins, minpt, maxpt);
0049     EffTFPt20Overall = ptSubdirOverall.make<TH1F>("EffTFPt20Overall","Efficiency v Overall Pt Tf > 20",ptbins, minpt, maxpt);
0050         EffTFPt40Overall = ptSubdirOverall.make<TH1F>("EffTFPt40Overall","Efficiency v Overall Pt Tf > 40",ptbins, minpt, maxpt);
0051         EffTFPt60Overall = ptSubdirOverall.make<TH1F>("EffTFPt60Overall","Efficiency v Overall Pt Tf > 60",ptbins, minpt, maxpt);
0052         EffTFPt10CSCOnly = ptSubdirCSCOnly.make<TH1F>("EffTFPt10CSCOnly","Efficiency v Pt Tf > 10; 1.2<= #eta <=2.4",ptbins, minpt, maxpt);
0053     EffTFPt12CSCOnly = ptSubdirCSCOnly.make<TH1F>("EffTFPt12CSCOnly","Efficiency v Pt Tf > 12; 1.2<= #eta <=2.4",ptbins, minpt, maxpt);
0054     EffTFPt16CSCOnly = ptSubdirCSCOnly.make<TH1F>("EffTFPt16CSCOnly","Efficiency v Pt Tf > 16; 1.2<= #eta <=2.4",ptbins, minpt, maxpt);
0055         EffTFPt20CSCOnly = ptSubdirCSCOnly.make<TH1F>("EffTFPt20CSCOnly","Efficiency v Pt Tf > 20; 1.2<= #eta <=2.4",ptbins, minpt, maxpt);
0056         EffTFPt40CSCOnly = ptSubdirCSCOnly.make<TH1F>("EffTFPt40CSCOnly","Efficiency v Pt Tf > 40; 1.2<= #eta <=2.4",ptbins, minpt, maxpt);
0057         EffTFPt60CSCOnly = ptSubdirCSCOnly.make<TH1F>("EffTFPt60CSCOnly","Efficiency v Pt Tf > 60; 1.2<= #eta <=2.4",ptbins, minpt, maxpt);
0058         EffTFPt10CSCRestricted = ptSubdirCSCRestricted.make<TH1F>("EffTFPt10CSCRestricted","Efficiency v Pt Tf > 10; 1.2<= #eta <=2.1",ptbins, minpt, maxpt);
0059     EffTFPt12CSCRestricted = ptSubdirCSCRestricted.make<TH1F>("EffTFPt12CSCRestricted","Efficiency v Pt Tf > 12; 1.2<= #eta <=2.1",ptbins, minpt, maxpt);
0060     EffTFPt16CSCRestricted = ptSubdirCSCRestricted.make<TH1F>("EffTFPt16CSCRestricted","Efficiency v Pt Tf > 16; 1.2<= #eta <=2.1",ptbins, minpt, maxpt);
0061         EffTFPt20CSCRestricted = ptSubdirCSCRestricted.make<TH1F>("EffTFPt20CSCRestricted","Efficiency v Pt Tf > 20; 1.2<= #eta <=2.1",ptbins, minpt, maxpt);
0062         EffTFPt40CSCRestricted = ptSubdirCSCRestricted.make<TH1F>("EffTFPt40CSCRestricted","Efficiency v Pt Tf > 40; 1.2<= #eta <=2.1",ptbins, minpt, maxpt);
0063         EffTFPt60CSCRestricted = ptSubdirCSCRestricted.make<TH1F>("EffTFPt60CSCRestricted","Efficiency v Pt Tf > 60; 1.2<= #eta <=2.1",ptbins, minpt, maxpt);
0064         EffTFPt10DTOnly = ptSubdirDTOnly.make<TH1F>("EffTFPt10DTOnly","Efficiency v Pt Tf > 10; 0<= #eta <=0.9",ptbins, minpt, maxpt);
0065     EffTFPt12DTOnly = ptSubdirDTOnly.make<TH1F>("EffTFPt12DTOnly","Efficiency v Pt Tf > 12; 0<= #eta <=0.9",ptbins, minpt, maxpt);
0066     EffTFPt16DTOnly = ptSubdirDTOnly.make<TH1F>("EffTFPt16DTOnly","Efficiency v Pt Tf > 16; 0<= #eta <=0.9",ptbins, minpt, maxpt);
0067         EffTFPt20DTOnly = ptSubdirDTOnly.make<TH1F>("EffTFPt20DTOnly","Efficiency v Pt Tf > 20; 0<= #eta <=0.9",ptbins, minpt, maxpt);
0068         EffTFPt40DTOnly = ptSubdirDTOnly.make<TH1F>("EffTFPt40DTOnly","Efficiency v Pt Tf > 40; 0<= #eta <=0.9",ptbins, minpt, maxpt);
0069         EffTFPt60DTOnly = ptSubdirDTOnly.make<TH1F>("EffTFPt60DTOnly","Efficiency v Pt Tf > 60; 0<= #eta <=0.9",ptbins, minpt, maxpt);
0070         EffTFPt10Overlap = ptSubdirOverlap.make<TH1F>("EffTFPt10Overlap","Efficiency v Pt Tf > 10; 0.9<= #eta <=1.2",ptbins, minpt, maxpt);
0071     EffTFPt12Overlap = ptSubdirOverlap.make<TH1F>("EffTFPt12Overlap","Efficiency v Pt Tf > 12; 0.9<= #eta <=1.2",ptbins, minpt, maxpt);
0072     EffTFPt16Overlap = ptSubdirOverlap.make<TH1F>("EffTFPt16Overlap","Efficiency v Pt Tf > 16; 0.9<= #eta <=1.2",ptbins, minpt, maxpt);
0073         EffTFPt20Overlap = ptSubdirOverlap.make<TH1F>("EffTFPt20Overlap","Efficiency v Pt Tf > 20; 0.9<= #eta <=1.2",ptbins, minpt, maxpt);
0074         EffTFPt40Overlap = ptSubdirOverlap.make<TH1F>("EffTFPt40Overlap","Efficiency v Pt Tf > 40; 0.9<= #eta <=1.2",ptbins, minpt, maxpt);
0075         EffTFPt60Overlap = ptSubdirOverlap.make<TH1F>("EffTFPt60Overlap","Efficiency v Pt Tf > 60; 0.9<= #eta <=1.2",ptbins, minpt, maxpt);
0076 
0077 
0078         EffTFPt10HighEta = ptSubdirHighEta.make<TH1F>("EffTFPt10HighEta","Efficiency v Pt Tf > 10; 2.1<= #eta",ptbins, minpt, maxpt);
0079     EffTFPt12HighEta = ptSubdirHighEta.make<TH1F>("EffTFPt12HighEta","Efficiency v Pt Tf > 12; 2.1<= #eta",ptbins, minpt, maxpt);
0080     EffTFPt16HighEta = ptSubdirHighEta.make<TH1F>("EffTFPt16HighEta","Efficiency v Pt Tf > 16; 2.1<= #eta",ptbins, minpt, maxpt);
0081         EffTFPt20HighEta = ptSubdirHighEta.make<TH1F>("EffTFPt20HighEta","Efficiency v Pt Tf > 20; 2.1<= #eta",ptbins, minpt, maxpt);
0082         EffTFPt40HighEta = ptSubdirHighEta.make<TH1F>("EffTFPt40HighEta","Efficiency v Pt Tf > 40; 2.1<= #eta",ptbins, minpt, maxpt);
0083         EffTFPt60HighEta = ptSubdirHighEta.make<TH1F>("EffTFPt60HighEta","Efficiency v Pt Tf > 60; 2.1<= #eta",ptbins, minpt, maxpt);
0084 
0085 
0086         EffEtaAll = etaSubdir.make<TH1F>("EffEtaAll","Efficiency v eta for all Tracks", 50, 0, 2.5);
0087         EffEtaQ3 = etaSubdir.make<TH1F>("EffEtaQ3","Efficiency v #eta for Quality >= 3 Tracks", 50, 0, 2.5);
0088         EffEtaQ2 = etaSubdir.make<TH1F>("EffEtaQ2","Efficiency v #eta for Quality >= 2 Tracks", 50, 0, 2.5);
0089         EffEtaQ1 = etaSubdir.make<TH1F>("EffEtaQ1","Efficiency v #eta for Quality >= 1 Tracks", 50, 0, 2.5);    
0090         EffSignedEtaAll = etaSubdir.make<TH1F>("EffSignedEtaAll","Efficiency v eta for all Tracks", 100, -2.5, 2.5);
0091         EffSignedEtaQ3 = etaSubdir.make<TH1F>("EffSignedEtaQ3","Efficiency v #eta for Quality >= 3 Tracks", 100, -2.5, 2.5);
0092         EffSignedEtaQ2 = etaSubdir.make<TH1F>("EffSignedEtaQ2","Efficiency v #eta for Quality >= 2 Tracks", 100, -2.5, 2.5);
0093         EffSignedEtaQ1 = etaSubdir.make<TH1F>("EffSignedEtaQ1","Efficiency v #eta for Quality >= 1 Tracks", 100, -2.5, 2.5);    
0094         EffPhiQ3 = phiSubdir.make<TH1F>("EffPhiQ3","Efficiency v #phi for Quality >= 3 Tracks",144,0,6.283);
0095         EffPhiQ2 = phiSubdir.make<TH1F>("EffPhiQ2","Efficiency v #phi for Quality >= 2 Tracks",144,0,6.283);
0096         EffPhiQ1 = phiSubdir.make<TH1F>("EffPhiQ1","Efficiency v #phi for Quality >= 1 Tracks",144,0,6.283);
0097 }
0098 
0099 
0100 void EffHistogramList::ComputeEff(TrackHistogramList* refHists)
0101 {
0102     
0103     divideHistograms(refHists);
0104     
0105 ////////////////////
0106 //// Pt Eff ///////
0107 //////////////////
0108    
0109     //Putting Histograms in vectors for use in later functions
0110     std::vector<TH1F*> Overallhists;
0111     Overallhists.push_back(EffPtOverall);
0112     Overallhists.push_back(EffTFPt12Overall);
0113     Overallhists.push_back(EffTFPt20Overall);
0114     Overallhists.push_back(EffTFPt40Overall);
0115     Overallhists.push_back(EffTFPt60Overall);
0116     
0117     std::vector<TH1F*> CSCOnlyhists;
0118     CSCOnlyhists.push_back(EffPtCSCOnly);
0119     CSCOnlyhists.push_back(EffTFPt12CSCOnly);
0120     CSCOnlyhists.push_back(EffTFPt20CSCOnly);
0121     CSCOnlyhists.push_back(EffTFPt40CSCOnly);
0122     CSCOnlyhists.push_back(EffTFPt60CSCOnly);
0123 
0124     std::vector<TH1F*> CSCRestrictedhists;
0125     CSCRestrictedhists.push_back(EffPtCSCRestricted);
0126     CSCRestrictedhists.push_back(EffTFPt12CSCRestricted);
0127     CSCRestrictedhists.push_back(EffTFPt20CSCRestricted);
0128     CSCRestrictedhists.push_back(EffTFPt40CSCRestricted);
0129     CSCRestrictedhists.push_back(EffTFPt60CSCRestricted);
0130     
0131     std::vector<TH1F*> DTOnlyhists;
0132     DTOnlyhists.push_back(EffPtDTOnly);
0133     DTOnlyhists.push_back(EffTFPt12DTOnly);
0134     DTOnlyhists.push_back(EffTFPt20DTOnly);
0135     DTOnlyhists.push_back(EffTFPt40DTOnly);
0136     DTOnlyhists.push_back(EffTFPt60DTOnly);
0137     
0138     std::vector<TH1F*> Overlaphists;
0139     Overlaphists.push_back(EffPtOverlap);
0140     Overlaphists.push_back(EffTFPt12Overlap);
0141     Overlaphists.push_back(EffTFPt20Overlap);
0142     Overlaphists.push_back(EffTFPt40Overlap);
0143     Overlaphists.push_back(EffTFPt60Overlap);
0144 
0145     std::vector<TH1F*> HighEtahists;
0146     HighEtahists.push_back(EffPtHighEta);
0147     HighEtahists.push_back(EffTFPt12HighEta);
0148     HighEtahists.push_back(EffTFPt20HighEta);
0149     HighEtahists.push_back(EffTFPt40HighEta);
0150     HighEtahists.push_back(EffTFPt60HighEta);
0151     
0152     //must match the threshold order of the histograms pushed into
0153     //the vectors directly above
0154     std::vector<std::string> thresholds;
0155     thresholds.push_back("");
0156     thresholds.push_back("12");
0157     thresholds.push_back("20");
0158     thresholds.push_back("40");
0159     thresholds.push_back("60");
0160     
0161     
0162     //Here you define where your Pt Histograms "Plateau"
0163     //the indices should line up with the OverallHists, 
0164     //CSCOnlyhists, DTOnlyhists, etc. above.
0165     std::vector<double> PlateauDefinitions;
0166     PlateauDefinitions.push_back(80);
0167     PlateauDefinitions.push_back(24);
0168     PlateauDefinitions.push_back(30);
0169     PlateauDefinitions.push_back(60);
0170     PlateauDefinitions.push_back(80);
0171     
0172     //Computing the plateau Efficiencies of Pt Histograms and writing them to a file
0173     std::ofstream* PtStats=new std::ofstream(PtEffStatsFilename.c_str());
0174     (*PtStats)<<"Pt Plateau Efficiencies for Overall region (|eta|<=2.4)";
0175     computePtPlateauEff(PtStats, PlateauDefinitions,thresholds,Overallhists);
0176     (*PtStats)<<"\n\nPt Plateau Efficiencies for CSC Only region (1.2<=|eta|<=2.4)";
0177     computePtPlateauEff(PtStats, PlateauDefinitions,thresholds,CSCOnlyhists);
0178     (*PtStats)<<"\n\nPt Plateau Efficiencies for CSC Restricted region (1.2<=|eta|<=2.1)";
0179     computePtPlateauEff(PtStats, PlateauDefinitions,thresholds,CSCRestrictedhists);
0180     (*PtStats)<<"\n\nPt Plateau Efficiencies for DT Only region (|eta|<=0.9)";
0181     computePtPlateauEff(PtStats, PlateauDefinitions,thresholds,DTOnlyhists);
0182     (*PtStats)<<"\n\nPt Plateau Efficiencies for Overlap region (1.2<=|eta|<=0.9)";
0183     computePtPlateauEff(PtStats, PlateauDefinitions,thresholds,Overlaphists);
0184     (*PtStats)<<"\n\nPt Plateau Efficiencies for HighEta region (2.1<=|eta|)";
0185     computePtPlateauEff(PtStats, PlateauDefinitions,thresholds,HighEtahists);
0186     PtStats->close();
0187     
0188     //Drawing Pt Histograms
0189     DrawPtEffHists("Overall",PtEffAllOverall,fitThreshOverall,TrackerLeg1Overall,thresholds,Overallhists);
0190     DrawPtEffHists("CSCOnly",PtEffAllCSCOnly,fitThreshCSCOnly,TrackerLeg1CSCOnly,thresholds,CSCOnlyhists);
0191     DrawPtEffHists("CSCRestricted",PtEffAllCSCRestricted,fitThreshCSCRestricted,TrackerLeg1CSCRestricted,thresholds,CSCRestrictedhists);
0192     DrawPtEffHists("DTOnly",PtEffAllDTOnly,fitThreshDTOnly,TrackerLeg1DTOnly,thresholds,DTOnlyhists);
0193     DrawPtEffHists("Overlap",PtEffAllOverlap,fitThreshOverlap,TrackerLeg1Overlap,thresholds,Overlaphists);
0194     DrawPtEffHists("HighEta",PtEffAllHighEta,fitThreshHighEta,TrackerLeg1HighEta,thresholds,HighEtahists);
0195    
0196     ///////////////////
0197     //Overall Eta Eff//
0198     //////////////////
0199     EtaEff = fs->make<TCanvas>("EtaEff");
0200     EffEtaQ1->GetXaxis()->SetTitle("Eta Sim");
0201     EffEtaQ1->GetYaxis()->SetTitle("Efficiency");
0202     EffEtaQ2->GetXaxis()->SetTitle("Eta Sim");
0203     EffEtaQ2->GetYaxis()->SetTitle("Efficiency");
0204     EffEtaQ3->GetXaxis()->SetTitle("Eta Sim");
0205     EffEtaQ3->GetYaxis()->SetTitle("Efficiency");
0206     EffEtaAll->GetYaxis()->SetRangeUser(0.0,1.1);
0207     EffEtaQ1->GetYaxis()->SetRangeUser(0.0,1.1);
0208     EffEtaQ2->GetYaxis()->SetRangeUser(0.0,1.1);
0209     EffEtaQ3->GetYaxis()->SetRangeUser(0.0,1.1);
0210     EffEtaQ1->SetTitle("Efficiency for Quality 1, 2, and 3 Tracks");
0211     EffEtaQ1->SetFillColor(1);
0212     EffEtaQ2->SetFillColor(4);
0213     EffEtaQ3->SetFillColor(3);
0214 
0215     EffEtaQ1->Draw();
0216     EffEtaQ2->Draw("same");
0217     EffEtaQ3->Draw("same");
0218     TrackerLeg2 = new TLegend(0.12,0.12,0.32,0.27);
0219     TrackerLeg2->AddEntry(EffEtaQ1,"All Tracks","f");
0220     TrackerLeg2->AddEntry(EffEtaQ2,"Quality > 1","f");
0221     TrackerLeg2->AddEntry(EffEtaQ3,"Quality > 2","f");
0222     TrackerLeg2->Draw();
0223     latexDescription->Draw();
0224     gPad->SetTicks(1,0);
0225     //EtaEff->Print("EffEta.png","png");
0226     
0227     
0228     //////////////////////////
0229     //Overall Signed Eta Eff// 
0230     /////////////////////////
0231     SignedEtaEff = fs->make<TCanvas>("SignedEtaEff");
0232     EffSignedEtaQ1->GetXaxis()->SetTitle("Eta Sim");
0233     EffSignedEtaQ1->GetYaxis()->SetTitle("Efficiency");
0234     EffSignedEtaQ2->GetXaxis()->SetTitle("Eta Sim");
0235     EffSignedEtaQ2->GetYaxis()->SetTitle("Efficiency");
0236     EffSignedEtaQ3->GetXaxis()->SetTitle("Eta Sim");
0237     EffSignedEtaQ3->GetYaxis()->SetTitle("Efficiency");
0238     EffSignedEtaAll->GetYaxis()->SetRangeUser(0.0,1.1);
0239     EffSignedEtaQ1->GetYaxis()->SetRangeUser(0.0,1.1);
0240     EffSignedEtaQ2->GetYaxis()->SetRangeUser(0.0,1.1);
0241     EffSignedEtaQ3->GetYaxis()->SetRangeUser(0.0,1.1);
0242     EffSignedEtaQ1->SetTitle("Efficiency for Quality 1, 2, and 3 Tracks");
0243     EffSignedEtaQ1->SetFillColor(1);
0244     EffSignedEtaQ2->SetFillColor(4);
0245     EffSignedEtaQ3->SetFillColor(3);
0246     EffSignedEtaQ1->Draw();
0247     EffSignedEtaQ2->Draw("same");
0248     EffSignedEtaQ3->Draw("same");
0249     TrackerLeg3 = new TLegend(0.12,0.12,0.32,0.27);
0250     TrackerLeg3->AddEntry(EffSignedEtaQ1,"All Tracks","f");
0251     TrackerLeg3->AddEntry(EffSignedEtaQ2,"Quality > 1","f");
0252     TrackerLeg3->AddEntry(EffSignedEtaQ3,"Quality > 2","f");
0253     TrackerLeg3->Draw();
0254     latexDescription->Draw();
0255     gPad->SetTicks(1,0);
0256     //EtaEff->Print("EffEta.png","png");
0257     
0258     //////////////////////
0259     //// Overall Phi Eff//
0260     //////////////////////
0261     PhiEff = fs->make<TCanvas>("PhiEff");
0262     EffPhiQ1->GetXaxis()->SetTitle("Phi Sim");
0263     EffPhiQ1->GetYaxis()->SetTitle("Efficiency");
0264     EffPhiQ2->GetXaxis()->SetTitle("Phi Sim");
0265     EffPhiQ2->GetYaxis()->SetTitle("Efficiency");
0266     EffPhiQ3->GetXaxis()->SetTitle("Phi Sim");
0267     EffPhiQ3->GetYaxis()->SetTitle("Efficiency");
0268     EffPhi->GetYaxis()->SetRangeUser(0.0,1.1);
0269     EffPhiQ1->GetYaxis()->SetRangeUser(0.0,1.1);
0270     EffPhiQ2->GetYaxis()->SetRangeUser(0.0,1.1);
0271     EffPhiQ3->GetYaxis()->SetRangeUser(0.0,1.1);
0272     EffPhiQ1->SetTitle("Efficiency for Quality 1, 2, and 3 Tracks");
0273     EffPhiQ1->SetFillColor(1);
0274     EffPhiQ2->SetFillColor(4);
0275     EffPhiQ3->SetFillColor(3);
0276     EffPhiQ1->Draw(); 
0277     EffPhiQ2->Draw("same");
0278     EffPhiQ3->Draw("same");
0279     TrackerLeg2 = new TLegend(0.4,0.12,0.6,0.27);
0280     TrackerLeg2->AddEntry(EffPhiQ1,"All Tracks","f");
0281     TrackerLeg2->AddEntry(EffPhiQ2,"Quality > 1","f"); 
0282     TrackerLeg2->AddEntry(EffPhiQ3,"Quality > 2","f");
0283     TrackerLeg2->Draw();
0284     latexDescription->Draw();
0285     gPad->SetTicks(1,0);
0286     //PhiEff->Print("EffPhi.png","png");
0287     
0288     EffPhi_mod_10_Q2_endcap1->GetXaxis()->SetTitle("Phi%10 (deg)");
0289     EffPhi_mod_10_Q3_endcap1->GetXaxis()->SetTitle("Phi%10 (deg)");
0290     EffPhi_mod_10_Q2_endcap2->GetXaxis()->SetTitle("Phi%10 (deg)");
0291     EffPhi_mod_10_Q3_endcap2->GetXaxis()->SetTitle("Phi%10 (deg)");
0292     EffPhi_mod_10_Q2_endcap1->GetYaxis()->SetTitle("Efficiency");
0293     EffPhi_mod_10_Q3_endcap1->GetYaxis()->SetTitle("Efficiency");
0294     EffPhi_mod_10_Q2_endcap2->GetYaxis()->SetTitle("Efficiency");
0295     EffPhi_mod_10_Q3_endcap2->GetYaxis()->SetTitle("Efficiency");
0296 
0297 }
0298 void EffHistogramList::Print()
0299 {
0300     PtEffAllOverall->Print("EffPtOverall.png","png");
0301     PtEffAllOverlap->Print("EffPtOverlap.png","png");
0302     PtEffAllHighEta->Print("EffPtHighEta.png","png");
0303     PtEffAllCSCOnly->Print("EffPtCSCOnly.png","png");
0304     EtaEff->Print("EffEta.png","png");
0305     SignedEtaEff->Print("EffSignedEta.png","png");
0306     PhiEff->Print("EffPhi.png","png");
0307 }
0308   
0309   
0310   
0311 void EffHistogramList::DrawPtEffHists(std::string region, TCanvas* canvas, TF1* fit, TLegend* legend, std::vector<std::string> thresholds, std::vector<TH1F*> PtEffHists)
0312 {
0313     std::string tmp;
0314     
0315     tmp="PtEffAll"+region;
0316     canvas = fs->make<TCanvas>(tmp.c_str());
0317     tmp="fitThresh"+region;
0318     fit = new TF1(tmp.c_str(), csctf_analysis::thresh, 0, 100, 4);
0319     legend = new TLegend(0.7,0.15,0.85,0.35);
0320     
0321     std::vector<TH1F*>::iterator iHist;
0322     std::vector<std::string>::iterator iThreshold;
0323 
0324     int i=0;
0325     for(iHist=PtEffHists.begin();iHist!=PtEffHists.end();iHist++)
0326     {
0327     PtEffHists[i]->GetXaxis()->SetTitle("Pt Sim (GeV/c)");
0328     PtEffHists[i]->GetYaxis()->SetTitle("Efficiency");
0329     PtEffHists[i]->GetYaxis()->SetRangeUser(0.0,1.1);
0330     tmp=region+" Pt Efficiency";
0331     PtEffHists[i]->SetTitle(tmp.c_str());
0332     PtEffHists[i]->SetFillColor(7-i);
0333     tmp="Pt"+thresholds[i];
0334     fit->SetParNames(tmp.c_str(),"Resol","Constant","Slope");
0335     
0336     tmp="fitThresh"+region; 
0337     PtEffHists[i]->Fit(tmp.c_str());
0338     
0339     if(i==0) tmp="All Tracks";
0340     else tmp="Pt_{TF} > "+thresholds[i];
0341     
0342     legend->AddEntry(PtEffHists[i],tmp.c_str(),"f");
0343     
0344     i++;
0345     }
0346     
0347     i=0;
0348     PtEffHists[0]->Draw("Hist");
0349     for(iHist=PtEffHists.begin();iHist!=PtEffHists.end();iHist++){PtEffHists[i]->Draw("Hist Same"); i++;}
0350  
0351     legend->Draw("same");
0352     latexDescription->Draw();
0353     gPad->SetTicks(1,0);
0354 }
0355 
0356 
0357 void EffHistogramList::computeErrors(TrackHistogramList* refHists)
0358 {
0359     refHists->matchTFPt10CSCRestricted->Sumw2();    refHists->matchTFPt12CSCRestricted->Sumw2();    refHists->matchTFPt16CSCRestricted->Sumw2();
0360     refHists->matchTFPt20CSCRestricted->Sumw2();    refHists->matchTFPt40CSCRestricted->Sumw2();    refHists->matchTFPt60CSCRestricted->Sumw2();
0361     
0362     refHists->matchTFPt10Overall->Sumw2();  refHists->matchTFPt12Overall->Sumw2();  refHists->matchTFPt16Overall->Sumw2();
0363     refHists->matchTFPt20Overall->Sumw2();  refHists->matchTFPt40Overall->Sumw2();  refHists->matchTFPt60Overall->Sumw2();
0364     
0365     refHists->matchTFPt10CSCOnly->Sumw2();  refHists->matchTFPt12CSCOnly->Sumw2();  refHists->matchTFPt16CSCOnly->Sumw2();
0366     refHists->matchTFPt20CSCOnly->Sumw2();  refHists->matchTFPt40CSCOnly->Sumw2();  refHists->matchTFPt60CSCOnly->Sumw2();
0367 
0368     refHists->matchTFPt10DTOnly->Sumw2();   refHists->matchTFPt12DTOnly->Sumw2();   refHists->matchTFPt16DTOnly->Sumw2();
0369     refHists->matchTFPt20DTOnly->Sumw2();   refHists->matchTFPt40DTOnly->Sumw2();   refHists->matchTFPt60DTOnly->Sumw2();
0370 
0371     refHists->matchTFPt10Overlap->Sumw2();  refHists->matchTFPt12Overlap->Sumw2();  refHists->matchTFPt16Overlap->Sumw2();
0372     refHists->matchTFPt20Overlap->Sumw2();  refHists->matchTFPt40Overlap->Sumw2();  refHists->matchTFPt60Overlap->Sumw2();
0373     refHists->matchTFPt10HighEta->Sumw2();  refHists->matchTFPt12HighEta->Sumw2();  refHists->matchTFPt16HighEta->Sumw2();
0374     refHists->matchTFPt20HighEta->Sumw2();  refHists->matchTFPt40HighEta->Sumw2();  refHists->matchTFPt60HighEta->Sumw2();
0375 
0376     refHists->matchPtOverall->Sumw2();  refHists->matchPtCSCOnly->Sumw2();  refHists->matchPtDTOnly->Sumw2();
0377     refHists->matchPtHighEta->Sumw2();  refHists->ptDenHighEta->Sumw2();    refHists->ptDenCSCOnly->Sumw2();
0378 
0379     refHists->ptDenDTOnly->Sumw2(); refHists->ptDenCSCRestricted->Sumw2();  refHists->ptDenOverall->Sumw2();
0380 }
0381 
0382 void EffHistogramList::divideHistograms(TrackHistogramList* refHists)
0383 {
0384     computeErrors(refHists);
0385 
0386 
0387     EffTFPt10Overall->Divide(refHists->matchTFPt10Overall, refHists->ptDenOverall);
0388     EffTFPt12Overall->Divide(refHists->matchTFPt12Overall, refHists->ptDenOverall);
0389     EffTFPt16Overall->Divide(refHists->matchTFPt16Overall, refHists->ptDenOverall);
0390         EffTFPt20Overall->Divide(refHists->matchTFPt20Overall, refHists->ptDenOverall);
0391         EffTFPt40Overall->Divide(refHists->matchTFPt40Overall, refHists->ptDenOverall);
0392         EffTFPt60Overall->Divide(refHists->matchTFPt60Overall, refHists->ptDenOverall);
0393         EffTFPt10CSCOnly->Divide(refHists->matchTFPt10CSCOnly, refHists->ptDenCSCOnly);
0394     EffTFPt12CSCOnly->Divide(refHists->matchTFPt12CSCOnly, refHists->ptDenCSCOnly);
0395     EffTFPt16CSCOnly->Divide(refHists->matchTFPt16CSCOnly, refHists->ptDenCSCOnly);
0396         EffTFPt20CSCOnly->Divide(refHists->matchTFPt20CSCOnly, refHists->ptDenCSCOnly);
0397         EffTFPt40CSCOnly->Divide(refHists->matchTFPt40CSCOnly, refHists->ptDenCSCOnly);
0398         EffTFPt60CSCOnly->Divide(refHists->matchTFPt60CSCOnly, refHists->ptDenCSCOnly);
0399         EffTFPt10CSCRestricted->Divide(refHists->matchTFPt10CSCRestricted, refHists->ptDenCSCRestricted);
0400     EffTFPt12CSCRestricted->Divide(refHists->matchTFPt12CSCRestricted, refHists->ptDenCSCRestricted);
0401     EffTFPt16CSCRestricted->Divide(refHists->matchTFPt16CSCRestricted, refHists->ptDenCSCRestricted);
0402         EffTFPt20CSCRestricted->Divide(refHists->matchTFPt20CSCRestricted, refHists->ptDenCSCRestricted);
0403         EffTFPt40CSCRestricted->Divide(refHists->matchTFPt40CSCRestricted, refHists->ptDenCSCRestricted);
0404         EffTFPt60CSCRestricted->Divide(refHists->matchTFPt60CSCRestricted, refHists->ptDenCSCRestricted);    
0405         EffTFPt10DTOnly->Divide(refHists->matchTFPt10DTOnly, refHists->ptDenDTOnly);
0406     EffTFPt12DTOnly->Divide(refHists->matchTFPt12DTOnly, refHists->ptDenDTOnly);
0407     EffTFPt16DTOnly->Divide(refHists->matchTFPt16DTOnly, refHists->ptDenDTOnly);
0408         EffTFPt20DTOnly->Divide(refHists->matchTFPt20DTOnly, refHists->ptDenDTOnly);
0409         EffTFPt40DTOnly->Divide(refHists->matchTFPt40DTOnly, refHists->ptDenDTOnly);
0410         EffTFPt60DTOnly->Divide(refHists->matchTFPt60DTOnly, refHists->ptDenDTOnly);
0411         EffTFPt10Overlap->Divide(refHists->matchTFPt10Overlap, refHists->ptDenOverlap);
0412     EffTFPt12Overlap->Divide(refHists->matchTFPt12Overlap, refHists->ptDenOverlap);
0413         EffTFPt16Overlap->Divide(refHists->matchTFPt16Overlap, refHists->ptDenOverlap);
0414     EffTFPt20Overlap->Divide(refHists->matchTFPt20Overlap, refHists->ptDenOverlap);
0415         EffTFPt40Overlap->Divide(refHists->matchTFPt40Overlap, refHists->ptDenOverlap);
0416         EffTFPt60Overlap->Divide(refHists->matchTFPt60Overlap, refHists->ptDenOverlap);
0417         EffTFPt10HighEta->Divide(refHists->matchTFPt10HighEta, refHists->ptDenHighEta);
0418     EffTFPt12HighEta->Divide(refHists->matchTFPt12HighEta, refHists->ptDenHighEta);
0419         EffTFPt16HighEta->Divide(refHists->matchTFPt16HighEta, refHists->ptDenHighEta);
0420     EffTFPt20HighEta->Divide(refHists->matchTFPt20HighEta, refHists->ptDenHighEta);
0421         EffTFPt40HighEta->Divide(refHists->matchTFPt40HighEta, refHists->ptDenHighEta);
0422         EffTFPt60HighEta->Divide(refHists->matchTFPt60HighEta, refHists->ptDenHighEta);
0423 
0424 
0425         //EffPt->Divide(refHists->matchPt, refHists->fidPtDen);
0426     EffPtOverall->Divide(refHists->matchPtOverall, refHists->ptDenOverall);
0427         EffPtCSCOnly->Divide(refHists->matchPtCSCOnly, refHists->ptDenCSCOnly);
0428     EffPtCSCRestricted->Divide(refHists->matchPtCSCRestricted, refHists->ptDenCSCRestricted);
0429         EffPtDTOnly->Divide(refHists->matchPtDTOnly, refHists->ptDenDTOnly); 
0430         EffPtOverlap->Divide(refHists->matchPtOverlap, refHists->ptDenOverlap);
0431         EffPtHighEta->Divide(refHists->matchPtHighEta, refHists->ptDenHighEta);
0432     
0433         EffEtaAll->Divide(refHists->matchEta, refHists->Eta);
0434     EffEtaQ3->Divide(refHists->EtaQ3, refHists->Eta);
0435         EffEtaQ2->Divide(refHists->EtaQ2, refHists->Eta);
0436         EffEtaQ1->Divide(refHists->EtaQ1, refHists->Eta);
0437     EffSignedEtaAll->Divide(refHists->signedMatchEta, refHists->signedEta);
0438         EffSignedEtaQ3->Divide(refHists->signedEtaQ3, refHists->signedEta);
0439         EffSignedEtaQ2->Divide(refHists->signedEtaQ2, refHists->signedEta);
0440         EffSignedEtaQ1->Divide(refHists->signedEtaQ1, refHists->signedEta);
0441 
0442         //EffPhi->Divide(refHists->matchPhi, refHists->Phi);
0443         EffPhi_mod_10_Q2_endcap1->Divide(refHists->matchPhi_mod_10_Q2_endcap1,refHists->Phi_mod_10_endcap1);
0444         EffPhi_mod_10_Q3_endcap1->Divide(refHists->matchPhi_mod_10_Q3_endcap1,refHists->Phi_mod_10_endcap1);
0445         EffPhi_mod_10_Q2_endcap2->Divide(refHists->matchPhi_mod_10_Q2_endcap2,refHists->Phi_mod_10_endcap2);
0446         EffPhi_mod_10_Q3_endcap2->Divide(refHists->matchPhi_mod_10_Q3_endcap2,refHists->Phi_mod_10_endcap2);
0447 
0448     EffPhi->Divide(refHists->matchPhi, refHists->Phi);
0449         EffPhiQ3->Divide(refHists->PhiQ3, refHists->Phi);
0450         EffPhiQ2->Divide(refHists->PhiQ2, refHists->Phi);
0451         EffPhiQ1->Divide(refHists->PhiQ1, refHists->Phi);
0452 
0453 }
0454 
0455 void EffHistogramList::computePtPlateauEff(std::ofstream* PtStats, std::vector<double> PlateauDefinitions, std::vector<std::string> thresholds, std::vector<TH1F*> PtEffHists)
0456 {
0457     std::vector<TH1F*>::iterator iHist;
0458     std::vector<std::string>::iterator iThreshold;
0459     
0460     TF1* constFit = new TF1("constFit", "[0]", 2., 140.);
0461     
0462     Double_t xmin;
0463     int i=0;
0464     for(iHist=PtEffHists.begin();iHist!=PtEffHists.end();iHist++)
0465     {
0466         xmin = PlateauDefinitions[i]; //define start of plateau
0467         PtEffHists[i] -> Fit(constFit,"R","", xmin, 140.); //do fit
0468         if(i==0) (*PtStats)<<"\nDefault Pt thresh   Efficiency:  "<<constFit->GetParameter(0)<<"   "; // efficiency of plateau
0469         else (*PtStats)<<"\nPt>"<<thresholds[i].c_str()<<"               Efficiency:  "<<constFit->GetParameter(0)<<"   "; // efficiency of plateau
0470         
0471         (*PtStats)<<"Error:   "<<constFit->GetParError(0); // error on the plateau efficiency
0472         i++;
0473     }
0474 }
0475   
0476   
0477   
0478   
0479   
0480   
0481 Double_t thresh(Double_t* pt, Double_t* par)
0482   {
0483     Double_t fitval = (0.5*TMath::Erf((pt[0]/par[0] + 1.0)/(TMath::Sqrt(2.0)*par[1])) + 0.5*TMath::Erf((pt[0]/par[0] - 1.0)/(TMath::Sqrt(2.0)*par[1])) )*(par[2] + par[3]*pt[0]);
0484     return fitval;
0485   }
0486 }