Add ExchangeContainer and Fix bug Clear TClonesArray
authorcbianchi <cbianchi@cern.ch>
Tue, 11 Feb 2014 16:06:31 +0000 (17:06 +0100)
committermvl <marco.van.leeuwen@cern.ch>
Wed, 12 Feb 2014 15:12:20 +0000 (16:12 +0100)
move to kExchangeContainer

PWGJE/FlavourJetTasks/AliAnalysisTaskFlavourJetCorrelations.cxx
PWGJE/FlavourJetTasks/AliAnalysisTaskFlavourJetCorrelations.h
PWGJE/FlavourJetTasks/AliAnalysisTaskSEDmesonsFilterCJ.cxx
PWGJE/FlavourJetTasks/macros/AddTaskDFilterAndCorrelations.C [new file with mode: 0644]
PWGJE/FlavourJetTasks/macros/AddTasksFlavourJet.C

index f28bcf4..7ef1e74 100644 (file)
@@ -68,7 +68,9 @@ fMaxMass(),
 fJetArrName(0),
 fCandArrName(0),
 fLeadingJetOnly(kFALSE),
-fJetRadius(0)
+fJetRadius(0),
+fCandidateArray(0),
+fSideBandArray(0)
 {
    //
    // Default ctor
@@ -95,7 +97,9 @@ fMaxMass(),
 fJetArrName(0),
 fCandArrName(0),
 fLeadingJetOnly(kFALSE),
-fJetRadius(0)
+fJetRadius(0),
+fCandidateArray(0),
+fSideBandArray(0)
 {
    //
    // Constructor. Initialization of Inputs and Outputs
@@ -142,6 +146,9 @@ fJetRadius(0)
    if(fCandidateType==kD0toKpi)SetMassLimits(0.15,fPDGmother);
    if(fCandidateType==kDstartoKpipi) SetMassLimits(0.015, fPDGmother);
    
+   DefineInput(1, TClonesArray::Class());
+   DefineInput(2, TClonesArray::Class());
+   
    DefineOutput(1,TList::Class()); // histos
    DefineOutput(2,AliRDHFCuts::Class()); // my cuts
    
@@ -222,8 +229,6 @@ void AliAnalysisTaskFlavourJetCorrelations::UserExec(Option_t *)
    
    TClonesArray *arrayDStartoD0pi=0;
    TClonesArray *trackArr = 0;
-   TClonesArray *candidatesArr = 0;
-   TClonesArray *sbcandArr = 0;
    
    if (!aodEvent && AODEvent() && IsStandardAOD()) {
       
@@ -269,27 +274,11 @@ void AliAnalysisTaskFlavourJetCorrelations::UserExec(Option_t *)
       return;
    }
    
+    
+   if (!fCandidateArray) fCandidateArray = dynamic_cast<TClonesArray*>(GetInputData(1));
+   if (fCandidateType==1 && !fSideBandArray) fSideBandArray = dynamic_cast<TClonesArray*>(GetInputData(2));
    
-   TString arrname="fCandidateArray";
-   TString candarrname=Form("%s%s%s",arrname.Data(),fCandArrName.Data(),fUseReco ? "rec" : "gen");
-   candidatesArr = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(candarrname));
-   if (!candidatesArr) {
-      Printf("%s array not found",candarrname.Data());
-      InputEvent()->GetList()->ls();
-      return;
-   }
-   //Printf("ncandidates found %d",candidatesArr->GetEntriesFast());
-   
-   TString arrSBname="fSideBandArray";
-   TString sbarrname=Form("%s%s%s",arrSBname.Data(),fCandArrName.Data(),fUseReco ? "rec" : "gen");
-   sbcandArr = dynamic_cast<TClonesArray*>(InputEvent()->FindListObject(sbarrname));
-   if (fCandidateType==1 && !sbcandArr) {
-      Printf("%s array not found",sbarrname.Data());
-      InputEvent()->GetList()->ls();
-      return;
-   }
-   //Printf("nSBCand or Bkg found %d",sbcandArr->GetEntriesFast());
-   
+   Printf("ncandidates found %d",fCandidateArray->GetEntriesFast());
    
    //Histograms
    TH1I* hstat=(TH1I*)fmyOutput->FindObject("hstat");
@@ -324,7 +313,7 @@ void AliAnalysisTaskFlavourJetCorrelations::UserExec(Option_t *)
    hstat->Fill(1);
 
    //retrieve charm candidates selected
-   Int_t candidates = candidatesArr->GetEntriesFast();
+   Int_t candidates = fCandidateArray->GetEntriesFast();
   
    //trigger on jets
    
@@ -333,7 +322,7 @@ void AliAnalysisTaskFlavourJetCorrelations::UserExec(Option_t *)
       hstat->Fill(6, candidates);
       hNDPerEvNoJet->Fill(candidates);
       for(Int_t iD=0;iD<candidates;iD++){
-        AliVParticle* cand=(AliVParticle*)candidatesArr->At(iD);
+        AliVParticle* cand=(AliVParticle*)fCandidateArray->At(iD);
         if(!cand) continue;
         hptDPerEvNoJet->Fill(cand->Pt());
       
@@ -347,15 +336,23 @@ void AliAnalysisTaskFlavourJetCorrelations::UserExec(Option_t *)
    for(Int_t ic = 0; ic < candidates; ic++) {
       
       // D* candidates
-      AliVParticle* charm=0x0;
-      charm=(AliVParticle*)candidatesArr->At(ic);
+      AliAODRecoDecayHF* charm=0x0;
+      AliAODRecoCascadeHF* dstar=0x0;
+      
+      
+      charm=(AliAODRecoDecayHF*)fCandidateArray->At(ic);
       if(!charm) continue;
+      
+      if(fCandidateType==kDstartoKpipi){ 
+        dstar=(AliAODRecoCascadeHF*)fCandidateArray->At(ic);
+        if(!dstar) continue;
+      }
+      
       hstat->Fill(2);
       
       Double_t candsparse[4]={charm->Eta(), charm->Phi(), charm->Pt(), 0};
       
       if(fCandidateType==kDstartoKpipi) {
-        AliAODRecoCascadeHF* dstar = (AliAODRecoCascadeHF*)charm;
         Double_t deltamass= dstar->DeltaInvMass();
         candsparse[3]=deltamass;
         hnspDstandalone->Fill(candsparse);
@@ -459,7 +456,7 @@ void AliAnalysisTaskFlavourJetCorrelations::UserExec(Option_t *)
         
         // D* candidates
         AliVParticle* charm=0x0;
-        charm=(AliVParticle*)candidatesArr->At(ic);
+        charm=(AliVParticle*)fCandidateArray->At(ic);
         if(!charm) continue;
         
         
@@ -470,17 +467,17 @@ void AliAnalysisTaskFlavourJetCorrelations::UserExec(Option_t *)
         
       }
       //retrieve side band background candidates for Dstar
-      Int_t nsbcand = 0; if(sbcandArr) nsbcand=sbcandArr->GetEntriesFast();
+      Int_t nsbcand = 0; if(fSideBandArray) nsbcand=fSideBandArray->GetEntriesFast();
       
       for(Int_t ib=0;ib<nsbcand;ib++){
         if(fCandidateType==kDstartoKpipi && !fUseMCInfo){
-           AliAODRecoCascadeHF *sbcand=(AliAODRecoCascadeHF*)sbcandArr->At(ib);
+           AliAODRecoCascadeHF *sbcand=(AliAODRecoCascadeHF*)fSideBandArray->At(ib);
            if(!sbcand) continue;
            SideBandBackground(sbcand,jet);
         }
         if(fUseMCInfo){
            AliAODRecoDecayHF* charmbg = 0x0;
-           charmbg=(AliAODRecoDecayHF*)candidatesArr->At(ib);
+           charmbg=(AliAODRecoDecayHF*)fCandidateArray->At(ib);
            if(!charmbg) continue;
            MCBackground(charmbg,jet);
         }
index 7591009..662df7a 100644 (file)
@@ -120,8 +120,10 @@ class AliAnalysisTaskFlavourJetCorrelations : public AliAnalysisTaskEmcalJet
   TString fCandArrName;          // string which correspond to the candidate type
   Bool_t fLeadingJetOnly;        // use only the leading jet in the event to make the correlations
   Double_t fJetRadius;           // jet radius (filled from the JetContainer)
+  TClonesArray *fCandidateArray;   //! contains candidates selected by AliRDHFCuts
+  TClonesArray *fSideBandArray;    //! contains candidates selected by AliRDHFCuts::IsSelected(kTracks), to be used for side bands (DStar case only!!)
 
-  ClassDef(AliAnalysisTaskFlavourJetCorrelations,2); // class for charm-jet correlations
+  ClassDef(AliAnalysisTaskFlavourJetCorrelations,2); // class for charm-jet CorrelationsExch
 };
 
 #endif
index cf0a0e6..4c47b2e 100644 (file)
@@ -60,7 +60,8 @@ fOutput(0),
 fCuts(0),
 fMinMass(0.),
 fMaxMass(0.),
-fCandidateArray(0)
+fCandidateArray(0),
+fSideBandArray(0)
 
 {
    //
@@ -86,7 +87,8 @@ fOutput(0),
 fCuts(cuts),
 fMinMass(0.),
 fMaxMass(0.),
-fCandidateArray(0)
+fCandidateArray(0),
+fSideBandArray(0)
 {
    //
    // Constructor. Initialization of Inputs and Outputs
@@ -137,6 +139,8 @@ fCandidateArray(0)
    
    DefineOutput(1, TList::Class());       // histos
    DefineOutput(2, AliRDHFCuts::Class()); // my cuts
+   DefineOutput(3, TClonesArray::Class()); //array of candidates
+   DefineOutput(4, TClonesArray::Class()); //array of SB candidates
 }
 
 //_______________________________________________________________________________
@@ -152,6 +156,7 @@ AliAnalysisTaskSEDmesonsFilterCJ::~AliAnalysisTaskSEDmesonsFilterCJ()
    if (fOutput) { delete fOutput; fOutput = 0; }
    if (fCuts)   { delete fCuts;   fCuts   = 0; }
    if (fCandidateArray)  { delete fCandidateArray;  fCandidateArray  = 0; }
+   delete fSideBandArray;
    
 }
 
@@ -166,17 +171,19 @@ void AliAnalysisTaskSEDmesonsFilterCJ::Init()
    if(fDebug>1) printf("AnalysisTaskSEDmesonsForJetCorrelations::Init() \n");
    
    switch (fCandidateType) {
-   case 0: {
+   case 0: 
+      {
         AliRDHFCutsD0toKpi* copyfCutsDzero = new AliRDHFCutsD0toKpi(*(static_cast<AliRDHFCutsD0toKpi*>(fCuts)));
         copyfCutsDzero->SetName("AnalysisCutsDzero");
         PostData(2, copyfCutsDzero);  // Post the data
-   } break;
-case 1: {
-      AliRDHFCutsDStartoKpipi* copyfCutsDstar = new AliRDHFCutsDStartoKpipi(*(static_cast<AliRDHFCutsDStartoKpipi*>(fCuts)));
-      copyfCutsDstar->SetName("AnalysisCutsDStar");
-      PostData(2, copyfCutsDstar); // Post the cuts
-} break;
-default: return;
+      } break;
+   case 1: 
+      {
+        AliRDHFCutsDStartoKpipi* copyfCutsDstar = new AliRDHFCutsDStartoKpipi(*(static_cast<AliRDHFCutsDStartoKpipi*>(fCuts)));
+        copyfCutsDstar->SetName("AnalysisCutsDStar");
+        PostData(2, copyfCutsDstar); // Post the cuts
+      } break;
+   default: return;
    }
    
    return;
@@ -195,15 +202,27 @@ void AliAnalysisTaskSEDmesonsFilterCJ::UserCreateOutputObjects()
    fOutput = new TList(); fOutput->SetOwner();
    DefineHistoForAnalysis(); // define histograms
    
-   fCandidateArray = new TClonesArray("AliAODRecoDecayHF",0);
-   fCandidateArray->SetName(Form("fCandidateArray%s%s",fCandidateName.Data(),fUseReco ? "rec" : "gen"));
+   if (fCandidateType==kD0toKpi){
+      fCandidateArray = new TClonesArray("AliAODRecoDecayHF",0);
+      fSideBandArray = new TClonesArray("AliAODRecoDecayHF",0); 
+   }
    
-   if (fCandidateType==kDstartoKpipi){
-      fSideBandArray = new TClonesArray("AliAODRecoCascadeHF",0); //this is for the DStar only!
-      fSideBandArray->SetName(Form("fSideBandArray%s%s",fCandidateName.Data(),fUseReco ? "rec" : "gen"));
+   if (fCandidateType==kDstartoKpipi) {
+      fCandidateArray = new TClonesArray("AliAODRecoCascadeHF",0);
+      fSideBandArray = new TClonesArray("AliAODRecoCascadeHF",0); 
    }
    
+   fCandidateArray->SetOwner();
+   fCandidateArray->SetName(Form("fCandidateArray%s%s",fCandidateName.Data(),fUseReco ? "rec" : "gen"));
+   
+   //this is used for the DStar side bands and MC!
+   fSideBandArray->SetOwner();
+   fSideBandArray->SetName(Form("fSideBandArray%s%s",fCandidateName.Data(),fUseReco ? "rec" : "gen"));
+  
    PostData(1, fOutput);
+   PostData(3, fCandidateArray);
+   PostData(4, fSideBandArray);
    return;
 }
 
@@ -213,15 +232,6 @@ void AliAnalysisTaskSEDmesonsFilterCJ::UserExec(Option_t *){
    //
    // user exec
    //
-   
-   // add cadidate branch
-   fCandidateArray->Delete();
-   if (!(InputEvent()->FindListObject(Form("fCandidateArray%s%s",fCandidateName.Data(),fUseReco ? "rec" : "gen")))) InputEvent()->AddObject(fCandidateArray);
-   if (fCandidateType==kDstartoKpipi){
-      fSideBandArray->Delete();
-      if (!(InputEvent()->FindListObject(Form("fSideBandArray%s%s",fCandidateName.Data(),fUseReco ? "rec" : "gen")))) InputEvent()->AddObject(fSideBandArray);
-   }
-   //Printf("Arr names %s, %s",fCandidateArray->GetName(),fSideBandArray->GetName());
    // Load the event
    AliAODEvent *aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
    
@@ -295,6 +305,7 @@ void AliAnalysisTaskSEDmesonsFilterCJ::UserExec(Option_t *){
    Int_t iSBCand=0;
    Int_t isSelected = 0;
    AliAODRecoDecayHF *charmCand = 0;
+   AliAODRecoCascadeHF *dstar = 0;
    AliAODMCParticle *charmPart = 0;
    Bool_t isMCBkg=kFALSE;
    
@@ -304,15 +315,19 @@ void AliAnalysisTaskSEDmesonsFilterCJ::UserExec(Option_t *){
    Int_t pdgMeson = 413;
    if (fCandidateType==kD0toKpi) pdgMeson = 421;
    
+   //clear the TClonesArray from the previous event
+   fCandidateArray->Clear();
+   fSideBandArray->Clear();
+   
    for (Int_t icharm=0; icharm<nD; icharm++) {   //loop over D candidates
       charmCand = (AliAODRecoDecayHF*)arrayDStartoD0pi->At(icharm); // D candidates
       if (!charmCand) continue;
       
+      if (fCandidateType==kDstartoKpipi) dstar = (AliAODRecoCascadeHF*)charmCand;
       
       if (fUseMCInfo) { // Look in MC, try to simulate the z
         if (fCandidateType==kDstartoKpipi) {
-           AliAODRecoCascadeHF *temp = (AliAODRecoCascadeHF*)charmCand;
-           mcLabel = temp->MatchToMC(413,421,pdgDgDStartoD0pi,pdgDgD0toKpi,mcArray);
+           mcLabel = dstar->MatchToMC(413,421,pdgDgDStartoD0pi,pdgDgD0toKpi,mcArray);
         }
         
         if (fCandidateType==kD0toKpi) 
@@ -338,11 +353,10 @@ void AliAnalysisTaskSEDmesonsFilterCJ::UserExec(Option_t *){
            AliError(Form("Pt %.3f out of bounds",ptD));
            continue;
         }
-        AliAODRecoCascadeHF *temp = (AliAODRecoCascadeHF*)charmCand;
         //if data and Dstar from D0 side band
-        if (((temp->InvMassD0()<=(mPDGD0-3.*fSigmaD0[bin])) && (temp->InvMassD0()>(mPDGD0-10.*fSigmaD0[bin]))) /*left side band*/||  ((temp->InvMassD0()>=(mPDGD0+3.*fSigmaD0[bin])) && (temp->InvMassD0()<(mPDGD0+10.*fSigmaD0[bin])))/*right side band*/){   
+        if (((dstar->InvMassD0()<=(mPDGD0-3.*fSigmaD0[bin])) && (dstar->InvMassD0()>(mPDGD0-10.*fSigmaD0[bin]))) /*left side band*/||  ((dstar->InvMassD0()>=(mPDGD0+3.*fSigmaD0[bin])) && (dstar->InvMassD0()<(mPDGD0+10.*fSigmaD0[bin])))/*right side band*/){       
            
-           new ((*fSideBandArray)[iSBCand]) AliAODRecoCascadeHF(*temp);
+           new ((*fSideBandArray)[iSBCand]) AliAODRecoCascadeHF(*dstar);
            iSBCand++;
         }
       }
@@ -354,8 +368,14 @@ void AliAnalysisTaskSEDmesonsFilterCJ::UserExec(Option_t *){
       if(!fUseMCInfo || (fUseMCInfo && !isMCBkg)){
         // for data or MC with the requirement fUseReco fill with candidates
         if(fUseReco) {
-           new ((*fCandidateArray)[iCand]) AliAODRecoDecayHF(*charmCand);
-           //Printf("Filling reco");
+           if (fCandidateType==kDstartoKpipi){
+              new ((*fCandidateArray)[iCand]) AliAODRecoCascadeHF(*dstar);
+              AliInfo(Form("Dstar delta mass = %f",dstar->DeltaInvMass()));
+           } else{
+              new ((*fCandidateArray)[iCand]) AliAODRecoDecayHF(*charmCand);
+              //Printf("Filling reco");
+           }               
+           
            hstat->Fill(3);
         }
         // for MC with requirement particle level fill with AliAODMCParticle
@@ -369,7 +389,12 @@ void AliAnalysisTaskSEDmesonsFilterCJ::UserExec(Option_t *){
       }
       //for MC background fill fSideBandArray (which is instead filled above for DStar in case of data for the side bands candidates)
       else if(fUseReco){
-        new ((*fSideBandArray)[iSBCand]) AliAODRecoDecayHF(*charmCand);
+        if (fCandidateType==kDstartoKpipi){
+           new ((*fSideBandArray)[iSBCand]) AliAODRecoCascadeHF(*dstar);
+        }
+        if (fCandidateType==kD0toKpi){
+           new ((*fSideBandArray)[iSBCand]) AliAODRecoDecayHF(*charmCand);
+        }
         iSBCand++;
       }
       
@@ -378,8 +403,7 @@ void AliAnalysisTaskSEDmesonsFilterCJ::UserExec(Option_t *){
       if (fCandidateType==kDstartoKpipi) { //D*->D0pi->Kpipi
         
         //softpion from D* decay
-        AliAODRecoCascadeHF *temp = (AliAODRecoCascadeHF*)charmCand;
-        AliAODTrack *track2 = (AliAODTrack*)temp->GetBachelor();  
+        AliAODTrack *track2 = (AliAODTrack*)dstar->GetBachelor();  
         
         // select D* in the D0 window.
         // In the cut object window is loose to allow for side bands
@@ -396,8 +420,8 @@ void AliAnalysisTaskSEDmesonsFilterCJ::UserExec(Option_t *){
         
         AliInfo(Form("Pt bin %d and sigma D0 %.4f",bin,fSigmaD0[bin]));
         //consider the Dstar candidates only if the mass of the D0 is in 3 sigma wrt the PDG value
-        if ((temp->InvMassD0()>=(mPDGD0-3.*fSigmaD0[bin])) && (temp->InvMassD0()<=(mPDGD0+3.*fSigmaD0[bin]))) {        
-           masses[0] = temp->DeltaInvMass(); //D*
+        if ((dstar->InvMassD0()>=(mPDGD0-3.*fSigmaD0[bin])) && (dstar->InvMassD0()<=(mPDGD0+3.*fSigmaD0[bin]))) {      
+           masses[0] = dstar->DeltaInvMass(); //D*
            masses[1] = 0.; //dummy for D*
            
            //D*  delta mass
@@ -405,7 +429,7 @@ void AliAnalysisTaskSEDmesonsFilterCJ::UserExec(Option_t *){
            
            // D* pt and soft pion pt for good candidates               
            Double_t mPDGDstar = TDatabasePDG::Instance()->GetParticle(413)->Mass();
-           Double_t invmassDelta = temp->DeltaInvMass();
+           Double_t invmassDelta = dstar->DeltaInvMass();
            if (TMath::Abs(invmassDelta-(mPDGDstar-mPDGD0))<0.0021) hPtPion->Fill(track2->Pt());
         }
       } //Dstar specific
@@ -432,7 +456,11 @@ void AliAnalysisTaskSEDmesonsFilterCJ::UserExec(Option_t *){
       hstat->Fill(4,nsbcand);
       hnSBCandEv->Fill(nsbcand);
    }
-   
+   Printf("N candidates selected %d, counter = %d",fCandidateArray->GetEntries(), iCand);
+   PostData(1, fOutput);
+   PostData(3, fCandidateArray);
+   PostData(4, fSideBandArray);
+  
    return;
 }
 
diff --git a/PWGJE/FlavourJetTasks/macros/AddTaskDFilterAndCorrelations.C b/PWGJE/FlavourJetTasks/macros/AddTaskDFilterAndCorrelations.C
new file mode 100644 (file)
index 0000000..1b1667a
--- /dev/null
@@ -0,0 +1,153 @@
+void *AddTaskDFilterAndCorrelations(
+  AliAnalysisTaskSEDmesonsFilterCJ::ECandidateType cand = AliAnalysisTaskSEDmesonsFilterCJ::kDstartoKpipi,
+  TString filename = "DStartoKpipiCuts.root",
+  Bool_t theMCon = kFALSE,
+  Bool_t reco = kTRUE /*must be true if theMCon is false*/,
+  TString suffix = "",
+  TString jetArrname = "",
+  Bool_t triggerOnLeadingJet = kFALSE,
+  Int_t leadingHadType = 0 /*0 = charged, 1 = neutral, 2 = both*/,
+  Float_t R = 0.4,
+  Float_t jptcut = 10.,
+  const char *cutType = "TPC",
+  Double_t percjetareacut = 1.)
+{
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) {
+    ::Error("AddTaskSEDmesonsFilterCJ", "No analysis manager to connect to.");
+    return NULL;
+  } 
+
+  Bool_t useStdC = kFALSE;
+  TFile* filecuts=TFile::Open(filename);
+  if(!filecuts || (filecuts && !filecuts->IsOpen())) {
+    cout<<"Input file not found: use std cuts"<<endl;
+    useStdC = kTRUE;
+  }
+
+  AliRDHFCuts *analysiscuts=0x0;
+  switch (cand) {
+  case 0 :
+    if(useStdC) {
+      analysiscuts = new AliRDHFCutsD0toKpi();
+      analysiscuts->SetStandardCutsPP2010();
+    } else
+      analysiscuts = (AliRDHFCutsD0toKpi*)filecuts->Get("D0toKpiCuts");
+    break;
+  case 1 :
+    if(useStdC) {
+      analysiscuts = new AliRDHFCutsDStartoKpipi();
+      analysiscuts->SetStandardCutsPP2010();
+    } else
+      analysiscuts = (AliRDHFCutsDStartoKpipi*)filecuts->Get("DStartoKpipiCuts");
+    analysiscuts->SetName("DStartoKpipiCuts");
+    break;
+  }
+  
+  if (!analysiscuts) { // mm let's see if everything is ok
+    AliFatal("Specific AliRDHFCuts not found");
+    return;
+  } 
+
+  printf("CREATE TASK\n"); //CREATE THE TASK
+
+  // create the task
+  AliAnalysisTaskSEDmesonsFilterCJ *taskFilter = new AliAnalysisTaskSEDmesonsFilterCJ("AnaTaskSEDmesonsFilterCJ",analysiscuts,cand);
+  if(!theMCon) reco=kTRUE;
+  taskFilter->SetMC(theMCon); //D meson settings
+  taskFilter->SetUseReco(reco);
+  taskFilter->SetName("AliAnalysisTaskSEDmesonsFilterCJ");
+  mgr->AddTask(taskFilter);
+  
+    // create the task
+    
+  AliAnalysisTaskFlavourJetCorrelations *taskCorr = new AliAnalysisTaskFlavourJetCorrelations("AnaTaskFlavourJetCorrelations", 
+     analysiscuts, cand);
+  taskCorr->SetName("AliAnalysisTaskFlavourJetCorrelations");
+  taskCorr->SetJetsName(jetArrname);
+  taskCorr->SetMC(theMCon);
+  taskCorr->SetUseReco(reco);
+  taskCorr->SetTriggerOnLeadingJet(triggerOnLeadingJet);
+  taskCorr->SetJetAcceptanceType(cutType);
+  taskCorr->SetJetPtCut(jptcut);
+  taskCorr->SetPercAreaCut(percjetareacut);
+  
+  mgr->AddTask(taskCorr);
+
+  if(theMCon) {
+     suffix+="MC";
+     if(reco) suffix+="rec";  
+  }
+  
+  TString candname="DStar"; 
+  if(cand==0)  candname="D0";
+  
+  // Create and connect containers for input/output
+  TString outputfile = AliAnalysisManager::GetCommonFileName();
+  TString outputfileF = outputfile, outputfileC = outputfile;
+  outputfileF += ":PWG3_D2H_DmesonsForJetCorrelations";
+  outputfileC += ":PWG3_D2H_DEmcalJet";
+  
+  outputfileF += suffix;
+  outputfileC += suffix;
+
+  TString nameContainerF0="histograms";
+  TString nameContainerF1="cuts";
+  
+  TString nameContainerC0="hCor";
+  TString nameContainerC1="cutsJ";
+
+  TString nameContainerFC2="Dcandidates";
+  TString nameContainerFC3="DSBcandidates";
+
+  nameContainerF0  += candname;
+  nameContainerF1  += candname;
+  nameContainerC0  += candname;
+  nameContainerC1  += candname;
+  nameContainerFC2 += candname;
+  nameContainerFC3 += candname;
+  
+  nameContainerF0  += suffix;
+  nameContainerF1  += suffix;
+  nameContainerC0  += suffix;
+  nameContainerC1  += suffix;
+  nameContainerFC2 += suffix;
+  nameContainerFC3 += suffix;
+  
+
+  // ------ input data ------
+  AliAnalysisDataContainer *cinput0  = mgr->GetCommonInputContainer();
+  
+  // ----- output data -----
+  
+  AliAnalysisDataContainer *coutputF0 = mgr->CreateContainer(nameContainerF0, TList::Class(),AliAnalysisManager::kOutputContainer,outputfileF.Data());
+  
+  AliAnalysisDataContainer *coutputF1 = mgr->CreateContainer(nameContainerF1, AliRDHFCuts::Class(),AliAnalysisManager::kOutputContainer, outputfileF.Data());
+  
+  AliAnalysisDataContainer *coutputC0 = mgr->CreateContainer(nameContainerC0, TList::Class(),AliAnalysisManager::kOutputContainer,outputfileC.Data());
+
+  AliAnalysisDataContainer *coutputC1 = mgr->CreateContainer(nameContainerC1, AliRDHFCuts::Class(),AliAnalysisManager::kOutputContainer, outputfileC.Data());
+  
+  AliAnalysisDataContainer *coutputFC2 = mgr->CreateContainer(nameContainerFC2, TClonesArray::Class(),AliAnalysisManager::kExchangeContainer, outputfileF.Data()); //
+  
+  AliAnalysisDataContainer *coutputFC3 = mgr->CreateContainer(nameContainerFC3, TClonesArray::Class(),AliAnalysisManager::kExchangeContainer, outputfileF.Data()); //
+  
+  mgr->ConnectInput(taskFilter,0,mgr->GetCommonInputContainer());
+  mgr->ConnectInput(taskCorr,0,mgr->GetCommonInputContainer());
+  
+  mgr->ConnectOutput(taskFilter,1,coutputF0);
+  mgr->ConnectOutput(taskFilter,2,coutputF1);
+  mgr->ConnectOutput(taskFilter,3,coutputFC2);
+  mgr->ConnectOutput(taskFilter,4,coutputFC3);
+  
+  
+  mgr->ConnectInput(taskCorr,1,coutputFC2);
+  mgr->ConnectInput(taskCorr,2,coutputFC3);
+  mgr->ConnectOutput(taskCorr,1,coutputC0);
+  mgr->ConnectOutput(taskCorr,2,coutputC1);
+  //if(cand==1) mgr->ConnectOutput(task,4,coutput4);
+
+  Printf("Input and Output connected to the manager");
+  return; 
+}
+
index b004a95..e061de6 100644 (file)
@@ -58,8 +58,8 @@ void AddTasksFlavourJet(const Int_t iCandType = 1 /*0 = D0, 1=Dstar...*/,
    
    // -- D meson selection
   
-   gROOT->LoadMacro("$ALICE_ROOT/PWGJE/FlavourJetTasks/macros/AddTaskSEDmesonsFilterCJ.C");
-   AliAnalysisTaskSEDmesonsFilterCJ *taskDmesonsFilter = AddTaskSEDmesonsFilterCJ(iCandType,sCutFile,bIsMC,bIsReco,sText);
+   gROOT->LoadMacro("AddTaskDFilterAndCorrelationsExch.C");
+
    if(bIsMap) {
       AliAnalysisTaskSEDmesonsFilterCJ *taskMCDmesonsFilter = AddTaskSEDmesonsFilterCJ(iCandType,sCutFile,bIsMC,kFALSE,sText);
    }
@@ -91,7 +91,6 @@ void AddTasksFlavourJet(const Int_t iCandType = 1 /*0 = D0, 1=Dstar...*/,
    gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJet.C");
    //gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskEmcalJetSample.C");
    
-   gROOT->LoadMacro("$ALICE_ROOT/PWGJE/FlavourJetTasks/macros/AddTaskFlavourJetCorrelations.C");
    gROOT->LoadMacro("$ALICE_ROOT/PWGJE/EMCALJetTasks/macros/AddTaskJetResponseMaker.C");
    
    for (Int_t i=0; i<nRadius; i++) {
@@ -108,26 +107,23 @@ void AddTasksFlavourJet(const Int_t iCandType = 1 /*0 = D0, 1=Dstar...*/,
        // "AliAnalysisTaskEmcalJetSample");
       //taskjetsample->SelectCollisionCandidates(uTriggerMask);
       
-      //correlation with D meson
+      //Filter and correlation with D meson
       
-      AliAnalysisTaskFlavourJetCorrelations *taskDmesonCJ = AddTaskFlavourJetCorrelations(
-        iCandType,
+      AddTaskDFilterAndCorrelationsExch(
+        iCandType,
         sCutFile,
         bIsMC,
         bIsReco,
+        "",
         taskFJ->GetName(),
-        Form("JetR%s",sRadius[i].Data()),
+        //Form("JetR%s",sRadius[i].Data()),
         iLeading,
         leadHadType,
         aRadius[i],
         dJetPtCut,
         acctype
-       /*percjetareacut=1.*/);
-      
-      taskDmesonCJ->SetName(Form("AliAnalysisTaskSEEmcalJetDmesonsCJ_%s",sRadius[i].Data()));
-      taskDmesonCJ->SetForceBeamType(uBeamType);
-      taskDmesonCJ->SetAnaType(uAnaType);
-      taskDmesonCJ->SetLeadingHadronType(iLeading);
+       //percjetareacut=1.
+         );
       
       AliEmcalJetTask *taskMCJ;
       //jet reconstruction for correction map