]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added classes to analyse TPC data from reconstructed clusters (not on tracks) and...
authorekman <ekman@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 1 Dec 2006 13:34:29 +0000 (13:34 +0000)
committerekman <ekman@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 1 Dec 2006 13:34:29 +0000 (13:34 +0000)
PWG0/TPC/AliROCClusterAnalysisSelector.cxx [new file with mode: 0644]
PWG0/TPC/AliROCClusterAnalysisSelector.h [new file with mode: 0644]
PWG0/TPC/AliTPCClusterHistograms.cxx
PWG0/TPC/AliTPCClusterHistograms.h
PWG0/TPC/runROCClusterAnalysis.C [new file with mode: 0644]

diff --git a/PWG0/TPC/AliROCClusterAnalysisSelector.cxx b/PWG0/TPC/AliROCClusterAnalysisSelector.cxx
new file mode 100644 (file)
index 0000000..4a8f881
--- /dev/null
@@ -0,0 +1,366 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * 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$ */
+
+// 
+//  This class analyses TPC cosmics data from clusters
+//
+//  Authors: Jan.Fiete.Grosse-Oetringhaus@cern.ch, Claus.Jorgensen@cern.ch
+//
+
+#include "AliROCClusterAnalysisSelector.h"
+
+#include <AliLog.h>
+#include <AliTPCclusterMI.h>
+#include <AliRunLoader.h>
+
+#include <AliTPCClustersRow.h>
+#include <AliESD.h>
+
+
+#include <TFile.h>
+#include <TMath.h>
+#include <TTree.h>
+#include <TCanvas.h>
+#include <TSystem.h>
+#include <TObjArray.h>
+#include <TTimeStamp.h>
+#include <TRandom.h>
+
+#include "TPC/AliTPCClusterHistograms.h"
+
+extern TSystem* gSystem;
+
+ClassImp(AliROCClusterAnalysisSelector)
+
+AliROCClusterAnalysisSelector::AliROCClusterAnalysisSelector() :
+  AliSelectorRL(),
+  fObjectsToSave(0)
+{
+  //
+  // Constructor. Initialization of pointers
+  //
+
+  fNMaxObjectsToSave = 50;
+  fObjectsToSave     = new TObjArray();
+  
+  for (Int_t i=0; i<kTPCHists; i++)
+    fClusterHistograms[i] = 0;
+}
+
+AliROCClusterAnalysisSelector::~AliROCClusterAnalysisSelector()
+{
+  //
+  // Destructor
+  //
+}
+
+void AliROCClusterAnalysisSelector::SlaveBegin(TTree* tree)
+{
+  //
+  
+  AliSelectorRL::SlaveBegin(tree);
+} 
+
+void AliROCClusterAnalysisSelector::Init(TTree *tree)
+{
+  // The Init() function is called when the selector needs to initialize
+  // a new tree or chain. Typically here the branch addresses of the tree
+  // will be set. It is normaly not necessary to make changes to the
+  // generated code, but the routine can be extended by the user if needed.
+  // Init() will be called many times when running with PROOF.
+
+  AliSelectorRL::Init(tree);
+  
+  // Set branch address
+  if (tree) {  
+    tree->SetBranchStatus("*", 0);
+    tree->SetBranchStatus("fTimeStamp", 1);
+  }
+}
+
+Bool_t AliROCClusterAnalysisSelector::Process(Long64_t entry)
+{
+  //
+  // Implement your analysis here. Do not forget to call the parent class Process by
+  // if (AliSelectorRL::Process(entry) == kFALSE)
+  //   return kFALSE;
+  //
+
+  if (AliSelectorRL::Process(entry) == kFALSE)
+    return kFALSE;
+
+
+  // reset counters
+  for (Int_t i=0; i<kTPCHists; i++)
+    if (fClusterHistograms[i])
+      fClusterHistograms[i]->StartEvent();
+  
+  //  runLoader->Dump();
+
+  Int_t flag = ProcessEvent(entry, kFALSE);
+  if (flag != 0)
+    ProcessEvent(entry, kTRUE, "");
+
+
+  Int_t time = 0;  
+  if (fESD) 
+    if (fESD->GetTimeStamp()>1160000000) {
+      time = fESD->GetTimeStamp();      
+    }  
+  
+  // finish event
+  for (Int_t i=0; i<kTPCHists; i++)
+    if (fClusterHistograms[i])
+      fClusterHistograms[i]->FinishEvent(time);
+
+  
+  // TODO This should not be needed, the TTree::GetEntry() should take care of this, maybe because it has a reference member, to be analyzed
+  // if the ESDfriend is not deleted we get a major memory leak
+  // here the esdfriend seems to be also deleted, very weird behaviour....
+
+  delete fESD;
+  fESD = 0;    
+
+  return kTRUE;
+}
+
+Int_t AliROCClusterAnalysisSelector::ProcessEvent(Long64_t entry, Bool_t detailedHistogram, const Char_t* label)
+{
+  //
+  // Looping over clusters in event and filling histograms 
+  //
+  // - if detailedHistogram = kTRUE special histograms are saved (in fObjectsToSave)
+  //   
+
+  // save maximum N objects
+  if (detailedHistogram) 
+    if (fObjectsToSave->GetEntries() > fNMaxObjectsToSave) 
+      return 0;
+      
+  // TODO: find a clever way to handle the time      
+  Int_t time = 0;  
+  if (fESD) 
+    if (fESD->GetTimeStamp()>1160000000) {
+      time = fESD->GetTimeStamp();      
+    }  
+
+  // for saving single events
+  AliTPCClusterHistograms* clusterHistograms[kTPCSectors];
+  Bool_t keepEvent[kTPCSectors];
+  for (Int_t i=0; i<kTPCSectors; i++) { 
+    clusterHistograms[i] = 0;  
+    keepEvent[i] = kFALSE;
+
+    if (fClusterHistograms[i]) {
+      TString why;
+      keepEvent[i] = fClusterHistograms[i]->KeepThisEvent(why);
+    }
+  }
+  
+  Bool_t intToReturn = 0;
+
+  // --------------
+
+  AliRunLoader* runLoader = GetRunLoader();
+  runLoader->LoadRecPoints("TPC");
+  
+  if (!runLoader) {
+    AliDebug(AliLog::kError, " Run loader not found");
+    return kFALSE;
+  }
+  
+  TTree* tree = runLoader->GetTreeR("TPC", kFALSE);
+  
+  // load clusters to the memory
+  AliTPCClustersRow* clrow = new AliTPCClustersRow;
+  clrow->SetClass("AliTPCclusterMI");
+  clrow->SetArray(0);
+  clrow->GetArray()->ExpandCreateFast(10000);
+  //
+
+  if (!tree) {
+    AliDebug(AliLog::kError, " TPC cluster tree not found");
+    return kFALSE;
+  }
+
+  TBranch* br = tree->GetBranch("Segment");
+  br->SetAddress(&clrow);
+  //
+
+  Int_t j = Int_t(tree->GetEntries());
+  for (Int_t i=0; i<j; i++) {
+    br->GetEntry(i);
+    //  
+    for (Int_t icl=0; icl<clrow->GetArray()->GetEntriesFast(); icl++){
+      
+      AliTPCclusterMI* cluster = (AliTPCclusterMI*)clrow->GetArray()->At(icl);
+
+      if (!cluster) 
+       continue;
+      
+     Int_t detector = cluster->GetDetector();
+     
+     if (detector < 0 || detector >= kTPCSectors) 
+     {
+       AliDebug(AliLog::kDebug, Form("We found a cluster from invalid sector %d", detector));
+       continue;
+     }
+
+     if (!detailedHistogram) {
+       
+       if (!fClusterHistograms[detector])
+        fClusterHistograms[detector] = new AliTPCClusterHistograms(detector,"",time,time+5*60*60);
+       
+       if (!fClusterHistograms[detector+kTPCSectors])
+         fClusterHistograms[detector+kTPCSectors] = new AliTPCClusterHistograms(detector,"",time,time+5*60*60, kTRUE);
+       
+       fClusterHistograms[detector]->FillCluster(cluster, time);
+       fClusterHistograms[detector+kTPCSectors]->FillCluster(cluster, time);
+                       
+     } // end of if !detailedHistograms
+     else {
+       // if we need the detailed histograms for this event
+       
+       if (keepEvent[detector]) {       
+
+        TString why(fClusterHistograms[detector]->WhyKeepEvent());
+       
+        why.Append(Form("_entry_%d",entry));
+        why.Append(label);
+
+        // if clusterHistograms for this event is not there, construct it
+        if (!clusterHistograms[detector]) {
+          clusterHistograms[detector] = new AliTPCClusterHistograms(detector, why.Data());
+          
+          // adding file and time as comment
+          TString comment = TString(Form("%s",fTree->GetCurrentFile()->GetName()));
+          comment.Append(Form(" entry %d", entry));
+          if (time!=0) {
+            TString timeStr(TTimeStamp(time).AsString());
+            timeStr.Remove(26);
+            
+            comment.Append(Form(" (%s)",timeStr.Data()));
+          }  
+          clusterHistograms[detector]->SetCommentToHistograms(comment.Data());
+          
+        }  
+        else 
+          clusterHistograms[detector]->FillCluster(cluster);
+       } // end of (keep this event)
+     } // 
+    }
+  }
+  
+  if (!detailedHistogram) {
+    for (Int_t i=0; i<kTPCSectors; i++)
+      if (fClusterHistograms[i]) {
+       TString why;
+       if (fClusterHistograms[i]->KeepThisEvent(why))
+         intToReturn = 1;
+      } 
+  }
+  else {
+    for (Int_t i=0; i< kTPCSectors; i++) {
+      if (clusterHistograms[i]) {
+       fObjectsToSave->Add(clusterHistograms[i]);
+      }
+    }    
+  }  
+  
+  delete clrow;
+   
+  return intToReturn;
+}
+
+
+void AliROCClusterAnalysisSelector::SlaveTerminate()
+{
+  //
+  
+  if (fOutput)
+  {
+    for (Int_t i=0; i<kTPCHists; i++)
+      if (fClusterHistograms[i])
+        fOutput->Add(fClusterHistograms[i]);
+  }
+} 
+
+void AliROCClusterAnalysisSelector::Terminate()
+{
+  // 
+  // read the objects from the output list and write them to a file
+  // the filename is modified by the object comment passed in the tree info or input list
+  //
+
+  if (fOutput)
+  {  
+    fOutput->Print();
+        
+    for (Int_t i=0; i<kTPCSectors; i++)
+      fClusterHistograms[i] = dynamic_cast<AliTPCClusterHistograms*> (fOutput->FindObject(AliTPCClusterHistograms::FormDetectorName(i, kFALSE)));
+    for (Int_t i=0; i<kTPCSectors; i++)
+      fClusterHistograms[kTPCSectors+i] = dynamic_cast<AliTPCClusterHistograms*> (fOutput->FindObject(AliTPCClusterHistograms::FormDetectorName(i, kTRUE)));
+  }
+  
+  TNamed* comment = 0;
+  if (fTree && fTree->GetUserInfo())
+    comment = dynamic_cast<TNamed*>(fTree->GetUserInfo()->FindObject("comment"));
+  if (!comment && fInput)
+    comment = dynamic_cast<TNamed*>(fInput->FindObject("comment"));
+
+  if (comment)
+  {
+    AliDebug(AliLog::kInfo, Form("INFO: Found comment in input list: %s", comment->GetTitle()));
+  }
+  else
+    return;
+
+  TFile* file = TFile::Open(Form("rocCluster_%s.root",comment->GetTitle()), "RECREATE");
+
+  for (Int_t i=0; i<kTPCHists; i++)
+     if (fClusterHistograms[i]) {
+       fClusterHistograms[i]->SaveHistograms();
+
+//        TCanvas* c = fClusterHistograms[i]->DrawHistograms();
+//        TString dir;
+//        dir.Form("WWW/%s/%s", comment->GetTitle(), c->GetName());
+//        gSystem->mkdir(dir, kTRUE);
+//        c->SaveAs(Form("%s/plots_%s_%s.eps",dir.Data(),comment->GetTitle(),c->GetName()));
+//        c->SaveAs(Form("%s/plots_%s_%s.gif",dir.Data(),comment->GetTitle(),c->GetName()));
+    
+//        c->Close();
+//        delete c;
+     }
+  
+  gDirectory->mkdir("saved_objects");
+  gDirectory->cd("saved_objects");
+
+  for (Int_t i=0; i<fObjectsToSave->GetSize(); i++) {
+    if (fObjectsToSave->At(i)) {
+      AliTPCClusterHistograms* clusterHistograms = dynamic_cast<AliTPCClusterHistograms*> (fObjectsToSave->At(i));
+      if (clusterHistograms)
+       clusterHistograms->SaveHistograms();
+      else
+       fObjectsToSave->At(i)->Write();
+    }
+  }
+
+  gDirectory->cd("../");
+
+
+  file->Close();
+}
diff --git a/PWG0/TPC/AliROCClusterAnalysisSelector.h b/PWG0/TPC/AliROCClusterAnalysisSelector.h
new file mode 100644 (file)
index 0000000..3740e6e
--- /dev/null
@@ -0,0 +1,48 @@
+/* $Id$ */
+
+#ifndef AliROCClusterAnalysisSelector_H
+#define AliROCClusterAnalysisSelector_H
+
+#include "AliSelectorRL.h"
+
+class AliTPCClusterHistograms;
+
+class TObjArray;
+
+// 
+// TODO explain this
+//
+
+class AliROCClusterAnalysisSelector : public AliSelectorRL {
+  public:
+    enum { kTPCSectors = 72, kTPCHists = kTPCSectors * 2 };
+  
+    AliROCClusterAnalysisSelector();
+    virtual ~AliROCClusterAnalysisSelector();
+
+    virtual void    SlaveBegin(TTree* tree);
+    virtual void    Init(TTree *tree);
+    virtual Bool_t  Process(Long64_t entry);
+    virtual void    SlaveTerminate();
+    virtual void    Terminate();
+
+    Int_t           ProcessEvent(Long64_t entry, Bool_t detailedHistogram=kFALSE, const Char_t* label="");
+
+
+ protected:
+
+    AliTPCClusterHistograms* fClusterHistograms[kTPCHists]; // 0..71 histograms created with all clusters, 72..143 without edges
+
+ private:
+
+    Int_t      fNMaxObjectsToSave;
+    TObjArray* fObjectsToSave;
+
+
+    AliROCClusterAnalysisSelector(const AliROCClusterAnalysisSelector&);
+    AliROCClusterAnalysisSelector& operator=(const AliROCClusterAnalysisSelector&);
+
+  ClassDef(AliROCClusterAnalysisSelector, 0);
+};
+
+#endif
index 92807e157338e47b2f214a0a423d118854b77519..1b3322a8af0d33c216a5e382e46f15fdd0eaef1c 100644 (file)
@@ -17,6 +17,8 @@
 #include <TProfile2D.h>
 #include <TObjArray.h>
 #include <TLatex.h>
+#include <TTimeStamp.h>
+#include <TRandom.h>
 
 #include <AliTPCclusterMI.h>
 #include <AliTPCseed.h>
@@ -46,13 +48,17 @@ AliTPCClusterHistograms::AliTPCClusterHistograms()
   fhQtotProfileZVsRow(0),
   fhSigmaYProfileZVsRow(0),
   fhSigmaZProfileZVsRow(0),
-  fhQtotVsTime(0),  
-  fhQmaxVsTime(0),
+  fhMeanQtotVsTime(0),  
+  fhQtotVsTime(0),
+  fhMeanNClustersVsTime(0),    
+  fhNClustersVsTime(0),        
   fhTrackQtotPerCluster(0),
-  fhTrackQtotPerClusterVsSnp(0),
-  fhTrackQtotPerClusterVsTgl(0),
-  fhTrackMeanQtotPerClusterVsSnp(0),
-  fhTrackMeanQtotPerClusterVsTgl(0),
+  fhTrackQtotPerClusterVsPhi(0),
+  fhTrackQtotPerClusterVsTheta(0),
+  fhTrackMeanQtotPerClusterVsPhi(0),
+  fhTrackMeanQtotPerClusterVsTheta(0),
+  fhMeanNTracksVsTime(),
+  fhNEventsVsTime(),
   fIsIROC(kFALSE),
   fEdgeSuppression(kFALSE)
 {
@@ -78,13 +84,17 @@ AliTPCClusterHistograms::AliTPCClusterHistograms(Int_t detector, const Char_t* c
   fhQtotProfileZVsRow(0),
   fhSigmaYProfileZVsRow(0),
   fhSigmaZProfileZVsRow(0),
-  fhQtotVsTime(0),  
-  fhQmaxVsTime(0),
+  fhMeanQtotVsTime(0),  
+  fhQtotVsTime(0),
+  fhMeanNClustersVsTime(0),    
+  fhNClustersVsTime(0),        
   fhTrackQtotPerCluster(0),
-  fhTrackQtotPerClusterVsSnp(0),
-  fhTrackQtotPerClusterVsTgl(0),
-  fhTrackMeanQtotPerClusterVsSnp(0),
-  fhTrackMeanQtotPerClusterVsTgl(0),
+  fhTrackQtotPerClusterVsPhi(0),
+  fhTrackQtotPerClusterVsTheta(0),
+  fhTrackMeanQtotPerClusterVsPhi(0),
+  fhTrackMeanQtotPerClusterVsTheta(0),
+  fhMeanNTracksVsTime(0),
+  fhNEventsVsTime(0),
   fIsIROC(kFALSE),
   fEdgeSuppression(edgeSuppression)
 {
@@ -98,6 +108,13 @@ AliTPCClusterHistograms::AliTPCClusterHistograms(Int_t detector, const Char_t* c
       
   TString name(FormDetectorName(detector, edgeSuppression, comment));
 
+  fNClustersInEvent = 0;
+  fQtotInEvent      = 0;
+  fMaxQtotInEvent   = 0;
+
+  fKeepEvent = kFALSE;
+  fWhyKeepEvent = TString("hi");
+
   fDetector = detector;
   if (detector < 36)
     fIsIROC = kTRUE; 
@@ -105,10 +122,10 @@ AliTPCClusterHistograms::AliTPCClusterHistograms(Int_t detector, const Char_t* c
   SetName(name);
   SetTitle(Form("%s (detector %d)",name.Data(), detector));
 
-  // rounding down to the closest 30 min
-  fTimeStart = 1800*Int_t(timeStart/1800);
-  // rounding up to the closest 30 min
-  fTimeStop  = 1800*Int_t((1800 + timeStop)/1800);
+  // rounding down to the closest hour and starting 10 hours before
+  fTimeStart = 3600*UInt_t(timeStart/3600) - 36000;
+  // rounding up to the closest hour
+  fTimeStop  = 3600*UInt_t((3600 + timeStop)/3600);
   // each time bin covers 5 min
   Int_t nTimeBins = (fTimeStop-fTimeStart)/300;
   
@@ -154,31 +171,41 @@ AliTPCClusterHistograms::AliTPCClusterHistograms(Int_t detector, const Char_t* c
   fhQtotProfileZVsRow = new TProfile2D("MeanQtotZVsPadRow","Mean Qtot, z vs pad row;Pad row;z",nPadRows+2, -1.5, nPadRows+0.5, BINNING_Z);
   fhSigmaYProfileZVsRow = new TProfile2D("MeanSigmaYZVsPadRow","Mean Sigma y, z vs pad row;Pad row;z",nPadRows+2, -1.5, nPadRows+0.5, BINNING_Z);
   fhSigmaZProfileZVsRow = new TProfile2D("MeanSigmaZZVsPadRow","Mean Sigma z, z vs pad row;Pad row;z",nPadRows+2, -1.5, nPadRows+0.5, BINNING_Z);
+
+
+  TString start(TTimeStamp(fTimeStart).AsString());
+  //  TString stop(TTimeStamp(fTimeStart).AsString());
+  start.Remove(26);
   
-  
-  fhQtotVsTime = new TProfile("MeanQtotVsTime", "Mean Qtot vs. time (5 min bins); time; Qtot",nTimeBins, fTimeStart, fTimeStop);
-  fhQmaxVsTime = new TProfile("MeanQmaxVsTime", "Mean Qmax vs. time (5 min bins); time; Qmax",nTimeBins, fTimeStart, fTimeStop);
+  fhMeanQtotVsTime = new TProfile("MeanQtotVsTime",Form("Mean Qtot vs. time (start %s , 1 min bins); time; Qtot",start.Data()),5*nTimeBins, fTimeStart, fTimeStop);
+  fhQtotVsTime     = new TH2F("QtotVsTime",Form("Qtot vs. time (start %s , 1 min bins); time; Qtot",start.Data()),5*nTimeBins, fTimeStart, fTimeStop,400,0,2000);
+
+  fhMeanNClustersVsTime = new TProfile("MeanNClustersVsTime",Form("Mean N Cluster vs. time (start %s , 5 min bins); time; NClusters",start.Data()),nTimeBins, fTimeStart, fTimeStop);
+  fhNClustersVsTime = new TH2F("NClustersVsTime",Form("N Clusters vs. time (start %s , 5 min bins); time; NClusters",start.Data()),nTimeBins, fTimeStart, fTimeStop,400,-0.5,3999.5);
 
   fhQmaxProfileVsRow->SetLineWidth(2);
   fhQtotProfileVsRow->SetLineWidth(2);
 
-  fhQtotVsTime->SetLineWidth(2);
-  fhQmaxVsTime->SetLineWidth(2);
+  fhMeanQtotVsTime->SetLineWidth(2);
 
   // histograms related to tracks
 
-  fhTrackQtotPerCluster = new TH1F("QtotPerCluster","Qtot per cluster; (Sum Qtot)/clusters",400,0,2000);
+  fhTrackQtotPerCluster = new TH1F("QtotPerCluster","Qtot per cluster; (Sum Qtot)/clusters",200,0,2000);
   fhTrackQtotPerCluster->SetMarkerStyle(22);
   fhTrackQtotPerCluster->SetMarkerSize(1);
 
-  fhTrackQtotPerClusterVsSnp = new TH2F("QtotPerClusterVsSnp","QtotPerCluster vs Snp; Snp; (Sum Qtot)/clusters",100,-TMath::Pi(),TMath::Pi(),200,0,2000);
-  fhTrackQtotPerClusterVsTgl = new TH2F("QtotPerClusterVsTgl","QtotPerCluster vs Tgl; Tgl; (Sum Qtot)/clusters",100,-TMath::Pi(),TMath::Pi(),200,0,2000);
+  fhTrackQtotPerClusterVsPhi = new TH2F("QtotPerClusterVsPhi","QtotPerCluster vs Phi; Phi; (Sum Qtot)/clusters",40,-2,2,200,0,2000);
+  fhTrackQtotPerClusterVsTheta = new TH2F("QtotPerClusterVsTheta","QtotPerCluster vs Theta; Theta; (Sum Qtot)/clusters",40,-2,2,200,0,2000);
+
+  fhTrackMeanQtotPerClusterVsPhi = new TProfile("MeanQtotPerClusterVsPhi", "QtotPerCluster vs Phi; Phi; Mean (Sum Qtot)/clusters",40,-2,2);
+  fhTrackMeanQtotPerClusterVsTheta = new TProfile("MeanQtotPerClusterVsTheta", "QtotPerCluster vs Theta; Theta; Mean (Sum Qtot)/clusters",40,-2,2);
+
+  fhTrackMeanQtotPerClusterVsPhi->SetLineWidth(2);
+  fhTrackMeanQtotPerClusterVsTheta->SetLineWidth(2);
 
-  fhTrackMeanQtotPerClusterVsSnp = new TProfile("MeanQtotPerClusterVsSnp", "QtotPerCluster vs Snp; Snp; Mean (Sum Qtot)/clusters",100,-TMath::Pi(),TMath::Pi());
-  fhTrackMeanQtotPerClusterVsTgl = new TProfile("MeanQtotPerClusterVsTgl", "QtotPerCluster vs Tgl; Tgl; Mean (Sum Qtot)/clusters",100,-TMath::Pi(),TMath::Pi());
+  fhMeanNTracksVsTime = new TProfile("MeanNTracksVsTime",Form("Mean n tracks vs. time (start %s , 5 min bins); time; N tracks",start.Data()),nTimeBins, fTimeStart, fTimeStop);
 
-  fhTrackMeanQtotPerClusterVsSnp->SetLineWidth(2);
-  fhTrackMeanQtotPerClusterVsTgl->SetLineWidth(2);
+  fhNEventsVsTime = new TH1F("NEventsVsTime",Form("N events vs. time (start %s , 5 min bins); time; N events",start.Data()),nTimeBins, fTimeStart, fTimeStop);
 
   TH1::AddDirectory(oldStatus);
 }
@@ -261,35 +288,50 @@ AliTPCClusterHistograms::~AliTPCClusterHistograms()
     delete fhSigmaZProfileZVsRow;
     fhSigmaZProfileZVsRow = 0;
   }
-
+  if (fhMeanQtotVsTime) {
+    delete fhMeanQtotVsTime;
+    fhMeanQtotVsTime = 0;
+  }
   if (fhQtotVsTime) {
     delete fhQtotVsTime;
     fhQtotVsTime = 0;
   }
-  if (fhQmaxVsTime) {
-    delete fhQmaxVsTime;
-    fhQmaxVsTime = 0;
+  if (fhMeanNClustersVsTime) {
+    delete fhMeanNClustersVsTime;
+    fhMeanNClustersVsTime = 0;
+  }
+  if (fhNClustersVsTime) {
+    delete fhNClustersVsTime;
+    fhNClustersVsTime = 0;
   }
   if (fhTrackQtotPerCluster) {
     delete fhTrackQtotPerCluster;
     fhTrackQtotPerCluster = 0;
   }
-  if (fhTrackQtotPerClusterVsSnp) {
-    delete fhTrackQtotPerClusterVsSnp;
-    fhTrackQtotPerClusterVsSnp = 0;
+  if (fhTrackQtotPerClusterVsPhi) {
+    delete fhTrackQtotPerClusterVsPhi;
+    fhTrackQtotPerClusterVsPhi = 0;
   }
-  if (fhTrackQtotPerClusterVsTgl) {
-    delete fhTrackQtotPerClusterVsTgl;
-    fhTrackQtotPerClusterVsTgl = 0;
+  if (fhTrackQtotPerClusterVsTheta) {
+    delete fhTrackQtotPerClusterVsTheta;
+    fhTrackQtotPerClusterVsTheta = 0;
   }
-  if (fhTrackMeanQtotPerClusterVsSnp) {
-    delete fhTrackMeanQtotPerClusterVsSnp;
-    fhTrackMeanQtotPerClusterVsSnp = 0;
+  if (fhTrackMeanQtotPerClusterVsPhi) {
+    delete fhTrackMeanQtotPerClusterVsPhi;
+    fhTrackMeanQtotPerClusterVsPhi = 0;
   }
-  if (fhTrackMeanQtotPerClusterVsTgl) {
-    delete fhTrackMeanQtotPerClusterVsTgl;
-    fhTrackMeanQtotPerClusterVsTgl = 0;
+  if (fhTrackMeanQtotPerClusterVsTheta) {
+    delete fhTrackMeanQtotPerClusterVsTheta;
+    fhTrackMeanQtotPerClusterVsTheta = 0;
   }
+  if (fhMeanNTracksVsTime) {
+    delete fhMeanNTracksVsTime;
+    fhMeanNTracksVsTime = 0;
+  }  
+  if (fhNEventsVsTime) {
+    delete fhNEventsVsTime;
+    fhNEventsVsTime = 0;
+  }  
 }
 
 //____________________________________________________________________
@@ -375,126 +417,149 @@ Long64_t AliTPCClusterHistograms::Merge(TCollection* list)
   TList* collectionSigmaYProfileZVsRow  = new TList;
   TList* collectionSigmaZProfileZVsRow  = new TList;
 
-  TList* collectionQtotVsTime  = new TList;
-  TList* collectionQmaxVsTime  = new TList;
+  TList* collectionMeanQtotVsTime  = new TList;
+  TList* collectionQtotVsTime      = new TList;
+
+  TList* collectionMeanNClustersVsTime = new TList; 
+  TList* collectionNClustersVsTime     = new TList;
 
   TList* collectionTrackQtotPerCluster = new TList;
 
-  TList* collectionTrackQtotPerClusterVsSnp = new TList;
-  TList* collectionTrackQtotPerClusterVsTgl = new TList;
+  TList* collectionTrackQtotPerClusterVsPhi = new TList;
+  TList* collectionTrackQtotPerClusterVsTheta = new TList;
 
-  TList* collectionTrackMeanQtotPerClusterVsSnp = new TList;
-  TList* collectionTrackMeanQtotPerClusterVsTgl = new TList;
+  TList* collectionTrackMeanQtotPerClusterVsPhi = new TList;
+  TList* collectionTrackMeanQtotPerClusterVsTheta = new TList;
 
+  TList* collectionMeanNTracksVsTime = new TList;
+  TList* collectionNEventsVsTime = new TList;
 
-   Int_t count = 0;
-   while ((obj = iter->Next())) {
+  Int_t count = 0;
+  while ((obj = iter->Next())) {
     
-     AliTPCClusterHistograms* entry = dynamic_cast<AliTPCClusterHistograms*> (obj);
-     if (entry == 0) 
-       continue;
-
-     collectionQmaxVsRow          ->Add(entry->fhQmaxVsRow        );
-     collectionQtotVsRow         ->Add(entry->fhQtotVsRow         );
-
-     collectionQmaxProfileVsRow   ->Add(entry->fhQmaxProfileVsRow  );
-     collectionQtotProfileVsRow          ->Add(entry->fhQtotProfileVsRow  );
-
-     collectionNClustersYVsRow    ->Add(entry->fhNClustersYVsRow);
-     collectionNClustersZVsRow    ->Add(entry->fhNClustersZVsRow);
-
-     collectionSigmaYVsRow       ->Add(entry->fhSigmaYVsRow       );
-     collectionSigmaZVsRow       ->Add(entry->fhSigmaZVsRow       );
-                                                                          
-     collectionQmaxProfileYVsRow  ->Add(entry->fhQmaxProfileYVsRow );
-     collectionQtotProfileYVsRow  ->Add(entry->fhQtotProfileYVsRow );
-     collectionSigmaYProfileYVsRow->Add(entry->fhSigmaYProfileYVsRow);
-     collectionSigmaZProfileYVsRow->Add(entry->fhSigmaZProfileYVsRow);
-
-     collectionQmaxProfileZVsRow  ->Add(entry->fhQmaxProfileZVsRow );
-     collectionQtotProfileZVsRow  ->Add(entry->fhQtotProfileZVsRow );
-     collectionSigmaYProfileZVsRow->Add(entry->fhSigmaYProfileZVsRow);
-     collectionSigmaZProfileZVsRow->Add(entry->fhSigmaZProfileZVsRow);
-
-     collectionQtotVsTime->Add(entry->fhQtotVsTime);
-     collectionQmaxVsTime->Add(entry->fhQmaxVsTime);
-
-     collectionTrackQtotPerCluster->Add(entry->fhTrackQtotPerCluster);
-
-     collectionTrackQtotPerClusterVsSnp->Add(entry->fhTrackQtotPerClusterVsSnp);
-     collectionTrackQtotPerClusterVsTgl->Add(entry->fhTrackQtotPerClusterVsTgl);
-
-     collectionTrackMeanQtotPerClusterVsSnp->Add(entry->fhTrackMeanQtotPerClusterVsSnp);
-     collectionTrackMeanQtotPerClusterVsTgl->Add(entry->fhTrackMeanQtotPerClusterVsTgl);
-
-     count++;
-   }
-
-   fhQmaxVsRow          ->Merge(collectionQmaxVsRow       );      
-   fhQtotVsRow          ->Merge(collectionQtotVsRow      );       
-
-   fhQmaxProfileVsRow   ->Merge(collectionQmaxProfileVsRow);
-   fhQtotProfileVsRow   ->Merge(collectionQtotProfileVsRow);
-
-   fhNClustersYVsRow    ->Merge(collectionNClustersYVsRow);
-   fhNClustersZVsRow    ->Merge(collectionNClustersZVsRow);
-
-   fhSigmaYVsRow        ->Merge(collectionSigmaYVsRow    );       
-   fhSigmaZVsRow        ->Merge(collectionSigmaZVsRow    );       
-                                                                    
-   fhQmaxProfileYVsRow  ->Merge(collectionQmaxProfileYVsRow  ); 
-   fhQtotProfileYVsRow  ->Merge(collectionQtotProfileYVsRow  );
-   fhSigmaYProfileYVsRow->Merge(collectionSigmaYProfileYVsRow);
-   fhSigmaZProfileYVsRow->Merge(collectionSigmaZProfileYVsRow);
-
-   fhQmaxProfileZVsRow  ->Merge(collectionQmaxProfileZVsRow  ); 
-   fhQtotProfileZVsRow  ->Merge(collectionQtotProfileZVsRow  );
-   fhSigmaYProfileZVsRow->Merge(collectionSigmaYProfileZVsRow);
-   fhSigmaZProfileZVsRow->Merge(collectionSigmaZProfileZVsRow);
-
-   fhQtotVsTime->Merge(collectionQtotVsTime);
-   fhQmaxVsTime->Merge(collectionQmaxVsTime);
-
-   fhTrackQtotPerCluster->Merge(collectionTrackQtotPerCluster);
-
-   fhTrackQtotPerClusterVsSnp->Merge(collectionTrackQtotPerClusterVsSnp);
-   fhTrackQtotPerClusterVsTgl->Merge(collectionTrackQtotPerClusterVsTgl);
-
-   fhTrackMeanQtotPerClusterVsSnp->Merge(collectionTrackMeanQtotPerClusterVsSnp);
-   fhTrackMeanQtotPerClusterVsTgl->Merge(collectionTrackMeanQtotPerClusterVsTgl);
-
-   delete collectionQmaxVsRow;          
-   delete collectionQtotVsRow;  
-
-   delete collectionQmaxProfileVsRow;
-   delete collectionQtotProfileVsRow;
-
-   delete collectionNClustersYVsRow;
-   delete collectionNClustersZVsRow;
-
-   delete collectionSigmaYVsRow;         
-   delete collectionSigmaZVsRow;         
-                                 
-   delete collectionQmaxProfileYVsRow;  
-   delete collectionQtotProfileYVsRow;  
-   delete collectionSigmaYProfileYVsRow;
-   delete collectionSigmaZProfileYVsRow;
-
-   delete collectionQmaxProfileZVsRow;  
-   delete collectionQtotProfileZVsRow;  
-   delete collectionSigmaYProfileZVsRow;
-   delete collectionSigmaZProfileZVsRow;
-
-   delete collectionQtotVsTime;
-   delete collectionQmaxVsTime;
+    AliTPCClusterHistograms* entry = dynamic_cast<AliTPCClusterHistograms*> (obj);
+    if (entry == 0) 
+      continue;
+    
+    collectionQmaxVsRow          ->Add(entry->fhQmaxVsRow         );
+    collectionQtotVsRow          ->Add(entry->fhQtotVsRow         );
+    
+    collectionQmaxProfileVsRow   ->Add(entry->fhQmaxProfileVsRow  );
+    collectionQtotProfileVsRow   ->Add(entry->fhQtotProfileVsRow  );
+    
+    collectionNClustersYVsRow    ->Add(entry->fhNClustersYVsRow);
+    collectionNClustersZVsRow    ->Add(entry->fhNClustersZVsRow);
+    
+    collectionSigmaYVsRow        ->Add(entry->fhSigmaYVsRow       );
+    collectionSigmaZVsRow        ->Add(entry->fhSigmaZVsRow       );
+    
+    collectionQmaxProfileYVsRow  ->Add(entry->fhQmaxProfileYVsRow );
+    collectionQtotProfileYVsRow  ->Add(entry->fhQtotProfileYVsRow );
+    collectionSigmaYProfileYVsRow->Add(entry->fhSigmaYProfileYVsRow);
+    collectionSigmaZProfileYVsRow->Add(entry->fhSigmaZProfileYVsRow);
+    
+    collectionQmaxProfileZVsRow  ->Add(entry->fhQmaxProfileZVsRow );
+    collectionQtotProfileZVsRow  ->Add(entry->fhQtotProfileZVsRow );
+    collectionSigmaYProfileZVsRow->Add(entry->fhSigmaYProfileZVsRow);
+    collectionSigmaZProfileZVsRow->Add(entry->fhSigmaZProfileZVsRow);
+    
+    collectionMeanQtotVsTime     ->Add(entry->fhMeanQtotVsTime);
+    collectionQtotVsTime         ->Add(entry->fhQtotVsTime);
 
-   delete collectionTrackQtotPerCluster;
+    collectionMeanNClustersVsTime->Add(entry->fhMeanNClustersVsTime);  
+    collectionNClustersVsTime    ->Add(entry->fhNClustersVsTime);
+    
+    collectionTrackQtotPerCluster->Add(entry->fhTrackQtotPerCluster);
+    
+    collectionTrackQtotPerClusterVsPhi->Add(entry->fhTrackQtotPerClusterVsPhi);
+    collectionTrackQtotPerClusterVsTheta->Add(entry->fhTrackQtotPerClusterVsTheta);
+    
+    collectionTrackMeanQtotPerClusterVsPhi->Add(entry->fhTrackMeanQtotPerClusterVsPhi);
+    collectionTrackMeanQtotPerClusterVsTheta->Add(entry->fhTrackMeanQtotPerClusterVsTheta);
+    
+    collectionMeanNTracksVsTime->Add(entry->fhMeanNTracksVsTime);
+    collectionNEventsVsTime->Add(entry->fhNEventsVsTime);
+    
+    count++;
+  }
+  
+  fhQmaxVsRow          ->Merge(collectionQmaxVsRow       );       
+  fhQtotVsRow          ->Merge(collectionQtotVsRow       );       
+  
+  fhQmaxProfileVsRow   ->Merge(collectionQtotProfileVsRow);
+  fhQtotProfileVsRow   ->Merge(collectionQtotProfileVsRow);
+  
+  fhNClustersYVsRow    ->Merge(collectionNClustersYVsRow);
+  fhNClustersZVsRow    ->Merge(collectionNClustersZVsRow);
+  
+  fhSigmaYVsRow        ->Merge(collectionSigmaYVsRow     );       
+  fhSigmaZVsRow        ->Merge(collectionSigmaZVsRow     );       
+  
+  fhQmaxProfileYVsRow  ->Merge(collectionQmaxProfileYVsRow  ); 
+  fhQtotProfileYVsRow  ->Merge(collectionQtotProfileYVsRow  );
+  fhSigmaYProfileYVsRow->Merge(collectionSigmaYProfileYVsRow);
+  fhSigmaZProfileYVsRow->Merge(collectionSigmaZProfileYVsRow);
+  
+  fhQmaxProfileZVsRow  ->Merge(collectionQmaxProfileZVsRow  ); 
+  fhQtotProfileZVsRow  ->Merge(collectionQtotProfileZVsRow  );
+  fhSigmaYProfileZVsRow->Merge(collectionSigmaYProfileZVsRow);
+  fhSigmaZProfileZVsRow->Merge(collectionSigmaZProfileZVsRow);
+  
+  fhMeanQtotVsTime     ->Merge(collectionMeanQtotVsTime);
+  fhQtotVsTime         ->Merge(collectionQtotVsTime);
 
-   delete collectionTrackQtotPerClusterVsSnp; 
-   delete collectionTrackQtotPerClusterVsTgl;
+  fhMeanNClustersVsTime->Merge(collectionMeanNClustersVsTime );
+  fhNClustersVsTime    ->Merge(collectionNClustersVsTime);
+  
+  fhTrackQtotPerCluster->Merge(collectionTrackQtotPerCluster);
+  
+  fhTrackQtotPerClusterVsPhi->Merge(collectionTrackQtotPerClusterVsPhi);
+  fhTrackQtotPerClusterVsTheta->Merge(collectionTrackQtotPerClusterVsTheta);
+  
+  fhTrackMeanQtotPerClusterVsPhi->Merge(collectionTrackMeanQtotPerClusterVsPhi);
+  fhTrackMeanQtotPerClusterVsTheta->Merge(collectionTrackMeanQtotPerClusterVsTheta);
+  
+  fhMeanNTracksVsTime->Merge(collectionMeanNTracksVsTime);
+  fhNEventsVsTime->Merge(collectionNEventsVsTime);
+  
+  delete collectionQmaxVsRow;          
+  delete collectionQtotVsRow;  
+  
+  delete collectionQmaxProfileVsRow;
+  delete collectionQtotProfileVsRow;
+  
+  delete collectionNClustersYVsRow;
+  delete collectionNClustersZVsRow;
+  
+  delete collectionSigmaYVsRow;          
+  delete collectionSigmaZVsRow;          
+  
+  delete collectionQmaxProfileYVsRow;  
+  delete collectionQtotProfileYVsRow;  
+  delete collectionSigmaYProfileYVsRow;
+  delete collectionSigmaZProfileYVsRow;
+  
+  delete collectionQmaxProfileZVsRow;  
+  delete collectionQtotProfileZVsRow;  
+  delete collectionSigmaYProfileZVsRow;
+  delete collectionSigmaZProfileZVsRow;
+  
+  delete collectionMeanQtotVsTime;
+  delete collectionQtotVsTime;
 
-   delete collectionTrackMeanQtotPerClusterVsSnp; 
-   delete collectionTrackMeanQtotPerClusterVsTgl;
+  delete collectionMeanNClustersVsTime; 
+  delete collectionNClustersVsTime;     
+  
+  delete collectionTrackQtotPerCluster;
+  
+  delete collectionTrackQtotPerClusterVsPhi; 
+  delete collectionTrackQtotPerClusterVsTheta;
+  
+  delete collectionTrackMeanQtotPerClusterVsPhi; 
+  delete collectionTrackMeanQtotPerClusterVsTheta;
+  
+  delete collectionMeanNTracksVsTime;
+  delete collectionNEventsVsTime;
 
   return count+1;
 }
@@ -519,19 +584,21 @@ void AliTPCClusterHistograms::FillCluster(AliTPCclusterMI* cluster, Int_t time)
 
   if (qMax<=0) {
     printf(Form("\n WARNING: Hi Marian! How can we have Qmax = %f ??? \n \n", qMax));
-    return;
   }
   if (qTot<=0) {
     printf(Form("\n WARNING: Hi Marian! How can we have Qtot = %f ??? \n \n ", qTot));
-    return;
-  } 
-  
+  }   
   
   // check if the cluster is accepted
   if (fEdgeSuppression)
     if (IsClusterOnEdge(cluster))
       return;
 
+  fNClustersInEvent++;
+  fQtotInEvent = fQtotInEvent + qTot;
+  if (qTot > fMaxQtotInEvent)
+    fMaxQtotInEvent = qTot;
+
   fhQmaxVsRow           ->Fill(padRow, qMax);
   fhQtotVsRow           ->Fill(padRow, qTot);
 
@@ -557,8 +624,8 @@ void AliTPCClusterHistograms::FillCluster(AliTPCclusterMI* cluster, Int_t time)
   if (time>0 & fTimeStart>0 & fTimeStop>0 & time>fTimeStart) {
     //Float_t timeFraction = (time - fTimeStart)/(fTimeStop-fTimeStart); 
 
+    fhMeanQtotVsTime->Fill(time,qTot);
     fhQtotVsTime->Fill(time,qTot);
-    fhQmaxVsTime->Fill(time,qMax);
   }
 }
 
@@ -597,19 +664,32 @@ void AliTPCClusterHistograms::FillTrack(const AliTPCseed* seed) {
   
   Float_t meanQtot = totalQtot/nClusters;
   
-  Float_t snp  =  TMath::ASin(seed->GetSnp());
-  Float_t tgl  =  TMath::ATan(seed->GetTgl());
+  // azimuthal angle 
+  Float_t phi    =  TMath::ASin(seed->GetSnp() + seed->GetAlpha());
+  // angle with respect to the central membrane
+  Float_t theta  =  TMath::ATan(seed->GetTgl());
 
   fhTrackQtotPerCluster->Fill(meanQtot);
 
-  fhTrackMeanQtotPerClusterVsSnp->Fill(snp, meanQtot);
-  fhTrackMeanQtotPerClusterVsTgl->Fill(tgl, meanQtot);
+  fhTrackMeanQtotPerClusterVsPhi->Fill(phi,   meanQtot);
+  fhTrackMeanQtotPerClusterVsTheta->Fill(theta, meanQtot);
+
+  fhTrackQtotPerClusterVsPhi->Fill(phi, meanQtot);
+  fhTrackQtotPerClusterVsTheta->Fill(theta, meanQtot);
+}
+
+//____________________________________________________________________
+void AliTPCClusterHistograms::FillEvent(Int_t time, Int_t nTracks) {
+  //
+  // fill event
+  //
 
-  fhTrackQtotPerClusterVsSnp->Fill(snp, meanQtot);
-  fhTrackQtotPerClusterVsTgl->Fill(tgl, meanQtot);
+  fhMeanNTracksVsTime->Fill(time, nTracks);
 
+  //  fhNEventsVsTime->Fill(time);
 }
 
+
 //____________________________________________________________________
 Bool_t AliTPCClusterHistograms::IsClusterOnEdge(AliTPCclusterMI* clusterMI) {
   //
@@ -633,6 +713,102 @@ Bool_t AliTPCClusterHistograms::IsClusterOnEdge(AliTPCclusterMI* clusterMI) {
   return kFALSE;
 }
 
+//____________________________________________________________________
+Float_t AliTPCClusterHistograms::DistanceToEdge(AliTPCclusterMI* clusterMI) {
+  //
+  // get the y-distance to closest edge 
+  //
+  
+  Int_t detector = clusterMI->GetDetector();
+  Int_t padRow   = clusterMI->GetRow(); 
+  Float_t y      = clusterMI->GetY();
+  
+  Float_t yEdge = -9999;
+  Float_t d     = 0;
+  
+  // IROC
+  if (detector < 36) {    
+    yEdge = 14 + padRow * 0.1333;
+    
+  }    
+  else { // OROC
+    if (padRow<64) // small pads
+      yEdge = 22.5 + padRow * 0.1746;
+    else           // large pads
+      yEdge = 34.0 + (padRow-64) * 0.2581;      
+  }
+  if (y<=0) yEdge = -yEdge;
+  
+  d = yEdge - y;
+  
+  return d;
+}
+
+
+//____________________________________________________________________
+Bool_t AliTPCClusterHistograms::KeepThisEvent(TString& why) {
+  //
+  // is this event interesting? 
+  //
+  // the criteria are ...
+  // 
+  
+  if (fKeepEvent) {
+    why = TString(fWhyKeepEvent);
+    return kTRUE;
+  }
+
+  if (fNClustersInEvent>20000) {
+    why.Append("_moreThan20000clusters");
+    fWhyKeepEvent = TString(why);
+    fKeepEvent = kTRUE;
+    return kTRUE;
+  }
+  
+  if (fMaxQtotInEvent>10000) {
+    why.Append("_clusterWithQtot20000plus");
+    fWhyKeepEvent = TString(why);
+    fKeepEvent = kTRUE;
+    return kTRUE;
+  }
+
+  if (gRandom->Uniform()<0.001) {
+    why.Append("_random");
+    fWhyKeepEvent = TString(why);
+    fKeepEvent = kTRUE;
+    return kTRUE;
+  }
+
+  return kFALSE;
+}
+
+//____________________________________________________________________
+void AliTPCClusterHistograms::StartEvent() {
+  //
+  // reset counters 
+  // 
+  fNClustersInEvent  = 0; 
+  fQtotInEvent       = 0; 
+  fMaxQtotInEvent    = 0; 
+  fKeepEvent         = kFALSE; 
+  fWhyKeepEvent      = TString("");
+}
+
+
+//____________________________________________________________________
+void AliTPCClusterHistograms::FinishEvent(Int_t timeStamp) {
+  //
+  // fill histograms related to the event
+  //
+  fhMeanNClustersVsTime->Fill(timeStamp, fNClustersInEvent); 
+  fhNClustersVsTime    ->Fill(timeStamp, fNClustersInEvent); 
+
+  fhNEventsVsTime->Fill(timeStamp);
+}
 
 
 //____________________________________________________________________
@@ -645,9 +821,6 @@ void AliTPCClusterHistograms::SaveHistograms()
   gDirectory->mkdir(fName.Data());
   gDirectory->cd(fName.Data());
 
-  //TTimeStamp* t = new TTimeStamp(timeStart);
-  //TNamed* time = new TNamed("timeStart", Form("%d",t->GetDate())
-
   fhQmaxVsRow           ->Write();
   fhQtotVsRow           ->Write();
 
@@ -670,23 +843,36 @@ void AliTPCClusterHistograms::SaveHistograms()
   fhSigmaYProfileZVsRow ->Write();
   fhSigmaZProfileZVsRow ->Write();
 
+  TNamed* comment = new TNamed("comment", fCommentToHistograms.Data());
+  comment->Write();
+
+  if (fhMeanQtotVsTime->GetEntries()>0)
+    fhMeanQtotVsTime->Write();
+
   if (fhQtotVsTime->GetEntries()>0)
     fhQtotVsTime->Write();
 
-  if (fhQmaxVsTime->GetEntries()>0)
-    fhQmaxVsTime->Write();
+  if (fhMeanNClustersVsTime->GetEntries()>0)
+    fhMeanNClustersVsTime->Write();
 
+  if (fhNClustersVsTime->GetEntries()>0)
+    fhNClustersVsTime->Write();
+
+  if (fhNEventsVsTime->GetEntries()>0)
+    fhNEventsVsTime->Write();
 
   gDirectory->mkdir("track_hists");
   gDirectory->cd("track_hists");
 
   fhTrackQtotPerCluster->Write();
 
-  fhTrackQtotPerClusterVsSnp->Write();
-  fhTrackQtotPerClusterVsTgl->Write();
+  fhTrackQtotPerClusterVsPhi->Write();
+  fhTrackQtotPerClusterVsTheta->Write();
+
+  fhTrackMeanQtotPerClusterVsPhi->Write();
+  fhTrackMeanQtotPerClusterVsTheta->Write();
 
-  fhTrackMeanQtotPerClusterVsSnp->Write();
-  fhTrackMeanQtotPerClusterVsTgl->Write();
+  fhMeanNTracksVsTime->Write();
 
   gDirectory->cd("../");
 
@@ -694,6 +880,7 @@ void AliTPCClusterHistograms::SaveHistograms()
 
 }
 
+
 //____________________________________________________________________
 TCanvas* AliTPCClusterHistograms::DrawHistograms(const Char_t* /*opt*/) {
   //
@@ -728,38 +915,34 @@ TCanvas* AliTPCClusterHistograms::DrawHistograms(const Char_t* /*opt*/) {
   
   tEdge->SetTextSize(0.015);
   tEdge->DrawClone();
+  
+
 
   c->cd(2);
+  fhNClustersYVsRow->Draw("colz");
+
+  c->cd(3);
+  fhNClustersZVsRow->Draw("colz");
+
+  c->cd(4);
   fhQmaxVsRow->Draw("colz");
   fhQmaxProfileVsRow->Draw("same");
 
-  c->cd(3);
+  c->cd(5);
   fhQtotVsRow->Draw("colz"); 
   fhQtotProfileVsRow->Draw("same");       
                        
-  c->cd(4);
-  fhQmaxProfileYVsRow   ->Draw("colz");
-
-  c->cd(5);
-  fhQtotProfileYVsRow   ->Draw("colz");
-
   c->cd(6);
-  fhQmaxProfileZVsRow   ->Draw("colz");
+  fhQtotProfileYVsRow   ->Draw("colz");
 
   c->cd(7);
   fhQtotProfileZVsRow   ->Draw("colz");
 
   c->cd(8);
-    
-  fhSigmaYVsRow         ->Draw("colz");
+  fhQmaxProfileYVsRow   ->Draw("colz");
 
   c->cd(9);
-  fhSigmaZVsRow         ->Draw("colz");
+  fhQmaxProfileZVsRow   ->Draw("colz");    
                        
-  //fhSigmaYProfileYVsRow ->Draw("colz");
-  //fhSigmaZProfileYVsRow ->Draw("colz");
-
-  //fhSigmaYProfileZVsRow ->Draw("colz");
-  //fhSigmaZProfileZVsRow ->Draw("colz");
   return c;
 }
index 398e24c9e1d2aab0f673cb81def3b772923165ee..10a298035f9a8a76373ca0b6ae8043ab6dae38e7 100644 (file)
@@ -34,14 +34,27 @@ public:
   AliTPCClusterHistograms& operator=(const AliTPCClusterHistograms& corrMatrix);
 
   virtual Long64_t Merge(TCollection* list);
-
+  
   virtual void SaveHistograms();
+  void         SetCommentToHistograms(const Char_t* text) {fCommentToHistograms = TString(text);}
 
+  void FillEvent(Int_t time, Int_t nTracks);
   void FillTrack(const AliTPCseed* seed);
   void FillCluster(AliTPCclusterMI* clusterMI, Int_t time=-1);
+  
+  void    StartEvent();
+  void    FinishEvent(Int_t timeStamp);
+  
+  Int_t   GetNClusters() {return fNClustersInEvent;}
+  Float_t GetQtotInEvent() {return fQtotInEvent;}
+  Float_t GetMaxQtotInEvent() {return fMaxQtotInEvent;}
 
-  Bool_t IsClusterOnEdge(AliTPCclusterMI* clusterMI);
+  Bool_t  KeepThisEvent(TString& why);
+  const Char_t* WhyKeepEvent() {return fWhyKeepEvent.Data();}
 
+  Bool_t  IsClusterOnEdge(AliTPCclusterMI* clusterMI);
+  Float_t DistanceToEdge(AliTPCclusterMI* clusterMI);
   TCanvas* DrawHistograms(const Char_t* opt="");
 
   static const char* FormDetectorName(Int_t detector, Bool_t edgeSuppression = kFALSE, const char* comment = 0);
@@ -57,8 +70,11 @@ protected:
   TProfile*   fhQtotProfileVsRow;       //       QtotProfileVsRow
   TProfile*   fhQmaxProfileVsRow;       //       QmaxProfileVsRow
 
-  TH2F*       fhNClustersYVsRow;        // 
-  TH2F*       fhNClustersZVsRow;        // 
+  TH2F*       fhQtotVsDistanceToEdge;        // qtot vs distance to edge
+  TProfile*   fhQtotProfileVsDistanceToEdge; // qtot vs distance to edge
+
+  TH2F*       fhNClustersYVsRow;        //        n clusters y vs row
+  TH2F*       fhNClustersZVsRow;        //        n clusters z vs row
                                                                                            
   TH2F*       fhSigmaYVsRow;            //       SigmaYVsRow
   TH2F*       fhSigmaZVsRow;            //       SigmaZVsRow
@@ -73,22 +89,35 @@ protected:
   TProfile2D* fhSigmaYProfileZVsRow;    //       SigmaYProfileZVsRow
   TProfile2D* fhSigmaZProfileZVsRow;    //       SigmaZProfileZVsRow
                                                                                            
-  TProfile*   fhQtotVsTime;             //       QtotVsTime
-  TProfile*   fhQmaxVsTime;             //       QmaxVsTime
+  TProfile*   fhMeanQtotVsTime;         //       mean qtot vs time
+  TH2F*       fhQtotVsTime;             //       qtot vs time
+  TProfile*   fhMeanNClustersVsTime;    //        mean number of clusters vs time
+  TH2F*       fhNClustersVsTime;        //        number of clusters vs time
                                                                                            
   TH1F*       fhTrackQtotPerCluster;    //       TrackQtotPerCluster
                                                                                            
-  TH2F*       fhTrackQtotPerClusterVsSnp; //     TrackQtotPerClusterVsSnp
-  TH2F*       fhTrackQtotPerClusterVsTgl; //     TrackQtotPerClusterVsTgl
+  TH2F*       fhTrackQtotPerClusterVsPhi; //     TrackQtotPerClusterVsPhi
+  TH2F*       fhTrackQtotPerClusterVsTheta; //   TrackQtotPerClusterVsTheta
                                                                                            
-  TProfile*   fhTrackMeanQtotPerClusterVsSnp; //  TrackMeanQtotPerClusterVsSnp
-  TProfile*   fhTrackMeanQtotPerClusterVsTgl; //  TrackMeanQtotPerClusterVsTgl
+  TProfile*   fhTrackMeanQtotPerClusterVsPhi; //  TrackMeanQtotPerClusterVsPhi
+  TProfile*   fhTrackMeanQtotPerClusterVsTheta; //  TrackMeanQtotPerClusterVsTheta
+
+  TProfile*   fhMeanNTracksVsTime;        // mean number of tracks vs time   
+  TH1F*       fhNEventsVsTime;            // number of events vs time
 
   Int_t       fDetector;                // number of detector
   Bool_t      fIsIROC;                  // true = IROC, false = OROC
   Bool_t      fEdgeSuppression;         // if set edges are not taken into account for histograms
 
+  Int_t       fNClustersInEvent;        // number of clusters in event
+  Float_t     fQtotInEvent;             // total qtot in event
+  Float_t     fMaxQtotInEvent;          // max qtot in event
+
+  Bool_t      fKeepEvent;               // keep this event
+  TString     fWhyKeepEvent;            // why
+
+  TString     fCommentToHistograms;     // comments to histograms
+
   ClassDef(AliTPCClusterHistograms,1)
 };
 
diff --git a/PWG0/TPC/runROCClusterAnalysis.C b/PWG0/TPC/runROCClusterAnalysis.C
new file mode 100644 (file)
index 0000000..0ec2448
--- /dev/null
@@ -0,0 +1,42 @@
+/* $Id$ */
+
+//
+// 
+//
+
+#include "../CreateESDChain.C"
+#include "../PWG0Helper.C"
+
+void runROCClusterAnalysis(Char_t* data, Int_t nRuns=20, Int_t offset=0, Bool_t aDebug = kFALSE, Int_t runNumber=0, Bool_t aProof = kFALSE, 
+    const char* option = "", const char* proofServer = "jgrosseo@lxb6046")
+{
+  if (aProof)
+    connectProof(proofServer);
+
+  TString libraries("libEG;libGeom;libESD;libPWG0base;libPWG0dep");
+  TString packages("PWG0base;PWG0dep");
+
+  if (!prepareQuery(libraries, packages, 2))
+    return;
+  
+  TChain* chain = CreateESDChain(data, nRuns, offset, kTRUE, kTRUE);
+
+  TList inputList;
+
+  //  TNamed* comment = new TNamed("comment",runStr.Data());
+  if (runNumber!=0)
+    inputList.Add(new TNamed("comment",Form("%d",runNumber)));
+
+  TString selectorName = "AliROCClusterAnalysisSelector";
+  AliLog::SetClassDebugLevel(selectorName, AliLog::kInfo);
+
+  if (aDebug != kFALSE)
+  {
+    AliLog::SetClassDebugLevel(selectorName, AliLog::kDebug);
+    selectorName += ".cxx++g";
+  }
+  else
+    selectorName += ".cxx+";
+
+  Int_t result = executeQuery(chain, &inputList, selectorName, option);
+}