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: Kalliopi Kanaki <Kalliopi.Kanaki@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 AliHLTTPCCFComparisonComponent.cxx
20 /// @author Kalliopi Kanaki
22 /// @brief A comparison component for FCF and SCF properties
25 #include "AliHLTTPCCFComparisonComponent.h"
26 #include "AliHLTTPCTransform.h"
27 #include "AliHLTTPCClusterDataFormat.h"
28 #include "AliHLTTPCTrackletDataFormat.h"
29 #include "AliHLTTPCMemHandler.h"
30 #include "AliHLTTPCDefinitions.h"
31 #include "AliHLTGlobalBarrelTrack.h"
32 #include "AliHLTExternalTrackParam.h"
33 #include "AliHLTDataTypes.h"
39 #include "TObjString.h"
40 #include "TObjArray.h"
42 /** ROOT macro for the implementation of ROOT specific class methods */
43 ClassImp(AliHLTTPCCFComparisonComponent)
45 AliHLTTPCCFComparisonComponent::AliHLTTPCCFComparisonComponent()
53 // see header file for class documentation
55 // refer to README to build package
57 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
58 for(int i=0; i<36; i++){
59 for(int j=0; j<6; j++){
60 fSCFClustersArray[i][j] = NULL;
61 fSCFNSpacePoints[i][j] = 0;
62 fFCFClustersArray[i][j] = NULL;
63 fFCFNSpacePoints[i][j] = 0;
68 const char* AliHLTTPCCFComparisonComponent::fgkOCDBEntry="HLT/ConfigTPC/TPCCFComparison";
70 AliHLTTPCCFComparisonComponent::~AliHLTTPCCFComparisonComponent(){
71 // see header file for class documentation
72 for(int i=0; i<36; i++){
73 for(int j=0; j<6; j++){
74 delete[] fSCFClustersArray[i][j];
75 fSCFClustersArray[i][j] = NULL;
76 delete[] fSCFClustersArray[i][j];
77 fSCFClustersArray[i][j] = NULL;
82 // Public functions to implement AliHLTComponent's interface.
83 // These functions are required for the registration process
85 const char* AliHLTTPCCFComparisonComponent::GetComponentID(){
86 // see header file for class documentation
88 return "TPCCFComparison";
91 void AliHLTTPCCFComparisonComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list){
92 // see header file for class documentation
95 list.push_back(AliHLTTPCDefinitions::fgkClustersDataType|kAliHLTDataOriginTPC);
96 list.push_back(AliHLTTPCDefinitions::fgkAlterClustersDataType|kAliHLTDataOriginTPC);
97 list.push_back(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);
100 AliHLTComponentDataType AliHLTTPCCFComparisonComponent::GetOutputDataType(){
101 // see header file for class documentation
102 return kAliHLTMultipleDataType;
105 int AliHLTTPCCFComparisonComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){
106 // see header file for class documentation
108 tgtList.push_back(kAliHLTDataTypeTNtuple|kAliHLTDataOriginTPC);
109 tgtList.push_back(kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
110 return tgtList.size();
113 void AliHLTTPCCFComparisonComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ){
114 // see header file for class documentation
117 inputMultiplier = 1;// XXX TODO: Find more realistic value
120 AliHLTComponent* AliHLTTPCCFComparisonComponent::Spawn(){
121 // see header file for class documentation
122 return new AliHLTTPCCFComparisonComponent;
125 int AliHLTTPCCFComparisonComponent::DoInit( int argc, const char** argv ){
126 // see header file for class documentation
128 fClusters = new TNtuple("fClusters", "fClusters", "charge:qmax:residualY:residualZ");
129 fTracks = new TNtuple("fTracks", "fTracks", "pt:eta:psi:nclusters");
131 fClusters->SetCircular(fBufferSize);
132 fTracks->SetCircular(fBufferSize);
134 fMultiplicity = new TH1F("fMultiplicity","Track multiplicity per event", 1000, 0, 1000);
137 // first configure the default
139 if (iResult>=0) iResult=ConfigureFromCDBTObjString(fgkOCDBEntry);
141 // configure from the command line parameters if specified
142 if (iResult>=0 && argc>0) iResult=ConfigureFromArgumentString(argc, argv);
147 int AliHLTTPCCFComparisonComponent::DoDeinit(){
148 // see header file for class documentation
152 delete fMultiplicity;
157 int AliHLTTPCCFComparisonComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/){
158 // see header file for class documentation
160 // configure from the specified antry or the default one
161 const char* entry=cdbEntry;
162 if (!entry || entry[0]==0) {
165 return ConfigureFromCDBTObjString(entry);
169 int AliHLTTPCCFComparisonComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/){
170 // see header file for class documentation
172 if(GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR)) return 0;
174 const AliHLTComponentBlockData *iter = NULL;
176 for(int i=0; i<36; i++){
177 for(int j=0; j<6; j++){
178 fSCFClustersArray[i][j] = NULL;
179 fSCFNSpacePoints[i][j] = 0;
180 fFCFClustersArray[i][j] = NULL;
181 fFCFNSpacePoints[i][j] = 0;
186 //----------------- loop over SCF output blocks ---------------------//
188 //Int_t totalSpacePoints = 0;
190 for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){
192 if(iter->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType) continue;
194 AliHLTUInt8_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
195 AliHLTUInt8_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
196 //HLTDebug("Input Data - TPC cluster - slice/partition: %d/%d.", minSlice, minPartition);
198 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*)iter->fPtr;
199 Int_t nSpacepoint = (Int_t)clusterData->fSpacePointCnt;
200 //totalSpacePoints += nSpacepoint;
201 HLTDebug("TPCCFComparison component found %d SCF spacepoints in slice %d partition %d", nSpacepoint, minSlice, minPartition);
203 AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*)clusterData->fSpacePoints;
205 if(fSCFClustersArray[minSlice][minPartition] != NULL){
206 delete(fSCFClustersArray[minSlice][minPartition]);
207 fSCFClustersArray[minSlice][minPartition] = NULL;
210 fSCFClustersArray[minSlice][minPartition] = clusters;
211 fSCFNSpacePoints[minSlice][minPartition] = nSpacepoint;
213 HLTInfo("SCF cluster loop charge %d, slice %d partition %d\n", (UInt_t)clusters->fCharge, minSlice, minPartition);
215 // Here are all the cluster data you can use:
217 //Float_t fX; // X coordinate in local coordinates
218 //Float_t fY; // Y coordinate in local coordinates
219 //Float_t fZ; // Z coordinate in local coordinates
220 //UInt_t fID; // contains slice patch and number
221 //UChar_t fPadRow; // Pad row number
222 //Float_t fSigmaY2; // error (former width) of the clusters
223 //Float_t fSigmaZ2; // error (former width) of the clusters
224 //UInt_t fCharge; // total charge of cluster
225 //UInt_t fQMax; // QMax of cluster
228 if(nSpacepoint==0) fSCFClustersArray[minSlice][minPartition] = NULL;
230 } // end of loop over cluster data blocks
232 //HLTDebug("TPCCFComparison found %d spacepoints",totalSpacePoints);
235 //----------------- loop over FCF output blocks ---------------------//
238 for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkAlterClustersDataType); iter != NULL; iter = GetNextInputBlock()){
240 if(iter->fDataType!=AliHLTTPCDefinitions::fgkAlterClustersDataType) continue;
242 AliHLTUInt8_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
243 AliHLTUInt8_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
244 //HLTDebug("Input Data - TPC cluster - slice/partition: %d/%d.", minSlice, minPartition);
246 const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*)iter->fPtr;
247 Int_t nSpacepoint = (Int_t)clusterData->fSpacePointCnt;
248 //totalSpacePoints += nSpacepoint;
249 HLTDebug("TPCCFComparison component found %d FCF spacepoints in slice %d partition %d", nSpacepoint, minSlice, minPartition);
251 AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*)clusterData->fSpacePoints;
253 if(fFCFClustersArray[minSlice][minPartition] != NULL){
254 delete(fFCFClustersArray[minSlice][minPartition]);
255 fFCFClustersArray[minSlice][minPartition] = NULL;
258 fFCFClustersArray[minSlice][minPartition] = clusters;
259 fFCFNSpacePoints[minSlice][minPartition] = nSpacepoint;
261 HLTInfo("FCF cluster loop charge %d, slice %d partition %d\n", (UInt_t)clusters->fCharge, minSlice, minPartition);
263 if(nSpacepoint==0) fFCFClustersArray[minSlice][minPartition] = NULL;
265 } // end of loop over cluster data blocks
269 //----------------- loop over merged tracks -------------------//
271 // Int_t totalTracks = 0;
273 // for(iter = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){
274 // if(iter->fDataType != (kAliHLTDataTypeTrack|kAliHLTDataOriginTPC)) continue;
275 // ReadTracks(iter,totalTracks);
278 // HLTDebug("TrackHisto found %d tracks", totalTracks);
280 // fMultiplicity->Fill(totalTracks);
287 // void AliHLTTPCCFComparisonComponent::ReadTracks(const AliHLTComponentBlockData* iter,Int_t &tt){
288 // // see header file for class documentation
290 // //AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
292 // Int_t usedSpacePoints = 0;
294 // vector<AliHLTGlobalBarrelTrack> tracksVector;
295 // AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(iter->fPtr), iter->fSize, tracksVector);
297 // tt = tracksVector.size();
299 // for(vector<AliHLTGlobalBarrelTrack>::iterator element=tracksVector.begin(); element!=tracksVector.end(); element++){
304 // UInt_t nHits = element->GetNumberOfPoints();
305 // fTracks->Fill( 1./element->OneOverPt(), element->GetSnp(), element->GetTgl(), nHits );
306 // //fdNdEta->Fill(element->GetSnp());
308 // Double_t totCharge = 0;
309 // const UInt_t *hitnum = element->GetPoints();
310 // for(UInt_t i=0; i<element->GetNumberOfPoints(); i++){
312 // UInt_t idTrack = hitnum[i];
313 // Int_t sliceTrack = AliHLTTPCSpacePointData::GetSlice(idTrack);
314 // Int_t patchTrack = AliHLTTPCSpacePointData::GetPatch(idTrack);
315 // UInt_t pos = AliHLTTPCSpacePointData::GetNumber(idTrack);
317 // //printf("KKKK pos :%d\n", pos);
318 // cout << "KKKK pos " << pos << endl;
320 // if( !fClustersArray[sliceTrack][patchTrack] ) continue;
322 // if(sliceTrack<0 || sliceTrack>36 || patchTrack<0 || patchTrack>5 ){
323 // HLTError("Corrupted TPC cluster Id: slice %d, patch %d, cluster %d", sliceTrack, patchTrack, idTrack);
327 // if(fNSpacePoints[sliceTrack][patchTrack]<=pos ){
328 // HLTError("Space point array out of boundaries!");
332 // totCharge += (fClustersArray[sliceTrack][patchTrack])[pos].fCharge;
334 // //Float_t xyz[3]; xyz[0] = xyz[1] = xyz[2] = 0.;
336 // //xyz[0] = (fClustersArray[sliceTrack][patchTrack])[pos].fX;
337 // //xyz[1] = (fClustersArray[sliceTrack][patchTrack])[pos].fY;
338 // //xyz[2] = (fClustersArray[sliceTrack][patchTrack])[pos].fZ;
340 // //AliHLTTPCTransform::Local2Global(xyz,slice);
342 // //Double_t p[2] = { xyz[1], xyz[2] };
343 // //Double_t cov[3] = { (fClustersArray[sliceTrack][patchTrack])[pos].fSigmaY2, 0., (fClustersArray[sliceTrack][patchTrack])[pos].fSigmaZ2};
344 // //Double_t *res = element->GetResiduals(p,cov,kFALSE);
346 // //HLTInfo("resy: %f, resz: %f", res[0], res[1]);
348 // //if(!res) res[0] = res[1] = -1000.;
349 // //else fClusters->Fill( (fClustersArray[sliceTrack][patchTrack])[pos].fCharge, (fClustersArray[sliceTrack][patchTrack])[pos].fQMax, res[0], res[1]);
351 // fClusters->Fill( (fClustersArray[sliceTrack][patchTrack])[pos].fCharge, (fClustersArray[sliceTrack][patchTrack])[pos].fQMax, -1000., -1000.);
353 // usedSpacePoints++;
359 // void AliHLTTPCCFComparisonComponent::PushHisto(){
360 // // see header file for class documentation
362 // PushBack( (TObject*)fTracks, kAliHLTDataTypeTNtuple |kAliHLTDataOriginTPC, 0x0);
363 // PushBack( (TObject*)fClusters, kAliHLTDataTypeTNtuple |kAliHLTDataOriginTPC, 0x0);
364 // PushBack( (TObject*)fMultiplicity, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, 0x0);
367 int AliHLTTPCCFComparisonComponent::ScanConfigurationArgument(int argc, const char** argv){
368 // see header file for class documentation
370 if (argc<=0) return 0;
372 TString argument=argv[i];
375 if (argument.CompareTo("-event-modulo")==0) {
376 if (++i>=argc) return -EPROTO;
378 fEvtMod=argument.Atoi();
383 if (argument.CompareTo("-buffer-size")==0) {
384 if (++i>=argc) return -EPROTO;
386 fBufferSize=argument.Atoi();
393 void AliHLTTPCCFComparisonComponent::GetOCDBObjectDescription( TMap* const targetMap){
394 // Get a list of OCDB object description needed for the particular component
395 if (!targetMap) return;
396 targetMap->Add(new TObjString("HLT/ConfigTPC/TPCCFComparison"), new TObjString("component arguments for setting the size of the filled ntuples and the event modulo for the mean multiplicity distribution"));