Added option fDoMixExtra and fDoMixIfNotEnoughEvents - can be controled by user
authormvala <mvala@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 2 Mar 2011 11:54:18 +0000 (11:54 +0000)
committermvala <mvala@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 2 Mar 2011 11:54:18 +0000 (11:54 +0000)
ANALYSIS/EventMixing/AliAnalysisTaskMixInfo.cxx
ANALYSIS/EventMixing/AliMixInputEventHandler.cxx
ANALYSIS/EventMixing/AliMixInputEventHandler.h

index 7269ea6..507729f 100644 (file)
@@ -94,7 +94,13 @@ void AliAnalysisTaskMixInfo::UserExec(Option_t *)
          if (fInputEHMix->NumberMixedTimes() >= fInputEHMix->BufferSize())
             fMixInfo->FillHistogram(AliMixInfo::kMainEvents, fInputEHMix->CurrentBinIndex());
       } else {
-         fMixInfo->FillHistogram(AliMixInfo::kMainEvents, fInputEHMix->CurrentBinIndex());
+         if ((!fInputEHMix->IsMixingIfNotEnoughEvents())) {
+            if (fInputEHMix->NumberMixed() == fInputEHMix->MixNumber())
+               // add main entry only when there was enough mixed events mixed
+               fMixInfo->FillHistogram(AliMixInfo::kMainEvents, fInputEHMix->CurrentBinIndex());
+         } else {
+            fMixInfo->FillHistogram(AliMixInfo::kMainEvents, fInputEHMix->CurrentBinIndex());
+         }
       }
       AliDebug(AliLog::kDebug, Form("Main %lld %d [%lld,%lld] %d", fInputEHMix->CurrentEntry(), fInputEHMix->CurrentBinIndex(), fInputEHMix->CurrentEntryMain(), fInputEHMix->CurrentEntryMix(), fInputEHMix->NumberMixed()));
    }
index 34b4d9d..e8c39d1 100644 (file)
@@ -34,7 +34,8 @@ AliMixInputEventHandler::AliMixInputEventHandler(const Int_t size, const Int_t m
    fNumberMixed(0),
    fMixNumber(mixNum),
    fUseDefautProcess(kFALSE),
-   fUsePreMixEvents(kTRUE),
+   fDoMixExtra(kTRUE),
+   fDoMixIfNotEnoughEvents(kTRUE),
    fCurrentEntry(0),
    fCurrentEntryMain(0),
    fCurrentEntryMix(0),
@@ -63,6 +64,7 @@ void AliMixInputEventHandler::SetInputHandlerForMixing(const AliInputEventHandle
       AliDebug(AliLog::kDebug + 5, Form("Adding %d ...", i));
       fInputHandlers.Add((AliInputEventHandler *) inHandler->Clone());
    }
+
    AliDebug(AliLog::kDebug + 5, Form("->"));
 }
 
@@ -79,6 +81,12 @@ Bool_t AliMixInputEventHandler::Init(TTree *tree, Option_t *opt)
       AliDebug(AliLog::kDebug + 5, Form("->"));
       return kFALSE;
    }
+
+   if (!fDoMixIfNotEnoughEvents) {
+      fDoMixExtra = kFALSE;
+      AliWarning("fDoMixIfNotEnoughEvents=kTRUE -> setting fDoMixExtra=kFALSE");
+   }
+
    // clears array of input handlers
    fMixTrees.Clear();
    // create AliMixInputHandlerInfo
@@ -211,7 +219,7 @@ Bool_t AliMixInputEventHandler::MixStd()
    }
    // pre mix evetns
    Int_t mixNum = fMixNumber;
-   if (fUsePreMixEvents) {
+   if (fDoMixExtra) {
       if (fEntryCounter <= 2 * fMixNumber) mixNum = 2 * fMixNumber + 2;
    }
    // start of
@@ -294,7 +302,7 @@ Bool_t AliMixInputEventHandler::MixBuffer()
       elNum = el->GetN();
       if (elNum < fBufferSize + 1) {
          UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
-         AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (%lld) +++++++++++++++++++", fEntryCounter, elNum));
+         AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (%lld) LESS THEN BUFFER +++++++++++++++++++", fEntryCounter, elNum));
          return kTRUE;
       }
    }
@@ -373,8 +381,12 @@ Bool_t AliMixInputEventHandler::MixEventsMoreTimesWithOneEvent()
    // return in case of 0 entry in full chain
    if (!fEntryCounter) {
       // runs UserExecMix for all tasks, if needed
-      if (el) UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
-      else UserExecMixAllTasks(fEntryCounter, -1, currentMainEntry, -1, 0);
+      if (el && fDoMixIfNotEnoughEvents) {
+         UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
+      } else {
+         idEntryList = -1;
+         UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
+      }
       AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (fEntryCounter=0, idEntryList=%d) +++++++++++++++++++", fEntryCounter, idEntryList));
       return kTRUE;
    }
@@ -387,14 +399,28 @@ Bool_t AliMixInputEventHandler::MixEventsMoreTimesWithOneEvent()
    } else {
       elNum = el->GetN();
       if (elNum < fBufferSize + 1) {
-         UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
+         if (fDoMixIfNotEnoughEvents) {
+            // include main event in to counter in this case (so idEntryList>0)
+            UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
+         }  else {
+            // dont include it in main event counter (idEntryList = -1)
+            idEntryList = -1;
+            UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
+         }
          AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED [FIRST ENTRY in el] (elnum=%lld, idEntryList=%d) +++++++++++++++++++", fEntryCounter, elNum, idEntryList));
          return kTRUE;
       }
+      if (!fDoMixIfNotEnoughEvents) {
+         if (elNum <= fMixNumber + 1) {
+            UserExecMixAllTasks(fEntryCounter, idEntryList, currentMainEntry, -1, 0);
+            AliDebug(AliLog::kDebug + 3, Form("++++++++++++++ END SETUP EVENT %lld SKIPPED (%lld) NOT ENOUGH EVENTS TO MIX => NEED=%d +++++++++++++++++++", fEntryCounter, elNum, fMixNumber + 1));
+            return kTRUE;
+         }
+      }
    }
    // pre mix evetns
    Int_t mixNum = fMixNumber;
-   if (fUsePreMixEvents) {
+   if (fDoMixExtra) {
       if (elNum <= 2 * fMixNumber + 1) mixNum = elNum + 1;
    }
    AliMixInputHandlerInfo *mihi = 0;
index 4a8f913..2706648 100644 (file)
@@ -47,7 +47,8 @@ public:
    Int_t                   MixNumber() const { return fMixNumber; }
    Long64_t                EntryAll() const { return fEntryCounter; }
    void                    UseDefaultProcess(Bool_t b = kTRUE) { fUseDefautProcess = b; }
-   void                    UsePreMixEvents(Bool_t b = kTRUE) { fUsePreMixEvents = b; }
+   void                    DoMixExtra(Bool_t b = kTRUE) { fDoMixExtra = b; }
+   void                    DoMixIfNotEnoughEvents(Bool_t b = kTRUE) { fDoMixIfNotEnoughEvents = b; }
    void                    SetMixNumber(const Int_t mixNum);
 
    void                    SetCurrentBinIndex(Int_t const index) { fCurrentBinIndex = index; }
@@ -64,6 +65,8 @@ public:
 
    void                    SelectCollisionCandidates(UInt_t offlineTriggerMask = AliVEvent::kMB) {fOfflineTriggerMask = offlineTriggerMask;}
    Bool_t                  IsEventCurrentSelected();
+   Bool_t                  IsMixingIfNotEnoughEvents() { return fDoMixIfNotEnoughEvents;}
+
 protected:
 
    TObjArray               fMixTrees;              // buffer of input handlers
@@ -77,7 +80,8 @@ protected:
 private:
 
    Bool_t                  fUseDefautProcess;      // use default process
-   Bool_t                  fUsePreMixEvents;       // use pre mixing events
+   Bool_t                  fDoMixExtra;            // mix extra events to get enough combinations
+   Bool_t                  fDoMixIfNotEnoughEvents;// mix events if they dont have enough events to mix
 
    // mixing info
    Long64_t fCurrentEntry;       //! current entry number (adds 1 for every event processed on each worker)
@@ -97,7 +101,7 @@ private:
    AliMixInputEventHandler(const AliMixInputEventHandler& handler);
    AliMixInputEventHandler &operator=(const AliMixInputEventHandler &handler);
 
-   ClassDef(AliMixInputEventHandler, 2)
+   ClassDef(AliMixInputEventHandler, 3)
 };
 
 #endif