]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCCFComparisonComponent.cxx
removing option to load clusters from binary file to get rid of dependency to AliHLTT...
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCCFComparisonComponent.cxx
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: Kalliopi Kanaki <Kalliopi.Kanaki@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   AliHLTTPCCFComparisonComponent.cxx
20     @author Kalliopi Kanaki
21     @date   
22     @brief  A comparison component for FCF and SCF properties
23 */
24
25 #if __GNUC__>= 3
26 using namespace std;
27 #endif
28
29 #include "AliHLTTPCCFComparisonComponent.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"
38
39 #include <TFile.h>
40 #include <TString.h>
41 #include "TNtuple.h"
42 #include "TH1F.h"
43 #include "TObjString.h"
44 #include "TObjArray.h"
45
46 #include "AliHLTTPCTrack.h"
47
48
49 /** ROOT macro for the implementation of ROOT specific class methods */
50 ClassImp(AliHLTTPCCFComparisonComponent)
51
52 AliHLTTPCCFComparisonComponent::AliHLTTPCCFComparisonComponent()
53     :
54     fEvtMod(20)
55   , fBufferSize(5000)
56   , fMultiplicity(NULL)
57   , fClusters(NULL)
58   , fTracks(NULL)
59 {
60   // see header file for class documentation
61   // or
62   // refer to README to build package
63   // or
64   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
65   for(int i=0; i<36; i++){
66      for(int j=0; j<6; j++){
67          fSCFClustersArray[i][j] = NULL;
68          fSCFNSpacePoints[i][j]  = 0;     
69          fFCFClustersArray[i][j] = NULL;
70          fFCFNSpacePoints[i][j]  = 0;     
71      }  
72   }
73 }
74
75 const char* AliHLTTPCCFComparisonComponent::fgkOCDBEntry="HLT/ConfigTPC/TPCCFComparison";
76
77 AliHLTTPCCFComparisonComponent::~AliHLTTPCCFComparisonComponent(){
78 // see header file for class documentation
79   for(int i=0; i<36; i++){
80      for(int j=0; j<6; j++){
81          delete[] fSCFClustersArray[i][j];
82          fSCFClustersArray[i][j] = NULL;         
83          delete[] fSCFClustersArray[i][j];
84          fSCFClustersArray[i][j] = NULL;         
85      }  
86   }
87 }
88
89 // Public functions to implement AliHLTComponent's interface.
90 // These functions are required for the registration process
91
92 const char* AliHLTTPCCFComparisonComponent::GetComponentID(){
93 // see header file for class documentation
94   
95   return "TPCCFComparison";
96 }
97
98 void AliHLTTPCCFComparisonComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list){
99 // see header file for class documentation
100   
101   list.clear();
102   list.push_back(AliHLTTPCDefinitions::fgkClustersDataType|kAliHLTDataOriginTPC);
103   list.push_back(AliHLTTPCDefinitions::fgkAlterClustersDataType|kAliHLTDataOriginTPC);
104   list.push_back(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC);  
105 }
106
107 AliHLTComponentDataType AliHLTTPCCFComparisonComponent::GetOutputDataType(){
108 // see header file for class documentation
109   return kAliHLTMultipleDataType;
110 }
111
112 int AliHLTTPCCFComparisonComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList){
113 // see header file for class documentation
114   tgtList.clear();
115   tgtList.push_back(kAliHLTDataTypeTNtuple|kAliHLTDataOriginTPC);
116   tgtList.push_back(kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC);
117   return tgtList.size();
118 }
119
120 void AliHLTTPCCFComparisonComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ){
121 // see header file for class documentation
122   
123   constBase = 5000;
124   inputMultiplier = 1;// XXX TODO: Find more realistic value
125 }
126
127 AliHLTComponent* AliHLTTPCCFComparisonComponent::Spawn(){
128 // see header file for class documentation
129   return new AliHLTTPCCFComparisonComponent;
130 }
131
132 int AliHLTTPCCFComparisonComponent::DoInit( int argc, const char** argv ){
133 // see header file for class documentation
134  
135   fClusters = new TNtuple("fClusters", "fClusters", "charge:qmax:residualY:residualZ"); 
136   fTracks   = new TNtuple("fTracks",  "fTracks",  "pt:eta:psi:nclusters"); 
137  
138   fClusters->SetCircular(fBufferSize);
139   fTracks->SetCircular(fBufferSize);
140  
141   fMultiplicity = new TH1F("fMultiplicity","Track multiplicity per event", 1000, 0, 1000);
142   
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
149   if (iResult>=0 && argc>0)  iResult=ConfigureFromArgumentString(argc, argv);
150   
151   return iResult;
152 }
153   
154 int AliHLTTPCCFComparisonComponent::DoDeinit(){
155 // see header file for class documentation
156   
157   delete fClusters;
158   delete fTracks;
159   delete fMultiplicity;
160   
161   return 0;
162 }
163
164 int AliHLTTPCCFComparisonComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/){
165 // see header file for class documentation
166
167   // configure from the specified antry or the default one
168   const char* entry=cdbEntry;
169   if (!entry || entry[0]==0) {
170      entry=fgkOCDBEntry;
171   }
172   return ConfigureFromCDBTObjString(entry);
173 }
174
175
176 int AliHLTTPCCFComparisonComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/){
177 // see header file for class documentation
178
179   if(GetFirstInputBlock(kAliHLTDataTypeSOR) || GetFirstInputBlock(kAliHLTDataTypeEOR)) return 0;  
180
181   const AliHLTComponentBlockData *iter = NULL;
182   
183   for(int i=0; i<36; i++){
184      for(int j=0; j<6; j++){
185          fSCFClustersArray[i][j] = NULL;
186          fSCFNSpacePoints[i][j]  = 0;     
187          fFCFClustersArray[i][j] = NULL;
188          fFCFNSpacePoints[i][j]  = 0;     
189      }  
190   }
191  
192  
193   //----------------- loop over SCF output blocks ---------------------//
194   
195   //Int_t totalSpacePoints = 0;
196   
197   for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock()){
198             
199       if(iter->fDataType!=AliHLTTPCDefinitions::fgkClustersDataType) continue;
200
201       AliHLTUInt8_t minSlice     = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
202       AliHLTUInt8_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
203       //HLTDebug("Input Data - TPC cluster - slice/partition: %d/%d.", minSlice, minPartition);
204
205       const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*)iter->fPtr;
206       Int_t nSpacepoint = (Int_t)clusterData->fSpacePointCnt;    
207       //totalSpacePoints += nSpacepoint;
208       HLTDebug("TPCCFComparison component found %d SCF spacepoints in slice %d partition %d", nSpacepoint, minSlice, minPartition);
209       
210       AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*)clusterData->fSpacePoints;
211       
212       if(fSCFClustersArray[minSlice][minPartition] != NULL){
213          delete(fSCFClustersArray[minSlice][minPartition]); 
214          fSCFClustersArray[minSlice][minPartition] = NULL;
215       }      
216
217       fSCFClustersArray[minSlice][minPartition] = clusters;
218       fSCFNSpacePoints[minSlice][minPartition]  = nSpacepoint;
219       
220       HLTInfo("SCF cluster loop charge %d, slice %d partition %d\n", (UInt_t)clusters->fCharge, minSlice, minPartition);   
221       
222       // Here are all the cluster data you can use:
223               
224       //Float_t fX;        // X coordinate in local coordinates
225       //Float_t fY;        // Y coordinate in local coordinates
226       //Float_t fZ;        // Z coordinate in local coordinates
227       //UInt_t fID;        // contains slice patch and number
228       //UChar_t fPadRow;  // Pad row number
229       //Float_t fSigmaY2; // error (former width) of the clusters
230       //Float_t fSigmaZ2; // error (former width) of the clusters
231       //UInt_t fCharge;   // total charge of cluster
232       //UInt_t fQMax;     // QMax of cluster
233   
234       
235       if(nSpacepoint==0) fSCFClustersArray[minSlice][minPartition] = NULL;
236
237   } // end of loop over cluster data blocks
238   
239   //HLTDebug("TPCCFComparison found %d spacepoints",totalSpacePoints);
240   
241   
242   //----------------- loop over FCF output blocks ---------------------//
243   
244   
245   for(iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkAlterClustersDataType); iter != NULL; iter = GetNextInputBlock()){
246             
247       if(iter->fDataType!=AliHLTTPCDefinitions::fgkAlterClustersDataType) continue;
248
249       AliHLTUInt8_t minSlice     = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
250       AliHLTUInt8_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(*iter);
251       //HLTDebug("Input Data - TPC cluster - slice/partition: %d/%d.", minSlice, minPartition);
252
253       const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*)iter->fPtr;
254       Int_t nSpacepoint = (Int_t)clusterData->fSpacePointCnt;    
255       //totalSpacePoints += nSpacepoint;
256       HLTDebug("TPCCFComparison component found %d FCF spacepoints in slice %d partition %d", nSpacepoint, minSlice, minPartition);
257       
258       AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*)clusterData->fSpacePoints;
259       
260       if(fFCFClustersArray[minSlice][minPartition] != NULL){
261          delete(fFCFClustersArray[minSlice][minPartition]); 
262          fFCFClustersArray[minSlice][minPartition] = NULL;
263       }      
264
265       fFCFClustersArray[minSlice][minPartition] = clusters;
266       fFCFNSpacePoints[minSlice][minPartition]  = nSpacepoint;
267            
268       HLTInfo("FCF cluster loop charge %d, slice %d partition %d\n", (UInt_t)clusters->fCharge, minSlice, minPartition);  
269       
270       if(nSpacepoint==0) fFCFClustersArray[minSlice][minPartition] = NULL;
271
272   } // end of loop over cluster data blocks
273   
274   
275   
276   //----------------- loop over merged tracks -------------------//
277
278 //   Int_t totalTracks = 0;
279 //   
280 //   for(iter = GetFirstInputBlock(kAliHLTDataTypeTrack|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputBlock()){    
281 //       if(iter->fDataType != (kAliHLTDataTypeTrack|kAliHLTDataOriginTPC)) continue; 
282 //       ReadTracks(iter,totalTracks);
283 //   }
284 //   
285 //   HLTDebug("TrackHisto found %d tracks", totalTracks);  
286 // 
287 //   fMultiplicity->Fill(totalTracks);
288 // 
289 //   PushHisto();
290   
291   return 0;
292 } // end of DoEvent
293  
294 // void AliHLTTPCCFComparisonComponent::ReadTracks(const AliHLTComponentBlockData* iter,Int_t &tt){
295 // // see header file for class documentation
296 // 
297 //   //AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(*iter);
298 //   
299 //   Int_t usedSpacePoints = 0;
300 //   
301 //   vector<AliHLTGlobalBarrelTrack> tracksVector;
302 //   AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(iter->fPtr), iter->fSize, tracksVector);
303 //   
304 //   tt = tracksVector.size();
305 //   
306 //   for(vector<AliHLTGlobalBarrelTrack>::iterator element=tracksVector.begin();  element!=tracksVector.end(); element++){
307 //        
308 //   
309 // 
310 //            
311 //        UInt_t nHits = element->GetNumberOfPoints();
312 //        fTracks->Fill( 1./element->OneOverPt(), element->GetSnp(), element->GetTgl(), nHits );  
313 //        //fdNdEta->Fill(element->GetSnp());
314 //  
315 //        Double_t totCharge = 0;
316 //        const UInt_t *hitnum = element->GetPoints();
317 //        for(UInt_t i=0; i<element->GetNumberOfPoints(); i++){
318 //            
319 //                 UInt_t idTrack   = hitnum[i];
320 //            Int_t sliceTrack = AliHLTTPCSpacePointData::GetSlice(idTrack);
321 //            Int_t patchTrack = AliHLTTPCSpacePointData::GetPatch(idTrack);
322 //            UInt_t pos            = AliHLTTPCSpacePointData::GetNumber(idTrack);
323 //         
324 //         //printf("KKKK pos :%d\n", pos);
325 //         cout << "KKKK pos  " << pos << endl;
326 // 
327 //            if( !fClustersArray[sliceTrack][patchTrack] ) continue;          
328 //                 
329 //                 if(sliceTrack<0 || sliceTrack>36 || patchTrack<0 || patchTrack>5 ){
330 //                    HLTError("Corrupted TPC cluster Id: slice %d, patch %d, cluster %d", sliceTrack, patchTrack, idTrack);
331 //                    continue;
332 //                 }
333 // 
334 //            if(fNSpacePoints[sliceTrack][patchTrack]<=pos ){
335 //                    HLTError("Space point array out of boundaries!");
336 //                    continue;
337 //            }
338 //                 
339 //                 totCharge += (fClustersArray[sliceTrack][patchTrack])[pos].fCharge; 
340 //                 
341 //                 //Float_t xyz[3]; xyz[0] = xyz[1] = xyz[2] = 0.;
342 //         
343 //            //xyz[0] = (fClustersArray[sliceTrack][patchTrack])[pos].fX;
344 //            //xyz[1] = (fClustersArray[sliceTrack][patchTrack])[pos].fY;
345 //            //xyz[2] = (fClustersArray[sliceTrack][patchTrack])[pos].fZ;
346 //         
347 //            //AliHLTTPCTransform::Local2Global(xyz,slice); 
348 //                 
349 //                 //Double_t p[2]   = { xyz[1], xyz[2] };
350 //            //Double_t cov[3] = { (fClustersArray[sliceTrack][patchTrack])[pos].fSigmaY2, 0., (fClustersArray[sliceTrack][patchTrack])[pos].fSigmaZ2};  
351 //                 //Double_t *res = element->GetResiduals(p,cov,kFALSE); 
352 //                 
353 //                 //HLTInfo("resy: %f, resz: %f", res[0], res[1]);
354 //                 
355 //                 //if(!res)  res[0] = res[1] = -1000.;
356 //                 //else      fClusters->Fill( (fClustersArray[sliceTrack][patchTrack])[pos].fCharge, (fClustersArray[sliceTrack][patchTrack])[pos].fQMax, res[0], res[1]);
357 //                
358 //                 fClusters->Fill( (fClustersArray[sliceTrack][patchTrack])[pos].fCharge, (fClustersArray[sliceTrack][patchTrack])[pos].fQMax, -1000., -1000.);
359 //             
360 //                 usedSpacePoints++;      
361 //        }     
362 // 
363 //   }
364 // }
365
366 // void AliHLTTPCCFComparisonComponent::PushHisto(){
367 // // see header file for class documentation
368 //     
369 //     PushBack( (TObject*)fTracks,       kAliHLTDataTypeTNtuple  |kAliHLTDataOriginTPC, 0x0);   
370 //     PushBack( (TObject*)fClusters,     kAliHLTDataTypeTNtuple  |kAliHLTDataOriginTPC, 0x0);
371 //     PushBack( (TObject*)fMultiplicity, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, 0x0);
372 // }
373
374 int AliHLTTPCCFComparisonComponent::ScanConfigurationArgument(int argc, const char** argv){
375 // see header file for class documentation
376  
377   if (argc<=0) return 0;
378   int i=0;
379   TString argument=argv[i];
380
381   // -event-modulo
382   if (argument.CompareTo("-event-modulo")==0) {
383     if (++i>=argc) return -EPROTO;
384     argument=argv[i];
385     fEvtMod=argument.Atoi();
386     return 2;
387   }    
388
389   // -buffer-size
390   if (argument.CompareTo("-buffer-size")==0) {
391     if (++i>=argc) return -EPROTO;
392     argument=argv[i];
393     fBufferSize=argument.Atoi();
394     return 2;
395   }    
396    
397   return -EINVAL;
398 }
399
400 void AliHLTTPCCFComparisonComponent::GetOCDBObjectDescription( TMap* const targetMap){
401 // Get a list of OCDB object description needed for the particular component
402   if (!targetMap) return;
403   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"));
404 }