]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MONITOR/AliMonitorHLTHough.cxx
use ESD based tracking methods
[u/mrichter/AliRoot.git] / MONITOR / AliMonitorHLTHough.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
17 ///////////////////////////////////////////////////////////////////////////////
18 //                                                                           //
19 // This class creates and fills monitor histograms for HLT Hough transform   //
20 //                                                                           //
21 ///////////////////////////////////////////////////////////////////////////////
22
23
24 #include "AliMonitorHLTHough.h"
25 #include "AliMonitorHisto.h"
26 #include "AliMonitorTrend.h"
27 #include "AliTPCParam.h"
28 #include <TFolder.h>
29 #ifdef ALI_HLT
30 #include <stdlib.h>
31 #include <AliL3MemHandler.h>
32 #include <AliL3TrackArray.h>
33 #include <AliL3SpacePointData.h>
34 #include <AliL3HoughTrack.h>
35 #include <AliL3Transform.h>
36 #endif
37
38 //_____________________________________________________________________________
39 AliMonitorHLTHough::AliMonitorHLTHough(AliTPCParam* param)
40 {
41 // create a HLT monitor object with the given parameters
42
43   fParam = param;
44 }
45
46 //_____________________________________________________________________________
47 AliMonitorHLTHough::AliMonitorHLTHough(const AliMonitorHLTHough& monitor) :
48   AliMonitor(monitor)
49 {
50   Fatal("AliMonitorHLTHough", "copy constructor not implemented");
51 }
52
53 //_____________________________________________________________________________
54 AliMonitorHLTHough& AliMonitorHLTHough::operator = (const AliMonitorHLTHough& 
55                                                     /*monitor*/)
56 {
57   Fatal("operator =", "assignment operator not implemented");
58   return *this;
59 }
60
61
62 //_____________________________________________________________________________
63 void AliMonitorHLTHough::CreateHistos(TFolder* folder)
64 {
65 // create the HLT Hough transform monitor histograms
66
67   fFolder = folder->AddFolder("HLTHOUGH", "HLTHOUGH");
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",
93                           AliMonitorHisto::kNormNone);
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);
102
103   fTrackNHits = CreateHisto1("TrackNHits", "Number of hits per track", 
104                            200, 0, 200, "N_{hits}", "#Delta N/N",
105                            AliMonitorHisto::kNormNone);
106
107   fTrackDEdxVsP = CreateHisto2("TrackDEdxVsP", "dE/dx of tracks", 
108                                100, 0, 3, 100, 0, 1000, 
109                                "p [GeV/c]", "dE/dx", "#Delta N/N",
110                                AliMonitorHisto::kNormEntries);
111
112   fTrackDEdx = CreateHisto1("TrackDEdx", "dE/dx for tracks with 0.4<p<1.0 GeV/c", 
113                                50, 0, 300, 
114                                "dE/dx", "#Delta N/N",
115                                AliMonitorHisto::kNormEntries);
116
117   fTrackEtaVsPhi = CreateHisto2("TrackEtaVsPhi", "#phi vs #eta", 
118                                20, -1, 1, 25, 0, 360, 
119                                "#eta", "#phi", "#Delta N/N",
120                                AliMonitorHisto::kNormNone);
121
122   fPtEtaVsPhi = CreateHisto2("PtEtaVsPhi", "#phi vs #eta", 
123                                20, -1, 1, 25, 0, 360, 
124                                "#eta", "#phi", "#Delta N/N",
125                                AliMonitorHisto::kNormNone);
126
127 }
128
129
130 //_____________________________________________________________________________
131 void AliMonitorHLTHough::FillHistos(AliRunLoader* /*runLoader*/, 
132                                     AliRawReader* /*rawReader*/, 
133                                     AliESD* /*esd*/)
134 {
135 // fill the HLT Hough transform monitor histograms
136
137 #ifndef ALI_HLT
138   Warning("FillHistos", "the code was compiled without HLT support");
139
140 #else
141   AliL3MemHandler clusterHandler[36][6];
142   AliL3SpacePointData *clusters[36][6];
143   for (Int_t iSector = 0; iSector < fParam->GetNInnerSector(); iSector++) {
144     for (Int_t iPatch = 0; iPatch < 6; iPatch++) {
145       char fileName[256];
146       sprintf(fileName, "hlt/fitter/points_%d_%d.raw", iSector,iPatch);
147       if (!clusterHandler[iSector][iPatch].SetBinaryInput(fileName)) {
148         Warning("FillHistos", "could not open file %s", fileName);
149         continue;
150       }
151       clusters[iSector][iPatch] = (AliL3SpacePointData*) clusterHandler[iSector][iPatch].Allocate();
152       UInt_t nClusters = 0;
153       clusterHandler[iSector][iPatch].Binary2Memory(nClusters, clusters[iSector][iPatch]);
154
155       for (UInt_t iCluster = 0; iCluster < nClusters; iCluster++) {
156         AliL3SpacePointData& cluster = clusters[iSector][iPatch][iCluster];
157         fClustersCharge->Fill(cluster.fCharge);
158         fNClustersVsRow->Fill(cluster.fPadRow);
159         fNClustersVsSector->Fill(iSector);
160       }
161
162       clusterHandler[iSector][iPatch].CloseBinaryInput();
163     }
164   }
165
166   fNClustersVsSector->ScaleErrorBy(10.);
167
168
169   AliL3MemHandler memHandler;
170   Int_t nHoughTracks = 0;
171
172   char fileName[256];
173   sprintf(fileName, "hlt/fitter/tracks.raw");
174   if (!memHandler.SetBinaryInput(fileName)) {
175     Warning("FillHistos", "could not open file hlt/fitter/tracks.raw");
176     return;
177   }
178   AliL3TrackArray* tracks = new AliL3TrackArray;
179   memHandler.Binary2TrackArray(tracks);
180
181   nHoughTracks += tracks->GetNTracks();
182   for (Int_t iTrack = 0; iTrack < tracks->GetNTracks(); iTrack++) {
183     AliL3HoughTrack *track = (AliL3HoughTrack*)tracks->GetCheckedTrack(iTrack);
184     if(!track) continue;
185
186     track->CalculateHelix();
187     //  track->Rotate(iSector);
188
189     fTrackPt->Fill(track->GetPt());
190     fTrackEta->Fill(track->GetPseudoRapidity());
191     fTrackPhi->Fill(track->GetPsi() * TMath::RadToDeg());
192     if(track->GetPt()>3.) {
193       fTrackEtaVsPhi->Fill(track->GetPseudoRapidity(),track->GetPsi() * TMath::RadToDeg());
194       fPtEtaVsPhi->Fill(track->GetPseudoRapidity(),track->GetPsi() * TMath::RadToDeg(),track->GetPt());
195     }
196     fTrackNHits->Fill(track->GetNHits());
197
198     // Track dEdx
199     Int_t nc=track->GetNHits();
200     UInt_t *hits = track->GetHitNumbers();
201     Float_t sampleDEdx[159];
202     for (Int_t iHit = 0; iHit < nc; iHit++) {
203       UInt_t hitID = hits[iHit];
204       Int_t iSector = (hitID>>25) & 0x7f;
205       Int_t iPatch = (hitID>>22) & 0x7;
206       UInt_t position = hitID&0x3fffff;
207       UChar_t padrow = clusters[iSector][iPatch][position].fPadRow;
208       Float_t pWidth = AliL3Transform::GetPadPitchWidthLow();
209       if (padrow>63)
210         pWidth = AliL3Transform::GetPadPitchWidthUp(); 
211       Float_t corr=1.; if (padrow>63) corr=0.67;
212       sampleDEdx[iHit] = clusters[iSector][iPatch][position].fCharge/pWidth*corr;
213       Double_t crossingangle = track->GetCrossingAngle(padrow,iSector);
214       Double_t s = sin(crossingangle);
215       Double_t t = track->GetTgl();
216       sampleDEdx[iHit] *= TMath::Sqrt((1-s*s)/(1+t*t));
217     }
218
219     /* Cook dEdx */
220     Int_t i;
221     Int_t swap;//stupid sorting
222     do {
223       swap=0;
224       for (i=0; i<nc-1; i++) {
225         if (sampleDEdx[i]<=sampleDEdx[i+1]) continue;
226         Float_t tmp=sampleDEdx[i];
227         sampleDEdx[i]=sampleDEdx[i+1]; sampleDEdx[i+1]=tmp;
228         swap++;
229       }
230     } while (swap);
231
232     Double_t low=0.05; Double_t up=0.7;
233     Int_t nl=Int_t(low*nc), nu=Int_t(up*nc);
234     Float_t trackDEdx=0;
235     for (i=nl; i<=nu; i++) trackDEdx += sampleDEdx[i];
236     trackDEdx /= (nu-nl+1);
237
238     fTrackDEdxVsP->Fill(track->GetP(),trackDEdx);
239     if(track->GetP()>0.4 && track->GetP()<1.0)
240       fTrackDEdx->Fill(trackDEdx);
241   }
242   fNTracks->Fill(nHoughTracks);
243
244   delete tracks;
245   memHandler.CloseBinaryInput();
246
247 #endif
248 }