AliAnalysisTaskFlowEvent *AddTaskFlowCentralityBayesian(Float_t centrMin=0.,
                                                        Float_t centrMax=100.,
                                                        TString fileNameBase="output",
                                                        Int_t specie=2, 
                                                        Int_t charge=0, 
                                                        Int_t harmonic=2,
                                                        Bool_t doQA=kFALSE,
                                                        TString uniqueStr="" )
{
  // Define the range for eta subevents (for SP method)
  Double_t minA = -0.9;
  Double_t maxA = -0.5;
  Double_t minB = 0.5;
  Double_t maxB = 0.9;
  
  // 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 MCEP     = kFALSE;  // correlation with Monte Carlo reaction plane
  Bool_t SP       = kTRUE;  // scalar product method (similar to eventplane method)
  Bool_t GFC      = kTRUE;  // cumulants based on generating function
  Bool_t QC       = kTRUE;  // cumulants using Q vectors
  Bool_t FQD      = kTRUE;  // fit of the distribution of the Q vector (only integrated v)
  Bool_t LYZ1SUM  = kTRUE;  // 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, kPMD
  AliFlowTrackCuts::trackParameterType rptype = AliFlowTrackCuts::kGlobal;
  AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kGlobal;
  
  //---------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);

  TString fileName(fileNameBase);
  fileName.Append(".root");
  //===========================================================================
  printf("CREATE CUTS\n");
  cout << "Used for RP: "<< rptypestr << endl;  
  cout << "Used for POI: "<< poitypestr << endl;  

  // EVENTS CUTS:
  AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("event cuts");
  cutsEvent->SetCentralityPercentileRange(centrMin,centrMax);
  cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0);
  cutsEvent->SetRefMultMethod(AliFlowEventCuts::kV0);
  //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets);
  cutsEvent->SetNContributorsRange(2);
  cutsEvent->SetPrimaryVertexZrange(-7.,7.);
  cutsEvent->SetCutSPDvertexerAnomaly(); //"Francesco's cut"
  cutsEvent->SetCutZDCtiming();
  cutsEvent->SetCutTPCmultiplicityOutliers();
  //cutsEvent->SetUseCentralityUnchecked();
  //cutsEvent->SetQA(doQA);
 
  // RP TRACK CUTS:
  AliFlowTrackCuts* cutsRP = new AliFlowTrackCuts("TPConlyRP");
  cutsRP->SetParamType(rptype);
  cutsRP->SetParamMix(rpmix);
  cutsRP->SetPtRange(0.2,5.);
  cutsRP->SetEtaRange(-0.8,0.8);
  cutsRP->SetMinNClustersTPC(70);
  cutsRP->SetMinChi2PerClusterTPC(0.1);
  cutsRP->SetMaxChi2PerClusterTPC(4.0);
  cutsRP->SetMinNClustersITS(2);
  cutsRP->SetRequireITSRefit(kTRUE);
  cutsRP->SetRequireTPCRefit(kTRUE);
  cutsRP->SetMaxDCAToVertexXY(0.3);
  cutsRP->SetMaxDCAToVertexZ(0.3);
  cutsRP->SetAcceptKinkDaughters(kFALSE);
  //  cutsRP->SetMinimalTPCdedx(10.);
  //  cutsRP->SetQA(doQA);

  // POI TRACK CUTS:
  AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("GlobalPOI");

  // Set priors as a function of centrality
  Float_t centr = (centrMin+centrMax)*0.5;
  cutsPOI->SetPriors(centr);

  cutsPOI->SetParamType(poitype);
  cutsPOI->SetParamMix(poimix);
  cutsPOI->SetPtRange(0.0,10.);
  cutsPOI->SetEtaRange(-0.8,0.8);
  //cutsPOI->SetRequireCharge(kTRUE);
  //cutsPOI->SetPID(PdgRP);

  // track cuts for PID
  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(0.3);
  cutsPOI->SetMaxDCAToVertexZ(0.3);
  //cutsPOI->SetDCAToVertex2D(kTRUE);
  //cutsPOI->SetMaxNsigmaToVertex(1.e+10);
  //cutsPOI->SetRequireSigmaToVertex(kFALSE);
  cutsPOI->SetAcceptKinkDaughters(kFALSE);
  //cutsPOI->SetPID(AliPID::kProton, AliFlowTrackCuts::kTOFpid);
  //cutsPOI->SetPID(AliPID::kPion, AliFlowTrackCuts::kTPCpid);
  //cutsPOI->SetPID(AliPID::kProton, AliFlowTrackCuts::kTPCdedx);
  //cutsPOI->SetPID(AliPID::kProton, AliFlowTrackCuts::kTOFbeta);
  cutsPOI->SetRequireStrictTOFTPCagreement();

  // Bayesian PID
  if(specie==0)
    cutsPOI->SetPID(AliPID::kElectron, AliFlowTrackCuts::kTOFbayesian,0.8);
  else if(specie==1)
    cutsPOI->SetPID(AliPID::kMuon, AliFlowTrackCuts::kTOFbayesian,0.8);
  else if(specie==2)
    cutsPOI->SetPID(AliPID::kPion, AliFlowTrackCuts::kTOFbayesian,0.8);
  else if(specie==3)
    cutsPOI->SetPID(AliPID::kKaon, AliFlowTrackCuts::kTOFbayesian,0.8);
  else if(specie==4)
    cutsPOI->SetPID(AliPID::kProton, AliFlowTrackCuts::kTOFbayesian,0.8);

  //not implemented yet
  //  else if(specie==10)
  //    cutsPOI->SetPID(AliPID::kDeuteron, AliFlowTrackCuts::kTOFbayesian,0.8);

  if(charge !=0) cutsPOI->SetCharge(charge);

  //iexample: francesco's tunig TPC Bethe Bloch for data (for TOF+TPC analysis):
  Float_t centrCur = (centrMax + centrMin) * 0.5;
  Float_t AlephParameters[5];
  Float_t mip=51;

  if(centrCur < 10){
    AlephParameters[0] = 7.68595e-02;
    AlephParameters[1] = 1.01781e+01;
    AlephParameters[2] = 9.34864e-06;
    AlephParameters[3] = 2.38588e+00;
    AlephParameters[4] = 2.13599e+00;
  }
  else if(centrCur < 20){
    AlephParameters[0] = 7.79393e-02;
    AlephParameters[1] = 1.00337e+01;
    AlephParameters[2] = 9.34864e-06;
    AlephParameters[3] = 2.40323e+00;
    AlephParameters[4] = 2.13072e+00;
  }
  else if(centrCur < 30){
    AlephParameters[0] = 7.87563e-02;
    AlephParameters[1] = 9.91265e+00;
    AlephParameters[2] = 9.34864e-06;
    AlephParameters[3] = 2.42280e+00;
    AlephParameters[4] = 2.13296e+00;
  }
  else if(centrCur < 40){
    AlephParameters[0] = 8.23869e-02;
    AlephParameters[1] = 9.50211e+00;
    AlephParameters[2] = 1.40230e-05;
    AlephParameters[3] = 2.42899e+00;
    AlephParameters[4] = 2.05572e+00;
  }
  else if(centrCur < 50){
    AlephParameters[0] = 8.25626e-02;
    AlephParameters[1] = 9.47698e+00;
    AlephParameters[2] = 1.40230e-05;
    AlephParameters[3] = 2.43731e+00;
    AlephParameters[4] = 2.06060e+00;
  }
  else if(centrCur < 60){
    AlephParameters[0] = 8.27528e-02;
    AlephParameters[1] = 9.44676e+00;
    AlephParameters[2] = 1.40230e-05;
    AlephParameters[3] = 2.44433e+00;
    AlephParameters[4] = 2.06498e+00;
  }
  else if(centrCur < 70){
    AlephParameters[0] = 8.29615e-02;
    AlephParameters[1] = 9.41909e+00;
    AlephParameters[2] = 1.40230e-05;
    AlephParameters[3] = 2.44894e+00;
    AlephParameters[4] = 2.06676e+00;
  }
  else if(centrCur < 80){
    AlephParameters[0] = 8.31397e-02;
    AlephParameters[1] = 9.41126e+00;
    AlephParameters[2] = 1.40230e-05;
    AlephParameters[3] = 2.44848e+00;
    AlephParameters[4] = 2.06326e+00;
  }
  else{
    AlephParameters[0] = 8.38910e-02;
    AlephParameters[1] = 9.30736e+00;
    AlephParameters[2] = 1.40230e-05;
    AlephParameters[3] = 2.45844e+00;
    AlephParameters[4] = 2.07334e+00;
  }

  cutsPOI->GetESDpid().GetTPCResponse().SetBetheBlochParameters(AlephParameters[0],AlephParameters[1],AlephParameters[2],AlephParameters[3],AlephParameters[4]);
  cutsPOI->GetESDpid().GetTPCResponse().SetMip(mip);

  TString outputSlotName("");
  outputSlotName+=uniqueStr;  
  outputSlotName+=Form("V%i ",harmonic);
  outputSlotName+=cutsRP->GetName();
  outputSlotName+=" ";
  outputSlotName+=cutsPOI->GetName();
  outputSlotName+=Form(" %.0f-",centrMin);
  outputSlotName+=Form("%.0f ",centrMax);
  outputSlotName+=AliFlowTrackCuts::PIDsourceName(sourcePID);
  outputSlotName+=" ";
  outputSlotName+=AliPID::ParticleName(particleType);
  if (charge<0) outputSlotName+="-";
  if (charge>0) outputSlotName+="+";

  Bool_t useWeights  = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2];
  if (useWeights) cout<<"Weights are used"<<endl;
  else cout<<"Weights are not used"<<endl;
  
  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    Error("AddTaskFlowEvent", "No analysis manager to connect to.");
    return NULL;
  }
  
  // Check the analysis type using the event handlers connected to the analysis
  // manager. The availability of MC handler can also be checked here.
  //==============================================================================
  if (!mgr->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 <weights.root> with weights from the previous run was not available."<<endl;
      break;
    } 
  }
  
  //LYZ2
  if (LYZ2SUM || LYZ2PROD) {
    //read the outputfile of the first run
    TString outputFileName = "AnalysisResults1.root";
    TString pwd(gSystem->pwd());
    pwd+="/";
    pwd+=outputFileName.Data();
    TFile *outputFile = NULL;
    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
      cout<<"WARNING: You do not have an output file:"<<endl;
      cout<<"         "<<pwd.Data()<<endl;
      exit(0);
    } else { outputFile = TFile::Open(pwd.Data(),"READ");}
    
    if (LYZ2SUM){  
      // read the output directory from LYZ1SUM 
      TString inputFileNameLYZ2SUM = "outputLYZ1SUManalysis" ;
      inputFileNameLYZ2SUM += rptypestr;
      cout<<"The input directory is "<<inputFileNameLYZ2SUM.Data()<<endl;
      TFile* fInputFileLYZ2SUM = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2SUM.Data());
      if(!fInputFileLYZ2SUM || fInputFileLYZ2SUM->IsZombie()) { 
	cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ; 
	break;
      }
      else {
	TList* fInputListLYZ2SUM = (TList*)fInputFileLYZ2SUM->Get("cobjLYZ1SUM");
	if (!fInputListLYZ2SUM) {cout<<"list is NULL pointer!"<<endl;}
      }
      cout<<"LYZ2SUM input file/list read..."<<endl;
    }

    if (LYZ2PROD){  
      // read the output directory from LYZ1PROD 
      TString inputFileNameLYZ2PROD = "outputLYZ1PRODanalysis" ;
      inputFileNameLYZ2PROD += rptypestr;
      cout<<"The input directory is "<<inputFileNameLYZ2PROD.Data()<<endl;
      TFile* fInputFileLYZ2PROD = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2PROD.Data());
      if(!fInputFileLYZ2PROD || fInputFileLYZ2PROD->IsZombie()) { 
	cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ; 
	break;
      }
      else {
	TList* fInputListLYZ2PROD = (TList*)fInputFileLYZ2PROD->Get("cobjLYZ1PROD");
	if (!fInputListLYZ2PROD) {cout<<"list is NULL pointer!"<<endl;}
      }
      cout<<"LYZ2PROD input file/list read..."<<endl;
    }
  }

  if (LYZEP) {
    //read the outputfile of the second run
    TString outputFileName = "AnalysisResults2.root";
    TString pwd(gSystem->pwd());
    pwd+="/";
    pwd+=outputFileName.Data();
    TFile *outputFile = NULL;
    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
      cout<<"WARNING: You do not have an output file:"<<endl;
      cout<<"         "<<pwd.Data()<<endl;
      exit(0);
    } else {
      outputFile = TFile::Open(pwd.Data(),"READ");
    }
    
    // read the output file from LYZ2SUM
    TString inputFileNameLYZEP = "outputLYZ2SUManalysis" ;
    inputFileNameLYZEP += rptypestr;
    cout<<"The input file is "<<inputFileNameLYZEP.Data()<<endl;
    TFile* fInputFileLYZEP = (TFile*)outputFile->FindObjectAny(inputFileNameLYZEP.Data());
    if(!fInputFileLYZEP || fInputFileLYZEP->IsZombie()) { 
      cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ; 
      break;
    }
    else {
      TList* fInputListLYZEP = (TList*)fInputFileLYZEP->Get("cobjLYZ2SUM");
      if (!fInputListLYZEP) {cout<<"list is NULL pointer!"<<endl;}
    }
    cout<<"LYZEP input file/list read..."<<endl;
  }
  
  
  // Create the FMD task and add it to the manager
  //===========================================================================
  if (rptypestr == "FMD") {
    AliFMDAnalysisTaskSE *taskfmd = NULL;
    if (rptypestr == "FMD") {
      taskfmd = new AliFMDAnalysisTaskSE("TaskFMD");
      mgr->AddTask(taskfmd);
      
      AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
      pars->Init();
      pars->SetProcessPrimary(kTRUE); //for MC only
      pars->SetProcessHits(kFALSE);
      
      //pars->SetRealData(kTRUE); //for real data
      //pars->SetProcessPrimary(kFALSE); //for real data
    }
  }
  
  // Create the task, add it to the manager.
  //===========================================================================
  AliAnalysisTaskFlowEvent *taskFE = NULL;

  if(useAfterBurner)
    { 
      taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA,1);
      taskFE->SetFlow(v1,v2,v3,v4); 
      taskFE->SetNonFlowNumberOfTrackClones(numberOfTrackClones);
      taskFE->SetAfterburnerOn();
    }
  else {taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA); }
  if (ExcludeRegion) {
    taskFE->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); 
  }
  taskFE->SetSubeventEtaRange(minA, maxA, minB, maxB);
  if (UsePhysicsSelection) {
    //taskFE->SelectCollisionCandidates(AliVEvent::kUserDefined);
    taskFE->SelectCollisionCandidates(AliVEvent::kMB);
    cout<<"Using Physics Selection"<<endl;
  }
  mgr->AddTask(taskFE);
  
  // Pass cuts for RPs and POIs to the task:
  taskFE->SetCutsEvent(cutsEvent);

  // Pass cuts for RPs and POIs to the task:
  taskFE->SetCutsRP(cutsRP);
  taskFE->SetCutsPOI(cutsPOI);
  if (cutsRP->GetParamType()==AliFlowTrackCuts::kV0)
  { 
    //TODO: since this is set in a static object all analyses in an analysis train
    //will be affected.
    taskFE->SetHistWeightvsPhiMin(0.);
    taskFE->SetHistWeightvsPhiMax(200.);
  }

  // Create the analysis tasks, add them to the manager.
  //===========================================================================
  if (SP){
    AliAnalysisTaskScalarProduct *taskSP = new AliAnalysisTaskScalarProduct("TaskScalarProduct",WEIGHTS[0]);
    taskSP->SetRelDiffMsub(1.0);
    taskSP->SetApplyCorrectionForNUA(kFALSE);
    taskSP->SetHarmonic(harmonic); // default is v2
    mgr->AddTask(taskSP);
  }
  if (LYZ1SUM){
    AliAnalysisTaskLeeYangZeros *taskLYZ1SUM = new AliAnalysisTaskLeeYangZeros("TaskLeeYangZerosSUM",kTRUE);
    taskLYZ1SUM->SetFirstRunLYZ(kTRUE);
    taskLYZ1SUM->SetUseSumLYZ(kTRUE);
    mgr->AddTask(taskLYZ1SUM);
  }
  if (LYZ1PROD){
    AliAnalysisTaskLeeYangZeros *taskLYZ1PROD = new AliAnalysisTaskLeeYangZeros("TaskLeeYangZerosPROD",kTRUE);
    taskLYZ1PROD->SetFirstRunLYZ(kTRUE);
    taskLYZ1PROD->SetUseSumLYZ(kFALSE);
    mgr->AddTask(taskLYZ1PROD);
  }
  if (LYZ2SUM){
    AliAnalysisTaskLeeYangZeros *taskLYZ2SUM = new AliAnalysisTaskLeeYangZeros("TaskLeeYangZerosSUM",kFALSE);
    taskLYZ2SUM->SetFirstRunLYZ(kFALSE);
    taskLYZ2SUM->SetUseSumLYZ(kTRUE);
    mgr->AddTask(taskLYZ2SUM);
  }
  if (LYZ2PROD){
    AliAnalysisTaskLeeYangZeros *taskLYZ2PROD = new AliAnalysisTaskLeeYangZeros("TaskLeeYangZerosPROD",kFALSE);
    taskLYZ2PROD->SetFirstRunLYZ(kFALSE);
    taskLYZ2PROD->SetUseSumLYZ(kFALSE);
    mgr->AddTask(taskLYZ2PROD);
  }
  if (LYZEP){
    AliAnalysisTaskLYZEventPlane *taskLYZEP = new AliAnalysisTaskLYZEventPlane("TaskLYZEventPlane");
    mgr->AddTask(taskLYZEP);
  }
  if (GFC){
    AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants("TaskCumulants",useWeights);
    taskGFC->SetUsePhiWeights(WEIGHTS[0]); 
    taskGFC->SetUsePtWeights(WEIGHTS[1]);
    taskGFC->SetUseEtaWeights(WEIGHTS[2]); 
    taskGFC->SetHarmonic(harmonic);
    mgr->AddTask(taskGFC);
  }
  if (QC){
    AliAnalysisTaskQCumulants *taskQC = new AliAnalysisTaskQCumulants("TaskQCumulants",useWeights);
    taskQC->SetUsePhiWeights(WEIGHTS[0]); 
    taskQC->SetUsePtWeights(WEIGHTS[1]);
    taskQC->SetUseEtaWeights(WEIGHTS[2]); 
    taskQC->SetCalculateCumulantsVsM(kFALSE);
    taskQC->SetnBinsMult(10000);
    taskQC->SetMinMult(0.);
    taskQC->SetMaxMult(10000.);
    taskQC->SetHarmonic(harmonic); // default is v2
    taskQC->SetApplyCorrectionForNUA(kFALSE);
    taskQC->SetFillMultipleControlHistograms(kFALSE);     
    mgr->AddTask(taskQC);
  }
  if (FQD){
    AliAnalysisTaskFittingQDistribution *taskFQD = new AliAnalysisTaskFittingQDistribution("TaskFittingQDistribution",kFALSE);
    taskFQD->SetUsePhiWeights(WEIGHTS[0]); 
    taskFQD->SetqMin(0.);
    taskFQD->SetqMax(1000.);
    taskFQD->SetqNbins(10000);
    mgr->AddTask(taskFQD);
  }
  if (MCEP){
    AliAnalysisTaskMCEventPlane *taskMCEP = new AliAnalysisTaskMCEventPlane("TaskMCEventPlane");
    taskMCEP->SetHarmonic(harmonic);
    mgr->AddTask(taskMCEP);
  }
  if (MH){
    AliAnalysisTaskMixedHarmonics *taskMH = new AliAnalysisTaskMixedHarmonics("TaskMixedHarmonics",useWeights);
    taskMH->SetHarmonic(harmonic); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
    taskMH->SetNoOfMultipicityBins(10000);
    taskMH->SetMultipicityBinWidth(1.);
    taskMH->SetMinMultiplicity(1.);
    taskMH->SetCorrectForDetectorEffects(kTRUE);
    taskMH->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>> (Remark: two nested loops)    
    taskMH->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
    mgr->AddTask(taskMH);
  }  
  if (NL){
    AliAnalysisTaskNestedLoops *taskNL = new AliAnalysisTaskNestedLoops("TaskNestedLoops",useWeights);
    taskNL->SetHarmonic(harmonic); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
    taskNL->SetEvaluateNestedLoopsForRAD(kTRUE); // RAD = Relative Angle Distribution
    taskNL->SetEvaluateNestedLoopsForMH(kTRUE); // evalaute <<cos[n(phi1+phi2-2phi3)]>> (Remark: three nested loops)   
    taskNL->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>>  (Remark: three nested loops)   
    taskNL->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
    mgr->AddTask(taskNL);
  }

  // Create the output container for the data produced by the task
  // Connect to the input and output containers
  //===========================================================================
  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
  
  if (rptypestr == "FMD") {
    AliAnalysisDataContainer *coutputFMD = 
      mgr->CreateContainer(Form("BackgroundCorrected_%s",centralityName.Data()), TList::Class(), AliAnalysisManager::kExchangeContainer);
    //input and output taskFMD     
    mgr->ConnectInput(taskfmd, 0, cinput1);
    mgr->ConnectOutput(taskfmd, 1, coutputFMD);
    //input into taskFE
    mgr->ConnectInput(taskFE,1,coutputFMD);
  }
  
  AliAnalysisDataContainer *coutputFE = 
  mgr->CreateContainer(Form("cobjFlowEventSimple_%s",centralityName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
  mgr->ConnectInput(taskFE,0,cinput1); 
  mgr->ConnectOutput(taskFE,1,coutputFE);

  if (taskFE->GetQAOn())
  {
    TString outputQA = fileName;
    outputQA += ":QA";
    AliAnalysisDataContainer* coutputFEQA = 
    mgr->CreateContainer(Form("QA %s",outputSlotName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA);
    mgr->ConnectOutput(taskFE,2,coutputFEQA);
  }

  // Create the output containers for the data produced by the analysis tasks
  // Connect to the input and output containers
  //===========================================================================
  if (useWeights) {    
    AliAnalysisDataContainer *cinputWeights = mgr->CreateContainer(Form("cobjWeights_%s",centralityName.Data()),
								   TList::Class(),AliAnalysisManager::kInputContainer); 
  }

  if(SP) {
    TString outputSP = fileName;
    outputSP += ":outputSPanalysis";
    outputSP+= rptypestr;
    AliAnalysisDataContainer *coutputSP = mgr->CreateContainer(Form("cobjSP_%s",centralityName.Data()), 
							       TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); 
    mgr->ConnectInput(taskSP,0,coutputFE); 
    mgr->ConnectOutput(taskSP,1,coutputSP); 
    if (WEIGHTS[0]) {
      mgr->ConnectInput(taskSP,1,cinputWeights);
      cinputWeights->SetData(weightsList);
    }
  }
  if(LYZ1SUM) {
    TString outputLYZ1SUM = fileName;
    outputLYZ1SUM += ":outputLYZ1SUManalysis";
    outputLYZ1SUM+= rptypestr;
    AliAnalysisDataContainer *coutputLYZ1SUM = mgr->CreateContainer(Form("cobjLYZ1SUM_%s",centralityName.Data()), 
								    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1SUM); 
    mgr->ConnectInput(taskLYZ1SUM,0,coutputFE);
    mgr->ConnectOutput(taskLYZ1SUM,1,coutputLYZ1SUM);
  }
  if(LYZ1PROD) {
    TString outputLYZ1PROD = fileName;
    outputLYZ1PROD += ":outputLYZ1PRODanalysis";
    outputLYZ1PROD+= rptypestr;
    AliAnalysisDataContainer *coutputLYZ1PROD = mgr->CreateContainer(Form("cobjLYZ1PROD_%s",centralityName.Data()), 
								     TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1PROD); 
    mgr->ConnectInput(taskLYZ1PROD,0,coutputFE); 
    mgr->ConnectOutput(taskLYZ1PROD,1,coutputLYZ1PROD);
  }
  if(LYZ2SUM) {
    AliAnalysisDataContainer *cinputLYZ2SUM = mgr->CreateContainer(Form("cobjLYZ2SUMin_%s",centralityName.Data()),
								   TList::Class(),AliAnalysisManager::kInputContainer);
    TString outputLYZ2SUM = fileName;
    outputLYZ2SUM += ":outputLYZ2SUManalysis";
    outputLYZ2SUM+= rptypestr;
    
    AliAnalysisDataContainer *coutputLYZ2SUM = mgr->CreateContainer(Form("cobjLYZ2SUM_%s",centralityName.Data()), 
								    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2SUM); 
    mgr->ConnectInput(taskLYZ2SUM,0,coutputFE); 
    mgr->ConnectInput(taskLYZ2SUM,1,cinputLYZ2SUM);
    mgr->ConnectOutput(taskLYZ2SUM,1,coutputLYZ2SUM); 
    cinputLYZ2SUM->SetData(fInputListLYZ2SUM);
  }
  if(LYZ2PROD) {
    AliAnalysisDataContainer *cinputLYZ2PROD = mgr->CreateContainer(Form("cobjLYZ2PRODin_%s",centralityName.Data()),
								    TList::Class(),AliAnalysisManager::kInputContainer);
    TString outputLYZ2PROD = fileName;
    outputLYZ2PROD += ":outputLYZ2PRODanalysis";
    outputLYZ2PROD+= rptypestr;
    
    AliAnalysisDataContainer *coutputLYZ2PROD = mgr->CreateContainer(Form("cobjLYZ2PROD_%s",centralityName.Data()), 
								     TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2PROD); 
    mgr->ConnectInput(taskLYZ2PROD,0,coutputFE); 
    mgr->ConnectInput(taskLYZ2PROD,1,cinputLYZ2PROD);
    mgr->ConnectOutput(taskLYZ2PROD,1,coutputLYZ2PROD); 
    cinputLYZ2PROD->SetData(fInputListLYZ2PROD);
  }
  if(LYZEP) {
    AliAnalysisDataContainer *cinputLYZEP = mgr->CreateContainer(Form("cobjLYZEPin_%s",centralityName.Data()),
								 TList::Class(),AliAnalysisManager::kInputContainer);
    TString outputLYZEP = fileName;
    outputLYZEP += ":outputLYZEPanalysis";
    outputLYZEP+= rptypestr;
    
    AliAnalysisDataContainer *coutputLYZEP = mgr->CreateContainer(Form("cobjLYZEP_%s",centralityName.Data()), 
								  TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZEP); 
    mgr->ConnectInput(taskLYZEP,0,coutputFE); 
    mgr->ConnectInput(taskLYZEP,1,cinputLYZEP);
    mgr->ConnectOutput(taskLYZEP,1,coutputLYZEP); 
    cinputLYZEP->SetData(fInputListLYZEP);
  }
  if(GFC) {
    TString outputGFC = fileName;
    outputGFC += ":outputGFCanalysis";
    outputGFC+= rptypestr;
    
    AliAnalysisDataContainer *coutputGFC = mgr->CreateContainer(Form("cobjGFC_%s",centralityName.Data()), 
								TList::Class(),AliAnalysisManager::kOutputContainer,outputGFC); 
    mgr->ConnectInput(taskGFC,0,coutputFE); 
    mgr->ConnectOutput(taskGFC,1,coutputGFC);
    if (useWeights) {
      mgr->ConnectInput(taskGFC,1,cinputWeights);
      cinputWeights->SetData(weightsList);
    } 
  }
  if(QC) {
    TString outputQC = fileName;
    outputQC += ":outputQCanalysis";
    outputQC+= rptypestr;

    AliAnalysisDataContainer *coutputQC = mgr->CreateContainer(Form("cobjQC_%s",centralityName.Data()), 
							       TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); 
    mgr->ConnectInput(taskQC,0,coutputFE); 
    mgr->ConnectOutput(taskQC,1,coutputQC);
    if (useWeights) {
      mgr->ConnectInput(taskQC,1,cinputWeights);
      cinputWeights->SetData(weightsList);
    }
  }
  if(FQD) {
    TString outputFQD = fileName;
    outputFQD += ":outputFQDanalysis";
    outputFQD+= rptypestr;
    
    AliAnalysisDataContainer *coutputFQD = mgr->CreateContainer(Form("cobjFQD_%s",centralityName.Data()), 
								TList::Class(),AliAnalysisManager::kOutputContainer,outputFQD); 
    mgr->ConnectInput(taskFQD,0,coutputFE); 
    mgr->ConnectOutput(taskFQD,1,coutputFQD);
    if(useWeights) {
      mgr->ConnectInput(taskFQD,1,cinputWeights);
      cinputWeights->SetData(weightsList);
    } 
  }
  if(MCEP) {
    TString outputMCEP = fileName;
    outputMCEP += ":outputMCEPanalysis";
    outputMCEP+= rptypestr;
    
    AliAnalysisDataContainer *coutputMCEP = mgr->CreateContainer(Form("cobjMCEP_%s",centralityName.Data()), 
								 TList::Class(),AliAnalysisManager::kOutputContainer,outputMCEP); 
    mgr->ConnectInput(taskMCEP,0,coutputFE);
    mgr->ConnectOutput(taskMCEP,1,coutputMCEP); 
  }
  if(MH) {
    TString outputMH = fileName;
    outputMH += ":outputMHanalysis";
    outputMH += rptypestr;
        
    AliAnalysisDataContainer *coutputMH = mgr->CreateContainer(Form("cobjMH_%s",centralityName.Data()), 
							       TList::Class(),AliAnalysisManager::kOutputContainer,outputMH); 
    mgr->ConnectInput(taskMH,0,coutputFE); 
    mgr->ConnectOutput(taskMH,1,coutputMH); 
    //if (useWeights) {
    //  mgr->ConnectInput(taskMH,1,cinputWeights);
    //  cinputWeights->SetData(weightsList);
    //} 
  }
  if(NL) {
    TString outputNL = fileName;
    outputNL += ":outputNLanalysis";
    outputNL += rptypestr;

    AliAnalysisDataContainer *coutputNL = mgr->CreateContainer(Form("cobjNL_%s",centralityName.Data()), 
							       TList::Class(),AliAnalysisManager::kOutputContainer,outputNL); 
    mgr->ConnectInput(taskNL,0,coutputFE);
    mgr->ConnectOutput(taskNL,1,coutputNL);
    //if (useWeights) {
    //  mgr->ConnectInput(taskNL,1,cinputWeights);
    //  cinputWeights->SetData(weightsList);
    //} 
  }

  ///////////////////////////////////////////////////////////////////////////////////////////
  if (runQAtask)
  {
    AliAnalysisTaskQAflow* taskQAflow = new AliAnalysisTaskQAflow("TaskQAflow");
    taskQAflow->SetEventCuts(cutsEvent);
    taskQAflow->SetTrackCuts(cutsRP);
    taskQAflow->SetFillNTuple(FillQAntuple);
    taskQAflow->SetDoCorrelations(DoQAcorrelations);
    mgr->AddTask(taskQAflow);
    
    Printf("centralityName %s",centralityName.Data());
    TString taskQAoutputFileName(fileNameBase);
    taskQAoutputFileName.Append("_QA.root");
    AliAnalysisDataContainer* coutputQAtask = mgr->CreateContainer(Form("flowQA_%s",centralityName.Data()),
                                              TObjArray::Class(),
                                              AliAnalysisManager::kOutputContainer,
                                              taskQAoutputFileName);
    AliAnalysisDataContainer* coutputQAtaskTree = mgr->CreateContainer(Form("flowQAntuple_%s",centralityName.Data()),
                                              TNtuple::Class(),
                                              AliAnalysisManager::kOutputContainer,
                                              taskQAoutputFileName);
    mgr->ConnectInput(taskQAflow,0,mgr->GetCommonInputContainer());
    mgr->ConnectInput(taskQAflow,1,coutputFE);
    mgr->ConnectOutput(taskQAflow,1,coutputQAtask);
    if (FillQAntuple) mgr->ConnectOutput(taskQAflow,2,coutputQAtaskTree);
  }

  return taskFE;
}
Example #2
0
AliAnalysisTask *AddTask_jpsi_JPsiME(TString prod="",
				     Bool_t gridconf=kFALSE,
				     ULong64_t triggers=AliVEvent::kCentral | AliVEvent::kSemiCentral | AliVEvent::kMB) {

  //get the current analysis manager
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    Error("AddTask_jpsi_JPsiME", "No analysis manager found.");
    return 0;
  }
  
  //Do we have an MC handler?
  Bool_t hasMC = kFALSE;
  TString list = gSystem->Getenv("LIST");
  if( list.IsNull()) list=prod;
  if( list.Contains("LHC10h")   || list.Contains("LHC11h")   ) hasMC=kFALSE;
  if( list.Contains("LHC11a10") || list.Contains("LHC12a17") ) hasMC=kTRUE;

  //Do we have an AOD handler?
  Bool_t isAOD=(mgr->GetInputEventHandler()->IsA()==AliAODInputHandler::Class() ? kTRUE : kFALSE);

  // set AOD debug levels
  if(isAOD) {
    mgr->AddClassDebug("AliAODTrack", AliLog::kFatal);
    mgr->AddClassDebug("AliAODpidUtil", AliLog::kInfo);
  }

  //set config file name
  TString configFile("");
  printf("%s \n",gSystem->pwd());
  TString trainRoot=gSystem->Getenv("TRAIN_ROOT");
  if (!trainRoot.IsNull())
    configFile="$TRAIN_ROOT/jbook_jpsi/ConfigJpsiME_jpsi_PbPb.C";   // gsi config
  else if(!gSystem->Exec("alien_cp alien:///alice/cern.ch/user/j/jbook/PWGDQ/dielectron/macrosJPSI/ConfigJpsiME_jpsi_PbPb.C .")) {
    gSystem->Exec(Form("ls -l %s",gSystem->pwd()));
    configFile=Form("%s/ConfigJpsiME_jpsi_PbPb.C",gSystem->pwd());                        // alien config
  }
  else {
    printf("ERROR: couldn't copy file %s from grid \n",
	   "alien:///alice/cern.ch/user/j/jbook/PWGDQ/dielectron/macrosJPSI/ConfigJpsiME_jpsi_PbPb.C");
    return;
  }

  // using aliroot config
  if(!gridconf)
    configFile="$ALICE_PHYSICS/PWGDQ/dielectron/macrosJPSI/ConfigJpsiME_jpsi_PbPb.C"; // aliroot config

  //create task and add it to the manager
  AliAnalysisTaskMultiDielectron *task;

  // trigger selection
  ULong64_t triggerSets[]={AliVEvent::kCentral , AliVEvent::kSemiCentral , AliVEvent::kMB,
			   AliVEvent::kCentral | AliVEvent::kSemiCentral | AliVEvent::kMB};
  const char* triggerNames[]={"Central","SemiCentral","MB","MB+Cent+SemiCent"};

  // find out the configured triggers
  Int_t j=0;
  for(j=0; j<4; j++) {
    if(triggers!=triggerSets[j]) continue;
    else break;
  }

  // print task configuration
  printf("production: %s MC: %d \n",  list.Data(),hasMC);
  printf("triggers:   %s \n",         triggerNames[j]  );
  printf("config:     %s Grid: %d \n",configFile.Data(),gridconf);

  task = new AliAnalysisTaskMultiDielectron((Form("MultiDieJpsiME_%s",triggerNames[j])));
  task->SetBeamEnergy(1380.);
  task->SetTriggerMask(triggers);
  if (!hasMC) task->UsePhysicsSelection();
  mgr->AddTask(task);

  //load dielectron configuration file
  TString checkconfig="ConfigJpsiME_jpsi_PbPb";
  if (!gROOT->GetListOfGlobalFunctions()->FindObject(checkconfig.Data()))
    gROOT->LoadMacro(configFile.Data());

  //add dielectron analysis with different cuts to the task
  for (Int_t i=0; i<nDie; ++i) { //nDie defined in config file
    AliDielectron *jpsi=ConfigJpsiME_jpsi_PbPb(i,list,triggers);
    if (jpsi ) task->AddDielectron(jpsi);
    if (jpsi ) printf(" %s added\n",jpsi->GetName());
  }

  //create output container
  TString containerName = "JPSI.root";
  AliAnalysisDataContainer *cOutputHist1 =
    mgr->CreateContainer(Form("jpsiME_QA_%s",triggerNames[j]),
			 TList::Class(),
			 AliAnalysisManager::kOutputContainer,
			 containerName.Data());

  AliAnalysisDataContainer *cOutputHist2 =
    mgr->CreateContainer(Form("jpsiME_CF_%s",triggerNames[j]),
			 TList::Class(),
			 AliAnalysisManager::kOutputContainer,
			 containerName.Data());

  AliAnalysisDataContainer *cOutputHist3 =
    mgr->CreateContainer(Form("jpsiME_EventStat_%s",triggerNames[j]),
			 TH1D::Class(),
			 AliAnalysisManager::kOutputContainer,
			 containerName.Data());

  mgr->ConnectInput(task,  0, mgr->GetCommonInputContainer());
  //  mgr->ConnectOutput(task, 0, coutput1 );
  mgr->ConnectOutput(task, 1, cOutputHist1);
  mgr->ConnectOutput(task, 2, cOutputHist2);
  mgr->ConnectOutput(task, 3, cOutputHist3);

  return task;
}
Example #3
0
AliAnalysisTaskCorrelation3p* AddTaskThreePartTracks (const char* name = "ThreePartTracks",
						      const char* centrality = "V0M",
						      const Double_t MinTriggerPt = 4.0,
						      const Double_t MaxTriggerPt = 8.0,
						      const Double_t MinAssociatedPt = 4.0,
						      const Double_t MaxAssociatedPt = 8.0,
						      const Double_t Acceptancecut = 0.9,
						      const Double_t MaxNumberOfTracks = 300,
						      const char* period = "11a",
						      UInt_t offlineTriggerMask = AliVEvent::kMB,
						      const Int_t MaxNEventsMix = 100,
						      const Int_t MinNTracksMix = 1000,
						      const Int_t NMBins = 7,
						      const Double_t Mbin0 = 0.,
						      const Double_t Mbin1 = 5.,
						      const Double_t Mbin2 = 10.,
						      const Double_t Mbin3 = 20.,
						      const Double_t Mbin4 = 40.,
						      const Double_t Mbin5 = 60.,
						      const Double_t Mbin6 = 80.,
						      const Double_t Mbin7 = 90.,
						      const char * file = "",
						      const char * cutmask = "GlobalHybrid",
						      const Int_t binver = 1,
						      const Int_t Zbinver =1
 						    )
{
  //Add a task AliAnalysisTaskCorrelation3p to the analysis train in charged track analysis, for pp data 
  //Author: Paul Baetzing
  /* $Id$ */
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr){
    ::Error("AddTaskThreePartTracks", "No analysis manager to connect to");
    return NULL;
  }
    if (!mgr->GetInputEventHandler()) {
    ::Error("AddTaskThreePartTracks", "This task requires an input event handler");
    return NULL;
  }
  const char* fname = Form("%s_%1.0f_%1.0f",name,MinTriggerPt,MaxTriggerPt,MinAssociatedPt,MaxAssociatedPt);
  const char* tname = Form("%s_%1.0f_%1.0f_%1.0f_%1.0f",name,MinTriggerPt,MaxTriggerPt,MinAssociatedPt,MaxAssociatedPt);

  
  
  
  AliAnalysisTaskCorrelation3p* task = new AliAnalysisTaskCorrelation3p(Form("%sTask", tname), "");

  
  
  
  task->SetCentralityEstimator(centrality);
  task->SetTrigger(AliAnalysisTaskCorrelation3p::tracks);
  task->SetMinTriggerPt(MinTriggerPt);
  task->SetMaxTriggerPt(MaxTriggerPt);
  task->SetMinAssociatedPt(MinAssociatedPt);
  task->SetMaxAssociatedPt(MaxAssociatedPt);
  task->SetAcceptanceCut(Acceptancecut);
  task->SetMaxNumberOfTracks(MaxNumberOfTracks);
  task->SetTrackCut(cutmask);
  task->SetBinVer(binver);
  if(TString(file).CompareTo("")!=0)   task->SetWeights(Form("alien:///alice/cern.ch/user/p/pbatzing/efficiencies/%s",file));
  //Mixing scheme:
  Double_t *Mbin = new Double_t[NMBins+1];
  Mbin[0] = Mbin0;
  Mbin[1] = Mbin1;
  if(NMBins>1) Mbin[2] = Mbin2;
  if(NMBins>2) Mbin[3] = Mbin3;
  if(NMBins>3) Mbin[4] = Mbin4;
  if(NMBins>4) Mbin[5] = Mbin5;
  if(NMBins>5) Mbin[6] = Mbin6;
  if(NMBins>6) Mbin[7] = Mbin6;
  TArrayD tMbin(NMBins+1, Mbin);
  //z vertex binning.
  const Int_t NZBins   =   19;
  const Double_t Zbin0 = -10.;
  const Double_t Zbin1 = -8.5;
  const Double_t Zbin2 = -7.5;
  const Double_t Zbin3 = -6.5;
  const Double_t Zbin4 = -5.5;
  const Double_t Zbin5 = -4.5;
  const Double_t Zbin6 = -3.5;
  const Double_t Zbin7 = -2.5;
  const Double_t Zbin8 = -1.5;
  const Double_t Zbin9 = -0.5;
  const Double_t Zbin10 = 0.5;
  const Double_t Zbin11 = 1.5;						      
  const Double_t Zbin12 = 2.5;						      
  const Double_t Zbin13 = 3.5;						      
  const Double_t Zbin14 = 4.5;						      
  const Double_t Zbin15 = 5.5;						      
  const Double_t Zbin16 = 6.5;						      
  const Double_t Zbin17 = 7.5;						      
  const Double_t Zbin18 = 8.5;						      
  const Double_t Zbin19 = 10.;  
  if(Zbinver==2){
    NZBins=    9;
    Zbin0 = -10.;
    Zbin1 = -7.5;
    Zbin2 = -5.5;
    Zbin3 = -3.5;
    Zbin4 = -1.5;
    Zbin5 =  1.5;
    Zbin6 =  3.5;
    Zbin7 =  5.5;
    Zbin8 =  7.5;
    Zbin9 =  10.;
  }
  Double_t *Zbin = new Double_t[NZBins+1];
  Zbin[0] = Zbin0;
  Zbin[1] = Zbin1;
  if(NZBins>1) Zbin[2] = Zbin2;
  if(NZBins>2) Zbin[3] = Zbin3;
  if(NZBins>3) Zbin[4] = Zbin4;
  if(NZBins>4) Zbin[5] = Zbin5;
  if(NZBins>5) Zbin[6] = Zbin6;
  if(NZBins>6) Zbin[7] = Zbin7;
  if(NZBins>7) Zbin[8] = Zbin8;
  if(NZBins>8) Zbin[9] = Zbin9;
  if(NZBins>9) Zbin[10] = Zbin10;
  if(NZBins>10) Zbin[11] = Zbin11;
  if(NZBins>11) Zbin[12] = Zbin12;
  if(NZBins>12) Zbin[13] = Zbin13;
  if(NZBins>13) Zbin[14] = Zbin14;
  if(NZBins>14) Zbin[15] = Zbin15;
  if(NZBins>15) Zbin[16] = Zbin16;
  if(NZBins>16) Zbin[17] = Zbin17;
  if(NZBins>17) Zbin[18] = Zbin18;
  if(NZBins>18) Zbin[19] = Zbin19;
  TArrayD tZbin(NZBins+1, Zbin);  
  task->SetMixingScheme(MaxNEventsMix,MinNTracksMix,tMbin,tZbin);

  if( TString(period).Contains("10b") )
    task->SetPeriod(AliAnalysisTaskCorrelation3p::P10b);
  if( TString(period).Contains("10c") )
    task->SetPeriod(AliAnalysisTaskCorrelation3p::P10c);
  if( TString(period).Contains("10d") )
    task->SetPeriod(AliAnalysisTaskCorrelation3p::P10d);  
  if( TString(period).Contains("10e") )
    task->SetPeriod(AliAnalysisTaskCorrelation3p::P10e);
  if( TString(period).Contains("11a") )
    task->SetPeriod(AliAnalysisTaskCorrelation3p::P11a);
  task->SelectCollisionCandidates(offlineTriggerMask);

  
  mgr->AddTask(task);
  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer() );
  
  TString cname(Form("%sCoutput1", tname));
  TString pname(Form("%s:%s", AliAnalysisManager::GetCommonFileName(), fname));
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(cname.Data(), TList::Class(), AliAnalysisManager::kOutputContainer, pname.Data());
  mgr->ConnectOutput(task, 1, coutput1);

  return task;
};
Example #4
0
AliAnalysisTaskEffContBF *AddTaskBalanceEffCont( TString  centralityEstimator="V0M",
						 Double_t centrMin=0.,
						 Double_t centrMax=80.,
						 Double_t vertexZ=10.,
						 Int_t AODfilterBit = 128,
						 Bool_t bUseElectronRejection = kFALSE,
						 TString fileNameBase="AnalysisResults",
						 AliAnalysisTaskBFPsi::etriggerSel triggerSel = AliAnalysisTaskBFPsi::kINT7,
						 Bool_t usePID=kFALSE,
						 AliPID::EParticleType particleType = AliPID::kPion
						 ) {

  // Creates a balance function analysis task and adds it to the analysis manager.
  // Get the pointer to the existing analysis manager via the static access method.
  TString centralityName("");

  centralityName+=Form("%.0f-%.0f_%.0f",centrMin,centrMax,vertexZ);
  TString outputFileName(fileNameBase);
  outputFileName.Append(".root");
  
  //===========================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    ::Error("AddTaskTriggeredBF", "No analysis manager to connect to.");
    return NULL;
  }

  // Check the analysis type using the event handlers connected to the analysis manager.
  //===========================================================================
  if (!mgr->GetInputEventHandler()) {
    ::Error("AddTaskTriggeredBF", "This task requires an input event handler");
    return NULL;
  }
  TString analysisType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
  if(dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler())) analysisType = "MC";

 
  // Create the task, add it to manager and configure it.
  //===========================================================================


  AliAnalysisTaskEffContBF *taskEffContBF = new AliAnalysisTaskEffContBF("TaskEffContBF");

  // centrality
  if(centralityEstimator) {
    taskEffContBF->UseCentrality();
    taskEffContBF->SetCentralityEstimator(centralityEstimator);
    taskEffContBF->SetCentralityPercentileRange(centrMin,centrMax);
  }
  
  if (triggerSel == AliAnalysisTaskBFPsi::kCentral) taskEffContBF->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);
  else if(triggerSel == AliAnalysisTaskBFPsi::kMB) taskEffContBF->SelectCollisionCandidates(AliVEvent::kMB);
  else if(triggerSel == AliAnalysisTaskBFPsi::kINT7) taskEffContBF->SelectCollisionCandidates(AliVEvent::kINT7);
  
  // vertex
  taskEffContBF->SetVertexDiamond(.3,.3,vertexZ);

  //analysis kinematic cuts
  taskEffContBF->SetMinPt(0.0);
  taskEffContBF->SetMaxPt(20.0); //5.0
  //taskEffContBF->SetEtaRange(-0.8,0.8,100,0.0,1.6, 64); //acceptance cuts
  //taskEffContBF->SetPtRange(0.1, 20.0, 100);  //acceptance cuts //5.0,49
  taskEffContBF->SetEtaRange(-0.8,0.8,100,0.0,1.6, 64); //acceptance cuts
  taskEffContBF->SetPtRange(0.0, 20.0, 100);  //acceptance cuts //5.0,49

  // electron rejection
    if(bUseElectronRejection){
      taskEffContBF->SetElectronOnlyRejection(3.); // no other particle in nsigma (this is what we use standard in BF code)
    }

    TString pidsuffix ="ch";
    if (usePID) {
      pidsuffix = AliPID::ParticleShortName(particleType);
      taskEffContBF->SetUsePID(usePID, particleType);
    }
    
  //AODs  
  taskEffContBF->SetAODtrackCutBit(AODfilterBit);
  mgr->AddTask(taskEffContBF);

  // Create ONLY the output containers for the data produced by the task.
  // Get and connect other common input/output containers via the manager as below
  //==============================================================================
  TString outputFileName = AliAnalysisManager::GetCommonFileName();
  outputFileName += ":PWGCFEbyE.outputBalanceFunctionEffContAnalysis";
  AliAnalysisDataContainer *coutQA = mgr->CreateContainer(Form("listQA_%s_%s",centralityName.Data(), pidsuffix.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
  AliAnalysisDataContainer *coutEffContBF = mgr->CreateContainer(Form("listEffContBF_%s_%s",centralityName.Data(), pidsuffix.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());

  mgr->ConnectInput(taskEffContBF, 0, mgr->GetCommonInputContainer());
  mgr->ConnectOutput(taskEffContBF, 1, coutQA);
  mgr->ConnectOutput(taskEffContBF, 2, coutEffContBF);
  
  return taskEffContBF;
}
Example #5
0
AliAnalysisTaskRhoSparse* AddTaskRhoSparse(
					   const char    *nJetsBkg    = "JetsBkg",
					   const char    *nJetsSig    = "JetsSig",
					   const char    *nTracks     = "PicoTracks",
					   const char    *nClusters   = "CaloClusters",  
					   const char    *nRho        = "Rho",
					   Double_t       jetradius   = 0.2,
					   const char    *cutType     = "TPC",
					   Double_t       jetareacut  = 0.01,
					   Double_t       jetptcut    = 0.0,
					   Double_t       emcareacut  = 0,
					   TF1           *sfunc       = 0x0,
					   const UInt_t   exclJets    = 2,
					   const Bool_t   histo       = kFALSE,
					   const char    *taskname    = "Rho",
					   const Bool_t   fRhoCMS      = kTRUE
					   )
{  

  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr)
  {
    ::Error("AddTaskRhoSparse", "No analysis manager to connect to.");
    return NULL;
  }  
  
  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  if (!mgr->GetInputEventHandler())
  {
    ::Error("AddTaskRhoSparse", "This task requires an input event handler");
    return NULL;
  }
  
  //-------------------------------------------------------
  // Init the task and do settings
  //-------------------------------------------------------

  TString name(Form("%s_%s_%s", taskname, nJetsBkg,cutType));
  AliAnalysisTaskRhoSparse* mgrTask = static_cast<AliAnalysisTaskRhoSparse *>(mgr->GetTask(name.Data()));
  if (mgrTask) return mgrTask;

  AliAnalysisTaskRhoSparse *rhotask = new AliAnalysisTaskRhoSparse(name, histo);
  rhotask->SetHistoBins(1000,-0.1,9.9);
  rhotask->SetRhoCMS(fRhoCMS);
  rhotask->SetExcludeLeadJets(exclJets);
  rhotask->SetScaleFunction(sfunc);
  rhotask->SetOutRhoName(nRho);

  AliParticleContainer *trackCont = rhotask->AddParticleContainer(nTracks);
  AliClusterContainer *clusterCont = rhotask->AddClusterContainer(nClusters);

  AliJetContainer *bkgJetCont = rhotask->AddJetContainer(nJetsBkg,cutType,jetradius);
  if (bkgJetCont) {
    bkgJetCont->SetJetAreaCut(jetareacut);
    bkgJetCont->SetAreaEmcCut(emcareacut);
    bkgJetCont->SetJetPtCut(0.);
    bkgJetCont->ConnectParticleContainer(trackCont);
    bkgJetCont->ConnectClusterContainer(clusterCont);
  }

  AliJetContainer *sigJetCont = rhotask->AddJetContainer(nJetsSig,cutType,jetradius);
  if (sigJetCont) {
    sigJetCont->SetJetAreaCut(jetareacut);
    sigJetCont->SetAreaEmcCut(emcareacut);
    sigJetCont->SetJetPtCut(jetptcut);
    sigJetCont->ConnectParticleContainer(trackCont);
    sigJetCont->ConnectClusterContainer(clusterCont);
  }

  //-------------------------------------------------------
  // Final settings, pass to manager and set the containers
  //-------------------------------------------------------

  rhotask->SetSmallSystem(fRhoCMS);
  mgr->AddTask(rhotask);

  // Create containers for input/output
  mgr->ConnectInput(rhotask, 0, mgr->GetCommonInputContainer());
  if (histo) {
    TString contname(name);
    contname += "_histos";
    AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(), 
							      TList::Class(),AliAnalysisManager::kOutputContainer,
							      Form("%s", AliAnalysisManager::GetCommonFileName()));
    mgr->ConnectOutput(rhotask, 1, coutput1);
  }

  return rhotask;
}
Example #6
0
AliAnalysisTaskHaHFECorrel *AddTaskHaHFECorrel(Double_t period, Double_t MinPtEvent, Double_t MaxPtEvent, Bool_t TRDQA, Bool_t CorrHadron, Bool_t CorrLP, Bool_t MCTruth,  Bool_t IsMC, Bool_t IsAOD, Bool_t UseTender, Int_t ITSnCut,  Int_t TPCnCut, Int_t TPCnCutdEdx,   Double_t PhotElecPtCut, Int_t PhotElecTPCnCut,Bool_t PhotElecITSrefitCut,Double_t InvmassCut, Int_t HTPCnCut,   Bool_t HITSrefitCut, Bool_t HTPCrefitCut, Bool_t UseITS, Double_t SigmaITScut, Double_t SigmaTOFcut, Double_t SigmaTPCcut, const char * ID="")
{
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    Error("AddTaskHaHFECorrel", "No analysis manager found.");
    return 0;
  }

  if (!mgr->GetInputEventHandler()) {
    ::Error("AddTaskHaHFECorrel", "This task requires an input event handler");
    return 0x0;
  }

  TString type = mgr->GetInputEventHandler()->GetDataType();

  /*
  AliMCEventHandler* mcHand = new AliMCEventHandler();
  mgr->SetMCtruthEventHandler(mcHand);
  Bool_t MCthere=kTRUE;
  AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler*>(mgr->GetMCtruthEventHandler());
  if (!mcH) {
    MCthere=kFALSE;
  }
  */



  gROOT->LoadMacro("$ALICE_PHYSICS/PWGHF/hfe/macros/configs/pp/ConfigHaHFECorrel.C");
  AliAnalysisTaskHaHFECorrel *taskMB = 
    ConfigHaHFECorrel(period, MinPtEvent, MaxPtEvent, TRDQA, CorrHadron, CorrLP, MCTruth, IsMC, IsAOD, UseTender, ITSnCut, TPCnCut, TPCnCutdEdx, PhotElecPtCut,PhotElecTPCnCut, PhotElecITSrefitCut,  InvmassCut,  HTPCnCut,  HITSrefitCut, HTPCrefitCut, UseITS, SigmaITScut, SigmaTOFcut, SigmaTPCcut, ID);
  if (!taskMB) {
    Error("AddTaskHaHFECorrel", "No task found.");
  }
  taskMB->SelectCollisionCandidates(AliVEvent::kINT7);
  
  // Load correction weights for pi0, eta
  if (IsMC) {
    TH1::AddDirectory(kFALSE);
    printf("Loading Pi0EtaCorrectionFiles\n");
    TString CorrectPi0EtaFile="alien:///alice/cern.ch/user/f/flherrma/HaHFECorrel/Pi0EtaWeights.root";
    TFile *CorrectPi0Eta = TFile::Open(CorrectPi0EtaFile.Data());
    if (CorrectPi0Eta) {    
      TH1F * Pi0W = (TH1F*)CorrectPi0Eta->Get("Pi0Weights");
      TH1F * EtaW = (TH1F*)CorrectPi0Eta->Get("EtaWeights");
      if (Pi0W) taskMB->SetPi0WeightToData(*Pi0W);
      else printf("Could not load Pi0Weights\n");
      if (EtaW)  taskMB->SetEtaWeightToData(*EtaW);
      else printf("Could not load EtaWeights\n");
    }
    else printf("Could not open Pi0Eta correction file \n");
    TH1::AddDirectory(kTRUE);
  }
  TH1::AddDirectory(kFALSE);
  printf("Loading RecEffFiles\n");
  TString RecEffFileName="alien:///alice/cern.ch/user/f/flherrma/HaHFECorrel/RecEff.root";
  TFile *RecEffFile = TFile::Open(RecEffFileName.Data());

  //RecEffFile->ls();
  if (RecEffFile) {    
    TH3F * HadRecEff = (TH3F*)RecEffFile->Get("HadRecEff");
    TH2F * EleRecEff = (TH2F*)RecEffFile->Get("EleRecEff");
    if (HadRecEff) taskMB->SetHadRecEff(*HadRecEff);
    else printf("Could not load HadRecEff\n");
    if (EleRecEff) taskMB->SetEleRecEff(*EleRecEff);
    else printf("Could not load EleRecEff\n");
  }
  else printf("Could not open RecEff correction file \n");
  TH1::AddDirectory(kTRUE);




  mgr->AddTask(taskMB);

  TString containerName1 = mgr->GetCommonFileName();
  containerName1 += ":PWGHF_HaHFECorrel_kINT7_";
  containerName1 += ID;
        
  TString name1 = "histMB_";
  name1 += ID;
        
  AliAnalysisDataContainer *cinput   = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(name1.Data(), TList::Class(),AliAnalysisManager::kOutputContainer, containerName1.Data());
  mgr->ConnectInput(taskMB, 0, cinput);
  mgr->ConnectOutput(taskMB, 1, coutput1);




  return NULL;
}
Example #7
0
AliEPSelectionTask *AddTaskEventplane(Bool_t useEtaGap=kTRUE,Float_t etaGap=0.4,Bool_t posTPCAOD=kFALSE,TString containername = "EPStat")
{
  // Macro to connect an event plane selection task to an existing analysis manager.

  if(useEtaGap && posTPCAOD){
    ::Error("AddTaskEventplane", "eta-splitting of events and one side of TPC not possible at same time!");
    return NULL;
  }
  
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    ::Error("AddTaskEventplane", "No analysis manager to connect to.");
    return NULL;
  }      
  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  if (!mgr->GetInputEventHandler()) {
    ::Error("AddTaskEventplane", "This task requires an input event handler");
    return NULL;
  }
  TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
 
  AliEPSelectionTask *eventplaneTask = new AliEPSelectionTask("EventplaneSelection");
  eventplaneTask->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kSemiCentral | AliVEvent::kCentral);
  if (inputDataType == "AOD"){
    eventplaneTask->SetInput("AOD");
  }
  eventplaneTask->SetTrackType("TPC");
  eventplaneTask->SetUsePtWeight();
  eventplaneTask->SetUsePhiWeight();
  eventplaneTask->SetSaveTrackContribution();
  if(useEtaGap){
    eventplaneTask->SetSubeventsSplitMethod(AliEPSelectionTask::kEta); 
    eventplaneTask->SetEtaGap(etaGap); 
  }
  if(posTPCAOD){
    eventplaneTask->SetPersonalAODtrackCuts(128,0.,0.8,0.15,20.);
    eventplaneTask->SetSubeventsSplitMethod(AliEPSelectionTask::kRandom);
  }
   // Cuts on primary tracks
  AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Standard");
  esdTrackCutsL->SetMinNClustersTPC(50);
  esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
//  esdTrackCutsL->SetMaxCovDiagonalElements(2, 2, 0.5, 0.5, 2);
//  esdTrackCutsL->SetRequireTPCRefit(kTRUE);
  esdTrackCutsL->SetMaxDCAToVertexXY(3.0);
  esdTrackCutsL->SetMaxDCAToVertexZ(3.0);
  esdTrackCutsL->SetDCAToVertex2D(kTRUE);
//  esdTrackCutsL->SetRequireSigmaToVertex(kFALSE);
//  esdTrackCutsL->SetAcceptKinkDaughters(kFALSE);
  eventplaneTask->SetPersonalESDtrackCuts(esdTrackCutsL);


  
  mgr->AddTask(eventplaneTask);

  AliAnalysisDataContainer *cinput0 = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(containername,
                TList::Class(), AliAnalysisManager::kOutputContainer,
                "EventStat_temp.root");
  
  mgr->ConnectInput(eventplaneTask, 0, mgr->GetCommonInputContainer());
  mgr->ConnectOutput(eventplaneTask,1,coutput1);

  return eventplaneTask;
}
AliAnalysisTaskKinkResonance *AddTaskKinkResonanceL1520MC(Short_t lCollidingSystems=0 /*0 = pp, 1 = AA*/)
{
// Creates, configures and attaches to the train a kink resonance task.
// Get the pointer to the existing analysis manager via the static access method.
//==============================================================================
AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
 if (!mgr) {
 ::Error("AddTaskKinkResonanceL1520MC", "No analysis manager to connect to.");
return NULL;
}

// Check the analysis type using the event handlers connected to the analysis manager.
//==============================================================================
if (!mgr->GetInputEventHandler()) {
 ::Error("AddTaskKinkResonanceL1520MC", "This task requires an input event handler");
 return NULL;
}
TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
 if (type != "ESD") {
 ::Error("AddTaskKinkResonanceL1520MC", "This task needs an ESD input handler");
return NULL;
}
if (!mgr->GetMCtruthEventHandler()) {
 ::Error("AddTaskKinkResonanceL1520MC", "This task needs an MC handler");
 return NULL;
}

// Setup the analysis object
  
  AliResonanceKink  *kinkResonanceObjectLMC=new AliResonanceKink();
  kinkResonanceObjectLMC->InitOutputHistograms(100,1.4,1.8, 36, -0.9, 0.9, 100, 0.0, 10.0);
  kinkResonanceObjectLMC->SetPDGCodes(kProton, kKPlus, AliResonanceKink::kLambda1520); 
  kinkResonanceObjectLMC->SetAnalysisType("MC"); // "ESD" or "MC" or "DATA"
  kinkResonanceObjectLMC->SetMaxNsigmaToVertex(4.0);
  kinkResonanceObjectLMC->SetMaxDCAxy(3.0);
  kinkResonanceObjectLMC->SetMaxDCAzaxis(3.0);
  kinkResonanceObjectLMC->SetPtTrackCut(0.25);
  kinkResonanceObjectLMC->SetMinTPCclusters(50);
  kinkResonanceObjectLMC->SetMaxChi2PerTPCcluster(3.5);
  kinkResonanceObjectLMC->SetMaxCov0(2.0);
  kinkResonanceObjectLMC->SetMaxCov2(2.0);
  kinkResonanceObjectLMC->SetMaxCov5(0.5);
  kinkResonanceObjectLMC->SetMaxCov9(0.5);
  kinkResonanceObjectLMC->SetMaxCov14(2.0);
  kinkResonanceObjectLMC->SetMinKinkRadius(120.);
  kinkResonanceObjectLMC->SetMaxKinkRadius(220.);
  kinkResonanceObjectLMC->SetQtLimits(0.05, 0.5);
  kinkResonanceObjectLMC->SetUpperAbsEtaCut(0.9);

// Create and configure the task
AliAnalysisTaskKinkResonance *taskresonanceL1520MC = new AliAnalysisTaskKinkResonance("TaskResL1520MCKinkPID");
taskresonanceL1520MC->SetAnalysisKinkObject(kinkResonanceObjectLMC);
mgr->AddTask(taskresonanceL1520MC);

// Create ONLY the output containers for the data produced by the task.
// Get and connect other common input/output containers via the manager as below
//==============================================================================
   TString outputFileName = AliAnalysisManager::GetCommonFileName();
   outputFileName += ":PWG2KINKResonanceL1520MC";
   if (lCollidingSystems) outputFileName += "_AA";
   else outputFileName += "_PP";
   if (mgr->GetMCtruthEventHandler()) outputFileName += "_MC";

   AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("KinkResL1520MC",
							     TList::Class(),
							     AliAnalysisManager::kOutputContainer,
							     outputFileName );

mgr->ConnectInput(taskresonanceL1520MC, 0, mgr->GetCommonInputContainer());
mgr->ConnectOutput(taskresonanceL1520MC, 1, coutput1);
return taskresonanceL1520MC;
} 
Example #9
0
void AddMixingHandler ( AliMultiInputEventHandler *multiInputHandler,TString format = "esd", Bool_t useMC = kFALSE, TString opts = "" ) {

   const Int_t bufferSize = 2;
   const Int_t mixNum = 1;
   if ( !multiInputHandler ) return;

   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   AliMixInputEventHandler *mixHandler = new AliMixInputEventHandler ( bufferSize, mixNum );
   mixHandler->SetInputHandlerForMixing ( dynamic_cast<AliMultiInputEventHandler *> ( mgr->GetInputEventHandler() ) );
   AliMixEventPool *evPool = new AliMixEventPool();

   AliMixEventCutObj *multi = new AliMixEventCutObj ( AliMixEventCutObj::kMultiplicity, 2, 102, 10 );
//    AliMixEventCutObj *zvertex = new AliMixEventCutObj ( AliMixEventCutObj::kZVertex, -10, 10, 1 );

//    AliMixEventCutObj *centrality = new AliMixEventCutObj(AliMixEventCutObj::kCentrality, 0, 20, 10, "V0M");
//    AliMixEventCutObj *multi = new AliMixEventCutObj(AliMixEventCutObj::kMultiplicity, 2, 102, 10);
//    AliMixEventCutObj *zvertex = new AliMixEventCutObj(AliMixEventCutObj::kZVertex, -5, 5, 1);
//
//    AliMixEventCutObj *multi = new AliMixEventCutObj(AliMixEventCutObj::kMultiplicity, 2, 10002, 1000);
//    AliMixEventCutObj *zvertex = new AliMixEventCutObj(AliMixEventCutObj::kZVertex, -10, 10, 1);
//
//     AliMixEventCutObj *centrality = new AliMixEventCutObj ( AliMixEventCutObj::kCentrality, 0, 100, 10, "V0M" );
   AliMixEventCutObj *zvertex = new AliMixEventCutObj ( AliMixEventCutObj::kZVertex, -10, 10, 1 );

//    evPool->AddCut(centrality);
   evPool->AddCut(multi);
   evPool->AddCut ( zvertex );

   // adds event pool (comment it and u will have default mixing)
   mixHandler->SetEventPool ( evPool );

//   mixHandler->SelectCollisionCandidates(AliVEvent::kAny);
//    mixHandler->SelectCollisionCandidates(AliVEvent::kAnyINT);
//    mixHandler->SelectCollisionCandidates(AliVEvent::kMB);
   mixHandler->SelectCollisionCandidates(AliVEvent::kMUSPB);


//    mixHandler->DoMixIfNotEnoughEvents(kFALSE);

   multiInputHandler->AddInputEventHandler ( mixHandler );

   // adds mixing info task
   gROOT->LoadMacro ( "AddAnalysisTaskMixInfo.C" );
   AddAnalysisTaskMixInfo (opts);

}
Example #10
0
AliAnalysisTaskFemto *AddTaskFemto(TString configMacroName, const char *containerName="femtolist", const char *configMacroParameters="" )
{
// Creates a proton analysis task and adds it to the analysis manager.
  
  // A. Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    Error("AddTaskFemto", "No analysis manager to connect to.");
    return NULL;
  }  

  // B. Check the analysis type using the event handlers connected to the analysis
  //    manager. The availability of MC handler cann also be checked here.
  //==============================================================================
  if (!mgr->GetInputEventHandler()) {
    ::Error("AddTaskFemto", "This task requires an input event handler");
    return NULL;
  }  
  TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
  cout << "Found " <<type << " event handler" << endl;

  // C. Create the task, add it to manager.
  //===========================================================================
//  gSystem->SetIncludePath("-I$ROOTSYS/include  -I./PWG2AOD/AOD -I./PWG2femtoscopy/FEMTOSCOPY/AliFemto -I./PWG2femtoscopyUser/FEMTOSCOPY/AliFemtoUser -I$ALICE_PHYSICS/include");

  if (TProofMgr::GetListOfManagers()->GetEntries()) {
//     if (dynamic_cast<TProofLite *> gProof) {
//       char *macrocommand[10000];
//       sprintf(macrocommand, ".L %s", configMacroName);
//       gProof->Exec(macrocommand);
//     }
//     else
    gProof->Load(configMacroName);
  }  
  //  gROOT->LoadMacro("ConfigFemtoAnalysis.C++");

  //was befere aliroot 5.04.33: AliAnalysisTaskFemto *taskfemto = new AliAnalysisTaskFemto("TaskFemto",configMacroName);
  //  AliAnalysisTaskFemto *taskfemto = new AliAnalysisTaskFemto("TaskFemto",configMacroName,kFALSE);
  //March 2013:
  //to check localy before new tag I did symbolic link on my laplot
  //in $ALICE_PHYSICS/PWGCF/FEMTOSCOPY/macros/Train/
  //[[email protected] Train]# ln -s /scratch/AliWork/PbPb2.76/Train2013/KchHBT KchHBT
  //
  AliAnalysisTaskFemto *taskfemto = new AliAnalysisTaskFemto("TaskFemto","$ALICE_PHYSICS/"+configMacroName,configMacroParameters,kFALSE);
  //10-90% only two triggers: SemiCentral and MB
  //taskfemto->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kSemiCentral);// this a new line for train
  taskfemto->SelectCollisionCandidates(AliVEvent::kINT7);
  //0-10 % all three triggers
  //taskfemto->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);// this a new line for train
  mgr->AddTask(taskfemto);

  // D. Configure the analysis task. Extra parameters can be used via optional
  // arguments of the AddTaskXXX() function.
  //===========================================================================
  
  // E. Create ONLY the output containers for the data produced by the task.
  // Get and connect other common input/output containers via the manager as below
  //==============================================================================
  TString outputfile = AliAnalysisManager::GetCommonFileName();  
  outputfile += ":PWG2FEMTO";
  AliAnalysisDataContainer *cout_femto  = mgr->CreateContainer("femtolist_kt13",  TList::Class(),
  							       AliAnalysisManager::kOutputContainer,outputfile);


   mgr->ConnectInput(taskfemto, 0, mgr->GetCommonInputContainer());
   mgr->ConnectOutput(taskfemto, 0, cout_femto);

   // Return task pointer at the end
   return taskfemto;
}
Example #11
0
AliAnalysisTaskJetExtractor* AddTaskJetExtractor(
  const char *trackArray         = "tracks",
  const char *jetArray           = "jets",
  const char *rhoObject          = "Rho",
  Double_t    jetRadius          = 0.3,
  Double_t    minJetEta          = 0.6,
  Double_t    minJetPt           = 0.15,
  Double_t    minTrackPt         = 0.15,
  Double_t    minJetAreaPerc     = 0.557,
  const char *suffix             = ""
)
{  
  cout << " ############ MACRO EXECUTION STARTED: AddTaskJetExtractor.C ############\n";
  //==============================================================================
  // Prepare analysis manager, containers, etc.
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();

  if (!mgr)
  {
    ::Error("AddTaskJetExtractor", "No analysis manager to connect to.");
    return NULL;
  }  
  if (!mgr->GetInputEventHandler())
  {
    ::Error("AddTaskJetExtractor", "This task requires an input event handler");
    return NULL;
  }
  
  TString name("AliAnalysisTaskJetExtractor");
  if (strcmp(jetArray,"")) {
    name += "_";
    name += jetArray;
  }
  if (strcmp(rhoObject,"")) {
    name += "_";
    name += rhoObject;
  }
  if (strcmp(suffix,"")) {
    name += "_";
    name += suffix;
  }

  AliAnalysisDataContainer* contHistos = mgr->CreateContainer(Form("%s_histos", name.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, Form("%s:ChargedJetsHadronCF", AliAnalysisManager::GetCommonFileName()));

  //==============================================================================
  // Adding and configuring tasks

  AliAnalysisTaskJetExtractor* jetTask = new AliAnalysisTaskJetExtractor(name);
  jetTask->SetNeedEmcalGeom(kFALSE);
  jetTask->SetVzRange(-10.,10.);

  AliParticleContainer *trackCont = 0;
  if(!strcmp(trackArray,"mctracks") || !strcmp(trackArray, "mcparticles"))
    trackCont = jetTask->AddMCParticleContainer(trackArray);
  else
    trackCont = jetTask->AddTrackContainer(trackArray);

  trackCont->SetParticlePtCut(minTrackPt);

  AliJetContainer *jetCont = jetTask->AddJetContainer(jetArray,6,jetRadius);
  if (jetCont) {
    jetCont->SetRhoName(rhoObject);
    jetCont->SetPercAreaCut(minJetAreaPerc);
    jetCont->SetJetPtCut(minJetPt);
    jetCont->SetLeadingHadronType(0);
    jetCont->SetPtBiasJetTrack(minTrackPt);
    jetCont->SetJetEtaLimits(-minJetEta, +minJetEta);
    jetCont->ConnectParticleContainer(trackCont);
    jetCont->SetMaxTrackPt(1000);
  }

  mgr->AddTask(jetTask);

  //==============================================================================
  // Finalization

  mgr->ConnectInput  (jetTask, 0,  mgr->GetCommonInputContainer() );
  mgr->ConnectOutput (jetTask, 1, contHistos );
 
  cout << " ############ MACRO EXECUTION DONE: AddTaskJetExtractor.C ############\n";
 
  return jetTask;
}
void AddTaskFlowCentralityKinkQbMunu( Float_t centrMin=0.,
                                  Float_t centrMax=100.,
                                  TString fileNameBase="output",
                                  AliPID::EParticleType particleType=AliPID::kUnknown,
                                  AliFlowTrackCuts::PIDsource sourcePID = AliFlowTrackCuts::kTOFpid,
                                  Int_t charge=0,
                                  Int_t harmonic=2,
                                  Bool_t doQA=kFALSE,
                                  TString uniqueStr=""
                                )
{
  // Define the range for eta subevents (for SP method)
  Double_t minA = -0.9;
  Double_t maxA = -0.4;
  Double_t minB = 0.4;
  Double_t maxB = 0.9;
  TString totalQvectorSP="Qb"; //["Qa"|"Qb"|"QaQb"]
  Double_t poiMinEta=-0.9;
  Double_t poiMaxEta=-0.4;


  // 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};
  Bool_t METHODS[] = {SP};

  // 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::kGlobal;
  AliFlowTrackCuts::trackParameterType poitype = AliFlowTrackCuts::kKink;

  //---------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::kV0);
  //cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kSPD1tracklets);
  cutsEvent->SetNContributorsRange(2);
  cutsEvent->SetPrimaryVertexZrange(-7.,7.);
  cutsEvent->SetQA(doQA);
  
  // RP TRACK CUTS:
  AliFlowTrackCuts* cutsRP = new AliFlowTrackCuts("TPConlyRP");
  cutsRP->SetParamType(rptype);
  cutsRP->SetParamMix(rpmix);
  cutsRP->SetPtRange(0.2,5.);
  cutsRP->SetEtaRange(-0.8,0.8);
  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->SetQA(doQA);

  // POI TRACK CUTS:
  AliFlowTrackCuts* cutsPOI = new AliFlowTrackCuts("GlobalPOI");
  cutsPOI->SetParamType(poitype);
  cutsPOI->SetParamMix(poimix);
  cutsPOI->SetPtRange(0.0,10.);
  cutsPOI->SetEtaRange(poiMinEta,poiMaxEta);
  //cutsPOI->SetRequireCharge(kTRUE);
  //cutsPOI->SetPID(PdgRP);
  cutsPOI->SetMinNClustersTPC(30);
  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.);
  cutsPOI->SetMaxDCAToVertexZ(3.);
  //cutsPOI->SetDCAToVertex2D(kTRUE);
  //cutsPOI->SetMaxNsigmaToVertex(1.e+10);
  //cutsPOI->SetRequireSigmaToVertex(kFALSE);
  cutsPOI->SetAcceptKinkDaughters(kTRUE);
  cutsPOI->SetPID(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->SetQA(doQA);
  cutsPOI->SetMinKinkInvMassKmu(0.46);

  TString outputSlotName("");
  outputSlotName+=uniqueStr;
  outputSlotName+=" ";
  outputSlotName+=totalQvectorSP;
  outputSlotName+=" ";
  outputSlotName+=Form("V%i ",harmonic);
  outputSlotName+=cutsRP->GetName();
  outputSlotName+=" ";
  outputSlotName+=cutsPOI->GetName();
  outputSlotName+=Form(" %.0f-",centrMin);
  outputSlotName+=Form("%.0f ",centrMax);
  outputSlotName+=Form("POI:%s ", AliFlowTrackCuts::GetParamTypeName(cutsPOI->GetParamType()) );
  outputSlotName+=Form("RP:%s ", AliFlowTrackCuts::GetParamTypeName(cutsRP->GetParamType()) );
  if (particleType!=AliPID::kUnknown)
  {
    outputSlotName+=AliFlowTrackCuts::PIDsourceName(sourcePID);
    outputSlotName+=" ";
    outputSlotName+=AliPID::ParticleName(particleType);
  }
  if (charge<0) outputSlotName+="-";
  if (charge>0) outputSlotName+="+";

  TString fileName(fileNameBase);
  fileName.Append(".root");

  Bool_t useWeights  = WEIGHTS[0] || WEIGHTS[1] || WEIGHTS[2];
  if (useWeights) cout<<"Weights are used"<<endl;
  else cout<<"Weights are not used"<<endl;
  
  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    Error("AddTaskFlowEvent", "No analysis manager to connect to.");
    return NULL;
  }
  
  // Check the analysis type using the event handlers connected to the analysis
  // manager. The availability of MC handler can also be checked here.
  //==============================================================================
  if (!mgr->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 <weights.root> with weights from the previous run was not available."<<endl;
      break;
    } 
  }
  
  //LYZ2
  if (LYZ2SUM || LYZ2PROD) {
    //read the outputfile of the first run
    TString outputFileName = "AnalysisResults1.root";
    TString pwd(gSystem->pwd());
    pwd+="/";
    pwd+=outputFileName.Data();
    TFile *outputFile = NULL;
    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
      cout<<"WARNING: You do not have an output file:"<<endl;
      cout<<"         "<<pwd.Data()<<endl;
      exit(0);
    } else { outputFile = TFile::Open(pwd.Data(),"READ");}
    
    if (LYZ2SUM){  
      // read the output directory from LYZ1SUM 
      TString inputFileNameLYZ2SUM = "outputLYZ1SUManalysis" ;
      inputFileNameLYZ2SUM += rptypestr;
      cout<<"The input directory is "<<inputFileNameLYZ2SUM.Data()<<endl;
      TFile* fInputFileLYZ2SUM = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2SUM.Data());
      if(!fInputFileLYZ2SUM || fInputFileLYZ2SUM->IsZombie()) { 
	cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ; 
	break;
      }
      else {
	TList* fInputListLYZ2SUM = (TList*)fInputFileLYZ2SUM->Get("LYZ1SUM");
	if (!fInputListLYZ2SUM) {cout<<"list is NULL pointer!"<<endl;}
      }
      cout<<"LYZ2SUM input file/list read..."<<endl;
    }

    if (LYZ2PROD){  
      // read the output directory from LYZ1PROD 
      TString inputFileNameLYZ2PROD = "outputLYZ1PRODanalysis" ;
      inputFileNameLYZ2PROD += rptypestr;
      cout<<"The input directory is "<<inputFileNameLYZ2PROD.Data()<<endl;
      TFile* fInputFileLYZ2PROD = (TFile*)outputFile->FindObjectAny(inputFileNameLYZ2PROD.Data());
      if(!fInputFileLYZ2PROD || fInputFileLYZ2PROD->IsZombie()) { 
	cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ; 
	break;
      }
      else {
	TList* fInputListLYZ2PROD = (TList*)fInputFileLYZ2PROD->Get("LYZ1PROD");
	if (!fInputListLYZ2PROD) {cout<<"list is NULL pointer!"<<endl;}
      }
      cout<<"LYZ2PROD input file/list read..."<<endl;
    }
  }

  if (LYZEP) {
    //read the outputfile of the second run
    TString outputFileName = "AnalysisResults2.root";
    TString pwd(gSystem->pwd());
    pwd+="/";
    pwd+=outputFileName.Data();
    TFile *outputFile = NULL;
    if(gSystem->AccessPathName(pwd.Data(),kFileExists)) {
      cout<<"WARNING: You do not have an output file:"<<endl;
      cout<<"         "<<pwd.Data()<<endl;
      exit(0);
    } else {
      outputFile = TFile::Open(pwd.Data(),"READ");
    }
    
    // read the output file from LYZ2SUM
    TString inputFileNameLYZEP = "outputLYZ2SUManalysis" ;
    inputFileNameLYZEP += rptypestr;
    cout<<"The input file is "<<inputFileNameLYZEP.Data()<<endl;
    TFile* fInputFileLYZEP = (TFile*)outputFile->FindObjectAny(inputFileNameLYZEP.Data());
    if(!fInputFileLYZEP || fInputFileLYZEP->IsZombie()) { 
      cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ; 
      break;
    }
    else {
      TList* fInputListLYZEP = (TList*)fInputFileLYZEP->Get("LYZ2SUM");
      if (!fInputListLYZEP) {cout<<"list is NULL pointer!"<<endl;}
    }
    cout<<"LYZEP input file/list read..."<<endl;
  }
  
  
  // Create the FMD task and add it to the manager
  //===========================================================================
  if (rptypestr == "FMD") {
    AliFMDAnalysisTaskSE *taskfmd = NULL;
    if (rptypestr == "FMD") {
      taskfmd = new AliFMDAnalysisTaskSE("TaskFMD");
      mgr->AddTask(taskfmd);
      
      AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
      pars->Init();
      pars->SetProcessPrimary(kTRUE); //for MC only
      pars->SetProcessHits(kFALSE);
      
      //pars->SetRealData(kTRUE); //for real data
      //pars->SetProcessPrimary(kFALSE); //for real data
    }
  }
  
  // Create the flow event task, add it to the manager.
  //===========================================================================
  AliAnalysisTaskFlowEvent *taskFE = NULL;

  if(useAfterBurner)
    { 
      taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA,1);
      taskFE->SetFlow(v1,v2,v3,v4); 
      taskFE->SetNonFlowNumberOfTrackClones(numberOfTrackClones);
      taskFE->SetAfterburnerOn();
    }
  else {taskFE = new AliAnalysisTaskFlowEvent(Form("TaskFlowEvent %s",outputSlotName.Data()),"",doQA); }
  if (ExcludeRegion) {
    taskFE->DefineDeadZone(excludeEtaMin, excludeEtaMax, excludePhiMin, excludePhiMax); 
  }
  taskFE->SetSubeventEtaRange(minA, maxA, minB, maxB);
  if (UsePhysicsSelection) {
    taskFE->SelectCollisionCandidates(AliVEvent::kMB);
    cout<<"Using Physics Selection"<<endl;
  }
  mgr->AddTask(taskFE);
  
  // Pass cuts for RPs and POIs to the task:
  taskFE->SetCutsEvent(cutsEvent);
  taskFE->SetCutsRP(cutsRP);
  taskFE->SetCutsPOI(cutsPOI);
  if (cutsRP->GetParamType()==AliFlowTrackCuts::kV0)
  { 
    //TODO: since this is set in a static object all analyses in an analysis train
    //will be affected.
    taskFE->SetHistWeightvsPhiMin(0.);
    taskFE->SetHistWeightvsPhiMax(200.);
  }

  // Create the analysis tasks, add them to the manager.
  //===========================================================================
  if (SP){
    AliAnalysisTaskScalarProduct *taskSP = new AliAnalysisTaskScalarProduct(Form("TaskScalarProduct %s",outputSlotName.Data()),WEIGHTS[0]);
    taskSP->SetRelDiffMsub(1.0);
    taskSP->SetApplyCorrectionForNUA(kTRUE);
    taskSP->SetTotalQvector(totalQvectorSP.Data());
    mgr->AddTask(taskSP);
  }
  if (LYZ1SUM){
    AliAnalysisTaskLeeYangZeros *taskLYZ1SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kTRUE);
    taskLYZ1SUM->SetFirstRunLYZ(kTRUE);
    taskLYZ1SUM->SetUseSumLYZ(kTRUE);
    mgr->AddTask(taskLYZ1SUM);
  }
  if (LYZ1PROD){
    AliAnalysisTaskLeeYangZeros *taskLYZ1PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kTRUE);
    taskLYZ1PROD->SetFirstRunLYZ(kTRUE);
    taskLYZ1PROD->SetUseSumLYZ(kFALSE);
    mgr->AddTask(taskLYZ1PROD);
  }
  if (LYZ2SUM){
    AliAnalysisTaskLeeYangZeros *taskLYZ2SUM = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosSUM %s",outputSlotName.Data()),kFALSE);
    taskLYZ2SUM->SetFirstRunLYZ(kFALSE);
    taskLYZ2SUM->SetUseSumLYZ(kTRUE);
    mgr->AddTask(taskLYZ2SUM);
  }
  if (LYZ2PROD){
    AliAnalysisTaskLeeYangZeros *taskLYZ2PROD = new AliAnalysisTaskLeeYangZeros(Form("TaskLeeYangZerosPROD %s",outputSlotName.Data()),kFALSE);
    taskLYZ2PROD->SetFirstRunLYZ(kFALSE);
    taskLYZ2PROD->SetUseSumLYZ(kFALSE);
    mgr->AddTask(taskLYZ2PROD);
  }
  if (LYZEP){
    AliAnalysisTaskLYZEventPlane *taskLYZEP = new AliAnalysisTaskLYZEventPlane(Form("TaskLYZEventPlane %s",outputSlotName.Data()));
    mgr->AddTask(taskLYZEP);
  }
  if (GFC){
    AliAnalysisTaskCumulants *taskGFC = new AliAnalysisTaskCumulants(Form("TaskCumulants %s",outputSlotName.Data()),useWeights);
    taskGFC->SetUsePhiWeights(WEIGHTS[0]); 
    taskGFC->SetUsePtWeights(WEIGHTS[1]);
    taskGFC->SetUseEtaWeights(WEIGHTS[2]); 
    mgr->AddTask(taskGFC);
  }
  if (QC){
    AliAnalysisTaskQCumulants *taskQC = new AliAnalysisTaskQCumulants(Form("TaskQCumulants %s",outputSlotName.Data()),useWeights);
    taskQC->SetUsePhiWeights(WEIGHTS[0]); 
    taskQC->SetUsePtWeights(WEIGHTS[1]);
    taskQC->SetUseEtaWeights(WEIGHTS[2]); 
    taskQC->SetCalculateCumulantsVsM(kFALSE);
    taskQC->SetnBinsMult(10000);
    taskQC->SetMinMult(0.);
    taskQC->SetMaxMult(10000.);
    taskQC->SetHarmonic(harmonic);
    taskQC->SetApplyCorrectionForNUA(kFALSE);
    taskQC->SetFillMultipleControlHistograms(kFALSE);     
    mgr->AddTask(taskQC);
  }
  if (FQD){
    AliAnalysisTaskFittingQDistribution *taskFQD = new AliAnalysisTaskFittingQDistribution(Form("TaskFittingQDistribution %s",outputSlotName.Data()),kFALSE);
    taskFQD->SetUsePhiWeights(WEIGHTS[0]); 
    taskFQD->SetqMin(0.);
    taskFQD->SetqMax(1000.);
    taskFQD->SetqNbins(10000);
    mgr->AddTask(taskFQD);
  }
  if (MCEP){
    AliAnalysisTaskMCEventPlane *taskMCEP = new AliAnalysisTaskMCEventPlane(Form("TaskMCEventPlane %s",outputSlotName.Data()));
    mgr->AddTask(taskMCEP);
  }
  if (MH){
    AliAnalysisTaskMixedHarmonics *taskMH = new AliAnalysisTaskMixedHarmonics(Form("TaskMixedHarmonics %s",outputSlotName.Data()),useWeights);
    taskMH->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
    taskMH->SetNoOfMultipicityBins(10000);
    taskMH->SetMultipicityBinWidth(1.);
    taskMH->SetMinMultiplicity(1.);
    taskMH->SetCorrectForDetectorEffects(kTRUE);
    taskMH->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>> (Remark: two nested loops)    
    taskMH->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
    mgr->AddTask(taskMH);
  }  
  if (NL){
    AliAnalysisTaskNestedLoops *taskNL = new AliAnalysisTaskNestedLoops(Form("TaskNestedLoops %s",outputSlotName.Data()),useWeights);
    taskNL->SetHarmonic(1); // n in cos[n(phi1+phi2-2phi3)] and cos[n(psi1+psi2-2phi3)]
    taskNL->SetEvaluateNestedLoopsForRAD(kTRUE); // RAD = Relative Angle Distribution
    taskNL->SetEvaluateNestedLoopsForMH(kTRUE); // evalaute <<cos[n(phi1+phi2-2phi3)]>> (Remark: three nested loops)   
    taskNL->SetEvaluateDifferential3pCorrelator(kFALSE); // evaluate <<cos[n(psi1+psi2-2phi3)]>>  (Remark: three nested loops)   
    taskNL->SetOppositeChargesPOI(kFALSE); // POIs psi1 and psi2 in cos[n(psi1+psi2-2phi3)] will have opposite charges  
    mgr->AddTask(taskNL);
  }

  // Create the output container for the data produced by the task
  // Connect to the input and output containers
  //===========================================================================
  AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
  
  if (rptypestr == "FMD") {
    AliAnalysisDataContainer *coutputFMD = 
      mgr->CreateContainer(Form("BackgroundCorrected %s",outputSlotName.Data()), TList::Class(), AliAnalysisManager::kExchangeContainer);
    //input and output taskFMD     
    mgr->ConnectInput(taskfmd, 0, cinput1);
    mgr->ConnectOutput(taskfmd, 1, coutputFMD);
    //input into taskFE
    mgr->ConnectInput(taskFE,1,coutputFMD);
  }
  
  AliAnalysisDataContainer *coutputFE = 
  mgr->CreateContainer(Form("FlowEventSimple %s",outputSlotName.Data()),AliFlowEventSimple::Class(),AliAnalysisManager::kExchangeContainer);
  mgr->ConnectInput(taskFE,0,cinput1); 
  mgr->ConnectOutput(taskFE,1,coutputFE);
 
  if (taskFE->GetQAOn())
  {
    TString outputQA = fileName;
    outputQA += ":QA";
    AliAnalysisDataContainer* coutputFEQA = 
    mgr->CreateContainer(Form("QA %s",outputSlotName.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputQA);
    mgr->ConnectOutput(taskFE,2,coutputFEQA);
  }

  // Create the output containers for the data produced by the analysis tasks
  // Connect to the input and output containers
  //===========================================================================
  if (useWeights) {    
    AliAnalysisDataContainer *cinputWeights = mgr->CreateContainer(Form("Weights %s",outputSlotName.Data()),
								   TList::Class(),AliAnalysisManager::kInputContainer); 
  }

  if(SP) {
    TString outputSP = fileName;
    outputSP += ":outputSPanalysis";
    outputSP+= rptypestr;
    AliAnalysisDataContainer *coutputSP = mgr->CreateContainer(Form("SP %s",outputSlotName.Data()), 
							       TList::Class(),AliAnalysisManager::kOutputContainer,outputSP); 
    mgr->ConnectInput(taskSP,0,coutputFE); 
    mgr->ConnectOutput(taskSP,1,coutputSP); 
    if (WEIGHTS[0]) {
      mgr->ConnectInput(taskSP,1,cinputWeights);
      cinputWeights->SetData(weightsList);
    }
  }
  if(LYZ1SUM) {
    TString outputLYZ1SUM = fileName;
    outputLYZ1SUM += ":outputLYZ1SUManalysis";
    outputLYZ1SUM+= rptypestr;
    AliAnalysisDataContainer *coutputLYZ1SUM = mgr->CreateContainer(Form("LYZ1SUM %s",outputSlotName.Data()), 
								    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1SUM); 
    mgr->ConnectInput(taskLYZ1SUM,0,coutputFE);
    mgr->ConnectOutput(taskLYZ1SUM,1,coutputLYZ1SUM);
  }
  if(LYZ1PROD) {
    TString outputLYZ1PROD = fileName;
    outputLYZ1PROD += ":outputLYZ1PRODanalysis";
    outputLYZ1PROD+= rptypestr;
    AliAnalysisDataContainer *coutputLYZ1PROD = mgr->CreateContainer(Form("LYZ1PROD %s",outputSlotName.Data()), 
								     TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ1PROD); 
    mgr->ConnectInput(taskLYZ1PROD,0,coutputFE); 
    mgr->ConnectOutput(taskLYZ1PROD,1,coutputLYZ1PROD);
  }
  if(LYZ2SUM) {
    AliAnalysisDataContainer *cinputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUMin %s",outputSlotName.Data()),
								   TList::Class(),AliAnalysisManager::kInputContainer);
    TString outputLYZ2SUM = fileName;
    outputLYZ2SUM += ":outputLYZ2SUManalysis";
    outputLYZ2SUM+= rptypestr;
    
    AliAnalysisDataContainer *coutputLYZ2SUM = mgr->CreateContainer(Form("LYZ2SUM %s",outputSlotName.Data()), 
								    TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2SUM); 
    mgr->ConnectInput(taskLYZ2SUM,0,coutputFE); 
    mgr->ConnectInput(taskLYZ2SUM,1,cinputLYZ2SUM);
    mgr->ConnectOutput(taskLYZ2SUM,1,coutputLYZ2SUM); 
    cinputLYZ2SUM->SetData(fInputListLYZ2SUM);
  }
  if(LYZ2PROD) {
    AliAnalysisDataContainer *cinputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PRODin %s",outputSlotName.Data()),
								    TList::Class(),AliAnalysisManager::kInputContainer);
    TString outputLYZ2PROD = fileName;
    outputLYZ2PROD += ":outputLYZ2PRODanalysis";
    outputLYZ2PROD+= rptypestr;
    
    AliAnalysisDataContainer *coutputLYZ2PROD = mgr->CreateContainer(Form("LYZ2PROD %s",outputSlotName.Data()), 
								     TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZ2PROD); 
    mgr->ConnectInput(taskLYZ2PROD,0,coutputFE); 
    mgr->ConnectInput(taskLYZ2PROD,1,cinputLYZ2PROD);
    mgr->ConnectOutput(taskLYZ2PROD,1,coutputLYZ2PROD); 
    cinputLYZ2PROD->SetData(fInputListLYZ2PROD);
  }
  if(LYZEP) {
    AliAnalysisDataContainer *cinputLYZEP = mgr->CreateContainer(Form("LYZEPin %s",outputSlotName.Data()),
								 TList::Class(),AliAnalysisManager::kInputContainer);
    TString outputLYZEP = fileName;
    outputLYZEP += ":outputLYZEPanalysis";
    outputLYZEP+= rptypestr;
    
    AliAnalysisDataContainer *coutputLYZEP = mgr->CreateContainer(Form("LYZEP %s",outputSlotName.Data()), 
								  TList::Class(),AliAnalysisManager::kOutputContainer,outputLYZEP); 
    mgr->ConnectInput(taskLYZEP,0,coutputFE); 
    mgr->ConnectInput(taskLYZEP,1,cinputLYZEP);
    mgr->ConnectOutput(taskLYZEP,1,coutputLYZEP); 
    cinputLYZEP->SetData(fInputListLYZEP);
  }
  if(GFC) {
    TString outputGFC = fileName;
    outputGFC += ":outputGFCanalysis";
    outputGFC+= rptypestr;
    
    AliAnalysisDataContainer *coutputGFC = mgr->CreateContainer(Form("GFC %s",outputSlotName.Data()), 
								TList::Class(),AliAnalysisManager::kOutputContainer,outputGFC); 
    mgr->ConnectInput(taskGFC,0,coutputFE); 
    mgr->ConnectOutput(taskGFC,1,coutputGFC);
    if (useWeights) {
      mgr->ConnectInput(taskGFC,1,cinputWeights);
      cinputWeights->SetData(weightsList);
    } 
  }
  if(QC) {
    TString outputQC = fileName;
    outputQC += ":outputQCanalysis";
    outputQC+= rptypestr;

    AliAnalysisDataContainer *coutputQC = mgr->CreateContainer(Form("QC %s",outputSlotName.Data()), 
							       TList::Class(),AliAnalysisManager::kOutputContainer,outputQC); 
    mgr->ConnectInput(taskQC,0,coutputFE); 
    mgr->ConnectOutput(taskQC,1,coutputQC);
    if (useWeights) {
      mgr->ConnectInput(taskQC,1,cinputWeights);
      cinputWeights->SetData(weightsList);
    }
  }
  if(FQD) {
    TString outputFQD = fileName;
    outputFQD += ":outputFQDanalysis";
    outputFQD+= rptypestr;
    
    AliAnalysisDataContainer *coutputFQD = mgr->CreateContainer(Form("FQD %s",outputSlotName.Data()), 
								TList::Class(),AliAnalysisManager::kOutputContainer,outputFQD); 
    mgr->ConnectInput(taskFQD,0,coutputFE); 
    mgr->ConnectOutput(taskFQD,1,coutputFQD);
    if(useWeights) {
      mgr->ConnectInput(taskFQD,1,cinputWeights);
      cinputWeights->SetData(weightsList);
    } 
  }
  if(MCEP) {
    TString outputMCEP = fileName;
    outputMCEP += ":outputMCEPanalysis";
    outputMCEP+= rptypestr;
    
    AliAnalysisDataContainer *coutputMCEP = mgr->CreateContainer(Form("MCEP %s",outputSlotName.Data()), 
								 TList::Class(),AliAnalysisManager::kOutputContainer,outputMCEP); 
    mgr->ConnectInput(taskMCEP,0,coutputFE);
    mgr->ConnectOutput(taskMCEP,1,coutputMCEP); 
  }
  if(MH) {
    TString outputMH = fileName;
    outputMH += ":outputMHanalysis";
    outputMH += rptypestr;
        
    AliAnalysisDataContainer *coutputMH = mgr->CreateContainer(Form("MH %s",outputSlotName.Data()), 
							       TList::Class(),AliAnalysisManager::kOutputContainer,outputMH); 
    mgr->ConnectInput(taskMH,0,coutputFE); 
    mgr->ConnectOutput(taskMH,1,coutputMH); 
    //if (useWeights) {
    //  mgr->ConnectInput(taskMH,1,cinputWeights);
    //  cinputWeights->SetData(weightsList);
    //} 
  }
  if(NL) {
    TString outputNL = fileName;
    outputNL += ":outputNLanalysis";
    outputNL += rptypestr;

    AliAnalysisDataContainer *coutputNL = mgr->CreateContainer(Form("NL %s",outputSlotName.Data()), 
							       TList::Class(),AliAnalysisManager::kOutputContainer,outputNL); 
    mgr->ConnectInput(taskNL,0,coutputFE);
    mgr->ConnectOutput(taskNL,1,coutputNL);
    //if (useWeights) {
    //  mgr->ConnectInput(taskNL,1,cinputWeights);
    //  cinputWeights->SetData(weightsList);
    //} 
  }

  ///////////////////////////////////////////////////////////////////////////////////////////
  if (runQAtask)
  {
    AliAnalysisTaskQAflow* taskQAflow = new AliAnalysisTaskQAflow(Form("TaskQAflow %s",outputSlotName.Data()));
    taskQAflow->SetEventCuts(cutsEvent);
    taskQAflow->SetTrackCuts(cutsRP);
    taskQAflow->SetFillNTuple(FillQAntuple);
    taskQAflow->SetDoCorrelations(DoQAcorrelations);
    mgr->AddTask(taskQAflow);
    
    Printf("outputSlotName %s",outputSlotName.Data());
    TString taskQAoutputFileName(fileNameBase);
    taskQAoutputFileName.Append("_QA.root");
    AliAnalysisDataContainer* coutputQAtask = mgr->CreateContainer(Form("flowQA %s",outputSlotName.Data()),
                                              TObjArray::Class(),
                                              AliAnalysisManager::kOutputContainer,
                                              taskQAoutputFileName);
    AliAnalysisDataContainer* coutputQAtaskTree = mgr->CreateContainer(Form("flowQAntuple %s",outputSlotName.Data()),
                                              TNtuple::Class(),
                                              AliAnalysisManager::kOutputContainer,
                                              taskQAoutputFileName);
    mgr->ConnectInput(taskQAflow,0,mgr->GetCommonInputContainer());
    mgr->ConnectInput(taskQAflow,1,coutputFE);
    mgr->ConnectOutput(taskQAflow,1,coutputQAtask);
    if (FillQAntuple) mgr->ConnectOutput(taskQAflow,2,coutputQAtaskTree);
  }
}
Example #13
0
void AddMixingHandler(Double_t centMin = 70, Double_t centMax = 80, Double_t centStep = 2, Bool_t bAOD = kTRUE, Bool_t useMC = kFALSE, Bool_t usePhysSel = kTRUE, Bool_t bCentralTrigger = kFALSE, TString opts = "")
{
  
    AliESDInputHandler *esdInputHandler = 0;
    AliAODInputHandler *aodInputHandler = 0;
    AliMCEventHandler  *mcInputHandler  = 0;
  
    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();

    AliMultiInputEventHandler *multiInputHandler = new AliMultiInputEventHandler();
    mgr->SetInputEventHandler(multiInputHandler);
    
    if (!bAOD) {
      esdInputHandler = new AliESDInputHandler();
      multiInputHandler->AddInputEventHandler(esdInputHandler);
      //centralityInputHandler = new AliCentralityInputHandler();
      //multiInputHandler->AddInputEventHandler(centralityInputHandler);
      if (bMCtruth) {
    	mcInputHandler = new AliMCEventHandler();
    	multiInputHandler->AddInputEventHandler(mcInputHandler);
    	// Not reading track references
    	mchandler->SetReadTR(kFALSE);
      }
    } else if (bAOD) {
      aodInputHandler = new AliAODInputHandler();
      multiInputHandler->AddInputEventHandler(aodInputHandler);
    } else {
      Printf("Error: Only ESD and AOD input format is supported !!!");
     return;
    }

   if (!multiInputHandler) return;

   const Int_t bufferSize = 1;
   const Int_t mixNum = 5;
   AliMixInputEventHandler *mixHandler = new AliMixInputEventHandler(bufferSize, mixNum);
   mixHandler->SetInputHandlerForMixing(dynamic_cast<AliMultiInputEventHandler*>(mgr->GetInputEventHandler()));
   AliMixEventPool *evPool = new AliMixEventPool();

   //AliMixEventCutObj *multi = new AliMixEventCutObj(AliMixEventCutObj::kMultiplicity, 2, 10002, 10000);
   AliMixEventCutObj *zvertex = new AliMixEventCutObj(AliMixEventCutObj::kZVertex, -10, 10, 5);

   AliMixEventCutObj *centrality = new AliMixEventCutObj(AliMixEventCutObj::kCentrality, centMin, centMax, centStep, "V0M");

   evPool->AddCut(centrality);
   //evPool->AddCut(multi);
   evPool->AddCut(zvertex);

   // adds event pool (comment it and u will have default mixing)
   mixHandler->SetEventPool(evPool);

   // only use events with physics selection
   if (usePhysSel){
     if (bCentralTrigger){
       mixHandler->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);
     }
     else{ 
       mixHandler->SelectCollisionCandidates(AliVEvent::kMB);
     }
   }
   
   multiInputHandler->AddInputEventHandler(mixHandler);

}
void AddTask_GammaCaloDalitzV1_pPb(  Int_t trainConfig = 1,  //change different set of cuts
                              Bool_t isMC   = kFALSE, //run MC
                              Int_t enableQAMesonTask = 0, //enable QA in AliAnalysisTaskGammaConvV1
                              Int_t enableQAPhotonTask = 0, // enable additional QA task
                              TString fileNameInputForWeighting = "MCSpectraInput.root", // path to file for weigting input
                              Int_t doWeightingPart = 0,  //enable Weighting
                              TString generatorName = "DPMJET",
                              TString cutnumberAODBranch = "8000000060084000001500000", // cutnumber for AOD branch
                              Bool_t enableExtendedMatching = kFALSE, //enable or disable extended matching histograms for conversion electrons <-> cluster
                              Bool_t isUsingTHnSparse = kTRUE, //enable or disable usage of THnSparses for background estimation
                              Bool_t enableV0findingEffi = kFALSE
              ) {

  Int_t isHeavyIon = 2;

  // ================== GetAnalysisManager ===============================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    Error(Form("AddTask_GammaConvV1_%i",trainConfig), "No analysis manager found.");
    return ;
  }

  // ================== GetInputEventHandler =============================
  AliVEventHandler *inputHandler=mgr->GetInputEventHandler();

  //========= Add PID Reponse to ANALYSIS manager ====
  if(!(AliPIDResponse*)mgr->GetTask("PIDResponseTask")){
    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
    AddTaskPIDResponse(isMC);
  }

  Printf("here \n");

  //=========  Set Cutnumber for V0Reader ================================
            //06000078400100001500000000
  TString cutnumberPhoton 	= "06000078400100007500000000";
  TString cutnumberEvent 		= "80000003";
  TString cutnumberElectron   = "90005400000002000000";            //Electron Cuts



  Bool_t doEtaShift = kFALSE;
  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();

  //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
    TString V0ReaderName = Form("V0ReaderV1_%s_%s",cutnumberEvent.Data(),cutnumberPhoton.Data());
    if( !(AliV0ReaderV1*)mgr->GetTask(V0ReaderName.Data()) ){

        AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1(V0ReaderName.Data());

    fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
    fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
    fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
    fV0ReaderV1->SetProduceV0FindingEfficiency(enableV0findingEffi);

    if (!mgr) {
      Error("AddTask_V0ReaderV1", "No analysis manager found.");
      return;
    }

    AliConvEventCuts *fEventCuts=NULL;
    if(cutnumberEvent!=""){
      fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
      fEventCuts->SetPreSelectionCutFlag(kTRUE);
            fEventCuts->SetV0ReaderName(V0ReaderName);
      if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
        fEventCuts->DoEtaShift(doEtaShift);
        fV0ReaderV1->SetEventCuts(fEventCuts);
        fEventCuts->SetFillCutHistograms("",kTRUE);
      }
    }

    // Set AnalysisCut Number
    AliConversionPhotonCuts *fCuts=NULL;
    if(cutnumberPhoton!=""){
      fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
      fCuts->SetPreSelectionCutFlag(kTRUE);
      fCuts->SetIsHeavyIon(isHeavyIon);
      fCuts->SetV0ReaderName(V0ReaderName);
      if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
        fV0ReaderV1->SetConversionCuts(fCuts);
        fCuts->SetFillCutHistograms("",kTRUE);
      }
    }
    if(inputHandler->IsA()==AliAODInputHandler::Class()){
    // AOD mode
      fV0ReaderV1->AliV0ReaderV1::SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
    }
    fV0ReaderV1->Init();

    AliLog::SetGlobalLogLevel(AliLog::kFatal);

    //connect input V0Reader
    mgr->AddTask(fV0ReaderV1);
    mgr->ConnectInput(fV0ReaderV1,0,cinput);

  }

    //================================================
    //========= Add Electron Selector ================
    if( !(AliDalitzElectronSelector*)mgr->GetTask("ElectronSelector") ){

    AliDalitzElectronSelector *fElectronSelector = new AliDalitzElectronSelector("ElectronSelector");

    // Set AnalysisCut Number
    AliDalitzElectronCuts *fElecCuts=0;
    if( cutnumberElectron!=""){
      fElecCuts= new AliDalitzElectronCuts(cutnumberElectron.Data(),cutnumberElectron.Data());

      if(fElecCuts->InitializeCutsFromCutString(cutnumberElectron.Data())){
        fElectronSelector->SetDalitzElectronCuts(fElecCuts);
        fElecCuts->SetFillCutHistograms("",kTRUE);
      }
    }

    fElectronSelector->Init();
    mgr->AddTask(fElectronSelector);

    AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer();

    //connect input V0Reader

    mgr->ConnectInput (fElectronSelector,0,cinput1);

    }

  //================================================
  //========= Add task to the ANALYSIS manager =====
  //================================================
  AliAnalysisTaskGammaCaloDalitzV1 *task=NULL;
  task= new AliAnalysisTaskGammaCaloDalitzV1(Form("GammaCaloDalitz_%i",trainConfig));
  task->SetIsHeavyIon(isHeavyIon);
  task->SetIsMC(isMC);
  task->SetV0ReaderName(V0ReaderName);

  // Cut Numbers to use in Analysis
  Int_t numberOfCuts = 2;

  if ( trainConfig == 1 || trainConfig == 2 )
  numberOfCuts = 4;


  TString *eventCutArray   	= new TString[numberOfCuts];
  TString *photonCutArray  	= new TString[numberOfCuts];
  TString *clusterCutArray 	= new TString[numberOfCuts];
  TString *electronCutArray	= new TString[numberOfCuts];
  TString *mesonCutArray   	= new TString[numberOfCuts];


  //************************************************ EMCAL clusters **********************************************************
  if ( trainConfig == 1){ // min energy = 0.3 GeV/c
      eventCutArray[0] = "80000013"; photonCutArray[0] = "00200009327002008250400000"; clusterCutArray[0] = "1111100043022030000"; electronCutArray[0] = "90475400233102623710"; mesonCutArray[0] = "0263103100000000"; //standart cut, kINT7
      eventCutArray[1] = "80052013"; photonCutArray[1] = "00200009327002008250400000"; clusterCutArray[1] = "1111100043022030000"; electronCutArray[1] = "90475400233102623710"; mesonCutArray[1] = "0263103100000000"; //standard cut, kEMC7
      eventCutArray[2] = "80000013"; photonCutArray[2] = "00200009327002008250400000"; clusterCutArray[2] = "1111100043022030000"; electronCutArray[2] = "90475400233102623110"; mesonCutArray[2] = "0263103100000000"; //standart cut, kINT7
      eventCutArray[3] = "80052013"; photonCutArray[3] = "00200009327002008250400000"; clusterCutArray[3] = "1111100043022030000"; electronCutArray[3] = "90475400233102623110"; mesonCutArray[3] = "0263103100000000"; //standard cut, kEMC7
  } else if ( trainConfig == 2 ){
      eventCutArray[0] = "80000013"; photonCutArray[0] = "00200009327002008250400000"; clusterCutArray[0] = "2000000048033200000"; electronCutArray[0] = "90475400233102623710"; mesonCutArray[0] = "0263103100000000"; //standart cut, kINT7
      eventCutArray[1] = "80062013"; photonCutArray[1] = "00200009327002008250400000"; clusterCutArray[1] = "2000000048033200000"; electronCutArray[1] = "90475400233102623710"; mesonCutArray[1] = "0263103100000000"; //standard cut, kPHI7
      eventCutArray[2] = "80000013"; photonCutArray[2] = "00200009327002008250400000"; clusterCutArray[2] = "2000000048033200000"; electronCutArray[2] = "90475400233102623110"; mesonCutArray[2] = "0263103100000000"; //standart cut, kINT7
      eventCutArray[3] = "80062013"; photonCutArray[3] = "00200009327002008250400000"; clusterCutArray[3] = "2000000048033200000"; electronCutArray[3] = "90475400233102623110"; mesonCutArray[3] = "0263103100000000"; //standard cut, kPHI7
  } else if ( trainConfig == 3){ // min energy = 0.3 GeV/c
      eventCutArray[0] = "80000013"; photonCutArray[0] = "00200009327002008250400000"; clusterCutArray[0] = "1111100053032230000"; electronCutArray[0] = "90475400233102623710"; mesonCutArray[0] = "0263103100000000"; //standart cut, kINT7
      eventCutArray[1] = "80000013"; photonCutArray[1] = "00200009327002008250400000"; clusterCutArray[1] = "1331100053032230000"; electronCutArray[1] = "90475400233102623710"; mesonCutArray[1] = "0263103100000000"; //standard cut, kEMC7
  } else if ( trainConfig == 4){
      eventCutArray[0] = "80000013"; photonCutArray[0] = "00200009327002008250400000"; clusterCutArray[0] = "2000000048033200000"; electronCutArray[0] = "90475400233102623710"; mesonCutArray[0] = "0263103100000000"; //standart cut, kINT7
      eventCutArray[1] = "80000013"; photonCutArray[1] = "00200009327002008250400000"; clusterCutArray[1] = "2444400048033200000"; electronCutArray[1] = "90475400233102623710"; mesonCutArray[1] = "0263103100000000"; //standard cut, kPHI7
  } else if ( trainConfig == 5 ){
      eventCutArray[0] = "80000013"; photonCutArray[0] = "00200009327002008250400000"; clusterCutArray[0] = "1002100053032230000"; electronCutArray[0] = "90475400233102623710"; mesonCutArray[0] = "0263103100000000"; //standart cut, kINT7 with TRD
      eventCutArray[1] = "80000013"; photonCutArray[1] = "00200009327002008250400000"; clusterCutArray[1] = "1001300053032230000"; electronCutArray[1] = "90475400233102623710"; mesonCutArray[1] = "0263103100000000"; //standard cut, kINT7 No TRD
  } else if ( trainConfig == 6 ) {
      eventCutArray[0] = "80000013"; photonCutArray[0] = "00200009327002008250400000"; clusterCutArray[0] = "2000000048033300000"; electronCutArray[0] = "90475400233102623710"; mesonCutArray[0] = "0263103100000000"; //standart cut, kINT7
      eventCutArray[1] = "80000013"; photonCutArray[1] = "00200009327002008250400000"; clusterCutArray[1] = "2444400048033300000"; electronCutArray[1] = "90475400233102623710"; mesonCutArray[1] = "0263103100000000"; //standard cut, kINT7
  } else if ( trainConfig == 7 ){ // min energy = 0.3 GeV/c
      eventCutArray[0] = "80000013"; photonCutArray[0] = "00200009327002008250400000"; clusterCutArray[0] = "1221100053032230000"; electronCutArray[0] = "90475400233102623710"; mesonCutArray[0] = "0263103100000000"; //standart cut, kINT7
      eventCutArray[1] = "80000013"; photonCutArray[1] = "00200009327002008250400000"; clusterCutArray[1] = "1331100053032230000"; electronCutArray[1] = "90475400233102623710"; mesonCutArray[1] = "0263103100000000"; //standard cut, kEMC7
  } else {
    Error(Form("GammaConvDalitzCalo_%i",trainConfig), "wrong trainConfig variable no cuts have been specified for the configuration");
    return;
  }


  TList *EventCutList     = new TList();
  TList *ConvCutList      = new TList();
  TList *ClusterCutList   = new TList();
  TList *ElectronCutList  = new TList();
  TList *MesonCutList     = new TList();

  TList *HeaderList = new TList();
  if (doWeightingPart==1) {
    TObjString *Header1 = new TObjString("pi0_1");
    HeaderList->Add(Header1);
  }
  if (doWeightingPart==2){
    TObjString *Header3 = new TObjString("eta_2");
    HeaderList->Add(Header3);
  }
  if (doWeightingPart==3) {
    TObjString *Header1 = new TObjString("pi0_1");
    HeaderList->Add(Header1);
    TObjString *Header3 = new TObjString("eta_2");
    HeaderList->Add(Header3);
  }

  EventCutList->SetOwner(kTRUE);
  AliConvEventCuts **analysisEventCuts = new AliConvEventCuts*[numberOfCuts];

  ConvCutList->SetOwner(kTRUE);
  AliConversionPhotonCuts **analysisCuts = new AliConversionPhotonCuts*[numberOfCuts];

  ClusterCutList->SetOwner(kTRUE);
  AliCaloPhotonCuts **analysisClusterCuts = new AliCaloPhotonCuts*[numberOfCuts];

  ElectronCutList->SetOwner(kTRUE);
  AliDalitzElectronCuts   **analysisElectronCuts = new AliDalitzElectronCuts*[numberOfCuts];

  MesonCutList->SetOwner(kTRUE);
  AliConversionMesonCuts **analysisMesonCuts = new AliConversionMesonCuts*[numberOfCuts];

  for(Int_t i = 0; i<numberOfCuts; i++){
    //create AliCaloTrackMatcher instance, if there is none present
    TString caloCutPos = clusterCutArray[i];
    caloCutPos.Resize(1);
    TString TrackMatcherName = Form("CaloTrackMatcher_%s",caloCutPos.Data());
    if( !(AliCaloTrackMatcher*)mgr->GetTask(TrackMatcherName.Data()) ){
      AliCaloTrackMatcher* fTrackMatcher = new AliCaloTrackMatcher(TrackMatcherName.Data(),caloCutPos.Atoi());
      fTrackMatcher->SetV0ReaderName(V0ReaderName);
      mgr->AddTask(fTrackMatcher);
      mgr->ConnectInput(fTrackMatcher,0,cinput);
    }

    analysisEventCuts[i] = new AliConvEventCuts();
    analysisEventCuts[i]->SetV0ReaderName(V0ReaderName);
    analysisEventCuts[i]->InitializeCutsFromCutString(eventCutArray[i].Data());
    EventCutList->Add(analysisEventCuts[i]);
    analysisEventCuts[i]->SetFillCutHistograms("",kFALSE);

    analysisCuts[i] = new AliConversionPhotonCuts();
    analysisCuts[i]->SetV0ReaderName(V0ReaderName);
    analysisCuts[i]->InitializeCutsFromCutString(photonCutArray[i].Data());
    analysisCuts[i]->SetIsHeavyIon(isHeavyIon);
    ConvCutList->Add(analysisCuts[i]);
    analysisCuts[i]->SetFillCutHistograms("",kFALSE);

    analysisClusterCuts[i] = new AliCaloPhotonCuts();
    analysisClusterCuts[i]->SetV0ReaderName(V0ReaderName);
    analysisClusterCuts[i]->SetCaloTrackMatcherName(TrackMatcherName);
    analysisClusterCuts[i]->InitializeCutsFromCutString(clusterCutArray[i].Data());
    ClusterCutList->Add(analysisClusterCuts[i]);
    analysisClusterCuts[i]->SetExtendedMatching(enableExtendedMatching);
    analysisClusterCuts[i]->SetFillCutHistograms("");

    analysisElectronCuts[i] = new AliDalitzElectronCuts();
    if( !analysisElectronCuts[i]->InitializeCutsFromCutString(electronCutArray[i].Data())) {
      cout<< "ERROR:  analysisElectronCuts [ " <<i<<" ] "<<endl;
      return 0;
    }
    ElectronCutList->Add(analysisElectronCuts[i]);
    analysisElectronCuts[i]->SetFillCutHistograms("",kFALSE,electronCutArray[i].Data());

    analysisMesonCuts[i] = new AliConversionMesonCuts();
    analysisMesonCuts[i]->InitializeCutsFromCutString(mesonCutArray[i].Data());
    MesonCutList->Add(analysisMesonCuts[i]);
    analysisMesonCuts[i]->SetFillCutHistograms("");
    analysisEventCuts[i]->SetAcceptedHeader(HeaderList);


  }

  task->SetEventCutList(numberOfCuts,EventCutList);
  task->SetConversionCutList(numberOfCuts,ConvCutList);
  task->SetCaloCutList(numberOfCuts,ClusterCutList);
  task->SetMesonCutList(numberOfCuts,MesonCutList);
  task->SetElectronCutList(numberOfCuts,ElectronCutList);
  task->SetMoveParticleAccordingToVertex(kTRUE);
  task->SetDoMesonAnalysis(kTRUE);
  task->SetDoMesonQA(enableQAMesonTask); //Attention new switch for Pi0 QA
  task->SetDoPhotonQA(enableQAPhotonTask);  //Attention new switch small for Photon QA
  task->SetDoClusterQA(1);  //Attention new switch small for Cluster QA
        task->SetUseTHnSparse(isUsingTHnSparse);

  //connect containers
  AliAnalysisDataContainer *coutput =
    mgr->CreateContainer(Form("GammaCaloDalitz_%i",trainConfig), TList::Class(),
              AliAnalysisManager::kOutputContainer,Form("GammaCaloDalitz_%i.root",trainConfig));

  mgr->AddTask(task);
  mgr->ConnectInput(task,0,cinput);
  mgr->ConnectOutput(task,1,coutput);

  return;

}
Example #15
0
AliAnalysisTaskThermalGAFlow* AddTaskThermalGAFlow(
   const char *outfilename    = "AnalysisOutput.root",

//Default Cuts
   const Int_t fDebug = 0,
   const Int_t fMinCells = 3,
   const Double_t fMinE = 0.3,
   const Double_t fMinTrackDr = 0,
   const Double_t fMaxVertexx = 10,
   const Double_t fMinCentrality = -1,
   const Double_t fMaxCentrality = 100,
   const Double_t fCoreRadius = 3.5,
   const Double_t fMinCoreEnergyRatio = 0.4,
   const Double_t fMinLambdaDisp = 0.3,
   const Double_t fMinCPVStd = 2.5,

   const Int_t fMixVertxbins = 1,
   const Int_t fMixCentbins = 1,
   const Int_t fMixEvbins = 1,
   const Int_t fNptbins = 150,
//End Default Cuts

   const char *tag            = ""

)

{    
  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr)
  {
    ::Error("AddTaskPHOSThermalGAFlow", "No analysis manager to connect to.");
    return NULL;
  }  

  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  if (!mgr->GetInputEventHandler()) {
    Error("AddTaskPHOSThermalGAFlow", "This task requires an input event handler");
    return NULL;
  }
  //-------------------------------------------------------
  // Init the task and do settings
  //-------------------------------------------------------
  TString name(Form("ash_%s", tag));
  printf("Adding\n");
  AliAnalysisTaskThermalGAFlow *PHOSGAtask = new AliAnalysisTaskThermalGAFlow(name);

  PHOSGAtask->SetDebug(fDebug);
  PHOSGAtask->SetMinCells(fMinCells);
  PHOSGAtask->SetMinE(fMinE);
  PHOSGAtask->SetMinTrackDr(fMinTrackDr);
  PHOSGAtask->SetMaxVertexx(fMaxVertexx);
  PHOSGAtask->SetMinCentrality(fMinCentrality);
  PHOSGAtask->SetMaxCentrality(fMaxCentrality);
  PHOSGAtask->SetCoreRadius(fCoreRadius);
  PHOSGAtask->SetMinCoreEnergyRatio(fMinCoreEnergyRatio);
  PHOSGAtask->SetMinLambdaDisp(fMinLambdaDisp);
  PHOSGAtask->SetMinCPVStd(fMinCPVStd);

  PHOSGAtask->SetMixVertxbins(fMixVertxbins);
  PHOSGAtask->SetMixCentbins(fMixCentbins);
  PHOSGAtask->SetMixEvbins(fMixEvbins);
  PHOSGAtask->SetNptbins(fNptbins);

  //-------------------------------------------------------
  // Final settings, pass to manager and set the containers
  //-------------------------------------------------------
  mgr->AddTask(PHOSGAtask);
  // Create containers for input/output
  mgr->ConnectInput (PHOSGAtask, 0, mgr->GetCommonInputContainer() );
  AliAnalysisDataContainer *coGAFlow = mgr->CreateContainer(name,
    TList::Class(),
    AliAnalysisManager::kOutputContainer,
    outfilename);

  mgr->ConnectOutput(PHOSGAtask,1,coGAFlow);
  return PHOSGAtask;
}
//____________________________________________
AliPerformanceTask* AddTaskPerformanceTPCdEdxQA(Bool_t bUseMCInfo=kFALSE, Bool_t bUseESDfriend=kTRUE, 
						Bool_t highMult = kFALSE, const char *triggerClass=0, 
						Bool_t bUseHLT = kFALSE, Bool_t bUseTOF = kFALSE, Bool_t bTPCTrackingOnly = kFALSE,
						Bool_t bDoEffTpcSec = kFALSE)
{
  const TString taskName[] = {"TPC", "HLT"};
  const TString taskName2[] = {"", "_Tracking"};
  Int_t idx = 0, idx2 = 0;
  if (bUseHLT) idx = 1;
  if (bTPCTrackingOnly) idx2 = 1;
  
  //
  // Add AliPerformanceTask with TPC performance components
  //
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if(!mgr) { 
    Error("AddTaskPerformanceTPCdEdxQA","AliAnalysisManager not set!");
    return NULL;
  }
  
  TString type = mgr->GetInputEventHandler()->GetDataType();
  if (!type.Contains("ESD")) {
    Error("AddTaskPerformanceTPCdEdxQA", "ESD input handler needed!");
    return NULL;
  }
  
  AliMCEventHandler *mcH = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
  if (!mcH && bUseMCInfo) {
    Error("AddTaskPerformanceTPCdEdxQA", "MC input handler needed!");
    return NULL;
  }

  //
  // Add HLT Event
  //
  if (bUseHLT) {
    AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*>(mgr->GetInputEventHandler());
    esdH->SetReadHLT();
  }

  //
  // Create task
  //
  AliPerformanceTask *task = new AliPerformanceTask("PerformanceQA",Form("%s%s Performance",taskName[idx].Data(), taskName2[idx2].Data()));
  if (!task) {
    Error("AddTaskPerformanceTPCdEdxQA", "%s", Form("%s%s performance task cannot be created!",taskName[idx].Data(), taskName2[idx2].Data()));
    return NULL;
  }
  task->SetUseMCInfo(bUseMCInfo);
  task->SetUseESDfriend(bUseESDfriend);
  //  task->SetUseTerminate(kFALSE);
  task->SetUseHLT(bUseHLT);

  //
  // Add task to analysis manager
  //
  mgr->AddTask(task);

  //
  // Create TPC-ESD track reconstruction cuts
  // MB tracks
  //
  AliRecInfoCuts *pRecInfoCutsTPC = new AliRecInfoCuts("pRecInfoCutsTPC"); 
  if(pRecInfoCutsTPC) {
    pRecInfoCutsTPC->SetMaxDCAToVertexXY(3.0);
    pRecInfoCutsTPC->SetMaxDCAToVertexZ(3.0);
    pRecInfoCutsTPC->SetRequireSigmaToVertex(kFALSE);
    pRecInfoCutsTPC->SetRequireTPCRefit(kFALSE);
    pRecInfoCutsTPC->SetAcceptKinkDaughters(kFALSE);
    pRecInfoCutsTPC->SetMinNClustersTPC(70);
    pRecInfoCutsTPC->SetMaxChi2PerClusterTPC(4.);
    pRecInfoCutsTPC->SetDCAToVertex2D(kTRUE);

    pRecInfoCutsTPC->SetHistogramsOn(kFALSE); 
  } else {
    Error("AddTaskPerformanceTPCdEdxQA", "AliRecInfoCutsTPC cannot be created!");
    return NULL;
  }

  //
  // Create TPC-MC track reconstruction cuts
  //
  AliMCInfoCuts *pMCInfoCuts = new AliMCInfoCuts("pMCInfoCuts");
  if(pMCInfoCuts) {
    pMCInfoCuts->SetMinTrackLength(70);
  } else {
    Error("AddTaskPerformanceTPCdEdxQA", "AliMCInfoCuts cannot be created!");
    return NULL;
  }

  //
  // Create performance objects for TPC and set cuts 
  //
  enum { kTPC = 0, kTPCITS, kConstrained, kTPCInner, kTPCOuter, kTPCSec };

  AliPerformanceTPC *pCompTPC0;
  AliPerformanceMatch *pCompMatch1;
  AliPerformanceMatch *pCompMatch2;
  AliPerformanceDEdx *pCompDEdx3;
  if (bTPCTrackingOnly == kFALSE) {
    //
    // TPC performance
    //
    pCompTPC0 = new AliPerformanceTPC("AliPerformanceTPC","AliPerformanceTPC",kTPC,kFALSE,-1,highMult); 
    if(!pCompTPC0) {
      Error("AddTaskPerformanceTPCdEdxQA", "Cannot create AliPerformanceTPC");
    }
    pCompTPC0->SetAliRecInfoCuts(pRecInfoCutsTPC);
    pCompTPC0->SetAliMCInfoCuts(pMCInfoCuts);
    //  pCompTPC0->SetUseTrackVertex(kFALSE);
    pCompTPC0->SetUseTrackVertex(kTRUE);
    pCompTPC0->SetUseHLT(bUseHLT);
    pCompTPC0->SetUseTOFBunchCrossing(bUseTOF);
    
    //
    // TPC ITS match
    //
    pCompMatch1 = new AliPerformanceMatch("AliPerformanceMatchTPCITS","AliPerformanceMatchTPCITS",0,kFALSE); 
    if(!pCompMatch1) {
      Error("AddTaskPerformanceTPCdEdxQA", "Cannot create AliPerformanceMatchTPCITS");
    }
    pCompMatch1->SetAliRecInfoCuts(pRecInfoCutsTPC);
    pCompMatch1->SetAliMCInfoCuts(pMCInfoCuts);
    pCompMatch1->SetUseTOFBunchCrossing(bUseTOF);


    //
    // ITS TPC match
    //
    pCompMatch2 = new AliPerformanceMatch("AliPerformanceMatchITSTPC","AliPerformanceMatchITSTPC",1,kFALSE); 
    if(!pCompMatch2) {
      Error("AddTaskPerformanceTPCdEdxQA", "Cannot create AliPerformanceMatchITSTPC");  }
    pCompMatch2->SetAliRecInfoCuts(pRecInfoCutsTPC);
    pCompMatch2->SetAliMCInfoCuts(pMCInfoCuts);
    pCompMatch2->SetUseTOFBunchCrossing(bUseTOF);

    //
    // dEdx
    //
    pCompDEdx3 = new AliPerformanceDEdx("AliPerformanceDEdxTPCInner","AliPerformanceDEdxTPCInner",kTPCInner,kFALSE); 
    if(!pCompDEdx3) {
      Error("AddTaskPerformanceTPCdEdxQA", "Cannot create AliPerformanceDEdxTPCInner");
    }
    pCompDEdx3->SetAliRecInfoCuts(pRecInfoCutsTPC);
    pCompDEdx3->SetAliMCInfoCuts(pMCInfoCuts);
    //pCompDEdx3->SetUseTrackVertex(kFALSE);
    pCompDEdx3->SetUseTrackVertex(kTRUE);
  } //end bTPCTrackingOnly == kFALSE

  //
  // Resolution ------------------------------------------------------------------------------------
  //

  AliPerformanceRes *pCompRes4 = new AliPerformanceRes(bTPCTrackingOnly ? "AliPerformanceResTPC" : "AliPerformanceRes",
						       "AliPerformanceRes", bTPCTrackingOnly == kTRUE ? kTPCInner : kTPC,kFALSE); 
  if(!pCompRes4) {
    Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceRes");
  }


  pCompRes4->SetAliRecInfoCuts(pRecInfoCutsTPC);
  pCompRes4->SetAliMCInfoCuts(pMCInfoCuts);
  pCompRes4->SetUseTrackVertex(bTPCTrackingOnly == kTRUE ? kFALSE : kTRUE);

  //
  // Efficiency ------------------------------------------------------------------------------------
  //

  AliPerformanceEff *pCompEff5 = new AliPerformanceEff(bTPCTrackingOnly ? "AliPerformanceEffTPC" : "AliPerformanceEff",
						       "AliPerformanceEff",kTPC,kFALSE); 
  if(!pCompEff5) {
    Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceEff");
  }

  AliRecInfoCuts *pRecInfoCutsTPC2 = NULL;
  if (bTPCTrackingOnly)
  {
    //For low pt tracks, HLT finds only short track segments.
    //Hence, for the tpc-tracking only tracking-efficiency, we lower the minimum number of hits per reconstructed TPC track
    pRecInfoCutsTPC2 = new AliRecInfoCuts(*pRecInfoCutsTPC); 
    pRecInfoCutsTPC2->SetMinNClustersTPC(20);
    pCompEff5->SetAliRecInfoCuts(pRecInfoCutsTPC2);
  }
  else
  {
    pCompEff5->SetAliRecInfoCuts(pRecInfoCutsTPC);
  }
  pCompEff5->SetAliMCInfoCuts(pMCInfoCuts);
  pCompEff5->SetUseTrackVertex(bTPCTrackingOnly == kTRUE ? kFALSE : kTRUE);

  AliPerformanceEff *pCompEff5Sec;
  if (bDoEffTpcSec)
  {
    pCompEff5Sec = new AliPerformanceEff(bTPCTrackingOnly ? "AliPerformanceEffSecTPC" : "AliPerformanceEffSec",
                   "AliPerformanceEffSec",kTPCSec,kFALSE); 
    if(!pCompEff5Sec) {
      Error("AddTaskPerformanceTPC", "Cannot create AliPerformanceEff");
    }

    pCompEff5Sec->SetAliRecInfoCuts(bTPCTrackingOnly ? pRecInfoCutsTPC2 : pRecInfoCutsTPC);
    pCompEff5Sec->SetAliMCInfoCuts(pMCInfoCuts);
    pCompEff5Sec->SetUseTrackVertex(bTPCTrackingOnly == kTRUE ? kFALSE : kTRUE);
  }

  //
  // TPC Constrain to vertex
  //
  AliPerformanceMatch *pCompConstrain6;
  if (bTPCTrackingOnly == kFALSE) {
    pCompConstrain6 = new AliPerformanceMatch("AliPerformanceMatchTPCConstrain","AliPerformanceMatchTPCConstrain",2,kFALSE); 
    if(!pCompConstrain6) {
      Error("AddTaskPerformanceTPCdEdxQA", "Cannot create AliPerformanceMatchTPCConstrain");  }
    pCompConstrain6->SetAliRecInfoCuts(pRecInfoCutsTPC);
    pCompConstrain6->SetAliMCInfoCuts(pMCInfoCuts);
    pCompConstrain6->SetUseTOFBunchCrossing(bUseTOF);
  } //end bTPCTrackingOnly == kFALSE



  //
  // Add components to the performance task
  //
  if (bTPCTrackingOnly == kFALSE) {
  if(!bUseMCInfo) { 
    pCompTPC0->SetTriggerClass(triggerClass);
    pCompMatch1->SetTriggerClass(triggerClass);
    pCompMatch2->SetTriggerClass(triggerClass);
    pCompDEdx3->SetTriggerClass(triggerClass);
    pCompConstrain6->SetTriggerClass(triggerClass);
  }
  task->AddPerformanceObject( pCompTPC0 );
  task->AddPerformanceObject( pCompMatch1 );
  task->AddPerformanceObject( pCompMatch2 );
  task->AddPerformanceObject( pCompDEdx3 );
  task->AddPerformanceObject( pCompConstrain6 );
  } //end bTPCTrackingOnly == kFALSE
  if(bUseMCInfo)   {
      task->AddPerformanceObject( pCompRes4 );
      task->AddPerformanceObject( pCompEff5 );
      if (bDoEffTpcSec) task->AddPerformanceObject( pCompEff5Sec );
  }

  //
  // Create containers for input
  //
  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());

  //
  // Create containers for output
  //
   
  AliAnalysisDataContainer *coutput = mgr->CreateContainer(Form("%s%sQA", taskName[idx].Data(), taskName2[idx2].Data()), TList::Class(), 
                 AliAnalysisManager::kOutputContainer, 
                 Form("%s:%s_%s", mgr->GetCommonFileName(), taskName[idx].Data(),task->GetName()));


  AliAnalysisDataContainer *coutput2  = mgr->CreateContainer(Form("%s%sQASummary", taskName[idx].Data(), taskName2[idx2].Data()), TTree::Class(), 
                   AliAnalysisManager::kParamContainer, 
                   Form("trending.root:Summary%sQA", taskName[idx].Data())); 
  
  mgr->ConnectOutput(task, 1, coutput);
  mgr->ConnectOutput(task, 0, coutput2);

return task;  
}
Example #17
0
AliEsdSkimTask* AddTaskEsdSkim(
  Bool_t tof       = kFALSE,
  Bool_t emc       = kFALSE,
  Bool_t emt       = kFALSE,
  Bool_t phc       = kFALSE,
  Bool_t pht       = kFALSE,
  Bool_t clus      = kFALSE,
  Bool_t tracks    = kFALSE,
  Bool_t mtracks   = kFALSE,
  Bool_t ptracks   = kFALSE,
  Bool_t remcov    = kFALSE,
  Bool_t rescov    = kFALSE,
  Bool_t sbytes    = kFALSE,
  Bool_t phosclus  = kFALSE,
  Bool_t emcclus   = kFALSE,
  Bool_t muons     = kFALSE,
  const char *tname = "Tracks",
  const char *filename = "AliSkimmedESD.root"
)
{  
  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr)
  {
    ::Error("AddTaskEmcalSetup", "No analysis manager to connect to.");
    return NULL;
  }  
  
  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  if (!mgr->GetInputEventHandler())
  {
    ::Error("AddTaskEmcalSetup", "This task requires an input event handler");
    return NULL;
  }
  
  //-------------------------------------------------------
  // Init the task and do settings
  //-------------------------------------------------------
  AliEsdSkimTask *task = new AliEsdSkimTask("EmcalSkimTask");
  task->SetDoClus(clus);
  task->SetDoEmC(emc);
  task->SetDoEmT(emt);
  task->SetDoMiniTracks(mtracks);
  task->SetDoMuonTracks(muons);
  task->SetDoPhC(phc);
  task->SetDoPhT(pht);
  task->SetDoPicoTracks(ptracks);
  task->SetDoSaveBytes(sbytes);
  task->SetDoTof(tof);
  task->SetDoTracks(tracks);
  task->SetEmcalClusOnly(emcclus);
  task->SetPhosClusOnly(phosclus);
  task->SetRemoveCP(remcov);
  task->SetResetCov(rescov);
  task->SetTracks(tname);

  //-------------------------------------------------------
  // Final settings, pass to manager and set the containers
  //-------------------------------------------------------

  mgr->AddTask(task);
  
  // Create containers for input/output
  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
  mgr->ConnectInput(task, 0, cinput);

  AliAnalysisDataContainer *coutput = mgr->CreateContainer(Form("EsdSkimTree"),
                                                           TTree::Class(),   
                                                           AliAnalysisManager::kOutputContainer, 
                                                           filename);
  mgr->ConnectOutput(task, 1, coutput);

  return task;
}
//
// *** Configuration script for phi->KK analysis with 2010 runs ***
// 
// A configuration script for RSN package needs to define the followings:
//
// (1) decay tree of each resonance to be studied, which is needed to select
//     true pairs and to assign the right mass to all candidate daughters
// (2) cuts at all levels: single daughters, tracks, events
// (3) output objects: histograms or trees
//
Bool_t RsnConfigPhiTPC
(
   AliRsnAnalysisTask *task,
   Bool_t              isMC,
   Bool_t              isMix,
   Bool_t              useCentrality,
   AliRsnCutSet       *eventCuts
)
{
   if (!task) ::Error("RsnConfigPhiTPC", "NULL task");
   
   // we define here a suffix to differentiate names of different setups for the same resonance
   // and we define also the name of the list of tracks we want to select for the analysis
   // (if will fail if no lists with this name were added to the RsnInputHandler)
   const char *suffix     = "tpc";
   const char *listName   = "kaonTPC";
   Bool_t      useCharged =  kTRUE;
   Int_t       listID     = -1;
   
   // find the index of the corresponding list in the RsnInputHandler
   AliAnalysisManager        *mgr   = AliAnalysisManager::GetAnalysisManager();
   AliMultiInputEventHandler *multi = dynamic_cast<AliMultiInputEventHandler*>(mgr->GetInputEventHandler());
   if (multi) {
      TObjArray          *array = multi->InputEventHandlers();
      AliRsnInputHandler *rsn   = (AliRsnInputHandler*)array->FindObject("rsnInputHandler");
      if (rsn) {
         AliRsnDaughterSelector *sel = rsn->GetSelector();
         listID = sel->GetID(listName, useCharged);
      }
   }
   if (listID >= 0)
      ::Info ("RsnConfigPhiTPC.C", "Required list '%s' stays in position %d", listName, listID);
   else {
      ::Error("RsnConfigPhiTPC.C", "Required list '%s' absent in handler!", listName);
      return kFALSE;
   }
   
   // ----------------------------------------------------------------------------------------------
   // -- DEFINITIONS -------------------------------------------------------------------------------
   // ----------------------------------------------------------------------------------------------
   
   // PAIR DEFINITIONS:
   // this contains the definition of particle species and charge for both daughters of a resonance,
   // which are used for the following purposes:
   // --> species is used to assign the mass to the daughter (e.g. for building invariant mass)
   // --> charge is used to select what tracks to use when doing the computation loops
   // When a user wants to compute a like-sign background, he must define also a pair definition
   // for each like-sign: in case of charged track decays, we need one for ++ and one for --
   // Last two arguments are necessary only in some cases (but it is not bad to well initialize them):
   // --> PDG code of resonance, which is used for selecting true pairs, when needed
   // --> nominal resonance mass, which is used for computing quantities like Y or Mt
   AliRsnPairDef *phi_kaonP_kaonM = new AliRsnPairDef(AliRsnDaughter::kKaon, '+', AliRsnDaughter::kKaon, '-', 333, 1.019455);
   AliRsnPairDef *phi_kaonP_kaonP = new AliRsnPairDef(AliRsnDaughter::kKaon, '+', AliRsnDaughter::kKaon, '+', 333, 1.019455);
   AliRsnPairDef *phi_kaonM_kaonM = new AliRsnPairDef(AliRsnDaughter::kKaon, '-', AliRsnDaughter::kKaon, '-', 333, 1.019455);

   // PAIR LOOPS:
   // these are the objects which drive the computations and fill the output histograms
   // each one requires to be initialized with an AliRsnPairDef object, which provided masses,
   // last argument tells if the pair is for mixing or not (this can be also set afterwards, anyway)
   const Int_t     nPairs = 5;
   Bool_t          addPair[nPairs] = {1, 1, 1, 1, 1};
   AliRsnLoopPair *phiLoop[nPairs];
   phiLoop[0] = new AliRsnLoopPair(Form("%s_phi_kaonP_kaonM"     , suffix), phi_kaonP_kaonM, kFALSE);
   phiLoop[1] = new AliRsnLoopPair(Form("%s_phi_kaonP_kaonM_true", suffix), phi_kaonP_kaonM, kFALSE);
   phiLoop[2] = new AliRsnLoopPair(Form("%s_phi_kaonP_kaonM_mix" , suffix), phi_kaonP_kaonM, kTRUE );
   phiLoop[3] = new AliRsnLoopPair(Form("%s_phi_kaonP_kaonP"     , suffix), phi_kaonP_kaonP, kFALSE);
   phiLoop[4] = new AliRsnLoopPair(Form("%s_phi_kaonM_kaonM"     , suffix), phi_kaonM_kaonM, kFALSE);

   // set additional option for true pairs
   // 1) we select only pairs coming from the same mother, which must have the right PDG code (from pairDef)
   // 2) we select only pairs decaying according to the right channel (from pairDef species+charge definitions)
   phiLoop[1]->SetOnlyTrue(kTRUE);
   phiLoop[1]->SetCheckDecay(kTRUE);
   
   // don't add true pairs if not MC
   if (!isMC) addPair[1] = 0;
   addPair[0] = !isMix;
   addPair[1] = !isMix;
   addPair[2] =  isMix;
   addPair[3] = !isMix;
   addPair[4] = !isMix;
   
   // ----------------------------------------------------------------------------------------------
   // -- COMPUTED VALUES & OUTPUTS -----------------------------------------------------------------
   // ----------------------------------------------------------------------------------------------
   
   // All values which should be computed are defined here and passed to the computation objects,
   // since they define all that is computed bye each one, and, in case one output is a histogram
   // they define the binning and range for that value
   //
   // NOTE:
   // --> multiplicity bins have variable size
   
   Double_t mult[] = {  0.,  1.,  2.,  3.,  4.,  5.,   6.,   7.,   8.,   9.,  10.,  11.,  12., 13., 
                       14., 15., 16., 17., 18., 19.,  20.,  21.,  22.,  23.,  24.,  25.,  30., 35., 
                       40., 50., 60., 70., 80., 90., 100., 120., 140., 160., 180., 200., 500.};
   Int_t    nmult  = sizeof(mult) / sizeof(mult[0]);
   
   AliRsnValuePair *axisIM      = new AliRsnValuePair("IM" , AliRsnValuePair::kInvMass   );
   AliRsnValuePair *axisRes     = new AliRsnValuePair("RES", AliRsnValuePair::kInvMassRes);
   AliRsnValuePair *axisPt      = new AliRsnValuePair("PT" , AliRsnValuePair::kPt        );
   AliRsnValuePair *axisY       = new AliRsnValuePair("Y"  , AliRsnValuePair::kY);
   
   AliRsnValueEvent*axisCentV0  = new AliRsnValueEvent("CNT" , AliRsnValueEvent::kCentralityV0);
   AliRsnValueEvent*axisMultESD = new AliRsnValueEvent("MESD", AliRsnValueEvent::kMultESDCuts );
   AliRsnValueEvent*axisMultSPD = new AliRsnValueEvent("MSPD", AliRsnValueEvent::kMultSPD     );
   AliRsnValueEvent*axisMultTRK = new AliRsnValueEvent("MTRK", AliRsnValueEvent::kMult        );
   AliRsnValueEvent*axisMultMC  = new AliRsnValueEvent("MMC" , AliRsnValueEvent::kMultMC      );
   
   axisIM     ->SetBins(500, 0.9, 1.4);
   axisRes    ->SetBins(-0.5,   0.5, 0.001);
   axisPt     ->SetBins(50, 0.0, 5.0);
   axisY      ->SetBins(1, -0.5, 0.5);

   axisCentV0 ->SetBins(20, 0.0, 100.0);
   axisMultESD->SetBins(nmult, mult);
   axisMultSPD->SetBins(nmult, mult);
   axisMultTRK->SetBins(nmult, mult);
   axisMultMC ->SetBins(nmult, mult);

   // create outputs:
   // we define one for true pairs, where we add resolution, and another without it, for all others
   // it seems that it is much advantageous to use sparse histograms when adding more than 2 axes
   AliRsnListOutput *out[2];
   out[0] = new AliRsnListOutput("res"  , AliRsnListOutput::kHistoSparse);
   out[1] = new AliRsnListOutput("nores", AliRsnListOutput::kHistoSparse);
   
   // add values to outputs:
   // if centrality is required, we add it only, otherwise we add all multiplicities
   // other axes (invmass, pt) are always added
   for (Int_t i = 0; i < 2; i++) {
      out[i]->AddValue(axisIM);
      out[i]->AddValue(axisPt);
      out[i]->AddValue(axisY);
      if (useCentrality) {
         ::Info("RsnConfigPhiTPC.C", "Adding centrality axis");
         out[i]->AddValue(axisCentV0);
      } else {
         ::Info("RsnConfigPhiTPC.C", "Adding multiplicity axes");
         //out[i]->AddValue(axisMultESD);
         //out[i]->AddValue(axisMultSPD);
         out[i]->AddValue(axisMultTRK);
         if (isMC) out[i]->AddValue(axisMultMC);
      }
   }
   // resolution only in the first
   out[0]->AddValue(axisRes);
   
   // ----------------------------------------------------------------------------------------------
   // -- ADD SETTINGS TO LOOPS AND LOOPS TO TASK ---------------------------------------------------
   // ----------------------------------------------------------------------------------------------
   
   for (Int_t ip = 0; ip < nPairs; ip++) {
      // skip pairs not to be added
      if (!addPair[ip]) continue;
      // assign list IDs
      phiLoop[ip]->SetListID(0, listID);
      phiLoop[ip]->SetListID(1, listID);
      // assign event cuts
      phiLoop[ip]->SetEventCuts(eventCuts);
      // assign outputs
      if (ip != 1)
         phiLoop[ip]->AddOutput(out[1]);
      else
         phiLoop[ip]->AddOutput(out[0]);
      // add to task
      task->AddLoop(phiLoop[ip]);
   }
   
   return kTRUE;
}
Example #19
0
AliAnalysisTaskBJetTC* AddTaskBJetTC(
		const char *ntracks             = "PicoTracks",
		const char *nclusters           = "",
		const char *njets               = "Jets",
		const char *nrho                = "",
		Double_t jetradius 		= 0.4,
		Bool_t isMC 			= kFALSE,
		const char * type 		= "TPC",
		const char *taskname           	= "AliAnalysisTaskBJetTC",
		const char *njetsMC             = "Jets",
		const char *nrhoMC              = "RhoMC",
		Bool_t V0PhotonRejection 	= kFALSE,
		Bool_t DoPtRelAna		= kFALSE,
		Bool_t DoJetProb 		= kFALSE,
		TString pathToResolFunc		= "",
  		Int_t       ptHardBin           = -999,
		const char* suffix 		= "")
{


	// Get the pointer to the existing analysis manager via the static access method.
	//==============================================================================
	AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
	if (!mgr)
	{
		::Error("AddTaskEmcalJetSample", "No analysis manager to connect to.");
		return NULL;
	}


	// Check the analysis type using the event handlers connected to the analysis manager.
	//==============================================================================
	if (!mgr->GetInputEventHandler())
	{
		::Error("AddTaskEmcalJetSample", "This task requires an input event handler");
		return NULL;
	}



  	if(V0PhotonRejection){

		  //=========  Set Cutnumber for V0Reader ================================
		  TString cutnumberAODBranch = "8000000060084000001500000";  // cutnumber for AOD branch
		  //TString cutnumberAODBranch = "00000003_06000008400100001000000000";  // cutnumber for AOD branch
		  TString cutnumberPhoton = "10000029200000003220400000";
		  TString cutnumberEvent = "80010103";

		  Bool_t doEtaShift = kFALSE;
		  AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
		  //========= Add V0 Reader to  ANALYSIS manager if not yet existent =====
		  TString V0ReaderName = Form("V0ReaderV1_%s_%s",cutnumberEvent.Data(),cutnumberPhoton.Data());
		  if( !(AliV0ReaderV1*)mgr->GetTask(V0ReaderName.Data()) ){
			AliV0ReaderV1 *fV0ReaderV1 = new AliV0ReaderV1(V0ReaderName.Data());
		    fV0ReaderV1->SetUseOwnXYZCalculation(kTRUE);
		    fV0ReaderV1->SetCreateAODs(kFALSE);// AOD Output
		    fV0ReaderV1->SetUseAODConversionPhoton(kTRUE);
		    if (!mgr) {
		      Error("AddTask_V0ReaderV1", "No analysis manager found.");
		      return;
		    }

		    AliConvEventCuts *fEventCuts=NULL;
		    if(cutnumberEvent!=""){
		      fEventCuts= new AliConvEventCuts(cutnumberEvent.Data(),cutnumberEvent.Data());
		      fEventCuts->SetPreSelectionCutFlag(kTRUE);
		      fEventCuts->SetPeriodEnumExplicit(AliConvEventCuts::kLHC16q);
		      fEventCuts->SetV0ReaderName(V0ReaderName);
		      fEventCuts->SetLightOutput(kTRUE);
		      if(fEventCuts->InitializeCutsFromCutString(cutnumberEvent.Data())){
			fEventCuts->DoEtaShift(doEtaShift);
			fV0ReaderV1->SetEventCuts(fEventCuts);
			fEventCuts->SetFillCutHistograms("",kTRUE);
		      }
		    }

		    // Set AnalysisCut Number
		    AliConversionPhotonCuts *fCuts=NULL;
		    if(cutnumberPhoton!=""){
		      fCuts= new AliConversionPhotonCuts(cutnumberPhoton.Data(),cutnumberPhoton.Data());
		      fCuts->SetPreSelectionCutFlag(kTRUE);
		      fCuts->SetIsHeavyIon(kTRUE);
		      fCuts->SetV0ReaderName(V0ReaderName);
		      fCuts->SetLightOutput(kTRUE);
		      fCuts->SetProcessAODCheck(kTRUE);
		      if(fCuts->InitializeCutsFromCutString(cutnumberPhoton.Data())){
			cout<<" Photon conversion is working \n";
			fV0ReaderV1->SetConversionCuts(fCuts);
			fCuts->SetFillCutHistograms("",kTRUE);
		      }
		    }
		    if( (mgr->GetInputEventHandler())->IsA()==AliAODInputHandler::Class()){
		    // AOD mode
		      cout << "AOD handler: adding " << cutnumberAODBranch.Data() << " as conversion branch" << endl;
		      fV0ReaderV1->SetDeltaAODBranchName(Form("GammaConv_%s_gamma",cutnumberAODBranch.Data()));
		    }
		    fV0ReaderV1->Init();

		    AliLog::SetGlobalLogLevel(AliLog::kInfo);

		    //connect input V0Reader
		    mgr->AddTask(fV0ReaderV1);
		    mgr->ConnectInput(fV0ReaderV1,0,cinput);

		  }
   	}


	TString name(taskname);

	TString combinedName;
	combinedName.Form("%s%s", name.Data(),suffix);

	AliAnalysisTaskBJetTC* jetTask = new AliAnalysisTaskBJetTC(combinedName);

  	jetTask->SetPtHardBin(ptHardBin);

  	jetTask->UseGammaV0Rejection(V0PhotonRejection);
	
	jetTask->DoJetProbabilityAnalysis(DoJetProb);

	jetTask->DoPtRelAnalysis(DoPtRelAna);
			
	AliTrackContainer *trackCont  = jetTask->AddTrackContainer(ntracks);
	trackCont->SetTrackFilterType(AliEmcalTrackSelection::kCustomTrackFilter);
	trackCont->SetAODFilterBits((1<<4)|(1<<9));

	AliClusterContainer *clusterCont = jetTask->AddClusterContainer(nclusters);

	TString strType(type);

	AliJetContainer *jetCont = jetTask->AddJetContainer(njets,strType,jetradius);

	if(jetCont) {
		jetCont->SetRhoName(nrho);

		jetCont->ConnectParticleContainer(trackCont);

		jetCont->ConnectClusterContainer(clusterCont);

		jetCont->SetJetEtaLimits(-0.5,0.5);

		jetCont->SetJetPtCut(0.0);

		jetCont->SetMaxTrackPt(1000);

		jetCont->SetPercAreaCut(0.6);
	}

	if(isMC)
	{
		AliJetContainer *jetContMC = jetTask->AddJetContainer(njetsMC,strType,jetradius);

		if(jetContMC) {

			jetContMC->SetRhoName(nrhoMC);

			jetContMC->SetIsParticleLevel(kTRUE);

			jetContMC->SetJetEtaLimits(-0.5,0.5);

			jetContMC->SetJetPtCut(0.0);

			jetContMC->SetMaxTrackPt(1000);

			jetContMC->SetPercAreaCut(0.6);
		}
	}
	//-------------------------------------------------------
	//  Configure analysis task
	//-------------------------------------------------------

	jetTask->SetIsPythia(isMC);

        if(V0PhotonRejection) jetTask->SetV0ReaderName(V0ReaderName);



	if(DoJetProb && !pathToResolFunc.IsNull()){
		TFile* file = TFile::Open(pathToResolFunc.Data());
		for(int i=0; i<7; i++){
			jetTask->SetResFunction((TF1*)file->Get(Form("QualityClass%i",i)), i);
		}
	}

	//-------------------------------------------------------
	// Final settings, pass to manager and set the containers
	//-------------------------------------------------------

	mgr->AddTask(jetTask);


	// Create containers for input/output
	AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer()  ;

	TString contname(combinedName);
	contname += "_histos";
	AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contname.Data(),
			TList::Class(),AliAnalysisManager::kOutputContainer,
			Form("%s", AliAnalysisManager::GetCommonFileName()));

	mgr->ConnectInput  (jetTask, 0,  cinput1 );

	mgr->ConnectOutput (jetTask, 1, coutput1 );

	return jetTask;
}
Example #20
0
EmcalHJetMassAnalysis::AliAnalysisTaskEmcalHJetMass* AddTaskEmcalHJetMass(const char * njetsBase,
						   const Double_t R,
						   const char * nrhoBase,
						   const char * ntracks,
						   const char * nclusters,
						   const char * type,
						   Double_t     ptMinH         = 5.,
						   Double_t     maxDPhi        = 0.6,
						   Int_t        pSel,
						   const char * CentEst        = "V0M",
						   TString      trigClass      = "",
						   TString      kEmcalTriggers = "",
						   TString      nJetsUnsub     = "",
						   TString      tag            = "") {

  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr)
    {
      Error("AddTaskEmcalHJetMass","No analysis manager found.");
      return 0;
    }
  Bool_t ismc=kFALSE;
  ismc = (mgr->GetMCtruthEventHandler())?kTRUE:kFALSE;

  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  if (!mgr->GetInputEventHandler())
    {
      ::Error("AddTaskEmcalHJetMass", "This task requires an input event handler");
      return NULL;
    }

  TString wagonName = Form("HJetMass_%s_TC%s%s",njetsBase,trigClass.Data(),tag.Data());

  //Configure jet tagger task
  EmcalHJetMassAnalysis::AliAnalysisTaskEmcalHJetMass *task = new EmcalHJetMassAnalysis::AliAnalysisTaskEmcalHJetMass(wagonName.Data());
  task->SetNCentBins(4);
  task->SetMaxDeltaPhi(maxDPhi);
  
  AliParticleContainer *trackCont  = task->AddParticleContainer(ntracks);
  trackCont->SetParticlePtCut(ptMinH);
  AliClusterContainer *clusterCont = task->AddClusterContainer(nclusters);

  task->SetJetContainerBase(0);

  TString strType(type);
  AliJetContainer *jetContBase = task->AddJetContainer(njetsBase,strType,R);
  if(jetContBase) {
    jetContBase->SetRhoName(nrhoBase);
    jetContBase->ConnectParticleContainer(trackCont);
    jetContBase->ConnectClusterContainer(clusterCont);
    jetContBase->SetPercAreaCut(0.6);
  }
  if(!nJetsUnsub.IsNull()) {
    AliJetContainer *jetContUS = task->AddJetContainer(nJetsUnsub.Data(),strType,R);
    if(jetContUS) {
      jetContUS->SetRhoName(nrhoBase);
      jetContUS->ConnectParticleContainer(trackCont);
      jetContUS->ConnectClusterContainer(clusterCont);
      jetContUS->SetPercAreaCut(0.6);
    }
  }

  task->SetCaloTriggerPatchInfoName(kEmcalTriggers.Data());
  task->SetCentralityEstimator(CentEst);
  task->SelectCollisionCandidates(pSel);
  task->SetUseAliAnaUtils(kFALSE);

  mgr->AddTask(task);

  //Connnect input
  mgr->ConnectInput (task, 0, mgr->GetCommonInputContainer() );

  //Connect output
  TString contName(wagonName);
  TString outputfile = Form("%s",AliAnalysisManager::GetCommonFileName());
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contName.Data(), TList::Class(),AliAnalysisManager::kOutputContainer,outputfile);
  mgr->ConnectOutput(task,1,coutput1);

  return task;  

}
Example #21
0
AliAnalysisTask* AddTaskLeadingPt(
		Bool_t AnalysisMC = kFALSE,
		Float_t ptleadingCut = 0.5,
		Int_t typerun =0, // 0 for pp and 1 for Pb-Pb or pPb
		TString  type ="ESD",
		UInt_t kTriggerInt = AliVEvent::kMB, //for pPb kINT7, for pp or PbPb kMB
		//UInt_t kTriggerInt = AliVEvent::kINT7, //LHC11c
		Bool_t ispileuprej = kTRUE,
		Bool_t ispileuprejMV = kTRUE,
		Int_t nContributors = 5
		)
{
	// Creates a pid task and adds it to the analysis manager

	// Get the pointer to the existing analysis manager via the static
	//access method
	//=========================================================================
	AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
	if (!mgr) {
		Error("AddTaskLeadingPt", "No analysis manager to connect to.");
		return NULL;
	}  

	// Check the analysis type using the event handlers connected to the
	// analysis manager The availability of MC handler can also be
	// checked here.
	// =========================================================================
	if (!mgr->GetInputEventHandler()) {
		Error("AddTaskLeadingPt", "This task requires an input event handler");
		return NULL;
	}  


	AliAnalysisFilter* trackFilterGolden = new AliAnalysisFilter("trackFilter");
	//AliESDtrackCuts* esdTrackCutsGolden = AliESDtrackCuts::GetStandardITSTPCTrackCuts2011(kTRUE,1);
	AliESDtrackCuts* esdTrackCutsGolden = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(kTRUE,1);
	trackFilterGolden->AddCuts(esdTrackCutsGolden);

	AliAnalysisFilter* trackFilterTPC = new AliAnalysisFilter("trackFilterTPC");
	AliESDtrackCuts* esdTrackCutsTPC = 
		AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
	trackFilterTPC->AddCuts(esdTrackCutsTPC);

	AliAnalysisTaskLeadingPt * taskLeadingPt = new AliAnalysisTaskLeadingPt("taskLeadingPt");
	TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
	taskLeadingPt->SetAnalysisType(type);
	taskLeadingPt->SetPtLeadingCut(ptleadingCut);
	taskLeadingPt->SetDebugLevel(0);
	taskLeadingPt->SetEtaCut(0.8);
	taskLeadingPt->SetVtxCut(10.0);
	taskLeadingPt->SetTrigger(kTriggerInt);
	taskLeadingPt->SetPileUpRej(ispileuprej);
	taskLeadingPt->SetPileUpRejMV(ispileuprejMV);
	taskLeadingPt->SetNcontributors(nContributors);
	//Set Filters
	taskLeadingPt->SetTrackFilterGolden(trackFilterGolden);
	taskLeadingPt->SetTrackFilterTPC(trackFilterTPC);
	mgr->AddTask(taskLeadingPt);

	// Create ONLY the output containers for the data produced by the
	// task.  Get and connect other common input/output containers via
	// the manager as below
	//=======================================================================
	TString outputFileName = AliAnalysisManager::GetCommonFileName();

	AliAnalysisDataContainer *cout_histLeadingPt;
	cout_histLeadingPt=0;
	cout_histLeadingPt = mgr->CreateContainer("outputLeadingPt", TList::Class(), AliAnalysisManager::kOutputContainer, outputFileName );
	mgr->ConnectInput (taskLeadingPt, 0, mgr->GetCommonInputContainer());
	mgr->ConnectOutput(taskLeadingPt, 1, cout_histLeadingPt);

	// Return task pointer at the end
	return taskLeadingPt;



}
Example #22
0
AliAnalysisTaskChargedFlow* AddTaskChargedFlow(
								     UInt_t filterbit = 768,
								     Double_t etaCut = 0.8,
								     Double_t vtxCut = 10.,
								     Double_t minPt = 0.2,
								     Double_t maxPt = 5.0,
								     Short_t nHarm = 2,
                                     Bool_t IsSample = kTRUE,
								     Int_t noclus = 70,
                                     Int_t effsys = 0,
                                     Int_t charge = 0,
								     Bool_t IsLHC10h = kTRUE,
								     Bool_t IsNUA = kTRUE,
								     Bool_t IsPileUp = kTRUE,
								     Int_t nPtb = 14,
								     Short_t nCentFl = 0,
								     Bool_t ismc = kFALSE,
								     TString uniqueID = "")
{
  // Creates a pid task and adds it to the analysis manager
  
  // Get the pointer to the existing analysis manager via the static
  //access method
  //=========================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    Error("AddTaskChargedFlow.C", "No analysis manager to connect to.");
    return NULL;
  }  
  
  // Check the analysis type using the event handlers connected to the
  // analysis manager The availability of MC handler can also be
  // checked here.
  // =========================================================================
  if (!mgr->GetInputEventHandler()) {
    Error("AddTaskChargedFlow", "This task requires an input event handler");
    return NULL;
  }  
  
  // Create the task and configure it 
  //========================================================================
  TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
    
  Double_t ptBins[] = {0.2, 0.4, 0.6, 0.8, 1.0, 1.25, 1.5, 1.75, 2.0, 2.5, 3.0, 3.5, 4.0, 5.0, 6.0};
  //Double_t ptBins[] = {0.2, 0.6, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 6.0};
    
  AliAnalysisTaskChargedFlow* taskFlowEp = new AliAnalysisTaskChargedFlow("taskFlowEp");
  taskFlowEp->SetDebugLevel(3);
  taskFlowEp->SetAnalysisType(type);
  taskFlowEp->SetFilterbit(filterbit);
  taskFlowEp->SetNoClus(noclus);
  taskFlowEp->SetCharge(charge);
  taskFlowEp->SetEff(effsys);
  taskFlowEp->SetEtaCut(etaCut);
  taskFlowEp->SetVtxCut(vtxCut);
  taskFlowEp->SetMinPt(minPt);
  taskFlowEp->SetMaxPt(maxPt);
  taskFlowEp->SetNHarmonic(nHarm);
  taskFlowEp->SetIsSample(IsSample);
  taskFlowEp->SetFlagLHC10h(IsLHC10h);
  taskFlowEp->SetFlagNUA(IsNUA);
  taskFlowEp->SetFlagPileUp(IsPileUp);
  taskFlowEp->SetNPtBins(nPtb);
  taskFlowEp->SetPtBins(ptBins);
  taskFlowEp->SetAnalysisMC(ismc);
  taskFlowEp->SetCentFlag(nCentFl);
  mgr->AddTask(taskFlowEp);
 
  
  // Create ONLY the output containers for the data produced by the
  // task.  Get and connect other common input/output containers via
  // the manager as below
   //=======================================================================
  //TString fileName = AliAnalysisManager::GetCommonFileName();
  //fileName+=suffixName;
  AliAnalysisDataContainer* cinput = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *cout_hist = mgr->CreateContainer(Form("output_%s", uniqueID.Data()), TList::Class(), AliAnalysisManager::kOutputContainer, Form("v4New.root:%s", uniqueID.Data()));
  mgr->ConnectInput (taskFlowEp, 0, cinput);
  mgr->ConnectOutput(taskFlowEp, 1, cout_hist);
  
  // Return task pointer at the end
  return taskFlowEp;
}
Example #23
0
AliPHOSCorrelations* AddTaskPi0Correlations (   	const char* name = "Pi0Corr",
						const char* options = "11h",
						Int_t downCentLimit = 0,
						Int_t upCentLimit = 90,
						const char* suffix = "" )
{
	//Author: Ponomarenko Daniil ([email protected])
	/* $Id$ */

	AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
	if (!mgr) 
	{
		::Error("AddTaskPi0Correlations", "No analysis manager to connect to");
		return NULL;
	}

	if (!mgr->GetInputEventHandler()) 
	{
		::Error("AddTaskPi0Correlations", "This task requires an input event handler");
		return NULL;
	}
	
	
	TString className = name;
	TString sName = Form("%s%sCB%it%iCnt", className.Data(), suffix, downCentLimit, upCentLimit);

	TString combinedName;
	combinedName.Form("%sTask", sName.Data());

	AliPHOSCorrelations* task = new AliPHOSCorrelations( combinedName );

	// Mixing binning 
	if( downCentLimit == 0 && upCentLimit == 10 ) 
	{
		//Central
		const int nbins = 5;
		Double_t cbin[nbins+1] = {0., 2., 4., 6., 8., 10.};
		TArrayD tbin(nbins+1, cbin);
		Int_t    nMixed[nbins] = {10, 10, 10, 10, 10};
		TArrayI tNMixed(nbins, nMixed);
		task->SetCentralityBinning(tbin, tNMixed);
		task->SetTriggerSelectionInPbPb(AliPHOSCorrelations::kCent);
	}
	else
	if( downCentLimit == 0 && upCentLimit == 20 ) 
	{
		//Central
		const int nbins = 4;
		Double_t cbin[nbins+1] = {0., 5., 10., 15., 20.};
		TArrayD tbin(nbins+1, cbin);
		Int_t    nMixed[nbins] = {10, 10, 10, 10};
		TArrayI tNMixed(nbins, nMixed);
		task->SetCentralityBinning(tbin, tNMixed);
		task->SetTriggerSelectionInPbPb(AliPHOSCorrelations::kCentAndSCent);
	}
	else
	if( downCentLimit == 10 && upCentLimit == 20 ) 
	{
		//Central
		const int nbins = 5;
		Double_t cbin[nbins+1] = {10., 12., 14., 16., 18., 20.};
		TArrayD tbin(nbins+1, cbin);
		Int_t    nMixed[nbins] = {10, 10, 10, 10, 10};
		TArrayI tNMixed(nbins, nMixed);
		task->SetCentralityBinning(tbin, tNMixed);
		task->SetTriggerSelectionInPbPb(AliPHOSCorrelations::kSCent);
	}
	else
	if( downCentLimit == 20 && upCentLimit == 40 ) 
	{
		// SemiCentral
		const int nbins = 4;
		Double_t cbin[nbins+1] = {20., 25., 30., 35., 40.};
		TArrayD tbin(nbins+1, cbin);
		Int_t    nMixed[nbins] = {10, 10, 10, 10,};
		TArrayI tNMixed(nbins, nMixed);
		task->SetCentralityBinning(tbin, tNMixed);
	}
	else
	if( downCentLimit == 20 && upCentLimit == 50 ) 
	{
		// SemiCentral
		const int nbins = 6;
		Double_t cbin[nbins+1] = {20., 25., 30., 35., 40., 45., 50.};
		TArrayD tbin(nbins+1, cbin);
		Int_t    nMixed[nbins] = {10, 10, 10, 10, 10, 10};
		TArrayI tNMixed(nbins, nMixed);
		task->SetCentralityBinning(tbin, tNMixed);
	}
	else
	if( downCentLimit == 40 && upCentLimit == 60 ) 
	{
		// SemiCentral
		const int nbins = 4;
		Double_t cbin[nbins+1] = {40., 45., 50., 55., 60.};
		TArrayD tbin(nbins+1, cbin);
		Int_t    nMixed[nbins] = {10, 10, 10, 10};
		TArrayI tNMixed(nbins, nMixed);
		task->SetCentralityBinning(tbin, tNMixed);
	}
	else
	if( downCentLimit == 60 && upCentLimit == 90 ) 
	{
		// SemiCentral
		const int nbins = 6;
		Double_t cbin[nbins+1] = {60., 65., 70., 75., 80., 85., 90.};
		TArrayD tbin(nbins+1, cbin);
		Int_t    nMixed[nbins] = {10, 10, 10, 10, 10, 10};
		TArrayI tNMixed(nbins, nMixed);
		task->SetCentralityBinning(tbin, tNMixed);
	}
	else
	{
		::Error("AddTaskPi0Correlations", Form("No centrality setings for %i-%i\%. Skip", downCentLimit, upCentLimit) );
		return NULL;
	}


	// Period depended properties
	if( TString(options).Contains("11h") )	
	{
		task->SetCentralityEstimator("V0M");

		if( downCentLimit == 0 && upCentLimit == 10 ) 
		{
			Double_t meanParametrs[2]  = {-3.36111e-05, 0.137305 };
			Double_t sigmaParametrs[3] = {0.0081226, -3.63246e-08, 0.00229115 };
			task->SetMassMeanParametrs(meanParametrs);
			task->SetMassSigmaParametrs(sigmaParametrs);
		}
		else
		{
			::Error("AddTaskPi0Correlations", Form("No mass window setings for %i-%i\% in %s. Set default", downCentLimit, upCentLimit, options));
			Double_t meanParametrs[2]  = {-2.72612e-05, 0.1357 };
			Double_t sigmaParametrs[3] = {0.00499517, 0.00950036, 0.00275293 };
			task->SetMassMeanParametrs(meanParametrs);
			task->SetMassSigmaParametrs(sigmaParametrs);
		}
	}
Example #24
0
AliAnalysisTaskOmegaOmegaOX *AddTaskOmegaOmegaOX(TString finname="",
						 Bool_t readMC=kFALSE,
						 Bool_t additionalChecks=kFALSE,
						 TString suffix = ""){

	//------------------------------------------------------------------------------------------
	// version 2.10 (2016/02/11)
	//------------------------------------------------------------------------------------------

  Bool_t stdcuts=kFALSE;
  TFile* filecuts;
  if( finname.EqualTo("") ) {
    stdcuts=kTRUE;
  } else {
      filecuts=TFile::Open(finname.Data());
      if(!filecuts ||(filecuts&& !filecuts->IsOpen())){
  AliFatal("Input file not found : check your cut object");
      }
  }

  // Creates, configures and attaches to the train the task for pi, K , p spectra
  // with ITS standalone tracks
  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  ::Info("AddTaskOmegaOmegaOX","Adding a new task with this settings readMC = %i",readMC);
 
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    ::Error("AddTaskOmegaOmegaOX", "No analysis manager to connect to.");
    return NULL;
  }   
  
  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  if (!mgr->GetInputEventHandler()) {
    ::Error("AddTaskOmegaOmegaOX", "This task requires an input event handler");
    return NULL;
  }   
  
  TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
  if(type.Contains("AOD")){
    ::Error("AddTaskOmegaOmegaOX", "This task requires to run on ESD");
    return NULL;
  }

  // Add MC handler (for kinematics)
  if(readMC){
    AliMCEventHandler* handler = new AliMCEventHandler;
    handler->SetReadTR(kFALSE);
    mgr->SetMCtruthEventHandler(handler);
  }


  // Create and configure the task

  TString taskname = "OmegaOmegaOX";
	TString combinedName;
	combinedName.Form("OmegaOmegaOX%s", suffix.Data());
  AliAnalysisTaskOmegaOmegaOX *task = new AliAnalysisTaskOmegaOmegaOX(combinedName);
  task->SetMC(readMC);
  mgr->AddTask(task);
  
  // Create ONLY the output containers for the data produced by the task.
  // Get and connect other common input/output containers via the manager as below
  //==============================================================================
  TString outputFileName = AliAnalysisManager::GetCommonFileName();
  outputFileName += ":Dibaryon";
  
  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());

  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(Form("CutPar_%s",combinedName.Data()), TTree::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
  mgr->ConnectOutput(task, 1, coutput1);
  AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(Form("Vertex_%s",combinedName.Data()), TTree::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
//  coutput2->SetSpecialOutput();
  mgr->ConnectOutput(task, 2, coutput2);


  return task;
}
Example #25
0
AliAnalysisTask *AddTaskHFEtpctofPbPb(Bool_t isaod, Bool_t isMC,Int_t aodfilter=16,Int_t clusterdef=AliHFEextraCuts::kFoundAll, Int_t clusterrdef=AliHFEextraCuts::kFoundAllOverFindable,Int_t tpcCls=130,  Int_t tpcClsPID = 80, Double_t tpcClsRatio = 0.6, Double_t tpcClShared = 1.1, Bool_t rejectkinkmother = kFALSE, Int_t itsCls=4,Double_t itsChi2PerClusters=-1,Int_t itspixelcut=AliHFEextraCuts::kBoth, Double_t dcaxy=1.0, Double_t dcaz=2.0, Bool_t usetof=kTRUE, Double_t tofs=3.,Bool_t etacor=kFALSE,TString listname="",Double_t tpceff=0.5, Float_t prodlow=0., Float_t prodhigh=3.,Bool_t kNoPhotonic = kTRUE){

  // libraries in case
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");


  //set config file name
  TString configFile("$ALICE_PHYSICS/PWGHF/hfe/macros/configs/PbPb/ConfigHFEpbpb.C");
  //TString configFile("/d/alice12/bailhache/AliRootInstallations/07_10_2012/AliRoot/PWGHF/hfe/macros/configs/PbPb/ConfigHFEpbpb.C");
  TString checkconfig="ConfigHFEpbpb";
  if (!gROOT->GetListOfGlobalFunctions()->FindObject(checkconfig.Data()))
    gROOT->LoadMacro(configFile.Data());

  
  // Name 
  Int_t itpcClsRatio = (Int_t) (tpcClsRatio*10);
  Int_t itpcClShared = (Int_t) (tpcClShared*10);
  Int_t iitsChi2PerClusters = (Int_t) (itsChi2PerClusters*10);
  Int_t idcaxy = (Int_t) (dcaxy*10);
  Int_t idcaz = (Int_t) (dcaz*10);
  Int_t itofs = (Int_t) (tofs*10);
  Int_t iprodlow = (Int_t) (prodlow*10);
  Int_t iprodhigh = (Int_t) (prodhigh*10);
  Int_t itof = 0;
  Int_t iNoPhotonic = 0;
  Int_t ietacor = 0;
  Int_t itpceff = (Int_t) (tpceff*10);
  Int_t irejectkinkmother = 0;
  if(usetof) itof=kTRUE;
  if(kNoPhotonic) iNoPhotonic = 1;
  if(etacor) ietacor = 1;
  if(rejectkinkmother) irejectkinkmother = 1;
  
  TString appendix(TString::Format("f%dcd%dcr%dt%dtp%dtr%dts%dkm%di%dic%di%ddcaxy%dz%dtof%dts%de%dtpc%dprodlow%dhigh%dnhfe%d",aodfilter,clusterdef,clusterrdef,tpcCls,tpcClsPID,itpcClsRatio,itpcClShared,irejectkinkmother,itsCls,iitsChi2PerClusters,itspixelcut,idcaxy,idcaz,itof,itofs,ietacor,itpceff,iprodlow,iprodhigh,iNoPhotonic));
  printf("appendix %s\n", appendix.Data());
  

  // ESD or AOD
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr->GetInputEventHandler()) {
    printf("AddTaskEventplane", "This task requires an input event handler");
    return NULL;
  }
  TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
  Bool_t isaod = kFALSE;
  if (inputDataType == "AOD") isaod = kTRUE;

  
  // TPC cut 2010
  // 0-5,5-10,10-20,20-30,30-40,40-50,50-60,60-70,70-80,80-90,90-100,one more per history
  // http://www.physi.uni-heidelberg.de/~pachmay/projects/hfe/pid/tpc/
  // without eta correction 50%
  Double_t tpcdEdxcutlow[12] = {0.03,0.15,0.24,0.3,0.39,0.48,0.5,0.51,0.5,0.5,0.5,0.5};
  // with eta correction 50%
  // Double_t tpcdEdxcutlow[12] = {-0.01,0.076,0.197,0.26,0.298,0.3,0.3,0.3,0.3,0.3,0.3,0.3};
  Double_t tpcdEdxcuthigh[12] = {3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0};


  // Task
  AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
  AliAnalysisTaskHFE *task = ConfigHFEpbpb(isaod,isMC,appendix,aodfilter,clusterdef,clusterrdef,tpcCls,tpcClsPID,tpcClsRatio,tpcClShared,irejectkinkmother,itsCls,itsChi2PerClusters,itspixelcut,dcaxy,dcaz,usetof,tofs,etacor,listname,tpcdEdxcutlow,tpcdEdxcuthigh,prodlow,prodhigh,kNoPhotonic);  

  mgr->AddTask(task);


  // Write Output 
  TString containerName = mgr->GetCommonFileName();
  containerName += ":";
  containerName += appendix.Data();

  AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
  mgr->ConnectOutput(task,1, mgr->CreateContainer(Form("HFE_Results_%s", appendix.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,containerName.Data()));
  mgr->ConnectOutput(task,2, mgr->CreateContainer(Form("HFE_QA_%s", appendix.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,containerName.Data()));
  mgr->ConnectInput(task,0, cinput );    

  return NULL;
  
}
Example #26
0
///
/// Main method calling all the configuration
/// Creates a CaloTrackCorr task, configures it and adds it to the analysis manager.
///
/// The options that can be passed to the macro are:
/// \param calorimeter : A string with he calorimeter used to measure the trigger particle.
/// \param simulation : A bool identifying the data as simulation.
/// \param collision: A string with the colliding system.
/// \param period : A string with the data period: LHC11h, LHC15n ... from it we extract the year.
/// \param qaan: execute the detector QA analysis.
/// \param hadronan: execute the track QA and cluster-track correlation analysis.
/// \param calibrate: if OADB was updated with calibration parameters not used in reconstruction, apply them here.
/// \param minTime: minimum time cut, leave it open by default even if calibration available, ns
/// \param maxTime: maximum time cut, leave it open by default even if calibration available, ns
/// \param minCen : An int to select the minimum centrality, -1 means no selection.
/// \param maxCen : An int to select the maximum centrality, -1 means no selection.
/// \param debugLevel : An int to define the debug level of all the tasks.
/// \param suffix : A string with the type of trigger (default: MB, EMC).
///
AliAnalysisTaskCaloTrackCorrelation *AddTaskPi0IMGammaCorrQA(const TString  calorimeter   = "EMCAL",
                                                             Bool_t   simulation    = kFALSE,
                                                             TString  collision     = "pp",
                                                             TString  period        = "",
                                                             const Bool_t   qaan          = kTRUE,
                                                             const Bool_t   hadronan      = kTRUE,
                                                             const Bool_t   calibrate     = kFALSE,
                                                             const Int_t    minTime       = -1000,
                                                             const Int_t    maxTime       =  1000,
                                                             const Int_t    minCen        = -1,
                                                             const Int_t    maxCen        = -1,
                                                             const Int_t    debugLevel    = -1,
                                                             const char *   suffix        = "default"
                                                             )
{
  // Check the global variables, and reset the provided ones if empty.
  //
  TString trigger  = suffix;
  
  gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/GetAlienGlobalProductionVariables.C");
  
  Int_t   year        = 2017;
  Bool_t  printGlobal = kFALSE;
  if ( trigger.Contains("default") || trigger.Contains("INT") || trigger.Contains("MB") ) printGlobal = kTRUE;
  
  GetAlienGlobalProductionVariables(simulation,collision,period,year,printGlobal);
  
  // Get the pointer to the existing analysis manager via the static access method.
  //
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) 
  {
    ::Error("AddTaskPi0IMGammaCorrQA", "No analysis manager to connect to.");
    return NULL;
  }  
  
  // Check the analysis type using the event handlers connected to the analysis manager.
  //
  if (!mgr->GetInputEventHandler()) 
  {
    ::Error("AddTaskPi0IMGammaCorrQA", "This task requires an input event handler");
    return NULL;
  }
  
  //
  // Create task
  //
  
  // Name for containers
  TString containerName = Form("%s_Trig_%s",calorimeter.Data(), trigger.Data());
  
  if(collision!="pp" && maxCen>=0) containerName+=Form("Cen%d_%d",minCen,maxCen);
  
  TString taskName =Form("Pi0IM_GammaTrackCorr_%s",containerName.Data());
  
  AliAnalysisTaskCaloTrackCorrelation * task = new AliAnalysisTaskCaloTrackCorrelation (taskName);
  //task->SetConfigFileName(""); //Don't configure the analysis via configuration file.
  task->SetDebugLevel(debugLevel);
  //task->SetBranches("ESD:AliESDRun.,AliESDHeader");
  //task->SetBranches("AOD:header,tracks,vertices,emcalCells,caloClusters");
  
  //
  // Init main analysis maker and pass it to the task
  AliAnaCaloTrackCorrMaker * maker = new AliAnaCaloTrackCorrMaker();
  task->SetAnalysisMaker(maker);
  
  //
  // Pass the task to the analysis manager
  mgr->AddTask(task);
  
  //
  // Create containers
  TString outputfile = AliAnalysisManager::GetCommonFileName();
  
  AliAnalysisDataContainer *cout_pc   = mgr->CreateContainer(trigger, TList::Class(),
                                                             AliAnalysisManager::kOutputContainer, 
                                                             Form("%s:%s",outputfile.Data(),Form("Pi0IM_GammaTrackCorr_%s",calorimeter.Data())));
  
  AliAnalysisDataContainer *cout_cuts = mgr->CreateContainer(Form("Param_%s",trigger.Data()), TList::Class(),
                                                             AliAnalysisManager::kParamContainer, 
                                                             Form("%s_Parameters.root",Form("Pi0IM_GammaTrackCorr_%s",calorimeter.Data())));
  
  // Create ONLY the output containers for the data produced by the task.
  // Get and connect other common input/output containers via the manager as below
  mgr->ConnectInput  (task, 0, mgr->GetCommonInputContainer());
  mgr->ConnectOutput (task, 1, cout_pc);
  mgr->ConnectOutput (task, 2, cout_cuts);
  //==============================================================================
  
  // Do not configure the wagon for certain analysis combinations
  // But create the task so that the sub-wagon train can run
  //
  gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/CheckActiveEMCalTriggerPerPeriod.C");
  Bool_t doAnalysis = CheckActiveEMCalTriggerPerPeriod(simulation,trigger,period,year);
  if(!doAnalysis) 
  {
    maker->SwitchOffProcessEvent();
    return task;
  }
  
  // #### Start analysis configuration ####
  //  
  TString inputDataType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
  
  // Make sure the B field is enabled for track selection, some cuts need it
  //
  ((AliInputEventHandler*)mgr->GetInputEventHandler())->SetNeedField(kTRUE);
  
  // Print settings to check all is as expected
  //
  printf("AddTaskPi0IMGammaCorrQA - Task NAME: %s \n",taskName.Data());
  
  printf("AddTaskPi0IMGammaCorrQA - Settings: data <%s>, calo <%s>, MC <%d>, collision <%s>, trigger <%s>, period <%s>, year <%d>,\n"
         "\t \t \t  CaloQA on <%d>, Track QA on <%d>, Make corrections <%d>, %d < time < %d, %d < cen < %d, debug level <%d> \n", 
         inputDataType.Data(), calorimeter.Data(),simulation, collision.Data(),trigger.Data(), period.Data(), year,
         qaan , hadronan, calibrate, minTime, maxTime, minCen, maxCen, debugLevel);
  //
  
  // General frame setting and configuration
  maker->SetReader   ( ConfigureReader   (inputDataType,collision,calibrate,minTime,maxTime,minCen,maxCen,simulation,year,debugLevel) );
  if(hadronan)maker->GetReader()->SwitchOnCTS();
  
  maker->SetCaloUtils( ConfigureCaloUtils(calorimeter,trigger,simulation,calibrate,year,debugLevel) );
  
  // Analysis tasks setting and configuration
  Int_t n = 0;//Analysis number, order is important
  
  // Cell QA
  if(qaan) maker->AddAnalysis(ConfigureQAAnalysis(calorimeter,collision,
                                                  //simulation,
                                                  year,debugLevel),n++);
  
  // Analysis with EMCal trigger or MB
  if ( !trigger.Contains("DCAL") )
  {
    // Cluster selection
    maker->AddAnalysis(ConfigurePhotonAnalysis(calorimeter,0,collision,containerName,simulation,year,debugLevel)       ,n++); 
    // Previous cluster invariant mass
    maker->AddAnalysis(ConfigurePi0Analysis   (calorimeter,0,collision,containerName,simulation,year,debugLevel,minCen),n++);     
    if(hadronan)
    {
      // Isolation of selected clusters by AliAnaPhoton
      maker->AddAnalysis(ConfigureIsolationAnalysis("Photon",calorimeter,0,collision,containerName,simulation,year,debugLevel), n++);
      // Selected clusters-track correlation
      maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Photon",calorimeter,0,collision,containerName,simulation,year,debugLevel,minCen), n++); 
    }
  }
  
  // Analysis with DCal trigger or MB
  if(year > 2014 && calorimeter=="EMCAL" && !trigger.Contains("EMCAL"))
  {
    // Cluster selection
    maker->AddAnalysis(ConfigurePhotonAnalysis(calorimeter,1,collision,containerName,simulation,year,debugLevel)       , n++); 
    // Previous cluster invariant mass
    maker->AddAnalysis(ConfigurePi0Analysis   (calorimeter,1,collision,containerName,simulation,year,debugLevel,minCen),n++); 
    if(hadronan)
    {
      // Isolation of selected clusters by AliAnaPhoton
      maker->AddAnalysis(ConfigureIsolationAnalysis("Photon",calorimeter,1,collision,containerName,simulation,year,debugLevel), n++);
      // Selected clusters-track correlation
      maker->AddAnalysis(ConfigureHadronCorrelationAnalysis("Photon",calorimeter,1,collision,containerName,simulation,year,debugLevel,minCen), n++); 
    }
  }
  
  // Charged tracks plots, any trigger
  if(hadronan)
    maker->AddAnalysis(ConfigureChargedAnalysis(collision,containerName,simulation,year,debugLevel), n++); 
  
  if(simulation)
  {
    // Calculate the cross section weights, apply them to all histograms 
    // and fill xsec and trial histo. Sumw2 must be activated.
    //maker->GetReader()->GetWeightUtils()->SwitchOnMCCrossSectionCalculation(); 
    //maker->SwitchOnSumw2Histograms();
    
    // For recent productions where the cross sections and trials are not stored in separate file
    //maker->GetReader()->GetWeightUtils()->SwitchOnMCCrossSectionFromEventHeader() ;
    
    // Just fill cross section and trials histograms.
    maker->GetReader()->GetWeightUtils()->SwitchOnMCCrossSectionHistoFill(); 
    
    // Add control histogram with pT hard to control aplication of weights 
    maker->SwitchOnPtHardHistogram();
  }
  
  //
  // Select events trigger depending on trigger
  //
  if(!simulation)
  {    
    gROOT->LoadMacro("$ALICE_PHYSICS/PWGGA/CaloTrackCorrelations/macros/ConfigureAndGetEventTriggerMaskAndCaloTriggerString.C");
    TString caloTriggerString = "";
    UInt_t mask = ConfigureAndGetEventTriggerMaskAndCaloTriggerString(trigger, year, caloTriggerString);
    
    task ->SelectCollisionCandidates( mask );
    maker->GetReader()->SetFiredTriggerClassName(caloTriggerString);
    printf("AddTaskPi0IMGammaCorrQA - Trigger Mask %d, caloTriggerString <%s>\n", mask, caloTriggerString.Data());
  }
  
  //
  // Final maker settings
  //
  maker->SetAnaDebug(debugLevel)  ;
  maker->SwitchOnHistogramsMaker()  ;
  maker->SwitchOnAODsMaker() ;
  maker->SwitchOnDataControlHistograms(); 
  
  if(debugLevel > 0) maker->Print("");
  
  return task;
}
AliCFSingleTrackEfficiencyTask *AddSingleTrackEfficiencyTaskAnalysisQA(TString collSyst="pp",
								       const Bool_t readAOD = 0, // Flag to read AOD:1 or ESD:0
								       TString suffix="default", // suffix for the output directory
								       AliPID::EParticleType specie=AliPID::kPion, 
								       Int_t pdgcode=0, //particle specie
								       Bool_t useMCtruthForKine=kFALSE,
								       Double_t maxRadiusForPrimaries=999.,
								       ULong64_t triggerMask=AliVEvent::kAnyINT,
								       TString centralityEstimator = "V0M",
								       Int_t fBit=0,
								       Bool_t TPCRefit = kTRUE,
								       Int_t minclustersTPC = 0,
								       Bool_t ITSRefit = kTRUE,
								       Int_t spdHits=AliESDtrackCuts::kAny,
								       Int_t minclustersITS = 0,
								       Bool_t useRecoEvSelCutsForKine=kFALSE,
								       Int_t configuration=AliCFSingleTrackEfficiencyTask::kFast,
								       Int_t usageOfBayesianPID=AliSingleTrackEffCuts::kNoBayesianPID)
{

  Info("AliCFSingleTrackEfficiencyTask","SETUP CONTAINER");

  //
  // Setting up the container
  // 
  // Variables
  const Int_t nvar = 7; // number of variables on the grid: pt, y, phi, theta, zvtx, multiplicity, centrality
  UInt_t nstep = 8;     // number of container steps
  const UInt_t ipt = 0;
  const UInt_t ieta  = 1;
  const UInt_t iphi = 2;
  const UInt_t itheta = 3;
  const UInt_t izvtx = 4;
  const UInt_t imult = 5;
  const UInt_t icent = 6;
  //
  // Containter bining

  const Int_t nbinpt=30;
  //   A2. Bins variation by hand for other variables
  const Int_t nbin2 = configuration==AliCFSingleTrackEfficiencyTask::kSlow ? 8 : 8; //bins in eta
  const Int_t nbin3 = configuration==AliCFSingleTrackEfficiencyTask::kSlow ? 9 : 18; //bins in phi
  const Int_t nbin4 = configuration==AliCFSingleTrackEfficiencyTask::kSlow ? 9 : 1; //bins in theta
  const Int_t nbin5 = configuration==AliCFSingleTrackEfficiencyTask::kSlow ? 10 : 4; //bins in zvtx

  const Int_t nbinmult=8;
  const Int_t nbincent=12;

  //arrays for the number of bins in each dimension
  Int_t iBin[nvar];
  iBin[0]=nbinpt;
  iBin[1]=nbin2;
  iBin[2]=nbin3;
  iBin[3]=nbin4;
  iBin[4]=nbin5;
  iBin[5]=nbinmult;
  iBin[6]=nbincent;

  //arrays for lower bounds :
  Double_t binLimpT[nbinpt+1] = {0.00,0.10,0.15,0.20,0.25,0.30,0.35,0.40,0.50,0.60,
				 0.70,0.80,0.90,1.00,1.25,1.50,1.75,2.00,2.50,3.00,
				 3.50,4.00,5.00,6.00,7.00,8.00,10.0,12.0,16.0,20.0,30.0};

  Double_t *binLim2 = new Double_t[iBin[1]+1];
  Double_t *binLim3 = new Double_t[iBin[2]+1];
  Double_t *binLim4 = new Double_t[iBin[3]+1];
  Double_t *binLim5 = new Double_t[iBin[4]+1];
  Double_t binLimmult[nbinmult+1] = {0.,5.,10.,20.,30.,40.,50.,80.,200.};
  Double_t binLimcent[nbincent+1] = {0.,2.5,5.0,7.5,10.,15.,20.,30.,40.,50.,60.,80.,100.};
  if(collSyst=="Pb-Pb" || collSyst=="PbPb" || collSyst=="Xe-Xe" || collSyst=="XeXe"){
    binLimmult[1]=100.;
    binLimmult[2]=500.;
    binLimmult[3]=1000.;
    binLimmult[4]=2000.;
    binLimmult[5]=3000.;
    binLimmult[6]=4000.;
    binLimmult[7]=5000.;
    binLimmult[8]=10000.;
  }

  // Other Variables
  for(Int_t i=0; i<=nbin2; i++) binLim2[i]=(Double_t)etamin + (etamax-etamin)/nbin2*(Double_t)i ;
  for(Int_t i=0; i<=nbin3; i++) binLim3[i]=(Double_t)phimin + (phimax-phimin)/nbin3*(Double_t)i ;
  for(Int_t i=0; i<=nbin4; i++) binLim4[i]=(Double_t)thetamin + (thetamax-thetamin)/nbin4*(Double_t)i ;
  for(Int_t i=0; i<=nbin5; i++) binLim5[i]=(Double_t)zvtxmin + (zvtxmax-zvtxmin)/nbin5*(Double_t)i ;

  // Container  
  AliCFContainer* container = new AliCFContainer(Form("container%s",suffix.Data()),"container for tracks",nstep,nvar,iBin);
  container -> SetBinLimits(ipt,binLimpT);    // pt
  container -> SetBinLimits(ieta,binLim2);      // eta
  container -> SetBinLimits(iphi,binLim3);    // phi
  container -> SetBinLimits(itheta,binLim4);  // theta
  container -> SetBinLimits(izvtx,binLim5);   // Zvtx
  container -> SetBinLimits(imult,binLimmult);// multiplicity
  container -> SetBinLimits(icent,binLimcent);// centrality

  // Variable Titles
  container -> SetVarTitle(ipt,"pt");
  container -> SetVarTitle(ieta, "eta");
  container -> SetVarTitle(iphi,"phi");
  container -> SetVarTitle(itheta, "theta");
  container -> SetVarTitle(izvtx, "Zvtx");
  container -> SetVarTitle(imult, "Multiplicity");
  container -> SetVarTitle(icent, "Centrality");

  // Step Titles
  container -> SetStepTitle(0, " MC Particle with Generated Cuts");
  container -> SetStepTitle(1, " MC Particle with Kine Acceptance Cuts");
  container -> SetStepTitle(2, " MC Particle with Track Ref Acceptance Cuts");
  container -> SetStepTitle(3, " Total Reconstructed  Particle ");
  container -> SetStepTitle(4, " Reco Particle With Kine Acceptance Cuts");
  container -> SetStepTitle(5, " Reco Particle to MC True pt particles ");
  container -> SetStepTitle(6, " Reco Particle With Quality Cuts");
  container -> SetStepTitle(7, " Reco PID With Quality Cuts");


  // SET TLIST FOR QA HISTOS
  TList* qaList = new TList();
  TObjArray* emptyList = new TObjArray(0);

  //CREATE THE INTERFACE TO CORRECTION FRAMEWORK USED IN THE TASK
  printf("CREATE INTERFACE AND CUTS\n");
  AliCFManager* man = new AliCFManager();

  man->SetNStepEvent(2);
  man->SetEventContainer(container);
  man->SetEventCutsList(0,emptyList);//evtmcList);
  man->SetEventCutsList(1,emptyList);//evtrecoList);
  
  man->SetParticleContainer(container);
  man->SetParticleCutsList(0,emptyList);//mcGenList);
  man->SetParticleCutsList(1,emptyList);//mcKineList);
  man->SetParticleCutsList(2,emptyList);//mcaccList);
  man->SetParticleCutsList(3,emptyList);//evtrecoPureList);
  man->SetParticleCutsList(4,emptyList);//recKineList);
  man->SetParticleCutsList(5,emptyList);
  man->SetParticleCutsList(6,emptyList);
  man->SetParticleCutsList(7,emptyList);
  
  // Simulated particle & event cuts
  AliSingleTrackEffCuts* cuts = new AliSingleTrackEffCuts();
  cuts->SetPtRange(ptmin,ptmax);
  cuts->SetEtaRange(etamin,etamax);
  cuts->SetIsCharged(ischarged);
  cuts->SetMinVtxContr(1);
  cuts->SetMaxVtxZ(zvtxmax);
  cuts->SetNumberOfClusters(mintrackrefsITS,mintrackrefsTPC,mintrackrefsTOF,mintrackrefsMUON);
  cuts->SetTriggerMask(triggerMask);
  cuts->SetIsAOD(readAOD);
  cuts->SetMaxRadiusOfParticleOrigin(maxRadiusForPrimaries);
  //
  // Pid selection here
  //
  if(pdgcode>0){
    cuts->SetUsePid(true);
    cuts->SetParticleSpecie(specie);
    cuts->SetPdgCode(pdgcode);
    // 
    const Int_t nlims=1;
    Float_t plims[nlims+1]={0.,999.}; //TPC limits in momentum [GeV/c]
    Float_t sigmas[nlims]={3.};
    cuts->SetUseTPCPid();
    cuts->SetTPCSigmaPtBins(nlims,plims,sigmas);
    cuts->SetMaximumPTPC(4.);
    // 
    const Int_t nlims2=1;
    Float_t plims2[nlims2+1]={0.,999.}; //TPC limits in momentum [GeV/c]
    Float_t sigmas2[nlims2]={3.};
    cuts->SetUseTOFPid();
    cuts->SetTOFSigmaPtBins(nlims2,plims2,sigmas2);
    cuts->SetMaximumPTOF(4.);

    if(usageOfBayesianPID>0) {
      cuts->SetUseCombinPID(usageOfBayesianPID);
      if(usageOfBayesianPID==AliSingleTrackEffCuts::kThresholdBayesianProb)
	cuts->SetPIDThreshold(thresholdPID);
    }

  }

  //
  //  Track Quality cuts via ESD track cuts
  //
  AliESDtrackCuts* QualityCuts = new AliESDtrackCuts();
  QualityCuts->SetRequireSigmaToVertex(kFALSE);
  QualityCuts->SetMinNClustersTPC(minclustersTPC);
  QualityCuts->SetMinNClustersITS(minclustersITS);
  QualityCuts->SetRequireTPCRefit(TPCRefit);
  QualityCuts->SetRequireITSRefit(ITSRefit);
  QualityCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD,spdHits);
  QualityCuts->SetMinDCAToVertexXY(0.);
  QualityCuts->SetEtaRange(etamin,etamax);
  QualityCuts->SetPtRange(ptmin,ptmax);


  //CREATE THE TASK
  printf("CREATE CF Single track task\n");

  AliCFSingleTrackEfficiencyTask *task = new AliCFSingleTrackEfficiencyTask("AliCFSingleTrackEfficiencyTask",QualityCuts,cuts);
  if(readAOD && fBit>=0){
    task->SetFilterBit(kTRUE);
    task->SetFilterType(fBit);
  }else{
    task->SetFilterBit(kFALSE);
  }

  //  task->SelectCollisionCandidates(triggerMask);//AliVEvent::kMB);
  if(centralityEstimator != "") task->SetUseCentrality(kTRUE,centralityEstimator);
  task->SetConfiguration(configuration);
  task->SetUseGeneratedKine(useMCtruthForKine);
  if(useRecoEvSelCutsForKine) task->ApplyRecoEventSelectionsToFillMCKine();
  task->SetCFManager(man); //here is set the CF manager

  //
  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    ::Error("AddTask", "No analysis manager to connect to.");
    return NULL;
  }

  // This task requires an ESD or AOD input handler and an AOD output handler.
  // Check this using the analysis manager.
  //===============================================================================
  TString type = mgr->GetInputEventHandler()->GetDataType();
  if (!type.Contains("ESD") && !type.Contains("AOD")) {
    ::Error("AddSingleTrackEfficiencyTaskPbPb", "AliCFSingleTrackEfficiency task needs the manager to have an ESD or AOD input handler.");
    return NULL;
  }
  
  mgr->AddTask(task);
  printf(" Create the output container\n");

  //
  // Create and connect containers for input/output
  //
  // ----- output data -----
  TString outputfile = AliAnalysisManager::GetCommonFileName();
  TString input1name="cchain0";
  TString output2name="HistEventsProcessed", output3name="container",output4name="list",output5name="ESDtrackCuts",output6name="MCtrackCuts";
  outputfile += ":PWGPP_CFSingleTrack";
//  outputfile += suffix;
  output2name += suffix;
  output3name += suffix;
  output4name += suffix;
  output5name += suffix;
  output6name += suffix;


  // ------ input data ------
  AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
  // ----- output data -----
  // output TH1I for event counting
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(output2name, TH1I::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
  // output Correction Framework Container (for acceptance & efficiency calculations)
  AliAnalysisDataContainer *coutput2 = mgr->CreateContainer(output3name, AliCFContainer::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
  // output QA histograms
  AliAnalysisDataContainer *coutput3 = mgr->CreateContainer(output4name, TList::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
  // output ESD track cuts for book keeping
  AliAnalysisDataContainer *coutput4 = mgr->CreateContainer(output5name, AliESDtrackCuts::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());
  // output event and particle selection cuts for book keeping
  AliAnalysisDataContainer *coutput5 = mgr->CreateContainer(output6name, AliSingleTrackEffCuts::Class(),AliAnalysisManager::kOutputContainer,outputfile.Data());

  mgr->ConnectInput(task,0,mgr->GetCommonInputContainer());
  mgr->ConnectOutput(task,1,coutput1);
  mgr->ConnectOutput(task,2,coutput2);
  mgr->ConnectOutput(task,3,coutput3);
  mgr->ConnectOutput(task,4,coutput4);
  mgr->ConnectOutput(task,5,coutput5);

  return task;
}
Example #28
0
AliAnalysisTaskHypCrossCheck *AddTaskHypCrossCheck(Bool_t readMC=kFALSE,
                                         Bool_t fillTree=kFALSE,
                                         Bool_t fillGen=kFALSE,
                                         TString suffix = ""){

  // Creates, configures and attaches to the train the task for pi, K , p spectra
  // with ITS standalone tracks
  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  ::Info("AddTaskHypCrossCheck","Adding a new task with this settings readMC = %i",readMC);

  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    ::Error("AddTaskHypCrossCheck", "No analysis manager to connect to.");
    return NULL;
  }

  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  if (!mgr->GetInputEventHandler()) {
    ::Error("AddTaskHypCrossCheck", "This task requires an input event handler");
    return NULL;
  }

  TString type = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
  if(type.Contains("AOD")){
    ::Error("AddTaskHypCrossCheck", "This task requires to run on ESD");
    return NULL;
  }

  // Add MC handler (for kinematics)
  if(readMC){
    AliMCEventHandler* handler = new AliMCEventHandler;
    handler->SetReadTR(kFALSE);
    mgr->SetMCtruthEventHandler(handler);
  }


  // Create and configure the task

  TString tskname = "hypertriton";
  tskname.Append(Form("%s",suffix.Data()));
  AliAnalysisTaskHypCrossCheck *taskhyp = new AliAnalysisTaskHypCrossCheck();
  Float_t p[5] = {7.25105e-01,4.99820e+01,2.35714e-10,2.49196e+00,1.41570e+01};
  taskhyp->SetCustomTPCpid(p,0.08f);

  mgr->AddTask(taskhyp);

  // Create ONLY the output containers for the data produced by the task.
  // Get and connect other common input/output containers via the manager as below
  //==============================================================================
  TString outputFileName = AliAnalysisManager::GetCommonFileName();
  outputFileName += ":ESDHypertriton";

  AliAnalysisDataContainer *coutput =0x0;

  coutput = mgr->CreateContainer(Form("strogolo_%s",tskname.Data()),
                                 TList::Class(),
                                 AliAnalysisManager::kOutputContainer,
                                 AliAnalysisManager::GetCommonFileName());



  mgr->ConnectInput(taskhyp, 0, mgr->GetCommonInputContainer());
  mgr->ConnectOutput(taskhyp, 1, coutput);


  if(fillTree){
      AliAnalysisDataContainer *coutput2 = mgr->CreateContainer("trogolo_HyperTree", TTree::Class(),
                                                                AliAnalysisManager::kOutputContainer,
                                                                "trogolo_HyperNt.root");
      coutput2->SetSpecialOutput();
      mgr->ConnectOutput(taskhyp,2, coutput2);

  }

  if(fillGen){
      AliAnalysisDataContainer *coutput3 = mgr->CreateContainer("trogolo_HyperGen",TTree::Class(),
                                                                AliAnalysisManager::kOutputContainer,
                                                                "trogolo_HyperGen.root");
      coutput3->SetSpecialOutput();
      mgr->ConnectOutput(taskhyp,3,coutput3);
  }

  return taskhyp;
}
//_________________________________________________________//
AliAnalysisTaskBFPsi *AddTaskBalancePsiCentralityTrain(Double_t centrMin=0.,
						       Double_t centrMax=100.,
						       Bool_t gRunShuffling=kFALSE,
						       Bool_t gRunMixing=kTRUE,
						       Bool_t gRunMixingWithEventPlane=kFALSE,
						       TString centralityEstimator="V0M",
						       Double_t vertexZ=10.,
						       Double_t DCAxy=-1,
						       Double_t DCAz=-1,
						       Double_t ptMin=0.3,
						       Double_t ptMax=1.5,
						       Double_t etaMin=-0.8,
						       Double_t etaMax=0.8,
						       Double_t maxTPCchi2 = -1, 
						       Int_t minNClustersTPC = -1,
						       Bool_t kUsePID = kTRUE,
						       Bool_t bResonancesCut = kTRUE,
						       Bool_t bHBTcut = kTRUE,
						       Double_t HBTCutValue = 0.02,
						       Bool_t bConversionCut = kTRUE,
						       Double_t invMassForConversionCut = 0.04,
						       Bool_t bMomentumDifferenceCut = kTRUE,
						       Double_t fQCutMin = 0.0,
						       Int_t AODfilterBit = 128,
						       AliAnalysisTaskBFPsi::etriggerSel triggerSel = AliAnalysisTaskBFPsi::kINT7,
						       TString fileNameBase="AnalysisResults",
						       TString dirNameExtra="",
						       TString fArgEventClass="Centrality",
						       TString analysisTypeUser="AOD",
						       Bool_t bVertexBinning=kTRUE,
						       Double_t sigmaElectronRejection=3,
						       Bool_t electronExclusiveRejection=kFALSE,
						       TString correctionFileName = "",
						       Int_t nCentralityArrayBinsForCorrection = -1,
						       Double_t *gCentralityArrayForCorrections = 0x0,
						       Bool_t gRunEbyE = kFALSE,
						       Bool_t bMomentumOrdering = kTRUE,
						       AliAnalysisTaskBFPsi::eCorrProcedure corrProc = AliAnalysisTaskBFPsi::kNoCorr) {
  // Creates a balance function analysis task and adds it to the analysis manager.
  // Get the pointer to the existing analysis manager via the static access method.
  TString outputFileName(fileNameBase);
  outputFileName.Append(".root");

  //===========================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    ::Error("AddTaskBF", "No analysis manager to connect to.");
    return NULL;
  }

  // Check the analysis type using the event handlers connected to the analysis manager.
  //===========================================================================
  if (!mgr->GetInputEventHandler()) {
    ::Error("AddTaskBF", "This task requires an input event handler");
    return NULL;
  }
  TString analysisType = mgr->GetInputEventHandler()->GetDataType(); // can be "ESD" or "AOD"
  if(dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler())) analysisType = "MC";
  
  // to set the analysis type manually
  if(analysisTypeUser != ""){
    analysisType = analysisTypeUser;
    ::Info("AddTaskBF",Form("Analysis Type manually set to %s",analysisType.Data()));
  }

  // for local changed BF configuration
  //gROOT->LoadMacro("./configBalanceFunctionPsiAnalysis.C");
  gROOT->LoadMacro("$ALICE_PHYSICS/PWGCF/EBYE/macros/configBalanceFunctionPsiAnalysis.C");
  AliBalancePsi *bf  = 0;  // Balance Function object
  AliBalancePsi *bfs = 0;  // shuffled Balance function object
  AliBalancePsi *bfm = 0;  // mixing Balance function object
  AliBalanceEbyE *bfebye = 0;  // EbyE Balance function object

  //maximum Delta eta range
  Double_t deltaEtaMax=TMath::Abs(etaMax-etaMin);

  if (analysisType=="ESD"){
    bf  = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
    if(gRunShuffling) bfs = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
    if(gRunMixing)    bfm = GetBalanceFunctionObject("ESD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
  }
  else if (analysisType=="AOD"){
    bf  = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
    if(gRunShuffling) bfs = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
    if(gRunMixing)    bfm = GetBalanceFunctionObject("AOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
    if(gRunEbyE)      bfebye = GetBalanceFunctionEbyEObject(bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,deltaEtaMax,bMomentumOrdering);
  }
  else if (analysisType=="MC"){
    bf  = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
    if(gRunShuffling) bfs = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
    if(gRunMixing)    bfm = GetBalanceFunctionObject("MC",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
  }
  else if (analysisType=="MCAOD"){
    bf  = GetBalanceFunctionObject("MCAOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
    if(gRunShuffling) bfs = GetBalanceFunctionObject("MCAOD",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
    if(gRunMixing)    bfm = GetBalanceFunctionObject("MCAOD",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
  }
  else if (analysisType=="MCAODrec"){
    bf  = GetBalanceFunctionObject("MCAODrec",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
    if(gRunShuffling) bfs = GetBalanceFunctionObject("MCAODrec",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
    if(gRunMixing)    bfm = GetBalanceFunctionObject("MCAODrec",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
  }
  else if (analysisType=="AODnano"){
    bf  = GetBalanceFunctionObject("AODnano",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
    if(gRunShuffling) bfs = GetBalanceFunctionObject("AODnano",centralityEstimator,centrMin,centrMax,kTRUE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
    if(gRunMixing)    bfm = GetBalanceFunctionObject("AODnano",centralityEstimator,centrMin,centrMax,kFALSE,bResonancesCut,bHBTcut,HBTCutValue,bConversionCut,invMassForConversionCut,bMomentumDifferenceCut,fQCutMin,fArgEventClass,deltaEtaMax,bVertexBinning,bMomentumOrdering);
  }
  else{
    ::Error("AddTaskBF", "analysis type NOT known.");
    return NULL;
  }

  // Create the task, add it to manager and configure it.
  //===========================================================================
  AliAnalysisTaskBFPsi *taskBF = new AliAnalysisTaskBFPsi(Form("TaskBFPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()));
  
  //Event characteristics scheme
  taskBF->SetEventClass(fArgEventClass);
  //taskBF->SetCustomBinning("centralityVertex:0,80");
  //taskBF->SetCustomBinning("multiplicity:0,260");
  
  if(fArgEventClass == "Multiplicity") {
    taskBF->SetPercentileRange(centrMin,centrMax);
    //taskBF->SetMultiplicityRange(centrMin,centrMax);
    taskBF->SetMultiplicityEstimator(centralityEstimator);
    cout<<"Multiplicity estimator "<<centralityEstimator.Data()<<endl;
  }
  else if(fArgEventClass == "Centrality") {
    if(analysisType == "MC")
      taskBF->SetImpactParameterRange(centrMin,centrMax);
    else {
      taskBF->SetPercentileRange(centrMin,centrMax);
      //taskBF->SetCentralityPercentileRange(centrMin,centrMax);
      // centrality estimator (default = V0M)
      taskBF->SetCentralityEstimator(centralityEstimator);
      cout<<"Centrality estimator "<<centralityEstimator.Data()<<endl;
    }
  }

  
  //+++++++++++++++++++++

  taskBF->SetAnalysisObject(bf);
  if(gRunShuffling) taskBF->SetShufflingObject(bfs);
  if(gRunMixing){
    taskBF->SetMixingObject(bfm);
    taskBF->SetMixingTracks(50000);
    if(gRunMixingWithEventPlane){
      taskBF->SetMixingWithEventPlane(gRunMixingWithEventPlane);
    }
  }
  if(gRunEbyE) taskBF->SetEbyEObject(bfebye);

  if(analysisType == "ESD") {
    AliESDtrackCuts *trackCuts = GetTrackCutsObject(ptMin,ptMax,etaMin,etaMax,maxTPCchi2,DCAxy,DCAz,minNClustersTPC);
    taskBF->SetAnalysisCutObject(trackCuts);
    if(kUsePID) {
      if(kUseBayesianPID)
	taskBF->SetUseBayesianPID(gMinAcceptedProbability);
      else if(kUseNSigmaPID)
	taskBF->SetUseNSigmaPID(nSigmaMax);
      taskBF->SetParticleOfInterest(AliAnalysisTaskBFPsi::kPion);
      taskBF->SetDetectorUsedForPID(AliAnalysisTaskBFPsi::kTOFpid);
    }
  }
  else if(analysisType == "AOD" || analysisType == "AODnano") {
    // pt and eta cut (pt_min, pt_max, eta_min, eta_max)
    taskBF->SetAODtrackCutBit(AODfilterBit);
    taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax);

    // set extra DCA cuts (-1 no extra cut)
    taskBF->SetExtraDCACutsAOD(DCAxy,DCAz);

    // set extra TPC chi2 / nr of clusters cut
    taskBF->SetExtraTPCCutsAOD(maxTPCchi2, minNClustersTPC);

    // electron rejection (so far only for AOD), <0 --> no rejection
    if(sigmaElectronRejection > 0){
      if(electronExclusiveRejection) taskBF->SetElectronOnlyRejection(sigmaElectronRejection); // no other particle in nsigma 
      else                           taskBF->SetElectronRejection(sigmaElectronRejection); // check only if electrons in nsigma
    }

    //++++++++++++++++//
    if(kUsePID) {
      if(kUseBayesianPID)
	taskBF->SetUseBayesianPID(gMinAcceptedProbability);
      else if(kUseNSigmaPID)
	taskBF->SetUseNSigmaPID(nSigmaMax);
      taskBF->SetParticleOfInterest(AliAnalysisTaskBFPsi::kKaon);
      taskBF->SetDetectorUsedForPID(AliAnalysisTaskBFPsi::kTPCTOF); //TOFpid,TPCpid
    }
    //++++++++++++++++//

  }
  else if(analysisType == "MC") {
    taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax);
  }
  else if(analysisType == "MCAOD") {
    // pt and eta cut (pt_min, pt_max, eta_min, eta_max)
    taskBF->SetAODtrackCutBit(AODfilterBit);
    taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax);    
  }
  else if(analysisType == "MCAODrec") {     //++++++++++++++++
    // pt and eta cut (pt_min, pt_max, eta_min, eta_max)
    taskBF->SetAODtrackCutBit(AODfilterBit);
    taskBF->SetKinematicsCutsAOD(ptMin,ptMax,etaMin,etaMax); 

    // set extra DCA cuts (-1 no extra cut)
    taskBF->SetExtraDCACutsAOD(DCAxy,DCAz);

    // set extra TPC chi2 / nr of clusters cut
    taskBF->SetExtraTPCCutsAOD(maxTPCchi2, minNClustersTPC);

    // electron rejection (so far only for AOD), <0 --> no rejection
    if(sigmaElectronRejection > 0){
      if(electronExclusiveRejection) taskBF->SetElectronOnlyRejection(sigmaElectronRejection); // no other particle in nsigma 
      else                           taskBF->SetElectronRejection(sigmaElectronRejection); // check only if electrons in nsigma
    }
  }//++++++++++++++++

  // offline trigger selection (AliVEvent.h)
  // taskBF->UseOfflineTrigger(); // NOT used (selection is done with the AliAnalysisTaskSE::SelectCollisionCandidates()) 
  // with this only selected events are analyzed (first 2 bins in event QA histogram are the same))
  // documentation in https://twiki.cern.ch/twiki/bin/viewauth/ALICE/PWG1EvSelDocumentation

  
  if(triggerSel == AliAnalysisTaskBFPsi::kCentral) taskBF->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);
  else if(triggerSel == AliAnalysisTaskBFPsi::kMB) taskBF->SelectCollisionCandidates(AliVEvent::kMB);
  else if(triggerSel == AliAnalysisTaskBFPsi::kINT7) taskBF->SelectCollisionCandidates(AliVEvent::kINT7);

  // centrality estimator (default = V0M)
  taskBF->SetCentralityEstimator(centralityEstimator);
  
  // vertex cut (x,y,z)
  taskBF->SetVertexDiamond(3.,3.,vertexZ);

  taskBF->SetCorrectionProcedure(corrProc);


  //++++++++++++++++++++++
  // Efficiency + Contamination corrections
  // If correctionFileName = "", do not use corrections
  // if(corrProc == AliAnalysisTaskBFPsi::kMCCorr)
  // taskBF->SetInputCorrection(Form("$ALICE_PHYSICS/PWGCF/EBYE/BalanceFunctions/Corrections/%s",correctionFileName.Data()),nCentralityArrayBinsForCorrection,gCentralityArrayForCorrections);
  
  /*else if (corrProc == AliAnalysisTaskBFPsi::kDataDrivCorr){

    TFile* fNUAFile = TFile::Open(nuaCorrFileName.Data(),"READ");
    TFile* fNUEFile = TFile::Open(nueCorrFileName.Data(),"READ");
    
    if(!fNUAFile) {
      printf(" *** ERROR: NUA file not found! **EXIT** ");
    } 
    TList* fListNUA = dynamic_cast<TList*>(fNUAFile->Get("fListNUA"));
    if(fListNUA)
      taskBF->SetInputListForNUACorr(fListNUA);
    else
      printf(" *** ERROR: NUA List not found! **EXIT**");
    
    
    if(!fNUEFile) {
      printf(" *** ERROR: NUE file not found! **EXIT** ");
    } 
    TList* fListNUE = dynamic_cast<TList*>(fNUEFile->Get("fListNUE"));
    if(fListNUE)
      taskBF->SetInputListForNUECorr(fListNUE);
    else
      printf(" *** ERROR: NUE List not found! **EXIT**");    
  }
  */
  
  //bf->PrintAnalysisSettings();
  mgr->AddTask(taskBF);
  
  // Create ONLY the output containers for the data produced by the task.
  // Get and connect other common input/output containers via the manager as below
  //==============================================================================
  TString outputFileName = AliAnalysisManager::GetCommonFileName();
  outputFileName += ":PWGCFEbyE.outputBalanceFunctionPsiAnalysis";
  AliAnalysisDataContainer *coutQA = mgr->CreateContainer(Form("listQAPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
  AliAnalysisDataContainer *coutBF = mgr->CreateContainer(Form("listBFPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
  if(gRunShuffling) AliAnalysisDataContainer *coutBFS = mgr->CreateContainer(Form("listBFPsiShuffled_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
  if(gRunMixing) AliAnalysisDataContainer *coutBFM = mgr->CreateContainer(Form("listBFPsiMixed_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());
  if(kUsePID || sigmaElectronRejection > 0) AliAnalysisDataContainer *coutQAPID = mgr->CreateContainer(Form("listQAPIDPsi_%.0f-%.0f_Bit%d_%s%s",centrMin,centrMax,AODfilterBit,centralityEstimator.Data(),dirNameExtra.Data()), TList::Class(),AliAnalysisManager::kOutputContainer,outputFileName.Data());

  mgr->ConnectInput(taskBF, 0, mgr->GetCommonInputContainer());
  mgr->ConnectOutput(taskBF, 1, coutQA);
  mgr->ConnectOutput(taskBF, 2, coutBF);
  if(gRunShuffling) mgr->ConnectOutput(taskBF, 3, coutBFS);
  if(gRunMixing) mgr->ConnectOutput(taskBF, 4, coutBFM);
  if(kUsePID||sigmaElectronRejection > 0) mgr->ConnectOutput(taskBF, 5, coutQAPID);
  //if((kUsePID && analysisType == "AOD")||sigmaElectronRejection > 0) mgr->ConnectOutput(taskBF, 5, coutQAPID);
  //if((kUsePID && analysisType == "ESD")||sigmaElectronRejection > 0) mgr->ConnectOutput(taskBF, 5, coutQAPID);

  return taskBF;
}
Example #30
0
///
/// Main method calling all the configuration
///
/// The parameters passed to the analysis are:
/// \param bias      : bias or not depending on EMCal signal.
/// \param mc        : simulation or data.
/// \param minE      : at least one cluster in EMCal with this energy.
/// \param minN      : at least one cluster in EMCal with this number of cells.
/// \param vz        : z vertex cut.
/// \param opt       : filter EMCal only, PHOS only or both.
/// \param correct   : calibrate the EMCal, remove bad cells ...
/// \param fillTrack : Fill event with hybrid tracks
/// \param fillAOD   : Output AOD is filled, not used only for a secondary task analysis at the same time.
///
AliAnalysisTaskCaloFilter * AddTaskCaloFilter
(  const Bool_t  bias      = kTRUE
 , const Bool_t  mc        = kFALSE
 , const Float_t minE      = 6.
 , const Int_t   minN      = 3 
 , const Float_t vz        = 10.
 , const Int_t   opt       = 0
 //AliAnalysisTaskCaloFilter::kBoth,kPHOS, kEMCAL or kBoth
 , const Bool_t  correct   = kFALSE
 , const Bool_t  fillTrack = kFALSE
 , const Bool_t  fillAOD   = kTRUE)
{

  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) 
  {
    ::Error("AddTaskCaloFilter", "No analysis manager to connect to.");
    return NULL;
  }  
  
  // Check the analysis type using the event handlers connected to the analysis manager.
  //==============================================================================
  if (!mgr->GetInputEventHandler()) 
  {
    ::Error("AddTaskCaloFilter", "This task requires an input event handler");
    return NULL;
  }
  
  // Set the output AOD handler
  //
  printf("AddTaskCaloFilter --- Init output handler ---\n");
  
  AliAODHandler* aodoutHandler   = new AliAODHandler();
  aodoutHandler->SetOutputFileName("AliAOD.EMCAL.root");
  //aodoutHandler->SetCreateNonStandardAOD();
  mgr->SetOutputEventHandler(aodoutHandler);

  // Configure the task
  //
  printf("AddTaskCaloFilter --- Init task ---\n");

  AliAnalysisTaskCaloFilter * filter = new AliAnalysisTaskCaloFilter("CaloFilter");
  
  //filter->SetDebugLevel(2);
  
  filter->SetCaloFilter(opt); //kPHOS, kEMCAL or kBoth
  
  filter->SetVzCut(vz);
  
  if(mc)
  {
    filter->SetEventSelection(1,0,0); // Select events depending on EMCAL, PHOS and tracks criteria
    filter->SwitchOnAcceptAllMBEvent();
    
    filter->SwitchOnFillMCParticles();
    
    filter->SetEMCALEnergyCut(minE);
    filter->SetEMCALNcellsCut(minN);
    
    filter->SetPHOSEnergyCut(minE);
    filter->SetPHOSNcellsCut(minN);
    
    filter->SetTrackPtCut(minE);
    printf("AddTaskCaloFilter --- Select MC events with bias in EMCal ---\n");
  }
  else if(bias) // select events with significant signal in EMCAL or TPC or PHOS
  {
    filter->SetEventSelection(1,0,0); // Select events depending on EMCAL, PHOS and tracks criteria
    filter->SwitchOnAcceptAllMBEvent();
    
    filter->SetEMCALEnergyCut(minE);
    filter->SetEMCALNcellsCut(minN);
 
    filter->SetPHOSEnergyCut(minE);
    filter->SetPHOSNcellsCut(minN);
    
    filter->SetTrackPtCut(minE);

    //filter->SetMBTriggerMask(AliVEvent::kAnyINT);
    filter->SetMBTriggerMask(AliVEvent::kINT7); // not working for all productions
    
    filter->SelectCollisionCandidates(AliVEvent::kAny) ;
    
    printf("AddTaskCaloFilter --- Select events with bias in EMCal ---\n");
  }
  else // Do not bias the signal in EMCAL, select MB events 
  {
    
    filter->SetEventSelection(0,0,0);
    filter->SwitchOnAcceptAllMBEvent();
    
    filter->SetEMCALEnergyCut(-1);
    filter->SetEMCALNcellsCut(0);  
    
    filter->SetPHOSEnergyCut(-1);
    filter->SetPHOSNcellsCut(0); 
    
    filter->SetTrackPtCut(-1);
    
    filter->SelectCollisionCandidates(AliVEvent::kINT7);// | AliVEvent::kCentral | AliVEvent::kSemiCentral ) ;
    
    printf("AddTaskCaloFilter --- Select INT7 events ---\n");
  }

  // Activate the cluster corrections (calibration, bad map...)     
  //
  if(correct)   filter->SwitchOnClusterCorrection();
  else          filter->SwitchOffClusterCorrection();  
  
  // Exoticity cut settings
  //
  AliEMCALRecoUtils * reco = filter->GetEMCALRecoUtils();
  reco->SwitchOnRejectExoticCluster() ;
  reco->SetExoticCellFractionCut(0.97);
  reco->SetExoticCellMinAmplitudeCut(4.);

  // Track storing
  //
  if(fillTrack) { filter->SwitchOnFillTracks()  ; filter->SwitchOnFillHybridTracks()  ; }
  else          { filter->SwitchOffFillTracks() ; filter->SwitchOffFillHybridTracks() ; }
  
  // Other options to store in event
  //
  filter->SwitchOffFillv0s() ; // Put ON if you know what you do.
  
  filter->SwitchOnFillVZERO(); // Be able to recalculate centrality and event plane 
                               // afterwards even it is stored in header
  
  // AOD output storing
  //
  if(fillAOD)   filter->SwitchOnFillAODFile();
  else          filter->SwitchOffFillAODFile();
  
  // Pass the task to the manager, print first set parameters
  filter->PrintInfo();
  
  mgr->AddTask(filter);
  
  // Create containers for input/output
  //
  printf("AddTaskCaloFilter --- Created input/output containers ---\n");

  AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer();
  AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer();
    
  printf("AddTaskCaloFilter --- Created containers, add them ---\n");
  
  mgr->ConnectInput  (filter, 0, cinput1  );
  mgr->ConnectOutput (filter, 0, coutput1 );
  
  printf("AddTaskCaloFilter --- End ---\n");

  return filter;

}