Line data Source code
1 : //**************************************************************************
2 : //* This file is property of and copyright by the ALICE HLT Project *
3 : //* ALICE Experiment at CERN, All rights reserved. *
4 : //* *
5 : //* Primary Author: Arshad Ahmad Masoodi <Arshad.Ahmad@cern.ch> *
6 : //* for The ALICE HLT Project. *
7 : //* *
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 : //**************************************************************************
16 :
17 : /** @file AliHLTMUONClusterHistoComponent.cxx
18 : @author Arshad Ahmad <Arshad.Ahmad@cern.ch>
19 : @date 27 Nov 2009
20 : @brief Component for onlinehistograms
21 : */
22 :
23 : #include "AliHLTMUONClusterHistoComponent.h"
24 : #include "AliCDBEntry.h"
25 : #include "AliCDBManager.h"
26 : #include "AliHLTDataTypes.h"
27 : #include "AliHLTMUONConstants.h"
28 : #include "AliHLTMUONClustersBlockStruct.h"
29 : #include "AliHLTMUONDataBlockReader.h"
30 : #include <TFile.h>
31 : #include <TString.h>
32 : #include "TObjString.h"
33 : #include "TObjArray.h"
34 :
35 : using namespace std;
36 :
37 : /** ROOT macro for the implementation of ROOT specific class methods */
38 6 : ClassImp(AliHLTMUONClusterHistoComponent);
39 :
40 : AliHLTMUONClusterHistoComponent::AliHLTMUONClusterHistoComponent() :
41 3 : AliHLTMUONProcessor(),
42 3 : fChargePerClusterBending(NULL),
43 3 : fChargePerClusterNonBending(NULL),
44 3 : fNumberOfClusters(NULL),
45 3 : fPlotChargePerClusterBending(kTRUE),
46 3 : fPlotChargePerClusterNonBending(kTRUE),
47 3 : fPlotNClusters(kTRUE)
48 15 : {
49 : // see header file for class documentation
50 6 : }
51 :
52 : AliHLTMUONClusterHistoComponent::~AliHLTMUONClusterHistoComponent()
53 18 : {
54 : // see header file for class documentation
55 :
56 3 : if (fChargePerClusterBending != NULL) delete fChargePerClusterBending;
57 3 : if (fChargePerClusterNonBending != NULL) delete fChargePerClusterNonBending;
58 3 : if (fNumberOfClusters != NULL) delete fNumberOfClusters;
59 9 : }
60 :
61 : // Public functions to implement AliHLTComponent's interface.
62 : // These functions are required for the registration process
63 :
64 : const char* AliHLTMUONClusterHistoComponent::GetComponentID()
65 : {
66 : // see header file for class documentation
67 :
68 168 : return AliHLTMUONConstants::ClusterHistogrammerId();
69 : // return "MUONClusterHistogrammer";
70 :
71 : }
72 :
73 : void AliHLTMUONClusterHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list)
74 : {
75 : // see header file for class documentation
76 0 : list.clear();
77 0 : list.push_back(AliHLTMUONConstants::ClusterBlockDataType() );
78 : //list.push_back( AliHLTMUONConstants::RecHitsBlockDataType() );
79 : //list.push_back( AliHLTMUONConstants::TriggerRecordsBlockDataType() );
80 0 : }
81 :
82 : AliHLTComponentDataType AliHLTMUONClusterHistoComponent::GetOutputDataType()
83 : {
84 : // see header file for class documentation
85 0 : return kAliHLTDataTypeHistogram;
86 : }
87 :
88 :
89 : int AliHLTMUONClusterHistoComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList)
90 :
91 : {
92 : // see header file for class documentation
93 0 : tgtList.clear();
94 0 : tgtList.push_back( AliHLTMUONConstants::HistogramDataType() );
95 0 : return tgtList.size();
96 : }
97 :
98 : void AliHLTMUONClusterHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier )
99 : {
100 : // see header file for class documentation
101 :
102 : // The total constant size is the size of the TH1F object, the space needed for
103 : // the arrays of data points and finally we add 4k for any extra streamer meta data
104 : // etc. added by ROOT.
105 0 : constBase = sizeof(TH1F)*3 + sizeof(Double_t)*(400*2+101) + 4*1024*3;
106 :
107 : // The multiplier can be zero since the histograms generated are a constant size
108 : // independent of the input data size.
109 0 : inputMultiplier = 0;
110 0 : }
111 :
112 : AliHLTComponent* AliHLTMUONClusterHistoComponent::Spawn()
113 : {
114 : // see header file for class documentation
115 0 : return new AliHLTMUONClusterHistoComponent;
116 0 : }
117 :
118 : int AliHLTMUONClusterHistoComponent::DoInit( int argc, const char** argv )
119 : {
120 : // see header file for class documentation
121 :
122 0 : fPlotChargePerClusterBending=kTRUE;
123 0 : fPlotChargePerClusterNonBending=kTRUE;
124 0 : fPlotNClusters=kTRUE;
125 :
126 0 : if(fPlotChargePerClusterBending)
127 0 : fChargePerClusterBending = new TH1F("fChargePerClusterBending","Total Charge of clusters ",400,0,4000);
128 :
129 0 : if(fPlotChargePerClusterNonBending)
130 0 : fChargePerClusterNonBending = new TH1F("fChargePerClusterNonBending","Total Charge of clusters ",400,0,4000);
131 :
132 0 : if(fPlotNClusters)
133 0 : fNumberOfClusters = new TH1F("fNumberOfClusters","Total Number of Clusters",101,0,100);
134 :
135 : int iResult=0;
136 0 : TString configuration="";
137 0 : TString argument="";
138 0 : for (int i=0; i<argc && iResult>=0; i++) {
139 0 : argument=argv[i];
140 0 : if (!configuration.IsNull()) configuration+=" ";
141 0 : configuration+=argument;
142 : }
143 :
144 0 : if (!configuration.IsNull()) {
145 0 : iResult=Configure(configuration.Data());
146 0 : }
147 :
148 : return iResult;
149 0 : }
150 :
151 : int AliHLTMUONClusterHistoComponent::DoDeinit()
152 : {
153 : // see header file for class documentation
154 0 : if (fChargePerClusterBending != NULL)
155 : {
156 0 : delete fChargePerClusterBending;
157 0 : fChargePerClusterBending = NULL;
158 0 : }
159 0 : if (fChargePerClusterNonBending != NULL)
160 : {
161 0 : delete fChargePerClusterNonBending;
162 0 : fChargePerClusterNonBending = NULL;
163 0 : }
164 0 : if (fNumberOfClusters != NULL)
165 : {
166 0 : delete fNumberOfClusters;
167 0 : fNumberOfClusters = NULL;
168 0 : }
169 0 : return 0;
170 : }
171 :
172 : int AliHLTMUONClusterHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/,
173 : const AliHLTComponentBlockData* /*blocks*/,
174 : AliHLTComponentTriggerData& /*trigData*/,
175 : AliHLTUInt8_t* /*outputPtr*/,
176 : AliHLTUInt32_t& /*size*/,
177 : AliHLTComponentBlockDataList& /*outputBlocks*/)
178 : {
179 : AliHLTUInt32_t specification = 0x0;
180 :
181 0 : if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) ) return 0;
182 :
183 0 : for (const AliHLTComponentBlockData* block = GetFirstInputBlock(AliHLTMUONConstants::ClusterBlockDataType());
184 0 : block != NULL;block = GetNextInputBlock()){
185 :
186 0 : if (block->fDataType != AliHLTMUONConstants::ClusterBlockDataType()) continue;
187 0 : specification |= block->fSpecification; // The specification bit pattern should indicate all the DDLs that contributed.
188 :
189 : HLTDebug("Handling block with fDataType = '%s', fPtr = %p and fSize = %u bytes.",
190 : DataType2Text(block->fDataType).c_str(), block->fPtr, block->fSize
191 : );
192 :
193 0 : AliHLTMUONClustersBlockReader clusterBlock(block->fPtr, block->fSize);
194 0 : if (not BlockStructureOk(clusterBlock))
195 : {
196 : //FIXME: Need to inherit AliHLTMUONProcessor DoInit functionality properly for
197 : // the following Dump feature to work properly. Like in AliHLTMUONRawDataHistoComponent.
198 : //if (DumpDataOnError()) DumpEvent(evtData, blocks, trigData, outputPtr, size, outputBlocks);
199 0 : continue;
200 : }
201 :
202 0 : const AliHLTMUONClusterStruct *cluster=clusterBlock.GetArray();
203 0 : for (AliHLTUInt32_t i = 0; i < clusterBlock.Nentries(); ++i){
204 :
205 : //commented for future use
206 : //AliHLTInt32_t detelement=cluster->fDetElemId; // Detector ID number from AliRoot geometry
207 :
208 : //AliHLTUInt16_t nchannelsB=cluster->fNchannelsB; // Number of channels/pads in the cluster in bending plane.
209 : //AliHLTUInt16_t nchannelsNB=cluster->fNchannelsNB; // Number of channels/pads in the cluster in non-bending plane.
210 :
211 :
212 0 : AliHLTFloat32_t BCharge= cluster->fChargeB; // Cluster charge in bending plane. Can be -1 if invalid or uncomputed.
213 0 : AliHLTFloat32_t NBCharge= cluster->fChargeNB; // Cluster charge in bending plane. Can be -1 if invalid or uncomputed.
214 :
215 0 : if(fPlotChargePerClusterBending)
216 0 : fChargePerClusterBending->Fill(BCharge);
217 0 : if(fPlotChargePerClusterNonBending)
218 0 : fChargePerClusterNonBending->Fill(NBCharge);
219 0 : cluster++;
220 : } // forloop clusterBlock.Nentries
221 0 : if(fPlotNClusters and clusterBlock.Nentries()>0)
222 0 : fNumberOfClusters->Fill(clusterBlock.Nentries());
223 :
224 0 : }//forloop clusterblock
225 :
226 0 : if( fPlotChargePerClusterBending ) PushBack( fChargePerClusterBending, AliHLTMUONConstants::HistogramDataType(), specification);
227 0 : if( fPlotChargePerClusterNonBending ) PushBack( fChargePerClusterBending, AliHLTMUONConstants::HistogramDataType(), specification);
228 0 : if( fPlotNClusters ) PushBack( fNumberOfClusters, AliHLTMUONConstants::HistogramDataType(), specification);
229 :
230 0 : return 0;
231 0 : }
232 :
233 :
234 : int AliHLTMUONClusterHistoComponent::Reconfigure(const char* cdbEntry, const char* chainId)
235 : {
236 : // see header file for class documentation
237 : int iResult=0;
238 : const char* path="HLT/ConfigMUON/MUONHistoComponent";
239 : const char* defaultNotify="";
240 0 : if (cdbEntry) {
241 : path=cdbEntry;
242 : defaultNotify=" (default)";
243 0 : }
244 0 : if (path) {
245 0 : HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
246 0 : AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
247 0 : if (pEntry) {
248 0 : TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject());
249 0 : if (pString) {
250 0 : HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data());
251 0 : iResult=Configure(pString->GetString().Data());
252 0 : } else {
253 0 : HLTError("configuration object \"%s\" has wrong type, required TObjString", path);
254 : }
255 0 : } else {
256 0 : HLTError("can not fetch object \"%s\" from CDB", path);
257 : }
258 0 : }
259 :
260 0 : return iResult;
261 0 : }
262 :
263 :
264 : int AliHLTMUONClusterHistoComponent::Configure(const char* arguments)
265 : {
266 :
267 : int iResult=0;
268 0 : if (!arguments) return iResult;
269 :
270 0 : TString allArgs=arguments;
271 0 : TString argument;
272 :
273 0 : TObjArray* pTokens=allArgs.Tokenize(" ");
274 :
275 0 : if (pTokens) {
276 0 : for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) {
277 0 : argument=((TObjString*)pTokens->At(i))->GetString();
278 0 : if (argument.IsNull()) continue;
279 :
280 : }
281 0 : delete pTokens;
282 : }
283 :
284 : return iResult;
285 0 : }
|