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