2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project *
4 //* ALICE Experiment at CERN, All rights reserved. *
6 //* Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
7 //* for The ALICE HLT Project. *
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 //**************************************************************************
18 /** @file AliHLTTPCHistogramHandlerComponent.cxx
19 @author Kalliopi Kanaki
21 @brief The Histogram Handler component
24 #include "AliHLTTPCHistogramHandlerComponent.h"
25 #include "AliHLTTPCDefinitions.h"
26 #include "AliCDBEntry.h"
27 #include "AliCDBManager.h"
28 #include "AliHLTTPCTransform.h"
34 #include "TObjArray.h"
35 #include "TObjString.h"
44 ClassImp(AliHLTTPCHistogramHandlerComponent) //ROOT macro for the implementation of ROOT specific class methods
46 AliHLTTPCHistogramHandlerComponent::AliHLTTPCHistogramHandlerComponent()
50 fKryptonHistograms(0),
52 fIgnoreSpecification(kFALSE),
56 fTotalClusterChargeIROCAll(NULL),
57 fTotalClusterChargeOROCAll(NULL),
58 fQMaxPartitionAll(NULL),
59 fPlotQmaxROCAll(NULL),
60 fNumberOfClusters(NULL),
63 fHistTPCSideAmax(NULL),
64 fHistTPCSideCmax(NULL),
65 fHistTPCSideAtot(NULL),
66 fHistTPCSideCtot(NULL),
67 fHistTPCSideArms(NULL),
68 fHistTPCSideCrms(NULL),
72 // see header file for class documentation
74 // refer to README to build package
76 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
79 AliHLTTPCHistogramHandlerComponent::~AliHLTTPCHistogramHandlerComponent() {
80 // see header file for class documentation
84 // Public functions to implement AliHLTComponent's interface.
85 // These functions are required for the registration process
87 const char* AliHLTTPCHistogramHandlerComponent::GetComponentID() {
88 // see header file for class documentation
90 return "TPCHistogramHandler";
93 void AliHLTTPCHistogramHandlerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
94 // see header file for class documentation
97 list.push_back( kAliHLTDataTypeHistogram );
100 AliHLTComponentDataType AliHLTTPCHistogramHandlerComponent::GetOutputDataType() {
101 // see header file for class documentation
103 return kAliHLTDataTypeHistogram;
106 int AliHLTTPCHistogramHandlerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) {
107 // see header file for class documentation
110 tgtList.push_back(kAliHLTDataTypeHistogram);
111 return tgtList.size();
114 void AliHLTTPCHistogramHandlerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
115 // see header file for class documentation
121 AliHLTComponent* AliHLTTPCHistogramHandlerComponent::Spawn() {
122 // see header file for class documentation
124 return new AliHLTTPCHistogramHandlerComponent();
127 int AliHLTTPCHistogramHandlerComponent::DoInit( int argc, const char** argv ) {
128 // see header file for class documentation
135 TString configuration="";
137 for (int j=0; j<argc && iResult>=0; j++) {
140 if (!configuration.IsNull()) configuration+=" ";
141 configuration+=argument;
144 if (!configuration.IsNull()) {
145 iResult=Configure(configuration.Data());
147 iResult=Reconfigure(NULL, NULL);
150 if(fUseGeneral == kFALSE){
151 fHistTPCSideAmax = new TH2F("fHistTPCSideAmax","TPC side A (max signal)",250,-250,250,250,-250,250);
152 fHistTPCSideAmax->SetXTitle("global X (cm)"); fHistTPCSideAmax->SetYTitle("global Y (cm)");
153 fHistTPCSideCmax = new TH2F("fHistTPCSideCmax","TPC side C (max signal)",250,-250,250,250,-250,250);
154 fHistTPCSideCmax->SetXTitle("global X (cm)"); fHistTPCSideCmax->SetYTitle("global Y (cm)");
156 fHistTPCSideAtot = new TH2F("fHistTPCSideAtot","TPC side A (total signal)",250,-250,250,250,-250,250);
157 fHistTPCSideAtot->SetXTitle("global X (cm)"); fHistTPCSideAtot->SetYTitle("global Y (cm)");
158 fHistTPCSideCtot = new TH2F("fHistTPCSideCtot","TPC side C (total signal)",250,-250,250,250,-250,250);
159 fHistTPCSideCtot->SetXTitle("global X (cm)"); fHistTPCSideCtot->SetYTitle("global Y (cm)");
161 fHistTPCSideArms = new TH2F("fHistTPCSideArms","TPC side A (baseline RMS)",250,-250,250,250,-250,250);
162 fHistTPCSideArms->SetXTitle("global X (cm)"); fHistTPCSideArms->SetYTitle("global Y (cm)");
163 fHistTPCSideCrms = new TH2F("fHistTPCSideCrms","TPC side C (baseline RMS)",250,-250,250,250,-250,250);
164 fHistTPCSideCrms->SetXTitle("global X (cm)"); fHistTPCSideCrms->SetYTitle("global Y (cm)");
169 int AliHLTTPCHistogramHandlerComponent::DoDeinit() {
170 // see header file for class documentation
172 if(fHistTPCSideAmax){ delete fHistTPCSideAmax; fHistTPCSideAmax=NULL; }
173 if(fHistTPCSideCmax){ delete fHistTPCSideCmax; fHistTPCSideCmax=NULL; }
175 if(fHistTPCSideAtot){ delete fHistTPCSideAtot; fHistTPCSideAtot=NULL; }
176 if(fHistTPCSideCtot){ delete fHistTPCSideCtot; fHistTPCSideCtot=NULL; }
178 if(fHistTPCSideArms){ delete fHistTPCSideArms; fHistTPCSideArms=NULL; }
179 if(fHistTPCSideCrms){ delete fHistTPCSideCrms; fHistTPCSideCrms=NULL; }
184 int AliHLTTPCHistogramHandlerComponent::DoEvent(const AliHLTComponentEventData&/* evtData*/, AliHLTComponentTriggerData& /*trigData*/){
185 // see header file for class documentation
187 //HLTInfo("--- Entering DoEvent() in TPCHistogramHandler ---");
189 if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )) return 0;
191 if(fUseGeneral == kFALSE){
192 fTotalClusterChargeIROCAll = new TH1F("fTotalClusterChargeIROCAll","Total Charge of clusters in all IROC",4000,0,4000);
193 fTotalClusterChargeOROCAll = new TH1F("fTotalClusterChargeOROCAll","Total Charge of clusters in all OROC",4000,0,4000);
194 fQMaxPartitionAll = new TH1F("fQMaxPartitionAll", "QMax for All Partitions", 216,0,216);
195 fPlotQmaxROCAll = new TH1F("fQMaxROCAll", "QMax for All ROC", 72,0,72);
196 fNumberOfClusters = new TH1F("fNumberOfClusters", "Total Number of Clusters", 1,0,1);
199 const TObject *iter = NULL;
200 for(iter = GetFirstInputObject(kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputObject()){
202 // HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
203 // evtData.fEventID, evtData.fEventID,
204 // DataType2Text(GetDataType(iter)).c_str(),
205 // DataType2Text(kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC).c_str());
207 // if (GetDataType(iter) == (kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC) && GetEventCount()<2){
208 // HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeHistogram)!",
209 // DataType2Text(kAliHLTDataTypeHistogram).c_str(),
210 // DataType2Text(kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC).c_str());
213 if (GetDataType(iter) != (kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC)) continue;
215 // Summing the output histograms of the AliHLTTPCNoiseMapComponent (from partition to TPC sides)
217 if(fUseGeneral == kFALSE){
218 if(fNoiseHistograms == kTRUE){
220 fHistTH2Tmp = (TH2F*)iter;
221 TString histName = fHistTH2Tmp->GetName();
223 UInt_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(iter));
224 UInt_t maxSlice = AliHLTTPCDefinitions::GetMaxSliceNr(GetSpecification(iter));
225 UInt_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(iter));
226 UInt_t maxPartition = AliHLTTPCDefinitions::GetMaxPatchNr(GetSpecification(iter));
228 if((minSlice!=maxSlice) || (minPartition!=maxPartition)){
229 HLTWarning("TPCHistogramHandler::The Noise Map component is not running on partition level!");
232 // minSlice=maxSlice, when the Noise Map component runs on partition level (as it should)
234 if (histName.Contains("fHistSideAMaxSignal")) fHistTPCSideAmax->Add(fHistTH2Tmp,1);
235 else if(histName.Contains("fHistSideATotSignal")) fHistTPCSideAtot->Add(fHistTH2Tmp,1);
236 else if(histName.Contains("fHistSideAPadRMS")) fHistTPCSideArms->Add(fHistTH2Tmp,1);
237 else if(histName.Contains("fHistSideCMaxSignal")) fHistTPCSideCmax->Add(fHistTH2Tmp,1);
238 else if(histName.Contains("fHistSideCTotSignal")) fHistTPCSideCtot->Add(fHistTH2Tmp,1);
239 else if(histName.Contains("fHistSideCPadRMS")) fHistTPCSideCrms->Add(fHistTH2Tmp,1);
242 } // endif fNoiseHistograms==kTRUE
244 // Summing the output of AliHLTTPCClusterHistoComponent
245 if(fKryptonHistograms){
246 Int_t thisrow=-1,thissector=-1,row=-1;
248 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(iter));
249 AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(iter));
250 row = AliHLTTPCTransform::GetFirstRow(patch);
251 AliHLTTPCTransform::Slice2Sector(slice,row,thissector,thisrow);
253 fHistTH1Tmp = (TH1F*)iter;
254 TString name = fHistTH1Tmp->GetName();
256 if(name=="fTotalClusterChargeIROCAll"){
257 fTotalClusterChargeIROCAll->Add(fTotalClusterChargeIROCAll,fHistTH1Tmp,1,1);
259 else if(name=="fTotalClusterChargeOROCAll"){
260 fTotalClusterChargeOROCAll->Add(fTotalClusterChargeOROCAll,fHistTH1Tmp,1,1);
262 else if(name=="fQMaxPartitionAll"){
263 for(Int_t t=0;t<216;t++){
264 if(fHistTH1Tmp->GetBinContent(t)>fQMaxPartitionAll->GetBinContent(t)){
265 fQMaxPartitionAll->SetBinContent(t,fHistTH1Tmp->GetBinContent(t));
269 else if(name=="fQMaxROCAll"){
270 for(Int_t t=0;t<72;t++){
271 if(fHistTH1Tmp->GetBinContent(t)>fPlotQmaxROCAll->GetBinContent(t)){
272 fPlotQmaxROCAll->SetBinContent(t,fHistTH1Tmp->GetBinContent(t));
276 else if(name=="fNumberOfClusters"){
277 fNumberOfClusters->Add(fNumberOfClusters,fHistTH1Tmp,1,1);
280 HLTWarning("No histogram names match. %s",name.Data());
283 } //endif fKryptonHistograms==kTRUE
286 else { // means fUseGeneral ==kTRUE
288 TH1 * tmp = (TH1*)iter;
289 TString histName = tmp->GetName();
290 UInt_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(iter));
291 UInt_t maxSlice = AliHLTTPCDefinitions::GetMaxSliceNr(GetSpecification(iter));
292 UInt_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(iter));
293 UInt_t maxPartition = AliHLTTPCDefinitions::GetMaxPatchNr(GetSpecification(iter));
295 Bool_t histogramNotAdded = kTRUE;
297 for(UInt_t i=0;i<fHistogramData.size();i++){
298 if(fIgnoreSpecification == kTRUE){
301 if(histName.Contains(Form("_Slice_%.2d%.2d_Partition_%.2d%.2d", minSlice, maxSlice, minPartition, maxPartition))){
302 cout << "HistogramContains the given string." << endl;
305 histName.ReplaceAll(Form("_Slice_%.2d%.2d_Partition_%.2d%.2d", minSlice, maxSlice, minPartition, maxPartition),"");
308 if(histName.CompareTo(fHistogramData.at(i).fHistogram->GetName())==0){
309 if((minSlice==fHistogramData.at(i).fMinSlice && maxSlice == fHistogramData.at(i).fMaxSlice) || fIgnoreSpecification == kTRUE){
310 if((minPartition==fHistogramData.at(i).fMinPartition && maxPartition == fHistogramData.at(i).fMaxPartition) || fIgnoreSpecification == kTRUE){
311 fHistogramData.at(i).fHistogram->Add(tmp);
312 histogramNotAdded = kFALSE;
316 HLTWarning("Histogram with same name does not have the same partition specification");
320 HLTWarning("Histogram with same name does not have the same slice specification");
325 if(fHistogramData.size()==0){
326 if(fIgnoreSpecification == kTRUE){
327 if(histName.Contains(Form("_Slice_%.2d%.2d_Partition_%.2d%.2d", minSlice, maxSlice, minPartition, maxPartition))){
328 cout << "HistogramContains the given string." << endl;
330 histName.ReplaceAll(Form("_Slice_%.2d%.2d_Partition_%.2d%.2d", minSlice, maxSlice, minPartition, maxPartition),"");
334 if(histogramNotAdded == kTRUE){
335 tmp->SetName(histName);
336 AliHLTHistogramData histogramData;
337 histogramData.fHistogram = tmp;
338 histogramData.fMinSlice = minSlice;
339 histogramData.fMaxSlice = maxSlice;
340 histogramData.fMinPartition = minPartition;
341 histogramData.fMaxPartition = maxPartition;
342 fHistogramData.push_back(histogramData);
345 } // end for loop over histogram blocks
351 void AliHLTTPCHistogramHandlerComponent::MakeHistosPublic() {
352 // see header file for class documentation
354 if(fUseGeneral == kFALSE){
355 if(fNoiseHistograms){
356 PushBack((TObject*)fHistTPCSideAmax,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification( 0,17,0,5));
357 PushBack((TObject*)fHistTPCSideCmax,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(18,35,0,5));
359 PushBack((TObject*)fHistTPCSideAtot,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification( 0,17,0,5));
360 PushBack((TObject*)fHistTPCSideCtot,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(18,35,0,5));
362 PushBack((TObject*)fHistTPCSideArms,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification( 0,17,0,5));
363 PushBack((TObject*)fHistTPCSideCrms,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(18,35,0,5));
365 //if(fHistTH2Tmp) { delete fHistTH2Tmp; fHistTH2Tmp=NULL; }
366 // if(fHistTPCSideA){ delete fHistTPCSideA; fHistTPCSideA=NULL; }
367 // if(fHistTPCSideC){ delete fHistTPCSideC; fHistTPCSideC=NULL; }
370 if(fKryptonHistograms){
371 PushBack((TObject*)fTotalClusterChargeIROCAll,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(0,17,0,1));
372 PushBack((TObject*)fTotalClusterChargeOROCAll,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(0,17,2,5));
373 PushBack((TObject*)fQMaxPartitionAll, kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5));
374 PushBack((TObject*)fPlotQmaxROCAll, kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5));
375 PushBack((TObject*)fNumberOfClusters, kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5));
377 if(fTotalClusterChargeIROCAll){ delete fTotalClusterChargeIROCAll; fTotalClusterChargeIROCAll=NULL; }
378 if(fTotalClusterChargeOROCAll){ delete fTotalClusterChargeOROCAll; fTotalClusterChargeOROCAll=NULL; }
379 if(fQMaxPartitionAll) { delete fQMaxPartitionAll; fQMaxPartitionAll=NULL; }
380 if(fPlotQmaxROCAll) { delete fPlotQmaxROCAll; fPlotQmaxROCAll=NULL; }
381 if(fNumberOfClusters) { delete fNumberOfClusters; fNumberOfClusters=NULL; }
382 if(fHistTH1Tmp) { delete fHistTH1Tmp; fHistTH1Tmp=NULL; }
385 else{ // means fUseGeneral == kTRUE
386 for(UInt_t i=0;i<fHistogramData.size();i++){
387 PushBack((TObject*)fHistogramData.at(i).fHistogram,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(
388 fHistogramData.at(i).fMinSlice,fHistogramData.at(i).fMaxSlice,fHistogramData.at(i).fMinPartition,fHistogramData.at(i).fMaxPartition));
390 fHistogramData.clear();
394 // if(fPlotSideA) histos.Add(fHistSideA);
395 // if(fPlotSideC) histos.Add(fHistSideC);
396 // if(fApplyNoiseMap) histos.Add(fHistCDBMap);
398 // TIter iterator(&histos);
399 // while(TObject *pObj=iterator.Next()){
401 // PushBack(pObj, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, fSpecification);
405 // //PushBack( (TObject*) &histos, kAliHLTDataTypeHistogram, fSpecification);
408 int AliHLTTPCHistogramHandlerComponent::Configure(const char* arguments) {
409 // see header file for class documentation
412 if (!arguments) return iResult;
413 HLTInfo("parsing configuration string \'%s\'", arguments);
415 TString allArgs=arguments;
419 TObjArray* pTokens=allArgs.Tokenize(" ");
421 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
422 argument=((TObjString*)pTokens->At(i))->GetString();
423 if (argument.IsNull()) continue;
425 if (argument.CompareTo("-sum-noise-histograms")==0) {
426 fNoiseHistograms = kTRUE;
427 HLTInfo("got \'-sum-noise-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
429 } else if (argument.CompareTo("-sum-krypton-histograms")==0) {
430 fKryptonHistograms = kTRUE;
431 HLTInfo("got \'-sum-krypton-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
433 } else if (argument.CompareTo("-use-general")==0) {
435 HLTInfo("got \'-use-general\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
437 } else if (argument.CompareTo("-ignore-specification")==0) {
438 fIgnoreSpecification = kTRUE;
439 HLTInfo("got \'-ignore-specification\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
442 HLTError("unknown argument %s", argument.Data());
448 /*for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
449 argument=((TObjString*)pTokens->At(i))->GetString();
450 if (argument.IsNull()) continue;
452 if (argument.CompareTo("-sum-noise-histograms")==0) {
453 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
454 HLTInfo("got \'-sum-noise-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
456 } else if (argument.CompareTo("-sum-krypton-histograms")==0) {
457 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
458 HLTInfo("got \'-sum-krypton-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
460 } else if (argument.CompareTo("-use-general")==0) {
462 HLTInfo("got \'-use-general\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
464 } else if (argument.CompareTo("-ignore-specification")==0) {
465 fIgnoreSpecification = kTRUE;
466 HLTInfo("got \'-ignore-specification\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
469 HLTError("unknown argument %s", argument.Data());
480 HLTError("missing parameter for argument %s", argument.Data());
486 int AliHLTTPCHistogramHandlerComponent::Reconfigure(const char* cdbEntry, const char* chainId) {
487 // see header file for class documentation
490 const char* path="HLT/ConfigTPC/TPCHistogramHandlerComponent";
491 const char* defaultNotify="";
494 defaultNotify=" (default)";
498 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
499 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
501 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
503 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
504 iResult=Configure(pString->GetString().Data());
506 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
509 HLTError("cannot fetch object \"%s\" from CDB", path);