]>
Commit | Line | Data |
---|---|---|
b21edf6e | 1 | // $Id$ |
2 | //************************************************************************** | |
3 | //* This file is property of and copyright by the ALICE HLT Project * | |
4 | //* ALICE Experiment at CERN, All rights reserved. * | |
5 | //* * | |
6 | //* Primary Authors: * | |
7 | //* for The ALICE HLT Project. * | |
8 | //* * | |
9 | //* Permission to use, copy, modify and distribute this software and its * | |
10 | //* documentation strictly for non-commercial purposes is hereby granted * | |
11 | //* without fee, provided that the above copyright notice appears in all * | |
12 | //* copies and that both the copyright notice and this permission notice * | |
13 | //* appear in the supporting documentation. The authors make no claims * | |
14 | //* about the suitability of this software for any purpose. It is * | |
15 | //* provided "as is" without express or implied warranty. * | |
16 | //************************************************************************** | |
17 | ||
18 | /** @file AliHLTTRDHistoMergerComponent.cxx | |
19 | @author Theodor Rascanu | |
20 | @brief Component for adding histos of partition wise working histo components | |
21 | */ | |
22 | ||
b21edf6e | 23 | #include "TFile.h" |
24 | #include "TString.h" | |
25 | #include "TObjString.h" | |
26 | #include "TObjArray.h" | |
27 | #include "TH1F.h" | |
28 | ||
29 | #include "AliHLTTRDHistoMergerComponent.h" | |
30 | #include "AliHLTTRDDefinitions.h" | |
31 | #include "AliHLTTRDUtils.h" | |
32 | ||
33 | #define stringCompare(a,b) !(strcmp(a,b)) | |
34 | ||
35 | //#include "AliHLTTRD.h" | |
36 | //#include <stdlib.h> | |
37 | //#include <cerrno> | |
38 | ||
a7f38894 | 39 | using namespace std; |
40 | ||
b21edf6e | 41 | /** ROOT macro for the implementation of ROOT specific class methods */ |
42 | ClassImp(AliHLTTRDHistoMergerComponent) | |
43 | ||
44 | AliHLTTRDHistoMergerComponent::AliHLTTRDHistoMergerComponent() | |
45 | : AliHLTProcessor(), | |
46 | fOutputSize(500000) | |
47 | { | |
48 | // see header file for class documentation | |
49 | // or | |
50 | // refer to README to build package | |
51 | // or | |
52 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
53 | ||
288725ab | 54 | for(int i=0; i<9; i++) |
55 | fHistoArr[i]=NULL; | |
56 | ||
57 | for(int i=0; i<18; i++) | |
58 | fIncSM[i]=kFALSE; | |
59 | ||
b21edf6e | 60 | } |
61 | ||
62 | AliHLTTRDHistoMergerComponent::~AliHLTTRDHistoMergerComponent() | |
63 | { | |
64 | // see header file for class documentation | |
65 | } | |
66 | ||
67 | // Public functions to implement AliHLTComponent's interface. | |
68 | // These functions are required for the registration process | |
69 | ||
70 | const char* AliHLTTRDHistoMergerComponent::GetComponentID() | |
71 | { | |
72 | // see header file for class documentation | |
73 | ||
74 | return "TRDHistoMerger"; | |
75 | } | |
76 | ||
77 | void AliHLTTRDHistoMergerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) | |
78 | { | |
79 | // see header file for class documentation | |
80 | list.clear(); | |
81 | list.push_back(kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD); | |
82 | } | |
83 | ||
84 | AliHLTComponentDataType AliHLTTRDHistoMergerComponent::GetOutputDataType() | |
85 | { | |
86 | // see header file for class documentation | |
87 | return kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD; | |
88 | ||
89 | } | |
90 | ||
91 | void AliHLTTRDHistoMergerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
92 | { | |
93 | // see header file for class documentation | |
94 | constBase = fOutputSize; | |
95 | inputMultiplier = 0; | |
96 | } | |
97 | ||
98 | AliHLTComponent* AliHLTTRDHistoMergerComponent::Spawn() | |
99 | { | |
100 | // see header file for class documentation | |
101 | return new AliHLTTRDHistoMergerComponent; | |
102 | } | |
103 | ||
104 | int AliHLTTRDHistoMergerComponent::DoInit(int argc, const char** argv) | |
105 | { | |
106 | ||
107 | int iResult=0; | |
108 | ||
109 | TString configuration=""; | |
110 | TString argument=""; | |
111 | for (int i=0; i<argc && iResult>=0; i++) { | |
112 | argument=argv[i]; | |
113 | if (!configuration.IsNull()) configuration+=" "; | |
114 | configuration+=argument; | |
115 | } | |
116 | ||
117 | if (!configuration.IsNull()) { | |
118 | iResult=Configure(configuration.Data()); | |
119 | } | |
120 | ||
121 | for(int i=0; i<9; i++) | |
122 | fHistoArr[i]=NULL; | |
123 | ||
124 | for(int i=0; i<18; i++) | |
125 | fIncSM[i]=kFALSE; | |
126 | ||
127 | return 0; | |
128 | } | |
129 | ||
130 | int AliHLTTRDHistoMergerComponent::DoDeinit() | |
131 | { | |
132 | // see header file for class documentation | |
133 | ||
134 | return 0; | |
135 | } | |
136 | ||
137 | int AliHLTTRDHistoMergerComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, | |
138 | AliHLTComponentTriggerData& /*trigData*/) | |
139 | { | |
1ea1f8e0 | 140 | if(!IsDataEvent())return 0; |
b21edf6e | 141 | |
142 | int histNr = 0; | |
143 | int lastSM = -1; | |
144 | ||
145 | for(const TObject* iter = GetFirstInputObject(kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD); | |
146 | iter != NULL; iter = GetNextInputObject() ) { | |
147 | ||
148 | if(!dynamic_cast<const TH1*>(iter)) | |
149 | continue; | |
150 | ||
151 | AliHLTUInt32_t spec = GetSpecification(iter); | |
152 | int SM = AliHLTTRDUtils::GetSM(spec); | |
153 | ||
154 | if(SM!=lastSM){ | |
155 | if(fIncSM[SM]){ | |
156 | for(int i = 0; fHistoArr[i]; i++){ | |
157 | PushBack((TObject*)fHistoArr[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, 0); | |
1fb94c99 | 158 | delete fHistoArr[i]; |
b21edf6e | 159 | fHistoArr[i] = NULL; |
160 | } | |
161 | for(int i=0; i<18; i++) | |
162 | fIncSM[i]=kFALSE; | |
163 | } | |
164 | lastSM = SM; | |
165 | histNr = 0; | |
166 | fIncSM[SM]=kTRUE; | |
167 | } | |
168 | ||
1ea1f8e0 | 169 | if(histNr>9){ |
170 | HLTError("Got more histogramms than expected."); | |
171 | return 0; | |
172 | } | |
173 | ||
b21edf6e | 174 | if(!fHistoArr[histNr]) fHistoArr[histNr] = (TH1*)iter->Clone(); |
175 | else if(stringCompare(fHistoArr[histNr]->GetName(),iter->GetName())) | |
176 | fHistoArr[histNr]->Add((TH1*)iter); | |
177 | ||
178 | histNr++; | |
179 | } | |
180 | ||
181 | return 0; | |
182 | } | |
183 | ||
184 | int AliHLTTRDHistoMergerComponent::Configure(const char* arguments){ | |
185 | int iResult=0; | |
186 | if (!arguments) return iResult; | |
187 | ||
188 | TString allArgs=arguments; | |
189 | TString argument; | |
190 | int bMissingParam=0; | |
191 | ||
192 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
193 | if (pTokens) { | |
194 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
195 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
196 | if (argument.IsNull()) continue; | |
197 | ||
198 | if (argument.CompareTo("output_size")==0) { | |
199 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
200 | HLTInfo("Setting output size to: %s", ((TObjString*)pTokens->At(i))->GetString().Data()); | |
201 | fOutputSize=((TObjString*)pTokens->At(i))->GetString().Atoi(); | |
202 | continue; | |
203 | } | |
204 | else { | |
205 | HLTError("unknown argument: %s", argument.Data()); | |
206 | iResult=-EINVAL; | |
207 | break; | |
208 | } | |
209 | } | |
210 | delete pTokens; | |
211 | } | |
212 | if (bMissingParam) { | |
213 | HLTError("missing parameter for argument %s", argument.Data()); | |
214 | iResult=-EINVAL; | |
215 | } | |
216 | return iResult; | |
217 | } |