Added two sets of pt-dep cuts (loose and tight) (Chiara B)
authordainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 16 Jul 2009 16:56:42 +0000 (16:56 +0000)
committerdainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 16 Jul 2009 16:56:42 +0000 (16:56 +0000)
PWG3/vertexingHF/AddTaskD0Mass.C
PWG3/vertexingHF/AliAnalysisTaskSED0Mass.cxx
PWG3/vertexingHF/AliAnalysisTaskSED0Mass.h

index 66d7771..692e3c0 100644 (file)
@@ -26,12 +26,23 @@ AliAnalysisTaskSED0Mass *AddTaskD0Mass()
   // Create containers for input/output
   AliAnalysisDataContainer *cinputmassD0 = mgr->CreateContainer("cinputmassD0",TChain::Class(), 
                                                          AliAnalysisManager::kInputContainer);
-  AliAnalysisDataContainer *coutputmassD0 = mgr->CreateContainer("coutputmassD0",TList::Class(),
+
+  AliAnalysisDataContainer *coutputmassD01 = mgr->CreateContainer("coutputmassD01",TList::Class(),
+                                                          AliAnalysisManager::kOutputContainer, 
+                                                          "D0InvMass.root");
+  AliAnalysisDataContainer *coutputmassD02 = mgr->CreateContainer("coutputmassD02",TList::Class(),
                                                           AliAnalysisManager::kOutputContainer, 
                                                           "D0InvMass.root");
+  AliAnalysisDataContainer *coutputmassD03 = mgr->CreateContainer("coutputmassD03",TH1F::Class(),
+                                                          AliAnalysisManager::kOutputContainer, 
+                                                          "D0InvMass.root");
+
   mgr->ConnectInput(massD0Task,0,mgr->GetCommonInputContainer());
 
-  mgr->ConnectOutput(massD0Task,1,coutputmassD0);
+  mgr->ConnectOutput(massD0Task,1,coutputmassD01);
+  mgr->ConnectOutput(massD0Task,2,coutputmassD02);
+  mgr->ConnectOutput(massD0Task,3,coutputmassD03);
+
 
   return massD0Task;
 }
index 3a73b6f..6950aa9 100644 (file)
@@ -46,8 +46,16 @@ ClassImp(AliAnalysisTaskSED0Mass)
 //________________________________________________________________________
 AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass():
 AliAnalysisTaskSE(),
-fOutput(0), 
-fVHF(0)
+fOutputtight(0),
+fOutputloose(0), 
+//fNtupleD0Cmp(0),
+/*
+fhistMass(0),
+fhistSgn(0),
+fhistBkg(0),
+*/
+fVHFtight(0),
+fVHFloose(0)
 {
   // Default constructor
 }
@@ -55,26 +63,62 @@ fVHF(0)
 //________________________________________________________________________
 AliAnalysisTaskSED0Mass::AliAnalysisTaskSED0Mass(const char *name):
 AliAnalysisTaskSE(name),
-fOutput(0), 
-fVHF(0)
+fOutputtight(0), 
+fOutputloose(0), 
+//fNtupleD0Cmp(0),
+/*
+fhistMass(0),
+fhistSgn(0),
+fhistBkg(0),
+*/
+fVHFtight(0),
+fVHFloose(0)
 {
   // Default constructor
 
   // Output slot #1 writes into a TList container
   DefineOutput(1,TList::Class());  //My private output
+  // Output slot #2 writes into a TList container
+  DefineOutput(2,TList::Class());  //My private output
+  // Output slot #3 writes into a TH1F container
+  DefineOutput(3,TH1F::Class());  //My private output
 }
 
 //________________________________________________________________________
 AliAnalysisTaskSED0Mass::~AliAnalysisTaskSED0Mass()
 {
   // Destructor
-  if (fOutput) {
-    delete fOutput;
-    fOutput = 0;
+  /*
+  if (fhistMass){
+    delete fhistMass;
+    fhistMass=0;
   }
-  if (fVHF) {
-    delete fVHF;
-    fVHF = 0;
+
+  if (fhistSgn){
+    delete fhistSgn;
+    fhistSgn=0;
+  }
+
+  if (fhistBkg){
+    delete fhistBkg;
+    fhistBkg=0;
+  }
+  */
+  if (fOutputtight) {
+    delete fOutputtight;
+    fOutputtight = 0;
+  }
+  if (fVHFtight) {
+    delete fVHFtight;
+    fVHFtight = 0;
+  }
+  if (fOutputloose) {
+    delete fOutputloose;
+    fOutputloose = 0;
+  }
+  if (fVHFloose) {
+    delete fVHFloose;
+    fVHFloose = 0;
   }
 
 }  
@@ -88,11 +132,10 @@ void AliAnalysisTaskSED0Mass::Init()
 
   gROOT->LoadMacro("$ALICE_ROOT/PWG3/vertexingHF/ConfigVertexingHF.C");
 
-  fVHF = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");  
-  // set dedidcated cuts
-  fVHF->SetD0toKpiCuts(0.7,0.03,0.8,0.06,0.06,0.05,0.05,-0.0002,0.6); //2.p-p vertex reconstructed
-  fVHF->PrintStatus();
-
+  // 2 sets of dedidcated cuts -- defined in UserExec
+  fVHFtight = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");
+  fVHFloose = (AliAnalysisVertexingHF*)gROOT->ProcessLine("ConfigVertexingHF()");  
+  
   return;
 }
 
@@ -105,30 +148,72 @@ void AliAnalysisTaskSED0Mass::UserCreateOutputObjects()
   if(fDebug > 1) printf("AnalysisTaskSED0Mass::UserCreateOutputObjects() \n");
 
   // Several histograms are more conveniently managed in a TList
-  fOutput = new TList();
-  fOutput->SetOwner();
+  fOutputtight = new TList();
+  fOutputtight->SetOwner();
+  fOutputtight->SetName("listtight");
+
+  fOutputloose = new TList();
+  fOutputloose->SetOwner();
+  fOutputloose->SetName("listloose");
 
   const Int_t nhist=3;
-  TString nameMass, nameSgn, nameBkg;
+
+  TString nameMass=" ", nameSgn=" ", nameBkg=" ", nameRfl=" ";
 
   for(Int_t i=0;i<nhist;i++){
     nameMass="histMass_";
     nameMass+=i+1;
-    TH1F* tmpM = new TH1F(nameMass.Data(),"D^{0} invariant mass; M [GeV]; Entries",200,1.765,1.965);
     nameSgn="histSgn_";
     nameSgn+=i+1;
-    TH1F* tmpS = new TH1F(nameSgn.Data(), "D^{0} invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
     nameBkg="histBkg_";
     nameBkg+=i+1;
-    TH1F* tmpB = new TH1F(nameBkg.Data(), "Background invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
-    printf("Created histograms %s\t%s\t%s\n",tmpM->GetName(),tmpS->GetName(),tmpB->GetName());
+    nameRfl="histRfl_";
+    nameRfl+=i+1;
 
-    fOutput->Add(tmpM);
-    fOutput->Add(tmpS);
-    fOutput->Add(tmpB);
+    TH1F* tmpM = new TH1F(nameMass.Data(),"D^{0} invariant mass; M [GeV]; Entries",200,1.765,1.965);
+    tmpM->Sumw2();
+
+    TH1F* tmpS = new TH1F(nameSgn.Data(), "D^{0} invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
+    tmpS->Sumw2();
+
+    TH1F* tmpB = new TH1F(nameBkg.Data(), "Background invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
+    tmpB->Sumw2();
+
+    //Reflection: histo filled with D0 which pass the cut (also) as D0bar and with D0bar which pass (also) the cut as D0
+    TH1F* tmpR = new TH1F(nameRfl.Data(), "Reflected signal invariant mass - MC; M [GeV]; Entries",200,1.765,1.965);
+    tmpR->Sumw2();
+
+  /*
+    tmpM->SetName(nameMass);
+    tmpS->SetName(nameSgn);
+    tmpB->SetName(nameBkg);
+    tmpR->SetName(nameRfl);
+  */
+  //  printf("Created histograms %s\t%s\t%s\t%s\n",tmpM->GetName(),tmpS->GetName(),tmpB->GetName(),tmpR->GetName());
+
+    fOutputtight->Add(tmpM);
+    fOutputtight->Add(tmpS);
+    fOutputtight->Add(tmpB);
+    fOutputtight->Add(tmpR);
+
+    fOutputloose->Add(tmpM);
+    fOutputloose->Add(tmpS);
+    fOutputloose->Add(tmpB);
+    fOutputloose->Add(tmpR);
+    
+//   delete tmpM;
+//   delete tmpS;
+//   delete tmpB;
+//   delete tmpR;
 
   }
-  fOutput->ls();
+
+
+  //fOutputloose->ls();
+  //fOutputtight->ls();
+
+  fNentries=new TH1F("nentries", "Look at the number of entries! = number of AODs", 2,1.,2.);
+
   return;
 }
 
@@ -137,7 +222,7 @@ void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
 {
   // Execute analysis for current event:
   // heavy flavor candidates association to MC truth
-  
+  //cout<<"I'm in UserExec"<<endl;
   AliAODEvent *aod = dynamic_cast<AliAODEvent*> (InputEvent());
  
   // load D0->Kpi candidates                                                   
@@ -168,7 +253,10 @@ void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
     return;
   }
   
-  
+
+  //histogram filled with 1 for every AOD
+  fNentries->Fill(1);
+  PostData(3,fNentries);
   // loop over D0->Kpi candidates
   Int_t nInD0toKpi = inputArrayD0toKpi->GetEntriesFast();
   printf("Number of D0->Kpi: %d\n",nInD0toKpi);
@@ -188,29 +276,53 @@ void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
     //       printf(cutsapplied[i]\t);
     //     }
     //    cout<<endl;
-    
+
+    //cuts order
+//       printf("    |M-MD0| [GeV]    < %f\n",fD0toKpiCuts[0]);
+//     printf("    dca    [cm]  < %f\n",fD0toKpiCuts[1]);
+//     printf("    cosThetaStar     < %f\n",fD0toKpiCuts[2]);
+//     printf("    pTK     [GeV/c]    > %f\n",fD0toKpiCuts[3]);
+//     printf("    pTpi    [GeV/c]    > %f\n",fD0toKpiCuts[4]);
+//     printf("    |d0K|  [cm]  < %f\n",fD0toKpiCuts[5]);
+//     printf("    |d0pi| [cm]  < %f\n",fD0toKpiCuts[6]);
+//     printf("    d0d0  [cm^2] < %f\n",fD0toKpiCuts[7]);
+//     printf("    cosThetaPoint    > %f\n",fD0toKpiCuts[8]);
+  
     
     Double_t pt = d->Pt();
     Int_t ptbin=0;
     
     //cout<<"P_t = "<<pt<<endl;
     if (pt>0. && pt<=1.) {
-      ptbin=1; 
+      ptbin=1;
+      fVHFtight->SetD0toKpiCuts(0.7,0.04,0.8,0.5,0.5,0.05,0.05,-0.0002,0.7);
+      fVHFloose->SetD0toKpiCuts(0.7,0.04,0.8,0.5,0.5,1,1,-0.00015,0.5);
       //printf("I'm in the bin %d\n",ptbin);
+      
     }
     else {
       if(pt>1. && pt<=3.) {
        ptbin=2;  
+       fVHFtight->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,0.05,0.05,-0.0002,0.9);
+       fVHFloose->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,1,1,-0.00015,0.8);
        //printf("I'm in the bin %d\n",ptbin);
+       
       }
       else {
        ptbin=3;  
+       fVHFtight->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,0.05,0.05,-0.0001,0.9);
+       fVHFloose->SetD0toKpiCuts(0.7,0.02,0.8,0.7,0.7,0.05,0.05,-0.00005,0.8);
        //printf("I'm in the bin %d\n",ptbin);
+       
       }//if(pt>3)
     }
-    
-    FillHists(ptbin,d,mcArray);
-   
+    //printf("I'm in the bin %d\n",ptbin);
+    //old
+    //fVHF->SetD0toKpiCuts(0.7,0.03,0.8,0.06,0.06,0.05,0.05,-0.0002,0.6); //2.p-p vertex reconstructed    
+
+
+    FillHists(ptbin,d,mcArray,fVHFtight,fOutputtight);
+    FillHists(ptbin,d,mcArray,fVHFloose,fOutputloose);
     if(unsetvtx) d->UnsetOwnPrimaryVtx();
  
   }
@@ -218,72 +330,82 @@ void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
   
    
   // Post the data
-  PostData(1,fOutput);
-
+  PostData(1,fOutputtight);
+  PostData(2,fOutputloose);
 
   return;
 }
 //____________________________________________________________________________*
-void AliAnalysisTaskSED0Mass::FillHists(Int_t ptbin, AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC){
+void AliAnalysisTaskSED0Mass::FillHists(Int_t ptbin, AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliAnalysisVertexingHF *vhf, TList *listout){
   //
   // function used in UserExec:
   //
   Int_t okD0=0,okD0bar=0;
 
-  if(part->SelectD0(fVHF->GetD0toKpiCuts(),okD0,okD0bar)) {//selected
+  if(part->SelectD0(vhf->GetD0toKpiCuts(),okD0,okD0bar)) {//selected
     Double_t invmassD0 = part->InvMassD0(), invmassD0bar = part->InvMassD0bar();
     //printf("SELECTED\n");
     Int_t labD0 = part->MatchToMC(421,arrMC); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
     //printf("labD0 %d",labD0);
+    
+    TString fillthis="";
+    TString fillrfl= "";
 
-    if(labD0>=0) {
-      
-      AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
-
-      Int_t pdgD0 = partD0->GetPdgCode();
-      
-      //printf(" pdgD0 %d\n",pdgD0);
-      TString fillthis="histSgn_";
-      fillthis+=ptbin;
-      cout<<"Filling "<<fillthis<<endl;
-
-      if (pdgD0==421){ //D0
-       //cout<<"Fill S with D0"<<endl;
-       ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(invmassD0);
-       //cout<<"Address "<<fOutput->FindObject(fillthis)<<endl;
-       //cout<<"Name "<<(fOutput->FindObject(fillthis))->GetName()<<endl;
-      }
-      else {//D0bar  
-       //printf("Fill S with D0bar");
-       ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(invmassD0bar);
-      }
-
-    }
-    else {//background
-      TString fillthis="histBkg_";
+    if (okD0==1) {
+      fillthis="histMass_";
       fillthis+=ptbin;
       //cout<<"Filling "<<fillthis<<endl;
 
-         //printf("Fill background");
-      ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(invmassD0);
-      ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(invmassD0bar);
-    }
-    
-    //no MC info, just cut selection
-    TString fillthis="histMass_";
-    fillthis+=ptbin;
-    cout<<"Filling "<<fillthis<<endl;
-    
-    if (okD0==1) {
       //printf("Fill mass with D0");
-      ((TH1F*)(fOutput->FindObject(fillthis)))->Fill(invmassD0);
-      
+      ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
+      if(labD0>=0) {
+       AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
+       Int_t pdgD0 = partD0->GetPdgCode();
+       //cout<<"pdg = "<<pdgD0<<endl;
+       fillthis="histSgn_";
+       fillrfl="histRfl_";
+       fillthis+=ptbin;
+       fillrfl+=ptbin;
+       if (pdgD0==421){ //D0
+         //cout<<"Fill S with D0"<<endl;
+         ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
+
+       } else{ //it was a D0bar
+         ((TH1F*)(listout->FindObject(fillrfl)))->Fill(invmassD0);
+       }
+      } else {//background
+       fillthis="histBkg_";
+       fillthis+=ptbin;
+       ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0);
+      }
     }
     if (okD0bar==1) {
-      ((TH1F*)fOutput->FindObject(fillthis))->Fill(invmassD0bar);
+      fillthis="histMass_";
+      fillthis+=ptbin;
       //printf("Fill mass with D0bar");
-    }
+      ((TH1F*)listout->FindObject(fillthis))->Fill(invmassD0bar);
       
+      if(labD0>=0) {
+       AliAODMCParticle *partD0 = (AliAODMCParticle*)arrMC->At(labD0);
+       Int_t pdgD0 = partD0->GetPdgCode();
+       //cout<<" pdg = "<<pdgD0<<endl;
+       if (pdgD0==-421){ //D0bar
+         fillthis="histSgn_";
+         fillthis+=ptbin;
+         ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
+         
+       } else{
+         ((TH1F*)(listout->FindObject(fillrfl)))->Fill(invmassD0bar);
+         
+       }
+      } else {//background
+       fillthis="histBkg_";
+       fillthis+=ptbin;
+       ((TH1F*)(listout->FindObject(fillthis)))->Fill(invmassD0bar);
+      }
+    }
+
+
   } //else cout<<"NOT SELECTED"<<endl;
 
 }
@@ -294,12 +416,22 @@ void AliAnalysisTaskSED0Mass::Terminate(Option_t */*option*/)
   //
   if(fDebug > 1) printf("AnalysisTaskSED0Mass: Terminate() \n");
 
-  fOutput = dynamic_cast<TList*> (GetOutputData(1));
-  if (!fOutput) {     
+  fOutputtight = dynamic_cast<TList*> (GetOutputData(1));
+  if (!fOutputtight) {     
+    printf("ERROR: fOutput not available\n");
+    return;
+  }
+  fOutputloose = dynamic_cast<TList*> (GetOutputData(2));
+  if (!fOutputloose) {     
     printf("ERROR: fOutput not available\n");
     return;
   }
 
+  /*  
+  fhistMass = dynamic_cast<TClonesArray*>(fOutput->FindObject("fhistMass"));
+  fhistSgn = dynamic_cast<TClonesArray*>(fOutput->FindObject("fhistSgn"));
+  fhistBkg = dynamic_cast<TClonesArray*>(fOutput->FindObject("fhistBkg"));
+  */
   return;
 }
 
index c55e25a..7909da7 100644 (file)
@@ -41,12 +41,18 @@ class AliAnalysisTaskSED0Mass : public AliAnalysisTaskSE
 
   AliAnalysisTaskSED0Mass(const AliAnalysisTaskSED0Mass &source);
   AliAnalysisTaskSED0Mass& operator=(const AliAnalysisTaskSED0Mass& source); 
-  void    FillHists(Int_t ptbin, AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC);
-  TList   *fOutput; //! list send on output slot 0
-
-  AliAnalysisVertexingHF *fVHF;  // Vertexer heavy flavour (used to pass the cuts)
-  
-  ClassDef(AliAnalysisTaskSED0Mass,2); // AliAnalysisTaskSE for the MC association of heavy-flavour decay candidates
+  void    FillHists(Int_t ptbin, AliAODRecoDecayHF2Prong *part, TClonesArray *arrMC, AliAnalysisVertexingHF *vhf, TList *listout);
+  TList   *fOutputtight; //! list send on output slot 1
+  TList   *fOutputloose; //! list send on output slot 2
+  /*
+  TH1F   **fhistMass;  //! invariant mass histograms - no MC truth
+  TH1F   **fhistSgn;   //! signal invariant mass histograms - MC
+  TH1F   **fhistBkg;   //! background invariant mass histograms - MC
+  */
+  AliAnalysisVertexingHF *fVHFtight;  // Vertexer heavy flavour (used to pass the cuts)
+  AliAnalysisVertexingHF *fVHFloose;  // Vertexer heavy flavour (used to pass the cuts)
+  TH1F *fNentries; //! histogram with number of events
+  ClassDef(AliAnalysisTaskSED0Mass,1); // AliAnalysisTaskSE for the MC association of heavy-flavour decay candidates
 };
 
 #endif