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