From cbf2835640b69aa453a60d281d68666b68355002 Mon Sep 17 00:00:00 2001 From: pchrista Date: Tue, 29 Oct 2013 12:37:04 +0000 Subject: [PATCH] New macros for the train (Naghmeh) --- .../macros/AddTaskFlowHigherOrdersAllPID.C | 389 +++++++++++++ .../macros/runTaskFlowHigherOrdersAllPID.C | 520 ++++++++++++++++++ 2 files changed, 909 insertions(+) create mode 100644 PWGCF/FLOW/macros/AddTaskFlowHigherOrdersAllPID.C create mode 100644 PWGCF/FLOW/macros/runTaskFlowHigherOrdersAllPID.C diff --git a/PWGCF/FLOW/macros/AddTaskFlowHigherOrdersAllPID.C b/PWGCF/FLOW/macros/AddTaskFlowHigherOrdersAllPID.C new file mode 100644 index 00000000000..b32f22dc903 --- /dev/null +++ b/PWGCF/FLOW/macros/AddTaskFlowHigherOrdersAllPID.C @@ -0,0 +1,389 @@ +///////////////////////////////////////////////////////////////////////////////////////////// +// +// AddTask* macro for flow analysis +// Creates a Flow Event task and adds it to the analysis manager. +// Sets the cuts using the correction framework (CORRFW) classes. +// Also creates Flow Analysis tasks and connects them to the output of the flow event task. +// +///////////////////////////////////////////////////////////////////////////////////////////// +#include +#include + +void AddTaskFlowHigherOrdersAllPID(Int_t triggerSelectionString, + Float_t centrMin=0., + Float_t centrMax=100., + TString fileNameBase="output", + Bool_t isPID = kTRUE, + Int_t AODfilterBitRP = 768, + Int_t AODfilterBitPOI = 768, + AliPID::EParticleType particleType=AliPID::kPion, + AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFbayesian, + Int_t charge=0, + Bool_t doQA=kFALSE, + Float_t etamin=-0.8, + Float_t etamax=0.8, + TString uniqueStr="" ) { + // Define the range for eta subevents (for SP method) + Double_t minA = -0.8;// + Double_t maxA = 0.8;// + Double_t minB = -0.8;// + Double_t maxB = 0.8;// + + // AFTERBURNER + Bool_t useAfterBurner=kFALSE; + Double_t v1=0.0; + Double_t v2=0.0; + Double_t v3=0.0; + Double_t v4=0.0; + Int_t numberOfTrackClones=0; //non-flow + + // Define a range of the detector to exclude + Bool_t ExcludeRegion = kFALSE; + Double_t excludeEtaMin = -0.; + Double_t excludeEtaMax = 0.; + Double_t excludePhiMin = 0.; + Double_t excludePhiMax = 0.; + + // use physics selection class + Bool_t UsePhysicsSelection = kTRUE; + + // QA + Bool_t runQAtask=kFALSE; + Bool_t FillQAntuple=kFALSE; + Bool_t DoQAcorrelations=kFALSE; + + // RUN SETTINGS + // Flow analysis method can be:(set to kTRUE or kFALSE) + Bool_t SP = kTRUE; // scalar product method (similar to eventplane method) + Bool_t QC = kTRUE; // cumulants using Q vectors + + //these are OBSOLETE, use at own peril + Bool_t GFC = kFALSE; // cumulants based on generating function + Bool_t MCEP = kFALSE; // correlation with Monte Carlo reaction plane + Bool_t FQD = kFALSE; // fit of the distribution of the Q vector (only integrated v) + Bool_t LYZ1SUM = kFALSE; // Lee Yang Zeroes using sum generating function (integrated v) + Bool_t LYZ1PROD = kFALSE; // Lee Yang Zeroes using product generating function (integrated v) + Bool_t LYZ2SUM = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v) + Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v) + Bool_t LYZEP = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight) + Bool_t MH = kFALSE; // azimuthal correlators in mixed harmonics + Bool_t NL = kFALSE; // nested loops (for instance distribution of phi1-phi2 for all distinct pairs) + + Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL}; + + // Boolean to use/not use weights for the Q vector + Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta) + + // SETTING THE CUTS + + //---------Data selection---------- + //kMC, kGlobal, kESD_TPConly, kESD_SPDtracklet + AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kTPCstandalone; + AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kTPCstandalone; + + //---------Parameter mixing-------- + //kPure - no mixing, kTrackWithMCkine, kTrackWithMCPID, kTrackWithMCpt + AliFlowTrackCuts::trackParameterMix rpmix = AliFlowTrackCuts::kPure; + AliFlowTrackCuts::trackParameterMix poimix = AliFlowTrackCuts::kPure; + + + const char* rptypestr = AliFlowTrackCuts::GetParamTypeName(rptype); + const char* poitypestr = AliFlowTrackCuts::GetParamTypeName(poitype); + + //=========================================================================== + // EVENTS CUTS: + AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("event cuts"); + cutsEvent->SetCentralityPercentileRange(centrMin,centrMax); + cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0); +// cutsEvent->SetRefMultMethod(AliFlowEventCuts::kVZERO); + //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets); + //cutsEvent->SetNContributorsRange(2); + cutsEvent->SetPrimaryVertexZrange(-10.,10.); + cutsEvent->SetQA(doQA); + cutsEvent->SetCutTPCmultiplicityOutliers(); + + // RP TRACK CUTS: +// AliFlowTrackCuts* cutsRP2 = AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts(); + AliFlowTrackCuts* cutsRP = new AliFlowTrackCuts("TPConlyRP"); + cutsRP->SetParamType(rptype); + cutsRP->SetParamMix(rpmix); + cutsRP->SetPtRange(0.2,5.); + cutsRP->SetEtaRange(etamin,etamax); + cutsRP->SetMinNClustersTPC(70); +// cutsRP->SetMinChi2PerClusterTPC(0.1);// + // cutsRP->SetMaxChi2PerClusterTPC(4.0);// + cutsRP->SetMaxDCAToVertexXY(3.0); + cutsRP->SetMaxDCAToVertexZ(3.0); + cutsRP->SetAcceptKinkDaughters(kFALSE); + cutsRP->SetMinimalTPCdedx(10.); + cutsRP->SetAODfilterBit(AODfilterBitRP); +// cutsRP->SetAODfilterBit(768); +cutsRP->SetQA(doQA); + + // POI TRACK CUTS: + AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("TPConlyPOI"); + cutsPOI->GetBayesianResponse()->ForceOldDedx(); // for 2010 data to use old TPC PID Response instead of the official one + cutsPOI->SetParamType(poitype); + cutsPOI->SetParamMix(poimix); + cutsPOI->SetPtRange(0.2,5.);// + cutsPOI->SetEtaRange(etamin,etamax); + //cutsPOI->SetRequireCharge(kTRUE); + //cutsPOI->SetPID(PdgRP); + cutsPOI->SetMinNClustersTPC(70); + // cutsPOI->SetMinChi2PerClusterTPC(0.1); // + // cutsPOI->SetMaxChi2PerClusterTPC(4.0); // +// cutsPOI->SetRequireITSRefit(kTRUE); +// cutsPOI->SetRequireTPCRefit(kTRUE); +// cutsPOI->SetMinNClustersITS(2); + //cutsPOI->SetMaxChi2PerClusterITS(1.e+09); + cutsPOI->SetMaxDCAToVertexXY(3.0); + cutsPOI->SetMaxDCAToVertexZ(3.0); + //cutsPOI->SetDCAToVertex2D(kTRUE); + //cutsPOI->SetMaxNsigmaToVertex(1.e+10); + //cutsPOI->SetRequireSigmaToVertex(kFALSE); + cutsPOI->SetAcceptKinkDaughters(kFALSE); + if(isPID) cutsPOI->SetPID(particleType, sourcePID);//particleType, sourcePID + if (charge!=0) cutsPOI->SetCharge(charge); + //cutsPOI->SetAllowTOFmismatch(kFALSE); + cutsPOI->SetRequireStrictTOFTPCagreement(kTRUE); + //iexample: francesco's tunig TPC Bethe Bloch for data: + //cutsPOI->GetESDpid().GetTPCResponse().SetBetheBlochParameters(4.36414e-02,1.75977e+01,1.14385e-08,2.27907e+00,3.36699e+00); + //cutsPOI->GetESDpid().GetTPCResponse().SetMip(49); + cutsPOI->SetMinimalTPCdedx(10.); + cutsPOI->SetAODfilterBit(AODfilterBitPOI); + // cutsPOI->SetAODfilterBit(768); + cutsPOI->SetQA(doQA); + cutsPOI->SetPriors((centrMin+centrMax)*0.5); // set priors and PID as a function of the centrality + +// Int_t sourcePID = 2; +// Int_t particleType = 2; //2 or 3 or 4 for kPion, kKaon and kProton + + TString outputSlotName[] = {"","",""}; + + for(int harmonic=3;harmonic<6;harmonic++){ //for v3,v4 and v5 + outputSlotName[harmonic-3]+=uniqueStr; + outputSlotName[harmonic-3]+=Form("%i",harmonic); + outputSlotName[harmonic-3]+=cutsRP->GetName(); + outputSlotName[harmonic-3]+="_"; + outputSlotName[harmonic-3]+=cutsPOI->GetName(); + outputSlotName[harmonic-3]+=Form("_%.0f-",centrMin); + outputSlotName[harmonic-3]+=Form("%.0f_",centrMax); + if(isPID){ + outputSlotName[harmonic-3]+=AliFlowTrackCuts::PIDsourceName(sourcePID);//sourcePID + outputSlotName[harmonic-3]+="_"; + outputSlotName[harmonic-3]+=AliPID::ParticleName(particleType);//particleType + } + else{ + outputSlotName[harmonic-3]+="AllCharged"; + } + if (charge<0) outputSlotName[harmonic-3]+="-"; + if (charge>0) outputSlotName[harmonic-3]+="+"; + } + + TString fileName(fileNameBase); + fileName.Append(".root"); + + Bool_t useWeights = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2]; + if (useWeights) cout<<"Weights are used"<GetInputEventHandler()) { + ::Error("AddTaskFlowEvent", "This task requires an input event handler"); + return NULL; + } + + // Open external input files + //=========================================================================== + //weights: + TFile *weightsFile = NULL; + TList *weightsList = NULL; + + if(useWeights) { + //open the file with the weights: + weightsFile = TFile::Open("weights.root","READ"); + if(weightsFile) { + //access the list which holds the histos with weigths: + weightsList = (TList*)weightsFile->Get("weights"); + } + else { + cout<<" WARNING: the file with weights from the previous run was not available."<SetFlow(v1,v2,v3,v4); + taskFE[i]->SetNonFlowNumberOfTrackClones(numberOfTrackClones); + taskFE[i]->SetAfterburnerOn(); + taskFE[i]->SelectCollisionCandidates(triggerSelectionString); + } + else{ + taskFE[i] = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent_%s",outputSlotName[i].Data()),"",doQA); + taskFE[i]->SelectCollisionCandidates(triggerSelectionString); + } + if (ExcludeRegion) { + taskFE[i]->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); + } + taskFE[i]->SetSubeventEtaRange(minA, maxA, minB, maxB); + if (UsePhysicsSelection) { + taskFE[i]->SelectCollisionCandidates(AliVEvent::kMB); + cout<<"Using Physics Selection"<AddTask(taskFE[i]); + + // Pass cuts for RPs and POIs to the task: + taskFE[i]->SetCutsEvent(cutsEvent); + taskFE[i]->SetCutsRP(cutsRP); + taskFE[i]->SetCutsPOI(cutsPOI); + if (cutsRP->GetParamType()==AliFlowTrackCuts::kVZERO) + { + //TODO: since this is set in a static object all analyses in an analysis train + //will be affected. + taskFE[i]->SetHistWeightvsPhiMin(0.); + taskFE[i]->SetHistWeightvsPhiMax(200.); + } + } + // Create the analysis tasks, add them to the manager. + //=========================================================================== + AliAnalysisTaskScalarProduct *taskSP[3]; + AliAnalysisTaskQCumulants *taskQC[3]; + for(int i=0;i<3;i++){ + if (SP){ + taskSP[i] = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct_%s",outputSlotName[i].Data()),WEIGHTS[0]); + taskSP[i]->SetHarmonic(i+3); + taskSP[i]->SelectCollisionCandidates(triggerSelectionString); + taskSP[i]->SetRelDiffMsub(1.0); + taskSP[i]->SetApplyCorrectionForNUA(kTRUE); + mgr->AddTask(taskSP[i]); + } + if (QC){ + taskQC[i] = new AliAnalysisTaskQCumulants(Form("TaskQCumulants_%s",outputSlotName[i].Data()),useWeights); + taskQC[i]->SelectCollisionCandidates(triggerSelectionString); + taskQC[i]->SetUsePhiWeights(WEIGHTS[0]); + taskQC[i]->SetUsePtWeights(WEIGHTS[1]); + taskQC[i]->SetUseEtaWeights(WEIGHTS[2]); + taskQC[i]->SetCalculateCumulantsVsM(kFALSE); + taskQC[i]->SetnBinsMult(10000); + taskQC[i]->SetMinMult(0.); + taskQC[i]->SetMaxMult(10000.); + taskQC[i]->SetHarmonic(i+3); + taskQC[i]->SetApplyCorrectionForNUA(kFALSE); + taskQC[i]->SetFillMultipleControlHistograms(kFALSE); + mgr->AddTask(taskQC[i]); + } +} + // Create the output container for the data produced by the task + // Connect to the input and output containers + //=========================================================================== + AliAnalysisDataContainer *cinput1[3]; + AliAnalysisDataContainer *coutputFE[3]; + AliAnalysisDataContainer* coutputFEQA[3]; + for(int i=0; i<3; i++) { + cinput1[i] = mgr->GetCommonInputContainer(); + + coutputFE[i] = mgr->CreateContainer(Form("FlowEventSimple_%s",outputSlotName[i].Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer); + mgr->ConnectInput(taskFE[i],0,cinput1[i]); + mgr->ConnectOutput(taskFE[i],1,coutputFE[i]); + + if (taskFE[i]->GetQAOn()) { + TString outputQA = fileName; + outputQA += ":QA"; + coutputFEQA[i] = mgr->CreateContainer(Form("QA_%s",outputSlotName[i].Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA); + mgr->ConnectOutput(taskFE[i],2,coutputFEQA[i]); + } + } + // Create the output containers for the data produced by the analysis tasks + // Connect to the input and output containers + //=========================================================================== + AliAnalysisDataContainer *cinputWeights[3]; + AliAnalysisDataContainer *coutputSP[3]; + AliAnalysisDataContainer *coutputQC[3]; + for(int i=0;i<3;i++) { + if (useWeights) { + cinputWeights[i] = mgr->CreateContainer(Form("Weights_%s",outputSlotName[i].Data()),TList::Class(),AliAnalysisManager::kInputContainer); + } + + if(SP) { + TString outputSP = fileName; + outputSP += ":outputSPanalysis"; + outputSP+= rptypestr; + coutputSP[i] = mgr->CreateContainer(Form("SP_%s",outputSlotName[i].Data()), + TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); + mgr->ConnectInput(taskSP[i],0,coutputFE[i]); + mgr->ConnectOutput(taskSP[i],1,coutputSP[i]); + if (WEIGHTS[0]) { + mgr->ConnectInput(taskSP[i],1,cinputWeights[i]); + cinputWeights[i]->SetData(weightsList); + } + } + + if(QC) { + TString outputQC = fileName; + outputQC += ":outputQCanalysis"; + outputQC+= rptypestr; + + coutputQC[i] = mgr->CreateContainer(Form("QC_%s",outputSlotName[i].Data()), + TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); + mgr->ConnectInput(taskQC[i],0,coutputFE[i]); + mgr->ConnectOutput(taskQC[i],1,coutputQC[i]); + if (useWeights) { + mgr->ConnectInput(taskQC[i],1,cinputWeights[i]); + cinputWeights[i]->SetData(weightsList); + } + } + } + + ///////////////////////////////////////////////////////////////////// + AliAnalysisTaskQAflow* taskQAflow[3]; + AliAnalysisDataContainer* coutputQAtask[3]; + AliAnalysisDataContainer* coutputQAtaskTree[3]; + TString taskQAoutputFileName[3]={"","",""}; + for(int i=0;i<3;i++) { + if (runQAtask) { + taskQAflow[i] = new AliAnalysisTaskQAflow(Form("TaskQAflow_%s",outputSlotName[i].Data())); + taskQAflow[i]->SelectCollisionCandidates(triggerSelectionString); + taskQAflow[i]->SetEventCuts(cutsEvent); + taskQAflow[i]->SetTrackCuts(cutsRP); + taskQAflow[i]->SetFillNTuple(FillQAntuple); + taskQAflow[i]->SetDoCorrelations(DoQAcorrelations); + mgr->AddTask(taskQAflow[i]); + + Printf("outputSlotName_%s",outputSlotName[i].Data()); + taskQAoutputFileName[i](fileNameBase); + taskQAoutputFileName[i].Append("_QA.root"); + coutputQAtask[i] = mgr->CreateContainer(Form("flowQA_%s",outputSlotName[i].Data()), + TObjArray::Class(), + AliAnalysisManager::kOutputContainer, + taskQAoutputFileName[i]); + coutputQAtaskTree[i] = mgr->CreateContainer(Form("flowQAntuple_%s",outputSlotName[i].Data()), + TNtuple::Class(), + AliAnalysisManager::kOutputContainer, + taskQAoutputFileName[i]); + mgr->ConnectInput(taskQAflow[i],0,mgr->GetCommonInputContainer()); + mgr->ConnectInput(taskQAflow[i],1,coutputFE[i]); + mgr->ConnectOutput(taskQAflow[i],1,coutputQAtask[i]); + if (FillQAntuple) mgr->ConnectOutput(taskQAflow[i],2,coutputQAtaskTree[i]); + } + } +} + + + + diff --git a/PWGCF/FLOW/macros/runTaskFlowHigherOrdersAllPID.C b/PWGCF/FLOW/macros/runTaskFlowHigherOrdersAllPID.C new file mode 100644 index 00000000000..1f822d89b0b --- /dev/null +++ b/PWGCF/FLOW/macros/runTaskFlowHigherOrdersAllPID.C @@ -0,0 +1,520 @@ +// run.C +// +// Template run macro for AliBasicTask.cxx/.h with example layout of +// physics selections and options, in macro and task. +// +// Author: Arvinder Palaha +// +class AliAnalysisGrid; +class AliAnalysisTaskBF; +class AliBalance; + +//Centrality stuff +Int_t binfirst = 0; //where do we start numbering bins +Int_t binlast = 8; //where do we stop numbering bins +const Int_t numberOfCentralityBins = 9; +Double_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile + +//Systematic studies +const Int_t numberOfSyst = 13; +Float_t vZ[numberOfSyst] = {10.,12.,6.,8.,10.,10.,10.,10.,10.,10.,10.,10.,10.}; // global Vertex Z cut +Float_t DCAxy[numberOfSyst] = {-1.,2.4,2.4,2.4,2.2,2.0,1.8,2.4,2.4,2.4,2.4,2.4,2.4}; // DCA xy cut (afterburner, -1 = w/o additional cut) +Float_t DCAz[numberOfSyst] = {-1.,3.2,3.2,3.2,3.0,2.8,2.6,3.2,3.2,3.2,3.2,3.2,3.2}; // DCA z cut (afterburner, -1 = w/o additional cut) +Float_t ptMin[numberOfSyst] = {0.3,0.3,0.3,0.3,0.3,0.3,0.3,1.5,5.0,0.3,0.3,0.3,0.3}; // pt cuts +Float_t ptMax[numberOfSyst] = {5.,1.5,1.5,1.5,1.5,1.5,1.5,5.0,10.0,10.0,1.5,1.5,1.5}; // pt cuts +Float_t etaMin[numberOfSyst] = {-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-0.8,-1.0,-0.6,-0.4}; // eta cuts +Float_t etaMax[numberOfSyst] = {0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,1.0,0.6,0.4}; // eta cuts + +Bool_t kUsePID = kFALSE; +Bool_t bUseHBTCut = kTRUE; +Bool_t bUseConversionCut = kTRUE; +Bool_t bResonancesCut = kTRUE; +Bool_t bMomentumDifferenceCut = kTRUE; +Int_t kNSigmaElectronRejection = 3; + +//______________________________________________________________________________ +void runTaskFlowHigherOrdersAllPID( + const char* runtype = "local", // local, proof or grid + const char *gridmode = "terminate", // Set the run mode (can be "full", "test", "offline", "submit" or "terminate"). Full & Test work for proof + const Int_t bunchN = 0, + const bool bAOD = 1, // 1 = AOD ANALYSIS, 0 = ESD ANALYSIS + const bool bMCtruth = 0, // 1 = MCEvent handler is on (MC truth), 0 = MCEvent handler is off (MC reconstructed/real data) + const bool bMCphyssel = 1, // 1 = looking at MC truth or reconstructed, 0 = looking at real data + const Long64_t nentries = 50000, // for local and proof mode, ignored in grid mode. Set to 1234567890 for all events. + const Long64_t firstentry = 0, // for local and proof mode, ignored in grid mode + TString proofdataset = "bunchPROOF", // path to dataset on proof cluster, for proof analysis + const char *proofcluster = "miweber@alice-caf.cern.ch", // which proof cluster to use in proof mode + const char *taskname = "BF_Syst_Test" // sets name of grid generated macros + ) +{ + // check run type + if(runtype != "local" && runtype != "proof" && runtype != "grid") { + Printf("\n\tIncorrect run option, check first argument of run macro"); + Printf("\tint runtype = local, proof or grid\n"); + return; + } + Printf("%s analysis chosen",runtype); + + // load libraries + gSystem->Load("libCore.so"); + gSystem->Load("libGeom.so"); + gSystem->Load("libVMC.so"); + gSystem->Load("libPhysics.so"); + gSystem->Load("libTree.so"); + gSystem->Load("libSTEERBase.so"); + gSystem->Load("libESD.so"); + gSystem->Load("libAOD.so"); + gSystem->Load("libANALYSIS.so"); + gSystem->Load("libANALYSISalice.so"); + gSystem->Load("libEventMixing.so"); + gSystem->Load("libCORRFW.so"); + gSystem->Load("libPWGTools.so"); + gSystem->Load("libPWGCFebye.so"); + gSystem->Load("libPWGflowBase.so"); + gSystem->Load("libPWGflowTasks.so"); + + // additional + + // compile standalone stuff + //gROOT->LoadMacro("AliBalance.cxx++g"); + //gROOT->LoadMacro("AliAnalysisTaskBF.cxx++g"); + + // add aliroot indlude path + //gROOT->ProcessLine(".include $PWD/."); + //gROOT->ProcessLine(Form(".include %s/include",gSystem->ExpandPathName("$ALICE_ROOT"))); + + gROOT->SetStyle("Plain"); + + // analysis manager + AliAnalysisManager* mgr = new AliAnalysisManager(Form("%s%i",taskname,bunchN)); + + // create the alien handler and attach it to the manager + if(runtype == "grid") { + AliAnalysisGrid *plugin = CreateAlienHandler(bAOD,bunchN,Form("%s%i",taskname,bunchN), gridmode, proofcluster, Form("%s_%d.txt",proofdataset.Data(),bunchN)); + mgr->SetGridHandler(plugin); + } + else if(runtype == "local") { + TString filename; + TChain* chain = 0x0; + if((!bAOD)&&(!bMCtruth)) { + chain = new TChain("esdTree"); + for(Int_t i = 0; i < 4; i++) { + filename = "/data/alice2/pchrist/HeavyIons/Data/2011/Set"; + filename += i; filename += "/AliESDs.root"; + chain->Add(filename.Data()); + } + } + else if((bAOD)&&(!bMCtruth)) { + chain = new TChain("aodTree"); + for(Int_t i = 0; i < 10; i++) { + filename = "/glusterfs/alice1/alice2/pchrist/HeavyIons/Data/2011/Set"; + filename += i; filename += "/AliAOD.root"; + chain->Add(filename.Data()); + } + } + else if((!bAOD)&&(bMCtruth)) { + chain = new TChain("TE"); + for(Int_t i = 10; i < 99; i++) { + filename = "/project/alice/users/alisrm/Efficiency_Contamination/LHC13b3_HIJING_pA_AOD/"; + filename += i; + filename += "/galice.root"; + chain->Add(filename.Data()); + } + } + else if((bAOD)&&(bMCtruth)) { //used for MCAOD + chain = new TChain("aodTree"); + for(Int_t i = 10; i < 99; i++) { + filename = "/project/alice/users/alisrm/Efficiency_Contamination/LHC13b3_HIJING_pA_AOD/"; + filename += i; + filename += "/AliAOD.root"; + chain->Add(filename.Data()); + } + } + + + }//local mode + + // input handler (ESD or AOD) + AliVEventHandler* inputH = NULL; + if(!bAOD){ + inputH = new AliESDInputHandler(); + } + else{ + inputH = new AliAODInputHandler(); + } + mgr->SetInputEventHandler(inputH); + + // mc event handler + if(bMCtruth) { + AliMCEventHandler* mchandler = new AliMCEventHandler(); + // Not reading track references + mchandler->SetReadTR(kFALSE); + mgr->SetMCtruthEventHandler(mchandler); + } + + // AOD output handler + //AliAODHandler* aodoutHandler = new AliAODHandler(); + //aodoutHandler->SetOutputFileName("aod.root"); + //mgr->SetOutputEventHandler(aodoutHandler); + + // === Physics Selection Task === + // + // In SelectCollisionCandidate(), default is kMB, so the task UserExec() + // function is only called for these events. + // Options are: + // kMB Minimum Bias trigger + // kMBNoTRD Minimum bias trigger where the TRD is not read out + // kMUON Muon trigger + // kHighMult High-Multiplicity Trigger + // kUserDefined For manually defined trigger selection + // + // Multiple options possible with the standard AND/OR operators && and || + // These all have the usual offline SPD or V0 selections performed. + // + // With a pointer to the physics selection object using physSelTask->GetPhysicsSelection(), + // one can manually set the selected and background classes using: + // AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL") + // AddBGTriggerClass("+CINT1A-ABCE-NOPF-ALL"); + // + // One can also specify multiple classes at once, or require a class to NOT + // trigger, for e.g. + // AddBGTriggerClass("+CSMBA-ABCE-NOPF-ALL -CSMBB-ABCE-NOPF-ALL"); + // + // NOTE that manually setting the physics selection overrides the standard + // selection, so it must be done in completeness. + // + // ALTERNATIVELY, one can make the physics selection inside the task + // UserExec(). + // For this case, comment out the task->SelectCol.... line, + // and see AliBasicTask.cxx UserExec() function for details on this. + + //gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); + //AliPhysicsSelectionTask *physSelTask = AddTaskPhysicsSelection(bMCphyssel); + //if(!physSelTask) { Printf("no physSelTask"); return; } + //AliPhysicsSelection *physSel = physSelTask->GetPhysicsSelection(); + //physSel->AddCollisionTriggerClass("+CINT1B-ABCE-NOPF-ALL");// #3119 #769"); + + // create task + //Add the centrality determination task and the physics selection + // (only on ESD level, in AODs centrality is already in header and events are selected) +// if((!bAOD)&&(!bMCtruth)){ +// gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C"); +// AliCentralitySelectionTask *taskCentrality = AddTaskCentrality(); + + // Add physics selection task (NOT needed for AODs) +// gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); +// AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(bMCphyssel); +// } +///////////////////////////////////////// + //Add flow centrality bayesian + + gROOT->LoadMacro("AddTaskFlowHigherOrdersAllPID.C"); + //gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/AddTaskFlowHigherOrdersAllPID.C"); + // gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/AddTaskFlowCentralityBayesian.C"); + // gROOT->LoadMacro("~/Desktop/work/PhD/flow/AddTaskFlowCentralityBayesian.C"); + AliAnalysisTaskFlowEvent* FlowTask = AddTaskFlowHigherOrdersAllPID(AliVEvent::kCentral | AliVEvent::kSemiCentral | AliVEvent::kMB,0.,80.,"AnalysisResults",kTRUE,768,768,AliPID::kPion,AliFlowTrackCuts::kTOFbayesian,0,kFALSE,-0.8,0.8,""); +///////////////////////////////////////// + + //Add the PID response +// if((kUsePID)||(kNSigmaElectronRejection)) { +// gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C"); +// AddTaskPIDResponse(bMCphyssel); +// } + + //Add the VZERO event plane task +// gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C"); +// AliVZEROEPSelectionTask* epSelTask = AddTaskVZEROEPSelection(); + + //Add the BF task (all centralities) + // gROOT->LoadMacro("$ALICE_ROOT/PWGCF/EBYE/macros/AddTaskBalancePsiCentralityTrain.C"); + +// AliAnalysisTaskBFPsi *taskBF = AddTaskBalancePsiCentralityTrain(0, 500, kFALSE, kTRUE, kFALSE, "V0M", 10, -1, -1, 0.2, 20.0, -0.8, 0.8, -1, -1, kUsePID, kFALSE, kTRUE, 0.02, kFALSE, 0.04, kTRUE, 0.1, 128, 1, "AnalysisResults","TE","Multiplicity","AOD",kTRUE, kNSigmaElectronRejection); + //taskBF->SetDebugLevel(); + + // enable debug printouts + //mgr->SetDebugLevel(2); + //mgr->SetUseProgressBar(1,100); + if (!mgr->InitAnalysis()) return; + mgr->PrintStatus(); + + // start analysis + Printf("Starting Analysis...."); + if(runtype == "local") + mgr->StartAnalysis("local",chain); + else + mgr->StartAnalysis(runtype,nentries,firstentry); +} + +//______________________________________________________________________________ +AliAnalysisGrid* CreateAlienHandler(Bool_t bAOD, Int_t bunchN, const char *taskname, const char *gridmode, const char *proofcluster, const char *proofdataset) +{ + AliAnalysisAlien *plugin = new AliAnalysisAlien(); + // Set the run mode (can be "full", "test", "offline", "submit" or "terminate") + plugin->SetRunMode(gridmode); + + // Set versions of used packages + plugin->SetAPIVersion("V1.1x"); + plugin->SetROOTVersion("v5-34-08"); + plugin->SetAliROOTVersion("v5-05-19-AN"); + + // Declare input data to be processed. + + // Method 1: Create automatically XML collections using alien 'find' command. + // Define production directory LFN + plugin->SetGridDataDir("/alice/data/2010/LHC10h/"); + // On real reconstructed data: + // plugin->SetGridDataDir("/alice/data/2009/LHC09d"); + + // Set data search pattern + //plugin->SetDataPattern("*ESDs.root"); // THIS CHOOSES ALL PASSES + // Data pattern for reconstructed data + if(!bAOD){ + plugin->SetDataPattern("*ESDs/pass2/*ESDs.root"); // CHECK LATEST PASS OF DATA SET IN ALIENSH + } + else{ + plugin->SetDataPattern("*ESDs/pass2/AOD086/*/AliAOD.root"); + } + + plugin->SetRunPrefix("000"); // real data + // ...then add run numbers to be considered + //plugin->SetRunRange(114917,115322); + + if(bunchN==0){ + plugin->AddRunNumber(137366); + } + + //bunch1 + else if(bunchN == 1){ + plugin->AddRunNumber(139510); + plugin->AddRunNumber(139507); + plugin->AddRunNumber(139505); + plugin->AddRunNumber(139503); + plugin->AddRunNumber(139465); + plugin->AddRunNumber(139438); + plugin->AddRunNumber(139437); + plugin->AddRunNumber(139360); + plugin->AddRunNumber(139329); + plugin->AddRunNumber(139328); + } + + //bunch2 + else if(bunchN == 2){ + plugin->AddRunNumber(139314); + plugin->AddRunNumber(139310); + plugin->AddRunNumber(139309); + plugin->AddRunNumber(139173); + plugin->AddRunNumber(139107); + plugin->AddRunNumber(139105); + plugin->AddRunNumber(139038); + plugin->AddRunNumber(139037); + plugin->AddRunNumber(139036); + plugin->AddRunNumber(139029); + plugin->AddRunNumber(139028); + plugin->AddRunNumber(138872); + plugin->AddRunNumber(138871); + plugin->AddRunNumber(138870); + plugin->AddRunNumber(138837); + plugin->AddRunNumber(138732); + plugin->AddRunNumber(138730); + plugin->AddRunNumber(138666); + plugin->AddRunNumber(138662); + plugin->AddRunNumber(138653); + } + + else if(bunchN == 3){ + plugin->AddRunNumber(138652); + plugin->AddRunNumber(138638); + plugin->AddRunNumber(138624); + plugin->AddRunNumber(138621); + plugin->AddRunNumber(138583); + plugin->AddRunNumber(138582); + plugin->AddRunNumber(138579); + plugin->AddRunNumber(138578); + plugin->AddRunNumber(138534); + plugin->AddRunNumber(138469); + } + + else if(bunchN == 4){ + + plugin->AddRunNumber(138442); + plugin->AddRunNumber(138439); + plugin->AddRunNumber(138438); + plugin->AddRunNumber(138396); + plugin->AddRunNumber(138364); + plugin->AddRunNumber(138275); + plugin->AddRunNumber(138225); + plugin->AddRunNumber(138201); + plugin->AddRunNumber(138197); + plugin->AddRunNumber(138192); + } + + else if(bunchN == 5){ + + plugin->AddRunNumber(138190); + plugin->AddRunNumber(137848); + plugin->AddRunNumber(137844); + plugin->AddRunNumber(137752); + plugin->AddRunNumber(137751); + plugin->AddRunNumber(137724); + plugin->AddRunNumber(137722); + plugin->AddRunNumber(137718); + plugin->AddRunNumber(137704); + plugin->AddRunNumber(137693); + } + + else if(bunchN == 6){ + + plugin->AddRunNumber(137692); + plugin->AddRunNumber(137691); + plugin->AddRunNumber(137686); + plugin->AddRunNumber(137685); + plugin->AddRunNumber(137639); + plugin->AddRunNumber(137638); + plugin->AddRunNumber(137608); + plugin->AddRunNumber(137595); + plugin->AddRunNumber(137549); + plugin->AddRunNumber(137546); + + } + + else if(bunchN == 7){ + + plugin->AddRunNumber(137544); + plugin->AddRunNumber(137541); + plugin->AddRunNumber(137539); + plugin->AddRunNumber(137531); + plugin->AddRunNumber(137530); + plugin->AddRunNumber(137443); + plugin->AddRunNumber(137441); + plugin->AddRunNumber(137440); + plugin->AddRunNumber(137439); + plugin->AddRunNumber(137434); + + } + + else if(bunchN == 8){ + + plugin->AddRunNumber(137432); + plugin->AddRunNumber(137431); + plugin->AddRunNumber(137430); + plugin->AddRunNumber(137366); + plugin->AddRunNumber(137243); + plugin->AddRunNumber(137236); + plugin->AddRunNumber(137235); + plugin->AddRunNumber(137232); + plugin->AddRunNumber(137231); + plugin->AddRunNumber(137162); + plugin->AddRunNumber(137161); + } + + else{ + + stderr<<"BUNCH NOT THERE"<AddRunList("139510, 139507, 139505, 139503, 139465, 139438, 139437, 139360, 139329, 139328, 139314, 139310, 139309, 139173, 139107, 139105, 139038, 139037, 139036, 139029, 139028, 138872, 138871, 138870, 138837, 138732, 138730, 138666, 138662, 138653, 138652, 138638, 138624, 138621, 138583, 138582, 138579, 138578, 138534, 138469, 138442, 138439, 138438, 138396, 138364, 138275, 138225, 138201, 138197, 138192, 138190, 137848, 137844, 137752, 137751, 137724, 137722, 137718, 137704, 137693, 137692, 137691, 137686, 137685, 137639, 137638, 137608, 137595, 137549, 137546, 137544, 137541, 137539, 137531, 137530, 137443, 137441, 137440, 137439, 137434, 137432, 137431, 137430, 137366, 137243, 137236, 137235, 137232, 137231, 137162, 137161"); + + + + + + plugin->SetNrunsPerMaster(1); + plugin->SetOutputToRunNo(); + // comment out the next line when using the "terminate" option, unless + // you want separate merged files for each run + plugin->SetMergeViaJDL(); + + // Method 2: Declare existing data files (raw collections, xml collections, root file) + // If no path mentioned data is supposed to be in the work directory (see SetGridWorkingDir()) + // XML collections added via this method can be combined with the first method if + // the content is compatible (using or not tags) + // plugin->AddDataFile("tag.xml"); + // plugin->AddDataFile("/alice/data/2008/LHC08c/000057657/raw/Run57657.Merged.RAW.tag.root"); + + // Define alien work directory where all files will be copied. Relative to alien $HOME. + plugin->SetGridWorkingDir(taskname); + + // Declare alien output directory. Relative to working directory. + plugin->SetGridOutputDir("out"); // In this case will be $HOME/taskname/out + + // Declare the analysis source files names separated by blancs. To be compiled runtime + // using ACLiC on the worker nodes. + plugin->SetAnalysisSource("AliBalance.cxx AliAnalysisTaskBF.cxx"); + + // Declare all libraries (other than the default ones for the framework. These will be + // loaded by the generated analysis macro. Add all extra files (task .cxx/.h) here. + //plugin->AddIncludePath("-I."); + //plugin->SetAdditionalLibs("libPWGCFebye.so"); + plugin->SetAdditionalLibs("AliBalance.cxx AliBalance.h AliAnalysisTaskBF.cxx AliAnalysisTaskBF.h"); + + // Declare the output file names separated by blancs. + // (can be like: file.root or file.root@ALICE::Niham::File) + // To only save certain files, use SetDefaultOutputs(kFALSE), and then + // SetOutputFiles("list.root other.filename") to choose which files to save + plugin->SetDefaultOutputs(); + //plugin->SetOutputFiles("list.root"); + + // Optionally set a name for the generated analysis macro (default MyAnalysis.C) + plugin->SetAnalysisMacro(Form("%s.C",taskname)); + + // Optionally set maximum number of input files/subjob (default 100, put 0 to ignore) + plugin->SetSplitMaxInputFileNumber(100); + + // Optionally modify the executable name (default analysis.sh) + plugin->SetExecutable(Form("%s.sh",taskname)); + + // set number of test files to use in "test" mode + plugin->SetNtestFiles(1); + + // Optionally resubmit threshold. + plugin->SetMasterResubmitThreshold(90); + + // Optionally set time to live (default 30000 sec) + plugin->SetTTL(90000); + + // Optionally set input format (default xml-single) + plugin->SetInputFormat("xml-single"); + + // Optionally modify the name of the generated JDL (default analysis.jdl) + plugin->SetJDLName(Form("%s.jdl",taskname)); + + // Optionally modify job price (default 1) + plugin->SetPrice(1); + + // Optionally modify split mode (default 'se') + plugin->SetSplitMode("se"); + + //plugin->SetUseSubmitPolicy(); + //plugin->SetKeepLogs(); + + //---------------------------------------------------------- + //--- PROOF MODE SPECIFIC SETTINGS ------------ + //---------------------------------------------------------- + // Proof cluster + plugin->SetProofCluster(proofcluster); + // Dataset to be used + plugin->SetProofDataSet(proofdataset); + // May need to reset proof. Supported modes: 0-no reset, 1-soft, 2-hard + plugin->SetProofReset(0); + // May limit number of workers + plugin->SetNproofWorkers(0); + // May limit the number of workers per slave + plugin->SetNproofWorkersPerSlave(1); + // May use a specific version of root installed in proof + plugin->SetRootVersionForProof("current"); + // May set the aliroot mode. Check http://aaf.cern.ch/node/83 + plugin->SetAliRootMode("default"); // Loads AF libs by default + // May request ClearPackages (individual ClearPackage not supported) + plugin->SetClearPackages(kFALSE); + // Plugin test mode works only providing a file containing test file locations, used in "local" mode also + plugin->SetFileForTestMode("files.txt"); // file should contain path name to a local directory containg *ESDs.root etc + // Request connection to alien upon connection to grid + plugin->SetProofConnectGrid(kFALSE); + + plugin->Print(); + + return plugin; +} + -- 2.43.0