3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Gaute Ovrebekk <ovrebekk@ift.uib.no> *
8 //* for The ALICE HLT Project. *
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 //**************************************************************************
19 /** @file AliHLTTPCTrackHistoComponent.cxx
20 @author Gaute Ovrebekk, Matthias Richter, Kalliopi Kanaki
22 @brief A histogram component with track and associated cluster properties
29 #include "AliHLTTPCTrackHistoComponent.h"
30 #include "AliHLTTPCTransform.h"
31 #include "AliHLTTPCClusterDataFormat.h"
32 #include "AliHLTTPCTrackletDataFormat.h"
33 #include "AliHLTTPCMemHandler.h"
34 #include "AliHLTTPCDefinitions.h"
35 #include "AliHLTGlobalBarrelTrack.h"
36 #include "AliHLTExternalTrackParam.h"
37 #include "AliHLTDataTypes.h"
44 #include "TObjString.h"
45 #include "TObjArray.h"
48 #include "AliHLTTPCTrack.h"
51 /** ROOT macro for the implementation of ROOT specific class methods */
52 ClassImp(AliHLTTPCTrackHistoComponent)
54 AliHLTTPCTrackHistoComponent::AliHLTTPCTrackHistoComponent()
62 , fMeanMultiplicity(NULL)
68 //, fNClusterVsXY(NULL)
70 //, fClustersArray(NULL)
71 //, fNSpacePoints(NULL)
73 // see header file for class documentation
75 // refer to README to build package
77 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
80 const char* AliHLTTPCTrackHistoComponent::fgkOCDBEntry="HLT/ConfigTPC/TPCTrackHisto";
82 AliHLTTPCTrackHistoComponent::~AliHLTTPCTrackHistoComponent(){
83 // see header file for class documentation
86 // Public functions to implement AliHLTComponent's interface.
87 // These functions are required for the registration process
89 const char* AliHLTTPCTrackHistoComponent::GetComponentID(){
90 // see header file for class documentation
92 return "TPCTrackHisto";
95 void AliHLTTPCTrackHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list){
96 // see header file for class documentation
99 list.push_back(AliHLTTPCDefinitions::fgkClustersDataType|kAliHLTDataOriginTPC);
100 list.push_back(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
101 //list.push_back(kAliHLTDataTypeTObjArray|kAliHLTDataOriginTPC);
104 AliHLTComponentDataType AliHLTTPCTrackHistoComponent::GetOutputDataType(){
105 // see header file for class documentation
106 return kAliHLTMultipleDataType;
109 int AliHLTTPCTrackHistoComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){
110 // see header file for class documentation
112 tgtList.push_back(kAliHLTDataTypeTNtuple|kAliHLTDataOriginTPC);
113 tgtList.push_back(kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
114 return tgtList.size();
117 void AliHLTTPCTrackHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ){
118 // see header file for class documentation
121 inputMultiplier = 1;// XXX TODO: Find more realistic value
124 AliHLTComponent* AliHLTTPCTrackHistoComponent::Spawn(){
125 // see header file for class documentation
126 return new AliHLTTPCTrackHistoComponent;
129 int AliHLTTPCTrackHistoComponent::DoInit( int argc, const char** argv ){
130 // see header file for class documentation
132 fClusters = new TNtuple("fClusters", "fClusters", "charge:qmax:residualY:residualZ");
133 fTracks = new TNtuple("fTracks", "fTracks", "pt:eta:psi:nclusters");
135 fClusters->SetCircular(fBufferSize);
136 fTracks->SetCircular(fBufferSize);
138 fMultiplicity = new TH1F("fMultiplicity", "Track multiplicity per event", 1000, 0, 1000);
139 fMeanMultiplicity = new TH1F("fMeanMultiplicity", "Mean track multiplicity vs. #evt", 10000/fEvtMod, 0, 10000);
140 fDeDxVsP = new TProfile("fDeDxVsP", "E deposition per unit length vs. p",100, 0, 100);
141 fDeDxVsP->SetXTitle("p (GeV/c)");
142 //fdNdEta = new TH1F("fdNdEta", "dN/d#eta",100,-10,10);
144 // first configure the default
146 if (iResult>=0) iResult=ConfigureFromCDBTObjString(fgkOCDBEntry);
148 // configure from the command line parameters if specified
149 if (iResult>=0 && argc>0) iResult=ConfigureFromArgumentString(argc, argv);
154 int AliHLTTPCTrackHistoComponent::DoDeinit(){
155 // see header file for class documentation
160 delete fMultiplicity;
161 delete fMeanMultiplicity;
168 int AliHLTTPCTrackHistoComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/){
169 // see header file for class documentation
171 // configure from the specified antry or the default one
172 const char* entry=cdbEntry;
173 if (!entry || entry[0]==0) {
177 return ConfigureFromCDBTObjString(entry);
181 int AliHLTTPCTrackHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/){
182 // see header file for class documentation
184 if(GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR)) return 0;
188 const AliHLTComponentBlockData *iter = NULL;
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;
198 //----------------- loop over cluster blocks ---------------------//
200 Int_t totalSpacePoints = 0;
202 for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){
204 if(iter->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType) continue;
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);
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);
215 AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*)clusterData->fSpacePoints;
217 if(fClustersArray[minSlice][minPartition] != NULL){
218 delete(fClustersArray[minSlice][minPartition]); // ???????
219 fClustersArray[minSlice][minPartition] = NULL;
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;
228 if(nSpacepoint==0) fClustersArray[minSlice][minPartition] = NULL;
230 } // end of loop over cluster data blocks
232 HLTDebug("TrackHisto found %d spacepoints",totalSpacePoints);
237 //----------------- loop over merged tracks -------------------//
239 Int_t totalTracks = 0;
241 for(iter = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){
242 if(iter->fDataType != (kAliHLTDataTypeTrack|kAliHLTDataOriginTPC)) continue;
243 ReadTracks(iter,totalTracks);
246 HLTDebug("TrackHisto found %d tracks", totalTracks);
248 fMultiplicity->Fill(totalTracks);
250 fNtotTracks += totalTracks;
252 if(fNEvents%fEvtMod==0){
253 fMeanMultiplicity->Fill(fNEvents, Float_t(fNtotTracks)/(fEvtMod));
254 //HLTInfo("-------------- Event number: %d, total tracks accummulated %d", fNEvents, fNtotTracks);
263 void AliHLTTPCTrackHistoComponent::ReadTracks(const AliHLTComponentBlockData* iter,Int_t &tt){
264 // see header file for class documentation
266 //AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
268 Int_t usedSpacePoints = 0;
270 vector<AliHLTGlobalBarrelTrack> tracksVector;
271 AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(iter->fPtr), iter->fSize, tracksVector);
273 tt = tracksVector.size();
275 for(vector<AliHLTGlobalBarrelTrack>::iterator element=tracksVector.begin(); element!=tracksVector.end(); element++){
277 Double_t trackLength = 0.;
278 if(fdEdx==kTRUE) trackLength = element->GetPathLengthTo( element->GetLastPointX(), 5.0);
280 UInt_t nHits = element->GetNumberOfPoints();
281 fTracks->Fill( 1./element->OneOverPt(), element->GetSnp(), element->GetTgl(), nHits );
282 //fdNdEta->Fill(element->GetSnp());
284 Double_t totCharge = 0;
285 const UInt_t *hitnum = element->GetPoints();
286 for(UInt_t i=0; i<element->GetNumberOfPoints(); i++){
288 UInt_t idTrack = hitnum[i];
289 Int_t sliceTrack = AliHLTTPCSpacePointData::GetSlice(idTrack);
290 Int_t patchTrack = AliHLTTPCSpacePointData::GetPatch(idTrack);
291 UInt_t pos = AliHLTTPCSpacePointData::GetNumber(idTrack);
293 if( !fClustersArray[sliceTrack][patchTrack] ) continue;
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);
300 if(fNSpacePoints[sliceTrack][patchTrack]<=pos ){
301 HLTError("Space point array out of boundaries!");
305 totCharge += (fClustersArray[sliceTrack][patchTrack])[pos].fCharge;
307 //Float_t xyz[3]; xyz[0] = xyz[1] = xyz[2] = 0.;
309 //xyz[0] = (fClustersArray[sliceTrack][patchTrack])[pos].fX;
310 //xyz[1] = (fClustersArray[sliceTrack][patchTrack])[pos].fY;
311 //xyz[2] = (fClustersArray[sliceTrack][patchTrack])[pos].fZ;
313 //AliHLTTPCTransform::Local2Global(xyz,slice);
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);
319 //HLTInfo("resy: %f, resz: %f", res[0], res[1]);
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]);
324 fClusters->Fill( (fClustersArray[sliceTrack][patchTrack])[pos].fCharge, (fClustersArray[sliceTrack][patchTrack])[pos].fQMax, -1000., -1000.);
328 if(fdEdx==kTRUE && trackLength > 0) fDeDxVsP->Fill(element->OneOverPt()*TMath::Sqrt(1.+element->GetTgl()*element->GetTgl()), totCharge/trackLength);
332 void AliHLTTPCTrackHistoComponent::PushHisto(){
333 // see header file for class documentation
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);
343 int AliHLTTPCTrackHistoComponent::ScanConfigurationArgument(int argc, const char** argv){
344 // see header file for class documentation
346 if (argc<=0) return 0;
348 TString argument=argv[i];
351 if (argument.CompareTo("-event-modulo")==0) {
352 if (++i>=argc) return -EPROTO;
354 fEvtMod=argument.Atoi();
359 if (argument.CompareTo("-buffer-size")==0) {
360 if (++i>=argc) return -EPROTO;
362 fBufferSize=argument.Atoi();
367 if (argument.CompareTo("-dEdx")==0) {
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"));