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