X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=PWG1%2FAliAnaFwdDetsQA.cxx;h=0c17c1591f080f832edb0f05b9e44817e10b50e9;hb=6e65c8a68e8909020d265026ba7f173f18179906;hp=ae8cac0482c0d65b34c96cb4cdb47d63ffe2cf5c;hpb=8b04dae19ec4f00fb1d570720ce10c183f511d10;p=u%2Fmrichter%2FAliRoot.git diff --git a/PWG1/AliAnaFwdDetsQA.cxx b/PWG1/AliAnaFwdDetsQA.cxx index ae8cac0482c..0c17c1591f0 100644 --- a/PWG1/AliAnaFwdDetsQA.cxx +++ b/PWG1/AliAnaFwdDetsQA.cxx @@ -96,9 +96,9 @@ AliAnalysisTaskSE(name), fV0ampl(0) { // Constructor - AliInfo("Constructor AliAnaFwdDetsQA"); // Define input and output slots here // Input slot #0 works with a TChain + AliInfo("Constructor AliAnaFwdDetsQA"); DefineInput(0, TChain::Class()); // Output slot #1 TList DefineOutput(1, TList::Class()); @@ -108,7 +108,8 @@ TH1F * AliAnaFwdDetsQA::CreateHisto(const char* name, const char* title,Int_t nB Double_t xMin, Double_t xMax, const char* xLabel, const char* yLabel) { - // create a histogram + // helper method which can be used + // in order to create a histogram TH1F* result = new TH1F(name, title, nBins, xMin, xMax); result->SetOption("E"); if (xLabel) result->GetXaxis()->SetTitle(xLabel); @@ -119,7 +120,8 @@ TH1F * AliAnaFwdDetsQA::CreateHisto(const char* name, const char* title,Int_t nB TH1F *AliAnaFwdDetsQA::CreateEffHisto(const TH1F* hGen, const TH1F* hRec) { - // create an efficiency histogram + // helper method which can be used + // in order create an efficiency histogram Int_t nBins = hGen->GetNbinsX(); TH1F* hEff = (TH1F*) hGen->Clone("hEff"); hEff->SetTitle(""); @@ -135,7 +137,7 @@ TH1F *AliAnaFwdDetsQA::CreateEffHisto(const TH1F* hGen, const TH1F* hRec) Double_t eff = nRecEff/nGenEff; hEff->SetBinContent(iBin, 100. * eff); Double_t error = sqrt(eff*(1.-eff) / nGenEff); - if (error == 0) error = 0.0001; + if (error < 1e-12) error = 0.0001; hEff->SetBinError(iBin, 100. * error); } else { @@ -149,7 +151,8 @@ TH1F *AliAnaFwdDetsQA::CreateEffHisto(const TH1F* hGen, const TH1F* hRec) Bool_t AliAnaFwdDetsQA::FitHisto(TH1* histo, Double_t& res, Double_t& resError) { - // fit a gaussian to a histogram + // fit a gaussian to + // a histogram static TF1* fitFunc = new TF1("fitFunc", "gaus"); fitFunc->SetLineWidth(2); fitFunc->SetFillStyle(0); @@ -172,8 +175,8 @@ Bool_t AliAnaFwdDetsQA::FitHisto(TH1* histo, Double_t& res, Double_t& resError) void AliAnaFwdDetsQA::UserCreateOutputObjects() { // Create histograms - AliInfo("AliAnaFwdDetsQA::UserCreateOutputObjects"); // Create output container + AliInfo("AliAnaFwdDetsQA::UserCreateOutputObjects"); fListOfHistos = new TList(); fT0vtxRec = CreateHisto("hT0vtxRec", "Z vertex reconstructed with T0", 100, -25, 25, "Z_{vtx} [cm]", ""); @@ -229,7 +232,8 @@ void AliAnaFwdDetsQA::UserCreateOutputObjects() void AliAnaFwdDetsQA::UserExec(Option_t */*option*/) { - + // The analysis code + // goes here AliMCEvent* mcEvent = MCEvent(); if (!mcEvent) { Printf("ERROR: Could not retrieve MC event"); @@ -271,6 +275,10 @@ void AliAnaFwdDetsQA::UserExec(Option_t */*option*/) } AliESDEvent* esd = dynamic_cast(event); + if (!esd) { + Printf("ERROR: Could not retrieve esd"); + return; + } const AliESDTZERO* esdT0 = esd->GetESDTZERO(); Double_t t0zvtx = esdT0->GetT0zVertex(); Double_t t0time = esdT0->GetT0(); @@ -311,96 +319,14 @@ void AliAnaFwdDetsQA::UserExec(Option_t */*option*/) void AliAnaFwdDetsQA::Terminate(Option_t *) { + // Terminate + // Store the output histos fListOfHistos = dynamic_cast(GetOutputData(1)); if (!fListOfHistos) { Printf("ERROR: fListOfHistos not available"); return; } - fT0vtxRec = dynamic_cast(fListOfHistos->At(0)); - fT0time = dynamic_cast(fListOfHistos->At(1)); - fT0mult = dynamic_cast(fListOfHistos->At(2)); - fT0vtxRecGen = dynamic_cast(fListOfHistos->At(3)); - fT0vtxRes = dynamic_cast(fListOfHistos->At(4)); - - fV0a = dynamic_cast(fListOfHistos->At(5)); - fV0c = dynamic_cast(fListOfHistos->At(6)); - fV0multA = dynamic_cast(fListOfHistos->At(7)); - fV0multC = dynamic_cast(fListOfHistos->At(8)); - fV0multAcorr = dynamic_cast(fListOfHistos->At(9)); - fV0multCcorr = dynamic_cast(fListOfHistos->At(10)); - fV0Acorr = dynamic_cast(fListOfHistos->At(11)); - fV0Ccorr = dynamic_cast(fListOfHistos->At(12)); - - fT0ampl = dynamic_cast(fListOfHistos->At(13)); - fV0ampl = dynamic_cast(fListOfHistos->At(14)); - fT0time2 = dynamic_cast(fListOfHistos->At(15)); - - - // draw the histograms if not in batch mode - if (!gROOT->IsBatch()) { - new TCanvas; - fT0vtxRec->DrawCopy("E"); - new TCanvas; - fT0time->DrawCopy("E"); - new TCanvas; - fT0mult->DrawCopy("E"); - new TCanvas; - fT0vtxRes->DrawCopy("E"); - new TCanvas; - fT0vtxRecGen->DrawCopy(); - new TCanvas; - fV0a->DrawCopy("E"); - new TCanvas; - fV0c->DrawCopy("E"); - new TCanvas; - fV0multA->DrawCopy("E"); - new TCanvas; - fV0multC->DrawCopy("E"); - new TCanvas; - fV0multAcorr->DrawCopy(); - new TCanvas; - fV0multCcorr->DrawCopy(); - new TCanvas; - fV0Acorr->DrawCopy(); - new TCanvas; - fV0Ccorr->DrawCopy(); - new TCanvas; - fT0ampl->DrawCopy("E"); - new TCanvas; - fV0ampl->DrawCopy("E"); - new TCanvas; - fT0time2->DrawCopy("E"); - } - - // write the output histograms to a file - TFile* outputFile = TFile::Open("FwdDetsQA.root", "recreate"); - if (!outputFile || !outputFile->IsOpen()) - { - Error("AliAnaFwdDetsQA", "opening output file FwdDetsQA.root failed"); - return; - } - fT0vtxRec->Write(); - fT0time->Write(); - fT0mult->Write(); - fT0vtxRecGen->Write(); - fT0vtxRes->Write(); - fT0ampl->Write(); - fT0time2->Write(); - - fV0a->Write(); - fV0c->Write(); - fV0multA->Write(); - fV0multC->Write(); - fV0multAcorr->Write(); - fV0multCcorr->Write(); - fV0Acorr->Write(); - fV0Ccorr->Write(); - fV0ampl->Write(); - - outputFile->Close(); - delete outputFile; - //delete esd; Info("AliAnaFwdDetsQA", "Successfully finished"); }