]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added AliInputEventHandler::SetUserCallSelectionMask(Bool_t flag) allowing a taskSE...
authoragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 17 Sep 2010 15:50:04 +0000 (15:50 +0000)
committeragheata <agheata@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 17 Sep 2010 15:50:04 +0000 (15:50 +0000)
Modified the tender and added method AliTender::SetCheckEventSelection(Bool_t flag) to use this feature automatically. The tender MUST be added first in the train.

ANALYSIS/Tender/AliTender.cxx
ANALYSIS/Tender/AliTender.h
ANALYSIS/TenderSupplies/AddTaskTender.C
STEER/AliESDInputHandler.cxx
STEER/AliESDInputHandler.h
STEER/AliInputEventHandler.h

index dd3273d88411bdea5f699dd3ae54f2f45d19875a..8ee8dc5a1aad61fb4526a858c72e70a1bf64bf15 100644 (file)
@@ -121,6 +121,13 @@ void AliTender::UserCreateOutputObjects()
 {
 // Nothing for the moment, but we may need ESD event replication here.
   if (fDebug > 1) Printf("AliTender::CreateOutputObjects()\n");
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  if (!mgr) AliFatal("No tender without an analysis manager");
+  fESDhandler = dynamic_cast<AliESDInputHandler *>(mgr->GetInputEventHandler());
+  if (fESDhandler && TObject::TestBit(kCheckEventSelection)) {
+     fESDhandler->SetUserCallSelectionMask(kTRUE);
+     Info("UserCreateOutputObjects","The TENDER will check the event selection. Make sure you add the tender as FIRST wagon!");
+  }   
 }
 
 //______________________________________________________________________________
@@ -133,6 +140,7 @@ void AliTender::UserExec(Option_t* /*option*/)
     Printf("AliTender::Exec() %s ==> processing event %lld\n", fESDhandler->GetTree()->GetCurrentFile()->GetName(),entry);
   }  
   fESD = fESDhandler->GetEvent();
+  if (TObject::TestBit(kCheckEventSelection)) fESDhandler->CheckSelectionMask();
 
 // Call the user analysis
   // Unlock CDB
index 275b34ce2dd27cfb41554c07614109be5cd0855f..a4850047e08ca1bd499fc14e189c209e0599deb3 100644 (file)
@@ -24,6 +24,11 @@ class AliTenderSupply;
 
 class AliTender : public AliAnalysisTaskSE {
 
+public:
+enum ETenderFlags {
+   kCheckEventSelection = BIT(18) // up to 18 used by AliAnalysisTask
+};
+   
 private:
   Int_t                     fRun;            //! Current run
   Bool_t                    fRunChanged;     //! Flag for run change.
@@ -49,6 +54,7 @@ public:
   AliESDInputHandler       *GetESDhandler() const {return fESDhandler;}
   AliESDEvent              *GetEvent() const {return fESD;}
   TObjArray                *GetSupplies() const {return fSupplies;}
+  void                      SetCheckEventSelection(Bool_t flag=kTRUE) {TObject::SetBit(kCheckEventSelection,flag);}
   Bool_t                    RunChanged() const {return fRunChanged;}
   // Configuration
   void                      SetDefaultCDBStorage(const char *dbString="local://$ALICE_ROOT/OCDB");
index df6d7086173e1f9f5083ac9e5891d060238bf5a9..649235de6a6030b644666814e1732dba8eed24c6 100644 (file)
@@ -1,4 +1,4 @@
-AliAnalysisTask *AddTaskTender(){
+AliAnalysisTask *AddTaskTender(Bool_t checkEvtSelection=kFALSE){
   //get the current analysis manager
   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
   if (!mgr) {
@@ -14,8 +14,15 @@ AliAnalysisTask *AddTaskTender(){
   
   //========= Add tender to the ANALYSIS manager and set default storage =====
   AliTender *tender=new AliTender("AnalysisTender");
+  tender->SetCheckEventSelection(checkEvtSelection);
   tender->SetDefaultCDBStorage("raw://");
   mgr->AddTask(tender);
+  if (checkEvtSelection) {
+     if (mgr->GetTasks()->First() != (TObject*)tender) {
+        ::Error("When setting the tender to check the event selection, it has to be the first wagon ! Aborting.");
+        return NULL;
+     }
+  }   
   
   //========= Attach TPC supply ======
   AliTPCTenderSupply *tpcSupply=new AliTPCTenderSupply("TPCtender");
index b7496817daa3d721831f35cb6e59e74667fd24c3..194c017212c1603acd4b08f559d593c9d2e69d70 100644 (file)
@@ -80,6 +80,7 @@ AliESDInputHandler::AliESDInputHandler(const char* name, const char* title):
     // Constructor
 }
 
+//______________________________________________________________________________
 Bool_t AliESDInputHandler::Init(TTree* tree,  Option_t* opt)
 {
     //
@@ -98,10 +99,14 @@ Bool_t AliESDInputHandler::Init(TTree* tree,  Option_t* opt)
     return kTRUE;
 }
 
+//______________________________________________________________________________
 Bool_t AliESDInputHandler::BeginEvent(Long64_t entry)
 {
     
     // Copy from old to new format if necessary
+  static Bool_t called = kFALSE;
+  if (!called && fEventCuts && IsUserCallSelectionMask())
+     AliInfo(Form("The ESD input handler expects that the first task calls AliESDInputHandler::CheckSelectionMask() %s", fEventCuts->ClassName()));
   AliESD* old = ((AliESDEvent*) fEvent)->GetAliESDOld();
   if (old) {
        ((AliESDEvent*)fEvent)->CopyFromOldESD();
@@ -116,14 +121,25 @@ Bool_t AliESDInputHandler::BeginEvent(Long64_t entry)
   //
   // Event selection
   // 
-  if (fEventCuts)
-    fIsSelectedResult = fEventCuts->GetSelectionMask((AliESDEvent*)fEvent); 
+  fIsSelectedResult = 0;
+  if (fEventCuts && !IsUserCallSelectionMask())
+      fIsSelectedResult = fEventCuts->GetSelectionMask((AliESDEvent*)fEvent); 
   //
   // Friends
   ((AliESDEvent*)fEvent)->SetESDfriend(fFriend);
+  called = kTRUE;
   return kTRUE;
 }
 
+//______________________________________________________________________________
+void AliESDInputHandler::CheckSelectionMask()
+{
+// This method can be called by a task only if IsUserCallSelectionMask is true.
+   if (!fEventCuts || !IsUserCallSelectionMask()) return;
+   fEventCuts->GetSelectionMask((AliESDEvent*)fEvent);
+}
+   
+//______________________________________________________________________________
 Bool_t  AliESDInputHandler::FinishEvent()
 {
     // Finish the event 
@@ -131,6 +147,7 @@ Bool_t  AliESDInputHandler::FinishEvent()
     return kTRUE;
 } 
 
+//______________________________________________________________________________
 Bool_t AliESDInputHandler::Notify(const char* path)
 {
     // Notify a directory change
@@ -158,8 +175,6 @@ Bool_t AliESDInputHandler::Notify(const char* path)
     SwitchOffBranches();
     SwitchOnBranches();
     fFriend = (AliESDfriend*)(fEvent->FindListObject("AliESDfriend"));
-    
-
     //
     if (fUseHLT) {
        // Get HLTesdTree from current file
@@ -174,9 +189,6 @@ Bool_t AliESDInputHandler::Notify(const char* path)
        }
     }
 
-
-
-
     if (!fUseTags) return (kTRUE);
     
     Bool_t zip = kFALSE;
@@ -266,14 +278,14 @@ Bool_t AliESDInputHandler::Notify(const char* path)
     return kTRUE;
 }
 
-
-
+//______________________________________________________________________________
 Option_t *AliESDInputHandler::GetDataType() const
 {
 // Returns handled data type.
    return gESDDataType;
 }
 
+//______________________________________________________________________________
 Int_t AliESDInputHandler::GetNEventAcceptedInFile()
 {
   // Get number of events in file accepted by the tag cuts
@@ -312,6 +324,8 @@ Int_t AliESDInputHandler::GetNEventAcceptedInFile()
 
   return iAcc;
 }
+
+//______________________________________________________________________________
 Int_t AliESDInputHandler::GetNEventRejectedInFile()
 {
   // Get number of events in file rejected by the tag cuts
@@ -351,6 +365,8 @@ Int_t AliESDInputHandler::GetNEventRejectedInFile()
 
   return iRej;
 }
+
+//______________________________________________________________________________
 Bool_t AliESDInputHandler::GetCutSummaryForChain(Int_t *aTotal, Int_t *aAccepted, Int_t *aRejected)
 {
   // Get number of events in the full chain
@@ -399,6 +415,7 @@ Bool_t AliESDInputHandler::GetCutSummaryForChain(Int_t *aTotal, Int_t *aAccepted
   return kTRUE;
 }
 
+//______________________________________________________________________________
 Int_t AliESDInputHandler::GetNFilesEmpty()
 {
   // Count number of files in which all events were de-selected
index 62bd6bcddeea4173ac5df61c45eadebdc01e887c..378282f6606783789b379daba785aadfb3b06451 100644 (file)
@@ -32,6 +32,7 @@ class AliESDInputHandler : public AliInputEventHandler {
     virtual Bool_t       Notify() { return AliVEventHandler::Notify(); };
     virtual Bool_t       Notify(const char* path);
     virtual Bool_t       FinishEvent();
+    void                 CheckSelectionMask();
     AliESDEvent         *GetEvent()        const {return fEvent;}
     Option_t            *GetAnalysisType() const {return fAnalysisType;}
     Option_t            *GetDataType() const;
index 53d15f53afbc3cb0fc4c38735d16454c31bf4341..4c33106a66e20b46bdd90681fa619b208a2b8c20 100644 (file)
@@ -22,6 +22,9 @@ class AliRunTag;
 class AliInputEventHandler : public AliVEventHandler {
 
  public:
+ enum EInputHandlerFlags {
+    kUserCallSelectionMask = BIT(14) // Watch out for defining base class bits
+ };
     AliInputEventHandler();
     AliInputEventHandler(const char* name, const char* title);
     virtual ~AliInputEventHandler();
@@ -38,6 +41,7 @@ class AliInputEventHandler : public AliVEventHandler {
     // Setters
     virtual void         SetInputTree(TTree* tree)                    {fTree = tree;}
     virtual void         SetEventSelection(AliVCuts* cuts)            {fEventCuts = cuts;}
+    virtual void         SetUserCallSelectionMask(Bool_t flag=kTRUE)  {TObject::SetBit(kUserCallSelectionMask,flag);}
     //
     void SetInactiveBranches(const char* branches) {fBranches   = branches;}
     void SetActiveBranches  (const char* branches) {fBranchesOn = branches;}
@@ -48,6 +52,7 @@ class AliInputEventHandler : public AliVEventHandler {
     virtual TTree       *GetTree( )        const                      {return fTree;}
     virtual AliVCuts    *GetEventSelection() const                    {return fEventCuts;}
     virtual Long64_t     GetReadEntry()    const;
+    virtual Bool_t       IsUserCallSelectionMask() const              {return TObject::TestBit(kUserCallSelectionMask);}
     virtual Bool_t       NewEvent()
        {Bool_t ne = fNewEvent; fNewEvent = kFALSE; return ne;}
     virtual UInt_t       IsEventSelected()