]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
add option to put new list of clusters in output or input event
authorgconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 6 May 2012 09:51:29 +0000 (09:51 +0000)
committergconesab <gconesab@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 6 May 2012 09:51:29 +0000 (09:51 +0000)
PWGGA/EMCALTasks/AliAnalysisTaskEMCALClusterize.cxx
PWGGA/EMCALTasks/AliAnalysisTaskEMCALClusterize.h
PWGGA/EMCALTasks/macros/AddTaskEMCALClusterize.C

index 9051c4136f7206c485ad94da2b0ae35c063a05a9..6e6d0ed749599da283158a6aa128c341e49597e4 100644 (file)
@@ -73,8 +73,8 @@ AliAnalysisTaskEMCALClusterize::AliAnalysisTaskEMCALClusterize(const char *name)
 , fDigitsArr(0),          fClusterArr(0),             fCaloClusterArr(0)
 , fRecParam(0),           fClusterizer(0)
 , fUnfolder(0),           fJustUnfold(kFALSE) 
-, fOutputAODBranch(0),    fOutputAODBranchName("")
-, fFillAODFile(kTRUE),    fFillAODHeader(0)
+, fOutputAODBranch(0),    fOutputAODBranchName(""),   fOutputAODBranchSet(0)
+, fFillAODFile(kFALSE),   fFillAODHeader(0)
 , fFillAODCaloCells(0),   fRun(-1)
 , fRecoUtils(0),          fConfigName("")
 , fCellLabels(),          fCellSecondLabels(),        fCellTime()
@@ -111,8 +111,8 @@ AliAnalysisTaskEMCALClusterize::AliAnalysisTaskEMCALClusterize()
 , fDigitsArr(0),            fClusterArr(0),             fCaloClusterArr(0)
 , fRecParam(0),             fClusterizer(0)
 , fUnfolder(0),             fJustUnfold(kFALSE) 
-, fOutputAODBranch(0),      fOutputAODBranchName("")
-, fFillAODFile(kTRUE),      fFillAODHeader(0)
+, fOutputAODBranch(0),      fOutputAODBranchName(""),   fOutputAODBranchSet(0)
+, fFillAODFile(kFALSE),     fFillAODHeader(0)
 , fFillAODCaloCells(0),     fRun(-1)
 , fRecoUtils(0),            fConfigName("")
 , fCellLabels(),            fCellSecondLabels(),        fCellTime()
@@ -450,8 +450,22 @@ void AliAnalysisTaskEMCALClusterize::CheckAndGetEvent()
   
   if( IsExoticEvent() )                            { fEvent = 0x0 ; return ; }
   
-  //Magic line to write events to AOD filem put after event rejection
-  AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(fFillAODFile);
+  //-------------------------------------------------------------------------------------
+  // Set the cluster array in the event (output or input)
+  //-------------------------------------------------------------------------------------
+  
+  if     ( fFillAODFile ) 
+  {
+    //Magic line to write events to AOD filem put after event rejection
+    AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE);
+  }
+  else if( !fOutputAODBranchSet )
+  {
+    // Create array and put it in the input event, if output AOD not selected, only once
+    InputEvent()->AddObject(fOutputAODBranch);
+    fOutputAODBranchSet = kTRUE;
+    printf("AliAnalysisTaskEMCALClusterize::UserExec() - Add AOD branch <%s> to input event\n",fOutputAODBranchName.Data());
+  }
   
 }
 
@@ -1108,7 +1122,7 @@ void AliAnalysisTaskEMCALClusterize::InitGeometry()
       if(!esd)
       {
         Error("InitGeometry"," - This event does not contain ESDs?");
-        AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);
+        if(fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);
         return;
       }
       
@@ -1157,7 +1171,7 @@ Bool_t AliAnalysisTaskEMCALClusterize::IsExoticEvent()
   //  else         triggerclasses = ((AliAODEvent*)event)->GetFiredTriggerClasses();
   //    //  
   //    printf("AliAnalysisTaskEMCALClusterize - reject event %d with cluster  - reject event with ncells in SM3 %d and SM4 %d\n",(Int_t)Entry(),ncellsSM3, ncellsSM4);
-  //    AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);
+  //    if(fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);;
   //    return;
   //  
   
@@ -1200,7 +1214,7 @@ Bool_t AliAnalysisTaskEMCALClusterize::IsLEDEvent(const Int_t run)
   if( ncellsSM3 >= ncellcut || ncellsSM4 >= 100 )
   {
     printf("AliAnalysisTaksEMCALClusterize::IsLEDEvent() - reject event %d with ncells in SM3 %d and SM4 %d\n",(Int_t)Entry(),ncellsSM3, ncellsSM4);
-    AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);
+    if(fFillAODFile) AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kFALSE);;
     return kTRUE;
   }
   
@@ -1388,16 +1402,25 @@ void AliAnalysisTaskEMCALClusterize::UserCreateOutputObjects()
 {
   // Init geometry, create list of output clusters
   
-  if(fOutputAODBranchName.Length()!=0)
+
+  fOutputAODBranch = new TClonesArray("AliAODCaloCluster", 0);
+
+  if(fOutputAODBranchName.Length()==0)
   {
-    fOutputAODBranch = new TClonesArray("AliAODCaloCluster", 0);
-    fOutputAODBranch->SetName(fOutputAODBranchName);
-    //fOutputAODBranch->SetOwner(kFALSE);
-    AddAODBranch("TClonesArray", &fOutputAODBranch);
+    fOutputAODBranchName = "newEMCALClustersArray";
+    printf("Cluster branch name not set, set it to newEMCALClustersArray \n");
   }
-  else
+  
+  fOutputAODBranch->SetName(fOutputAODBranchName);
+  
+  if( fFillAODFile )
   {
-    AliFatal("fOutputAODBranchName not set\n");
+    //fOutputAODBranch = new TClonesArray("AliAODCaloCluster", 0);
+
+    
+    //fOutputAODBranch->SetOwner(kFALSE);
+    
+    AddAODBranch("TClonesArray", &fOutputAODBranch);
   }
   
 }
@@ -1430,7 +1453,7 @@ void AliAnalysisTaskEMCALClusterize::UserExec(Option_t *)
     if(DebugLevel() > 0 ) printf("AliAnalysisTaksEMCALClusterize::UserExec() - Skip Event %d", (Int_t) Entry());
     return ;
   }
-  
+
   //Init pointers, geometry, clusterizer, ocdb, aodb
   
   InitGeometry(); // only once, must be done before OADB, geo OADB accessed here
index 18025b04a8dd728a3ff69c786f1fe9af0eb33d99..269d3ff1c07177d372dcbc4c821113b1807e7e13 100644 (file)
@@ -142,6 +142,7 @@ class AliAnalysisTaskEMCALClusterize : public AliAnalysisTaskSE {
   //AOD
   TClonesArray          *fOutputAODBranch;         //! AOD Branch with output clusters  
   TString                fOutputAODBranchName;     // New of output AOD branch
+  Bool_t                 fOutputAODBranchSet ;     // Set the AOD clusters branch in the input event once
   Bool_t                 fFillAODFile;             // Fill the output AOD file with the new clusters, 
                                                    // if not they will be only available for the event they were generated
   Bool_t                 fFillAODHeader;           // Copy header to standard branch
@@ -173,12 +174,11 @@ class AliAnalysisTaskEMCALClusterize : public AliAnalysisTaskSE {
   Bool_t                 fOADBSet ;                //  AODB parameters already set
   Bool_t                 fAccessOADB ;             //  Get calibration from OADB for EMCAL
   TString                fOADBFilePath ;           //  Default path $ALICE_ROOT/OADB/EMCAL, if needed change
-  
-  
+    
   AliAnalysisTaskEMCALClusterize(           const AliAnalysisTaskEMCALClusterize&); // not implemented
   AliAnalysisTaskEMCALClusterize& operator=(const AliAnalysisTaskEMCALClusterize&); // not implemented
 
-  ClassDef(AliAnalysisTaskEMCALClusterize, 20);
+  ClassDef(AliAnalysisTaskEMCALClusterize, 21);
 
 };
 
index 72d2dcf0848bf664ee9ba08565db3a0f1ab52ece..c2eda382892eacd4530562f8a59da0726d2436f5 100644 (file)
@@ -1,10 +1,11 @@
 // $Id$
 
 AliAnalysisTaskEMCALClusterize* AddTaskEMCALClusterize(
+  TString & arrayName,
+  const Bool_t  bFillAOD   = kFALSE,                                                
   const Int_t   bMC        = kFALSE,
   const Bool_t  exotic     = kTRUE,
   const TString name       = "V1Unfold", 
-  TString & arrayName,
   const TString trigger    = "", 
   const Bool_t  tm         = kTRUE, 
   const Int_t   minEcell   = 50,
@@ -54,7 +55,7 @@ AliAnalysisTaskEMCALClusterize* AddTaskEMCALClusterize(
   // Some general settings to create AOD file in case we want to keep it
   clusterize->SwitchOffFillAODCaloCells();
   clusterize->SwitchOffFillAODHeader();
-  clusterize->FillAODFile(kFALSE); // fill aod.root with clusters?, not really needed for analysis.
+  clusterize->FillAODFile(bFillAOD); // fill aod.root with clusters?, not really needed for analysis.
 
   // Do track matching after clusterization
   if(tm) clusterize->SwitchOnTrackMatching();
@@ -247,10 +248,13 @@ AliAnalysisTaskEMCALClusterize* AddTaskEMCALClusterize(
   
   // Create containers for input/output
   AliAnalysisDataContainer *cinput1  = mgr->GetCommonInputContainer()  ;
-  AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer() ;
-  
   mgr->ConnectInput  (clusterize, 0,  cinput1 );
-  mgr->ConnectOutput (clusterize, 0, coutput1 );
   
+  if(bFillAOD)  
+  {
+    printf("AddTaskEMCALClusterize - Fill output AOD\n");
+    AliAnalysisDataContainer *coutput1 = mgr->GetCommonOutputContainer() ;
+    mgr->ConnectOutput (clusterize, 0, coutput1 );
+  }
   return clusterize;
 }