]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Changes by Sara V. to UE class, and one cosmetic change in Spectrum task
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 16 Nov 2009 07:11:07 +0000 (07:11 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 16 Nov 2009 07:11:07 +0000 (07:11 +0000)
PWG4/JetTasks/AliAnalysisTaskJetSpectrum.cxx
PWG4/JetTasks/AliAnalysisTaskUE.cxx
PWG4/JetTasks/AliAnalysisTaskUE.h

index a875d99b3ab4201dbdc6101976e21fa8b49068e6..b273deb738dac8236f41c6ff9c5f444a16a07866 100644 (file)
@@ -513,20 +513,8 @@ void AliAnalysisTaskJetSpectrum::UserExec(Option_t */*option*/)
     return;
   }
 
-
-  //  aodH->SelectEvent(kTRUE);
-
-  // ========= These pointers need to be valid in any case ======= 
-
-
-  /*
-  AliUA1JetHeaderV1 *jhRec = dynamic_cast<AliUA1JetHeaderV1*>(fJetFinderRec->GetHeader());
-  if(!jhRec){
-    Printf("%s:%d No Jet Header found",(char*)__FILE__,__LINE__);
-    return;
-  }
-  */
   if (fDebug > 10)Printf("%s:%d",(char*)__FILE__,__LINE__);
+
   TClonesArray *aodRecJets = dynamic_cast<TClonesArray*>(fAOD->FindListObject(fBranchRec.Data()));
   if(!aodRecJets){
     Printf("%s:%d no reconstructed Jet array with name %s in AOD",(char*)__FILE__,__LINE__,fBranchRec.Data());
index 73770fb0c135eabc0265d22965a5646b0733494c..eafee42ce0f374f8006a7d182fa9b723fbf4a2ed 100644 (file)
@@ -78,9 +78,15 @@ ClassImp( AliAnalysisTaskUE)
 //____________________________________________________________________
 AliAnalysisTaskUE:: AliAnalysisTaskUE(const char* name):
 AliAnalysisTask(name, ""),
-fDebug(kFALSE),          
+fDebug(kFALSE),
+fDeltaAOD(kFALSE),
+fDeltaAODBranch(""),
+  fArrayJets(0x0),           
 fAOD(0x0),            
 fAODjets(0x0),
+//fArrayJets(0x0),
+//fDeltaAOD(kFALSE),
+//fDeltaAODBranch("jetsAOD"),
 fListOfHistos(0x0),  
 fBinsPtInHist(30),     
 fMinJetPtInHist(0.),
@@ -108,7 +114,7 @@ fJet2RatioPtCut(0.8),
 fJet3PtCut(15.),
 fTrackPtCut(0.),
 fTrackEtaCut(0.9),
-  fAvgTrials(1),
+fAvgTrials(1),
 fhNJets(0x0),
 fhEleadingPt(0x0),
 fhMinRegPtDist(0x0),
@@ -149,8 +155,6 @@ Bool_t AliAnalysisTaskUE::Notify()
   // Implemented Notify() to read the cross sections
   // and number of trials from pyxsec.root
   // Copy from AliAnalysisTaskJFSystematics
-  // 
-
   fAvgTrials = 1;
   TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
   Float_t xsection = 0;
@@ -165,12 +169,13 @@ Bool_t AliAnalysisTaskUE::Notify()
       Printf("%s%d No Histogram fh1Xsec",(char*)__FILE__,__LINE__);
       return kFALSE;
     }
-    AliAnalysisHelperJetTasks::PythiaInfoFromFile(curfile->GetName(),xsection,ftrials);
+    AliAnalysisHelperJetTasks::PythiaInfoFromFile(curfile->GetName(),xsection,ftrials); 
     fh1Xsec->Fill("<#sigma>",xsection);
-    // construct average trials 
-    Float_t nEntries = (Float_t)tree->GetTree()->GetEntries();
-    if(ftrials>=nEntries)fAvgTrials = ftrials/nEntries; 
-  }  
+   // construct average trials
+   Float_t nEntries = (Float_t)tree->GetTree()->GetEntries();
+   if(ftrials>=nEntries)fAvgTrials = ftrials/nEntries;
+  }
+  
   return kTRUE;
 }
 
@@ -184,33 +189,36 @@ void AliAnalysisTaskUE::ConnectInputData(Option_t* /*option*/)
   // or to the OutputEventHandler ( AOD is create by a previus task in the train )
   // we need to check where it is and get the pointer to AODEvent in the right way
   
-  if (fDebug > 1) AliInfo("ConnectInputData() \n");
+  // Delta AODs are also implemented
+  
+  if (fDebug > 1) AliInfo("ConnectInputData() ");
   
   TObject* handler = AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler();
   
-  if( handler && handler->InheritsFrom("AliAODInputHandler") ) {
-    fAOD  =  ((AliAODInputHandler*)handler)->GetEvent();
-    if (fDebug > 1) AliInfo("  ==== Tracks from AliAODInputHandler");
-    // Case when jets are reconstructed on the fly from AOD tracks
-    // (the Jet Finder is using the AliJetAODReader) of InputEventHandler
-    // and put in the OutputEventHandler AOD. Useful whe you want to reconstruct jets with
-    // different parameters to default ones stored in the AOD or to use a different algorithm
-    if( fJetsOnFly ) {
-      handler = AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler();
-      if( handler && handler->InheritsFrom("AliAODHandler") ) {
-        fAODjets = ((AliAODHandler*)handler)->GetAOD();
-        if (fDebug > 1) AliInfo("  ==== Jets from AliAODHandler");
-      }
-    } else {
-      fAODjets = fAOD;
-      if (fDebug > 1) AliInfo("  ==== Jets from AliAODInputHandler");
-    }
-  } else {
+  if( handler && handler->InheritsFrom("AliAODInputHandler") ) { // input AOD
+    fAOD = ((AliAODInputHandler*)handler)->GetEvent();
+    if (fDebug > 1) AliInfo(" ==== Tracks from AliAODInputHandler");
+       // Case when jets are reconstructed on the fly from AOD tracks
+       // (the Jet Finder is using the AliJetAODReader) of InputEventHandler
+       // and put in the OutputEventHandler AOD. Useful whe you want to reconstruct jets with
+       // different parameters to default ones stored in the AOD or to use a different algorithm
+       if( fJetsOnFly ) {
+       handler = AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler();
+       if( handler && handler->InheritsFrom("AliAODHandler") ) {
+               fAODjets = ((AliAODHandler*)handler)->GetAOD();
+               if (fDebug > 1) AliInfo(" ==== Jets from AliAODHandler (on the fly)");
+       }
+        } else {
+       fAODjets = fAOD;
+       if (fDebug > 1) AliInfo(" ==== Jets from AliAODInputHandler");
+        }
+  } else {  //output AOD
     handler = AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler();
     if( handler && handler->InheritsFrom("AliAODHandler") ) {
-      fAOD  = ((AliAODHandler*)handler)->GetAOD();
+      fAOD = ((AliAODHandler*)handler)->GetAOD();
       fAODjets = fAOD;
-      if (fDebug > 1) AliInfo("  ==== Tracks and Jets from AliAODHandler");
+      if (fDebug > 1) AliInfo(" ==== Tracks and Jets from AliAODHandler");
     } else {
       AliFatal("I can't get any AOD Event Handler");
       return;
@@ -241,24 +249,20 @@ void  AliAnalysisTaskUE::Exec(Option_t */*option*/)
   // Execute analysis for current event
   //
   if ( fDebug > 3 ) AliInfo( " Processing event..." );
-
   // fetch the pythia header info and get the trials
   AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
   Float_t nTrials = 1;
-  if (mcHandler) {  
-    AliMCEvent* mcEvent = mcHandler->MCEvent();
-    if (mcEvent) {
-      AliGenPythiaEventHeader*  pythiaGenHeader = AliAnalysisHelperJetTasks::GetPythiaEventHeader(mcEvent);
-      if(pythiaGenHeader){
-       nTrials = pythiaGenHeader->Trials();
+  if (mcHandler) {
+       AliMCEvent* mcEvent = mcHandler->MCEvent();
+       if (mcEvent) {
+         AliGenPythiaEventHeader*  pythiaGenHeader = AliAnalysisHelperJetTasks::GetPythiaEventHeader(mcEvent);
+         if(pythiaGenHeader){
+           nTrials = pythiaGenHeader->Trials();
+         }
       }
     }
-  }
-
-  fh1Trials->Fill("#sum{ntrials}",fAvgTrials); 
-    
-
-  AnalyseUE();
+ fh1Trials->Fill("#sum{ntrials}",fAvgTrials);
+ AnalyseUE();
   
   // Post the data
   PostData(0, fListOfHistos);
@@ -284,36 +288,71 @@ void  AliAnalysisTaskUE::AnalyseUE()
   TVector3 jetVect[3];
   Int_t nJets = 0;
   
+  
   if( !fUseChPartJet ) {
     
     // Use AOD Jets
-    nJets = fAODjets->GetNJets();
-    //  printf("AOD %d jets \n", nJets);
+    if(fDeltaAOD){
+      if (fDebug > 1) AliInfo(" ==== Jets From  Delta-AODs !");
+      if (fDebug > 1) AliInfo(Form(" ====  Reading Branch: %s  ",fDeltaAODBranch.Data()));
+       fArrayJets =
+         (TClonesArray*)fAODjets->GetList()->FindObject(fDeltaAODBranch.Data());
+       if (!fArrayJets){
+               AliFatal(" No jet-array! ");
+               return;
+       }
+       nJets=fArrayJets->GetEntries();
+    }else{
+      if (fDebug > 1) AliInfo(" ==== Read Standard-AODs !");
+      nJets = fAODjets->GetNJets();
+    }
+    //printf("AOD %d jets \n", nJets);
+
     for( Int_t i=0; i<nJets; ++i ) {
-      AliAODJet* jet = fAODjets->GetJet(i);
-      Double_t jetPt = jet->Pt();//*1.666;  // FIXME Jet Pt Correction ?????!!!
+       AliAODJet* jet;
+      if (fDeltaAOD){
+      jet =(AliAODJet*)fArrayJets->At(i);
+      }else{
+      jet = fAODjets->GetJet(i);
+      }
+      Double_t jetPt = jet->Pt();//*1.666; // FIXME Jet Pt Correction ?????!!!
       if( jetPt > maxPtJet1 ) {
-        maxPtJet3 = maxPtJet2; index3 = index2;
-        maxPtJet2 = maxPtJet1; index2 = index1;
-        maxPtJet1 = jetPt; index1 = i;
+       maxPtJet3 = maxPtJet2; index3 = index2;
+       maxPtJet2 = maxPtJet1; index2 = index1;
+       maxPtJet1 = jetPt; index1 = i;
       } else if( jetPt > maxPtJet2 ) {
-        maxPtJet3 = maxPtJet2; index3 = index2;
-        maxPtJet2 = jetPt; index2 = i;
+       maxPtJet3 = maxPtJet2; index3 = index2;
+       maxPtJet2 = jetPt; index2 = i;
       } else if( jetPt > maxPtJet3 ) {
-        maxPtJet3 = jetPt; index3 = i;
+       maxPtJet3 = jetPt; index3 = i;
       }
     }
     if( index1 != -1 ) {
-      AliAODJet* jet = fAODjets->GetJet(index1);
+      AliAODJet *jet = 0;
+      if (fDeltaAOD) {
+       jet =(AliAODJet*) fArrayJets->At(index1);
+      }else{
+       jet = fAODjets->GetJet(index1);
+      }
       jetVect[0].SetXYZ(jet->Px(), jet->Py(), jet->Pz());
     }
     if( index2 != -1 ) {
-      AliAODJet* jet = fAODjets->GetJet(index2);
+      AliAODJet* jet = 0;
+      if (fDeltaAOD) {
+       jet= (AliAODJet*) fArrayJets->At(index2);
+       }else{
+       jet= fAODjets->GetJet(index2);
+       }
       jetVect[1].SetXYZ(jet->Px(), jet->Py(), jet->Pz());
     }
     if( index3 != -1 ) {
-      AliAODJet* jet = fAODjets->GetJet(index3);
-      jetVect[2].SetXYZ(jet->Px(), jet->Py(), jet->Pz());
+      AliAODJet* jet = 0;
+      if (fDeltaAOD) {
+       jet= (AliAODJet*) fArrayJets->At(index3);
+     }else{
+       fAODjets->GetJet(index3);
+     }
+     jetVect[2].SetXYZ(jet->Px(), jet->Py(), jet->Pz());
     }
     
   } else {
@@ -323,22 +362,22 @@ void  AliAnalysisTaskUE::AnalyseUE()
     if( jets ) {
       nJets = jets->GetEntriesFast();
       if( nJets > 0 ) {
-        index1 = 0;
-        AliAODJet* jet = (AliAODJet*)jets->At(0);
-        maxPtJet1 = jet->Pt();
-        jetVect[0].SetXYZ(jet->Px(), jet->Py(), jet->Pz());
+       index1 = 0;
+       AliAODJet* jet = (AliAODJet*)jets->At(0);
+       maxPtJet1 = jet->Pt();
+       jetVect[0].SetXYZ(jet->Px(), jet->Py(), jet->Pz());
       }
       if( nJets > 1 ) {
-        index2 = 1;
-        AliAODJet* jet = (AliAODJet*)jets->At(1);
-        maxPtJet1 = jet->Pt();
-        jetVect[1].SetXYZ(jet->Px(), jet->Py(), jet->Pz());
+       index2 = 1;
+       AliAODJet* jet = (AliAODJet*)jets->At(1);
+       maxPtJet1 = jet->Pt();
+       jetVect[1].SetXYZ(jet->Px(), jet->Py(), jet->Pz());
       }
       if( nJets > 2 ) {
-        index3 = 2;
-        AliAODJet* jet = (AliAODJet*)jets->At(2);
-        maxPtJet1 = jet->Pt();
-        jetVect[2].SetXYZ(jet->Px(), jet->Py(), jet->Pz());
+       index3 = 2;
+       AliAODJet* jet = (AliAODJet*)jets->At(2);
+       maxPtJet1 = jet->Pt();
+       jetVect[2].SetXYZ(jet->Px(), jet->Py(), jet->Pz());
       }
       
       jets->Delete();
@@ -346,7 +385,8 @@ void  AliAnalysisTaskUE::AnalyseUE()
     }
   }
   
-  fhNJets->Fill(nJets);
+
+fhNJets->Fill(nJets);
   
   if( fDebug > 1 ) {
     if( index1 < 0 ) {
index 64dc8f937495bd4837e7f65b9db416bde6f92934..ae70930f7215766cb60eae2f07ff66c2de929c54 100644 (file)
@@ -4,7 +4,7 @@
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-#include "AliAnalysisTaskSE.h"
+#include "AliAnalysisTask.h"
 
 class AliESDEvent;
 class AliAODEvent;
@@ -35,6 +35,11 @@ class  AliAnalysisTaskUE : public AliAnalysisTask
       fMinJetPtInHist = min; 
       fMaxJetPtInHist = max; 
     }
+
+    // Read deltaAODs
+    void   ReadDeltaAOD()                   { fDeltaAOD = kTRUE; }
+    void   SelectDeltaAODBranch(const char* val)     { fDeltaAODBranch = val;   }
+
     // Setters for MC
     void  SetUseMCBranch(){fUseMCParticleBranch = kTRUE;}
     void  SetConstrainDistance(Bool_t val1, Double_t val2){ fMinDistance = val2; fConstrainDistance = val1;}
@@ -76,7 +81,11 @@ class  AliAnalysisTaskUE : public AliAnalysisTask
     void   QSortTracks(TObjArray &a, Int_t first, Int_t last);
     void   WriteSettings();
     
-    Int_t   fDebug;           //  Debug flag
+    Int_t      fDebug;           //  Debug flag
+    Bool_t      fDeltaAOD;        //  Read jets from delta AOD 
+    TString     fDeltaAODBranch;  //  Jet branch name from delta AOD
+    TClonesArray*  fArrayJets;       //  Array of Jets from delta AOD
+
     AliAODEvent*  fAOD;             //! AOD Event 
     AliAODEvent*  fAODjets;         //! AOD Event for reconstructed on the fly (see ConnectInputData()
     TList*  fListOfHistos;    //  Output list of histograms
@@ -154,7 +163,7 @@ class  AliAnalysisTaskUE : public AliAnalysisTask
     Double_t   fTrackPtCut;       // Pt cut of tracks in the regions
     Double_t   fTrackEtaCut;      // Eta cut on tracks in the regions (fRegionType=1)
     Double_t   fAvgTrials;        // average trials used to fill the fh1Triasl histogram in case we do not have trials on a event by event basis
-    
+                
     // Histograms    ( are owned by fListOfHistos TList )
     TH1F*  fhNJets;                  //!
     TH1F*  fhEleadingPt;             //!
@@ -191,7 +200,7 @@ class  AliAnalysisTaskUE : public AliAnalysisTask
     
     
     
-    ClassDef( AliAnalysisTaskUE, 2); // Analysis task for Underlying Event analysis
+    ClassDef( AliAnalysisTaskUE, 3); // Analysis task for Underlying Event analysis
   };
 
 #endif