histos added, HLT cuts updated (C.Cheshkov)
[u/mrichter/AliRoot.git] / MONITOR / AliMonitorTPC.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  This class creates and fills the monitor histograms for the TPC          //
21 //                                                                           //
22 ///////////////////////////////////////////////////////////////////////////////
23
24
25 #include "AliMonitorTPC.h"
26 #include "AliMonitorDataTPC.h"
27 #include "AliMonitorHisto.h"
28 #include "AliMonitorTrend.h"
29 #include "AliTPCParam.h"
30 #include "AliTPCRawStream.h"
31 #include "AliTPCClustersRow.h"
32 #include "AliTPCclusterMI.h"
33 #include "AliTPCtrack.h"
34 #include "AliRunLoader.h"
35 #include <TFolder.h>
36 #include <TTree.h>
37
38
39 ClassImp(AliMonitorTPC) 
40
41
42 //_____________________________________________________________________________
43 AliMonitorTPC::AliMonitorTPC(AliTPCParam* param)
44 {
45 // create a TPC monitor object with the given parameters
46
47   fParam = param;
48   fData = new AliMonitorDataTPC(10000);
49 }
50
51 //_____________________________________________________________________________
52 AliMonitorTPC::AliMonitorTPC(const AliMonitorTPC& monitor) :
53   AliMonitor(monitor)
54 {
55   Fatal("AliMonitorTPC", "copy constructor not implemented");
56 }
57
58 //_____________________________________________________________________________
59 AliMonitorTPC& AliMonitorTPC::operator = (const AliMonitorTPC& /*monitor*/)
60 {
61   Fatal("operator =", "assignment operator not implemented");
62   return *this;
63 }
64
65 //_____________________________________________________________________________
66 AliMonitorTPC::~AliMonitorTPC()
67 {
68   delete fData;
69 }
70
71
72 //_____________________________________________________________________________
73 void AliMonitorTPC::CreateHistos(TFolder* folder)
74 {
75 // create the TPC monitor histograms
76
77   fFolder = folder->AddFolder("TPC", "TPC");
78
79   fPadsCharge = CreateHisto1("PadsCharge", "charge distribution of pads", 
80                              100, 0, 200, "charge", "#Delta N/N",
81                              AliMonitorHisto::kNormEvents);
82
83   fClustersCharge = CreateHisto1("ClustersCharge", 
84                                  "charge distribution of clusters", 
85                                  100, 0, 1000, "charge", "#Delta N/N",
86                                  AliMonitorHisto::kNormEvents);
87
88   Int_t nRows = fParam->GetNRowLow() + fParam->GetNRowUp();
89   fNClustersVsRow = CreateHisto1("NClustersVsRow", 
90                                  "mean number of clusters per pad row", 
91                                  nRows, -0.5, nRows-0.5,
92                                  "pad row", "<N_{clusters}>",
93                                  AliMonitorHisto::kNormEvents);
94
95   Int_t nSector = fParam->GetNInnerSector();
96   fNClustersVsSector = CreateHisto1("NClustersVsSector", 
97                                     "mean number of clusters per sector", 
98                                     nSector, -0.5, nSector-0.5, 
99                                     "sector", "<N_{clusters}>",
100                                     AliMonitorHisto::kNormEvents);
101
102   fNTracks = CreateTrend("NTracks", "number of tracks per event", 
103                          "N_{tracks}");
104
105   fTrackPt = CreateHisto1("TrackPt", "pt distribution of tracks", 
106                           90, 0, 3, "p_{t} [GeV/c]", "#Delta N/N",
107                           AliMonitorHisto::kNormNone);
108
109   fTrackEta = CreateHisto1("TrackEta", "eta distribution of tracks", 
110                            100, -2, 2, "#eta", "#Delta N/N",
111                            AliMonitorHisto::kNormEntries);
112
113   fTrackPhi = CreateHisto1("TrackPhi", "phi distribution of tracks", 
114                            120, 0, 360, "#phi [#circ]", "#Delta N/N",
115                            AliMonitorHisto::kNormEntries);
116   fTrackPhi->SetDescription("The phi distribution should be flat on average.\nIf it is not flat check for dead TPC sectors.");
117
118   fTrackNCl = CreateHisto1("TrackNCl", "Number of clusters per track", 
119                            200, 0, 200, "N_{clusters}", "#Delta N/N",
120                            AliMonitorHisto::kNormNone);
121
122   fTrackDEdxVsP = CreateHisto2("TrackDEdxVsP", "dE/dx of tracks", 
123                                100, 0, 3, 100, 0, 200, 
124                                "p [GeV/c]", "dE/dx", "#Delta N/N",
125                                AliMonitorHisto::kNormEntries);
126
127   fTrackDEdx = CreateHisto1("TrackDEdx", "dE/dx of tracks with 0.4<p<1.0 GeV/c", 
128                                50, 0, 100, 
129                                "dE/dx", "#Delta N/N",
130                                AliMonitorHisto::kNormEntries);
131
132   fTrackEtaVsPhi = CreateHisto2("TrackEtaVsPhi", "#phi vs #eta", 
133                                20, -1, 1, 25, 0, 360, 
134                                "#eta", "#phi", "#Delta N/N",
135                                AliMonitorHisto::kNormNone);
136
137   fPtEtaVsPhi = CreateHisto2("PtEtaVsPhi", "#phi vs #eta", 
138                                20, -1, 1, 25, 0, 360, 
139                                "#eta", "#phi", "#Delta N/N",
140                                AliMonitorHisto::kNormNone);
141
142 }
143
144
145 //_____________________________________________________________________________
146 void AliMonitorTPC::CreateBranches(TTree* tree)
147 {
148 // create a branch with TPC variables
149
150   tree->Branch("TPC", "AliMonitorDataTPC", &fData);
151 }
152
153
154 //_____________________________________________________________________________
155 void AliMonitorTPC::FillHistos(AliRunLoader* runLoader, 
156                                AliRawReader* rawReader)
157 {
158 // fill the TPC monitor histogrms
159
160   rawReader->Reset();
161   AliTPCRawStream input(rawReader);
162   while (input.Next()) {
163     fPadsCharge->Fill(input.GetSignal());
164   }
165
166   AliLoader* tpcLoader = runLoader->GetLoader("TPCLoader");
167   if (!tpcLoader) return;
168
169
170   tpcLoader->LoadRecPoints();
171   TTree* clusters = tpcLoader->TreeR();
172   if (!clusters) return;
173   AliTPCClustersRow* clustersRow = new AliTPCClustersRow;
174   clustersRow->SetClass("AliTPCclusterMI");
175   clusters->SetBranchAddress("Segment", &clustersRow);
176
177   for (Int_t i = 0; i < clusters->GetEntries(); i++) {
178     clusters->GetEntry(i);
179     Int_t iSector, iRow;
180     fParam->AdjustSectorRow(clustersRow->GetID(), iSector, iRow);
181     if (iSector >= fParam->GetNInnerSector()) {
182       iRow += fParam->GetNRowLow();
183       iSector -= fParam->GetNInnerSector();
184     }
185
186     TObjArray* array = clustersRow->GetArray();
187     for (Int_t j = 0; j < array->GetEntriesFast(); j++) {
188       AliTPCclusterMI* cluster = (AliTPCclusterMI*) array->At(j);
189       fClustersCharge->Fill(cluster->GetQ());
190       fNClustersVsRow->Fill(iRow);
191       fNClustersVsSector->Fill(iSector);
192     }
193   }
194   fNClustersVsSector->ScaleErrorBy(10.);
195
196   delete clustersRow;
197   tpcLoader->UnloadRecPoints();
198
199
200   tpcLoader->LoadTracks();
201   TTree* tracks = tpcLoader->TreeT();
202   if (!tracks) return;
203   AliTPCtrack* track = new AliTPCtrack;
204   tracks->SetBranchAddress("tracks", &track);
205
206   Int_t nTracks = (Int_t) tracks->GetEntries();
207   fNTracks->Fill(nTracks);
208   fData->SetNTracks(nTracks);
209   for (Int_t i = 0; i < nTracks; i++) {
210     tracks->GetEntry(i);
211     fTrackPt->Fill(track->Pt());
212     fTrackEta->Fill(track->Eta());
213     fTrackPhi->Fill(track->Phi() * TMath::RadToDeg());
214     if(track->Pt()>3.) {
215       fTrackEtaVsPhi->Fill(track->Eta(),track->Phi() * TMath::RadToDeg());
216       fPtEtaVsPhi->Fill(track->Eta(),track->Phi() * TMath::RadToDeg(),track->Pt());
217     }
218     fTrackNCl->Fill(track->GetNumberOfClusters());
219     fTrackDEdxVsP->Fill(track->P(), track->GetdEdx());
220     if(track->P()>0.4 && track->P()<1.0)
221       fTrackDEdx->Fill(track->GetdEdx());
222
223     fData->SetData(i, track->Pt(), track->Eta(), 
224                    track->Phi() * TMath::RadToDeg());
225   }
226
227   delete track;
228   tpcLoader->UnloadTracks();
229 }