]>
Commit | Line | Data |
---|---|---|
cdfe3c01 | 1 | // $Id$ |
2 | ||
3 | //************************************************************************** | |
4 | //* This file is property of and copyright by the ALICE HLT Project * | |
5 | //* ALICE Experiment at CERN, All rights reserved. * | |
6 | //* * | |
7 | //* Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no> * | |
8 | //* for The ALICE HLT Project. * | |
9 | //* * | |
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 | //************************************************************************** | |
18 | ||
19 | /** @file AliHLTTPCHistogramHandlerComponent.cxx | |
20 | @author Kalliopi Kanaki | |
21 | @date | |
22 | @brief The Histogram Handler component | |
23 | */ | |
24 | ||
25 | #if __GNUC__>= 3 | |
26 | using namespace std; | |
27 | #endif | |
28 | #include "AliHLTTPCHistogramHandlerComponent.h" | |
29 | #include "AliHLTTPCDefinitions.h" | |
30 | #include "AliCDBEntry.h" | |
31 | #include "AliCDBManager.h" | |
32 | ||
33 | #include <cstdlib> | |
34 | #include <cerrno> | |
35 | #include "TString.h" | |
36 | #include "TFile.h" | |
37 | #include "TObjArray.h" | |
38 | #include "TObjString.h" | |
39 | #include <sys/time.h> | |
40 | #include "TH1.h" | |
41 | #include "TH2.h" | |
42 | #include "TLine.h" | |
43 | #include "TMath.h" | |
44 | ||
45 | ||
46 | AliHLTTPCHistogramHandlerComponent gAliHLTTPCHistogramHandlerComponent; | |
47 | ||
48 | ClassImp(AliHLTTPCHistogramHandlerComponent) //ROOT macro for the implementation of ROOT specific class methods | |
49 | ||
50 | AliHLTTPCHistogramHandlerComponent::AliHLTTPCHistogramHandlerComponent() | |
51 | : | |
52 | fNoiseHistograms(0), | |
53 | fKryptonHistograms(0), | |
54 | fSpecificationTPCA(0), | |
55 | fSpecificationTPCC(0), | |
56 | fSlice(-99), | |
57 | fHistTH1Tmp(NULL), | |
58 | fHistTH2Tmp(NULL), | |
59 | fHistTPCSideA(NULL), | |
60 | fHistTPCSideC(NULL) | |
61 | { | |
62 | // see header file for class documentation | |
63 | // or | |
64 | // refer to README to build package | |
65 | // or | |
66 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
67 | } | |
68 | ||
69 | AliHLTTPCHistogramHandlerComponent::~AliHLTTPCHistogramHandlerComponent() { | |
70 | // see header file for class documentation | |
71 | ||
72 | } | |
73 | ||
74 | // Public functions to implement AliHLTComponent's interface. | |
75 | // These functions are required for the registration process | |
76 | ||
77 | const char* AliHLTTPCHistogramHandlerComponent::GetComponentID() { | |
78 | // see header file for class documentation | |
79 | ||
80 | return "TPCHistogramHandler"; | |
81 | } | |
82 | ||
83 | void AliHLTTPCHistogramHandlerComponent::GetInputDataTypes( vector<AliHLTComponentDataType>& list) { | |
84 | // see header file for class documentation | |
85 | ||
86 | list.clear(); | |
87 | list.push_back( kAliHLTDataTypeHistogram ); | |
88 | } | |
89 | ||
90 | AliHLTComponentDataType AliHLTTPCHistogramHandlerComponent::GetOutputDataType() { | |
91 | // see header file for class documentation | |
92 | ||
93 | return kAliHLTDataTypeHistogram; | |
94 | } | |
95 | ||
96 | int AliHLTTPCHistogramHandlerComponent::GetOutputDataTypes(AliHLTComponentDataTypeList& tgtList) { | |
97 | // see header file for class documentation | |
98 | ||
99 | tgtList.clear(); | |
100 | tgtList.push_back(kAliHLTDataTypeHistogram); | |
101 | return tgtList.size(); | |
102 | } | |
103 | ||
104 | void AliHLTTPCHistogramHandlerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) { | |
105 | // see header file for class documentation | |
106 | ||
107 | constBase=0; | |
108 | inputMultiplier=2.0; | |
109 | } | |
110 | ||
111 | AliHLTComponent* AliHLTTPCHistogramHandlerComponent::Spawn() { | |
112 | // see header file for class documentation | |
113 | ||
114 | return new AliHLTTPCHistogramHandlerComponent(); | |
115 | } | |
116 | ||
117 | int AliHLTTPCHistogramHandlerComponent::DoInit( int argc, const char** argv ) { | |
118 | // see header file for class documentation | |
119 | ||
120 | Int_t i = 0; | |
121 | Char_t* cpErr; | |
122 | ||
123 | int iResult=0; | |
124 | ||
125 | TString configuration=""; | |
126 | TString argument=""; | |
127 | for (int i=0; i<argc && iResult>=0; i++) { | |
128 | ||
129 | argument=argv[i]; | |
130 | if (!configuration.IsNull()) configuration+=" "; | |
131 | configuration+=argument; | |
132 | } | |
133 | ||
134 | if (!configuration.IsNull()) { | |
135 | iResult=Configure(configuration.Data()); | |
136 | } else { | |
137 | iResult=Reconfigure(NULL, NULL); | |
138 | } | |
139 | ||
140 | ||
141 | while ( i < argc ) { | |
142 | if (!strcmp( argv[i], "-sum-noise-histograms")) { | |
143 | fNoiseHistograms = strtoul( argv[i+1], &cpErr ,0); | |
144 | ||
145 | if ( *cpErr ) { | |
146 | HLTError("Cannot convert sum-noise-histograms specifier '%s'.", argv[i+1]); | |
147 | return EINVAL; | |
148 | } | |
149 | i+=2; | |
150 | continue; | |
151 | } | |
152 | ||
153 | if (!strcmp( argv[i], "-sum-krypton-histograms")) { | |
154 | fKryptonHistograms = strtoul( argv[i+1], &cpErr ,0); | |
155 | ||
156 | if ( *cpErr ) { | |
157 | HLTError("Cannot convert sum-krypton-histograms specifier '%s'.", argv[i+1]); | |
158 | return EINVAL; | |
159 | } | |
160 | i+=2; | |
161 | continue; | |
162 | } | |
163 | ||
164 | Logging(kHLTLogError, "HLT::TPCHistogramHandler::DoInit", "Unknown Option", "Unknown option '%s'", argv[i] ); | |
165 | return EINVAL; | |
166 | ||
167 | } // end while | |
168 | ||
169 | return 0; | |
170 | } // end DoInit() | |
171 | ||
172 | int AliHLTTPCHistogramHandlerComponent::DoDeinit() { | |
173 | // see header file for class documentation | |
174 | ||
175 | return 0; | |
176 | } | |
177 | ||
178 | int AliHLTTPCHistogramHandlerComponent::DoEvent(const AliHLTComponentEventData& evtData, AliHLTComponentTriggerData& trigData){ | |
179 | // see header file for class documentation | |
180 | ||
181 | HLTInfo("--- Entering DoEvent() in TPCHistogramHandler ---"); | |
182 | ||
183 | if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR )) return 0; | |
184 | ||
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)"); | |
190 | ||
191 | const TObject *iter = NULL; | |
192 | ||
193 | for(iter = GetFirstInputObject(kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC); iter != NULL; iter = GetNextInputObject()){ | |
194 | ||
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()); | |
199 | ||
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()); | |
204 | } | |
205 | ||
206 | if (GetDataType(iter) != (kAliHLTDataTypeHistogram | kAliHLTDataOriginTPC)) continue; | |
207 | ||
208 | // Summing the output histograms of the TPCNoiseMapComponent (from partition to TPC sides) | |
209 | if(fNoiseHistograms){ | |
210 | ||
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)); | |
216 | ||
217 | if((minSlice!=maxSlice) || (minPartition!=maxPartition)){ | |
218 | HLTWarning("TPCHistogramHandler::The Noise Map component is not running on partition level!"); | |
219 | } | |
220 | ||
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) | |
224 | ||
225 | fSpecificationTPCA = AliHLTTPCDefinitions::EncodeDataSpecification( 17, 0, 5, 0 ); | |
226 | fSpecificationTPCC = AliHLTTPCDefinitions::EncodeDataSpecification( 35, 18, 5, 0 ); | |
227 | ||
228 | } // endif fNoiseHistograms==kTRUE | |
229 | ||
230 | ||
231 | // Summing the output of TPCKryptonClusterFinderComponent | |
232 | // if(fKryptonHistograms){ | |
233 | // | |
234 | // } //endif fKryptonHistograms==kTRUE | |
235 | } // end for loop over histogram blocks | |
236 | ||
237 | MakeHistosPublic(); | |
238 | ||
239 | return 0; | |
240 | } // end DoEvent() | |
241 | ||
242 | void AliHLTTPCHistogramHandlerComponent::MakeHistosPublic() { | |
243 | // see header file for class documentation | |
244 | ||
245 | ||
246 | if(fNoiseHistograms){ | |
247 | PushBack( (TObject*) fHistTPCSideA, kAliHLTDataTypeHistogram, fSpecificationTPCA); | |
248 | PushBack( (TObject*) fHistTPCSideC, kAliHLTDataTypeHistogram, fSpecificationTPCC); | |
249 | delete fHistTH2Tmp; | |
250 | delete fHistTPCSideA; | |
251 | delete fHistTPCSideC; | |
252 | } | |
253 | ||
254 | // TObjArray histos; | |
255 | ||
256 | // if(fPlotSideA) histos.Add(fHistSideA); | |
257 | // if(fPlotSideC) histos.Add(fHistSideC); | |
258 | // if(fApplyNoiseMap) histos.Add(fHistCDBMap); | |
259 | // | |
260 | // TIter iterator(&histos); | |
261 | // while(TObject *pObj=iterator.Next()){ | |
262 | // | |
263 | // PushBack(pObj, kAliHLTDataTypeHistogram|kAliHLTDataOriginTPC, fSpecification); | |
264 | // } | |
265 | // | |
266 | // | |
267 | // //PushBack( (TObject*) &histos, kAliHLTDataTypeHistogram, fSpecification); | |
268 | } | |
269 | ||
270 | int AliHLTTPCHistogramHandlerComponent::Configure(const char* arguments) { | |
271 | // see header file for class documentation | |
272 | ||
273 | int iResult=0; | |
274 | if (!arguments) return iResult; | |
275 | HLTInfo("parsing configuration string \'%s\'", arguments); | |
276 | ||
277 | TString allArgs=arguments; | |
278 | TString argument; | |
279 | int bMissingParam=0; | |
280 | ||
281 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
282 | if (pTokens) { | |
283 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
284 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
285 | if (argument.IsNull()) continue; | |
286 | ||
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()); | |
290 | ||
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()); | |
294 | ||
295 | } | |
296 | else { | |
297 | HLTError("unknown argument %s", argument.Data()); | |
298 | iResult=-EINVAL; | |
299 | break; | |
300 | } | |
301 | } // end for | |
302 | ||
303 | delete pTokens; | |
304 | ||
305 | } // end if pTokens | |
306 | ||
307 | if (bMissingParam) { | |
308 | HLTError("missing parameter for argument %s", argument.Data()); | |
309 | iResult=-EINVAL; | |
310 | } | |
311 | return iResult; | |
312 | } | |
313 | ||
314 | int AliHLTTPCHistogramHandlerComponent::Reconfigure(const char* cdbEntry, const char* chainId) { | |
315 | // see header file for class documentation | |
316 | ||
317 | int iResult=0; | |
318 | const char* path="HLT/ConfigTPC/TPCHistogramHandlerComponent"; | |
319 | const char* defaultNotify=""; | |
320 | if (cdbEntry) { | |
321 | path=cdbEntry; | |
322 | defaultNotify=" (default)"; | |
323 | } | |
324 | ||
325 | if (path) { | |
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()*/); | |
328 | if (pEntry) { | |
329 | TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); | |
330 | if (pString) { | |
331 | HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data()); | |
332 | iResult=Configure(pString->GetString().Data()); | |
333 | } else { | |
334 | HLTError("configuration object \"%s\" has wrong type, required TObjString", path); | |
335 | } | |
336 | } else { | |
337 | HLTError("cannot fetch object \"%s\" from CDB", path); | |
338 | } | |
339 | } | |
340 | return iResult; | |
341 | } |