]>
Commit | Line | Data |
---|---|---|
dadc7068 | 1 | // $Id$ |
2 | ||
3 | //************************************************************************** | |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Gaute Ovrebekk <ovrebekk@ift.uib.no> * | |
8 | //* for The ALICE HLT Project. * | |
9 | //* * | |
10 | //* Permission to use, copy, modify and distribute this software and its * | |
11 | //* documentation strictly for non-commercial purposes is hereby granted * | |
12 | //* without fee, provided that the above copyright notice appears in all * | |
13 | //* copies and that both the copyright notice and this permission notice * | |
14 | //* appear in the supporting documentation. The authors make no claims * | |
15 | //* about the suitability of this software for any purpose. It is * | |
16 | //* provided "as is" without express or implied warranty. * | |
17 | //************************************************************************** | |
18 | ||
19 | /** @file AliHLTTPCTrackHistoComponent.cxx | |
20 | @author Gaute Ovrebekk, Matthias Richter | |
21 | @date | |
14b31e2b | 22 | @brief A histogram component with track and associated cluster properties |
dadc7068 | 23 | */ |
24 | ||
dadc7068 | 25 | #if __GNUC__>= 3 |
26 | using namespace std; | |
27 | #endif | |
28 | ||
29 | #include "AliHLTTPCTrackHistoComponent.h" | |
30 | #include "AliHLTTPCTransform.h" | |
31 | #include "AliHLTTPCClusterDataFormat.h" | |
32 | #include "AliHLTTPCTrackletDataFormat.h" | |
33 | #include "AliHLTTPCMemHandler.h" | |
34 | #include "AliHLTTPCDefinitions.h" | |
97fdadce | 35 | #include "AliHLTGlobalBarrelTrack.h" |
e2a9091e | 36 | #include "AliHLTExternalTrackParam.h" |
37 | #include "AliHLTDataTypes.h" | |
38 | ||
dadc7068 | 39 | #include <TFile.h> |
40 | #include <TString.h> | |
a267c68e | 41 | #include "TNtuple.h" |
2c95fda7 | 42 | #include "TH1F.h" |
43 | #include "TProfile.h" | |
dadc7068 | 44 | #include "TObjString.h" |
45 | #include "TObjArray.h" | |
46 | ||
dadc7068 | 47 | |
dadc7068 | 48 | /** ROOT macro for the implementation of ROOT specific class methods */ |
49 | ClassImp(AliHLTTPCTrackHistoComponent) | |
50 | ||
51 | AliHLTTPCTrackHistoComponent::AliHLTTPCTrackHistoComponent() | |
97fdadce | 52 | : |
97fdadce | 53 | //, fReset(0) |
14b31e2b | 54 | fNEvents(0) |
97fdadce | 55 | , fNtotTracks(0) |
56 | , fEvtMod(20) | |
57 | , fBufferSize(5000) | |
f53b49dd | 58 | , fdEdx(kFALSE) |
97fdadce | 59 | , fMeanMultiplicity(NULL) |
60 | , fMultiplicity(NULL) | |
14b31e2b | 61 | //, fdNdEta(NULL) |
f53b49dd | 62 | , fDeDxVsP(NULL) |
97fdadce | 63 | , fClusters(NULL) |
64 | , fTracks(NULL) | |
65 | //, fNClusterVsXY(NULL) | |
66 | //, fChargeVsXY(NULL) | |
97fdadce | 67 | //, fClustersArray(NULL) |
68 | //, fNSpacePoints(NULL) | |
dadc7068 | 69 | { |
dadc7068 | 70 | // see header file for class documentation |
71 | // or | |
72 | // refer to README to build package | |
73 | // or | |
74 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
dadc7068 | 75 | } |
76 | ||
97fdadce | 77 | const char* AliHLTTPCTrackHistoComponent::fgkOCDBEntry="HLT/ConfigTPC/TPCTrackHisto"; |
78 | ||
e2a9091e | 79 | AliHLTTPCTrackHistoComponent::~AliHLTTPCTrackHistoComponent(){ |
80 | // see header file for class documentation | |
dadc7068 | 81 | } |
82 | ||
83 | // Public functions to implement AliHLTComponent's interface. | |
84 | // These functions are required for the registration process | |
85 | ||
e2a9091e | 86 | const char* AliHLTTPCTrackHistoComponent::GetComponentID(){ |
87 | // see header file for class documentation | |
dadc7068 | 88 | |
89 | return "TPCTrackHisto"; | |
90 | } | |
91 | ||
e2a9091e | 92 | void AliHLTTPCTrackHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list){ |
93 | // see header file for class documentation | |
97fdadce | 94 | |
dadc7068 | 95 | list.clear(); |
2c95fda7 | 96 | list.push_back(AliHLTTPCDefinitions::fgkClustersDataType|kAliHLTDataOriginTPC); |
e2a9091e | 97 | list.push_back(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); |
97fdadce | 98 | //list.push_back(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC); |
dadc7068 | 99 | } |
100 | ||
e2a9091e | 101 | AliHLTComponentDataType AliHLTTPCTrackHistoComponent::GetOutputDataType(){ |
102 | // see header file for class documentation | |
2c95fda7 | 103 | return kAliHLTMultipleDataType; |
104 | } | |
105 | ||
106 | int AliHLTTPCTrackHistoComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){ | |
107 | // see header file for class documentation | |
108 | tgtList.clear(); | |
109 | tgtList.push_back(kAliHLTDataTypeTNtuple|kAliHLTDataOriginTPC); | |
110 | tgtList.push_back(kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC); | |
111 | return tgtList.size(); | |
dadc7068 | 112 | } |
113 | ||
e2a9091e | 114 | void AliHLTTPCTrackHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ){ |
115 | // see header file for class documentation | |
116 | ||
6b484df1 | 117 | constBase = 5000; |
e2a9091e | 118 | inputMultiplier = 1;// XXX TODO: Find more realistic value |
dadc7068 | 119 | } |
120 | ||
e2a9091e | 121 | AliHLTComponent* AliHLTTPCTrackHistoComponent::Spawn(){ |
122 | // see header file for class documentation | |
dadc7068 | 123 | return new AliHLTTPCTrackHistoComponent; |
124 | } | |
125 | ||
e2a9091e | 126 | int AliHLTTPCTrackHistoComponent::DoInit( int argc, const char** argv ){ |
127 | // see header file for class documentation | |
a267c68e | 128 | |
482875f5 | 129 | fClusters = new TNtuple("fClusters", "fClusters", "charge:qmax:residualY:residualZ"); |
482875f5 | 130 | fTracks = new TNtuple("fTracks", "fTracks", "pt:eta:psi:nclusters"); |
97fdadce | 131 | |
132 | fClusters->SetCircular(5000); | |
482875f5 | 133 | fTracks->SetCircular(5000); |
97fdadce | 134 | |
2c95fda7 | 135 | fMultiplicity = new TH1F("fMultiplicity", "Track multiplicity per event", 1000, 0, 1000); |
97fdadce | 136 | fMeanMultiplicity = new TH1F("fMeanMultiplicity", "Mean track multiplicity vs. #evt", 10000/fEvtMod, 0, 10000); |
f53b49dd | 137 | fDeDxVsP = new TProfile("fDeDxVsP", "E deposition per unit length vs. p",100, 0, 100); |
138 | fDeDxVsP->SetXTitle("p (GeV/c)"); | |
14b31e2b | 139 | //fdNdEta = new TH1F("fdNdEta", "dN/d#eta",100,-10,10); |
97fdadce | 140 | |
141 | // first configure the default | |
142 | int iResult=0; | |
143 | if (iResult>=0) iResult=ConfigureFromCDBTObjString(fgkOCDBEntry); | |
144 | ||
145 | // configure from the command line parameters if specified | |
146 | if (iResult>=0 && argc>0) | |
147 | iResult=ConfigureFromArgumentString(argc, argv); | |
148 | ||
149 | return iResult; | |
dadc7068 | 150 | } |
151 | ||
e2a9091e | 152 | int AliHLTTPCTrackHistoComponent::DoDeinit(){ |
153 | // see header file for class documentation | |
dadc7068 | 154 | |
a267c68e | 155 | delete fClusters; |
156 | delete fTracks; | |
14b31e2b | 157 | |
2c95fda7 | 158 | delete fMultiplicity; |
159 | delete fMeanMultiplicity; | |
f53b49dd | 160 | delete fDeDxVsP; |
14b31e2b | 161 | //delete fdNdEta; |
162 | ||
dadc7068 | 163 | return 0; |
164 | } | |
165 | ||
97fdadce | 166 | int AliHLTTPCTrackHistoComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/){ |
167 | // see header file for class documentation | |
168 | ||
169 | // configure from the specified antry or the default one | |
170 | const char* entry=cdbEntry; | |
171 | if (!entry || entry[0]==0) { | |
172 | entry=fgkOCDBEntry; | |
173 | } | |
174 | ||
175 | return ConfigureFromCDBTObjString(entry); | |
176 | } | |
177 | ||
178 | ||
e2a9091e | 179 | int AliHLTTPCTrackHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/){ |
180 | // see header file for class documentation | |
dadc7068 | 181 | |
e2a9091e | 182 | if(GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR)) return 0; |
2c95fda7 | 183 | |
184 | fNEvents++; | |
185 | ||
e2a9091e | 186 | const AliHLTComponentBlockData *iter = NULL; |
dadc7068 | 187 | |
e2a9091e | 188 | |
189 | //----------------- loop over cluster blocks ---------------------// | |
190 | ||
191 | Int_t totalSpacePoints = 0; | |
192 | ||
193 | for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){ | |
194 | ||
195 | if(iter->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType) continue; | |
196 | ||
197 | AliHLTUInt8_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(*iter); | |
198 | AliHLTUInt8_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter); | |
199 | //HLTDebug("Input Data - TPC cluster - slice/partition: %d/%d.", minSlice, minPartition); | |
200 | ||
201 | const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*)iter->fPtr; | |
202 | Int_t nSpacepoint = (Int_t)clusterData->fSpacePointCnt; | |
203 | totalSpacePoints += nSpacepoint; | |
204 | HLTDebug("TrackHisto component found %d spacepoints in slice %d partition %d", nSpacepoint, minSlice, minPartition); | |
205 | ||
206 | AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*)clusterData->fSpacePoints; | |
207 | ||
208 | if(fClustersArray[minSlice][minPartition] != NULL){ | |
209 | //delete(fClustersArray[minSlice][minPartition]); | |
210 | fClustersArray[minSlice][minPartition] = NULL; | |
211 | } | |
212 | ||
213 | // fill the array with AliHLTTPCSpacePointData pointers | |
214 | // it will be used in the track loop to access information | |
215 | // for the used clusters only | |
216 | fClustersArray[minSlice][minPartition] = clusters; | |
217 | fNSpacePoints[minSlice][minPartition] = nSpacepoint; | |
218 | ||
219 | if(nSpacepoint==0) fClustersArray[minSlice][minPartition] = NULL; | |
220 | ||
221 | } // end of loop over cluster data blocks | |
222 | ||
97fdadce | 223 | HLTDebug("TrackHisto found %d spacepoints",totalSpacePoints); |
e2a9091e | 224 | |
225 | ||
226 | ||
227 | ||
228 | //----------------- loop over merged tracks -------------------// | |
dadc7068 | 229 | |
e2a9091e | 230 | Int_t totalTracks = 0; |
a9f47f83 | 231 | |
e2a9091e | 232 | for(iter = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){ |
233 | if(iter->fDataType != (kAliHLTDataTypeTrack|kAliHLTDataOriginTPC)) continue; | |
234 | ReadTracks(iter,totalTracks); | |
235 | } | |
dadc7068 | 236 | |
97fdadce | 237 | HLTDebug("TrackHisto found %d tracks", totalTracks); |
dadc7068 | 238 | |
2c95fda7 | 239 | fMultiplicity->Fill(totalTracks); |
240 | ||
241 | fNtotTracks += totalTracks; | |
97fdadce | 242 | |
243 | if(fNEvents%fEvtMod==0){ | |
244 | fMeanMultiplicity->Fill(fNEvents, Float_t(fNtotTracks)/(fEvtMod)); | |
245 | //HLTInfo("-------------- Event number: %d, total tracks accummulated %d", fNEvents, fNtotTracks); | |
2c95fda7 | 246 | fNtotTracks = 0; |
247 | } | |
dadc7068 | 248 | |
2c95fda7 | 249 | PushHisto(); |
250 | ||
dadc7068 | 251 | return 0; |
252 | } | |
253 | ||
dadc7068 | 254 | void AliHLTTPCTrackHistoComponent::ReadTracks(const AliHLTComponentBlockData* iter,Int_t &tt){ |
e2a9091e | 255 | // see header file for class documentation |
dadc7068 | 256 | |
14b31e2b | 257 | AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*iter); |
e2a9091e | 258 | |
259 | Int_t usedSpacePoints = 0; | |
dadc7068 | 260 | |
97fdadce | 261 | vector<AliHLTGlobalBarrelTrack> tracksVector; |
262 | AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(iter->fPtr), iter->fSize, tracksVector); | |
2c95fda7 | 263 | |
97fdadce | 264 | tt = tracksVector.size(); |
265 | ||
266 | for(vector<AliHLTGlobalBarrelTrack>::iterator element=tracksVector.begin(); element!=tracksVector.end(); element++){ | |
f53b49dd | 267 | |
268 | Double_t trackLength = 0.; | |
269 | if(fdEdx==kTRUE) trackLength = element->GetPathLengthTo( element->GetLastPointX(), 5.0); | |
270 | ||
271 | UInt_t nHits = element->GetNumberOfPoints(); | |
272 | fTracks->Fill( 1./element->OneOverPt(), element->GetSnp(), element->GetTgl(), nHits ); | |
14b31e2b | 273 | //fdNdEta->Fill(element->GetSnp()); |
97fdadce | 274 | |
14b31e2b | 275 | Double_t totCharge = 0; |
276 | const UInt_t *hitnum = element->GetPoints(); | |
277 | for(UInt_t i=0; i<element->GetNumberOfPoints(); i++){ | |
97fdadce | 278 | |
14b31e2b | 279 | UInt_t idTrack = hitnum[i]; |
280 | Int_t sliceTrack = (idTrack>>25) & 0x7f; | |
281 | Int_t patchTrack = (idTrack>>22) & 0x7; | |
282 | UInt_t pos = idTrack&0x3fffff; | |
283 | ||
284 | if( !fClustersArray[sliceTrack][patchTrack] ) continue; | |
285 | ||
286 | if(sliceTrack<0 || sliceTrack>36 || patchTrack<0 || patchTrack>5 ){ | |
287 | HLTError("Corrupted TPC cluster Id: slice %d, patch %d, cluster %d", sliceTrack, patchTrack, idTrack); | |
288 | continue; | |
289 | } | |
290 | ||
291 | if(fNSpacePoints[sliceTrack][patchTrack]<=pos ){ | |
292 | HLTError("Space point array out of boundaries!"); | |
293 | continue; | |
294 | } | |
295 | ||
296 | totCharge += (fClustersArray[sliceTrack][patchTrack])[pos].fCharge; | |
297 | ||
298 | Float_t xyz[3]; xyz[0] = xyz[1] = xyz[2] = 0.; | |
299 | ||
300 | xyz[0] = (fClustersArray[sliceTrack][patchTrack])[pos].fX; | |
301 | xyz[1] = (fClustersArray[sliceTrack][patchTrack])[pos].fY; | |
302 | xyz[2] = (fClustersArray[sliceTrack][patchTrack])[pos].fZ; | |
303 | ||
304 | AliHLTTPCTransform::Local2Global(xyz,slice); | |
305 | ||
306 | Double_t p[2] = { xyz[1], xyz[2] }; | |
307 | Double_t cov[3] = { (fClustersArray[sliceTrack][patchTrack])[pos].fSigmaY2, 0., (fClustersArray[sliceTrack][patchTrack])[pos].fSigmaZ2}; | |
308 | Double_t *res = element->GetResiduals(p,cov,kFALSE); | |
309 | ||
310 | //HLTInfo("resy: %f, resz: %f", res[0], res[1]); | |
311 | ||
312 | if(!res) res[0] = res[1] = -1000.; | |
313 | else fClusters->Fill( (fClustersArray[sliceTrack][patchTrack])[pos].fCharge, (fClustersArray[sliceTrack][patchTrack])[pos].fQMax, res[0], res[1]); | |
314 | ||
315 | usedSpacePoints++; | |
316 | } | |
f53b49dd | 317 | if(fdEdx==kTRUE && trackLength > 0) fDeDxVsP->Fill(element->OneOverPt()*TMath::Sqrt(1.+element->GetTgl()*element->GetTgl()), totCharge/trackLength); |
97fdadce | 318 | } |
dadc7068 | 319 | } |
320 | ||
321 | void AliHLTTPCTrackHistoComponent::PushHisto(){ | |
e2a9091e | 322 | // see header file for class documentation |
2c95fda7 | 323 | |
14b31e2b | 324 | PushBack( (TObject*)fTracks, kAliHLTDataTypeTNtuple |kAliHLTDataOriginTPC, 0x0); |
325 | PushBack( (TObject*)fClusters, kAliHLTDataTypeTNtuple |kAliHLTDataOriginTPC, 0x0); | |
326 | PushBack( (TObject*)fMultiplicity, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, 0x0); | |
327 | PushBack( (TObject*)fMeanMultiplicity, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, 0x0); | |
328 | PushBack( (TObject*)fDeDxVsP, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, 0x0); | |
329 | //PushBack( (TObject*)fdNdEta, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, 0x0); | |
a267c68e | 330 | } |
a267c68e | 331 | |
97fdadce | 332 | int AliHLTTPCTrackHistoComponent::ScanConfigurationArgument(int argc, const char** argv){ |
e2a9091e | 333 | // see header file for class documentation |
2c95fda7 | 334 | |
97fdadce | 335 | if (argc<=0) return 0; |
336 | int i=0; | |
337 | TString argument=argv[i]; | |
338 | ||
339 | // -event-modulo | |
340 | if (argument.CompareTo("-event-modulo")==0) { | |
341 | if (++i>=argc) return -EPROTO; | |
342 | argument=argv[i]; | |
343 | fEvtMod=argument.Atof(); | |
344 | return 2; | |
345 | } | |
346 | ||
347 | // -buffer-size | |
348 | if (argument.CompareTo("-buffer-size")==0) { | |
349 | if (++i>=argc) return -EPROTO; | |
350 | argument=argv[i]; | |
351 | fBufferSize=argument.Atof(); | |
352 | return 2; | |
353 | } | |
f53b49dd | 354 | |
355 | // -dEdx | |
356 | if (argument.CompareTo("-dEdx")==0) { | |
357 | fdEdx=kTRUE; | |
358 | return 1; | |
359 | } | |
97fdadce | 360 | return -EINVAL; |
dadc7068 | 361 | } |