Reverted direct flow parameters
[u/mrichter/AliRoot.git] / MONITOR / AliMonitorHLT.cxx
CommitLineData
97d6eb66 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 HLT //
21// //
22///////////////////////////////////////////////////////////////////////////////
23
24
25#include "AliMonitorHLT.h"
c4bd737c 26#include "AliMonitorTrend.h"
27#include "AliTPCParam.h"
7ba8900c 28#include "AliLog.h"
c4bd737c 29#include <TFolder.h>
97d6eb66 30#include <stdlib.h>
31#include "AliL3MemHandler.h"
32#include "AliL3SpacePointData.h"
33#include "AliL3TrackArray.h"
34#include "AliL3Track.h"
db9d2b7f 35#include "AliL3Transform.h"
524a85e8 36#include "AliL3Vertex.h"
97d6eb66 37
38//_____________________________________________________________________________
39AliMonitorHLT::AliMonitorHLT(AliTPCParam* param)
40{
41// create a HLT monitor object with the given parameters
42
43 fParam = param;
44}
45
46//_____________________________________________________________________________
c4bd737c 47AliMonitorHLT::AliMonitorHLT(const AliMonitorHLT& monitor) :
48 AliMonitor(monitor)
97d6eb66 49{
7ba8900c 50 AliFatal("copy constructor not implemented");
c4bd737c 51}
52
53//_____________________________________________________________________________
54AliMonitorHLT& AliMonitorHLT::operator = (const AliMonitorHLT& /*monitor*/)
55{
7ba8900c 56 AliFatal("assignment operator not implemented");
c4bd737c 57 return *this;
97d6eb66 58}
59
60
61//_____________________________________________________________________________
62void AliMonitorHLT::CreateHistos(TFolder* folder)
63{
64// create the HLT monitor histograms
65
66 fFolder = folder->AddFolder("HLT", "HLT");
67
68 fClustersCharge = CreateHisto1("ClustersCharge",
69 "charge distribution of clusters",
70 100, 0, 1000, "charge", "#Delta N/N",
71 AliMonitorHisto::kNormEvents);
72
73 Int_t nRows = fParam->GetNRowLow() + fParam->GetNRowUp();
74 fNClustersVsRow = CreateHisto1("NClustersVsRow",
75 "mean number of clusters per pad row",
76 nRows, -0.5, nRows-0.5,
77 "pad row", "<N_{clusters}>",
78 AliMonitorHisto::kNormEvents);
79
80 Int_t nSector = fParam->GetNInnerSector();
81 fNClustersVsSector = CreateHisto1("NClustersVsSector",
82 "mean number of clusters per sector",
83 nSector, -0.5, nSector-0.5,
84 "sector", "<N_{clusters}>",
85 AliMonitorHisto::kNormEvents);
86
87 fNTracks = CreateTrend("NTracks", "number of tracks per event",
88 "N_{tracks}");
89
90 fTrackPt = CreateHisto1("TrackPt", "pt distribution of tracks",
91 90, 0, 3, "p_{t} [GeV/c]", "#Delta N/N",
524a85e8 92 AliMonitorHisto::kNormNone);
97d6eb66 93
94 fTrackEta = CreateHisto1("TrackEta", "eta distribution of tracks",
95 100, -2, 2, "#eta", "#Delta N/N",
96 AliMonitorHisto::kNormEntries);
97
98 fTrackPhi = CreateHisto1("TrackPhi", "phi distribution of tracks",
99 120, 0, 360, "#phi [#circ]", "#Delta N/N",
100 AliMonitorHisto::kNormEntries);
db9d2b7f 101
102 fTrackNHits = CreateHisto1("TrackNHits", "Number of hits per track",
103 200, 0, 200, "N_{hits}", "#Delta N/N",
524a85e8 104 AliMonitorHisto::kNormNone);
105
106 fTrackXYvsNHits = CreateHisto2("TrackXYvsNHits", "XY vs Number of hits per track",
107 50, 0, 200,50,0,10,
108 "N_{hits}","Radius [cm]","#Delta N/N",
109 AliMonitorHisto::kNormNone);
110
111 fTrackZvsNHits = CreateHisto2("TrackZvsNHits", "Z vs Number of hits per track",
112 50, 0, 200,50,-20,20,
113 "N_{hits}","Z [cm]","#Delta N/N",
114 AliMonitorHisto::kNormNone);
db9d2b7f 115
116 fTrackDEdxVsP = CreateHisto2("TrackDEdxVsP", "dE/dx of tracks",
117 100, 0, 3, 100, 0, 1000,
118 "p [GeV/c]", "dE/dx", "#Delta N/N",
119 AliMonitorHisto::kNormEntries);
120
524a85e8 121 fTrackDEdx = CreateHisto1("TrackDEdx", "dE/dx for tracks with 0.4<p<1.0 GeV/c",
122 50, 0, 300,
123 "dE/dx", "#Delta N/N",
124 AliMonitorHisto::kNormEntries);
125
db9d2b7f 126 fTrackDz0 = CreateHisto1("TrackDz0", "Dz0 of tracks",
127 100, -100, 100, "#Delta z0 [cm]", "#Delta N/N",
128 AliMonitorHisto::kNormEntries);
129
130 fTrackDr0 = CreateHisto1("TrackDr0", "Dr0 of tracks",
131 130, 80, 250, "#Delta r0 [cm]", "#Delta N/N",
132 AliMonitorHisto::kNormEntries);
133
524a85e8 134 fTrackEtaVsPhi = CreateHisto2("TrackEtaVsPhi", "#phi vs #eta",
135 20, -1, 1, 25, 0, 360,
136 "#eta", "#phi", "#Delta N/N",
137 AliMonitorHisto::kNormNone);
138
139 fPtEtaVsPhi = CreateHisto2("PtEtaVsPhi", "#phi vs #eta",
140 20, -1, 1, 25, 0, 360,
141 "#eta", "#phi", "#Delta N/N",
142 AliMonitorHisto::kNormNone);
db9d2b7f 143
97d6eb66 144}
145
146
97d6eb66 147//_____________________________________________________________________________
148void AliMonitorHLT::FillHistos(AliRunLoader* /*runLoader*/,
b6a3610d 149 AliRawReader* /*rawReader*/, AliESD* /*esd*/)
97d6eb66 150{
151// fill the HLT monitor histogrms
152
db9d2b7f 153 AliL3MemHandler clusterHandler[36];
154 AliL3SpacePointData *clusters[36];
97d6eb66 155 for (Int_t iSector = 0; iSector < fParam->GetNInnerSector(); iSector++) {
156 char fileName[256];
157 sprintf(fileName, "hlt/points_%d_-1.raw", iSector);
db9d2b7f 158 if (!clusterHandler[iSector].SetBinaryInput(fileName)) {
7ba8900c 159 AliWarning(Form("could not open file %s", fileName));
97d6eb66 160 continue;
161 }
db9d2b7f 162 clusters[iSector] = (AliL3SpacePointData*) clusterHandler[iSector].Allocate();
97d6eb66 163 UInt_t nClusters = 0;
db9d2b7f 164 clusterHandler[iSector].Binary2Memory(nClusters, clusters[iSector]);
97d6eb66 165
166 for (UInt_t iCluster = 0; iCluster < nClusters; iCluster++) {
db9d2b7f 167 AliL3SpacePointData& cluster = clusters[iSector][iCluster];
97d6eb66 168 fClustersCharge->Fill(cluster.fCharge);
169 fNClustersVsRow->Fill(cluster.fPadRow);
170 fNClustersVsSector->Fill(iSector);
171 }
172
db9d2b7f 173 clusterHandler[iSector].CloseBinaryInput();
97d6eb66 174 }
175
176 fNClustersVsSector->ScaleErrorBy(10.);
177
db9d2b7f 178 AliL3MemHandler memHandler;
97d6eb66 179 if (!memHandler.SetBinaryInput("hlt/tracks.raw")) {
7ba8900c 180 AliWarning("could not open file hlt/tracks.raw");
97d6eb66 181 return;
182 }
183 AliL3TrackArray* tracks = new AliL3TrackArray;
184 memHandler.Binary2TrackArray(tracks);
524a85e8 185 Double_t xc,yc,zc;
186 AliL3Vertex vertex;
97d6eb66 187
188 fNTracks->Fill(tracks->GetNTracks());
189 for (Int_t iTrack = 0; iTrack < tracks->GetNTracks(); iTrack++) {
db9d2b7f 190 AliL3Track* track = tracks->GetCheckedTrack(iTrack);
191 if(!track) continue;
192 track->CalculateHelix();
524a85e8 193 track->GetClosestPoint(&vertex,xc,yc,zc);
0f87abda 194 if(TMath::Abs(zc)>10.) continue;
97d6eb66 195 fTrackPt->Fill(track->GetPt());
196 fTrackEta->Fill(track->GetPseudoRapidity());
197 fTrackPhi->Fill(track->GetPsi() * TMath::RadToDeg());
524a85e8 198 if(track->GetPt()>3.) {
199 fTrackEtaVsPhi->Fill(track->GetPseudoRapidity(),track->GetPsi() * TMath::RadToDeg());
200 fPtEtaVsPhi->Fill(track->GetPseudoRapidity(),track->GetPsi() * TMath::RadToDeg(),track->GetPt());
201 }
db9d2b7f 202 fTrackDz0->Fill(track->GetZ0());
203 fTrackDr0->Fill(track->GetR0());
204 fTrackNHits->Fill(track->GetNHits());
524a85e8 205 fTrackXYvsNHits->Fill(track->GetNHits(),TMath::Sqrt(xc*xc+yc*yc));
206 fTrackZvsNHits->Fill(track->GetNHits(),zc);
db9d2b7f 207
208 // Track dEdx
209 Int_t nc=track->GetNHits();
210 UInt_t *hits = track->GetHitNumbers();
211 Float_t sampleDEdx[159];
212 for (Int_t iHit = 0; iHit < nc; iHit++) {
213 UInt_t hitID = hits[iHit];
214 Int_t iSector = (hitID>>25) & 0x7f;
215 UInt_t position = hitID&0x3fffff;
216 UChar_t padrow = clusters[iSector][position].fPadRow;
217 Float_t pWidth = AliL3Transform::GetPadPitchWidthLow();
218 if (padrow>63)
219 pWidth = AliL3Transform::GetPadPitchWidthUp();
220 Float_t corr=1.; if (padrow>63) corr=0.67;
221 sampleDEdx[iHit] = clusters[iSector][position].fCharge/pWidth*corr;
222 Double_t crossingangle = track->GetCrossingAngle(padrow,iSector);
db9d2b7f 223 Double_t s = sin(crossingangle);
224 Double_t t = track->GetTgl();
225 sampleDEdx[iHit] *= TMath::Sqrt((1-s*s)/(1+t*t));
226 }
227
228 /* Cook dEdx */
229 Int_t i;
230 Int_t swap;//stupid sorting
231 do {
232 swap=0;
233 for (i=0; i<nc-1; i++) {
234 if (sampleDEdx[i]<=sampleDEdx[i+1]) continue;
235 Float_t tmp=sampleDEdx[i];
236 sampleDEdx[i]=sampleDEdx[i+1]; sampleDEdx[i+1]=tmp;
237 swap++;
238 }
239 } while (swap);
240
241 Double_t low=0.05; Double_t up=0.7;
242 Int_t nl=Int_t(low*nc), nu=Int_t(up*nc);
243 Float_t trackDEdx=0;
244 for (i=nl; i<=nu; i++) trackDEdx += sampleDEdx[i];
245 trackDEdx /= (nu-nl+1);
246
247 fTrackDEdxVsP->Fill(track->GetP(),trackDEdx);
524a85e8 248 if(track->GetP()>0.4 && track->GetP()<1.0)
249 fTrackDEdx->Fill(trackDEdx);
97d6eb66 250 }
251
252 delete tracks;
253 memHandler.CloseBinaryInput();
97d6eb66 254}