From 73b32206c32bd69a46616a5fb07d0a07c2599ee3 Mon Sep 17 00:00:00 2001 From: cholm Date: Tue, 18 Dec 2012 09:58:14 +0000 Subject: [PATCH] Coverity fixes etc. --- .../analysis2/AliFMDCorrAcceptance.cxx | 2 + .../FORWARD/analysis2/AliFMDEventInspector.h | 4 +- .../analysis2/AliFMDMCEventInspector.cxx | 60 +- .../analysis2/AliFMDMCEventInspector.h | 17 +- .../AliForwardCreateResponseMatrices.cxx | 23 +- .../AliForwardMCMultiplicityTask.cxx | 2 +- .../AliForwardMultiplicityDistribution.cxx | 12 +- PWGLF/FORWARD/analysis2/DrawAODSummary.C | 1276 +---------------- PWGLF/FORWARD/analysis2/DrawdNdeta.C | 152 +- PWGLF/FORWARD/analysis2/DrawdNdetaSummary.C | 21 +- PWGLF/FORWARD/analysis2/gridAnalysis.sh | 18 +- .../analysis2/trains/MakedNdetaTrain.C | 14 +- PWGLF/FORWARD/trains/ChainBuilder.C | 8 +- PWGLF/FORWARD/trains/Helper.C | 6 +- PWGLF/FORWARD/trains/TrainSetup.C | 38 +- PWGLF/FORWARD/trains/trainMain.cxx | 55 +- 16 files changed, 332 insertions(+), 1376 deletions(-) diff --git a/PWGLF/FORWARD/analysis2/AliFMDCorrAcceptance.cxx b/PWGLF/FORWARD/analysis2/AliFMDCorrAcceptance.cxx index 373e88b779a..fbf0feae242 100644 --- a/PWGLF/FORWARD/analysis2/AliFMDCorrAcceptance.cxx +++ b/PWGLF/FORWARD/analysis2/AliFMDCorrAcceptance.cxx @@ -66,6 +66,8 @@ AliFMDCorrAcceptance::operator=(const AliFMDCorrAcceptance& o) // Return: // Reference to this object // + if (&o == this) return *this; + fRingArray = o.fRingArray; fCache = o.fCache; fHasOverflow = o.fHasOverflow; diff --git a/PWGLF/FORWARD/analysis2/AliFMDEventInspector.h b/PWGLF/FORWARD/analysis2/AliFMDEventInspector.h index 20e105272aa..0a743099dfe 100644 --- a/PWGLF/FORWARD/analysis2/AliFMDEventInspector.h +++ b/PWGLF/FORWARD/analysis2/AliFMDEventInspector.h @@ -473,8 +473,8 @@ protected: * * @return False on error, true otherwise */ - Bool_t ReadCentrality(const AliESDEvent& esd, Double_t& cent, - UShort_t& qual) const; + virtual Bool_t ReadCentrality(const AliESDEvent& esd, Double_t& cent, + UShort_t& qual) const; TH1I* fHEventsTr; //! Histogram of events w/trigger TH1I* fHEventsTrVtx; //! Events w/trigger and vertex diff --git a/PWGLF/FORWARD/analysis2/AliFMDMCEventInspector.cxx b/PWGLF/FORWARD/analysis2/AliFMDMCEventInspector.cxx index 02b4cc29a48..33a4df08681 100644 --- a/PWGLF/FORWARD/analysis2/AliFMDMCEventInspector.cxx +++ b/PWGLF/FORWARD/analysis2/AliFMDMCEventInspector.cxx @@ -44,12 +44,14 @@ AliFMDMCEventInspector::AliFMDMCEventInspector() fHVertex(0), fHPhiR(0), fHB(0), + fHMcC(0), fHBvsPart(0), fHBvsBin(0), fHBvsCent(0), fHVzComp(0), fHCentVsPart(0), fHCentVsBin(0), + fHCentVsMcC(0), fProduction("") { // @@ -63,12 +65,14 @@ AliFMDMCEventInspector::AliFMDMCEventInspector(const char* /* name */) fHVertex(0), fHPhiR(0), fHB(0), + fHMcC(0), fHBvsPart(0), fHBvsBin(0), fHBvsCent(0), fHVzComp(0), fHCentVsPart(0), fHCentVsBin(0), + fHCentVsMcC(0), fProduction("") { // @@ -85,12 +89,14 @@ AliFMDMCEventInspector::AliFMDMCEventInspector(const AliFMDMCEventInspector& o) fHVertex(0), fHPhiR(0), fHB(0), + fHMcC(0), fHBvsPart(0), fHBvsBin(0), fHBvsCent(0), fHVzComp(0), fHCentVsPart(0), fHCentVsBin(0), + fHCentVsMcC(0), fProduction("") { // @@ -168,6 +174,11 @@ AliFMDMCEventInspector::SetupForData(const TAxis& vtxAxis) fHB->SetDirectory(0); fList->Add(fHB); + fHMcC = static_cast(fHCent->Clone("mcC")); + fHMcC->SetFillColor(kCyan+2); + fHMcC->SetDirectory(0); + fList->Add(fHMcC); + fHBvsPart = new TH2F("bVsParticipants", "Impact parameter vs Participants", 5*maxB, 0, maxB, maxPart, -.5, maxPart-.5); fHBvsPart->SetXTitle("b [fm]"); @@ -221,11 +232,23 @@ AliFMDMCEventInspector::SetupForData(const TAxis& vtxAxis) fHCentVsBin->SetZTitle("Event"); fHCentVsBin->SetDirectory(0); fList->Add(fHCentVsBin); + + Int_t nC = fHCent->GetNbinsX(); + Double_t cL = fHCent->GetXaxis()->GetXmin(); + Double_t cH = fHCent->GetXaxis()->GetXmax(); + fHCentVsMcC = new TH2F("centralityRecoVsMC", + "Centrality from reconstruction vs MC derived", + nC, cL, cH, nC, cL, cH); + fHCentVsMcC->SetDirectory(0); + fHCentVsMcC->SetStats(0); + fHCentVsMcC->SetXTitle("Centralty from Reco [%]"); + fHCentVsMcC->SetYTitle("Centralty derived from Impact Par. [%]"); + fHCentVsMcC->SetZTitle("Events"); + fList->Add(fHCentVsMcC); } //____________________________________________________________________ -void -AliFMDMCEventInspector::StoreInformation(Int_t runNo) +void AliFMDMCEventInspector::StoreInformation(Int_t runNo) { // Store information about running conditions in the output list if (!fList) return; @@ -434,6 +457,7 @@ AliFMDMCEventInspector::ProcessMC(AliMCEvent* event, fHVertex->Fill(vz); fHPhiR->Fill(phiR); fHB->Fill(b); + fHMcC->Fill(c); fHBvsPart->Fill(b, npart); fHBvsBin->Fill(b, nbin); @@ -462,6 +486,32 @@ AliFMDMCEventInspector::ProcessMC(AliMCEvent* event, return kOk; } +//____________________________________________________________________ +Bool_t +AliFMDMCEventInspector::ReadCentrality(const AliESDEvent& esd, + Double_t& cent, + UShort_t& qual) const +{ + // + // Read centrality from event + // + // Parameters: + // esd Event + // cent On return, the centrality or negative if not found + // + // Return: + // False on error, true otherwise + // + Bool_t ret = AliFMDEventInspector::ReadCentrality(esd, cent, qual); + if (qual != 0) { + AliCentrality* centObj = const_cast(esd).GetCentrality(); + if (!centObj) return ret; + + // For MC, we allow `bad' centrality selections + cent = centObj->GetCentralityPercentileUnchecked(fCentMethod); + } + return ret; +} //____________________________________________________________________ namespace { @@ -565,16 +615,20 @@ AliFMDMCEventInspector::IsSingleDiffractive(AliStack* stack, //____________________________________________________________________ Bool_t AliFMDMCEventInspector::CompareResults(Double_t vz, Double_t trueVz, - Double_t cent, Double_t b, + Double_t cent, Double_t mcC, + Double_t b, Int_t npart, Int_t nbin) { fHVzComp->Fill(trueVz, vz); fHBvsCent->Fill(b, cent); fHCentVsPart->Fill(npart, cent); fHCentVsBin->Fill(nbin, cent); + fHCentVsMcC->Fill(cent, mcC); return true; } + + // // EOF // diff --git a/PWGLF/FORWARD/analysis2/AliFMDMCEventInspector.h b/PWGLF/FORWARD/analysis2/AliFMDMCEventInspector.h index a041a9128a7..ef31b58430c 100644 --- a/PWGLF/FORWARD/analysis2/AliFMDMCEventInspector.h +++ b/PWGLF/FORWARD/analysis2/AliFMDMCEventInspector.h @@ -110,6 +110,7 @@ public: * @param vz Found @f$ v_z@f$ * @param trueVz True @f$ v_z@f$ * @param cent Centrality + * @param mcC Centrality from Impact par. * @param b Impact parameter (if available) * @param npart Number of participants (if available) * @param nbin Number of binary collisions (if available) @@ -117,7 +118,8 @@ public: * @return true */ virtual Bool_t CompareResults(Double_t vz, Double_t trueVz, - Double_t cent, Double_t b, + Double_t cent, Double_t mcC, + Double_t b, Int_t npart, Int_t nbin); /** * Store information about running conditions in output list @@ -138,6 +140,17 @@ public: */ virtual void ReadProductionDetails(AliMCEvent* event); protected: + /** + * Read centrality from event + * + * @param esd Event + * @param cent On return, the centrality or negative if not found + * @param qual On return, centrality quality flag + * + * @return False on error, true otherwise + */ + virtual Bool_t ReadCentrality(const AliESDEvent& esd, Double_t& cent, + UShort_t& qual) const; /** * Check if the event is single diffractive * @@ -155,12 +168,14 @@ protected: TH1F* fHVertex; // Histogram of vertex TH1F* fHPhiR; // Histogram of event plane TH1F* fHB; // Histogram of impact parameter + TH1F* fHMcC; // Histogram of centrality derived from imp. par. TH2F* fHBvsPart; // Impact parameter vs # participants TH2F* fHBvsBin; // Impact parameter vs # participants TH2F* fHBvsCent; // Impact parameter vs centrality TH2F* fHVzComp; // True vs reconstructed vz TH2F* fHCentVsPart; // Centrality versus # participants TH2F* fHCentVsBin; // Centrality versus # binary collisions + TH2F* fHCentVsMcC; // Compare centralities TString fProduction; // Production information ClassDef(AliFMDMCEventInspector,4); // Inspect the event }; diff --git a/PWGLF/FORWARD/analysis2/AliForwardCreateResponseMatrices.cxx b/PWGLF/FORWARD/analysis2/AliForwardCreateResponseMatrices.cxx index 6f70e8291f8..e2c82fc8534 100644 --- a/PWGLF/FORWARD/analysis2/AliForwardCreateResponseMatrices.cxx +++ b/PWGLF/FORWARD/analysis2/AliForwardCreateResponseMatrices.cxx @@ -319,8 +319,16 @@ void AliForwardCreateResponseMatrices::Bin::CreateOutputObjectss(TList* cont, I //_____________________________________________________________________ -void AliForwardCreateResponseMatrices::Bin::Process(TH1D* dndetaForward, TH1D* dndetaCentral, - TH1D* normForward, TH1D* normCentral, TH1D* mc, Double_t VtxZ, Bool_t selectedTrigger, Bool_t isMCNSD, Bool_t isESDNSD, AliAODEvent* aodevent) +void AliForwardCreateResponseMatrices::Bin::Process(TH1D* dndetaForward, + TH1D* dndetaCentral, + TH1D* normForward, + TH1D* normCentral, + TH1D* mc, + Double_t VtxZ, + Bool_t selectedTrigger, + Bool_t isMCNSD, + Bool_t isESDNSD, + AliAODEvent* aodevent) { // // Process a single eta bin @@ -384,15 +392,18 @@ void AliForwardCreateResponseMatrices::Bin::Process(TH1D* dndetaForward, TH1D* d e2 += ee2; } - //retreive MC particles from event + // retreive MC particles from event TClonesArray* mcArray = (TClonesArray*)aodevent->FindListObject(AliAODMCParticle::StdBranchName()); if(!mcArray){ - AliWarning("No MC array found in AOD. Try making it again."); - // return kFALSE; + AliWarning("No MC array found in AOD. Try making it again."); + return; } - AliAODMCHeader* header = dynamic_cast(aodevent->FindListObject(AliAODMCHeader::StdBranchName())); + AliAODMCHeader* header = + dynamic_cast(aodevent-> + FindListObject(AliAODMCHeader::StdBranchName())); if (!header) { AliWarning("No header file found."); + return; } diff --git a/PWGLF/FORWARD/analysis2/AliForwardMCMultiplicityTask.cxx b/PWGLF/FORWARD/analysis2/AliForwardMCMultiplicityTask.cxx index 8c84a92196b..29985bd27b7 100644 --- a/PWGLF/FORWARD/analysis2/AliForwardMCMultiplicityTask.cxx +++ b/PWGLF/FORWARD/analysis2/AliForwardMCMultiplicityTask.cxx @@ -344,7 +344,7 @@ AliForwardMCMultiplicityTask::UserExec(Option_t*) // UInt_t foundMC = fEventInspector.ProcessMC(mcEvent, triggers, ivzMC, vzMC, b, cMC, npart, nbin, phiR); - fEventInspector.CompareResults(ip.Z(), vzMC, cent, b, npart, nbin); + fEventInspector.CompareResults(ip.Z(), vzMC, cent, cMC, b, npart, nbin); //Store all events MarkEventForStore(); diff --git a/PWGLF/FORWARD/analysis2/AliForwardMultiplicityDistribution.cxx b/PWGLF/FORWARD/analysis2/AliForwardMultiplicityDistribution.cxx index 8c2418254c8..4e93ea45bdb 100644 --- a/PWGLF/FORWARD/analysis2/AliForwardMultiplicityDistribution.cxx +++ b/PWGLF/FORWARD/analysis2/AliForwardMultiplicityDistribution.cxx @@ -116,12 +116,12 @@ void AliForwardMultiplicityDistribution::UserExec(Option_t */*option*/) // Get 2D eta-phi histograms for each event GetHistograms(aod, forward, central); - TH1D* dndetaSumForward = (TH1D*)fOutput->FindObject("dndetaSumForward"); - TH1D* dndetaSumCentral = (TH1D*)fOutput->FindObject("dndetaSumCentral"); - TH1D* dndetaEventForward = (TH1D*)fOutput->FindObject("dndetaEventForward"); - TH1D* dndetaEventCentral = (TH1D*)fOutput->FindObject("dndetaEventCentral"); - TH1D* normEventForward = 0; - TH1D* normEventCentral = 0; + TH1D* dndetaSumForward = (TH1D*)fOutput->FindObject("dndetaSumForward"); + TH1D* dndetaSumCentral = (TH1D*)fOutput->FindObject("dndetaSumCentral"); + TH1D* dndetaEventForward = 0;//(TH1D*)fOutput->FindObject("dndetaEventForward"); + TH1D* dndetaEventCentral = 0;//(TH1D*)fOutput->FindObject("dndetaEventCentral"); + TH1D* normEventForward = 0; + TH1D* normEventCentral = 0; dndetaEventForward = forward.ProjectionX("dndetaForward",1,forward.GetNbinsY(),""); dndetaEventCentral = central.ProjectionX("dndetaCentral",1,central.GetNbinsY(),""); diff --git a/PWGLF/FORWARD/analysis2/DrawAODSummary.C b/PWGLF/FORWARD/analysis2/DrawAODSummary.C index 48a28a4d43c..6a63d3a8555 100644 --- a/PWGLF/FORWARD/analysis2/DrawAODSummary.C +++ b/PWGLF/FORWARD/analysis2/DrawAODSummary.C @@ -7,1274 +7,16 @@ * * */ -#ifndef __CINT__ -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -# include -#else -class THStack; -class TH1; -class TH2; -class TCollection; -class TCanvas; -class TVirtualPad; -class TLatex; -#endif - -bool fgPause = false; //____________________________________________________________________ -/** - * Find an object in a collection - * - * @param parent Parent list - * @param name Name of object - * - * @return Pointer to object or null - */ -TObject* GetObject(const TCollection* parent, const TString& name) -{ - // Info("GetObject", "Getting object %s from %p", name.Data(), parent); - // --- Check parent ------------------------------------------------ - if (!parent) { - Warning("GetObject", "No parent list"); - return 0; - } - // --- Check name -------------------------------------------------- - if (name.IsNull()) { - Warning("GetObject", "No name specified"); - return 0; - } - // --- Find the object --------------------------------------------- - TObject* o = parent->FindObject(name); - if (!o) { - Warning("GetObject", "Object \"%s\" not found in parent \"%s\"", - name.Data(), parent->GetName()); - return 0; - } - return o; -} -//____________________________________________________________________ -/** - * Find an object in a directory - * - * @param parent Parent directory - * @param name Name of object - * - * @return Pointer to object or null - */ -TObject* GetObject(const TDirectory* parent, const TString& name) -{ - // Info("GetObject", "Getting object %s from %p", name.Data(), parent); - // --- Check parent ------------------------------------------------ - if (!parent) { - Warning("GetObject", "No parent directory"); - return 0; - } - // --- Check name -------------------------------------------------- - if (name.IsNull()) { - Warning("GetObject", "No name specified"); - return 0; - } - // --- Find the object --------------------------------------------- - TObject* o = const_cast(parent)->Get(name); - if (!o) { - Warning("GetObject", "Object \"%s\" not found in parent \"%s\"", - name.Data(), parent->GetName()); - return 0; - } - return o; -} - -//____________________________________________________________________ -/** - * Check the type of a found object - * - * @param o Object - * @param cl Class - * @param src Source of object - * - * @return true on success, false otherwise - */ -Bool_t CheckType(const TObject* o, const TClass* cl, const TString& src) -{ - // Info("CheckType", "Checking type of %s vs %s", o->GetName(), cl->GetName()); - if (!o->IsA()->InheritsFrom(cl)) { - Warning("CheckType", "Object \"%s\" retrieved from \"%s\" is not a " - "%s but a %s", o->GetName(), src.Data(), cl->GetName(), - o->ClassName()); - return false; - } - return true; -} - -//_____________________________________________________________________ -void GetParameter(const TCollection* c, const TString& name, UShort_t& value) -{ - // Info("GetParameter", "Getting parameter of %s from %p", name.Data(), c); - TObject* o = GetObject(c, name); - if (!o) return; - value = o->GetUniqueID(); -} -//_____________________________________________________________________ -void GetParameter(const TCollection* c, const TString& name, Int_t& value) -{ - // Info("GetParameter", "Getting parameter of %s from %p", name.Data(), c); - TObject* o = GetObject(c, name); - if (!o) return; - value = o->GetUniqueID(); -} -//_____________________________________________________________________ -void GetParameter(const TCollection* c, const TString& name, Double_t& value) -{ - // Info("GetParameter", "Getting parameter of %s from %p", name.Data(), c); - TObject* o = GetObject(c, name); - if (!o) return; - UInt_t i = o->GetUniqueID(); - Float_t v = *reinterpret_cast(&i); - value = v; -} -//_____________________________________________________________________ -void GetParameter(const TCollection* c, const TString& name, Bool_t& value) -{ - // Info("GetParameter", "Getting parameter of %s from %p", name.Data(), c); - TObject* o = GetObject(c, name); - if (!o) return; - value = o->GetUniqueID(); -} - -//____________________________________________________________________ -/** - * Find a collection in another collection - * - * @param parent Parent collection - * @param name Name of the collection - * - * @return pointer to collection on success, otherwise null - */ -TCollection* GetCollection(const TCollection* parent, const TString& name) -{ - // Info("GetCollection", "Getting collection of %s from %p", name.Data(), c); - // --- Find the object --------------------------------------------- - TObject* o = GetObject(parent, name); - if (!o) return 0; - - // --- Check type of found object ---------------------------------- - if (!CheckType(o, TCollection::Class(), parent->GetName())) return 0; - - // --- Return the collection --------------------------------------- - return static_cast(o); -} - -//____________________________________________________________________ -/** - * Find a collection in a directory - * - * @param parent Parent directory - * @param name Name of the collection - * - * @return pointer to collection on success, otherwise null - */ -TCollection* GetCollection(const TDirectory* parent, const TString& name) -{ - // Info("GetCollection", "Getting collection of %s from %p", - // name.Data(), parent); - // --- Find the object --------------------------------------------- - TObject* o = GetObject(parent, name); - if (!o) return 0; - - // --- Check the type of object ------------------------------------ - if (!CheckType(o, TCollection::Class(), parent->GetName())) return 0; - - // --- Return the collection --------------------------------------- - return static_cast(o); -} - -//____________________________________________________________________ -/** - * Get a 1D histogram from a collection - * - * @param parent Parent collection - * @param name Name of histogram - * - * @return pointer or null - */ -TH1* GetH1(const TCollection* parent, const TString& name) -{ - // Info("GetH1", "Getting 1D histogram of %s from %p", name.Data(), c); - // --- Find the object --------------------------------------------- - TObject* o = GetObject(parent, name); - if (!o) return 0; - - // --- Check the type of object ------------------------------------ - if (!CheckType(o, TH1::Class(), parent->GetName())) return 0; - - // --- Return the collection --------------------------------------- - return static_cast(o); -} -//____________________________________________________________________ -/** - * Get a 2D histogram from a collection - * - * @param parent Parent collection - * @param name Name of histogram - * - * @return pointer or null - */ -TH2* GetH2(const TCollection* parent, const TString& name) -{ - // Info("GetH2", "Getting 2D histogram of %s from %p", name.Data(), c); - // --- Find the object --------------------------------------------- - TObject* o = GetObject(parent, name); - if (!o) return 0; - - // --- Check the type of object ------------------------------------ - if (!CheckType(o, TH2::Class(), parent->GetName())) return 0; - - // --- Return the collection --------------------------------------- - return static_cast(o); -} -//____________________________________________________________________ -/** - * Get a histogram stack from a collection - * - * @param parent Parent collection - * @param name Name of histogram - * - * @return pointer or null - */ -THStack* GetStack(const TCollection* parent, const TString& name, - const char* sub=0) +void DrawAODSummary(const char* fname="forward.root", UShort_t what=0x7F) { - // Info("GetStack", "Getting histogram stack %s from %p", name.Data(), parent); - // --- Find the object --------------------------------------------- - TObject* o = GetObject(parent, name); - if (!o) return 0; - - // --- Check the type of object ------------------------------------ - if (!CheckType(o, THStack::Class(), parent->GetName())) return 0; - - THStack* stack = static_cast(o); - if (sub == 0) return stack; + gROOT->SetMacroPath(Form("%s:$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts", + gROOT->GetMacroPath())); + gROOT->LoadMacro("SummaryAODDrawer.C++g"); - if (stack->GetHists()->GetEntries() <= 0 ||stack->GetMaximum() < 1) { - stack->GetHists()->Delete(); - const char* subs[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3O", "FMD3I", 0 }; - const char** ptr = subs; - while (*ptr) { - TCollection* sc = GetCollection(parent, *ptr); - if (!sc) { ptr++; continue; } - - TH2* h = GetH2(sc, sub); - if (!h) continue; - TH1* p = h->ProjectionX(*ptr, 1, h->GetNbinsY(), "e"); - p->Scale(1., "width"); - p->SetTitle(*ptr); - p->SetDirectory(0); - stack->Add(p); - ptr++; - } - } - // --- Return the collection --------------------------------------- - return stack; + SummaryAODDrawer d; + d.Run(fname, what); } - -//____________________________________________________________________ -void Pause() -{ - printf("Press enter to continue"); - std::cin.get(); -} - -//____________________________________________________________________ -/** - * Clear canvas - * - * @param c Canvas to clear - * - * @ingroup pwglf_forward_scripts_corr - */ -void -ClearCanvas(TCanvas* c) -{ - // Info("ClearCanvas", "Clearing canvas"); - c->SetLeftMargin(.1); - c->SetRightMargin(.05); - c->SetBottomMargin(.1); - c->SetTopMargin(.05); - c->Clear(); - - Float_t dy = .05; - TPad* p1 = new TPad("top", "Top", 0, 1-dy, 1, 1, 0, 0); - p1->SetNumber(1); - p1->SetFillColor(kBlue-5); - p1->SetBorderSize(0); - p1->SetBorderMode(0); - c->cd(); - p1->Draw(); - - TPad* p2 = new TPad("body", "Body", 0, 0, 1, 1-dy, 0, 0); - p2->SetNumber(2); - p2->SetFillColor(0); - p2->SetFillStyle(0); - p2->SetBorderSize(0); - p2->SetBorderMode(0); - c->cd(); - p2->Draw(); - p2->cd(); - -} -//____________________________________________________________________ -/** - * Create a canvas - * - * @param pname Name of PDF file to make - * - * @return Created canvas - */ -TCanvas* CreateCanvas(const TString& pname) -{ - // Info("CreateCanvas", "Creating canvas"); - Int_t size = 1000; - TCanvas* c = new TCanvas("c", pname.Data(), size / TMath::Sqrt(2), size); - c->SetFillColor(0); - c->SetBorderSize(0); - c->SetBorderMode(0); - c->Print(Form("%s[", pname.Data())); - - gStyle->SetOptStat(0); - gStyle->SetTitleColor(0); - gStyle->SetTitleStyle(0); - gStyle->SetTitleBorderSize(0); - gStyle->SetTitleX(.5); - gStyle->SetTitleY(1); - gStyle->SetTitleW(.8); - gStyle->SetTitleH(.09); - gStyle->SetFrameFillColor(kWhite); - gStyle->SetFrameBorderSize(1); - gStyle->SetFrameBorderMode(1); - gStyle->SetPalette(1); - - ClearCanvas(c); - - return c; -} - -//____________________________________________________________________ -/** - * Close the PDF - * - * @param c Canvas - */ -void CloseCanvas(TCanvas* c) -{ - // Info("CloseCanvas", "Closing canvas"); - ClearCanvas(c); - c->Print(Form("%s]", c->GetTitle())); -} - -//____________________________________________________________________ -/** - * Print the canvas - * - * @param c Canvas - * @param title Title - */ -void PrintCanvas(TCanvas* c, const TString& title, Float_t size=.7) -{ - // Info("PrintCanvas", "Printing page %s", title.Data()); - TString tit; - tit.Form("Title:%s", title.Data()); - - c->cd(1); - TLatex* ltx = new TLatex(.5, .5, title); - ltx->SetNDC(); - ltx->SetTextAlign(22); - ltx->SetTextSize(size); - ltx->SetTextColor(kWhite); - ltx->SetTextFont(62); - ltx->Draw(); - - c->Modified(); - c->Update(); - c->cd(); - gSystem->RedirectOutput("/dev/null"); - c->Print(c->GetTitle(), tit); - gSystem->RedirectOutput(0); - - // std::cin.peek(); - if (fgPause) Pause(); - - ClearCanvas(c); -} -//____________________________________________________________________ -/** - * Make a chapter page - * - * @param c Canvas - * @param title Title - */ -void MakeChapter(TCanvas* c, const TString& title) -{ - c->cd(2); - - // Info("MakeChapter", "Making chapter %s", title.Data()); - TLatex* ltx = new TLatex(.5, .5, title); - ltx->SetNDC(); - ltx->SetTextAlign(22); - ltx->Draw(); - - PrintCanvas(c, title); -} -//____________________________________________________________________ -void DrawInPad(TVirtualPad* c, Int_t padNo, TObject* h, Option_t* opts="", - UShort_t flags=0x0) -{ - // Info("DrawInPad", "Drawing %p in pad # %d of %p w/options %s, flags 0x%x", - // h, padNo, c, opts, flags); - TVirtualPad* p = c->cd(padNo); - if (!p) { - Warning("DrawInPad", "Pad # %d not found in %s", padNo, c->GetName()); - return; - } - if (flags & 0x1) p->SetLogx(); - if (flags & 0x2) p->SetLogy(); - if (flags & 0x4) p->SetLogz(); - p->SetFillColor(0); - TString o(opts); - if (o.Contains("colz", TString::kIgnoreCase)) - p->SetRightMargin(0.15); - - if (!h) { - Warning("DrawInPad", "Nothing to draw in pad # %d", padNo); - return; - } - h->Draw(opts); - - if (flags& 0x10) { - TLegend* l = p->BuildLegend(); - l->SetFillColor(0); - l->SetFillStyle(0); - l->SetBorderSize(0); - } - p->Modified(); - p->Update(); - p->cd(); -} -//____________________________________________________________________ -void DrawTwoInPad(TVirtualPad* c, Int_t padNo, TH1* h1, TH1* h2, - Option_t* opts="", UShort_t flags=0x0) -{ - // Info("DrawInPad", "Drawing %p in pad # %d of %p w/options %s, flags 0x%x", - // h, padNo, c, opts, flags); - TVirtualPad* p = c->cd(padNo); - if (!p) { - Warning("DrawInPad", "Pad # %d not found in %s", padNo, c->GetName()); - return; - } - if (flags & 0x1) p->SetLogx(); - if (flags & 0x2) p->SetLogy(); - if (flags & 0x4) p->SetLogz(); - p->SetFillColor(0); - - TString o(opts); - o.ToLower(); - TString fopts(o); - Bool_t e3 = o.Contains("e3"); - if (e3) { - fopts.ReplaceAll("e3", " same"); - } - - h1->GetYaxis()->SetLabelSize(0); - h1->GetYaxis()->SetTicks(""); - h1->GetYaxis()->SetNdivisions(0); - h1->DrawCopy(o); // First draw with opts - if (e3) h1->DrawCopy(fopts); - p->Update(); - - // Make axis - Double_t m1 = 1.05 * h1->GetMaximum(); - TGaxis* a1 = new TGaxis(p->GetUxmin(), p->GetUymin(), - p->GetUxmin(), p->GetUymax(), - 0, m1, 510); - a1->SetLineColor(h1->GetLineColor()); - a1->Draw(); - - o.Append(" same"); - Double_t m2 = 1.1 * h2->GetMaximum(); - Double_t scale = m1 / m2; - h2->Scale(scale); - h2->DrawCopy(o); - if (e3) h2->DrawCopy(fopts); - - TGaxis* a2 = new TGaxis(p->GetUxmax(), p->GetUymin(), - p->GetUxmax(), p->GetUymax(), - 0, m2, 510, "+L"); - a2->SetLineColor(h2->GetLineColor()); - a2->Draw(); - - if (flags& 0x10) { - TLegend* l = p->BuildLegend(); - l->SetFillColor(0); - l->SetFillStyle(0); - l->SetBorderSize(0); - } - p->Modified(); - p->Update(); - p->cd(); -} - - -//____________________________________________________________________ -void CreateTemplates(TLatex*& name, TLatex*& value, Float_t size=.03) -{ - Double_t x1 = .1; - Double_t x2 = .6; - Double_t y = .8; - name = new TLatex(x1, y, ""); - name->SetTextAlign(13); - name->SetNDC(); - name->SetTextSize(size); - - value = new TLatex(x2, y, ""); - value->SetTextAlign(13); - value->SetNDC(); - value->SetTextSize(size); -} - -//____________________________________________________________________ -void DrawParameter(TLatex* name, TLatex* value, Double_t& y, - const TString& sName, const TString& sValue) -{ - name->DrawLatex(name->GetX(), y, Form("%s:", sName.Data())); - value->DrawLatex(value->GetX(), y, sValue.Data()); - y -= name->GetTextSize() + .02; -} - - -//____________________________________________________________________ -void DrawEventInspector(const TCollection* forward, TCanvas* can) -{ - Info("DrawEventInspector", "Drawing event inspector from %p", - forward); - TCollection* c = GetCollection(forward, "fmdEventInspector"); - if (!c) return; - - can->cd(2); - - TLatex* name; - TLatex* value; - Double_t y = .8; - CreateTemplates(name, value); - - Int_t sys, sNN, field, runNo, lowFlux, nPileUp; - Int_t aliRev, aliBra; - Bool_t fpVtx, v0and; - Double_t dPileUp; - - GetParameter(c, "sys", sys); - GetParameter(c, "sNN", sNN); - GetParameter(c, "field", field); - GetParameter(c, "runNo", runNo); - GetParameter(c, "lowFlux", lowFlux); - GetParameter(c, "fpVtx", fpVtx); - GetParameter(c, "v0and", v0and); - GetParameter(c, "nPileUp", nPileUp); - GetParameter(c, "dPileup", dPileUp); - GetParameter(c, "alirootRev", aliRev); - GetParameter(c, "alirootBranch", aliBra); - - DrawParameter(name, value, y, "System", (sys == 1 ? "pp" : - sys == 2 ? "PbPb" : - sys == 3 ? "pPb" : "unknown")); - DrawParameter(name, value, y, "#sqrt{s_{NN}}", Form("%5dGeV", sNN)); - DrawParameter(name, value, y, "L3 B field", Form("%+2dkG", field)); - DrawParameter(name, value, y, "Run #", Form("%6d", runNo)); - DrawParameter(name, value, y, "Low flux cut", Form("%6d", lowFlux)); - DrawParameter(name, value, y, "Use PWG-UD vertex", (fpVtx ? "yes" : "no")); - DrawParameter(name, value, y, "Use V0AND for NSD", (v0and ? "yes" : "no")); - DrawParameter(name, value, y, "Least # of pile-up vertex", - Form("%d", nPileUp)); - DrawParameter(name, value, y, "Least distance of pile-up vertex", - Form("%fcm", dPileUp)); - DrawParameter(name, value, y, "AliROOT", - Form("%7lu/0x%8lx", ULong_t(aliRev), ULong_t(aliBra))); - - PrintCanvas(can, "Event Inspector"); - - TVirtualPad* body = can->cd(2); - body->Divide(2,4); - - TH1* nEventsTr = GetH1(c, "nEventsTr"); - TH1* nEventsTrVtx = GetH1(c, "nEventsTrVtx"); - TH1* vertex = GetH1(c, "vertex"); - Bool_t mc = (vertex != 0); - if (nEventsTr) nEventsTr->Rebin(2); - if (nEventsTrVtx) nEventsTrVtx->Rebin(2); - if (vertex) { - // vertex->Rebin(2); - vertex->SetFillColor(kMagenta+2); - } - DrawInPad(body, 1, nEventsTr); - DrawInPad(body, 1, vertex, "same"); - DrawInPad(body, 1, nEventsTrVtx, "same"); - DrawInPad(body, 1, GetH1(c, "nEventsAccepted"), "same", 0x10); - - - DrawInPad(body, 2, GetH2(c, "nEventsAcceptedXY"), "colz", 0x4); - DrawInPad(body, 3, GetH1(c, "triggers"), "hist text"); - DrawInPad(body, 4, GetH2(c, "triggerCorr"), "colz", 0x4); - DrawInPad(body, 5, GetH1(c, "status"), "hist text"); - DrawInPad(body, 6, GetH1(c, "type"), "hist text"); - DrawInPad(body, 7, GetH1(c, "cent")); - DrawInPad(body, 8, GetH2(c, "centVsQuality"), "colz", 0x4); - - PrintCanvas(can, "EventInspector - Histograms"); - - if (!mc) return; // not MC - - TH1* phiR = GetH1(c, "phiR"); - TH1* b = GetH1(c, "b"); - TH2* bVsNpart = GetH2(c, "bVsParticipants"); - TH2* bVsNbin = GetH2(c, "bVsBinary"); - TH2* bVsCent = GetH2(c, "bVsCentrality"); - TH2* vzComparison = GetH2(c, "vzComparison"); - TH2* centVsNpart = GetH2(c, "centralityVsParticipans");// Spelling! - TH2* centVsNbin = GetH2(c, "centralityVsBinary"); - - body = can->cd(2); - body->Divide(2,3); - - DrawInPad(body, 1, phiR); - DrawInPad(body, 2, vzComparison, "colz", 0x4); - DrawInPad(body, 3, b); - - TProfile* nPartB = bVsNpart->ProfileX("nPartB",1,-1,"s"); - TProfile* nBinB = bVsNbin->ProfileX("nBinB",1,-1,"s"); - nPartB->SetMarkerColor(kBlue+2); - nPartB->SetMarkerStyle(20); - nPartB->SetLineColor(kBlue+2); - nPartB->SetFillColor(kBlue-10); - nPartB->SetFillStyle(1001); - nPartB->SetMarkerSize(0.7); - nBinB->SetMarkerColor(kRed+2); - nBinB->SetMarkerStyle(21); - nBinB->SetLineColor(kRed+2); - nBinB->SetFillColor(kRed-10); - nBinB->SetMarkerSize(0.7); - nBinB->SetFillStyle(1001); - - DrawTwoInPad(body, 4, nPartB, nBinB, "e3 p", 0x10); - - DrawInPad(body, 5, bVsCent, "colz", 0x4); - - TProfile* nPartC = centVsNpart->ProfileY("nPartC",1,-1,"s"); - TProfile* nBinC = centVsNbin->ProfileY("nBinC",1,-1,"s"); - nPartC->SetMarkerColor(kBlue+2); - nPartC->SetMarkerStyle(20); - nPartC->SetLineColor(kBlue+2); - nPartC->SetFillColor(kBlue-10); - nPartC->SetFillStyle(1001); - nPartC->SetMarkerSize(0.7); - nBinC->SetMarkerColor(kRed+2); - nBinC->SetMarkerStyle(21); - nBinC->SetLineColor(kRed+2); - nBinC->SetFillColor(kRed-10); - nBinC->SetMarkerSize(0.7); - nBinC->SetFillStyle(1001); - - DrawTwoInPad(body, 6, nPartC, nBinC, "e3 p", 0x10); - - PrintCanvas(can, "EventInspector - Monte-Carlo"); - -} - -//____________________________________________________________________ -void DrawSharingFilter(const TCollection* forward, TCanvas* can) -{ - Info("DrawEventInspector", "Drawing sharing filter from %p", - forward); - TCollection* c = GetCollection(forward, "fmdSharingFilter"); - if (!c) return; - - TVirtualPad* body = can->cd(2); - body->Divide(1, 3); - body->cd(1); - - TLatex* name; - TLatex* value; - Double_t y = .8; - CreateTemplates(name, value, .05); - - Bool_t angle, lowSignal, simple; - - GetParameter(c, "angle", angle); - GetParameter(c, "lowSignal", lowSignal); - GetParameter(c, "simple", simple); - - DrawParameter(name, value, y, "Angle correct", (angle ? "yes" : "no")); - DrawParameter(name, value, y, "Lower signal", (lowSignal ? "yes" : "no")); - DrawParameter(name, value, y, "Simple method", (simple ? "yes" : "no")); - - DrawInPad(body, 2, GetH2(c, "lowCuts"), "colz"); - DrawInPad(body, 3, GetH2(c, "highCuts"), "colz"); - - PrintCanvas(can, "Sharing filter"); - - const char* subs[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3O", "FMD3I", 0 }; - const char** ptr = subs; - while (*ptr) { - TCollection* sc = GetCollection(c, *ptr); - if (!sc) { ptr++; continue; } - - body = can->cd(2); - body->Divide(2,3); - DrawInPad(body, 1, GetH1(sc, "esdEloss"), "", 0x2); - DrawInPad(body, 1, GetH1(sc, "anaEloss"), "same", 0x12); - DrawInPad(body, 2, GetH1(sc, "singleEloss"), "", 0x2); - DrawInPad(body, 2, GetH1(sc, "doubleEloss"), "same", 0x2); - DrawInPad(body, 2, GetH1(sc, "tripleEloss"), "same", 0x12); - DrawInPad(body, 3, GetH2(sc, "singlePerStrip"), "colz", 0x4); - DrawInPad(body, 4, GetH1(sc, "distanceBefore"), "", 0x2); - DrawInPad(body, 4, GetH1(sc, "distanceAfter"), "same", 0x12); - - TH2* nB = GetH2(sc, "neighborsBefore"); - if (nB) { - nB->GetXaxis()->SetRangeUser(0,8); - nB->GetYaxis()->SetRangeUser(0,8); - } - DrawInPad(body, 5, nB, "colz", 0x4); - DrawInPad(body, 5, GetH2(sc, "neighborsAfter"), "p same", 0x4); - DrawInPad(body, 6, GetH2(sc, "beforeAfter"), "colz", 0x4); - - PrintCanvas(can, Form("Sharing filter - %s", *ptr)); - ptr++; - } - - TCollection* cc = GetCollection(c, "esd_mc_comparion"); // Spelling! - if (!cc) return; // Not MC - - body = can->cd(2); - body->Divide(2,3); - DrawInPad(body, 1, GetH2(cc, "FMD1i_corr"), "colz", 0x4); - DrawInPad(body, 3, GetH2(cc, "FMD2i_corr"), "colz", 0x4); - DrawInPad(body, 4, GetH2(cc, "FMD2o_corr"), "colz", 0x4); - DrawInPad(body, 5, GetH2(cc, "FMD3i_corr"), "colz", 0x4); - DrawInPad(body, 6, GetH2(cc, "FMD3o_corr"), "colz", 0x4); - - PrintCanvas(can, "Sharing filter - MC vs Reco"); - - TCollection* mc = GetCollection(c, "mcTrackDensity"); // Spelling! - if (!mc) return; // Not MC - - body = can->cd(2); - body->Divide(2,3); - DrawInPad(body, 1, GetH2(mc, "binFlow"), "colz", 0x4); - DrawInPad(body, 2, GetH2(mc, "binFlowEta"), "colz", 0x4); - DrawInPad(body, 3, GetH2(mc, "binFlowPhi"), "colz", 0x4); - DrawInPad(body, 4, GetH1(mc, "nRefs"), "", 0x2); - DrawInPad(body, 4, GetH1(mc, "clusterRefs"), "same"); - DrawInPad(body, 4, GetH1(mc, "clusterSize"), "same"); - DrawInPad(body, 4, GetH1(mc, "nClusters"), "same", 0x10); - DrawInPad(body, 5, GetH2(mc, "clusterVsRefs"),"colz", 0x4); - - - PrintCanvas(can, "Sharing filter - MC"); - -} - -//____________________________________________________________________ -void DrawDensityCalculator(const TCollection* forward, TCanvas* can) -{ - Info("DrawDensityCalculator", "Drawing density calculator from %p", - forward); - TCollection* c = GetCollection(forward, "fmdDensityCalculator"); - if (!c) return; - - TVirtualPad* body = can->cd(2); - body->Divide(2, 2); - body->cd(1); - - TLatex* name; - TLatex* value; - Double_t y = .8; - CreateTemplates(name, value, .05); - - Int_t maxParticles, phiAcceptance, etaLumping, phiLumping; - Bool_t method, recalcEta, recalcPhi; - - GetParameter(c, "maxParticle", maxParticles); - GetParameter(c, "phiAcceptance", phiAcceptance); - GetParameter(c, "etaLumping", etaLumping); - GetParameter(c, "phiLumping", phiLumping); - GetParameter(c, "method", method); - GetParameter(c, "recalcEta", recalcEta); - GetParameter(c, "recalcPhi", recalcPhi); - - DrawParameter(name, value, y, "Method", (method ? "Poisson" : "#DeltaE")); - DrawParameter(name, value, y, "Recalculate #eta",(recalcEta ? "yes" : "no")); - DrawParameter(name, value, y, "Recalculate #phi",(recalcPhi ? "yes" : "no")); - DrawParameter(name, value, y, "#phi acceptance method", - (phiAcceptance == 1 ? "N_{ch}" : - phiAcceptance == 2 ? "#DeltaE" : "none")); - DrawParameter(name, value, y, "Region size (sector#timesstrip)", - Form("%2d #times %2d", phiLumping, etaLumping)); - - TVirtualPad* p = body; // body->cd(2); - // p->Divide(3,1); - - TH1* accI = GetH1(c, "accI"); - TH1* accO = GetH1(c, "accO"); - if (accI) { - Double_t scale = 1./accI->GetMaximum(); - accI->Scale(scale); - accO->Scale(scale); - accI->SetMinimum(0); - } - DrawInPad(p, 2, accI); - DrawInPad(p, 2, accO, "same", 0x10); - DrawInPad(p, 3, GetH2(c, "lowCuts"), "colz"); - DrawInPad(p, 4, GetH2(c, "maxWeights"), "colz"); - - PrintCanvas(can, "Density calculator"); - - const char* subs[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3O", "FMD3I", 0 }; - const char** ptr = subs; - while (*ptr) { - TCollection* sc = GetCollection(c, *ptr); - if (!sc) { ptr++; continue; } - - body = can->cd(2); - body->Divide(2,3); - - DrawInPad(body, 1, GetH2(sc, "elossVsPoisson"), "colz", 0x4); - DrawInPad(body, 2, GetH1(sc, "diffElossPoisson"), "", 0x2); - DrawInPad(body, 3, GetH1(sc, "occupancy"), "", 0x2); - DrawInPad(body, 4, GetH1(sc, "eloss"), "", 0x2); - DrawInPad(body, 4, GetH1(sc, "elossUsed"), "same", 0x12); - TH1* phiB = GetH1(sc, "phiBefore"); - TH1* phiA = GetH1(sc, "phiAfter"); - if (phiB && phiA) { - phiA->Add(phiB, -1); - phiA->Divide(phiB); - phiA->SetTitle("#Delta#phi from Ip (x,y) correction"); - phiA->SetYTitle("(#phi_{after}-#phi_{before})/#phi_{before}"); - } - DrawInPad(body, 5, phiA); - DrawInPad(body, 6, GetH2(sc, "phiAcc"), "colz", 0x4); - - PrintCanvas(can, Form("Density calculator - %s", *ptr)); - ptr++; - } - - TCollection* cc = GetCollection(c, "esd_mc_comparison"); - if (!cc) return; // Not MC - - body = can->cd(2); - body->Divide(2,5); - DrawInPad(body, 1, GetH2(cc, "FMD1I_corr_mc_esd"), "colz", 0x4); - DrawInPad(body, 3, GetH2(cc, "FMD2I_corr_mc_esd"), "colz", 0x4); - DrawInPad(body, 5, GetH2(cc, "FMD2O_corr_mc_esd"), "colz", 0x4); - DrawInPad(body, 7, GetH2(cc, "FMD3O_corr_mc_esd"), "colz", 0x4); - DrawInPad(body, 9, GetH2(cc, "FMD3I_corr_mc_esd"), "colz", 0x4); - DrawInPad(body, 2, GetH1(cc, "FMD1I_diff_mc_esd"), "", 0x2); - DrawInPad(body, 4, GetH1(cc, "FMD2I_diff_mc_esd"), "", 0x2); - DrawInPad(body, 6, GetH1(cc, "FMD2O_diff_mc_esd"), "", 0x2); - DrawInPad(body, 8, GetH1(cc, "FMD3O_diff_mc_esd"), "", 0x2); - DrawInPad(body, 10, GetH1(cc, "FMD3I_diff_mc_esd"), "", 0x2); - - PrintCanvas(can, "Density calculator - MC vs Reco"); -} - -//____________________________________________________________________ -void DrawCorrector(const TCollection* forward, TCanvas* can) -{ - Info("DrawCorrector", "Drawing corrector from %p", forward); - TCollection* c = GetCollection(forward, "fmdCorrector"); - if (!c) return; - - TVirtualPad* body = can->cd(2); - body->cd(); - - TLatex* name; - TLatex* value; - Double_t y = .8; - CreateTemplates(name, value, .05); - - Bool_t secondary, vertexBias, acceptance, merging; - GetParameter(c, "secondary", secondary); - GetParameter(c, "acceptance", acceptance); - GetParameter(c, "vertexBias", vertexBias); - GetParameter(c, "merging", merging); - - DrawParameter(name, value, y, "Secondary corr.", secondary ? "yes" : "no"); - DrawParameter(name, value, y, "Acceptance corr.", acceptance ? "yes" : "no"); - DrawParameter(name, value, y, "Vertex bias corr.", vertexBias ? "yes" : "no"); - DrawParameter(name, value, y, "Merging eff.", merging ? "yes" : "no"); - - PrintCanvas(can, "Corrector"); - - TCollection* cc = GetCollection(c, "esd_mc_comparison"); - if (!cc) return; // Not MC - - body = can->cd(2); - body->Divide(2,3); - DrawInPad(body, 1, GetH2(cc, "FMD1I_esd_vs_mc"), "colz", 0x0); - DrawInPad(body, 3, GetH2(cc, "FMD2I_esd_vs_mc"), "colz", 0x0); - DrawInPad(body, 4, GetH2(cc, "FMD2O_esd_vs_mc"), "colz", 0x0); - DrawInPad(body, 5, GetH2(cc, "FMD3O_esd_vs_mc"), "colz", 0x0); - DrawInPad(body, 6, GetH2(cc, "FMD3I_esd_vs_mc"), "colz", 0x0); - - PrintCanvas(can, "Corrector - MC vs Reco"); -} - -//____________________________________________________________________ -void DrawHistCollector(const TCollection* forward, TCanvas* can) -{ - Info("DrawHistCollector", "Drawing histogram collector from %p", forward); - TCollection* c = GetCollection(forward, "fmdHistCollector"); - if (!c) return; - - TVirtualPad* body = can->cd(2); - body->Divide(1, 3); - body->cd(1); - - TLatex* name; - TLatex* value; - Double_t y = .8; - CreateTemplates(name, value, .05); - - Int_t nCutBins, fiducial, merge, skipRings; - Double_t fiducialCut; - Bool_t bgAndHits; - - GetParameter(c, "nCutBins", nCutBins); - GetParameter(c, "skipRings", skipRings); - GetParameter(c, "bgAndHits", bgAndHits); - GetParameter(c, "merge", merge); - GetParameter(c, "fiducial", fiducial); - // GetParameter(c, "correctionCut", fiducialCut); - GetParameter(c, "fiducialCut", fiducialCut); - - DrawParameter(name, value, y, "# of bins to cut", Form("%d", nCutBins)); - DrawParameter(name, value, y, "Bg & hit maps stored.", bgAndHits?"yes":"no"); - DrawParameter(name, value, y, "Fiducial method.", - fiducial == 0 ? "cut" : "distance"); - DrawParameter(name, value, y, "Fiducial cut.", Form("%f", fiducialCut)); - DrawParameter(name, value, y, "Merge method", - (merge == 0 ? "straight mean" : - merge == 1 ? "straight mean, no zeroes" : - merge == 2 ? "weighted mean" : - merge == 3 ? "least error" : - merge == 4 ? "sum" : "unknown")); - TString skipped; - if (skipRings & 0x11) skipped.Append("FMD1i "); - if (skipRings & 0x21) skipped.Append("FMD2i "); - if (skipRings & 0x22) skipped.Append("FMD2o "); - if (skipRings & 0x31) skipped.Append("FMD3i "); - if (skipRings & 0x32) skipped.Append("FMD3o "); - DrawParameter(name, value, y, "Skipped rings", skipped); - - DrawInPad(body, 2, GetH2(c, "sumRings"), "colz"); - DrawInPad(body, 3, GetH2(c, "coverage"), "colz"); - - body->cd(1)->Modified(); - body->cd(2)->Modified(); - body->cd(3)->Modified(); - body->cd(1)->Update(); - body->cd(2)->Update(); - body->cd(3)->Update(); - PrintCanvas(can, "Histogram collector"); -} - -//____________________________________________________________________ -void AddToAll(THStack* all, const THStack* stack, Int_t curr, Int_t step) -{ - if (!stack) return; - - TIter next(stack->GetHists()); - TH1* h = 0; - while ((h = static_cast(next()))) { - TH1* copy = static_cast(h->Clone(Form("%s_copy", h->GetName()))); - copy->SetDirectory(0); - if (curr != step) { - copy->SetMarkerColor(kGray); - copy->SetLineColor(kGray); - } - all->Add(copy); - } -} - -//____________________________________________________________________ -void DrawStep(THStack* delta, - THStack* nchs, - THStack* prims, - THStack* rings, - TH1* dndeta, - TVirtualPad* can, - Int_t step) -{ - THStack* all = 0; - TH1* res = 0; - if (step < 6) { - all = new THStack; - if (step != 1) AddToAll(all, delta, step, 1); - if (step != 2) AddToAll(all, nchs, step, 2); - if (step != 3) AddToAll(all, prims, step, 3); - if (step != 4) AddToAll(all, rings, step, 4); - - res = static_cast(dndeta->Clone("dNdeta")); - res->SetTitle("dN/d#eta"); - res->SetMarkerColor(step == 5 ? kBlack : kGray); - res->SetLineColor(step == 5 ? kBlack : kGray); - res->SetDirectory(0); - all->Add(res); - if (step == 1) AddToAll(all, delta, step, 1); - if (step == 2) AddToAll(all, nchs, step, 2); - if (step == 3) AddToAll(all, prims, step, 3); - if (step == 4) AddToAll(all, rings, step, 4); - } - - TVirtualPad* p = can->cd(step); - p->SetFillColor(kWhite); - p->SetRightMargin(0.02); - p->SetTopMargin(0.02); - - if (all) { - all->Draw("nostack"); - all->GetHistogram()->SetXTitle("#eta"); - all->GetHistogram()->SetYTitle("signal"); - // all->GetHistogram()->GetXaxis()->SetLabelFont(132); - // all->GetHistogram()->GetXaxis()->SetTitleFont(132); - // all->GetHistogram()->GetYaxis()->SetLabelFont(132); - // all->GetHistogram()->GetYaxis()->SetTitleFont(132); - } - - TLegend* l = 0; - if (step < 6) - l = new TLegend(.33, .2, .53, .9); - else - l = new TLegend(0.1, 0.1, .9, .9); - l->SetFillColor(kWhite); - l->SetFillStyle(0); - l->SetBorderSize(0); - TLegendEntry* e = 0; - - TIter next(delta->GetHists()); - TH1* h = 0; - if (step == 6) { - while ((h = static_cast(next()))) { - e = l->AddEntry("dummy", h->GetTitle(), "pl"); - e->SetMarkerStyle(20); - e->SetMarkerColor(h->GetMarkerColor()); - } - } - else { - h = static_cast(delta->GetHists()->At(0)); - e = l->AddEntry("dummy", delta->GetTitle(), "pl"); - e->SetMarkerStyle(h->GetMarkerStyle()); - e->SetMarkerColor(step != 1 ? kGray : kBlack); - e->SetLineColor(e->GetMarkerColor()); - - h = static_cast(nchs->GetHists()->At(0)); - e = l->AddEntry("dummy", nchs->GetTitle(), "pl"); - e->SetMarkerStyle(h->GetMarkerStyle()); - e->SetMarkerColor(step != 2 ? kGray : kBlack); - e->SetLineColor(e->GetMarkerColor()); - - h = static_cast(prims->GetHists()->At(0)); - e = l->AddEntry("dummy", prims->GetTitle(), "pl"); - e->SetMarkerStyle(h->GetMarkerStyle()); - e->SetMarkerColor(step != 3 ? kGray : kBlack); - e->SetLineColor(e->GetMarkerColor()); - - h = static_cast(rings->GetHists()->At(0)); - e = l->AddEntry("dummy", rings->GetTitle(), "pl"); - e->SetMarkerStyle(h->GetMarkerStyle()); - e->SetMarkerColor(step != 4 ? kGray : kBlack); - e->SetLineColor(e->GetMarkerColor()); - - h = res; - e = l->AddEntry("dummy", h->GetTitle(), "pl"); - e->SetMarkerStyle(h->GetMarkerStyle()); - e->SetMarkerColor(step != 5 ? kGray : kBlack); - e->SetLineColor(e->GetMarkerColor()); - } - - l->Draw("nostack"); - - TString what; - if (step > 0) { - switch (step) { - case 1: - what = "After merging"; - break; - case 2: - what = "After particle counting"; - break; - case 3: - what = "After corrections"; - break; - case 4: - what = "After normalisation"; - break; - case 5: - what = "Result"; - break; - case 6: - break; - default: - Error("DrawStep", "Unknown step: %d (must be in 1-6)", step); - break; - } - } - TLatex* ltx = new TLatex(.97, .97, what); - ltx->SetNDC(); - ltx->SetTextSize(.06); - ltx->SetTextAlign(33); - // ltx->SetTextFont(132); - ltx->Draw(); - - if (step < 6) - ltx->DrawLatex(.32, .97, Form("Step %d", step)); - - -} - -//____________________________________________________________________ -void FixStack(THStack* stack, const TString& title, Int_t marker) -{ - if (!stack) return; - stack->SetTitle(title); - TIter next(stack->GetHists()); - TH1* h = 0; - while ((h = static_cast(next()))) h->SetMarkerStyle(marker); -} -//____________________________________________________________________ -void DrawSteps(const TCollection* forward, TCanvas* can) -{ - // MakeChapter(can, "Steps"); - - THStack* deltas = GetStack(GetCollection(forward, "fmdSharingFilter"), - "sums", "summed"); - THStack* nchs = GetStack(GetCollection(forward, "fmdDensityCalculator"), - "sums", "inclDensity"); - THStack* prims = GetStack(GetCollection(forward, "fmdCorrector"), - "sums", "primaryDensity"); - THStack* rings = GetStack(GetCollection(forward, "ringResults"), "all"); - TH1* dndeta = GetH1(forward, "dNdeta"); - - FixStack(deltas, "#sum_{} #Delta/#Delta_{mip}", 25); - FixStack(nchs, "#sum_{} N_{ch,incl}", 21); - FixStack(prims, "#sum_{} N_{ch,primary}", 22); - FixStack(rings, "dN/d#eta per ring", 23); - - TVirtualPad* body = can->cd(2); - body->Divide(2,3,0,0); - for (Int_t step = 1; step <= 6; step++) { - DrawStep(deltas, nchs, prims, rings, dndeta, body, step); - } - PrintCanvas(can, "Steps"); -} - - -//____________________________________________________________________ -void DrawResults(const TCollection* forward, - const TCollection* forwardRes, TCanvas* can) -{ - // MakeChapter(can, "Results"); - - TVirtualPad* body = can->cd(2); - body->Divide(2,3, .1, 0); - - TCollection* c = GetCollection(forwardRes, "ringResults"); - if (!c) return; - - DrawInPad(body, 1, GetStack(c, "all"), "nostack"); - - DrawInPad(body, 2, GetH1(forwardRes, "dNdeta")); - DrawInPad(body, 3, GetH1(forwardRes, "dNdeta_")); - DrawInPad(body, 4, GetH1(forwardRes, "norm")); - DrawInPad(body, 4, GetH1(forwardRes, "phi"), "same", 0x10); - DrawInPad(body, 5, GetH1(forward, "d2Ndetadphi"), "colz"); - - TCollection* mc = GetCollection(forwardRes, "mcRingResults"); - if (mc) { - THStack* sMc = new THStack; - sMc->SetTitle("MC dN/d#eta per Ring"); - const char* subs[] = { "FMD1I", "FMD2I", "FMD2O", "FMD3O", "FMD3I", 0 }; - const char** ptr = subs; - while (*ptr) { - TCollection* sc = GetCollection(mc, *ptr); - if (!sc) { ptr++; continue; } - - TH1* h = GetH1(sc, "dndeta_eta"); - if (!h) { ptr++; continue; } - sMc->Add(h); - ptr++; - } - DrawInPad(body, 1, sMc, "nostack same", 0x10); - } - - - PrintCanvas(can, "Results"); - -} - - -//____________________________________________________________________ -void DrawAODSummary(const char* fname="forward.root", - UShort_t what=0x7F) -{ - // --- Open the file ----------------------------------------------- - TString filename(fname); - TFile* file = TFile::Open(filename.Data(), "READ"); - if (!file) { - Error("DrawAODSummary", "Failed to open \"%s\"", filename.Data()); - return; - } - - // --- Get top-level collection ------------------------------------ - TCollection* forward = GetCollection(file, "Forward"); - if (!forward) return; - - // --- Make our canvas --------------------------------------------- - TString pdfName(filename); - pdfName.ReplaceAll(".root", ".pdf"); - - TCanvas* c = CreateCanvas(pdfName); - - fgPause = what & 0x80; - - // --- Do each sub-algorithm --------------------------------------- - if (what & 0x01) DrawEventInspector(forward,c); - if (what & 0x02) DrawSharingFilter(forward,c); - if (what & 0x04) DrawDensityCalculator(forward, c); - if (what & 0x08) DrawCorrector(forward, c); - if (what & 0x10) DrawHistCollector(forward, c); - - // --- Do the results ---------------------------------------------- - TCollection* forwardRes = GetCollection(file, "ForwardResults"); - if (!forwardRes) return; - - if (what & 0x20) DrawSteps(forwardRes, c); - if (what & 0x40) DrawResults(forward, forwardRes, c); - - CloseCanvas(c); -} - - - +// +// EOF +// diff --git a/PWGLF/FORWARD/analysis2/DrawdNdeta.C b/PWGLF/FORWARD/analysis2/DrawdNdeta.C index cda1999d782..10e107fb2f3 100644 --- a/PWGLF/FORWARD/analysis2/DrawdNdeta.C +++ b/PWGLF/FORWARD/analysis2/DrawdNdeta.C @@ -78,6 +78,7 @@ struct dNdetaDrawer fShowOthers(0), // Show other data fMirror(false), fForceMB(false), + fAddExec(false), // Settings fRebin(0), // Rebinning factor fFwdSysErr(0.076), // Systematic error in forward range @@ -217,9 +218,41 @@ struct dNdetaDrawer * @param e Systematic error in the forward region */ void SetCentralSysError(Double_t e=0) { fCenSysErr = e; } + /** + * Force the plot of minimum bias, even if centrality dependent data + * is present + * + * @param force if true, force minimum bias + */ void SetForceMB(Bool_t force=true) { fForceMB = force; } + /** + * Force the plot of minimum bias, even if centrality dependent data + * is present + * + * @param force if true, force minimum bias + */ + void SetAddExec(Bool_t add=true) { fAddExec = add; } + /** + * Mirror data to regions with no coverage (@f$-5.0<\eta<-3.5@f$) + * + * @param mirror If true, mirror data + */ void SetMirror(Bool_t mirror=true) { fMirror = mirror; } + /** + * Set the 'Final MC' correction file. This is needed if the + * secondary maps where produced using the old code + * + * @param file Filename + */ void SetFinalMC(const TString& file) { fFinalMC = file; } + /** + * Set the file that contains the empirical correction. This is + * needed when the secondary maps was generated with an in-accurate + * geometry, and when we're analysing data at nominal interaction + * points + * + * @param file Filename + */ void SetEmpirical(const TString& file) { fEmpirical = file; } /* @} */ //================================================================== @@ -296,19 +329,50 @@ struct dNdetaDrawer // --- Open input file ------------------------------------------- TFile* file = TFile::Open(filename, "READ"); if (!file) { - Error("Open", "Cannot open %s", filename); + Error("Run", "Cannot open %s", filename); return; } - Info("Open", "Drawing results from %s", file->GetName()); + Info("Run", "Drawing results from %s", file->GetName()); // --- Get forward list ------------------------------------------ TList* forward = static_cast(file->Get("ForwardResults")); if (!forward) { - Error("Open", "Couldn't find list ForwardResults"); + Error("Run", "Couldn't find list ForwardResults"); return; } // --- Get information on the run -------------------------------- FetchInformation(forward); + + // --- Print settings -------------------------------------------- + Info("Run", "Settings for the drawer:\n" + " Show ratios: %5s\n" + " Show Left/right: %5s\n" + " Show rings: %5s\n" + " Export to file: %5s\n" + " Cut edges when rebinning: %5s\n" + " Remove outer rings: %5s\n" + " Mirror to un-covered regions: %5s\n" + " Force minimum bias: %5s\n" + " Show other results: 0x%03x\n" + " Rebinning factor: %5d\n" + " Forward systematic error: %5.1f%%\n" + " Central systematic error: %5.1f%%\n" + " Title on plot: %s\n" + " Scaling of clusters to tracklets: %s\n" + " Final MC correction file: %s\n" + " Empirical correction file: %s", + (fShowRatios ? "yes" : "no"), + (fShowLeftRight ? "yes" : "no"), + (fShowRings ? "yes" : "no"), + (fExport ? "yes" : "no"), + (fCutEdges ? "yes" : "no"), + (fRemoveOuters ? "yes" : "no"), + (fMirror ? "yes" : "no"), + (fForceMB ? "yes" : "no"), + fShowOthers, fRebin, (100*fFwdSysErr), (100*fCenSysErr), + fTitle.Data(), fClusterScale.Data(), fFinalMC.Data(), + fEmpirical.Data()); + // --- Set the macro pathand load other data script -------------- gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2", gROOT->GetMacroPath())); @@ -316,11 +380,11 @@ struct dNdetaDrawer // --- Get the central results ----------------------------------- TList* clusters = static_cast(file->Get("CentralResults")); - if (!clusters) Warning("Open", "Couldn't find list CentralResults"); + if (!clusters) Warning("Run", "Couldn't find list CentralResults"); // --- Get the central results ----------------------------------- TList* mcTruth = static_cast(file->Get("MCTruthResults")); - if (!mcTruth) Warning("Open", "Couldn't find list MCTruthResults"); + if (!mcTruth) Warning("Run", "Couldn't find list MCTruthResults"); // --- Make our containtes --------------------------------------- fResults = new THStack("results", "Results"); @@ -340,11 +404,11 @@ struct dNdetaDrawer else { forwardMC = static_cast(finalMC->Get("ForwardResults")); if (!forwardMC) - Warning("Open", "Couldn't find list ForwardResults for final MC"); + Warning("Run", "Couldn't find list ForwardResults for final MC"); #if 0 centralMC = static_cast(finalMC->Get("CentralResults")); if (!centralMC) - Warning("Open", "Couldn't find list CentralResults for final MC"); + Warning("Run", "Couldn't find list CentralResults for final MC"); #endif } } @@ -359,21 +423,21 @@ struct dNdetaDrawer "corrections/Empirical/%s", fEmpirical.Data()))); if (gSystem->AccessPathName(fEmpirical.Data())) { // Not found here - Warning("Open", "Couldn't get empirical correction file"); + Warning("Run", "Couldn't get empirical correction file"); fEmpirical = ""; } } if (!fEmpirical.IsNull()) { TFile* empirical = TFile::Open(fEmpirical, "READ"); if (!empirical) { - Warning("Open", "couldn't open empirical correction file: %s", + Warning("Run", "couldn't open empirical correction file: %s", fEmpirical.Data()); fEmpirical = ""; } const char* empPath = "fmdfull/average"; empCorr = static_cast(empirical->Get(empPath)); if (!empCorr) { - Warning("Open", "Didn't find the graph %s in %s", + Warning("Run", "Didn't find the graph %s in %s", empPath, fEmpirical.Data()); fEmpirical = ""; } @@ -1120,9 +1184,10 @@ struct dNdetaDrawer p1->Draw(); p1->cd(); - // Info("PlotResults", "Plotting results with max=%f", max); + Info("PlotResults", "Plotting results with max=%f", max); fResults->SetMaximum(1.15*max); fResults->SetMinimum(yd > 0.00001 ? -0.02*max : 0); + // fResults->SetMinimum(yd > 0.00001 ? -0.02*max : 0); FixAxis(fResults, (1-yd)*(yd > .001 ? 1 : .9 / 1.2), "#font[12]{#frac{1}{N} " @@ -1312,14 +1377,16 @@ struct dNdetaDrawer // Replot the ratios on top fRatios->DrawClone("nostack e1 same"); - if (isBottom) { - fRangeParam->fMasterAxis = FindXAxis(p2, fRatios->GetName()); - p2->AddExec("range", Form("RangeExec((dNdetaDrawer::RangeParam*)%p)", - fRangeParam)); - } - else { - fRangeParam->fSlave2Axis = FindXAxis(p2, fRatios->GetName()); - fRangeParam->fSlave2Pad = p2; + if (fAddExec) { + if (isBottom) { + fRangeParam->fMasterAxis = FindXAxis(p2, fRatios->GetName()); + p2->AddExec("range", Form("RangeExec((dNdetaDrawer::RangeParam*)%p)", + fRangeParam)); + } + else { + fRangeParam->fSlave2Axis = FindXAxis(p2, fRatios->GetName()); + fRangeParam->fSlave2Pad = p2; + } } } //__________________________________________________________________ @@ -1509,7 +1576,7 @@ struct dNdetaDrawer if (fCutEdges) { if (h->GetBinContent(bin+1)<=0 || - h->GetBinContent(bin-1)) { + h->GetBinContent(bin-1)<=0) { Warning("Rebin", "removing bin %d=%f of %s (%d=%f,%d=%f)", bin, c, h->GetName(), bin+1, h->GetBinContent(bin+1), @@ -2158,6 +2225,13 @@ struct dNdetaDrawer << "}\n" << std::endl; } /* @} */ + /** + * Check if we have centrality dependent information, and we're not + * forcing to use minimum bias + * + * + * @return True if we should do centrality dependent ploting + */ Bool_t HasCent() const { return fCentAxis && !fForceMB; } @@ -2176,6 +2250,7 @@ struct dNdetaDrawer UShort_t fShowOthers; // Show other data Bool_t fMirror; // Whether to mirror Bool_t fForceMB; // Force min-bias + Bool_t fAddExec; // Add code to do combined zooms /* @} */ /** * @{ @@ -2326,23 +2401,25 @@ Usage() " Float_t IPZMIN (optional) Least z coordinate of IP\n" " Float_t IPZMAX (optional) Largest z coordinate of IP\n\n" " OTHERS is a bit mask of\n\n" - " 0x1 Show UA5 data (INEL,NSD, ppbar, 900GeV)\n" - " 0x2 Show CMS data (NSD, pp)\n" - " 0x4 Show published ALICE data (INEL,INEL>0,NSD, pp)\n" - " 0x8 Show event genertor data\n\n" + " 0x1 Show UA5 data (INEL,NSD, ppbar, 900GeV)\n" + " 0x2 Show CMS data (NSD, pp)\n" + " 0x4 Show published ALICE data (INEL,INEL>0,NSD, pp)\n" + " 0x8 Show event genertor data\n\n" " FLAGS is a bit mask of\n\n" - " 0x1 Show ratios of data to other data and possibly MC\n" - " 0x2 Show left-right asymmetry\n" - " 0x4 Show systematic error band\n" - " 0x8 Show individual ring results (INEL only)\n" - " 0x10 Cut edges when rebinning\n" - " 0x20 Remove FMDxO points\n" - " 0x40 Do not make our own canvas\n" - " 0x80 Force use of MB\n" - " 0x100 Mirror data\n" - " 0x200 Apply `final MC' correction\n" - " 0x400 Apply `Emperical' correction\n" - " 0x800 Export results to script\n\n" + " 0x1 Show ratios of data to other data and possibly MC\n" + " 0x2 Show left-right asymmetry\n" + " 0x4 Show systematic error band\n" + " 0x8 Show individual ring results (INEL only)\n" + " 0x10 Cut edges when rebinning\n" + " 0x20 Remove FMDxO points\n" + " 0x40 Do not make our own canvas\n" + " 0x80 Force use of MB\n" + " 0x100 Mirror data\n" + " 0x200 Apply `final MC' correction\n" + " 0x400 Apply `Emperical' correction\n" + " 0x800 Export results to script\n" + " 0x1000 Add code to do combined zooms on eta axis\n" + " 0x2000 Assume old-style input\n\n" "0x200 requires the file forward_dndetamc.root\n" "0x400 requires the file EmpiricalCorrection.root\n" "To specify that you want ratios, force MB, apply empirical " @@ -2404,7 +2481,8 @@ DrawdNdeta(const char* filename="forward_dndeta.root", d.SetFinalMC(flags & 0x200 ? "forward_dndetamc.root" : ""); d.SetEmpirical(flags & 0x400 ? "EmpiricalCorrection.root" : ""); d.SetExport(flags & 0x800); - d.SetOld(flags & 0x1000); + d.SetAddExec(flags & 0x1000); + d.SetOld(flags & 0x2000); // d.fClusterScale = "1.06 -0.003*x +0.0119*x*x"; // Do the below if your input data does not contain these settings if (sNN > 0) d.SetSNN(sNN); // Collision energy per nucleon pair (GeV) diff --git a/PWGLF/FORWARD/analysis2/DrawdNdetaSummary.C b/PWGLF/FORWARD/analysis2/DrawdNdetaSummary.C index dab61dc4132..2b63ad4a68b 100644 --- a/PWGLF/FORWARD/analysis2/DrawdNdetaSummary.C +++ b/PWGLF/FORWARD/analysis2/DrawdNdetaSummary.C @@ -7,6 +7,20 @@ * * */ +#if 1 +//____________________________________________________________________ +void DrawdNdetaSummary(const char* fname="forward_dndeta.root", + UShort_t what=0x0) +{ + gROOT->SetMacroPath(Form("%s:$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts", + gROOT->GetMacroPath())); + gROOT->LoadMacro("SummarydNdetaDrawer.C++g"); + + SummarydNdetaDrawer d; + d.Run(fname, what); +} + +#else #ifndef __CINT__ # include # include @@ -789,6 +803,7 @@ void DrawdNdetaSummary(const char* fname="forward_dndeta.root", CloseCanvas(c); } - - - +#endif +// +// EOF +// diff --git a/PWGLF/FORWARD/analysis2/gridAnalysis.sh b/PWGLF/FORWARD/analysis2/gridAnalysis.sh index 8c9181ea9eb..a236919f613 100755 --- a/PWGLF/FORWARD/analysis2/gridAnalysis.sh +++ b/PWGLF/FORWARD/analysis2/gridAnalysis.sh @@ -210,8 +210,10 @@ draw() download for i in *.zip ; do d=`basename $i .zip` - mkdir -p $d - unzip $i -d $d + if test ! -d $d ; then + mkdir -p $d + unzip $i -d $d + fi (cd $d && script $scr) done } @@ -225,8 +227,8 @@ TGrid::Connect("alien://"); gSystem->RedirectOutput(0); std::cout << gGrid->GetHomeDirectory() << std::endl; EOF` - my_real_dir="$l/${name}_${now}_aod/output" - my_mc_dir="$l/${name}_${now}_mcaod/output" + my_real_dir="$l/${name}_aod_${now}/output" + my_mc_dir="$l/${name}_mcaod_${now}/output" } # === Trains ========================================================= @@ -460,7 +462,7 @@ Then, do to get a PDF of the diagnostics histograms, and - (cd ${nme}_${now} && aliroot -l draw.C) + (cd ${nme}_${now} && aliroot -l Draw.C) to get the final plot. EOF @@ -532,9 +534,9 @@ dndetas_upload() dndetas_draw() { (cd ${name}_mcdndeta_${now} && draw ${fwd_dir}/DrawdNdetaSummary.C && \ - script draw.C) + draw ../Draw.C) (cd ${name}_dndeta_${now} && draw ${fwd_dir}/DrawdNdetaSummary.C && \ - script draw.C) + draw ../Draw.C) } # === Executable code @@ -593,7 +595,7 @@ case $what in clean) cleanup ; exit 0 ;; corr*) func=corrs;; aod*) func=aods ;; - dndeta*) func=dndeta ;; + dndeta*) func=dndetas ;; *) echo "$0: Unknown operation: $what" > /dev/stderr ; exit 1 ;; esac diff --git a/PWGLF/FORWARD/analysis2/trains/MakedNdetaTrain.C b/PWGLF/FORWARD/analysis2/trains/MakedNdetaTrain.C index ca50043f935..5c1c9769950 100644 --- a/PWGLF/FORWARD/analysis2/trains/MakedNdetaTrain.C +++ b/PWGLF/FORWARD/analysis2/trains/MakedNdetaTrain.C @@ -68,6 +68,7 @@ protected: Bool_t cent = fOptions.Has("cent"); Bool_t edges = fOptions.Has("cut-edges"); Bool_t corrEm = fOptions.Has("corr-empty"); + Bool_t mc = fOptions.Has("mc"); // --- Form arguments -------------------------------------------- TString args; @@ -83,7 +84,14 @@ protected: /** * Do not the centrality selection */ + //__________________________________________________________________ void CreateCentralitySelection(Bool_t, AliAnalysisManager*) {} + /** + * Do not create MC input handler + * + * @return Always null + */ + AliVEventHandler* CreateMCHandler(UShort_t, bool) { return 0; } //__________________________________________________________________ /** * Crete output handler - we don't want one here. @@ -103,9 +111,9 @@ protected: { TrainSetup::SaveSetup(asShellScript); - std::ofstream o("draw.C"); + std::ofstream o("Draw.C"); if (!o) { - Error("MakedNdetaTrain::SaveSetup", "Failed to open draw.C"); + Error("MakedNdetaTrain::SaveSetup", "Failed to open Draw.C"); return; } @@ -116,7 +124,7 @@ protected: << "// Options can be specified as needed. To get help, pass the\n" << "// string \"help\" for the title\n" << "// \n" - << "void draw(const TString& title="",\n" + << "void Draw(const TString& title="",\n" << " UShort_t rebin=5,\n" << " UShort_t others=0x7,\n" << " UShort_t flags=0xD87,\n" diff --git a/PWGLF/FORWARD/trains/ChainBuilder.C b/PWGLF/FORWARD/trains/ChainBuilder.C index cdeb531e756..6a5f6c109c2 100644 --- a/PWGLF/FORWARD/trains/ChainBuilder.C +++ b/PWGLF/FORWARD/trains/ChainBuilder.C @@ -179,12 +179,14 @@ struct ChainBuilder } TGridCollection* collection = reinterpret_cast(ret); +#if 0 if (!collection) { Error("ChainBuilder::CreateFromXML", "Cannot create AliEn collection from XML file %s", src.Data()); return false; } - +#endif + collection->Reset(); while (collection->Next()) chain->Add(collection->GetTURL("")); @@ -273,6 +275,10 @@ struct ChainBuilder TString cl(k->GetClassName()); if (!cl.EqualTo("TFileCollection")) continue; TFileCollection* fc = dynamic_cast(k->ReadObj()); + if (!fc) { + Warning("", "Returned collection invalid"); + continue; + } Info("", "Adding file collection"); chain->AddFileInfoList(fc->GetList()); ok = true; diff --git a/PWGLF/FORWARD/trains/Helper.C b/PWGLF/FORWARD/trains/Helper.C index 4111bc83eff..64dade5fa1f 100644 --- a/PWGLF/FORWARD/trains/Helper.C +++ b/PWGLF/FORWARD/trains/Helper.C @@ -130,7 +130,9 @@ struct Helper { if (!AuxFile(name, copy)) return false; TString base(gSystem->BaseName(name)); + gROOT->ProcessLine("gSystem->RedirectOutput(\"build.log\",\"a\");"); gROOT->LoadMacro(Form("%s++g", base.Data())); + gROOT->ProcessLine("gSystem->RedirectOutput(0);"); return true; } /** @@ -317,7 +319,7 @@ struct Helper const TUrl& url, Int_t verbose=0) { - if (verbose > 3) gSystem->RedirectOutput("/dev/null","w"); + if (verbose < 3) gSystem->RedirectOutput("/dev/null","w"); if (cl.Contains("proof", TString::kIgnoreCase) || cl.Contains("lite", TString::kIgnoreCase) || cl.Contains("aaf", TString::kIgnoreCase)) { @@ -328,7 +330,7 @@ struct Helper gROOT->LoadMacro(Form("%s.C++g",cl.Data())); Long_t ptr = gROOT->ProcessLine(Form("new %s(\"%s\", %d);", cl.Data(), url.GetUrl(), verbose)); - if (verbose > 3) gSystem->RedirectOutput(0); + if (verbose < 3) gSystem->RedirectOutput(0); if (!ptr) { Warning("Helper::CreateObject", "Failed to instantize a %s", cl.Data()); return 0; diff --git a/PWGLF/FORWARD/trains/TrainSetup.C b/PWGLF/FORWARD/trains/TrainSetup.C index bb91be17236..a1092e72221 100644 --- a/PWGLF/FORWARD/trains/TrainSetup.C +++ b/PWGLF/FORWARD/trains/TrainSetup.C @@ -315,21 +315,11 @@ struct TrainSetup { if (!fOptions.Has("help")) return true; - if (asProg) - o << "Usage: runTrain2 --name=NAME --class=CLASS [OPTIONS]"; - else + if (!asProg) o << "Usage: RunTrain(NAME, CLASS, OPTIONS)"; - o << "\n\nOptions:\n\n"; - if (asProg) { - OptionList tmp(fOptions); - tmp.Add("name", "STRING", "Name of train", fName); - tmp.Add("class", "NAME", "Name of setup class", ""); - tmp.Help(o," --"); - } - else - fOptions.Help(o, " "); - + o << "\n\nTrain Options:\n"; + fOptions.Help(o, asProg ? " --" : " "); o << "\n"; if (!fHelper && fOptions.Has("url")) { @@ -368,7 +358,8 @@ struct TrainSetup */ static Bool_t Main(const TString& name, const TString& cls, const TCollection* opts, - Bool_t asProg=true) + Bool_t asProg=true, + Bool_t spawn=false) { Bool_t ret = false; try { @@ -377,10 +368,13 @@ struct TrainSetup if (name.IsNull()) throw TString("No train name specified"); + gROOT->ProcessLine("gSystem->RedirectOutput(\"build.log\",\"w\");"); Int_t error = 0; Int_t r1 = gROOT->LoadMacro(Form("%s.C++g", cls.Data()), &error); + gROOT->ProcessLine("gSystem->RedirectOutput(0);"); if (r1 < 0 || error) - throw TString::Format("Failed to load setup %s: %d", cls.Data(), error); + throw TString::Format("Failed to load setup %s: %d - see build.log", + cls.Data(), error); // Make our object using the interpreter TString create = TString::Format("new %s(\"%s\")", @@ -413,8 +407,10 @@ struct TrainSetup if (!e.IsNull()) Error("Main", "%s", e.Data()); } if (gApplication && asProg) { - gSystem->Sleep(3); - gApplication->Terminate(ret ? 0 : 1); + if (!spawn) { + gSystem->Sleep(3); + gApplication->Terminate(ret ? 0 : 1); + } } return ret; } @@ -526,7 +522,7 @@ protected: */ virtual void CreateCentralitySelection(Bool_t mc, AliAnalysisManager* mgr) { - gROOT->Macro("AddTaskCentrality.C"); + gROOT->Macro("AddTaskCentrality.C(true)"); const char* name = "CentralitySelection"; AliCentralitySelectionTask* ctask = dynamic_cast(mgr->GetTask(name)); @@ -540,6 +536,12 @@ protected: * @param mgr Manager */ virtual void CreateTasks(AliAnalysisManager* mgr)=0; + /** + * Set the name of the train - should be name of the class. Must be + * overloaded. + * + * @return Class name as a constant C string + */ virtual const Char_t* ClassName() const = 0; /* @} */ //__________________________________________________________________ diff --git a/PWGLF/FORWARD/trains/trainMain.cxx b/PWGLF/FORWARD/trains/trainMain.cxx index 507e7a91b5d..2aa4ad893ff 100644 --- a/PWGLF/FORWARD/trains/trainMain.cxx +++ b/PWGLF/FORWARD/trains/trainMain.cxx @@ -25,6 +25,7 @@ #include "TrainSetup.C" #include +#include #include #include #include @@ -40,11 +41,12 @@ struct Deferred : public TTimer { Deferred(const TString& name, const TString& cls, - const TCollection* opts) + const TCollection* opts, bool spawn) : TTimer(1000, false), fName(name), fClass(cls), - fOptions(opts) + fOptions(opts), + fSpawn(spawn) { Start(1000, true); } @@ -52,7 +54,8 @@ struct Deferred : public TTimer : TTimer(), fName(o.fName), fClass(o.fClass), - fOptions(o.fOptions) + fOptions(o.fOptions), + fSpawn(o.fSpawn) {} Deferred& operator=(const Deferred& o) { @@ -60,6 +63,7 @@ struct Deferred : public TTimer fName = o.fName; fClass = o.fClass; fOptions = o.fOptions; + fSpawn = o.fSpawn; return *this; } Bool_t Notify() @@ -67,11 +71,12 @@ struct Deferred : public TTimer // gSystem->RemoveTimer(this); Info("Notify", "Will run train setup: %s (%s)", fName.Data(), fClass.Data()); - return TrainSetup::Main(fName, fClass, fOptions); + return TrainSetup::Main(fName, fClass, fOptions, fSpawn); } TString fName; TString fClass; const TCollection* fOptions; + Bool_t fSpawn; }; /** @@ -98,9 +103,21 @@ void AppendPath(const char* dir) */ void PrintFakeOption(std::ostream& o, const char* opt, const char* desc) { - o << " --" << std::left << std::setw(30) << opt << " " << desc << std::endl; + o << " --" << std::left << std::setw(30) << opt << " " << desc + << std::right << std::endl; } +void ProgramUsage(const char* progname, std::ostream& o) +{ + o << "Usage: " << progname + << " --class=CLASS --name=NAME --url=URI [OPTIONS]\n\n" + << progname << " specific options:\n"; + PrintFakeOption(o, "class=CLASS", "Train class"); + PrintFakeOption(o, "name=NAME", "Name of train"); + PrintFakeOption(o, "include=DIRECTORY", "Append dir to macro/header path"); + PrintFakeOption(o, "batch", "Batch mode"); + PrintFakeOption(o, "spawn", "Spawn interactive ROOT shell"); +} /** * Print usage information * @@ -112,13 +129,7 @@ void PrintFakeOption(std::ostream& o, const char* opt, const char* desc) */ void Usage(const char* progname, std::ostream& o) { - o << "Usage: " << progname - << " --class=CLASS --name=NAME --url=URI [OPTIONS]\n\n" - << "PROGRAM OPTIONS:\n"; - PrintFakeOption(o, "class=CLASS", "Train class"); - PrintFakeOption(o, "name=NAME", "Name of train"); - PrintFakeOption(o, "include=DIRECTORY", "Append dir to macro/header path"); - PrintFakeOption(o, "batch", "Batch mode"); + ProgramUsage(progname, o); PrintFakeOption(o, "url=URI", "Execution URI"); o << "\nAlternatively to using --url=URI, one can use\n"; PrintFakeOption(o, "where=BASE_URI", "Set protocol, user, host, " @@ -126,7 +137,6 @@ void Usage(const char* progname, std::ostream& o) PrintFakeOption(o, "file=FILE_OR_PATH", "File/path part of URI"); PrintFakeOption(o, "options=OPTIONS", "Query options for URI"); PrintFakeOption(o, "anchor=ANCHOR", "Query anchor for URI"); - } int @@ -142,7 +152,7 @@ main(int argc, char** argv) Bool_t batch = false; Bool_t help = false; Bool_t urlSeen = false; - + Bool_t spawn = true; // --- Parse options ----------------------------------------------- for (int i = 1; i < argc; i++) { if (argv[i][0] == '-' && argv[i][1] == '-') { @@ -160,6 +170,7 @@ main(int argc, char** argv) else if (arg.BeginsWith("--file")) file = val; else if (arg.BeginsWith("--opts")) opts = val; else if (arg.BeginsWith("--anchor")) anchor = val; + else if (arg.BeginsWith("--spawn")) spawn = true; else { if (arg.BeginsWith("--url")) urlSeen = true; optList.Add(new TObjString(&(argv[i][2]))); @@ -180,11 +191,12 @@ main(int argc, char** argv) } // --- check for help ---------------------------------------------- - if (help && cls.IsNull()) { + if (help) { if (cls.IsNull()) { Usage(argv[0], std::cout); return 0; } + ProgramUsage(argv[0], std::cout); optList.Add(new TObjString("help")); } @@ -210,9 +222,15 @@ main(int argc, char** argv) // --- Set-up Application ------------------------------------------ TApplication* app = 0; gROOT->SetBatch(true); - if (!batch) { + if (!batch || spawn) { gROOT->SetBatch(false); - app = new TGApplication("runTrain", 0, 0); + if (!spawn) + app = new TGApplication("runTrain", 0, 0); + else { + TRint* rint = new TRint("runTrain", 0, 0, 0, 0, true); + rint->SetPrompt("runTrain[%3d]> "); + app = rint; + } app->InitializeGraphics(); } @@ -221,7 +239,8 @@ main(int argc, char** argv) if (batch) ret = TrainSetup::Main(name, cls, &optList); else { - new Deferred(name, cls, &optList); + optList.ls(); + new Deferred(name, cls, &optList, spawn); Info("main", "Running application (%s)", gROOT->IsBatch() ? "batch" : "normal"); gApplication->Run(); -- 2.39.3