]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Bug fixes on selections for event mixing, and addition of some runtime messages
authorpulvir <pulvir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 20 Jun 2011 14:31:00 +0000 (14:31 +0000)
committerpulvir <pulvir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 20 Jun 2011 14:31:00 +0000 (14:31 +0000)
PWG2/RESONANCES/AliRsnCutKaonForPhi2010.cxx
PWG2/RESONANCES/AliRsnCutKaonForPhi2010.h
PWG2/RESONANCES/AliRsnMiniAnalysisTask.cxx
PWG2/RESONANCES/AliRsnMiniAnalysisTask.h
PWG2/RESONANCES/AliRsnMiniOutput.cxx

index 72ecd52aedb0fd0fd4a243d0c0c2f5862b638077..77613041550fc5db423838ddcb964e89a6bea078 100644 (file)
 ClassImp(AliRsnCutKaonForPhi2010)
 
 //__________________________________________________________________________________________________
-AliRsnCutKaonForPhi2010::AliRsnCutKaonForPhi2010(const char *name) :
-   AliRsnCut(name, AliRsnTarget::kDaughter, 0.0, 3.0),
+AliRsnCutKaonForPhi2010::AliRsnCutKaonForPhi2010
+(const char *name, Double_t nSigmaTPC, Double_t nSigmaTOF, Double_t tofLimit) :
+   AliRsnCut(name, AliRsnTarget::kDaughter),
    fOnlyQuality(kFALSE),
    fOnlyTPC(kFALSE),
    fOnlyTOF(kFALSE),
-   fCutTPC(2.0),
-   fCutTOF(2.0),
-   fTOFthreshold(0.8),
+   fCutTPC(nSigmaTPC),
+   fCutTOF(nSigmaTOF),
+   fTOFthreshold(tofLimit),
    fCutQuality(Form("%s_quality", name))
 {
 //
index b08209390753cdebedc5adf7bcf74a92612581d2..f7696ae053b3a44dd211e3b3080f283cc9daab96 100644 (file)
@@ -16,7 +16,7 @@ class AliRsnCutKaonForPhi2010 : public AliRsnCut {
 
 public:
 
-   AliRsnCutKaonForPhi2010(const char *name = "");
+   AliRsnCutKaonForPhi2010(const char *name = "", Double_t nSigmaTPC = 3.0, Double_t nSigmaTOF = 3.0, Double_t tofLimit = 0.8);
    virtual ~AliRsnCutKaonForPhi2010() { }
    
    virtual Bool_t IsSelected(TObject *obj);
index 5654323255aa6265dd998816843ef6ef9698fd88..0f8cadba92e4b6d1e3f02d24475fc363d78019ce 100644 (file)
@@ -57,7 +57,6 @@ AliRsnMiniAnalysisTask::AliRsnMiniAnalysisTask() :
    fTrackCuts(0),
    fRsnEvent(),
    fEvBuffer(0x0),
-   fNMixed(0),
    fTriggerAna(0x0),
    fESDtrackCuts(0x0),
    fMiniEvent(0x0)
@@ -86,7 +85,6 @@ AliRsnMiniAnalysisTask::AliRsnMiniAnalysisTask(const char *name, Bool_t useMC) :
    fTrackCuts(0),
    fRsnEvent(),
    fEvBuffer(0x0),
-   fNMixed(0),
    fTriggerAna(0x0),
    fESDtrackCuts(0x0),
    fMiniEvent(0x0)
@@ -120,7 +118,6 @@ AliRsnMiniAnalysisTask::AliRsnMiniAnalysisTask(const AliRsnMiniAnalysisTask& cop
    fTrackCuts(copy.fTrackCuts),
    fRsnEvent(),
    fEvBuffer(0x0),
-   fNMixed(0),
    fTriggerAna(copy.fTriggerAna),
    fESDtrackCuts(copy.fESDtrackCuts),
    fMiniEvent(0x0)
@@ -305,16 +302,13 @@ void AliRsnMiniAnalysisTask::FinishTaskOutput()
    // security code: reassign the buffer to the mini-event cursor
    fEvBuffer->SetBranchAddress("events", &fMiniEvent);
    
+   // prepare variables
    Int_t ievt, nEvents = (Int_t)fEvBuffer->GetEntries();
    Int_t idef, nDefs   = fHistograms.GetEntries();
    Int_t imix, iloop, ifill;
    AliRsnMiniOutput *def = 0x0;
    AliRsnMiniOutput::EComputation compType;
    
-   // initialize mixing counter
-   fNMixed.Set(nEvents);
-   for (ievt = 0; ievt < nEvents; ievt++) fNMixed[ievt] = 0;
-   
    // loop on events, and for each one fill all outputs
    // using the appropriate procedure depending on its type
    // only mother-related histograms are filled in UserExec,
@@ -322,8 +316,6 @@ void AliRsnMiniAnalysisTask::FinishTaskOutput()
    for (ievt = 0; ievt < nEvents; ievt++) {
       // get next entry
       fEvBuffer->GetEntry(ievt);
-      // store in temp variable
-      AliRsnMiniEvent evMain(*fMiniEvent);
       // fill
       for (idef = 0; idef < nDefs; idef++) {
          def = (AliRsnMiniOutput*)fHistograms[idef];
@@ -332,49 +324,25 @@ void AliRsnMiniAnalysisTask::FinishTaskOutput()
          // execute computation in the appropriate way
          switch (compType) {
             case AliRsnMiniOutput::kEventOnly:
-               AliDebugClass(1, Form("Event %d, def %d: event-value histogram filling", ievt, idef));
+               AliDebugClass(1, Form("Event %d, def '%s': event-value histogram filling", ievt, def->GetName()));
                ifill = 1;
-               def->FillEvent(&evMain, &fValues);
+               def->FillEvent(fMiniEvent, &fValues);
                break;
             case AliRsnMiniOutput::kTruePair:
-               AliDebugClass(1, Form("Event %d, def %d: true-pair histogram filling", ievt, idef));
-               ifill = def->FillPair(&evMain, &evMain, &fValues);
+               AliDebugClass(1, Form("Event %d, def '%s': true-pair histogram filling", ievt, def->GetName()));
+               ifill = def->FillPair(fMiniEvent, fMiniEvent, &fValues);
                break;
             case AliRsnMiniOutput::kTrackPair:
-               AliDebugClass(1, Form("Event %d, def %d: pair-value histogram filling", ievt, idef));
-               ifill = def->FillPair(&evMain, &evMain, &fValues);
+               AliDebugClass(1, Form("Event %d, def '%s': pair-value histogram filling", ievt, def->GetName()));
+               ifill = def->FillPair(fMiniEvent, fMiniEvent, &fValues);
                break;
             case AliRsnMiniOutput::kTrackPairRotated1:
-               AliDebugClass(1, Form("Event %d, def %d: rotated (1) background histogram filling", ievt, idef));
-               ifill = def->FillPair(&evMain, &evMain, &fValues);
+               AliDebugClass(1, Form("Event %d, def '%s': rotated (1) background histogram filling", ievt, def->GetName()));
+               ifill = def->FillPair(fMiniEvent, fMiniEvent, &fValues);
                break;
             case AliRsnMiniOutput::kTrackPairRotated2:
-               AliDebugClass(1, Form("Event %d, def %d: rotated (2) background histogram filling", ievt, idef));
-               ifill = def->FillPair(&evMain, &evMain, &fValues);
-               break;
-            case AliRsnMiniOutput::kTrackPairMix:
-               ifill = 0;
-               for (iloop = 1; iloop < nEvents; iloop++) {
-                  imix = ievt + iloop;
-                  AliDebugClass(1, Form("Event %d, def %d: event mixing (%d with %d)", ievt, idef, ievt, imix));
-                  // restart from beginning if reached last event
-                  if (imix >= nEvents) imix -= nEvents;
-                  // avoid to mix an event with itself
-                  if (imix == ievt) continue;
-                  // skip all events already mixed enough times
-                  if (fNMixed[ievt] >= fNMix) break;
-                  if (fNMixed[imix] >= fNMix) continue;
-                  fEvBuffer->GetEntry(imix);
-                  // skip if events are not matched
-                  if (TMath::Abs(evMain.Vz()    - fMiniEvent->Vz()   ) > fMaxDiffVz   ) continue;
-                  if (TMath::Abs(evMain.Mult()  - fMiniEvent->Mult() ) > fMaxDiffMult ) continue;
-                  if (TMath::Abs(evMain.Angle() - fMiniEvent->Angle()) > fMaxDiffAngle) continue;
-                  // found a match: increment counter for both events
-                  fNMixed[ievt]++;
-                  fNMixed[imix]++;
-                  // process mixing
-                  ifill += def->FillPair(&evMain, fMiniEvent, &fValues);
-               }
+               AliDebugClass(1, Form("Event %d, def '%s': rotated (2) background histogram filling", ievt, def->GetName()));
+               ifill = def->FillPair(fMiniEvent, fMiniEvent, &fValues);
                break;
             default:
                // other kinds are processed elsewhere
@@ -386,10 +354,101 @@ void AliRsnMiniAnalysisTask::FinishTaskOutput()
       }
    }
    
+   // if no mixing is required, stop here and post the output
+   if (fNMix < 1) {
+      AliDebugClass(2, "Stopping here, since no mixing is required");
+      PostData(1, fOutput);
+      return;
+   }
+   
+   // initialize mixing counter
+   TString *matched = new TString[nEvents];
+   for (ievt = 0; ievt < nEvents; ievt++) {
+      matched[ievt] = "|";
+   }
+   
+   // search for good matchings
+   for (ievt = 0; ievt < nEvents; ievt++) {
+      ifill = 0;
+      fEvBuffer->GetEntry(ievt);
+      AliRsnMiniEvent evMain(*fMiniEvent);
+      for (iloop = 1; iloop < nEvents; iloop++) {
+         imix = ievt + iloop;
+         if (imix >= nEvents) imix -= nEvents;
+         if (imix == ievt) continue;
+         // text next entry
+         fEvBuffer->GetEntry(imix);
+         // skip if events are not matched
+         if (TMath::Abs(evMain.Vz()    - fMiniEvent->Vz()   ) > fMaxDiffVz   ) continue;
+         if (TMath::Abs(evMain.Mult()  - fMiniEvent->Mult() ) > fMaxDiffMult ) continue;
+         if (TMath::Abs(evMain.Angle() - fMiniEvent->Angle()) > fMaxDiffAngle) continue;
+         // check that the array of good matches for mixed does not already contain main event
+         if (matched[imix].Contains(Form("|%d|", ievt))) continue;
+         // add new mixing candidate
+         matched[ievt].Append(Form("%d|", imix));
+         ifill++;
+         if (ifill >= fNMix) break;
+      }
+      //cout << "Matches for event " << Form("%5d", ievt) << ": " << matched[ievt].Data() << " (" << ifill << ")" << endl;
+   }
+   
+   // perform mixing
+   TObjArray *list = 0x0;
+   TObjString *os = 0x0;
+   for (ievt = 0; ievt < nEvents; ievt++) {
+      ifill = 0;
+      fEvBuffer->GetEntry(ievt);
+      AliRsnMiniEvent evMain(*fMiniEvent);
+      list = matched[ievt].Tokenize("|");
+      TObjArrayIter next(list);
+      while ( (os = (TObjString*)next()) ) {
+         imix = os->GetString().Atoi();
+         //cout << "Mixing " << ievt << " with " << imix << endl;
+         fEvBuffer->GetEntry(imix);
+         for (idef = 0; idef < nDefs; idef++) {
+            def = (AliRsnMiniOutput*)fHistograms[idef];
+            if (!def) continue;
+            if (!def->IsTrackPairMix()) continue;
+            ifill += def->FillPair(&evMain, fMiniEvent, &fValues);
+         }
+      }
+      delete list;
+   }
+   
+   delete [] matched;
+      
+   /*
+   OLD   
+   ifill = 0;
+   for (iloop = 1; iloop < nEvents; iloop++) {
+      imix = ievt + iloop;
+      // restart from beginning if reached last event
+      if (imix >= nEvents) imix -= nEvents;
+      // avoid to mix an event with itself
+      if (imix == ievt) continue;
+      // skip all events already mixed enough times
+      if (fNMixed[ievt] >= fNMix) break;
+      if (fNMixed[imix] >= fNMix) continue;
+      fEvBuffer->GetEntry(imix);
+      // skip if events are not matched
+      if (TMath::Abs(evMain.Vz()    - fMiniEvent->Vz()   ) > fMaxDiffVz   ) continue;
+      if (TMath::Abs(evMain.Mult()  - fMiniEvent->Mult() ) > fMaxDiffMult ) continue;
+      if (TMath::Abs(evMain.Angle() - fMiniEvent->Angle()) > fMaxDiffAngle) continue;
+      // found a match: increment counter for both events
+      AliDebugClass(1, Form("Event %d, def '%s': event mixing (%d with %d)", ievt, def->GetName(), ievt, imix));
+      fNMixed[ievt]++;
+      fNMixed[imix]++;
+      // process mixing
+      ifill += def->FillPair(&evMain, fMiniEvent, &fValues);
+      // stop if mixed enough times
+      if (fNMixed[ievt] >= fNMix) break;
+   }
+   break;      
    // print number of mixings done with each event
    for (ievt = 0; ievt < nEvents; ievt++) {
       AliDebugClass(2, Form("Event %6d: mixed %2d times", ievt, fNMixed[ievt]));
    }
+   */
    
    // post computed data
    PostData(1, fOutput);
index acc724812e0fd814b4b961420d6528f7f9028274..29d1dee2cdca22f8dee0156ffa3b26877c7649b3 100644 (file)
@@ -86,7 +86,6 @@ private:
    TObjArray            fTrackCuts;       //  list of single track cuts
    AliRsnEvent          fRsnEvent;        //! interface object to the event
    TTree               *fEvBuffer;        //! mini-event buffer
-   TArrayI              fNMixed;          //! array to keep trace of how many times an event was mixed
    AliTriggerAnalysis  *fTriggerAna;      //! trigger analysis
    AliESDtrackCuts     *fESDtrackCuts;    //! quality cut for ESD tracks
    AliRsnMiniEvent     *fMiniEvent;       //! mini-event cursor
index 7411c3630f5da91138745853066458742e4819c4..b70394d44627ae16298c184dcb10331a071aadc8 100644 (file)
@@ -253,13 +253,7 @@ Bool_t AliRsnMiniOutput::Init(const char *prefix, TList *list)
 
    switch (fOutputType) {
       case kHistogram:
-         if (size <= 3) {
-            CreateHistogram(Form("%s_%s", prefix, GetName()));
-         } else {
-            AliInfo(Form("[%s] Added %d > 3 axes. Creating a sparse histogram", GetName(), size));
-            fOutputType = kHistogramSparse;
-            CreateHistogramSparse(Form("%s_%s", prefix, GetName()));
-         }
+         CreateHistogram(Form("%s_%s", prefix, GetName()));
          return kTRUE;
       case kHistogramSparse:
          CreateHistogramSparse(Form("%s_%s", prefix, GetName()));