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"
37 #include "TObjArray.h"
38 #include "TObjString.h"
46 AliHLTTPCHistogramHandlerComponent gAliHLTTPCHistogramHandlerComponent;
48 ClassImp(AliHLTTPCHistogramHandlerComponent) //ROOT macro for the implementation of ROOT specific class methods
50 AliHLTTPCHistogramHandlerComponent::AliHLTTPCHistogramHandlerComponent()
53 fKryptonHistograms(0),
54 fSpecificationTPCA(0),
55 fSpecificationTPCC(0),
62 // see header file for class documentation
64 // refer to README to build package
66 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
69 AliHLTTPCHistogramHandlerComponent::~AliHLTTPCHistogramHandlerComponent() {
70 // see header file for class documentation
74 // Public functions to implement AliHLTComponent's interface.
75 // These functions are required for the registration process
77 const char* AliHLTTPCHistogramHandlerComponent::GetComponentID() {
78 // see header file for class documentation
80 return "TPCHistogramHandler";
83 void AliHLTTPCHistogramHandlerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) {
84 // see header file for class documentation
87 list.push_back( kAliHLTDataTypeHistogram );
90 AliHLTComponentDataType AliHLTTPCHistogramHandlerComponent::GetOutputDataType() {
91 // see header file for class documentation
93 return kAliHLTDataTypeHistogram;
96 int AliHLTTPCHistogramHandlerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) {
97 // see header file for class documentation
100 tgtList.push_back(kAliHLTDataTypeHistogram);
101 return tgtList.size();
104 void AliHLTTPCHistogramHandlerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) {
105 // see header file for class documentation
111 AliHLTComponent* AliHLTTPCHistogramHandlerComponent::Spawn() {
112 // see header file for class documentation
114 return new AliHLTTPCHistogramHandlerComponent();
117 int AliHLTTPCHistogramHandlerComponent::DoInit( int argc, const char** argv ) {
118 // see header file for class documentation
125 TString configuration="";
127 for (int i=0; i<argc && iResult>=0; i++) {
130 if (!configuration.IsNull()) configuration+=" ";
131 configuration+=argument;
134 if (!configuration.IsNull()) {
135 iResult=Configure(configuration.Data());
137 iResult=Reconfigure(NULL, NULL);
142 if (!strcmp( argv[i], "-sum-noise-histograms")) {
143 fNoiseHistograms = strtoul( argv[i+1], &cpErr ,0);
146 HLTError("Cannot convert sum-noise-histograms specifier '%s'.", argv[i+1]);
153 if (!strcmp( argv[i], "-sum-krypton-histograms")) {
154 fKryptonHistograms = strtoul( argv[i+1], &cpErr ,0);
157 HLTError("Cannot convert sum-krypton-histograms specifier '%s'.", argv[i+1]);
164 Logging(kHLTLogError, "HLT::TPCHistogramHandler::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] );
172 int AliHLTTPCHistogramHandlerComponent::DoDeinit() {
173 // see header file for class documentation
178 int AliHLTTPCHistogramHandlerComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData){
179 // see header file for class documentation
181 HLTInfo("--- Entering DoEvent() in TPCHistogramHandler ---");
183 if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )) return 0;
185 fHistTH2Tmp = new TH2F("fHistTH2Tmp","fHistTH2Tmp",250,-250,250,250,-250,250);
186 fHistTPCSideA = new TH2F("fHistTPCSideA","TPC side A (max signal)",250,-250,250,250,-250,250);
187 fHistTPCSideA->SetXTitle("global X (cm)"); fHistTPCSideA->SetYTitle("global Y (cm)");
188 fHistTPCSideC = new TH2F("fHistTPCSideC","TPC side C (max signal)",250,-250,250,250,-250,250);
189 fHistTPCSideC->SetXTitle("global X (cm)"); fHistTPCSideC->SetYTitle("global Y (cm)");
191 const TObject *iter = NULL;
193 for(iter = GetFirstInputObject(kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputObject()){
195 HLTInfo("Event 0x%08LX (%Lu) received datatype: %s - required datatype: %s",
196 evtData.fEventID, evtData.fEventID,
197 DataType2Text(GetDataType(iter)).c_str(),
198 DataType2Text(kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC).c_str());
200 if (GetDataType(iter) == (kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC) && GetEventCount()<2){
201 HLTWarning("data type %s is depricated, use %s (kAliHLTDataTypeHistogram)!",
202 DataType2Text(kAliHLTDataTypeHistogram).c_str(),
203 DataType2Text(kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC).c_str());
206 if (GetDataType(iter) != (kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC)) continue;
208 // Summing the output histograms of the TPCNoiseMapComponent (from partition to TPC sides)
209 if(fNoiseHistograms){
211 fHistTH2Tmp = (TH2F*)iter;
212 UInt_t minSlice = AliHLTTPCDefinitions::GetMinSliceNr(GetSpecification(iter));
213 UInt_t maxSlice = AliHLTTPCDefinitions::GetMaxSliceNr(GetSpecification(iter));
214 UInt_t minPartition = AliHLTTPCDefinitions::GetMinPatchNr(GetSpecification(iter));
215 UInt_t maxPartition = AliHLTTPCDefinitions::GetMaxPatchNr(GetSpecification(iter));
217 if((minSlice!=maxSlice) || (minPartition!=maxPartition)){
218 HLTWarning("TPCHistogramHandler::The Noise Map component is not running on partition level!");
221 if(minSlice<18) fHistTPCSideA->Add(fHistTPCSideA,fHistTH2Tmp,1,1);
222 else fHistTPCSideC->Add(fHistTPCSideC,fHistTH2Tmp,1,1);
223 // minSlice=maxSlice, when the Noise Map component runs on partition level (as it should)
225 fSpecificationTPCA = AliHLTTPCDefinitions::EncodeDataSpecification( 17, 0, 5, 0 );
226 fSpecificationTPCC = AliHLTTPCDefinitions::EncodeDataSpecification( 35, 18, 5, 0 );
228 } // endif fNoiseHistograms==kTRUE
231 // Summing the output of TPCKryptonClusterFinderComponent
232 // if(fKryptonHistograms){
234 // } //endif fKryptonHistograms==kTRUE
235 } // end for loop over histogram blocks
242 void AliHLTTPCHistogramHandlerComponent::MakeHistosPublic() {
243 // see header file for class documentation
246 if(fNoiseHistograms){
247 PushBack( (TObject*) fHistTPCSideA, kAliHLTDataTypeHistogram, fSpecificationTPCA);
248 PushBack( (TObject*) fHistTPCSideC, kAliHLTDataTypeHistogram, fSpecificationTPCC);
250 delete fHistTPCSideA;
251 delete fHistTPCSideC;
256 // if(fPlotSideA) histos.Add(fHistSideA);
257 // if(fPlotSideC) histos.Add(fHistSideC);
258 // if(fApplyNoiseMap) histos.Add(fHistCDBMap);
260 // TIter iterator(&histos);
261 // while(TObject *pObj=iterator.Next()){
263 // PushBack(pObj, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, fSpecification);
267 // //PushBack( (TObject*) &histos, kAliHLTDataTypeHistogram, fSpecification);
270 int AliHLTTPCHistogramHandlerComponent::Configure(const char* arguments) {
271 // see header file for class documentation
274 if (!arguments) return iResult;
275 HLTInfo("parsing configuration string \'%s\'", arguments);
277 TString allArgs=arguments;
281 TObjArray* pTokens=allArgs.Tokenize(" ");
283 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
284 argument=((TObjString*)pTokens->At(i))->GetString();
285 if (argument.IsNull()) continue;
287 if (argument.CompareTo("-sum-noise-histograms")==0) {
288 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
289 HLTInfo("got \'-sum-noise-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
291 } else if (argument.CompareTo("-sum-krypton-histograms")==0) {
292 if ((bMissingParam=(++i>=pTokens->GetEntries()))) break;
293 HLTInfo("got \'-sum-krypton-histograms\': %s", ((TObjString*)pTokens->At(i))->GetString().Data());
297 HLTError("unknown argument %s", argument.Data());
308 HLTError("missing parameter for argument %s", argument.Data());
314 int AliHLTTPCHistogramHandlerComponent::Reconfigure(const char* cdbEntry, const char* chainId) {
315 // see header file for class documentation
318 const char* path="HLT/ConfigTPC/TPCHistogramHandlerComponent";
319 const char* defaultNotify="";
322 defaultNotify=" (default)";
326 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
327 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
329 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
331 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
332 iResult=Configure(pString->GetString().Data());
334 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
337 HLTError("cannot fetch object \"%s\" from CDB", path);