]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/AliHLTTPCHistogramHandlerComponent.cxx
first steps to set the covariance matrix from the errors calculated in conformal...
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCHistogramHandlerComponent.cxx
CommitLineData
cdfe3c01 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 AliHLTTPCHistogramHandlerComponent.cxx
20 @author Kalliopi Kanaki
21 @date
22 @brief The Histogram Handler component
23*/
24
25#if __GNUC__>= 3
26using namespace std;
27#endif
28#include "AliHLTTPCHistogramHandlerComponent.h"
29#include "AliHLTTPCDefinitions.h"
30#include "AliCDBEntry.h"
31#include "AliCDBManager.h"
0efebbac 32#include "AliHLTTPCTransform.h"
cdfe3c01 33
34#include <cstdlib>
35#include <cerrno>
36#include "TString.h"
37#include "TFile.h"
38#include "TObjArray.h"
39#include "TObjString.h"
40#include <sys/time.h>
41#include "TH1.h"
42#include "TH2.h"
43#include "TLine.h"
44#include "TMath.h"
45
cdfe3c01 46ClassImp(AliHLTTPCHistogramHandlerComponent) //ROOT macro for the implementation of ROOT specific class methods
47
48AliHLTTPCHistogramHandlerComponent::AliHLTTPCHistogramHandlerComponent()
49 :
0e588049 50 fSpecification(0),
cdfe3c01 51 fNoiseHistograms(0),
52 fKryptonHistograms(0),
cdfe3c01 53 fSlice(-99),
0efebbac 54
cdfe3c01 55 fHistTH1Tmp(NULL),
0efebbac 56 fTotalClusterChargeIROCAll(NULL),
57 fTotalClusterChargeOROCAll(NULL),
58 fQMaxPartitionAll(NULL),
59 fPlotQmaxROCAll(NULL),
60 fNumberOfClusters(NULL),
61
cdfe3c01 62 fHistTH2Tmp(NULL),
63 fHistTPCSideA(NULL),
64 fHistTPCSideC(NULL)
65{
66 // see header file for class documentation
67 // or
68 // refer to README to build package
69 // or
70 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
71}
72
73AliHLTTPCHistogramHandlerComponent::~AliHLTTPCHistogramHandlerComponent() {
74// see header file for class documentation
75
76}
77
78// Public functions to implement AliHLTComponent's interface.
79// These functions are required for the registration process
80
81const char* AliHLTTPCHistogramHandlerComponent::GetComponentID() {
82// see header file for class documentation
83
84 return "TPCHistogramHandler";
85}
86
87void AliHLTTPCHistogramHandlerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
88// see header file for class documentation
89
90 list.clear();
91 list.push_back( kAliHLTDataTypeHistogram );
92}
93
94AliHLTComponentDataType AliHLTTPCHistogramHandlerComponent::GetOutputDataType() {
95// see header file for class documentation
96
97 return kAliHLTDataTypeHistogram;
98}
99
100int AliHLTTPCHistogramHandlerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) {
101// see header file for class documentation
102
103 tgtList.clear();
104 tgtList.push_back(kAliHLTDataTypeHistogram);
105 return tgtList.size();
106}
107
108void AliHLTTPCHistogramHandlerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
109// see header file for class documentation
110
111 constBase=0;
112 inputMultiplier=2.0;
113}
114
115AliHLTComponent* AliHLTTPCHistogramHandlerComponent::Spawn() {
116// see header file for class documentation
117
118 return new AliHLTTPCHistogramHandlerComponent();
119}
120
121int AliHLTTPCHistogramHandlerComponent::DoInit( int argc, const char** argv ) {
122// see header file for class documentation
123
124 Int_t i = 0;
125 Char_t* cpErr;
126
127 int iResult=0;
128
129 TString configuration="";
130 TString argument="";
0e588049 131 for (int j=0; j<argc && iResult>=0; j++) {
cdfe3c01 132
0e588049 133 argument=argv[j];
cdfe3c01 134 if (!configuration.IsNull()) configuration+=" ";
135 configuration+=argument;
136 }
137
138 if (!configuration.IsNull()) {
139 iResult=Configure(configuration.Data());
140 } else {
141 iResult=Reconfigure(NULL, NULL);
142 }
143
144
145 while ( i < argc ) {
146 if (!strcmp( argv[i], "-sum-noise-histograms")) {
147 fNoiseHistograms = strtoul( argv[i+1], &cpErr ,0);
148
149 if ( *cpErr ) {
150 HLTError("Cannot convert sum-noise-histograms specifier '%s'.", argv[i+1]);
151 return EINVAL;
152 }
153 i+=2;
154 continue;
155 }
156
157 if (!strcmp( argv[i], "-sum-krypton-histograms")) {
158 fKryptonHistograms = strtoul( argv[i+1], &cpErr ,0);
159
160 if ( *cpErr ) {
161 HLTError("Cannot convert sum-krypton-histograms specifier '%s'.", argv[i+1]);
162 return EINVAL;
163 }
164 i+=2;
165 continue;
166 }
167
168 Logging(kHLTLogError, "HLT::TPCHistogramHandler::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
169 return EINVAL;
170
171 } // end while
172
173 return 0;
174} // end DoInit()
175
176int AliHLTTPCHistogramHandlerComponent::DoDeinit() {
177// see header file for class documentation
178
179 return 0;
180}
181
0e588049 182int AliHLTTPCHistogramHandlerComponent::DoEvent(const AliHLTComponentEventData&/* evtData*/, AliHLTComponentTriggerData& /*trigData*/){
cdfe3c01 183// see header file for class documentation
184
185 HLTInfo("--- Entering DoEvent() in TPCHistogramHandler ---");
186
187 if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )) return 0;
0efebbac 188
189 fTotalClusterChargeIROCAll = new TH1F("fTotalClusterChargeIROCAll","Total Charge of clusters in all IROC",4000,0,4000);
190 fTotalClusterChargeOROCAll = new TH1F("fTotalClusterChargeOROCAll","Total Charge of clusters in all OROC",4000,0,4000);
191 fQMaxPartitionAll = new TH1F("fQMaxPartitionAll", "QMax for All Partitions", 216,0,216);
192 fPlotQmaxROCAll = new TH1F("fQMaxROCAll", "QMax for All ROC", 72,0,72);
0e588049 193 fNumberOfClusters = new TH1F("fNumberOfClusters", "Total Number of Clusters", 1,0,1);
0efebbac 194
cdfe3c01 195 fHistTH2Tmp = new TH2F("fHistTH2Tmp","fHistTH2Tmp",250,-250,250,250,-250,250);
196 fHistTPCSideA = new TH2F("fHistTPCSideA","TPC side A (max signal)",250,-250,250,250,-250,250);
197 fHistTPCSideA->SetXTitle("global X (cm)"); fHistTPCSideA->SetYTitle("global Y (cm)");
198 fHistTPCSideC = new TH2F("fHistTPCSideC","TPC side C (max signal)",250,-250,250,250,-250,250);
199 fHistTPCSideC->SetXTitle("global X (cm)"); fHistTPCSideC->SetYTitle("global Y (cm)");
200
201 const TObject *iter = NULL;
202
203 for(iter = GetFirstInputObject(kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputObject()){
204
0efebbac 205// HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
206// evtData.fEventID, evtData.fEventID,
207// DataType2Text(GetDataType(iter)).c_str(),
208// DataType2Text(kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC).c_str());
cdfe3c01 209
0efebbac 210// if (GetDataType(iter) == (kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC) && GetEventCount()<2){
211// HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeHistogram)!",
212// DataType2Text(kAliHLTDataTypeHistogram).c_str(),
213// DataType2Text(kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC).c_str());
214// }
cdfe3c01 215
216 if (GetDataType(iter) != (kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC)) continue;
217
0efebbac 218 // Summing the output histograms of the AliHLTTPCNoiseMapComponent (from partition to TPC sides)
cdfe3c01 219 if(fNoiseHistograms){
220
0efebbac 221 fHistTH2Tmp = (TH2F*)iter;
222 UInt_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(iter));
223 UInt_t maxSlice = AliHLTTPCDefinitions::GetMaxSliceNr(GetSpecification(iter));
224 UInt_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(iter));
225 UInt_t maxPartition = AliHLTTPCDefinitions::GetMaxPatchNr(GetSpecification(iter));
cdfe3c01 226
0efebbac 227 if((minSlice!=maxSlice) || (minPartition!=maxPartition)){
228 HLTWarning("TPCHistogramHandler::The Noise Map component is not running on partition level!");
229 }
cdfe3c01 230
0efebbac 231 // minSlice=maxSlice, when the Noise Map component runs on partition level (as it should)
232 if(minSlice<18) fHistTPCSideA->Add(fHistTPCSideA,fHistTH2Tmp,1,1);
233 else fHistTPCSideC->Add(fHistTPCSideC,fHistTH2Tmp,1,1);
cdfe3c01 234 } // endif fNoiseHistograms==kTRUE
235
236
0efebbac 237 // Summing the output of AliHLTTPCClusterHistoComponent
238 if(fKryptonHistograms){
239 Int_t thisrow=-1,thissector=-1,row=-1;
240
241 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(iter));
242 AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(iter));
243 row = AliHLTTPCTransform::GetFirstRow(patch);
244 AliHLTTPCTransform::Slice2Sector(slice,row,thissector,thisrow);
245
246 fHistTH1Tmp = (TH1F*)iter;
247 //cout << fHistTH1Tmp->GetName() << "\t" << fHistTH1Tmp->GetEntries() << endl;
248
249 TString name = fHistTH1Tmp->GetName();
250
251 if(name=="fTotalClusterChargeIROCAll"){
252 fTotalClusterChargeIROCAll->Add(fTotalClusterChargeIROCAll,fHistTH1Tmp,1,1);
253 }
254 else if(name=="fTotalClusterChargeOROCAll"){
255 fTotalClusterChargeOROCAll->Add(fTotalClusterChargeOROCAll,fHistTH1Tmp,1,1);
256 }
257 else if(name=="fQMaxPartitionAll"){
0e588049 258 for(Int_t t=0;t<216;t++){
259 if(fHistTH1Tmp->GetBinContent(t)>fQMaxPartitionAll->GetBinContent(t)){
260 fQMaxPartitionAll->SetBinContent(t,fHistTH1Tmp->GetBinContent(t));
261 }
262 }
263 }
264 else if(name=="fQMaxROCAll"){
265 for(Int_t t=0;t<72;t++){
266 if(fHistTH1Tmp->GetBinContent(t)>fPlotQmaxROCAll->GetBinContent(t)){
267 fPlotQmaxROCAll->SetBinContent(t,fHistTH1Tmp->GetBinContent(t));
268 }
269 }
0efebbac 270 }
0efebbac 271 else if(name=="fNumberOfClusters"){
0e588049 272 fNumberOfClusters->Add(fNumberOfClusters,fHistTH1Tmp,1,1);
273 }
274 else{
275 HLTWarning("No histogram names match. %s",name.Data());
276 continue;
277 }
0efebbac 278 } //endif fKryptonHistograms==kTRUE
cdfe3c01 279 } // end for loop over histogram blocks
280
281 MakeHistosPublic();
cdfe3c01 282 return 0;
283} // end DoEvent()
284
285void AliHLTTPCHistogramHandlerComponent::MakeHistosPublic() {
286// see header file for class documentation
cdfe3c01 287
288 if(fNoiseHistograms){
0efebbac 289 PushBack((TObject*)fHistTPCSideA,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification( 0,17,0,5));
290 PushBack((TObject*)fHistTPCSideC,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(18,35,0,5));
0e588049 291
3a3550fa 292 if(fHistTH2Tmp) { delete fHistTH2Tmp; fHistTH2Tmp=NULL; }
293 if(fHistTPCSideA){ delete fHistTPCSideA; fHistTPCSideA=NULL; }
294 if(fHistTPCSideC){ delete fHistTPCSideC; fHistTPCSideC=NULL; }
0efebbac 295 }
296
297 if(fKryptonHistograms){
298 PushBack((TObject*)fTotalClusterChargeIROCAll,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(0,17,0,1));
299 PushBack((TObject*)fTotalClusterChargeOROCAll,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(0,17,2,5));
300 PushBack((TObject*)fQMaxPartitionAll, kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5));
301 PushBack((TObject*)fPlotQmaxROCAll, kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5));
302 PushBack((TObject*)fNumberOfClusters, kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5));
303
3a3550fa 304 if(fTotalClusterChargeIROCAll){ delete fTotalClusterChargeIROCAll; fTotalClusterChargeIROCAll=NULL; }
305 if(fTotalClusterChargeOROCAll){ delete fTotalClusterChargeOROCAll; fTotalClusterChargeOROCAll=NULL; }
306 if(fQMaxPartitionAll) { delete fQMaxPartitionAll; fQMaxPartitionAll=NULL; }
307 if(fPlotQmaxROCAll) { delete fPlotQmaxROCAll; fPlotQmaxROCAll=NULL; }
308 if(fNumberOfClusters) { delete fNumberOfClusters; fNumberOfClusters=NULL; }
309 if(fHistTH1Tmp) { delete fHistTH1Tmp; fHistTH1Tmp=NULL; }
cdfe3c01 310 }
311
312// TObjArray histos;
313
314// if(fPlotSideA) histos.Add(fHistSideA);
315// if(fPlotSideC) histos.Add(fHistSideC);
316// if(fApplyNoiseMap) histos.Add(fHistCDBMap);
317//
318// TIter iterator(&histos);
319// while(TObject *pObj=iterator.Next()){
320//
321// PushBack(pObj, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, fSpecification);
322// }
323//
324//
325// //PushBack( (TObject*) &histos, kAliHLTDataTypeHistogram, fSpecification);
326}
327
328int AliHLTTPCHistogramHandlerComponent::Configure(const char* arguments) {
329// see header file for class documentation
330
331 int iResult=0;
332 if (!arguments) return iResult;
333 HLTInfo("parsing configuration string \'%s\'", arguments);
334
335 TString allArgs=arguments;
336 TString argument;
337 int bMissingParam=0;
338
339 TObjArray* pTokens=allArgs.Tokenize(" ");
340 if (pTokens) {
341 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
342 argument=((TObjString*)pTokens->At(i))->GetString();
343 if (argument.IsNull()) continue;
344
345 if (argument.CompareTo("-sum-noise-histograms")==0) {
346 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
347 HLTInfo("got \'-sum-noise-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
348
349 } else if (argument.CompareTo("-sum-krypton-histograms")==0) {
350 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
351 HLTInfo("got \'-sum-krypton-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
352
353 }
354 else {
355 HLTError("unknown argument %s", argument.Data());
356 iResult=-EINVAL;
357 break;
358 }
359 } // end for
360
361 delete pTokens;
362
363 } // end if pTokens
364
365 if (bMissingParam) {
366 HLTError("missing parameter for argument %s", argument.Data());
367 iResult=-EINVAL;
368 }
369 return iResult;
370}
371
372int AliHLTTPCHistogramHandlerComponent::Reconfigure(const char* cdbEntry, const char* chainId) {
373// see header file for class documentation
374
375 int iResult=0;
376 const char* path="HLT/ConfigTPC/TPCHistogramHandlerComponent";
377 const char* defaultNotify="";
378 if (cdbEntry) {
379 path=cdbEntry;
380 defaultNotify=" (default)";
381 }
382
383 if (path) {
384 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
385 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
386 if (pEntry) {
387 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
388 if (pString) {
389 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
390 iResult=Configure(pString->GetString().Data());
391 } else {
392 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
393 }
394 } else {
395 HLTError("cannot fetch object \"%s\" from CDB", path);
396 }
397 }
398 return iResult;
399}