Changes to run also without reading the MC (Chiara B)
authordainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 3 Nov 2009 21:52:13 +0000 (21:52 +0000)
committerdainese <dainese@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 3 Nov 2009 21:52:13 +0000 (21:52 +0000)
PWG3/vertexingHF/AddTaskD0Mass.C
PWG3/vertexingHF/AliAnalysisTaskSED0Mass.cxx
PWG3/vertexingHF/AliAnalysisTaskSED0Mass.h

index feb7297..1e55269 100644 (file)
@@ -1,4 +1,4 @@
-AliAnalysisTaskSED0Mass *AddTaskD0Mass(Int_t flag=0/*0 = D0,1 = LS*/)
+AliAnalysisTaskSED0Mass *AddTaskD0Mass(Int_t flag=0/*0 = D0,1 = LS*/,Bool_t readMC=kTRUE)
 {
   //
   // AddTask for the AliAnalysisTaskSE for D0 candidates
@@ -37,6 +37,7 @@ AliAnalysisTaskSED0Mass *AddTaskD0Mass(Int_t flag=0/*0 = D0,1 = LS*/)
   AliAnalysisTaskSED0Mass *massD0Task = new AliAnalysisTaskSED0Mass("D0MassAndDistrAnalysis");
   massD0Task->SetDebugLevel(0);
   massD0Task->SetArray(flag);
+  massD0Task->SetReadMC(readMC);
   mgr->AddTask(massD0Task);
   
   //
index 532040e..04e2b83 100644 (file)
@@ -58,6 +58,7 @@ fNentries(0),
 fVHFPPR(0),
 fVHFloose(0),
 fArray(0),
+fReadMC(0),
 fLsNormalization(1.)
 
 {
@@ -75,6 +76,7 @@ fNentries(0),
 fVHFPPR(0),
 fVHFloose(0),
 fArray(0),
+fReadMC(0),
 fLsNormalization(1.)
 {
   // Default constructor
@@ -344,20 +346,23 @@ void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
   AliAODVertex *vtx1 = (AliAODVertex*)aod->GetPrimaryVertex();
   //vtx1->Print();
 
-  // load MC particles
-  TClonesArray *mcArray = 
-    (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
-  if(!mcArray) {
-    printf("AliAnalysisTaskSED0Mass::UserExec: MC particles branch not found!\n");
-    return;
-  }
+  TClonesArray *mcArray = 0;
+  AliAODMCHeader *mcHeader = 0;
+
+  if(fReadMC) {
+    // load MC particles
+    mcArray = (TClonesArray*)aod->GetList()->FindObject(AliAODMCParticle::StdBranchName());
+    if(!mcArray) {
+      printf("AliAnalysisTaskSED0Mass::UserExec: MC particles branch not found!\n");
+      return;
+    }
   
-  // load MC header
-  AliAODMCHeader *mcHeader = 
-    (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
-  if(!mcHeader) {
-    printf("AliAnalysisTaskSED0Mass::UserExec: MC header branch not found!\n");
-    return;
+    // load MC header
+    mcHeader = (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
+    if(!mcHeader) {
+      printf("AliAnalysisTaskSED0Mass::UserExec: MC header branch not found!\n");
+      return;
+    }
   }
   
   //printf("VERTEX Z %f %f\n",vtx1->GetZ(),mcHeader->GetVtxZ());
@@ -397,73 +402,75 @@ void AliAnalysisTaskSED0Mass::UserExec(Option_t */*option*/)
     pdgs[0]=321;
     Double_t minvD0bar = d->InvMassD0bar();
     //apply cut on invariant mass on the pair
-    if(TMath::Abs(minvD0-mPDG)<0.03 || TMath::Abs(minvD0bar-mPDG)<0.03){
-      //cout<<"inside mass cut"<<endl;
-      Int_t pdgDgD0toKpi[2]={321,211};
-      Int_t lab=d->MatchToMC(421,mcArray,2,pdgDgD0toKpi); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
-
-      if(lab>=0){ //signal
-       if(fArray==1) cout<<"LS signal: ERROR"<<endl;
-       for (Int_t iprong=0; iprong<2; iprong++){
-         AliAODTrack *prong=(AliAODTrack*)d->GetDaughter(iprong);
-         Int_t labprong=prong->GetLabel();
-
-         //cout<<"prong name = "<<prong->GetName()<<" label = "<<prong->GetLabel()<<endl;
-         AliAODMCParticle *mcprong=0;
-         if(labprong>=0)  mcprong= (AliAODMCParticle*)mcArray->At(labprong);
-         Int_t pdgprong=mcprong->GetPdgCode();
-         if(TMath::Abs(pdgprong)==211) {
-           //cout<<"pi"<<endl;
-           ((TH1F*)fDistr->FindObject("hptpiS"))->Fill(d->PtProng(iprong));
-           ((TH1F*)fDistr->FindObject("hd0piS"))->Fill(d->Getd0Prong(iprong));
-         }
-
-         if(TMath::Abs(pdgprong)==321) {
-           //cout<<"kappa"<<endl;
-           ((TH1F*)fDistr->FindObject("hptKS"))->Fill(d->PtProng(iprong));
-           ((TH1F*)fDistr->FindObject("hd0KS"))->Fill(d->Getd0Prong(iprong));
-         }
-         ((TH1F*)fDistr->FindObject("hdcaS"))->Fill(d->GetDCA());
-
-       }
-
-       if (((AliAODMCParticle*)mcArray->At(lab))->GetPdgCode() == 421)
-         ((TH1F*)fDistr->FindObject("hcosthetastarS"))->Fill(d->CosThetaStarD0());
-       else ((TH1F*)fDistr->FindObject("hcosthetastarS"))->Fill(d->CosThetaStarD0bar());
-
-       ((TH1F*)fDistr->FindObject("hd0d0S"))->Fill(d->Prodd0d0());
-
-       ((TH1F*)fDistr->FindObject("hcosthetapointS"))->Fill(d->CosPointingAngle());
-       ((TH1F*)fDistr->FindObject("hcosthpointd0d0S"))->Fill(d->CosPointingAngle(),d->Prodd0d0());
-
-       //cout<<"ok point"<<endl;
+     if(fReadMC){
+       if(TMath::Abs(minvD0-mPDG)<0.03 || TMath::Abs(minvD0bar-mPDG)<0.03){
+        //cout<<"inside mass cut"<<endl;
+        Int_t pdgDgD0toKpi[2]={321,211};
+        Int_t lab=d->MatchToMC(421,mcArray,2,pdgDgD0toKpi); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
+        if(lab>=0){ //signal
+          if(fArray==1) cout<<"LS signal: ERROR"<<endl;
+          for (Int_t iprong=0; iprong<2; iprong++){
+            AliAODTrack *prong=(AliAODTrack*)d->GetDaughter(iprong);
+            Int_t labprong=prong->GetLabel();
+
+            //cout<<"prong name = "<<prong->GetName()<<" label = "<<prong->GetLabel()<<endl;
+            AliAODMCParticle *mcprong=0;
+            if(labprong>=0)  mcprong= (AliAODMCParticle*)mcArray->At(labprong);
+            Int_t pdgprong=mcprong->GetPdgCode();
+            if(TMath::Abs(pdgprong)==211) {
+              //cout<<"pi"<<endl;
+              ((TH1F*)fDistr->FindObject("hptpiS"))->Fill(d->PtProng(iprong));
+              ((TH1F*)fDistr->FindObject("hd0piS"))->Fill(d->Getd0Prong(iprong));
+            }
+
+            if(TMath::Abs(pdgprong)==321) {
+              //cout<<"kappa"<<endl;
+              ((TH1F*)fDistr->FindObject("hptKS"))->Fill(d->PtProng(iprong));
+              ((TH1F*)fDistr->FindObject("hd0KS"))->Fill(d->Getd0Prong(iprong));
+            }
+            ((TH1F*)fDistr->FindObject("hdcaS"))->Fill(d->GetDCA());
+
+          }
+
+          if (((AliAODMCParticle*)mcArray->At(lab))->GetPdgCode() == 421)
+            ((TH1F*)fDistr->FindObject("hcosthetastarS"))->Fill(d->CosThetaStarD0());
+          else ((TH1F*)fDistr->FindObject("hcosthetastarS"))->Fill(d->CosThetaStarD0bar());
+
+          ((TH1F*)fDistr->FindObject("hd0d0S"))->Fill(d->Prodd0d0());
+
+          ((TH1F*)fDistr->FindObject("hcosthetapointS"))->Fill(d->CosPointingAngle());
+          ((TH1F*)fDistr->FindObject("hcosthpointd0d0S"))->Fill(d->CosPointingAngle(),d->Prodd0d0());
+
+          //cout<<"ok point"<<endl;
 
        
-      } else{ //Background or LS
-       //cout<<"is background"<<endl;
-       AliAODTrack *prong=(AliAODTrack*)d->GetDaughter(0);
-       if(!prong) cout<<"No daughter found";
-       else{
-         if(prong->Charge()==1) {fTotPosPairs[4]++;} else {fTotNegPairs[4]++;}
-       }
-       ((TH1F*)fDistr->FindObject("hptB"))->Fill(d->PtProng(0));
-       //cout<<"ptok"<<endl;
-       ((TH1F*)fDistr->FindObject("hd0B"))->Fill(d->Getd0Prong(0));
-       //cout<<"d0ok"<<endl;
-       ((TH1F*)fDistr->FindObject("hdcaB"))->Fill(d->GetDCA());
-       //cout<<"dcaok"<<endl;
-       ((TH1F*)fDistr->FindObject("hcosthetastarB"))->Fill(d->CosThetaStarD0());
-       ((TH1F*)fDistr->FindObject("hcosthetastarB"))->Fill(d->CosThetaStarD0bar());    
-       ((TH1F*)fDistr->FindObject("hd0d0B"))->Fill(d->Prodd0d0());
-       //cout<<"d0d0ok"<<endl;
-       ((TH1F*)fDistr->FindObject("hcosthetapointB"))->Fill(d->CosPointingAngle());
-       ((TH1F*)fDistr->FindObject("hcosthpointd0d0B"))->Fill(d->CosPointingAngle(),d->Prodd0d0());
-
-       //cout<<"pointok"<<endl;
+        } else{ //Background or LS
+          //cout<<"is background"<<endl;
+          AliAODTrack *prong=(AliAODTrack*)d->GetDaughter(0);
+          if(!prong) cout<<"No daughter found";
+          else{
+            if(prong->Charge()==1) {fTotPosPairs[4]++;} else {fTotNegPairs[4]++;}
+          }
+          ((TH1F*)fDistr->FindObject("hptB"))->Fill(d->PtProng(0));
+          //cout<<"ptok"<<endl;
+          ((TH1F*)fDistr->FindObject("hd0B"))->Fill(d->Getd0Prong(0));
+          //cout<<"d0ok"<<endl;
+          ((TH1F*)fDistr->FindObject("hdcaB"))->Fill(d->GetDCA());
+          //cout<<"dcaok"<<endl;
+          ((TH1F*)fDistr->FindObject("hcosthetastarB"))->Fill(d->CosThetaStarD0());
+          ((TH1F*)fDistr->FindObject("hcosthetastarB"))->Fill(d->CosThetaStarD0bar()); 
+          ((TH1F*)fDistr->FindObject("hd0d0B"))->Fill(d->Prodd0d0());
+          //cout<<"d0d0ok"<<endl;
+          ((TH1F*)fDistr->FindObject("hcosthetapointB"))->Fill(d->CosPointingAngle());
+          ((TH1F*)fDistr->FindObject("hcosthpointd0d0B"))->Fill(d->CosPointingAngle(),d->Prodd0d0());
+
+          //cout<<"pointok"<<endl;
 
-      }
-
-    } //inv mass cut
+      
+        }
+       } //inv mass cut
+     }
   
      //cuts order
 //       printf("    |M-MD0| [GeV]    < %f\n",fD0toKpiCuts[0]);
@@ -554,7 +561,8 @@ void AliAnalysisTaskSED0Mass::FillHists(Int_t ptbin, AliAODRecoDecayHF2Prong *pa
 
     TString fillthis="";
     Int_t pdgDgD0toKpi[2]={321,211};
-    Int_t labD0 = part->MatchToMC(421,arrMC,2,pdgDgD0toKpi); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
+    Int_t labD0=-1;
+    if (fReadMC) labD0 = part->MatchToMC(421,arrMC,2,pdgDgD0toKpi); //return MC particle label if the array corresponds to a D0, -1 if not (cf. AliAODRecoDecay.cxx)
 
     //count candidates selected by cuts
     fNentries->Fill(2);
index f289de2..7e75411 100644 (file)
@@ -38,9 +38,10 @@ class AliAnalysisTaskSED0Mass : public AliAnalysisTaskSE
   virtual void Terminate(Option_t *option);
 
   void SetArray(Int_t type=AliAnalysisTaskSED0Mass::kD0){fArray=type;}
-
   enum{kD0,kLS};
-  
+
+  void SetReadMC(Bool_t readMC=kFALSE){fReadMC=readMC;}
+
  private:
 
   AliAnalysisTaskSED0Mass(const AliAnalysisTaskSED0Mass &source);
@@ -53,6 +54,7 @@ class AliAnalysisTaskSED0Mass : public AliAnalysisTaskSE
   AliAnalysisVertexingHF *fVHFPPR;  // Vertexer heavy flavour (used to pass the cuts)
   AliAnalysisVertexingHF *fVHFloose;  // Vertexer heavy flavour (used to pass the cuts)
   Int_t    fArray;        //   can be D0 or Like Sign candidates
+  Bool_t   fReadMC;       // flag for MC array: kTRUE = read it, kFALSE = do not read it
 
   Int_t    fTotPosPairs[5];     //
   Int_t    fTotNegPairs[5];     //