]>
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 | ||
23 | #if __GNUC__>= 3 | |
24 | using namespace std; | |
25 | #endif | |
26 | ||
27 | #include "TFile.h" | |
28 | #include "TString.h" | |
29 | #include "TObjString.h" | |
30 | #include "TObjArray.h" | |
31 | #include "TH1F.h" | |
32 | ||
33 | #include "AliHLTTRDHistoMergerComponent.h" | |
34 | #include "AliHLTTRDDefinitions.h" | |
35 | #include "AliHLTTRDUtils.h" | |
36 | ||
37 | #define stringCompare(a,b) !(strcmp(a,b)) | |
38 | ||
39 | //#include "AliHLTTRD.h" | |
40 | //#include <stdlib.h> | |
41 | //#include <cerrno> | |
42 | ||
43 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
44 | ClassImp(AliHLTTRDHistoMergerComponent) | |
45 | ||
46 | AliHLTTRDHistoMergerComponent::AliHLTTRDHistoMergerComponent() | |
47 | : AliHLTProcessor(), | |
48 | fOutputSize(500000) | |
49 | { | |
50 | // see header file for class documentation | |
51 | // or | |
52 | // refer to README to build package | |
53 | // or | |
54 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
55 | ||
56 | } | |
57 | ||
58 | AliHLTTRDHistoMergerComponent::~AliHLTTRDHistoMergerComponent() | |
59 | { | |
60 | // see header file for class documentation | |
61 | } | |
62 | ||
63 | // Public functions to implement AliHLTComponent's interface. | |
64 | // These functions are required for the registration process | |
65 | ||
66 | const char* AliHLTTRDHistoMergerComponent::GetComponentID() | |
67 | { | |
68 | // see header file for class documentation | |
69 | ||
70 | return "TRDHistoMerger"; | |
71 | } | |
72 | ||
73 | void AliHLTTRDHistoMergerComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) | |
74 | { | |
75 | // see header file for class documentation | |
76 | list.clear(); | |
77 | list.push_back(kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD); | |
78 | } | |
79 | ||
80 | AliHLTComponentDataType AliHLTTRDHistoMergerComponent::GetOutputDataType() | |
81 | { | |
82 | // see header file for class documentation | |
83 | return kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD; | |
84 | ||
85 | } | |
86 | ||
87 | void AliHLTTRDHistoMergerComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
88 | { | |
89 | // see header file for class documentation | |
90 | constBase = fOutputSize; | |
91 | inputMultiplier = 0; | |
92 | } | |
93 | ||
94 | AliHLTComponent* AliHLTTRDHistoMergerComponent::Spawn() | |
95 | { | |
96 | // see header file for class documentation | |
97 | return new AliHLTTRDHistoMergerComponent; | |
98 | } | |
99 | ||
100 | int AliHLTTRDHistoMergerComponent::DoInit(int argc, const char** argv) | |
101 | { | |
102 | ||
103 | int iResult=0; | |
104 | ||
105 | TString configuration=""; | |
106 | TString argument=""; | |
107 | for (int i=0; i<argc && iResult>=0; i++) { | |
108 | argument=argv[i]; | |
109 | if (!configuration.IsNull()) configuration+=" "; | |
110 | configuration+=argument; | |
111 | } | |
112 | ||
113 | if (!configuration.IsNull()) { | |
114 | iResult=Configure(configuration.Data()); | |
115 | } | |
116 | ||
117 | for(int i=0; i<9; i++) | |
118 | fHistoArr[i]=NULL; | |
119 | ||
120 | for(int i=0; i<18; i++) | |
121 | fIncSM[i]=kFALSE; | |
122 | ||
123 | return 0; | |
124 | } | |
125 | ||
126 | int AliHLTTRDHistoMergerComponent::DoDeinit() | |
127 | { | |
128 | // see header file for class documentation | |
129 | ||
130 | return 0; | |
131 | } | |
132 | ||
133 | int AliHLTTRDHistoMergerComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, | |
134 | AliHLTComponentTriggerData& /*trigData*/) | |
135 | { | |
1ea1f8e0 | 136 | if(!IsDataEvent())return 0; |
b21edf6e | 137 | |
138 | int histNr = 0; | |
139 | int lastSM = -1; | |
140 | ||
141 | for(const TObject* iter = GetFirstInputObject(kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD); | |
142 | iter != NULL; iter = GetNextInputObject() ) { | |
143 | ||
144 | if(!dynamic_cast<const TH1*>(iter)) | |
145 | continue; | |
146 | ||
147 | AliHLTUInt32_t spec = GetSpecification(iter); | |
148 | int SM = AliHLTTRDUtils::GetSM(spec); | |
149 | ||
150 | if(SM!=lastSM){ | |
151 | if(fIncSM[SM]){ | |
152 | for(int i = 0; fHistoArr[i]; i++){ | |
153 | PushBack((TObject*)fHistoArr[i], kAliHLTDataTypeHistogram | kAliHLTDataOriginTRD, 0); | |
1fb94c99 | 154 | delete fHistoArr[i]; |
b21edf6e | 155 | fHistoArr[i] = NULL; |
156 | } | |
157 | for(int i=0; i<18; i++) | |
158 | fIncSM[i]=kFALSE; | |
159 | } | |
160 | lastSM = SM; | |
161 | histNr = 0; | |
162 | fIncSM[SM]=kTRUE; | |
163 | } | |
164 | ||
1ea1f8e0 | 165 | if(histNr>9){ |
166 | HLTError("Got more histogramms than expected."); | |
167 | return 0; | |
168 | } | |
169 | ||
b21edf6e | 170 | if(!fHistoArr[histNr]) fHistoArr[histNr] = (TH1*)iter->Clone(); |
171 | else if(stringCompare(fHistoArr[histNr]->GetName(),iter->GetName())) | |
172 | fHistoArr[histNr]->Add((TH1*)iter); | |
173 | ||
174 | histNr++; | |
175 | } | |
176 | ||
177 | return 0; | |
178 | } | |
179 | ||
180 | int AliHLTTRDHistoMergerComponent::Configure(const char* arguments){ | |
181 | int iResult=0; | |
182 | if (!arguments) return iResult; | |
183 | ||
184 | TString allArgs=arguments; | |
185 | TString argument; | |
186 | int bMissingParam=0; | |
187 | ||
188 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
189 | if (pTokens) { | |
190 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
191 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
192 | if (argument.IsNull()) continue; | |
193 | ||
194 | if (argument.CompareTo("output_size")==0) { | |
195 | if ((bMissingParam=(++i>=pTokens->GetEntries()))) break; | |
196 | HLTInfo("Setting output size to: %s", ((TObjString*)pTokens->At(i))->GetString().Data()); | |
197 | fOutputSize=((TObjString*)pTokens->At(i))->GetString().Atoi(); | |
198 | continue; | |
199 | } | |
200 | else { | |
201 | HLTError("unknown argument: %s", argument.Data()); | |
202 | iResult=-EINVAL; | |
203 | break; | |
204 | } | |
205 | } | |
206 | delete pTokens; | |
207 | } | |
208 | if (bMissingParam) { | |
209 | HLTError("missing parameter for argument %s", argument.Data()); | |
210 | iResult=-EINVAL; | |
211 | } | |
212 | return iResult; | |
213 | } |