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