Calculating Background only when the background branch is also stored save computing...
authorkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 31 Oct 2010 19:27:32 +0000 (19:27 +0000)
committerkleinb <kleinb@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 31 Oct 2010 19:27:32 +0000 (19:27 +0000)
JETAN/AliAnalysisTaskJetCluster.h
JETAN/AliAnalysisTaskJets.cxx
JETAN/AliAnalysisTaskJets.h
JETAN/AliFastJetFinder.cxx

index adc639a..2694841 100644 (file)
@@ -64,6 +64,7 @@ class AliAnalysisTaskJetCluster : public AliAnalysisTaskSE
     virtual void SetJetOutputBranch(const char *c){fNonStdBranch = c;}
     virtual void SetJetOutputFile(const char *c){fNonStdFile = c;}
     virtual void SetJetOutputMinPt(Float_t x){fJetOutputMinPt = x;}
+    virtual void SetBackgroundCalc(Bool_t b){fUseBackgroundCalc = b;} 
 
     // for Fast Jet
     fastjet::JetAlgorithm        GetAlgorithm()         const {return fAlgorithm;}
@@ -108,6 +109,7 @@ class AliAnalysisTaskJetCluster : public AliAnalysisTaskSE
     Bool_t        fUseAODTrackInput;      // take track from input AOD not from ouptu AOD
     Bool_t        fUseAODMCInput;         // take MC from input AOD not from ouptu AOD
     Bool_t        fUseGlobalSelection;    // Limit the eta of the generated jets
+    Bool_t        fUseBackgroundCalc;     // switches on background calculations
     UInt_t        fFilterMask;            // filter bit for slecected tracks
     Int_t         fTrackTypeRec;          // type of tracks used for FF 
     Int_t         fTrackTypeGen;          // type of tracks used for FF 
@@ -192,7 +194,7 @@ class AliAnalysisTaskJetCluster : public AliAnalysisTaskSE
     TList *fHistList; // Output list
    
 
-    ClassDef(AliAnalysisTaskJetCluster, 6) 
+    ClassDef(AliAnalysisTaskJetCluster, 7) 
 };
  
 #endif
index 664acd4..936b91e 100644 (file)
@@ -57,6 +57,7 @@ AliAnalysisTaskJets::AliAnalysisTaskJets():
   fChain(0x0),
   fOpt(0),
   fReadAODFromOutput(0),
+  fUseAODBackground(kFALSE),
   fFilterPt(0.)
 {
   // Default constructor
@@ -74,6 +75,7 @@ AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name):
   fChain(0x0),
   fOpt(0),
   fReadAODFromOutput(0),
+  fUseAODBackground(kFALSE),
   fFilterPt(0.)
 {
   // Default constructor
@@ -92,6 +94,7 @@ AliAnalysisTaskJets::AliAnalysisTaskJets(const char* name, TChain* chain):
   fChain(chain),
   fOpt(0),
   fReadAODFromOutput(0),
+  fUseAODBackground(kFALSE),
   fFilterPt(0.)
 {
   // Default constructor
@@ -105,14 +108,19 @@ void AliAnalysisTaskJets::UserCreateOutputObjects()
   //
   if (fDebug > 1) printf("AnalysisTaskJets::CreateOutPutData() \n");
 
+  AliJetHeader *fH = fJetFinder->GetHeader();
+
   if(fNonStdBranch.Length()==0)
     {
       //  Connec default AOD to jet finder
       // create a new branch for the background
-      if(!AODEvent()->FindListObject(AliAODJetEventBackground::StdBranchName())){
-       AliAODJetEventBackground* evBkg = new AliAODJetEventBackground();
-       evBkg->SetName(AliAODJetEventBackground::StdBranchName());
-       AddAODBranch("AliAODJetEventBackground",&evBkg);
+
+      if(fUseAODBackground){
+       if(!AODEvent()->FindListObject(AliAODJetEventBackground::StdBranchName())){
+         AliAODJetEventBackground* evBkg = new AliAODJetEventBackground();
+         evBkg->SetName(AliAODJetEventBackground::StdBranchName());
+         AddAODBranch("AliAODJetEventBackground",&evBkg);
+       }
       }
       fJetFinder->ConnectAOD(AODEvent());
     }
@@ -126,12 +134,13 @@ void AliAnalysisTaskJets::UserCreateOutputObjects()
       TClonesArray *tca = new TClonesArray("AliAODJet", 0);
       tca->SetName(fNonStdBranch.Data());
       AddAODBranch("TClonesArray",&tca,fNonStdFile.Data());
-      if(!AODEvent() || !AODEvent()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()))){
-       AliAODJetEventBackground* evBkg = new AliAODJetEventBackground();
-       evBkg->SetName(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()));
-       AddAODBranch("AliAODJetEventBackground",&evBkg,fNonStdFile.Data());
+      if(fUseAODBackground){
+       if(!AODEvent() || !AODEvent()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()))){
+         AliAODJetEventBackground* evBkg = new AliAODJetEventBackground();
+         evBkg->SetName(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data()));
+         AddAODBranch("AliAODJetEventBackground",&evBkg,fNonStdFile.Data());
+       }
       }
-
       if(fNonStdFile.Length()!=0){
        // 
        // case that we have an AOD extension we need to fetch the jets from the extended output
@@ -176,7 +185,6 @@ void AliAnalysisTaskJets::UserCreateOutputObjects()
   fHistos->AddHistosToList(fListOfHistos);
   
   // Add the JetFinderInformation to the Outputlist
-  AliJetHeader *fH = fJetFinder->GetHeader();
   
   // Compose a characteristic output name
   // with the name of the output branch
@@ -230,16 +238,20 @@ void AliAnalysisTaskJets::UserExec(Option_t */*option*/)
 
   if(fNonStdBranch.Length()==0) {
     jarray = AODEvent()->GetJets();
-    evBkg = (AliAODJetEventBackground*)(AODEvent()->FindListObject(AliAODJetEventBackground::StdBranchName()));
-    evBkg->Reset();
+    if(fUseAODBackground){
+      evBkg = (AliAODJetEventBackground*)(AODEvent()->FindListObject(AliAODJetEventBackground::StdBranchName()));
+      evBkg->Reset();
+    }
   }
   else {
     if(AODEvent())jarray = (TClonesArray*)(AODEvent()->FindListObject(fNonStdBranch.Data()));
     if(!jarray)jarray = (TClonesArray*)(fAODExtension->GetAOD()->FindListObject(fNonStdBranch.Data()));
     if(jarray)jarray->Delete();    // this is our responsibility, clear before filling again
-    if(AODEvent())evBkg = (AliAODJetEventBackground*)(AODEvent()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data())));
-    if(!evBkg)  evBkg = (AliAODJetEventBackground*)(fAODExtension->GetAOD()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data())));
-    if(evBkg)evBkg->Reset();
+    if(fUseAODBackground){
+      if(AODEvent())evBkg = (AliAODJetEventBackground*)(AODEvent()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data())));
+      if(!evBkg)  evBkg = (AliAODJetEventBackground*)(fAODExtension->GetAOD()->FindListObject(Form("%s_%s",AliAODJetEventBackground::StdBranchName(),fNonStdBranch.Data())));
+      if(evBkg)evBkg->Reset();
+    }
   }
 
   if (dynamic_cast<AliAODEvent*>(InputEvent()) !=  0 && !fReadAODFromOutput) {
index 6c9e0e2..a571319 100644 (file)
@@ -34,6 +34,7 @@ class AliAnalysisTaskJets : public AliAnalysisTaskSE
     virtual void SetJetFinder(AliJetFinder *finder) {fJetFinder = finder;}
     virtual void SetNonStdBranch(const char *c){fNonStdBranch = c;}
     virtual void SetNonStdOutputFile(const char *c){fNonStdFile = c;}
+    virtual void SetBookAODBackground(Bool_t b){fUseAODBackground = b;}
     virtual void Terminate(Option_t *option);
     virtual void ReadAODFromOutput() {fReadAODFromOutput = kTRUE;}
     virtual void SetFilterPt(Float_t f){fFilterPt = f;}
@@ -53,8 +54,9 @@ class AliAnalysisTaskJets : public AliAnalysisTaskSE
   TChain*       fChain;             //  Chain 
   Int_t         fOpt;               //  Detector configuration used
   Bool_t        fReadAODFromOutput; //  Force reading of the AOD from the output
+  Bool_t        fUseAODBackground;  // decide wether we book the backround branch or not 
   Float_t       fFilterPt;          // use this as a switch for writing the AOD, minium p_T of leading jet   
-  ClassDef(AliAnalysisTaskJets, 5); // Analysis task for standard jet analysis
+  ClassDef(AliAnalysisTaskJets, 6); // Analysis task for standard jet analysis
 };
  
 #endif
index 68ef13a..f324a21 100644 (file)
@@ -425,17 +425,19 @@ Bool_t AliFastJetFinder::ProcessEvent()
   // Jets
   FindJets(); 
 
-  fJetBkg->SetHeader(fHeader);
-  fJetBkg->SetReader(fReader);
-  Double_t sigma1 = 0,meanarea1= 0,sigma2 = 0,meanarea2 = 0;
-  Double_t bkg1 = 0,bkg2 = 0;
-  
-  fJetBkg->SetFastJetInput(fInputFJ);
-  fJetBkg->BkgFastJetb(bkg1,sigma1,meanarea1);
-  fJetBkg->BkgFastJetWoHardest(bkg2,sigma2,meanarea2);
-  fAODEvBkg->SetBackground(0,bkg1,sigma1,meanarea1);
-  fAODEvBkg->SetBackground(1,bkg2,sigma2,meanarea2);
 
+  if( fAODEvBkg){
+    fJetBkg->SetHeader(fHeader);
+    fJetBkg->SetReader(fReader);
+    Double_t sigma1 = 0,meanarea1= 0,sigma2 = 0,meanarea2 = 0;
+    Double_t bkg1 = 0,bkg2 = 0;
+    
+    fJetBkg->SetFastJetInput(fInputFJ);
+    fJetBkg->BkgFastJetb(bkg1,sigma1,meanarea1);
+    fJetBkg->BkgFastJetWoHardest(bkg2,sigma2,meanarea2);
+    fAODEvBkg->SetBackground(0,bkg1,sigma1,meanarea1);
+    fAODEvBkg->SetBackground(1,bkg2,sigma2,meanarea2);
+  }
 
 
 
@@ -479,16 +481,17 @@ Bool_t AliFastJetFinder::ProcessEvent2()
   // Jets
   FindJets();
   
-  fJetBkg->SetHeader(fHeader);
-  fJetBkg->SetReader(fReader);
-  fJetBkg->SetFastJetInput(fInputFJ);
-  Double_t sigma1,meanarea1,sigma2,meanarea2;
-  Double_t bkg1,bkg2;
-  fJetBkg->BkgFastJetb(bkg1,sigma1,meanarea1);
-  fJetBkg->BkgFastJetWoHardest(bkg2,sigma2,meanarea2);
-  fAODEvBkg->SetBackground(0,bkg1,sigma1,meanarea1);
-  fAODEvBkg->SetBackground(1,bkg2,sigma2,meanarea2);
-
+  if( fAODEvBkg){
+    fJetBkg->SetHeader(fHeader);
+    fJetBkg->SetReader(fReader);
+    fJetBkg->SetFastJetInput(fInputFJ);
+    Double_t sigma1,meanarea1,sigma2,meanarea2;
+    Double_t bkg1,bkg2;
+    fJetBkg->BkgFastJetb(bkg1,sigma1,meanarea1);
+    fJetBkg->BkgFastJetWoHardest(bkg2,sigma2,meanarea2);
+    fAODEvBkg->SetBackground(0,bkg1,sigma1,meanarea1);
+    fAODEvBkg->SetBackground(1,bkg2,sigma2,meanarea2);
+  }
 
 
 //  Double_t bkg1=fJetBkg->BkgFastJet();