]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGHF/vertexingHF/AliAnalysisTaskSELc2V0bachelorTMVA.cxx
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / AliAnalysisTaskSELc2V0bachelorTMVA.cxx
old mode 100644 (file)
new mode 100755 (executable)
index 98f7315..000a1fd
@@ -188,7 +188,10 @@ AliAnalysisTaskSE(),
   fCurrentEvent(-1),
   fBField(0),
   fKeepingOnlyPYTHIABkg(kFALSE),
-  fHistoMCLcK0Sp(0x0)
+  fHistoMCLcK0SpGen(0x0),
+  fHistoMCLcK0SpGenAcc(0x0),
+  fHistoMCLcK0SpGenLimAcc(0x0),
+  fTriggerMask(0)
 {
   //
   // Default ctor
@@ -309,8 +312,10 @@ AliAnalysisTaskSELc2V0bachelorTMVA::AliAnalysisTaskSELc2V0bachelorTMVA(const Cha
   fCurrentEvent(-1),
   fBField(0),
   fKeepingOnlyPYTHIABkg(kFALSE),
-  fHistoMCLcK0Sp(0x0)
-
+  fHistoMCLcK0SpGen(0x0),
+  fHistoMCLcK0SpGenAcc(0x0),
+  fHistoMCLcK0SpGenLimAcc(0x0),
+  fTriggerMask(0)
 {
   //
   // Constructor. Initialization of Inputs and Outputs
@@ -409,7 +414,7 @@ void AliAnalysisTaskSELc2V0bachelorTMVA::Terminate(Option_t*)
   // a query. It always runs on the client, it can be used to present
   // the results graphically or save the results to file.
   
-  //AliInfo("Terminate","");
+  AliInfo("Terminate");
   AliAnalysisTaskSE::Terminate();
   
   fOutput = dynamic_cast<TList*> (GetOutputData(1));
@@ -419,8 +424,25 @@ void AliAnalysisTaskSELc2V0bachelorTMVA::Terminate(Option_t*)
   }
 
   
-  AliDebug(2, Form("At MC level, %f Lc --> K0S + p were found", fHistoMCLcK0Sp->GetEntries()));
-
+  //AliDebug(2, Form("At MC level, %f Lc --> K0S + p were found", fHistoMCLcK0SpGen->GetEntries()));
+  //AliDebug(2, Form("At MC level, %f Lc --> K0S + p were found in the acceptance", fHistoMCLcK0SpGenAcc->GetEntries()));
+  //AliDebug(2, Form("At Reco level, %lld Lc --> K0S + p were found", fVariablesTreeSgn->GetEntries()));
+  if(fHistoMCLcK0SpGen) {
+    AliInfo(Form("At MC level, %f Lc --> K0S + p were found", fHistoMCLcK0SpGen->GetEntries()));
+  } else {
+    AliInfo("fHistoMCLcK0SpGen not available");
+  }
+  if(fHistoMCLcK0SpGenAcc) {
+    AliInfo(Form("At MC level, %f Lc --> K0S + p were found in the acceptance", fHistoMCLcK0SpGenAcc->GetEntries()));
+  } else {
+    AliInfo("fHistoMCLcK0SpGenAcc not available");
+  }
+  if(fVariablesTreeSgn) {
+    AliInfo(Form("At Reco level, %lld Lc --> K0S + p were found", fVariablesTreeSgn->GetEntries()));
+  } else {
+    AliInfo("fVariablesTreeSgn not available");
+  }    
+  
   fOutputKF = dynamic_cast<TList*> (GetOutputData(6));
   if (!fOutputKF) {     
     AliError("fOutputKF not available");
@@ -613,7 +635,9 @@ void AliAnalysisTaskSELc2V0bachelorTMVA::UserCreateOutputObjects() {
 
   const Float_t ptbins[15] = {0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 12., 17., 25., 35.};
 
-  fHistoMCLcK0Sp = new TH1F("fHistoMCLcK0Sp", "fHistoMCLcK0Sp", 14, ptbins);
+  fHistoMCLcK0SpGen = new TH1F("fHistoMCLcK0SpGen", "fHistoMCLcK0SpGen", 14, ptbins);
+  fHistoMCLcK0SpGenAcc = new TH1F("fHistoMCLcK0SpGenAcc", "fHistoMCLcK0SpGenAcc", 14, ptbins);
+  fHistoMCLcK0SpGenLimAcc = new TH1F("fHistoMCLcK0SpGenLimAcc", "fHistoMCLcK0SpGenLimAcc", 14, ptbins);
 
   fOutput->Add(fHistoEvents);
   fOutput->Add(fHistoLc);
@@ -624,7 +648,9 @@ void AliAnalysisTaskSELc2V0bachelorTMVA::UserCreateOutputObjects() {
   fOutput->Add(fHistoCodesBkg);
   fOutput->Add(fHistoLcpKpiBeforeCuts);
   fOutput->Add(fHistoBackground);
-  fOutput->Add(fHistoMCLcK0Sp);
+  fOutput->Add(fHistoMCLcK0SpGen);
+  fOutput->Add(fHistoMCLcK0SpGenAcc);
+  fOutput->Add(fHistoMCLcK0SpGenLimAcc);
 
   PostData(1, fOutput);
   PostData(4, fVariablesTreeSgn);
@@ -865,17 +891,23 @@ void AliAnalysisTaskSELc2V0bachelorTMVA::UserExec(Option_t *)
   
   if ( !fUseMCInfo && fIspA) {
     fAnalCuts->SetTriggerClass("");
-    fAnalCuts->SetTriggerMask(AliVEvent::kINT7);
+    fAnalCuts->SetTriggerMask(fTriggerMask);
   }
-
+  
+  Int_t runnumber = aodEvent->GetRunNumber();
+  if (aodEvent->GetTriggerMask() == 0 && (runnumber >= 195344 && runnumber <= 195677)){
+    AliDebug(3,"Event rejected because of null trigger mask");
+    return;
+  }
+  
   fCounter->StoreEvent(aodEvent,fAnalCuts,fUseMCInfo);
-
+  
   // mc analysis 
   TClonesArray *mcArray = 0;
   AliAODMCHeader *mcHeader=0;
 
   if (fUseMCInfo) {
-    // MC array need for maching
+    // MC array need for matching
     mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
     if (!mcArray) {
       AliError("Could not find Monte-Carlo in AOD");
@@ -887,10 +919,18 @@ void AliAnalysisTaskSELc2V0bachelorTMVA::UserExec(Option_t *)
       AliError("AliAnalysisTaskSELc2V0bachelorTMVA::UserExec: MC header branch not found!\n");
       return;
     }
+
+    Double_t zMCVertex = mcHeader->GetVtxZ();
+    if (TMath::Abs(zMCVertex) > fAnalCuts->GetMaxVtxZ()){
+      AliDebug(3,Form("z coordinate of MC vertex = %f, it was required to be within [-%f, +%f], skipping event", zMCVertex, fAnalCuts->GetMaxVtxZ(), fAnalCuts->GetMaxVtxZ()));
+      AliInfo(Form("z coordinate of MC vertex = %f, it was required to be within [-%f, +%f], skipping event", zMCVertex, fAnalCuts->GetMaxVtxZ(), fAnalCuts->GetMaxVtxZ()));
+      return;
+    }
+    
     //Printf("Filling MC histo");
     FillMCHisto(mcArray);
   }
-
+  
   // AOD primary vertex
   fVtx1 = (AliAODVertex*)aodEvent->GetPrimaryVertex();
   if (!fVtx1) return;
@@ -931,7 +971,6 @@ void AliAnalysisTaskSELc2V0bachelorTMVA::FillMCHisto(TClonesArray *mcArray){
     AliAODMCParticle* mcPart = dynamic_cast<AliAODMCParticle*>(mcArray->At(iPart));
     if (!mcPart){
       AliError("Failed casting particle from MC array!, Skipping particle");
-      AliInfo("Failed casting particle from MC array!, Skipping particle");
       continue;
     }
     Int_t pdg = mcPart->GetPdgCode();
@@ -950,16 +989,20 @@ void AliAnalysisTaskSELc2V0bachelorTMVA::FillMCHisto(TClonesArray *mcArray){
       AliDebug(2, Form("Step 1 ok: The MC particle has correct daughters!!"));
       AliAODMCParticle* daugh0 = dynamic_cast<AliAODMCParticle*>(mcArray->At(labeldaugh0));
       AliAODMCParticle* daugh1 = dynamic_cast<AliAODMCParticle*>(mcArray->At(labeldaugh1));
+      if(!daugh0 || !daugh1){
+       AliDebug(2,"Particle daughters not properly retrieved!");
+       return;
+      }
       Int_t pdgCodeDaugh0 = TMath::Abs(daugh0->GetPdgCode());
       Int_t pdgCodeDaugh1 = TMath::Abs(daugh1->GetPdgCode());
-      //      AliAODMCParticle* bachelorMC = daugh0;
+      AliAODMCParticle* bachelorMC = daugh0;
       AliAODMCParticle* v0MC = daugh1;
       AliDebug(2, Form("pdgCodeDaugh0 = %d, pdgCodeDaugh1 = %d", pdgCodeDaugh0, pdgCodeDaugh1));
       if ((pdgCodeDaugh0 == 311 && pdgCodeDaugh1 == 2212) || (pdgCodeDaugh0 == 2212 && pdgCodeDaugh1 == 311)){ 
        // we are in the case of Lc --> K0 + p; now we have to check if the K0 decays in K0S, and if this goes in pi+pi-
        /// first, we set the bachelor and the v0: above we assumed first proton and second V0, but we could have to change it:
        if (pdgCodeDaugh0 == 311 && pdgCodeDaugh1 == 2212) {
-         // bachelorMC = daugh1;
+         bachelorMC = daugh1;
          v0MC = daugh0;
        }
        AliDebug(2, Form("Number of Daughters of v0 = %d", v0MC->GetNDaughters()));
@@ -973,7 +1016,6 @@ void AliAnalysisTaskSELc2V0bachelorTMVA::FillMCHisto(TClonesArray *mcArray){
          AliAODMCParticle* partK0S = dynamic_cast<AliAODMCParticle*>(mcArray->At(labelK0daugh));
          if(!partK0S){
            AliError("Error while casting particle! returning a NULL array");
-           AliInfo("Error while casting particle! returning a NULL array");
            continue;
          }
          else { // So far: Lc --> K0 + p, K0 with 1 daughter that we can access
@@ -1002,7 +1044,14 @@ void AliAnalysisTaskSELc2V0bachelorTMVA::FillMCHisto(TClonesArray *mcArray){
                else { // Full chain: Lc --> K0 + p, K0 --> K0S, K0S --> pi+pi-
                  if (fAnalCuts->IsInFiducialAcceptance(mcPart->Pt(), mcPart->Y())) {
                    AliDebug(2, Form("----> Filling histo with pt = %f", mcPart->Pt()));
-                   fHistoMCLcK0Sp->Fill(mcPart->Pt());
+                   if(TMath::Abs(mcPart->Y()) < 0.5) fHistoMCLcK0SpGenLimAcc->Fill(mcPart->Pt());
+                   //AliInfo(Form("\nparticle = %d, Filling MC Gen histo\n", iPart));
+                   fHistoMCLcK0SpGen->Fill(mcPart->Pt());
+                   if(!(TMath::Abs(bachelorMC->Eta()) > 0.9 || bachelorMC->Pt() < 0.1 ||
+                        TMath::Abs(daughK0S0->Eta()) > 0.9 || daughK0S0->Pt() < 0.1 ||
+                        TMath::Abs(daughK0S1->Eta()) > 0.9 || daughK0S1->Pt() < 0.1)) {
+                     fHistoMCLcK0SpGenAcc->Fill(mcPart->Pt());
+                   }
                  }
                  else {
                    AliDebug(2, "not in fiducial acceptance! Skipping");
@@ -1229,7 +1278,7 @@ void AliAnalysisTaskSELc2V0bachelorTMVA::MakeAnalysisForLc2prK0S(TClonesArray *a
       }
     }
 
-    FillLc2pK0Sspectrum(lcK0spr, isLc, nSelectedAnal, cutsAnal, mcArray);
+    FillLc2pK0Sspectrum(lcK0spr, isLc, nSelectedAnal, cutsAnal, mcArray, iLctopK0s);
     
   }
   
@@ -1241,7 +1290,7 @@ void AliAnalysisTaskSELc2V0bachelorTMVA::FillLc2pK0Sspectrum(AliAODRecoCascadeHF
                                                             Int_t isLc,
                                                             Int_t &nSelectedAnal,
                                                             AliRDHFCutsLctoV0 *cutsAnal,
-                                                            TClonesArray *mcArray){
+                                                            TClonesArray *mcArray, Int_t iLctopK0s){
   //
   // Fill histos for Lc -> K0S+proton
   //
@@ -1299,8 +1348,8 @@ void AliAnalysisTaskSELc2V0bachelorTMVA::FillLc2pK0Sspectrum(AliAODRecoCascadeHF
   Int_t isInV0window = (((cutsAnal->IsSelectedSingleCut(part, AliRDHFCuts::kCandidate, 2)) & (AliRDHFCutsLctoV0::kLcToK0Spr)) == (AliRDHFCutsLctoV0::kLcToK0Spr)); // cut on V0 invMass
 
   if (isInV0window == 0) {
-    AliDebug(2, "No: The candidate has NOT passed the mass cuts!");
-    if (isLc) Printf("SIGNAL candidate rejected");
+    AliDebug(2, "No: The candidate has NOT passed the V0 window cuts!");
+    if (isLc) Printf("SIGNAL candidate rejected: V0 window cuts");
     return;           
   }
   else AliDebug(2, "Yes: The candidate has passed the mass cuts!");
@@ -1309,12 +1358,13 @@ void AliAnalysisTaskSELc2V0bachelorTMVA::FillLc2pK0Sspectrum(AliAODRecoCascadeHF
 
   if (!isInCascadeWindow) {
     AliDebug(2, "No: The candidate has NOT passed the cascade window cuts!");
-    if (isLc) Printf("SIGNAL candidate rejected");
+    if (isLc) Printf("SIGNAL candidate rejected: cascade window cuts");
     return;
   }
   else AliDebug(2, "Yes: The candidate has passed the cascade window cuts!");
 
   Bool_t isCandidateSelectedCuts = (((cutsAnal->IsSelected(part, AliRDHFCuts::kCandidate)) & (AliRDHFCutsLctoV0::kLcToK0Spr)) == (AliRDHFCutsLctoV0::kLcToK0Spr)); // kinematic/topological cuts
+  AliDebug(2, Form("recoAnalysisCuts = %d", cutsAnal->IsSelected(part, AliRDHFCuts::kCandidate) & (AliRDHFCutsLctoV0::kLcToK0Spr)));
   if (!isCandidateSelectedCuts){
     AliDebug(2, "No: Analysis cuts kCandidate level NOT passed");
     if (isLc) Printf("SIGNAL candidate rejected");
@@ -1653,7 +1703,7 @@ void AliAnalysisTaskSELc2V0bachelorTMVA::FillLc2pK0Sspectrum(AliAODRecoCascadeHF
 
     if (fUseMCInfo) {
       if (isLc){
-       AliDebug(2, "Filling Sgn");
+       AliDebug(2, Form("Reco particle %d --> Filling Sgn", iLctopK0s));
        fVariablesTreeSgn->Fill();
        fHistoCodesSgn->Fill(bachCode, k0SCode);          
       }