]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/FORWARD/analysis2/AliFMDEventInspector.cxx
Coverity fixes
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliFMDEventInspector.cxx
index 9f76c527e9ec512b7d8358d02c0edf0814a82fa8..ece4bb3f1be785517d1ad55fd1fe707fd2cdbe4e 100644 (file)
 #include <TROOT.h>
 #include <iostream>
 #include <iomanip>
-#include "AliMCEvent.h"
-#include "AliGenPythiaEventHeader.h"
-#include "AliGenDPMjetEventHeader.h"
-#include "AliHeader.h"
-#include "AliMCEventHandler.h"
+
 //====================================================================
 AliFMDEventInspector::AliFMDEventInspector()
   : TNamed(),
     fHEventsTr(0), 
     fHEventsTrVtx(0),
+    fHEventsAccepted(0),
     fHTriggers(0),
     fHType(0),
     fHWords(0),
     fHCent(0),
+    fHCentVsQual(0),
     fLowFluxCut(1000),
     fMaxVzErr(0.2),
     fList(0),
     fEnergy(0),
     fField(999), 
     fCollisionSystem(kUnknown),
-    fDebug(0)
+    fDebug(0),
+    fCentAxis(0),
+    fVtxAxis(10,-10,10)
 {
   // 
   // Constructor 
@@ -63,17 +63,21 @@ AliFMDEventInspector::AliFMDEventInspector(const char* name)
   : TNamed("fmdEventInspector", name),
     fHEventsTr(0), 
     fHEventsTrVtx(0), 
+    fHEventsAccepted(0),
     fHTriggers(0),
     fHType(0),
     fHWords(0),
     fHCent(0),
+    fHCentVsQual(0),
     fLowFluxCut(1000),
     fMaxVzErr(0.2),
     fList(0),
     fEnergy(0),
     fField(999), 
     fCollisionSystem(kUnknown),
-    fDebug(0)
+    fDebug(0),
+    fCentAxis(0),
+    fVtxAxis(10,-10,10)
 {
   // 
   // Constructor 
@@ -88,17 +92,21 @@ AliFMDEventInspector::AliFMDEventInspector(const AliFMDEventInspector& o)
   : TNamed(o), 
     fHEventsTr(o.fHEventsTr), 
     fHEventsTrVtx(o.fHEventsTrVtx), 
+    fHEventsAccepted(o.fHEventsAccepted),
     fHTriggers(o.fHTriggers),
     fHType(o.fHType),
     fHWords(o.fHWords),
     fHCent(o.fHCent),
+    fHCentVsQual(o.fHCentVsQual),
     fLowFluxCut(o.fLowFluxCut),
     fMaxVzErr(o.fMaxVzErr),
     fList(o.fList),
     fEnergy(o.fEnergy),
     fField(o.fField), 
     fCollisionSystem(o.fCollisionSystem),
-    fDebug(0)
+    fDebug(0),
+    fCentAxis(0),
+    fVtxAxis(o.fVtxAxis)
 {
   // 
   // Copy constructor 
@@ -114,12 +122,6 @@ AliFMDEventInspector::~AliFMDEventInspector()
   // 
   // Destructor 
   //
-  if (fHEventsTr)    delete fHEventsTr;
-  if (fHEventsTrVtx) delete fHEventsTrVtx;
-  if (fHTriggers)    delete fHTriggers;  
-  if (fHType)        delete fHType;
-  if (fHWords)       delete fHWords;
-  if (fHCent)        delete fHCent;
   if (fList)         delete fList;
 }
 //____________________________________________________________________
@@ -138,10 +140,12 @@ AliFMDEventInspector::operator=(const AliFMDEventInspector& o)
   TNamed::operator=(o);
   fHEventsTr         = o.fHEventsTr;
   fHEventsTrVtx      = o.fHEventsTrVtx;
+  fHEventsAccepted   = o.fHEventsAccepted;
   fHTriggers         = o.fHTriggers;
   fHType             = o.fHType;
   fHWords            = o.fHWords;
   fHCent             = o.fHCent;
+  fHCentVsQual       = o.fHCentVsQual;
   fLowFluxCut        = o.fLowFluxCut;
   fMaxVzErr          = o.fMaxVzErr;
   fDebug             = o.fDebug;
@@ -149,6 +153,8 @@ AliFMDEventInspector::operator=(const AliFMDEventInspector& o)
   fEnergy            = o.fEnergy;
   fField             = o.fField;
   fCollisionSystem   = o.fCollisionSystem;
+  fVtxAxis.Set(o.fVtxAxis.GetNbins(), o.fVtxAxis.GetXmin(), 
+              o.fVtxAxis.GetXmax());
   if (fList) { 
     fList->SetName(GetName());
     if (fHEventsTr)    fList->Add(fHEventsTr);
@@ -157,13 +163,14 @@ AliFMDEventInspector::operator=(const AliFMDEventInspector& o)
     if (fHType)        fList->Add(fHType);
     if (fHWords)       fList->Add(fHWords);
     if (fHCent)        fList->Add(fHCent);
+    if (fHCentVsQual)  fList->Add(fHCentVsQual);
   }
   return *this;
 }
 
 //____________________________________________________________________
 Bool_t
-AliFMDEventInspector::FetchHistograms(TList* d, 
+AliFMDEventInspector::FetchHistograms(const TList* d, 
                                      TH1I*& hEventsTr, 
                                      TH1I*& hEventsTrVtx, 
                                      TH1I*& hTriggers) const
@@ -203,10 +210,19 @@ AliFMDEventInspector::Init(const TAxis& vtxAxis)
   // Parameters:
   //   vtxAxis Vertex axis in use 
   //
+  
+  // -1.5 -0.5 0.5 1.5 ... 89.5 ... 100.5
+  // ----- 92 number --------- ---- 1 ---
+  TArrayD limits(93);
+  for (Int_t i = 0; i < 92; i++) limits[i] = -1.5 + i;
+
+  fVtxAxis.Set(vtxAxis.GetNbins(), vtxAxis.GetXmin(), vtxAxis.GetXmax());
+  
+  fCentAxis  = new TAxis(limits.GetSize()-1, limits.GetArray());
   fHEventsTr = new TH1I("nEventsTr", "Number of events w/trigger", 
-                       vtxAxis.GetNbins(), 
-                       vtxAxis.GetXmin(), 
-                       vtxAxis.GetXmax());
+                       4*vtxAxis.GetNbins(), 
+                       2*vtxAxis.GetXmin(), 
+                       2*vtxAxis.GetXmax());
   fHEventsTr->SetXTitle("v_{z} [cm]");
   fHEventsTr->SetYTitle("# of events");
   fHEventsTr->SetFillColor(kRed+1);
@@ -215,21 +231,28 @@ AliFMDEventInspector::Init(const TAxis& vtxAxis)
   // fHEventsTr->Sumw2();
   fList->Add(fHEventsTr);
 
-  fHEventsTrVtx = new TH1I("nEventsTrVtx", 
-                          "Number of events w/trigger and vertex", 
-                          vtxAxis.GetNbins(), 
-                          vtxAxis.GetXmin(), 
-                          vtxAxis.GetXmax());
-  fHEventsTrVtx->SetXTitle("v_{z} [cm]");
-  fHEventsTrVtx->SetYTitle("# of events");
+  fHEventsTrVtx = static_cast<TH1I*>(fHEventsTr->Clone("nEventsTrVtx"));
+  fHEventsTrVtx->SetTitle("Number of events w/trigger and vertex"); 
   fHEventsTrVtx->SetFillColor(kBlue+1);
-  fHEventsTrVtx->SetFillStyle(3001);
   fHEventsTrVtx->SetDirectory(0);
   // fHEventsTrVtx->Sumw2();
   fList->Add(fHEventsTrVtx);
 
+  fHEventsAccepted = new TH1I("nEventsAccepted", 
+                             "Number of events  w/trigger and vertex in range",
+                             2*vtxAxis.GetNbins(), 
+                             2*vtxAxis.GetXmin(), 
+                             2*vtxAxis.GetXmax());
+  fHEventsAccepted->SetXTitle("v_{z} [cm]");
+  fHEventsAccepted->SetYTitle("# of events");
+  fHEventsAccepted->SetFillColor(kGreen+1);
+  fHEventsAccepted->SetFillStyle(3001);
+  fHEventsAccepted->SetDirectory(0);
+  // fHEventsAccepted->Sumw2();
+  fList->Add(fHEventsAccepted);
+                             
       
-  fHTriggers = new TH1I("triggers", "Triggers", 10, 0, 10);
+  fHTriggers = new TH1I("triggers", "Triggers", kOffline+1, 0, kOffline+1);
   fHTriggers->SetFillColor(kRed+1);
   fHTriggers->SetFillStyle(3001);
   fHTriggers->SetStats(0);
@@ -243,7 +266,8 @@ AliFMDEventInspector::Init(const TAxis& vtxAxis)
   fHTriggers->GetXaxis()->SetBinLabel(kC      +1,"C");
   fHTriggers->GetXaxis()->SetBinLabel(kE      +1,"E");
   fHTriggers->GetXaxis()->SetBinLabel(kPileUp +1,"Pileup");
-  fHTriggers->GetXaxis()->SetBinLabel(kMCNSD  +1,"nsd");
+  fHTriggers->GetXaxis()->SetBinLabel(kMCNSD  +1,"NSD_{MC}");
+  fHTriggers->GetXaxis()->SetBinLabel(kOffline+1,"Offline");
   fList->Add(fHTriggers);
 
   fHType = new TH1I("type", Form("Event type (cut: SPD mult>%d)", 
@@ -265,7 +289,7 @@ AliFMDEventInspector::Init(const TAxis& vtxAxis)
   fHWords->SetBit(TH1::kCanRebin);
   fList->Add(fHWords);
 
-  fHCent = new TH1F("cent", "Centrality", 101, -1.5, 100.5);
+  fHCent = new TH1F("cent", "Centrality", limits.GetSize()-1,limits.GetArray());
   fHCent->SetFillColor(kBlue+1);
   fHCent->SetFillStyle(3001);
   fHCent->SetStats(0);
@@ -273,6 +297,18 @@ AliFMDEventInspector::Init(const TAxis& vtxAxis)
   fHCent->SetXTitle("Centrality [%]");
   fHCent->SetYTitle("Events");
   fList->Add(fHCent);
+
+  fHCentVsQual = new TH2F("centVsQuality", "Quality vs Centrality", 
+                         5, 0, 5, limits.GetSize()-1, limits.GetArray());
+  fHCentVsQual->SetXTitle("Quality");
+  fHCentVsQual->SetYTitle("Centrality [%]");
+  fHCentVsQual->SetZTitle("Events");
+  fHCentVsQual->GetXaxis()->SetBinLabel(1, "OK");
+  fHCentVsQual->GetXaxis()->SetBinLabel(2, "Outside v_{z} cut");
+  fHCentVsQual->GetXaxis()->SetBinLabel(3, "V0 vs SPD outlier");
+  fHCentVsQual->GetXaxis()->SetBinLabel(4, "V0 vs TPC outlier");
+  fHCentVsQual->GetXaxis()->SetBinLabel(5, "V0 vs ZDC outlier");
+  fList->Add(fHCentVsQual);
 }
 
 //____________________________________________________________________
@@ -298,7 +334,8 @@ AliFMDEventInspector::Process(const AliESDEvent* event,
                              Bool_t&            lowFlux,
                              UShort_t&          ivz, 
                              Double_t&          vz,
-                             Double_t&          cent)
+                             Double_t&          cent,
+                             UShort_t&          nClusters)
 {
   // 
   // Process the event 
@@ -317,49 +354,45 @@ AliFMDEventInspector::Process(const AliESDEvent* event,
   //    0 (or kOk) on success, otherwise a bit mask of error codes 
   //
 
-  // Check that we have an event 
+  // --- Check that we have an event ---------------------------------
   if (!event) { 
     AliWarning("No ESD event found for input event");
     return kNoEvent;
   }
 
-  // Read trigger information from the ESD and store in AOD object
-  if (!ReadTriggers(event, triggers)) { 
+  // --- Read trigger information from the ESD and store in AOD object
+  if (!ReadTriggers(event, triggers, nClusters)) { 
     if (fDebug > 2) {
       AliWarning("Failed to read triggers from ESD"); }
     return kNoTriggers;
   }
 
-  // Check if this is a high-flux event 
+  // --- Check if this is a high-flux event --------------------------
   const AliMultiplicity* testmult = event->GetMultiplicity();
   if (!testmult) {
     if (fDebug > 3) {
       AliWarning("No central multiplicity object found"); }
-    return kNoSPD;
   }
-  lowFlux = testmult->GetNumberOfTracklets() < fLowFluxCut;
+  else 
+    lowFlux = testmult->GetNumberOfTracklets() < fLowFluxCut;
 
   fHType->Fill(lowFlux ? 0 : 1);
   
-  cent = -10;
-  AliCentrality* centObj = const_cast<AliESDEvent*>(event)->GetCentrality();
-  if (centObj) {
-    // AliInfo(Form("Got centrality object %p with quality %d", 
-    //              centObj, centObj->GetQuality()));
-    // centObj->Print();
-    cent = centObj->GetCentralityPercentileUnchecked("V0M");  
+  // --- Read centrality information 
+  cent          = -10;
+  UShort_t qual = 0;
+  if (!ReadCentrality(event, cent, qual)) {
+    if (fDebug > 3) 
+      AliWarning("Failed to get centrality");
   }
-  // AliInfo(Form("Centrality is %f", cent));
   fHCent->Fill(cent);
-
-  // Check the FMD ESD data 
-  if (!event->GetFMDData()) { 
-    if (fDebug > 3) {
-      AliWarning("No FMD data found in ESD"); }
-    return kNoFMD;
+  if (qual == 0) fHCentVsQual->Fill(0., cent);
+  else { 
+    for (UShort_t i = 0; i < 4; i++) 
+      if (qual & (1 << i)) fHCentVsQual->Fill(Double_t(i+1), cent);
   }
 
-  // Get the vertex information 
+  // --- Get the vertex information ----------------------------------
   vz          = 0;
   Bool_t vzOk = ReadVertex(event, vz);
 
@@ -371,24 +404,63 @@ AliFMDEventInspector::Process(const AliESDEvent* event,
   }
   fHEventsTrVtx->Fill(vz);
 
-  // Get the vertex bin 
-  ivz = fHEventsTr->GetXaxis()->FindBin(vz);
-  if (ivz <= 0 || ivz > fHEventsTr->GetXaxis()->GetNbins()) { 
+  // --- Get the vertex bin ------------------------------------------
+  ivz = fVtxAxis.FindBin(vz);
+  if (ivz <= 0 || ivz > fVtxAxis.GetNbins()) { 
     if (fDebug > 3) {
       AliWarning(Form("Vertex @ %f outside of range [%f,%f]", 
-                     vz, fHEventsTr->GetXaxis()->GetXmin(), 
-                     fHEventsTr->GetXaxis()->GetXmax())); }
+                     vz, fVtxAxis.GetXmin(), fVtxAxis.GetXmax())); 
+    }
     ivz = 0;
     return kBadVertex;
   }
+  fHEventsAccepted->Fill(vz);
   
+  // --- Check the FMD ESD data --------------------------------------
+  if (!event->GetFMDData()) { 
+    if (fDebug > 3) {
+      AliWarning("No FMD data found in ESD"); }
+    return kNoFMD;
+  }
+
   
   return kOk;
 }
 
 //____________________________________________________________________
 Bool_t
-AliFMDEventInspector::ReadTriggers(const AliESDEvent* esd, UInt_t& triggers)
+AliFMDEventInspector::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;
+
+  // AliInfo(Form("Got centrality object %p with quality %d", 
+  //              centObj, centObj->GetQuality()));
+  // centObj->Print();
+  cent = centObj->GetCentralityPercentile("V0M");  
+  qual = centObj->GetQuality();
+
+  return true;
+}
+
+//____________________________________________________________________
+Bool_t
+AliFMDEventInspector::ReadTriggers(const AliESDEvent* esd, UInt_t& triggers,
+                                  UShort_t& nClusters)
 {
   // 
   // Read the trigger information from the ESD event 
@@ -416,52 +488,21 @@ AliFMDEventInspector::ReadTriggers(const AliESDEvent* esd, UInt_t& triggers)
     AliWarning("No input handler");
     return kFALSE;
   }
-  
-  AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
-  AliMCEvent* mcEvent = 0;
-  if(mcHandler)
-    mcEvent = mcHandler->MCEvent();
-  
-  if(mcEvent) {
-    //Assign MC only triggers : True NSD etc.
-    AliHeader* header            = mcEvent->Header();
-    AliGenEventHeader* genHeader = header->GenEventHeader();
     
-    AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(genHeader);
-    AliGenDPMjetEventHeader* dpmHeader = dynamic_cast<AliGenDPMjetEventHeader*>(header->GenEventHeader());
-    Bool_t sd = kFALSE;
-    if(pythiaGenHeader) {
-      Int_t pythiaType = pythiaGenHeader->ProcessType();
-      if(pythiaType==92 || pythiaType==93)
-       sd = kTRUE;
-    }
-    if(dpmHeader) {
-      Int_t processType = dpmHeader->ProcessType();
-      if(processType == 5 || processType == 6)  
-       sd = kTRUE;
-      
-    }
-    if(!sd) {
-      triggers |= AliAODForwardMult::kMCNSD;
-      fHTriggers->Fill(kMCNSD+0.5);
-    }
-    
-  }
-    
-  // Check if this is a collision candidate (INEL)
+  // Check if this is a collision candidate (MB)
   // Note, that we should use the value cached in the input 
   // handler rather than calling IsCollisionCandiate directly 
   // on the AliPhysicsSelection obejct.  If we called the latter
   // then the AliPhysicsSelection object would overcount by a 
   // factor of 2! :-(
-  Bool_t inel = ih->IsEventSelected();
-  if (inel) { 
+  Bool_t offline = ih->IsEventSelected();
+  nClusters = 0;
+  if (offline) {
+    triggers |= AliAODForwardMult::kOffline;
     triggers |= AliAODForwardMult::kInel;
-    fHTriggers->Fill(kInel+0.5);
-  }
+    fHTriggers->Fill(kOffline+0.5);
 
-  // If this is inel, see if we have a tracklet 
-  if (inel) { 
+    // If this is inel, see if we have a tracklet 
     const AliMultiplicity* spdmult = esd->GetMultiplicity();
     if (!spdmult) {
       AliWarning("No SPD multiplicity");
@@ -470,29 +511,38 @@ AliFMDEventInspector::ReadTriggers(const AliESDEvent* esd, UInt_t& triggers)
       // 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;
-         fHTriggers->Fill(kInelGt0+.5);
-         break;
+         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 (nClusters > 0) triggers |= AliAODForwardMult::kNClusterGt0;
   }
 
   // Analyse some trigger stuff 
   AliTriggerAnalysis ta;
-  if (ta.IsOfflineTriggerFired(esd, AliTriggerAnalysis::kNSD1)) {
+  if (ta.IsOfflineTriggerFired(esd, AliTriggerAnalysis::kNSD1)) 
     triggers |= AliAODForwardMult::kNSD;
-    fHTriggers->Fill(kNSD+.5);
-  }
-  //Check pileup
+    
+  // Check for multiple vertices (pile-up) with at least 3
+  // contributors and at least 0.8cm from the primary vertex
   Bool_t pileup =  esd->IsPileupFromSPD(3,0.8);
   if (pileup) {
     triggers |= AliAODForwardMult::kPileUp;
     fHTriggers->Fill(kPileUp+.5);
   }
+
     
   // Get trigger stuff 
   TString trigStr = esd->GetFiredTriggerClasses();
@@ -500,7 +550,7 @@ AliFMDEventInspector::ReadTriggers(const AliESDEvent* esd, UInt_t& triggers)
   fHWords->Fill(trigStr.Data(), 1);
 #if 0
   if (trigStr.Contains("MB1") || trigStr.Contains("MBBG3"))
-      triggers |= AliAOODForwardMult::kB;
+    triggers |= AliAOODForwardMult::kB;
   if (trigStr.Contains("COTA")) 
     triggers |= AliAODForwardMult::kA;
   if (trigStr.Contains("COTC")) 
@@ -511,27 +561,87 @@ AliFMDEventInspector::ReadTriggers(const AliESDEvent* esd, UInt_t& triggers)
     fHTriggers->Fill(kEmpty+.5);
   }
 
-  if (trigStr.Contains("CINT1A-ABCE-NOPF-ALL")) {
-    triggers |= AliAODForwardMult::kA;
-    fHTriggers->Fill(kA+.5);
-  }
-
-  if (trigStr.Contains("CINT1B-ABCE-NOPF-ALL")) {
+  // Check for B triggers
+  if (trigStr.Contains("CINT1B-ABCE-NOPF-ALL")   ||   // Early pp
+      trigStr.Contains("CINT1-B-NOPF-ALLNOTRD")  ||   // Late pp 
+      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
+      ) {
     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("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);
+  }
 
-
-  if (trigStr.Contains("CINT1C-ABCE-NOPF-ALL")) {
+  // 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);
   }
 
-  if (trigStr.Contains("CINT1-E-NOPF-ALL")) {
+  // Check for E triggers 
+  if (trigStr.Contains("CINT1-E-NOPF-ALL")       ||   // Early pp 
+      trigStr.Contains("CINT1-E-NOPF-ALLNOTRD")  ||   // 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);
   }
 
+  // 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);
+    
+    if (triggers & AliAODForwardMult::kNSD)
+      fHTriggers->Fill(kNSD+.5);
+  }
+  
   return kTRUE;
 }
 //____________________________________________________________________
@@ -549,6 +659,40 @@ AliFMDEventInspector::ReadVertex(const AliESDEvent* esd, Double_t& vz)
   //    @c true on success, @c false otherwise 
   //
   vz = 0;
+#if 1
+  // 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();
+  return true;
+#else 
   // Get the vertex 
   const AliESDVertex* vertex = esd->GetPrimaryVertexSPD();
   if (!vertex) { 
@@ -564,8 +708,7 @@ AliFMDEventInspector::ReadVertex(const AliESDEvent* esd, Double_t& vz)
                      vertex->GetNContributors())); }
     vz = 0;
     return kFALSE;
-  }
-
+  } 
   // Check that the uncertainty isn't too large 
   if (vertex->GetZRes() > fMaxVzErr) { 
     if (fDebug > 2) {
@@ -573,22 +716,13 @@ AliFMDEventInspector::ReadVertex(const AliESDEvent* esd, Double_t& vz)
                      vertex->GetZRes(), fMaxVzErr)); }
     return kFALSE;
   }
-
-  // HHD test
-  /*
-  if (vertex->IsFromVertexerZ()) { 
-    return kFALSE;
-  }
-  if (TMath::Sqrt(TMath::Power(vertex->GetX(),2) + TMath::Power(vertex->GetY(),2)) > 3 ) { 
-      return kFALSE;
-  }
-  */
   
   // Get the z coordiante 
   vz = vertex->GetZ();
   return kTRUE;
+#endif 
 }
-
+  
 //____________________________________________________________________
 Bool_t
 AliFMDEventInspector::ReadRunDetails(const AliESDEvent* esd)
@@ -610,7 +744,7 @@ AliFMDEventInspector::ReadRunDetails(const AliESDEvent* esd)
     AliForwardUtil::ParseCollisionSystem(esd->GetBeamType());
   fEnergy          = 
     AliForwardUtil::ParseCenterOfMassEnergy(fCollisionSystem,  
-                                             2 * esd->GetBeamEnergy());
+                                           2 * esd->GetBeamEnergy());
   fField           = 
     AliForwardUtil::ParseMagneticField(esd->GetMagneticField());
   
@@ -642,7 +776,7 @@ AliFMDEventInspector::Print(Option_t*) const
   field.ReplaceAll("m",  "-");
   field.ReplaceAll("kG", " kG");
   
-  std::cout << ind << "AliFMDEventInspector: " << GetName() << '\n'
+  std::cout << ind << ClassName() << ": " << GetName() << '\n'
            << ind << " Low flux cut:           " << fLowFluxCut << '\n'
            << ind << " Max(delta v_z):         " << fMaxVzErr << " cm\n"
            << ind << " System:                 "