Protection against wrong trigger bc mask pattern
[u/mrichter/AliRoot.git] / MONITOR / AliMonitorITS.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 ITS          //
21 //                                                                           //
22 ///////////////////////////////////////////////////////////////////////////////
23
24 #include <TFolder.h>
25 #include <TTree.h>
26 #include <TVector3.h>
27
28 #include "AliLog.h"
29 #include "AliESDEvent.h"
30 #include "AliESDtrack.h"
31 #include "AliITSRawStreamSDD.h"
32 #include "AliITSRawStreamSSD.h"
33 #include "AliITSclusterV2.h"
34 #include "AliITSgeom.h"
35 #include "AliMonitorHisto.h"
36 #include "AliMonitorITS.h"
37 #include "AliRawReader.h"
38 #include "AliRunLoader.h"
39
40 ClassImp(AliMonitorITS) 
41
42
43 //_____________________________________________________________________________
44 AliMonitorITS::AliMonitorITS(AliITSgeom* geom):
45   AliMonitor(),
46   fGeom(geom),
47   fSDDDigitsCharge(NULL),
48   fSSDDigitsCharge(NULL),
49   fSDDClustersCharge(NULL),
50   fSSDClustersCharge(NULL),
51   fSPDNClustersVsModule(NULL),
52   fSDDNClustersVsModule(NULL),
53   fSSDNClustersVsModule(NULL),
54   fNClustersVsLayer(NULL),
55   fNTracks(NULL),
56   fNTracksITSTPC(NULL),
57   fTrackPt(NULL),
58   fTrackEta(NULL),
59   fTrackPhi(NULL),
60   fTrackDEdxVsP(NULL)
61
62 {
63 // create a ITS monitor object with the given geometry
64
65 }
66
67
68 //_____________________________________________________________________________
69 void AliMonitorITS::CreateHistos(TFolder* folder)
70 {
71 // create the ITS monitor histograms
72
73   fFolder = folder->AddFolder("ITS", "ITS");
74
75   fSDDDigitsCharge = CreateHisto1("SDDDigitsCharge", 
76                                   "charge distribution of SDD digits", 
77                                   128, 0, 256, "charge", "#Delta N/N",
78                                   AliMonitorHisto::kNormEvents);
79
80   fSSDDigitsCharge = CreateHisto1("SSDDigitsCharge", 
81                                   "charge distribution of SSD digits", 
82                                   100, 0, 200, "charge", "#Delta N/N",
83                                   AliMonitorHisto::kNormEvents);
84
85   fSDDClustersCharge = CreateHisto1("SDDClustersCharge", 
86                                     "charge distribution of SDD clusters", 
87                                     100, 0, 200, "charge", "#Delta N/N",
88                                     AliMonitorHisto::kNormEvents);
89
90   fSSDClustersCharge = CreateHisto1("SSDClustersCharge", 
91                                     "charge distribution of SSD clusters", 
92                                     100, 0, 400, "charge", "#Delta N/N",
93                                     AliMonitorHisto::kNormEvents);
94
95   Int_t nModulesSPD = fGeom->GetLastSPD() - fGeom->GetStartSPD() + 1;
96   fSPDNClustersVsModule = CreateHisto1("SPDNClustersVsModule", 
97                                        "mean number of clusters per SPD module", 
98                                        nModulesSPD, -0.5, nModulesSPD-0.5,
99                                        "module", "<N_{clusters}>",
100                                        AliMonitorHisto::kNormEvents);
101
102   Int_t nModulesSDD = fGeom->GetLastSDD() - fGeom->GetStartSDD() + 1;
103   fSDDNClustersVsModule = CreateHisto1("SDDNClustersVsModule", 
104                                        "mean number of clusters per SDD module", 
105                                        nModulesSDD, -0.5, nModulesSDD-0.5,
106                                        "module", "<N_{clusters}>",
107                                        AliMonitorHisto::kNormEvents);
108
109   Int_t nModulesSSD = fGeom->GetLastSSD() - fGeom->GetStartSSD() + 1;
110   fSSDNClustersVsModule = CreateHisto1("SSDNClustersVsModule", 
111                                        "mean number of clusters per SSD module", 
112                                        nModulesSSD, -0.5, nModulesSSD-0.5,
113                                        "module", "<N_{clusters}>",
114                                        AliMonitorHisto::kNormEvents);
115
116   Int_t nLayer = fGeom->GetNlayers();
117   fNClustersVsLayer = CreateHisto1("NClustersVsLayer", 
118                                    "mean number of clusters per layer", 
119                                    nLayer, 0.5, nLayer+0.5, 
120                                    "layer", "<N_{clusters}>",
121                                    AliMonitorHisto::kNormEvents);
122
123   fNTracks = CreateHisto1("NTracks", "number of tracks per event", 
124                           300, 0, 30000, "N_{tracks}", "#Delta N/N",
125                           AliMonitorHisto::kNormEvents);
126
127   fNTracksITSTPC = CreateHisto2("NTracksTPCITS", 
128                                 "correlation of number of ITS and TPC tracks per event", 
129                                 30, 0, 30000, 30, 0, 30000, 
130                                 "N_{tracks}(ITS)", "N_{tracks}(TPC)", 
131                                 "#Delta N/N", AliMonitorHisto::kNormEvents);
132
133   fTrackPt = CreateHisto1("TrackPt", "pt distribution of tracks", 
134                           90, 0, 3, "p_{t} [GeV/c]", "#Delta N/N",
135                           AliMonitorHisto::kNormEntries);
136
137   fTrackEta = CreateHisto1("TrackEta", "eta distribution of tracks", 
138                            100, -2, 2, "#eta", "#Delta N/N",
139                            AliMonitorHisto::kNormEntries);
140
141   fTrackPhi = CreateHisto1("TrackPhi", "phi distribution of tracks", 
142                            120, -180, 180, "#phi [#circ]", "#Delta N/N",
143                            AliMonitorHisto::kNormEntries);
144
145   fTrackDEdxVsP = CreateHisto2("TrackDEdxVsP", "dE/dx of tracks", 
146                                100, 0, 3, 100, 0, 150, 
147                                "p [GeV/c]", "dE/dx", "#Delta N/N",
148                                AliMonitorHisto::kNormEntries);
149 }
150
151
152 //_____________________________________________________________________________
153 void AliMonitorITS::FillHistos(AliRunLoader* runLoader, 
154                                AliRawReader* rawReader, AliESDEvent* esd)
155 {
156 // fill the ITS monitor histogrms
157
158   rawReader->Reset();
159   AliITSRawStreamSDD inputSDD(rawReader);
160   while (inputSDD.Next()) {
161     fSDDDigitsCharge->Fill(inputSDD.GetSignal());
162   }
163
164   rawReader->Reset();
165   AliITSRawStreamSSD inputSSD(rawReader);
166   while (inputSSD.Next()) {
167     fSSDDigitsCharge->Fill(inputSSD.GetSignal());
168   }
169
170   AliLoader* itsLoader = runLoader->GetLoader("ITSLoader");
171   if (!itsLoader) return;
172
173
174   itsLoader->LoadRecPoints();
175   TTree* clustersTree = itsLoader->TreeR();
176   if (!clustersTree) return;
177   TClonesArray* clusters = new TClonesArray("AliITSclusterV2");
178   clustersTree->SetBranchAddress("Clusters", &clusters);
179
180   for (Int_t iModule = 0; iModule < clustersTree->GetEntries(); iModule++) {
181     clustersTree->GetEntry(iModule);
182     Int_t iLayer, iLadder, iDetector;
183     fGeom->GetModuleId(iModule, iLayer, iLadder, iDetector);
184
185     for (Int_t j = 0; j < clusters->GetEntriesFast(); j++) {
186       AliITSclusterV2* cluster = (AliITSclusterV2*) clusters->At(j);
187       switch (iLayer) {
188       case 1: case 2: {
189         fSPDNClustersVsModule->Fill(iModule - fGeom->GetStartSPD());
190         break;
191       }
192       case 3: case 4: {
193         fSDDClustersCharge->Fill(cluster->GetQ());
194         fSDDNClustersVsModule->Fill(iModule - fGeom->GetStartSDD());
195         break;
196       }
197       case 5: case 6: {
198         fSSDClustersCharge->Fill(cluster->GetQ());
199         fSSDNClustersVsModule->Fill(iModule - fGeom->GetStartSSD());
200         break;
201       }
202       }
203       fNClustersVsLayer->Fill(iLayer);
204     }
205   }
206
207   delete clusters;
208   itsLoader->UnloadRecPoints();
209
210
211   Int_t nTracks = 0;
212   Int_t nTPCTracks = 0;
213   for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
214     AliESDtrack* track = esd->GetTrack(i);
215     if (!track) continue;
216     if ((track->GetStatus() | AliESDtrack::kTPCin) != 0) nTPCTracks++;
217     if ((track->GetStatus() | AliESDtrack::kITSin) == 0) continue;
218     nTracks++;
219
220     Double_t pxyz[3];
221     track->GetPxPyPz(pxyz);
222     TVector3 pTrack(pxyz);
223     fTrackPt->Fill(pTrack.Pt());
224     fTrackEta->Fill(pTrack.Eta());
225     fTrackPhi->Fill(pTrack.Phi() * TMath::RadToDeg());
226     fTrackDEdxVsP->Fill(pTrack.Mag(), track->GetITSsignal());
227   }
228   fNTracks->Fill(nTracks);
229   fNTracksITSTPC->Fill(nTracks, nTPCTracks);
230 }