changes to run also on AOD MC
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Nov 2009 12:59:53 +0000 (12:59 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 20 Nov 2009 12:59:53 +0000 (12:59 +0000)
PWG4/JetTasks/AliAnalysisHelperJetTasks.cxx
PWG4/JetTasks/AliAnalysisTaskJetCorrections.cxx
PWG4/JetTasks/AliAnalysisTaskThreeJets.cxx

index c6866df..0823516 100644 (file)
@@ -528,7 +528,7 @@ Bool_t AliAnalysisHelperJetTasks::GetEventShapes(TVector3 &n01, TVector3 * pTrac
       if(switch2 == 0 && switch1 == 0 && switch3 == 0){
        if(TMath::Abs(th-th02) < 10e-7 && TMath::Abs(th-th03) < 10e-7 && TMath::Abs(th02-th03) < 10e-7){
          eventShapes[0] = th;
-         Printf("===== THRUST VALUE FOUND AT %d :: %f\n", k, th);
+         AliInfoGeneral(Form(" %s:%d",(char*)__FILE__,__LINE__),Form("===== THRUST VALUE FOUND AT %d :: %f\n", k, th));
          break;
        }
        //if they did not, reset switches
index f418942..686226c 100644 (file)
@@ -38,7 +38,7 @@
 #include "AliAODHandler.h"
 #include "AliAODTrack.h"
 #include "AliAODJet.h"
-#include "AliMCEvent.h"
+//#include "AliMCEvent.h"
 
 #include "AliAnalysisHelperJetTasks.h"
 
@@ -186,42 +186,29 @@ Bool_t AliAnalysisTaskJetCorrections::Notify()
   // Implemented Notify() to read the cross sections
   // and number of trials from pyxsec.root
   // 
+
+
   TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
-  UInt_t   ntrials  = 0;
+  Float_t xsection = 0;
+  Float_t ftrials  = 1;
+
+  Float_t fAvgTrials = 1;
   if(tree){
     TFile *curfile = tree->GetCurrentFile();
     if (!curfile) {
       Error("Notify","No current file");
       return kFALSE;
     }
+    AliAnalysisHelperJetTasks::PythiaInfoFromFile(curfile->GetName(),xsection,ftrials);
+    // construct a poor man average trials 
+    Float_t nEntries = (Float_t)tree->GetTree()->GetEntries();
+    if(ftrials>=nEntries)fAvgTrials = ftrials/nEntries; // CKB take this into account for normalisation
+  }  
+
+  if(xsection>0)fXsection  = xsection;
 
-    TString fileName(curfile->GetName());
-    if(fileName.Contains("AliESDs.root")){
-        fileName.ReplaceAll("AliESDs.root", "pyxsec.root");
-    }
-    else if(fileName.Contains("AliAOD.root")){
-        fileName.ReplaceAll("AliAOD.root", "pyxsec.root");
-    }
-    else if(fileName.Contains("galice.root")){
-        // for running with galice and kinematics alone...                      
-        fileName.ReplaceAll("galice.root", "pyxsec.root");
-    }
-    TFile *fxsec = TFile::Open(fileName.Data());
-    if(!fxsec){
-      Printf("%s:%d %s not found in the Input",(char*)__FILE__,__LINE__,fileName.Data());
-      // no a severe condition
-      return kTRUE;
-    }
-    TTree *xtree = (TTree*)fxsec->Get("Xsection");
-    if(!xtree){
-      Printf("%s:%d tree not found in the pyxsec.root",(char*)__FILE__,__LINE__);
-    }
-    xtree->SetBranchAddress("xsection",&fXsection);
-    xtree->SetBranchAddress("ntrials",&ntrials);
-    xtree->GetEntry(0);
-  }
-  
   return kTRUE;
+
 }
 
 
@@ -447,11 +434,11 @@ void AliAnalysisTaskJetCorrections::UserExec(Option_t * )
       return;
     }
   
-  AliMCEvent* mcEvent =MCEvent();
-  if(!mcEvent){
-    Printf("%s:%d no mcEvent",(char*)__FILE__,__LINE__);
-    return;
-  }
+//   AliMCEvent* mcEvent =MCEvent();
+//   if(!mcEvent){
+//     Printf("%s:%d no mcEvent",(char*)__FILE__,__LINE__);
+//     return;
+//   }
   
   if (fDebug > 10)Printf("%s:%d",(char*)__FILE__,__LINE__);
 
@@ -959,7 +946,7 @@ void AliAnalysisTaskJetCorrections::UserExec(Option_t * )
 //__________________________________________________________________________________________________________________________________________________
 void AliAnalysisTaskJetCorrections::Terminate(Option_t *)
 {
-  printf("AnalysisJetCorrelation::Terminate()");
+  printf("AnalysisJetCorrections::Terminate()");
 
 } 
 
index 1a2c9ed..2cb485c 100644 (file)
 #include "AliAODHandler.h"
 #include "AliAODTrack.h"
 #include "AliAODJet.h"
-#include "AliGenPythiaEventHeader.h"
-#include "AliMCEvent.h"
-#include "AliStack.h"
+#include "AliAODMCParticle.h"
+//#include "AliGenPythiaEventHeader.h"
+//#include "AliMCEvent.h"
+//#include "AliStack.h"
 
 
 #include "AliAnalysisHelperJetTasks.h"
@@ -464,11 +465,11 @@ void AliAnalysisTaskThreeJets::UserExec(Option_t * )
     }    
   }
 
-  AliMCEvent* mcEvent =MCEvent();
-  if(!mcEvent){
-    Printf("%s:%d no mcEvent",(char*)__FILE__,__LINE__);
-    return;
-  }
+//   AliMCEvent* mcEvent =MCEvent();
+//   if(!mcEvent){
+//     Printf("%s:%d no mcEvent",(char*)__FILE__,__LINE__);
+//     return;
+//   }
   
   if (fDebug > 10)Printf("%s:%d",(char*)__FILE__,__LINE__);
   
@@ -477,9 +478,10 @@ void AliAnalysisTaskThreeJets::UserExec(Option_t * )
   if(!pvtx){
     if (fDebug > 1)     Printf("%s:%d AOD Vertex found",(char*)__FILE__,__LINE__);
     return;
-  }  
-  AliAODJet genJetsPythia[kMaxJets];
-  Int_t nPythiaGenJets = 0;
+  }
+  
+//   AliAODJet genJetsPythia[kMaxJets];
+//   Int_t nPythiaGenJets = 0;
   
   AliAODJet genJets[kMaxJets];
   Int_t nGenJets = 0;
@@ -525,18 +527,19 @@ void AliAnalysisTaskThreeJets::UserExec(Option_t * )
       genJets[ig] = * tmp;
     }
   
-  AliGenPythiaEventHeader*  pythiaGenHeader = AliAnalysisHelperJetTasks::GetPythiaEventHeader(mcEvent);
-  if(!pythiaGenHeader){
-    Printf("!!!NO GEN HEADER AVALABLE!!!");
-    return;
-  }
+//   AliGenPythiaEventHeader*  pythiaGenHeader = AliAnalysisHelperJetTasks::GetPythiaEventHeader(mcEvent);
+//   if(!pythiaGenHeader){
+//     Printf("!!!NO GEN HEADER AVALABLE!!!");
+//     return;
+//   }
   
-  // Int_t ProcessType = pythiaGenHeader->ProcessType();
-  // if(ProcessType != 28) return;
-  fhXSec->Fill(pythiaGenHeader->GetPtHard(), fXsection);
-  nPythiaGenJets = pythiaGenHeader->NTriggerJets();
-  nPythiaGenJets = TMath::Min(nPythiaGenJets, kMaxJets);
+//   // Int_t ProcessType = pythiaGenHeader->ProcessType();
+//   // if(ProcessType != 28) return;
+//   nPythiaGenJets = pythiaGenHeader->NTriggerJets();
+//   nPythiaGenJets = TMath::Min(nPythiaGenJets, kMaxJets);
    
+//  fXsection = 1;
+
   Double_t eRec[kMaxJets];
   Double_t eGen[kMaxJets];
  
@@ -574,15 +577,15 @@ void AliAnalysisTaskThreeJets::UserExec(Option_t * )
 
   Double_t psumRestRec = 0;
   //  Double_t psumRestGen = 0;
-  //Pythia_________________________________________________________________________________________________________________
-
-  for(int ip = 0;ip < nPythiaGenJets;++ip)
-    {
-      if(ip>=kMaxJets)continue;
-      Float_t p[4];
-      pythiaGenHeader->TriggerJet(ip,p);
-      genJetsPythia[ip].SetPxPyPzE(p[0],p[1],p[2],p[3]);
-    }
+//   //Pythia_________________________________________________________________________________________________________________
+
+//   for(int ip = 0;ip < nPythiaGenJets;++ip)
+//     {
+//       if(ip>=kMaxJets)continue;
+//       Float_t p[4];
+//       pythiaGenHeader->TriggerJet(ip,p);
+//       genJetsPythia[ip].SetPxPyPzE(p[0],p[1],p[2],p[3]);
+//     }
   
 //_________________________________________________________________________________________________________________________
  
@@ -638,8 +641,14 @@ void AliAnalysisTaskThreeJets::UserExec(Option_t * )
     {
       jetGen[ig] = selJets[idxGen[ig]];
     }
-  AliStack * stack = mcEvent->Stack();
-  Int_t nMCtracks = stack->GetNprimary();
+
+  fhXSec->Fill(jetGen[0].Pt(), fXsection);
+
+//  AliStack * stack = mcEvent->Stack();
+
+  TClonesArray *tca = dynamic_cast<TClonesArray*>(fAOD->FindListObject(AliAODMCParticle::StdBranchName()));
+  if(!tca) return;
+  Int_t nMCtracks = tca->GetEntries();
   Double_t * eTracksMC = new Double_t[kTracks];
   Double_t pTracksMC[kTracks];
   Int_t * idxTracksMC = new Int_t[kTracks];
@@ -659,12 +668,13 @@ void AliAnalysisTaskThreeJets::UserExec(Option_t * )
 
   for(Int_t iTrack = 0; iTrack < nMCtracks; iTrack++)
     {
-      TParticle * part = (TParticle*)stack->Particle(iTrack);
+      //      TParticle * part = (TParticle*)stack->Particle(iTrack);
+      AliAODMCParticle *part = dynamic_cast<AliAODMCParticle*>(tca->At(iTrack));
       if (!part) continue;
+      if(!part->IsPhysicalPrimary())continue;      
       Double_t fEta = part->Eta();
       if(TMath::Abs(fEta) > .9) continue;
-      if(!IsPrimChar(part, nMCtracks, 0)) continue;
-      vTrackMCAll[nAllTracksMC].SetPxPyPzE(part->Px(), part->Py(), part->Pz(), part->Energy());
+      vTrackMCAll[nAllTracksMC].SetPxPyPzE(part->Px(), part->Py(), part->Pz(), part->E());
       pTrackMCAll[nAllTracksMC] = part->Pt();
       nAllTracksMC++;
     }