Exemplo n.º 1
0
AliAnalysisTaskDeltaPt* AddTaskDeltaPt(
  const char *ntracks            = "Tracks",
  const char *nclusters          = "CaloClusters",
  const char *njets              = "Jets",
  const char *nembtracks         = "TracksEmbedded",
  const char *nembclusters       = "CaloClustersEmbedded",
  const char *nembjets           = "EmbJets",
  const char *nrandtracks        = "TracksRandomized",
  const char *nrandclusters      = "CaloClustersRandomized",
  const char *nrho               = "Rho",
  Double_t    jetradius          = 0.2,
  Double_t    jetareacut         = 0.557,
  Double_t    trackptcut         = 0.15,
  Double_t    clusptcut          = 0.30,
  const char *type               = "TPC",
  const char *taskname           = "AliAnalysisTaskDeltaPt"
)
{  
  // Get the pointer to the existing analysis manager via the static access method.
  //==============================================================================
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr)
  {
    ::Error("AddTaskDeltaPt", "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("AddTaskDeltaPt", "This task requires an input event handler");
    return NULL;
  }
  
  //-------------------------------------------------------
  // Init the task and do settings
  //-------------------------------------------------------
  TString name;
  if (strcmp(ntracks, "") == 0 && strcmp(nclusters, "") == 0) 
    name = Form("%s_%s_R0%d_%s",taskname,nrho,(Int_t)floor(jetradius*100+0.5),type);
  else if (strcmp(ntracks, "") == 0) 
    name = Form("%s_%s_%s_R0%d_%s",taskname,nclusters,nrho,(Int_t)floor(jetradius*100+0.5),type);
  else if (strcmp(nclusters, "") == 0) 
    name = Form("%s_%s_%s_R0%d_%s",taskname,ntracks,nrho,(Int_t)floor(jetradius*100+0.5),type);
  else
    name = Form("%s_%s_%s_%s_R0%d_%s",taskname,ntracks,nclusters,nrho,(Int_t)floor(jetradius*100+0.5),type);

  AliAnalysisTaskDeltaPt* jetTask = new AliAnalysisTaskDeltaPt(name);
  jetTask->SetConeRadius(jetradius);
  jetTask->SetRhoName(nrho,-1);
  if (strcmp(type,"TPC")==0) 
    jetTask->SetConeEtaPhiTPC();
  else if (strcmp(type,"EMCAL")==0) 
    jetTask->SetConeEtaPhiEMCAL();

  AliParticleContainer *partCont = jetTask->AddParticleContainer(ntracks);
  if (partCont) {
    partCont->SetName("Tracks");
    partCont->SetParticlePtCut(trackptcut);
  }

  AliClusterContainer *clusCont = jetTask->AddClusterContainer(nclusters);
  if (clusCont) {
    clusCont->SetName("CaloClusters");
    clusCont->SetClusPtCut(clusptcut);
  }

  AliJetContainer *jetCont = jetTask->AddJetContainer(njets,type,jetradius);
  if (jetCont) {
    jetCont->SetName("Jets");
    jetCont->SetPercAreaCut(jetareacut);
    jetCont->SetRhoName(nrho);
    jetCont->ConnectParticleContainer(partCont);
    jetCont->ConnectClusterContainer(clusCont);
  }

  AliParticleContainer *embPartCont = jetTask->AddParticleContainer(nembtracks);
  if (embPartCont) {
    embPartCont->SetName("EmbTracks");
    embPartCont->SetParticlePtCut(trackptcut);
  }

  AliClusterContainer *embClusCont = jetTask->AddClusterContainer(nembclusters);
  if (embClusCont) {
    embClusCont->SetName("EmbClusters");
    embClusCont->SetClusPtCut(clusptcut);
  }

  AliJetContainer *embJetCont = jetTask->AddJetContainer(nembjets,type,jetradius);
  if (embJetCont) {
    embJetCont->SetName("EmbJets");
    embJetCont->SetPercAreaCut(jetareacut);
    embJetCont->SetRhoName(nrho);
    embJetCont->ConnectParticleContainer(embPartCont);
    embJetCont->ConnectClusterContainer(embClusCont);
  }

  AliParticleContainer *randPartCont = jetTask->AddParticleContainer(nrandtracks);
  if (randPartCont) {
    randPartCont->SetName("RandTracks");
    randPartCont->SetParticlePtCut(trackptcut);
  }

  AliClusterContainer *randClusCont = jetTask->AddClusterContainer(nrandclusters);    
  if (randClusCont) {
    randClusCont->SetName("RandClusters");
    randClusCont->SetClusPtCut(clusptcut);
  }
  
  //-------------------------------------------------------
  // Final settings, pass to manager and set the containers
  //-------------------------------------------------------
  
  mgr->AddTask(jetTask);
  
  // Create containers for input/output
  AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer();
  TString contname(name);
  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;
}
Bool_t AddTasksEmcalFjetSparseMaker()
{
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();

  if (bIsInfoAOD) {
    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddAODHandler.C");
    AliAODInputHandler *aodIH = AddAODHandler();
  } else {
    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddESDHandler.C");
    AliESDInputHandler *esdIH = AddESDHandler();
//  esdIH->SetReadFriends(kFALSE);
  }

  if (bAnaInfoMC && (!bIsInfoAOD)) {
    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddMCHandler.C");
    AliMCEventHandler *mctEH = AddMCHandler(kTRUE);
  }

  if (bOutputAOD) {
    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/train/AddAODOutputHandler.C");
    AliAODHandler *aodH = AddAODOutputHandler();
    aodH->SetOutputFileName("AliAOD.PicoJets.root");
    aodH->SetFillAOD(kTRUE);
    aodH->SetCreateNonStandardAOD();
    mgr->SetOutputEventHandler(aodH);
  }
//=============================================================================

  if (bIsPhysSel) {
    gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/AddTaskEmcalPhysicsSelection.C");
    AliEmcalPhysicsSelectionTask *taksPhysSel = AddTaskEmcalPhysicsSelection(kTRUE, kTRUE, wTriggerMask, 5., 5., 10., kTRUE, -1, -1, -1, -1);
    if (bAnaInfoMC) {
      AliEmcalPhysicsSelection *pPhysSel = static_cast<AliEmcalPhysicsSelection*>(taksPhysSel->GetPhysicsSelection());
      if (!pPhysSel) return kTRUE; pPhysSel->SetAnalyzeMC();
    }
  }

  if (bIsCentSel) {
    gROOT->LoadMacro("$ALICE_PHYSICS/OADB/macros/AddTaskCentrality.C");
    AliCentralitySelectionTask *taskCentSel = AddTaskCentrality(kTRUE, bIsAOD);
    if (bAnaInfoMC) taskCentSel->SetMCInput();
  }

  if (bIsEvPnSel) {
    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskEventplane.C");
    AliEPSelectionTask *taskEventPlane = AddTaskEventplane();
    if (bAnaInfoMC) taskEventPlane->SetUseMCRP();
  }

  if (bIsRespPID) {
    gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
    AliAnalysisTaskSE *taskRespPID = AddTaskPIDResponse(bAnaInfoMC);
  }
//=============================================================================

  gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/AddTaskEmcalSetup.C");
  AliEmcalSetupTask *taskSetupEMCal = AddTaskEmcalSetup();
  taskSetupEMCal->SetGeoPath("$ALICE_PHYSICS/OADB/EMCAL");

  gROOT->LoadMacro("$ALICE_PHYSICS/PWG/EMCAL/macros/AddTaskEmcalPreparation.C");
  AliAnalysisTaskSE *taskEmcMaker = AddTaskEmcalPreparation(sPeriodIn);

  gROOT->LoadMacro("$ALICE_PHYSICS/PWGJE/EMCALJetTasks/macros/AddTaskJetPreparation.C");
  AliAnalysisTaskSE *taskHadCorr = AddTaskJetPreparation(sPeriodIn.Data(),
                                                         sUsedTrksRD.Data(),
                                                        (bAnaInfoMC ? sUsedTrksMC.Data() : ""),
                                                         sInputClsRD.Data(),
                                                         sUsedClusRD.Data(),
                                                         2., 0., 0.03, 0.015, 0.15,
                                                         wTriggerMask,
                                                         kTRUE,   // do trk clus
                                                         kTRUE,   // histos
                                                         kTRUE,   // make pico trk
                                                         kFALSE,  // make trigger
                                                         kFALSE,  // is EMCal train
                                                         1.,      // track eff
                                                         kTRUE,   // do AOD track prop
                                                         kTRUE,   // modify match
                                                         kFALSE,  // use old bit
                                                         kFALSE,  // trigger QA
                                                         4);      // cent bin
//=============================================================================

  gROOT->LoadMacro("$ALICE_PHYSICS/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJet.C");

/*AliEmcalJetTask *taskAkt = AddTaskEmcalJet(sUsedTrksRD.Data(),
                                             sUsedClusRD.Data(),
                                             1, // anti-kT
                                             dJetRadius,
                                             nJetType,
                                             dTrkPtCut,
                                             dCluEnCut);*/
//=============================================================================

  AliAnalysisTaskEmcalFjetSparseMaker *taskEmcalSM = new AliAnalysisTaskEmcalFjetSparseMaker("AliAnalysisTaskEmcalFjetSM");
//taskEmcalSM->SetForceBeamType(0);
//taskEmcalSM->SetIsPythia(kTRUE);

/*taskEmcalSM->SetCaloTriggerPatchInfoName("EmcalTriggers");
  taskEmcalSM->SetTriggerTypeSel(AliAnalysisTaskEmcal::kJ2);
  taskEmcalSM->SetMainPatchType(AliAnalysisTaskEmcal::kTriggerLevel1Jet);*/

  AliParticleContainer *pContTrks = taskEmcalSM->AddParticleContainer(sUsedTrksRD.Data());
  pContTrks->SetParticlePtCut(dTrkPtCut);

  AliClusterContainer *pContClus = taskEmcalSM->AddClusterContainer(sUsedClusRD.Data());
  pContClus->SetClusPtCut(dCluEnCut);

/*AliJetContainer *pContJets = taskEmcalSM->AddJetContainer(taskAkt->GetName(), sCutType.Data(), dJetRadius);
  pContJets->SetPercAreaCut(dJetAreaCut);
  pContJets->SetJetPtCut(dJetPtCut);
//pContJets->SetRhoName(sUsedRho.Data());
//pContJets->SetLocalRhoName();
  pContJets->SetLeadingHadronType(nLeading);
  pContJets->ConnectParticleContainer(taskEmcalSM->GetParticleContainer());
  pContJets->ConnectClusterContainer(taskEmcalSM->GetClusterContainer());
  pContJets->SetNameTitle(taskEmcalSM->GetNameJet().Data(),
                          taskEmcalSM->GetNameJet().Data());*/

  mgr->AddTask(taskEmcalSM);
  mgr->ConnectInput(taskEmcalSM,  0, mgr->GetCommonInputContainer());

  mgr->ConnectOutput(taskEmcalSM, 1, mgr->CreateContainer("listGeneralH",
                                                          TList::Class(),
                                                          AliAnalysisManager::kOutputContainer,
                                                          AliAnalysisManager::GetCommonFileName()));

  mgr->ConnectOutput(taskEmcalSM, 2, mgr->CreateContainer("listEmcalEvH",
                                                          TList::Class(),
                                                          AliAnalysisManager::kOutputContainer,
                                                          "AnalysisResults_EmcalEvH.root"));

  mgr->ConnectOutput(taskEmcalSM, 3, mgr->CreateContainer("listEmcalTrk",
                                                          TList::Class(),
                                                          AliAnalysisManager::kOutputContainer,
                                                          "AnalysisResults_EmcalTrk.root"));

  mgr->ConnectOutput(taskEmcalSM, 4, mgr->CreateContainer("listEmcalClu",
                                                          TList::Class(),
                                                          AliAnalysisManager::kOutputContainer,
                                                          "AnalysisResults_EmcalClu.root"));

/*mgr->ConnectOutput(taskEmcalSM, 5, mgr->CreateContainer("listEmcalJet",
                                                          TList::Class(),
                                                          AliAnalysisManager::kOutputContainer,
                                                          "AnalysisResults_EmcalJet.root"));*/
//=============================================================================

  TObjArray *aTasks = mgr->GetTasks();
  for (Int_t i=0; i<aTasks->GetEntries(); i++) {
    AliAnalysisTaskEmcal *taskJE = dynamic_cast<AliAnalysisTaskEmcal*>(aTasks->At(i));
    if (taskJE) if (taskJE->InheritsFrom("AliAnalysisTaskEmcal")) {
      taskJE->SetVzRange(-10., 10.);

      if (!sCentEsti.IsNull()) {
        taskJE->SetCentralityEstimator(sCentEsti.Data());
        taskJE->SetCentRange(dCentMin, dCentMax);
       }
    }

    if (wTriggerMask) {
      AliAnalysisTaskSE *taskSE = dynamic_cast<AliAnalysisTaskSE*>(aTasks->At(i));
      if (taskSE) if (!(taskSE->InheritsFrom("AliPhysicsSelectionTask"))) {
        taskSE->SelectCollisionCandidates(wTriggerMask);
      }
    }
  }
//=============================================================================

  return kFALSE;
}
Exemplo n.º 3
0
AliAnalysisTaskPWGJEQA* AddTaskPWGJEQA(
                                       const char* ntracks            = "usedefault",
                                       const char* nclusters          = "usedefault",
                                       const char* ncells             = "usedefault",
                                       const char *nGenLev            = "mcparticles",
                                       Bool_t      doTrackQA          = kTRUE,
                                       Bool_t      doCaloQA           = kTRUE,
                                       Bool_t      doJetQA            = kTRUE,
                                       Bool_t      doEventQA          = kTRUE,
                                       Double_t    trackPtCut         = 0.15,
                                       Double_t    clusECut           = 0.30,
                                       const char* suffix             = ""
                                       )
{
  
  // Get the pointer to the existing analysis manager via the static access method
  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
  if (!mgr) {
    ::Error("AddTaskPWGJEQA", "No analysis manager to connect to.");
    return NULL;
  }
  
  // Check the analysis type using the event handlers connected to the analysis manager
  AliVEventHandler* handler = mgr->GetInputEventHandler();
  if (!handler) {
    ::Error("AddTaskPWGJEQA", "This task requires an input event handler");
    return NULL;
  }
  
  enum EDataType_t {
    kUnknown,
    kESD,
    kAOD
  };
  
  EDataType_t dataType = kUnknown;
  
  if (handler->InheritsFrom("AliESDInputHandler")) {
    dataType = kESD;
  }
  else if (handler->InheritsFrom("AliAODInputHandler")) {
    dataType = kAOD;
  }
  
  // Init the task and do settings
  TString trackName(ntracks);
  TString clusName(nclusters);
  TString cellName(ncells);
  
  if (trackName == "usedefault") {
    if (dataType == kESD) {
      trackName = "Tracks";
    }
    else if (dataType == kAOD) {
      trackName = "tracks";
    }
    else {
      trackName = "";
    }
  }
  
  if (clusName == "usedefault") {
    if (dataType == kESD) {
      clusName = "CaloClusters";
    }
    else if (dataType == kAOD) {
      clusName = "caloClusters";
    }
    else {
      clusName = "";
    }
  }
  
  if (ncells == "usedefault") {
    if (dataType == kESD) {
      cellName = "EMCALCells";
    }
    else if (dataType == kAOD) {
      cellName = "emcalCells";
    }
    else {
      cellName = "";
    }
  }
  
  TString name("AliAnalysisTaskPWGJEQA");
  if (!trackName.IsNull()) {
    name += "_";
    name += trackName;
  }
  if (!clusName.IsNull()) {
    name += "_";
    name += clusName;
  }
  
  if (!cellName.IsNull()) {
    name += "_";
    name += cellName;
  }
   
  if (strcmp(suffix,"")) {
    name += "_";
    name += suffix;
  }
  
  AliAnalysisTaskPWGJEQA* qaTask = new AliAnalysisTaskPWGJEQA(name);
  qaTask->SetVzRange(-10,10);
  qaTask->SetNeedEmcalGeom(kFALSE);
  qaTask->SetCaloCellsName(cellName);
  qaTask->SetDetectorLevelName(trackName);
  if (nGenLev && strcmp(nGenLev,"")!=0) qaTask->SetGeneratorLevelName(nGenLev);
  qaTask->SetDoTrackQA(doTrackQA);
  qaTask->SetDoCaloQA(doCaloQA);
  qaTask->SetDoJetQA(doJetQA);
  qaTask->SetDoEventQA(doEventQA);
  
  // Add the detector-level track container
  if (trackName == "tracks" || trackName == "Tracks") {
    AliTrackContainer* trackCont = qaTask->AddTrackContainer(trackName);
    trackCont->SetFilterHybridTracks(kTRUE);
  }
  else if (!trackName.IsNull()) {
    qaTask->AddParticleContainer(trackName);
  }
  AliParticleContainer *partCont = qaTask->GetParticleContainer(trackName);
  if (partCont) {
    partCont->SetParticlePtCut(trackPtCut);
  }
  
  // Add the generator-level container, if specified
  if (nGenLev && strcmp(nGenLev,"")!=0) {
    AliMCParticleContainer* mcpartCont = qaTask->AddMCParticleContainer(nGenLev);
    mcpartCont->SelectPhysicalPrimaries(kTRUE);
    mcpartCont->SetParticlePtCut(0);
  }

  // Add the cluster container
  AliClusterContainer *clusterCont = qaTask->AddClusterContainer(clusName);
  if (clusterCont) {
    clusterCont->SetClusECut(0.);
    clusterCont->SetClusPtCut(0.);
    clusterCont->SetClusHadCorrEnergyCut(clusECut);
    clusterCont->SetDefaultClusterEnergy(AliVCluster::kHadCorr);
  }

  // Final settings, pass to manager and set the containers
  mgr->AddTask(qaTask);
  
  // Create containers for input/output
  AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer()  ;
  
  TString contName = TString::Format("%s_histos", name.Data());
  TString commonoutput;
  commonoutput = mgr->GetCommonFileName();
  AliAnalysisDataContainer *coutput1 = mgr->CreateContainer(contName.Data(),
                                                            TList::Class(),AliAnalysisManager::kOutputContainer,
                                                            commonoutput);
  mgr->ConnectInput  (qaTask, 0,  cinput1 );
  mgr->ConnectOutput (qaTask, 1, coutput1 );
  
  return qaTask;
}