--- /dev/null
+//=============================================================================
+//
+// *** AliRsnAnalysisTask.C ***
+//
+// This macro initialize a complete AnalysisTask object for resonances.
+// All the possibilities are made available through enumerations,
+// with the same style of the Config.C file used for simulation.
+//
+//=============================================================================
+
+
+
+static AliRsnAnalysisTaskSEBase::EInputType inputType = AliRsnAnalysisTaskSEBase::kESDMC;
+
+static Bool_t useAutoHandler = kTRUE;
+static Int_t bufferSize = 3000;
+static Int_t pidArraySize = 2000;
+
+static const char* outputFileName = "rsn.root";
+
+static Bool_t useRsnTrackCuts = kFALSE;
+static Double_t etaRange = 10.0;
+static Double_t rsnImpactParam = 3.0;
+static Double_t ptMin = 0.0;
+
+static Bool_t useESDTrackCuts = kFALSE;
+static Double_t cov11 = 2;
+static Double_t cov22 = 2;
+static Double_t cov33 = 0.5;
+static Double_t cov44 = 0.5;
+static Double_t cov55 = 2;
+static Double_t nSigmaToVertex = 4;
+static Double_t dcaToVertex = 3.0;
+static Double_t maxChi2PerClusterTPC = 3.5;
+static Bool_t requireTPCRefit = kTRUE;
+static Bool_t requireSigmaToVertex = kTRUE;
+static Bool_t acceptKinkDaughters = kFALSE;
+static Int_t minNClustersTPC = 50;
+
+static Int_t nMixedEvents = 5;
+
+Int_t AddRsnAnalysisTask(AliAnalysisManager *mgr)
+{
+//
+// Core method of the macro.
+// Creates and initialized the analysis task object and inserts it
+// into the AnalysisManager object passed as argument.
+//
+
+ // initialize task objects and retrieve managers for PID and reading
+ AliRsnAnalysisSE *task = new AliRsnAnalysisSE("RsnAnalysisTask", bufferSize);
+ AliRsnReader *reader = task->GetReader();
+ AliRsnPID *pid = task->GetPID();
+
+ // set the input type
+ task->SetInputType(inputType, mgr, useAutoHandler);
+
+ // define event-mixing cuts
+ AliRsnCut *cutVz = new AliRsnCut("cutVz" , "", AliRsnCut::kVzDifference, 0.0, 0.5);
+ AliRsnCut *cutMult = new AliRsnCut("cutMult", "", AliRsnCut::kMultiplicityDifference, 0, 10);
+ AliRsnCutSet *cutMixing = new AliRsnCutSet("cutMixing");
+ cutMixing->AddCut(cutVz);
+ cutMixing->AddCut(cutMult);
+ cutMixing->SetCutScheme("cutVz&cutMult");
+ task->SetMixingCut(cutMixing);
+ task->SetMixingNum(nMixedEvents);
+
+ // ESD settings
+ reader->SetCheckSplit(kTRUE);
+ pid->SetPIDArraysSize(pidArraySize);
+ pid->SetPriorProbability(AliRsnPID::kElectron, 0.02);
+ pid->SetPriorProbability(AliRsnPID::kMuon, 0.02);
+ pid->SetPriorProbability(AliRsnPID::kPion, 0.83);
+ pid->SetPriorProbability(AliRsnPID::kKaon, 0.07);
+ pid->SetPriorProbability(AliRsnPID::kProton, 0.06);
+ pid->SetMaxPt(100.0);
+ pid->SetMinProb(0.0);
+
+ // default cuts for ITS+TPC
+ AliESDtrackCuts *esdCuts = reader->GetESDTrackCuts();
+ esdCuts->SetMaxCovDiagonalElements(cov11, cov22, cov33, cov44, cov55);
+ esdCuts->SetRequireSigmaToVertex(requireSigmaToVertex);
+ if (requireSigmaToVertex) esdCuts->SetMaxNsigmaToVertex(nSigmaToVertex);
+ else
+ {
+ esdCuts->SetDCAToVertexZ(dcaToVertex);
+ esdCuts->SetDCAToVertexXY(dcaToVertex);
+ }
+ esdCuts->SetRequireTPCRefit(requireTPCRefit);
+ esdCuts->SetAcceptKingDaughters(acceptKinkDaughters);
+ esdCuts->SetMinNClustersTPC(minNClustersTPC);
+ esdCuts->SetMaxChi2PerClusterTPC(maxChi2PerClusterTPC);
+ reader->SetUseESDTrackCuts(useESDTrackCuts);
+
+ // default cuts from package for tracks
+ AliRsnCut *cutPt = new AliRsnCut("cutPt", "", AliRsnCut::kTransMomentumMC, ptMin, 1000000.0);
+ AliRsnCut *cutEta = new AliRsnCut("cutEtaMC", "", AliRsnCut::kEtaMC, -etaRange, etaRange);
+ AliRsnCut *cutDr = new AliRsnCut("cutDr", "", AliRsnCut::kRadialImpactParam, 0.0, rsnImpactParam);
+ AliRsnCutSet *rsnCuts = reader->GetRsnTrackCuts();
+ rsnCuts->AddCut(cutPt);
+ rsnCuts->AddCut(cutEta);
+ rsnCuts->AddCut(cutDr);
+ rsnCuts->SetCutScheme("cutPt&cutEta&cutDr");
+ reader->SetUseRsnTrackCuts(useRsnTrackCuts);
+
+ // add configs for all impact parameters
+ task->AddPairMgrFromMacro("CreatePairsPhi.C");
+
+ // initialize containers
+ AliAnalysisDataContainer *input = mgr->CreateContainer("in", TChain::Class(), AliAnalysisManager::kInputContainer);
+ AliAnalysisDataContainer *dummy = mgr->CreateContainer("dummy1", TTree::Class(), AliAnalysisManager::kOutputContainer, "default");
+ AliAnalysisDataContainer *out = mgr->CreateContainer("RSN", TList::Class(), AliAnalysisManager::kOutputContainer, outputFileName);
+
+ // connect containers to AnalysisManager
+ mgr->AddTask(task);
+ mgr->ConnectInput(task, 0, input);
+ mgr->ConnectOutput(task, 0, dummy);
+ mgr->ConnectOutput(task, 1, out);
+}
--- /dev/null
+//=============================================================================
+//
+// *** AliRsnAnalysis.C ***
+//
+// This macro contains all stuff which is required to run
+// a resonance analysis in whatever environment.
+// It contains a pool of macroes which do all the steps to set it up
+// and run it with the appropriate configurations.
+// All the possibilities are made available through enumerations,
+// with the same style of the Config.C file used for simulation.
+//
+//=============================================================================
+
+#include <TProof.h>
+
+enum Rsn_DataSource
+{
+ kTextFile, // text file with paths of all used files (local analysis)
+ kXMLCollection, // XML collection of files (local/AliEn analysis)
+ kDataset // CAF dataset
+};
+
+static Bool_t cleanPars = kTRUE;
+static Bool_t cleanPWG2resonances = kFALSE;
+static const char* listPar = "STEERBase:ESD:AOD:ANALYSIS:ANALYSISalice:PWG2resonances";
+static const char* proofConnection = "pulvir@alicecaf.cern.ch";
+
+static Bool_t isProof = kFALSE;
+static Rsn_DataSource listType = kTextFile;
+
+static const char* inputSource = "local.txt";
+static Int_t nReadFiles = 2;
+static Int_t nSkippedFiles = 0;
+static TString treeName = "esdTree";
+
+//_________________________________________________________________________________________________
+Bool_t CleanPars(const char *pars)
+{
+//
+// Cleans existing PAR library directories.
+// The string argument must contain their names
+// separated by colons (':').
+// Returns kTRUE if everything went well, otherwise returns kFALSE.
+//
+
+ TString list(pars);
+ TObjArray* array = list.Tokenize(":");
+ TObjString *ostr;
+ TString str;
+
+ for (Int_t i = 0; i < array->GetEntriesFast(); i++)
+ {
+ ostr = (TObjString *) array->At(i);
+ str = ostr->GetString();
+ Info("", ">> Cleaning PARs: %s", str.Data());
+ if (isProof) {
+ if (!gProof) {
+ Error("CleanPars", "gProof object not initialized");
+ return kFALSE;
+ }
+ gProof->ClearPackage(Form("%s.par", str.Data()));
+ }
+ else {
+ gSystem->Exec(Form("rm -Rf %s/", str.Data()));
+ }
+ }
+
+ return kTRUE;
+}
+
+//_________________________________________________________________________________________________
+Bool_t LoadPars(TString pars)
+{
+//
+// Loads required PAR libraries.
+// The string argument must contain their names
+// separated by colons (':').
+// Returns kTRUE if everything went well, otherwise returns kFALSE.
+//
+
+ TObjArray *array = pars.Tokenize(":");
+ TObjString *ostr;
+ TString str;
+
+ for (Int_t i = 0; i < array->GetEntriesFast(); i++) {
+ ostr = (TObjString *) array->At(i);
+ str = ostr->GetString();
+ Info("", ">> Creating PARs: %s", str.Data());
+ if (isProof) {
+ if (!gProof) {
+ Error("CleanPars", "gProof object not initialized");
+ return kFALSE;
+ }
+ gProof->UploadPackage(Form("%s.par", str.Data()));
+ gProof->EnablePackage(str.Data());
+ }
+ else {
+ // check that file exists...
+ if (gSystem->AccessPathName(Form("%s.par", str.Data()))) {
+ Error("", " !!! File not found");
+ return kFALSE;
+ }
+ // ...explode tar-ball...
+ gROOT->ProcessLine(Form(".! tar xzf %s.par", str.Data()));
+ // ...go to unpacked directory of PAR library...
+ TString ocwd = gSystem->WorkingDirectory();
+ gSystem->ChangeDirectory(Form("%s", str.Data()));
+ // ...checks for BUILD.sh and execute it...
+ if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
+ if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
+ Error("", " !!! Build error");
+ return kFALSE;
+ }
+ }
+ // ...check and execute SETUP.C...
+ if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
+ if (gROOT->Macro("PROOF-INF/SETUP.C")) {
+ Error("", " !!! Set-up error");
+ return kFALSE;
+ }
+ }
+ // ...return to main dir and finish
+ gSystem->ChangeDirectory(ocwd);
+ }
+ }
+
+ return kTRUE;
+}
+
+//_________________________________________________________________________________________________
+TChain* CreateChainFromTXT()
+{
+//
+// Create a TChain of files to be analyzed from a text file.
+// This text file must contain in each line the FULL PATH of an analyzed file.
+// Last argument specifies the TTree name.
+//
+
+ TChain *chain = new TChain(treeName.Data());
+
+ ifstream fileIn(inputSource);
+ Int_t count = 0, skip = nSkippedFiles;
+
+ TString line;
+ while (fileIn.good()) {
+ fileIn >> line;
+ if (line.IsNull()) continue;
+ if (skip > 0) {
+ --skip;
+ continue;
+ }
+ if (nReadFiles > 0 && count++ >= nReadFiles) break;
+ chain->Add(Form("%s", line.Data()));
+ }
+ fileIn.close();
+
+ return chain;
+}
+
+//_________________________________________________________________________________________________
+TChain* CreateChainFromXML
+(const char *fileName, Int_t nread = 0, Int_t nskip = 0, const char *treeName = "esdTree")
+{
+//
+// Create a TChain of files to be analyzed from a XML file.
+// Last argument specifies the TTree name.
+//
+
+ TChain *chain = new TChain(treeName.Data());
+ TAlienCollection *myCollection = TAlienCollection::Open(inputSource);
+ if (!myCollection)
+ {
+ Error("CreateChainFromXML", "Cannot create an AliEn collection from %s", collectionFile);
+ return 0x0;
+ }
+
+ // initialize a counter to check the number of read files
+ Int_t nfiles = 0, skip = nSkippedFiles;
+ TString filename;
+ myCollection->Reset();
+ while (myCollection->Next())
+ {
+ if (skip > 0) { --skip; continue; }
+ if (nReadFiles > 0 && nfiles >= nReadFiles) break;
+ // char fileName[255];
+ // sprintf(fileName, "%s", myCollection->GetTURL(""));
+ filename = myCollection->GetTURL("");
+ chain->Add(filename.Data());
+ nfiles++;
+ }
+
+ return chain;
+}
+
+//_________________________________________________________________________________________________
+TChain* CreateChainFromDataset()
+{
+//
+// Create a TChain of files to be analyzed from a CAF dataset.
+// Last argument specifies the TTree name.
+//
+
+ if (!gProof) {
+ Error("CreateChainFromDataset", "gProof object not initialized");
+ return kFALSE;
+ }
+
+ TFileCollection *fc = gProof->GetDataSet(inputSource)->GetStagedSubset();
+ TIter iter(fc->GetList());
+
+ TChain* target = new TChain(treeName.Data());
+
+ TFileInfo* fileInfo = 0;
+ Int_t nfiles = 0, skip = nSkippedFiles;
+ while ((fileInfo = dynamic_cast<TFileInfo*> (iter()))) {
+ if (fileInfo->GetFirstUrl()) {
+ if (skip > 0) { --skip; continue; }
+ if (nReadFiles > 0 && nfiles >= nReadFiles) break;
+ target->Add(fileInfo->GetFirstUrl()->GetUrl());
+ nfiles++;
+ }
+ }
+
+ return target;
+}
+
+//_________________________________________________________________________________________________
+Int_t AliRsnAnalysis(const char *addMacro = "AddRsnAnalysisTask.C")
+{
+//
+// Main macro (named after the macro filename).
+// It initializes the job, creates the AnalysisManager and calls the config macro which
+// fills this AnalysisManager with all AnalysisTask objects for resonance analysis.
+// ---
+// The argument is the name of the macro used for configuration
+// ---
+// Return values:
+// - 0 = successful execution
+// - 1 = problem while cleanind PAR libraries
+// - 2 = problem while loading PAR libraries
+// - 3 = invalid TTree name (allowed: esdTree, aodTree)
+// - 4 = data source not found
+// - 5 = wrong definition of source type (allowed any member of enum Rsn_DataSource)
+// - 6 = TChain initialization returned a NULL object
+// - 7 = error while initializing AliAnalysisManager object
+//
+
+ // connect to PROOF if required
+ if (isProof) TProof::Open(proofConnection);
+
+ //
+ // *** SETUP PAR LIBRARIES **********************************************************************
+ // - libraries are cleaned if requested
+ //
+
+ if (cleanPars) {
+ if (!CleanPars(listPar)) {
+ Error("AliRsnAnalysis", "Error while cleaning PAR libraries");
+ return 1;
+ }
+ }
+ if (cleanPWG2resonances) CleanPars("PWG2resonances");
+ if (!LoadPars(listPar)) {
+ Error("AliRsnAnalysis", "Error while initializing PAR libraries");
+ return 2;
+ }
+
+ // set up log level
+ AliLog::SetGlobalLogLevel(AliLog::kError);
+
+ // *** CREATE TChain OF INPUT EVENTS ************************************************************
+
+ // preliminary check #1: is the tree name OK?
+ if (treeName != "esdTree" && treeName != "aodTree") {
+ Error("AliRsnAnalysis", "Invalid tree name specified");
+ return 3;
+ }
+
+ // preliminary check #2: does the input source exist?
+ // (valid only for local files and XML collections)
+ if (listType == kTextFile || listType == kXMLCollection) {
+ Long_t id, size, flags, modtime;
+ if (gSystem->GetPathInfo(inputSource, &id, &size, &flags, &modtime)) {
+ Error("AliRsnAnalysis", "Input source not found");
+ return 4;
+ }
+ }
+
+ // create TChain
+ TChain *analysisChain = 0;
+ switch (listType) {
+ case kTextFile:
+ analysisChain = CreateChainFromTXT();
+ break;
+ case kXMLCollection:
+ analysisChain = CreateChainFromXML();
+ break;
+ case kDataset:
+ analysisChain = CreateChainFromDataset();
+ break;
+ default:
+ Error("AliRsnAnalysis", "Input type not supported");
+ return 5;
+ }
+ if (!analysisChain) {
+ Error("AliRsnAnalysis", "Analysis TChain not properly initialized");
+ return 6;
+ }
+
+ //
+ // *** INITIALIZE ANALYSIS MANAGER **************************************************************
+ //
+
+ AliAnalysisManager *mgr = new AliAnalysisManager("ResonanceAnalysis");
+ if (!mgr) {
+ Error("AliRsnAnalysis", "Error occurred while initializing AnalysisManager");
+ return 7;
+ }
+
+ // load configuration macro and uses it to initialize this object
+ gROOT->LoadMacro(addMacro);
+ AddRsnAnalysisTask(mgr);
+
+ // initialize analysis and run it
+ TString strEnv = (isProof ? "proof" : "local");
+ TStopwatch timer;
+ timer.Start();
+ mgr->InitAnalysis();
+ mgr->StartAnalysis(strEnv.Data(), analysisChain);
+ timer.Stop();
+ timer.Print();
+}