]>
Commit | Line | Data |
---|---|---|
a4c1f5dd | 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: Matthias Richter <Matthias.Richter@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 AliHLTGlobalHistoComponent.cxx | |
20 | /// @author Matthias Richter | |
21 | /// @date 2010-09-16 | |
22 | /// @brief A histogramming component for global ESD properties based | |
23 | /// on the AliHLTTTreeProcessor | |
24 | ||
25 | #include "AliHLTGlobalHistoComponent.h" | |
26 | #include "AliESDEvent.h" | |
7a37a034 | 27 | #include "AliESDv0.h" |
28 | #include "AliKFParticle.h" | |
29 | #include "AliKFVertex.h" | |
30 | ||
a4c1f5dd | 31 | #include "TTree.h" |
32 | #include "TString.h" | |
a4c1f5dd | 33 | #include <cassert> |
34 | ||
35 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
36 | ClassImp(AliHLTGlobalHistoComponent) | |
37 | ||
38 | AliHLTGlobalHistoComponent::AliHLTGlobalHistoComponent() | |
39 | : AliHLTTTreeProcessor() | |
40 | , fEvent(0) | |
41 | , fNofTracks(0) | |
a0cfb01c | 42 | , fNofV0s(0) |
1b89b93a | 43 | , fNofContributors(0) |
54da0d34 | 44 | , fVertexX(-99) |
45 | , fVertexY(-99) | |
46 | , fVertexZ(-99) | |
1b89b93a | 47 | , fVertexStatus(kFALSE) |
b77cb0b8 | 48 | , fMaxTrackCount(20000) |
a0cfb01c | 49 | , fMaxV0Count(1000) |
50 | , fFillV0(kFALSE) | |
a4c1f5dd | 51 | , fTrackVariables() |
e7f3baeb | 52 | , fTrackVariablesInt() |
a0cfb01c | 53 | , fV0Variables() |
a4c1f5dd | 54 | { |
55 | // see header file for class documentation | |
56 | // or | |
57 | // refer to README to build package | |
58 | // or | |
59 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
a4c1f5dd | 60 | } |
61 | ||
b77cb0b8 | 62 | AliHLTGlobalHistoComponent::~AliHLTGlobalHistoComponent(){ |
a4c1f5dd | 63 | // see header file for class documentation |
64 | fTrackVariables.Reset(); | |
e7f3baeb | 65 | fTrackVariablesInt.Reset(); |
a0cfb01c | 66 | fV0Variables.Reset(); |
a4c1f5dd | 67 | } |
68 | ||
7a37a034 | 69 | void AliHLTGlobalHistoComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list){ |
a4c1f5dd | 70 | // see header file for class documentation |
71 | list.push_back(kAliHLTAllDataTypes); | |
72 | } | |
73 | ||
7a37a034 | 74 | AliHLTComponentDataType AliHLTGlobalHistoComponent::GetOutputDataType(){ |
af747e4b | 75 | // see header file for class documentation |
76 | return kAliHLTDataTypeHistogram|kAliHLTDataOriginOut; | |
77 | } | |
78 | ||
7a37a034 | 79 | TTree* AliHLTGlobalHistoComponent::CreateTree(int /*argc*/, const char** /*argv*/){ |
b77cb0b8 | 80 | // create the tree and branches |
81 | ||
a4c1f5dd | 82 | int iResult=0; |
b77cb0b8 | 83 | TTree* pTree = new TTree("ESDproperties", "HLT ESD properties"); |
a4c1f5dd | 84 | if (!pTree) return NULL; |
85 | ||
86 | const char* trackVariableNames = { | |
e7f3baeb | 87 | // Note the black at the end of each name! |
a4c1f5dd | 88 | "Track_pt " |
89 | "Track_phi " | |
90 | "Track_eta " | |
54da0d34 | 91 | "Track_p " |
92 | "Track_theta " | |
e43650fb | 93 | "Track_TPCclus " |
94 | "Track_ITSclus " | |
97491309 | 95 | "Track_status " |
54da0d34 | 96 | "Track_charge " |
97491309 | 97 | "Track_DCAr " |
98 | "Track_DCAz " | |
99 | "Track_dEdx " | |
a4c1f5dd | 100 | }; |
54da0d34 | 101 | |
e7f3baeb | 102 | const char* trackIntVariableNames = { |
103 | // Note the black at the end of each name! | |
104 | "Track_status " | |
105 | }; | |
a0cfb01c | 106 | |
107 | const char* V0VariableNames = { | |
108 | // Note the black at the end of each name! | |
109 | "V0_AP " | |
110 | "V0_pt " | |
111 | "clust1 " | |
112 | "clust2 " | |
113 | "dev1 " | |
114 | "dev2 " | |
115 | "devPrim " | |
116 | "length " | |
117 | "sigmaLength " | |
118 | "r " | |
119 | }; | |
8a79a0a9 | 120 | |
a0cfb01c | 121 | if((iResult=fTrackVariables.Init(fMaxTrackCount, trackVariableNames))<0){ |
e7f3baeb | 122 | HLTError("failed to initialize internal structure for track properties (float)"); |
123 | } | |
a0cfb01c | 124 | if((iResult=fTrackVariablesInt.Init(fMaxTrackCount, trackIntVariableNames))<0){ |
e7f3baeb | 125 | HLTError("failed to initialize internal structure for track properties (int)"); |
a4c1f5dd | 126 | } |
a0cfb01c | 127 | if((iResult=fV0Variables.Init(fMaxV0Count, V0VariableNames))<0){ |
128 | HLTError("failed to initialize internal structure for V0 properties (float)"); | |
129 | } | |
a4c1f5dd | 130 | |
a0cfb01c | 131 | if(iResult>=0){ |
132 | pTree->Branch("event", &fEvent, "event/I"); | |
133 | pTree->Branch("trackcount", &fNofTracks, "trackcount/I"); | |
134 | pTree->Branch("vertexX", &fVertexX, "vertexX/F"); | |
135 | pTree->Branch("vertexY", &fVertexY, "vertexY/F"); | |
136 | pTree->Branch("vertexZ", &fVertexZ, "vertexZ/F"); | |
137 | pTree->Branch("nContributors",&fNofContributors, "nContributors/I"); | |
138 | pTree->Branch("vertexStatus", &fVertexStatus, "vertexStatus/I"); | |
139 | if(fFillV0==kTRUE) pTree->Branch("V0", &fNofV0s, "V0/I"); | |
140 | ||
141 | int i=0; | |
142 | // FIXME: this is a bit ugly since type 'f' and 'i' are specified | |
143 | // explicitely. Would be better to use a function like | |
144 | // AliHLTGlobalHistoVariables::GetType but could not get this working | |
145 | ||
146 | for(i=0; i<fTrackVariables.Variables(); i++){ | |
147 | TString specifier=fTrackVariables.GetKey(i); | |
148 | float* pArray=fTrackVariables.GetArray(specifier); | |
149 | specifier+="[trackcount]/f"; | |
150 | pTree->Branch(fTrackVariables.GetKey(i), pArray, specifier.Data()); | |
151 | } | |
152 | for(i=0; i<fTrackVariablesInt.Variables(); i++){ | |
153 | TString specifier=fTrackVariablesInt.GetKey(i); | |
154 | int* pArray=fTrackVariablesInt.GetArray(specifier); | |
155 | specifier+="[trackcount]/i"; | |
156 | pTree->Branch(fTrackVariablesInt.GetKey(i), pArray, specifier.Data()); | |
157 | } | |
158 | if(fFillV0==kTRUE){ | |
159 | for(i=0; i<fV0Variables.Variables(); i++){ | |
160 | TString specifier=fV0Variables.GetKey(i); | |
161 | float* pArray=fV0Variables.GetArray(specifier); | |
162 | specifier+="[V0]/f"; | |
163 | pTree->Branch(fV0Variables.GetKey(i), pArray, specifier.Data()); | |
164 | } | |
165 | } | |
a4c1f5dd | 166 | } else { |
167 | delete pTree; | |
a0cfb01c | 168 | pTree = NULL; |
a4c1f5dd | 169 | } |
7a37a034 | 170 | |
a4c1f5dd | 171 | return pTree; |
172 | } | |
173 | ||
7a37a034 | 174 | void AliHLTGlobalHistoComponent::FillHistogramDefinitions(){ |
a4c1f5dd | 175 | /// default histogram definitions |
176 | } | |
177 | ||
7a37a034 | 178 | int AliHLTGlobalHistoComponent::FillTree(TTree* pTree, const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ){ |
179 | ||
a4c1f5dd | 180 | /// fill the tree from the ESD |
181 | int iResult=0; | |
182 | if (!IsDataEvent()) return 0; | |
183 | ||
184 | ResetVariables(); | |
185 | ||
186 | // fetch ESD from input stream | |
e43650fb | 187 | const TObject *obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent"); |
188 | AliESDEvent *esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj)); | |
7ed629b1 | 189 | if(!esd) return 0; |
a4c1f5dd | 190 | esd->GetStdContent(); |
191 | ||
192 | // fill track variables | |
1b89b93a | 193 | fVertexX = esd->GetPrimaryVertexTracks()->GetX(); |
194 | fVertexY = esd->GetPrimaryVertexTracks()->GetY(); | |
195 | fVertexZ = esd->GetPrimaryVertexTracks()->GetZ(); | |
1b89b93a | 196 | fNofContributors = esd->GetPrimaryVertexTracks()->GetNContributors(); |
197 | fVertexStatus = esd->GetPrimaryVertexTracks()->GetStatus(); | |
e43650fb | 198 | fNofV0s = esd->GetNumberOfV0s(); |
54da0d34 | 199 | |
e43650fb | 200 | if(fFillV0==kTRUE && (fNofV0s > fMaxV0Count)){ |
a0cfb01c | 201 | HLTWarning("Found V0s are %d, while component argument is %d, the respective TTree branch is not filled properly. Need to reconfigure.\n", fNofV0s, fMaxV0Count); |
7a37a034 | 202 | } |
8e377702 | 203 | |
204 | Int_t nTracks = 0; | |
205 | ||
206 | for(int i=0; i<esd->GetNumberOfTracks(); i++){ | |
a0cfb01c | 207 | AliESDtrack *esdTrack = esd->GetTrack(i); |
208 | if (!esdTrack) continue; | |
209 | ||
210 | Float_t DCAr, DCAz = -99; | |
211 | esdTrack->GetImpactParametersTPC(DCAr, DCAz); | |
212 | ||
213 | fTrackVariables.Fill("Track_pt" , esdTrack->Pt() ); | |
214 | fTrackVariables.Fill("Track_phi" , esdTrack->Phi()*TMath::RadToDeg() ); | |
e43650fb | 215 | fTrackVariables.Fill("Track_eta" , esdTrack->Eta() ); |
a0cfb01c | 216 | fTrackVariables.Fill("Track_p" , esdTrack->P() ); |
217 | fTrackVariables.Fill("Track_theta" , esdTrack->Theta()*TMath::RadToDeg() ); | |
e43650fb | 218 | fTrackVariables.Fill("Track_TPCclus" , esdTrack->GetTPCNcls() ); |
219 | fTrackVariables.Fill("Track_ITSclus" , esdTrack->GetNcls(0) ); | |
a0cfb01c | 220 | fTrackVariables.Fill("Track_status" , esdTrack->GetStatus() ); |
221 | fTrackVariables.Fill("Track_charge" , esdTrack->Charge() ); | |
222 | fTrackVariables.Fill("Track_DCAr" , DCAr ); | |
223 | fTrackVariables.Fill("Track_DCAz" , DCAz ); | |
224 | fTrackVariables.Fill("Track_dEdx" , esdTrack->GetTPCsignal() ); | |
8e377702 | 225 | fTrackVariablesInt.Fill("Track_status" , esdTrack->GetStatus() ); |
226 | ||
227 | // selection of TPC tracks, the condition rejects e.g. TRD tracklets which would appear with 0 TPC clusters | |
228 | if( esdTrack->GetTPCNcls()>0 ) nTracks++; | |
a0cfb01c | 229 | } |
7a37a034 | 230 | |
8e377702 | 231 | fNofTracks = nTracks; |
232 | ||
a0cfb01c | 233 | if(fFillV0==kTRUE){ |
e43650fb | 234 | for(int i=0; i<fNofV0s; i++){ |
a0cfb01c | 235 | AliESDv0 *esdV0 = esd->GetV0(i); |
236 | if(!esdV0) continue; | |
a0cfb01c | 237 | |
238 | //fV0Variables.Fill("V0_AP", ap); | |
239 | //fV0Variables.Fill("V0_pt", pt); | |
240 | //fV0Variables.Fill("clust1", t1->GetTPCNcls()); | |
241 | //fV0Variables.Fill("clust2", t2->GetTPCNcls()); | |
242 | //fV0Variables.Fill("dev1", dev1); | |
243 | //fV0Variables.Fill("dev2", dev2); | |
244 | //fV0Variables.Fill("devPrim", devPrim); | |
245 | //fV0Variables.Fill("length", length); | |
246 | //fV0Variables.Fill("sigmaLength", sigmaLength); | |
247 | //fV0Variables.Fill("r", r); | |
248 | ||
249 | } // end of loop over V0s | |
d995b300 | 250 | } |
251 | /* | |
a0cfb01c | 252 | if(iResult<0){ |
a4c1f5dd | 253 | // fill an empty event |
254 | ResetVariables(); | |
255 | } | |
d995b300 | 256 | */ |
a4c1f5dd | 257 | fEvent++; |
a4c1f5dd | 258 | pTree->Fill(); |
259 | return iResult; | |
260 | } | |
261 | ||
b77cb0b8 | 262 | int AliHLTGlobalHistoComponent::ResetVariables(){ |
263 | /// reset all filling variables | |
a4c1f5dd | 264 | fNofTracks=0; |
a0cfb01c | 265 | fNofV0s=0; |
a4c1f5dd | 266 | fTrackVariables.ResetCount(); |
e7f3baeb | 267 | fTrackVariablesInt.ResetCount(); |
a0cfb01c | 268 | fV0Variables.ResetCount(); |
a4c1f5dd | 269 | return 0; |
270 | } | |
271 | ||
b77cb0b8 | 272 | AliHLTComponentDataType AliHLTGlobalHistoComponent::GetOriginDataType() const{ |
273 | // get the origin of the output data | |
4bb46850 | 274 | return kAliHLTDataTypeHistogram|kAliHLTDataOriginHLT; |
a4c1f5dd | 275 | } |
b77cb0b8 | 276 | |
277 | int AliHLTGlobalHistoComponent::ScanConfigurationArgument(int argc, const char** argv){ | |
278 | /// inherited from AliHLTComponent, scan argument | |
279 | ||
280 | if (argv==NULL || argc<1) return 0; | |
281 | ||
282 | int i=0; | |
a0cfb01c | 283 | TString argument = argv[i]; |
284 | ||
285 | // -max-track-count | |
286 | if(argument.CompareTo("-max-track-count")==0){ | |
287 | if (++i>=argc) return -EPROTO; // missing parameter | |
288 | argument = argv[i]; | |
289 | fMaxTrackCount = argument.Atoi(); | |
290 | HLTInfo("got %s with parameter %s", argument.Data(), argv[i]); | |
291 | return ++i; | |
292 | } | |
293 | ||
294 | // -max-V0-count | |
295 | if(argument.CompareTo("-max-V0-count")==0){ | |
296 | if (++i>=argc) return -EPROTO; // missing parameter | |
297 | argument = argv[i]; | |
298 | fMaxV0Count = argument.Atoi(); | |
299 | HLTInfo("got %s with parameter %s", argument.Data(), argv[i]); | |
300 | return ++i; | |
301 | } | |
302 | ||
303 | // -fill-V0 | |
304 | if(argument.CompareTo("-fill-V0")==0){ | |
305 | fFillV0 = kTRUE; | |
306 | HLTInfo("got %s", argument.Data()); | |
307 | return ++i; | |
b77cb0b8 | 308 | } |
b77cb0b8 | 309 | // no recognized argument, forward to base class |
310 | return AliHLTTTreeProcessor::ScanConfigurationArgument(argc, argv); | |
311 | } | |
312 | ||
313 | int AliHLTGlobalHistoComponent::Reconfigure(const char* cdbEntry, const char* /*chainId*/){ | |
314 | // see header file for class documentation | |
315 | ||
316 | TString cdbPath; | |
317 | if (cdbEntry) { | |
318 | cdbPath=cdbEntry; | |
319 | } else { | |
320 | cdbPath="HLT/ConfigHLT/"; | |
321 | cdbPath+=GetComponentID(); | |
322 | } | |
323 | ||
324 | return ConfigureFromCDBTObjString(cdbPath.Data()); | |
325 | } | |
326 | ||
327 |