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