]>
Commit | Line | Data |
---|---|---|
c0b68f8e | 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: Gaute Ovrebekk <ovrebekk@ift.uib.no> * | |
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 AliHLTITSClusterHistoComponent.cxx | |
19 | @author Gaute Ovrebekk | |
20 | @brief Component for ploting charge in clusters | |
21 | */ | |
22 | ||
23 | #if __GNUC__>= 3 | |
24 | using namespace std; | |
25 | #endif | |
26 | ||
27 | #include "AliHLTITSClusterHistoComponent.h" | |
28 | #include "AliHLTITSClusterDataFormat.h" | |
29 | #include "AliCDBEntry.h" | |
30 | #include "AliCDBManager.h" | |
31 | #include "AliITSRecPoint.h" | |
32 | #include <TFile.h> | |
33 | #include <TString.h> | |
34 | #include "TObjString.h" | |
35 | #include "TObjArray.h" | |
36 | ||
37 | //#include <stdlib.h> | |
38 | //#include <cerrno> | |
39 | ||
40 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
41 | ClassImp(AliHLTITSClusterHistoComponent) | |
42 | ||
43 | AliHLTITSClusterHistoComponent::AliHLTITSClusterHistoComponent() | |
44 | : | |
45 | fXY(NULL), | |
46 | fXYZ(NULL), | |
47 | fCharge(NULL), | |
48 | fPlotCharge(kFALSE), | |
49 | fPlotXY(kTRUE), | |
50 | fPlotXYZ(kFALSE) | |
51 | { | |
52 | // see header file for class documentation | |
53 | // or | |
54 | // refer to README to build package | |
55 | // or | |
56 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
57 | ||
58 | } | |
59 | ||
60 | AliHLTITSClusterHistoComponent::~AliHLTITSClusterHistoComponent() | |
61 | { | |
62 | // see header file for class documentation | |
63 | } | |
64 | ||
65 | // Public functions to implement AliHLTComponent's interface. | |
66 | // These functions are required for the registration process | |
67 | ||
68 | const char* AliHLTITSClusterHistoComponent::GetComponentID() | |
69 | { | |
70 | // see header file for class documentation | |
71 | ||
72 | return "ITSClusterHisto"; | |
73 | } | |
74 | ||
75 | void AliHLTITSClusterHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) | |
76 | { | |
77 | // see header file for class documentation | |
78 | list.clear(); | |
8ce2efb0 | 79 | list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSPD ); |
80 | list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSDD ); | |
81 | list.push_back( kAliHLTDataTypeClusters|kAliHLTDataOriginITSSSD ); | |
c0b68f8e | 82 | } |
83 | ||
84 | AliHLTComponentDataType AliHLTITSClusterHistoComponent::GetOutputDataType() | |
85 | { | |
86 | // see header file for class documentation | |
87 | return kAliHLTDataTypeHistogram; | |
88 | ||
89 | } | |
90 | ||
91 | void AliHLTITSClusterHistoComponent::GetOutputDataSize( unsigned long& constBase, double& inputMultiplier ) | |
92 | { | |
93 | // see header file for class documentation | |
94 | // XXX TODO: Find more realistic values. | |
95 | constBase = 80000; | |
96 | inputMultiplier = 10; | |
97 | } | |
98 | ||
99 | AliHLTComponent* AliHLTITSClusterHistoComponent::Spawn() | |
100 | { | |
101 | // see header file for class documentation | |
102 | return new AliHLTITSClusterHistoComponent; | |
103 | } | |
104 | ||
105 | int AliHLTITSClusterHistoComponent::DoInit( int argc, const char** argv ) | |
106 | { | |
107 | fPlotCharge=kFALSE; | |
108 | fPlotXY=kTRUE; | |
109 | fPlotXYZ=kFALSE; | |
110 | ||
111 | if(fPlotCharge){fCharge = new TH1F("fCharge","Total Charge of clusters",4000,0,4000);} | |
112 | if(fPlotXY){fXY = new TH2F("fXY","Global XY of ITS clusters",1600,-80,80,1600,-80,80);} | |
113 | if(fPlotXYZ){fXYZ = new TH3F("fXYZ","Global XYZ of ITS clusters",1600,-80,80,1600,-80,80,2000,-100,100);} | |
114 | ||
115 | int iResult=0; | |
116 | TString configuration=""; | |
117 | TString argument=""; | |
118 | for (int i=0; i<argc && iResult>=0; i++) { | |
119 | argument=argv[i]; | |
120 | if (!configuration.IsNull()) configuration+=" "; | |
121 | configuration+=argument; | |
122 | } | |
123 | ||
124 | if (!configuration.IsNull()) { | |
125 | iResult=Configure(configuration.Data()); | |
126 | } | |
127 | ||
128 | return iResult; | |
129 | } | |
130 | ||
131 | int AliHLTITSClusterHistoComponent::DoDeinit() | |
132 | { | |
133 | // see header file for class documentation | |
134 | if(fCharge!=NULL) delete fCharge; | |
135 | if(fXY!=NULL) delete fXY; | |
136 | if(fXYZ!=NULL) delete fXYZ; | |
137 | return 0; | |
138 | } | |
139 | ||
140 | int AliHLTITSClusterHistoComponent::DoEvent(const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/) | |
141 | { | |
142 | ||
143 | int TotalSpacePoint = 0; | |
144 | ||
145 | const AliHLTComponentBlockData* iter = NULL; | |
146 | ||
147 | if(!IsDataEvent()) | |
148 | return 0; | |
149 | ||
8ce2efb0 | 150 | for ( iter = GetFirstInputBlock(kAliHLTDataTypeClusters); iter != NULL; iter = GetNextInputBlock() ) { |
c0b68f8e | 151 | |
8ce2efb0 | 152 | if(iter->fDataType!=(kAliHLTAnyDataType|kAliHLTDataOriginITSSPD) && |
153 | iter->fDataType!=(kAliHLTAnyDataType|kAliHLTDataOriginITSSDD) && | |
154 | iter->fDataType!=(kAliHLTAnyDataType|kAliHLTDataOriginITSSSD)) | |
155 | continue; | |
156 | ||
c0b68f8e | 157 | const AliHLTITSClusterData* clusterData = (const AliHLTITSClusterData*) iter->fPtr; |
158 | Int_t nSpacepoint = (Int_t) clusterData->fSpacePointCnt; | |
159 | TotalSpacePoint += nSpacepoint; | |
160 | AliHLTITSSpacePointData *clusters = (AliHLTITSSpacePointData*) clusterData->fSpacePoints; | |
161 | ||
162 | for(int i=0;i<nSpacepoint;i++){ | |
163 | Int_t lab[4]={0,0,0,0}; | |
164 | Float_t hit[6]={0,0,0,0,0,0}; | |
165 | Int_t info[3]={0,0,0}; | |
166 | ||
167 | lab[0]=clusters[i].fTracks[0]; | |
168 | lab[1]=clusters[i].fTracks[1]; | |
169 | lab[2]=clusters[i].fTracks[2]; | |
170 | lab[3]=clusters[i].fIndex; | |
171 | hit[0]=clusters[i].fY; | |
172 | hit[1]=clusters[i].fZ; | |
173 | hit[2]=clusters[i].fSigmaY2; | |
174 | hit[3]=clusters[i].fSigmaZ2; | |
175 | hit[4]=clusters[i].fQ; | |
176 | hit[5]=clusters[i].fSigmaYZ; | |
177 | info[0]=clusters[i].fNy; | |
178 | info[1]=clusters[i].fNz; | |
179 | info[2]=clusters[i].fLayer; | |
180 | ||
181 | Float_t xyz[3]; | |
182 | AliITSRecPoint recpoint(lab,hit,info); | |
183 | recpoint.GetGlobalXYZ(xyz); | |
184 | if(fPlotXY){ | |
185 | fXY->Fill(xyz[0],xyz[1]); | |
186 | } | |
187 | if(fPlotXYZ){ | |
188 | fXYZ->Fill(xyz[0],xyz[1],xyz[2]); | |
189 | } | |
190 | if(fPlotCharge){ | |
191 | fCharge->Fill(recpoint.GetQ()); | |
192 | } | |
193 | } | |
194 | } | |
195 | ||
196 | if(fPlotCharge){ | |
197 | AliHLTUInt32_t fSpecification = 0x0; | |
198 | PushBack( (TObject*) fCharge,kAliHLTDataTypeHistogram,fSpecification); | |
199 | } | |
200 | if(fPlotXY){ | |
201 | AliHLTUInt32_t fSpecification = 0x0; | |
202 | PushBack( (TObject*) fXY,kAliHLTDataTypeHistogram,fSpecification); | |
203 | } | |
204 | if(fPlotXYZ){ | |
205 | AliHLTUInt32_t fSpecification = 0x0; | |
206 | PushBack( (TObject*) fXYZ,kAliHLTDataTypeHistogram,fSpecification); | |
207 | } | |
208 | ||
209 | HLTInfo("ITSClusterHisto found %d Total Spacepoints", TotalSpacePoint); | |
210 | ||
211 | return 0; | |
212 | } | |
213 | ||
214 | int AliHLTITSClusterHistoComponent::Configure(const char* arguments) | |
215 | { | |
216 | ||
217 | int iResult=0; | |
218 | ||
219 | if (!arguments) return iResult; | |
220 | ||
221 | TString allArgs=arguments; | |
222 | TString argument; | |
223 | ||
224 | TObjArray* pTokens=allArgs.Tokenize(" "); | |
225 | ||
226 | if (pTokens) { | |
227 | for (int i=0; i<pTokens->GetEntries() && iResult>=0; i++) { | |
228 | argument=((TObjString*)pTokens->At(i))->GetString(); | |
229 | if (argument.IsNull()) continue; | |
230 | ||
231 | if (argument.CompareTo("-plot-all")==0) { | |
232 | HLTInfo("Ploting all historgams"); | |
233 | fPlotXY = kTRUE; | |
234 | fPlotXYZ = kTRUE; | |
235 | fPlotCharge = kTRUE; | |
236 | continue; | |
237 | } | |
238 | ||
239 | else if (argument.CompareTo("-plot-xy")==0) { | |
240 | HLTInfo("Ploting Global XY"); | |
241 | fPlotXY = kTRUE; | |
242 | continue; | |
243 | } | |
244 | ||
245 | else if (argument.CompareTo("-plot-xyz")==0) { | |
246 | HLTInfo("Ploting Global XYZ"); | |
247 | //fPlotXYZ = kTRUE; | |
248 | continue; | |
249 | } | |
250 | else if (argument.CompareTo("-plot-charge")==0) { | |
251 | HLTInfo("Ploting charge of clusters"); | |
252 | fPlotCharge = kTRUE; | |
253 | continue; | |
254 | } | |
255 | ||
256 | else { | |
257 | HLTError("unknown argument %s", argument.Data()); | |
258 | iResult=-EINVAL; | |
259 | break; | |
260 | } | |
261 | } | |
262 | delete pTokens; | |
263 | } | |
264 | ||
265 | if(!fCharge && fPlotCharge){fCharge = new TH1F("fCharge","Total Charge of clusters",4000,0,4000);} | |
266 | if(!fXY && fPlotXY){fXY = new TH2F("fXY","Global XY of ITS clusters",1600,-80,80,1600,-80,80);} | |
267 | if(!fXYZ && fPlotXYZ){fXYZ = new TH3F("fXYZ","Global XYZ of ITS clusters",1600,-80,80,1600,-80,80,2000,-100,100);} | |
268 | ||
269 | return iResult; | |
270 | } | |
271 | ||
272 | int AliHLTITSClusterHistoComponent::Reconfigure(const char* cdbEntry, const char* chainId) | |
273 | { | |
274 | // see header file for class documentation | |
275 | int iResult=0; | |
276 | ||
277 | const char* path="HLT/ConfigITS/HistoComponent"; | |
278 | const char* defaultNotify=""; | |
279 | if (cdbEntry) { | |
280 | path=cdbEntry; | |
281 | defaultNotify=" (default)"; | |
282 | } | |
283 | if (path) { | |
284 | HLTInfo("reconfigure from entry %s%s, chain id %s", path, defaultNotify,(chainId!=NULL && chainId[0]!=0)?chainId:"<none>"); | |
285 | AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path); | |
286 | if (pEntry) { | |
287 | TObjString* pString=dynamic_cast<TObjString*>(pEntry->GetObject()); | |
288 | if (pString) { | |
289 | HLTInfo("received configuration object string: \'%s\'", pString->GetString().Data()); | |
290 | iResult=Configure(pString->GetString().Data()); | |
291 | } else { | |
292 | HLTError("configuration object \"%s\" has wrong type, required TObjString", path); | |
293 | } | |
294 | } else { | |
295 | HLTError("can not fetch object \"%s\" from CDB", path); | |
296 | } | |
297 | } | |
298 | ||
299 | return iResult; | |
300 | } |