From 7b59a00b16d50ac97231925df164c0f45eadf984 Mon Sep 17 00:00:00 2001 From: pchrist Date: Sun, 3 Aug 2008 20:27:33 +0000 Subject: [PATCH] Adding the files to be used for the QA of the proton analysis --- PWG2/AliAnalysisTaskProtonsQA.cxx | 166 +++++++++++++++++++++++++++++ PWG2/AliAnalysisTaskProtonsQA.h | 41 +++++++ PWG2/SPECTRA/AliProtonAnalysis.cxx | 2 + PWG2/SPECTRA/AliProtonAnalysis.h | 1 + PWG2/runProtonAnalysisQA.C | 116 ++++++++++++++++++++ 5 files changed, 326 insertions(+) create mode 100644 PWG2/AliAnalysisTaskProtonsQA.cxx create mode 100644 PWG2/AliAnalysisTaskProtonsQA.h create mode 100644 PWG2/runProtonAnalysisQA.C diff --git a/PWG2/AliAnalysisTaskProtonsQA.cxx b/PWG2/AliAnalysisTaskProtonsQA.cxx new file mode 100644 index 00000000000..cef14681e58 --- /dev/null +++ b/PWG2/AliAnalysisTaskProtonsQA.cxx @@ -0,0 +1,166 @@ +#include "TChain.h" +#include "TTree.h" +#include "TString.h" +#include "TList.h" +#include "TH2F.h" +#include "TH1I.h" +#include "TF1.h" +#include "TCanvas.h" +#include "TLorentzVector.h" + +#include "AliAnalysisTask.h" +#include "AliAnalysisManager.h" + +#include "AliESDEvent.h" +#include "AliESDInputHandler.h" +#include "AliMCEventHandler.h" +#include "AliMCEvent.h" +#include "AliStack.h" + +#include "PWG2spectra/SPECTRA/AliProtonAnalysis.h" +#include "AliAnalysisTaskProtonsQA.h" + +// Analysis task used for the QA of the (anti)proton analysis +// Author: Panos Cristakoglou + +ClassImp(AliAnalysisTaskProtonsQA) + +//________________________________________________________________________ +AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA() + : AliAnalysisTask(), fESD(0), fMC(0), + fList(0), fAnalysis(0) { + //Dummy constructor + +} + +//________________________________________________________________________ +AliAnalysisTaskProtonsQA::AliAnalysisTaskProtonsQA(const char *name) +: AliAnalysisTask(name, ""), fESD(0), fAOD(0), fMC(0), fAnalysisType("ESD"), + fList(0), fAnalysis(0), + fElectronFunction(0), fMuonFunction(0), + fPionFunction(0), fKaonFunction(0), fProtonFunction(0), + fFunctionUsed(kFALSE) { + // Constructor + + // Define input and output slots here + // Input slot #0 works with a TChain + DefineInput(0, TChain::Class()); + // Output slot #0 writes into a TList container + DefineOutput(0, TList::Class()); +} + +//________________________________________________________________________ +void AliAnalysisTaskProtonsQA::ConnectInputData(Option_t *) { + // Connect ESD or AOD here + // Called once + + TTree* tree = dynamic_cast (GetInputData(0)); + if (!tree) { + Printf("ERROR: Could not read chain from input slot 0"); + } else { + //tree->SetBranchStatus("*", kFALSE); + //tree->SetBranchStatus("Tracks.*", kTRUE); + + AliESDInputHandler *esdH = dynamic_cast (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()); + + if (!esdH) { + Printf("ERROR: Could not get ESDInputHandler"); + } else + fESD = esdH->GetEvent(); + } + + AliMCEventHandler* mcH = dynamic_cast (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler()); + if (!mcH) { + Printf("ERROR: Could not retrieve MC event handler"); + } + else + fMC = mcH->MCEvent(); +} + +//________________________________________________________________________ +void AliAnalysisTaskProtonsQA::CreateOutputObjects() { + // Create histograms + // Called once + //Prior probabilities + Double_t partFrac[5] = {0.01, 0.01, 0.85, 0.10, 0.05}; + + //proton analysis object + fAnalysis = new AliProtonAnalysis(); + fAnalysis->SetQAOn(); + + //Use of TPConly tracks + fAnalysis->SetQAYPtBins(10, -0.5, 0.5, 12, 0.5, 0.9); //TPC only + fAnalysis->UseTPCOnly(); + fAnalysis->SetMinTPCClusters(50); + fAnalysis->SetMaxChi2PerTPCCluster(3.5); + fAnalysis->SetMaxCov11(2.0); + fAnalysis->SetMaxCov22(2.0); + fAnalysis->SetMaxCov33(0.5); + fAnalysis->SetMaxCov44(0.5); + fAnalysis->SetMaxCov55(2.0); + fAnalysis->SetMaxSigmaToVertexTPC(2.5); + fAnalysis->SetTPCRefit(); + fAnalysis->SetTPCpid(); + + //Combined tracking + /*fAnalysis->SetQAYPtBins(20, -1.0, 1.0, 27, 0.4, 3.1); //combined tracking + fAnalysis->SetMinTPCClusters(50); + fAnalysis->SetMaxChi2PerTPCCluster(3.5); + fAnalysis->SetMaxCov11(2.0); + fAnalysis->SetMaxCov22(2.0); + fAnalysis->SetMaxCov33(0.5); + fAnalysis->SetMaxCov44(0.5); + fAnalysis->SetMaxCov55(2.0); + fAnalysis->SetMaxSigmaToVertexTPC(2.5); + fAnalysis->SetTPCRefit(); + //ITS related cuts - to be used in the case of the analysis of global tracks + fAnalysis->SetMinITSClusters(5); + fAnalysis->SetITSRefit(); + fAnalysis->SetESDpid();*/ + + fAnalysis->SetPriorProbabilities(partFrac); + + fList = new TList(); + fList = GetGlobalQAList(); +} + +//________________________________________________________________________ +void AliAnalysisTaskProtonsQA::Exec(Option_t *) { + // Main loop + // Called for each event + + if (!fESD) { + Printf("ERROR: fESD not available"); + return; + } + + if (!fMC) { + Printf("ERROR: Could not retrieve MC event"); + return; + } + + AliStack* stack = fMC->Stack(); + if (!stack) { + Printf("ERROR: Could not retrieve the stack"); + return; + } + + fAnalysis->RunQA(stack, fESD); + + // Post output data. + PostData(0, fList); +} + +//________________________________________________________________________ +void AliAnalysisTaskProtonsQA::Terminate(Option_t *) { + // Draw result to the screen + // Called once at the end of the query + + fList = dynamic_cast (GetOutputData(0)); + if (!fList) { + Printf("ERROR: fList not available"); + return; + } +} + + diff --git a/PWG2/AliAnalysisTaskProtonsQA.h b/PWG2/AliAnalysisTaskProtonsQA.h new file mode 100644 index 00000000000..b7de42ef2d1 --- /dev/null +++ b/PWG2/AliAnalysisTaskProtonsQA.h @@ -0,0 +1,41 @@ +#ifndef AliAnalysisTaskProtonsQA_cxx +#define AliAnalysisTaskProtonsQA_cxx + +// Analysis task creating a the 2d y-p_t spectrum of p and antip +// Author: Panos Cristakoglou +class TString; +class TList; +class AliESDEvent; +class AliAODEvent; +class AliMCEvent; +class AliProtonAnalysis; +class TF1; + +#include "AliAnalysisTask.h" + +class AliAnalysisTaskProtonsQA : public AliAnalysisTask { + public: + AliAnalysisTaskProtonsQA(); + AliAnalysisTaskProtonsQA(const char *name); + virtual ~AliAnalysisTaskProtonsQA() {} + + virtual void ConnectInputData(Option_t *); + virtual void CreateOutputObjects(); + virtual void Exec(Option_t *option); + virtual void Terminate(Option_t *); + + private: + AliESDEvent *fESD; //ESD object + AliMCEvent *fMC; //MC object + + TList *fList; //TList output object + + AliProtonAnalysis *fAnalysis; //analysis object + + AliAnalysisTaskProtonsQA(const AliAnalysisTaskProtonsQA&); // not implemented + AliAnalysisTaskProtonsQA& operator=(const AliAnalysisTaskProtonsQA&); // not implemented + + ClassDef(AliAnalysisTaskProtonsQA, 1); // example of analysis +}; + +#endif diff --git a/PWG2/SPECTRA/AliProtonAnalysis.cxx b/PWG2/SPECTRA/AliProtonAnalysis.cxx index 16badce15a3..d2fe151994e 100644 --- a/PWG2/SPECTRA/AliProtonAnalysis.cxx +++ b/PWG2/SPECTRA/AliProtonAnalysis.cxx @@ -1282,6 +1282,8 @@ Bool_t AliProtonAnalysis::ReadCorrectionContainer(const char* filename) { //____________________________________________________________________// void AliProtonAnalysis::InitQA() { //Initializes the QA histograms and builds the directory structure + if(!fQAHistograms) SetQAOn(); + //2D histograms TDirectory *dir2D = gDirectory->mkdir("2D"); fGlobalQAList->Add(dir2D); dir2D->cd(); diff --git a/PWG2/SPECTRA/AliProtonAnalysis.h b/PWG2/SPECTRA/AliProtonAnalysis.h index d8a0e0733d1..72e6393e954 100644 --- a/PWG2/SPECTRA/AliProtonAnalysis.h +++ b/PWG2/SPECTRA/AliProtonAnalysis.h @@ -121,6 +121,7 @@ class AliProtonAnalysis : public TObject { } void InitQA(); void RunQA(AliStack *stack, AliESDEvent *esd); + TList *GetGlobalQAList() {return fGlobalQAList;} //Prior probabilities void SetPriorProbabilities(Double_t *partFrac) {for(Int_t i = 0; i < AliPID::kSPECIESN; i++) fPartFrac[i] = partFrac[i];} diff --git a/PWG2/runProtonAnalysisQA.C b/PWG2/runProtonAnalysisQA.C new file mode 100644 index 00000000000..fd6f793228c --- /dev/null +++ b/PWG2/runProtonAnalysisQA.C @@ -0,0 +1,116 @@ +void runProtonAnalysisQA() { + TStopwatch timer; + timer.Start(); + + runProof(200000,"/PWG0/COMMON/run30000X_10TeV_0.5T"); //use data sets + //runProof(200); //use ascii files + + timer.Stop(); + timer.Print(); +} + +//_________________________________________________// +void runProof(Int_t stats = 0, const char* dataset = 0x0) { + TStopwatch timer; + timer.Start(); + + TString outputFilename = "Protons.QA.root"; + + printf("****** Connect to PROOF *******\n"); + TProof::Open("proof://lxb6046.cern.ch"); + gProof->SetParallel(); + + // Enable the Analysis Package + gProof->UploadPackage("STEERBase.par"); + gProof->EnablePackage("STEERBase"); + gProof->UploadPackage("ESD.par"); + gProof->EnablePackage("ESD"); + gProof->UploadPackage("AOD.par"); + gProof->EnablePackage("AOD"); + gProof->UploadPackage("ANALYSIS.par"); + gProof->EnablePackage("ANALYSIS"); + gProof->UploadPackage("ANALYSISalice.par"); + gProof->EnablePackage("ANALYSISalice"); + gProof->UploadPackage("PWG2spectra.par"); + gProof->EnablePackage("PWG2spectra"); + + gProof->Load("AliAnalysisTaskProtonsQA.cxx++"); + + //____________________________________________// + // Make the analysis manager + AliAnalysisManager *mgr = new AliAnalysisManager("TestManager"); + AliVEventHandler* esdH = new AliESDInputHandler; + mgr->SetInputEventHandler(esdH); + AliMCEventHandler *mc = new AliMCEventHandler(); + mgr->SetMCtruthEventHandler(mc); + + //____________________________________________// + // 1st Proton task + AliAnalysisTaskProtonsQA *taskProtonsQA = new AliAnalysisTaskProtonsQA("TaskProtonsQA"); + mgr->AddTask(taskProtonsQA); + + // Create containers for input/output + AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("dataChain", + TChain::Class(),AliAnalysisManager::kInputContainer); + AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("outputList1", + TList::Class(),AliAnalysisManager::kOutputContainer, + outputFilename.Data()); + + //____________________________________________// + mgr->ConnectInput(taskProtonsQA,0,cinput1); + mgr->ConnectOutput(taskProtonsQA,0,coutput1); + if (!mgr->InitAnalysis()) return; + mgr->PrintStatus(); + + if(dataset) + mgr->StartAnalysis("proof",dataset,stats); + else { + // You should get this macro and the txt file from: + // http://aliceinfo.cern.ch/Offline/Analysis/CAF/ + gROOT->LoadMacro("CreateESDChain.C"); + TChain* chain = 0x0; + chain = CreateESDChain("ESD82XX_30K.txt",stats); + chain->SetBranchStatus("*Calo*",0); + + mgr->StartAnalysis("proof",chain); + } + + timer.Stop(); + timer.Print(); +} + +//_________________________________________________// +Int_t setupPar(const char* pararchivename) { + /////////////////// + // Setup PAR File// + /////////////////// + if (pararchivename) { + char processline[1024]; + sprintf(processline,".! tar xvzf %s.par",pararchivename); + gROOT->ProcessLine(processline); + const char* ocwd = gSystem->WorkingDirectory(); + gSystem->ChangeDirectory(pararchivename); + + // check for BUILD.sh and execute + if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) { + printf("*******************************\n"); + printf("*** Building PAR archive ***\n"); + printf("*******************************\n"); + + if (gSystem->Exec("PROOF-INF/BUILD.sh")) { + Error("runAnalysis","Cannot Build the PAR Archive! - Abort!"); + return -1; + } + } + // check for SETUP.C and execute + if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) { + printf("*******************************\n"); + printf("*** Setup PAR archive ***\n"); + printf("*******************************\n"); + gROOT->Macro("PROOF-INF/SETUP.C"); + } + + gSystem->ChangeDirectory("../"); + } + return 1; +} -- 2.43.0