From 7456914cf7841151411ea19861bf3b04d52172ac Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Wed, 27 Oct 2021 13:42:19 -0400 Subject: [PATCH 01/51] Added stdDev plots to Analysis and summary plot method in Postprocessor --- src/Analysis.cxx | 194 ++++++++++++++++++--- src/Analysis.h | 8 +- src/AnalysisDelphes.cxx | 151 +++++++++++++++- src/PostProcessor.cxx | 40 +++++ src/PostProcessor.h | 1 + tutorial/analysis_xqbins.C | 2 +- tutorial/analysis_xqbins_stddevs.C | 145 +++++++++++++++ tutorial/postprocess_xqbins_draw.C | 23 +++ tutorial/postprocess_xqbins_stddevs_draw.C | 93 ++++++++++ 9 files changed, 633 insertions(+), 24 deletions(-) create mode 100644 tutorial/analysis_xqbins_stddevs.C create mode 100644 tutorial/postprocess_xqbins_stddevs_draw.C diff --git a/src/Analysis.cxx b/src/Analysis.cxx index d6802277..047839a7 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -265,28 +265,77 @@ void Analysis::Prepare() { HS->DefineHist1D("phiH_Res","#phi_{h}-#phi_{h}^{true}","", NBINS, -TMath::Pi(), TMath::Pi()); HS->DefineHist1D("phiS_Res","#phi_{S}-#phi_{S}^{true}","", NBINS, -TMath::Pi(), TMath::Pi()); HS->DefineHist2D("Q2vsXtrue","x","Q^{2}","","GeV^{2}", - 20,1e-4,1, - 10,1,1e4, + // 20,1e-4,1,//TODO: OLD -> Might revert... + // 10,1,1e4, + // true,true + NBINS,1e-3,1, + NBINS,1,100, true,true ); HS->DefineHist2D("Q2vsXpurity","x","Q^{2}","","GeV^{2}", - 20,1e-4,1, - 10,1,1e4, + NBINS,1e-3,1, + NBINS,1,100, + true,true + ); + HS->DefineHist2D("Q2vsX_q2res","x","Q^{2}","","GeV^{2}", + NBINS,1e-3,1, + NBINS,1,100, + true,true + ); + HS->DefineHist2D("Q2vsX_xres","x","Q^{2}","","GeV^{2}", + NBINS,1e-3,1, + NBINS,1,100, + true,true + ); + HS->DefineHist2D("Q2vsX_yres","x","Q^{2}","","GeV^{2}", + NBINS,1e-3,1, + NBINS,1,100, true,true ); HS->DefineHist2D("Q2vsX_zres","x","Q^{2}","","GeV^{2}", - 20,1e-4,1, - 10,1,1e4, + NBINS,1e-3,1, + NBINS,1,100, true,true ); HS->DefineHist2D("Q2vsX_pTres","x","Q^{2}","","GeV^{2}", - 20,1e-4,1, - 10,1,1e4, + NBINS,1e-3,1, + NBINS,1,100, true,true ); HS->DefineHist2D("Q2vsX_phiHres","x","Q^{2}","","GeV^{2}", - 20,1e-4,1, - 10,1,1e4, + NBINS,1e-3,1, + NBINS,1,100, + true,true + ); + // -- resolutions StdDevs + HS->DefineHist2D("Q2vsX_q2resSD","x","Q^{2}","","GeV^{2}", + NBINS,1e-3,1, + NBINS,1,100, + true,true + ); + HS->DefineHist2D("Q2vsX_xresSD","x","Q^{2}","","GeV^{2}", + NBINS,1e-3,1, + NBINS,1,100, + true,true + ); + HS->DefineHist2D("Q2vsX_yresSD","x","Q^{2}","","GeV^{2}", + NBINS,1e-3,1, + NBINS,1,100, + true,true + ); + HS->DefineHist2D("Q2vsX_zresSD","x","Q^{2}","","GeV^{2}", + NBINS,1e-3,1, + NBINS,1,100, + true,true + ); + HS->DefineHist2D("Q2vsX_pTresSD","x","Q^{2}","","GeV^{2}", + NBINS,1e-3,1, + NBINS,1,100, + true,true + ); + HS->DefineHist2D("Q2vsX_phiHresSD","x","Q^{2}","","GeV^{2}", + NBINS,1e-3,1, + NBINS,1,100, true,true ); // -- reconstructed vs. generated @@ -347,6 +396,40 @@ Int_t Analysis::GetEventQ2Idx(Double_t Q2, Int_t guess) { } } +//TODO: Find a better place for this +/** +* Element-wise sqrt function for 2D histograms like in numpy. +* Modifies histogram in place. +*/ +void Analysis::npSqrt(Histos *H, TString name) { + int xBins, q2Bins; + + // Get axes' # bins + xBins = dynamic_cast(H->Hist(name))->GetXaxis()->GetNbins(); + q2Bins = dynamic_cast(H->Hist(name))->GetYaxis()->GetNbins(); + + // Loop x vs. Q2 histogram + for (int i=1;i<=xBins;i++) { + for (int j=1;j<=q2Bins;j++){ + dynamic_cast(H->Hist(name))->SetBinContent(i,j,TMath::Sqrt(dynamic_cast(H->Hist(name))->GetBinContent(i,j))); + } + } +} + +/** +* Get mean counts per bin for 2D histogram. +*/ +Double_t Analysis::GetMean(Histos *H, TString name) { + int xBins, q2Bins; + Double_t counts; + + // Get axes' # bins + counts = dynamic_cast(H->Hist(name))->GetSum(); + xBins = dynamic_cast(H->Hist(name))->GetXaxis()->GetNbins(); + q2Bins = dynamic_cast(H->Hist(name))->GetYaxis()->GetNbins(); + return counts / (xBins * q2Bins); +} + // finish the analysis //----------------------------------- @@ -364,7 +447,7 @@ void Analysis::Finish() { // calculate cross sections, and print yields HD->Initial([this](){ cout << sep << endl << "Histogram Entries:" << endl; }); HD->Final([this](){ cout << sep << endl; }); - HD->Payload([&lumi](Histos *H){ + HD->Payload([&lumi,this](Histos *H){ cout << H->GetSetTitle() << " ::: " << H->Hist("Q2vsX")->GetEntries() << endl; @@ -372,10 +455,20 @@ void Analysis::Finish() { H->Hist("Q_xsec")->Scale(1./lumi); // TODO: generalize (`if (name contains "xsec") ...`) // divide resolution plots by true counts per x-Q2 bin H->Hist("Q2vsXpurity")->Divide(H->Hist("Q2vsXtrue")); - H->Hist("Q2vsX_zres")->Divide(H->Hist("Q2vsXtrue")); - H->Hist("Q2vsX_pTres")->Divide(H->Hist("Q2vsXtrue")); - H->Hist("Q2vsX_phiHres")->Divide(H->Hist("Q2vsXtrue")); + H->Hist("Q2vsX_q2resSD")->Divide(H->Hist("Q2vsXtrue")); + H->Hist("Q2vsX_xresSD")->Divide(H->Hist("Q2vsXtrue")); + H->Hist("Q2vsX_yresSD")->Divide(H->Hist("Q2vsXtrue")); + H->Hist("Q2vsX_zresSD")->Divide(H->Hist("Q2vsXtrue")); + H->Hist("Q2vsX_pTresSD")->Divide(H->Hist("Q2vsXtrue")); + H->Hist("Q2vsX_phiHresSD")->Divide(H->Hist("Q2vsXtrue")); + this->npSqrt(H,"Q2vsX_q2resSD"); //NOTE: Important: Take sqrt() AFTER normalizing. + this->npSqrt(H,"Q2vsX_xresSD"); + this->npSqrt(H,"Q2vsX_yresSD"); + this->npSqrt(H,"Q2vsX_zresSD"); + this->npSqrt(H,"Q2vsX_pTresSD"); + this->npSqrt(H,"Q2vsX_phiHresSD"); }); + HD->ExecuteAndClearOps(); // write histograms @@ -553,12 +646,18 @@ void Analysis::FillHistosTracks() { H->Hist("phiH_Res")->Fill( Kinematics::AdjAngle(kin->phiH - kinTrue->phiH), wTrack ); H->Hist("phiS_Res")->Fill( Kinematics::AdjAngle(kin->phiS - kinTrue->phiS), wTrack ); dynamic_cast(H->Hist("Q2vsXtrue"))->Fill(kinTrue->x,kinTrue->Q2,wTrack); + if(kinTrue->Q2!=0) dynamic_cast(H->Hist("Q2vsX_q2res"))->Fill( + kinTrue->x,kinTrue->Q2,wTrack*( (kinTrue->Q2 - kin->Q2)/(kinTrue->Q2) ) ); + if(kinTrue->x!=0) dynamic_cast(H->Hist("Q2vsX_xres"))->Fill( + kinTrue->x,kinTrue->Q2,wTrack*( (kinTrue->x - kin->x)/(kinTrue->x) ) ); + if(kinTrue->y!=0) dynamic_cast(H->Hist("Q2vsX_yres"))->Fill( + kinTrue->x,kinTrue->Q2,wTrack*( (kinTrue->y - kin->y)/(kinTrue->y) ) ); if(kinTrue->z!=0) dynamic_cast(H->Hist("Q2vsX_zres"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( fabs(kinTrue->z - kin->z)/(kinTrue->z) ) ); + kinTrue->x,kinTrue->Q2,wTrack*( (kinTrue->z - kin->z)/(kinTrue->z) ) ); if(kinTrue->pT!=0) dynamic_cast(H->Hist("Q2vsX_pTres"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( fabs(kinTrue->pT - kin->pT)/(kinTrue->pT) ) ); - dynamic_cast(H->Hist("Q2vsX_phiHres"))->Fill(kinTrue->x,kinTrue->Q2,wTrack*( fabs(kinTrue->phiH - kin->phiH) ) ); - + kinTrue->x,kinTrue->Q2,wTrack*( (kinTrue->pT - kin->pT)/(kinTrue->pT) ) ); + dynamic_cast(H->Hist("Q2vsX_phiHres"))->Fill(kinTrue->x,kinTrue->Q2,wTrack*( (kinTrue->phiH - kin->phiH) ) ); + if( (H->Hist("Q2vsXtrue"))->FindBin(kinTrue->x,kinTrue->Q2) == (H->Hist("Q2vsXtrue"))->FindBin(kin->x,kin->Q2) ) dynamic_cast(H->Hist("Q2vsXpurity"))->Fill(kin->x,kin->Q2,wTrack); // -- reconstructed vs. generated @@ -573,6 +672,62 @@ void Analysis::FillHistosTracks() { HD->ExecuteOps(true); }; +//-------------------------------------------------------------------------- +// tracks (single particles) (StdDevs) +void Analysis::FillHistosTracksSD() { + + // add kinematic values to `valueMap` + valueMap.clear(); + activeEvent = false; + /* DIS */ + valueMap.insert(std::pair( "x", kin->x )); + valueMap.insert(std::pair( "q2", kin->Q2 )); + valueMap.insert(std::pair( "w", kin->W )); + valueMap.insert(std::pair( "y", kin->y )); + /* single hadron */ + valueMap.insert(std::pair( "p", kin->pLab )); + valueMap.insert(std::pair( "eta", kin->etaLab )); + valueMap.insert(std::pair( "pt", kin->pT )); + valueMap.insert(std::pair( "ptLab", kin->pTlab )); + valueMap.insert(std::pair( "z", kin->z )); + valueMap.insert(std::pair( "qT", kin->qT )); + valueMap.insert(std::pair( "qTq", kin->qT/TMath::Sqrt(kin->Q2) )); + valueMap.insert(std::pair( "mX", kin->mX )); + valueMap.insert(std::pair( "xF", kin->xF )); + valueMap.insert(std::pair( "phiH", kin->phiH )); + valueMap.insert(std::pair( "phiS", kin->phiS )); + valueMap.insert(std::pair( "tSpin", (Double_t)kin->tSpin )); + + // check bins + // - activates HistosDAG bin nodes which contain this track + // - sets `activeEvent` if there is at least one multidimensional bin to fill + HD->TraverseBreadth(CheckBin()); + if(!activeEvent) return; + + // fill histograms, for activated bins only + HD->Payload([this](Histos *H){ + + if(kinTrue->Q2!=0) dynamic_cast(H->Hist("Q2vsX_q2resSD"))->Fill( + kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->Q2 - kin->Q2)/(kinTrue->Q2) - this->GetMean(H,"Q2vsX_q2res"),2) ) ); + if(kinTrue->x!=0) dynamic_cast(H->Hist("Q2vsX_xresSD"))->Fill( + kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->x - kin->x)/(kinTrue->x) - this->GetMean(H,"Q2vsX_xres"),2) ) ); + if(kinTrue->y!=0) dynamic_cast(H->Hist("Q2vsX_yresSD"))->Fill( + kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->y - kin->y)/(kinTrue->y) - this->GetMean(H,"Q2vsX_yres"),2) ) ); + if(kinTrue->z!=0) dynamic_cast(H->Hist("Q2vsX_zresSD"))->Fill( + kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->z - kin->z)/(kinTrue->z) - this->GetMean(H,"Q2vsX_zres"),2) ) ); + if(kinTrue->pT!=0) dynamic_cast(H->Hist("Q2vsX_pTresSD"))->Fill( + kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->pT - kin->pT)/(kinTrue->pT) - this->GetMean(H,"Q2vsX_pTres"),2) ) ); + dynamic_cast(H->Hist("Q2vsX_phiHresSD"))->Fill( + kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->z - kin->z)/(kinTrue->z) - this->GetMean(H,"Q2vsX_phiHres"),2) ) ); + + }); + // execute the payload + // - save time and don't call `ClearOps` (next loop will overwrite lambda) + // - called with `activeNodesOnly==true` since we only want to fill bins associated + // with this track + HD->ExecuteOps(true); +}; + // jets void Analysis::FillHistosJets() { @@ -614,9 +769,6 @@ void Analysis::FillHistosJets() { HD->ExecuteOps(true); }; - - - // destructor Analysis::~Analysis() { }; diff --git a/src/Analysis.h b/src/Analysis.h index 87cea63f..b7802f1c 100644 --- a/src/Analysis.h +++ b/src/Analysis.h @@ -46,7 +46,7 @@ class Analysis : public TNamed ~Analysis(); // number of bins for histograms - const Int_t NBINS = 50; + Int_t NBINS = 50; const Int_t NBINS_FULL = 10; // bin schemes @@ -97,7 +97,13 @@ class Analysis : public TNamed // FillHistos methods: fill histograms void FillHistosTracks(); + void FillHistosTracksSD(); void FillHistosJets(); + void FillHistosJetsSD(); + + // Miscellaneous histogram operations + void npSqrt(Histos *H, TString name); + Double_t GetMean(Histos *H, TString name); // lambda to check which bins an observable is in, during DAG breadth // traversal; it requires `finalStateID`, `valueMap`, and will diff --git a/src/AnalysisDelphes.cxx b/src/AnalysisDelphes.cxx index f75b48d3..282bb405 100644 --- a/src/AnalysisDelphes.cxx +++ b/src/AnalysisDelphes.cxx @@ -147,7 +147,6 @@ void AnalysisDelphes::Execute() { wTrack = Q2weightFactor * weight->GetWeight(*kinTrue); wTrackTotal += wTrack; - // track loop - - - - - - - - - - - - - - - - - - - - - - - - - - - - itTrack.Reset(); while(Track *trk = (Track*) itTrack()) { @@ -234,6 +233,156 @@ void AnalysisDelphes::Execute() { cout << "end event loop" << endl; // event loop end ========================================================= +// Loop again for StdDevs of resolutions +// event loop ========================================================= + cout << "begin event loop (StdDevs)..." << endl; + for(Long64_t e=0; e0&&e%10000==0) cout << (Double_t)e/ENT*100 << "%" << endl; + tr->ReadEntry(e); + + // electron loop + // - finds max-momentum electron + itElectron.Reset(); + maxEleP = 0; + while(Electron *ele = (Electron*) itElectron()) { + eleP = ele->PT * TMath::CosH(ele->Eta); + if(eleP>maxEleP) { + maxEleP = eleP; + kin->vecElectron.SetPtEtaPhiM( + ele->PT, + ele->Eta, + ele->Phi, + Kinematics::ElectronMass() + ); + }; + }; + if(maxEleP<0.001) continue; // no scattered electron found + + // - repeat for truth electron + itParticle.Reset(); + maxElePtrue = 0; + while(GenParticle *part = (GenParticle*) itParticle()){ + if(part->PID == 11 && part->Status == 1){ + elePtrue = part->PT * TMath::CosH(part->Eta); + if(elePtrue > maxElePtrue){ + maxElePtrue = elePtrue; + kinTrue->vecElectron.SetPtEtaPhiM( + part->PT, + part->Eta, + part->Phi, + Kinematics::ElectronMass() + ); + }; + }; + }; + + // get hadronic final state variables + kin->GetHadronicFinalState(itTrack, itEFlowTrack, itEFlowPhoton, itEFlowNeutralHadron, itParticle); + + // calculate DIS kinematics + kin->CalculateDIS(reconMethod); // reconstructed + kinTrue->CalculateDIS(reconMethod); // generated (truth) + Double_t Q2weightFactor = GetEventQ2Weight(kinTrue->Q2, chain->GetTreeNumber()); + + // get vector of jets + // TODO: should this have an option for clustering method? + kin->GetJets(itEFlowTrack, itEFlowPhoton, itEFlowNeutralHadron, itParticle); + + // asymmetry injection + //kin->InjectFakeAsymmetry(); // sets tSpin, based on reconstructed kinematics + //kinTrue->InjectFakeAsymmetry(); // sets tSpin, based on generated kinematics + //kin->tSpin = kinTrue->tSpin; // copy to "reconstructed" tSpin + + // Get index of file that the event comes from. + wTrack = Q2weightFactor * weight->GetWeight(*kinTrue); + wTrackTotal += wTrack; + + // track loop - - - - - - - - - - - - - - - - - - - - - - - - - - - - + itTrack.Reset(); + while(Track *trk = (Track*) itTrack()) { + //cout << e << " " << trk->PID << endl; + + // final state cut + // - check PID, to see if it's a final state we're interested in for + // histograms; if not, proceed to next track + pid = trk->PID; + auto kv = PIDtoFinalState.find(pid); + if(kv!=PIDtoFinalState.end()) finalStateID = kv->second; else continue; + if(activeFinalStates.find(finalStateID)==activeFinalStates.end()) continue; + + // get parent particle, to check if pion is from vector meson + GenParticle *trkParticle = (GenParticle*)trk->Particle.GetObject(); + TObjArray *brParticle = (TObjArray*)itParticle.GetCollection(); + GenParticle *parentParticle = (GenParticle*)brParticle->At(trkParticle->M1); + int parentPID = (parentParticle->PID); // TODO: this is not used yet... + + // calculate hadron kinematics + kin->vecHadron.SetPtEtaPhiM( + trk->PT, + trk->Eta, + trk->Phi, + trk->Mass /* TODO: do we use track mass here ?? */ + ); + GenParticle* trkPart = (GenParticle*)trk->Particle.GetObject(); + kinTrue->vecHadron.SetPtEtaPhiM( + trkPart->PT, + trkPart->Eta, + trkPart->Phi, + trkPart->Mass /* TODO: do we use track mass here ?? */ + ); + + kin->CalculateHadronKinematics(); + kinTrue->CalculateHadronKinematics(); + + // fill track histograms in activated bins + FillHistosTracksSD(); + + // fill simple tree + // - not binned + // - `activeEvent` is only true if at least one bin gets filled for this track + // - TODO [critical]: add a `finalState` cut (also needed in AnalysisDD4hep) + if( writeSimpleTree && activeEvent ) ST->FillTree(wTrack); + + }; // end track loop + + + // // jet loop - - - - - - - - - - - - - - - - - - - - - - - - - - - - + // finalStateID = "jet"; + // if(activeFinalStates.find(finalStateID)!=activeFinalStates.end()) { + + // #if INCCENTAURO == 1 + // if(useBreitJets) kin->GetBreitFrameJets(itEFlowTrack, itEFlowPhoton, itEFlowNeutralHadron, itParticle); + // #endif + + // wJet = Q2weightFactor * weightJet->GetWeight(*kinTrue); // TODO: should we separate weights for breit and non-breit jets? + // wJetTotal += wJet; + + // Int_t nJets; + // if(useBreitJets) nJets = kin->breitJetsRec.size(); + // else nJets = kin->jetsRec.size(); + + // for(int i = 0; i < kin->jetsRec.size(); i++){ + + // if(useBreitJets) { + // #if INCCENTAURO == 1 + // jet = kin->breitJetsRec[i]; + // kin->CalculateBreitJetKinematics(jet); + // #endif + // } else { + // jet = kin->jetsRec[i]; + // kin->CalculateJetKinematics(jet); + // }; + + // // fill jet histograms in activated bins + // // FillHistosJetsSD(); //TODO + + // }; + // }; // end jet loop + + }; + cout << "end event loop (StdDevs)" << endl; + // event loop end ========================================================= + // finish execution Finish(); diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index 6b3ef664..f17fbd95 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -234,6 +234,46 @@ void PostProcessor::DrawSingle(Histos *H, TString histName, TString drawFormat) canv->Print(pngDir+"/"+canvN+".png"); }; +/* ALGORITHM: draw a summary histogram to a canvas, and write it + * - `histName` is the name of the histogram given in Histos + * - `drawFormat` is the formatting string passed to TH1::Draw() + */ +void PostProcessor::DrawSummary(Histos *H, TString histName, TString drawFormat) { + cout << "draw summary plot " << histName << "..." << endl; + TH1 *hist = H->Hist(histName); + if(hist==nullptr) { + cerr << "ERROR: cannot find histogram " << histName << endl; + return; + }; + + // Repurposed from deprecated code in OLD VERSION of DrawSingle() below. + TH1 *histClone = (TH1*) hist->Clone(); + TString canvN = "summaryCanv_"+histName; + histClone->SetLineColor(nsumSetMarkerColor(nsumSetMarkerStyle(nsumSetGrid(1,1); + summaryCanv->SetLogx(H->GetHistConfig(histName)->logx); + summaryCanv->SetLogy(H->GetHistConfig(histName)->logy); + summaryCanv->SetLogz(H->GetHistConfig(histName)->logz); + summaryCanv->SetBottomMargin(0.15); + summaryCanv->SetLeftMargin(0.15); + }; + summaryCanv->cd(); + // std::cout << "histClone max = " << histClone->GetBinContent(histClone->GetMaximumBin()) << std::endl; //DEBUGGING + histClone->Draw(drawFormat+(nsum>0?" SAME":"")); + summaryCanv->Print(pngDir+"/"+canvN+".png"); + nsum++; + +}; + // OLD VERSION: void PostProcessor::DrawSingle(TString histSet, TString histName) { diff --git a/src/PostProcessor.h b/src/PostProcessor.h index 908d78dd..128c3a6e 100644 --- a/src/PostProcessor.h +++ b/src/PostProcessor.h @@ -62,6 +62,7 @@ class PostProcessor : public TNamed void DumpHist(TString datFile, TString histSet, TString varName); void DumpAve(TString datFile, Histos *H, TString cutName); void DrawSingle(Histos *H, TString histName, TString drawFormat=""); + void DrawSummary(Histos *H, TString histName, TString drawFormat=""); void DrawSingle(TString histSet, TString histName); void DrawRatios( TString outName, Histos *numerSet, Histos *denomSet, Bool_t plotRatioOnly=false diff --git a/tutorial/analysis_xqbins.C b/tutorial/analysis_xqbins.C index db08fe14..c7c3dee6 100644 --- a/tutorial/analysis_xqbins.C +++ b/tutorial/analysis_xqbins.C @@ -20,7 +20,7 @@ void analysis_xqbins( crossingAngle, outfilePrefix ); - + A->NBINS = 50; // use this to set the number of bins along each axis for each overall bin in e.g. x and Q2 //A->maxEvents = 30000; // use this to limit the number of events A->SetReconMethod("Ele"); // set reconstruction method A->AddFinalState("pipTrack"); // pion final state diff --git a/tutorial/analysis_xqbins_stddevs.C b/tutorial/analysis_xqbins_stddevs.C new file mode 100644 index 00000000..8b986a78 --- /dev/null +++ b/tutorial/analysis_xqbins_stddevs.C @@ -0,0 +1,145 @@ +R__LOAD_LIBRARY(Largex) + +/* run in a grid of (x,Q2) 2D bins + * - various ways to make a grid are demonstrated + * - observe how the resulting histograms differ in each (x,Q2) bin + */ +void analysis_xqbins_stddevs( + TString infiles="datarec/tutorial.config", /* list of input files */ + Double_t eleBeamEn=5, /* electron beam energy [GeV] */ + Double_t ionBeamEn=41, /* ion beam energy [GeV] */ + Double_t crossingAngle=0, /* crossing angle [mrad] */ + TString outfilePrefix="tutorial.xqbins.stddevs." /* output filename prefix*/ +) { + + // setup analysis ======================================== + AnalysisDelphes *A = new AnalysisDelphes( + infiles, + eleBeamEn, + ionBeamEn, + crossingAngle, + outfilePrefix + ); + A->NBINS = 3; // use this to set the number of bins along each axis for each overall bin in e.g. x and Q2 + //A->maxEvents = 30000; // use this to limit the number of events + A->SetReconMethod("Ele"); // set reconstruction method + A->AddFinalState("pipTrack"); // pion final state + //A->AddFinalState("KpTrack"); // kaon final state + //A->AddFinalState("jet"); // jets + + + // define cuts ==================================== + /* - cuts are defined the same way as bins are defined (see below for syntax details and examples); + * the `CutDef` class handles bin definitions + * + * For example, if you want to apply the y<0.95 cut, do: + * A->AddBinScheme("y"); + * A->BinScheme("y")->BuildBin("Max",0.95); + * This makes a single y bin, defined by a maximum of 0.95. + * + * If instead you want to make a cut of 0.01AddBinScheme("y"); + * A->BinScheme("y")->BuildBin("Range",0.01,0.95); + * to define a single y bin. If instead you try to do something like + * A->AddBinScheme("y"); + * A->BinScheme("y")->BuildBin("Min",0.01); + * A->BinScheme("y")->BuildBin("Max",0.95); + * you would actually be defining two y bins, one with the minimum and a + * second with the maximum, which may not be what you want. + * + * You must also be mindful of what other bins you are defining. Suppose you + * want to apply a Q2>10 GeV2 cut, and then do an analysis in bins of Q2. If + * you do + * A->AddBinScheme("q2"); + * A->BinScheme("q2")->BuildBin("Min",10); // your Q2>19 GeV2 cut + * A->BinScheme("q2")->BuildBins( 5, 10, 100, true ); // 5 bins in range 10-100 GeV, equal width log scale + * you are actually defining 6 Q2 bins: the 5 you specify with `BuildBins` + * plus the one you specified with `BuildBin("Min",10)`. In this case, only + * the third line is needed to apply the Q2>10 GeV2 cut, since your binning + * range starts at 10 GeV2. + */ + // here are some common cuts we typically use for SIDIS: + A->AddBinScheme("w"); A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV + A->AddBinScheme("y"); A->BinScheme("y")->BuildBin("Range",0.01,0.95); // 0.01 < y < 0.95 + A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,0.9); // 0.2 < z < 0.9 + A->AddBinScheme("xF"); A->BinScheme("xF")->BuildBin("Min",0.0); // xF > 0 + A->AddBinScheme("ptLab"); A->BinScheme("ptLab")->BuildBin("Min",0.1); // pT_lab > 0.1 GeV (tracking limit) + + + + // set binning scheme ==================================== + + // first add what bin schemes you want; you don't have to define + // bins for all of them, but you need to add at least the ones + // you plan to use below + A->AddBinScheme("q2"); + A->AddBinScheme("x"); + A->AddBinScheme("pt"); + + // then add the bins that you want + // - tutorial switch statement: change tutorial number to try out + // the different binning implementations + int tutorialNum = 1; + switch(tutorialNum) { + + case 0: + // 1D binning in Q2, equal width in linear scale + // - arguments of BuildBins are: (numBins, min, max, log-scale bool) + // - alternatively: BuildBins(TAxis*, log-scale bool) + // - log-scale is false by default + A->BinScheme("q2")->BuildBins( 3, 1, 100); + break; + + case 1: + // 3x3 grid of (x,Q2) bins, equal width in logarithmic scale + A->BinScheme("q2")->BuildBins( 3, 1, 100, true ); + A->BinScheme("x")->BuildBins( 3, 0.01, 1, true ); + break; + + case 2: + // alternatively: equal width in linear scale + A->BinScheme("q2")->BuildBins( 3, 1, 100 ); + A->BinScheme("x")->BuildBins( 3, 0.01, 1 ); + break; + + case 3: + // custom 2x2 grid (see `CutDef` class for more cut definitions) + // - arguments of BuildBin are (cutType, a, b), where cutType is + // one of the types given in `../src/CutDef.cxx`, and a and b + // depend on which cutType + // - various cutTypes are exemplified here: + A->BinScheme("q2")->BuildBin("Max",10); // Q2 < 10 GeV2 + A->BinScheme("q2")->BuildBin("Min",10); // Q2 > 10 GeV2 + A->BinScheme("x")->BuildBin("Range", 0.05, 0.2 ); // 0.05 < x < 0.2 + A->BinScheme("x")->BuildBin("CenterDelta", 0.5, 0.1 ); // |x-0.5|<0.1 + break; + + case 4: + // overlapping Q2 bins, by specifying various Q2 minima + // - bins are arbitrary and allowed to be overlapping + A->BinScheme("q2")->BuildBin("Min",1); + A->BinScheme("q2")->BuildBin("Min",10); + A->BinScheme("q2")->BuildBin("Min",50); + break; + + case 5: + // 3D binning: 2x2 grid of (x,Q2) bins, for two pT bins + // - you can add more dimensions, but be careful of the curse + // of dimensionality + A->BinScheme("q2")->BuildBins( 2, 1, 100, true ); + A->BinScheme("x")->BuildBins( 2, 0.01, 1, true ); + A->BinScheme("pt")->BuildBin("Range", 0.2, 0.5 ); + A->BinScheme("pt")->BuildBin("Range", 0.5, 0.8 ); + break; + }; + + + + // perform the analysis ================================== + A->Execute(); + + // for reference, here is a print out of HistosDAG + // - it lists each node, together with its inputs and outputs, which + // indicate the connections between the nodes + //A->GetHistosDAG()->PrintBreadth("HistosDAG Nodes"); +}; diff --git a/tutorial/postprocess_xqbins_draw.C b/tutorial/postprocess_xqbins_draw.C index f82e5fa8..20b55a03 100644 --- a/tutorial/postprocess_xqbins_draw.C +++ b/tutorial/postprocess_xqbins_draw.C @@ -49,6 +49,29 @@ void postprocess_xqbins_draw( P->DrawSingle(H,"phiH_RvG","COLZ"); P->DrawSingle(H,"phiS_RvG","COLZ"); */ + + /* + P->DrawSingle(H,"Q2vsX_q2res","COLZ"); + P->DrawSingle(H,"Q2vsX_xres","COLZ"); + P->DrawSingle(H,"Q2vsX_yres","COLZ"); + P->DrawSingle(H,"Q2vsX_zres","COLZ"); + P->DrawSingle(H,"Q2vsX_pTres","COLZ"); + P->DrawSingle(H,"Q2vsX_phiHres","COLZ"); + */ + + P->DrawSingle(H,"Q2vsX_q2resSD","COLZ"); + P->DrawSingle(H,"Q2vsX_xresSD","COLZ"); + P->DrawSingle(H,"Q2vsX_yresSD","COLZ"); + P->DrawSingle(H,"Q2vsX_zresSD","COLZ"); + P->DrawSingle(H,"Q2vsX_pTresSD","COLZ"); + P->DrawSingle(H,"Q2vsX_phiHresSD","COLZ"); + + P->DrawSummary(H,"Q2vsX_q2resSD","COLZ"); + P->DrawSummary(H,"Q2vsX_xresSD","COLZ"); + P->DrawSummary(H,"Q2vsX_yresSD","COLZ"); + P->DrawSummary(H,"Q2vsX_zresSD","COLZ"); + P->DrawSummary(H,"Q2vsX_pTresSD","COLZ"); + P->DrawSummary(H,"Q2vsX_phiHresSD","COLZ"); } ); diff --git a/tutorial/postprocess_xqbins_stddevs_draw.C b/tutorial/postprocess_xqbins_stddevs_draw.C new file mode 100644 index 00000000..dd130570 --- /dev/null +++ b/tutorial/postprocess_xqbins_stddevs_draw.C @@ -0,0 +1,93 @@ +R__LOAD_LIBRARY(Largex) + +// make kinematics coverage plots, such as eta vs. p in bins of (x,Q2) +void postprocess_xqbins_stddevs_draw( + TString infile="out/tutorial.xqbins.stddevs.root" +) { + + // setup postprocessor ======================================== + // - this will read in the Histos objects and your defined + // binning, to construct a HistosDAG object + PostProcessor *P = new PostProcessor(infile); + + // print DAG ================================================== + // - here we print out the HistosDAG object, to show the structure + // - it lists each node, together with its inputs and outputs, which + // indicate the connections between the nodes + // - observe how the structure changes for the different bins + // you specified in the analysis macro + P->Op()->PrintBreadth("HistosDAG Initial Setup"); + + // lambdas ===================================================== + // - we now define what operations we want to happen while + // traversing through the DAG; this example shows how to define + // a payload operator, which will act on every multidimensional + // bin + + // payload: draw a few plots, using PostProcessor::DrawSingle + // - this lambda expression will be executed on every multidimensional + // bin's Histos object + // - capture the pointer to PostProcessor `P` by reference, so we + // have access to it while the lambda executes + // - lambda arguments can include a Histos pointer, and optinally + // a `NodePath` pointer, which gives binning information; here + // we just need the Histos pointer + // - `PostProcessor::Op()` is just an interface (alias) for the + // `HistosDAG` object; see classes `HistosDAG` and its parent `DAG` + // for available methods + P->Op()->Payload( + [&P](Histos *H) { + P->DrawSingle(H,"Q2vsX","COLZ"); + P->DrawSingle(H,"etaVsP","COLZ"); + /* + P->DrawSingle(H,"x_Res",""); + P->DrawSingle(H,"Q2_Res",""); + P->DrawSingle(H,"y_Res",""); + P->DrawSingle(H,"phiH_Res",""); + P->DrawSingle(H,"phiS_Res",""); + P->DrawSingle(H,"x_RvG","COLZ"); + P->DrawSingle(H,"phiH_RvG","COLZ"); + P->DrawSingle(H,"phiS_RvG","COLZ"); + */ + + /* + P->DrawSingle(H,"Q2vsX_q2res","COLZ"); + P->DrawSingle(H,"Q2vsX_xres","COLZ"); + P->DrawSingle(H,"Q2vsX_yres","COLZ"); + P->DrawSingle(H,"Q2vsX_zres","COLZ"); + P->DrawSingle(H,"Q2vsX_pTres","COLZ"); + P->DrawSingle(H,"Q2vsX_phiHres","COLZ"); + */ + + P->DrawSingle(H,"Q2vsX_q2resSD","COLZ"); + P->DrawSingle(H,"Q2vsX_xresSD","COLZ"); + P->DrawSingle(H,"Q2vsX_yresSD","COLZ"); + P->DrawSingle(H,"Q2vsX_zresSD","COLZ"); + P->DrawSingle(H,"Q2vsX_pTresSD","COLZ"); + P->DrawSingle(H,"Q2vsX_phiHresSD","COLZ"); + + P->DrawSummary(H,"Q2vsX_q2resSD","COLZ"); + P->DrawSummary(H,"Q2vsX_xresSD","COLZ"); + P->DrawSummary(H,"Q2vsX_yresSD","COLZ"); + P->DrawSummary(H,"Q2vsX_zresSD","COLZ"); + P->DrawSummary(H,"Q2vsX_pTresSD","COLZ"); + P->DrawSummary(H,"Q2vsX_phiHresSD","COLZ"); + } + ); + + // print DAG ============================ + // - we only added a payload, we did not restructure the DAG, + // therefore this second printout should have the same structure + // as the first + P->Op()->PrintBreadth("HistosDAG Final Setup"); + + // execution =================================================== + // - after you have defined all your operators, run them: + P->Execute(); + + // finish =================================================== + // - PostProcessor::Finish() is NECESSARY to close output streams + // - output file names and directories will be printed to stdout + P->Finish(); + +}; From e16490dec8ffecf77d1a3decb5a092267736ae55 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Tue, 2 Nov 2021 13:46:46 -0400 Subject: [PATCH 02/51] Updated stdDev routines to plot 1D z-binned histograms in Q2 vs. x --- macro/analysis_resolution_SD.C | 38 +++++++++ macro/postprocess_resolution_SD.C | 82 +++++++++++++++++++ src/Analysis.cxx | 132 +++++++++++++++++++++++++----- src/Analysis.h | 6 +- src/PostProcessor.cxx | 18 +++- 5 files changed, 254 insertions(+), 22 deletions(-) create mode 100644 macro/analysis_resolution_SD.C create mode 100644 macro/postprocess_resolution_SD.C diff --git a/macro/analysis_resolution_SD.C b/macro/analysis_resolution_SD.C new file mode 100644 index 00000000..a4b8c8ab --- /dev/null +++ b/macro/analysis_resolution_SD.C @@ -0,0 +1,38 @@ +R__LOAD_LIBRARY(Largex) + +// make resolution plots +void analysis_resolution_SD( + TString infiles="datarec/tutorial.config", /* list of input files */ + Double_t eleBeamEn=5, /* electron beam energy [GeV] */ + Double_t ionBeamEn=41, /* ion beam energy [GeV] */ + Double_t crossingAngle=0, /* crossing angle [mrad] */ + TString outfilePrefix="resolution" /* output filename prefix*/ +) { + + // setup analysis ======================================== + AnalysisDelphes *A = new AnalysisDelphes( + infiles, + eleBeamEn, + ionBeamEn, + crossingAngle, + outfilePrefix + ); + + //A->maxEvents = 30000; // use this to limit the number of events + A->SetReconMethod("Ele"); // set reconstruction method + A->AddFinalState("pipTrack"); // pion final state + + // define cuts ==================================== + A->AddBinScheme("w"); A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV + A->AddBinScheme("y"); A->BinScheme("y")->BuildBin("Range",0.01,0.95); // 0.01 < y < 0.95 + A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,0.9); // 0.2 < z < 0.9 + A->AddBinScheme("xF"); A->BinScheme("xF")->BuildBin("Min",0.0); // xF > 0 + A->AddBinScheme("ptLab"); A->BinScheme("ptLab")->BuildBin("Min",0.1); // pT_lab > 0.1 GeV (tracking limit) + + // set binning scheme ==================================== + A->AddBinScheme("q2"); A->BinScheme("q2")->BuildBins( 4, 1, 100, true ); + A->AddBinScheme("x"); A->BinScheme("x")->BuildBins( 6, 0.01, 1, true ); + + // perform the analysis ================================== + A->Execute(); +}; diff --git a/macro/postprocess_resolution_SD.C b/macro/postprocess_resolution_SD.C new file mode 100644 index 00000000..684e4cc4 --- /dev/null +++ b/macro/postprocess_resolution_SD.C @@ -0,0 +1,82 @@ +R__LOAD_LIBRARY(Largex) + +// make resolution plots +// - adapted from `postprocess_pTvsEta.C` +void postprocess_resolution_SD( + TString infile="out/resolution.root" +){ + + gROOT->ProcessLine(".! rm -v out/resolution.images/*.png"); // cleanup old image files + gROOT->ProcessLine(".! rm -v out/resolution.images/*.pdf"); // cleanup old image files + + PostProcessor *P = new PostProcessor(infile); + P->Op()->PrintBreadth("HistosDAG Initial Setup"); + + // number of bins in x and Q2 + int nx = P->Op()->GetBinSet("x")->GetNumBins(); + int nq2 = P->Op()->GetBinSet("q2")->GetNumBins(); + + // just counters for filling Histos vector + int xbin = 0; + int q2bin = 0; + + // initialize this 2D vector to be some large size + std::vector> histos_xQ2(30,std::vector(30)); + + auto findxQ2bins = [&histos_xQ2,&P,&xbin,&q2bin,nx,nq2](Histos *H ){ + histos_xQ2[xbin][q2bin] = H; + q2bin++; + if(q2bin == nq2){ + q2bin=0; xbin++; + if(xbin == nx) xbin = 0; + } + }; + + auto drawinxQ2bins = [&histos_xQ2, &P, &nx, &nq2](NodePath *bins){ + TString canvname = "xQ2cov_"; //+ bins->GetVar + for(Node *bin: bins->GetBinNodes()){ + if(bin->GetVarName() == "finalState"){ + canvname+=bin->GetID(); + canvname+="_"; + } + if(bin->GetVarName() == "z"){ + canvname+=bin->GetID(); + canvname+="_"; + } + } + + double xMin = 1e-4; + double xMax = 1; + double q2Min = 0.99; + double q2Max = 1000; + + // loop over resolution histograms (see ../src/Analysis.cxx `DefineHist*` calls + // for available histograms, or add your own there) + for( TString histname : {"x_Res","y_Res","Q2_Res","phiH_Res","phiS_Res","phiHvsPhiS","z_purity","z_q2resSD","z_xresSD","z_yresSD","z_zresSD","z_pTresSD","z_phiHresSD"} ) { + P->DrawInBins( + canvname, histos_xQ2, histname, + "x", nx, xMin, xMax, true, + "Q^{2}", nq2, q2Min, q2Max, true + ); + }; + }; + + auto beforefunction = [](){ + }; + + P->Op()->Subloop({"x","q2"},beforefunction,drawinxQ2bins); + P->Op()->Payload(findxQ2bins); + + //DEBUGGING + P->Op()->Payload([&P](Histos *H) { + P->DrawSingle(H,"Q2vsX_q2resSD","COLZ"); + } + ); + //END DEBUGGING + + //P->Op()->PrintBreadth("HistosDAG Final Setup"); + + P->Execute(); + + P->Finish(); +}; diff --git a/src/Analysis.cxx b/src/Analysis.cxx index 047839a7..dc75dade 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -264,6 +264,26 @@ void Analysis::Prepare() { HS->DefineHist1D("Q2_Res","Q2-Q2_{true}","GeV", NBINS, -2, 2); HS->DefineHist1D("phiH_Res","#phi_{h}-#phi_{h}^{true}","", NBINS, -TMath::Pi(), TMath::Pi()); HS->DefineHist1D("phiS_Res","#phi_{S}-#phi_{S}^{true}","", NBINS, -TMath::Pi(), TMath::Pi()); + + // 1D z-binned resolutions + HS->DefineHist1D("z_true","z","", NBINS, 0, 1); + HS->DefineHist1D("z_purity","purity","", NBINS, 0, 1); + HS->DefineHist1D("z_q2res","z","", NBINS, 0, 1); + HS->DefineHist1D("z_xres","z","", NBINS, 0, 1); + HS->DefineHist1D("z_yres","z","", NBINS, 0, 1); + HS->DefineHist1D("z_zres","z","", NBINS, 0, 1); + HS->DefineHist1D("z_pTres","z","", NBINS, 0, 1); + HS->DefineHist1D("z_phiHres","z","", NBINS, 0, 1); + // 1D z-binned resolutions StdDevs + // HS->DefineHist1D("z_puritySD","z","", NBINS, 0, 1); + HS->DefineHist1D("z_q2resSD","z","", NBINS, 0, 1); + HS->DefineHist1D("z_xresSD","z","", NBINS, 0, 1); + HS->DefineHist1D("z_yresSD","z","", NBINS, 0, 1); + HS->DefineHist1D("z_zresSD","z","", NBINS, 0, 1); + HS->DefineHist1D("z_pTresSD","z","", NBINS, 0, 1); + HS->DefineHist1D("z_phiHresSD","z","", NBINS, 0, 1); + + // 2D Q2 vs. x binned resolutions HS->DefineHist2D("Q2vsXtrue","x","Q^{2}","","GeV^{2}", // 20,1e-4,1,//TODO: OLD -> Might revert... // 10,1,1e4, @@ -307,7 +327,7 @@ void Analysis::Prepare() { NBINS,1,100, true,true ); - // -- resolutions StdDevs + // 2D Q2 vs. x resolutions StdDevs HS->DefineHist2D("Q2vsX_q2resSD","x","Q^{2}","","GeV^{2}", NBINS,1e-3,1, NBINS,1,100, @@ -355,7 +375,6 @@ void Analysis::Prepare() { }); HD->ExecuteAndClearOps(); - // initialize total weights wTrackTotal = 0.; wJetTotal = 0.; @@ -396,12 +415,28 @@ Int_t Analysis::GetEventQ2Idx(Double_t Q2, Int_t guess) { } } -//TODO: Find a better place for this +//TODO: Find a better place for the following functions +/** +* Element-wise sqrt function for 1D histograms like in numpy. +* Modifies histogram in place. +*/ +void Analysis::npSqrt1D(Histos *H, TString name) { + int zBins; + + // Get axes' # bins + zBins = H->Hist(name)->GetXaxis()->GetNbins(); + + // Loop z binned histogram + for (int i=1;i<=zBins;i++) { + H->Hist(name)->SetBinContent(i,TMath::Sqrt(H->Hist(name)->GetBinContent(i))); + } +} + /** * Element-wise sqrt function for 2D histograms like in numpy. * Modifies histogram in place. */ -void Analysis::npSqrt(Histos *H, TString name) { +void Analysis::npSqrt2D(Histos *H, TString name) { int xBins, q2Bins; // Get axes' # bins @@ -416,10 +451,23 @@ void Analysis::npSqrt(Histos *H, TString name) { } } +/** +* Get mean counts per bin for 1D histogram. +*/ +Double_t Analysis::GetMean1D(Histos *H, TString name) { + int zBins; + Double_t counts; + + // Get axes' # bins + counts = dynamic_cast(H->Hist(name))->GetSum(); + zBins = H->Hist(name)->GetXaxis()->GetNbins(); + return counts / zBins; +} + /** * Get mean counts per bin for 2D histogram. */ -Double_t Analysis::GetMean(Histos *H, TString name) { +Double_t Analysis::GetMean2D(Histos *H, TString name) { int xBins, q2Bins; Double_t counts; @@ -430,7 +478,6 @@ Double_t Analysis::GetMean(Histos *H, TString name) { return counts / (xBins * q2Bins); } - // finish the analysis //----------------------------------- void Analysis::Finish() { @@ -453,7 +500,28 @@ void Analysis::Finish() { << endl; // calculate cross sections H->Hist("Q_xsec")->Scale(1./lumi); // TODO: generalize (`if (name contains "xsec") ...`) - // divide resolution plots by true counts per x-Q2 bin + + // Normalize and sqrt 1D z-binned resolution StdDevs + H->Hist("z_purity")->Divide(H->Hist("z_true")); + H->Hist("z_q2resSD")->Divide(H->Hist("z_true")); + H->Hist("z_xresSD")->Divide(H->Hist("z_true")); + H->Hist("z_yresSD")->Divide(H->Hist("z_true")); + H->Hist("z_zresSD")->Divide(H->Hist("z_true")); + H->Hist("z_pTresSD")->Divide(H->Hist("z_true")); + H->Hist("z_phiHresSD")->Divide(H->Hist("z_true")); + this->npSqrt1D(H,"z_q2resSD"); //NOTE: Important: Take sqrt() AFTER normalizing. + this->npSqrt1D(H,"z_xresSD"); + this->npSqrt1D(H,"z_yresSD"); + this->npSqrt1D(H,"z_zresSD"); + this->npSqrt1D(H,"z_pTresSD"); + this->npSqrt1D(H,"z_phiHresSD"); + + //DEBUGGING + cout << "DEBUGGING z_purity: " << H->Hist("z_purity")->GetMean() << std::endl; + cout << "DEBUGGING z_q2res: " << H->Hist("z_q2res")->GetMean() << std::endl; + cout << "DEBUGGING z_q2resSD: " << H->Hist("z_q2resSD")->GetMean() << std::endl; + + // Normalize and sqrt 2D Q2 vs. x binned resolution StdDevs H->Hist("Q2vsXpurity")->Divide(H->Hist("Q2vsXtrue")); H->Hist("Q2vsX_q2resSD")->Divide(H->Hist("Q2vsXtrue")); H->Hist("Q2vsX_xresSD")->Divide(H->Hist("Q2vsXtrue")); @@ -461,12 +529,17 @@ void Analysis::Finish() { H->Hist("Q2vsX_zresSD")->Divide(H->Hist("Q2vsXtrue")); H->Hist("Q2vsX_pTresSD")->Divide(H->Hist("Q2vsXtrue")); H->Hist("Q2vsX_phiHresSD")->Divide(H->Hist("Q2vsXtrue")); - this->npSqrt(H,"Q2vsX_q2resSD"); //NOTE: Important: Take sqrt() AFTER normalizing. - this->npSqrt(H,"Q2vsX_xresSD"); - this->npSqrt(H,"Q2vsX_yresSD"); - this->npSqrt(H,"Q2vsX_zresSD"); - this->npSqrt(H,"Q2vsX_pTresSD"); - this->npSqrt(H,"Q2vsX_phiHresSD"); + this->npSqrt2D(H,"Q2vsX_q2resSD"); //NOTE: Important: Take sqrt() AFTER normalizing. + this->npSqrt2D(H,"Q2vsX_xresSD"); + this->npSqrt2D(H,"Q2vsX_yresSD"); + this->npSqrt2D(H,"Q2vsX_zresSD"); + this->npSqrt2D(H,"Q2vsX_pTresSD"); + this->npSqrt2D(H,"Q2vsX_phiHresSD"); + + //DEBUGGING + cout << "DEBUGGING Q2vsXpurity: " << H->Hist("Q2vsXpurity")->GetMean() << std::endl; + cout << "DEBUGGING Q2vsX_q2res: " << H->Hist("Q2vsX_q2res")->GetMean() << std::endl; + cout << "DEBUGGING Q2vsX_q2resSD: " << H->Hist("Q2vsX_q2resSD")->GetMean() << std::endl; }); HD->ExecuteAndClearOps(); @@ -645,6 +718,18 @@ void Analysis::FillHistosTracks() { H->Hist("Q2_Res")->Fill( kin->Q2 - kinTrue->Q2, wTrack ); H->Hist("phiH_Res")->Fill( Kinematics::AdjAngle(kin->phiH - kinTrue->phiH), wTrack ); H->Hist("phiS_Res")->Fill( Kinematics::AdjAngle(kin->phiS - kinTrue->phiS), wTrack ); + + // z binned resolutions + H->Hist("z_true")->Fill(kinTrue->z, wTrack ); + if( (H->Hist("z_true"))->FindBin(kinTrue->z) == (H->Hist("z_true"))->FindBin(kin->z) ) H->Hist("z_purity")->Fill(kin->z,wTrack); + if(kinTrue->Q2!=0) H->Hist("z_q2res")->Fill( kinTrue->z, (kinTrue->Q2 - kinTrue->Q2)/kinTrue->Q2 * wTrack ); + if(kinTrue->x!=0) H->Hist("z_xres")->Fill( kinTrue->z, (kinTrue->x - kin->x)/kinTrue->x * wTrack ); + if(kinTrue->y!=0) H->Hist("z_yres")->Fill( kinTrue->z, (kinTrue->y - kin->y)/kinTrue->y * wTrack ); + if(kinTrue->z!=0) H->Hist("z_zres")->Fill( kinTrue->z, (kinTrue->z - kin->z)/kinTrue->z * wTrack ); + if(kinTrue->pT!=0) H->Hist("z_pTres")->Fill( kinTrue->z, (kinTrue->pT - kin->pT)/kinTrue->pT * wTrack ); + H->Hist("z_phiHres")->Fill( kinTrue->z, (kinTrue->phiH - kin->phiH) * wTrack ); + + // Q2 vs. x binned resolutions dynamic_cast(H->Hist("Q2vsXtrue"))->Fill(kinTrue->x,kinTrue->Q2,wTrack); if(kinTrue->Q2!=0) dynamic_cast(H->Hist("Q2vsX_q2res"))->Fill( kinTrue->x,kinTrue->Q2,wTrack*( (kinTrue->Q2 - kin->Q2)/(kinTrue->Q2) ) ); @@ -707,18 +792,27 @@ void Analysis::FillHistosTracksSD() { // fill histograms, for activated bins only HD->Payload([this](Histos *H){ + // z binned resolution StdDevs + if(kinTrue->Q2!=0) H->Hist("z_q2resSD")->Fill( kinTrue->z, wTrack * TMath::Power( (kinTrue->Q2 - kin->Q2)/kinTrue->Q2 - this->GetMean1D(H,"z_q2res"),2) ); + if(kinTrue->x!=0) H->Hist("z_xresSD")->Fill( kinTrue->z, wTrack * TMath::Power( (kinTrue->x - kin->x)/kinTrue->x - this->GetMean1D(H,"z_xres"),2) ); + if(kinTrue->y!=0) H->Hist("z_yresSD")->Fill( kinTrue->z, wTrack * TMath::Power( (kinTrue->y - kin->y)/kinTrue->y - this->GetMean1D(H,"z_yres"),2) ); + if(kinTrue->z!=0) H->Hist("z_zresSD")->Fill( kinTrue->z, wTrack * TMath::Power( (kinTrue->z - kin->z)/kinTrue->z - this->GetMean1D(H,"z_zres"),2) ); + if(kinTrue->pT!=0) H->Hist("z_pTresSD")->Fill( kinTrue->z, wTrack * TMath::Power( (kinTrue->pT - kin->pT)/kinTrue->pT - this->GetMean1D(H,"z_pTres"),2) ); + H->Hist("z_phiHresSD")->Fill( kinTrue->z, wTrack * TMath::Power( (kinTrue->phiH - kin->phiH) -this->GetMean1D(H,"z_phiHres"),2) ); + + // Q2 vs. x resolution StdDevs if(kinTrue->Q2!=0) dynamic_cast(H->Hist("Q2vsX_q2resSD"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->Q2 - kin->Q2)/(kinTrue->Q2) - this->GetMean(H,"Q2vsX_q2res"),2) ) ); + kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->Q2 - kin->Q2)/(kinTrue->Q2) - this->GetMean2D(H,"Q2vsX_q2res"),2) ) ); if(kinTrue->x!=0) dynamic_cast(H->Hist("Q2vsX_xresSD"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->x - kin->x)/(kinTrue->x) - this->GetMean(H,"Q2vsX_xres"),2) ) ); + kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->x - kin->x)/(kinTrue->x) - this->GetMean2D(H,"Q2vsX_xres"),2) ) ); if(kinTrue->y!=0) dynamic_cast(H->Hist("Q2vsX_yresSD"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->y - kin->y)/(kinTrue->y) - this->GetMean(H,"Q2vsX_yres"),2) ) ); + kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->y - kin->y)/(kinTrue->y) - this->GetMean2D(H,"Q2vsX_yres"),2) ) ); if(kinTrue->z!=0) dynamic_cast(H->Hist("Q2vsX_zresSD"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->z - kin->z)/(kinTrue->z) - this->GetMean(H,"Q2vsX_zres"),2) ) ); + kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->z - kin->z)/(kinTrue->z) - this->GetMean2D(H,"Q2vsX_zres"),2) ) ); if(kinTrue->pT!=0) dynamic_cast(H->Hist("Q2vsX_pTresSD"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->pT - kin->pT)/(kinTrue->pT) - this->GetMean(H,"Q2vsX_pTres"),2) ) ); + kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->pT - kin->pT)/(kinTrue->pT) - this->GetMean2D(H,"Q2vsX_pTres"),2) ) ); dynamic_cast(H->Hist("Q2vsX_phiHresSD"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->z - kin->z)/(kinTrue->z) - this->GetMean(H,"Q2vsX_phiHres"),2) ) ); + kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->phiH - kin->phiH) - this->GetMean2D(H,"Q2vsX_phiHres"),2) ) ); }); // execute the payload diff --git a/src/Analysis.h b/src/Analysis.h index b7802f1c..36c718ed 100644 --- a/src/Analysis.h +++ b/src/Analysis.h @@ -102,8 +102,10 @@ class Analysis : public TNamed void FillHistosJetsSD(); // Miscellaneous histogram operations - void npSqrt(Histos *H, TString name); - Double_t GetMean(Histos *H, TString name); + void npSqrt1D(Histos *H, TString name); + Double_t GetMean1D(Histos *H, TString name); + void npSqrt2D(Histos *H, TString name); + Double_t GetMean2D(Histos *H, TString name); // lambda to check which bins an observable is in, during DAG breadth // traversal; it requires `finalStateID`, `valueMap`, and will diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index f17fbd95..37e91d06 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -411,6 +411,8 @@ void PostProcessor::DrawInBins( yaxisy1 = 0.08; }; + double yMin = 0; double yMax = 1;//TODO CHECK THIS WORKS + TString canvN = "canv_"+outName+"_"+histName; TCanvas *canv = new TCanvas(canvN,canvN, canvx, canvy); TPad *mainpad = new TPad("mainpad", "mainpad", 0.07, 0.07, 0.98, 0.98); @@ -442,6 +444,18 @@ void PostProcessor::DrawInBins( //hist->GetYaxis()->SetTitle(""); //hist->GetXaxis()->SetLabelSize(0); //hist->GetYaxis()->SetLabelSize(0); + hist->GetXaxis()->SetTitleSize(0.1); + hist->GetXaxis()->SetTitleOffset(0.5); + hist->GetXaxis()->SetNdivisions(8); + hist->GetXaxis()->SetLabelSize(0.06); + hist->GetYaxis()->SetRangeUser(-15,15);//TODO: CHECK THIS IS REASONABLE ALSO WHAT ABOUT ERROR BARS??? + hist->GetYaxis()->SetNdivisions(8); + hist->GetYaxis()->SetLabelSize(0.06); + // for(int k = 0; k < i; k++){ + // for(int l = 0; l < j; k++){ + // histArray[k][l]->GetYaxis()->SetRangeUser(TMath::Min(yMin,hist->GetYaxis()->GetMinimum(),TMath::Max(yMax,hist->GetYaxis()->GetMaximum()))); + // } + // } mainpad->cd((nvar2-j-1)*nvar1 + i + 1); gPad->SetLogx(intlog1); @@ -461,8 +475,10 @@ void PostProcessor::DrawInBins( break; }; //hist->Write(); - if( hist->GetEntries() > 0 ) { + if( hist->GetEntries() > 0 ) { //TODO come back and do this after setting up all histograms??? hist->Draw(drawStr); + // TF1 *zeroF = new TF1("zeroF","0",0,1); //TODO: Add optional switch for this? + // zeroF->Draw("SAME"); //TODO: Added zero line if(drawpid){ lDIRClow->Draw(); lDIRC->Draw(); From 3964cb91a7c064240eeb24165d6981125ac838cf Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Thu, 4 Nov 2021 11:34:44 -0400 Subject: [PATCH 03/51] Updated z-binned hists in Q2vsx --- macro/analysis_resolution_SD.C | 2 +- macro/postprocess_resolution_SD.C | 25 +++- src/PostProcessor.cxx | 207 ++++++++++++++++++++++++++++-- src/PostProcessor.h | 10 ++ 4 files changed, 227 insertions(+), 17 deletions(-) diff --git a/macro/analysis_resolution_SD.C b/macro/analysis_resolution_SD.C index a4b8c8ab..9f4b5cf9 100644 --- a/macro/analysis_resolution_SD.C +++ b/macro/analysis_resolution_SD.C @@ -17,7 +17,7 @@ void analysis_resolution_SD( crossingAngle, outfilePrefix ); - + A->NBINS = 5; // use this to set the number of bins along each axis for each overall bin in e.g. x and Q2 //A->maxEvents = 30000; // use this to limit the number of events A->SetReconMethod("Ele"); // set reconstruction method A->AddFinalState("pipTrack"); // pion final state diff --git a/macro/postprocess_resolution_SD.C b/macro/postprocess_resolution_SD.C index 684e4cc4..d5d35b8d 100644 --- a/macro/postprocess_resolution_SD.C +++ b/macro/postprocess_resolution_SD.C @@ -59,6 +59,17 @@ void postprocess_resolution_SD( "Q^{2}", nq2, q2Min, q2Max, true ); }; + // int nNames = 6;//Don't forget to change both nNames and allocation # below! + // TString histNames[6] = {"z_q2resSD","z_xresSD","z_yresSD","z_zresSD","z_pTresSD","z_phiHresSD"};//,"z_yresSD","z_zresSD","z_pTresSD","z_phiHresSD"}; + // TString labels[6] = {"Q^{2}","x","y","z","p_{T}","#phi_{H}"}; + int nNames = 2; + TString histNames[2] = {"z_q2resSD","z_xresSD"};//,"z_yresSD","z_zresSD","z_pTresSD","z_phiHresSD"}; + TString labels[2] = {"Q^{2}","x"}; + P->DrawInBinsTogether( + canvname, histos_xQ2, histNames, labels, nNames, + "x", nx, xMin, xMax, true, + "Q^{2}", nq2, q2Min, q2Max, true + ); }; auto beforefunction = [](){ @@ -67,13 +78,13 @@ void postprocess_resolution_SD( P->Op()->Subloop({"x","q2"},beforefunction,drawinxQ2bins); P->Op()->Payload(findxQ2bins); - //DEBUGGING - P->Op()->Payload([&P](Histos *H) { - P->DrawSingle(H,"Q2vsX_q2resSD","COLZ"); - } - ); - //END DEBUGGING - + // //DEBUGGING + // P->Op()->Payload([&P](Histos *H) { + // P->DrawSingle(H,"Q2vsX_q2resSD","COLZ"); + // } + // ); + // //END DEBUGGING + //P->Op()->PrintBreadth("HistosDAG Final Setup"); P->Execute(); diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index 37e91d06..0db3c0f2 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -437,25 +437,29 @@ void PostProcessor::DrawInBins( for(int j = 0; j < nvar2; j++){ //Histos *H = (Histos*) infile->Get(histList[i][j]); Histos *H = histList[i][j]; + // INTRODUCE LOOP OVER HISTNAMES HERE -> TURN INTO MULTIGRAPHS AND SHOW PERSPECTIVE WISE TH1 *hist = H->Hist(histName); histArray[i][j] = hist; hist->SetTitle(""); - //hist->GetXaxis()->SetTitle(""); - //hist->GetYaxis()->SetTitle(""); - //hist->GetXaxis()->SetLabelSize(0); - //hist->GetYaxis()->SetLabelSize(0); + // //hist->GetXaxis()->SetTitle(""); + // //hist->GetYaxis()->SetTitle(""); + // //hist->GetXaxis()->SetLabelSize(0); + // //hist->GetYaxis()->SetLabelSize(0); hist->GetXaxis()->SetTitleSize(0.1); hist->GetXaxis()->SetTitleOffset(0.5); hist->GetXaxis()->SetNdivisions(8); hist->GetXaxis()->SetLabelSize(0.06); + hist->GetXaxis()->CenterTitle(); + hist->GetXaxis()->SetLabelOffset(0.02); hist->GetYaxis()->SetRangeUser(-15,15);//TODO: CHECK THIS IS REASONABLE ALSO WHAT ABOUT ERROR BARS??? hist->GetYaxis()->SetNdivisions(8); hist->GetYaxis()->SetLabelSize(0.06); - // for(int k = 0; k < i; k++){ - // for(int l = 0; l < j; k++){ - // histArray[k][l]->GetYaxis()->SetRangeUser(TMath::Min(yMin,hist->GetYaxis()->GetMinimum(),TMath::Max(yMax,hist->GetYaxis()->GetMaximum()))); - // } - // } + hist->GetYaxis()->SetLabelOffset(0.02); + // // for(int k = 0; k < i; k++){ + // // for(int l = 0; l < j; k++){ + // // histArray[k][l]->GetYaxis()->SetRangeUser(TMath::Min(yMin,hist->GetYaxis()->GetMinimum(),TMath::Max(yMax,hist->GetYaxis()->GetMaximum()))); + // // } + // // } mainpad->cd((nvar2-j-1)*nvar1 + i + 1); gPad->SetLogx(intlog1); @@ -537,6 +541,191 @@ void PostProcessor::DrawInBins( } }; +//========================================================================= +/* ALGORITHM: draw histograms from different bins in their respective bins +on axis of bin variables, e.g. Q2 vs x. +*/ +void PostProcessor::DrawInBinsTogether( + TString outName, + std::vector>& histList, + TString histNames[], TString labels[], int nNames, + TString var1name, int nvar1, double var1low, double var1high, bool var1log, + TString var2name, int nvar2, double var2low, double var2high, bool var2log, + bool intlog1, bool intlog2, bool intgrid1, bool intgrid2 // log option for small plots + +){ + // default values set for nvar1==nvar2 + int canvx = 933;//700; + int canvy = 800;//600;//TODO: check new numbers are better? + double botmargin = 0.2; + double leftmargin = 0.2; + double xaxisy = 0.04; + double xaxisx1 = 0.08; + double xaxisx2 = 0.97; + double yaxisx = 0.04; + double yaxisy1 = 0.085; + double yaxisy2 = 0.97; + if(nvar1 > nvar2){ + // different canvas sizing/axis position for unequal binning + canvx = 1100; + canvy = 700; + xaxisx1 = 0.075; + xaxisx2 = 0.975; + yaxisy1 = 0.08; + }; + + TString canvN = "canv_"+outName+"_all__"; + for (int k=0; kSetFillStyle(4000); + mainpad->Divide(nvar1,nvar2,0,0); + mainpad->Draw(); + TLine * lDIRC = new TLine(6,-1,6,1); + TLine * lDIRClow = new TLine(0.5,-1,0.5,1); + TLine * lmRICH = new TLine(2,-1,2,-4); + TLine * lDRICH = new TLine(2.5,1,2.5,4); + lDIRC->SetLineColor(kRed); + lDIRClow->SetLineColor(kRed); + lmRICH->SetLineColor(kRed); + lDRICH->SetLineColor(kRed); + THStack* histArray[nvar1][nvar2]; + int drawpid = 0; + outfile->cd("/"); + canv->Write(); + // get histograms from Histos 2D vector + for(int i = 0; i < nvar1; i++){ + for(int j = 0; j < nvar2; j++){ + //Histos *H = (Histos*) infile->Get(histList[i][j]); + Histos *H = histList[i][j]; + + THStack *hist = new THStack(); + TLegend *lg = new TLegend(0.1,0.1,0.9,0.9); + lg->SetTextSize(0.2); + + for (int k=0; kHist(histNames[k])->Clone(); + subHist->SetTitle(""); + //subHist->GetXaxis()->SetTitle(""); + //subHist->GetYaxis()->SetTitle(""); + //subHist->GetXaxis()->SetLabelSize(0); + //subHist->GetYaxis()->SetLabelSize(0); + + subHist->GetXaxis()->SetTitleSize(0.1); + subHist->GetXaxis()->SetTitleOffset(0.5); + subHist->GetXaxis()->SetNdivisions(8); + subHist->GetXaxis()->SetLabelSize(0.06); + subHist->GetXaxis()->CenterTitle(); + subHist->GetXaxis()->SetLabelOffset(0.02); + subHist->GetYaxis()->SetRangeUser(-15,15);//TODO: CHECK THIS IS REASONABLE ALSO WHAT ABOUT ERROR BARS??? + subHist->GetYaxis()->SetNdivisions(8); + subHist->GetYaxis()->SetLabelSize(0.06); + subHist->GetYaxis()->SetLabelOffset(0.02); + + subHist->SetTitle(histNames[k]); + subHist->SetMarkerStyle(k+24); + subHist->SetMarkerColor(k+2); + if (k+2>=5) subHist->SetMarkerColor(k+3); //NOTE: 5 is yellow: very hard to see. + subHist->SetMarkerSize(0.5);//NOTE: Remember these will be small plots so keep the binning small and the markers big + if ( subHist->GetEntries() > 10 ) { + hist->Add(subHist); + std::cout<<"DEBUGGING: Added hist:"<cd((nvar2-j-1)*nvar1 + i + 1); + gPad->SetLogx(intlog1); + gPad->SetLogy(intlog2); + gPad->SetGridy(intgrid2); + gPad->SetGridx(intgrid1); + TString drawStr = ""; + switch(1) {//TODO: figure out how to get THStack dimension? //can't use hist->GetHistogram()->GetDimension() + case 1: + drawStr = "hist p nostack"/*"ex0 p nostack"*/;//NOTE: nostackb will just throw an error, don't use + break; + case 2: + drawStr = "COLZ"; + break; + case 3: + drawStr = "BOX"; + break; + }; + //hist->Write(); + if( hist->GetNhists() > 0 ) { + hist->Draw(drawStr); + if (i==0 && j==0) { + mainpad->cd(1);// Upper left corner pad + lg->Draw(); + mainpad->cd((nvar2-j-1)*nvar1 + i + 1);// Return to original pad + } + if(drawpid){ + lDIRClow->Draw(); + lDIRC->Draw(); + lmRICH->Draw(); + lDRICH->Draw(); + } + } + }; + }; + canv->cd(); + + TPad *newpad1 = new TPad("newpad1","full pad",0,0,1,1); + TPad *newpad2 = new TPad("newpad2","full pad",0,0,1,1); + newpad1->SetFillStyle(4000); + newpad1->Draw(); + newpad2->SetFillStyle(4000); + newpad2->Draw(); + + TString xopt, yopt; + if(var1log) xopt = "GS"; + else xopt = "S"; + if(var2log) yopt = "GS"; + else yopt = "S"; + + TGaxis *xaxis = new TGaxis(xaxisx1,xaxisy,xaxisx2,xaxisy,var1low,var1high,510,xopt); + TGaxis *yaxis = new TGaxis(yaxisx,yaxisy1,yaxisx,yaxisy2,var2low,var2high,510,yopt); + xaxis->SetTitle(var1name); + xaxis->SetName("xaxis"); + xaxis->SetTitleSize(0.02); + xaxis->SetTextFont(40); + xaxis->SetLabelSize(0.02); + xaxis->SetTickSize(0.02); + + yaxis->SetTitle(var2name); + yaxis->SetTitleSize(0.02); + yaxis->SetName("yaxis"); + yaxis->SetTextFont(40); + yaxis->SetLabelSize(0.02); + yaxis->SetTickSize(0.02); + + newpad1->cd(); + yaxis->Draw(); + newpad2->cd(); + xaxis->Draw(); + + + // canv->Write(); + canv->Print(pngDir+"/"+canvN+".png"); + canv->Print(pngDir+"/"+canvN+".pdf"); + outfile->cd("/"); + canv->Write(); + for(int i = 0; i Write(); + } + } +}; + //========================================================================= /* ALGORITHM: draw a ratio of all 1D histograms in the specified histogram set diff --git a/src/PostProcessor.h b/src/PostProcessor.h index 128c3a6e..54566f81 100644 --- a/src/PostProcessor.h +++ b/src/PostProcessor.h @@ -12,6 +12,8 @@ #include "TROOT.h" #include "TStyle.h" #include "TGaxis.h" +#include "THStack.h" +#include "TLegend.h" // largex-eic #include "Histos.h" @@ -75,6 +77,14 @@ class PostProcessor : public TNamed bool intlog1=false, bool intlog2=false, bool intgrid1=false, bool intgrid2=false ); + void DrawInBinsTogether( + TString outName, + std::vector>& histList, TString histNames[], TString labels[], int nNames, + TString var1name, int nvar1, double var1low, double var1high, bool var1log, + TString var2name, int nvar2, double var2low, double var2high, bool var2log, + bool intlog1=false, bool intlog2=false, bool intgrid1=false, bool intgrid2=false + ); + // algorithm finish methods; to be called after loops void FinishDumpAve(TString datFile); void FinishDrawRatios(TString summaryDir); From e7b3f08df436b79cb3ece0cd37a9f3d473222e86 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Tue, 9 Nov 2021 16:04:33 -0500 Subject: [PATCH 04/51] Updated resolution plots to use Gaussian fits --- macro/analysis_resolution_SD.C | 7 +- macro/postprocess_resolution_SD.C | 24 +-- src/Analysis.cxx | 304 +++--------------------------- src/Analysis.h | 11 +- src/AnalysisDelphes.cxx | 151 --------------- src/PostProcessor.cxx | 85 +++++++-- src/PostProcessor.h | 10 +- 7 files changed, 126 insertions(+), 466 deletions(-) diff --git a/macro/analysis_resolution_SD.C b/macro/analysis_resolution_SD.C index 9f4b5cf9..8b4de7f2 100644 --- a/macro/analysis_resolution_SD.C +++ b/macro/analysis_resolution_SD.C @@ -2,7 +2,7 @@ R__LOAD_LIBRARY(Largex) // make resolution plots void analysis_resolution_SD( - TString infiles="datarec/tutorial.config", /* list of input files */ + TString infiles="datarec/test.config", /* list of input files */ Double_t eleBeamEn=5, /* electron beam energy [GeV] */ Double_t ionBeamEn=41, /* ion beam energy [GeV] */ Double_t crossingAngle=0, /* crossing angle [mrad] */ @@ -17,7 +17,10 @@ void analysis_resolution_SD( crossingAngle, outfilePrefix ); - A->NBINS = 5; // use this to set the number of bins along each axis for each overall bin in e.g. x and Q2 + A->NBINS = 5; // use this to set the number of bins along each axis, e.g., z binning (except resolution axes) for each overall bin in e.g. x and Q2 + A->NBINSRES = 100; // use this to set the number of bins along the resolution axes for each overall bin in e.g. x and Q2 + // A->RESHIGH = 1; + // A->RESLOW = -1; //A->maxEvents = 30000; // use this to limit the number of events A->SetReconMethod("Ele"); // set reconstruction method A->AddFinalState("pipTrack"); // pion final state diff --git a/macro/postprocess_resolution_SD.C b/macro/postprocess_resolution_SD.C index d5d35b8d..8bb061b2 100644 --- a/macro/postprocess_resolution_SD.C +++ b/macro/postprocess_resolution_SD.C @@ -52,21 +52,20 @@ void postprocess_resolution_SD( // loop over resolution histograms (see ../src/Analysis.cxx `DefineHist*` calls // for available histograms, or add your own there) - for( TString histname : {"x_Res","y_Res","Q2_Res","phiH_Res","phiS_Res","phiHvsPhiS","z_purity","z_q2resSD","z_xresSD","z_yresSD","z_zresSD","z_pTresSD","z_phiHresSD"} ) { + for( TString histname : {"x_Res","y_Res","Q2_Res","phiH_Res","phiS_Res","phiHvsPhiS","z_purity"} ) { P->DrawInBins( canvname, histos_xQ2, histname, "x", nx, xMin, xMax, true, "Q^{2}", nq2, q2Min, q2Max, true ); }; - // int nNames = 6;//Don't forget to change both nNames and allocation # below! - // TString histNames[6] = {"z_q2resSD","z_xresSD","z_yresSD","z_zresSD","z_pTresSD","z_phiHresSD"};//,"z_yresSD","z_zresSD","z_pTresSD","z_phiHresSD"}; - // TString labels[6] = {"Q^{2}","x","y","z","p_{T}","#phi_{H}"}; - int nNames = 2; - TString histNames[2] = {"z_q2resSD","z_xresSD"};//,"z_yresSD","z_zresSD","z_pTresSD","z_phiHresSD"}; - TString labels[2] = {"Q^{2}","x"}; - P->DrawInBinsTogether( - canvname, histos_xQ2, histNames, labels, nNames, + + const int nNames = 2; + double yMin, yMax; yMin = -0.1; yMax = 0.5;//Adjust as needed + TString histNames[nNames] = {"z_Q2_Res","z_x_Res"};//,"z_y_Res","z_z_Res","z_pT_Res","z_phiH_Res","z_phiS_Res"}; + TString labels[nNames] = {"Q^{2}","x"}; + P->DrawSDInBinsTogether( + canvname, histos_xQ2, histNames, labels, nNames, yMin, yMax, "x", nx, xMin, xMax, true, "Q^{2}", nq2, q2Min, q2Max, true ); @@ -78,13 +77,6 @@ void postprocess_resolution_SD( P->Op()->Subloop({"x","q2"},beforefunction,drawinxQ2bins); P->Op()->Payload(findxQ2bins); - // //DEBUGGING - // P->Op()->Payload([&P](Histos *H) { - // P->DrawSingle(H,"Q2vsX_q2resSD","COLZ"); - // } - // ); - // //END DEBUGGING - //P->Op()->PrintBreadth("HistosDAG Final Setup"); P->Execute(); diff --git a/src/Analysis.cxx b/src/Analysis.cxx index dc75dade..bcf544f7 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -259,29 +259,26 @@ void Analysis::Prepare() { HS->DefineHist1D("jperp","j_{#perp}","GeV", NBINS, 0, 3.0); HS->DefineHist1D("qTQ_jet","jet q_{T}/Q","", NBINS, 0, 3.0); // -- resolutions - HS->DefineHist1D("x_Res","x-x_{true}","", NBINS, -2, 2); - HS->DefineHist1D("y_Res","y-y_{true}","", NBINS, -2, 2); - HS->DefineHist1D("Q2_Res","Q2-Q2_{true}","GeV", NBINS, -2, 2); - HS->DefineHist1D("phiH_Res","#phi_{h}-#phi_{h}^{true}","", NBINS, -TMath::Pi(), TMath::Pi()); - HS->DefineHist1D("phiS_Res","#phi_{S}-#phi_{S}^{true}","", NBINS, -TMath::Pi(), TMath::Pi()); - - // 1D z-binned resolutions + HS->DefineHist1D("Q2_Res","Q2_{true}-Q2","GeV^{2}", NBINS, -2, 2); + HS->DefineHist1D("x_Res","x_{true}-x","", NBINS, -2, 2); + HS->DefineHist1D("y_Res","y_{true}-y","", NBINS, -2, 2); + HS->DefineHist1D("z_Res","z_{true}-z","", NBINS, -2, 2); + HS->DefineHist1D("pT_Res","pT_{true}-pT","GeV", NBINS, -2, 2); + HS->DefineHist1D("phiH_Res","#phi_{h}^{true}-#phi_{h}","", NBINS, -TMath::Pi(), TMath::Pi()); + HS->DefineHist1D("phiS_Res","#phi_{S}^{true}-#phi_{S}","", NBINS, -TMath::Pi(), TMath::Pi()); + + // resolutions vs. z on x axis. + HS->DefineHist2D("z_Q2_Res","z","","#sigma_{Q2}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5);//TODO: Fill these + HS->DefineHist2D("z_x_Res","z","","#sigma_{x}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); + HS->DefineHist2D("z_y_Res","z","","#sigma_{y}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); + HS->DefineHist2D("z_z_Res","z","","#sigma_{z}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); + HS->DefineHist2D("z_pT_Res","z","","#sigma_{pT}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); + HS->DefineHist2D("z_phiH_Res","z","","#sigma_{#phi_{h}^{true}}","", NBINS, 0, 1, NBINSRES, -TMath::Pi(), TMath::Pi()); + HS->DefineHist2D("z_phiS_Res","z","","#sigma_{#phi_{S}^{true}}","", NBINS, 0, 1, NBINSRES, -TMath::Pi(), TMath::Pi()); + + // 1D z-binned counts and summed resolutions HS->DefineHist1D("z_true","z","", NBINS, 0, 1); HS->DefineHist1D("z_purity","purity","", NBINS, 0, 1); - HS->DefineHist1D("z_q2res","z","", NBINS, 0, 1); - HS->DefineHist1D("z_xres","z","", NBINS, 0, 1); - HS->DefineHist1D("z_yres","z","", NBINS, 0, 1); - HS->DefineHist1D("z_zres","z","", NBINS, 0, 1); - HS->DefineHist1D("z_pTres","z","", NBINS, 0, 1); - HS->DefineHist1D("z_phiHres","z","", NBINS, 0, 1); - // 1D z-binned resolutions StdDevs - // HS->DefineHist1D("z_puritySD","z","", NBINS, 0, 1); - HS->DefineHist1D("z_q2resSD","z","", NBINS, 0, 1); - HS->DefineHist1D("z_xresSD","z","", NBINS, 0, 1); - HS->DefineHist1D("z_yresSD","z","", NBINS, 0, 1); - HS->DefineHist1D("z_zresSD","z","", NBINS, 0, 1); - HS->DefineHist1D("z_pTresSD","z","", NBINS, 0, 1); - HS->DefineHist1D("z_phiHresSD","z","", NBINS, 0, 1); // 2D Q2 vs. x binned resolutions HS->DefineHist2D("Q2vsXtrue","x","Q^{2}","","GeV^{2}", @@ -292,72 +289,8 @@ void Analysis::Prepare() { NBINS,1,100, true,true ); - HS->DefineHist2D("Q2vsXpurity","x","Q^{2}","","GeV^{2}", - NBINS,1e-3,1, - NBINS,1,100, - true,true - ); - HS->DefineHist2D("Q2vsX_q2res","x","Q^{2}","","GeV^{2}", - NBINS,1e-3,1, - NBINS,1,100, - true,true - ); - HS->DefineHist2D("Q2vsX_xres","x","Q^{2}","","GeV^{2}", - NBINS,1e-3,1, - NBINS,1,100, - true,true - ); - HS->DefineHist2D("Q2vsX_yres","x","Q^{2}","","GeV^{2}", - NBINS,1e-3,1, - NBINS,1,100, - true,true - ); - HS->DefineHist2D("Q2vsX_zres","x","Q^{2}","","GeV^{2}", - NBINS,1e-3,1, - NBINS,1,100, - true,true - ); - HS->DefineHist2D("Q2vsX_pTres","x","Q^{2}","","GeV^{2}", - NBINS,1e-3,1, - NBINS,1,100, - true,true - ); - HS->DefineHist2D("Q2vsX_phiHres","x","Q^{2}","","GeV^{2}", - NBINS,1e-3,1, - NBINS,1,100, - true,true - ); - // 2D Q2 vs. x resolutions StdDevs - HS->DefineHist2D("Q2vsX_q2resSD","x","Q^{2}","","GeV^{2}", - NBINS,1e-3,1, - NBINS,1,100, - true,true - ); - HS->DefineHist2D("Q2vsX_xresSD","x","Q^{2}","","GeV^{2}", - NBINS,1e-3,1, - NBINS,1,100, - true,true - ); - HS->DefineHist2D("Q2vsX_yresSD","x","Q^{2}","","GeV^{2}", - NBINS,1e-3,1, - NBINS,1,100, - true,true - ); - HS->DefineHist2D("Q2vsX_zresSD","x","Q^{2}","","GeV^{2}", - NBINS,1e-3,1, - NBINS,1,100, - true,true - ); - HS->DefineHist2D("Q2vsX_pTresSD","x","Q^{2}","","GeV^{2}", - NBINS,1e-3,1, - NBINS,1,100, - true,true - ); - HS->DefineHist2D("Q2vsX_phiHresSD","x","Q^{2}","","GeV^{2}", - NBINS,1e-3,1, - NBINS,1,100, - true,true - ); + + // -- reconstructed vs. generated HS->DefineHist2D("x_RvG","generated x","reconstructed x","","", NBINS,1e-3,1, @@ -415,69 +348,6 @@ Int_t Analysis::GetEventQ2Idx(Double_t Q2, Int_t guess) { } } -//TODO: Find a better place for the following functions -/** -* Element-wise sqrt function for 1D histograms like in numpy. -* Modifies histogram in place. -*/ -void Analysis::npSqrt1D(Histos *H, TString name) { - int zBins; - - // Get axes' # bins - zBins = H->Hist(name)->GetXaxis()->GetNbins(); - - // Loop z binned histogram - for (int i=1;i<=zBins;i++) { - H->Hist(name)->SetBinContent(i,TMath::Sqrt(H->Hist(name)->GetBinContent(i))); - } -} - -/** -* Element-wise sqrt function for 2D histograms like in numpy. -* Modifies histogram in place. -*/ -void Analysis::npSqrt2D(Histos *H, TString name) { - int xBins, q2Bins; - - // Get axes' # bins - xBins = dynamic_cast(H->Hist(name))->GetXaxis()->GetNbins(); - q2Bins = dynamic_cast(H->Hist(name))->GetYaxis()->GetNbins(); - - // Loop x vs. Q2 histogram - for (int i=1;i<=xBins;i++) { - for (int j=1;j<=q2Bins;j++){ - dynamic_cast(H->Hist(name))->SetBinContent(i,j,TMath::Sqrt(dynamic_cast(H->Hist(name))->GetBinContent(i,j))); - } - } -} - -/** -* Get mean counts per bin for 1D histogram. -*/ -Double_t Analysis::GetMean1D(Histos *H, TString name) { - int zBins; - Double_t counts; - - // Get axes' # bins - counts = dynamic_cast(H->Hist(name))->GetSum(); - zBins = H->Hist(name)->GetXaxis()->GetNbins(); - return counts / zBins; -} - -/** -* Get mean counts per bin for 2D histogram. -*/ -Double_t Analysis::GetMean2D(Histos *H, TString name) { - int xBins, q2Bins; - Double_t counts; - - // Get axes' # bins - counts = dynamic_cast(H->Hist(name))->GetSum(); - xBins = dynamic_cast(H->Hist(name))->GetXaxis()->GetNbins(); - q2Bins = dynamic_cast(H->Hist(name))->GetYaxis()->GetNbins(); - return counts / (xBins * q2Bins); -} - // finish the analysis //----------------------------------- void Analysis::Finish() { @@ -501,45 +371,9 @@ void Analysis::Finish() { // calculate cross sections H->Hist("Q_xsec")->Scale(1./lumi); // TODO: generalize (`if (name contains "xsec") ...`) - // Normalize and sqrt 1D z-binned resolution StdDevs + // // Normalize and sqrt 1D z-binned resolution StdDevs H->Hist("z_purity")->Divide(H->Hist("z_true")); - H->Hist("z_q2resSD")->Divide(H->Hist("z_true")); - H->Hist("z_xresSD")->Divide(H->Hist("z_true")); - H->Hist("z_yresSD")->Divide(H->Hist("z_true")); - H->Hist("z_zresSD")->Divide(H->Hist("z_true")); - H->Hist("z_pTresSD")->Divide(H->Hist("z_true")); - H->Hist("z_phiHresSD")->Divide(H->Hist("z_true")); - this->npSqrt1D(H,"z_q2resSD"); //NOTE: Important: Take sqrt() AFTER normalizing. - this->npSqrt1D(H,"z_xresSD"); - this->npSqrt1D(H,"z_yresSD"); - this->npSqrt1D(H,"z_zresSD"); - this->npSqrt1D(H,"z_pTresSD"); - this->npSqrt1D(H,"z_phiHresSD"); - - //DEBUGGING - cout << "DEBUGGING z_purity: " << H->Hist("z_purity")->GetMean() << std::endl; - cout << "DEBUGGING z_q2res: " << H->Hist("z_q2res")->GetMean() << std::endl; - cout << "DEBUGGING z_q2resSD: " << H->Hist("z_q2resSD")->GetMean() << std::endl; - - // Normalize and sqrt 2D Q2 vs. x binned resolution StdDevs - H->Hist("Q2vsXpurity")->Divide(H->Hist("Q2vsXtrue")); - H->Hist("Q2vsX_q2resSD")->Divide(H->Hist("Q2vsXtrue")); - H->Hist("Q2vsX_xresSD")->Divide(H->Hist("Q2vsXtrue")); - H->Hist("Q2vsX_yresSD")->Divide(H->Hist("Q2vsXtrue")); - H->Hist("Q2vsX_zresSD")->Divide(H->Hist("Q2vsXtrue")); - H->Hist("Q2vsX_pTresSD")->Divide(H->Hist("Q2vsXtrue")); - H->Hist("Q2vsX_phiHresSD")->Divide(H->Hist("Q2vsXtrue")); - this->npSqrt2D(H,"Q2vsX_q2resSD"); //NOTE: Important: Take sqrt() AFTER normalizing. - this->npSqrt2D(H,"Q2vsX_xresSD"); - this->npSqrt2D(H,"Q2vsX_yresSD"); - this->npSqrt2D(H,"Q2vsX_zresSD"); - this->npSqrt2D(H,"Q2vsX_pTresSD"); - this->npSqrt2D(H,"Q2vsX_phiHresSD"); - - //DEBUGGING - cout << "DEBUGGING Q2vsXpurity: " << H->Hist("Q2vsXpurity")->GetMean() << std::endl; - cout << "DEBUGGING Q2vsX_q2res: " << H->Hist("Q2vsX_q2res")->GetMean() << std::endl; - cout << "DEBUGGING Q2vsX_q2resSD: " << H->Hist("Q2vsX_q2resSD")->GetMean() << std::endl; + }); HD->ExecuteAndClearOps(); @@ -720,28 +554,17 @@ void Analysis::FillHistosTracks() { H->Hist("phiS_Res")->Fill( Kinematics::AdjAngle(kin->phiS - kinTrue->phiS), wTrack ); // z binned resolutions + if(kinTrue->Q2!=0) dynamic_cast(H->Hist("z_Q2_Res"))->Fill( kinTrue->z, (kinTrue->Q2 - kin->Q2)/kinTrue->Q2, wTrack ); + if(kinTrue->z!=0) dynamic_cast(H->Hist("z_x_Res"))->Fill( kinTrue->z, (kinTrue->x - kin->x)/kinTrue->x, wTrack ); + if(kinTrue->y!=0) dynamic_cast(H->Hist("z_y_Res"))->Fill( kinTrue->z, (kinTrue->y - kin->y)/kinTrue->y, wTrack ); + if(kinTrue->z!=0) dynamic_cast(H->Hist("z_z_Res"))->Fill( kinTrue->z, (kinTrue->z - kin->z)/kinTrue->z, wTrack ); + if(kinTrue->pT!=0) dynamic_cast(H->Hist("z_pT_Res"))->Fill( kinTrue->z, (kinTrue->pT - kin->pT)/kinTrue->pT, wTrack ); + dynamic_cast(H->Hist("z_phiH_Res"))->Fill( kinTrue->z, Kinematics::AdjAngle(kin->phiH - kinTrue->phiH), wTrack ); + dynamic_cast(H->Hist("z_phiS_Res"))->Fill( kinTrue->z, Kinematics::AdjAngle(kin->phiS - kinTrue->phiS), wTrack ); + + // purities H->Hist("z_true")->Fill(kinTrue->z, wTrack ); if( (H->Hist("z_true"))->FindBin(kinTrue->z) == (H->Hist("z_true"))->FindBin(kin->z) ) H->Hist("z_purity")->Fill(kin->z,wTrack); - if(kinTrue->Q2!=0) H->Hist("z_q2res")->Fill( kinTrue->z, (kinTrue->Q2 - kinTrue->Q2)/kinTrue->Q2 * wTrack ); - if(kinTrue->x!=0) H->Hist("z_xres")->Fill( kinTrue->z, (kinTrue->x - kin->x)/kinTrue->x * wTrack ); - if(kinTrue->y!=0) H->Hist("z_yres")->Fill( kinTrue->z, (kinTrue->y - kin->y)/kinTrue->y * wTrack ); - if(kinTrue->z!=0) H->Hist("z_zres")->Fill( kinTrue->z, (kinTrue->z - kin->z)/kinTrue->z * wTrack ); - if(kinTrue->pT!=0) H->Hist("z_pTres")->Fill( kinTrue->z, (kinTrue->pT - kin->pT)/kinTrue->pT * wTrack ); - H->Hist("z_phiHres")->Fill( kinTrue->z, (kinTrue->phiH - kin->phiH) * wTrack ); - - // Q2 vs. x binned resolutions - dynamic_cast(H->Hist("Q2vsXtrue"))->Fill(kinTrue->x,kinTrue->Q2,wTrack); - if(kinTrue->Q2!=0) dynamic_cast(H->Hist("Q2vsX_q2res"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( (kinTrue->Q2 - kin->Q2)/(kinTrue->Q2) ) ); - if(kinTrue->x!=0) dynamic_cast(H->Hist("Q2vsX_xres"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( (kinTrue->x - kin->x)/(kinTrue->x) ) ); - if(kinTrue->y!=0) dynamic_cast(H->Hist("Q2vsX_yres"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( (kinTrue->y - kin->y)/(kinTrue->y) ) ); - if(kinTrue->z!=0) dynamic_cast(H->Hist("Q2vsX_zres"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( (kinTrue->z - kin->z)/(kinTrue->z) ) ); - if(kinTrue->pT!=0) dynamic_cast(H->Hist("Q2vsX_pTres"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( (kinTrue->pT - kin->pT)/(kinTrue->pT) ) ); - dynamic_cast(H->Hist("Q2vsX_phiHres"))->Fill(kinTrue->x,kinTrue->Q2,wTrack*( (kinTrue->phiH - kin->phiH) ) ); if( (H->Hist("Q2vsXtrue"))->FindBin(kinTrue->x,kinTrue->Q2) == (H->Hist("Q2vsXtrue"))->FindBin(kin->x,kin->Q2) ) dynamic_cast(H->Hist("Q2vsXpurity"))->Fill(kin->x,kin->Q2,wTrack); @@ -757,71 +580,6 @@ void Analysis::FillHistosTracks() { HD->ExecuteOps(true); }; -//-------------------------------------------------------------------------- -// tracks (single particles) (StdDevs) -void Analysis::FillHistosTracksSD() { - - // add kinematic values to `valueMap` - valueMap.clear(); - activeEvent = false; - /* DIS */ - valueMap.insert(std::pair( "x", kin->x )); - valueMap.insert(std::pair( "q2", kin->Q2 )); - valueMap.insert(std::pair( "w", kin->W )); - valueMap.insert(std::pair( "y", kin->y )); - /* single hadron */ - valueMap.insert(std::pair( "p", kin->pLab )); - valueMap.insert(std::pair( "eta", kin->etaLab )); - valueMap.insert(std::pair( "pt", kin->pT )); - valueMap.insert(std::pair( "ptLab", kin->pTlab )); - valueMap.insert(std::pair( "z", kin->z )); - valueMap.insert(std::pair( "qT", kin->qT )); - valueMap.insert(std::pair( "qTq", kin->qT/TMath::Sqrt(kin->Q2) )); - valueMap.insert(std::pair( "mX", kin->mX )); - valueMap.insert(std::pair( "xF", kin->xF )); - valueMap.insert(std::pair( "phiH", kin->phiH )); - valueMap.insert(std::pair( "phiS", kin->phiS )); - valueMap.insert(std::pair( "tSpin", (Double_t)kin->tSpin )); - - // check bins - // - activates HistosDAG bin nodes which contain this track - // - sets `activeEvent` if there is at least one multidimensional bin to fill - HD->TraverseBreadth(CheckBin()); - if(!activeEvent) return; - - // fill histograms, for activated bins only - HD->Payload([this](Histos *H){ - - // z binned resolution StdDevs - if(kinTrue->Q2!=0) H->Hist("z_q2resSD")->Fill( kinTrue->z, wTrack * TMath::Power( (kinTrue->Q2 - kin->Q2)/kinTrue->Q2 - this->GetMean1D(H,"z_q2res"),2) ); - if(kinTrue->x!=0) H->Hist("z_xresSD")->Fill( kinTrue->z, wTrack * TMath::Power( (kinTrue->x - kin->x)/kinTrue->x - this->GetMean1D(H,"z_xres"),2) ); - if(kinTrue->y!=0) H->Hist("z_yresSD")->Fill( kinTrue->z, wTrack * TMath::Power( (kinTrue->y - kin->y)/kinTrue->y - this->GetMean1D(H,"z_yres"),2) ); - if(kinTrue->z!=0) H->Hist("z_zresSD")->Fill( kinTrue->z, wTrack * TMath::Power( (kinTrue->z - kin->z)/kinTrue->z - this->GetMean1D(H,"z_zres"),2) ); - if(kinTrue->pT!=0) H->Hist("z_pTresSD")->Fill( kinTrue->z, wTrack * TMath::Power( (kinTrue->pT - kin->pT)/kinTrue->pT - this->GetMean1D(H,"z_pTres"),2) ); - H->Hist("z_phiHresSD")->Fill( kinTrue->z, wTrack * TMath::Power( (kinTrue->phiH - kin->phiH) -this->GetMean1D(H,"z_phiHres"),2) ); - - // Q2 vs. x resolution StdDevs - if(kinTrue->Q2!=0) dynamic_cast(H->Hist("Q2vsX_q2resSD"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->Q2 - kin->Q2)/(kinTrue->Q2) - this->GetMean2D(H,"Q2vsX_q2res"),2) ) ); - if(kinTrue->x!=0) dynamic_cast(H->Hist("Q2vsX_xresSD"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->x - kin->x)/(kinTrue->x) - this->GetMean2D(H,"Q2vsX_xres"),2) ) ); - if(kinTrue->y!=0) dynamic_cast(H->Hist("Q2vsX_yresSD"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->y - kin->y)/(kinTrue->y) - this->GetMean2D(H,"Q2vsX_yres"),2) ) ); - if(kinTrue->z!=0) dynamic_cast(H->Hist("Q2vsX_zresSD"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->z - kin->z)/(kinTrue->z) - this->GetMean2D(H,"Q2vsX_zres"),2) ) ); - if(kinTrue->pT!=0) dynamic_cast(H->Hist("Q2vsX_pTresSD"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->pT - kin->pT)/(kinTrue->pT) - this->GetMean2D(H,"Q2vsX_pTres"),2) ) ); - dynamic_cast(H->Hist("Q2vsX_phiHresSD"))->Fill( - kinTrue->x,kinTrue->Q2,wTrack*( TMath::Power((kinTrue->phiH - kin->phiH) - this->GetMean2D(H,"Q2vsX_phiHres"),2) ) ); - - }); - // execute the payload - // - save time and don't call `ClearOps` (next loop will overwrite lambda) - // - called with `activeNodesOnly==true` since we only want to fill bins associated - // with this track - HD->ExecuteOps(true); -}; - // jets void Analysis::FillHistosJets() { diff --git a/src/Analysis.h b/src/Analysis.h index 36c718ed..76e014be 100644 --- a/src/Analysis.h +++ b/src/Analysis.h @@ -46,7 +46,8 @@ class Analysis : public TNamed ~Analysis(); // number of bins for histograms - Int_t NBINS = 50; + Int_t NBINS = 50; + Int_t NBINSRES = 50; const Int_t NBINS_FULL = 10; // bin schemes @@ -97,15 +98,7 @@ class Analysis : public TNamed // FillHistos methods: fill histograms void FillHistosTracks(); - void FillHistosTracksSD(); void FillHistosJets(); - void FillHistosJetsSD(); - - // Miscellaneous histogram operations - void npSqrt1D(Histos *H, TString name); - Double_t GetMean1D(Histos *H, TString name); - void npSqrt2D(Histos *H, TString name); - Double_t GetMean2D(Histos *H, TString name); // lambda to check which bins an observable is in, during DAG breadth // traversal; it requires `finalStateID`, `valueMap`, and will diff --git a/src/AnalysisDelphes.cxx b/src/AnalysisDelphes.cxx index 282bb405..25b85335 100644 --- a/src/AnalysisDelphes.cxx +++ b/src/AnalysisDelphes.cxx @@ -233,157 +233,6 @@ void AnalysisDelphes::Execute() { cout << "end event loop" << endl; // event loop end ========================================================= -// Loop again for StdDevs of resolutions -// event loop ========================================================= - cout << "begin event loop (StdDevs)..." << endl; - for(Long64_t e=0; e0&&e%10000==0) cout << (Double_t)e/ENT*100 << "%" << endl; - tr->ReadEntry(e); - - // electron loop - // - finds max-momentum electron - itElectron.Reset(); - maxEleP = 0; - while(Electron *ele = (Electron*) itElectron()) { - eleP = ele->PT * TMath::CosH(ele->Eta); - if(eleP>maxEleP) { - maxEleP = eleP; - kin->vecElectron.SetPtEtaPhiM( - ele->PT, - ele->Eta, - ele->Phi, - Kinematics::ElectronMass() - ); - }; - }; - if(maxEleP<0.001) continue; // no scattered electron found - - // - repeat for truth electron - itParticle.Reset(); - maxElePtrue = 0; - while(GenParticle *part = (GenParticle*) itParticle()){ - if(part->PID == 11 && part->Status == 1){ - elePtrue = part->PT * TMath::CosH(part->Eta); - if(elePtrue > maxElePtrue){ - maxElePtrue = elePtrue; - kinTrue->vecElectron.SetPtEtaPhiM( - part->PT, - part->Eta, - part->Phi, - Kinematics::ElectronMass() - ); - }; - }; - }; - - // get hadronic final state variables - kin->GetHadronicFinalState(itTrack, itEFlowTrack, itEFlowPhoton, itEFlowNeutralHadron, itParticle); - - // calculate DIS kinematics - kin->CalculateDIS(reconMethod); // reconstructed - kinTrue->CalculateDIS(reconMethod); // generated (truth) - Double_t Q2weightFactor = GetEventQ2Weight(kinTrue->Q2, chain->GetTreeNumber()); - - // get vector of jets - // TODO: should this have an option for clustering method? - kin->GetJets(itEFlowTrack, itEFlowPhoton, itEFlowNeutralHadron, itParticle); - - // asymmetry injection - //kin->InjectFakeAsymmetry(); // sets tSpin, based on reconstructed kinematics - //kinTrue->InjectFakeAsymmetry(); // sets tSpin, based on generated kinematics - //kin->tSpin = kinTrue->tSpin; // copy to "reconstructed" tSpin - - // Get index of file that the event comes from. - wTrack = Q2weightFactor * weight->GetWeight(*kinTrue); - wTrackTotal += wTrack; - - // track loop - - - - - - - - - - - - - - - - - - - - - - - - - - - - - itTrack.Reset(); - while(Track *trk = (Track*) itTrack()) { - //cout << e << " " << trk->PID << endl; - - // final state cut - // - check PID, to see if it's a final state we're interested in for - // histograms; if not, proceed to next track - pid = trk->PID; - auto kv = PIDtoFinalState.find(pid); - if(kv!=PIDtoFinalState.end()) finalStateID = kv->second; else continue; - if(activeFinalStates.find(finalStateID)==activeFinalStates.end()) continue; - - // get parent particle, to check if pion is from vector meson - GenParticle *trkParticle = (GenParticle*)trk->Particle.GetObject(); - TObjArray *brParticle = (TObjArray*)itParticle.GetCollection(); - GenParticle *parentParticle = (GenParticle*)brParticle->At(trkParticle->M1); - int parentPID = (parentParticle->PID); // TODO: this is not used yet... - - // calculate hadron kinematics - kin->vecHadron.SetPtEtaPhiM( - trk->PT, - trk->Eta, - trk->Phi, - trk->Mass /* TODO: do we use track mass here ?? */ - ); - GenParticle* trkPart = (GenParticle*)trk->Particle.GetObject(); - kinTrue->vecHadron.SetPtEtaPhiM( - trkPart->PT, - trkPart->Eta, - trkPart->Phi, - trkPart->Mass /* TODO: do we use track mass here ?? */ - ); - - kin->CalculateHadronKinematics(); - kinTrue->CalculateHadronKinematics(); - - // fill track histograms in activated bins - FillHistosTracksSD(); - - // fill simple tree - // - not binned - // - `activeEvent` is only true if at least one bin gets filled for this track - // - TODO [critical]: add a `finalState` cut (also needed in AnalysisDD4hep) - if( writeSimpleTree && activeEvent ) ST->FillTree(wTrack); - - }; // end track loop - - - // // jet loop - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // finalStateID = "jet"; - // if(activeFinalStates.find(finalStateID)!=activeFinalStates.end()) { - - // #if INCCENTAURO == 1 - // if(useBreitJets) kin->GetBreitFrameJets(itEFlowTrack, itEFlowPhoton, itEFlowNeutralHadron, itParticle); - // #endif - - // wJet = Q2weightFactor * weightJet->GetWeight(*kinTrue); // TODO: should we separate weights for breit and non-breit jets? - // wJetTotal += wJet; - - // Int_t nJets; - // if(useBreitJets) nJets = kin->breitJetsRec.size(); - // else nJets = kin->jetsRec.size(); - - // for(int i = 0; i < kin->jetsRec.size(); i++){ - - // if(useBreitJets) { - // #if INCCENTAURO == 1 - // jet = kin->breitJetsRec[i]; - // kin->CalculateBreitJetKinematics(jet); - // #endif - // } else { - // jet = kin->jetsRec[i]; - // kin->CalculateJetKinematics(jet); - // }; - - // // fill jet histograms in activated bins - // // FillHistosJetsSD(); //TODO - - // }; - // }; // end jet loop - - }; - cout << "end event loop (StdDevs)" << endl; - // event loop end ========================================================= - - // finish execution Finish(); }; diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index 0db3c0f2..4bc741f8 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -451,7 +451,7 @@ void PostProcessor::DrawInBins( hist->GetXaxis()->SetLabelSize(0.06); hist->GetXaxis()->CenterTitle(); hist->GetXaxis()->SetLabelOffset(0.02); - hist->GetYaxis()->SetRangeUser(-15,15);//TODO: CHECK THIS IS REASONABLE ALSO WHAT ABOUT ERROR BARS??? + hist->GetYaxis()->SetRangeUser(0,0.05);//TODO: CHECK THIS IS REASONABLE ALSO WHAT ABOUT ERROR BARS??? hist->GetYaxis()->SetNdivisions(8); hist->GetYaxis()->SetLabelSize(0.06); hist->GetYaxis()->SetLabelOffset(0.02); @@ -541,14 +541,73 @@ void PostProcessor::DrawInBins( } }; +//========================================================================= +/* Convert 2D histogram to 1D histogram of stddevs from y distribution. + * Fits slices along x axis with Gaussian. + */ + +TH1D *PostProcessor::GetSDs(TH2D* fitHist){ + + int nbins = fitHist->GetNbinsX(); + double high = fitHist->GetXaxis()->GetXmax(); + double low = fitHist->GetXaxis()->GetXmin(); + double highY = fitHist->GetYaxis()->GetXmax(); + double lowY = fitHist->GetYaxis()->GetXmin(); + TString name = fitHist->GetName(); + TString title = fitHist->GetTitle(); + TString xtitle = fitHist->GetXaxis()->GetTitle(); + TH1D* subHist = new TH1D(name,title,nbins,low,high); + subHist->GetXaxis()->SetTitle(xtitle); + + // Loop x-axis bins and fit y profiles to get stdev and errors + for (int bin=1; bin<=nbins; bin++) { //NOTE: Bin #'s begin at 1! + + // Define fit function //NOTE: Keep this definition, do not change syntax or use lambda! It will not work, still not sure why... + TF1 *func = new TF1("func","[0]*(1/([1]*TMath::Sqrt(2*TMath::Pi())))*TMath::Exp(-0.5*(x-[2])*(x-[2])/[1]/[1])",lowY,highY); + TH1D *h = new TH1D("h","h",fitHist->GetNbinsY(),lowY,highY); + for (int i=1; i<=h->GetNbinsX(); i++) { //NOTE: Bin #'s start at 1! + h->SetBinContent(i,fitHist->GetBinContent(bin,i)); + } + if (h->GetEntries() < 10 || h->GetMaximum()<1 ) continue; + func->SetParameters(h->GetMaximum()*h->GetStdDev(),h->GetStdDev(),h->GetMean()); + TFitResultPtr fr = h->Fit("func","NS","",lowY,highY); //IMPORTANT: N option keeps fit results from being plotted, otherwise you change the current canvas. + if (fr->IsEmpty() || !(fr->IsValid())) { continue; } + // TMatrixDSym *covMat = new TMatrixDSym(fr->GetCovarianceMatrix()); + + // Gaussian fit parameters + double N0 = func->GetParameter(0); + double sigma = func->GetParameter(1); + double mu = func->GetParameter(2); + + // Gaussian fit errors + double EN0 = func->GetParError(0); + double Esigma = func->GetParError(1); + double Emu = func->GetParError(2); + double chi2 = func->GetChisquare(); + double ndf = func->GetNDF(); + + // //DEBUGGING + // std::cout<<"\tINFO bin["<Write(); + // get histograms from Histos 2D vector for(int i = 0; i < nvar1; i++){ for(int j = 0; j < nvar2; j++){ @@ -605,12 +665,15 @@ void PostProcessor::DrawInBinsTogether( lg->SetTextSize(0.2); for (int k=0; kHist(histNames[k])->Clone(); - subHist->SetTitle(""); + TH2D *fitHist = (TH2D*)H->Hist(histNames[k])->Clone(); + if ( fitHist->GetEntries() < 10 ) continue; // Filter out low filled hists that can't get good fits. + fitHist->SetTitle(""); + //subHist->GetXaxis()->SetTitle(""); //subHist->GetYaxis()->SetTitle(""); //subHist->GetXaxis()->SetLabelSize(0); //subHist->GetYaxis()->SetLabelSize(0); + TH1D *subHist = this->GetSDs(fitHist); subHist->GetXaxis()->SetTitleSize(0.1); subHist->GetXaxis()->SetTitleOffset(0.5); @@ -618,7 +681,7 @@ void PostProcessor::DrawInBinsTogether( subHist->GetXaxis()->SetLabelSize(0.06); subHist->GetXaxis()->CenterTitle(); subHist->GetXaxis()->SetLabelOffset(0.02); - subHist->GetYaxis()->SetRangeUser(-15,15);//TODO: CHECK THIS IS REASONABLE ALSO WHAT ABOUT ERROR BARS??? + subHist->GetYaxis()->SetRangeUser(yMin,yMax);//TODO: CHECK THIS IS REASONABLE ALSO WHAT ABOUT ERROR BARS??? subHist->GetYaxis()->SetNdivisions(8); subHist->GetYaxis()->SetLabelSize(0.06); subHist->GetYaxis()->SetLabelOffset(0.02); @@ -628,12 +691,8 @@ void PostProcessor::DrawInBinsTogether( subHist->SetMarkerColor(k+2); if (k+2>=5) subHist->SetMarkerColor(k+3); //NOTE: 5 is yellow: very hard to see. subHist->SetMarkerSize(0.5);//NOTE: Remember these will be small plots so keep the binning small and the markers big - if ( subHist->GetEntries() > 10 ) { + if ( subHist->GetEntries()>0 ) { hist->Add(subHist); - std::cout<<"DEBUGGING: Added hist:"<GetHistogram()->GetDimension() case 1: - drawStr = "hist p nostack"/*"ex0 p nostack"*/;//NOTE: nostackb will just throw an error, don't use + drawStr = "ex0 p nostack"; //NOTE: nostackb will just throw an error, don't use. /*"ex0 p nostack"*/ break; case 2: drawStr = "COLZ"; @@ -726,7 +785,7 @@ void PostProcessor::DrawInBinsTogether( } }; -//========================================================================= +// ========================================================================= /* ALGORITHM: draw a ratio of all 1D histograms in the specified histogram set * - the ratio will be of `numerSet` over `denomSet` diff --git a/src/PostProcessor.h b/src/PostProcessor.h index 54566f81..58a4f38a 100644 --- a/src/PostProcessor.h +++ b/src/PostProcessor.h @@ -14,6 +14,10 @@ #include "TGaxis.h" #include "THStack.h" #include "TLegend.h" +#include "TF1.h" +#include "TFitResult.h" +#include "TFitResultPtr.h" +#include "TMatrixDSym.h" // largex-eic #include "Histos.h" @@ -77,9 +81,11 @@ class PostProcessor : public TNamed bool intlog1=false, bool intlog2=false, bool intgrid1=false, bool intgrid2=false ); - void DrawInBinsTogether( + TH1D *GetSDs(TH2D* fitHist); + + void DrawSDInBinsTogether( TString outName, - std::vector>& histList, TString histNames[], TString labels[], int nNames, + std::vector>& histList, TString histNames[], TString labels[], int nNames, double yMin, double yMax, TString var1name, int nvar1, double var1low, double var1high, bool var1log, TString var2name, int nvar2, double var2low, double var2high, bool var2log, bool intlog1=false, bool intlog2=false, bool intgrid1=false, bool intgrid2=false From 740369a62fac256906441e4cae2d2c8a3fa5ba89 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Thu, 11 Nov 2021 14:05:30 -0500 Subject: [PATCH 05/51] Small updates to marker style and config file options. --- macro/postprocess_resolution_SD.C | 6 +++--- src/Analysis.cxx | 3 +-- src/PostProcessor.cxx | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/macro/postprocess_resolution_SD.C b/macro/postprocess_resolution_SD.C index 8bb061b2..11a80c50 100644 --- a/macro/postprocess_resolution_SD.C +++ b/macro/postprocess_resolution_SD.C @@ -60,10 +60,10 @@ void postprocess_resolution_SD( ); }; - const int nNames = 2; + const int nNames = 3; double yMin, yMax; yMin = -0.1; yMax = 0.5;//Adjust as needed - TString histNames[nNames] = {"z_Q2_Res","z_x_Res"};//,"z_y_Res","z_z_Res","z_pT_Res","z_phiH_Res","z_phiS_Res"}; - TString labels[nNames] = {"Q^{2}","x"}; + TString histNames[nNames] = {"z_purity","z_Q2_Res","z_x_Res"};//,"z_y_Res","z_z_Res","z_pT_Res","z_phiH_Res","z_phiS_Res"}; + TString labels[nNames] = {"purity","Q^{2}","x"}; P->DrawSDInBinsTogether( canvname, histos_xQ2, histNames, labels, nNames, yMin, yMax, "x", nx, xMin, xMax, true, diff --git a/src/Analysis.cxx b/src/Analysis.cxx index bcf544f7..2ec00598 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -156,6 +156,7 @@ void Analysis::Prepare() { string fileName; Double_t xs, Q2min; ss >> fileName >> xs >> Q2min; + std::cout<Hist("z_true")->Fill(kinTrue->z, wTrack ); if( (H->Hist("z_true"))->FindBin(kinTrue->z) == (H->Hist("z_true"))->FindBin(kin->z) ) H->Hist("z_purity")->Fill(kin->z,wTrack); - - if( (H->Hist("Q2vsXtrue"))->FindBin(kinTrue->x,kinTrue->Q2) == (H->Hist("Q2vsXtrue"))->FindBin(kin->x,kin->Q2) ) dynamic_cast(H->Hist("Q2vsXpurity"))->Fill(kin->x,kin->Q2,wTrack); // -- reconstructed vs. generated dynamic_cast(H->Hist("x_RvG"))->Fill(kinTrue->x,kin->x,wTrack); diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index 4bc741f8..5e422f98 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -687,7 +687,7 @@ void PostProcessor::DrawSDInBinsTogether( subHist->GetYaxis()->SetLabelOffset(0.02); subHist->SetTitle(histNames[k]); - subHist->SetMarkerStyle(k+24); + subHist->SetMarkerStyle(k==0 ? 32 : k+25); subHist->SetMarkerColor(k+2); if (k+2>=5) subHist->SetMarkerColor(k+3); //NOTE: 5 is yellow: very hard to see. subHist->SetMarkerSize(0.5);//NOTE: Remember these will be small plots so keep the binning small and the markers big From 7643abb725c6023547c21eafba4fd7e9e490e8e5 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Thu, 11 Nov 2021 16:15:29 -0500 Subject: [PATCH 06/51] Removed extra assymetry injection block from merge conflict resolution --- src/AnalysisDelphes.cxx | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/AnalysisDelphes.cxx b/src/AnalysisDelphes.cxx index 2cd75609..6ddd155b 100644 --- a/src/AnalysisDelphes.cxx +++ b/src/AnalysisDelphes.cxx @@ -148,15 +148,6 @@ void AnalysisDelphes::Execute() { // get vector of jets // TODO: should this have an option for clustering method? kin->GetJets(itEFlowTrack, itEFlowPhoton, itEFlowNeutralHadron, itParticle); - - // asymmetry injection - //kin->InjectFakeAsymmetry(); // sets tSpin, based on reconstructed kinematics - //kinTrue->InjectFakeAsymmetry(); // sets tSpin, based on generated kinematics - //kin->tSpin = kinTrue->tSpin; // copy to "reconstructed" tSpin - - // Get index of file that the event comes from. - wTrack = Q2weightFactor * weight->GetWeight(*kinTrue); - wTrackTotal += wTrack; // track loop - - - - - - - - - - - - - - - - - - - - - - - - - - - - itTrack.Reset(); From fdaa6bb093521e08f65e85c88fb437718c0f3b8c Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Thu, 11 Nov 2021 16:27:46 -0500 Subject: [PATCH 07/51] Added in histogram definitions missing from merge conflict resolution --- src/Analysis.cxx | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/Analysis.cxx b/src/Analysis.cxx index a7f94c95..d4d291d2 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -314,15 +314,30 @@ void Analysis::Prepare() { // HS->DefineHist1D("phiS_Res","#phi_{S}-#phi_{S}^{true}","", NBINS, -0.1*TMath::Pi(), 0.1*TMath::Pi()); // HS->DefineHist1D("pT_Res","pT-pT^{true}","GeV", NBINS, -1.5, 1.5); HS->DefineHist2D("Q2vsXtrue","x","Q^{2}","","GeV^{2}", - // 20,1e-4,1,//TODO: OLD -> Might revert... - // 10,1,1e4, - // true,true - NBINS,1e-3,1, - NBINS,1,100, + 20,1e-4,1, + 10,1,1e4, + true,true + ); + HS->DefineHist2D("Q2vsXpurity","x","Q^{2}","","GeV^{2}", + 20,1e-4,1, + 10,1,1e4, + true,true + ); + HS->DefineHist2D("Q2vsX_zres","x","Q^{2}","","GeV^{2}", + 20,1e-4,1, + 10,1,1e4, + true,true + ); + HS->DefineHist2D("Q2vsX_pTres","x","Q^{2}","","GeV^{2}", + 20,1e-4,1, + 10,1,1e4, + true,true + ); + HS->DefineHist2D("Q2vsX_phiHres","x","Q^{2}","","GeV^{2}", + 20,1e-4,1, + 10,1,1e4, true,true ); - - // -- reconstructed vs. generated HS->DefineHist2D("x_RvG","generated x","reconstructed x","","", NBINS,1e-3,1, From 233fa22b867d186828f1c57d6134b07dfe152fbe Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Thu, 11 Nov 2021 16:37:48 -0500 Subject: [PATCH 08/51] Fixing legend sizing issue --- src/PostProcessor.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index e042b035..d855e5db 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -665,6 +665,7 @@ void PostProcessor::DrawSDInBinsTogether( THStack *hist = new THStack(); TLegend *lg = new TLegend(0.1,0.1,0.9,0.9); lg->SetTextSize(0.2); + if (nNames>3) lg->SetNColumns(2); for (int k=0; kHist(histNames[k])->Clone(); From deca0ff2df1d7c0d274eaf67bde84c28e6c87d51 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Fri, 12 Nov 2021 07:52:45 -0500 Subject: [PATCH 09/51] Updated legend placement in `PostProcessor.cxx` --- src/PostProcessor.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index d855e5db..fcb0273a 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -725,8 +725,8 @@ void PostProcessor::DrawSDInBinsTogether( //hist->Write(); if( hist->GetNhists() > 0 ) { hist->Draw(drawStr); - if (i==0 && j==0) { - mainpad->cd(1);// Upper left corner pad + if (i==nvar1-1 && j==nvar2-1) { + mainpad->cd(1);// Bottom right corner pad lg->Draw(); mainpad->cd((nvar2-j-1)*nvar1 + i + 1);// Return to original pad } From f7159f1ccdac75dae2a8a364443723620b579131 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Fri, 12 Nov 2021 10:18:21 -0500 Subject: [PATCH 10/51] Added zero lines to draw with `THStacks` in `PostProcessor::DrawSDInBinsTogether()` and updated draw options --- src/PostProcessor.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index fcb0273a..3cc3a202 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -713,7 +713,7 @@ void PostProcessor::DrawSDInBinsTogether( TString drawStr = ""; switch(1) {//TODO: figure out how to get THStack dimension? //can't use hist->GetHistogram()->GetDimension() case 1: - drawStr = "ex0 p nostack"; //NOTE: nostackb will just throw an error, don't use. /*"ex0 p nostack"*/ + drawStr = "hist p nostack"; //NOTE: nostackb will just throw an error, don't use. /*"ex0 p nostack"*/ break; case 2: drawStr = "COLZ"; @@ -725,8 +725,11 @@ void PostProcessor::DrawSDInBinsTogether( //hist->Write(); if( hist->GetNhists() > 0 ) { hist->Draw(drawStr); + TF1 *f1 = new TF1("f1","0",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); + f1->SetLineColor(1); + f1->Draw("SAME"); if (i==nvar1-1 && j==nvar2-1) { - mainpad->cd(1);// Bottom right corner pad + mainpad->cd(nvar1*nvar2);// Bottom right corner pad lg->Draw(); mainpad->cd((nvar2-j-1)*nvar1 + i + 1);// Return to original pad } From 8bf1e369d6fd49c3afe438b179e1e8d1cf521998 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Fri, 12 Nov 2021 11:59:05 -0500 Subject: [PATCH 11/51] Updated purity to contamination plot for better y axis scaling when plotting with resolutions. Also add full sim analysis script --- macro/analysis_resolution_SD_Full.C | 41 +++++++++++++++++++++++++++++ macro/postprocess_resolution_SD.C | 1 + src/Analysis.cxx | 5 +++- src/Analysis.h | 1 + src/PostProcessor.cxx | 9 ++++--- src/PostProcessor.h | 2 +- 6 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 macro/analysis_resolution_SD_Full.C diff --git a/macro/analysis_resolution_SD_Full.C b/macro/analysis_resolution_SD_Full.C new file mode 100644 index 00000000..9f2a5292 --- /dev/null +++ b/macro/analysis_resolution_SD_Full.C @@ -0,0 +1,41 @@ +R__LOAD_LIBRARY(Largex) + +// make resolution plots +void analysis_resolution_SD_Full( + TString infiles="datarec/canyonlands/5x41/files.config", /* list of input files */ + Double_t eleBeamEn=5, /* electron beam energy [GeV] */ + Double_t ionBeamEn=41, /* ion beam energy [GeV] */ + Double_t crossingAngle=0, /* crossing angle [mrad] */ + TString outfilePrefix="resolution" /* output filename prefix*/ +) { + + // setup analysis ======================================== + AnalysisDelphes *A = new AnalysisDD4hep( + infiles, + eleBeamEn, + ionBeamEn, + crossingAngle, + outfilePrefix + ); + A->NBINS = 5; // use this to set the number of bins along each axis, e.g., z binning (except resolution axes) for each overall bin in e.g. x and Q2 + A->NBINSRES = 100; // use this to set the number of bins along the resolution axes for each overall bin in e.g. x and Q2 + // A->RESHIGH = 1; + // A->RESLOW = -1; + //A->maxEvents = 30000; // use this to limit the number of events + A->SetReconMethod("Ele"); // set reconstruction method + A->AddFinalState("pipTrack"); // pion final state + + // define cuts ==================================== + A->AddBinScheme("w"); A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV + A->AddBinScheme("y"); A->BinScheme("y")->BuildBin("Range",0.01,0.95); // 0.01 < y < 0.95 + A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,0.9); // 0.2 < z < 0.9 + A->AddBinScheme("xF"); A->BinScheme("xF")->BuildBin("Min",0.0); // xF > 0 + A->AddBinScheme("ptLab"); A->BinScheme("ptLab")->BuildBin("Min",0.1); // pT_lab > 0.1 GeV (tracking limit) + + // set binning scheme ==================================== + A->AddBinScheme("q2"); A->BinScheme("q2")->BuildBins( 4, 1, 100, true ); + A->AddBinScheme("x"); A->BinScheme("x")->BuildBins( 6, 0.01, 1, true ); + + // perform the analysis ================================== + A->Execute(); +}; diff --git a/macro/postprocess_resolution_SD.C b/macro/postprocess_resolution_SD.C index 11a80c50..fd9e19d2 100644 --- a/macro/postprocess_resolution_SD.C +++ b/macro/postprocess_resolution_SD.C @@ -4,6 +4,7 @@ R__LOAD_LIBRARY(Largex) // - adapted from `postprocess_pTvsEta.C` void postprocess_resolution_SD( TString infile="out/resolution.root" + TString header="resolution" ){ gROOT->ProcessLine(".! rm -v out/resolution.images/*.png"); // cleanup old image files diff --git a/src/Analysis.cxx b/src/Analysis.cxx index 95493552..243b0a14 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -464,8 +464,11 @@ void Analysis::Finish() { // calculate cross sections H->Hist("Q_xsec")->Scale(1./lumi); // TODO: generalize (`if (name contains "xsec") ...`) - // // Normalize and sqrt 1D z-binned resolution StdDevs + // Convert to contamination plot since the y scale is better for plotting with stddevs + H->Hist("z_purity")->Add(H->Hist("z_true"),-1); H->Hist("z_purity")->Divide(H->Hist("z_true")); + TF1 *f1 = new TF1("f1","1",0,1); //TODO: Set limits automatically + H->Hist("z_purity")->Multiply(f1,-1); }); diff --git a/src/Analysis.h b/src/Analysis.h index 0c848fb8..d0aaa1cf 100644 --- a/src/Analysis.h +++ b/src/Analysis.h @@ -17,6 +17,7 @@ #include "TClonesArray.h" #include "TFile.h" #include "TRegexp.h" +#include "TF1.h" // largex-eic #include "Histos.h" diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index 3cc3a202..9642c197 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -608,7 +608,7 @@ on axis of bin variables, e.g. Q2 vs x. void PostProcessor::DrawSDInBinsTogether( TString outName, - std::vector>& histList, + std::vector>& histList, TString header, TString histNames[], TString labels[], int nNames, double yMin, double yMax, TString var1name, int nvar1, double var1low, double var1high, bool var1log, TString var2name, int nvar2, double var2low, double var2high, bool var2log, @@ -665,6 +665,7 @@ void PostProcessor::DrawSDInBinsTogether( THStack *hist = new THStack(); TLegend *lg = new TLegend(0.1,0.1,0.9,0.9); lg->SetTextSize(0.2); + lg->SetHeader(header); if (nNames>3) lg->SetNColumns(2); for (int k=0; kGetYaxis()->SetTitle(""); //subHist->GetXaxis()->SetLabelSize(0); //subHist->GetYaxis()->SetLabelSize(0); - TH1D *subHist = this->GetSDs(fitHist); + TH1D *subHist; + if (histNames[k]=="z_purity") subHist = (TH1D*)H->Hist(histNames[k])->Clone(); + else subHist = this->GetSDs(fitHist); subHist->GetXaxis()->SetTitleSize(0.1); subHist->GetXaxis()->SetTitleOffset(0.5); @@ -728,7 +731,7 @@ void PostProcessor::DrawSDInBinsTogether( TF1 *f1 = new TF1("f1","0",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); f1->SetLineColor(1); f1->Draw("SAME"); - if (i==nvar1-1 && j==nvar2-1) { + if (i==0 && j==0) { mainpad->cd(nvar1*nvar2);// Bottom right corner pad lg->Draw(); mainpad->cd((nvar2-j-1)*nvar1 + i + 1);// Return to original pad diff --git a/src/PostProcessor.h b/src/PostProcessor.h index 58a4f38a..f4a312f9 100644 --- a/src/PostProcessor.h +++ b/src/PostProcessor.h @@ -85,7 +85,7 @@ class PostProcessor : public TNamed void DrawSDInBinsTogether( TString outName, - std::vector>& histList, TString histNames[], TString labels[], int nNames, double yMin, double yMax, + std::vector>& histList, TString header, TString histNames[], TString labels[], int nNames, double yMin, double yMax, TString var1name, int nvar1, double var1low, double var1high, bool var1log, TString var2name, int nvar2, double var2low, double var2high, bool var2log, bool intlog1=false, bool intlog2=false, bool intgrid1=false, bool intgrid2=false From 65fba73e41a7c6069d3c772127f5ea93f551c1af Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Mon, 15 Nov 2021 11:46:33 -0500 Subject: [PATCH 12/51] Added full sim analysis script for resolutions --- macro/analysis_resolution_SD_Full.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/macro/analysis_resolution_SD_Full.C b/macro/analysis_resolution_SD_Full.C index 9f2a5292..00520964 100644 --- a/macro/analysis_resolution_SD_Full.C +++ b/macro/analysis_resolution_SD_Full.C @@ -2,7 +2,7 @@ R__LOAD_LIBRARY(Largex) // make resolution plots void analysis_resolution_SD_Full( - TString infiles="datarec/canyonlands/5x41/files.config", /* list of input files */ + TString infiles="datarec/dis-5x41.config", /* list of input files */ Double_t eleBeamEn=5, /* electron beam energy [GeV] */ Double_t ionBeamEn=41, /* ion beam energy [GeV] */ Double_t crossingAngle=0, /* crossing angle [mrad] */ @@ -10,7 +10,7 @@ void analysis_resolution_SD_Full( ) { // setup analysis ======================================== - AnalysisDelphes *A = new AnalysisDD4hep( + AnalysisDD4hep *A = new AnalysisDD4hep( infiles, eleBeamEn, ionBeamEn, From 352f92159656b5ebb6f7c8fec2646cca5d369df0 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Mon, 15 Nov 2021 17:02:31 -0500 Subject: [PATCH 13/51] Small updates to resolution scripts and working out purities in `AnalysisDelphes.cxx` --- macro/analysis_resolution_SD.C | 4 ++-- macro/analysis_resolution_SD_Full.C | 2 +- src/AnalysisDelphes.cxx | 3 +++ src/PostProcessor.cxx | 5 +++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/macro/analysis_resolution_SD.C b/macro/analysis_resolution_SD.C index 8b4de7f2..1cee9d22 100644 --- a/macro/analysis_resolution_SD.C +++ b/macro/analysis_resolution_SD.C @@ -2,11 +2,11 @@ R__LOAD_LIBRARY(Largex) // make resolution plots void analysis_resolution_SD( - TString infiles="datarec/test.config", /* list of input files */ + TString infiles="datarec/dis-5x41.config", /* list of input files */ Double_t eleBeamEn=5, /* electron beam energy [GeV] */ Double_t ionBeamEn=41, /* ion beam energy [GeV] */ Double_t crossingAngle=0, /* crossing angle [mrad] */ - TString outfilePrefix="resolution" /* output filename prefix*/ + TString outfilePrefix="dis-5x41" /* output filename prefix*/ ) { // setup analysis ======================================== diff --git a/macro/analysis_resolution_SD_Full.C b/macro/analysis_resolution_SD_Full.C index 00520964..434ca60e 100644 --- a/macro/analysis_resolution_SD_Full.C +++ b/macro/analysis_resolution_SD_Full.C @@ -6,7 +6,7 @@ void analysis_resolution_SD_Full( Double_t eleBeamEn=5, /* electron beam energy [GeV] */ Double_t ionBeamEn=41, /* ion beam energy [GeV] */ Double_t crossingAngle=0, /* crossing angle [mrad] */ - TString outfilePrefix="resolution" /* output filename prefix*/ + TString outfilePrefix="full_dis-5x41" /* output filename prefix*/ ) { // setup analysis ======================================== diff --git a/src/AnalysisDelphes.cxx b/src/AnalysisDelphes.cxx index 5e8467fe..74174bbe 100644 --- a/src/AnalysisDelphes.cxx +++ b/src/AnalysisDelphes.cxx @@ -161,12 +161,15 @@ void AnalysisDelphes::Execute() { // - check PID, to see if it's a final state we're interested in for // histograms; if not, proceed to next track pid = trk->PID; + std::cout<<"DEBUGGING trk->PID = "<second; else continue; if(activeFinalStates.find(finalStateID)==activeFinalStates.end()) continue; // get parent particle, to check if pion is from vector meson GenParticle *trkParticle = (GenParticle*)trk->Particle.GetObject(); + std::cout<<"DEBUGGING finalStateID = "<PID = \n"<PID<At(trkParticle->M1); int parentPID = (parentParticle->PID); // TODO: this is not used yet... diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index 9642c197..9ce99315 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -664,8 +664,8 @@ void PostProcessor::DrawSDInBinsTogether( THStack *hist = new THStack(); TLegend *lg = new TLegend(0.1,0.1,0.9,0.9); - lg->SetTextSize(0.2); - lg->SetHeader(header); + lg->SetHeader(header,"C"); + lg->SetTextSize(0.15); if (nNames>3) lg->SetNColumns(2); for (int k=0; kDraw(drawStr); TF1 *f1 = new TF1("f1","0",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); f1->SetLineColor(1); + f1->SetLineWidth(1); f1->Draw("SAME"); if (i==0 && j==0) { mainpad->cd(nvar1*nvar2);// Bottom right corner pad From 80b78a2b9ea74db17f2c3ad12e95a0c13c2c5ee6 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Tue, 16 Nov 2021 13:49:57 -0500 Subject: [PATCH 14/51] Added PID purity plots and scripts to make and run analysis/postprocessing scripts on different energies. Also added new macro for Barak --- createDelphesScripts.sh | 56 ++++++++++++++++++++ createFullScripts.sh | 60 +++++++++++++++++++++ macro/analysis_barak.C | 41 +++++++++++++++ macro/postprocess_barak.C | 86 +++++++++++++++++++++++++++++++ macro/postprocess_resolution_SD.C | 4 +- src/Analysis.cxx | 37 ++++++++++++- src/Analysis.h | 1 + src/AnalysisDD4hep.cxx | 2 + src/AnalysisDelphes.cxx | 44 ++++++++++++++-- src/PostProcessor.cxx | 14 ++++- src/PostProcessor.h | 5 ++ 11 files changed, 342 insertions(+), 8 deletions(-) create mode 100755 createDelphesScripts.sh create mode 100755 createFullScripts.sh create mode 100644 macro/analysis_barak.C create mode 100644 macro/postprocess_barak.C diff --git a/createDelphesScripts.sh b/createDelphesScripts.sh new file mode 100755 index 00000000..5bade7d7 --- /dev/null +++ b/createDelphesScripts.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +# Create fast simulation resolutions plotting scripts and submit to ifarm + +script='/work/clas12/users/mfmce/largex-eic/macro/analysis_resolution_SD.C' +postScript='/work/clas12/users/mfmce/largex-eic/macro/postprocess_resolution_SD.C' +submitScript='/work/clas12/users/mfmce/largex-eic/submit.sh' +jobScript='/work/clas12/users/mfmce/largex-eic/job.sh' +out='/work/clas12/users/mfmce/largex-eic/macro/' +cd /work/clas12/users/mfmce/largex-eic/datarec/ +for file in *.config +do + config=`echo $file | sed "s;.config;;g"` + mkdir -p $out/$config + cp $script $out/$config/ + newscript=${out}${config}/*.C + eleIn=`echo $file | grep -Eo "[0-9][0-9]*x[0-9]*" | sed "s;x.*;;g"` + beamIn=`echo $file | grep -Eo "[0-9][0-9]*x[0-9]*" | sed "s;.*x;;g"` + xAng=`echo $file | grep -Eo "[0-9][0-9]*x[0-9]*-x[0-9]*" | sed "s;.*-x;;g"` + xAngM=`echo $file | grep -Eo "[0-9][0-9]*x[0-9]*-xm[0-9]*" | sed "s;.*-xm;;g"` + echo "file=${file}" + echo "config=${config}" + echo "newscript=${newscript}" + echo "eleIn=${eleIn}" + echo "beamIn=${beamIn}" + echo "xAng=${xAng}" + echo "xAngM=${xAngM}" + echo -------------------- + + sed -i "s;dis-5x41;${config};g" $newscript + sed -i "s;eleBeamEn=5;eleBeamEn=${eleIn};g" $newscript + sed -i "s;ionBeamEn=41;ionBeamEn=${beamIn};g" $newscript + if [ $xAng ]; then + sed -i "s;crossingAngle=0;crossingAngle=${xAng};g" $newscript + fi + if [ $xAngM ]; then + sed -i "s;icrossingAngle=0;crossingAngle=-${xAngM};g" $newscript + fi + cp $postScript $out/$config + sed -i "s;out/resolution;out/${config};g" $out/$config/*.C + if [ $xAng ]; then + sed -i "s;testheader;${eleIn}x${beamIn} ${xAng};g" $out/$config/*.C + fi + if [ $xAngM ]; then + sed -i "s;testheader;${eleIn}x${beamIn} -${xAngM};g" $out/$config/*.C + fi + cp $submitScript $out/$config + cp $jobScript $out/$config + sed -i "s;dis-5x41;${config};g" $out/$config/*.sh + if [ $xAngM ]; then #NOTE: Just use negative angle files + sbatch $out/$config/submit.sh + fi + +done +cd .. +echo DONE diff --git a/createFullScripts.sh b/createFullScripts.sh new file mode 100755 index 00000000..40f2097c --- /dev/null +++ b/createFullScripts.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# Create full simulation resolution plotting scripts and submit to ifarm +script='/work/clas12/users/mfmce/largex-eic/macro/analysis_resolution_SD_Full.C' +postScript='/work/clas12/users/mfmce/largex-eic/macro/postprocess_resolution_SD.C' +submitScript='/work/clas12/users/mfmce/largex-eic/submit.sh' +jobScript='/work/clas12/users/mfmce/largex-eic/job.sh' +out='/work/clas12/users/mfmce/largex-eic/macro/canyonlands/' +cd /work/clas12/users/mfmce/largex-eic/datarec/canyonlands/5x41/ +for file in /work/clas12/users/mfmce/largex-eic/datarec/canyonlands/*/*.config +do + config=`echo $file | sed "s;.config;;g" | grep -Eo 'canyonlands/.*' | sed 's;canyonlands/;;g' | sed 's;/files;;g'` + mkdir -p $out/$config + cp $script $out/$config/ + newscript=${out}${config}/*.C + eleIn=`echo $file | grep -Eo "[0-9][0-9]*x[0-9]*" | sed "s;x.*;;g"` + beamIn=`echo $file | grep -Eo "[0-9][0-9]*x[0-9]*" | sed "s;.*x;;g"` + xAng=`echo $file | grep -Eo "[0-9][0-9]*x[0-9]*-x[0-9]*" | sed "s;.*-x;;g"` + xAngM=`echo $file | grep -Eo "[0-9][0-9]*x[0-9]*-xm[0-9]*" | sed "s;.*-xm;;g"` + echo "name=${name}" + echo "file=${file}" + echo "config=${config}" + echo "newscript=${newscript}" + echo "eleIn=${eleIn}" + echo "beamIn=${beamIn}" + echo "xAng=${xAng}" + echo "xAngM=${xAngM}" + echo -------------------- + + sed -i "s;datarec/dis-5x41.config;${file};g" $newscript + sed -i "s;full_dis-5x41;full_${config};g" $newscript + sed -i "s;eleBeamEn=5;eleBeamEn=${eleIn};g" $newscript + sed -i "s;ionBeamEn=41;ionBeamEn=${beamIn};g" $newscript + if [ $xAng ]; then + sed -i "s;crossingAngle=0;crossingAngle=${xAng};g" $newscript + fi + if [ $xAngM ]; then + sed -i "s;icrossingAngle=0;crossingAngle=-${xAngM};g" $newscript + fi + cp $postScript $out/$config + sed -i "s;out/resolution;out/full_${config};g" $out/$config/*.C + if [ $xAng ]; then + sed -i "s;testheader;${eleIn}x${beamIn} ${xAng};g" $out/$config/*.C + fi + if [ $xAngM ]; then + sed -i "s;testheader;${eleIn}x${beamIn} -${xAngM};g" $out/$config/*.C + fi + cp $submitScript $out/$config + cp $jobScript $out/$config + sed -i "s;dis-5x41;canyonlands/${config};g" $out/$config/*.sh + + # submit job + sbatch $out/$config/submit.sh + +done +cd .. +echo DONE +#cd /work/clas12/users/mfmce/largex-eic +#echo "root -q -b macro/analysis_resolution_SD.C" | ./container/shell.sh +#echo "root -q -b macro/postprocess_resolution_SD.C" | ./container/shell.sh +#echo DONE diff --git a/macro/analysis_barak.C b/macro/analysis_barak.C new file mode 100644 index 00000000..1354a2a4 --- /dev/null +++ b/macro/analysis_barak.C @@ -0,0 +1,41 @@ +R__LOAD_LIBRARY(Largex) + +// make resolution plots +void analysis_barak( + TString infiles="datarec/dis-18x275.config", /* list of input files */ + Double_t eleBeamEn=5, /* electron beam energy [GeV] */ + Double_t ionBeamEn=41, /* ion beam energy [GeV] */ + Double_t crossingAngle=0, /* crossing angle [mrad] */ + TString outfilePrefix="barak_dis-18x275" /* output filename prefix*/ +) { + + // setup analysis ======================================== + AnalysisDelphes *A = new AnalysisDelphes( + infiles, + eleBeamEn, + ionBeamEn, + crossingAngle, + outfilePrefix + ); + A->NBINS = 1; // use this to set the number of bins along each axis, e.g., z binning (except resolution axes) for each overall bin in e.g. x and Q2 + A->NBINSRES = 100; // use this to set the number of bins along the resolution axes for each overall bin in e.g. x and Q2 + // A->RESHIGH = 1; + // A->RESLOW = -1; + //A->maxEvents = 30000; // use this to limit the number of events + A->SetReconMethod("Ele"); // set reconstruction method + A->AddFinalState("pipTrack"); // pion final state + + // define cuts ==================================== + A->AddBinScheme("w"); A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV + A->AddBinScheme("y"); A->BinScheme("y")->BuildBin("Range",0.01,0.95); // 0.01 < y < 0.95 + A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,0.9); // 0.2 < z < 0.9 + A->AddBinScheme("xF"); A->BinScheme("xF")->BuildBin("Min",0.0); // xF > 0 + A->AddBinScheme("ptLab"); A->BinScheme("ptLab")->BuildBin("Min",0.1); // pT_lab > 0.1 GeV (tracking limit) + + // set binning scheme ==================================== + A->AddBinScheme("q2"); A->BinScheme("q2")->BuildBins( 25, 0.1, 10000, true ); + A->AddBinScheme("x"); A->BinScheme("x")->BuildBins( 25, 0.00001, 1, true ); + + // perform the analysis ================================== + A->Execute(); +}; diff --git a/macro/postprocess_barak.C b/macro/postprocess_barak.C new file mode 100644 index 00000000..3e54ddd4 --- /dev/null +++ b/macro/postprocess_barak.C @@ -0,0 +1,86 @@ +R__LOAD_LIBRARY(Largex) + +// make resolution plots +// - adapted from `postprocess_pTvsEta.C` +void postprocess_barak( + TString infile="out/barak_dis-18x275.root" + TString header="18x275GeV" +){ + + gROOT->ProcessLine(".! rm -v out/barak_dis-18x275.images/*.png"); // cleanup old image files + gROOT->ProcessLine(".! rm -v out/barak_dis-18x275.images/*.pdf"); // cleanup old image files + + PostProcessor *P = new PostProcessor(infile); + P->Op()->PrintBreadth("HistosDAG Initial Setup"); + + // number of bins in x and Q2 + int nx = P->Op()->GetBinSet("x")->GetNumBins(); + int nq2 = P->Op()->GetBinSet("q2")->GetNumBins(); + + // just counters for filling Histos vector + int xbin = 0; + int q2bin = 0; + + // initialize this 2D vector to be some large size + std::vector> histos_xQ2(30,std::vector(30)); + + auto findxQ2bins = [&histos_xQ2,&P,&xbin,&q2bin,nx,nq2](Histos *H ){ + histos_xQ2[xbin][q2bin] = H; + q2bin++; + if(q2bin == nq2){ + q2bin=0; xbin++; + if(xbin == nx) xbin = 0; + } + }; + + auto drawinxQ2bins = [&histos_xQ2, &P, &nx, &nq2](NodePath *bins){ + TString canvname = "xQ2cov_"; //+ bins->GetVar + for(Node *bin: bins->GetBinNodes()){ + if(bin->GetVarName() == "finalState"){ + canvname+=bin->GetID(); + canvname+="_"; + } + if(bin->GetVarName() == "z"){ + canvname+=bin->GetID(); + canvname+="_"; + } + } + + double xMin = 1e-5; + double xMax = 1; + double q2Min = 1e-1; + double q2Max = 1e4; + + // loop over resolution histograms (see ../src/Analysis.cxx `DefineHist*` calls + // for available histograms, or add your own there) + for( TString histname : {"y_Res"} ) { + P->DrawInBins( + canvname, histos_xQ2, histname, + "x", nx, xMin, xMax, true, + "Q^{2}", nq2, q2Min, q2Max, true + ); + }; + + const int nNames = 1; + double yMin, yMax; yMin = -0.1; yMax = 0.5;//Adjust as needed + TString histNames[nNames] = {"z_y_Res"}; + TString labels[nNames] = {"y"}; + P->DrawSDInBinsTogether( + canvname, histos_xQ2, histNames, labels, nNames, yMin, yMax, + "x", nx, xMin, xMax, true, + "Q^{2}", nq2, q2Min, q2Max, true + ); + }; + + auto beforefunction = [](){ + }; + + P->Op()->Subloop({"x","q2"},beforefunction,drawinxQ2bins); + P->Op()->Payload(findxQ2bins); + + //P->Op()->PrintBreadth("HistosDAG Final Setup"); + + P->Execute(); + + P->Finish(); +}; diff --git a/macro/postprocess_resolution_SD.C b/macro/postprocess_resolution_SD.C index fd9e19d2..9f61da2d 100644 --- a/macro/postprocess_resolution_SD.C +++ b/macro/postprocess_resolution_SD.C @@ -63,8 +63,8 @@ void postprocess_resolution_SD( const int nNames = 3; double yMin, yMax; yMin = -0.1; yMax = 0.5;//Adjust as needed - TString histNames[nNames] = {"z_purity","z_Q2_Res","z_x_Res"};//,"z_y_Res","z_z_Res","z_pT_Res","z_phiH_Res","z_phiS_Res"}; - TString labels[nNames] = {"purity","Q^{2}","x"}; + TString histNames[nNames] = {"z_Q2_Res","z_x_Res","z_y_Res","z_z_Res","z_pT_Res","z_purity"}; + TString labels[nNames] = {"Q^{2}","x","y","z","p_{T}","1-purity"}; P->DrawSDInBinsTogether( canvname, histos_xQ2, histNames, labels, nNames, yMin, yMax, "x", nx, xMin, xMax, true, diff --git a/src/Analysis.cxx b/src/Analysis.cxx index b1bbcbf0..71720cbc 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -464,6 +464,7 @@ void Analysis::Finish() { // calculate cross sections H->Hist("Q_xsec")->Scale(1./lumi); // TODO: generalize (`if (name contains "xsec") ...`) + // Convert to contamination plot since the y scale is better for plotting with stddevs H->Hist("z_purity")->Add(H->Hist("z_true"),-1); H->Hist("z_purity")->Divide(H->Hist("z_true")); @@ -666,8 +667,8 @@ void Analysis::FillHistosTracks() { dynamic_cast(H->Hist("z_phiS_Res"))->Fill( kinTrue->z, Kinematics::AdjAngle(kin->phiS - kinTrue->phiS), wTrack ); // purities - H->Hist("z_true")->Fill(kinTrue->z, wTrack ); - if( (H->Hist("z_true"))->FindBin(kinTrue->z) == (H->Hist("z_true"))->FindBin(kin->z) ) H->Hist("z_purity")->Fill(kin->z,wTrack); + // H->Hist("z_true")->Fill(kinTrue->z, wTrack ); + // if( (H->Hist("z_true"))->FindBin(kinTrue->z) == (H->Hist("z_true"))->FindBin(kin->z) ) H->Hist("z_purity")->Fill(kin->z,wTrack); H->Hist("pT_Res")->Fill( kin->pT - kinTrue->pT, wTrack ); dynamic_cast(H->Hist("Q2vsXtrue"))->Fill(kinTrue->x,kinTrue->Q2,wTrack); if(kinTrue->z!=0) dynamic_cast(H->Hist("Q2vsX_zres"))->Fill( @@ -690,6 +691,38 @@ void Analysis::FillHistosTracks() { HD->ExecuteOps(true); }; +// jets +void Analysis::FillHistosPurity(int recpid, int mcpid) { + + // add kinematic values to `valueMap` + valueMap.clear(); + activeEvent = false; + /* DIS */ + valueMap.insert(std::pair( "x", kin->x )); + valueMap.insert(std::pair( "q2", kin->Q2 )); + valueMap.insert(std::pair( "y", kin->y )); + valueMap.insert(std::pair( "z", kin->z )); + + // check bins + // - activates HistosDAG bin nodes which contain this track + // - sets `activeEvent` if there is at least one multidimensional bin to fill + HD->TraverseBreadth(CheckBin()); + if(!activeEvent) return; + + // fill histograms, for activated bins only + HD->Payload([this,recpid,mcpid](Histos *H){ + H->Hist("z_true")->Fill(kinTrue->z, wTrack ); + if (recpid==mcpid) { + H->Hist("z_purity")->Fill(kinTrue->z,wTrack); + }//endif + }); + // execute the payload + // - save time and don't call `ClearOps` (next loop will overwrite lambda) + // - called with `activeNodesOnly==true` since we only want to fill bins associated + // with this jet + HD->ExecuteOps(true); +}; + // jets void Analysis::FillHistosJets() { diff --git a/src/Analysis.h b/src/Analysis.h index d0aaa1cf..7d1be112 100644 --- a/src/Analysis.h +++ b/src/Analysis.h @@ -100,6 +100,7 @@ class Analysis : public TNamed // FillHistos methods: fill histograms void FillHistosTracks(); + void FillHistosPurity(int recpid, int mcpid); void FillHistosJets(); // lambda to check which bins an observable is in, during DAG breadth diff --git a/src/AnalysisDD4hep.cxx b/src/AnalysisDD4hep.cxx index 8851f672..9829bbea 100644 --- a/src/AnalysisDD4hep.cxx +++ b/src/AnalysisDD4hep.cxx @@ -228,6 +228,7 @@ void AnalysisDD4hep::process_event() { if(mcid_ == imc.mcID) { + FillHistosPurity(pid_,imc.pid); kinTrue->vecHadron = imc.vecPart; break; } @@ -244,6 +245,7 @@ void AnalysisDD4hep::process_event() if( deta < mineta ) { mineta = deta; + FillHistosPurity(pid_,mcpart[imc].pid); kinTrue->vecHadron = mcpart[imc].vecPart; } } diff --git a/src/AnalysisDelphes.cxx b/src/AnalysisDelphes.cxx index 74174bbe..b32c5701 100644 --- a/src/AnalysisDelphes.cxx +++ b/src/AnalysisDelphes.cxx @@ -26,6 +26,41 @@ AnalysisDelphes::AnalysisDelphes( /* ... none defined yet ... */ }; +// Borrowed this method from `Kinematics.cxx` +// get PID information from PID systems tracks +int getPID(Track *track, TObjArrayIter itParticle, + TObjArrayIter itmRICHTrack, TObjArrayIter itbarrelDIRCTrack, TObjArrayIter itdualRICHagTrack, TObjArrayIter itdualRICHcfTrack){ + itParticle.Reset(); + itmRICHTrack.Reset(); + itbarrelDIRCTrack.Reset(); + itdualRICHagTrack.Reset(); + itdualRICHcfTrack.Reset(); + GenParticle *trackParticle = (GenParticle*)track->Particle.GetObject(); + GenParticle *detectorParticle; + int pidOut = -1; + while(Track *detectorTrack = (Track*)itmRICHTrack() ){ + detectorParticle = (GenParticle*)detectorTrack->Particle.GetObject(); + if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; + } + itParticle.Reset(); + while(Track *detectorTrack = (Track*)itbarrelDIRCTrack() ){ + detectorParticle = (GenParticle*)detectorTrack->Particle.GetObject(); + if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; + } + itParticle.Reset(); + while(Track *detectorTrack = (Track*)itdualRICHagTrack() ){ + detectorParticle = (GenParticle*)detectorTrack->Particle.GetObject(); + if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; + } + while(Track *detectorTrack = (Track*)itdualRICHcfTrack() ){ + detectorParticle = (GenParticle*)detectorTrack->Particle.GetObject(); + if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; + } + + + return pidOut; +} + //============================================= // perform the analysis //============================================= @@ -161,19 +196,22 @@ void AnalysisDelphes::Execute() { // - check PID, to see if it's a final state we're interested in for // histograms; if not, proceed to next track pid = trk->PID; - std::cout<<"DEBUGGING trk->PID = "<second; else continue; if(activeFinalStates.find(finalStateID)==activeFinalStates.end()) continue; // get parent particle, to check if pion is from vector meson GenParticle *trkParticle = (GenParticle*)trk->Particle.GetObject(); - std::cout<<"DEBUGGING finalStateID = "<PID = \n"<PID<At(trkParticle->M1); int parentPID = (parentParticle->PID); // TODO: this is not used yet... + // Get REC and MC particle PID + int recpid = getPID(trk, itParticle, itmRICHTrack, itbarrelDIRCTrack, itdualRICHagTrack, itdualRICHcfTrack); + int mcpid = trkParticle->PID; + + FillHistosPurity(recpid,mcpid); + // calculate hadron kinematics kin->hadPID = pid; kin->vecHadron.SetPtEtaPhiM( diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index 9ce99315..75d14c69 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -634,7 +634,8 @@ void PostProcessor::DrawSDInBinsTogether( xaxisx2 = 0.975; yaxisy1 = 0.08; }; - + logFile.open("out/barak_log.txt");//DEBUGGING: PRINTOUT FOR BARAK + logFile<<"x\tQ2\tyres\n";//DEBUGGING: PRINT OUT BIN BY BIN RESULTS FOR BARAK TString canvN = "canv_"+outName+"_all__"; for (int k=0; kGetYaxis()->SetLabelSize(0.06); subHist->GetYaxis()->SetLabelOffset(0.02); + //DEBUGGING: ALL BELOW FOR BARAK + double x_bw = (log10(var1high)-log10(var1low))/nvar1; + double q2_bw = (log10(var2high)-log10(var2low))/nvar2; + double xBin = log10(var1low)+(i+1/2)*x_bw; + double q2Bin = log10(var2low)+(j+1/2)*q2_bw; + double yres = subHist->GetBinContent(1); + double yerr = subHist->GetBinError(1); + logFile<SetTitle(histNames[k]); subHist->SetMarkerStyle(k==0 ? 32 : k+25); subHist->SetMarkerColor(k+2); @@ -782,6 +793,7 @@ void PostProcessor::DrawSDInBinsTogether( newpad2->cd(); xaxis->Draw(); + logFile.close(); // canv->Write(); canv->Print(pngDir+"/"+canvN+".png"); diff --git a/src/PostProcessor.h b/src/PostProcessor.h index f4a312f9..222a46bf 100644 --- a/src/PostProcessor.h +++ b/src/PostProcessor.h @@ -3,6 +3,9 @@ #include #include +#include +#include +#include // root #include "TFile.h" @@ -40,6 +43,8 @@ class PostProcessor : public TNamed const Int_t dimy=700; static const int nsumMax=3; // number of summary plots with formatting + std::ofstream logFile; + // DAG interfaces: HistosDAG *GetHistosDAG() { return HD; }; From 6492cf98e1df274bcdefb76be49c9b2161210ea9 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Tue, 16 Nov 2021 14:56:39 -0500 Subject: [PATCH 15/51] Small updates: removed y axis scaling in `PostProcessor::DrawInBins()` method, just divide by total counts for purities, change config file name for barak macro --- macro/analysis_barak.C | 6 +++--- src/Analysis.cxx | 6 +++--- src/PostProcessor.cxx | 20 ++++++++++---------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/macro/analysis_barak.C b/macro/analysis_barak.C index 1354a2a4..9fa1d732 100644 --- a/macro/analysis_barak.C +++ b/macro/analysis_barak.C @@ -2,11 +2,11 @@ R__LOAD_LIBRARY(Largex) // make resolution plots void analysis_barak( - TString infiles="datarec/dis-18x275.config", /* list of input files */ + TString infiles="datarec/dis-18x275-xm25.config", /* list of input files */ Double_t eleBeamEn=5, /* electron beam energy [GeV] */ Double_t ionBeamEn=41, /* ion beam energy [GeV] */ - Double_t crossingAngle=0, /* crossing angle [mrad] */ - TString outfilePrefix="barak_dis-18x275" /* output filename prefix*/ + Double_t crossingAngle=25, /* crossing angle [mrad] */ + TString outfilePrefix="barak_dis-18x275-xm25" /* output filename prefix*/ ) { // setup analysis ======================================== diff --git a/src/Analysis.cxx b/src/Analysis.cxx index 71720cbc..db01988d 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -466,10 +466,10 @@ void Analysis::Finish() { // Convert to contamination plot since the y scale is better for plotting with stddevs - H->Hist("z_purity")->Add(H->Hist("z_true"),-1); + // H->Hist("z_purity")->Add(H->Hist("z_true"),-1); H->Hist("z_purity")->Divide(H->Hist("z_true")); - TF1 *f1 = new TF1("f1","1",0,1); //TODO: Set limits automatically - H->Hist("z_purity")->Multiply(f1,-1); + // TF1 *f1 = new TF1("f1","1",0,1); //TODO: Set limits automatically + // H->Hist("z_purity")->Multiply(f1,-1); }); diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index 75d14c69..0ededd9d 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -447,16 +447,16 @@ void PostProcessor::DrawInBins( // //hist->GetYaxis()->SetTitle(""); // //hist->GetXaxis()->SetLabelSize(0); // //hist->GetYaxis()->SetLabelSize(0); - hist->GetXaxis()->SetTitleSize(0.1); - hist->GetXaxis()->SetTitleOffset(0.5); - hist->GetXaxis()->SetNdivisions(8); - hist->GetXaxis()->SetLabelSize(0.06); - hist->GetXaxis()->CenterTitle(); - hist->GetXaxis()->SetLabelOffset(0.02); - hist->GetYaxis()->SetRangeUser(0,0.05);//TODO: CHECK THIS IS REASONABLE ALSO WHAT ABOUT ERROR BARS??? - hist->GetYaxis()->SetNdivisions(8); - hist->GetYaxis()->SetLabelSize(0.06); - hist->GetYaxis()->SetLabelOffset(0.02); + // hist->GetXaxis()->SetTitleSize(0.1); + // hist->GetXaxis()->SetTitleOffset(0.5); + // hist->GetXaxis()->SetNdivisions(8); + // hist->GetXaxis()->SetLabelSize(0.06); + // hist->GetXaxis()->CenterTitle(); + // hist->GetXaxis()->SetLabelOffset(0.02); + // hist->GetYaxis()->SetRangeUser(0,0.05);//TODO: CHECK THIS IS REASONABLE ALSO WHAT ABOUT ERROR BARS??? + // hist->GetYaxis()->SetNdivisions(8); + // hist->GetYaxis()->SetLabelSize(0.06); + // hist->GetYaxis()->SetLabelOffset(0.02); // // for(int k = 0; k < i; k++){ // // for(int l = 0; l < j; k++){ // // histArray[k][l]->GetYaxis()->SetRangeUser(TMath::Min(yMin,hist->GetYaxis()->GetMinimum(),TMath::Max(yMax,hist->GetYaxis()->GetMaximum()))); From f49acfa620fabd70cdb8038b66ca083f7c0bede8 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Tue, 16 Nov 2021 21:29:15 -0500 Subject: [PATCH 16/51] Still debugging pid assignments, also fixed old issues in scripts --- createDelphesScripts.sh | 36 ++++++++++++----------------- createFullScripts.sh | 36 ++++++++++------------------- macro/analysis_barak.C | 9 ++++++-- macro/analysis_resolution_SD.C | 2 +- macro/analysis_resolution_SD_Full.C | 4 ++-- macro/postprocess_barak.C | 4 ++-- macro/postprocess_resolution_SD.C | 12 +++++----- src/Analysis.cxx | 16 ++++++------- src/Analysis.h | 2 +- src/AnalysisDD4hep.cxx | 3 ++- src/AnalysisDelphes.cxx | 29 +++++++++++++++++------ 11 files changed, 77 insertions(+), 76 deletions(-) diff --git a/createDelphesScripts.sh b/createDelphesScripts.sh index 5bade7d7..420253fb 100755 --- a/createDelphesScripts.sh +++ b/createDelphesScripts.sh @@ -2,13 +2,13 @@ # Create fast simulation resolutions plotting scripts and submit to ifarm -script='/work/clas12/users/mfmce/largex-eic/macro/analysis_resolution_SD.C' -postScript='/work/clas12/users/mfmce/largex-eic/macro/postprocess_resolution_SD.C' -submitScript='/work/clas12/users/mfmce/largex-eic/submit.sh' -jobScript='/work/clas12/users/mfmce/largex-eic/job.sh' -out='/work/clas12/users/mfmce/largex-eic/macro/' -cd /work/clas12/users/mfmce/largex-eic/datarec/ -for file in *.config +script="$PWD/macro/analysis_resolution_SD.C" +postScript="/$PWD/macro/postprocess_resolution_SD.C" +submitScript="$PWD/submit.sh" +jobScript="$PWD/job.sh" +out="$PWD/macro/" +cd datarec +for file in *-xm25.config do config=`echo $file | sed "s;.config;;g"` mkdir -p $out/$config @@ -25,32 +25,26 @@ do echo "beamIn=${beamIn}" echo "xAng=${xAng}" echo "xAngM=${xAngM}" - echo -------------------- sed -i "s;dis-5x41;${config};g" $newscript sed -i "s;eleBeamEn=5;eleBeamEn=${eleIn};g" $newscript sed -i "s;ionBeamEn=41;ionBeamEn=${beamIn};g" $newscript if [ $xAng ]; then - sed -i "s;crossingAngle=0;crossingAngle=${xAng};g" $newscript + sed -i "s;crossingAngle=25;crossingAngle=-${xAng};g" $newscript fi if [ $xAngM ]; then - sed -i "s;icrossingAngle=0;crossingAngle=-${xAngM};g" $newscript + sed -i "s;icrossingAngle=25;crossingAngle=${xAngM};g" $newscript fi cp $postScript $out/$config - sed -i "s;out/resolution;out/${config};g" $out/$config/*.C - if [ $xAng ]; then - sed -i "s;testheader;${eleIn}x${beamIn} ${xAng};g" $out/$config/*.C - fi - if [ $xAngM ]; then - sed -i "s;testheader;${eleIn}x${beamIn} -${xAngM};g" $out/$config/*.C - fi + sed -i "s;datarec/dis-5x41;datarec/${config};g" $out/$config/*.C + sed -i "s;out/dis-5x41;out/${config};g" $out/$config/*.C + sed -i "s;testheader;${eleIn}x${beamIn}GeV;g" $out/$config/*.C cp $submitScript $out/$config cp $jobScript $out/$config sed -i "s;dis-5x41;${config};g" $out/$config/*.sh - if [ $xAngM ]; then #NOTE: Just use negative angle files - sbatch $out/$config/submit.sh - fi - + sbatch $out/$config/submit.sh + echo -------------------- + done cd .. echo DONE diff --git a/createFullScripts.sh b/createFullScripts.sh index 40f2097c..7a6ca8ce 100755 --- a/createFullScripts.sh +++ b/createFullScripts.sh @@ -1,12 +1,12 @@ #!/bin/bash # Create full simulation resolution plotting scripts and submit to ifarm -script='/work/clas12/users/mfmce/largex-eic/macro/analysis_resolution_SD_Full.C' -postScript='/work/clas12/users/mfmce/largex-eic/macro/postprocess_resolution_SD.C' -submitScript='/work/clas12/users/mfmce/largex-eic/submit.sh' -jobScript='/work/clas12/users/mfmce/largex-eic/job.sh' -out='/work/clas12/users/mfmce/largex-eic/macro/canyonlands/' -cd /work/clas12/users/mfmce/largex-eic/datarec/canyonlands/5x41/ -for file in /work/clas12/users/mfmce/largex-eic/datarec/canyonlands/*/*.config +script="$PWD/macro/analysis_resolution_SD_Full.C" +postScript="$PWD/macro/postprocess_resolution_SD.C" +submitScript="$PWD/submit.sh" +jobScript="$PWD/job.sh" +out="$PWD/macro/canyonlands/" +cd datarec/canyonlands/ +for file in */*.config do config=`echo $file | sed "s;.config;;g" | grep -Eo 'canyonlands/.*' | sed 's;canyonlands/;;g' | sed 's;/files;;g'` mkdir -p $out/$config @@ -24,37 +24,25 @@ do echo "beamIn=${beamIn}" echo "xAng=${xAng}" echo "xAngM=${xAngM}" - echo -------------------- sed -i "s;datarec/dis-5x41.config;${file};g" $newscript sed -i "s;full_dis-5x41;full_${config};g" $newscript sed -i "s;eleBeamEn=5;eleBeamEn=${eleIn};g" $newscript sed -i "s;ionBeamEn=41;ionBeamEn=${beamIn};g" $newscript if [ $xAng ]; then - sed -i "s;crossingAngle=0;crossingAngle=${xAng};g" $newscript + sed -i "s;crossingAngle=25;crossingAngle=-${xAng};g" $newscript fi if [ $xAngM ]; then - sed -i "s;icrossingAngle=0;crossingAngle=-${xAngM};g" $newscript + sed -i "s;icrossingAngle=25;crossingAngle=${xAngM};g" $newscript fi cp $postScript $out/$config - sed -i "s;out/resolution;out/full_${config};g" $out/$config/*.C - if [ $xAng ]; then - sed -i "s;testheader;${eleIn}x${beamIn} ${xAng};g" $out/$config/*.C - fi - if [ $xAngM ]; then - sed -i "s;testheader;${eleIn}x${beamIn} -${xAngM};g" $out/$config/*.C - fi + sed -i "s;dis-5x41;${config};g" $out/$config/*.C + sed -i "s;testheader;${eleIn}x${beamIn}GeV;g" $out/$config/*.C cp $submitScript $out/$config cp $jobScript $out/$config sed -i "s;dis-5x41;canyonlands/${config};g" $out/$config/*.sh - - # submit job sbatch $out/$config/submit.sh - + echo -------------------- done cd .. echo DONE -#cd /work/clas12/users/mfmce/largex-eic -#echo "root -q -b macro/analysis_resolution_SD.C" | ./container/shell.sh -#echo "root -q -b macro/postprocess_resolution_SD.C" | ./container/shell.sh -#echo DONE diff --git a/macro/analysis_barak.C b/macro/analysis_barak.C index 9fa1d732..b30d21e8 100644 --- a/macro/analysis_barak.C +++ b/macro/analysis_barak.C @@ -22,8 +22,13 @@ void analysis_barak( // A->RESHIGH = 1; // A->RESLOW = -1; //A->maxEvents = 30000; // use this to limit the number of events - A->SetReconMethod("Ele"); // set reconstruction method - A->AddFinalState("pipTrack"); // pion final state + A->SetReconMethod("JB"); // set reconstruction method + //A->SetReconMethod("DA"); // set reconstruction method + A->AddFinalState("pipTrack"); // pi+ final state + A->AddFinalState("pimTrack"); // pi- final state + A->AddFinalState("KpTrack"); // K+ final state + A->AddFinalState("KmTrack"); // K- final state + A->AddFinalState("pTrack"); // proton final state // define cuts ==================================== A->AddBinScheme("w"); A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV diff --git a/macro/analysis_resolution_SD.C b/macro/analysis_resolution_SD.C index 1cee9d22..258cbab4 100644 --- a/macro/analysis_resolution_SD.C +++ b/macro/analysis_resolution_SD.C @@ -5,7 +5,7 @@ void analysis_resolution_SD( TString infiles="datarec/dis-5x41.config", /* list of input files */ Double_t eleBeamEn=5, /* electron beam energy [GeV] */ Double_t ionBeamEn=41, /* ion beam energy [GeV] */ - Double_t crossingAngle=0, /* crossing angle [mrad] */ + Double_t crossingAngle=25, /* crossing angle [mrad] */ TString outfilePrefix="dis-5x41" /* output filename prefix*/ ) { diff --git a/macro/analysis_resolution_SD_Full.C b/macro/analysis_resolution_SD_Full.C index 434ca60e..4823c157 100644 --- a/macro/analysis_resolution_SD_Full.C +++ b/macro/analysis_resolution_SD_Full.C @@ -2,10 +2,10 @@ R__LOAD_LIBRARY(Largex) // make resolution plots void analysis_resolution_SD_Full( - TString infiles="datarec/dis-5x41.config", /* list of input files */ + TString infiles="datarec/full_dis-5x41.config", /* list of input files */ Double_t eleBeamEn=5, /* electron beam energy [GeV] */ Double_t ionBeamEn=41, /* ion beam energy [GeV] */ - Double_t crossingAngle=0, /* crossing angle [mrad] */ + Double_t crossingAngle=25, /* crossing angle [mrad] */ TString outfilePrefix="full_dis-5x41" /* output filename prefix*/ ) { diff --git a/macro/postprocess_barak.C b/macro/postprocess_barak.C index 3e54ddd4..4f80f109 100644 --- a/macro/postprocess_barak.C +++ b/macro/postprocess_barak.C @@ -4,7 +4,6 @@ R__LOAD_LIBRARY(Largex) // - adapted from `postprocess_pTvsEta.C` void postprocess_barak( TString infile="out/barak_dis-18x275.root" - TString header="18x275GeV" ){ gROOT->ProcessLine(".! rm -v out/barak_dis-18x275.images/*.png"); // cleanup old image files @@ -65,8 +64,9 @@ void postprocess_barak( double yMin, yMax; yMin = -0.1; yMax = 0.5;//Adjust as needed TString histNames[nNames] = {"z_y_Res"}; TString labels[nNames] = {"y"}; + TString header="18x275GeV"; P->DrawSDInBinsTogether( - canvname, histos_xQ2, histNames, labels, nNames, yMin, yMax, + canvname, histos_xQ2, header, histNames, labels, nNames, yMin, yMax, "x", nx, xMin, xMax, true, "Q^{2}", nq2, q2Min, q2Max, true ); diff --git a/macro/postprocess_resolution_SD.C b/macro/postprocess_resolution_SD.C index 9f61da2d..40ac8d42 100644 --- a/macro/postprocess_resolution_SD.C +++ b/macro/postprocess_resolution_SD.C @@ -3,12 +3,11 @@ R__LOAD_LIBRARY(Largex) // make resolution plots // - adapted from `postprocess_pTvsEta.C` void postprocess_resolution_SD( - TString infile="out/resolution.root" - TString header="resolution" + TString infile="out/dis-5x41.root" ){ - gROOT->ProcessLine(".! rm -v out/resolution.images/*.png"); // cleanup old image files - gROOT->ProcessLine(".! rm -v out/resolution.images/*.pdf"); // cleanup old image files + gROOT->ProcessLine(".! rm -v out/dis-5x41.images/*.png"); // cleanup old image files + gROOT->ProcessLine(".! rm -v out/dis-5x41.images/*.pdf"); // cleanup old image files PostProcessor *P = new PostProcessor(infile); P->Op()->PrintBreadth("HistosDAG Initial Setup"); @@ -61,12 +60,13 @@ void postprocess_resolution_SD( ); }; - const int nNames = 3; + const int nNames = 6; double yMin, yMax; yMin = -0.1; yMax = 0.5;//Adjust as needed TString histNames[nNames] = {"z_Q2_Res","z_x_Res","z_y_Res","z_z_Res","z_pT_Res","z_purity"}; TString labels[nNames] = {"Q^{2}","x","y","z","p_{T}","1-purity"}; + TString header="testheader"; P->DrawSDInBinsTogether( - canvname, histos_xQ2, histNames, labels, nNames, yMin, yMax, + canvname, histos_xQ2, header, histNames, labels, nNames, yMin, yMax, "x", nx, xMin, xMax, true, "Q^{2}", nq2, q2Min, q2Max, true ); diff --git a/src/Analysis.cxx b/src/Analysis.cxx index db01988d..130043e4 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -466,10 +466,10 @@ void Analysis::Finish() { // Convert to contamination plot since the y scale is better for plotting with stddevs - // H->Hist("z_purity")->Add(H->Hist("z_true"),-1); + H->Hist("z_purity")->Add(H->Hist("z_true"),-1); H->Hist("z_purity")->Divide(H->Hist("z_true")); - // TF1 *f1 = new TF1("f1","1",0,1); //TODO: Set limits automatically - // H->Hist("z_purity")->Multiply(f1,-1); + TF1 *f1 = new TF1("f1","1",0,1); //TODO: Set limits automatically + H->Hist("z_purity")->Multiply(f1,-1); }); @@ -692,7 +692,7 @@ void Analysis::FillHistosTracks() { }; // jets -void Analysis::FillHistosPurity(int recpid, int mcpid) { +void Analysis::FillHistosPurity(bool recMatch, bool mcMatch) { // add kinematic values to `valueMap` valueMap.clear(); @@ -710,11 +710,9 @@ void Analysis::FillHistosPurity(int recpid, int mcpid) { if(!activeEvent) return; // fill histograms, for activated bins only - HD->Payload([this,recpid,mcpid](Histos *H){ - H->Hist("z_true")->Fill(kinTrue->z, wTrack ); - if (recpid==mcpid) { - H->Hist("z_purity")->Fill(kinTrue->z,wTrack); - }//endif + HD->Payload([this,recMatch,mcMatch](Histos *H){ + if (recMatch) H->Hist("z_true")->Fill(kinTrue->z, wTrack ); + if (mcMatch) H->Hist("z_purity")->Fill(kinTrue->z,wTrack); }); // execute the payload // - save time and don't call `ClearOps` (next loop will overwrite lambda) diff --git a/src/Analysis.h b/src/Analysis.h index 7d1be112..3c3bee17 100644 --- a/src/Analysis.h +++ b/src/Analysis.h @@ -100,7 +100,7 @@ class Analysis : public TNamed // FillHistos methods: fill histograms void FillHistosTracks(); - void FillHistosPurity(int recpid, int mcpid); + void FillHistosPurity(bool recMatch, bool mcMatch); void FillHistosJets(); // lambda to check which bins an observable is in, during DAG breadth diff --git a/src/AnalysisDD4hep.cxx b/src/AnalysisDD4hep.cxx index 9829bbea..d6e9d604 100644 --- a/src/AnalysisDD4hep.cxx +++ b/src/AnalysisDD4hep.cxx @@ -228,7 +228,8 @@ void AnalysisDD4hep::process_event() { if(mcid_ == imc.mcID) { - FillHistosPurity(pid_,imc.pid); + bool mcMatch=(pid_==imc.pid); + FillHistosPurity(false,mcMatch); kinTrue->vecHadron = imc.vecPart; break; } diff --git a/src/AnalysisDelphes.cxx b/src/AnalysisDelphes.cxx index b32c5701..262f043d 100644 --- a/src/AnalysisDelphes.cxx +++ b/src/AnalysisDelphes.cxx @@ -196,22 +196,37 @@ void AnalysisDelphes::Execute() { // - check PID, to see if it's a final state we're interested in for // histograms; if not, proceed to next track pid = trk->PID; + + // Purities + // Get REC and MC particle PID + GenParticle *trkParticle = (GenParticle*)trk->Particle.GetObject(); + int recpid = getPID(trk, itParticle, itmRICHTrack, itbarrelDIRCTrack, itdualRICHagTrack, itdualRICHcfTrack); + int mcpid = trkParticle->PID; + + //DEBUGGING + if (pid!=mcpid) {std::cout<<"DEBUGGING: "<NBINS = 5; // use this to set the number of bins along each axis, e.g., z binning (except resolution axes) for each overall bin in e.g. x and Q2 + A->NBINSRES = 100; // use this to set the number of bins along the resolution axes for each overall bin in e.g. x and Q2 + // A->RESHIGH = 1; + // A->RESLOW = -1; + //A->maxEvents = 30000; // use this to limit the number of events + A->SetReconMethod("DA"); // set reconstruction method + A->AddFinalState("pipTrack"); // pion final state + A->AddFinalState("pimTrack"); // pion final state + A->AddFinalState("KpTrack"); // pion final state + A->AddFinalState("KmTrack"); // pion final state + A->AddFinalState("pTrack"); // pion final state + + // define cuts ==================================== + A->AddBinScheme("w"); A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV + A->AddBinScheme("y"); A->BinScheme("y")->BuildBin("Range",0.01,0.95); // 0.01 < y < 0.95 + A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,0.9); // 0.2 < z < 0.9 + A->AddBinScheme("xF"); A->BinScheme("xF")->BuildBin("Min",0.0); // xF > 0 + A->AddBinScheme("ptLab"); A->BinScheme("ptLab")->BuildBin("Min",0.1); // pT_lab > 0.1 GeV (tracking limit) + + // set binning scheme ==================================== + A->AddBinScheme("q2"); A->BinScheme("q2")->BuildBins( 4, 1, 100, true ); + A->AddBinScheme("x"); A->BinScheme("x")->BuildBins( 6, 0.01, 1, true ); + + // perform the analysis ================================== + A->Execute(); +}; diff --git a/macro/analysis_resolution_ELE.C b/macro/analysis_resolution_ELE.C new file mode 100644 index 00000000..543a0ed1 --- /dev/null +++ b/macro/analysis_resolution_ELE.C @@ -0,0 +1,45 @@ +R__LOAD_LIBRARY(Largex) + +// make resolution plots +void analysis_resolution_ELE( + TString infiles="datarec/dis-5x41.config", /* list of input files */ + Double_t eleBeamEn=5, /* electron beam energy [GeV] */ + Double_t ionBeamEn=41, /* ion beam energy [GeV] */ + Double_t crossingAngle=25, /* crossing angle [mrad] */ + TString outfilePrefix="ELE_dis-5x41" /* output filename prefix*/ +) { + + // setup analysis ======================================== + AnalysisDelphes *A = new AnalysisDelphes( + infiles, + eleBeamEn, + ionBeamEn, + crossingAngle, + outfilePrefix + ); + A->NBINS = 5; // use this to set the number of bins along each axis, e.g., z binning (except resolution axes) for each overall bin in e.g. x and Q2 + A->NBINSRES = 100; // use this to set the number of bins along the resolution axes for each overall bin in e.g. x and Q2 + // A->RESHIGH = 1; + // A->RESLOW = -1; + //A->maxEvents = 30000; // use this to limit the number of events + A->SetReconMethod("Ele"); // set reconstruction method + A->AddFinalState("pipTrack"); // pion final state + A->AddFinalState("pimTrack"); // pion final state + A->AddFinalState("KpTrack"); // pion final state + A->AddFinalState("KmTrack"); // pion final state + A->AddFinalState("pTrack"); // pion final state + + // define cuts ==================================== + A->AddBinScheme("w"); A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV + A->AddBinScheme("y"); A->BinScheme("y")->BuildBin("Range",0.01,0.95); // 0.01 < y < 0.95 + A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,0.9); // 0.2 < z < 0.9 + A->AddBinScheme("xF"); A->BinScheme("xF")->BuildBin("Min",0.0); // xF > 0 + A->AddBinScheme("ptLab"); A->BinScheme("ptLab")->BuildBin("Min",0.1); // pT_lab > 0.1 GeV (tracking limit) + + // set binning scheme ==================================== + A->AddBinScheme("q2"); A->BinScheme("q2")->BuildBins( 4, 1, 100, true ); + A->AddBinScheme("x"); A->BinScheme("x")->BuildBins( 6, 0.01, 1, true ); + + // perform the analysis ================================== + A->Execute(); +}; diff --git a/macro/analysis_resolution_JB.C b/macro/analysis_resolution_JB.C new file mode 100644 index 00000000..47fd7528 --- /dev/null +++ b/macro/analysis_resolution_JB.C @@ -0,0 +1,45 @@ +R__LOAD_LIBRARY(Largex) + +// make resolution plots +void analysis_resolution_JB( + TString infiles="datarec/dis-5x41.config", /* list of input files */ + Double_t eleBeamEn=5, /* electron beam energy [GeV] */ + Double_t ionBeamEn=41, /* ion beam energy [GeV] */ + Double_t crossingAngle=25, /* crossing angle [mrad] */ + TString outfilePrefix="JB_dis-5x41" /* output filename prefix*/ +) { + + // setup analysis ======================================== + AnalysisDelphes *A = new AnalysisDelphes( + infiles, + eleBeamEn, + ionBeamEn, + crossingAngle, + outfilePrefix + ); + A->NBINS = 5; // use this to set the number of bins along each axis, e.g., z binning (except resolution axes) for each overall bin in e.g. x and Q2 + A->NBINSRES = 100; // use this to set the number of bins along the resolution axes for each overall bin in e.g. x and Q2 + // A->RESHIGH = 1; + // A->RESLOW = -1; + //A->maxEvents = 30000; // use this to limit the number of events + A->SetReconMethod("JB"); // set reconstruction method + A->AddFinalState("pipTrack"); // pion final state + A->AddFinalState("pimTrack"); // pion final state + A->AddFinalState("KpTrack"); // pion final state + A->AddFinalState("KmTrack"); // pion final state + A->AddFinalState("pTrack"); // pion final state + + // define cuts ==================================== + A->AddBinScheme("w"); A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV + A->AddBinScheme("y"); A->BinScheme("y")->BuildBin("Range",0.01,0.95); // 0.01 < y < 0.95 + A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,0.9); // 0.2 < z < 0.9 + A->AddBinScheme("xF"); A->BinScheme("xF")->BuildBin("Min",0.0); // xF > 0 + A->AddBinScheme("ptLab"); A->BinScheme("ptLab")->BuildBin("Min",0.1); // pT_lab > 0.1 GeV (tracking limit) + + // set binning scheme ==================================== + A->AddBinScheme("q2"); A->BinScheme("q2")->BuildBins( 4, 1, 100, true ); + A->AddBinScheme("x"); A->BinScheme("x")->BuildBins( 6, 0.01, 1, true ); + + // perform the analysis ================================== + A->Execute(); +}; diff --git a/macro/analysis_resolution_SD.C b/macro/analysis_resolution_SD.C index 258cbab4..344d50db 100644 --- a/macro/analysis_resolution_SD.C +++ b/macro/analysis_resolution_SD.C @@ -24,6 +24,10 @@ void analysis_resolution_SD( //A->maxEvents = 30000; // use this to limit the number of events A->SetReconMethod("Ele"); // set reconstruction method A->AddFinalState("pipTrack"); // pion final state + A->AddFinalState("pimTrack"); // pion final state + A->AddFinalState("KpTrack"); // pion final state + A->AddFinalState("KmTrack"); // pion final state + A->AddFinalState("pTrack"); // pion final state // define cuts ==================================== A->AddBinScheme("w"); A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV diff --git a/macro/postprocess_barak.C b/macro/postprocess_barak.C index 4f80f109..075783b9 100644 --- a/macro/postprocess_barak.C +++ b/macro/postprocess_barak.C @@ -3,11 +3,11 @@ R__LOAD_LIBRARY(Largex) // make resolution plots // - adapted from `postprocess_pTvsEta.C` void postprocess_barak( - TString infile="out/barak_dis-18x275.root" + TString infile="out/barak_dis-18x275-xm25.root" ){ - gROOT->ProcessLine(".! rm -v out/barak_dis-18x275.images/*.png"); // cleanup old image files - gROOT->ProcessLine(".! rm -v out/barak_dis-18x275.images/*.pdf"); // cleanup old image files + gROOT->ProcessLine(".! rm -v out/barak_dis-18x275-xm25.images/*.png"); // cleanup old image files + gROOT->ProcessLine(".! rm -v out/barak_dis-18x275-xm25.images/*.pdf"); // cleanup old image files PostProcessor *P = new PostProcessor(infile); P->Op()->PrintBreadth("HistosDAG Initial Setup"); diff --git a/macro/postprocess_resolution_DA.C b/macro/postprocess_resolution_DA.C new file mode 100644 index 00000000..234134de --- /dev/null +++ b/macro/postprocess_resolution_DA.C @@ -0,0 +1,86 @@ +R__LOAD_LIBRARY(Largex) + +// make resolution plots +// - adapted from `postprocess_pTvsEta.C` +void postprocess_resolution_SD( + TString infile="out/DA_dis-5x41.root" +){ + + gROOT->ProcessLine(".! rm -v out/DA_dis-5x41.images/*.png"); // cleanup old image files + gROOT->ProcessLine(".! rm -v out/DA_dis-5x41.images/*.pdf"); // cleanup old image files + + PostProcessor *P = new PostProcessor(infile); + P->Op()->PrintBreadth("HistosDAG Initial Setup"); + + // number of bins in x and Q2 + int nx = P->Op()->GetBinSet("x")->GetNumBins(); + int nq2 = P->Op()->GetBinSet("q2")->GetNumBins(); + + // just counters for filling Histos vector + int xbin = 0; + int q2bin = 0; + + // initialize this 2D vector to be some large size + std::vector> histos_xQ2(30,std::vector(30)); + + auto findxQ2bins = [&histos_xQ2,&P,&xbin,&q2bin,nx,nq2](Histos *H ){ + histos_xQ2[xbin][q2bin] = H; + q2bin++; + if(q2bin == nq2){ + q2bin=0; xbin++; + if(xbin == nx) xbin = 0; + } + }; + + auto drawinxQ2bins = [&histos_xQ2, &P, &nx, &nq2](NodePath *bins){ + TString canvname = "xQ2cov_"; //+ bins->GetVar + for(Node *bin: bins->GetBinNodes()){ + if(bin->GetVarName() == "finalState"){ + canvname+=bin->GetID(); + canvname+="_"; + } + if(bin->GetVarName() == "z"){ + canvname+=bin->GetID(); + canvname+="_"; + } + } + + double xMin = 1e-4; + double xMax = 1; + double q2Min = 0.99; + double q2Max = 1000; + + // loop over resolution histograms (see ../src/Analysis.cxx `DefineHist*` calls + // for available histograms, or add your own there) + for( TString histname : {"x_Res","y_Res","Q2_Res","phiH_Res","phiS_Res","phiHvsPhiS","z_purity"} ) { + P->DrawInBins( + canvname, histos_xQ2, histname, + "x", nx, xMin, xMax, true, + "Q^{2}", nq2, q2Min, q2Max, true + ); + }; + + const int nNames = 6; + double yMin, yMax; yMin = -0.1; yMax = 0.5;//Adjust as needed + TString histNames[nNames] = {"z_Q2_Res","z_x_Res","z_y_Res","z_z_Res","z_pT_Res","z_purity"}; + TString labels[nNames] = {"Q^{2}","x","y","z","p_{T}","1-purity"}; + TString header="testheader"; + P->DrawSDInBinsTogether( + canvname, histos_xQ2, header, histNames, labels, nNames, yMin, yMax, + "x", nx, xMin, xMax, true, + "Q^{2}", nq2, q2Min, q2Max, true + ); + }; + + auto beforefunction = [](){ + }; + + P->Op()->Subloop({"x","q2"},beforefunction,drawinxQ2bins); + P->Op()->Payload(findxQ2bins); + + //P->Op()->PrintBreadth("HistosDAG Final Setup"); + + P->Execute(); + + P->Finish(); +}; diff --git a/macro/postprocess_resolution_ELE.C b/macro/postprocess_resolution_ELE.C new file mode 100644 index 00000000..b167c249 --- /dev/null +++ b/macro/postprocess_resolution_ELE.C @@ -0,0 +1,86 @@ +R__LOAD_LIBRARY(Largex) + +// make resolution plots +// - adapted from `postprocess_pTvsEta.C` +void postprocess_resolution_ELE( + TString infile="out/ELE_dis-5x41.root" +){ + + gROOT->ProcessLine(".! rm -v out/ELE_dis-5x41.images/*.png"); // cleanup old image files + gROOT->ProcessLine(".! rm -v out/ELE_dis-5x41.images/*.pdf"); // cleanup old image files + + PostProcessor *P = new PostProcessor(infile); + P->Op()->PrintBreadth("HistosDAG Initial Setup"); + + // number of bins in x and Q2 + int nx = P->Op()->GetBinSet("x")->GetNumBins(); + int nq2 = P->Op()->GetBinSet("q2")->GetNumBins(); + + // just counters for filling Histos vector + int xbin = 0; + int q2bin = 0; + + // initialize this 2D vector to be some large size + std::vector> histos_xQ2(30,std::vector(30)); + + auto findxQ2bins = [&histos_xQ2,&P,&xbin,&q2bin,nx,nq2](Histos *H ){ + histos_xQ2[xbin][q2bin] = H; + q2bin++; + if(q2bin == nq2){ + q2bin=0; xbin++; + if(xbin == nx) xbin = 0; + } + }; + + auto drawinxQ2bins = [&histos_xQ2, &P, &nx, &nq2](NodePath *bins){ + TString canvname = "xQ2cov_"; //+ bins->GetVar + for(Node *bin: bins->GetBinNodes()){ + if(bin->GetVarName() == "finalState"){ + canvname+=bin->GetID(); + canvname+="_"; + } + if(bin->GetVarName() == "z"){ + canvname+=bin->GetID(); + canvname+="_"; + } + } + + double xMin = 1e-4; + double xMax = 1; + double q2Min = 0.99; + double q2Max = 1000; + + // loop over resolution histograms (see ../src/Analysis.cxx `DefineHist*` calls + // for available histograms, or add your own there) + for( TString histname : {"x_Res","y_Res","Q2_Res","phiH_Res","phiS_Res","phiHvsPhiS","z_purity"} ) { + P->DrawInBins( + canvname, histos_xQ2, histname, + "x", nx, xMin, xMax, true, + "Q^{2}", nq2, q2Min, q2Max, true + ); + }; + + const int nNames = 6; + double yMin, yMax; yMin = -0.1; yMax = 0.5;//Adjust as needed + TString histNames[nNames] = {"z_Q2_Res","z_x_Res","z_y_Res","z_z_Res","z_pT_Res","z_purity"}; + TString labels[nNames] = {"Q^{2}","x","y","z","p_{T}","1-purity"}; + TString header="testheader"; + P->DrawSDInBinsTogether( + canvname, histos_xQ2, header, histNames, labels, nNames, yMin, yMax, + "x", nx, xMin, xMax, true, + "Q^{2}", nq2, q2Min, q2Max, true + ); + }; + + auto beforefunction = [](){ + }; + + P->Op()->Subloop({"x","q2"},beforefunction,drawinxQ2bins); + P->Op()->Payload(findxQ2bins); + + //P->Op()->PrintBreadth("HistosDAG Final Setup"); + + P->Execute(); + + P->Finish(); +}; diff --git a/macro/postprocess_resolution_JB.C b/macro/postprocess_resolution_JB.C new file mode 100644 index 00000000..8c50288c --- /dev/null +++ b/macro/postprocess_resolution_JB.C @@ -0,0 +1,86 @@ +R__LOAD_LIBRARY(Largex) + +// make resolution plots +// - adapted from `postprocess_pTvsEta.C` +void postprocess_resolution_SD( + TString infile="out/JB_dis-5x41.root" +){ + + gROOT->ProcessLine(".! rm -v out/JB_dis-5x41.images/*.png"); // cleanup old image files + gROOT->ProcessLine(".! rm -v out/JB_dis-5x41.images/*.pdf"); // cleanup old image files + + PostProcessor *P = new PostProcessor(infile); + P->Op()->PrintBreadth("HistosDAG Initial Setup"); + + // number of bins in x and Q2 + int nx = P->Op()->GetBinSet("x")->GetNumBins(); + int nq2 = P->Op()->GetBinSet("q2")->GetNumBins(); + + // just counters for filling Histos vector + int xbin = 0; + int q2bin = 0; + + // initialize this 2D vector to be some large size + std::vector> histos_xQ2(30,std::vector(30)); + + auto findxQ2bins = [&histos_xQ2,&P,&xbin,&q2bin,nx,nq2](Histos *H ){ + histos_xQ2[xbin][q2bin] = H; + q2bin++; + if(q2bin == nq2){ + q2bin=0; xbin++; + if(xbin == nx) xbin = 0; + } + }; + + auto drawinxQ2bins = [&histos_xQ2, &P, &nx, &nq2](NodePath *bins){ + TString canvname = "xQ2cov_"; //+ bins->GetVar + for(Node *bin: bins->GetBinNodes()){ + if(bin->GetVarName() == "finalState"){ + canvname+=bin->GetID(); + canvname+="_"; + } + if(bin->GetVarName() == "z"){ + canvname+=bin->GetID(); + canvname+="_"; + } + } + + double xMin = 1e-4; + double xMax = 1; + double q2Min = 0.99; + double q2Max = 1000; + + // loop over resolution histograms (see ../src/Analysis.cxx `DefineHist*` calls + // for available histograms, or add your own there) + for( TString histname : {"x_Res","y_Res","Q2_Res","phiH_Res","phiS_Res","phiHvsPhiS","z_purity"} ) { + P->DrawInBins( + canvname, histos_xQ2, histname, + "x", nx, xMin, xMax, true, + "Q^{2}", nq2, q2Min, q2Max, true + ); + }; + + const int nNames = 6; + double yMin, yMax; yMin = -0.1; yMax = 0.5;//Adjust as needed + TString histNames[nNames] = {"z_Q2_Res","z_x_Res","z_y_Res","z_z_Res","z_pT_Res","z_purity"}; + TString labels[nNames] = {"Q^{2}","x","y","z","p_{T}","1-purity"}; + TString header="testheader"; + P->DrawSDInBinsTogether( + canvname, histos_xQ2, header, histNames, labels, nNames, yMin, yMax, + "x", nx, xMin, xMax, true, + "Q^{2}", nq2, q2Min, q2Max, true + ); + }; + + auto beforefunction = [](){ + }; + + P->Op()->Subloop({"x","q2"},beforefunction,drawinxQ2bins); + P->Op()->Payload(findxQ2bins); + + //P->Op()->PrintBreadth("HistosDAG Final Setup"); + + P->Execute(); + + P->Finish(); +}; diff --git a/src/AnalysisDelphes.cxx b/src/AnalysisDelphes.cxx index 262f043d..6f2f8ae9 100644 --- a/src/AnalysisDelphes.cxx +++ b/src/AnalysisDelphes.cxx @@ -197,29 +197,12 @@ void AnalysisDelphes::Execute() { // histograms; if not, proceed to next track pid = trk->PID; - // Purities - // Get REC and MC particle PID - GenParticle *trkParticle = (GenParticle*)trk->Particle.GetObject(); - int recpid = getPID(trk, itParticle, itmRICHTrack, itbarrelDIRCTrack, itdualRICHagTrack, itdualRICHcfTrack); - int mcpid = trkParticle->PID; - - //DEBUGGING - if (pid!=mcpid) {std::cout<<"DEBUGGING: "<SetHeader(header,"C"); lg->SetTextSize(0.15); if (nNames>3) lg->SetNColumns(2); @@ -693,16 +691,6 @@ void PostProcessor::DrawSDInBinsTogether( subHist->GetYaxis()->SetLabelSize(0.06); subHist->GetYaxis()->SetLabelOffset(0.02); - //DEBUGGING: ALL BELOW FOR BARAK - double x_bw = (log10(var1high)-log10(var1low))/nvar1; - double q2_bw = (log10(var2high)-log10(var2low))/nvar2; - double xBin = log10(var1low)+(i+1/2)*x_bw; - double q2Bin = log10(var2low)+(j+1/2)*q2_bw; - double yres = subHist->GetBinContent(1); - double yerr = subHist->GetBinError(1); - logFile<SetTitle(histNames[k]); subHist->SetMarkerStyle(k==0 ? 32 : k+25); subHist->SetMarkerColor(k+2); @@ -793,8 +781,6 @@ void PostProcessor::DrawSDInBinsTogether( newpad2->cd(); xaxis->Draw(); - logFile.close(); - // canv->Write(); canv->Print(pngDir+"/"+canvN+".png"); canv->Print(pngDir+"/"+canvN+".pdf"); diff --git a/src/PostProcessor.h b/src/PostProcessor.h index 222a46bf..29e5f6ee 100644 --- a/src/PostProcessor.h +++ b/src/PostProcessor.h @@ -43,9 +43,6 @@ class PostProcessor : public TNamed const Int_t dimy=700; static const int nsumMax=3; // number of summary plots with formatting - std::ofstream logFile; - - // DAG interfaces: HistosDAG *GetHistosDAG() { return HD; }; HistosDAG *Op() { return GetHistosDAG(); }; // syntactic sugar From ae3635152a96264647d0531b439581da90badb12 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Thu, 18 Nov 2021 23:44:50 -0500 Subject: [PATCH 18/51] Simplified analysis script creation for different reconstruction methods --- createDelphesScripts.sh | 8 +- job.sh | 6 ++ ..._resolution_SD.C => analysis_resolution.C} | 2 +- macro/analysis_resolution_DA.C | 45 ---------- macro/analysis_resolution_ELE.C | 45 ---------- macro/analysis_resolution_JB.C | 45 ---------- ...solution_SD.C => postprocess_resolution.C} | 2 +- macro/postprocess_resolution_DA.C | 86 ------------------- macro/postprocess_resolution_ELE.C | 86 ------------------- macro/postprocess_resolution_JB.C | 86 ------------------- submit.sh | 13 +++ 11 files changed, 25 insertions(+), 399 deletions(-) create mode 100755 job.sh rename macro/{analysis_resolution_SD.C => analysis_resolution.C} (98%) delete mode 100644 macro/analysis_resolution_DA.C delete mode 100644 macro/analysis_resolution_ELE.C delete mode 100644 macro/analysis_resolution_JB.C rename macro/{postprocess_resolution_SD.C => postprocess_resolution.C} (98%) delete mode 100644 macro/postprocess_resolution_DA.C delete mode 100644 macro/postprocess_resolution_ELE.C delete mode 100644 macro/postprocess_resolution_JB.C create mode 100755 submit.sh diff --git a/createDelphesScripts.sh b/createDelphesScripts.sh index 44157ca3..051c68ba 100755 --- a/createDelphesScripts.sh +++ b/createDelphesScripts.sh @@ -1,16 +1,16 @@ #!/bin/bash # Create fast simulation resolutions plotting scripts and submit to ifarm - -script="$PWD/macro/analysis_resolution_ELE.C" -postScript="/$PWD/macro/postprocess_resolution_ELE.C" +METHOD="ELE" # Switch this to select reconstruction method +script="$PWD/macro/analysis_resolution_${METHOD}.C" +postScript="/$PWD/macro/postprocess_resolution_${METHOD}.C" submitScript="$PWD/submit.sh" jobScript="$PWD/job.sh" out="$PWD/macro/" cd datarec for file in *-xm25.config do - config=`echo $file | sed "s;.config;;g"` + config="${METHOD}_`echo $file | sed "s;.config;;g"`" mkdir -p $out/$config cp $script $out/$config/ newscript=${out}${config}/*.C diff --git a/job.sh b/job.sh new file mode 100755 index 00000000..9d661ad6 --- /dev/null +++ b/job.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +cd /work/clas12/users/$USER/largex-eic +echo "root -q -b macro/dis-5x41/analysis_resolution_SD.C" | ./container/shell.sh +echo "root -q -b macro/dis-5x41/postprocess_resolution_SD.C" | ./container/shell.sh +echo DONE diff --git a/macro/analysis_resolution_SD.C b/macro/analysis_resolution.C similarity index 98% rename from macro/analysis_resolution_SD.C rename to macro/analysis_resolution.C index 344d50db..d6fccdce 100644 --- a/macro/analysis_resolution_SD.C +++ b/macro/analysis_resolution.C @@ -1,7 +1,7 @@ R__LOAD_LIBRARY(Largex) // make resolution plots -void analysis_resolution_SD( +void analysis_resolution( TString infiles="datarec/dis-5x41.config", /* list of input files */ Double_t eleBeamEn=5, /* electron beam energy [GeV] */ Double_t ionBeamEn=41, /* ion beam energy [GeV] */ diff --git a/macro/analysis_resolution_DA.C b/macro/analysis_resolution_DA.C deleted file mode 100644 index 48a86651..00000000 --- a/macro/analysis_resolution_DA.C +++ /dev/null @@ -1,45 +0,0 @@ -R__LOAD_LIBRARY(Largex) - -// make resolution plots -void analysis_resolution_DA( - TString infiles="datarec/dis-5x41.config", /* list of input files */ - Double_t eleBeamEn=5, /* electron beam energy [GeV] */ - Double_t ionBeamEn=41, /* ion beam energy [GeV] */ - Double_t crossingAngle=25, /* crossing angle [mrad] */ - TString outfilePrefix="DA_dis-5x41" /* output filename prefix*/ -) { - - // setup analysis ======================================== - AnalysisDelphes *A = new AnalysisDelphes( - infiles, - eleBeamEn, - ionBeamEn, - crossingAngle, - outfilePrefix - ); - A->NBINS = 5; // use this to set the number of bins along each axis, e.g., z binning (except resolution axes) for each overall bin in e.g. x and Q2 - A->NBINSRES = 100; // use this to set the number of bins along the resolution axes for each overall bin in e.g. x and Q2 - // A->RESHIGH = 1; - // A->RESLOW = -1; - //A->maxEvents = 30000; // use this to limit the number of events - A->SetReconMethod("DA"); // set reconstruction method - A->AddFinalState("pipTrack"); // pion final state - A->AddFinalState("pimTrack"); // pion final state - A->AddFinalState("KpTrack"); // pion final state - A->AddFinalState("KmTrack"); // pion final state - A->AddFinalState("pTrack"); // pion final state - - // define cuts ==================================== - A->AddBinScheme("w"); A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV - A->AddBinScheme("y"); A->BinScheme("y")->BuildBin("Range",0.01,0.95); // 0.01 < y < 0.95 - A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,0.9); // 0.2 < z < 0.9 - A->AddBinScheme("xF"); A->BinScheme("xF")->BuildBin("Min",0.0); // xF > 0 - A->AddBinScheme("ptLab"); A->BinScheme("ptLab")->BuildBin("Min",0.1); // pT_lab > 0.1 GeV (tracking limit) - - // set binning scheme ==================================== - A->AddBinScheme("q2"); A->BinScheme("q2")->BuildBins( 4, 1, 100, true ); - A->AddBinScheme("x"); A->BinScheme("x")->BuildBins( 6, 0.01, 1, true ); - - // perform the analysis ================================== - A->Execute(); -}; diff --git a/macro/analysis_resolution_ELE.C b/macro/analysis_resolution_ELE.C deleted file mode 100644 index 543a0ed1..00000000 --- a/macro/analysis_resolution_ELE.C +++ /dev/null @@ -1,45 +0,0 @@ -R__LOAD_LIBRARY(Largex) - -// make resolution plots -void analysis_resolution_ELE( - TString infiles="datarec/dis-5x41.config", /* list of input files */ - Double_t eleBeamEn=5, /* electron beam energy [GeV] */ - Double_t ionBeamEn=41, /* ion beam energy [GeV] */ - Double_t crossingAngle=25, /* crossing angle [mrad] */ - TString outfilePrefix="ELE_dis-5x41" /* output filename prefix*/ -) { - - // setup analysis ======================================== - AnalysisDelphes *A = new AnalysisDelphes( - infiles, - eleBeamEn, - ionBeamEn, - crossingAngle, - outfilePrefix - ); - A->NBINS = 5; // use this to set the number of bins along each axis, e.g., z binning (except resolution axes) for each overall bin in e.g. x and Q2 - A->NBINSRES = 100; // use this to set the number of bins along the resolution axes for each overall bin in e.g. x and Q2 - // A->RESHIGH = 1; - // A->RESLOW = -1; - //A->maxEvents = 30000; // use this to limit the number of events - A->SetReconMethod("Ele"); // set reconstruction method - A->AddFinalState("pipTrack"); // pion final state - A->AddFinalState("pimTrack"); // pion final state - A->AddFinalState("KpTrack"); // pion final state - A->AddFinalState("KmTrack"); // pion final state - A->AddFinalState("pTrack"); // pion final state - - // define cuts ==================================== - A->AddBinScheme("w"); A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV - A->AddBinScheme("y"); A->BinScheme("y")->BuildBin("Range",0.01,0.95); // 0.01 < y < 0.95 - A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,0.9); // 0.2 < z < 0.9 - A->AddBinScheme("xF"); A->BinScheme("xF")->BuildBin("Min",0.0); // xF > 0 - A->AddBinScheme("ptLab"); A->BinScheme("ptLab")->BuildBin("Min",0.1); // pT_lab > 0.1 GeV (tracking limit) - - // set binning scheme ==================================== - A->AddBinScheme("q2"); A->BinScheme("q2")->BuildBins( 4, 1, 100, true ); - A->AddBinScheme("x"); A->BinScheme("x")->BuildBins( 6, 0.01, 1, true ); - - // perform the analysis ================================== - A->Execute(); -}; diff --git a/macro/analysis_resolution_JB.C b/macro/analysis_resolution_JB.C deleted file mode 100644 index 47fd7528..00000000 --- a/macro/analysis_resolution_JB.C +++ /dev/null @@ -1,45 +0,0 @@ -R__LOAD_LIBRARY(Largex) - -// make resolution plots -void analysis_resolution_JB( - TString infiles="datarec/dis-5x41.config", /* list of input files */ - Double_t eleBeamEn=5, /* electron beam energy [GeV] */ - Double_t ionBeamEn=41, /* ion beam energy [GeV] */ - Double_t crossingAngle=25, /* crossing angle [mrad] */ - TString outfilePrefix="JB_dis-5x41" /* output filename prefix*/ -) { - - // setup analysis ======================================== - AnalysisDelphes *A = new AnalysisDelphes( - infiles, - eleBeamEn, - ionBeamEn, - crossingAngle, - outfilePrefix - ); - A->NBINS = 5; // use this to set the number of bins along each axis, e.g., z binning (except resolution axes) for each overall bin in e.g. x and Q2 - A->NBINSRES = 100; // use this to set the number of bins along the resolution axes for each overall bin in e.g. x and Q2 - // A->RESHIGH = 1; - // A->RESLOW = -1; - //A->maxEvents = 30000; // use this to limit the number of events - A->SetReconMethod("JB"); // set reconstruction method - A->AddFinalState("pipTrack"); // pion final state - A->AddFinalState("pimTrack"); // pion final state - A->AddFinalState("KpTrack"); // pion final state - A->AddFinalState("KmTrack"); // pion final state - A->AddFinalState("pTrack"); // pion final state - - // define cuts ==================================== - A->AddBinScheme("w"); A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV - A->AddBinScheme("y"); A->BinScheme("y")->BuildBin("Range",0.01,0.95); // 0.01 < y < 0.95 - A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,0.9); // 0.2 < z < 0.9 - A->AddBinScheme("xF"); A->BinScheme("xF")->BuildBin("Min",0.0); // xF > 0 - A->AddBinScheme("ptLab"); A->BinScheme("ptLab")->BuildBin("Min",0.1); // pT_lab > 0.1 GeV (tracking limit) - - // set binning scheme ==================================== - A->AddBinScheme("q2"); A->BinScheme("q2")->BuildBins( 4, 1, 100, true ); - A->AddBinScheme("x"); A->BinScheme("x")->BuildBins( 6, 0.01, 1, true ); - - // perform the analysis ================================== - A->Execute(); -}; diff --git a/macro/postprocess_resolution_SD.C b/macro/postprocess_resolution.C similarity index 98% rename from macro/postprocess_resolution_SD.C rename to macro/postprocess_resolution.C index 40ac8d42..2581f518 100644 --- a/macro/postprocess_resolution_SD.C +++ b/macro/postprocess_resolution.C @@ -2,7 +2,7 @@ R__LOAD_LIBRARY(Largex) // make resolution plots // - adapted from `postprocess_pTvsEta.C` -void postprocess_resolution_SD( +void postprocess_resolution( TString infile="out/dis-5x41.root" ){ diff --git a/macro/postprocess_resolution_DA.C b/macro/postprocess_resolution_DA.C deleted file mode 100644 index 234134de..00000000 --- a/macro/postprocess_resolution_DA.C +++ /dev/null @@ -1,86 +0,0 @@ -R__LOAD_LIBRARY(Largex) - -// make resolution plots -// - adapted from `postprocess_pTvsEta.C` -void postprocess_resolution_SD( - TString infile="out/DA_dis-5x41.root" -){ - - gROOT->ProcessLine(".! rm -v out/DA_dis-5x41.images/*.png"); // cleanup old image files - gROOT->ProcessLine(".! rm -v out/DA_dis-5x41.images/*.pdf"); // cleanup old image files - - PostProcessor *P = new PostProcessor(infile); - P->Op()->PrintBreadth("HistosDAG Initial Setup"); - - // number of bins in x and Q2 - int nx = P->Op()->GetBinSet("x")->GetNumBins(); - int nq2 = P->Op()->GetBinSet("q2")->GetNumBins(); - - // just counters for filling Histos vector - int xbin = 0; - int q2bin = 0; - - // initialize this 2D vector to be some large size - std::vector> histos_xQ2(30,std::vector(30)); - - auto findxQ2bins = [&histos_xQ2,&P,&xbin,&q2bin,nx,nq2](Histos *H ){ - histos_xQ2[xbin][q2bin] = H; - q2bin++; - if(q2bin == nq2){ - q2bin=0; xbin++; - if(xbin == nx) xbin = 0; - } - }; - - auto drawinxQ2bins = [&histos_xQ2, &P, &nx, &nq2](NodePath *bins){ - TString canvname = "xQ2cov_"; //+ bins->GetVar - for(Node *bin: bins->GetBinNodes()){ - if(bin->GetVarName() == "finalState"){ - canvname+=bin->GetID(); - canvname+="_"; - } - if(bin->GetVarName() == "z"){ - canvname+=bin->GetID(); - canvname+="_"; - } - } - - double xMin = 1e-4; - double xMax = 1; - double q2Min = 0.99; - double q2Max = 1000; - - // loop over resolution histograms (see ../src/Analysis.cxx `DefineHist*` calls - // for available histograms, or add your own there) - for( TString histname : {"x_Res","y_Res","Q2_Res","phiH_Res","phiS_Res","phiHvsPhiS","z_purity"} ) { - P->DrawInBins( - canvname, histos_xQ2, histname, - "x", nx, xMin, xMax, true, - "Q^{2}", nq2, q2Min, q2Max, true - ); - }; - - const int nNames = 6; - double yMin, yMax; yMin = -0.1; yMax = 0.5;//Adjust as needed - TString histNames[nNames] = {"z_Q2_Res","z_x_Res","z_y_Res","z_z_Res","z_pT_Res","z_purity"}; - TString labels[nNames] = {"Q^{2}","x","y","z","p_{T}","1-purity"}; - TString header="testheader"; - P->DrawSDInBinsTogether( - canvname, histos_xQ2, header, histNames, labels, nNames, yMin, yMax, - "x", nx, xMin, xMax, true, - "Q^{2}", nq2, q2Min, q2Max, true - ); - }; - - auto beforefunction = [](){ - }; - - P->Op()->Subloop({"x","q2"},beforefunction,drawinxQ2bins); - P->Op()->Payload(findxQ2bins); - - //P->Op()->PrintBreadth("HistosDAG Final Setup"); - - P->Execute(); - - P->Finish(); -}; diff --git a/macro/postprocess_resolution_ELE.C b/macro/postprocess_resolution_ELE.C deleted file mode 100644 index b167c249..00000000 --- a/macro/postprocess_resolution_ELE.C +++ /dev/null @@ -1,86 +0,0 @@ -R__LOAD_LIBRARY(Largex) - -// make resolution plots -// - adapted from `postprocess_pTvsEta.C` -void postprocess_resolution_ELE( - TString infile="out/ELE_dis-5x41.root" -){ - - gROOT->ProcessLine(".! rm -v out/ELE_dis-5x41.images/*.png"); // cleanup old image files - gROOT->ProcessLine(".! rm -v out/ELE_dis-5x41.images/*.pdf"); // cleanup old image files - - PostProcessor *P = new PostProcessor(infile); - P->Op()->PrintBreadth("HistosDAG Initial Setup"); - - // number of bins in x and Q2 - int nx = P->Op()->GetBinSet("x")->GetNumBins(); - int nq2 = P->Op()->GetBinSet("q2")->GetNumBins(); - - // just counters for filling Histos vector - int xbin = 0; - int q2bin = 0; - - // initialize this 2D vector to be some large size - std::vector> histos_xQ2(30,std::vector(30)); - - auto findxQ2bins = [&histos_xQ2,&P,&xbin,&q2bin,nx,nq2](Histos *H ){ - histos_xQ2[xbin][q2bin] = H; - q2bin++; - if(q2bin == nq2){ - q2bin=0; xbin++; - if(xbin == nx) xbin = 0; - } - }; - - auto drawinxQ2bins = [&histos_xQ2, &P, &nx, &nq2](NodePath *bins){ - TString canvname = "xQ2cov_"; //+ bins->GetVar - for(Node *bin: bins->GetBinNodes()){ - if(bin->GetVarName() == "finalState"){ - canvname+=bin->GetID(); - canvname+="_"; - } - if(bin->GetVarName() == "z"){ - canvname+=bin->GetID(); - canvname+="_"; - } - } - - double xMin = 1e-4; - double xMax = 1; - double q2Min = 0.99; - double q2Max = 1000; - - // loop over resolution histograms (see ../src/Analysis.cxx `DefineHist*` calls - // for available histograms, or add your own there) - for( TString histname : {"x_Res","y_Res","Q2_Res","phiH_Res","phiS_Res","phiHvsPhiS","z_purity"} ) { - P->DrawInBins( - canvname, histos_xQ2, histname, - "x", nx, xMin, xMax, true, - "Q^{2}", nq2, q2Min, q2Max, true - ); - }; - - const int nNames = 6; - double yMin, yMax; yMin = -0.1; yMax = 0.5;//Adjust as needed - TString histNames[nNames] = {"z_Q2_Res","z_x_Res","z_y_Res","z_z_Res","z_pT_Res","z_purity"}; - TString labels[nNames] = {"Q^{2}","x","y","z","p_{T}","1-purity"}; - TString header="testheader"; - P->DrawSDInBinsTogether( - canvname, histos_xQ2, header, histNames, labels, nNames, yMin, yMax, - "x", nx, xMin, xMax, true, - "Q^{2}", nq2, q2Min, q2Max, true - ); - }; - - auto beforefunction = [](){ - }; - - P->Op()->Subloop({"x","q2"},beforefunction,drawinxQ2bins); - P->Op()->Payload(findxQ2bins); - - //P->Op()->PrintBreadth("HistosDAG Final Setup"); - - P->Execute(); - - P->Finish(); -}; diff --git a/macro/postprocess_resolution_JB.C b/macro/postprocess_resolution_JB.C deleted file mode 100644 index 8c50288c..00000000 --- a/macro/postprocess_resolution_JB.C +++ /dev/null @@ -1,86 +0,0 @@ -R__LOAD_LIBRARY(Largex) - -// make resolution plots -// - adapted from `postprocess_pTvsEta.C` -void postprocess_resolution_SD( - TString infile="out/JB_dis-5x41.root" -){ - - gROOT->ProcessLine(".! rm -v out/JB_dis-5x41.images/*.png"); // cleanup old image files - gROOT->ProcessLine(".! rm -v out/JB_dis-5x41.images/*.pdf"); // cleanup old image files - - PostProcessor *P = new PostProcessor(infile); - P->Op()->PrintBreadth("HistosDAG Initial Setup"); - - // number of bins in x and Q2 - int nx = P->Op()->GetBinSet("x")->GetNumBins(); - int nq2 = P->Op()->GetBinSet("q2")->GetNumBins(); - - // just counters for filling Histos vector - int xbin = 0; - int q2bin = 0; - - // initialize this 2D vector to be some large size - std::vector> histos_xQ2(30,std::vector(30)); - - auto findxQ2bins = [&histos_xQ2,&P,&xbin,&q2bin,nx,nq2](Histos *H ){ - histos_xQ2[xbin][q2bin] = H; - q2bin++; - if(q2bin == nq2){ - q2bin=0; xbin++; - if(xbin == nx) xbin = 0; - } - }; - - auto drawinxQ2bins = [&histos_xQ2, &P, &nx, &nq2](NodePath *bins){ - TString canvname = "xQ2cov_"; //+ bins->GetVar - for(Node *bin: bins->GetBinNodes()){ - if(bin->GetVarName() == "finalState"){ - canvname+=bin->GetID(); - canvname+="_"; - } - if(bin->GetVarName() == "z"){ - canvname+=bin->GetID(); - canvname+="_"; - } - } - - double xMin = 1e-4; - double xMax = 1; - double q2Min = 0.99; - double q2Max = 1000; - - // loop over resolution histograms (see ../src/Analysis.cxx `DefineHist*` calls - // for available histograms, or add your own there) - for( TString histname : {"x_Res","y_Res","Q2_Res","phiH_Res","phiS_Res","phiHvsPhiS","z_purity"} ) { - P->DrawInBins( - canvname, histos_xQ2, histname, - "x", nx, xMin, xMax, true, - "Q^{2}", nq2, q2Min, q2Max, true - ); - }; - - const int nNames = 6; - double yMin, yMax; yMin = -0.1; yMax = 0.5;//Adjust as needed - TString histNames[nNames] = {"z_Q2_Res","z_x_Res","z_y_Res","z_z_Res","z_pT_Res","z_purity"}; - TString labels[nNames] = {"Q^{2}","x","y","z","p_{T}","1-purity"}; - TString header="testheader"; - P->DrawSDInBinsTogether( - canvname, histos_xQ2, header, histNames, labels, nNames, yMin, yMax, - "x", nx, xMin, xMax, true, - "Q^{2}", nq2, q2Min, q2Max, true - ); - }; - - auto beforefunction = [](){ - }; - - P->Op()->Subloop({"x","q2"},beforefunction,drawinxQ2bins); - P->Op()->Payload(findxQ2bins); - - //P->Op()->PrintBreadth("HistosDAG Final Setup"); - - P->Execute(); - - P->Finish(); -}; diff --git a/submit.sh b/submit.sh new file mode 100755 index 00000000..9e7422ae --- /dev/null +++ b/submit.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +#SBATCH --job-name=athenaSIDIS +#SBATCH --output=/farm_out/%u/%x-%j-%N.out +#SBATCH --error=/farm_out/%u/%x-%j-%N.err +#SBATCH --partition=production +#SBATCH --account=clas12 +#SBATCH --mem-per-cpu=4000 +#SBATCH --gres=disk:1000 +#SBATCH --time=24:00:00 +##SBATCH --mail-user=$USER@jlab.org + +/work/clas12/users/$USER/eic/largex-eic/macro/dis-5x41/job.sh From 9c133b74aaa76a9469983ba62ef1fb1ab3658fc4 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Thu, 18 Nov 2021 23:48:52 -0500 Subject: [PATCH 19/51] Fixed small typo --- job.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/job.sh b/job.sh index 9d661ad6..c6d03630 100755 --- a/job.sh +++ b/job.sh @@ -1,6 +1,6 @@ #!/bin/bash cd /work/clas12/users/$USER/largex-eic -echo "root -q -b macro/dis-5x41/analysis_resolution_SD.C" | ./container/shell.sh -echo "root -q -b macro/dis-5x41/postprocess_resolution_SD.C" | ./container/shell.sh +echo "root -q -b macro/dis-5x41/analysis_resolution.C" | ./container/shell.sh +echo "root -q -b macro/dis-5x41/postprocess_resolution.C" | ./container/shell.sh echo DONE From 6938b2bbd41d6f02427811b49a5c85642b61781f Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Thu, 18 Nov 2021 23:54:13 -0500 Subject: [PATCH 20/51] More small typos --- createDelphesScripts.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/createDelphesScripts.sh b/createDelphesScripts.sh index 051c68ba..c2816835 100755 --- a/createDelphesScripts.sh +++ b/createDelphesScripts.sh @@ -2,8 +2,8 @@ # Create fast simulation resolutions plotting scripts and submit to ifarm METHOD="ELE" # Switch this to select reconstruction method -script="$PWD/macro/analysis_resolution_${METHOD}.C" -postScript="/$PWD/macro/postprocess_resolution_${METHOD}.C" +script="$PWD/macro/analysis_resolution.C" +postScript="$PWD/macro/postprocess_resolution.C" submitScript="$PWD/submit.sh" jobScript="$PWD/job.sh" out="$PWD/macro/" From cb508ac7ea754ac8cd1658574a4742ac3cc31486 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Fri, 19 Nov 2021 00:03:43 -0500 Subject: [PATCH 21/51] Fixed typos in creation script --- createDelphesScripts.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/createDelphesScripts.sh b/createDelphesScripts.sh index c2816835..604d9b3c 100755 --- a/createDelphesScripts.sh +++ b/createDelphesScripts.sh @@ -1,7 +1,7 @@ #!/bin/bash # Create fast simulation resolutions plotting scripts and submit to ifarm -METHOD="ELE" # Switch this to select reconstruction method +METHOD="Ele" # Switch this to select reconstruction method from {"Ele","JB","DA"} script="$PWD/macro/analysis_resolution.C" postScript="$PWD/macro/postprocess_resolution.C" submitScript="$PWD/submit.sh" @@ -26,6 +26,7 @@ do echo "xAng=${xAng}" echo "xAngM=${xAngM}" + sed -i "s;Ele;${METHOD};g" $newscript sed -i "s;dis-5x41;${config};g" $newscript sed -i "s;eleBeamEn=5;eleBeamEn=${eleIn};g" $newscript sed -i "s;ionBeamEn=41;ionBeamEn=${beamIn};g" $newscript From 2b455842b4c72024e0f759798991c1b72b596633 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Fri, 19 Nov 2021 00:14:35 -0500 Subject: [PATCH 22/51] Updated analysis script creation --- createDelphesScripts.sh | 15 ++++++++++++--- macro/analysis_resolution.C | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/createDelphesScripts.sh b/createDelphesScripts.sh index 604d9b3c..dea21c3f 100755 --- a/createDelphesScripts.sh +++ b/createDelphesScripts.sh @@ -10,7 +10,8 @@ out="$PWD/macro/" cd datarec for file in *-xm25.config do - config="${METHOD}_`echo $file | sed "s;.config;;g"`" + energies=`echo $file | sed "s;.config;;g"` + config="${METHOD}_${energies}" mkdir -p $out/$config cp $script $out/$config/ newscript=${out}${config}/*.C @@ -26,8 +27,9 @@ do echo "xAng=${xAng}" echo "xAngM=${xAngM}" - sed -i "s;Ele;${METHOD};g" $newscript - sed -i "s;dis-5x41;${config};g" $newscript + # Modify analysis script + sed -i "s;datarec/dis-5x41;${energies};g" $newscript + sed -i "s;Ele_dis-5x41;${config};g" $newscript sed -i "s;eleBeamEn=5;eleBeamEn=${eleIn};g" $newscript sed -i "s;ionBeamEn=41;ionBeamEn=${beamIn};g" $newscript if [ $xAng ]; then @@ -36,12 +38,19 @@ do if [ $xAngM ]; then sed -i "s;crossingAngle=25;crossingAngle=${xAngM};g" $newscript fi + sed -i "s;Ele;${METHOD};g" $newscript + + # Postprocessor cp $postScript $out/$config sed -i "s;dis-5x41;${config};g" $out/$config/*.C sed -i "s;testheader;${eleIn}x${beamIn}GeV;g" $out/$config/*.C + + # And job scripts cp $submitScript $out/$config cp $jobScript $out/$config sed -i "s;dis-5x41;${config};g" $out/$config/*.sh + + # And submit sbatch $out/$config/submit.sh echo -------------------- diff --git a/macro/analysis_resolution.C b/macro/analysis_resolution.C index d6fccdce..e666da67 100644 --- a/macro/analysis_resolution.C +++ b/macro/analysis_resolution.C @@ -6,7 +6,7 @@ void analysis_resolution( Double_t eleBeamEn=5, /* electron beam energy [GeV] */ Double_t ionBeamEn=41, /* ion beam energy [GeV] */ Double_t crossingAngle=25, /* crossing angle [mrad] */ - TString outfilePrefix="dis-5x41" /* output filename prefix*/ + TString outfilePrefix="Ele_dis-5x41" /* output filename prefix*/ ) { // setup analysis ======================================== From cb82f50e9af23db0943f652ef3a5a919a1b17e33 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Fri, 19 Nov 2021 00:21:10 -0500 Subject: [PATCH 23/51] Finally fixed creation script --- createDelphesScripts.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/createDelphesScripts.sh b/createDelphesScripts.sh index dea21c3f..47018b6a 100755 --- a/createDelphesScripts.sh +++ b/createDelphesScripts.sh @@ -20,6 +20,7 @@ do xAng=`echo $file | grep -Eo "[0-9][0-9]*x[0-9]*-x[0-9]*" | sed "s;.*-x;;g"` xAngM=`echo $file | grep -Eo "[0-9][0-9]*x[0-9]*-xm[0-9]*" | sed "s;.*-xm;;g"` echo "file=${file}" + echo "energies=${energies}" echo "config=${config}" echo "newscript=${newscript}" echo "eleIn=${eleIn}" @@ -42,8 +43,8 @@ do # Postprocessor cp $postScript $out/$config - sed -i "s;dis-5x41;${config};g" $out/$config/*.C - sed -i "s;testheader;${eleIn}x${beamIn}GeV;g" $out/$config/*.C + sed -i "s;dis-5x41;${config};g" $out/$config/postprocess*.C + sed -i "s;testheader;${eleIn}x${beamIn}GeV;g" $out/$config/postprocess*.C # And job scripts cp $submitScript $out/$config From e881e8c2cb5e1d6aeaa95de1762f9d46d8a7894f Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Fri, 19 Nov 2021 00:32:44 -0500 Subject: [PATCH 24/51] Fixed small typo --- job.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/job.sh b/job.sh index c6d03630..4b6c8fe0 100755 --- a/job.sh +++ b/job.sh @@ -1,6 +1,6 @@ #!/bin/bash -cd /work/clas12/users/$USER/largex-eic +cd /work/clas12/users/$USER/eic/largex-eic echo "root -q -b macro/dis-5x41/analysis_resolution.C" | ./container/shell.sh echo "root -q -b macro/dis-5x41/postprocess_resolution.C" | ./container/shell.sh echo DONE From 5eb36f0eab038bdd861a44784641d8bfcabe2cef Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Fri, 19 Nov 2021 12:32:42 -0500 Subject: [PATCH 25/51] Updated getPID() method and fixed typo in creation script --- createDelphesScripts.sh | 2 +- src/AnalysisDelphes.cxx | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/createDelphesScripts.sh b/createDelphesScripts.sh index 47018b6a..3a34b4d9 100755 --- a/createDelphesScripts.sh +++ b/createDelphesScripts.sh @@ -29,7 +29,7 @@ do echo "xAngM=${xAngM}" # Modify analysis script - sed -i "s;datarec/dis-5x41;${energies};g" $newscript + sed -i "s;datarec/dis-5x41;datarec/${energies};g" $newscript sed -i "s;Ele_dis-5x41;${config};g" $newscript sed -i "s;eleBeamEn=5;eleBeamEn=${eleIn};g" $newscript sed -i "s;ionBeamEn=41;ionBeamEn=${beamIn};g" $newscript diff --git a/src/AnalysisDelphes.cxx b/src/AnalysisDelphes.cxx index 6f2f8ae9..36d599c5 100644 --- a/src/AnalysisDelphes.cxx +++ b/src/AnalysisDelphes.cxx @@ -39,20 +39,27 @@ int getPID(Track *track, TObjArrayIter itParticle, GenParticle *detectorParticle; int pidOut = -1; while(Track *detectorTrack = (Track*)itmRICHTrack() ){ + if ((detectorTrack->Eta < -3.5) || (-1.0 < detectorTrack->Eta)) continue; detectorParticle = (GenParticle*)detectorTrack->Particle.GetObject(); if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; } itParticle.Reset(); while(Track *detectorTrack = (Track*)itbarrelDIRCTrack() ){ + if ((detectorTrack->Eta < -1.0) || (1.0 < detectorTrack->Eta)) continue; detectorParticle = (GenParticle*)detectorTrack->Particle.GetObject(); if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; } itParticle.Reset(); + Double_t ag_p_threshold = 12.0; while(Track *detectorTrack = (Track*)itdualRICHagTrack() ){ + Double_t p_track = detectorTrack->P4().Vect().Mag(); + if (!((1.0 <= track->Eta) && (track->Eta <= 3.5)) || p_track>=ag_p_threshold) continue; detectorParticle = (GenParticle*)detectorTrack->Particle.GetObject(); if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; } while(Track *detectorTrack = (Track*)itdualRICHcfTrack() ){ + Double_t p_track = detectorTrack->P4().Vect().Mag(); + if (!((1.0 <= track->Eta) && (track->Eta <= 3.5)) || p_trackParticle.GetObject(); if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; } @@ -195,7 +202,8 @@ void AnalysisDelphes::Execute() { // final state cut // - check PID, to see if it's a final state we're interested in for // histograms; if not, proceed to next track - pid = trk->PID; + // pid = trk->PID; + pid = getPID(trk, itParticle, itmRICHTrack, itbarrelDIRCTrack, itdualRICHagTrack, itdualRICHcfTrack); auto kv = PIDtoFinalState.find(pid); if(kv!=PIDtoFinalState.end()) finalStateID = kv->second; else continue; From 5e1146a90d6989e1011d8248a26f07c7f4f3554e Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Mon, 22 Nov 2021 12:05:48 -0500 Subject: [PATCH 26/51] Changed z limits in `macro/analysis_resolution.C` and fixed bug with purity plots in `PostProcessor.cxx` --- macro/analysis_barak.C | 3 ++- macro/analysis_resolution.C | 4 ++-- src/PostProcessor.cxx | 20 +++++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/macro/analysis_barak.C b/macro/analysis_barak.C index 69911a9b..7ff16c32 100644 --- a/macro/analysis_barak.C +++ b/macro/analysis_barak.C @@ -22,7 +22,8 @@ void analysis_barak( // A->RESHIGH = 1; // A->RESLOW = -1; //A->maxEvents = 30000; // use this to limit the number of events - A->SetReconMethod("JB"); // set reconstruction method + A->SetReconMethod("Ele"); // set reconstruction method + // A->SetReconMethod("JB"); // set reconstruction method //A->SetReconMethod("DA"); // set reconstruction method A->AddFinalState("pipTrack"); // pi+ final state A->AddFinalState("pimTrack"); // pi- final state diff --git a/macro/analysis_resolution.C b/macro/analysis_resolution.C index e666da67..f980c9c4 100644 --- a/macro/analysis_resolution.C +++ b/macro/analysis_resolution.C @@ -17,7 +17,7 @@ void analysis_resolution( crossingAngle, outfilePrefix ); - A->NBINS = 5; // use this to set the number of bins along each axis, e.g., z binning (except resolution axes) for each overall bin in e.g. x and Q2 + A->NBINS = 1; // use this to set the number of bins along each axis, e.g., z binning (except resolution axes) for each overall bin in e.g. x and Q2 A->NBINSRES = 100; // use this to set the number of bins along the resolution axes for each overall bin in e.g. x and Q2 // A->RESHIGH = 1; // A->RESLOW = -1; @@ -32,7 +32,7 @@ void analysis_resolution( // define cuts ==================================== A->AddBinScheme("w"); A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV A->AddBinScheme("y"); A->BinScheme("y")->BuildBin("Range",0.01,0.95); // 0.01 < y < 0.95 - A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,0.9); // 0.2 < z < 0.9 + A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,0.6); // 0.2 < z < 0.9 A->AddBinScheme("xF"); A->BinScheme("xF")->BuildBin("Min",0.0); // xF > 0 A->AddBinScheme("ptLab"); A->BinScheme("ptLab")->BuildBin("Min",0.1); // pT_lab > 0.1 GeV (tracking limit) diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index ea39f41f..c02af391 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -668,9 +668,6 @@ void PostProcessor::DrawSDInBinsTogether( if (nNames>3) lg->SetNColumns(2); for (int k=0; kHist(histNames[k])->Clone(); - if ( fitHist->GetEntries() < 10 ) continue; // Filter out low filled hists that can't get good fits. - fitHist->SetTitle(""); //subHist->GetXaxis()->SetTitle(""); //subHist->GetYaxis()->SetTitle(""); @@ -678,17 +675,22 @@ void PostProcessor::DrawSDInBinsTogether( //subHist->GetYaxis()->SetLabelSize(0); TH1D *subHist; if (histNames[k]=="z_purity") subHist = (TH1D*)H->Hist(histNames[k])->Clone(); - else subHist = this->GetSDs(fitHist); + else { + TH2D *fitHist = (TH2D*)H->Hist(histNames[k])->Clone(); + if ( fitHist->GetEntries() < 10 ) continue; // Filter out low filled hists that can't get good fits. + fitHist->SetTitle(""); + subHist = this->GetSDs(fitHist); + } subHist->GetXaxis()->SetTitleSize(0.1); subHist->GetXaxis()->SetTitleOffset(0.5); subHist->GetXaxis()->SetNdivisions(8); - subHist->GetXaxis()->SetLabelSize(0.06); + subHist->GetXaxis()->SetLabelSize(0.1); subHist->GetXaxis()->CenterTitle(); subHist->GetXaxis()->SetLabelOffset(0.02); - subHist->GetYaxis()->SetRangeUser(yMin,yMax);//TODO: CHECK THIS IS REASONABLE ALSO WHAT ABOUT ERROR BARS??? + subHist->GetYaxis()->SetRangeUser(yMin,yMax);//TODO: CHECK THIS IS REASONABLE ALSO WHAT ABOUT ERROR BARS?? subHist->GetYaxis()->SetNdivisions(8); - subHist->GetYaxis()->SetLabelSize(0.06); + subHist->GetYaxis()->SetLabelSize(0.1); subHist->GetYaxis()->SetLabelOffset(0.02); subHist->SetTitle(histNames[k]); @@ -696,7 +698,7 @@ void PostProcessor::DrawSDInBinsTogether( subHist->SetMarkerColor(k+2); if (k+2>=5) subHist->SetMarkerColor(k+3); //NOTE: 5 is yellow: very hard to see. subHist->SetMarkerSize(0.5);//NOTE: Remember these will be small plots so keep the binning small and the markers big - if ( subHist->GetEntries()>0 ) { + if ( subHist->GetEntries()>0 || (histNames[k]=="z_purity" && h1->GetMaximum()!=0)) { hist->Add(subHist); if (i==0 && j==0){ @@ -724,7 +726,7 @@ void PostProcessor::DrawSDInBinsTogether( drawStr = "BOX"; break; }; - //hist->Write(); + hist->Write(); if( hist->GetNhists() > 0 ) { hist->Draw(drawStr); TF1 *f1 = new TF1("f1","0",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); From dec8cd98cb9ac1243edc248786432644cfcb72c9 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Mon, 22 Nov 2021 12:06:05 -0500 Subject: [PATCH 27/51] Added TODO for mRICH which is now eRICH I think... --- src/AnalysisDelphes.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AnalysisDelphes.cxx b/src/AnalysisDelphes.cxx index 36d599c5..2223c078 100644 --- a/src/AnalysisDelphes.cxx +++ b/src/AnalysisDelphes.cxx @@ -98,7 +98,7 @@ void AnalysisDelphes::Execute() { TObjArrayIter itEFlowPhoton(tr->UseBranch("EFlowPhoton")); TObjArrayIter itEFlowNeutralHadron(tr->UseBranch("EFlowNeutralHadron")); TObjArrayIter itPIDSystemsTrack(tr->UseBranch("PIDSystemsTrack")); - TObjArrayIter itmRICHTrack(tr->UseBranch("mRICHTrack")); + TObjArrayIter itmRICHTrack(tr->UseBranch("mRICHTrack"));//TODO: Change to eRICHTrack or pfRICHTrack ? TObjArrayIter itbarrelDIRCTrack(tr->UseBranch("barrelDIRCTrack")); TObjArrayIter itdualRICHagTrack(tr->UseBranch("dualRICHagTrack")); TObjArrayIter itdualRICHcfTrack(tr->UseBranch("dualRICHcfTrack")); From 2c523993167d601cfa603d05e13b075dd79d885d Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Mon, 22 Nov 2021 16:34:32 -0500 Subject: [PATCH 28/51] Added efficiency plots (not tested yet) --- src/Analysis.cxx | 41 +++++++++++++++++++++++++--- src/Analysis.h | 1 + src/AnalysisDelphes.cxx | 59 +++++++++++++++++++++++++++++++++++++---- 3 files changed, 92 insertions(+), 9 deletions(-) diff --git a/src/Analysis.cxx b/src/Analysis.cxx index 130043e4..afa292cb 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -331,7 +331,9 @@ void Analysis::Prepare() { // 1D z-binned counts and summed resolutions HS->DefineHist1D("z_true","z","", NBINS, 0, 1); + HS->DefineHist1D("z_trueMC","z","", NBINS, 0, 1); HS->DefineHist1D("z_purity","purity","", NBINS, 0, 1); + HS->DefineHist1D("z_efficiency","efficiency","", NBINS, 0, 1); // // 2D Q2 vs. x binned resolutions // HS->DefineHist1D("x_Res","x-x_{true}","", NBINS, -0.5, 0.5); @@ -466,10 +468,11 @@ void Analysis::Finish() { // Convert to contamination plot since the y scale is better for plotting with stddevs - H->Hist("z_purity")->Add(H->Hist("z_true"),-1); + // H->Hist("z_purity")->Add(H->Hist("z_true"),-1); H->Hist("z_purity")->Divide(H->Hist("z_true")); - TF1 *f1 = new TF1("f1","1",0,1); //TODO: Set limits automatically - H->Hist("z_purity")->Multiply(f1,-1); + H->Hist("z_efficiency")->Divide(H->Hist("z_trueMC")); + // TF1 *f1 = new TF1("f1","1",0,1); //TODO: Set limits automatically + // H->Hist("z_purity")->Multiply(f1,-1); }); @@ -691,7 +694,7 @@ void Analysis::FillHistosTracks() { HD->ExecuteOps(true); }; -// jets +// purity void Analysis::FillHistosPurity(bool recMatch, bool mcMatch) { // add kinematic values to `valueMap` @@ -721,6 +724,36 @@ void Analysis::FillHistosPurity(bool recMatch, bool mcMatch) { HD->ExecuteOps(true); }; +// purity +void Analysis::FillHistosEfficiency(bool recMatch, bool mcMatch) { + + // add kinematic values to `valueMap` + valueMap.clear(); + activeEvent = false; + /* DIS */ + valueMap.insert(std::pair( "x", kin->x )); + valueMap.insert(std::pair( "q2", kin->Q2 )); + valueMap.insert(std::pair( "y", kin->y )); + valueMap.insert(std::pair( "z", kin->z )); + + // check bins + // - activates HistosDAG bin nodes which contain this track + // - sets `activeEvent` if there is at least one multidimensional bin to fill + HD->TraverseBreadth(CheckBin()); + if(!activeEvent) return; + + // fill histograms, for activated bins only + HD->Payload([this,recMatch,mcMatch](Histos *H){ + if (recMatch) H->Hist("z_trueMC")->Fill(kinTrue->z, wTrack ); + if (mcMatch) H->Hist("z_efficiency")->Fill(kinTrue->z,wTrack); + }); + // execute the payload + // - save time and don't call `ClearOps` (next loop will overwrite lambda) + // - called with `activeNodesOnly==true` since we only want to fill bins associated + // with this jet + HD->ExecuteOps(true); +}; + // jets void Analysis::FillHistosJets() { diff --git a/src/Analysis.h b/src/Analysis.h index 3c3bee17..f82eac2f 100644 --- a/src/Analysis.h +++ b/src/Analysis.h @@ -101,6 +101,7 @@ class Analysis : public TNamed // FillHistos methods: fill histograms void FillHistosTracks(); void FillHistosPurity(bool recMatch, bool mcMatch); + void FillHistosEfficiency(bool recMatch, bool mcMatch); void FillHistosJets(); // lambda to check which bins an observable is in, during DAG breadth diff --git a/src/AnalysisDelphes.cxx b/src/AnalysisDelphes.cxx index 2223c078..b0fdf921 100644 --- a/src/AnalysisDelphes.cxx +++ b/src/AnalysisDelphes.cxx @@ -202,12 +202,14 @@ void AnalysisDelphes::Execute() { // final state cut // - check PID, to see if it's a final state we're interested in for // histograms; if not, proceed to next track - // pid = trk->PID; + int mcpid = trk->PID; pid = getPID(trk, itParticle, itmRICHTrack, itbarrelDIRCTrack, itdualRICHagTrack, itdualRICHcfTrack); + auto kvMC = PIDtoFinalState.find(mcpid); auto kv = PIDtoFinalState.find(pid); - if(kv!=PIDtoFinalState.end()) finalStateID = kv->second; else continue; - if(activeFinalStates.find(finalStateID)==activeFinalStates.end()) continue; + + if(kv!=PIDtoFinalState.end()) { finalStateID = kv->second; + if(activeFinalStates.find(finalStateID)!=activeFinalStates.end()) { // Get total # of final state particles correctly identified in reconstruction GenParticle *trkParticle = (GenParticle*)trk->Particle.GetObject(); @@ -252,8 +254,11 @@ void AnalysisDelphes::Execute() { FillHistosPurity(true,false); // And number correctly identified - int mcpid = trkParticle->PID; - if (pid==mcpid) FillHistosPurity(false,true); + mcpid = trkParticle->PID; + if (pid==mcpid) { + FillHistosPurity(false,true); + FillHistosEfficiency(true,true); + } // fill track histograms in activated bins FillHistosTracks(); @@ -267,6 +272,50 @@ void AnalysisDelphes::Execute() { // tests //kin->ValidateHeadOnFrame(); + } // if(kv!=PIDtoFinalState.end()) + } // if(activeFinalStates.find(finalStateID)!=activeFinalStates.end()) + if (pid!=mcpid) { + if(kvMC!=PIDtoFinalState.end()) { finalStateID = kv->second; + if(activeFinalStates.find(finalStateID)!=activeFinalStates.end()) { + + // calculate hadron kinematics + GenParticle* trkPart = (GenParticle*)trk->Particle.GetObject(); + kinTrue->hadPID = mcpid; + kinTrue->vecHadron.SetPtEtaPhiM( + trkPart->PT, + trkPart->Eta, + trkPart->Phi, + trkPart->Mass /* TODO: do we use track mass here ?? */ + ); + + kinTrue->CalculateHadronKinematics(); + + // asymmetry injection + //kin->InjectFakeAsymmetry(); // sets tSpin, based on reconstructed kinematics + //kinTrue->InjectFakeAsymmetry(); // sets tSpin, based on generated kinematics + //kin->tSpin = kinTrue->tSpin; // copy to "reconstructed" tSpin + + // Get index of file that the event comes from. + Double_t Q2weightFactor = GetEventQ2Weight(kinTrue->Q2, inLookup[chain->GetTreeNumber()]); + wTrack = Q2weightFactor * weight->GetWeight(*kinTrue); + wTrackTotal += wTrack; + + // Get total # of final state particles identified in selected final state + FillHistosEfficiency(true,false); + + // fill simple tree + // - not binned + // - `activeEvent` is only true if at least one bin gets filled for this track + // - TODO [critical]: add a `finalState` cut (also needed in AnalysisDD4hep) + if( writeSimpleTree && activeEvent ) ST->FillTree(wTrack); + + // tests + //kin->ValidateHeadOnFrame(); + + } // if (activeFinalStates.find(finalStateID)!=activeFinalStates.end()) + } // if (kv!=PIDtoFinalState.end()) + } // if (pid!=mcpid) + }; // end track loop From 6914d46f70b6ffdb3e2002c1e5b1bcc4812556ca Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Mon, 22 Nov 2021 16:41:19 -0500 Subject: [PATCH 29/51] Fixed min count check in PostProcessor::plotSDsInBinsTogether() --- src/PostProcessor.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index c02af391..22e5a652 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -698,7 +698,7 @@ void PostProcessor::DrawSDInBinsTogether( subHist->SetMarkerColor(k+2); if (k+2>=5) subHist->SetMarkerColor(k+3); //NOTE: 5 is yellow: very hard to see. subHist->SetMarkerSize(0.5);//NOTE: Remember these will be small plots so keep the binning small and the markers big - if ( subHist->GetEntries()>0 || (histNames[k]=="z_purity" && h1->GetMaximum()!=0)) { + if ( subHist->GetEntries()>0 || (histNames[k]=="z_purity" && H->Hist("z_z_Res")->GetMaximum()!=0)) { hist->Add(subHist); if (i==0 && j==0){ From 9e2ba9f2e6e8287e0eac04237a49e83cda3efb76 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Tue, 23 Nov 2021 00:02:08 -0500 Subject: [PATCH 30/51] Added x-binned purity and efficiency plots --- src/Analysis.cxx | 14 +++++++++++++- src/PostProcessor.cxx | 13 +++++++------ 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/Analysis.cxx b/src/Analysis.cxx index afa292cb..54ab9c67 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -329,12 +329,18 @@ void Analysis::Prepare() { HS->DefineHist2D("z_phiH_Res","z","","#sigma_{#phi_{h}^{true}}","", NBINS, 0, 1, NBINSRES, -TMath::Pi(), TMath::Pi()); HS->DefineHist2D("z_phiS_Res","z","","#sigma_{#phi_{S}^{true}}","", NBINS, 0, 1, NBINSRES, -TMath::Pi(), TMath::Pi()); - // 1D z-binned counts and summed resolutions + // 1D z-binned purity and efficiency HS->DefineHist1D("z_true","z","", NBINS, 0, 1); HS->DefineHist1D("z_trueMC","z","", NBINS, 0, 1); HS->DefineHist1D("z_purity","purity","", NBINS, 0, 1); HS->DefineHist1D("z_efficiency","efficiency","", NBINS, 0, 1); + // 1D x-binned purity and efficiency + HS->DefineHist1D("z_true","z","", NBINS, 1e-5, 1, true); + HS->DefineHist1D("z_trueMC","z","", NBINS, 1e-5, 1, true); + HS->DefineHist1D("x_purity","purity","", NBINS, 1e-5, 1, true); + HS->DefineHist1D("x_efficiency","efficiency","", NBINS, 1e-5, 1, true); + // // 2D Q2 vs. x binned resolutions // HS->DefineHist1D("x_Res","x-x_{true}","", NBINS, -0.5, 0.5); // HS->DefineHist1D("y_Res","y-y_{true}","", NBINS, -0.2, 0.2); @@ -471,6 +477,8 @@ void Analysis::Finish() { // H->Hist("z_purity")->Add(H->Hist("z_true"),-1); H->Hist("z_purity")->Divide(H->Hist("z_true")); H->Hist("z_efficiency")->Divide(H->Hist("z_trueMC")); + H->Hist("x_purity")->Divide(H->Hist("x_true")); + H->Hist("x_efficiency")->Divide(H->Hist("x_trueMC")); // TF1 *f1 = new TF1("f1","1",0,1); //TODO: Set limits automatically // H->Hist("z_purity")->Multiply(f1,-1); @@ -716,6 +724,8 @@ void Analysis::FillHistosPurity(bool recMatch, bool mcMatch) { HD->Payload([this,recMatch,mcMatch](Histos *H){ if (recMatch) H->Hist("z_true")->Fill(kinTrue->z, wTrack ); if (mcMatch) H->Hist("z_purity")->Fill(kinTrue->z,wTrack); + if (recMatch) H->Hist("x_true")->Fill(kinTrue->x, wTrack ); + if (mcMatch) H->Hist("x_purity")->Fill(kinTrue->x,wTrack); }); // execute the payload // - save time and don't call `ClearOps` (next loop will overwrite lambda) @@ -746,6 +756,8 @@ void Analysis::FillHistosEfficiency(bool recMatch, bool mcMatch) { HD->Payload([this,recMatch,mcMatch](Histos *H){ if (recMatch) H->Hist("z_trueMC")->Fill(kinTrue->z, wTrack ); if (mcMatch) H->Hist("z_efficiency")->Fill(kinTrue->z,wTrack); + if (recMatch) H->Hist("x_trueMC")->Fill(kinTrue->z, wTrack ); + if (mcMatch) H->Hist("x_efficiency")->Fill(kinTrue->z,wTrack); }); // execute the payload // - save time and don't call `ClearOps` (next loop will overwrite lambda) diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index 22e5a652..2f80e9e3 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -635,7 +635,8 @@ void PostProcessor::DrawSDInBinsTogether( yaxisy1 = 0.08; }; TString canvN = "canv_"+outName+"_all__"; - for (int k=0; kGet(histList[i][j]); Histos *H = histList[i][j]; - - THStack *hist = new THStack(); + TString stackN; stackN.Form("stack__"+histNames[k]+"__bin_%d_%d__",i,j); + THStack *hist = new THStack(stackN,stackN); TLegend *lg = new TLegend(0.05,0.05,0.95,0.95); lg->SetHeader(header,"C"); lg->SetTextSize(0.15); @@ -674,10 +675,10 @@ void PostProcessor::DrawSDInBinsTogether( //subHist->GetXaxis()->SetLabelSize(0); //subHist->GetYaxis()->SetLabelSize(0); TH1D *subHist; - if (histNames[k]=="z_purity") subHist = (TH1D*)H->Hist(histNames[k])->Clone(); + if (histNames[k]=="z_purity" || histNames[k]=="z_effiency" || histNames[k]=="x_purity" || histNames[k]=="x_efficiency") subHist = (TH1D*)H->Hist(histNames[k])->Clone(); else { TH2D *fitHist = (TH2D*)H->Hist(histNames[k])->Clone(); - if ( fitHist->GetEntries() < 10 ) continue; // Filter out low filled hists that can't get good fits. + if ( fitHist->GetEntries() < 10 ) continue; //NOTE: Filter out low filled hists that can't get good fits. fitHist->SetTitle(""); subHist = this->GetSDs(fitHist); } @@ -698,7 +699,7 @@ void PostProcessor::DrawSDInBinsTogether( subHist->SetMarkerColor(k+2); if (k+2>=5) subHist->SetMarkerColor(k+3); //NOTE: 5 is yellow: very hard to see. subHist->SetMarkerSize(0.5);//NOTE: Remember these will be small plots so keep the binning small and the markers big - if ( subHist->GetEntries()>0 || (histNames[k]=="z_purity" && H->Hist("z_z_Res")->GetMaximum()!=0)) { + if ( subHist->GetEntries()>0 || ((histNames[k]=="z_purity" || histNames[k]=="z_effiency" || histNames[k]=="x_purity" || histNames[k]=="x_efficiency") && H->Hist("z_z_Res")->GetMaximum()!=0)) { hist->Add(subHist); if (i==0 && j==0){ From 424851f459829f01013947dc1ce96a192e575467 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Tue, 23 Nov 2021 00:59:12 -0500 Subject: [PATCH 31/51] Fixed a couple typos from last commit --- src/Analysis.cxx | 4 ++-- src/PostProcessor.cxx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Analysis.cxx b/src/Analysis.cxx index 54ab9c67..3cfb65d5 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -336,8 +336,8 @@ void Analysis::Prepare() { HS->DefineHist1D("z_efficiency","efficiency","", NBINS, 0, 1); // 1D x-binned purity and efficiency - HS->DefineHist1D("z_true","z","", NBINS, 1e-5, 1, true); - HS->DefineHist1D("z_trueMC","z","", NBINS, 1e-5, 1, true); + HS->DefineHist1D("x_true","x","", NBINS, 1e-5, 1, true); + HS->DefineHist1D("x_trueMC","x","", NBINS, 1e-5, 1, true); HS->DefineHist1D("x_purity","purity","", NBINS, 1e-5, 1, true); HS->DefineHist1D("x_efficiency","efficiency","", NBINS, 1e-5, 1, true); diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index 2f80e9e3..91fc8268 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -661,7 +661,7 @@ void PostProcessor::DrawSDInBinsTogether( for(int j = 0; j < nvar2; j++){ //Histos *H = (Histos*) infile->Get(histList[i][j]); Histos *H = histList[i][j]; - TString stackN; stackN.Form("stack__"+histNames[k]+"__bin_%d_%d__",i,j); + TString stackN; stackN.Form("stack__bin_%d_%d__",i,j); THStack *hist = new THStack(stackN,stackN); TLegend *lg = new TLegend(0.05,0.05,0.95,0.95); lg->SetHeader(header,"C"); From 05706c76519e076f530b5725c5a26d4c90d73f0e Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Tue, 23 Nov 2021 10:43:27 -0500 Subject: [PATCH 32/51] Changed arg names for clarity in FillHistosEfficiency --- src/Analysis.cxx | 8 ++++---- src/Analysis.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Analysis.cxx b/src/Analysis.cxx index 3cfb65d5..82ac70cb 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -735,7 +735,7 @@ void Analysis::FillHistosPurity(bool recMatch, bool mcMatch) { }; // purity -void Analysis::FillHistosEfficiency(bool recMatch, bool mcMatch) { +void Analysis::FillHistosEfficiency(bool noMatch, bool mcMatch) { // add kinematic values to `valueMap` valueMap.clear(); @@ -753,10 +753,10 @@ void Analysis::FillHistosEfficiency(bool recMatch, bool mcMatch) { if(!activeEvent) return; // fill histograms, for activated bins only - HD->Payload([this,recMatch,mcMatch](Histos *H){ - if (recMatch) H->Hist("z_trueMC")->Fill(kinTrue->z, wTrack ); + HD->Payload([this,truthMatch,mcMatch](Histos *H){ + if (noMatch) H->Hist("z_trueMC")->Fill(kinTrue->z, wTrack ); if (mcMatch) H->Hist("z_efficiency")->Fill(kinTrue->z,wTrack); - if (recMatch) H->Hist("x_trueMC")->Fill(kinTrue->z, wTrack ); + if (noMatch) H->Hist("x_trueMC")->Fill(kinTrue->z, wTrack ); if (mcMatch) H->Hist("x_efficiency")->Fill(kinTrue->z,wTrack); }); // execute the payload diff --git a/src/Analysis.h b/src/Analysis.h index f82eac2f..34e25f03 100644 --- a/src/Analysis.h +++ b/src/Analysis.h @@ -101,7 +101,7 @@ class Analysis : public TNamed // FillHistos methods: fill histograms void FillHistosTracks(); void FillHistosPurity(bool recMatch, bool mcMatch); - void FillHistosEfficiency(bool recMatch, bool mcMatch); + void FillHistosEfficiency(bool noMatch, bool mcMatch); void FillHistosJets(); // lambda to check which bins an observable is in, during DAG breadth From 498f7314d0b01a34e2c046e77f5f4efb4782fa97 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Tue, 23 Nov 2021 12:27:53 -0500 Subject: [PATCH 33/51] Fixed typo in x-binned efficiencies and updated z limits in macro/analysis_resolution.C --- macro/analysis_resolution.C | 2 +- src/Analysis.cxx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/macro/analysis_resolution.C b/macro/analysis_resolution.C index f980c9c4..267b5501 100644 --- a/macro/analysis_resolution.C +++ b/macro/analysis_resolution.C @@ -32,7 +32,7 @@ void analysis_resolution( // define cuts ==================================== A->AddBinScheme("w"); A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV A->AddBinScheme("y"); A->BinScheme("y")->BuildBin("Range",0.01,0.95); // 0.01 < y < 0.95 - A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,0.6); // 0.2 < z < 0.9 + A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,1); // 0.2 < z < 0.9 (originally) A->AddBinScheme("xF"); A->BinScheme("xF")->BuildBin("Min",0.0); // xF > 0 A->AddBinScheme("ptLab"); A->BinScheme("ptLab")->BuildBin("Min",0.1); // pT_lab > 0.1 GeV (tracking limit) diff --git a/src/Analysis.cxx b/src/Analysis.cxx index 82ac70cb..23ea63c3 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -756,8 +756,8 @@ void Analysis::FillHistosEfficiency(bool noMatch, bool mcMatch) { HD->Payload([this,truthMatch,mcMatch](Histos *H){ if (noMatch) H->Hist("z_trueMC")->Fill(kinTrue->z, wTrack ); if (mcMatch) H->Hist("z_efficiency")->Fill(kinTrue->z,wTrack); - if (noMatch) H->Hist("x_trueMC")->Fill(kinTrue->z, wTrack ); - if (mcMatch) H->Hist("x_efficiency")->Fill(kinTrue->z,wTrack); + if (noMatch) H->Hist("x_trueMC")->Fill(kinTrue->x, wTrack ); + if (mcMatch) H->Hist("x_efficiency")->Fill(kinTrue->x,wTrack); }); // execute the payload // - save time and don't call `ClearOps` (next loop will overwrite lambda) From 4f96bf0e14e2972973a9a063bc3e5f4815424300 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Tue, 23 Nov 2021 16:07:47 -0500 Subject: [PATCH 34/51] Added test script for plotting different hadronic method results together --- macro/plotPurities.C | 205 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 macro/plotPurities.C diff --git a/macro/plotPurities.C b/macro/plotPurities.C new file mode 100644 index 00000000..7c3c1458 --- /dev/null +++ b/macro/plotPurities.C @@ -0,0 +1,205 @@ + + +void plotPurities(){ + // Get purity and efficiency plots from different methods output files + // And plot together + + TString p1 = "out/JB_dis-10x275-xm25.canvas.root"; + TString p2 = "out/DA_dis-10x275-xm25.canvas.root"; + + TFile *f1 = TFile::Open(p1); + TFile *f2 = TFile::Open(p2); + + // You should know nbins and limits in x and Q2 already + int nx = 6; + int nq = 4; + double xMin = 1e-2; double xMax = 1; + double qMin = 1; double qMax = 1000; + + TString outName = "dis-10x275-xm25"; + const int nNames = 3; + TString histNames[nNames] = {"z_z_Res","z_pT_Res","z_phiH_Res"}; + TString labels[nNames] = {"z","p_{T}","#phi_{H}"}; + TString header = "10x275GeV"; + double yMin = -0.1; double yMax=1.0; + + // borrowed from postprocessor.cxx + // default values set for nvar1==nvar2 + + // used to be input args + TString var1name="x"; int nvar1=nx; double var1low=xMin; double var1high=xMax; bool var1log=true; + TString var2name="Q2"; int nvar2=nq; double var2low=qMin; double var2high=qMax; bool var2log=true; + bool intlog1=false; bool intlog2=false; bool intgrid1=false; bool intgrid2=false; + + + int canvx = 933;//700; + int canvy = 800;//600;//TODO: check new numbers are better? + double botmargin = 0.2; + double leftmargin = 0.2; + double xaxisy = 0.04; + double xaxisx1 = 0.08; + double xaxisx2 = 0.97; + double yaxisx = 0.04; + double yaxisy1 = 0.085; + double yaxisy2 = 0.97; + if(nvar1 > nvar2){ + // different canvas sizing/axis position for unequal binning + canvx = 1100; + canvy = 700; + xaxisx1 = 0.075; + xaxisx2 = 0.975; + yaxisy1 = 0.08; + } + + TString canvN = "canv_"+outName+"_all__"; + TString histN = "stack_"+outName+"_all__"; + for (int k=0; kSetFillStyle(4000); + mainpad->Divide(nvar1,nvar2,0,0); + mainpad->Draw(); + TLine * lDIRC = new TLine(6,-1,6,1); + TLine * lDIRClow = new TLine(0.5,-1,0.5,1); + TLine * lmRICH = new TLine(2,-1,2,-4); + TLine * lDRICH = new TLine(2.5,1,2.5,4); + lDIRC->SetLineColor(kRed); + lDIRClow->SetLineColor(kRed); + lmRICH->SetLineColor(kRed); + lDRICH->SetLineColor(kRed); + THStack* histArray[nvar1][nvar2]; + int drawpid = 0; + //outfile->cd("/"); + // canv->Write(); + + for (int i=0; iSetHeader(header,"C"); + lg->SetTextSize(0.15); + if (nNames>3) lg->SetNColumns(2); + + for (int k=0; kGet(name)!=nullptr) h1 = (TH1D*)f1->Get(name); + TH1D *h2; if (f1->Get(name)!=nullptr) h2 = (TH1D*)f2->Get(name); + if (h1->GetBinContent(1)GetBinContent(1) || h2==nullptr) { + h1->SetMarkerColor(2); + hist->Add(h1); + if (i==0 && j==0){//TODO: Find where these actually pop up + lg->AddEntry(h1,"JB "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin + } + } + if (h2->GetBinContent(1)GetBinContent(1) || h1==nullptr) { + h2->SetMarkerColor(4); + hist->Add(h2); + if (i==1 && j==1){//TODO: Find where these actually pop up + lg->AddEntry(h2,"DA "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin + } + } + } + + mainpad->cd((nvar2-j-1)*nvar1 + i + 1); + gPad->SetLogx(intlog1); + gPad->SetLogy(intlog2); + gPad->SetGridy(intgrid2); + gPad->SetGridx(intgrid1); + TString drawStr = ""; + switch(1) {//TODO: figure out how to get THStack dimension? //can't use hist->GetHistogram()->GetDimension() + case 1: + drawStr = "hist p nostackb"; //NOTE: nostackb will just throw an error, don't use. /*"ex0 p nostack"*/ + break; + case 2: + drawStr = "COLZ"; + break; + case 3: + drawStr = "BOX"; + break; + }; + + if( hist->GetNhists() > 0 ) { + hist->Draw(drawStr); + TF1 *f1 = new TF1("f1","0",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); + f1->SetLineColor(1); + f1->SetLineWidth(1); + f1->Draw("SAME"); + if (i==0 && j==0) { + mainpad->cd(nvar1*nvar2);// Bottom right corner pad + lg->Draw(); + mainpad->cd((nvar2-j-1)*nvar1 + i + 1);// Return to original pad + } + if(drawpid){ + lDIRClow->Draw(); + lDIRC->Draw(); + lmRICH->Draw(); + lDRICH->Draw(); + } + } + + } + } + + // Overall stuff + canv->cd(); + + TPad *newpad1 = new TPad("newpad1","full pad",0,0,1,1); + TPad *newpad2 = new TPad("newpad2","full pad",0,0,1,1); + newpad1->SetFillStyle(4000); + newpad1->Draw(); + newpad2->SetFillStyle(4000); + newpad2->Draw(); + + TString xopt, yopt; + if(var1log) xopt = "GS"; + else xopt = "S"; + if(var2log) yopt = "GS"; + else yopt = "S"; + + TGaxis *xaxis = new TGaxis(xaxisx1,xaxisy,xaxisx2,xaxisy,var1low,var1high,510,xopt); + TGaxis *yaxis = new TGaxis(yaxisx,yaxisy1,yaxisx,yaxisy2,var2low,var2high,510,yopt); + xaxis->SetTitle(var1name); + xaxis->SetName("xaxis"); + xaxis->SetTitleSize(0.02); + xaxis->SetTextFont(40); + xaxis->SetLabelSize(0.02); + xaxis->SetTickSize(0.02); + + yaxis->SetTitle(var2name); + yaxis->SetTitleSize(0.02); + yaxis->SetName("yaxis"); + yaxis->SetTextFont(40); + yaxis->SetLabelSize(0.02); + yaxis->SetTickSize(0.02); + + newpad1->cd(); + yaxis->Draw(); + newpad2->cd(); + xaxis->Draw(); + + // canv->Write(); + canv->Print(canvN+".png"); + canv->Print(canvN+".pdf"); + + // OLD + // // THStack *hs = new THStack("myStack","myStack"); + // // hs->Add(h1); hs->Add(h2); + + // // Make legend + // TString header = "testheader"; + // TLegend *lg = new TLegend(0.80,0.05,0.90,0.15); + // lg->SetHeader(header,"C"); + // lg->SetTextSize(0.15); + // lg->SetNColumns(2); + // lg->AddEntry(h1,"label1","p"); + // lg->AddEntry(h2,"label2","p"); + + // // Draw and save + // TCanvas *c1 = new TCanvas(); + // h1->Draw("BOX"); + // h2->Draw("SAME") + // lg->Draw(); + // c1->Print("myStack.pdf"); + +} \ No newline at end of file From 2be5eebd1cd5f0cb07094bbf0bb98944f8f30578 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Fri, 26 Nov 2021 22:36:56 -0500 Subject: [PATCH 35/51] Added plotting script for kinematics and purities/efficiencies all together --- macro/plotPurities.C | 412 ++++++++++++++++++++++++++++++++++++++++-- src/Analysis.cxx | 4 +- src/PostProcessor.cxx | 7 +- 3 files changed, 399 insertions(+), 24 deletions(-) diff --git a/macro/plotPurities.C b/macro/plotPurities.C index 7c3c1458..5467d563 100644 --- a/macro/plotPurities.C +++ b/macro/plotPurities.C @@ -6,9 +6,11 @@ void plotPurities(){ TString p1 = "out/JB_dis-10x275-xm25.canvas.root"; TString p2 = "out/DA_dis-10x275-xm25.canvas.root"; + TString p3 = "out/Ele_dis-10x275-xm25.canvas.root"; TFile *f1 = TFile::Open(p1); TFile *f2 = TFile::Open(p2); + TFile *f3 = TFile::Open(p3); // You should know nbins and limits in x and Q2 already int nx = 6; @@ -17,19 +19,22 @@ void plotPurities(){ double qMin = 1; double qMax = 1000; TString outName = "dis-10x275-xm25"; - const int nNames = 3; - TString histNames[nNames] = {"z_z_Res","z_pT_Res","z_phiH_Res"}; - TString labels[nNames] = {"z","p_{T}","#phi_{H}"}; - TString header = "10x275GeV"; + const int nNames = 5; + TString histNames[nNames] = {"z_efficiency","z_purity","z_phiH_Res","z_pT_Res","z_z_Res"}; + TString labels[nNames] = {"K^{#pm} efficiency","K^{#pm} purity","#phi_{H}","p_{T}","z"}; + TString header = "10x275GeV (0.2 < z < 1.0)"; double yMin = -0.1; double yMax=1.0; + int nbinsz = 1; //Set manually...NOTE TODO + // borrowed from postprocessor.cxx + // default values set for nvar1==nvar2 // used to be input args TString var1name="x"; int nvar1=nx; double var1low=xMin; double var1high=xMax; bool var1log=true; TString var2name="Q2"; int nvar2=nq; double var2low=qMin; double var2high=qMax; bool var2log=true; - bool intlog1=false; bool intlog2=false; bool intgrid1=false; bool intgrid2=false; + bool intlog1=false; bool intlog2=false; bool intgrid1=true; bool intgrid2=false; int canvx = 933;//700; @@ -57,6 +62,10 @@ void plotPurities(){ TCanvas *canv = new TCanvas(canvN,canvN, canvx, canvy); TPad *mainpad = new TPad("mainpad", "mainpad", 0.07, 0.07, 0.98, 0.98); + // Get Rid of border frame + gStyle->SetFrameLineWidth(0); + mainpad->UseCurrentStyle(); + mainpad->SetFillStyle(4000); mainpad->Divide(nvar1,nvar2,0,0); mainpad->Draw(); @@ -72,33 +81,335 @@ void plotPurities(){ int drawpid = 0; //outfile->cd("/"); // canv->Write(); + bool daz = false; + bool dapt = false; + bool daphi = false; + bool elez = false; + bool elept = false; + bool elephi = false; + bool jbz = false; + bool jbpt = false; + bool jbphi = false; + bool purity = false; + bool efficiency = false; + TPad *lgpad = new TPad("lgpad", "lgpad", 0.84, 0.07, 0.98, 0.21); + TLegend *lg = new TLegend(0.01,0.01,0.99,0.99); + lg->SetHeader(header,"C"); + lg->SetTextSize(0.08); + if (nNames>3) lg->SetNColumns(2); + // if (nNames>4) lg->SetNColumns(3); for (int i=0; iSetHeader(header,"C"); - lg->SetTextSize(0.15); - if (nNames>3) lg->SetNColumns(2); - + // TH1D *h1_ = new TH1D("h1_","h1_",nNames,0,1); + // TH1D *h2_ = new TH1D("h2_","h2_",nNames,0,1); + // TH1D *h3_ = new TH1D("h3_","h3_",nNames,0,1); + for (int k=0; kGet(name)!=nullptr) h1 = (TH1D*)f1->Get(name); - TH1D *h2; if (f1->Get(name)!=nullptr) h2 = (TH1D*)f2->Get(name); - if (h1->GetBinContent(1)GetBinContent(1) || h2==nullptr) { - h1->SetMarkerColor(2); + TString name; name.Form("hist__"+histNames[k]+"__bin_%d_%d",i,j); + // std::cout<<"Getting "<Get(name)!=nullptr) h1_ = (TH1D*)f1->Get(name); else h1_ = nullptr; + TH1D *h2_; if (f2->Get(name)!=nullptr) h2_ = (TH1D*)f2->Get(name); else h2_ = nullptr; + TH1D *h3_; if (f3->Get(name)!=nullptr) h3_ = (TH1D*)f3->Get(name); else h3_ = nullptr; + + TH1D *h1 = new TH1D("h1","",nbinsz,0,1); + TH1D *h2 = new TH1D("h2","",nbinsz,0,1); + TH1D *h3 = new TH1D("h3","",nbinsz,0,1); + for (int idx=1; idx<=nbinsz; idx++) { + if (h1_!=nullptr && h2_!=nullptr && h3_!=nullptr){ + // h1_->SetBinError(idx,0); h2_->SetBinError(idx,0); h3_->SetBinError(idx,0); + // std::cout<<"\t"<Get(name)<<" "<Get(name)<<" "<Get(name)<GetBinContent(idx)GetBinContent(idx) && h1_->GetBinContent(idx)GetBinContent(idx) && (histNames[k]!="z_purity" && histNames[k]!="z_efficiency")) { + // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetBinContent(idx,h1_->GetBinContent(idx)); + if (histNames[k]=="z_z_Res") h1->SetMarkerStyle(71); + if (histNames[k]=="z_pT_Res") h1->SetMarkerStyle(73); + if (histNames[k]=="z_phiH_Res") h1->SetMarkerStyle(77); + // std::cout<<"\th1: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(8); + h1->SetMarkerSize(1); + h1->GetYaxis()->SetRangeUser(-0.05,1); hist->Add(h1); - if (i==0 && j==0){//TODO: Find where these actually pop up + if ( ((i==4 && j==1) || (i==5 && j==2)) && ((histNames[k]=="z_z_Res" && !jbz) || (histNames[k]=="z_pT_Res" && !jbpt) || (histNames[k]=="z_phiH_Res" && !jbphi)) ) {//TODO: Find where these actually pop up + + if (histNames[k]=="z_z_Res") jbz=true; + if (histNames[k]=="z_pT_Res") jbpt=true; + if (histNames[k]=="z_phiH_Res") jbphi=true; + std::cout<<"ADDING JB ENTRY "<AddEntry(h1,"JB "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin } + // continue; //IMPORTANT! + } + if (h2_->GetBinContent(idx)GetBinContent(1) && h2_->GetBinContent(idx)GetBinContent(idx) && (histNames[k]!="z_purity" && histNames[k]!="z_efficiency")) { + // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetBinContent(idx,h2_->GetBinContent(idx)); + if (histNames[k]=="z_z_Res") h2->SetMarkerStyle(71); + if (histNames[k]=="z_pT_Res") h2->SetMarkerStyle(73); + if (histNames[k]=="z_phiH_Res") h2->SetMarkerStyle(77); + // std::cout<<"\th2: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(4); + h2->SetMarkerSize(1); + h2->GetYaxis()->SetRangeUser(-0.05,1); + hist->Add(h2); + if ((histNames[k]=="z_z_Res" && !daz) || (histNames[k]=="z_pT_Res" && !dapt) || (histNames[k]=="z_phiH_Res" && !daphi)){//TODO: Find where these actually pop up + if (histNames[k]=="z_z_Res") daz=true; + if (histNames[k]=="z_pT_Res") dapt=true; + if (histNames[k]=="z_phiH_Res") daphi=true; + std::cout<<"ADDING ENTRY "<AddEntry(h2,"DA "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin + } + // continue; + } + // else { + // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetBinContent(idx,h3_->GetBinContent(idx)); + if (histNames[k]=="z_z_Res") h3->SetMarkerStyle(71); + if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(73); + if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(77); + if (histNames[k]=="z_purity") h3->SetMarkerStyle(21); + if (histNames[k]=="z_efficiency") h3->SetMarkerStyle(34); + // std::cout<<"\th3: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(2); if (histNames[k]=="z_purity") h3->SetMarkerColor(8); + if (histNames[k]=="z_efficiency") h3->SetMarkerColor(9); + h3->SetMarkerSize(1); + h3->GetYaxis()->SetRangeUser(-0.05,1); + hist->Add(h3); + if ((histNames[k]=="z_z_Res" && !elez) || (histNames[k]=="z_pT_Res" && !elept) || (histNames[k]=="z_phiH_Res" && !elephi) || !purity){//TODO: Find where these actually pop up + if (histNames[k]=="z_z_Res") elez=true; + if (histNames[k]=="z_pT_Res") elept=true; + if (histNames[k]=="z_phiH_Res") elephi=true; + if (histNames[k]=="z_purity") purity=true; + if (histNames[k]=="z_efficiency") efficiency=true; + std::cout<<"ADDING ENTRY "<AddEntry(h3,"Ele "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin + else lg->AddEntry(h3,labels[k],"p"); + // } } - if (h2->GetBinContent(1)GetBinContent(1) || h1==nullptr) { + }// if (h1!=nullptr && h2!=nullptr) + + if (h1_==nullptr && h2_!=nullptr && h3_!=nullptr){ + // h2_->SetBinError(idx,0); h3_->SetBinError(idx,0); + // std::cout<<"\t"<Get(name)<<" "<Get(name)<<" "<Get(name)<GetBinContent(1)GetBinContent(1) && h1->GetBinContent(1)GetBinContent(1) && histNames[k]!="z_purity") { + // // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetMarkerStyle(71); + // if (histNames[k]=="z_pT_Res") h1->SetMarkerStyle(73); + // if (histNames[k]=="z_phiH_Res") h1->SetMarkerStyle(77); + // // std::cout<<"\th1: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(8); + // h1->SetMarkerSize(1); + // h1->GetYaxis()->SetRangeUser(-0.05,1); + // hist->Add(h1); + // if ( ((i==4 && j==1) || (i==5 && j==2)) && ((histNames[k]=="z_z_Res" && !jbz) || (histNames[k]=="z_pT_Res" && !jbpt) || (histNames[k]=="z_phiH_Res" && !jbphi)) ) {//TODO: Find where these actually pop up + + // if (histNames[k]=="z_z_Res") jbz=true; + // if (histNames[k]=="z_pT_Res") jbpt=true; + // if (histNames[k]=="z_phiH_Res") jbphi=true; + // std::cout<<"ADDING JB ENTRY "<AddEntry(h1,"JB "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin + // } + // // continue; //IMPORTANT! + // } + if (h2_->GetBinContent(idx)GetBinContent(idx) && (histNames[k]!="z_purity" && histNames[k]!="z_efficiency")) { + // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetBinContent(idx,h2_->GetBinContent(idx)); + if (histNames[k]=="z_z_Res") h2->SetMarkerStyle(71); + if (histNames[k]=="z_pT_Res") h2->SetMarkerStyle(73); + if (histNames[k]=="z_phiH_Res") h2->SetMarkerStyle(77); + // std::cout<<"\th2: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(4); + h2->SetMarkerSize(1); + h2->GetYaxis()->SetRangeUser(-0.05,1); hist->Add(h2); - if (i==1 && j==1){//TODO: Find where these actually pop up + if ((histNames[k]=="z_z_Res" && !daz) || (histNames[k]=="z_pT_Res" && !dapt) || (histNames[k]=="z_phiH_Res" && !daphi)){//TODO: Find where these actually pop up + if (histNames[k]=="z_z_Res") daz=true; + if (histNames[k]=="z_pT_Res") dapt=true; + if (histNames[k]=="z_phiH_Res") daphi=true; + std::cout<<"ADDING ENTRY "<AddEntry(h2,"DA "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin } + // continue; + } + // else { + // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetBinContent(idx,h3_->GetBinContent(idx)); + if (histNames[k]=="z_z_Res") h3->SetMarkerStyle(71); + if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(73); + if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(77); + if (histNames[k]=="z_purity") h3->SetMarkerStyle(21); + // std::cout<<"\th3: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(2); if (histNames[k]=="z_purity") h3->SetMarkerColor(8); + if (histNames[k]=="z_efficiency") h3->SetMarkerColor(9); + h3->SetMarkerSize(1); + h3->GetYaxis()->SetRangeUser(-0.05,1); + hist->Add(h3); + if ((histNames[k]=="z_z_Res" && !elez) || (histNames[k]=="z_pT_Res" && !elept) || (histNames[k]=="z_phiH_Res" && !elephi) || !purity){//TODO: Find where these actually pop up + if (histNames[k]=="z_z_Res") elez=true; + if (histNames[k]=="z_pT_Res") elept=true; + if (histNames[k]=="z_phiH_Res") elephi=true; + if (histNames[k]=="z_purity") purity=true; + if (histNames[k]=="z_efficiency") efficiency=true; + std::cout<<"ADDING ENTRY "<AddEntry(h3,"Ele "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin + else lg->AddEntry(h3,labels[k],"p"); + // } } + }// if (h2!=nullptr && h3!=nullptr) + + if (h1_!=nullptr && h2_==nullptr && h3_!=nullptr){ + // h1_->SetBinError(1,0); h3_->SetBinError(1,0); + // std::cout<<"\t"<Get(name)<<" "<Get(name)<<" "<Get(name)<GetBinContent(idx)GetBinContent(idx) && (histNames[k]!="z_purity" && histNames[k]!="z_efficiency")) { + h1->SetBinContent(idx,h1_->GetBinContent(idx)); + // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetMarkerStyle(71); + if (histNames[k]=="z_pT_Res") h1->SetMarkerStyle(73); + if (histNames[k]=="z_phiH_Res") h1->SetMarkerStyle(77); + // std::cout<<"\th1: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(8); + h1->SetMarkerSize(1); + h1->GetYaxis()->SetRangeUser(-0.05,1); + hist->Add(h1); + if ( ((i==4 && j==1) || (i==5 && j==2)) && ((histNames[k]=="z_z_Res" && !jbz) || (histNames[k]=="z_pT_Res" && !jbpt) || (histNames[k]=="z_phiH_Res" && !jbphi)) ) {//TODO: Find where these actually pop up + + if (histNames[k]=="z_z_Res") jbz=true; + if (histNames[k]=="z_pT_Res") jbpt=true; + if (histNames[k]=="z_phiH_Res") jbphi=true; + std::cout<<"ADDING JB ENTRY "<AddEntry(h1,"JB "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin + } + // continue; //IMPORTANT! + } + // if (h2->GetBinContent(1)GetBinContent(1) && histNames[k]!="z_purity") { + // // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetMarkerStyle(71); + // if (histNames[k]=="z_pT_Res") h2->SetMarkerStyle(73); + // if (histNames[k]=="z_phiH_Res") h2->SetMarkerStyle(77); + // // std::cout<<"\th2: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(4); + // h2->SetMarkerSize(1); + // h2->GetYaxis()->SetRangeUser(-0.05,1); + // hist->Add(h2); + // if ((histNames[k]=="z_z_Res" && !daz) || (histNames[k]=="z_pT_Res" && !dapt) || (histNames[k]=="z_phiH_Res" && !daphi)){//TODO: Find where these actually pop up + // if (histNames[k]=="z_z_Res") daz=true; + // if (histNames[k]=="z_pT_Res") dapt=true; + // if (histNames[k]=="z_phiH_Res") daphi=true; + // std::cout<<"ADDING ENTRY "<AddEntry(h2,"DA "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin + // } + // // continue; + // } + // else { + // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetBinContent(idx,h3_->GetBinContent(idx)); + if (histNames[k]=="z_z_Res") h3->SetMarkerStyle(71); + if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(73); + if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(77); + if (histNames[k]=="z_purity") h3->SetMarkerStyle(21); + // std::cout<<"\th3: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(2); if (histNames[k]=="z_purity") h3->SetMarkerColor(8); if (histNames[k]=="z_efficiency") h3->SetMarkerColor(8); + h3->SetMarkerSize(1); + h3->GetYaxis()->SetRangeUser(-0.05,1); + hist->Add(h3); + if ((histNames[k]=="z_z_Res" && !elez) || (histNames[k]=="z_pT_Res" && !elept) || (histNames[k]=="z_phiH_Res" && !elephi) || !purity){//TODO: Find where these actually pop up + if (histNames[k]=="z_z_Res") elez=true; + if (histNames[k]=="z_pT_Res") elept=true; + if (histNames[k]=="z_phiH_Res") elephi=true; + if (histNames[k]=="z_purity") purity=true; + std::cout<<"ADDING ENTRY "<AddEntry(h3,"Ele "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin + else lg->AddEntry(h3,labels[k],"p"); + // } + } + }// if (h1!=nullptr && h3!=nullptr) + } // idx loop + /* + // if (h1!=nullptr && h2!=nullptr && h3==nullptr){ + // // std::cout<<"\t"<Get(name)<<" "<Get(name)<<" "<Get(name)<GetBinContent(1)GetBinContent(1) && histNames[k]!="z_purity") { + // // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetMarkerStyle(71); + // if (histNames[k]=="z_pT_Res") h1->SetMarkerStyle(73); + // if (histNames[k]=="z_phiH_Res") h1->SetMarkerStyle(77); + // // std::cout<<"\th1: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(8); + // h1->SetMarkerSize(1); + // h1->GetYaxis()->SetRangeUser(-0.05,1); + // hist->Add(h1); + // if ( ((i==4 && j==1) || (i==5 && j==2)) && ((histNames[k]=="z_z_Res" && !jbz) || (histNames[k]=="z_pT_Res" && !jbpt) || (histNames[k]=="z_phiH_Res" && !jbphi)) ) {//TODO: Find where these actually pop up + + // if (histNames[k]=="z_z_Res") jbz=true; + // if (histNames[k]=="z_pT_Res") jbpt=true; + // if (histNames[k]=="z_phiH_Res") jbphi=true; + // std::cout<<"ADDING JB ENTRY "<AddEntry(h1,"JB "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin + // } + // // continue; //IMPORTANT! + // } + // if (h2->GetBinContent(1)GetBinContent(1) && histNames[k]!="z_purity") { + // // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetMarkerStyle(71); + // if (histNames[k]=="z_pT_Res") h2->SetMarkerStyle(73); + // if (histNames[k]=="z_phiH_Res") h2->SetMarkerStyle(77); + // // std::cout<<"\th2: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(4); + // h2->SetMarkerSize(1); + // h2->GetYaxis()->SetRangeUser(-0.05,1); + // hist->Add(h2); + // if ((histNames[k]=="z_z_Res" && !daz) || (histNames[k]=="z_pT_Res" && !dapt) || (histNames[k]=="z_phiH_Res" && !daphi)){//TODO: Find where these actually pop up + // if (histNames[k]=="z_z_Res") daz=true; + // if (histNames[k]=="z_pT_Res") dapt=true; + // if (histNames[k]=="z_phiH_Res") daphi=true; + // std::cout<<"ADDING ENTRY "<AddEntry(h2,"DA "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin + // } + // // continue; + // } + // // // else { + // // // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetMarkerStyle(71); + // // if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(73); + // // if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(77); + // // if (histNames[k]=="z_purity") h3->SetMarkerStyle(21); + // // // std::cout<<"\th3: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(2); + // // h3->SetMarkerSize(1); + // // h3->GetYaxis()->SetRangeUser(-0.05,1); + // // hist->Add(h3); + // // if ((histNames[k]=="z_z_Res" && !elez) || (histNames[k]=="z_pT_Res" && !elept) || (histNames[k]=="z_phiH_Res" && !elephi) || !purity){//TODO: Find where these actually pop up + // // if (histNames[k]=="z_z_Res") elez=true; + // // if (histNames[k]=="z_pT_Res") elept=true; + // // if (histNames[k]=="z_phiH_Res") elephi=true; + // // if (histNames[k]=="z_purity") purity=true; + // // std::cout<<"ADDING ENTRY "<AddEntry(h3,"Ele "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin + // // else lg->AddEntry(h3,labels[k],"p"); + // // // } + // // } + // }// if (h2!=nullptr && h2!=nullptr) + */ + + // if (h1!=nullptr) { + // h1->SetMarkerColor(2); + // h1->SetMarkerSize(1); + // hist->Add(h1); + // if (i==0 && j==0){//TODO: Find where these actually pop up + // lg->AddEntry(h1,"JB "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin + // } + // continue; + // } + // if (h2!=nullptr) { + // h2->SetMarkerColor(4); + // h2->SetMarkerSize(1); + // // h1->GetXaxis()->SetNDivision + // hist->Add(h2); + // if (i==1 && j==1){//TODO: Find where these actually pop up + // lg->AddEntry(h2,"DA "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin + // } + // continue; + // } } mainpad->cd((nvar2-j-1)*nvar1 + i + 1); @@ -106,10 +417,12 @@ void plotPurities(){ gPad->SetLogy(intlog2); gPad->SetGridy(intgrid2); gPad->SetGridx(intgrid1); + // gPad->SetGrid(0,5);//NOTE: ADDED TODO: CHECK TString drawStr = ""; switch(1) {//TODO: figure out how to get THStack dimension? //can't use hist->GetHistogram()->GetDimension() case 1: - drawStr = "hist p nostackb"; //NOTE: nostackb will just throw an error, don't use. /*"ex0 p nostack"*/ + if (i==0) drawStr = "nostack b p"; //NOTE: nostackb will just throw an error, don't use. /*"ex0 p nostack"*/ + else drawStr = "nostack b p a"; break; case 2: drawStr = "COLZ"; @@ -121,10 +434,69 @@ void plotPurities(){ if( hist->GetNhists() > 0 ) { hist->Draw(drawStr); - TF1 *f1 = new TF1("f1","0",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); + hist->GetHistogram()->GetYaxis()->SetNdivisions(10); + if (nbinsz==1) hist->GetHistogram()->GetXaxis()->SetNdivisions(0); + hist->GetHistogram()->GetYaxis()->SetLabelSize(0.09); + mainpad->SetGrid(0,10); + // if (i!=0) { + // for (int idx=0; idx<5; idx++){ + // TF1 *f5 = new TF1("f5","0.2",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); + // f5->SetLineStyle(2); + // f5->SetLineColor(1); + // f5->Draw("SAME"); + // TF1 *f2 = new TF1("f2","0.4",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); + // f2->SetLineStyle(2); + // f2->SetLineColor(1); + // f2->Draw("SAME"); + // TF1 *f3 = new TF1("f3","0.6",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); + // f3->SetLineStyle(2); + // f3->SetLineColor(1); + // f3->Draw(); + // TF1 *f4 = new TF1("f4","0.8",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); + // f4->SetLineStyle(2); + // f4->SetLineColor(1); + // f4->Draw("SAME"); + + // } + // } + // hist->GetHistogram()->GetYaxis()->SetRangeUser(0,1); + // hist->Draw(drawStr); + TF1 *f1 = new TF1("f1","0.0",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); f1->SetLineColor(1); + f1->SetLineStyle(1); f1->SetLineWidth(1); f1->Draw("SAME"); + + TF1 *f2 = new TF1("f2","0.2",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); + f2->SetLineColor(1); + f2->SetLineStyle(2); + f2->SetLineWidth(1); + f2->Draw("SAME"); + + TF1 *f3 = new TF1("f3","0.4",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); + f3->SetLineColor(1); + f3->SetLineStyle(2); + f3->SetLineWidth(1); + f3->Draw("SAME"); + + TF1 *f4 = new TF1("f4","0.6",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); + f4->SetLineColor(1); + f4->SetLineStyle(2); + f4->SetLineWidth(1); + f4->Draw("SAME"); + + TF1 *f5 = new TF1("f5","0.8",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); + f5->SetLineColor(1); + f5->SetLineStyle(2); + f5->SetLineWidth(1); + f5->Draw("SAME"); + + TF1 *f6 = new TF1("f6","1.0",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); + f6->SetLineColor(1); + f6->SetLineStyle(2); + f6->SetLineWidth(1); + f6->Draw("SAME"); + if (i==0 && j==0) { mainpad->cd(nvar1*nvar2);// Bottom right corner pad lg->Draw(); diff --git a/src/Analysis.cxx b/src/Analysis.cxx index 23ea63c3..676cd850 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -326,8 +326,8 @@ void Analysis::Prepare() { HS->DefineHist2D("z_y_Res","z","","#sigma_{y}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); HS->DefineHist2D("z_z_Res","z","","#sigma_{z}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); HS->DefineHist2D("z_pT_Res","z","","#sigma_{pT}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); - HS->DefineHist2D("z_phiH_Res","z","","#sigma_{#phi_{h}^{true}}","", NBINS, 0, 1, NBINSRES, -TMath::Pi(), TMath::Pi()); - HS->DefineHist2D("z_phiS_Res","z","","#sigma_{#phi_{S}^{true}}","", NBINS, 0, 1, NBINSRES, -TMath::Pi(), TMath::Pi()); + HS->DefineHist2D("z_phiH_Res","z","","#sigma_{#phi_{h}^{true}}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); + HS->DefineHist2D("z_phiS_Res","z","","#sigma_{#phi_{S}^{true}}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); // 1D z-binned purity and efficiency HS->DefineHist1D("z_true","z","", NBINS, 0, 1); diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index 91fc8268..9c9069a6 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -675,7 +675,7 @@ void PostProcessor::DrawSDInBinsTogether( //subHist->GetXaxis()->SetLabelSize(0); //subHist->GetYaxis()->SetLabelSize(0); TH1D *subHist; - if (histNames[k]=="z_purity" || histNames[k]=="z_effiency" || histNames[k]=="x_purity" || histNames[k]=="x_efficiency") subHist = (TH1D*)H->Hist(histNames[k])->Clone(); + if (histNames[k]=="z_purity" || histNames[k]=="z_efficiency" || histNames[k]=="x_purity" || histNames[k]=="x_efficiency") subHist = (TH1D*)H->Hist(histNames[k])->Clone(); else { TH2D *fitHist = (TH2D*)H->Hist(histNames[k])->Clone(); if ( fitHist->GetEntries() < 10 ) continue; //NOTE: Filter out low filled hists that can't get good fits. @@ -699,8 +699,11 @@ void PostProcessor::DrawSDInBinsTogether( subHist->SetMarkerColor(k+2); if (k+2>=5) subHist->SetMarkerColor(k+3); //NOTE: 5 is yellow: very hard to see. subHist->SetMarkerSize(0.5);//NOTE: Remember these will be small plots so keep the binning small and the markers big - if ( subHist->GetEntries()>0 || ((histNames[k]=="z_purity" || histNames[k]=="z_effiency" || histNames[k]=="x_purity" || histNames[k]=="x_efficiency") && H->Hist("z_z_Res")->GetMaximum()!=0)) { + if ( subHist->GetEntries()>0 || ((histNames[k]=="z_purity" || histNames[k]=="z_efficiency" || histNames[k]=="x_purity" || histNames[k]=="x_efficiency") && H->Hist("z_z_Res")->GetMaximum()!=0)) { hist->Add(subHist); + TString myname; myname.Form("hist__"+histNames[k]+"__bin_%d_%d",i,j); + subHist->SetName(myname); + subHist->Write(); if (i==0 && j==0){ lg->AddEntry(subHist,labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin From 973f9fd71005282e69a7c14c310fc93de7494e39 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Fri, 26 Nov 2021 22:53:08 -0500 Subject: [PATCH 36/51] No changes --- macro/plotPurities.C | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/macro/plotPurities.C b/macro/plotPurities.C index 5467d563..c8dd2de1 100644 --- a/macro/plotPurities.C +++ b/macro/plotPurities.C @@ -4,7 +4,7 @@ void plotPurities(){ // Get purity and efficiency plots from different methods output files // And plot together - TString p1 = "out/JB_dis-10x275-xm25.canvas.root"; + TString p1 = "out/JB_dis-1x275-xm25.canvas.root"; TString p2 = "out/DA_dis-10x275-xm25.canvas.root"; TString p3 = "out/Ele_dis-10x275-xm25.canvas.root"; @@ -421,8 +421,8 @@ void plotPurities(){ TString drawStr = ""; switch(1) {//TODO: figure out how to get THStack dimension? //can't use hist->GetHistogram()->GetDimension() case 1: - if (i==0) drawStr = "nostack b p"; //NOTE: nostackb will just throw an error, don't use. /*"ex0 p nostack"*/ - else drawStr = "nostack b p a"; + if (i==0) drawStr = "nostack p"; //NOTE: nostackb will just throw an error, don't use. /*"ex0 p nostack"*/ + else drawStr = "nostack p a"; break; case 2: drawStr = "COLZ"; From 73fb42f39dc6ff98a121ad3183db7dd09646d089 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Sat, 27 Nov 2021 14:49:05 -0500 Subject: [PATCH 37/51] Changed marker size in plotPurities.C --- macro/plotPurities.C | 88 ++++++++++++++++++++++---------------------- src/Analysis.cxx | 4 +- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/macro/plotPurities.C b/macro/plotPurities.C index c8dd2de1..1f678311 100644 --- a/macro/plotPurities.C +++ b/macro/plotPurities.C @@ -4,9 +4,9 @@ void plotPurities(){ // Get purity and efficiency plots from different methods output files // And plot together - TString p1 = "out/JB_dis-1x275-xm25.canvas.root"; - TString p2 = "out/DA_dis-10x275-xm25.canvas.root"; - TString p3 = "out/Ele_dis-10x275-xm25.canvas.root"; + TString p1 = "out/1bin/JB_dis-18x275-xm25.canvas.root"; + TString p2 = "out/1bin/DA_dis-18x275-xm25.canvas.root"; + TString p3 = "out/1bin/Ele_dis-18x275-xm25.canvas.root"; TFile *f1 = TFile::Open(p1); TFile *f2 = TFile::Open(p2); @@ -18,11 +18,11 @@ void plotPurities(){ double xMin = 1e-2; double xMax = 1; double qMin = 1; double qMax = 1000; - TString outName = "dis-10x275-xm25"; + TString outName = "dis-18x275-xm25"; const int nNames = 5; TString histNames[nNames] = {"z_efficiency","z_purity","z_phiH_Res","z_pT_Res","z_z_Res"}; TString labels[nNames] = {"K^{#pm} efficiency","K^{#pm} purity","#phi_{H}","p_{T}","z"}; - TString header = "10x275GeV (0.2 < z < 1.0)"; + TString header = "18x275GeV (0.2 < z < 1.0)"; double yMin = -0.1; double yMax=1.0; int nbinsz = 1; //Set manually...NOTE TODO @@ -34,7 +34,7 @@ void plotPurities(){ // used to be input args TString var1name="x"; int nvar1=nx; double var1low=xMin; double var1high=xMax; bool var1log=true; TString var2name="Q2"; int nvar2=nq; double var2low=qMin; double var2high=qMax; bool var2log=true; - bool intlog1=false; bool intlog2=false; bool intgrid1=true; bool intgrid2=false; + bool intlog1=false; bool intlog2=false; bool intgrid1=false; bool intgrid2=false; int canvx = 933;//700; @@ -124,9 +124,9 @@ void plotPurities(){ if (h1_->GetBinContent(idx)GetBinContent(idx) && h1_->GetBinContent(idx)GetBinContent(idx) && (histNames[k]!="z_purity" && histNames[k]!="z_efficiency")) { // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetBinContent(idx,h1_->GetBinContent(idx)); - if (histNames[k]=="z_z_Res") h1->SetMarkerStyle(71); - if (histNames[k]=="z_pT_Res") h1->SetMarkerStyle(73); - if (histNames[k]=="z_phiH_Res") h1->SetMarkerStyle(77); + if (histNames[k]=="z_z_Res") h1->SetMarkerStyle(24); + if (histNames[k]=="z_pT_Res") h1->SetMarkerStyle(26); + if (histNames[k]=="z_phiH_Res") h1->SetMarkerStyle(32); // std::cout<<"\th1: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(8); h1->SetMarkerSize(1); @@ -145,9 +145,9 @@ void plotPurities(){ if (h2_->GetBinContent(idx)GetBinContent(1) && h2_->GetBinContent(idx)GetBinContent(idx) && (histNames[k]!="z_purity" && histNames[k]!="z_efficiency")) { // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetBinContent(idx,h2_->GetBinContent(idx)); - if (histNames[k]=="z_z_Res") h2->SetMarkerStyle(71); - if (histNames[k]=="z_pT_Res") h2->SetMarkerStyle(73); - if (histNames[k]=="z_phiH_Res") h2->SetMarkerStyle(77); + if (histNames[k]=="z_z_Res") h2->SetMarkerStyle(24); + if (histNames[k]=="z_pT_Res") h2->SetMarkerStyle(26); + if (histNames[k]=="z_phiH_Res") h2->SetMarkerStyle(32); // std::cout<<"\th2: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(4); h2->SetMarkerSize(1); @@ -165,9 +165,9 @@ void plotPurities(){ // else { // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetBinContent(idx,h3_->GetBinContent(idx)); - if (histNames[k]=="z_z_Res") h3->SetMarkerStyle(71); - if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(73); - if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(77); + if (histNames[k]=="z_z_Res") h3->SetMarkerStyle(24); + if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(26); + if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(32); if (histNames[k]=="z_purity") h3->SetMarkerStyle(21); if (histNames[k]=="z_efficiency") h3->SetMarkerStyle(34); // std::cout<<"\th3: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<Get(name)<<" "<Get(name)<<" "<Get(name)<GetBinContent(1)GetBinContent(1) && h1->GetBinContent(1)GetBinContent(1) && histNames[k]!="z_purity") { // // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetMarkerStyle(71); - // if (histNames[k]=="z_pT_Res") h1->SetMarkerStyle(73); - // if (histNames[k]=="z_phiH_Res") h1->SetMarkerStyle(77); + // if (histNames[k]=="z_z_Res") h1->SetMarkerStyle(24); + // if (histNames[k]=="z_pT_Res") h1->SetMarkerStyle(26); + // if (histNames[k]=="z_phiH_Res") h1->SetMarkerStyle(32); // // std::cout<<"\th1: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(8); // h1->SetMarkerSize(1); @@ -215,9 +215,9 @@ void plotPurities(){ if (h2_->GetBinContent(idx)GetBinContent(idx) && (histNames[k]!="z_purity" && histNames[k]!="z_efficiency")) { // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetBinContent(idx,h2_->GetBinContent(idx)); - if (histNames[k]=="z_z_Res") h2->SetMarkerStyle(71); - if (histNames[k]=="z_pT_Res") h2->SetMarkerStyle(73); - if (histNames[k]=="z_phiH_Res") h2->SetMarkerStyle(77); + if (histNames[k]=="z_z_Res") h2->SetMarkerStyle(24); + if (histNames[k]=="z_pT_Res") h2->SetMarkerStyle(26); + if (histNames[k]=="z_phiH_Res") h2->SetMarkerStyle(32); // std::cout<<"\th2: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(4); h2->SetMarkerSize(1); @@ -235,9 +235,9 @@ void plotPurities(){ // else { // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetBinContent(idx,h3_->GetBinContent(idx)); - if (histNames[k]=="z_z_Res") h3->SetMarkerStyle(71); - if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(73); - if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(77); + if (histNames[k]=="z_z_Res") h3->SetMarkerStyle(24); + if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(26); + if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(32); if (histNames[k]=="z_purity") h3->SetMarkerStyle(21); // std::cout<<"\th3: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(2); if (histNames[k]=="z_purity") h3->SetMarkerColor(8); @@ -264,9 +264,9 @@ void plotPurities(){ if (h1_->GetBinContent(idx)GetBinContent(idx) && (histNames[k]!="z_purity" && histNames[k]!="z_efficiency")) { h1->SetBinContent(idx,h1_->GetBinContent(idx)); // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetMarkerStyle(71); - if (histNames[k]=="z_pT_Res") h1->SetMarkerStyle(73); - if (histNames[k]=="z_phiH_Res") h1->SetMarkerStyle(77); + if (histNames[k]=="z_z_Res") h1->SetMarkerStyle(24); + if (histNames[k]=="z_pT_Res") h1->SetMarkerStyle(26); + if (histNames[k]=="z_phiH_Res") h1->SetMarkerStyle(32); // std::cout<<"\th1: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(8); h1->SetMarkerSize(1); @@ -284,9 +284,9 @@ void plotPurities(){ } // if (h2->GetBinContent(1)GetBinContent(1) && histNames[k]!="z_purity") { // // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetMarkerStyle(71); - // if (histNames[k]=="z_pT_Res") h2->SetMarkerStyle(73); - // if (histNames[k]=="z_phiH_Res") h2->SetMarkerStyle(77); + // if (histNames[k]=="z_z_Res") h2->SetMarkerStyle(24); + // if (histNames[k]=="z_pT_Res") h2->SetMarkerStyle(26); + // if (histNames[k]=="z_phiH_Res") h2->SetMarkerStyle(32); // // std::cout<<"\th2: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(4); // h2->SetMarkerSize(1); @@ -304,9 +304,9 @@ void plotPurities(){ // else { // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetBinContent(idx,h3_->GetBinContent(idx)); - if (histNames[k]=="z_z_Res") h3->SetMarkerStyle(71); - if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(73); - if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(77); + if (histNames[k]=="z_z_Res") h3->SetMarkerStyle(24); + if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(26); + if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(32); if (histNames[k]=="z_purity") h3->SetMarkerStyle(21); // std::cout<<"\th3: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(2); if (histNames[k]=="z_purity") h3->SetMarkerColor(8); if (histNames[k]=="z_efficiency") h3->SetMarkerColor(8); @@ -330,9 +330,9 @@ void plotPurities(){ // // std::cout<<"\t"<Get(name)<<" "<Get(name)<<" "<Get(name)<GetBinContent(1)GetBinContent(1) && histNames[k]!="z_purity") { // // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetMarkerStyle(71); - // if (histNames[k]=="z_pT_Res") h1->SetMarkerStyle(73); - // if (histNames[k]=="z_phiH_Res") h1->SetMarkerStyle(77); + // if (histNames[k]=="z_z_Res") h1->SetMarkerStyle(24); + // if (histNames[k]=="z_pT_Res") h1->SetMarkerStyle(26); + // if (histNames[k]=="z_phiH_Res") h1->SetMarkerStyle(32); // // std::cout<<"\th1: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(8); // h1->SetMarkerSize(1); @@ -350,9 +350,9 @@ void plotPurities(){ // } // if (h2->GetBinContent(1)GetBinContent(1) && histNames[k]!="z_purity") { // // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetMarkerStyle(71); - // if (histNames[k]=="z_pT_Res") h2->SetMarkerStyle(73); - // if (histNames[k]=="z_phiH_Res") h2->SetMarkerStyle(77); + // if (histNames[k]=="z_z_Res") h2->SetMarkerStyle(24); + // if (histNames[k]=="z_pT_Res") h2->SetMarkerStyle(26); + // if (histNames[k]=="z_phiH_Res") h2->SetMarkerStyle(32); // // std::cout<<"\th2: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(4); // h2->SetMarkerSize(1); @@ -369,9 +369,9 @@ void plotPurities(){ // } // // // else { // // // std::cout<<"\tbin content: "<GetBinContent(1)<<" nbins: "<GetNbinsX()<SetMarkerStyle(71); - // // if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(73); - // // if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(77); + // // if (histNames[k]=="z_z_Res") h3->SetMarkerStyle(24); + // // if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(26); + // // if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(32); // // if (histNames[k]=="z_purity") h3->SetMarkerStyle(21); // // // std::cout<<"\th3: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(2); @@ -422,7 +422,7 @@ void plotPurities(){ switch(1) {//TODO: figure out how to get THStack dimension? //can't use hist->GetHistogram()->GetDimension() case 1: if (i==0) drawStr = "nostack p"; //NOTE: nostackb will just throw an error, don't use. /*"ex0 p nostack"*/ - else drawStr = "nostack p a"; + else if (nbinsz==1) drawStr = "nostack p a"; break; case 2: drawStr = "COLZ"; @@ -437,7 +437,7 @@ void plotPurities(){ hist->GetHistogram()->GetYaxis()->SetNdivisions(10); if (nbinsz==1) hist->GetHistogram()->GetXaxis()->SetNdivisions(0); hist->GetHistogram()->GetYaxis()->SetLabelSize(0.09); - mainpad->SetGrid(0,10); + // mainpad->SetGrid(0,0); // if (i!=0) { // for (int idx=0; idx<5; idx++){ // TF1 *f5 = new TF1("f5","0.2",hist->GetXaxis()->GetXmin(),hist->GetXaxis()->GetXmax()); diff --git a/src/Analysis.cxx b/src/Analysis.cxx index 676cd850..9f39b57f 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -326,8 +326,8 @@ void Analysis::Prepare() { HS->DefineHist2D("z_y_Res","z","","#sigma_{y}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); HS->DefineHist2D("z_z_Res","z","","#sigma_{z}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); HS->DefineHist2D("z_pT_Res","z","","#sigma_{pT}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); - HS->DefineHist2D("z_phiH_Res","z","","#sigma_{#phi_{h}^{true}}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); - HS->DefineHist2D("z_phiS_Res","z","","#sigma_{#phi_{S}^{true}}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); + HS->DefineHist2D("z_phiH_Res","z","","#sigma_{#phi_{h}^{true}}","", NBINS, 0, 1, NBINSRES, -TMath::Pi(), TMath::Pi()); + HS->DefineHist2D("z_phiS_Res","z","","#sigma_{#phi_{S}^{true}}","", NBINS, 0, 1, NBINSRES, -TMath::Pi(), TMath::Pi(); // 1D z-binned purity and efficiency HS->DefineHist1D("z_true","z","", NBINS, 0, 1); From cc924d11cebe9d3918808f86f68e2abeb9c80068 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Sat, 27 Nov 2021 14:58:42 -0500 Subject: [PATCH 38/51] Added new updates for cards --- cards | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cards b/cards index f9efe9d3..dde05fb3 160000 --- a/cards +++ b/cards @@ -1 +1 @@ -Subproject commit f9efe9d3ae3195e3058cb49019f117b28b7c2c9c +Subproject commit dde05fb31013bd20dc3a5038c28547f76037fd03 From 08deb5a86a8bc19f618d4e75e24f1521fb0dec83 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Sat, 27 Nov 2021 15:14:31 -0500 Subject: [PATCH 39/51] Updated cuts and default plots selected in macro/analysis_resolution.C --- macro/analysis_resolution.C | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/macro/analysis_resolution.C b/macro/analysis_resolution.C index 267b5501..86f79f68 100644 --- a/macro/analysis_resolution.C +++ b/macro/analysis_resolution.C @@ -24,15 +24,15 @@ void analysis_resolution( //A->maxEvents = 30000; // use this to limit the number of events A->SetReconMethod("Ele"); // set reconstruction method A->AddFinalState("pipTrack"); // pion final state - A->AddFinalState("pimTrack"); // pion final state - A->AddFinalState("KpTrack"); // pion final state - A->AddFinalState("KmTrack"); // pion final state - A->AddFinalState("pTrack"); // pion final state + // A->AddFinalState("pimTrack"); // pion final state + // A->AddFinalState("KpTrack"); // pion final state + // A->AddFinalState("KmTrack"); // pion final state + // A->AddFinalState("pTrack"); // pion final state // define cuts ==================================== A->AddBinScheme("w"); A->BinScheme("w")->BuildBin("Min",3.0); // W > 3 GeV A->AddBinScheme("y"); A->BinScheme("y")->BuildBin("Range",0.01,0.95); // 0.01 < y < 0.95 - A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,1); // 0.2 < z < 0.9 (originally) + A->AddBinScheme("z"); A->BinScheme("z")->BuildBin("Range",0.2,0.9); // 0.2 < z < 0.9 A->AddBinScheme("xF"); A->BinScheme("xF")->BuildBin("Min",0.0); // xF > 0 A->AddBinScheme("ptLab"); A->BinScheme("ptLab")->BuildBin("Min",0.1); // pT_lab > 0.1 GeV (tracking limit) From ce9413ebdd1c3affdc7b8a6864b5a6a569d6f37c Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Sat, 27 Nov 2021 15:14:59 -0500 Subject: [PATCH 40/51] Updated default plots selected --- macro/postprocess_resolution.C | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/macro/postprocess_resolution.C b/macro/postprocess_resolution.C index 2581f518..aff6f79b 100644 --- a/macro/postprocess_resolution.C +++ b/macro/postprocess_resolution.C @@ -52,7 +52,7 @@ void postprocess_resolution( // loop over resolution histograms (see ../src/Analysis.cxx `DefineHist*` calls // for available histograms, or add your own there) - for( TString histname : {"x_Res","y_Res","Q2_Res","phiH_Res","phiS_Res","phiHvsPhiS","z_purity"} ) { + for( TString histname : {"x_Res","y_Res","Q2_Res","phiH_Res","phiS_Res","phiHvsPhiS","z_purity","z_efficiency"} ) { P->DrawInBins( canvname, histos_xQ2, histname, "x", nx, xMin, xMax, true, @@ -62,8 +62,8 @@ void postprocess_resolution( const int nNames = 6; double yMin, yMax; yMin = -0.1; yMax = 0.5;//Adjust as needed - TString histNames[nNames] = {"z_Q2_Res","z_x_Res","z_y_Res","z_z_Res","z_pT_Res","z_purity"}; - TString labels[nNames] = {"Q^{2}","x","y","z","p_{T}","1-purity"}; + TString histNames[nNames] = {"z_z_Res","z_pT_Res","z_phiH_Res","z_purity","z_efficiency"}; + TString labels[nNames] = {"z","p_{T}","#phi_{H}","purity","efficiency"}; TString header="testheader"; P->DrawSDInBinsTogether( canvname, histos_xQ2, header, histNames, labels, nNames, yMin, yMax, From 923564b13dc527b70e23f015dedb7759e9e5ca96 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Sat, 27 Nov 2021 15:15:41 -0500 Subject: [PATCH 41/51] Fixed variable name typo for FillHistosEfficiency in Analysis.cxx --- src/Analysis.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Analysis.cxx b/src/Analysis.cxx index 60798035..24c4eb07 100644 --- a/src/Analysis.cxx +++ b/src/Analysis.cxx @@ -327,7 +327,7 @@ void Analysis::Prepare() { HS->DefineHist2D("z_z_Res","z","","#sigma_{z}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); HS->DefineHist2D("z_pT_Res","z","","#sigma_{pT}","", NBINS, 0, 1, NBINSRES, -0.5, 0.5); HS->DefineHist2D("z_phiH_Res","z","","#sigma_{#phi_{h}^{true}}","", NBINS, 0, 1, NBINSRES, -TMath::Pi(), TMath::Pi()); - HS->DefineHist2D("z_phiS_Res","z","","#sigma_{#phi_{S}^{true}}","", NBINS, 0, 1, NBINSRES, -TMath::Pi(), TMath::Pi(); + HS->DefineHist2D("z_phiS_Res","z","","#sigma_{#phi_{S}^{true}}","", NBINS, 0, 1, NBINSRES, -TMath::Pi(), TMath::Pi()); // 1D z-binned purity and efficiency HS->DefineHist1D("z_true","z","", NBINS, 0, 1); @@ -753,7 +753,7 @@ void Analysis::FillHistosEfficiency(bool noMatch, bool mcMatch) { if(!activeEvent) return; // fill histograms, for activated bins only - HD->Payload([this,truthMatch,mcMatch](Histos *H){ + HD->Payload([this,noMatch,mcMatch](Histos *H){ if (noMatch) H->Hist("z_trueMC")->Fill(kinTrue->z, wTrack ); if (mcMatch) H->Hist("z_efficiency")->Fill(kinTrue->z,wTrack); if (noMatch) H->Hist("x_trueMC")->Fill(kinTrue->x, wTrack ); From 038b4b25a92eaf2b1ace1aa1514f849daa88070c Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Sat, 27 Nov 2021 15:16:27 -0500 Subject: [PATCH 42/51] Added back in kvMC assignment which was missing from pulling main --- src/AnalysisDelphes.cxx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/AnalysisDelphes.cxx b/src/AnalysisDelphes.cxx index 9d4d7f8a..4ff88667 100644 --- a/src/AnalysisDelphes.cxx +++ b/src/AnalysisDelphes.cxx @@ -173,7 +173,12 @@ void AnalysisDelphes::Execute() { // final state cut // - check PID, to see if it's a final state we're interested in for // histograms; if not, proceed to next track + + // MC Truth PID int mcpid = trk->PID; //NOTE: trk->PID is currently not smeared so it just returns the truth-level PID + auto kvMC = PIDtoFinalState.find(mcpid); + + // Reconstructed PID pid = kin->getTrackPID( // get smeared PID trk, itpfRICHTrack, From 669f8ac790879b71c145d9f87567fcadda35910e Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Sat, 27 Nov 2021 15:17:48 -0500 Subject: [PATCH 43/51] Now PostProcessor.cxx also writes out fithists used for resolutions --- src/PostProcessor.cxx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/PostProcessor.cxx b/src/PostProcessor.cxx index d5bab03e..b2db7d0c 100644 --- a/src/PostProcessor.cxx +++ b/src/PostProcessor.cxx @@ -671,8 +671,7 @@ void PostProcessor::DrawSDInBinsTogether( for(int j = 0; j < nvar2; j++){ //Histos *H = (Histos*) infile->Get(histList[i][j]); Histos *H = histList[i][j]; - TString stackN; stackN.Form("stack__bin_%d_%d__",i,j); - THStack *hist = new THStack(stackN,stackN); + THStack *hist = new THStack(); TLegend *lg = new TLegend(0.05,0.05,0.95,0.95); lg->SetHeader(header,"C"); lg->SetTextSize(0.15); @@ -690,6 +689,10 @@ void PostProcessor::DrawSDInBinsTogether( TH2D *fitHist = (TH2D*)H->Hist(histNames[k])->Clone(); if ( fitHist->GetEntries() < 10 ) continue; //NOTE: Filter out low filled hists that can't get good fits. fitHist->SetTitle(""); + //DEBUGGING + TString fithistname; fithistname.Form("fithist_"+histNames[k]+"_bin_%d_%d",i,j); + fitHist->SetName(fithistname); fitHist->Write(); + //DEBUGGING subHist = this->GetSDs(fitHist); } From da7ca53ba5bbf092223c55aa3a544a3fe21384cb Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Sat, 27 Nov 2021 15:34:18 -0500 Subject: [PATCH 44/51] =?UTF-8?q?Quick=20(temporary)=20fix=20to=20select?= =?UTF-8?q?=20=C2=B1K,=20=C2=B1pi=20all=20in=20same=20final=20state=20bin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/AnalysisDelphes.cxx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/AnalysisDelphes.cxx b/src/AnalysisDelphes.cxx index 4ff88667..45df1d38 100644 --- a/src/AnalysisDelphes.cxx +++ b/src/AnalysisDelphes.cxx @@ -188,8 +188,9 @@ void AnalysisDelphes::Execute() { ); auto kv = PIDtoFinalState.find(pid); - if(kv!=PIDtoFinalState.end()) { finalStateID = kv->second; - if(activeFinalStates.find(finalStateID)!=activeFinalStates.end()) { + // if(kv!=PIDtoFinalState.end()) { finalStateID = kv->second; + // if(activeFinalStates.find(finalStateID)!=activeFinalStates.end()) { + if (true) { finalStateID = "pipTrack"; if (pid==321 || pid==-321 || pid==211 || pid==-211) { //DEBUGGING: This is just a temporary fix for not being able to select multiple final states in the same bin. // Get total # of final state particles correctly identified in reconstruction GenParticle *trkParticle = (GenParticle*)trk->Particle.GetObject(); @@ -231,17 +232,17 @@ void AnalysisDelphes::Execute() { wTrackTotal += wTrack; // Get total # of final state particles identified in selected final state - FillHistosPurity(true,false); + if (pid==321 || pid==-321) FillHistosPurity(true,false); // And number correctly identified mcpid = trkParticle->PID; - if (pid==mcpid) { + if ((pid==321 || pid==-321) && pid==mcpid) { FillHistosPurity(false,true); FillHistosEfficiency(true,true); } // fill track histograms in activated bins - FillHistosTracks(); + if (pid==211 || pid==-211) FillHistosTracks(); // fill simple tree // - not binned @@ -255,8 +256,9 @@ void AnalysisDelphes::Execute() { } // if(kv!=PIDtoFinalState.end()) } // if(activeFinalStates.find(finalStateID)!=activeFinalStates.end()) if (pid!=mcpid) { - if(kvMC!=PIDtoFinalState.end()) { finalStateID = kv->second; - if(activeFinalStates.find(finalStateID)!=activeFinalStates.end()) { + // if(kvMC!=PIDtoFinalState.end()) { finalStateID = kv->second; + // if(activeFinalStates.find(finalStateID)!=activeFinalStates.end()) { + if (true) { finalStateID = "pipTrack"; if (mcpid==321 || mcpid==-321 || mcpid==211 || mcpid==-211) { // calculate hadron kinematics GenParticle* trkPart = (GenParticle*)trk->Particle.GetObject(); @@ -281,7 +283,7 @@ void AnalysisDelphes::Execute() { wTrackTotal += wTrack; // Get total # of final state particles identified in selected final state - FillHistosEfficiency(true,false); + if (mcpid==321 || mcpid==-321) FillHistosEfficiency(true,false); //NOTE: DEBUGGING For now just quick fix since can't combine multiple final states in a bin. // fill simple tree // - not binned From 920e0c8f38f6e882dd9155e96835733b60953c63 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Sat, 27 Nov 2021 15:42:01 -0500 Subject: [PATCH 45/51] Updated upper q2 limit in macro/analysis_resolution.C --- macro/analysis_resolution.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macro/analysis_resolution.C b/macro/analysis_resolution.C index 86f79f68..aa408eb1 100644 --- a/macro/analysis_resolution.C +++ b/macro/analysis_resolution.C @@ -37,7 +37,7 @@ void analysis_resolution( A->AddBinScheme("ptLab"); A->BinScheme("ptLab")->BuildBin("Min",0.1); // pT_lab > 0.1 GeV (tracking limit) // set binning scheme ==================================== - A->AddBinScheme("q2"); A->BinScheme("q2")->BuildBins( 4, 1, 100, true ); + A->AddBinScheme("q2"); A->BinScheme("q2")->BuildBins( 4, 1, 1000, true ); A->AddBinScheme("x"); A->BinScheme("x")->BuildBins( 6, 0.01, 1, true ); // perform the analysis ================================== From 1a51a6bb850d74cc84e3eaa6894600632f6f860d Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Sat, 27 Nov 2021 18:46:33 -0500 Subject: [PATCH 46/51] Git pulled cards submodule --- cards | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cards b/cards index dde05fb3..f9efe9d3 160000 --- a/cards +++ b/cards @@ -1 +1 @@ -Subproject commit dde05fb31013bd20dc3a5038c28547f76037fd03 +Subproject commit f9efe9d3ae3195e3058cb49019f117b28b7c2c9c From 5f3102b1d624ad6f2142bffd7a27baf4799955d2 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Sat, 27 Nov 2021 20:08:19 -0500 Subject: [PATCH 47/51] Reverted to old getPID() method for now --- src/AnalysisDelphes.cxx | 87 +++++++++++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 13 deletions(-) diff --git a/src/AnalysisDelphes.cxx b/src/AnalysisDelphes.cxx index 45df1d38..915861ac 100644 --- a/src/AnalysisDelphes.cxx +++ b/src/AnalysisDelphes.cxx @@ -26,6 +26,49 @@ AnalysisDelphes::AnalysisDelphes( /* ... none defined yet ... */ }; +// Borrowed this method from `Kinematics.cxx` +// get PID information from PID systems tracks +int getPID(Track *track, TObjArrayIter itParticle, + TObjArrayIter itmRICHTrack, TObjArrayIter itbarrelDIRCTrack, TObjArrayIter itdualRICHagTrack, TObjArrayIter itdualRICHcfTrack){ + itParticle.Reset(); + itmRICHTrack.Reset(); + itbarrelDIRCTrack.Reset(); + itdualRICHagTrack.Reset(); + itdualRICHcfTrack.Reset(); + GenParticle *trackParticle = (GenParticle*)track->Particle.GetObject(); + GenParticle *detectorParticle; + int pidOut = -1; + while(Track *detectorTrack = (Track*)itmRICHTrack() ){ + if ((detectorTrack->Eta < -3.5) || (-1.0 < detectorTrack->Eta)) continue; + detectorParticle = (GenParticle*)detectorTrack->Particle.GetObject(); + if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; + } + itParticle.Reset(); + while(Track *detectorTrack = (Track*)itbarrelDIRCTrack() ){ + if ((detectorTrack->Eta < -1.0) || (1.0 < detectorTrack->Eta)) continue; + detectorParticle = (GenParticle*)detectorTrack->Particle.GetObject(); + if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; + } + itParticle.Reset(); + Double_t ag_p_threshold = 12.0; + while(Track *detectorTrack = (Track*)itdualRICHagTrack() ){ + Double_t p_track = detectorTrack->P4().Vect().Mag(); + if (!((1.0 <= track->Eta) && (track->Eta <= 3.5)) || p_track>=ag_p_threshold) continue; + detectorParticle = (GenParticle*)detectorTrack->Particle.GetObject(); + if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; + } + while(Track *detectorTrack = (Track*)itdualRICHcfTrack() ){ + Double_t p_track = detectorTrack->P4().Vect().Mag(); + if (!((1.0 <= track->Eta) && (track->Eta <= 3.5)) || p_trackParticle.GetObject(); + if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; + } + + + return pidOut; +} + + //============================================= // perform the analysis //============================================= @@ -48,7 +91,23 @@ void AnalysisDelphes::Execute() { // calculate cross section if(maxEvents>0) ENT = maxEvents; // limiter - // branch iterators + // // branch iterators (NEW) + // TObjArrayIter itTrack(tr->UseBranch("Track")); + // TObjArrayIter itElectron(tr->UseBranch("Electron")); + // TObjArrayIter itParticle(tr->UseBranch("Particle")); + // TObjArrayIter itEFlowTrack(tr->UseBranch("EFlowTrack")); + // TObjArrayIter itEFlowPhoton(tr->UseBranch("EFlowPhoton")); + // TObjArrayIter itEFlowNeutralHadron(tr->UseBranch("EFlowNeutralHadron")); + // TObjArrayIter itPIDSystemsTrack(tr->UseBranch("PIDSystemsTrack")); + // TObjArrayIter itpfRICHTrack(tr->UseBranch("pfRICHTrack")); + // TObjArrayIter itDIRCepidTrack(tr->UseBranch("barrelDIRC_epidTrack")); + // TObjArrayIter itDIRChpidTrack(tr->UseBranch("barrelDIRC_hpidTrack")); + // TObjArrayIter itBTOFepidTrack(tr->UseBranch("BTOF_eTrack")); + // TObjArrayIter itBTOFhpidTrack(tr->UseBranch("BTOF_hTrack")); + // TObjArrayIter itdualRICHagTrack(tr->UseBranch("dualRICHagTrack")); + // TObjArrayIter itdualRICHcfTrack(tr->UseBranch("dualRICHcfTrack")); + + // branch iterators (OLD) TObjArrayIter itTrack(tr->UseBranch("Track")); TObjArrayIter itElectron(tr->UseBranch("Electron")); TObjArrayIter itParticle(tr->UseBranch("Particle")); @@ -56,11 +115,8 @@ void AnalysisDelphes::Execute() { TObjArrayIter itEFlowPhoton(tr->UseBranch("EFlowPhoton")); TObjArrayIter itEFlowNeutralHadron(tr->UseBranch("EFlowNeutralHadron")); TObjArrayIter itPIDSystemsTrack(tr->UseBranch("PIDSystemsTrack")); - TObjArrayIter itpfRICHTrack(tr->UseBranch("pfRICHTrack")); - TObjArrayIter itDIRCepidTrack(tr->UseBranch("barrelDIRC_epidTrack")); - TObjArrayIter itDIRChpidTrack(tr->UseBranch("barrelDIRC_hpidTrack")); - TObjArrayIter itBTOFepidTrack(tr->UseBranch("BTOF_eTrack")); - TObjArrayIter itBTOFhpidTrack(tr->UseBranch("BTOF_hTrack")); + TObjArrayIter itmRICHTrack(tr->UseBranch("mRICHTrack"));//TODO: Change to eRICHTrack or pfRICHTrack ? + TObjArrayIter itbarrelDIRCTrack(tr->UseBranch("barrelDIRCTrack")); TObjArrayIter itdualRICHagTrack(tr->UseBranch("dualRICHagTrack")); TObjArrayIter itdualRICHcfTrack(tr->UseBranch("dualRICHcfTrack")); @@ -179,13 +235,18 @@ void AnalysisDelphes::Execute() { auto kvMC = PIDtoFinalState.find(mcpid); // Reconstructed PID - pid = kin->getTrackPID( // get smeared PID - trk, - itpfRICHTrack, - itDIRCepidTrack, itDIRChpidTrack, - itBTOFepidTrack, itBTOFhpidTrack, - itdualRICHagTrack, itdualRICHcfTrack - ); + pid = getPID( + trk, itParticle, + itmRICHTrack, itbarrelDIRCTrack, + itdualRICHagTrack, itdualRICHcfTrack + ); + // pid = kin->getTrackPID( // get smeared PID + // trk, + // itpfRICHTrack, + // itDIRCepidTrack, itDIRChpidTrack, + // itBTOFepidTrack, itBTOFhpidTrack, + // itdualRICHagTrack, itdualRICHcfTrack + // ); auto kv = PIDtoFinalState.find(pid); // if(kv!=PIDtoFinalState.end()) { finalStateID = kv->second; From 5f7eb9c599070bfb45db0cf6528c5a190e9a4743 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Sat, 27 Nov 2021 20:10:55 -0500 Subject: [PATCH 48/51] Reverted back --- src/AnalysisDelphes.cxx | 87 ++++++----------------------------------- 1 file changed, 13 insertions(+), 74 deletions(-) diff --git a/src/AnalysisDelphes.cxx b/src/AnalysisDelphes.cxx index 915861ac..c6d822a9 100644 --- a/src/AnalysisDelphes.cxx +++ b/src/AnalysisDelphes.cxx @@ -26,49 +26,6 @@ AnalysisDelphes::AnalysisDelphes( /* ... none defined yet ... */ }; -// Borrowed this method from `Kinematics.cxx` -// get PID information from PID systems tracks -int getPID(Track *track, TObjArrayIter itParticle, - TObjArrayIter itmRICHTrack, TObjArrayIter itbarrelDIRCTrack, TObjArrayIter itdualRICHagTrack, TObjArrayIter itdualRICHcfTrack){ - itParticle.Reset(); - itmRICHTrack.Reset(); - itbarrelDIRCTrack.Reset(); - itdualRICHagTrack.Reset(); - itdualRICHcfTrack.Reset(); - GenParticle *trackParticle = (GenParticle*)track->Particle.GetObject(); - GenParticle *detectorParticle; - int pidOut = -1; - while(Track *detectorTrack = (Track*)itmRICHTrack() ){ - if ((detectorTrack->Eta < -3.5) || (-1.0 < detectorTrack->Eta)) continue; - detectorParticle = (GenParticle*)detectorTrack->Particle.GetObject(); - if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; - } - itParticle.Reset(); - while(Track *detectorTrack = (Track*)itbarrelDIRCTrack() ){ - if ((detectorTrack->Eta < -1.0) || (1.0 < detectorTrack->Eta)) continue; - detectorParticle = (GenParticle*)detectorTrack->Particle.GetObject(); - if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; - } - itParticle.Reset(); - Double_t ag_p_threshold = 12.0; - while(Track *detectorTrack = (Track*)itdualRICHagTrack() ){ - Double_t p_track = detectorTrack->P4().Vect().Mag(); - if (!((1.0 <= track->Eta) && (track->Eta <= 3.5)) || p_track>=ag_p_threshold) continue; - detectorParticle = (GenParticle*)detectorTrack->Particle.GetObject(); - if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; - } - while(Track *detectorTrack = (Track*)itdualRICHcfTrack() ){ - Double_t p_track = detectorTrack->P4().Vect().Mag(); - if (!((1.0 <= track->Eta) && (track->Eta <= 3.5)) || p_trackParticle.GetObject(); - if( detectorParticle == trackParticle ) pidOut = detectorTrack->PID; - } - - - return pidOut; -} - - //============================================= // perform the analysis //============================================= @@ -91,23 +48,7 @@ void AnalysisDelphes::Execute() { // calculate cross section if(maxEvents>0) ENT = maxEvents; // limiter - // // branch iterators (NEW) - // TObjArrayIter itTrack(tr->UseBranch("Track")); - // TObjArrayIter itElectron(tr->UseBranch("Electron")); - // TObjArrayIter itParticle(tr->UseBranch("Particle")); - // TObjArrayIter itEFlowTrack(tr->UseBranch("EFlowTrack")); - // TObjArrayIter itEFlowPhoton(tr->UseBranch("EFlowPhoton")); - // TObjArrayIter itEFlowNeutralHadron(tr->UseBranch("EFlowNeutralHadron")); - // TObjArrayIter itPIDSystemsTrack(tr->UseBranch("PIDSystemsTrack")); - // TObjArrayIter itpfRICHTrack(tr->UseBranch("pfRICHTrack")); - // TObjArrayIter itDIRCepidTrack(tr->UseBranch("barrelDIRC_epidTrack")); - // TObjArrayIter itDIRChpidTrack(tr->UseBranch("barrelDIRC_hpidTrack")); - // TObjArrayIter itBTOFepidTrack(tr->UseBranch("BTOF_eTrack")); - // TObjArrayIter itBTOFhpidTrack(tr->UseBranch("BTOF_hTrack")); - // TObjArrayIter itdualRICHagTrack(tr->UseBranch("dualRICHagTrack")); - // TObjArrayIter itdualRICHcfTrack(tr->UseBranch("dualRICHcfTrack")); - - // branch iterators (OLD) + // branch iterators (NEW) TObjArrayIter itTrack(tr->UseBranch("Track")); TObjArrayIter itElectron(tr->UseBranch("Electron")); TObjArrayIter itParticle(tr->UseBranch("Particle")); @@ -115,8 +56,11 @@ void AnalysisDelphes::Execute() { TObjArrayIter itEFlowPhoton(tr->UseBranch("EFlowPhoton")); TObjArrayIter itEFlowNeutralHadron(tr->UseBranch("EFlowNeutralHadron")); TObjArrayIter itPIDSystemsTrack(tr->UseBranch("PIDSystemsTrack")); - TObjArrayIter itmRICHTrack(tr->UseBranch("mRICHTrack"));//TODO: Change to eRICHTrack or pfRICHTrack ? - TObjArrayIter itbarrelDIRCTrack(tr->UseBranch("barrelDIRCTrack")); + TObjArrayIter itpfRICHTrack(tr->UseBranch("pfRICHTrack")); + TObjArrayIter itDIRCepidTrack(tr->UseBranch("barrelDIRC_epidTrack")); + TObjArrayIter itDIRChpidTrack(tr->UseBranch("barrelDIRC_hpidTrack")); + TObjArrayIter itBTOFepidTrack(tr->UseBranch("BTOF_eTrack")); + TObjArrayIter itBTOFhpidTrack(tr->UseBranch("BTOF_hTrack")); TObjArrayIter itdualRICHagTrack(tr->UseBranch("dualRICHagTrack")); TObjArrayIter itdualRICHcfTrack(tr->UseBranch("dualRICHcfTrack")); @@ -235,18 +179,13 @@ void AnalysisDelphes::Execute() { auto kvMC = PIDtoFinalState.find(mcpid); // Reconstructed PID - pid = getPID( - trk, itParticle, - itmRICHTrack, itbarrelDIRCTrack, - itdualRICHagTrack, itdualRICHcfTrack - ); - // pid = kin->getTrackPID( // get smeared PID - // trk, - // itpfRICHTrack, - // itDIRCepidTrack, itDIRChpidTrack, - // itBTOFepidTrack, itBTOFhpidTrack, - // itdualRICHagTrack, itdualRICHcfTrack - // ); + pid = kin->getTrackPID( // get smeared PID + trk, + itpfRICHTrack, + itDIRCepidTrack, itDIRChpidTrack, + itBTOFepidTrack, itBTOFhpidTrack, + itdualRICHagTrack, itdualRICHcfTrack + ); auto kv = PIDtoFinalState.find(pid); // if(kv!=PIDtoFinalState.end()) { finalStateID = kv->second; From 5af1671a4f0d401e52b78025bccb932b91438118 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Sat, 27 Nov 2021 22:54:57 -0500 Subject: [PATCH 49/51] Updated default paths for job scripts --- job.sh | 2 +- submit.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/job.sh b/job.sh index 4b6c8fe0..3d0fcd0f 100755 --- a/job.sh +++ b/job.sh @@ -1,6 +1,6 @@ #!/bin/bash -cd /work/clas12/users/$USER/eic/largex-eic +cd /work/clas12/users/$USER/eic3/largex-eic echo "root -q -b macro/dis-5x41/analysis_resolution.C" | ./container/shell.sh echo "root -q -b macro/dis-5x41/postprocess_resolution.C" | ./container/shell.sh echo DONE diff --git a/submit.sh b/submit.sh index 9e7422ae..78cecc0e 100755 --- a/submit.sh +++ b/submit.sh @@ -10,4 +10,4 @@ #SBATCH --time=24:00:00 ##SBATCH --mail-user=$USER@jlab.org -/work/clas12/users/$USER/eic/largex-eic/macro/dis-5x41/job.sh +/work/clas12/users/$USER/eic3/largex-eic/macro/dis-5x41/job.sh From 1202fb090be8ee9a560a59950e1be214bb92a9aa Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Sat, 27 Nov 2021 23:50:47 -0500 Subject: [PATCH 50/51] Updated default axes limits and fixed typo with array length in macro/postprocess_resolution.C --- macro/postprocess_resolution.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/macro/postprocess_resolution.C b/macro/postprocess_resolution.C index aff6f79b..001d37b4 100644 --- a/macro/postprocess_resolution.C +++ b/macro/postprocess_resolution.C @@ -60,8 +60,8 @@ void postprocess_resolution( ); }; - const int nNames = 6; - double yMin, yMax; yMin = -0.1; yMax = 0.5;//Adjust as needed + const int nNames = 5; + double yMin, yMax; yMin = -0.1; yMax = 1.0;//Adjust as needed TString histNames[nNames] = {"z_z_Res","z_pT_Res","z_phiH_Res","z_purity","z_efficiency"}; TString labels[nNames] = {"z","p_{T}","#phi_{H}","purity","efficiency"}; TString header="testheader"; From 50fdba0abec7060e872fd11a2a8410773ae0bbb8 Mon Sep 17 00:00:00 2001 From: Matthew McEneaney Date: Wed, 1 Dec 2021 09:46:57 -0500 Subject: [PATCH 51/51] Changed file names in plotPurities.C --- macro/plotPurities.C | 57 +++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/macro/plotPurities.C b/macro/plotPurities.C index 1f678311..7bc48df9 100644 --- a/macro/plotPurities.C +++ b/macro/plotPurities.C @@ -4,9 +4,13 @@ void plotPurities(){ // Get purity and efficiency plots from different methods output files // And plot together - TString p1 = "out/1bin/JB_dis-18x275-xm25.canvas.root"; - TString p2 = "out/1bin/DA_dis-18x275-xm25.canvas.root"; - TString p3 = "out/1bin/Ele_dis-18x275-xm25.canvas.root"; + // TString p1 = "out/1bin/JB_dis-18x275-xm25.canvas.root"; + // TString p2 = "out/1bin/DA_dis-18x275-xm25.canvas.root"; + // TString p3 = "out/1bin/Ele_dis-18x275-xm25.canvas.root"; + + TString p1 = "out/JB_dis-10x275-xm25.canvas.root"; + TString p2 = "out/DA_dis-10x275-xm25.canvas.root"; + TString p3 = "out/Ele_dis-10x275-xm25.canvas.root"; TFile *f1 = TFile::Open(p1); TFile *f2 = TFile::Open(p2); @@ -18,11 +22,13 @@ void plotPurities(){ double xMin = 1e-2; double xMax = 1; double qMin = 1; double qMax = 1000; - TString outName = "dis-18x275-xm25"; + TString outName = "dis-10x275-xm25"; + // TString outName = "dis-18x275-xm25"; const int nNames = 5; - TString histNames[nNames] = {"z_efficiency","z_purity","z_phiH_Res","z_pT_Res","z_z_Res"}; - TString labels[nNames] = {"K^{#pm} efficiency","K^{#pm} purity","#phi_{H}","p_{T}","z"}; - TString header = "18x275GeV (0.2 < z < 1.0)"; + TString histNames[nNames] = {"z_efficiency","z_purity","z_phiH_Res","z_pT_Res","z_z_Res"};//,"z_phiH_Res", + TString labels[nNames] = {"K^{#pm} efficiency","K^{#pm} purity","#phi_{H}","p_{T}","z"};//"#phi_{H}", + TString header = "10x275GeV (0.2 < z < 1.0)"; + // TString header = "18x275GeV (0.2 < z < 1.0)"; double yMin = -0.1; double yMax=1.0; int nbinsz = 1; //Set manually...NOTE TODO @@ -132,7 +138,7 @@ void plotPurities(){ h1->SetMarkerSize(1); h1->GetYaxis()->SetRangeUser(-0.05,1); hist->Add(h1); - if ( ((i==4 && j==1) || (i==5 && j==2)) && ((histNames[k]=="z_z_Res" && !jbz) || (histNames[k]=="z_pT_Res" && !jbpt) || (histNames[k]=="z_phiH_Res" && !jbphi)) ) {//TODO: Find where these actually pop up + if ( /*((i==4 && j==1) || (i==5 && j==2)) &&*/ ((histNames[k]=="z_z_Res" && !jbz) || (histNames[k]=="z_pT_Res" && !jbpt) || (histNames[k]=="z_phiH_Res" && !jbphi)) ) {//TODO: Find where these actually pop up if (histNames[k]=="z_z_Res") jbz=true; if (histNames[k]=="z_pT_Res") jbpt=true; @@ -168,7 +174,7 @@ void plotPurities(){ if (histNames[k]=="z_z_Res") h3->SetMarkerStyle(24); if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(26); if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(32); - if (histNames[k]=="z_purity") h3->SetMarkerStyle(21); + if (histNames[k]=="z_purity") h3->SetMarkerStyle(25); if (histNames[k]=="z_efficiency") h3->SetMarkerStyle(34); // std::cout<<"\th3: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(2); if (histNames[k]=="z_purity") h3->SetMarkerColor(8); @@ -180,11 +186,12 @@ void plotPurities(){ if (histNames[k]=="z_z_Res") elez=true; if (histNames[k]=="z_pT_Res") elept=true; if (histNames[k]=="z_phiH_Res") elephi=true; - if (histNames[k]=="z_purity") purity=true; - if (histNames[k]=="z_efficiency") efficiency=true; + // if (histNames[k]=="z_purity") purity=true; + // if (histNames[k]=="z_efficiency") efficiency=true; std::cout<<"ADDING ENTRY "<AddEntry(h3,"Ele "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin - else lg->AddEntry(h3,labels[k],"p"); + else if (!purity && histNames[k]=="z_purity") lg->AddEntry(h3,labels[k],"p"); if (histNames[k]=="z_purity") purity=true; + else if (!efficiency && histNames[k]=="z_efficiency") lg->AddEntry(h3,labels[k],"p"); if (histNames[k]=="z_efficiency") efficiency=true; // } } }// if (h1!=nullptr && h2!=nullptr) @@ -238,7 +245,7 @@ void plotPurities(){ if (histNames[k]=="z_z_Res") h3->SetMarkerStyle(24); if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(26); if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(32); - if (histNames[k]=="z_purity") h3->SetMarkerStyle(21); + if (histNames[k]=="z_purity") h3->SetMarkerStyle(25); // std::cout<<"\th3: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(2); if (histNames[k]=="z_purity") h3->SetMarkerColor(8); if (histNames[k]=="z_efficiency") h3->SetMarkerColor(9); @@ -249,11 +256,12 @@ void plotPurities(){ if (histNames[k]=="z_z_Res") elez=true; if (histNames[k]=="z_pT_Res") elept=true; if (histNames[k]=="z_phiH_Res") elephi=true; - if (histNames[k]=="z_purity") purity=true; - if (histNames[k]=="z_efficiency") efficiency=true; + // if (histNames[k]=="z_purity") purity=true; + // if (histNames[k]=="z_efficiency") efficiency=true; std::cout<<"ADDING ENTRY "<AddEntry(h3,"Ele "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin - else lg->AddEntry(h3,labels[k],"p"); + else if (!purity && histNames[k]=="z_purity") lg->AddEntry(h3,labels[k],"p"); if (histNames[k]=="z_purity") purity=true; + else if (!efficiency && histNames[k]=="z_efficiency") lg->AddEntry(h3,labels[k],"p"); if (histNames[k]=="z_efficiency") efficiency=true; // } } }// if (h2!=nullptr && h3!=nullptr) @@ -272,7 +280,7 @@ void plotPurities(){ h1->SetMarkerSize(1); h1->GetYaxis()->SetRangeUser(-0.05,1); hist->Add(h1); - if ( ((i==4 && j==1) || (i==5 && j==2)) && ((histNames[k]=="z_z_Res" && !jbz) || (histNames[k]=="z_pT_Res" && !jbpt) || (histNames[k]=="z_phiH_Res" && !jbphi)) ) {//TODO: Find where these actually pop up + if ( /*((i==4 && j==1) || (i==5 && j==2)) &&*/ ((histNames[k]=="z_z_Res" && !jbz) || (histNames[k]=="z_pT_Res" && !jbpt) || (histNames[k]=="z_phiH_Res" && !jbphi)) ) {//TODO: Find where these actually pop up if (histNames[k]=="z_z_Res") jbz=true; if (histNames[k]=="z_pT_Res") jbpt=true; @@ -307,20 +315,21 @@ void plotPurities(){ if (histNames[k]=="z_z_Res") h3->SetMarkerStyle(24); if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(26); if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(32); - if (histNames[k]=="z_purity") h3->SetMarkerStyle(21); + if (histNames[k]=="z_purity") h3->SetMarkerStyle(25); // std::cout<<"\th3: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(2); if (histNames[k]=="z_purity") h3->SetMarkerColor(8); if (histNames[k]=="z_efficiency") h3->SetMarkerColor(8); h3->SetMarkerSize(1); h3->GetYaxis()->SetRangeUser(-0.05,1); hist->Add(h3); - if ((histNames[k]=="z_z_Res" && !elez) || (histNames[k]=="z_pT_Res" && !elept) || (histNames[k]=="z_phiH_Res" && !elephi) || !purity){//TODO: Find where these actually pop up + if ((histNames[k]=="z_z_Res" && !elez) || (histNames[k]=="z_pT_Res" && !elept) || (histNames[k]=="z_phiH_Res" && !elephi) || !purity || !efficiency){//TODO: Find where these actually pop up if (histNames[k]=="z_z_Res") elez=true; if (histNames[k]=="z_pT_Res") elept=true; if (histNames[k]=="z_phiH_Res") elephi=true; - if (histNames[k]=="z_purity") purity=true; + std::cout<<"ADDING ENTRY "<AddEntry(h3,"Ele "+labels[k],"p");//NOTE: Only grabs hists that are in 0,0 bin - else lg->AddEntry(h3,labels[k],"p"); + else if (!purity && histNames[k]=="z_purity") lg->AddEntry(h3,labels[k],"p"); if (histNames[k]=="z_purity") purity=true; + else if (!efficiency && histNames[k]=="z_efficiency") lg->AddEntry(h3,labels[k],"p"); if (histNames[k]=="z_efficiency") efficiency=true; // } } }// if (h1!=nullptr && h3!=nullptr) @@ -372,7 +381,7 @@ void plotPurities(){ // // if (histNames[k]=="z_z_Res") h3->SetMarkerStyle(24); // // if (histNames[k]=="z_pT_Res") h3->SetMarkerStyle(26); // // if (histNames[k]=="z_phiH_Res") h3->SetMarkerStyle(32); - // // if (histNames[k]=="z_purity") h3->SetMarkerStyle(21); + // // if (histNames[k]=="z_purity") h3->SetMarkerStyle(25); // // // std::cout<<"\th3: marker style, color: "<GetMarkerStyle()<<" "<GetMarkerColor()<SetMarkerColor(2); // // h3->SetMarkerSize(1); @@ -421,8 +430,8 @@ void plotPurities(){ TString drawStr = ""; switch(1) {//TODO: figure out how to get THStack dimension? //can't use hist->GetHistogram()->GetDimension() case 1: - if (i==0) drawStr = "nostack p"; //NOTE: nostackb will just throw an error, don't use. /*"ex0 p nostack"*/ - else if (nbinsz==1) drawStr = "nostack p a"; + if (i==0 || nbinsz!=1) drawStr = "nostack p"; //NOTE: nostackb will just throw an error, don't use. /*"ex0 p nostack"*/ + else drawStr = "nostack p a"; break; case 2: drawStr = "COLZ";