corrections from Alberto
[u/mrichter/AliRoot.git] / MONITOR / AliMonitorTPC.cxx
index 54f7135..c1063cc 100644 (file)
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
-
+#include <TFolder.h>
+#include <TTree.h>
+#include <TVector3.h>
+
+#include "AliLog.h"
+#include "AliESD.h"
+#include "AliMonitorDataTPC.h"
+#include "AliMonitorHisto.h"
 #include "AliMonitorTPC.h"
-#include "AliTPCRawStream.h"
+#include "AliMonitorTrend.h"
+#include "AliRawReader.h"
+#include "AliRunLoader.h"
 #include "AliTPCClustersRow.h"
+#include "AliTPCParam.h"
+#include "AliTPCRawStream.h"
 #include "AliTPCclusterMI.h"
-#include "AliTPCtrack.h"
-
-
-ClassImp(AliMonitorDataTPC) 
-
-
-//_____________________________________________________________________________
-AliMonitorDataTPC::AliMonitorDataTPC()
-{
-  fPt = fEta = fPhi = NULL;
-  fSize = 0;
-}
-
-//_____________________________________________________________________________
-AliMonitorDataTPC::AliMonitorDataTPC(Int_t size)
-{
-  fPt = new Float_t[size];
-  fEta = new Float_t[size];
-  fPhi = new Float_t[size];
-  fSize = size;
-}
-
-//_____________________________________________________________________________
-AliMonitorDataTPC::~AliMonitorDataTPC()
-{
-  delete[] fPt;
-  delete[] fEta;
-  delete[] fPhi;
-}
-
-//_____________________________________________________________________________
-void AliMonitorDataTPC::SetSize(Int_t size)
-{
-  if (size > fSize) {
-    delete[] fPt;
-    delete[] fEta;
-    delete[] fPhi;
-    fPt = new Float_t[size];
-    fEta = new Float_t[size];
-    fPhi = new Float_t[size];
-    fSize = size;
-  }
-}
-
-
 
 ClassImp(AliMonitorTPC) 
 
 
 //_____________________________________________________________________________
-AliMonitorTPC::AliMonitorTPC(AliTPCParam* param)
+AliMonitorTPC::AliMonitorTPC(AliTPCParam* param):
+  AliMonitor(),
+  fParam(param),
+  fPadsCharge(NULL),
+  fClustersCharge(NULL),
+  fNClustersVsRow(NULL),
+  fNClustersVsSector(NULL),
+  fNTracks(NULL),
+  fTrackPt(NULL),
+  fTrackEta(NULL),
+  fTrackPhi(NULL),
+  fTrackNCl(NULL),
+  fTrackDEdxVsP(NULL),
+  fTrackDEdx(NULL),
+  fTrackEtaVsPhi(NULL),
+  fPtEtaVsPhi(NULL),
+  fData(new AliMonitorDataTPC(10000))
 {
 // create a TPC monitor object with the given parameters
 
-  fParam = param;
-  fData = new AliMonitorDataTPC(10000);
 }
 
 //_____________________________________________________________________________
@@ -126,21 +106,41 @@ void AliMonitorTPC::CreateHistos(TFolder* folder)
 
   fTrackPt = CreateHisto1("TrackPt", "pt distribution of tracks", 
                          90, 0, 3, "p_{t} [GeV/c]", "#Delta N/N",
-                         AliMonitorHisto::kNormEntries);
+                         AliMonitorHisto::kNormNone);
 
   fTrackEta = CreateHisto1("TrackEta", "eta distribution of tracks", 
                           100, -2, 2, "#eta", "#Delta N/N",
                           AliMonitorHisto::kNormEntries);
 
   fTrackPhi = CreateHisto1("TrackPhi", "phi distribution of tracks", 
-                          120, 0, 360, "#phi [#circ]", "#Delta N/N",
+                          120, -180, 180, "#phi [#circ]", "#Delta N/N",
                           AliMonitorHisto::kNormEntries);
   fTrackPhi->SetDescription("The phi distribution should be flat on average.\nIf it is not flat check for dead TPC sectors.");
 
+  fTrackNCl = CreateHisto1("TrackNCl", "Number of clusters per track", 
+                          200, 0, 200, "N_{clusters}", "#Delta N/N",
+                          AliMonitorHisto::kNormNone);
+
   fTrackDEdxVsP = CreateHisto2("TrackDEdxVsP", "dE/dx of tracks", 
                               100, 0, 3, 100, 0, 200, 
                               "p [GeV/c]", "dE/dx", "#Delta N/N",
                               AliMonitorHisto::kNormEntries);
+
+  fTrackDEdx = CreateHisto1("TrackDEdx", "dE/dx of tracks with 0.4<p<1.0 GeV/c", 
+                              50, 0, 100, 
+                              "dE/dx", "#Delta N/N",
+                              AliMonitorHisto::kNormEntries);
+
+  fTrackEtaVsPhi = CreateHisto2("TrackEtaVsPhi", "#phi vs #eta", 
+                              20, -1, 1, 25, 0, 360, 
+                              "#eta", "#phi", "#Delta N/N",
+                              AliMonitorHisto::kNormNone);
+
+  fPtEtaVsPhi = CreateHisto2("PtEtaVsPhi", "#phi vs #eta", 
+                              20, -1, 1, 25, 0, 360, 
+                              "#eta", "#phi", "#Delta N/N",
+                              AliMonitorHisto::kNormNone);
+
 }
 
 
@@ -155,7 +155,7 @@ void AliMonitorTPC::CreateBranches(TTree* tree)
 
 //_____________________________________________________________________________
 void AliMonitorTPC::FillHistos(AliRunLoader* runLoader, 
-                              AliRawReader* rawReader)
+                              AliRawReader* rawReader, AliESD* esd)
 {
 // fill the TPC monitor histogrms
 
@@ -193,33 +193,40 @@ void AliMonitorTPC::FillHistos(AliRunLoader* runLoader,
       fNClustersVsSector->Fill(iSector);
     }
   }
-  fNClustersVsSector->ScaleErrorBy(100.);
+  fNClustersVsSector->ScaleErrorBy(10.);
 
   delete clustersRow;
   tpcLoader->UnloadRecPoints();
 
 
-  tpcLoader->LoadTracks();
-  TTree* tracks = tpcLoader->TreeT();
-  if (!tracks) return;
-  AliTPCtrack* track = new AliTPCtrack;
-  tracks->SetBranchAddress("tracks", &track);
-
-  fNTracks->Fill(tracks->GetEntries());
-  fData->fNTracks = (Int_t) tracks->GetEntries();
-  fData->SetSize(fData->fNTracks);
-  for (Int_t i = 0; i < tracks->GetEntries(); i++) {
-    tracks->GetEntry(i);
-    fTrackPt->Fill(track->Pt());
-    fTrackEta->Fill(track->Eta());
-    fTrackPhi->Fill(track->Phi() * TMath::RadToDeg());
-    fTrackDEdxVsP->Fill(track->P(), track->GetdEdx());
-
-    fData->fPt[i] = track->Pt();
-    fData->fEta[i] = track->Eta();
-    fData->fPhi[i] = track->Phi() * TMath::RadToDeg();
-  }
+  Int_t nTracks = 0;
+  for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
+    AliESDtrack* track = esd->GetTrack(i);
+    if (!track || ((track->GetStatus() | AliESDtrack::kTPCin) == 0)) continue;
+    nTracks++;
+
+    Double_t pxyz[3];
+    track->GetInnerPxPyPz(pxyz);
+    TVector3 pTrack(pxyz);
+    Double_t p = pTrack.Mag();
+    Double_t pt = pTrack.Pt();
+    Double_t eta = pTrack.Eta();
+    Double_t phi = pTrack.Phi() * TMath::RadToDeg();
+
+    fTrackPt->Fill(pt);
+    fTrackEta->Fill(eta);
+    fTrackPhi->Fill(phi);
+    if (pt > 3.) {
+      fTrackEtaVsPhi->Fill(eta, phi);
+      fPtEtaVsPhi->Fill(eta, phi, pTrack.Pt());
+    }
+    fTrackNCl->Fill(track->GetTPCclusters(NULL));
+    fTrackDEdxVsP->Fill(p, track->GetTPCsignal());
+    if(p>0.4 && p<1.0)
+      fTrackDEdx->Fill(track->GetTPCsignal());
 
-  delete track;
-  tpcLoader->UnloadTracks();
+    fData->SetData(i, pt, eta, phi); 
+  }
+  fNTracks->Fill(nTracks);
+  fData->SetNTracks(nTracks);
 }