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"
47 AliHLTTPCHistogramHandlerComponent gAliHLTTPCHistogramHandlerComponent;
49 ClassImp(AliHLTTPCHistogramHandlerComponent) //ROOT macro for the implementation of ROOT specific class methods
51 AliHLTTPCHistogramHandlerComponent::AliHLTTPCHistogramHandlerComponent()
54 fKryptonHistograms(0),
58 fTotalClusterChargeIROCAll(NULL),
59 fTotalClusterChargeOROCAll(NULL),
60 fQMaxPartitionAll(NULL),
61 fPlotQmaxROCAll(NULL),
62 fNumberOfClusters(NULL),
68 // see header file for class documentation
70 // refer to README to build package
72 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
75 AliHLTTPCHistogramHandlerComponent::~AliHLTTPCHistogramHandlerComponent() {
76 // see header file for class documentation
80 // Public functions to implement AliHLTComponent's interface.
81 // These functions are required for the registration process
83 const char* AliHLTTPCHistogramHandlerComponent::GetComponentID() {
84 // see header file for class documentation
86 return "TPCHistogramHandler";
89 void AliHLTTPCHistogramHandlerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
90 // see header file for class documentation
93 list.push_back( kAliHLTDataTypeHistogram );
96 AliHLTComponentDataType AliHLTTPCHistogramHandlerComponent::GetOutputDataType() {
97 // see header file for class documentation
99 return kAliHLTDataTypeHistogram;
102 int AliHLTTPCHistogramHandlerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) {
103 // see header file for class documentation
106 tgtList.push_back(kAliHLTDataTypeHistogram);
107 return tgtList.size();
110 void AliHLTTPCHistogramHandlerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
111 // see header file for class documentation
117 AliHLTComponent* AliHLTTPCHistogramHandlerComponent::Spawn() {
118 // see header file for class documentation
120 return new AliHLTTPCHistogramHandlerComponent();
123 int AliHLTTPCHistogramHandlerComponent::DoInit( int argc, const char** argv ) {
124 // see header file for class documentation
131 TString configuration="";
133 for (int i=0; i<argc && iResult>=0; i++) {
136 if (!configuration.IsNull()) configuration+=" ";
137 configuration+=argument;
140 if (!configuration.IsNull()) {
141 iResult=Configure(configuration.Data());
143 iResult=Reconfigure(NULL, NULL);
148 if (!strcmp( argv[i], "-sum-noise-histograms")) {
149 fNoiseHistograms = strtoul( argv[i+1], &cpErr ,0);
152 HLTError("Cannot convert sum-noise-histograms specifier '%s'.", argv[i+1]);
159 if (!strcmp( argv[i], "-sum-krypton-histograms")) {
160 fKryptonHistograms = strtoul( argv[i+1], &cpErr ,0);
163 HLTError("Cannot convert sum-krypton-histograms specifier '%s'.", argv[i+1]);
170 Logging(kHLTLogError, "HLT::TPCHistogramHandler::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
178 int AliHLTTPCHistogramHandlerComponent::DoDeinit() {
179 // see header file for class documentation
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 fTotalClusterChargeIROCAll = new TH1F("fTotalClusterChargeIROCAll","Total Charge of clusters in all IROC",4000,0,4000);
192 fTotalClusterChargeOROCAll = new TH1F("fTotalClusterChargeOROCAll","Total Charge of clusters in all OROC",4000,0,4000);
193 fQMaxPartitionAll = new TH1F("fQMaxPartitionAll", "QMax for All Partitions", 216,0,216);
194 fPlotQmaxROCAll = new TH1F("fQMaxROCAll", "QMax for All ROC", 72,0,72);
195 fNumberOfClusters = new TH1F("fNumberOfClusters", "Total Number of Clusters", 100,0,100);
197 fHistTH2Tmp = new TH2F("fHistTH2Tmp","fHistTH2Tmp",250,-250,250,250,-250,250);
198 fHistTPCSideA = new TH2F("fHistTPCSideA","TPC side A (max signal)",250,-250,250,250,-250,250);
199 fHistTPCSideA->SetXTitle("global X (cm)"); fHistTPCSideA->SetYTitle("global Y (cm)");
200 fHistTPCSideC = new TH2F("fHistTPCSideC","TPC side C (max signal)",250,-250,250,250,-250,250);
201 fHistTPCSideC->SetXTitle("global X (cm)"); fHistTPCSideC->SetYTitle("global Y (cm)");
203 const TObject *iter = NULL;
205 for(iter = GetFirstInputObject(kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputObject()){
207 // HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
208 // evtData.fEventID, evtData.fEventID,
209 // DataType2Text(GetDataType(iter)).c_str(),
210 // DataType2Text(kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC).c_str());
212 // if (GetDataType(iter) == (kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC) && GetEventCount()<2){
213 // HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeHistogram)!",
214 // DataType2Text(kAliHLTDataTypeHistogram).c_str(),
215 // DataType2Text(kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC).c_str());
218 if (GetDataType(iter) != (kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC)) continue;
220 // Summing the output histograms of the AliHLTTPCNoiseMapComponent (from partition to TPC sides)
221 if(fNoiseHistograms){
223 fHistTH2Tmp = (TH2F*)iter;
224 UInt_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(iter));
225 UInt_t maxSlice = AliHLTTPCDefinitions::GetMaxSliceNr(GetSpecification(iter));
226 UInt_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(iter));
227 UInt_t maxPartition = AliHLTTPCDefinitions::GetMaxPatchNr(GetSpecification(iter));
229 if((minSlice!=maxSlice) || (minPartition!=maxPartition)){
230 HLTWarning("TPCHistogramHandler::The Noise Map component is not running on partition level!");
233 // minSlice=maxSlice, when the Noise Map component runs on partition level (as it should)
234 if(minSlice<18) fHistTPCSideA->Add(fHistTPCSideA,fHistTH2Tmp,1,1);
235 else fHistTPCSideC->Add(fHistTPCSideC,fHistTH2Tmp,1,1);
236 } // endif fNoiseHistograms==kTRUE
239 // Summing the output of AliHLTTPCClusterHistoComponent
240 if(fKryptonHistograms){
241 Int_t thisrow=-1,thissector=-1,row=-1;
243 AliHLTUInt8_t slice = AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(iter));
244 AliHLTUInt8_t patch = AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(iter));
245 row = AliHLTTPCTransform::GetFirstRow(patch);
246 AliHLTTPCTransform::Slice2Sector(slice,row,thissector,thisrow);
248 fHistTH1Tmp = (TH1F*)iter;
249 //cout << fHistTH1Tmp->GetName() << "\t" << fHistTH1Tmp->GetEntries() << endl;
251 TString name = fHistTH1Tmp->GetName();
253 if(name=="fTotalClusterChargeIROCAll"){
254 fTotalClusterChargeIROCAll->Add(fTotalClusterChargeIROCAll,fHistTH1Tmp,1,1);
256 else if(name=="fTotalClusterChargeOROCAll"){
257 fTotalClusterChargeOROCAll->Add(fTotalClusterChargeOROCAll,fHistTH1Tmp,1,1);
259 else if(name=="fQMaxPartitionAll"){
260 AliHLTUInt8_t partitionNr=patch+slice*6;
261 // if(fHistTH1Tmp->GetBinContent(partitionNr)>fQMaxPartitionAll->GetBinContent(partitionNr)){
262 fQMaxPartitionAll->SetBinContent(partitionNr,fHistTH1Tmp->GetBinContent(partitionNr));
264 fQMaxPartitionAll->Add(fQMaxPartitionAll,fHistTH1Tmp,1,1);
266 else if(name=="fPlotQmaxROCAll"){
267 // if(fHistTH1Tmp->GetBinContent(thissector)>fPlotQmaxROCAll->GetBinContent(thissector)){
268 // fPlotQmaxROCAll->SetBinContent(thissector,fHistTH1Tmp->GetBinContent(thissector));
270 fPlotQmaxROCAll->Add(fPlotQmaxROCAll,fHistTH1Tmp,1,1);
272 else if(name=="fNumberOfClusters"){
273 // fNumberOfClusters->Add(fNumberOfClusters,fHistTH1Tmp,1,1);
275 } //endif fKryptonHistograms==kTRUE
276 } // end for loop over histogram blocks
282 void AliHLTTPCHistogramHandlerComponent::MakeHistosPublic() {
283 // see header file for class documentation
285 if(fNoiseHistograms){
286 PushBack((TObject*)fHistTPCSideA,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification( 0,17,0,5));
287 PushBack((TObject*)fHistTPCSideC,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(18,35,0,5));
289 delete fHistTPCSideA;
290 delete fHistTPCSideC;
293 if(fKryptonHistograms){
294 PushBack((TObject*)fTotalClusterChargeIROCAll,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(0,17,0,1));
295 PushBack((TObject*)fTotalClusterChargeOROCAll,kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(0,17,2,5));
296 PushBack((TObject*)fQMaxPartitionAll, kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5));
297 PushBack((TObject*)fPlotQmaxROCAll, kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5));
298 PushBack((TObject*)fNumberOfClusters, kAliHLTDataTypeHistogram,AliHLTTPCDefinitions::EncodeDataSpecification(0,35,0,5));
300 delete fTotalClusterChargeIROCAll;
301 delete fTotalClusterChargeOROCAll;
302 delete fQMaxPartitionAll;
303 delete fPlotQmaxROCAll;
304 delete fNumberOfClusters;
309 // if(fPlotSideA) histos.Add(fHistSideA);
310 // if(fPlotSideC) histos.Add(fHistSideC);
311 // if(fApplyNoiseMap) histos.Add(fHistCDBMap);
313 // TIter iterator(&histos);
314 // while(TObject *pObj=iterator.Next()){
316 // PushBack(pObj, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, fSpecification);
320 // //PushBack( (TObject*) &histos, kAliHLTDataTypeHistogram, fSpecification);
323 int AliHLTTPCHistogramHandlerComponent::Configure(const char* arguments) {
324 // see header file for class documentation
327 if (!arguments) return iResult;
328 HLTInfo("parsing configuration string \'%s\'", arguments);
330 TString allArgs=arguments;
334 TObjArray* pTokens=allArgs.Tokenize(" ");
336 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
337 argument=((TObjString*)pTokens->At(i))->GetString();
338 if (argument.IsNull()) continue;
340 if (argument.CompareTo("-sum-noise-histograms")==0) {
341 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
342 HLTInfo("got \'-sum-noise-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
344 } else if (argument.CompareTo("-sum-krypton-histograms")==0) {
345 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
346 HLTInfo("got \'-sum-krypton-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
350 HLTError("unknown argument %s", argument.Data());
361 HLTError("missing parameter for argument %s", argument.Data());
367 int AliHLTTPCHistogramHandlerComponent::Reconfigure(const char* cdbEntry, const char* chainId) {
368 // see header file for class documentation
371 const char* path="HLT/ConfigTPC/TPCHistogramHandlerComponent";
372 const char* defaultNotify="";
375 defaultNotify=" (default)";
379 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
380 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
382 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
384 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
385 iResult=Configure(pString->GetString().Data());
387 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
390 HLTError("cannot fetch object \"%s\" from CDB", path);