]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MONITOR/AliMonitorHLTHough.cxx
Full Hough->deconvolution->fit chain implemented (C.Cheshkov)
[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 {
134 // fill the HLT Hough transform monitor histograms
135
136 #ifndef ALI_HLT
137   Warning("FillHistos", "the code was compiled without HLT support");
138
139 #else
140   AliL3MemHandler clusterHandler[36][6];
141   AliL3SpacePointData *clusters[36][6];
142   for (Int_t iSector = 0; iSector < fParam->GetNInnerSector(); iSector++) {
143     for (Int_t iPatch = 0; iPatch < 6; iPatch++) {
144       char fileName[256];
145       sprintf(fileName, "hlt/fitter/points_%d_%d.raw", iSector,iPatch);
146       if (!clusterHandler[iSector][iPatch].SetBinaryInput(fileName)) {
147         Warning("FillHistos", "could not open file %s", fileName);
148         continue;
149       }
150       clusters[iSector][iPatch] = (AliL3SpacePointData*) clusterHandler[iSector][iPatch].Allocate();
151       UInt_t nClusters = 0;
152       clusterHandler[iSector][iPatch].Binary2Memory(nClusters, clusters[iSector][iPatch]);
153
154       for (UInt_t iCluster = 0; iCluster < nClusters; iCluster++) {
155         AliL3SpacePointData& cluster = clusters[iSector][iPatch][iCluster];
156         fClustersCharge->Fill(cluster.fCharge);
157         fNClustersVsRow->Fill(cluster.fPadRow);
158         fNClustersVsSector->Fill(iSector);
159       }
160
161       clusterHandler[iSector][iPatch].CloseBinaryInput();
162     }
163   }
164
165   fNClustersVsSector->ScaleErrorBy(10.);
166
167
168   AliL3MemHandler memHandler;
169   Int_t nHoughTracks = 0;
170
171   char fileName[256];
172   sprintf(fileName, "hlt/fitter/tracks.raw");
173   if (!memHandler.SetBinaryInput(fileName)) {
174     Warning("FillHistos", "could not open file hlt/fitter/tracks.raw");
175     return;
176   }
177   AliL3TrackArray* tracks = new AliL3TrackArray;
178   memHandler.Binary2TrackArray(tracks);
179
180   nHoughTracks += tracks->GetNTracks();
181   for (Int_t iTrack = 0; iTrack < tracks->GetNTracks(); iTrack++) {
182     AliL3HoughTrack *track = (AliL3HoughTrack*)tracks->GetCheckedTrack(iTrack);
183     if(!track) continue;
184
185     track->CalculateHelix();
186     //  track->Rotate(iSector);
187
188     fTrackPt->Fill(track->GetPt());
189     fTrackEta->Fill(track->GetPseudoRapidity());
190     fTrackPhi->Fill(track->GetPsi() * TMath::RadToDeg());
191     if(track->GetPt()>3.) {
192       fTrackEtaVsPhi->Fill(track->GetPseudoRapidity(),track->GetPsi() * TMath::RadToDeg());
193       fPtEtaVsPhi->Fill(track->GetPseudoRapidity(),track->GetPsi() * TMath::RadToDeg(),track->GetPt());
194     }
195     fTrackNHits->Fill(track->GetNHits());
196
197     // Track dEdx
198     Int_t nc=track->GetNHits();
199     UInt_t *hits = track->GetHitNumbers();
200     Float_t sampleDEdx[159];
201     for (Int_t iHit = 0; iHit < nc; iHit++) {
202       UInt_t hitID = hits[iHit];
203       Int_t iSector = (hitID>>25) & 0x7f;
204       Int_t iPatch = (hitID>>22) & 0x7;
205       UInt_t position = hitID&0x3fffff;
206       UChar_t padrow = clusters[iSector][iPatch][position].fPadRow;
207       Float_t pWidth = AliL3Transform::GetPadPitchWidthLow();
208       if (padrow>63)
209         pWidth = AliL3Transform::GetPadPitchWidthUp(); 
210       Float_t corr=1.; if (padrow>63) corr=0.67;
211       sampleDEdx[iHit] = clusters[iSector][iPatch][position].fCharge/pWidth*corr;
212       Double_t crossingangle = track->GetCrossingAngle(padrow,iSector);
213       Double_t s = sin(crossingangle);
214       Double_t t = track->GetTgl();
215       sampleDEdx[iHit] *= TMath::Sqrt((1-s*s)/(1+t*t));
216     }
217
218     /* Cook dEdx */
219     Int_t i;
220     Int_t swap;//stupid sorting
221     do {
222       swap=0;
223       for (i=0; i<nc-1; i++) {
224         if (sampleDEdx[i]<=sampleDEdx[i+1]) continue;
225         Float_t tmp=sampleDEdx[i];
226         sampleDEdx[i]=sampleDEdx[i+1]; sampleDEdx[i+1]=tmp;
227         swap++;
228       }
229     } while (swap);
230
231     Double_t low=0.05; Double_t up=0.7;
232     Int_t nl=Int_t(low*nc), nu=Int_t(up*nc);
233     Float_t trackDEdx=0;
234     for (i=nl; i<=nu; i++) trackDEdx += sampleDEdx[i];
235     trackDEdx /= (nu-nl+1);
236
237     fTrackDEdxVsP->Fill(track->GetP(),trackDEdx);
238     if(track->GetP()>0.4 && track->GetP()<1.0)
239       fTrackDEdx->Fill(trackDEdx);
240   }
241   fNTracks->Fill(nHoughTracks);
242
243   delete tracks;
244   memHandler.CloseBinaryInput();
245
246 #endif
247 }