void composeTrackAnalysisbyAssociator(string FileListName, int FileNumber) { if(debug) cout << FileListName << endl; string theFileName; ifstream composeFileList; composeFileList.open(FileListName.c_str()); string OutputPlotNamepreFix = FileListName + "_"; string OutputPlotNameFix = ".png"; unsigned int EventNumber; unsigned int trackingParticleMatch; double recTrackPurity; double recTrackrefMomentum; double recTrackrefPhi; double recTrackrefEta; double recTrackinnerMomentum; double recTrackinnerPhi; double recTrackinnerEta; unsigned int recTrackinnerValid; double recTrackouterMomentum; double recTrackouterPhi; double recTrackouterEta; unsigned int recTrackouterValid; double simTrackinnerMomentum; double simTrackinnerPhi; double simTrackinnerEta; unsigned int simTrackinnerMatch; double simTrackouterMomentum; double simTrackouterPhi; double simTrackouterEta; unsigned int simTrackouterMatch; double recTrackinnerMomentumofTSOS; double recTrackinnerPhiofTSOS; double recTrackinnerEtaofTSOS; unsigned int recTrackinnerValidofTSOS; double recTrackouterMomentumofTSOS; double recTrackouterPhiofTSOS; double recTrackouterEtaofTSOS; unsigned int recTrackouterValidofTSOS; double recTrackimpactMomentumofTSOS; double recTrackimpactPhiofTSOS; double recTrackimpactEtaofTSOS; unsigned int recTrackimpactValidofTSOS; int recTrackCharge; double simTrackMomentumPt; double simTrackPhi; double simTrackEta; int simTrackCharge; TObjArray* myEfficiencyHist = new TObjArray(); TObjArray* myParticleHist = new TObjArray(); TObjArray* mySTAHist = new TObjArray(); TObjArray* myChargeCheckHist = new TObjArray(); TObjArray* myDeltaPtHist = new TObjArray(); TObjArray* myDeltaPhiHist = new TObjArray(); TObjArray* myDeltaEtaHist = new TObjArray(); vector<string> TypeName; TypeName.clear(); for(int Index = 0; Index < FileNumber; Index++) { getline(composeFileList, theFileName); TypeName.push_back(theFileName); string fullFileName = "data/"+ theFileName + ".root"; if(debug) cout << theFileName << endl; TFile* RootFile = TFile::Open(fullFileName.c_str()); TTree* T1 = (TTree*)RootFile->Get("ExTree"); T1->SetBranchAddress("EventNumber", &EventNumber); T1->SetBranchAddress("trackingParticleMatch", &trackingParticleMatch); T1->SetBranchAddress("recTrackPurity", &recTrackPurity); T1->SetBranchAddress("recTrackrefMomentum", &recTrackrefMomentum); T1->SetBranchAddress("recTrackrefPhi", &recTrackrefPhi); T1->SetBranchAddress("recTrackrefEta", &recTrackrefEta); T1->SetBranchAddress("recTrackinnerMomentum", &recTrackinnerMomentum); T1->SetBranchAddress("recTrackinnerPhi", &recTrackinnerPhi); T1->SetBranchAddress("recTrackinnerEta", &recTrackinnerEta); T1->SetBranchAddress("recTrackinnerValid", &recTrackinnerValid); T1->SetBranchAddress("recTrackouterMomentum", &recTrackouterMomentum); T1->SetBranchAddress("recTrackouterPhi", &recTrackouterPhi); T1->SetBranchAddress("recTrackouterEta", &recTrackouterEta); T1->SetBranchAddress("recTrackouterValid", &recTrackouterValid); T1->SetBranchAddress("simTrackinnerMomentum", &simTrackinnerMomentum); T1->SetBranchAddress("simTrackinnerPhi", &simTrackinnerPhi); T1->SetBranchAddress("simTrackinnerEta", &simTrackinnerEta); T1->SetBranchAddress("simTrackinnerMatch", &simTrackinnerMatch); T1->SetBranchAddress("simTrackouterMomentum", &simTrackouterMomentum); T1->SetBranchAddress("simTrackouterPhi", &simTrackouterPhi); T1->SetBranchAddress("simTrackouterEta", &simTrackouterEta); T1->SetBranchAddress("simTrackouterMatch", &simTrackouterMatch); T1->SetBranchAddress("recTrackinnerMomentumofTSOS", &recTrackinnerMomentumofTSOS); T1->SetBranchAddress("recTrackinnerPhiofTSOS", &recTrackinnerPhiofTSOS); T1->SetBranchAddress("recTrackinnerEtaofTSOS", &recTrackinnerEtaofTSOS); T1->SetBranchAddress("recTrackinnerValidofTSOS", &recTrackinnerValidofTSOS); T1->SetBranchAddress("recTrackouterMomentumofTSOS", &recTrackouterMomentumofTSOS); T1->SetBranchAddress("recTrackouterPhiofTSOS", &recTrackouterPhiofTSOS); T1->SetBranchAddress("recTrackouterEtaofTSOS", &recTrackouterEtaofTSOS); T1->SetBranchAddress("recTrackouterValidofTSOS", &recTrackouterValidofTSOS); T1->SetBranchAddress("recTrackimpactMomentumofTSOS", &recTrackimpactMomentumofTSOS); T1->SetBranchAddress("recTrackimpactPhiofTSOS", &recTrackimpactPhiofTSOS); T1->SetBranchAddress("recTrackimpactEtaofTSOS", &recTrackimpactEtaofTSOS); T1->SetBranchAddress("recTrackimpactValidofTSOS", &recTrackimpactValidofTSOS); T1->SetBranchAddress("recTrackCharge", &recTrackCharge); T1->SetBranchAddress("simTrackMomentumPt", &simTrackMomentumPt); T1->SetBranchAddress("simTrackPhi", &simTrackPhi); T1->SetBranchAddress("simTrackEta", &simTrackEta); T1->SetBranchAddress("simTrackCharge", &simTrackCharge); string TempHistName; TempHistName = theFileName + "_Efficiency2simPt"; TH1D* Efficiency2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_Particle2simPt"; TH1D* Particle2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_STA2simPt"; TH1D* STA2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_InverseChargeRato2simPt"; TH1D* InverseChargeRato2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_DeltaPt2simPt"; TH1D* DeltaPt2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_DeltaPhi2simPt"; TH1D* DeltaPhi2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_DeltaEta2simPt"; TH1D* DeltaEta2simPtHist = new TH1D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale); TempHistName = theFileName + "_MaxPurity2simPt"; TH2D* MaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 6, 0., 1.2); TempHistName = theFileName + "_Multiplicity2simPt"; TH2D* Multiplicity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 10, 0., 10.); TempHistName = theFileName + "_ChargeCheck2simPt"; TH2D* ChargeCheck2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 5, -2.5, 2.5); TempHistName = theFileName + "_simTrackMomentumPtmaxPurity2simPt"; TH2D* simTrackMomentumPtmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, (int)5*PtScale, 0, PtScale); TempHistName = theFileName + "_simTrackPhimaxPurity2simPt"; TH2D* simTrackPhimaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 314, -PI, PI); TempHistName = theFileName + "_simTrackEtamaxPurity2simPt"; TH2D* simTrackEtamaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 400, -2.0, 2.0); TempHistName = theFileName + "_recTrackimpactMomentumofTSOSmaxPurity2simPt"; TH2D* recTrackimpactMomentumofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, (int)5*PtScale, 0, PtScale); TempHistName = theFileName + "_recTrackimpactPhiofTSOSmaxPurity2simPt"; TH2D* recTrackimpactPhiofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 314, -PI, PI); TempHistName = theFileName + "_recTrackimpactEtaofTSOSmaxPurity2simPt"; TH2D* recTrackimpactEtaofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 600, -3.0, 3.0); TempHistName = theFileName + "_recTrackimpactValidofTSOSmaxPurity2simPt"; TH2D* recTrackimpactValidofTSOSmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 2, 0., 2.); TempHistName = theFileName + "_DeltaPtmaxPurity2simPt"; TH2D* DeltaPtmaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, (int)5*PtScale, -1.*PtScale, PtScale); TempHistName = theFileName + "_DeltaPhimaxPurity2simPt"; TH2D* DeltaPhimaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 314, -PI, PI); TempHistName = theFileName + "_DeltaEtamaxPurity2simPt"; TH2D* DeltaEtamaxPurity2simPtHist = new TH2D(TempHistName.c_str(), TempHistName.c_str(), (int)(PtScale/2), 0, PtScale, 400, -2.0, 2.0); unsigned int trackingParticleMatch_temp; unsigned int efficiency_temp; double recTrackPurity_temp; double recTrackrefMomentum_temp; double recTrackrefPhi_temp; double recTrackrefEta_temp; double recTrackinnerMomentum_temp; double recTrackinnerPhi_temp; double recTrackinnerEta_temp; unsigned int recTrackinnerValid_temp; double recTrackouterMomentum_temp; double recTrackouterPhi_temp; double recTrackouterEta_temp; unsigned int recTrackouterValid_temp; double simTrackinnerMomentum_temp; double simTrackinnerPhi_temp; double simTrackinnerEta_temp; unsigned int simTrackinnerMatch_temp; double simTrackouterMomentum_temp; double simTrackouterPhi_temp; double simTrackouterEta_temp; unsigned int simTrackouterMatch_temp; double recTrackinnerMomentumofTSOS_temp; double recTrackinnerPhiofTSOS_temp; double recTrackinnerEtaofTSOS_temp; unsigned int recTrackinnerValidofTSOS_temp; double recTrackouterMomentumofTSOS_temp; double recTrackouterPhiofTSOS_temp; double recTrackouterEtaofTSOS_temp; unsigned int recTrackouterValidofTSOS_temp; double recTrackimpactMomentumofTSOS_temp; double recTrackimpactPhiofTSOS_temp; double recTrackimpactEtaofTSOS_temp; unsigned int recTrackimpactValidofTSOS_temp; int recTrackCharge_temp; double simTrackMomentumPt_temp; double simTrackPhi_temp; double simTrackEta_temp; int simTrackCharge_temp; int Nentries = T1->GetEntries(); for(int i = 0; i < Nentries; i++) { T1->GetEntry(i); if(trackingParticleMatch == 0) { MaxPurity2simPtHist->Fill(simTrackMomentumPt, 0); Multiplicity2simPtHist->Fill(simTrackMomentumPt, 0); int tempParticleBinNumber = Particle2simPtHist->FindBin(simTrackMomentumPt); double tempParticleBinValue = Particle2simPtHist->GetBinContent(tempParticleBinNumber); tempParticleBinValue += 1.; Particle2simPtHist->SetBinContent(tempParticleBinNumber, tempParticleBinValue); } else { efficiency_temp = 1; trackingParticleMatch_temp = trackingParticleMatch; recTrackPurity_temp = recTrackPurity; recTrackrefMomentum_temp = recTrackrefMomentum; recTrackrefPhi_temp = recTrackrefPhi; recTrackrefEta_temp = recTrackrefEta; recTrackinnerMomentum_temp = recTrackinnerMomentum; recTrackinnerPhi_temp = recTrackinnerPhi; recTrackinnerEta_temp = recTrackinnerEta; recTrackinnerValid_temp = recTrackinnerValid; recTrackouterMomentum_temp = recTrackouterMomentum; recTrackouterPhi_temp = recTrackouterPhi; recTrackouterEta_temp = recTrackouterEta; recTrackouterValid_temp = recTrackouterValid; simTrackinnerMomentum_temp = simTrackinnerMomentum; simTrackinnerPhi_temp = simTrackinnerPhi; simTrackinnerEta_temp = simTrackinnerEta; simTrackinnerMatch_temp = simTrackinnerMatch; simTrackouterMomentum_temp = simTrackouterMomentum; simTrackouterPhi_temp = simTrackouterPhi; simTrackouterEta_temp = simTrackouterEta; simTrackouterMatch_temp = simTrackouterMatch; recTrackinnerMomentumofTSOS_temp = recTrackinnerMomentumofTSOS; recTrackinnerPhiofTSOS_temp = recTrackinnerPhiofTSOS; recTrackinnerEtaofTSOS_temp = recTrackinnerEtaofTSOS; recTrackinnerValidofTSOS_temp = recTrackinnerValidofTSOS; recTrackouterMomentumofTSOS_temp = recTrackouterMomentumofTSOS; recTrackouterPhiofTSOS_temp = recTrackouterPhiofTSOS; recTrackouterEtaofTSOS_temp = recTrackouterEtaofTSOS; recTrackouterValidofTSOS_temp = recTrackouterValidofTSOS; recTrackimpactMomentumofTSOS_temp = recTrackimpactMomentumofTSOS; recTrackimpactPhiofTSOS_temp = recTrackimpactPhiofTSOS; recTrackimpactEtaofTSOS_temp = recTrackimpactEtaofTSOS; recTrackimpactValidofTSOS_temp = recTrackimpactValidofTSOS; recTrackCharge_temp = recTrackCharge; simTrackMomentumPt_temp = simTrackMomentumPt; simTrackPhi_temp = simTrackPhi; simTrackEta_temp = simTrackEta; simTrackCharge_temp = simTrackCharge; bool nextStep = true; while(nextStep) { i++; T1->GetEntry(i); if(trackingParticleMatch <= trackingParticleMatch_temp) nextStep = false; else trackingParticleMatch_temp = trackingParticleMatch; if(nextStep == true && recTrackPurity_temp < recTrackPurity) { if(debug) cout << "step another match, trackingParticleMatch_temp: " << trackingParticleMatch_temp << endl; //trackingParticleMatch_temp = trackingParticleMatch; recTrackPurity_temp = recTrackPurity; recTrackrefMomentum_temp = recTrackrefMomentum; recTrackrefPhi_temp = recTrackrefPhi; recTrackrefEta_temp = recTrackrefEta; recTrackinnerMomentum_temp = recTrackinnerMomentum; recTrackinnerPhi_temp = recTrackinnerPhi; recTrackinnerEta_temp = recTrackinnerEta; recTrackinnerValid_temp = recTrackinnerValid; recTrackouterMomentum_temp = recTrackouterMomentum; recTrackouterPhi_temp = recTrackouterPhi; recTrackouterEta_temp = recTrackouterEta; recTrackouterValid_temp = recTrackouterValid; simTrackinnerMomentum_temp = simTrackinnerMomentum; simTrackinnerPhi_temp = simTrackinnerPhi; simTrackinnerEta_temp = simTrackinnerEta; simTrackinnerMatch_temp = simTrackinnerMatch; simTrackouterMomentum_temp = simTrackouterMomentum; simTrackouterPhi_temp = simTrackouterPhi; simTrackouterEta_temp = simTrackouterEta; simTrackouterMatch_temp = simTrackouterMatch; recTrackinnerMomentumofTSOS_temp = recTrackinnerMomentumofTSOS; recTrackinnerPhiofTSOS_temp = recTrackinnerPhiofTSOS; recTrackinnerEtaofTSOS_temp = recTrackinnerEtaofTSOS; recTrackinnerValidofTSOS_temp = recTrackinnerValidofTSOS; recTrackouterMomentumofTSOS_temp = recTrackouterMomentumofTSOS; recTrackouterPhiofTSOS_temp = recTrackouterPhiofTSOS; recTrackouterEtaofTSOS_temp = recTrackouterEtaofTSOS; recTrackouterValidofTSOS_temp = recTrackouterValidofTSOS; recTrackimpactMomentumofTSOS_temp = recTrackimpactMomentumofTSOS; recTrackimpactPhiofTSOS_temp = recTrackimpactPhiofTSOS; recTrackimpactEtaofTSOS_temp = recTrackimpactEtaofTSOS; recTrackimpactValidofTSOS_temp = recTrackimpactValidofTSOS; recTrackCharge_temp = recTrackCharge; simTrackMomentumPt_temp = simTrackMomentumPt; simTrackPhi_temp = simTrackPhi; simTrackEta_temp = simTrackEta; simTrackCharge_temp = simTrackCharge; } } i--; //if(debug) cout << "Filling Multiplicity " << trackingParticleMatch_temp << endl; MaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackPurity_temp); Multiplicity2simPtHist->Fill(simTrackMomentumPt_temp, trackingParticleMatch_temp); ChargeCheck2simPtHist->Fill(simTrackMomentumPt_temp, simTrackCharge_temp*recTrackCharge_temp); simTrackMomentumPtmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, simTrackMomentumPt_temp); simTrackPhimaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, simTrackPhi_temp); simTrackEtamaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, simTrackEta_temp); recTrackimpactMomentumofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactMomentumofTSOS_temp); recTrackimpactPhiofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactPhiofTSOS_temp); recTrackimpactEtaofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactEtaofTSOS_temp); recTrackimpactValidofTSOSmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactValidofTSOS_temp); DeltaPtmaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, (recTrackimpactMomentumofTSOS_temp-simTrackMomentumPt_temp)/simTrackMomentumPt_temp); DeltaPhimaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactPhiofTSOS_temp-simTrackPhi_temp); DeltaEtamaxPurity2simPtHist->Fill(simTrackMomentumPt_temp, recTrackimpactEtaofTSOS_temp-simTrackEta_temp); int tempParticleBinNumber = STA2simPtHist->FindBin(simTrackMomentumPt_temp); double tempParticleBinValue = Particle2simPtHist->GetBinContent(tempParticleBinNumber); tempParticleBinValue += 1.; Particle2simPtHist->SetBinContent(tempParticleBinNumber, tempParticleBinValue); double tempSTABinValue = STA2simPtHist->GetBinContent(tempParticleBinNumber); tempSTABinValue += 1.; STA2simPtHist->SetBinContent(tempParticleBinNumber, tempSTABinValue); } } for(int PtIndex = 1; PtIndex <= (int)(PtScale/2); PtIndex++) { double ParticleBinValue = Particle2simPtHist->GetBinContent(PtIndex); double STABinValue = STA2simPtHist->GetBinContent(PtIndex); if(ParticleBinValue == 0.) ParticleBinValue += 1.; double EfficiencyBinValue = STABinValue / ParticleBinValue * 100.; double EfficiencyBinError = sqrt(EfficiencyBinValue * (100. - EfficiencyBinValue) / ParticleBinValue); cout << ParticleBinValue << ", " << STABinValue << ", " << EfficiencyBinValue << endl; Efficiency2simPtHist->SetBinContent(PtIndex, EfficiencyBinValue); Efficiency2simPtHist->SetBinError(PtIndex, EfficiencyBinError); TH1D* ChargeCheckHist = ChargeCheck2simPtHist->ProjectionY("ChargeCheck", PtIndex, PtIndex, "o"); double ReverseChargeBinValue = ChargeCheckHist->GetBinContent(2); double CoverseChargeBinValue = ChargeCheckHist->GetBinContent(4); double TotalChargeBinValue = ReverseChargeBinValue + CoverseChargeBinValue; if(TotalChargeBinValue == 0.); TotalChargeBinValue += 1.; double ReverseChargeRato = ReverseChargeBinValue / TotalChargeBinValue; InverseChargeRato2simPtHist->SetBinContent(PtIndex, ReverseChargeRato); TH1D* DeltaPtHist = DeltaPtmaxPurity2simPtHist->ProjectionY("DeltaPt", PtIndex, PtIndex, "o"); double DeltaPtMean = DeltaPtHist->GetMean(); double DeltaPtRMS = DeltaPtHist->GetRMS(); DeltaPt2simPtHist->SetBinContent(PtIndex, DeltaPtMean); DeltaPt2simPtHist->SetBinError(PtIndex, DeltaPtRMS); TH1D* DeltaPhiHist = DeltaPhimaxPurity2simPtHist->ProjectionY("DeltaPhi", PtIndex, PtIndex, "o"); double DeltaPhiMean = DeltaPhiHist->GetMean(); double DeltaPhiRMS = DeltaPhiHist->GetRMS(); DeltaPhi2simPtHist->SetBinContent(PtIndex, DeltaPhiMean); DeltaPhi2simPtHist->SetBinError(PtIndex, DeltaPhiRMS); TH1D* DeltaEtaHist = DeltaEtamaxPurity2simPtHist->ProjectionY("DeltaEta", PtIndex, PtIndex, "o"); double DeltaEtaMean = DeltaEtaHist->GetMean(); double DeltaEtaRMS = DeltaEtaHist->GetRMS(); DeltaEta2simPtHist->SetBinContent(PtIndex, DeltaEtaMean); DeltaEta2simPtHist->SetBinError(PtIndex, DeltaEtaRMS); } myEfficiencyHist->AddLast(Efficiency2simPtHist); myParticleHist->AddLast(Particle2simPtHist); mySTAHist->AddLast(STA2simPtHist); myChargeCheckHist->AddLast(InverseChargeRato2simPtHist); myDeltaPtHist->AddLast(DeltaPt2simPtHist); } double minX = 0; double minY = 0; double maxX = 110; double maxY = 40; TCanvas* myCanvas = new TCanvas("Canvas", "Canvas", 800, 600); myCanvas->cd(); TPad* myPad = new TPad("Pad", "Pad", 0, 0, 1, 1); myPad->Draw(); myPad->cd(); ((TH1D*)(myParticleHist->At(0)))->SetStats(0); ((TH1D*)(myParticleHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev"); ((TH1D*)(myParticleHist->At(0)))->GetXaxis()->CenterTitle(1); ((TH1D*)(myParticleHist->At(0)))->Draw(); for(int Index = 0; Index < FileNumber; Index++) { ((TH1D*)(mySTAHist->At(Index)))->SetStats(0); ((TH1D*)(mySTAHist->At(Index)))->SetLineColor(kRed+Index); ((TH1D*)(mySTAHist->At(Index)))->Draw("same"); } TLegend *STALeg = new TLegend(0.6,0.1,0.9,0.3); STALeg->SetBorderSize(1); TString LegKey = "ParticleTrack"; STALeg->AddEntry(myParticleHist->At(0), LegKey, "lpf"); for(int Index = 0; Index < FileNumber; Index++) { LegKey = TypeName[Index]; STALeg->AddEntry(mySTAHist->At(Index), LegKey, "lpf"); } STALeg->Draw(); string SaveName = OutputPlotNamepreFix + "_STA2simPt" + OutputPlotNameFix; myCanvas->SaveAs(SaveName.c_str()); myPad->Clear(); myPad->Update(); double YScale = myPad->GetUymax() / 110.; ((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev"); ((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->CenterTitle(1); ((TH1D*)(myEfficiencyHist->At(0)))->SetStats(0); ((TH1D*)(myEfficiencyHist->At(0)))->Scale(YScale); ((TH1D*)(myEfficiencyHist->At(0)))->SetLineColor(kRed); ((TH1D*)(myEfficiencyHist->At(0)))->Draw("same,ah"); for(int Index = 1; Index < FileNumber; Index++) { ((TH1D*)(myEfficiencyHist->At(Index)))->SetStats(0); ((TH1D*)(myEfficiencyHist->At(Index)))->Scale(YScale); ((TH1D*)(myEfficiencyHist->At(Index)))->SetLineColor(kRed+Index); ((TH1D*)(myEfficiencyHist->At(Index)))->Draw("same,ah"); } myPad->Update(); if(debug) cout << "Y: " << myPad->GetUymax() << endl; double YAxisMinValue=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetXmin(); double YAxisMaxValue=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetXmax(); int YAxisNBins=((TH1D*)(myEfficiencyHist->At(0)))->GetYaxis()->GetNbins(); TGaxis* YAxis = new TGaxis(myPad->GetUxmin(), myPad->GetUymin(), myPad->GetUxmin(), myPad->GetUymax(), 0, 110, 510, "-R"); YAxis->SetLineColor(kGreen); YAxis->SetLabelColor(kGreen); YAxis->SetTitle("Efficiency of STA for simPts"); YAxis->CenterTitle(1); YAxis->Draw(); double XAxisMinValue=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetXmin(); double XAxisMaxValue=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetXmax(); int XAxisNBins=((TH1D*)(myEfficiencyHist->At(0)))->GetXaxis()->GetNbins(); TGaxis* XAxis = new TGaxis(myPad->GetUxmin(), myPad->GetUymin(), myPad->GetUxmax(), myPad->GetUymin(), XAxisMinValue, XAxisMaxValue, 510, "+L"); XAxis->SetTitle("simPt/Gev"); XAxis->CenterTitle(1); XAxis->Draw(); TLegend *EffLeg = new TLegend(0.1,0.9,0.4,1.0); EffLeg->SetBorderSize(1); for(int Index = 0; Index < FileNumber; Index++) { TString LegKey = TypeName[Index]; EffLeg->AddEntry(myEfficiencyHist->At(Index), LegKey, "lpf"); } EffLeg->Draw(); string SaveName = OutputPlotNamepreFix + "_Eff2simPt" + OutputPlotNameFix; myCanvas->SaveAs(SaveName.c_str()); ((TH1D*)(myDeltaPtHist->At(0)))->SetStats(0); ((TH1D*)(myDeltaPtHist->At(0)))->GetXaxis()->SetTitle("simPt/Gev"); ((TH1D*)(myDeltaPtHist->At(0)))->GetXaxis()->CenterTitle(1); ((TH1D*)(myDeltaPtHist->At(0)))->GetYaxis()->SetTitle("deltPt/simPt"); ((TH1D*)(myDeltaPtHist->At(0)))->GetYaxis()->CenterTitle(1); ((TH1D*)(myDeltaPtHist->At(0)))->SetLineColor(kRed); ((TH1D*)(myDeltaPtHist->At(0)))->Draw(""); for(int Index = 1; Index < FileNumber; Index++) { ((TH1D*)(myDeltaPtHist->At(Index)))->SetStats(0); //((TH1D*)(myDeltaPtHist->At(Index)))->GetXaxis()->SetTitle("simPt/Gev"); //((TH1D*)(myDeltaPtHist->At(Index)))->GetXaxis()->CenterTitle(1); //((TH1D*)(myDeltaPtHist->At(Index)))->GetYaxis()->SetTitle("deltPt/simPt"); //((TH1D*)(myDeltaPtHist->At(Index)))->GetYaxis()->CenterTitle(1); ((TH1D*)(myDeltaPtHist->At(Index)))->SetLineColor(kRed+Index); ((TH1D*)(myDeltaPtHist->At(Index)))->Draw("same"); //SaveName = OutputPlotNamepreFix + TypeName[Index] + "DeltaPt" + OutputPlotNameFix; //myCanvas->SaveAs(SaveName.c_str()); } TLegend *PtLeg = new TLegend(0.6,0.8,0.9,0.9); PtLeg->SetBorderSize(1); for(int Index = 0; Index < FileNumber; Index++) { TString LegKey = TypeName[Index]; PtLeg->AddEntry(myDeltaPtHist->At(Index), LegKey, "lpf"); } PtLeg->Draw(); SaveName = OutputPlotNamepreFix + "_DeltaPt" + OutputPlotNameFix; myCanvas->SaveAs(SaveName.c_str()); }
// ----------------------------------------------------------------------------- // void talk() { time_t start = TTimeStamp().GetSec(); bool draw = true; bool debug = true; // Binning int xbins = 100; int ybins = 100; double xmin = 0.0; double xmax = 1.0; double ymin = 0.0; double ymax = 1.0; double xbin_centre = ( ( xmax - xmin ) / xbins ) / 2.; double ybin_centre = ( ( ymax - ymin ) / ybins ) / 2.; // AlphaT values const int nat = 1; double at[nat]; for ( int ii = 0; ii < nat; ++ii ) { at[ii] = 0.55 + ii * 0.001; } // HT regions const int nht = 3; double ht_min[nht] = { 250., 300., 350. }; // Jet pT thresholds double pt1_min[nht] = { 71.4, 85.7, 100. }; double pt2_min[nht] = { 71.4, 85.7, 100. }; double pt3_min[nht] = { 35.7, 42.9., 50. }; // x fractions double x1_min[nht]; double x2_min[nht]; double x3_max[nht]; for ( int ii = 0; ii < nht; ++ii ) { x1_min[ii] = ( 2. * pt1_min[ii]) / ( ht_min[ii] + pt3_min[ii] ); } for ( int ii = 0; ii < nht; ++ii ) { x2_min[ii] = ( 2. * pt2_min[ii]) / ( ht_min[ii] + pt3_min[ii] ); } for ( int ii = 0; ii < nht; ++ii ) { x3_max[ii] = ( 2. * pt3_min[ii]) / ( ht_min[ii] + pt3_min[ii] ); } // Loop through bins int loop = 0; int nloops = nht; for ( int iht = 0; iht < nht; ++iht ) { std::cout << "Completed " << 100.*float(loop)/float(nloops) << "%..." << std::endl; loop++; // Labeling std::stringstream ss; ss << "HT" << int(ht_min[iht]); // New canvas for plots TCanvas* c1 = 0; if (draw) c1 = new TCanvas( TString("Canvas"+ss.str()), "" ); // Pad for cross-section plot TPad* pad = 0; if (draw) pad = new TPad(TString("Pad"+ss.str()),"",0.,0.,1.,1.); if (pad) { pad->SetGrid(); pad->Draw(); pad->cd(); pad->SetLogz(); } TH1F* hr = 0; if (draw) hr = pad->DrawFrame(0.,0.,1.,1.); // Histo title if (hr) { std::stringstream sss; sss << "H_{T}=" << ht_min[iht] << "(p_{T1},p_{T2},p_{T3})=" << pt1_min[iht] << "," << pt2_min[iht] << "," << pt3_min[iht] << ")" << ", (x_{1},x_{2},x_{3})=" << x1_min[iht] << "," << x2_min[iht] << "," << x3_max[iht] << ")"; hr->SetTitle( sss.str().c_str() ); hr->GetXaxis()->SetTitle( "x_{2}" ); hr->GetYaxis()->SetTitle( "x_{1}" ); } // Create 2D cross-section plot TH2D* his = 0; if (draw) his = new TH2D(TString("Histo"+ss.str()),"", xbins,xmin,xmax, ybins,ymin,ymax); // Fill 2D cross-section plot for ( int xbin = 0; xbin < xbins; ++xbin ) { for ( int ybin = 0; ybin < ybins; ++ybin ) { double x2 = ( ( xmax - xmin ) / xbins ) * xbin + xmin; double x1 = ( ( ymax - ymin ) / ybins ) * ybin + ymin; double val = ( x1*x1 + x2*x2 ) / ( ( 1 - x1 ) * ( 1 - x2 ) ); if ( !constrain( x1, x2, x3 ) ) { continue; } if ( x1 < x1_cut[ix1] ) { continue; } double alpha_t = x2 / ( 2 * sqrt(x1+x2-1) ); if (his) his->Fill( x2+xbin_centre, x1+ybin_centre, val ); } } // Draw 2D cross-section plot gStyle->SetPalette(1); if (his) { his->SetMaximum( his->GetMaximum() ); his->SetMinimum( his->GetMinimum(1.e-12) ); his->Draw("COLZsame"); } // Pad for AlphaT contours if (c1) c1->cd(); TPad* overlay = 0; if (draw) overlay = new TPad(TString("Overlay"+ss.str()),"",0.,0.,1.,1.); if (overlay) { overlay->SetFillStyle(4000); overlay->SetFillColor(0); overlay->SetFrameFillStyle(4000); overlay->Draw(); overlay->cd(); } TH1F* hframe = 0; if (draw) overlay->DrawFrame(pad->GetUxmin(), pad->GetUymin(), pad->GetUxmax(), pad->GetUymax()); // Graphs of AlphaT contours TMultiGraph* mg = 0; if (draw) { mg = new TMultiGraph(); for ( Int_t iat = 0; iat < nat; iat++ ) { Double_t alpha_t = at[iat]; const Int_t n_ = 100; Double_t x1_[n_]; Double_t x2_[n_]; for ( Int_t j = 0; j < 100; j++ ) { x2_[j] = j*0.01; Double_t temp = ( x2_[j] - 2. * alpha_t * alpha_t ) / ( 2. * alpha_t ); x1_[j] = temp * temp + 1 - alpha_t * alpha_t; } TGraph* gr = new TGraph(n_,x2_,x1_); mg->Add(gr,"l"); } mg->Draw(); } if (c1) c1->cd(); if (c1) c1->SaveAs(TString(ss.str()+".png")); } }
// ----------------------------------------------------------------------------- // void test() { time_t start = TTimeStamp().GetSec(); set_plot_style(); bool draw = true; //bool debug = true; // Define analysis configuration PSet ps; defaultPSet(ps); // Response plots if (false) { //xSectDistr(ps); responseProfile(); return; } // Print configuration std::stringstream ss; printPSet(ps,ss); std::cout << ss.str() << std::endl; // Params to store DoubleVV ratio, ratio_errh, ratio_errl, pass, pass_err, fail, fail_err; IntV length; clear( ratio, ratio_errh, ratio_errl, pass, pass_err, fail, fail_err, length ); init( ps, ratio, ratio_errh, ratio_errl, pass, pass_err, fail, fail_err, length ); // Loop through Meff bins int loop = 0; int nloops = ps.nmeff; for ( int imeff = 0; imeff < ps.nmeff; ++imeff ) { // Generate numbers in (x1,x2) plane DoubleVV dalitz; generateTruth( ps, imeff, dalitz, true ); // Integrate across dalitz plane integrate( ps, imeff, dalitz, ratio, ratio_errh, ratio_errl, pass, pass_err, fail, fail_err, length ); // Labeling std::stringstream ss; ss << "Meff" << int( ps.meff_bins[imeff] ); // New canvas for plots TCanvas* c1 = 0; if (draw) c1 = new TCanvas( TString("Canvas"+ss.str()), "" ); // Pad for cross-section plot TPad* pad = 0; if (draw) pad = new TPad(TString("Pad"+ss.str()),"",0.,0.,1.,1.); if (pad) { pad->SetGrid(); pad->Draw(); pad->cd(); pad->SetLogz(); } TH1F* hr = 0; if (draw) hr = pad->DrawFrame(ps.min,ps.min,ps.max,ps.max); // Histo title if (hr) { std::stringstream sss; sss << "M_{eff}=" << ps.meff_bins[imeff] << " GeV" << ", p_{T1}=" << dr(ps.pt1_bins[imeff],1) << " GeV" << ", p_{T2}=" << dr(ps.pt2_bins[imeff],1) << " GeV" << ", p_{T3}=" << dr(ps.pt3_bins[imeff],1) << " GeV"; hr->SetTitle( sss.str().c_str() ); hr->GetXaxis()->SetTitle( "x_{2}" ); hr->GetYaxis()->SetTitle( "x_{1}" ); } // Create 2D cross-section plot TH2D* his = 0; if (draw) his = new TH2D(TString("Histo"+ss.str()),"", ps.nbins,ps.min,ps.max, ps.nbins,ps.min,ps.max); //double x3 = ( 2. * ps.pt3_bins[imeff] ) / ( ps.meff_bins[imeff] + ps.pt3_bins[imeff] ); // Fill 2D cross-section plot for ( int x2_bin = 0; x2_bin < ps.nbins; ++x2_bin ) { for ( int x1_bin = 0; x1_bin < ps.nbins; ++x1_bin ) { // std::cout << " Fill:" // << " x2_bin: " << x2_bin // << " x2: " << val(x2_bin,nbins) // << " x1_bin: " << x1_bin // << " x1: " << val(x1_bin,nbins) // << " val: " << dalitz[x2_bin][x1_bin] // << std::endl; if (his) his->Fill( val(x2_bin,ps)+ps.width/2., val(x1_bin,ps)+ps.width/2., dalitz[x2_bin][x1_bin] ); } } // Draw 2D cross-section plot gStyle->SetPalette(1); if (his) { //his->SetMaximum( his->GetMaximum()*10. ); //his->SetMinimum( his->GetMinimum(1.e-12)*0.1 ); // his->SetMaximum( 1.e9 ); // his->SetMinimum( 1.e0 ); his->Draw("COLZsame"); } // Pad for AlphaT contours if (c1) c1->cd(); TPad* overlay = 0; if (draw) overlay = new TPad(TString("Overlay"+ss.str()),"",0.,0.,1.,1.); if (overlay) { overlay->SetFillStyle(4000); overlay->SetFillColor(0); overlay->SetFrameFillStyle(4000); overlay->Draw(); overlay->cd(); } //TH1F* hframe = 0; if (draw) overlay->DrawFrame(pad->GetUxmin(), pad->GetUymin(), pad->GetUxmax(), pad->GetUymax()); // Graphs of AlphaT contours TMultiGraph* mg = 0; if (draw) { mg = new TMultiGraph(); for ( Int_t icut = 0; icut < (int)ps.cutValues.size(); icut++ ) { Double_t alpha_t = ps.cutValues[icut]; const Int_t n = ps.nbins; DoubleV x1(n,0.); DoubleV x2(n,0.); for ( Int_t x2_bin = 0; x2_bin < ps.nbins; x2_bin++ ) { x2[x2_bin] = x2_bin * ps.width; x1[x2_bin] = cutAlgoInverse(ps.cutValues[icut],x2[x2_bin],ALGO_TYPE); } TGraph* gr = new TGraph(n,&x2.front(),&x1.front()); mg->Add(gr,"l"); } mg->Draw(); } if (c1) c1->cd(); if (c1) c1->SaveAs(TString(ss.str()+".png")); if (c1) c1->SaveAs(TString(ss.str()+".pdf")); if (c1) c1->SaveAs(TString(ss.str()+".C")); } // Canvas for ratio vs Meff if (false) { TCanvas* c2 = new TCanvas( "c2", "" ); c2->SetRightMargin(0.2); c2->SetLogy(); c2->cd(); TMultiGraph* mg2 = new TMultiGraph(); DoubleV err( ps.nmeff, 0. ); for ( Int_t icut = 0; icut < (int)ps.cutValues.size(); icut++ ) { if ( length[icut] == 0 ) { continue; } // TGraphAsymmErrors* gr = new TGraphAsymmErrors( length[icut], // &ps.meff_bins.front(), // &err.front(), // &err.front(), // &ratio[icut].front(), // &ratio_errl[icut].front(), // &ratio_errh[icut].front() ); TGraph* gr = new TGraphAsymmErrors( length[icut], &ps.meff_bins.front(), &ratio[icut].front() ); std::stringstream ss; ss << "a_{T}=" << ps.cutValues[icut]; // << " Meff=" << meff_bins[imeff] // << ", p_{T3}=" << pt3_bins[imeff]; mg2->Add(gr,"lp"); gr->SetTitle(TString(ss.str())); gr->SetLineColor(2+icut); gr->SetLineWidth(2); gr->SetMarkerStyle(20+icut); gr->SetMarkerColor(2+icut); gr->SetMarkerSize(1.5); } mg2->Draw("a"); mg2->GetYaxis()->SetRangeUser(1.e-6,1.e0); c2->Update(); c2->BuildLegend(0.81,0.1,0.99,0.9); // Save canvases c2->cd(); c2->SaveAs("RatioVsMeff.png"); c2->SaveAs("RatioVsMeff.pdf"); c2->SaveAs("RatioVsMeff.C"); } time_t stop = TTimeStamp().GetSec(); std::cout << " Time taken: " << stop - start << " seconds" << std::endl; }
void GE11sEfficiencyScan(int RunNumber, string RunName, string path) { ifstream InGE11_IV_GIF, InGE11_IV, InGE11_V; //string path = "/home/ramkrishna/TEMP/LogFiles_TB/LogFiles306To407"; string gif = path+"/Efficiency_LC1_"+std::to_string(RunNumber)+".log"; string IV = path+"/Efficiency_LC2_"+std::to_string(RunNumber)+".log"; string V = path+"/Efficiency_LC3_"+std::to_string(RunNumber)+".log"; cout<<"gif = "<<gif<<endl; InGE11_IV_GIF.open(gif); InGE11_IV.open(IV); InGE11_V.open(V); string rootFile = "Efficiency_Run"+std::to_string(RunNumber)+".root"; const char *CharrootFile = rootFile.c_str(); TFile *f = new TFile(CharrootFile,"RECREATE"); //TTree *tree = new TTree("Run306", "Detector info for Run 306"); TNtuple *GE11_IV_GIF = new TNtuple("GE11_IV_GIF","data from text file LC1","MeanPosOfSector:Efficiency:EfficiencyError:Nevents"); TNtuple *GE11_IV = new TNtuple("GE11_IV","data from text file LC2","MeanPosOfSector:Efficiency:EfficiencyError:Nevents"); TNtuple *GE11_V = new TNtuple("GE11_V","data from text file LC3","MeanPosOfSector:Efficiency:EfficiencyError:Nevents"); Int_t nlines = 0; vector<double> GIF_MeanPosOfSector, GIF_Efficiency, GIF_EfficiencyError; vector<unsigned int> GIF_Nevents; unsigned int temp_Nevents; double temp_MeanPosOfSector, temp_Efficiency, temp_EfficiencyError; vector<double> IV_MeanPosOfSector, IV_Efficiency, IV_EfficiencyError; vector<unsigned int> IV_Nevents; vector<double> V_MeanPosOfSector, V_Efficiency, V_EfficiencyError; vector<unsigned int> V_Nevents; string NameOfDet, xRange; while (1) { InGE11_IV_GIF >> NameOfDet >> xRange >> temp_MeanPosOfSector >> temp_Efficiency >> temp_EfficiencyError >> temp_Nevents; if (!InGE11_IV_GIF.good()) break; GIF_MeanPosOfSector.push_back(temp_MeanPosOfSector+(nlines*5)); GIF_Efficiency.push_back(temp_Efficiency); GIF_EfficiencyError.push_back(temp_EfficiencyError); GIF_Nevents.push_back(temp_Nevents); GE11_IV_GIF->Fill(temp_MeanPosOfSector+(nlines*5),temp_Efficiency,temp_EfficiencyError,temp_Nevents); nlines++; if (nlines > 20) { cout<<"Check the input text file for run number "<< RunNumber << endl; exit(EXIT_SUCCESS); } } InGE11_IV_GIF.close(); nlines=0; while (1) { InGE11_IV >> NameOfDet >> xRange >> temp_MeanPosOfSector >> temp_Efficiency >> temp_EfficiencyError >> temp_Nevents; if (!InGE11_IV.good()) break; IV_MeanPosOfSector.push_back(temp_MeanPosOfSector+(nlines*5)); IV_Efficiency.push_back(temp_Efficiency); IV_EfficiencyError.push_back(temp_EfficiencyError); IV_Nevents.push_back(temp_Nevents); GE11_IV->Fill(temp_MeanPosOfSector+(nlines*5),temp_Efficiency,temp_EfficiencyError,temp_Nevents); nlines++; } InGE11_IV.close(); nlines=0; while (1) { InGE11_V >> NameOfDet >> xRange >> temp_MeanPosOfSector >> temp_Efficiency >> temp_EfficiencyError >> temp_Nevents; if (!InGE11_V.good()) break; V_MeanPosOfSector.push_back(temp_MeanPosOfSector+(nlines*5)); V_Efficiency.push_back(temp_Efficiency); V_EfficiencyError.push_back(temp_EfficiencyError); V_Nevents.push_back(temp_Nevents); GE11_V->Fill(temp_MeanPosOfSector+(nlines*5),temp_Efficiency,temp_EfficiencyError,temp_Nevents); nlines++; } InGE11_V.close(); string CanvasName = "RunNumber"+std::to_string(RunNumber); const char * CharCanvasName = CanvasName.c_str(); TCanvas* c1 = new TCanvas(CharCanvasName,"Efficiency Scan Plot",200,10,700,500); TPad *pad = new TPad("pad","",0,0,1,1); //pad->SetFillColor(42); pad->SetGrid(); pad->Draw(); pad->cd(); // draw a frame to define the range TH1F *hr = pad->DrawFrame(0,-0.5,100,1.1); hr->SetXTitle("Detector Position (mm)"); hr->SetYTitle("Efficiency"); //pad->GetFrame()->SetFillColor(21); pad->GetFrame()->SetBorderSize(12); // create first graph TGraphErrors *gr_GIF = new TGraphErrors(V_Efficiency.size()); TGraphErrors *gr_IV = new TGraphErrors(V_Efficiency.size()); TGraphErrors *gr_V = new TGraphErrors(V_Efficiency.size()); for(unsigned int i=0;i<V_Efficiency.size();i++) { gr_GIF->SetPoint(i, GIF_MeanPosOfSector[i], GIF_Efficiency[i]); gr_GIF->SetPointError(i,0, GIF_EfficiencyError[i]); gr_IV->SetPoint(i, IV_MeanPosOfSector[i], IV_Efficiency[i]); gr_IV->SetPointError(i,0, IV_EfficiencyError[i]); gr_V->SetPoint(i, V_MeanPosOfSector[i], V_Efficiency[i]); gr_V->SetPointError(i,0, V_EfficiencyError[i]); } gr_GIF->SetMarkerColor(kBlue); gr_GIF->SetLineColor(kBlue); gr_GIF->SetMarkerStyle(21); gr_GIF->GetXaxis()->SetTitle("dist (mm)"); gr_GIF->GetYaxis()->SetTitle("Efficiency"); gr_GIF->GetYaxis()->SetRangeUser(0,1.2); gr_GIF->SetTitle("Efficiency Scan"); gr_GIF->Draw("ACP"); gr_IV->SetMarkerColor(kGreen-6); gr_IV->SetLineColor(kGreen); gr_IV->SetMarkerStyle(21); gr_IV->Draw("sameCP"); gr_V->SetMarkerColor(kBlack); gr_V->SetLineColor(kBlack); gr_V->SetMarkerStyle(21); gr_V->Draw("sameCP"); //create a transparent pad drawn on top of the main pad c1->cd(); TPad *overlay = new TPad("overlay","",0,0,1,1); overlay->SetFillStyle(4000); overlay->SetFillColor(0); overlay->SetFrameFillStyle(4000); overlay->Draw(); overlay->cd(); // create second graph //TGraphErrors* gr_GIF_Num = new TGraphErrors("data_noerror.dat","%lg %lg"); TGraphErrors *gr_GIF_Num = new TGraphErrors(GIF_Nevents.size()); TGraphErrors *gr_IV_Num = new TGraphErrors(IV_Nevents.size()); TGraphErrors *gr_V_Num = new TGraphErrors(V_Nevents.size()); for(unsigned int i=0;i<V_MeanPosOfSector.size();i++) { gr_GIF_Num->SetPoint(i,GIF_MeanPosOfSector[i],GIF_Nevents[i]); gr_IV_Num->SetPoint(i,IV_MeanPosOfSector[i],IV_Nevents[i]); gr_V_Num->SetPoint(i,V_MeanPosOfSector[i],V_Nevents[i]); } gr_GIF_Num->SetMarkerColor(kBlue); gr_GIF_Num->SetLineColor(kBlue); gr_GIF_Num->SetLineStyle(2); gr_GIF_Num->SetLineWidth(3); gr_GIF_Num->SetMarkerStyle(22); gr_GIF_Num->SetName("gr_GIF_Num"); gr_IV_Num->SetMarkerColor(kGreen-6); gr_IV_Num->SetLineColor(kGreen); gr_IV_Num->SetMarkerStyle(22); gr_IV_Num->SetLineStyle(2); gr_IV_Num->SetLineWidth(3); gr_IV_Num->SetName("gr_IV_Num"); gr_V_Num->SetMarkerColor(kBlack); gr_V_Num->SetLineColor(kBlack); gr_V_Num->SetMarkerStyle(22); gr_V_Num->SetLineStyle(2); gr_V_Num->SetLineWidth(3); gr_V_Num->SetName("gr_V_Num"); Double_t xmin = pad->GetUxmin(); Double_t ymin = 0; Double_t xmax = pad->GetUxmax(); Double_t ymax = 1550; TH1F *hframe = overlay->DrawFrame(xmin,ymin,xmax,ymax); hframe->GetXaxis()->SetLabelOffset(99); hframe->GetYaxis()->SetLabelOffset(99); hframe->Draw("Y+"); gr_GIF_Num->Draw("CPY+"); gr_IV_Num->Draw("CPY+"); gr_V_Num->Draw("CPY+"); //Draw the Legend TLegend *leg = new TLegend(0.10,0.732,0.40,0.90); leg->AddEntry(gr_GIF,"GE11_IV_GIF eff","LPE"); leg->AddEntry(gr_IV,"GE11_IV eff","LPE"); leg->AddEntry(gr_V,"GE11_V eff","LPE"); leg->AddEntry(gr_GIF_Num,"No of events_GE11_IV_GIF","LPE"); leg->AddEntry(gr_IV_Num,"No of events_GE11_IV","LPE"); leg->AddEntry(gr_V_Num,"No of events_GE11_V","LPE"); leg->Draw("same"); const char *runnum = RunName.c_str(); TLatex *t2a = new TLatex(0.00,0.94, runnum ); t2a->SetNDC(); t2a->SetTextFont(42); t2a->SetTextSize(0.033); t2a->SetTextAlign(13); t2a->Draw("same"); //Draw an axis on the right side TGaxis *axis = new TGaxis(xmax,ymin,xmax, ymax,ymin,ymax,510,"+L"); axis->SetLineColor(kRed); axis->SetLabelColor(kRed); axis->SetTitle("Approx. No. of Events"); axis->Draw(); string OutputFileName = "GE11_Efficiency_Scan_"+std::to_string(RunNumber)+".pdf"; const char *CharOutputFileName = OutputFileName.c_str(); c1->SaveAs(CharOutputFileName); c1->Write(); //tree->Write(); //tree->Write("", TObject::kOverwrite); f->Write(); }