3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
7 //* Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> *
8 //* for The ALICE HLT Project. *
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 //**************************************************************************
19 /** @file AliHLTTPCHistogramHandlerComponent.cxx
20 @author Kalliopi Kanaki
22 @brief The Histogram Handler component
28 #include "AliHLTTPCHistogramHandlerComponent.h"
29 #include "AliHLTTPCDefinitions.h"
30 #include "AliCDBEntry.h"
31 #include "AliCDBManager.h"
32 #include "AliHLTTPCTransform.h"
38 #include "TObjArray.h"
39 #include "TObjString.h"
46 ClassImp(AliHLTTPCHistogramHandlerComponent) //ROOT macro for the implementation of ROOT specific class methods
48 AliHLTTPCHistogramHandlerComponent::AliHLTTPCHistogramHandlerComponent()
52 fKryptonHistograms(0),
56 fTotalClusterChargeIROCAll(NULL),
57 fTotalClusterChargeOROCAll(NULL),
58 fQMaxPartitionAll(NULL),
59 fPlotQmaxROCAll(NULL),
60 fNumberOfClusters(NULL),
66 // see header file for class documentation
68 // refer to README to build package
70 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
73 AliHLTTPCHistogramHandlerComponent::~AliHLTTPCHistogramHandlerComponent() {
74 // see header file for class documentation
78 // Public functions to implement AliHLTComponent's interface.
79 // These functions are required for the registration process
81 const char* AliHLTTPCHistogramHandlerComponent::GetComponentID() {
82 // see header file for class documentation
84 return "TPCHistogramHandler";
87 void AliHLTTPCHistogramHandlerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
88 // see header file for class documentation
91 list.push_back( kAliHLTDataTypeHistogram );
94 AliHLTComponentDataType AliHLTTPCHistogramHandlerComponent::GetOutputDataType() {
95 // see header file for class documentation
97 return kAliHLTDataTypeHistogram;
100 int AliHLTTPCHistogramHandlerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) {
101 // see header file for class documentation
104 tgtList.push_back(kAliHLTDataTypeHistogram);
105 return tgtList.size();
108 void AliHLTTPCHistogramHandlerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
109 // see header file for class documentation
115 AliHLTComponent* AliHLTTPCHistogramHandlerComponent::Spawn() {
116 // see header file for class documentation
118 return new AliHLTTPCHistogramHandlerComponent();
121 int AliHLTTPCHistogramHandlerComponent::DoInit( int argc, const char** argv ) {
122 // see header file for class documentation
129 TString configuration="";
131 for (int j=0; j<argc && iResult>=0; j++) {
134 if (!configuration.IsNull()) configuration+=" ";
135 configuration+=argument;
138 if (!configuration.IsNull()) {
139 iResult=Configure(configuration.Data());
141 iResult=Reconfigure(NULL, NULL);
146 if (!strcmp( argv[i], "-sum-noise-histograms")) {
147 fNoiseHistograms = strtoul( argv[i+1], &cpErr ,0);
150 HLTError("Cannot convert sum-noise-histograms specifier '%s'.", argv[i+1]);
157 if (!strcmp( argv[i], "-sum-krypton-histograms")) {
158 fKryptonHistograms = strtoul( argv[i+1], &cpErr ,0);
161 HLTError("Cannot convert sum-krypton-histograms specifier '%s'.", argv[i+1]);
168 Logging(kHLTLogError, "HLT::TPCHistogramHandler::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
176 int AliHLTTPCHistogramHandlerComponent::DoDeinit() {
177 // see header file for class documentation
182 int AliHLTTPCHistogramHandlerComponent::DoEvent(const AliHLTComponentEventData&/* evtData*/, AliHLTComponentTriggerData& /*trigData*/){
183 // see header file for class documentation
185 HLTInfo("--- Entering DoEvent() in TPCHistogramHandler ---");
187 if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )) return 0;
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);
193 fNumberOfClusters = new TH1F("fNumberOfClusters", "Total Number of Clusters", 1,0,1);
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)");
201 const TObject *iter = NULL;
203 for(iter = GetFirstInputObject(kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputObject()){
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());
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());
216 if (GetDataType(iter) != (kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC)) continue;
218 // Summing the output histograms of the AliHLTTPCNoiseMapComponent (from partition to TPC sides)
219 if(fNoiseHistograms){
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));
227 if((minSlice!=maxSlice) || (minPartition!=maxPartition)){
228 HLTWarning("TPCHistogramHandler::The Noise Map component is not running on partition level!");
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);
234 } // endif fNoiseHistograms==kTRUE
237 // Summing the output of AliHLTTPCClusterHistoComponent
238 if(fKryptonHistograms){
239 Int_t thisrow=-1,thissector=-1,row=-1;
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);
246 fHistTH1Tmp = (TH1F*)iter;
247 //cout << fHistTH1Tmp->GetName() << "\t" << fHistTH1Tmp->GetEntries() << endl;
249 TString name = fHistTH1Tmp->GetName();
251 if(name=="fTotalClusterChargeIROCAll"){
252 fTotalClusterChargeIROCAll->Add(fTotalClusterChargeIROCAll,fHistTH1Tmp,1,1);
254 else if(name=="fTotalClusterChargeOROCAll"){
255 fTotalClusterChargeOROCAll->Add(fTotalClusterChargeOROCAll,fHistTH1Tmp,1,1);
257 else if(name=="fQMaxPartitionAll"){
258 for(Int_t t=0;t<216;t++){
259 if(fHistTH1Tmp->GetBinContent(t)>fQMaxPartitionAll->GetBinContent(t)){
260 fQMaxPartitionAll->SetBinContent(t,fHistTH1Tmp->GetBinContent(t));
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));
271 else if(name=="fNumberOfClusters"){
272 fNumberOfClusters->Add(fNumberOfClusters,fHistTH1Tmp,1,1);
275 HLTWarning("No histogram names match. %s",name.Data());
278 } //endif fKryptonHistograms==kTRUE
279 } // end for loop over histogram blocks
285 void AliHLTTPCHistogramHandlerComponent::MakeHistosPublic() {
286 // see header file for class documentation
288 if(fNoiseHistograms){
289 PushBack((TObject*)fHistTPCSideA,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification( 0,17,0,5));
290 PushBack((TObject*)fHistTPCSideC,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(18,35,0,5));
292 if(fHistTH2Tmp) { delete fHistTH2Tmp; fHistTH2Tmp=NULL; }
293 if(fHistTPCSideA){ delete fHistTPCSideA; fHistTPCSideA=NULL; }
294 if(fHistTPCSideC){ delete fHistTPCSideC; fHistTPCSideC=NULL; }
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));
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; }
314 // if(fPlotSideA) histos.Add(fHistSideA);
315 // if(fPlotSideC) histos.Add(fHistSideC);
316 // if(fApplyNoiseMap) histos.Add(fHistCDBMap);
318 // TIter iterator(&histos);
319 // while(TObject *pObj=iterator.Next()){
321 // PushBack(pObj, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, fSpecification);
325 // //PushBack( (TObject*) &histos, kAliHLTDataTypeHistogram, fSpecification);
328 int AliHLTTPCHistogramHandlerComponent::Configure(const char* arguments) {
329 // see header file for class documentation
332 if (!arguments) return iResult;
333 HLTInfo("parsing configuration string \'%s\'", arguments);
335 TString allArgs=arguments;
339 TObjArray* pTokens=allArgs.Tokenize(" ");
341 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
342 argument=((TObjString*)pTokens->At(i))->GetString();
343 if (argument.IsNull()) continue;
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());
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());
355 HLTError("unknown argument %s", argument.Data());
366 HLTError("missing parameter for argument %s", argument.Data());
372 int AliHLTTPCHistogramHandlerComponent::Reconfigure(const char* cdbEntry, const char* chainId) {
373 // see header file for class documentation
376 const char* path="HLT/ConfigTPC/TPCHistogramHandlerComponent";
377 const char* defaultNotify="";
380 defaultNotify=" (default)";
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()*/);
387 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
389 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
390 iResult=Configure(pString->GetString().Data());
392 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
395 HLTError("cannot fetch object \"%s\" from CDB", path);