]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG4/PartCorrBase/AliAnalysisTaskCounter.cxx
add calibration histograms for vzero centroids
[u/mrichter/AliRoot.git] / PWG4 / PartCorrBase / AliAnalysisTaskCounter.cxx
index 2f1e9a63d7cf5c2c0cace472a8c96c0f55be0774..801b459ac33fcca81f7dde0892ce23a86de819e3 100644 (file)
 /**************************************************************************\r
  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
  *                                                                        *\r
- * Author: The ALICE Off-line Project.                                    *\r
- * Contributors are mentioned in the code where appropriate.              *\r
- *                                                                        *\r
- * Permission to use, copy, modify and distribute this software and its   *\r
- * documentation strictly for non-commercial purposes is hereby granted   *\r
- * without fee, provided that the above copyright notice appears in all   *\r
- * copies and that both the copyright notice and this permission notice   *\r
- * appear in the supporting documentation. The authors make no claims     *\r
- * about the suitability of this software for any purpose. It is          *\r
- * provided "as is" without express or implied warranty.                  *\r
- **************************************************************************/\r
-/* $Id: $ */\r
-\r
-//_________________________________________________________________________\r
-// Count events with different selections\r
-//\r
-// It produces a histogram with the number of events with 9 bins:\r
-// 0: all events (that passed the physics selection if it was on)\r
-// 1: same but cross check that event pointer did exist\r
-// 2: passes vertex cut\r
-// 3: passes track number cut, tracks for eta < 0.8\r
-// 4: 3 && 2\r
-// 5: pass VAND\r
-// 6: 5 && 2\r
-// 7: 5 && 3\r
-// 8: 5 && 3 && 2\r
-// 9: not pileup from SPD\r
-// 10: Good vertex\r
-// 11: 10 && 5\r
-// 12: 10 && 3\r
-// 13: 10 && 2\r
-// 14: 10 && 2 && 3 && 5\r
-// 15: 10 && 9\r
-// 16: 9  && 5\r
-//\r
-// Author: Gustavo Conesa Balbastre (LPSC)\r
-//         \r
-//_________________________________________________________________________\r
-\r
-#include "TH2F.h"\r
-#include "AliAODHeader.h"\r
-#include "AliTriggerAnalysis.h"\r
-#include "AliESDEvent.h"\r
-#include "AliESDtrackCuts.h"\r
-#include "AliAnalysisManager.h"\r
-#include "AliInputEventHandler.h"\r
-\r
-#include "AliAnalysisTaskCounter.h"\r
-ClassImp(AliAnalysisTaskCounter)\r
-\r
-//________________________________________________________________________\r
-AliAnalysisTaskCounter::AliAnalysisTaskCounter(const char *name) \r
-: AliAnalysisTaskSE(name), \r
-  fZVertexCut(10.),\r
-  fTrackMultEtaCut(0.8),\r
-  fCaloFilterPatch(kFALSE),\r
-  fOutputContainer(0x0), \r
-  fESDtrackCuts(AliESDtrackCuts::GetStandardITSTPCTrackCuts2010()),\r
-  fTriggerAnalysis (new AliTriggerAnalysis),\r
-  fhNEvents(0),\r
-  fhXVertex(0),fhYVertex(0),fhZVertex(0),\r
-  fhXGoodVertex(0),fhYGoodVertex(0),fhZGoodVertex(0)\r
-{\r
-  //ctor\r
-  DefineOutput(1, TList::Class());\r
-}\r
-\r
-//________________________________________________________________________\r
-AliAnalysisTaskCounter::AliAnalysisTaskCounter() \r
-  : AliAnalysisTaskSE("DefaultAnalysis_AliAnalysisTaskCounter"),\r
-    fZVertexCut(10.),\r
-    fTrackMultEtaCut(0.8),\r
-    fCaloFilterPatch(kFALSE),\r
-    fOutputContainer(0x0), \r
-    fESDtrackCuts(AliESDtrackCuts::GetStandardITSTPCTrackCuts2010()),\r
-    fTriggerAnalysis (new AliTriggerAnalysis),\r
-    fhNEvents(0),\r
-    fhXVertex(0),fhYVertex(0),fhZVertex(0),\r
-    fhXGoodVertex(0),fhYGoodVertex(0),fhZGoodVertex(0)\r
-{\r
-  // ctor\r
-  DefineOutput(1, TList::Class());\r
-}\r
-\r
-//__________________________________________________\r
-AliAnalysisTaskCounter::~AliAnalysisTaskCounter()\r
-{\r
-  //Destructor\r
-  if(fOutputContainer){\r
-    fOutputContainer->Delete() ; \r
-    delete fOutputContainer ;\r
-  }\r
-  \r
-  if(fESDtrackCuts)    delete fESDtrackCuts;\r
-  if(fTriggerAnalysis) delete fTriggerAnalysis;\r
-  \r
-}\r
-\r
-\r
-//-------------------------------------------------------------------\r
-void AliAnalysisTaskCounter::UserCreateOutputObjects()\r
-{\r
-  // Init histograms\r
-  \r
-  fOutputContainer = new TList();\r
-  \r
-  fhZVertex     = new TH1F("hZVertex", " Z vertex distribution"   , 200 , -50 , 50  ) ;\r
-  fhZVertex->SetXTitle("v_{z} (cm)");\r
-  fOutputContainer->Add(fhZVertex);\r
-\r
-  fhZGoodVertex     = new TH1F("hZGoodVertex", " Good Z vertex distribution"   , 200 , -50 , 50  ) ;\r
-  fhZGoodVertex->SetXTitle("v_{z} (cm)");\r
-  fOutputContainer->Add(fhZGoodVertex);\r
-  \r
-  fhXVertex     = new TH1F("hXVertex", " X vertex distribution"   , 200 , -2 , 2  ) ;\r
-  fhXVertex->SetXTitle("v_{x} (cm)");\r
-  fOutputContainer->Add(fhXVertex);\r
-  \r
-  fhXGoodVertex     = new TH1F("hXGoodVertex", " Good X vertex distribution"   , 200 , -2 , 2  ) ;\r
-  fhXGoodVertex->SetXTitle("v_{x} (cm)");\r
-  fOutputContainer->Add(fhXGoodVertex);\r
-  \r
-  fhYVertex     = new TH1F("hYVertex", " Y vertex distribution"   , 200 , -2 , 2  ) ;\r
-  fhYVertex->SetXTitle("v_{y} (cm)");\r
-  fOutputContainer->Add(fhYVertex);\r
-  \r
-  fhYGoodVertex     = new TH1F("hYGoodVertex", " Good Y vertex distribution"   , 200 , -2 , 2  ) ;\r
-  fhYGoodVertex->SetXTitle("v_{y} (cm)");\r
-  fOutputContainer->Add(fhYGoodVertex);\r
-  \r
-  \r
-  fhNEvents = new TH1I("hNEvents", "Number of analyzed events", 17, 0, 17) ;\r
-  fhNEvents->SetXTitle("Selection");\r
-  fhNEvents->SetYTitle("# events");\r
-  fhNEvents->GetXaxis()->SetBinLabel(1 ,"1  = PS");\r
-  fhNEvents->GetXaxis()->SetBinLabel(2 ,"2  = 1  & ESD");\r
-  fhNEvents->GetXaxis()->SetBinLabel(3 ,"3  = 2  & |Z|<10");\r
-  fhNEvents->GetXaxis()->SetBinLabel(4 ,"4  = 2  & |eta|<0.8");\r
-  fhNEvents->GetXaxis()->SetBinLabel(5 ,"5  = 3  & 4");\r
-  fhNEvents->GetXaxis()->SetBinLabel(6 ,"6  = 2  & V0AND");\r
-  fhNEvents->GetXaxis()->SetBinLabel(7 ,"7  = 3  & 6");\r
-  fhNEvents->GetXaxis()->SetBinLabel(8 ,"8  = 4  & 6");\r
-  fhNEvents->GetXaxis()->SetBinLabel(9 ,"9  = 5  & 6");\r
-  fhNEvents->GetXaxis()->SetBinLabel(10,"10 = 2  & not pileup");\r
-  fhNEvents->GetXaxis()->SetBinLabel(11,"11 = 2  & good vertex");\r
-  fhNEvents->GetXaxis()->SetBinLabel(12,"12 = 3  & 11");\r
-  fhNEvents->GetXaxis()->SetBinLabel(13,"13 = 4  & 11");\r
-  fhNEvents->GetXaxis()->SetBinLabel(14,"14 = 6  & 11");\r
-  fhNEvents->GetXaxis()->SetBinLabel(15,"15 = 9  & 11");\r
-  fhNEvents->GetXaxis()->SetBinLabel(16,"16 = 10 & 11");\r
-  fhNEvents->GetXaxis()->SetBinLabel(17,"17 = 6  & 10");\r
-\r
-  fOutputContainer->Add(fhNEvents);\r
-\r
-  fOutputContainer->SetOwner(kTRUE);\r
-  \r
-  PostData(1,fOutputContainer);\r
-  \r
-}\r
-\r
-//________________________________________________________________________\r
-void AliAnalysisTaskCounter::UserExec(Option_t *) \r
-{\r
-  // Main loop\r
-  // Called for each event\r
-  \r
-  //printf("___ Event __ %d __\n",(Int_t)Entry());\r
-  \r
-  fhNEvents->Fill(0.5);  \r
-  \r
-  AliVEvent * event = InputEvent();\r
-  if (!event) {\r
-    printf("AliAnalysisTaskCounter::UserExec() - ERROR: event not available \n");\r
-    return;\r
-  }\r
-  AliESDEvent * esdevent = dynamic_cast<AliESDEvent*> (event);\r
-\r
-  fhNEvents->Fill(1.5);  \r
-    \r
-  //Initialize bools\r
-  Bool_t bSelectVZ    = kFALSE;\r
-  Bool_t bV0AND       = kFALSE; \r
-  Bool_t bPileup      = kFALSE;\r
-  Bool_t bGoodV       = kFALSE;\r
-  Bool_t bSelectTrack = kFALSE;   \r
-  Int_t  trackMult    = 0;\r
-  \r
-  //---------------------------------\r
-  //Get the primary vertex, cut on Z\r
-  //---------------------------------\r
-  Double_t v[3];\r
-  event->GetPrimaryVertex()->GetXYZ(v) ;\r
-  fhXVertex->Fill(v[0]);\r
-  fhYVertex->Fill(v[1]);\r
-  fhZVertex->Fill(v[2]);\r
-  \r
-  if(TMath::Abs(v[2]) < fZVertexCut) {\r
-    bSelectVZ=kTRUE;\r
-    fhNEvents->Fill(2.5);  \r
-  }\r
-  //else printf("Vertex out %f \n",v[2]);\r
-  \r
-\r
-  //--------------------------------------------------\r
-  //Tweak for calorimeter only productions\r
-  //--------------------------------------------------\r
-  if(fCaloFilterPatch && !esdevent){ \r
-    if(event->GetNumberOfCaloClusters() > 0) {\r
-      AliVCluster * calo = event->GetCaloCluster(0);\r
-      if(calo->GetNLabels() == 4){\r
-        Int_t * selection = calo->GetLabels();\r
-        bPileup   = selection[0];\r
-        bGoodV    = selection[1]; \r
-        bV0AND    = selection[2]; \r
-        trackMult = selection[3];\r
-        //if(selection[0] || selection[1] || selection[2])\r
-        //printf(" pu %d, gv %d, v0 %d, track mult %d\n ", selection[0], selection[1], selection[2], selection[3]);\r
-        if(trackMult > 0 )  \r
-          bSelectTrack = kFALSE;\r
-      } else {\r
-        //First filtered AODs, track multiplicity stored there.  \r
-        trackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();\r
-      }\r
-    }else{//at least one cluster\r
-        //printf("AliAnalysisTaskCounter::UserExec() - No clusters in event\n");\r
-        //Remove events with  vertex (0,0,0), bad vertex reconstruction\r
-        if(TMath::Abs(v[0]) < 1.e-6 && TMath::Abs(v[1]) < 1.e-6 && TMath::Abs(v[2]) < 1.e-6) bGoodV = kFALSE;\r
-      \r
-        //First filtered AODs, track multiplicity stored there.  \r
-        trackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();\r
-    }\r
-  }\r
-  else {\r
-    //--------------------------------------------------\r
-    //Count tracks, cut on number of tracks in eta < 0.8\r
-    //--------------------------------------------------\r
-    Int_t nTracks   = event->GetNumberOfTracks() ;\r
-    for (Int_t itrack =  0; itrack <  nTracks; itrack++) {////////////// track loop\r
-      AliVTrack * track = (AliVTrack*)event->GetTrack(itrack) ; // retrieve track from esd\r
-      \r
-      //Only for ESDs\r
-      if(esdevent && !fESDtrackCuts->AcceptTrack((AliESDtrack*)track)) continue;\r
-      \r
-      //Do not count tracks out of acceptance cut\r
-      if(TMath::Abs(track->Eta())< fTrackMultEtaCut) trackMult++;\r
-    }\r
-  }\r
-  \r
-  //printf("AliAnalysisTaskCounter::UserExec() - Track Mult %d \n",trackMult);\r
-  \r
-  //--------------------------------------------------\r
-  // At least one track\r
-  //--------------------------------------------------\r
-  if (trackMult > 0) {\r
-    bSelectTrack = kTRUE; \r
-                  fhNEvents->Fill(3.5);\r
-    if(bSelectVZ) fhNEvents->Fill(4.5);\r
-  }\r
-  \r
-  //---------------------------------\r
-  // V0AND\r
-  //---------------------------------\r
-  if(esdevent && !fCaloFilterPatch) bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esdevent, AliTriggerAnalysis::kV0AND);\r
-  //else if(aodevent  && !fCaloFilterPatch) bV0AND = //FIXME FOR AODs\r
-  \r
-  if(bV0AND)\r
-  {\r
-                                    fhNEvents->Fill(5.5);\r
-    if (bSelectVZ)                  fhNEvents->Fill(6.5);\r
-    if (bSelectTrack)               fhNEvents->Fill(7.5);\r
-    if (bSelectVZ &&  bSelectTrack) fhNEvents->Fill(8.5);\r
-  }\r
-  \r
-  //---------------------------------\r
-  // Pileup\r
-  //---------------------------------\r
-  if(!fCaloFilterPatch)\r
-    bPileup = event->IsPileupFromSPD(3, 0.8, 3., 2., 5.); //Default values, if not it does not compile\r
-  //bPileup = event->IsPileupFromSPD(); \r
-  if (!bPileup){\r
-                fhNEvents->Fill(9.5);\r
-    if(bV0AND)  fhNEvents->Fill(16.5);\r
-  }\r
-  \r
-  //---------------------------------\r
-  // Good vertex\r
-  //---------------------------------\r
-  if(esdevent && !fCaloFilterPatch) bGoodV = CheckForPrimaryVertex();\r
-  if(bGoodV) \r
-  {\r
-    fhXGoodVertex->Fill(v[0]);\r
-    fhYGoodVertex->Fill(v[1]);\r
-    fhZGoodVertex->Fill(v[2]);\r
-    \r
-                     fhNEvents->Fill(10.5);\r
-    if(bSelectVZ)    fhNEvents->Fill(11.5);\r
-    if(bSelectTrack) fhNEvents->Fill(12.5);\r
-    if(bV0AND)       fhNEvents->Fill(13.5);\r
-    if(bSelectVZ && bSelectTrack && bV0AND)    \r
-                     fhNEvents->Fill(14.5); \r
-    if(!bPileup)     fhNEvents->Fill(15.5); \r
-  }\r
-\r
-  //printf("AliAnalysisTaskCounter::UserExec() : z vertex %d, good vertex %d, v0and %d, pile up %d, track mult %d\n ", bSelectVZ, bGoodV, bV0AND, bPileup, trackMult);\r
-  \r
-  PostData(1,fOutputContainer);\r
-\r
-}\r
-\r
-//____________________________________________________________________________\r
-Bool_t AliAnalysisTaskCounter::CheckForPrimaryVertex(){\r
-  //Check if the vertex was well reconstructed, copy from V0Reader of conversion group\r
-  //It only works for ESDs\r
-  \r
-  AliESDEvent * event = dynamic_cast<AliESDEvent*> (InputEvent());\r
-  if(event->GetPrimaryVertexTracks()->GetNContributors() > 0) {\r
-    return 1;\r
-  }\r
-  \r
-  if(event->GetPrimaryVertexTracks()->GetNContributors() < 1) {\r
-    // SPD vertex\r
-    if(event->GetPrimaryVertexSPD()->GetNContributors() > 0) {\r
-      //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;\r
-      return 1;\r
-      \r
-    }\r
-    if(event->GetPrimaryVertexSPD()->GetNContributors() < 1) {\r
-      //      cout<<"bad vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;\r
-      return 0;\r
-    }\r
-  }\r
-  return 0;\r
-  //return fInputEvent->GetPrimaryVertex()->GetNContributors()>0;\r
-}\r
-\r
-\r
-\r
-//_____________________________________________________\r
-void AliAnalysisTaskCounter::FinishTaskOutput()\r
-{\r
-  // Put in the output some event summary histograms\r
-  \r
-  AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();\r
-  AliInputEventHandler *inputH = dynamic_cast<AliInputEventHandler*>(am->GetInputEventHandler());\r
-  if (!inputH) return; \r
-  TH2F *histStat = dynamic_cast<TH2F*>(inputH->GetStatistics()); \r
-  TH2F *histBin0 = dynamic_cast<TH2F*>(inputH->GetStatistics("BIN0"));\r
-  \r
-  if(histStat)\r
-    fOutputContainer->Add(histStat);\r
-  else\r
-    printf("AliAnalysisTaskCounter::FinishTaskOutput() - Stat histogram not available check, \n if ESDs, that AliPhysicsSelection was on, \n if AODs, if EventStat_temp.root exists \n");\r
-\r
-  if(histBin0)\r
-    fOutputContainer->Add(histBin0); \r
-  \r
-}\r
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id: $ */
+
+//_________________________________________________________________________
+// Count events with different selections
+//
+// It produces a histogram with the number of events with 9 bins:
+// 0: all events (that passed the physics selection if it was on)
+// 1: same but cross check that event pointer did exist
+// 2: passes vertex cut
+// 3: passes track number cut, tracks for eta < 0.8
+// 4: 3 && 2
+// 5: pass VAND
+// 6: 5 && 2
+// 7: 5 && 3
+// 8: 5 && 3 && 2
+// 9: not pileup from SPD
+// 10: Good vertex
+// 11: 10 && 5
+// 12: 10 && 3
+// 13: 10 && 2
+// 14: 10 && 2 && 3 && 5
+// 15: 10 && 9
+// 16: 9  && 5
+//
+// Author: Gustavo Conesa Balbastre (LPSC)
+//         
+//_________________________________________________________________________
+
+#include "TH2F.h"
+#include "AliAODHeader.h"
+#include "AliTriggerAnalysis.h"
+#include "AliESDEvent.h"
+#include "AliESDtrackCuts.h"
+#include "AliAnalysisManager.h"
+#include "AliInputEventHandler.h"
+
+#include "AliAnalysisTaskCounter.h"
+ClassImp(AliAnalysisTaskCounter)
+
+//________________________________________________________________________
+AliAnalysisTaskCounter::AliAnalysisTaskCounter(const char *name) 
+: AliAnalysisTaskSE(name), 
+  fZVertexCut(10.),
+  fTrackMultEtaCut(0.8),
+  fCaloFilterPatch(kFALSE),
+  fOutputContainer(0x0), 
+  fESDtrackCuts(AliESDtrackCuts::GetStandardITSTPCTrackCuts2010()),
+  fTriggerAnalysis (new AliTriggerAnalysis),
+  fhNEvents(0),
+  fhXVertex(0),fhYVertex(0),fhZVertex(0),
+  fhXGoodVertex(0),fhYGoodVertex(0),fhZGoodVertex(0)
+{
+  //ctor
+  DefineOutput(1, TList::Class());
+}
+
+//________________________________________________________________________
+AliAnalysisTaskCounter::AliAnalysisTaskCounter() 
+  : AliAnalysisTaskSE("DefaultAnalysis_AliAnalysisTaskCounter"),
+    fZVertexCut(10.),
+    fTrackMultEtaCut(0.8),
+    fCaloFilterPatch(kFALSE),
+    fOutputContainer(0x0), 
+    fESDtrackCuts(AliESDtrackCuts::GetStandardITSTPCTrackCuts2010()),
+    fTriggerAnalysis (new AliTriggerAnalysis),
+    fhNEvents(0),
+    fhXVertex(0),fhYVertex(0),fhZVertex(0),
+    fhXGoodVertex(0),fhYGoodVertex(0),fhZGoodVertex(0)
+{
+  // ctor
+  DefineOutput(1, TList::Class());
+}
+
+//__________________________________________________
+AliAnalysisTaskCounter::~AliAnalysisTaskCounter()
+{
+  //Destructor
+  if(fOutputContainer){
+    fOutputContainer->Delete() ; 
+    delete fOutputContainer ;
+  }
+  
+  if(fESDtrackCuts)    delete fESDtrackCuts;
+  if(fTriggerAnalysis) delete fTriggerAnalysis;
+  
+}
+
+
+//-------------------------------------------------------------------
+void AliAnalysisTaskCounter::UserCreateOutputObjects()
+{
+  // Init histograms
+  
+  fOutputContainer = new TList();
+  
+  fhZVertex     = new TH1F("hZVertex", " Z vertex distribution"   , 200 , -50 , 50  ) ;
+  fhZVertex->SetXTitle("v_{z} (cm)");
+  fOutputContainer->Add(fhZVertex);
+
+  fhZGoodVertex     = new TH1F("hZGoodVertex", " Good Z vertex distribution"   , 200 , -50 , 50  ) ;
+  fhZGoodVertex->SetXTitle("v_{z} (cm)");
+  fOutputContainer->Add(fhZGoodVertex);
+  
+  fhXVertex     = new TH1F("hXVertex", " X vertex distribution"   , 200 , -2 , 2  ) ;
+  fhXVertex->SetXTitle("v_{x} (cm)");
+  fOutputContainer->Add(fhXVertex);
+  
+  fhXGoodVertex     = new TH1F("hXGoodVertex", " Good X vertex distribution"   , 200 , -2 , 2  ) ;
+  fhXGoodVertex->SetXTitle("v_{x} (cm)");
+  fOutputContainer->Add(fhXGoodVertex);
+  
+  fhYVertex     = new TH1F("hYVertex", " Y vertex distribution"   , 200 , -2 , 2  ) ;
+  fhYVertex->SetXTitle("v_{y} (cm)");
+  fOutputContainer->Add(fhYVertex);
+  
+  fhYGoodVertex     = new TH1F("hYGoodVertex", " Good Y vertex distribution"   , 200 , -2 , 2  ) ;
+  fhYGoodVertex->SetXTitle("v_{y} (cm)");
+  fOutputContainer->Add(fhYGoodVertex);
+  
+  
+  fhNEvents = new TH1I("hNEvents", "Number of analyzed events", 17, 0, 17) ;
+  fhNEvents->SetXTitle("Selection");
+  fhNEvents->SetYTitle("# events");
+  fhNEvents->GetXaxis()->SetBinLabel(1 ,"1  = PS");
+  fhNEvents->GetXaxis()->SetBinLabel(2 ,"2  = 1  & ESD");
+  fhNEvents->GetXaxis()->SetBinLabel(3 ,"3  = 2  & |Z|<10");
+  fhNEvents->GetXaxis()->SetBinLabel(4 ,"4  = 2  & |eta|<0.8");
+  fhNEvents->GetXaxis()->SetBinLabel(5 ,"5  = 3  & 4");
+  fhNEvents->GetXaxis()->SetBinLabel(6 ,"6  = 2  & V0AND");
+  fhNEvents->GetXaxis()->SetBinLabel(7 ,"7  = 3  & 6");
+  fhNEvents->GetXaxis()->SetBinLabel(8 ,"8  = 4  & 6");
+  fhNEvents->GetXaxis()->SetBinLabel(9 ,"9  = 5  & 6");
+  fhNEvents->GetXaxis()->SetBinLabel(10,"10 = 2  & not pileup");
+  fhNEvents->GetXaxis()->SetBinLabel(11,"11 = 2  & good vertex");
+  fhNEvents->GetXaxis()->SetBinLabel(12,"12 = 3  & 11");
+  fhNEvents->GetXaxis()->SetBinLabel(13,"13 = 4  & 11");
+  fhNEvents->GetXaxis()->SetBinLabel(14,"14 = 6  & 11");
+  fhNEvents->GetXaxis()->SetBinLabel(15,"15 = 9  & 11");
+  fhNEvents->GetXaxis()->SetBinLabel(16,"16 = 10 & 11");
+  fhNEvents->GetXaxis()->SetBinLabel(17,"17 = 6  & 10");
+
+  fOutputContainer->Add(fhNEvents);
+
+  fOutputContainer->SetOwner(kTRUE);
+  
+  PostData(1,fOutputContainer);
+  
+}
+
+//________________________________________________________________________
+void AliAnalysisTaskCounter::UserExec(Option_t *) 
+{
+  // Main loop
+  // Called for each event
+  
+  //printf("___ Event __ %d __\n",(Int_t)Entry());
+  
+  fhNEvents->Fill(0.5);  
+  
+  AliVEvent * event = InputEvent();
+  if (!event) {
+    printf("AliAnalysisTaskCounter::UserExec() - ERROR: event not available \n");
+    return;
+  }
+  AliESDEvent * esdevent = dynamic_cast<AliESDEvent*> (event);
+
+  fhNEvents->Fill(1.5);  
+    
+  //Initialize bools
+  Bool_t bSelectVZ    = kFALSE;
+  Bool_t bV0AND       = kFALSE; 
+  Bool_t bPileup      = kFALSE;
+  Bool_t bGoodV       = kFALSE;
+  Bool_t bSelectTrack = kFALSE;   
+  Int_t  trackMult    = 0;
+  
+  //---------------------------------
+  //Get the primary vertex, cut on Z
+  //---------------------------------
+  Double_t v[3];
+  event->GetPrimaryVertex()->GetXYZ(v) ;
+  fhXVertex->Fill(v[0]);
+  fhYVertex->Fill(v[1]);
+  fhZVertex->Fill(v[2]);
+  
+  if(TMath::Abs(v[2]) < fZVertexCut) {
+    bSelectVZ=kTRUE;
+    fhNEvents->Fill(2.5);  
+  }
+  //else printf("Vertex out %f \n",v[2]);
+  
+
+  //--------------------------------------------------
+  //Tweak for calorimeter only productions
+  //--------------------------------------------------
+  if(fCaloFilterPatch && !esdevent){ 
+    if(event->GetNumberOfCaloClusters() > 0) {
+      AliVCluster * calo = event->GetCaloCluster(0);
+      if(calo->GetNLabels() == 4){
+        Int_t * selection = calo->GetLabels();
+        bPileup   = selection[0];
+        bGoodV    = selection[1]; 
+        bV0AND    = selection[2]; 
+        trackMult = selection[3];
+        //if(selection[0] || selection[1] || selection[2])
+        //printf(" pu %d, gv %d, v0 %d, track mult %d\n ", selection[0], selection[1], selection[2], selection[3]);
+        if(trackMult > 0 )  
+          bSelectTrack = kFALSE;
+      } else {
+        //First filtered AODs, track multiplicity stored there.  
+        trackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
+      }
+    }else{//at least one cluster
+        //printf("AliAnalysisTaskCounter::UserExec() - No clusters in event\n");
+        //Remove events with  vertex (0,0,0), bad vertex reconstruction
+        if(TMath::Abs(v[0]) < 1.e-6 && TMath::Abs(v[1]) < 1.e-6 && TMath::Abs(v[2]) < 1.e-6) bGoodV = kFALSE;
+      
+        //First filtered AODs, track multiplicity stored there.  
+        trackMult = (Int_t) ((AliAODHeader*)fInputEvent->GetHeader())->GetCentrality();
+    }
+  }
+  else {
+    //--------------------------------------------------
+    //Count tracks, cut on number of tracks in eta < 0.8
+    //--------------------------------------------------
+    Int_t nTracks   = event->GetNumberOfTracks() ;
+    for (Int_t itrack =  0; itrack <  nTracks; itrack++) {////////////// track loop
+      AliVTrack * track = (AliVTrack*)event->GetTrack(itrack) ; // retrieve track from esd
+      
+      //Only for ESDs
+      if(esdevent && !fESDtrackCuts->AcceptTrack((AliESDtrack*)track)) continue;
+      
+      //Do not count tracks out of acceptance cut
+      if(TMath::Abs(track->Eta())< fTrackMultEtaCut) trackMult++;
+    }
+  }
+  
+  //printf("AliAnalysisTaskCounter::UserExec() - Track Mult %d \n",trackMult);
+  
+  //--------------------------------------------------
+  // At least one track
+  //--------------------------------------------------
+  if (trackMult > 0) {
+    bSelectTrack = kTRUE; 
+                  fhNEvents->Fill(3.5);
+    if(bSelectVZ) fhNEvents->Fill(4.5);
+  }
+  
+  //---------------------------------
+  // V0AND
+  //---------------------------------
+  if(esdevent && !fCaloFilterPatch) bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(esdevent, AliTriggerAnalysis::kV0AND);
+  //else if(aodevent  && !fCaloFilterPatch) bV0AND = //FIXME FOR AODs
+  
+  if(bV0AND)
+  {
+                                    fhNEvents->Fill(5.5);
+    if (bSelectVZ)                  fhNEvents->Fill(6.5);
+    if (bSelectTrack)               fhNEvents->Fill(7.5);
+    if (bSelectVZ &&  bSelectTrack) fhNEvents->Fill(8.5);
+  }
+  
+  //---------------------------------
+  // Pileup
+  //---------------------------------
+  if(!fCaloFilterPatch)
+    bPileup = event->IsPileupFromSPD(3, 0.8, 3., 2., 5.); //Default values, if not it does not compile
+  //bPileup = event->IsPileupFromSPD(); 
+  if (!bPileup){
+                fhNEvents->Fill(9.5);
+    if(bV0AND)  fhNEvents->Fill(16.5);
+  }
+  
+  //---------------------------------
+  // Good vertex
+  //---------------------------------
+  if(esdevent && !fCaloFilterPatch) bGoodV = CheckForPrimaryVertex();
+  if(bGoodV) 
+  {
+    fhXGoodVertex->Fill(v[0]);
+    fhYGoodVertex->Fill(v[1]);
+    fhZGoodVertex->Fill(v[2]);
+    
+                     fhNEvents->Fill(10.5);
+    if(bSelectVZ)    fhNEvents->Fill(11.5);
+    if(bSelectTrack) fhNEvents->Fill(12.5);
+    if(bV0AND)       fhNEvents->Fill(13.5);
+    if(bSelectVZ && bSelectTrack && bV0AND)    
+                     fhNEvents->Fill(14.5); 
+    if(!bPileup)     fhNEvents->Fill(15.5); 
+  }
+
+  //printf("AliAnalysisTaskCounter::UserExec() : z vertex %d, good vertex %d, v0and %d, pile up %d, track mult %d\n ", bSelectVZ, bGoodV, bV0AND, bPileup, trackMult);
+  
+  PostData(1,fOutputContainer);
+
+}
+
+//____________________________________________________________________________
+Bool_t AliAnalysisTaskCounter::CheckForPrimaryVertex(){
+  //Check if the vertex was well reconstructed, copy from V0Reader of conversion group
+  //It only works for ESDs
+  
+  AliESDEvent * event = dynamic_cast<AliESDEvent*> (InputEvent());
+  if(!event) return 0;
+  
+  if(event->GetPrimaryVertexTracks()->GetNContributors() > 0) {
+    return 1;
+  }
+  
+  if(event->GetPrimaryVertexTracks()->GetNContributors() < 1) {
+    // SPD vertex
+    if(event->GetPrimaryVertexSPD()->GetNContributors() > 0) {
+      //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
+      return 1;
+      
+    }
+    if(event->GetPrimaryVertexSPD()->GetNContributors() < 1) {
+      //      cout<<"bad vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
+      return 0;
+    }
+  }
+  return 0;
+  //return fInputEvent->GetPrimaryVertex()->GetNContributors()>0;
+}
+
+
+
+//_____________________________________________________
+void AliAnalysisTaskCounter::FinishTaskOutput()
+{
+  // Put in the output some event summary histograms
+  
+  AliAnalysisManager *am = AliAnalysisManager::GetAnalysisManager();
+  AliInputEventHandler *inputH = dynamic_cast<AliInputEventHandler*>(am->GetInputEventHandler());
+  if (!inputH) return; 
+  TH2F *histStat = dynamic_cast<TH2F*>(inputH->GetStatistics()); 
+  TH2F *histBin0 = dynamic_cast<TH2F*>(inputH->GetStatistics("BIN0"));
+  
+  if(histStat)
+    fOutputContainer->Add(histStat);
+  else
+    printf("AliAnalysisTaskCounter::FinishTaskOutput() - Stat histogram not available check, \n if ESDs, that AliPhysicsSelection was on, \n if AODs, if EventStat_temp.root exists \n");
+
+  if(histBin0)
+    fOutputContainer->Add(histBin0); 
+  
+}