]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCClusterHistoComponent.cxx
removing unnecessary include files; updating class description
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCClusterHistoComponent.cxx
1 // $Id$
2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project        * 
4 //* ALICE Experiment at CERN, All rights reserved.                         *
5 //*                                                                        *
6 //* Primary Authors: Gaute Ovrebekk <ovrebekk@ift.uib.no>                  *
7 //*                  for The ALICE HLT Project.                            *
8 //*                                                                        *
9 //* Permission to use, copy, modify and distribute this software and its   *
10 //* documentation strictly for non-commercial purposes is hereby granted   *
11 //* without fee, provided that the above copyright notice appears in all   *
12 //* copies and that both the copyright notice and this permission notice   *
13 //* appear in the supporting documentation. The authors make no claims     *
14 //* about the suitability of this software for any purpose. It is          *
15 //* provided "as is" without express or implied warranty.                  *
16 //**************************************************************************
17
18 /// @file   AliHLTTPCClusterHistoComponent.cxx
19 /// @author Gaute Ovrebekk
20 /// @brief  Component for ploting charge in clusters
21 ///
22
23 #include "AliHLTTPCClusterHistoComponent.h"
24 #include "AliHLTTPCTransform.h"
25 #include "AliHLTTPCClusterDataFormat.h"
26 #include "AliHLTTPCTrackletDataFormat.h"
27 #include "AliHLTTPCDefinitions.h"
28 #include "AliCDBEntry.h"
29 #include "AliCDBManager.h"
30 #include <TFile.h>
31 #include <TString.h>
32 #include "TObjString.h"
33 #include "TObjArray.h"
34
35 /** ROOT macro for the implementation of ROOT specific class methods */
36 ClassImp(AliHLTTPCClusterHistoComponent)
37
38 AliHLTTPCClusterHistoComponent::AliHLTTPCClusterHistoComponent()
39 :
40 fTotalClusterChargeOROCAll(NULL),                     
41   fTotalClusterChargeIROCAll(NULL),                   
42   fTotalClusterChargeROCSelection(NULL),               
43   fTotalClusterChargePartitionSelection(NULL),         
44   fQMaxPartitionAll(NULL),                             
45   fQMaxROCAll(NULL),                              
46   fNumberOfClusters(NULL),                        
47   fPlotChargeOROCAll(kTRUE),   
48   fPlotChargeIROCAll(kTRUE),
49   fPlotChargeROCSel(kFALSE), 
50   fPlotChargePartSel(kFALSE),
51   fPlotQmaxPartAll(kTRUE),  
52   fPlotQmaxROCAll(kTRUE),   
53   fPlotNClusters(kTRUE)    
54 {
55   // see header file for class documentation
56   // or
57   // refer to README to build package
58   // or
59   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
60
61 }
62
63 AliHLTTPCClusterHistoComponent::~AliHLTTPCClusterHistoComponent()
64 {
65   // see header file for class documentation
66 }
67
68 // Public functions to implement AliHLTComponent's interface.
69 // These functions are required for the registration process
70
71 const char* AliHLTTPCClusterHistoComponent::GetComponentID()
72 {
73   // see header file for class documentation
74   
75   return "TPCClusterHisto";
76 }
77
78 void AliHLTTPCClusterHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
79 {
80   // see header file for class documentation
81   list.clear();
82   list.push_back( AliHLTTPCDefinitions::fgkClustersDataType );
83 }
84
85 AliHLTComponentDataType AliHLTTPCClusterHistoComponent::GetOutputDataType()
86 {
87   // see header file for class documentation
88   return kAliHLTDataTypeHistogram;
89
90 }
91
92 void AliHLTTPCClusterHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
93 {
94   // see header file for class documentation
95   // XXX TODO: Find more realistic values.
96   constBase = 80000;
97   inputMultiplier = 1;
98 }
99
100 AliHLTComponent* AliHLTTPCClusterHistoComponent::Spawn()
101 {
102   // see header file for class documentation
103   return new AliHLTTPCClusterHistoComponent;
104 }
105
106 int AliHLTTPCClusterHistoComponent::DoInit( int argc, const char** argv )
107 {
108   //  HLTFatal("Initializing with log fatal");
109   //  cout<<"Initializing with cout"<<endl;
110   
111   fPlotChargeOROCAll=kTRUE;   
112   fPlotChargeIROCAll=kTRUE;
113   fPlotChargeROCSel=kFALSE; 
114   fPlotChargePartSel=kFALSE;
115   fPlotQmaxPartAll=kTRUE;  
116   fPlotQmaxROCAll=kTRUE;   
117   fPlotNClusters=kTRUE;
118    
119   if(fPlotChargeOROCAll){fTotalClusterChargeOROCAll = new TH1F("fTotalClusterChargeOROCAll","Total Charge of clusters in all OROC",4000,0,4000);}
120   if(fPlotChargeIROCAll){fTotalClusterChargeIROCAll = new TH1F("fTotalClusterChargeIROCAll","Total Charge of clusters in all IROC",4000,0,4000);}
121   if(fPlotChargeROCSel){fTotalClusterChargeROCSelection = new TH1F("fTotalClusterChargeROCSelection","Total Charge of clusters in selection ROC",4000,0,4000);}
122   if(fPlotChargePartSel){fTotalClusterChargePartitionSelection = new TH1F("fTotalClusterChargePartitionSelection","Total Charge of clusters in sel Part",4000,0,4000);}
123   if(fPlotQmaxPartAll){fQMaxPartitionAll = new TH1F("fQMaxPartitionAll","QMax for All Partitions",216,0,216);}
124   if(fPlotQmaxROCAll){fQMaxROCAll = new TH1F("fQMaxROCAll","QMax for All Partitions",72,0,72);}
125   if(fPlotNClusters){fNumberOfClusters = new TH1F("fNumberOfClusters","Total Number of Clusters",1,0,1);}
126
127   int iResult=0;
128   TString configuration="";
129   TString argument="";
130   for (int i=0; i<argc && iResult>=0; i++) {
131     argument=argv[i];
132     if (!configuration.IsNull()) configuration+=" ";
133     configuration+=argument;
134   }
135   
136   if (!configuration.IsNull()) {
137     iResult=Configure(configuration.Data());
138   }  
139
140   return iResult; 
141 }
142   
143 int AliHLTTPCClusterHistoComponent::DoDeinit()
144 {
145   // see header file for class documentation
146   if(fTotalClusterChargeOROCAll!=NULL) delete fTotalClusterChargeOROCAll;
147   if(fTotalClusterChargeIROCAll!=NULL) delete fTotalClusterChargeIROCAll;     
148   if(fQMaxPartitionAll!=NULL) delete fQMaxPartitionAll;
149   if(fQMaxROCAll!=NULL) delete fQMaxROCAll;
150   return 0;
151 }
152
153 int AliHLTTPCClusterHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/)
154 {
155   
156   int TotalSpacePoint = 0;
157   
158   const AliHLTComponentBlockData* iter = NULL;
159   
160   if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
161     return 0;
162   
163   fQMaxPartitionAll->Reset();
164   fQMaxROCAll->Reset();
165
166   for ( iter = GetFirstInputBlock(AliHLTTPCDefinitions::fgkClustersDataType); iter != NULL; iter = GetNextInputBlock() ) {
167     
168     Int_t thisrow=-1,thissector=-1,row=-1;
169     
170     AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr( *iter );
171     AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr( *iter );
172     row = AliHLTTPCTransform::GetFirstRow(patch); 
173     AliHLTTPCTransform::Slice2Sector(slice,row,thissector,thisrow);
174     
175     HLTDebug ( "Input Data - TPC cluster - Slice/Patch: %d/%d.", slice, patch );
176     
177     const AliHLTTPCClusterData* clusterData = (const AliHLTTPCClusterData*) iter->fPtr;
178     Int_t nSpacepoint = (Int_t) clusterData->fSpacePointCnt;
179     TotalSpacePoint += nSpacepoint;
180     //HLTInfo("KryptonHisto found %d Spacepoints in slice %d patch %d", nSpacepoint, slice, patch);
181     AliHLTTPCSpacePointData *clusters = (AliHLTTPCSpacePointData*) &clusterData->fSpacePoints;
182     
183     UInt_t tmpQPart = 0;//,tmpQROC = -1;
184     
185     for(int i=0;i<nSpacepoint;i++){
186       if(fPlotChargeOROCAll){
187         if(thissector>=36){
188           fTotalClusterChargeOROCAll->Fill(clusters[i].fCharge);
189         }
190       }
191       if(fPlotChargeIROCAll){
192         if(thissector<=35){
193           fTotalClusterChargeIROCAll->Fill(clusters[i].fCharge);
194         }
195       }
196       if(fPlotChargeROCSel){
197         
198       }
199       if(fPlotChargePartSel){
200         
201       }
202       if(fPlotQmaxPartAll){
203         if(clusters[i].fQMax>tmpQPart){
204           fQMaxPartitionAll->SetBinContent(patch+6*slice,clusters[i].fQMax);
205           tmpQPart=clusters[i].fQMax;
206         }
207       }
208       if(fPlotQmaxROCAll){
209         if(clusters[i].fQMax>fQMaxROCAll->GetBinContent(thissector)){
210           fQMaxROCAll->SetBinContent(thissector,clusters[i].fQMax);
211           //      tmpQROC=clusters[i].fQMax;
212         }
213       }
214     }
215     if(fPlotNClusters){
216       fNumberOfClusters->Fill(nSpacepoint);
217     }
218   }
219   
220   //delete til dodeinit
221   if(fPlotChargeOROCAll){
222     AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,2,5);
223     PushBack( (TObject*) fTotalClusterChargeOROCAll,kAliHLTDataTypeHistogram,fSpecification);
224   }
225   if(fPlotChargeIROCAll){
226     AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,1);
227     PushBack( (TObject*) fTotalClusterChargeIROCAll,kAliHLTDataTypeHistogram,fSpecification);
228   }
229   if(fPlotChargeROCSel){
230     
231     
232   }
233   if(fPlotChargePartSel){
234     
235     
236   }
237   if(fPlotQmaxPartAll){
238     AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
239     PushBack( (TObject*) fQMaxPartitionAll,kAliHLTDataTypeHistogram,fSpecification);
240     //delete fQMaxPartitionAll;
241   }
242   if(fPlotQmaxROCAll){
243     AliHLTUInt32_t fSpecification = AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5);
244     PushBack( (TObject*) fQMaxROCAll,kAliHLTDataTypeHistogram,fSpecification);
245     //delete fQMaxROCAll;
246   }
247   if(fPlotNClusters){
248     
249     
250   }
251   
252   HLTInfo("KryptonHisto found %d Total Spacepoints", TotalSpacePoint);
253   
254   return 0;
255 }
256
257 int AliHLTTPCClusterHistoComponent::Configure(const char* arguments)
258 {
259   
260   int iResult=0;
261   if (!arguments) return iResult;
262   
263   TString allArgs=arguments;
264   TString argument;
265   
266   TObjArray* pTokens=allArgs.Tokenize(" ");
267   
268   if (pTokens) {
269     for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
270       argument=((TObjString*)pTokens->At(i))->GetString();
271       if (argument.IsNull()) continue;
272       
273       if (argument.CompareTo("-plot-all")==0) {
274         HLTInfo("Ploting charge of all clusters");
275         //fPlotAll = kTRUE;
276         continue;
277       }
278       
279       else if (argument.CompareTo("-plot-trackclusters")==0) {
280         HLTInfo("Ploting charge of clusters used on a track");
281         //fPlotAll = kFALSE;
282         continue;
283       }
284       else {
285         HLTError("unknown argument %s", argument.Data());
286         iResult=-EINVAL;
287         break;
288       }
289     }
290     delete pTokens;
291   }
292   
293   //if hvis det eksisterer
294   if(fPlotChargeOROCAll){fTotalClusterChargeOROCAll = new TH1F("fTotalClusterChargeOROCAll","Total Charge of clusters in all OROC",4000,0,4000);}
295   if(fPlotChargeIROCAll){fTotalClusterChargeIROCAll = new TH1F("fTotalClusterChargeIROCAll","Total Charge of clusters in all IROC",4000,0,4000);}
296   if(fPlotChargeROCSel){fTotalClusterChargeROCSelection = new TH1F("fTotalClusterChargeROCSelection","Total Charge of clusters in selection ROC",4000,0,4000);}
297   if(fPlotChargePartSel){fTotalClusterChargePartitionSelection = new TH1F("fTotalClusterChargePartitionSelection","Total Charge of clusters in sel Part",4000,0,4000);}
298   if(fPlotQmaxPartAll){fQMaxPartitionAll = new TH1F("fQMaxPartitionAll","QMax for All Partitions",216,0,216);}
299   if(fPlotQmaxROCAll){fQMaxROCAll = new TH1F("fQMaxROCAll","QMax for All Partitions",72,0,72);}
300   if(fPlotNClusters){fNumberOfClusters = new TH1F("fNumberOfClusters","Total Number of Clusters",100,0,100);}
301
302   return iResult;
303 }
304
305 int AliHLTTPCClusterHistoComponent::Reconfigure(const char* cdbEntry, const char* chainId)
306 {
307   // see header file for class documentation
308   int iResult=0;
309   const char* path="HLT/ConfigTPC/KryptonHistoComponent";
310   const char* defaultNotify="";
311   if (cdbEntry) {
312     path=cdbEntry;
313     defaultNotify=" (default)";
314   }
315   if (path) {
316     HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
317     AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
318     if (pEntry) {
319       TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
320       if (pString) {
321         HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
322         iResult=Configure(pString->GetString().Data());
323       } else {
324         HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
325       }
326     } else {
327       HLTError("can not fetch object \"%s\" from CDB", path);
328     }
329   }
330
331   return iResult;
332 }