1 //**************************************************************************
2 //* This file is property of and copyright by the ALICE HLT Project *
3 //* ALICE Experiment at CERN, All rights reserved. *
5 //* Primary Author: Arshad Ahmad Masoodi <Arshad.Ahmad@cern.ch> *
6 //* for The ALICE HLT Project. *
8 //* Permission to use, copy, modify and distribute this software and its *
9 //* documentation strictly for non-commercial purposes is hereby granted *
10 //* without fee, provided that the above copyright notice appears in all *
11 //* copies and that both the copyright notice and this permission notice *
12 //* appear in the supporting documentation. The authors make no claims *
13 //* about the suitability of this software for any purpose. It is *
14 //* provided "as is" without express or implied warranty. *
15 //**************************************************************************
17 /** @file AliHLTMUONClusterHistoComponent.cxx
18 @author Arshad Ahmad <Arshad.Ahmad@cern.ch>
20 @brief Component for onlinehistograms
27 #include "AliHLTMUONClusterHistoComponent.h"
28 #include "AliCDBEntry.h"
29 #include "AliCDBManager.h"
30 #include "AliHLTDataTypes.h"
31 #include "AliHLTMUONConstants.h"
32 #include "AliHLTMUONClustersBlockStruct.h"
33 #include "AliHLTMUONDataBlockReader.h"
36 #include "TObjString.h"
37 #include "TObjArray.h"
40 /** ROOT macro for the implementation of ROOT specific class methods */
41 ClassImp(AliHLTMUONClusterHistoComponent);
43 AliHLTMUONClusterHistoComponent::AliHLTMUONClusterHistoComponent() :
44 AliHLTMUONProcessor(),
45 fChargePerClusterBending(NULL),
46 fChargePerClusterNonBending(NULL),
47 fNumberOfClusters(NULL),
48 fPlotChargePerClusterBending(kTRUE),
49 fPlotChargePerClusterNonBending(kTRUE),
52 // see header file for class documentation
55 AliHLTMUONClusterHistoComponent::~AliHLTMUONClusterHistoComponent()
57 // see header file for class documentation
59 if (fChargePerClusterBending) delete fChargePerClusterBending;
60 if (fChargePerClusterNonBending) delete fChargePerClusterNonBending;
61 if (fNumberOfClusters) delete fNumberOfClusters;
64 // Public functions to implement AliHLTComponent's interface.
65 // These functions are required for the registration process
67 const char* AliHLTMUONClusterHistoComponent::GetComponentID()
69 // see header file for class documentation
71 return AliHLTMUONConstants::ClusterHistogrammerId();
72 // return "MUONClusterHistogrammer";
76 void AliHLTMUONClusterHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
78 // see header file for class documentation
80 list.push_back(AliHLTMUONConstants::ClusterBlockDataType() );
81 //list.push_back( AliHLTMUONConstants::RecHitsBlockDataType() );
82 //list.push_back( AliHLTMUONConstants::TriggerRecordsBlockDataType() );
85 AliHLTComponentDataType AliHLTMUONClusterHistoComponent::GetOutputDataType()
87 // see header file for class documentation
88 return kAliHLTDataTypeHistogram;
92 int AliHLTMUONClusterHistoComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
95 // see header file for class documentation
97 tgtList.push_back( AliHLTMUONConstants::HistogramDataType() );
98 return tgtList.size();
101 void AliHLTMUONClusterHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
103 // see header file for class documentation
105 // The total constant size is the size of the TH1F object, the space needed for
106 // the arrays of data points and finally we add 4k for any extra streamer meta data
107 // etc. added by ROOT.
108 constBase = sizeof(TH1F)*3 + sizeof(Double_t)*(400*2+101) + 4*1024*3;
110 // The multiplier can be zero since the histograms generated are a constant size
111 // independent of the input data size.
115 AliHLTComponent* AliHLTMUONClusterHistoComponent::Spawn()
117 // see header file for class documentation
118 return new AliHLTMUONClusterHistoComponent;
121 int AliHLTMUONClusterHistoComponent::DoInit( int argc, const char** argv )
123 // see header file for class documentation
125 fPlotChargePerClusterBending=kTRUE;
126 fPlotChargePerClusterNonBending=kTRUE;
127 fPlotNClusters=kTRUE;
129 if(fPlotChargePerClusterBending)
130 fChargePerClusterBending = new TH1F("fChargePerClusterBending","Total Charge of clusters ",400,0,4000);
132 if(fPlotChargePerClusterNonBending)
133 fChargePerClusterNonBending = new TH1F("fChargePerClusterNonBending","Total Charge of clusters ",400,0,4000);
136 fNumberOfClusters = new TH1F("fNumberOfClusters","Total Number of Clusters",101,0,100);
139 TString configuration="";
141 for (int i=0; i<argc && iResult>=0; i++) {
143 if (!configuration.IsNull()) configuration+=" ";
144 configuration+=argument;
147 if (!configuration.IsNull()) {
148 iResult=Configure(configuration.Data());
154 int AliHLTMUONClusterHistoComponent::DoDeinit()
156 // see header file for class documentation
157 if(fChargePerClusterBending!=NULL) delete fChargePerClusterBending;
158 if(fChargePerClusterNonBending!=NULL) delete fChargePerClusterNonBending;
159 if(fNumberOfClusters!=NULL) delete fNumberOfClusters;
163 int AliHLTMUONClusterHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
164 const AliHLTComponentBlockData* /*blocks*/,
165 AliHLTComponentTriggerData& /*trigData*/,
166 AliHLTUInt8_t* /*outputPtr*/,
167 AliHLTUInt32_t& size,
168 AliHLTComponentBlockDataList& /*outputBlocks*/)
170 AliHLTUInt32_t specification = 0x0;
172 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) ) return 0;
174 for (const AliHLTComponentBlockData* block = GetFirstInputBlock(AliHLTMUONConstants::ClusterBlockDataType());
175 block != NULL;block = GetNextInputBlock()){
177 if (block->fDataType != AliHLTMUONConstants::ClusterBlockDataType()) continue;
178 specification |= block->fSpecification; // The specification bit pattern should indicate all the DDLs that contributed.
180 HLTDebug("Handling block: with fDataType = '%s', fPtr = %p and fSize = %u bytes.",
181 DataType2Text(block->fDataType).c_str(), block->fPtr, block->fSize
184 AliHLTMUONClustersBlockReader clusterBlock(block->fPtr, block->fSize);
185 if (not BlockStructureOk(clusterBlock))
187 //FIXME: Need to inherit AliHLTMUONProcessor DoInit functionality properly for
188 // the following Dump feature to work properly. Like in AliHLTMUONRawDataHistoComponent.
189 //if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
193 const AliHLTMUONClusterStruct *cluster=clusterBlock.GetArray();
194 for (AliHLTUInt32_t i = 0; i < clusterBlock.Nentries(); ++i){
196 //commented for future use
197 //AliHLTInt32_t detelement=cluster->fDetElemId; // Detector ID number from AliRoot geometry
199 AliHLTUInt16_t nchannelsB=cluster->fNchannelsB; // Number of channels/pads in the cluster in bending plane.
200 AliHLTUInt16_t nchannelsNB=cluster->fNchannelsNB; // Number of channels/pads in the cluster in non-bending plane.
203 AliHLTFloat32_t BCharge= cluster->fChargeB; // Cluster charge in bending plane. Can be -1 if invalid or uncomputed.
204 AliHLTFloat32_t NBCharge= cluster->fChargeNB; // Cluster charge in bending plane. Can be -1 if invalid or uncomputed.
206 if(fPlotChargePerClusterBending)
207 fChargePerClusterBending->Fill(BCharge);
208 if(fPlotChargePerClusterNonBending)
209 fChargePerClusterNonBending->Fill(NBCharge);
211 } // forloop clusterBlock.Nentries
212 if(fPlotNClusters and clusterBlock.Nentries()>0)
213 fNumberOfClusters->Fill(clusterBlock.Nentries());
215 }//forloop clusterblock
217 if( fPlotChargePerClusterBending ) PushBack( fChargePerClusterBending, AliHLTMUONConstants::HistogramDataType(), specification);
218 if( fPlotChargePerClusterNonBending ) PushBack( fChargePerClusterBending, AliHLTMUONConstants::HistogramDataType(), specification);
219 if( fPlotNClusters ) PushBack( fNumberOfClusters, AliHLTMUONConstants::HistogramDataType(), specification);
225 int AliHLTMUONClusterHistoComponent::Reconfigure(const char* cdbEntry, const char* chainId)
227 // see header file for class documentation
229 const char* path="HLT/ConfigMUON/MUONHistoComponent";
230 const char* defaultNotify="";
233 defaultNotify=" (default)";
236 HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
237 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
239 TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
241 HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
242 iResult=Configure(pString->GetString().Data());
244 HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
247 HLTError("can not fetch object \"%s\" from CDB", path);
255 int AliHLTMUONClusterHistoComponent::Configure(const char* arguments)
259 if (!arguments) return iResult;
261 TString allArgs=arguments;
264 TObjArray* pTokens=allArgs.Tokenize(" ");
267 for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
268 argument=((TObjString*)pTokens->At(i))->GetString();
269 if (argument.IsNull()) continue;