]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Multiple fixes:
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 12 Jul 2012 09:09:12 +0000 (09:09 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 12 Jul 2012 09:09:12 +0000 (09:09 +0000)
- Use TParameter<T> for storing parameters of the
  analysis rather than TNamed.  TNamed cannot be
  merged which results in a huge overhead of
  objects and time when merging containers with
  objects of that class.  TParameter<T> can be
  merged and should not imply this overhead.
- Fix memory leak and very inefficient and wrong code when
  inspecting the trigger words in AliFMDEventInspector.
  - The previous code (by Alexander) tokenized every
    defined trigger class (from the physiscs selection)
    on every event, but the returned TObjArray was never
    free'd - which causes a memory leak.
  - The code was wrong, because the trigger classes
    where only tokenized to get the positive and
    negative parts, and then the found trigger word
    was compared the positive part.  However, the
    positive part can consist of many words
    (separated by commas) and so the comparison
    would always fail.
  - The code was inefficient, since the classes
    where inspected on each event.  Since the
    trigger classes are constant over a run,
    it is much more efficient to cache the
    positive words up front (on the first event
    say).
  The new implementation caches the positive
  words for both collision and background triggers
  on the first event.  For each event, we then
  loop over these cached words and compare those
  to the found trigger word of the event.  In this
  way, we only tokenize the trigger classes once
  (actually, twice per class - one to get the
  positive list, one to get the individual words)
  and we make sure we clean up the memory.  In each
  event we can do simple comparisons (using the
  AliESDEvent supplied methods), and thereby
  speed up the code.  We also avoid hidden memory
  leaks and overly many allocations this way.
- Other clean up in the event inspector, so that all
  MC specific stuff is done in the derived class
  AliFMDMCEventInspector.
- Code in the event inspector has been re-factored
  into separate member functions for clear structure
  and easier maintaince.
- Debug statements added in various places to help
  identify problems (conditional on verbosity level
  of AliAnalysisManager)
- AliDisplacedVertexSelection had duplicate code
  in the member functions for the vertex and
  centrality.  This has been unified into a
  single member function Process that should be
  called early in each event.  This will set
  internal member variables which can be retrieved
  using GetVertexZ and GetCentralityPercentile.

IMPORTANT CHANGE FOR SATELITTE EVENT ANALYSIS:

  The AliFMDEventInspector when run over MC no
  longer tries to subsitute the IP z coordinate
  and centrality with information directly from
  the simulation.  Instead, this information is
  available from the
  AliFMDMCEventInspector::ProcessMC member function.

20 files changed:
PWGLF/FORWARD/analysis2/AliBasedNdetaTask.cxx
PWGLF/FORWARD/analysis2/AliBasedNdetaTask.h
PWGLF/FORWARD/analysis2/AliCentralMCCorrectionsTask.cxx
PWGLF/FORWARD/analysis2/AliDisplacedVertexSelection.cxx
PWGLF/FORWARD/analysis2/AliDisplacedVertexSelection.h
PWGLF/FORWARD/analysis2/AliFMDCorrector.cxx
PWGLF/FORWARD/analysis2/AliFMDDensityCalculator.cxx
PWGLF/FORWARD/analysis2/AliFMDEnergyFitter.cxx
PWGLF/FORWARD/analysis2/AliFMDEventInspector.cxx
PWGLF/FORWARD/analysis2/AliFMDEventInspector.h
PWGLF/FORWARD/analysis2/AliFMDMCEventInspector.cxx
PWGLF/FORWARD/analysis2/AliFMDMCEventInspector.h
PWGLF/FORWARD/analysis2/AliFMDMultCuts.cxx
PWGLF/FORWARD/analysis2/AliFMDMultCuts.h
PWGLF/FORWARD/analysis2/AliFMDSharingFilter.cxx
PWGLF/FORWARD/analysis2/AliForwardMCCorrectionsTask.cxx
PWGLF/FORWARD/analysis2/AliForwardMCMultiplicityTask.cxx
PWGLF/FORWARD/analysis2/AliForwardQATask.cxx
PWGLF/FORWARD/analysis2/AliForwardUtil.cxx
PWGLF/FORWARD/analysis2/AliForwardUtil.h

index 746dc8db349e5e6a6210b53e256cfde2bc8dc79f..10205b6ebe807ba5f21c2f2960a6370ad9a4d5f4 100644 (file)
@@ -5,7 +5,6 @@
 #include <TH1D.h>
 #include <THStack.h>
 #include <TList.h>
-#include <TParameter.h>
 #include <AliAnalysisManager.h>
 #include <AliAODEvent.h>
 #include <AliAODHandler.h>
@@ -280,9 +279,8 @@ AliBasedNdetaTask::SetNormalizationScheme(UShort_t scheme)
   fSchemeString->SetTitle(tit);
   fSchemeString->SetUniqueID(fNormalizationScheme);
 #else 
-  if (!fSchemeString) 
-    fSchemeString = new TParameter<int>("scheme", scheme);
-  fSchemeString->SetUniqueID(fNormalizationScheme);
+  if (fSchemeString) delete fSchemeString;
+  fSchemeString = AliForwardUtil::MakeParameter("scheme", scheme);
 #endif
 }
 //________________________________________________________________________
@@ -311,9 +309,8 @@ AliBasedNdetaTask::SetTriggerMask(UShort_t mask)
   fTriggerString->SetTitle(tit);
   fTriggerString->SetUniqueID(fTriggerMask);
 #else 
-  if (!fTriggerString) 
-    fTriggerString = new TParameter<int>("trigger", fTriggerMask);
-  fTriggerString->SetUniqueID(fTriggerMask);  
+  if (fTriggerString) delete fTriggerString;
+  fTriggerString = AliForwardUtil::MakeParameter("trigger", fTriggerMask);
 #endif
 }
 
@@ -460,16 +457,11 @@ AliBasedNdetaTask::UserExec(Option_t *)
   }
 #else
   if (!fSNNString) { 
-    UShort_t sNN = forward->GetSNN();
-    fSNNString = new TParameter<int>("sNN", sNN);
-    fSNNString->SetUniqueID(sNN);
+    fSNNString = AliForwardUtil::MakeParameter("sNN", forward->GetSNN());
+    fSysString = AliForwardUtil::MakeParameter("sys", forward->GetSystem());
+
     fSums->Add(fSNNString);
-  
-    UShort_t sys = forward->GetSystem();
-    fSysString = new TParameter<int>("sys", sys);
-    fSysString->SetUniqueID(sys);
     fSums->Add(fSysString);
-
     fSums->Add(fSchemeString);
     fSums->Add(fTriggerString);
 
@@ -652,11 +644,11 @@ AliBasedNdetaTask::Terminate(Option_t *)
   fOutput->SetName(Form("%s_result", GetName()));
   fOutput->SetOwner();
   
-  fSNNString     = static_cast<TParameter<int>*>(fSums->FindObject("sNN"));
-  fSysString     = static_cast<TParameter<int>*>(fSums->FindObject("sys"));
+  fSNNString     = fSums->FindObject("sNN");
+  fSysString     = fSums->FindObject("sys");
   fCentAxis      = static_cast<TAxis*>(fSums->FindObject("centAxis"));
-  fSchemeString  = static_cast<TParameter<int>*>(fSums->FindObject("scheme"));
-  fTriggerString = static_cast<TParameter<int>*>(fSums->FindObject("trigger"));
+  fSchemeString  = fSums->FindObject("scheme");
+  fTriggerString = fSums->FindObject("trigger");
 
   if(fSysString && fSNNString && 
      fSysString->GetUniqueID() == AliForwardUtil::kPP)
@@ -796,7 +788,7 @@ AliBasedNdetaTask::Terminate(Option_t *)
   fOutput->Add(vtxAxis);
 
   // Output trigger efficiency and shape correction 
-  fOutput->Add(new TParameter<Double_t>("triggerEff", fTriggerEff)); 
+  fOutput->Add(AliForwardUtil::MakeParameter("triggerEff", fTriggerEff));
   if (fShapeCorr) fOutput->Add(fShapeCorr);
 
   TNamed* options = new TNamed("options","");
@@ -863,10 +855,12 @@ AliBasedNdetaTask::LoadNormalizationData(UShort_t sys, UShort_t energy)
                       fTriggerMask == AliAODForwardMult::kNSD ? "nsd" :
                       fTriggerMask == AliAODForwardMult::kInelGt0 ?
                       "inelgt0" : "all"));
-  TParameter<float>* eff = 0;
-  if (fNormalizationScheme & kTriggerEfficiency) 
-    eff = static_cast<TParameter<float>*>(fin->Get(effName));
-  Double_t trigEff = eff ? eff->GetVal() : 1;
+
+  Double_t trigEff = 1; 
+  if (fNormalizationScheme & kTriggerEfficiency) { 
+    TObject* eff = fin->Get(effName);
+    if (eff) AliForwardUtil::GetParameter(eff, trigEff);
+  }
   if (fTriggerEff != 1) SetTriggerEff(trigEff);
   if (fTriggerEff < 0)  fTriggerEff = 1;
 
index 1772de5738e1c7d8b18a6cadb3ad528d92deee7f..50d59e4a7405ed13b9174e7db37aa83e186b59d7 100644 (file)
@@ -14,7 +14,6 @@
  * 
  */
 #include <AliAnalysisTaskSE.h>
-#include <TParameter.h>
 class TAxis;
 class TList;
 class TH2D;
@@ -865,8 +864,8 @@ protected:
   TNamed*         fSNNString;    // sqrt(s_NN) string 
   TNamed*         fSysString;    // Collision system string 
 #else
-  TParameter<int>* fSNNString;    // sqrt(s_NN) string 
-  TParameter<int>* fSysString;    // Collision system string 
+  TObject* fSNNString;    // sqrt(s_NN) string 
+  TObject* fSysString;    // Collision system string 
 #endif
   TH1D*           fCent;         // Centrality distribution 
   TAxis*          fCentAxis;     // Centrality axis
@@ -875,12 +874,12 @@ protected:
   TNamed*         fSchemeString;     // Normalization scheme string
   TNamed*         fTriggerString;    // Trigger string 
 #else 
-  TParameter<int>* fSchemeString;    // Normalization scheme string
-  TParameter<int>* fTriggerString;    // Trigger string 
+  TObject*        fSchemeString;    // Normalization scheme string
+  TObject*        fTriggerString;    // Trigger string 
 #endif
   TString         fFinalMCCorrFile; //Filename for final MC corr
   
-  ClassDef(AliBasedNdetaTask,7); // Determine multiplicity in base area
+  ClassDef(AliBasedNdetaTask,8); // Determine multiplicity in base area
 };
 
 #endif
index b1b75741a08965cff25b29e72884429307f3d055..ae7629818c8a1ca966089288adea3d96160136cc 100644 (file)
@@ -39,21 +39,6 @@ namespace {
   {
     return Form("nEvents%s%s", (tr ? "Tr" : ""), (vtx ? "Vtx" : ""));
   }
-  /*const char* GetHitsName(UShort_t d, Char_t r) 
-  {
-    return Form("hitsSPD%d%c", d, r);
-  }
-  const char* GetStripsName(UShort_t d, Char_t r)
-  {
-    return Form("stripsSPD%d%c", d, r);
-  }
-  const char* GetPrimaryName(Char_t r, Bool_t trVtx)
-  {
-    return Form("primaries%s%s", 
-               ((r == 'I' || r == 'i') ? "Inner" : "Outer"), 
-               (trVtx ? "TrVtx" : "All"));
-               }
-  */
 }
 
 //====================================================================
@@ -391,6 +376,7 @@ AliCentralMCCorrectionsTask::UserExec(Option_t*)
   UShort_t iVzMc;    // Vertex bin from MC
   Double_t vZMc;     // Z coordinate of IP vertex from MC
   Double_t b;        // Impact parameter
+  Double_t cMC;      // Centrality estimate from b
   Int_t    nPart;    // Number of participants 
   Int_t    nBin;     // Number of binary collisions 
   Double_t phiR;     // Reaction plane from MC
@@ -399,7 +385,7 @@ AliCentralMCCorrectionsTask::UserExec(Option_t*)
   UInt_t retESD = fInspector.Process(esd, triggers, lowFlux, iVz, vZ, 
                                     cent, nClusters);
   fInspector.ProcessMC(mcEvent, triggers, iVzMc, vZMc, 
-                      b, nPart, nBin, phiR);
+                      b, cMC, nPart, nBin, phiR);
 
   Bool_t isInel   = triggers & AliAODForwardMult::kInel;
   Bool_t hasVtx   = retESD == AliFMDMCEventInspector::kOk;
index e38a73fcb9bff0c8fcf21061b6b35b0c83367b2f..75b11dbeac947a67956761b1b45e7ba59f0460b1 100644 (file)
@@ -10,12 +10,16 @@ ClassImp(AliDisplacedVertexSelection)
 
 //____________________________________________________________________
 AliDisplacedVertexSelection::AliDisplacedVertexSelection()
-  : TObject()
+  : TObject(), 
+    fVertexZ(9999), 
+    fCent(100)
 {
 }
 //____________________________________________________________________
 AliDisplacedVertexSelection::AliDisplacedVertexSelection(const AliDisplacedVertexSelection& o)
-  : TObject(o)
+  : TObject(o), 
+    fVertexZ(9999), 
+    fCent(100)
 {
 }
 //____________________________________________________________________
@@ -44,11 +48,148 @@ AliDisplacedVertexSelection::Print(Option_t*) const
            << std::noboolalpha << std::endl;
 #endif
 }
+
 //____________________________________________________________________
+Bool_t
+AliDisplacedVertexSelection::Process(const AliESDEvent* esd)
+{
+  fVertexZ = 9999; // Default vertex value 
+  fCent    = 100;  // Default centrality value 
+
+  // Some constants 
+  const Float_t kZDCrefSum        = -66.5;
+  const Float_t kZDCrefDelta      =  -2.10;
+  const Float_t kZDCsigmaSum      =   3.25;
+  const Float_t kZDCsigmaDelta    =   2.25;
+  const Float_t kZDCsigmaSumSat   =   2.50;
+  const Float_t kZDCsigmaDeltaSat =   1.35;  
+  
+  // Corrections for magnetic fields
+  const Float_t kZEMcorrPlusPlus[21]   = {0.6840,0.7879,0.8722,
+                                         0.9370,0.9837,1.0137,
+                                         1.0292,1.0327,1.0271,
+                                         1.0152,1.0000,0.9844,
+                                         0.9714,0.9634,0.9626,
+                                         0.9708,0.9891,1.0181,
+                                         1.0574,1.1060,1.1617};
+  const Float_t kZEMcorrMoinsMoins[21] = {0.7082,0.8012,0.8809,
+                                         0.9447,0.9916,1.0220,
+                                         1.0372,1.0395,1.0318,
+                                         1.0174,1.0000,0.9830,
+                                         0.9699,0.9635,0.9662,
+                                         0.9794,1.0034,1.0371,
+                                         1.0782,1.1224,1.1634};
+
+  // --- Get the ESD object ------------------------------------------
+  AliESDZDC* esdZDC = esd->GetESDZDC();
+  if (!esdZDC) { 
+    AliWarning("No ZDC ESD object!");
+    return false; 
+  }
+  Double_t currentL3   = esd->GetCurrentL3();
+  Double_t currentDipo = esd->GetCurrentDip();
+
+  // --- ZDC and ZEM energy signal -----------------------------------
+  Double_t zdcEn      = (esdZDC->GetZDCN1Energy()+
+                        esdZDC->GetZDCP1Energy()+
+                        esdZDC->GetZDCN2Energy()+
+                        esdZDC->GetZDCP2Energy());
+  Double_t zemEn      = (esdZDC->GetZDCEMEnergy(0)+
+                        esdZDC->GetZDCEMEnergy(1))/8.;
+
+  // --- Calculate DeltaT and sumT -----------------------------------
+  Double_t deltaTdc = 0;
+  Double_t sumTdc   = 0;
+   
+  for(Int_t i = 0; i < 4; ++i) {
+    if(esdZDC->GetZDCTDCData(10,i) != 0) {
+      Double_t  tdcCnoCorr = 0.025*(esdZDC->GetZDCTDCData(10,i)-
+                                   esdZDC->GetZDCTDCData(14,i)); 
+      Double_t  tdcC       = esdZDC->GetZDCTDCCorrected(10,i); 
+      for(Int_t j = 0; j < 4; ++j) {
+       if(esdZDC->GetZDCTDCData(12,j) != 0) {
+         Double_t   tdcAnoCorr = 0.025*(esdZDC->GetZDCTDCData(12,j)-
+                                        esdZDC->GetZDCTDCData(14,j));
+         Double_t   tdcA       = esdZDC->GetZDCTDCCorrected(12,j);
+         if(esdZDC->TestBit(AliESDZDC::kCorrectedTDCFilled)) {     
+           deltaTdc = tdcC-tdcA;
+           sumTdc   = tdcC+tdcA;
+         }
+         else {
+           deltaTdc = tdcCnoCorr-tdcAnoCorr;
+           sumTdc   = tdcCnoCorr+tdcAnoCorr;
+         }
+       }
+      }
+    }
+  }
+
+  // --- Find the vertex ---------------------------------------------
+  if(deltaTdc!=0. || sumTdc!=0.) {
+    for (Int_t k = -10; k <= 10; ++k) {
+      Float_t zsat  = 2.55F * k;
+      Float_t delta = (k == 0 ? kZDCsigmaDelta : kZDCsigmaDeltaSat);
+      Float_t sum   = (k == 0 ? kZDCsigmaSum   : kZDCsigmaSumSat);
+      Float_t dT    = deltaTdc - kZDCrefDelta - zsat;
+      Float_t sT    = sumTdc  - kZDCrefSum - zsat;
+      Float_t check = dT * dT / delta / delta + sT * sT / sum  / sum;
+      if (check > 1.0 || k == 0) continue; 
+      
+      // Set the vertex 
+      fVertexZ = 37.5 * k;
+      
+      // Correct zem energy 
+      if(currentDipo>0 && currentL3>0) zemEn /= kZEMcorrPlusPlus[k+10];
+      if(currentDipo<0 && currentL3<0) zemEn /= kZEMcorrMoinsMoins[k+10];
+    }
+  }
+
+  // --- Calculate the centrality ------------------------------------
+  Float_t c1, c2, c3, c4, c5;
+  Int_t runnumber = esd->GetRunNumber();
+  if (runnumber < 137722 && runnumber >= 137161 ) {
+    c1 = 16992;
+    c2 = 345;
+    c3 = 2.23902e+02;
+    c4 = 1.56667;
+    c5 = 9.49434e-05;
+  }
+  else if (runnumber < 139172 && runnumber >= 137722) {
+    c1  = 15000;
+    c2  = 295;
+    c3  = 2.23660e+02;
+    c4 = 1.56664;
+    c5 = 8.99571e-05;
+  }
+  else if (runnumber >= 139172) {
+    c1 = 16992;
+    c2 = 345;
+    c3 = 2.04789e+02;
+    c4 = 1.56629;
+    c5 = 1.02768e-04;
+  }
+  else {
+    c1 = 16992;
+    c2 = 345;
+    c3 = 2.04789e+02;
+    c4 = 1.56629;
+    c5 = 1.02768e-04;
+  }
+
+  if (zemEn > c2) { 
+    Float_t slope   = (zdcEn + c1) / (zemEn - c2) + c3;
+    Float_t zdcCent = (TMath::ATan(slope) - c4) / c5;
+    if (zdcCent >= 0) fCent = zdcCent;
+  }
 
+  return true;
+}
+
+//____________________________________________________________________
 Double_t
 AliDisplacedVertexSelection::CheckDisplacedVertex(const AliESDEvent* esd) const {
   // Code taken directly from M.Guilbaud.
+  AliWarning("This method is deprecated");
   Double_t zvtx = 9999.;
   
   Float_t kZDCrefSum        =-66.5;
@@ -71,88 +212,76 @@ AliDisplacedVertexSelection::CheckDisplacedVertex(const AliESDEvent* esd) const
   //Double_t fzemEn      = (esdZDC->GetZDCEMEnergy(0)+esdZDC->GetZDCEMEnergy(1))/8.;
   
 
-///////////////////
-//Event Selection//
-///////////////////
- Double_t deltaTdc = 0;
- Double_t sumTdc   = 0;
+
+  ///////////////////
+  //Event Selection//
+  ///////////////////
+  Double_t deltaTdc = 0;
+  Double_t sumTdc   = 0;
    
-for(Int_t i = 0; i < 4; ++i) 
-   {
-        if(esdZDC->GetZDCTDCData(10,i) != 0) 
-         {
-             Double_t  tdcCnoCorr = 0.025*(esdZDC->GetZDCTDCData(10,i)-esdZDC->GetZDCTDCData(14,i)); 
-             Double_t  tdcC       = esdZDC->GetZDCTDCCorrected(10,i); 
-              for(Int_t j = 0; j < 4; ++j) 
-                 {
-                      if(esdZDC->GetZDCTDCData(12,j) != 0) 
-                        {
-                           Double_t   tdcAnoCorr = 0.025*(esdZDC->GetZDCTDCData(12,j)-esdZDC->GetZDCTDCData(14,j));
-                            Double_t   tdcA       = esdZDC->GetZDCTDCCorrected(12,j);
-                             if(esdZDC->TestBit(AliESDZDC::kCorrectedTDCFilled)) 
-                               {           
-                                     deltaTdc = tdcC-tdcA;
-                                     sumTdc   = tdcC+tdcA;
-                               }
-                             else
-                               {
-                                     deltaTdc = tdcCnoCorr-tdcAnoCorr;
-                                     sumTdc   = tdcCnoCorr+tdcAnoCorr;
-                               }
-                        }
-                 }
-          }
-   }
-//if(TMath::Abs(deltaTdc) > 0)
-//std::cout<<deltaTdc<<"   "<<sumTdc<<std::endl;
-///////////////////////
-//Global Event Filter//
-///////////////////////
- Bool_t zdcAccSat[21];
- // Bool_t zdcAccSatRunClass[21];
- for(Int_t k = -10; k <= 10; k++) 
-   {
-      zdcAccSat[k+10]         = kFALSE;
-      // zdcAccSatRunClass[k+10] = kFALSE;
-   }
+  for(Int_t i = 0; i < 4; ++i) {
+    if(esdZDC->GetZDCTDCData(10,i) != 0) {
+      Double_t  tdcCnoCorr = 0.025*(esdZDC->GetZDCTDCData(10,i)-
+                                   esdZDC->GetZDCTDCData(14,i)); 
+      Double_t  tdcC       = esdZDC->GetZDCTDCCorrected(10,i); 
+      for(Int_t j = 0; j < 4; ++j) {
+       if(esdZDC->GetZDCTDCData(12,j) != 0) {
+         Double_t   tdcAnoCorr = 0.025*(esdZDC->GetZDCTDCData(12,j)-
+                                        esdZDC->GetZDCTDCData(14,j));
+         Double_t   tdcA       = esdZDC->GetZDCTDCCorrected(12,j);
+         if(esdZDC->TestBit(AliESDZDC::kCorrectedTDCFilled)) {     
+           deltaTdc = tdcC-tdcA;
+           sumTdc   = tdcC+tdcA;
+         }
+         else {
+           deltaTdc = tdcCnoCorr-tdcAnoCorr;
+           sumTdc   = tdcCnoCorr+tdcAnoCorr;
+         }
+       }
+      }
+    }
+  }
 
+  ///////////////////////
+  //Global Event Filter//
+  ///////////////////////
+  Bool_t zdcAccSat[21];
 
-if(deltaTdc!=0. || sumTdc!=0.)
-  {
+  // Bool_t zdcAccSatRunClass[21];
+  for(Int_t k = -10; k <= 10; k++) zdcAccSat[k+10] = kFALSE;
 
-     for(Int_t k = -10; k <= 10; ++k) 
-        {
-            Float_t zsat = 2.55*(Float_t)k;
+
+  if(deltaTdc!=0. || sumTdc!=0.) {
+    for (Int_t k = -10; k <= 10; ++k) {
+      Float_t zsat = 2.55F * k;
                
-            if(k==0)
-              {
-                    if(((deltaTdc-kZDCrefDelta)*(deltaTdc-kZDCrefDelta)/(kZDCsigmaDelta*kZDCsigmaDelta)+
-                        (sumTdc  -kZDCrefSum  )*(sumTdc  -kZDCrefSum  )/(kZDCsigmaSum  *kZDCsigmaSum))<=1.0)
-                      {
-                          zdcAccSat[k+10] = kTRUE;
-                      }        
-              }
-            else
-              {
-                    if(((deltaTdc-kZDCrefDelta-zsat)*(deltaTdc-kZDCrefDelta-zsat)/(kZDCsigmaDeltaSat*kZDCsigmaDeltaSat)+
-                        (sumTdc  -kZDCrefSum  -zsat)*(sumTdc  -kZDCrefSum  -zsat)/(kZDCsigmaSumSat  *kZDCsigmaSumSat  ))<=1.0)
-                      {
-                          zdcAccSat[k+10] = kTRUE;
-                      }                
-         
-              }
-         
-         }
+      if(k==0) {
+       if(((deltaTdc-kZDCrefDelta)*(deltaTdc-kZDCrefDelta)/
+           (kZDCsigmaDelta*kZDCsigmaDelta)+
+           (sumTdc  -kZDCrefSum  ) * (sumTdc  -kZDCrefSum  ) / 
+           (kZDCsigmaSum  *kZDCsigmaSum))<=1.0) {
+         zdcAccSat[k+10] = kTRUE;
+       }       
+      }
+      else {
+       if(((deltaTdc-kZDCrefDelta-zsat)*(deltaTdc-kZDCrefDelta-zsat)/
+           (kZDCsigmaDeltaSat*kZDCsigmaDeltaSat)+
+           (sumTdc  -kZDCrefSum  -zsat)*(sumTdc  -kZDCrefSum  -zsat)/
+           (kZDCsigmaSumSat  *kZDCsigmaSumSat  ))<=1.0) {
+         zdcAccSat[k+10] = kTRUE;
+       }               
+      }
+    }
   }
    
- for(Int_t k=-10;k<=10;++k) {
-   if(zdcAccSat[k+10] && k!=0 ) {
-     //std::cout<<"Displaced vertex at "<<37.5*(Float_t)k<<" cm"<<std::endl; 
-     zvtx = 37.5*(Float_t)k;
-   }
- }
 for(Int_t k=-10;k<=10;++k) {
+    if(zdcAccSat[k+10] && k!=0 ) {
+      //std::cout<<"Displaced vertex at "<<37.5*(Float_t)k<<" cm"<<std::endl; 
+      zvtx = 37.5*(Float_t)k;
+    }
 }
  
- return zvtx;
 return zvtx;
  
 }
 //____________________________________________________________________
@@ -173,172 +302,147 @@ AliDisplacedVertexSelection::CalculateDisplacedVertexCent(const AliESDEvent* esd
   Double_t fcurrentDipo = esd->GetCurrentDip();
   Double_t cent = -1;
   
-  /*Double_t zdcNCEnergy  = esdZDC->GetZDCN1Energy();
-  Double_t fZpcEnergy  = esdZDC->GetZDCP1Energy();
-  Double_t fZnaEnergy  = esdZDC->GetZDCN2Energy();
-  Double_t fZpaEnergy  = esdZDC->GetZDCP2Energy();
-  Double_t fZem1Energy = esdZDC->GetZDCEMEnergy(0);
-  Double_t fZem2Energy = esdZDC->GetZDCEMEnergy(1);*/
-  
-  Double_t fzdcEn      = (esdZDC->GetZDCN1Energy()+esdZDC->GetZDCP1Energy()+esdZDC->GetZDCN2Energy()+esdZDC->GetZDCP2Energy());
-  Double_t fzemEn      = (esdZDC->GetZDCEMEnergy(0)+esdZDC->GetZDCEMEnergy(1))/8.;
+  Double_t fzdcEn      = (esdZDC->GetZDCN1Energy()+
+                         esdZDC->GetZDCP1Energy()+
+                         esdZDC->GetZDCN2Energy()+
+                         esdZDC->GetZDCP2Energy());
+  Double_t fzemEn      = (esdZDC->GetZDCEMEnergy(0)+
+                         esdZDC->GetZDCEMEnergy(1))/8.;
   
 
-///////////////////
-//Event Selection//
-///////////////////
- Double_t deltaTdc = 0;
- Double_t sumTdc   = 0;
+  ///////////////////
+  //Event Selection//
+  ///////////////////
 Double_t deltaTdc = 0;
 Double_t sumTdc   = 0;
    
-for(Int_t i = 0; i < 4; ++i) 
-   {
-        if(esdZDC->GetZDCTDCData(10,i) != 0) 
-         {
-             Double_t  tdcCnoCorr = 0.025*(esdZDC->GetZDCTDCData(10,i)-esdZDC->GetZDCTDCData(14,i)); 
-             Double_t  tdcC       = esdZDC->GetZDCTDCCorrected(10,i); 
-              for(Int_t j = 0; j < 4; ++j) 
-                 {
-                      if(esdZDC->GetZDCTDCData(12,j) != 0) 
-                        {
-                           Double_t   tdcAnoCorr = 0.025*(esdZDC->GetZDCTDCData(12,j)-esdZDC->GetZDCTDCData(14,j));
-                            Double_t   tdcA       = esdZDC->GetZDCTDCCorrected(12,j);
-                             if(esdZDC->TestBit(AliESDZDC::kCorrectedTDCFilled)) 
-                               {           
-                                     deltaTdc = tdcC-tdcA;
-                                     sumTdc   = tdcC+tdcA;
-                               }
-                             else
-                               {
-                                     deltaTdc = tdcCnoCorr-tdcAnoCorr;
-                                     sumTdc   = tdcCnoCorr+tdcAnoCorr;
-                               }
-                        }
-                 }
-          }
-   }
-//if(TMath::Abs(deltaTdc) > 0)
-//std::cout<<deltaTdc<<"   "<<sumTdc<<std::endl;
-///////////////////////
-//Global Event Filter//
-///////////////////////
- Bool_t zdcAccSat[21];
- // Bool_t zdcAccSatRunClass[21];
-for(Int_t k = -10; k <= 10; k++) 
-   {
-      zdcAccSat[k+10]         = kFALSE;
-      // zdcAccSatRunClass[k+10] = kFALSE;
-   }
-
+  for(Int_t i = 0; i < 4; ++i) {
+    if(esdZDC->GetZDCTDCData(10,i) != 0) {
+      Double_t  tdcCnoCorr = 0.025*(esdZDC->GetZDCTDCData(10,i)-
+                                   esdZDC->GetZDCTDCData(14,i)); 
+      Double_t  tdcC       = esdZDC->GetZDCTDCCorrected(10,i); 
+      for(Int_t j = 0; j < 4; ++j) {
+       if(esdZDC->GetZDCTDCData(12,j) != 0) {
+         Double_t   tdcAnoCorr = 0.025*(esdZDC->GetZDCTDCData(12,j)-
+                                        esdZDC->GetZDCTDCData(14,j));
+         Double_t   tdcA       = esdZDC->GetZDCTDCCorrected(12,j);
+         if(esdZDC->TestBit(AliESDZDC::kCorrectedTDCFilled)) {     
+           deltaTdc = tdcC-tdcA;
+           sumTdc   = tdcC+tdcA;
+         }
+         else {
+           deltaTdc = tdcCnoCorr-tdcAnoCorr;
+           sumTdc   = tdcCnoCorr+tdcAnoCorr;
+         }
+       }
+      }
+    }
+  }
 
-if(deltaTdc!=0. || sumTdc!=0.)
-  {
+  ///////////////////////
+  //Global Event Filter//
+  ///////////////////////
+  Bool_t zdcAccSat[21];
+  // Bool_t zdcAccSatRunClass[21];
+  for(Int_t k = -10; k <= 10; k++)  zdcAccSat[k+10]         = kFALSE;
 
-     for(Int_t k = -10; k <= 10; ++k) 
-        {
-            Float_t zsat = 2.55*(Float_t)k;
+  if(deltaTdc!=0. || sumTdc!=0.) {
+    for(Int_t k = -10; k <= 10; ++k) {
+      Float_t zsat = 2.55*(Float_t)k;
                
-            if(k==0)
-              {
-                    if(((deltaTdc-kZDCrefDelta)*(deltaTdc-kZDCrefDelta)/(kZDCsigmaDelta*kZDCsigmaDelta)+
-                        (sumTdc  -kZDCrefSum  )*(sumTdc  -kZDCrefSum  )/(kZDCsigmaSum  *kZDCsigmaSum))<=1.0)
-                      {
-                          zdcAccSat[k+10] = kTRUE;
-                      }        
-              }
-            else
-              {
-                    if(((deltaTdc-kZDCrefDelta-zsat)*(deltaTdc-kZDCrefDelta-zsat)/(kZDCsigmaDeltaSat*kZDCsigmaDeltaSat)+
-                        (sumTdc  -kZDCrefSum  -zsat)*(sumTdc  -kZDCrefSum  -zsat)/(kZDCsigmaSumSat  *kZDCsigmaSumSat  ))<=1.0)
-                      {
-                          zdcAccSat[k+10] = kTRUE;
-                      }                
-         
-              }
-         
-         }
+      if(k==0) {
+       if(((deltaTdc-kZDCrefDelta)*(deltaTdc-kZDCrefDelta)/
+           (kZDCsigmaDelta*kZDCsigmaDelta)+
+           (sumTdc  -kZDCrefSum  )*(sumTdc  -kZDCrefSum  )/
+           (kZDCsigmaSum  *kZDCsigmaSum))<=1.0) {
+         zdcAccSat[k+10] = kTRUE;
+       }       
+      }
+      else {
+       if(((deltaTdc-kZDCrefDelta-zsat)*(deltaTdc-kZDCrefDelta-zsat)/
+           (kZDCsigmaDeltaSat*kZDCsigmaDeltaSat)+
+           (sumTdc  -kZDCrefSum  -zsat)*(sumTdc  -kZDCrefSum  -zsat)/
+           (kZDCsigmaSumSat  *kZDCsigmaSumSat  ))<=1.0) {
+         zdcAccSat[k+10] = kTRUE;
+       }               
+       
+      }
+      
+    }
   }
 
- Float_t kZEMcorrPlusPlus[21]   = {0.6840,0.7879,0.8722,0.9370,0.9837,1.0137,
-                                  1.0292,1.0327,1.0271,1.0152,1.0000,0.9844,
-                                  0.9714,0.9634,0.9626,0.9708,0.9891,1.0181,
-                                  1.0574,1.1060,1.1617};
- Float_t kZEMcorrMoinsMoins[21] = {0.7082,0.8012,0.8809,0.9447,0.9916,1.0220,
-                                  1.0372,1.0395,1.0318,1.0174,1.0000,0.9830,
-                                  0.9699,0.9635,0.9662,0.9794,1.0034,1.0371,
-                                  1.0782,1.1224,1.1634};
- ///////////////////
- //ZemEn correction//
- ////////////////////
 Float_t kZEMcorrPlusPlus[21]   = {0.6840,0.7879,0.8722,0.9370,0.9837,1.0137,
+                                   1.0292,1.0327,1.0271,1.0152,1.0000,0.9844,
+                                   0.9714,0.9634,0.9626,0.9708,0.9891,1.0181,
+                                   1.0574,1.1060,1.1617};
 Float_t kZEMcorrMoinsMoins[21] = {0.7082,0.8012,0.8809,0.9447,0.9916,1.0220,
+                                   1.0372,1.0395,1.0318,1.0174,1.0000,0.9830,
+                                   0.9699,0.9635,0.9662,0.9794,1.0034,1.0371,
+                                   1.0782,1.1224,1.1634};
 ///////////////////
 //ZemEn correction//
 ////////////////////
 
- for(Int_t k = -10; k <= 10; ++k)
-   {        
-     if(zdcAccSat[k+10])
-       { 
-        //std::cout<<"Vertex at "<<37.5*(Float_t)k<<"cm from cent"<<std::endl;
-         if(fcurrentDipo>0 && fcurrentL3>0)
-          {
-            fzemEn /= kZEMcorrPlusPlus[k+10];
-          }
-        if(fcurrentDipo<0 && fcurrentL3<0)
-          {
-            fzemEn /= kZEMcorrMoinsMoins[k+10];
-          }
-       }          
-   }
+  for(Int_t k = -10; k <= 10; ++k) {        
+    if(zdcAccSat[k+10]) { 
+      //std::cout<<"Vertex at "<<37.5*(Float_t)k<<"cm from cent"<<std::endl;
+      if(fcurrentDipo>0 && fcurrentL3>0) {
+       fzemEn /= kZEMcorrPlusPlus[k+10];
+      }
+      if(fcurrentDipo<0 && fcurrentL3<0) {
+       fzemEn /= kZEMcorrMoinsMoins[k+10];
+      }
+    }          
+  }
  
- ////////////////////////
- //Centrality selection//
- ////////////////////////
- Double_t fzdcPercentile = -1;
- Float_t slope;
 ////////////////////////
 //Centrality selection//
 ////////////////////////
 Double_t fzdcPercentile = -1;
 Float_t slope;
  
  
- if(runnumber < 137722 && runnumber >= 137161 )
-   {
-     if(fzemEn > 345.)
-       {
-        slope = (fzdcEn + 16992.)/(fzemEn - 345.);
-        slope += 2.23902e+02;
-        fzdcPercentile = (TMath::ATan(slope) - 1.56667)/9.49434e-05;
-        if (fzdcPercentile<0) fzdcPercentile = 0;
-       }
-     else fzdcPercentile = 100;                }
- else if(runnumber < 139172 && runnumber >= 137722)
-   {
-     if(fzemEn > 295.)
-       {
-        slope = (fzdcEn + 15000.)/(fzemEn - 295.);
-        slope += 2.23660e+02;
-        fzdcPercentile = (TMath::ATan(slope) - 1.56664)/8.99571e-05;
-        if (fzdcPercentile<0) fzdcPercentile = 0;
-       }                            else fzdcPercentile = 100;          }
-
-
- else if(runnumber >= 139172)
-   {
-     if(fzemEn > 345.)
-       {
-        slope = (fzdcEn + 16992.)/(fzemEn - 345.);
-        slope += 2.04789e+02;
-        fzdcPercentile = (TMath::ATan(slope) - 1.56629)/1.02768e-04;
-        if (fzdcPercentile<0) fzdcPercentile = 0;
-       }                               else fzdcPercentile = 100;           }
- else
-   {
-     if(fzemEn > 345.)
-       {
-        slope = (fzdcEn + 16992.)/(fzemEn - 345.);
-        slope += 2.04789e+02;
-        fzdcPercentile = (TMath::ATan(slope) - 1.56629)/1.02768e-04;
-        if(fzdcPercentile<0) fzdcPercentile = 0;
-       }
-     else fzdcPercentile = 100;                  }
- if(fzdcPercentile > 0 && fzdcPercentile <100) {
-   //std::cout<<fzdcPercentile<<std::endl;
-   cent = fzdcPercentile;
- }
- return cent;
+  if(runnumber < 137722 && runnumber >= 137161 ) {
+    if(fzemEn > 345.) {
+      slope = (fzdcEn + 16992.)/(fzemEn - 345.);
+      slope += 2.23902e+02;
+      fzdcPercentile = (TMath::ATan(slope) - 1.56667)/9.49434e-05;
+      if (fzdcPercentile<0) fzdcPercentile = 0;
+    }
+    else fzdcPercentile = 100;                }
+  else if(runnumber < 139172 && runnumber >= 137722) {
+    if(fzemEn > 295.) {
+      slope = (fzdcEn + 15000.)/(fzemEn - 295.);
+      slope += 2.23660e+02;
+      fzdcPercentile = (TMath::ATan(slope) - 1.56664)/8.99571e-05;
+      if (fzdcPercentile<0) fzdcPercentile = 0;
+    }
+    else fzdcPercentile = 100;          
+  }
+  else if(runnumber >= 139172) {
+    if(fzemEn > 345.) {
+      slope = (fzdcEn + 16992.)/(fzemEn - 345.);
+      slope += 2.04789e+02;
+      fzdcPercentile = (TMath::ATan(slope) - 1.56629)/1.02768e-04;
+      if (fzdcPercentile<0) fzdcPercentile = 0;
+    }                               
+    else fzdcPercentile = 100;           
+  }
+  else {
+    if(fzemEn > 345.) {
+      slope = (fzdcEn + 16992.)/(fzemEn - 345.);
+      slope += 2.04789e+02;
+      fzdcPercentile = (TMath::ATan(slope) - 1.56629)/1.02768e-04;
+      if(fzdcPercentile<0) fzdcPercentile = 0;
+    }
+    else fzdcPercentile = 100;                  
+  }
+  
+  if(fzdcPercentile > 0 && fzdcPercentile <100) {
+    //std::cout<<fzdcPercentile<<std::endl;
+    cent = fzdcPercentile;
+  }
+  return cent;
 }
 //____________________________________________________________________
 //
index 5c33a76e9804040b42bded1a34b4acecda8f135c..ff70299e30028ac2acef956a20a4045e464ed97b 100644 (file)
@@ -40,6 +40,17 @@ public:
    * @param option  Not used 
    */
   void Print(Option_t* option="") const;
+  /** 
+   * Process an ESD event to get the information 
+   * 
+   * @param esd ESD event 
+   * 
+   * @return true on success
+   */
+  Bool_t Process(const AliESDEvent* esd);
+
+  Double_t GetVertexZ() const { return fVertexZ; }
+  Double_t GetCentralityPercentile() const { return fCent; }
   /** 
    * Check for displaced vertices (M.Guilbaud) 
    * 
@@ -58,7 +69,8 @@ public:
   Double_t CalculateDisplacedVertexCent(const AliESDEvent* esd) const;
   
 protected:
-  
+  Double_t fVertexZ;
+  Double_t fCent;
   
   ClassDef(AliDisplacedVertexSelection,1); // Cuts on ESD Mult 
 };
index 10e436890ffd6744aa214b5866235d58b2331b24..4a6b3fee7c8bc2b32086591949286d96dbcba5bf 100644 (file)
@@ -341,6 +341,13 @@ AliFMDCorrector::DefineOutput(TList* dir)
   TList* d = new TList;
   d->SetName(GetName());
   dir->Add(d);
+
+  d->Add(AliForwardUtil::MakeParameter("secondary", fUseSecondaryMap));
+  d->Add(AliForwardUtil::MakeParameter("vertexBias", fUseVertexBias));
+  d->Add(AliForwardUtil::MakeParameter("acceptance", fUseAcceptance));
+  d->Add(AliForwardUtil::MakeParameter("merging", fUseMergingEfficiency));
+  
+
   TIter    next(&fRingHistos);
   RingHistos* o = 0;
   while ((o = static_cast<RingHistos*>(next()))) {
index bec3bf93f2074779dd9cc3279c84d9b30a448cde..60de22fba445debaf3189a0baa8f4eee0bd286d2 100644 (file)
@@ -14,7 +14,6 @@
 #include <TProfile.h>
 #include <THStack.h>
 #include <TROOT.h>
-#include <TParameter.h>
 #include <iostream>
 #include <iomanip>
 
@@ -435,7 +434,7 @@ AliFMDDensityCalculator::FindMaxWeight(const AliFMDCorrELossFit* cor,
   //    r     Ring 
   //    iEta  Eta bin 
   //
-  DGUARD(fDebug, 3, "Find maximum weight in FMD density calculator");
+  DGUARD(fDebug, 10, "Find maximum weight in FMD density calculator");
   if(!cor) return -1; 
 
   AliFMDCorrELossFit::ELossFit* fit = cor->GetFit(d,r,iEta);
@@ -657,7 +656,7 @@ AliFMDDensityCalculator::Correction(UShort_t d,
   // Return:
   //    
   //
-  DGUARD(fDebug, 3, "Apply correction in FMD density calculator");
+  DGUARD(fDebug, 10, "Apply correction in FMD density calculator");
   AliForwardCorrectionManager&  fcm = AliForwardCorrectionManager::Instance();
 
   Float_t correction = 1; 
@@ -833,6 +832,7 @@ AliFMDDensityCalculator::DefineOutput(TList* dir)
 
   // TNamed* sigma  = new TNamed("sigma",
   // (fIncludeSigma ? "included" : "excluded"));
+#if 0
   TNamed* maxP   = new TNamed("maxParticle", Form("%d", fMaxParticles));
   TNamed* method = new TNamed("method", 
                              (fUsePoisson ? "Poisson" : "Energy loss"));
@@ -843,7 +843,14 @@ AliFMDDensityCalculator::DefineOutput(TList* dir)
   TNamed* etaL   = new TNamed("etaLumping", Form("%d", fEtaLumping));
   TNamed* phiL   = new TNamed("phiLumping", Form("%d", fPhiLumping));
   // TParameter<double>* nxi = new TParameter<double>("nXi", fNXi);
-
+#else
+  TObject* maxP   = AliForwardUtil::MakeParameter("maxParticle", fMaxParticles);
+  TObject* method = AliForwardUtil::MakeParameter("method", fUsePoisson);
+  TObject* phiA   = AliForwardUtil::MakeParameter("phiAcceptance", 
+                                                 fUsePhiAcceptance);
+  TObject* etaL   = AliForwardUtil::MakeParameter("etaLumping", fEtaLumping);
+  TObject* phiL   = AliForwardUtil::MakeParameter("phiLumping", fPhiLumping);
+#endif
   // d->Add(sigma);
   d->Add(maxP);
   d->Add(method);
@@ -1137,8 +1144,7 @@ AliFMDDensityCalculator::RingHistos::Output(TList* dir)
   y.SetTitle("sector");
   fPoisson.Define(x, y);
 
-  TParameter<double>* cut = new TParameter<double>("cut", fMultCut);
-  d->Add(cut);
+  d->Add(AliForwardUtil::MakeParameter("cut", fMultCut));
 }
 
 //____________________________________________________________________
index 1a3c1ea7e19be802c3b67d9940f1d20419de405b..571a7aa38bcc23a15fd79dd5e9738e808dcdadb1 100644 (file)
@@ -49,7 +49,7 @@ AliFMDEnergyFitter::AliFMDEnergyFitter()
   // 
   // Default Constructor - do not use 
   //
-  DGUARD(fDebug, 0, "Default CTOR of AliFMDEnergyFitter");
+  DGUARD(fDebug, 1, "Default CTOR of AliFMDEnergyFitter");
 }
 
 //____________________________________________________________________
@@ -78,7 +78,7 @@ AliFMDEnergyFitter::AliFMDEnergyFitter(const char* title)
   // Parameters:
   //    title Title of object  - not significant 
   //
-  DGUARD(fDebug, 0, "Named CTOR of AliFMDEnergyFitter: %s", title);
+  DGUARD(fDebug, 1, "Named CTOR of AliFMDEnergyFitter: %s", title);
   fEtaAxis.SetName("etaAxis");
   fEtaAxis.SetTitle("#eta");
   fCentralityAxis.SetName("centralityAxis");
@@ -116,7 +116,7 @@ AliFMDEnergyFitter::AliFMDEnergyFitter(const AliFMDEnergyFitter& o)
   // Parameters:
   //    o Object to copy from 
   //
-  DGUARD(fDebug, 0, "Copy CTOR of AliFMDEnergyFitter");
+  DGUARD(fDebug, 1, "Copy CTOR of AliFMDEnergyFitter");
   TIter    next(&o.fRingHistos);
   TObject* obj = 0;
   while ((obj = next())) fRingHistos.Add(obj);
@@ -293,6 +293,7 @@ AliFMDEnergyFitter::Accumulate(const AliESDFMD& input,
   Int_t icent = fCentralityAxis.FindBin(cent);
   if (icent < 1 || icent > fCentralityAxis.GetNbins()) icent = 0;
 
+  UShort_t nFills = 0;
   for(UShort_t d = 1; d <= 3; d++) {
     Int_t nRings = (d == 1 ? 1 : 2);
     for (UShort_t q = 0; q < nRings; q++) {
@@ -316,12 +317,14 @@ AliFMDEnergyFitter::Accumulate(const AliESDFMD& input,
          if (ieta < 1 || ieta >  fEtaAxis.GetNbins()) continue; 
 
          histos->Fill(empty, ieta-1, icent, mult);
-
+         nFills++;
        } // for strip
       } // for sector
     } // for ring 
   } // for detector
 
+  DMSG(fDebug, 1, "Found a total of %d signals for c=%f, and %sempty event", 
+       nFills, cent, (empty ? "" : "non-"));
   return kTRUE;
 }
 
@@ -610,7 +613,7 @@ AliFMDEnergyFitter::RingHistos::Fill(Bool_t empty, Int_t ieta,
   //    icent  Centrality bin (1-based)
   //    mult   Signal 
   //
-  DGUARD(fDebug, 2, "Filling in AliFMDEnergyFitter::RingHistos");
+  DGUARD(fDebug, 10, "Filling in AliFMDEnergyFitter::RingHistos");
   if (empty) { 
     fEmpty->Fill(mult);
     return;
index 20d481dcc793f3b7a872a5be5e91381d4866ca87..006c3faa9553d891582119ec17c100db3cc5f48e 100644 (file)
@@ -48,9 +48,10 @@ AliFMDEventInspector::AliFMDEventInspector()
     fHEventsAcceptedXY(0),
     fHTriggers(0),
     fHType(0),
-    fHWords(0),
+  fHWords(0),
     fHCent(0),
-    fHCentVsQual(0),
+  fHCentVsQual(0),
+  fHStatus(0),
     fLowFluxCut(1000),
     fMaxVzErr(0.2),
     fList(0),
@@ -65,12 +66,14 @@ AliFMDEventInspector::AliFMDEventInspector()
     fMinPileupContrib(3), 
     fMinPileupDistance(0.8),
     fUseDisplacedVertices(false),
-    fDisplacedVertex()
+  fDisplacedVertex(),
+  fCollWords(),
+  fBgWords()
 {
   // 
   // Constructor 
   //
-  DGUARD(fDebug,0,"Default CTOR of AliFMDEventInspector");
+  DGUARD(fDebug,1,"Default CTOR of AliFMDEventInspector");
 }
 
 //____________________________________________________________________
@@ -85,6 +88,7 @@ AliFMDEventInspector::AliFMDEventInspector(const char* name)
     fHWords(0),
     fHCent(0),
     fHCentVsQual(0),
+    fHStatus(0),
     fLowFluxCut(1000),
     fMaxVzErr(0.2),
     fList(0),
@@ -99,7 +103,9 @@ AliFMDEventInspector::AliFMDEventInspector(const char* name)
     fMinPileupContrib(3), 
     fMinPileupDistance(0.8),
     fUseDisplacedVertices(false),
-    fDisplacedVertex()
+  fDisplacedVertex(),
+  fCollWords(),
+  fBgWords()
 {
   // 
   // Constructor 
@@ -107,7 +113,7 @@ AliFMDEventInspector::AliFMDEventInspector(const char* name)
   // Parameters:
   //   name Name of object
   //
-  DGUARD(fDebug,0,"Named CTOR of AliFMDEventInspector: %s", name);
+  DGUARD(fDebug,1,"Named CTOR of AliFMDEventInspector: %s", name);
 }
 
 //____________________________________________________________________
@@ -122,6 +128,7 @@ AliFMDEventInspector::AliFMDEventInspector(const AliFMDEventInspector& o)
     fHWords(o.fHWords),
     fHCent(o.fHCent),
     fHCentVsQual(o.fHCentVsQual),
+    fHStatus(o.fHStatus),
     fLowFluxCut(o.fLowFluxCut),
     fMaxVzErr(o.fMaxVzErr),
     fList(o.fList),
@@ -136,7 +143,9 @@ AliFMDEventInspector::AliFMDEventInspector(const AliFMDEventInspector& o)
     fMinPileupContrib(o.fMinPileupContrib), 
     fMinPileupDistance(o.fMinPileupDistance),
     fUseDisplacedVertices(o.fUseDisplacedVertices),
-    fDisplacedVertex(o.fDisplacedVertex)
+    fDisplacedVertex(o.fDisplacedVertex),
+  fCollWords(),
+  fBgWords()
 {
   // 
   // Copy constructor 
@@ -144,7 +153,7 @@ AliFMDEventInspector::AliFMDEventInspector(const AliFMDEventInspector& o)
   // Parameters:
   //   o Object to copy from 
   //
-  DGUARD(fDebug,0,"Copy CTOR of AliFMDEventInspector");
+  DGUARD(fDebug,1,"Copy CTOR of AliFMDEventInspector");
 }
 
 //____________________________________________________________________
@@ -180,6 +189,7 @@ AliFMDEventInspector::operator=(const AliFMDEventInspector& o)
   fHWords            = o.fHWords;
   fHCent             = o.fHCent;
   fHCentVsQual       = o.fHCentVsQual;
+  fHStatus           = o.fHStatus;
   fLowFluxCut        = o.fLowFluxCut;
   fMaxVzErr          = o.fMaxVzErr;
   fDebug             = o.fDebug;
@@ -205,6 +215,7 @@ AliFMDEventInspector::operator=(const AliFMDEventInspector& o)
     if (fHWords)       fList->Add(fHWords);
     if (fHCent)        fList->Add(fHCent);
     if (fHCentVsQual)  fList->Add(fHCentVsQual);
+    if (fHStatus)      fList->Add(fHStatus);
   }
   return *this;
 }
@@ -242,17 +253,102 @@ AliFMDEventInspector::FetchHistograms(const TList* d,
   if (!hEventsTr || !hEventsTrVtx || !hTriggers) return kFALSE;
   return kTRUE;
 }
+//____________________________________________________________________
+void
+AliFMDEventInspector::CacheConfiguredTriggerClasses(TList& cache, 
+                                                   const TList* classes,
+                                                   AliOADBPhysicsSelection* o)
+{
+  TIter nextClass(classes);
+  TObjString* trigClass = 0;
+  // Loop over all trigger classes.  Trigger classes have the format 
+  //
+  //   class          := positive_words SPACE(s) negative_words 
+  //   positive_words := 
+  //                  |  '+' words
+  //   negative_words := 
+  //                  |  '-' words
+  //   words          := word 
+  //                  |  word ',' words 
+  //   
+  while ((trigClass = static_cast<TObjString*>(nextClass()))) {
+    // Tokenize on space to get positive and negative parts 
+    TString     side   = o->GetBeamSide(trigClass->String());
+    TObjArray*  parts  = trigClass->String().Tokenize(" ");
+    TObjString* part   = 0;
+    TIter       nextPart(parts);
+    while ((part = static_cast<TObjString*>(nextPart()))) {
+      // We only care about the positive ones 
+      if (part->GetName()[0] != '+') continue;
+      part->String().Remove(0,1);
+       
+      // Tokenize on a comma to get the words 
+      TObjArray*  words = part->String().Tokenize(",");
+      TObjString* word  = 0;
+      TIter       nextWord(words);
+      while ((word = static_cast<TObjString*>(nextWord()))) {
+       TNamed* store = new TNamed(word->String(), side);
+       cache.Add(store);
+       DMSG(fDebug,3,"Caching %s trigger word %s", 
+            store->GetTitle(), store->GetName());
+      } // while (word)
+      delete words;
+    }
+    delete parts;
+  }
+}
+
 //____________________________________________________________________
 void
 AliFMDEventInspector::Init(const TAxis& vtxAxis)
 {
   // 
-  // Initialize the object 
+  // Initialize the object - this is called on the first seen event. 
   // 
   // Parameters:
   //   vtxAxis Vertex axis in use 
   //
   DGUARD(fDebug,1,"Initialize in AliFMDEventInspector");
+
+  AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
+
+  // Get the input handler - should always be there 
+  AliInputEventHandler* ih = 
+    static_cast<AliInputEventHandler*>(am->GetInputEventHandler());
+  if (!ih) { 
+    AliWarning("No input handler");
+    return;
+  }
+  // Get the physics selection - should always be there 
+  AliPhysicsSelection* ps = 
+    static_cast<AliPhysicsSelection*>(ih->GetEventSelection());
+  if (!ps) {
+    AliWarning("No physics selection");
+    return;
+  }
+  // Get the configured triggers
+  AliOADBPhysicsSelection* oadb = 
+    const_cast<AliOADBPhysicsSelection*>(ps->GetOADBPhysicsSelection());
+  if (!oadb) {
+    AliWarning("No OADB physics selection object");
+    return;
+  }
+  // Get the configured trigger words from the physics selection 
+  const TList* collTriggClasses = ps->GetCollisionTriggerClasses();
+  const TList* bgTriggClasses   = ps->GetBGTriggerClasses();
+  if (!collTriggClasses) { 
+    AliWarning("No configured collision trigger classes");
+    return;
+  }
+  if (!bgTriggClasses) { 
+    AliWarning("No configured background trigger classes");
+    return;
+  }
+  CacheConfiguredTriggerClasses(fCollWords, collTriggClasses, oadb);
+  CacheConfiguredTriggerClasses(fBgWords,   bgTriggClasses,   oadb);
+  // fCollWords.ls();
+  // fBgWords.ls();
+  
   
   // -1.5 -0.5 0.5 1.5 ... 89.5 ... 100.5
   // ----- 92 number --------- ---- 1 ---
@@ -366,6 +462,20 @@ AliFMDEventInspector::Init(const TAxis& vtxAxis)
   fHCentVsQual->GetXaxis()->SetBinLabel(4, "V0 vs TPC outlier");
   fHCentVsQual->GetXaxis()->SetBinLabel(5, "V0 vs ZDC outlier");
   fList->Add(fHCentVsQual);
+
+  fHStatus = new TH1I("status", "Status", 7, 1, 8);
+  fHStatus->SetFillColor(kRed+1);
+  fHStatus->SetFillStyle(3001);
+  fHStatus->SetStats(0);
+  fHStatus->SetDirectory(0);
+  fHStatus->GetXaxis()->SetBinLabel(1, "OK");
+  fHStatus->GetXaxis()->SetBinLabel(2, "No event");
+  fHStatus->GetXaxis()->SetBinLabel(3, "No triggers");
+  fHStatus->GetXaxis()->SetBinLabel(4, "No SPD");
+  fHStatus->GetXaxis()->SetBinLabel(5, "No FMD");
+  fHStatus->GetXaxis()->SetBinLabel(6, "No vertex");
+  fHStatus->GetXaxis()->SetBinLabel(7, "Bad vertex");
+  fList->Add(fHStatus);
 }
 
 //____________________________________________________________________
@@ -377,49 +487,16 @@ AliFMDEventInspector::StoreInformation(Int_t runNo)
   DGUARD(fDebug,2,"Store information from AliFMDEventInspector");
   if (!fList) return;
 
-#if 0
-  TNamed* sys = new TNamed("sys", "");
-  TNamed* sNN = new TNamed("sNN", "");
-  TNamed* fld = new TNamed("field", "");
-  TNamed* run = new TNamed("runNo", Form("%d", runNo));
-  TNamed* low = new TNamed("lowFlux", Form("%d", fLowFluxCut));
-  TNamed* fpv = new TNamed("fpVtx", Form("%s", fUseFirstPhysicsVertex ? 
-                                        "true" : "false"));
-  TNamed* v0a = new TNamed("v0and", Form("%s", fUseV0AND ? "true" : "false"));
-  TNamed* nCp = new TNamed("nPileup", Form("%d", fMinPileupContrib));
-  sys->SetTitle(AliForwardUtil::CollisionSystemString(fCollisionSystem));
-  sNN->SetTitle(AliForwardUtil::CenterOfMassEnergyString(fEnergy));
-  fld->SetTitle(AliForwardUtil::MagneticFieldString(fField));
-#else
-  TParameter<int>*  sys = new TParameter<int>("sys", fCollisionSystem);
-  TParameter<int>*  sNN = new TParameter<int>("sNN", fEnergy);
-  TParameter<int>*  fld = new TParameter<int>("field", fField);
-  TParameter<int>*  run = new TParameter<int>("runNo", runNo);
-  TParameter<int>*  low = new TParameter<int>("lowFlux", fLowFluxCut);
-  TParameter<bool>* fpv = new TParameter<bool>("fpVtx",fUseFirstPhysicsVertex);
-  TParameter<bool>* v0a = new TParameter<bool>("v0and",fUseV0AND);
-  TParameter<int>*  nCp = new TParameter<int>("nPileUp", fMinPileupContrib);
-  TParameter<Double_t>* dP = new TParameter<Double_t>("dPileup", 
-                                                     fMinPileupDistance);
-#endif
-  sys->SetUniqueID(fCollisionSystem);
-  sNN->SetUniqueID(fEnergy);
-  fld->SetUniqueID(fField);
-  run->SetUniqueID(runNo);
-  low->SetUniqueID(fLowFluxCut);
-  fpv->SetUniqueID(fUseFirstPhysicsVertex ? 1 : 0);
-  v0a->SetUniqueID(fUseV0AND ? 1  : 0);
-  nCp->SetUniqueID(fMinPileupContrib);
-
-  fList->Add(sys);
-  fList->Add(sNN);
-  fList->Add(fld);
-  fList->Add(run);                             
-  fList->Add(low);
-  fList->Add(fpv);
-  fList->Add(v0a);
-  fList->Add(nCp);
-  fList->Add(dP);
+  
+  fList->Add(AliForwardUtil::MakeParameter("sys", fCollisionSystem));
+  fList->Add(AliForwardUtil::MakeParameter("sNN", fEnergy));
+  fList->Add(AliForwardUtil::MakeParameter("field", fField));
+  fList->Add(AliForwardUtil::MakeParameter("runNo", runNo));
+  fList->Add(AliForwardUtil::MakeParameter("lowFlux", fLowFluxCut));
+  fList->Add(AliForwardUtil::MakeParameter("fpVtx",fUseFirstPhysicsVertex));
+  fList->Add(AliForwardUtil::MakeParameter("v0and",fUseV0AND));
+  fList->Add(AliForwardUtil::MakeParameter("nPileUp", fMinPileupContrib));
+  fList->Add(AliForwardUtil::MakeParameter("dPileup", fMinPileupDistance));
 }
 
 //____________________________________________________________________
@@ -470,13 +547,15 @@ AliFMDEventInspector::Process(const AliESDEvent* event,
   // --- Check that we have an event ---------------------------------
   if (!event) { 
     AliWarning("No ESD event found for input event");
+    fHStatus->Fill(2);
     return kNoEvent;
   }
 
   // --- Read trigger information from the ESD and store in AOD object
-  if (!ReadTriggers(event, triggers, nClusters)) { 
+  if (!ReadTriggers(*event, triggers, nClusters)) { 
     if (fDebug > 2) {
       AliWarning("Failed to read triggers from ESD"); }
+    fHStatus->Fill(3);
     return kNoTriggers;
   }
 
@@ -490,11 +569,17 @@ AliFMDEventInspector::Process(const AliESDEvent* event,
     lowFlux = testmult->GetNumberOfTracklets() < fLowFluxCut;
 
   fHType->Fill(lowFlux ? 0 : 1);
+
+  // --- Process satellite event information is requested ------------
+  if (fUseDisplacedVertices) { 
+    if (!fDisplacedVertex.Process(event)) 
+      AliWarning("Failed to process satellite event");
+  }
   
   // --- Read centrality information 
   cent          = -10;
   UShort_t qual = 0;
-  if (!ReadCentrality(event, cent, qual)) {
+  if (!ReadCentrality(*event, cent, qual)) {
     if (fDebug > 3) 
       AliWarning("Failed to get centrality");
   }
@@ -506,17 +591,17 @@ AliFMDEventInspector::Process(const AliESDEvent* event,
   }
 
   // --- Get the vertex information ----------------------------------
-  
   Double_t vx = 0;
   Double_t vy = 0;
   vz          = 0;
   
-  Bool_t vzOk = ReadVertex(event, vz,vx,vy);
+  Bool_t vzOk = ReadVertex(*event, vz,vx,vy);
 
   fHEventsTr->Fill(vz);
   if (!vzOk) { 
     if (fDebug > 3) {
       AliWarning("Failed to read vertex from ESD"); }
+    fHStatus->Fill(6);
     return kNoVertex;
   }
   fHEventsTrVtx->Fill(vz);
@@ -529,6 +614,7 @@ AliFMDEventInspector::Process(const AliESDEvent* event,
                      vz, fVtxAxis.GetXmin(), fVtxAxis.GetXmax())); 
     }
     ivz = 0;
+    fHStatus->Fill(7);
     return kBadVertex;
   }
   fHEventsAccepted->Fill(vz);
@@ -538,16 +624,17 @@ AliFMDEventInspector::Process(const AliESDEvent* event,
   if (!event->GetFMDData()) { 
     if (fDebug > 3) {
       AliWarning("No FMD data found in ESD"); }
+    fHStatus->Fill(5);
     return kNoFMD;
   }
 
-  
+  fHStatus->Fill(1);
   return kOk;
 }
 
 //____________________________________________________________________
 Bool_t
-AliFMDEventInspector::ReadCentrality(const AliESDEvent* esd, 
+AliFMDEventInspector::ReadCentrality(const AliESDEvent& esd, 
                                     Double_t& cent, 
                                     UShort_t& qual) const
 {
@@ -562,66 +649,31 @@ AliFMDEventInspector::ReadCentrality(const AliESDEvent* esd,
   //    False on error, true otherwise 
   //
   DGUARD(fDebug,2,"Read the centrality in AliFMDEventInspector");
-  
-  cent = -1;
-  qual = 0;
-  AliCentrality* centObj = const_cast<AliESDEvent*>(esd)->GetCentrality();
-  if (!centObj)  return true;
-AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
-  Bool_t isMC = am->GetMCtruthEventHandler() != 0;
-  
-  //std::cout<<fUseDisplacedVertices<<"  "<<isMC<<std::endl;
-  if(fUseDisplacedVertices && !isMC) {
-    Double_t zvtx = fDisplacedVertex.CheckDisplacedVertex(esd);
+
+  if(fUseDisplacedVertices) {
+    Double_t zvtx = fDisplacedVertex.GetVertexZ();
     qual          = 1;
     if(TMath::Abs(zvtx) < 999) {
-      cent = fDisplacedVertex.CalculateDisplacedVertexCent(esd); //centObj->GetCentralityPercentileUnchecked("ZEMvsZDC");  
+      cent = fDisplacedVertex.GetCentralityPercentile();
       qual = 0;
     }
-  }
-  else if(fUseDisplacedVertices && isMC) {
-    
-    
-    AliMCEventHandler* mchandler = static_cast<AliMCEventHandler*>(am->GetMCtruthEventHandler());
-    AliMCEvent* mcevent          = mchandler->MCEvent();
-    
-    AliHeader*               header          = mcevent->Header();
-    AliGenEventHeader*       genHeader       = header->GenEventHeader();
-    AliCollisionGeometry*    colGeometry     = 
-      dynamic_cast<AliCollisionGeometry*>(genHeader);
-    Double_t b              = -1;
-    if (colGeometry)  
-      b     = colGeometry->ImpactParameter();
-    std::cout<<"Hallo!!  "<<b<<std::endl;
-    cent = -1;
-    if(b<3.5 && b >0) cent = 2.5; //0-5%
-    if(b>3.5 && b<4.95) cent = 7.5; //5-10%
-    if(b>4.95 && b<6.98) cent = 15; //10-20%
-    if(b>6.98 && b<8.55) cent = 25; //20-30%
-    if(b>8.55 && b<9.88) cent = 35; //30-40%
-    if(b>9.88 && b<11.04) cent = 45; //40-50%
-    if(b>11.04) cent = 55; //50-60%
-    //cent = 10;
-    qual = 0;
-  }
-  else {
-    cent = centObj->GetCentralityPercentile("V0M");  
-    qual = centObj->GetQuality();
+    return true;
   }
   
-  // AliInfo(Form("Got centrality object %p with quality %d", 
-  //              centObj, centObj->GetQuality()));
-  // centObj->Print();
-  //cent = centObj->GetCentralityPercentile("V0M");  
-  //cent = centObj->GetCentralityPercentile("ZEMvsZDC");  
-  //qual = centObj->GetQuality();
+  cent = -1;
+  qual = 0;
+  AliCentrality* centObj = const_cast<AliESDEvent&>(esd).GetCentrality();
+  if (!centObj)  return true;
+
+  cent = centObj->GetCentralityPercentile("V0M");  
+  qual = centObj->GetQuality();
 
   return true;
 }
 
 //____________________________________________________________________
 Bool_t
-AliFMDEventInspector::ReadTriggers(const AliESDEvent* esd, UInt_t& triggers,
+AliFMDEventInspector::ReadTriggers(const AliESDEvent& esd, UInt_t& triggers,
                                   UShort_t& nClusters)
 {
   // 
@@ -639,6 +691,7 @@ AliFMDEventInspector::ReadTriggers(const AliESDEvent* esd, UInt_t& triggers,
 
   // Get the analysis manager - should always be there 
   AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
+  DMSG(fDebug,10,"Got analysis manager %p", am);
   if (!am) { 
     AliWarning("No analysis manager defined!");
     return kFALSE;
@@ -647,22 +700,11 @@ AliFMDEventInspector::ReadTriggers(const AliESDEvent* esd, UInt_t& triggers,
   // Get the input handler - should always be there 
   AliInputEventHandler* ih = 
     static_cast<AliInputEventHandler*>(am->GetInputEventHandler());
+  DMSG(fDebug,10,"Got input handler %p", ih);
   if (!ih) { 
     AliWarning("No input handler");
     return kFALSE;
   }
-  AliPhysicsSelection* ps = 
-    static_cast<AliPhysicsSelection*>(ih->GetEventSelection());
-  if (!ps) {
-    AliWarning("No physics selection");
-    return kFALSE;
-  }
-  AliOADBPhysicsSelection* oadb = 
-    const_cast<AliOADBPhysicsSelection*>(ps->GetOADBPhysicsSelection());
-  if (!oadb) {
-    AliWarning("No OADB physics selection object");
-    return kFALSE;
-  }
 
   // Check if this is a collision candidate (MB)
   // Note, that we should use the value cached in the input 
@@ -670,269 +712,211 @@ AliFMDEventInspector::ReadTriggers(const AliESDEvent* esd, UInt_t& triggers,
   // on the AliPhysicsSelection obejct.  If we called the latter
   // then the AliPhysicsSelection object would overcount by a 
   // factor of 2! :-(
-  Bool_t offline  = ih->IsEventSelected() ;
-  Bool_t fastonly = (ih->IsEventSelected() & AliVEvent::kFastOnly);
-  TString trigStr = esd->GetFiredTriggerClasses();
+  Bool_t  offline  = ih->IsEventSelected() ;
+  Bool_t  fastonly = (ih->IsEventSelected() & AliVEvent::kFastOnly);
+  TString trigStr  = esd.GetFiredTriggerClasses();
+
+  if (fHWords) fHWords->Fill(trigStr.Data(), 1);
   
-  //If we have the MC input handler,  this must be MC
-  Bool_t isMC = am->GetMCtruthEventHandler() != 0;
+  if(fUseDisplacedVertices) {
+    DMSG(fDebug,3,"Using displaced vertex stuff");
+    if (TMath::Abs(fDisplacedVertex.GetVertexZ()) >= 999) offline = false;
+  }
   
-  if(fUseDisplacedVertices && isMC) {
-    AliMCEventHandler* mchandler = static_cast<AliMCEventHandler*>(am->GetMCtruthEventHandler());
-    AliMCEvent* mcevent          = mchandler->MCEvent();
-    AliHeader* header            = mcevent->Header();
-    AliGenEventHeader* genHeader = header->GenEventHeader();
-    TArrayF vertex;
-    genHeader->PrimaryVertex(vertex);
+  if (CheckFastPartition(fastonly))     offline = false;
+  if (offline && CheckCosmics(trigStr)) offline = false;
+
+  DMSG(fDebug,2,"Event is %striggered by off-line", offline ? "" : "NOT ");
+
+  if (offline) {
+    triggers |= AliAODForwardMult::kOffline;
+    triggers |= AliAODForwardMult::kInel;
+    if (!fHTriggers) { 
+      AliWarning("Histogram of triggers not defined - has init been called");
+      return false;
+    }
+    fHTriggers->Fill(kOffline+0.5);
     
-    Double_t zvtx = vertex.At(2);
-    if(TMath::Abs(zvtx) > 35)
-      offline = true;
-    else offline = false;
+    CheckINELGT0(esd, nClusters, triggers);
   }
   
-  if(fUseDisplacedVertices && !isMC) {
-    Double_t zvtx = fDisplacedVertex.CheckDisplacedVertex(esd);
-    if(TMath::Abs(zvtx) < 999) offline = true;
-    else offline = false;
+  CheckNSD(esd,triggers);
+  if (CheckPileup(esd, triggers)) fHTriggers->Fill(kPileUp+.5);
+  if (CheckEmpty(trigStr, triggers)) fHTriggers->Fill(kEmpty+.5);
+
+  CheckWords(esd, triggers);
+
+  // Now check - if we have a collision - for offline triggers and
+  // fill histogram.
+  if (triggers & AliAODForwardMult::kB) {
+    fHTriggers->Fill(kB+.5);
+    if (triggers & AliAODForwardMult::kInel) 
+      fHTriggers->Fill(kInel);
+    
+    if (triggers & AliAODForwardMult::kInelGt0)
+      fHTriggers->Fill(kInelGt0+.5);
     
+    if (triggers & AliAODForwardMult::kNSD)
+      fHTriggers->Fill(kNSD+.5);
+
+    if (triggers & AliAODForwardMult::kV0AND)
+      fHTriggers->Fill(kV0AND+.5);
   }
+  if (triggers & AliAODForwardMult::kA) fHTriggers->Fill(kA+.5);
+  if (triggers & AliAODForwardMult::kC) fHTriggers->Fill(kC+.5);
+  if (triggers & AliAODForwardMult::kE) fHTriggers->Fill(kE+.5);
+  
+  return kTRUE;
+}
+
+//____________________________________________________________________
+Bool_t
+AliFMDEventInspector::CheckFastPartition(bool fastonly) const
+{
   // For the 2.76 TeV p+p run, the FMD ran in the slow partition 
   // so it received no triggers from the fast partition. Therefore
   // the fast triggers are removed here but not for MC where all 
   // triggers are fast.
-  if(TMath::Abs(fEnergy - 2750.) < 20 && 
-     fCollisionSystem == AliForwardUtil::kPP &&
-     !isMC)
-    if (fastonly) offline = false;
+  if (TMath::Abs(fEnergy - 2750.) > 20) return false;
+  if (fCollisionSystem != AliForwardUtil::kPP) return false;
+  if (fastonly)
+    DMSG(fDebug,1,"Fast trigger in pp @ sqrt(s)=2.76TeV removed");
+
+  return fastonly;
+}
+
+//____________________________________________________________________
+Bool_t
+AliFMDEventInspector::CheckCosmics(const TString& trigStr) const
+{
+  // MUON triggers are not strictly minimum bias (MB) so they are
+  // removed (HHD)
+  if(trigStr.Contains("CMUS1")) {
+    DMSG(fDebug,1,"Cosmic trigger ins't min-bias, removed");
+    return true;
+  }
+  return false;
+}
+
+//____________________________________________________________________
+Bool_t
+AliFMDEventInspector::CheckINELGT0(const AliESDEvent& esd, 
+                                  UShort_t& nClusters, 
+                                  UInt_t& triggers) const
+{
   nClusters = 0;
-  
-  // MUON triggers are not strictly minimum bias (MB) so they are removed (HHD)
-  
-  if(offline && trigStr.Contains("CMUS1")) offline = false;
-    
-  if (offline) {
-    triggers |= AliAODForwardMult::kOffline;
-    triggers |= AliAODForwardMult::kInel;
-    if (!fHTriggers) { 
-      AliWarning("Histogram of triggers not defined - has init been called");
-      return false;
-    }
-    fHTriggers->Fill(kOffline+0.5);
 
-    // If this is inel, see if we have a tracklet 
-    const AliMultiplicity* spdmult = esd->GetMultiplicity();
-    if (!spdmult) {
-      AliWarning("No SPD multiplicity");
-    }
-    else { 
-      // Check if we have one or more tracklets 
-      // in the range -1 < eta < 1 to set the INEL>0 
-      // trigger flag. 
-      // 
-      // Also count tracklets as a single cluster 
-      Int_t n = spdmult->GetNumberOfTracklets();
-      for (Int_t j = 0; j < n; j++) { 
-       if(TMath::Abs(spdmult->GetEta(j)) < 1) { 
-         triggers |= AliAODForwardMult::kInelGt0;
-         nClusters++;
-       }
-      }
-      n = spdmult->GetNumberOfSingleClusters();
-      for (Int_t j = 0; j < n; j++) { 
-       Double_t eta = -TMath::Log(TMath::Tan(spdmult->GetThetaSingle(j)/2.));
-       if (TMath::Abs(eta) < 1) nClusters++;
-      }
+  // If this is inel, see if we have a tracklet 
+  const AliMultiplicity* spdmult = esd.GetMultiplicity();
+  if (!spdmult) {
+    AliWarning("No SPD multiplicity");
+    return false;
+  }
+
+  // Check if we have one or more tracklets 
+  // in the range -1 < eta < 1 to set the INEL>0 
+  // trigger flag. 
+  // 
+  // Also count tracklets as a single cluster 
+  Int_t n = spdmult->GetNumberOfTracklets();
+  for (Int_t j = 0; j < n; j++) { 
+    if(TMath::Abs(spdmult->GetEta(j)) < 1) { 
+      triggers |= AliAODForwardMult::kInelGt0;
+      nClusters++;
     }
-    if (nClusters > 0) triggers |= AliAODForwardMult::kNClusterGt0;
   }
-  
+  n = spdmult->GetNumberOfSingleClusters();
+  for (Int_t j = 0; j < n; j++) { 
+    Double_t eta = -TMath::Log(TMath::Tan(spdmult->GetThetaSingle(j)/2.));
+    if (TMath::Abs(eta) < 1) nClusters++;
+  }
+  if (nClusters > 0) triggers |= AliAODForwardMult::kNClusterGt0;
+
+  return triggers & AliAODForwardMult::kNClusterGt0;
+}
+
+//____________________________________________________________________
+Bool_t
+AliFMDEventInspector::CheckNSD(const AliESDEvent& esd, UInt_t& triggers) const
+{
   // Analyse some trigger stuff 
   AliTriggerAnalysis ta;
-  if (ta.IsOfflineTriggerFired(esd, AliTriggerAnalysis::kV0AND)) {
+  if (ta.IsOfflineTriggerFired(&esd, AliTriggerAnalysis::kV0AND)) {
     triggers |= AliAODForwardMult::kV0AND;
     if (fUseV0AND) 
       triggers |= AliAODForwardMult::kNSD;
   }
-  if (ta.IsOfflineTriggerFired(esd, AliTriggerAnalysis::kNSD1)) 
+  if (ta.IsOfflineTriggerFired(&esd, AliTriggerAnalysis::kNSD1)) 
     triggers |= AliAODForwardMult::kNSD;
-  
+  return triggers & AliAODForwardMult::kNSD;
+}
+//____________________________________________________________________
+Bool_t
+AliFMDEventInspector::CheckPileup(const AliESDEvent& esd, 
+                                 UInt_t& triggers) const
+{
   // Check for multiple vertices (pile-up) with at least 3
   // contributors and at least 0.8cm from the primary vertex
-  Bool_t pileup = kFALSE;
-  if(fCollisionSystem == AliForwardUtil::kPP)
-    pileup =  esd->IsPileupFromSPD(fMinPileupContrib,fMinPileupDistance);
-  if (pileup) {
-    triggers |= AliAODForwardMult::kPileUp;
-    fHTriggers->Fill(kPileUp+.5);
-  }
-  
-  // Get trigger stuff 
-  
-  //TString trigStr = esd->GetFiredTriggerClasses();
-  // AliWarning(Form("Fired trigger classes: %s", trigStr.Data()));
-  if (fHWords) fHWords->Fill(trigStr.Data(), 1);
-#if 0
-  if (trigStr.Contains("MB1") || trigStr.Contains("MBBG3"))
-    triggers |= AliAOODForwardMult::kB;
-  if (trigStr.Contains("COTA")) 
-    triggers |= AliAODForwardMult::kA;
-  if (trigStr.Contains("COTC")) 
-    triggers |= AliAODForwardMult::kC;
-#endif
+  if(fCollisionSystem != AliForwardUtil::kPP) return false;
+
+  Bool_t pileup =  esd.IsPileupFromSPD(fMinPileupContrib,fMinPileupDistance);
+  if (pileup) triggers |= AliAODForwardMult::kPileUp;
+  return pileup;
+}
+
+//____________________________________________________________________
+Bool_t
+AliFMDEventInspector::CheckEmpty(const TString& trigStr, UInt_t& triggers) const
+{
   if (trigStr.Contains("CBEAMB-ABCE-NOPF-ALL")) {
     triggers |= AliAODForwardMult::kEmpty;
-    fHTriggers->Fill(kEmpty+.5);
-  }
-#if 0 
-  // Check for B triggers
-  if (trigStr.Contains("CINT1B-ABCE-NOPF-ALL")   ||   // Early pp
-      trigStr.Contains("CINT1-B-NOPF-ALLNOTRD")  ||   // Late pp 
-      trigStr.Contains("CINT1-B-NOPF-FASTNOTRD") ||   // Late pp
-      //trigStr.Contains("CMUS1-B-NOPF-MUON")      ||   // Late pp -- HHD 160811
-      trigStr.Contains("CSMBB-ABCE-NOPF-ALL")    ||   // pp
-      trigStr.Contains("CMBACS2-B-NOPF-ALL")     ||   // PbPb
-      // trigStr.Contains("C0SMH-B-NOPF-ALL")    ||   // PbPb - high mult
-      trigStr.Contains("CMBS2A-B-NOPF-ALL")      ||   // PbPb
-      trigStr.Contains("CMBS2C-B-NOPF-ALL")      ||   // PbPb
-      trigStr.Contains("CMBAC-B-NOPF-ALL")       ||   // PbPb
-      // trigStr.Contains("C0SMH-B-NOPF-ALL")    ||   // PbPb - high mult
-      trigStr.Contains("CMBACS2-B-NOPF-ALLNOTRD")     // PbPb
-      // trigStr.Contains("C0SMH-B-NOPF-ALLNOTRD")    // PbPb - high mult
-      ) {
-    Bool_t bTrigger = kTRUE;
-    if ( trigStr.Contains("CINT1-B-NOPF-FASTNOTRD") && 
-        !trigStr.Contains("CINT1-B-NOPF-ALLNOTRD") && 
-        TMath::Abs(fEnergy - 2750.) < 20 && 
-        fCollisionSystem == AliForwardUtil::kPP)
-      bTrigger = kFALSE;
-    if(bTrigger) {
-      triggers |= AliAODForwardMult::kB;
-      fHTriggers->Fill(kB+.5);
-    }
-  }
-  
-  // Check for A triggers
-  if (trigStr.Contains("CINT1A-ABCE-NOPF-ALL")    ||   // Early pp
-      trigStr.Contains("CINT1-AC-NOPF-ALLNOTRD")  ||   // Late pp
-      trigStr.Contains("CINT1-AC-NOPF-FASTNOTRD") ||   // Late pp
-      (trigStr.Contains("CSMBA-ABCE-NOPF-ALL") && 
-       !(triggers & AliAODForwardMult::kB))       ||   // pp
-      trigStr.Contains("CMBACS2-A-NOPF-ALL")      ||   // PbPb
-      // trigStr.Contains("C0SMH-A-NOPF-ALL")     ||   // PbPb - high mult
-      trigStr.Contains("CMBS2A-A-NOPF-ALL")       ||   // PbPb
-      trigStr.Contains("CMBS2C-A-NOPF-ALL")       ||   // PbPb
-      trigStr.Contains("CMBAC-A-NOPF-ALL")        ||   // PbPb
-      // trigStr.Contains("C0SMH-A-NOPF-ALL")     ||   // PbPb - high mult
-      trigStr.Contains("CMBACS2-A-NOPF-ALLNOTRD")     // PbPb
-      // trigStr.Contains("C0SMH-A-NOPF-ALLNOTRD")    // PbPb - high mult
-      ) {
-    triggers |= AliAODForwardMult::kA;
-    fHTriggers->Fill(kA+.5);
-  }
-
-  // Check for C triggers
-  if (trigStr.Contains("CINT1C-ABCE-NOPF-ALL")   ||  // Early pp
-      (trigStr.Contains("CSMBC-ABCE-NOPF-ALL") && 
-       !(triggers & AliAODForwardMult::kB))      ||   // pp
-      trigStr.Contains("CMBACS2-C-NOPF-ALL")     ||   // PbPb
-      // trigStr.Contains("C0SMH-B-NOPF-ALL")    ||   // PbPb - high mult
-      trigStr.Contains("CMBS2A-C-NOPF-ALL")      ||   // PbPb
-      trigStr.Contains("CMBS2C-C-NOPF-ALL")      ||   // PbPb
-      trigStr.Contains("CMBAC-C-NOPF-ALL")       ||   // PbPb
-      // trigStr.Contains("C0SMH-B-NOPF-ALL")    ||   // PbPb - high mult
-      trigStr.Contains("CMBACS2-C-NOPF-ALLNOTRD")     // PbPb
-      // trigStr.Contains("C0SMH-B-NOPF-ALLNOTRD")    // PbPb - high mult
-      ) {
-    triggers |= AliAODForwardMult::kC;
-    fHTriggers->Fill(kC+.5);
+    return true;
   }
+  return false;
+}
+//____________________________________________________________________
+Bool_t
+AliFMDEventInspector::CheckWords(const AliESDEvent& esd, UInt_t& triggers) const
+{
+  TObject* word = 0;
+  TIter nextColl(&fCollWords);
+  while ((word = nextColl())) {
+    DMSG(fDebug,10,"Checking if %s trigger %s is fired", 
+        word->GetTitle(), word->GetName());
+    if (!esd.IsTriggerClassFired(word->GetName())) continue;
 
-  // Check for E triggers 
-  if (trigStr.Contains("CINT1-E-NOPF-ALL")       ||   // Early pp 
-      trigStr.Contains("CINT1-E-NOPF-ALLNOTRD")  ||   // Late pp 
-      trigStr.Contains("CINT1-E-NOPF-FASTNOTRD") ||   // Late pp 
-      trigStr.Contains("CMBACS2-E-NOPF-ALL")     ||   // PbPb
-      // trigStr.Contains("C0SMH-B-NOPF-ALL")    ||   // PbPb - high mult
-      trigStr.Contains("CMBS2A-E-NOPF-ALL")      ||   // PbPb
-      trigStr.Contains("CMBS2C-E-NOPF-ALL")      ||   // PbPb
-      trigStr.Contains("CMBAC-E-NOPF-ALL")       ||   // PbPb
-      // trigStr.Contains("C0SMH-B-NOPF-ALL")    ||   // PbPb - high mult
-      trigStr.Contains("CMBACS2-E-NOPF-ALLNOTRD")     // PbPb
-      // trigStr.Contains("C0SMH-B-NOPF-ALLNOTRD")    // PbPb - high mult
-      ) {
-    triggers |= AliAODForwardMult::kE;
-    fHTriggers->Fill(kE+.5);
-  }
-#endif
+    TString beamSide = word->GetTitle();
+    DMSG(fDebug,10,"Found it - this is a %s trigger", beamSide.Data());
 
-  const TList* collTriggClasses = ps->GetCollisionTriggerClasses();
-  const TList* bgTriggClasses = ps->GetBGTriggerClasses();
-
-  TIter nextColl(collTriggClasses);
-  TObjString* oadbString = 0;
-  TObjArray* tokens = 0;
-  while ((oadbString = static_cast<TObjString*>(nextColl()))) {
-    tokens = oadbString->String().Tokenize(" ");
-    for (Int_t i = 0; i < tokens->GetEntries(); i++) {
-      TString string = (((TObjString*)tokens->At(i))->String());
-      if (string[0] != '+') continue;
-      string.Remove(0,1);
-      if (trigStr.Contains(string.Data())) {
-        TString beamSide = oadb->GetBeamSide(oadbString->String().Data());
-        if (beamSide.EqualTo("B")) {
-          triggers |= AliAODForwardMult::kB;
-          fHTriggers->Fill(kB+.5);
-        }
-      }
-    }
-  }
-  TIter nextBG(bgTriggClasses);
-  while ((oadbString = static_cast<TObjString*>(nextBG()))) {
-    tokens = oadbString->String().Tokenize(" ");
-    for (Int_t i = 0; i < tokens->GetEntries(); i++) {
-      TString string = (((TObjString*)tokens->At(i))->String());
-      if (string[0] != '+') continue;
-      string.Remove(0,1);
-      if (trigStr.Contains(string.Data())) {
-        TString beamSide = oadb->GetBeamSide(oadbString->String().Data());
-        if (beamSide.Contains("A")) {
-          triggers |= AliAODForwardMult::kA;
-          fHTriggers->Fill(kA+.5);
-        }
-        if (beamSide.Contains("C")) {
-          triggers |= AliAODForwardMult::kC;
-          fHTriggers->Fill(kC+.5);
-        }
-        if (beamSide.Contains("E")) {
-          triggers |= AliAODForwardMult::kE;
-          fHTriggers->Fill(kE+.5);
-        }
-      }
-    }
+    if (!beamSide.EqualTo("B")) continue;
+    triggers |= AliAODForwardMult::kB;
+    break; // No more to do here
   }
-
-  // Now check - if we have a collision - for offline triggers and
-  // fill histogram.
-  if (triggers & AliAODForwardMult::kB) {
-    if (triggers & AliAODForwardMult::kInel) 
-      fHTriggers->Fill(kInel);
-    
-    if (triggers & AliAODForwardMult::kInelGt0)
-      fHTriggers->Fill(kInelGt0+.5);
+  TIter nextBg(&fBgWords);
+  UInt_t all = (AliAODForwardMult::kA | 
+               AliAODForwardMult::kC | 
+               AliAODForwardMult::kE);
+  while ((word = nextBg())) {
+    DMSG(fDebug,10,"Checking if %s trigger %s is fired", 
+        word->GetTitle(), word->GetName());
+    if (!esd.IsTriggerClassFired(word->GetName())) continue;
     
-    if (triggers & AliAODForwardMult::kNSD)
-      fHTriggers->Fill(kNSD+.5);
+    TString beamSide = word->GetTitle();
+    DMSG(fDebug,10,"Found it - this is a %s trigger", beamSide.Data());
 
-    if (triggers & AliAODForwardMult::kV0AND)
-      fHTriggers->Fill(kV0AND+.5);
+    if (beamSide.Contains("A")) triggers |= AliAODForwardMult::kA;
+    if (beamSide.Contains("C")) triggers |= AliAODForwardMult::kC;
+    if (beamSide.Contains("E")) triggers |= AliAODForwardMult::kE;
+
+    if ((triggers & all) == all) break; // No more to do
   }
-  
-  return kTRUE;
+  return true;
 }
+
+
 //____________________________________________________________________
 Bool_t
-AliFMDEventInspector::ReadVertex(const AliESDEvent* esd, 
+AliFMDEventInspector::ReadVertex(const AliESDEvent& esd, 
                                 Double_t& vz, 
                                 Double_t& vx, 
                                 Double_t& vy)
@@ -952,117 +936,102 @@ AliFMDEventInspector::ReadVertex(const AliESDEvent* esd,
   vx = 1024;
   vy = 1024;
   
-  AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
-  Bool_t isMC = am->GetMCtruthEventHandler() != 0;
-  if(fUseDisplacedVertices && isMC) {
-    
-    AliMCEventHandler* mchandler = static_cast<AliMCEventHandler*>(am->GetMCtruthEventHandler());
-    AliMCEvent* mcevent          = mchandler->MCEvent();
-    AliHeader* header            = mcevent->Header();
-    AliGenEventHeader* genHeader = header->GenEventHeader();
-    TArrayF vertex;
-    genHeader->PrimaryVertex(vertex);
-
-    Double_t zvtx = vertex.At(2);
-    Double_t ratio = zvtx/37.5;
-    if(ratio > 0) ratio = ratio + 0.5;
-    if(ratio < 0) ratio = ratio - 0.5;
-    Int_t ratioInt = (Int_t)ratio;
-    zvtx = 37.5*((Double_t)ratioInt);
-    if(TMath::Abs(zvtx) < 999) {
-      vz = zvtx;
-      return true;
-    }
-    else return false;
-    
-  }
-  if(fUseDisplacedVertices && !isMC) {
-    Double_t zvtx = fDisplacedVertex.CheckDisplacedVertex(esd);
-    
+  if(fUseDisplacedVertices) {
+    Double_t zvtx = fDisplacedVertex.GetVertexZ();
+      
     if(TMath::Abs(zvtx) < 999) {
       vz = zvtx;
       return true;
     }
-    else return false;
+    return false;
   }
 
-  if(fUseFirstPhysicsVertex) {
-    // This is the code used by the 1st physics people 
-    const AliESDVertex* vertex    = esd->GetPrimaryVertex();
-    if (!vertex  || !vertex->GetStatus()) {
-      if (fDebug > 2) {
-       AliWarning(Form("No primary vertex (%p) or bad status %d", 
-                       vertex, (vertex ? vertex->GetStatus() : -1)));
-      }
-      return false;
-    }
-    const AliESDVertex* vertexSPD = esd->GetPrimaryVertexSPD();
-    if (!vertexSPD || !vertexSPD->GetStatus()) {
-      if (fDebug > 2) {
-       AliWarning(Form("No primary SPD vertex (%p) or bad status %d", 
-                       vertexSPD, (vertexSPD ? vertexSPD->GetStatus() : -1)));
-      }
-      return false;
-    }
-    
-    // if vertex is from SPD vertexZ, require more stringent cuts 
-    if (vertex->IsFromVertexerZ()) { 
-      if (vertex->GetDispersion() > fMaxVzErr || 
-         vertex->GetZRes() > 1.25 * fMaxVzErr) {
-       if (fDebug > 2) {
-         AliWarning(Form("Dispersion %f > %f or resolution %f > %f",
-                         vertex->GetDispersion(), fMaxVzErr,
-                         vertex->GetZRes(), 1.25 * fMaxVzErr)); 
-       }
-       return false;
-      }
-    }
-    vz = vertex->GetZ();
+  if(fUseFirstPhysicsVertex) return CheckPWGUDVertex(esd, vz, vx, vy);
+  
+  
+  return CheckVertex(esd, vz, vx, vy);
+}
+
+//____________________________________________________________________
+Bool_t
+AliFMDEventInspector::CheckPWGUDVertex(const AliESDEvent& esd, 
+                                      Double_t& vz, 
+                                      Double_t& vx, 
+                                      Double_t& vy) const
+{
+  // This is the code used by the 1st physics people 
+  const AliESDVertex* vertex    = esd.GetPrimaryVertex();
+  if (!vertex  || !vertex->GetStatus()) {
+    DMSG(fDebug,2,"No primary vertex (%p) or bad status %d", 
+        vertex, (vertex ? vertex->GetStatus() : -1));
+    return false;
+  }
+  const AliESDVertex* vertexSPD = esd.GetPrimaryVertexSPD();
+  if (!vertexSPD || !vertexSPD->GetStatus()) {
+    DMSG(fDebug,2,"No primary SPD vertex (%p) or bad status %d", 
+        vertexSPD, (vertexSPD ? vertexSPD->GetStatus() : -1));
+    return false;
+  }
     
-    if(!vertex->IsFromVertexerZ()) {
-      vx = vertex->GetX();
-      vy = vertex->GetY();
+  // if vertex is from SPD vertexZ, require more stringent cuts 
+  if (vertex->IsFromVertexerZ()) { 
+    if (vertex->GetDispersion() > fMaxVzErr || 
+       vertex->GetZRes() > 1.25 * fMaxVzErr) {
+      DMSG(fDebug,2,"Dispersion %f > %f or resolution %f > %f",
+          vertex->GetDispersion(), fMaxVzErr,
+          vertex->GetZRes(), 1.25 * fMaxVzErr);
+      return false;
     }
-    return true;
   }
-  else { //Use standard SPD vertex (perhaps preferable for Pb+Pb)
-   
-    // Get the vertex 
-    const AliESDVertex* vertex = esd->GetPrimaryVertexSPD();
-    if (!vertex) { 
-      if (fDebug > 2) {
-       AliWarning("No SPD vertex found in ESD"); }
-      return kFALSE;
-    }
+  vz = vertex->GetZ();
+  
+  if(!vertex->IsFromVertexerZ()) {
+    vx = vertex->GetX();
+    vy = vertex->GetY();
+  }
+  return true;
+}
+//____________________________________________________________________
+Bool_t
+AliFMDEventInspector::CheckVertex(const AliESDEvent& esd, 
+                                 Double_t& vz, 
+                                 Double_t& vx, 
+                                 Double_t& vy) const
+{
+  // Use standard SPD vertex (perhaps preferable for Pb+Pb)
+  // Get the vertex 
+  const AliESDVertex* vertex = esd.GetPrimaryVertexSPD();
+  if (!vertex) { 
+    if (fDebug > 2) {
+      AliWarning("No SPD vertex found in ESD"); }
+    return false;
+  }
     
-    // Check that enough tracklets contributed 
-    if(vertex->GetNContributors() <= 0) {
-      if (fDebug > 2) {
-       AliWarning(Form("Number of contributors to vertex is %d<=0",
-                       vertex->GetNContributors())); }
-      vz = 0;
-      return kFALSE;
-    } 
-    // Check that the uncertainty isn't too large 
-    if (vertex->GetZRes() > fMaxVzErr) { 
-      if (fDebug > 2) {
-       AliWarning(Form("Uncertaintity in Z of vertex is too large %f > %f", 
-                     vertex->GetZRes(), fMaxVzErr)); }
-      return kFALSE;
-    }
+  // Check that enough tracklets contributed 
+  if(vertex->GetNContributors() <= 0) {
+    DMSG(fDebug,2,"Number of contributors to vertex is %d<=0",
+        vertex->GetNContributors());
+    vz = 0;
+    return false;
+  } 
+  // Check that the uncertainty isn't too large 
+  if (vertex->GetZRes() > fMaxVzErr) { 
+    DMSG(fDebug,2,"Uncertaintity in Z of vertex is too large %f > %f", 
+        vertex->GetZRes(), fMaxVzErr);
+    return false;
+  }
     
-    // Get the z coordiante 
-    vz = vertex->GetZ();
-    const AliESDVertex* vertexXY = esd->GetPrimaryVertex();
+  // Get the z coordiante 
+  vz = vertex->GetZ();
+  const AliESDVertex* vertexXY = esd.GetPrimaryVertex();
     
-    if(!vertexXY->IsFromVertexerZ()) {
-      vx = vertexXY->GetX();
-      vy = vertexXY->GetY();
-    }
-    return kTRUE;
-  } 
+  if(!vertexXY->IsFromVertexerZ()) {
+    vx = vertexXY->GetX();
+    vy = vertexXY->GetY();
+  }
+  return true;
 }
-  
+
 //____________________________________________________________________
 Bool_t
 AliFMDEventInspector::ReadRunDetails(const AliESDEvent* esd)
@@ -1098,6 +1067,21 @@ AliFMDEventInspector::ReadRunDetails(const AliESDEvent* esd)
   return kTRUE;
 }
 
+
+//____________________________________________________________________
+const Char_t*
+AliFMDEventInspector::CodeString(UInt_t code)
+{
+  static TString s;
+  s = "";
+  if (code & kNoEvent)    s.Append("NOEVENT ");
+  if (code & kNoTriggers) s.Append("NOTRIGGERS ");
+  if (code & kNoSPD)      s.Append("NOSPD ");
+  if (code & kNoFMD)      s.Append("NOFMD ");
+  if (code & kNoVertex)   s.Append("NOVERTEX ");
+  if (code & kBadVertex)  s.Append("BADVERTEX ");
+  return s.Data();
+}
 //____________________________________________________________________
 void
 AliFMDEventInspector::Print(Option_t*) const
@@ -1118,7 +1102,8 @@ AliFMDEventInspector::Print(Option_t*) const
   field.ReplaceAll("m",  "-");
   field.ReplaceAll("kG", " kG");
   
-  std::cout << ind << ClassName() << ": " << GetName() << '\n'
+  std::cout << std::boolalpha 
+           << ind << ClassName() << ": " << GetName() << '\n'
            << ind << " Vertex bins:            " << fVtxAxis.GetNbins() << '\n'
            << ind << " Vertex range:           [" << fVtxAxis.GetXmin() 
            << "," << fVtxAxis.GetXmax() << "]\n"
@@ -1129,7 +1114,9 @@ AliFMDEventInspector::Print(Option_t*) const
            << ind << " System:                 " 
            << AliForwardUtil::CollisionSystemString(fCollisionSystem) << '\n'
            << ind << " CMS energy per nucleon: " << sNN << '\n'
-           << ind << " Field:                  " <<  field << '\n';
+           << ind << " Field:                  " <<  field << '\n'
+           << ind << " Satellite events:       " << fUseDisplacedVertices 
+           << "\n" << std::noboolalpha;
   if (!fCentAxis) { std::cout << std::flush; return; }
   Int_t nBin = fCentAxis->GetNbins();
   std::cout << ind << " Centrality axis:        " << nBin << " bins"
index a08ec575801db8d7a4a917b56aaa24427875b481..c1bd0586ff47a3eb9840f4255f07a92dcbc24d25 100644 (file)
  */
 #include <TNamed.h>
 #include <TAxis.h>
+#include <TList.h>
 #include "AliDisplacedVertexSelection.h"
 class AliESDEvent;
+class AliOADBPhysicsSelection;
 class TH2D;
 class TH1D;
 class TH1I;
 class TH1F;
 class TH2F;
 class TAxis;
-class TList;
+// class TList;
 
 /** 
  * This class inspects the event 
@@ -51,19 +53,19 @@ public:
    * Return codes 
    */
   enum ECodes {
-    /** all ok */
+    /** all ok - bin 1 */
     kOk = 0,
-    /** No ESD event */
+    /** No ESD event - bin 2 */
     kNoEvent = 0x1, 
-    /** No triggers found */
+    /** No triggers found - bin 3 */
     kNoTriggers = 0x2, 
-    /** No SPD data */ 
+    /** No SPD data - bin 4 */ 
     kNoSPD = 0x4, 
-    /** No FMD data */
+    /** No FMD data - bin 5 */
     kNoFMD = 0x8, 
-    /** No vertex found */
+    /** No vertex found - bin 6 */
     kNoVertex = 0x10, 
-    /** Vertex out of range */
+    /** Vertex out of range - bin 7 */
     kBadVertex = 0x20
   };
   /** 
@@ -278,7 +280,25 @@ public:
    * @param runNo Run number - read off from ESD event
    */
   virtual void StoreInformation(Int_t runNo);
+  /** 
+   * Return a string representing the return code 
+   * 
+   * @param mask Code 
+   * 
+   * @return String representation 
+   */
+  static const char* CodeString(UInt_t mask);
 protected:
+  /** 
+   * Cache the configure trigger classes from the physis selection.  
+   * 
+   * @param cache   where to cache the trigger class. 
+   * @param classes List of configured classes. 
+   * @param o       Object from OADB with config
+   */
+  void CacheConfiguredTriggerClasses(TList& cache, 
+                                    const TList* classes,
+                                    AliOADBPhysicsSelection* o);
   /** 
    * Read the trigger information from the ESD event 
    * 
@@ -288,8 +308,73 @@ protected:
    * 
    * @return @c true on success, @c false otherwise 
    */
-  Bool_t ReadTriggers(const AliESDEvent* esd, UInt_t& triggers, 
+  Bool_t ReadTriggers(const AliESDEvent& esd, UInt_t& triggers, 
                      UShort_t& nClusters);
+  /** 
+   * Check, for the @f$\sqrt{s}=2.76GeV@f$ pp run wether this event
+   * was in the fast partition, and if so, filter it out.
+   * 
+   * @param fastonly Event was in fast-only partition 
+   * 
+   * @return true if event was in the fast-only partition, for the run
+   * period.
+   */
+  virtual Bool_t CheckFastPartition(bool fastonly) const;
+  /** 
+   * Check if we have an NSD trigger for pp runs 
+   * 
+   * @param esd      Data
+   * @param triggers Trigger mask to be filled 
+   * 
+   * @return true if we have an NSD trigger 
+   */
+  virtual Bool_t CheckNSD(const AliESDEvent& esd, UInt_t& triggers) const;
+  /** 
+   * Check if we have an INEL&gt;0 trigger 
+   *  
+   * @param esd        Data 
+   * @param nClusters  On return, number of clusters
+   * @param triggers   Trigger mask to be filled
+   * 
+   * @return true if we have an INEL&gt;0 trigger 
+   */
+  virtual Bool_t CheckINELGT0(const AliESDEvent& esd, UShort_t& nClusters, 
+                             UInt_t& triggers) const;
+  /** 
+   * Check if this is a pile-up event
+   * 
+   * @param esd       Data
+   * @param triggers Trigger mask to be filled
+   * 
+   * @return true if this is a pile-up event
+   */
+  virtual Bool_t CheckPileup(const AliESDEvent& esd, UInt_t& triggers) const;
+  /** 
+   * Check if we have a cosmic trigger.  These should be filtered out. 
+   * 
+   * @param trigStri Trigger string 
+   * 
+   * @return true if we have a cosmic trigger
+   */
+  virtual Bool_t CheckCosmics(const TString& trigStri) const;
+  /** 
+   * Check if the trigger string corresponds to an empty event 
+   * 
+   * @param trigStr  Trigger string 
+   * @param triggers Trigger mask to be filled
+   * 
+   * @return true if the trigger string corresponds to an empty event 
+   */
+  virtual Bool_t CheckEmpty(const TString& trigStr, UInt_t& triggers) const;
+  /** 
+   * Check the trigger words to see if we have a B, A, C, or E event. 
+   * 
+   * @param esd       Data
+   * @param triggers  Trigger mask to be filled
+   * 
+   * @return always true
+   */
+  virtual Bool_t CheckWords(const AliESDEvent& esd, UInt_t& triggers) const;
   /** 
    * Read the vertex information from the ESD event 
    * 
@@ -300,10 +385,47 @@ protected:
    * 
    * @return @c true on success, @c false otherwise 
    */
-  Bool_t ReadVertex(const AliESDEvent* esd, 
+  Bool_t ReadVertex(const AliESDEvent& esd, 
                    Double_t& vz, 
                    Double_t& vx, 
                    Double_t& vy);
+  /** 
+   * Check the vertex using the method used in PWG-UD.  That is 
+   *
+   * - Check we have a vertex and status is OK
+   * - Check if we have an SPD vertex and that it's status is OK 
+   * - Check if the vertex is from the Z-vertexer, and if it is, 
+   *   - Check that the dispersion and resolution is OK 
+   * 
+   * @param esd Data 
+   * @param vz  On return, the Z coordinate of the IP
+   * @param vx  On return, possibly the X coordinate of the IP
+   * @param vy  On return, possibly the Y coordinate of the IP 
+   * 
+   * @return true if the vertex was found and met the requirements
+   */
+  virtual Bool_t CheckPWGUDVertex(const AliESDEvent& esd, 
+                                 Double_t& vz, 
+                                 Double_t& vx, 
+                                 Double_t& vy) const;
+  /** 
+   * Check the vertex. That is
+   *
+   * - Check if we have an SPD vertex and that it's status is OK 
+   * - Check that we have enough contributors 
+   * - Check that the reslution is OK 
+   * 
+   * @param esd Data 
+   * @param vz  On return, the Z coordinate of the IP
+   * @param vx  On return, possibly the X coordinate of the IP
+   * @param vy  On return, possibly the Y coordinate of the IP 
+   * 
+   * @return true if the vertex was found and met the requirements
+   */
+  virtual Bool_t CheckVertex(const AliESDEvent& esd, 
+                                 Double_t& vz, 
+                                 Double_t& vx, 
+                                 Double_t& vy) const;
   /** 
    * Read centrality from event 
    * 
@@ -313,8 +435,8 @@ protected:
    * 
    * @return False on error, true otherwise 
    */
-  virtual Bool_t ReadCentrality(const AliESDEvent* esd, Double_t& cent,
-                               UShort_t& qual) const;
+  Bool_t ReadCentrality(const AliESDEvent& esd, Double_t& cent,
+                       UShort_t& qual) const;
 
   TH1I*    fHEventsTr;    //! Histogram of events w/trigger
   TH1I*    fHEventsTrVtx; //! Events w/trigger and vertex 
@@ -325,6 +447,7 @@ protected:
   TH1I*    fHWords;       //! Trigger words 
   TH1F*    fHCent;        //! Centrality 
   TH2F*    fHCentVsQual;  //! Centrality vs quality 
+  TH1I*    fHStatus;      //! Event processing status 
   Int_t    fLowFluxCut;   //  Low flux cut
   Double_t fMaxVzErr;     //  Maximum error on v_z
   TList*   fList;         //! Histogram container 
@@ -342,6 +465,8 @@ protected:
                               // vertex 
   Bool_t   fUseDisplacedVertices; //Analyze displaced vertices?
   AliDisplacedVertexSelection fDisplacedVertex; //Displaced vertex selector
+  TList    fCollWords;     //! Configured collision words 
+  TList    fBgWords;       //! Configured background words 
   ClassDef(AliFMDEventInspector,4); // Inspect the event 
 };
 
index 8c6f9f1551ace3bcc54c026ce8be50f6dbe34839..4013b514bba80c41f175d5e90ed564d93ac1bd56 100644 (file)
@@ -286,6 +286,7 @@ AliFMDMCEventInspector::ProcessMC(AliMCEvent*       event,
                                  UShort_t&         ivz, 
                                  Double_t&         vz,
                                  Double_t&         b,
+                                 Double_t&         c,
                                  Int_t&            npart, 
                                  Int_t&            nbin,
                                  Double_t&         phiR)
@@ -300,6 +301,7 @@ AliFMDMCEventInspector::ProcessMC(AliMCEvent*       event,
   //                  means outside of the defined vertex range
   //   vz        On return, the z position of the interaction
   //   b         On return, the impact parameter - < 0 if not available
+  //   c         On return, centrality estimate - < 0 if not available 
   //   phiR      On return, the event plane angle - < 0 if not available 
   // 
   // Return:
@@ -338,6 +340,7 @@ AliFMDMCEventInspector::ProcessMC(AliMCEvent*       event,
   npart          = 0;
   nbin           = 0;
   b              = -1;
+  c              = -1;
   if (colGeometry) { 
     b     = colGeometry->ImpactParameter();
     phi   = colGeometry->ReactionPlaneAngle();
@@ -354,6 +357,15 @@ AliFMDMCEventInspector::ProcessMC(AliMCEvent*       event,
     npart = 2; // Always 2 protons
     nbin  = 1; // Always 1 binary collision 
   }
+  if (b >= 0) { 
+    if      (b <  3.5)  c = 2.5; //0-5%
+    else if (b <  4.95) c = 7.5; //5-10%
+    else if (b <  6.98) c = 15; //10-20%
+    else if (b <  8.55) c = 25; //20-30%
+    else if (b <  9.88) c = 35; //30-40%
+    else if (b < 11.04) c = 45; //40-50%
+    else                c = 55; //50-60%
+  }
   if(dpmHeader) { // Also an AliCollisionGeometry 
     Int_t processType = dpmHeader->ProcessType();
     // 1 & 4 are ND 
@@ -414,6 +426,18 @@ AliFMDMCEventInspector::ProcessMC(AliMCEvent*       event,
   fHBvsPart->Fill(b, npart);
   fHBvsBin->Fill(b, nbin);
 
+  if(fUseDisplacedVertices) {
+    // Put the vertex at fixed locations 
+    Double_t zvtx  = vz;
+    Double_t ratio = zvtx/37.5;
+    if(ratio > 0) ratio = ratio + 0.5;
+    if(ratio < 0) ratio = ratio - 0.5;
+    Int_t ratioInt = Int_t(ratio);
+    zvtx = 37.5*((Double_t)ratioInt);
+    if(TMath::Abs(zvtx) > 999) 
+      return kBadVertex;
+  }
+
   // Check for the vertex bin 
   ivz = fVtxAxis.FindBin(vz);
   if (ivz <= 0 || ivz > fHEventsTr->GetXaxis()->GetNbins()) { 
@@ -526,66 +550,6 @@ AliFMDMCEventInspector::IsSingleDiffractive(AliStack* stack,
     
   return false;
 }
-//____________________________________________________________________
-Bool_t
-AliFMDMCEventInspector::ReadCentrality(const AliESDEvent* esd, 
-                                      Double_t& cent, 
-                                      UShort_t& qual) const
-{
-  // 
-  // Read centrality from event 
-  // 
-  // Parameters:
-  //    esd  Event 
-  //    cent On return, the centrality or negative if not found
-  // 
-  // Return:
-  //    False on error, true otherwise 
-  //
-  cent = -1;
-  qual = 0;
-  AliCentrality* centObj = const_cast<AliESDEvent*>(esd)->GetCentrality();
-  if (!centObj) return true;
-AliAnalysisManager* am = AliAnalysisManager::GetAnalysisManager();
-  Bool_t isMC = am->GetMCtruthEventHandler() != 0;
-  
-  //std::cout<<fUseDisplacedVertices<<"  "<<isMC<<std::endl;
-  
-  if(fUseDisplacedVertices && isMC) {
-    
-    
-    AliMCEventHandler* mchandler = static_cast<AliMCEventHandler*>(am->GetMCtruthEventHandler());
-    AliMCEvent* mcevent          = mchandler->MCEvent();
-    
-    AliHeader*               header          = mcevent->Header();
-    AliGenEventHeader*       genHeader       = header->GenEventHeader();
-    AliCollisionGeometry*    colGeometry     = 
-      dynamic_cast<AliCollisionGeometry*>(genHeader);
-    Double_t b              = -1;
-    if (colGeometry)  
-      b     = colGeometry->ImpactParameter();
-    //std::cout<<"Hallo!!  "<<b<<std::endl;
-    cent = -1;
-    if(b<3.5 && b >0) cent = 2.5; //0-5%
-    if(b>3.5 && b<4.95) cent = 7.5; //5-10%
-    if(b>4.95 && b<6.98) cent = 15; //10-20%
-    if(b>6.98 && b<8.55) cent = 25; //20-30%
-    if(b>8.55 && b<9.88) cent = 35; //30-40%
-    if(b>9.88 && b<11.04) cent = 45; //40-50%
-    if(b>11.04) cent = 55; //50-60%
-    //cent = 10;
-    qual = 0;
-  }
-  else {
-    
-    qual = centObj->GetQuality();
-    if (qual == 0x8) // Ignore ZDC outliers 
-      cent = centObj->GetCentralityPercentileUnchecked("V0M");  
-    else
-      cent = centObj->GetCentralityPercentile("V0M");        
-  }
-  return true;
-}
 
 //____________________________________________________________________
 Bool_t
index 05e5ef3d3af240bccd8642172f699ed433f61079..63754ac2e1a3cb3b02b39d8ed94ae73713617123 100644 (file)
@@ -86,6 +86,7 @@ public:
    *                  means outside of the defined vertex range
    * @param vz        On return, the z position of the interaction
    * @param b         On return, impact parameter [fm] (if available)
+   * @param b         On return, centrality estimate [%] (if available)
    * @param npart     On return, number of participants (if available)
    * @param nbin      On return, number of binary collisions (if available)
    * @param phiR      On return, reaction plane angle (if available)
@@ -97,6 +98,7 @@ public:
                   UShort_t&         ivz, 
                   Double_t&         vz,
                   Double_t&         b,
+                  Double_t&         c,
                   Int_t&            npart, 
                   Int_t&            nbin,
                   Double_t&         phiR);
@@ -136,17 +138,6 @@ public:
    */
   virtual void ReadProductionDetails(AliMCEvent* event);
 protected:
-  /** 
-   * Read centrality from event 
-   * 
-   * @param esd  Event 
-   * @param cent On return, the centrality or negative if not found
-   * @param qual Quality flag 
-   * 
-   * @return False on error, true otherwise 
-   */
-  virtual Bool_t ReadCentrality(const AliESDEvent* esd, Double_t& cent,
-                               UShort_t& qual) const;
   /** 
    * Check if the event is single diffractive 
    * 
@@ -159,6 +150,8 @@ protected:
   Bool_t IsSingleDiffractive(AliStack* stack,
                             Double_t xiMin=0, 
                             Double_t xiMax=1./81) const;
+  virtual Bool_t CheckFastPartition(bool) const { return false; }
+
   TH1F* fHVertex;  // Histogram of vertex 
   TH1F* fHPhiR;    // Histogram of event plane 
   TH1F* fHB;       // Histogram of impact parameter 
index 84406c9f4c769fbe6fbdc85cdd9c444b5fecd433..b2e3b894ee96eccc3332795e4288ca7b438145fd 100644 (file)
@@ -1,6 +1,7 @@
 #include "AliFMDMultCuts.h"
 #include "AliForwardCorrectionManager.h"
 #include "AliFMDCorrELossFit.h"
+#include "AliForwardUtil.h"
 #include <iostream>
 #include <TROOT.h>
 #include <TParameter.h>
@@ -129,14 +130,30 @@ AliFMDMultCuts::Output(TList* l, const char* name) const
     l->Add(ll);
   }
     
-  TParameter<double>* nXi    = new TParameter<double>("nXi", fNXi);
-  TParameter<double>* frac   = new TParameter<double>("frac", fMPVFraction);
-  TNamed*             sigma  = new TNamed("sigma", fIncludeSigma ? 
-                                         "included" : "excluded");
-  sigma->SetUniqueID(fIncludeSigma);
-  ll->Add(nXi);
-  ll->Add(frac);
-  ll->Add(sigma);
+  ll->Add(AliForwardUtil::MakeParameter("nXi", fNXi));
+  ll->Add(AliForwardUtil::MakeParameter("frac", fMPVFraction));
+  ll->Add(AliForwardUtil::MakeParameter("sigma", fIncludeSigma));
+}
+//____________________________________________________________________
+Bool_t
+AliFMDMultCuts::Input(TList* l, const char* name)
+{
+  if (!l) return false;
+  TList* ll = l;
+  if (name && name[0] != '\0') { 
+    ll = static_cast<TList*>(l->FindObject(name));
+  }
+  if (!ll) return false;
+  
+  TObject* nXi   = ll->FindObject("nXi");
+  TObject* frac  = ll->FindObject("frac");
+  TObject* sigma = ll->FindObject("sigma");
+  if (!nXi || !frac || !sigma) return false;
+  AliForwardUtil::GetParameter(nXi, fNXi);
+  AliForwardUtil::GetParameter(frac, fMPVFraction);
+  AliForwardUtil::GetParameter(sigma, fIncludeSigma);
+  
+  return true;
 }
   
 //____________________________________________________________________
index 8b500bcbcd66121f1f58eadf3b0922f757c7fd40..d000465b157c38b5b9df13cabe6132ed151447ba 100644 (file)
@@ -99,6 +99,15 @@ public:
    * @param name   Name 
    */
   void Output(TList* l, const char* name=0) const;
+  /** 
+   * Read in cuts stored in file 
+   * 
+   * @param l      List to read from 
+   * @param name   Name of possible sub-list
+   * 
+   * @return true on success
+   */
+  Bool_t Input(TList* l, const char* name);
   /** 
    * Get a fixed cut value 
    * 
index 0c2af0d79cf0faa5c68bebe8e4461e12008c86eb..18b919db50928a8187f217cef335a1f9b973f7cf 100644 (file)
@@ -68,7 +68,7 @@ AliFMDSharingFilter::AliFMDSharingFilter()
   // 
   // Default Constructor - do not use 
   //
-  DGUARD(fDebug,0, "Default CTOR for AliFMDSharingFilter");
+  DGUARD(fDebug,1, "Default CTOR for AliFMDSharingFilter");
 }
 
 //____________________________________________________________________
@@ -94,7 +94,7 @@ AliFMDSharingFilter::AliFMDSharingFilter(const char* title)
   // Parameters:
   //    title Title of object  - not significant 
   //
-  DGUARD(fDebug,0, "Named CTOR for AliFMDSharingFilter: %s", title);
+  DGUARD(fDebug,1, "Named CTOR for AliFMDSharingFilter: %s", title);
   fRingHistos.SetName(GetName());
   fRingHistos.SetOwner();
   
@@ -132,7 +132,7 @@ AliFMDSharingFilter::AliFMDSharingFilter(const AliFMDSharingFilter& o)
   // Parameters:
   //    o Object to copy from 
   //
-  DGUARD(fDebug,0, "Copy CTOR for AliFMDSharingFilter");
+  DGUARD(fDebug,1, "Copy CTOR for AliFMDSharingFilter");
   TIter    next(&o.fRingHistos);
   TObject* obj = 0;
   while ((obj = next())) fRingHistos.Add(obj);
@@ -270,6 +270,9 @@ AliFMDSharingFilter::Init(const TAxis& axis)
 }
 
 //____________________________________________________________________
+#define ETA2COS(ETA) \
+  TMath::Cos(2*TMath::ATan(TMath::Exp(-TMath::Abs(ETA))))
+
 Bool_t
 AliFMDSharingFilter::Filter(const AliESDFMD& input, 
                            Bool_t           lowFlux,
@@ -299,6 +302,9 @@ AliFMDSharingFilter::Filter(const AliESDFMD& input,
   Int_t nCandidate = 0;
   Int_t nMerged    = 0;
   Int_t nSummed    = 0;
+  Int_t nSingle    = 0;
+  Int_t nDouble    = 0;
+  Int_t nTriple    = 0;
 
   Status status[512];
   
@@ -319,8 +325,8 @@ AliFMDSharingFilter::Filter(const AliESDFMD& input,
        Bool_t usedPrev   = kFALSE;
 #endif 
        //For simple merging
-       Bool_t used = kFALSE;
-       Double_t eTotal = -1;
+       Bool_t   used            = kFALSE;
+       Double_t eTotal          = -1;
        Int_t    nDistanceBefore = -1;
        Int_t    nDistanceAfter  = -1;
        Bool_t   twoLow = kFALSE;
@@ -329,38 +335,31 @@ AliFMDSharingFilter::Filter(const AliESDFMD& input,
          nDistanceAfter++;
          
          output.SetMultiplicity(d,r,s,t,0.);
-         Float_t mult = SignalInStrip(input,d,r,s,t);
-         //For simple merging
-         Float_t multNext     = 0;
-         Float_t multNextNext = 0;
-         
-         if(t<nstr-1) multNext = SignalInStrip(input,d,r,s,t+1);
-         if(t<nstr-2) multNextNext = SignalInStrip(input,d,r,s,t+2);
-         if(multNext ==  AliESDFMD::kInvalidMult) multNext = 0;
-         if(multNextNext ==  AliESDFMD::kInvalidMult) multNextNext = 0;
+         Float_t mult         = SignalInStrip(input,d,r,s,t);
+         Float_t multNext     = (t<nstr-1) ? SignalInStrip(input,d,r,s,t+1) :0;
+         Float_t multNextNext = (t<nstr-2) ? SignalInStrip(input,d,r,s,t+2) :0;
+         if (multNext     ==  AliESDFMD::kInvalidMult) multNext     = 0;
+         if (multNextNext ==  AliESDFMD::kInvalidMult) multNextNext = 0;
          if(!fThreeStripSharing) multNextNext = 0;
+
          // Get the pseudo-rapidity 
          Double_t eta = input.Eta(d,r,s,t);
          Double_t phi = input.Phi(d,r,s,t) * TMath::Pi() / 180.;
          if (s == 0) output.SetEta(d,r,s,t,eta);
          
-         Double_t etaOld  = eta;
-         Double_t etaCalc = 0;
          if(fRecalculateEta) { 
-           etaCalc = AliForwardUtil::GetEtaFromStrip(d,r,s,t,zvtx);
-           eta = etaCalc;
-         }
-         if(fRecalculateEta && mult > 0 && mult != AliESDFMD::kInvalidMult ) {
-           Double_t cosOld = TMath::Cos(2*TMath::ATan(TMath::Exp(-1*TMath::Abs(etaOld))));
-           Double_t cosNew = TMath::Cos(2*TMath::ATan(TMath::Exp(-1*TMath::Abs(etaCalc))));        
-           if(mult > 0) mult = (mult/cosOld)*cosNew;
-           if(multNext > 0) multNext = (multNext/cosOld)*cosNew;
-           if(multNextNext > 0) multNextNext = (multNextNext/cosOld)*cosNew;
+           Double_t etaOld  = eta;
+           Double_t etaCalc = AliForwardUtil::GetEtaFromStrip(d,r,s,t,zvtx);
+           eta              = etaCalc;
            
-           //No corrections beyond this point
-           //  if(eta < -4) {
-           //  mult = 0; multNext = 0; multNextNext = 0;
-           // }
+           if (mult > 0 && mult != AliESDFMD::kInvalidMult ) {
+             Double_t cosOld =  ETA2COS(etaOld);
+             Double_t cosNew =  ETA2COS(etaCalc);
+             Double_t corr   =  cosNew / cosOld;
+             mult            *= corr;
+             multNext        *= corr;
+             multNextNext    *= corr;
+           }
          }
          
          // Keep dead-channel information. 
@@ -393,11 +392,13 @@ AliFMDSharingFilter::Filter(const AliESDFMD& input,
                eTotal = eTotal + multNext;
                used = kTRUE;
                histos->fTriple->Fill(eTotal);
+               nTriple++;
                twoLow = kFALSE;
              }
              else {
                used = kFALSE;
                histos->fDouble->Fill(eTotal);
+               nDouble++;
              }
              etot   = eTotal;
              eTotal = -1;
@@ -420,6 +421,7 @@ AliFMDSharingFilter::Filter(const AliESDFMD& input,
                    etot = mult + multNext;
                    used=kTRUE;
                    histos->fDouble->Fill(etot);
+                   nDouble++;
                  }
                else {
                  etot   = 0;
@@ -430,6 +432,7 @@ AliFMDSharingFilter::Filter(const AliESDFMD& input,
                if(etot > 0) {
                  histos->fSingle->Fill(etot);
                  histos->fSinglePerStrip->Fill(etot,t);
+                 nSingle++;
                }
              }
            }
@@ -441,8 +444,8 @@ AliFMDSharingFilter::Filter(const AliESDFMD& input,
            }
            //if(mult>0 && multNext >0)
            //  std::cout<<mult<<"  "<<multNext<<"  "<<mergedEnergy<<std::endl;
-         }
-         else {
+         } // End of simple merge 
+         else { // Not simple 
            // Get next and previous signal - if any 
            Double_t prevE = 0;
            Double_t nextE = 0;
@@ -479,7 +482,7 @@ AliFMDSharingFilter::Filter(const AliESDFMD& input,
 #endif
            // If we're processing on non-angle corrected data, we
            // should do the angle correction here
-         }
+         } // End of non-simple
          if (!fCorrectAngles)
            mergedEnergy = AngleCorrect(mergedEnergy, eta);
          if (mergedEnergy > 0) histos->Incr();
@@ -511,8 +514,8 @@ AliFMDSharingFilter::Filter(const AliESDFMD& input,
   fSummed->Fill(kMergedWithOther, nMerged);
   fSummed->Fill(kMergedInto,      nSummed);
 
-  DBGL(5, Form("none=%9d, candidate=%9d, merged=%9d, summed=%9d", 
-              nNone, nCandidate, nMerged, nSummed));
+  DMSG(fDebug, 3,"single=%9d, double=%9d, triple=%9d", 
+       nSingle, nDouble, nTriple);
   next.Reset();
   while ((o = static_cast<RingHistos*>(next())))
     o->Finish();
@@ -946,21 +949,13 @@ AliFMDSharingFilter::DefineOutput(TList* dir)
   fLowCuts->SetDirectory(0);
   d->Add(fLowCuts);
 
-  TNamed* angle  = new TNamed("angle", fCorrectAngles ? 
-                             "corrected" : "uncorrected");
-  angle->SetUniqueID(fCorrectAngles);
-  TNamed* low = new TNamed("lowSignal", fZeroSharedHitsBelowThreshold ? 
-                          "zeroed" : "kept");
-  low->SetUniqueID(fZeroSharedHitsBelowThreshold);
-  TNamed* simple = new TNamed("simple", fUseSimpleMerging ? "yes" : "no");
-  simple->SetUniqueID(fUseSimpleMerging);
-  
   // d->Add(lowCut);
   // d->Add(nXi);
   // d->Add(sigma);
-  d->Add(angle);
-  d->Add(low);
-  d->Add(simple);
+  d->Add(AliForwardUtil::MakeParameter("angle", fCorrectAngles));
+  d->Add(AliForwardUtil::MakeParameter("lowSignal", 
+                                      fZeroSharedHitsBelowThreshold));
+  d->Add(AliForwardUtil::MakeParameter("simple", fUseSimpleMerging));
   fLCuts.Output(d,"lCuts");
   fHCuts.Output(d,"hCuts");
 
index 9a014f6c5ae732ddb491ab3e8e3fe40961ca2d70..3de944e776239aba1ed4f5e28a01a1ed7a3f8702 100644 (file)
@@ -383,6 +383,7 @@ AliForwardMCCorrectionsTask::UserExec(Option_t*)
   UShort_t iVzMc;    // Vertex bin from MC
   Double_t vZMc;     // Z coordinate of IP vertex from MC
   Double_t b;        // Impact parameter
+  Double_t cMC;      // Centrality estimate from b
   Int_t    nPart;    // Number of participants 
   Int_t    nBin;     // Number of binary collisions 
   Double_t phiR;     // Reaction plane from MC
@@ -391,7 +392,7 @@ AliForwardMCCorrectionsTask::UserExec(Option_t*)
   UInt_t retESD = fInspector.Process(esd, triggers, lowFlux, iVz, vZ, 
                                     cent, nClusters);
   fInspector.ProcessMC(mcEvent, triggers, iVzMc, vZMc, 
-                      b, nPart, nBin, phiR);
+                      b, cMC, nPart, nBin, phiR);
 
   Bool_t isInel   = triggers & AliAODForwardMult::kInel;
   Bool_t hasVtx   = retESD == AliFMDMCEventInspector::kOk;
index ad29e4545f52a3863cef9c7573cb1bcaf1ff4147..3825b2a5cc7ededbd68dc2ff82e5bceb5c68e090 100644 (file)
@@ -336,10 +336,11 @@ AliForwardMCMultiplicityTask::UserExec(Option_t*)
   Double_t vzMC     = 0;
   Double_t phiR     = 0;
   Double_t b        = 0;
+  Double_t cMC      = 0;
   Int_t    npart    = 0;
   Int_t    nbin     = 0;
   // UInt_t   foundMC  = 
-  fEventInspector.ProcessMC(mcEvent, triggers, ivzMC, vzMC, b, 
+  fEventInspector.ProcessMC(mcEvent, triggers, ivzMC, vzMC, b, cMC,
                            npart, nbin, phiR);
   fEventInspector.CompareResults(vz, vzMC, cent, b, npart, nbin);
   
index 3971d776a0f63a8b4de3cb2105f63111cd66fd0e..8112079c7ed58c4781b162681325eba092f1f70c 100644 (file)
@@ -230,7 +230,11 @@ AliForwardQATask::GetESDEvent()
   //
   // Get the ESD event. IF this is the first event, initialise
   //
-  if (IsZombie()) return 0;
+  DGUARD(fDebug,2,"Get the ESD event");
+  if (IsZombie()) {
+    DMSG(fDebug,3,"We're a Zombie - bailing out");
+    return 0;
+  }
   AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent());
   if (!esd) {
     AliWarning("No ESD event found for input event");
@@ -323,6 +327,7 @@ AliForwardQATask::UserExec(Option_t*)
   // Parameters:
   //    option Not used
   //  
+  DGUARD(fDebug,1,"Process the input event");
 
   // static Int_t cnt = 0;
   // cnt++;
@@ -353,13 +358,20 @@ AliForwardQATask::UserExec(Option_t*)
   UInt_t   found     = fEventInspector.Process(esd, triggers, lowFlux, 
                                               ivz, vz, cent, nClusters);
   
-  if (found & AliFMDEventInspector::kNoEvent)    return;
-  if (found & AliFMDEventInspector::kNoTriggers) return;
-  if (found & AliFMDEventInspector::kNoSPD)      return;
-  if (found & AliFMDEventInspector::kNoFMD)      return;
-  if (found & AliFMDEventInspector::kNoVertex)   return;
-  if (triggers & AliAODForwardMult::kPileUp)     return;
-  if (found & AliFMDEventInspector::kBadVertex)  return;
+  Bool_t ok = true;
+  if (found & AliFMDEventInspector::kNoEvent)    ok = false;
+  if (found & AliFMDEventInspector::kNoTriggers) ok = false;
+  if (found & AliFMDEventInspector::kNoSPD)      ok = false;
+  if (found & AliFMDEventInspector::kNoFMD)      ok = false;
+  if (found & AliFMDEventInspector::kNoVertex)   ok = false;
+  if (triggers & AliAODForwardMult::kPileUp)     ok = false;
+  if (found & AliFMDEventInspector::kBadVertex)  ok = false;
+  if (!ok) { 
+    DMSG(fDebug,2,"Event failed selection: %s", 
+        AliFMDEventInspector::CodeString(found));
+    return;
+  }
+  DMSG(fDebug,2,"Event triggers: %s", AliAODForwardMult::GetTriggerString(triggers));
 
   // We we do not want to use low flux specific code, we disable it here. 
   if (!fEnableLowFlux) lowFlux = false;
index e99b6147cd2fcf2f4ae25645e480c117ce997374..e796d0d25891742c653f291a8d6125449f9ea2d5 100644 (file)
@@ -15,6 +15,7 @@
 #include <AliPhysicsSelection.h>
 #include <AliTriggerAnalysis.h>
 #include <AliMultiplicity.h>
+#include <TParameter.h>
 #include <TH2D.h>
 #include <TH1I.h>
 #include <TF1.h>
@@ -212,7 +213,62 @@ Bool_t AliForwardUtil::CheckForTask(const char* clsOrName, Bool_t cls)
   return false;
 }
 
-  
+//_____________________________________________________________________
+TObject* AliForwardUtil::MakeParameter(const Char_t* name, UShort_t value)
+{
+  TParameter<int>* ret = new TParameter<int>(name, value);
+  ret->SetUniqueID(value);
+  return ret;
+}
+//_____________________________________________________________________
+TObject* AliForwardUtil::MakeParameter(const Char_t* name, Int_t value)
+{
+  TParameter<int>* ret = new TParameter<int>(name, value);
+  ret->SetUniqueID(value);
+  return ret;
+}
+//_____________________________________________________________________
+TObject* AliForwardUtil::MakeParameter(const Char_t* name, Double_t value)
+{
+  TParameter<double>* ret = new TParameter<double>(name, value);
+  Float_t v = value;
+  ret->SetUniqueID(*reinterpret_cast<UInt_t*>(&v));
+  return ret;
+}
+//_____________________________________________________________________
+TObject* AliForwardUtil::MakeParameter(const Char_t* name, Bool_t value)
+{
+  TParameter<bool>* ret = new TParameter<bool>(name, value);
+  ret->SetUniqueID(value);
+  return ret;
+}
+
+//_____________________________________________________________________
+void AliForwardUtil::GetParameter(TObject* o, UShort_t& value)
+{
+  if (!o) return;
+  value = o->GetUniqueID();
+}
+//_____________________________________________________________________
+void AliForwardUtil::GetParameter(TObject* o, Int_t& value)
+{
+  if (!o) return;
+  value = o->GetUniqueID();
+}
+//_____________________________________________________________________
+void AliForwardUtil::GetParameter(TObject* o, Double_t& value)
+{
+  if (!o) return;
+  UInt_t  i = o->GetUniqueID();
+  Float_t v = *reinterpret_cast<Float_t*>(&i);
+  value = v;
+}
+//_____________________________________________________________________
+void AliForwardUtil::GetParameter(TObject* o, Bool_t& value)
+{
+  if (!o) return;
+  value = o->GetUniqueID();
+}
   
 //_____________________________________________________________________
 Double_t AliForwardUtil::GetEtaFromStrip(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip, Double_t zvtx)
index 67d5748646c2bc45f3d45a32538d00e7cf487e6c..b25c728d9e242c0cc7f584e28e4d949322bf55d5 100644 (file)
@@ -162,6 +162,21 @@ public:
    */
   static Bool_t CheckForTask(const char* clsOrName, Bool_t cls=true);
 
+  //__________________________________________________________________
+  /** 
+   * @{ 
+   * @name Member functions to store and retrieve analysis parameters 
+   */
+  static TObject* MakeParameter(const char* name, UShort_t value);
+  static TObject* MakeParameter(const char* name, Int_t value);
+  static TObject* MakeParameter(const char* name, Double_t value);
+  static TObject* MakeParameter(const char* name, Bool_t value);
+  static void GetParameter(TObject* o, UShort_t& value);
+  static void GetParameter(TObject* o, Int_t& value);
+  static void GetParameter(TObject* o, Double_t& value);
+  static void GetParameter(TObject* o, Bool_t& value);
+  /* @} */
+
   /** 
    * @{ 
    * @name Energy stragling functions