]>
Commit | Line | Data |
---|---|---|
cafc1a86 | 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: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
7fe93db6 | 7 | //* Jochen Thaeder <jochen@thaeder.de> * |
cafc1a86 | 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 AliHLTTriggerBarrelMultiplicity.cxx | |
7fe93db6 | 20 | /// @author Matthias Richter, Jochen Thaeder |
cafc1a86 | 21 | /// @date 2009-06-30 |
22 | /// @brief HLT trigger component for charged particle multiplicity in | |
23 | /// the central barrel. | |
24 | ||
25 | // see header file for class documentation | |
26 | // or | |
27 | // refer to README to build package | |
28 | // or | |
29 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
30 | ||
31 | #include "AliHLTTriggerBarrelMultiplicity.h" | |
7fe93db6 | 32 | #include "AliHLTESDTrackCuts.h" |
33 | #include "AliESDtrack.h" | |
cafc1a86 | 34 | #include "AliESDEvent.h" |
35 | #include "AliHLTTriggerDecision.h" | |
36 | #include "AliHLTDomainEntry.h" | |
f1574126 | 37 | #include "AliHLTGlobalBarrelTrack.h" |
7fe93db6 | 38 | #include "AliHLTErrorGuard.h" |
5299dd39 | 39 | #include "TObjArray.h" |
40 | #include "TObjString.h" | |
cafc1a86 | 41 | |
42 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
43 | ClassImp(AliHLTTriggerBarrelMultiplicity) | |
44 | ||
45 | AliHLTTriggerBarrelMultiplicity::AliHLTTriggerBarrelMultiplicity() | |
46 | : AliHLTTrigger() | |
7fe93db6 | 47 | , fHLTESDTrackCuts(NULL) |
cafc1a86 | 48 | , fMinTracks(1) |
508ca723 | 49 | , fName() |
cafc1a86 | 50 | { |
51 | // see header file for class documentation | |
52 | // or | |
53 | // refer to README to build package | |
54 | // or | |
55 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
56 | } | |
57 | ||
508ca723 | 58 | const char* AliHLTTriggerBarrelMultiplicity::fgkDefaultOCDBEntry="HLT/ConfigHLT/BarrelMultiplicityTrigger"; |
f1574126 | 59 | |
cafc1a86 | 60 | AliHLTTriggerBarrelMultiplicity::~AliHLTTriggerBarrelMultiplicity() |
61 | { | |
62 | // see header file for class documentation | |
63 | } | |
64 | ||
65 | const char* AliHLTTriggerBarrelMultiplicity::GetTriggerName() const | |
66 | { | |
67 | // see header file for class documentation | |
7fe93db6 | 68 | |
69 | if (!fName.IsNull()) | |
70 | return fName.Data(); | |
71 | else | |
72 | return "BarrelMultiplicityTrigger"; | |
cafc1a86 | 73 | } |
74 | ||
75 | AliHLTComponent* AliHLTTriggerBarrelMultiplicity::Spawn() | |
76 | { | |
77 | // see header file for class documentation | |
78 | return new AliHLTTriggerBarrelMultiplicity; | |
79 | } | |
80 | ||
81 | int AliHLTTriggerBarrelMultiplicity::DoTrigger() | |
82 | { | |
83 | // see header file for class documentation | |
f1574126 | 84 | int iResult=0; |
85 | int numberOfTracks=-1; | |
86 | ||
87 | // try the ESD as input | |
cafc1a86 | 88 | const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent"); |
89 | AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj)); | |
7fe93db6 | 90 | |
cafc1a86 | 91 | if (esd != NULL) { |
f1574126 | 92 | numberOfTracks=0; |
cafc1a86 | 93 | esd->GetStdContent(); |
94 | ||
cafc1a86 | 95 | for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) { |
7fe93db6 | 96 | AliESDtrack *esdTrack = esd->GetTrack(i); |
97 | if ( !esdTrack ) | |
98 | continue; | |
99 | ||
100 | if ( fHLTESDTrackCuts->IsSelected(esdTrack) ) | |
101 | numberOfTracks++; | |
f1574126 | 102 | } |
103 | } | |
104 | ||
105 | // try the AliHLTExternal track data as input | |
7fe93db6 | 106 | // TODO: 2010-08-27 |
107 | // AliHLTTrackCuts needs an AliESDtrack object and not just AliExternalTrackParam | |
108 | // this part needs to be revised to work correctly with the track array as input | |
109 | // - think about specific conversion method in AliHLTGlobalBarrelTrack | |
110 | // - make sure that all necessary parameters are set | |
111 | // - clarify what to do about the track flags | |
f1574126 | 112 | if (iResult>=0 && numberOfTracks<0) { |
113 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack); | |
114 | pBlock!=NULL; pBlock=GetNextInputBlock()) { | |
b97c19da | 115 | if (numberOfTracks<0) numberOfTracks=0; |
f1574126 | 116 | vector<AliHLTGlobalBarrelTrack> tracks; |
117 | if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) { | |
118 | for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); | |
119 | element!=tracks.end(); element++) { | |
7fe93db6 | 120 | ALIHLTERRORGUARD(1, "component needs to be revised to work with track array as input"); |
121 | // TODO CHECK CONDITION HERE | |
f1574126 | 122 | } |
123 | } else if (iResult<0) { | |
124 | HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d", | |
125 | DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult); | |
cafc1a86 | 126 | } |
127 | } | |
f1574126 | 128 | } |
cafc1a86 | 129 | |
508ca723 | 130 | bool condition=false; |
7fe93db6 | 131 | TString description; |
5299dd39 | 132 | |
7fe93db6 | 133 | if (iResult>=0 && numberOfTracks>=0) { |
cafc1a86 | 134 | if (numberOfTracks>=fMinTracks) { |
7fe93db6 | 135 | description.Form("Event contains %d track(s) with : ", numberOfTracks); |
136 | description += fHLTESDTrackCuts->GetTitle(); | |
508ca723 | 137 | condition=true; |
138 | } else { | |
7fe93db6 | 139 | description.Form("No tracks matching the tresholds found in the central barrel (min tracks %d) with : ", fMinTracks); |
140 | description += fHLTESDTrackCuts->GetTitle(); | |
508ca723 | 141 | } |
f1574126 | 142 | } else { |
7fe93db6 | 143 | if(IsDataEvent()) { |
144 | description.Form("No input blocks found"); | |
145 | } else { | |
146 | description.Form("No DataEvent found"); | |
147 | } | |
cafc1a86 | 148 | } |
7fe93db6 | 149 | |
150 | SetDescription(description.Data()); | |
508ca723 | 151 | |
152 | // add a specific trigger decision object with initialized name | |
153 | // the readout list however is fixed | |
154 | AliHLTTriggerDecision decision( | |
155 | condition, | |
7fe93db6 | 156 | GetTriggerName(), |
508ca723 | 157 | GetReadoutList(), |
7fe93db6 | 158 | GetDescription() |
508ca723 | 159 | ); |
160 | TriggerEvent(&decision, kAliHLTDataTypeTObject|kAliHLTDataOriginOut); | |
161 | ||
f1574126 | 162 | return iResult; |
163 | } | |
164 | ||
f1574126 | 165 | int AliHLTTriggerBarrelMultiplicity::DoInit(int argc, const char** argv) |
166 | { | |
167 | // see header file for class documentation | |
508ca723 | 168 | int iResult=0; |
169 | ||
170 | // check if the -triggername argument is used | |
171 | // the name of the trigger determines the following initialization | |
172 | vector<const char*> remainingArgs; | |
173 | for (int i=0; i<argc; i++) { | |
174 | if (strcmp(argv[i], "-triggername")==0) { | |
175 | if (++i<argc) fName=argv[i]; | |
176 | else { | |
177 | HLTError("invalid parameter for argument '-triggername', string expected"); | |
178 | return -EINVAL; | |
179 | } | |
180 | continue; | |
181 | } | |
182 | remainingArgs.push_back(argv[i]); | |
183 | } | |
f1574126 | 184 | |
7fe93db6 | 185 | // get path from triggername, use default object otherwise |
508ca723 | 186 | TString cdbPath; |
187 | if (!fName.IsNull()) { | |
188 | cdbPath="HLT/ConfigHLT/"; | |
189 | cdbPath+=fName; | |
190 | } else { | |
191 | cdbPath=fgkDefaultOCDBEntry; | |
192 | } | |
f1574126 | 193 | |
7fe93db6 | 194 | // -- Check if CDB object is AliHLTESDTrackCuts or TObjString |
195 | // and configure from it. Replace "-" by "_._" if needed in the cdbPath | |
196 | iResult = ConfigureFromCDBObject(cdbPath); | |
197 | ||
198 | // -- Configure from the command line parameters if specified | |
f1574126 | 199 | if (iResult>=0 && argc>0) |
508ca723 | 200 | iResult=ConfigureFromArgumentString(remainingArgs.size(), &(remainingArgs[0])); |
75970b8d | 201 | |
7fe93db6 | 202 | // -- Check if we have the track cuts for triggering |
203 | if (!fHLTESDTrackCuts) { | |
204 | HLTError("No AliHLTESDTrackCuts object has been created as basis for triggering."); | |
205 | iResult=-ENOENT; | |
206 | } | |
207 | else { | |
208 | if (!fName.IsNull()) { | |
209 | if (fName.Contains("Barrel_pT_Single")) | |
210 | fMinTracks = 1; | |
211 | } | |
212 | } | |
213 | ||
508ca723 | 214 | return iResult; |
f1574126 | 215 | } |
216 | ||
217 | int AliHLTTriggerBarrelMultiplicity::DoDeinit() | |
218 | { | |
219 | // see header file for class documentation | |
7fe93db6 | 220 | |
221 | if (fHLTESDTrackCuts) | |
222 | delete fHLTESDTrackCuts; | |
223 | fHLTESDTrackCuts = NULL; | |
224 | ||
cafc1a86 | 225 | return 0; |
226 | } | |
f1574126 | 227 | |
228 | int AliHLTTriggerBarrelMultiplicity::Reconfigure(const char* cdbEntry, const char* /*chainId*/) | |
229 | { | |
230 | // see header file for class documentation | |
231 | ||
232 | // configure from the specified antry or the default one | |
508ca723 | 233 | TString cdbPath; |
234 | if (!cdbEntry || cdbEntry[0]==0) { | |
235 | if (!fName.IsNull()) { | |
236 | cdbPath="HLT/ConfigHLT/"; | |
237 | cdbPath+=fName; | |
238 | } else { | |
239 | cdbPath=fgkDefaultOCDBEntry; | |
240 | } | |
241 | } else { | |
242 | cdbPath=cdbEntry; | |
5299dd39 | 243 | } |
f1574126 | 244 | |
7fe93db6 | 245 | return ConfigureFromCDBObject(cdbPath); |
f1574126 | 246 | } |
247 | ||
5299dd39 | 248 | int AliHLTTriggerBarrelMultiplicity::ReadPreprocessorValues(const char* /*modules*/) |
249 | { | |
250 | // see header file for class documentation | |
251 | ||
75970b8d | 252 | // nothing to do for the moment |
253 | return 0; | |
5299dd39 | 254 | } |
255 | ||
7fe93db6 | 256 | Int_t AliHLTTriggerBarrelMultiplicity::ConfigureFromCDBObject(TString cdbPath) |
257 | { | |
258 | // see header file for class documentation | |
259 | ||
260 | Int_t iResult = 0; | |
261 | TString arguments; | |
262 | ||
263 | // -- check for "-" and replace by "_._" in the path name | |
264 | cdbPath.ReplaceAll("-",1,"_._",3); | |
265 | ||
266 | TObject* pCDBObject = LoadAndExtractOCDBObject(cdbPath); | |
267 | if (pCDBObject) { | |
268 | AliHLTESDTrackCuts *pCuts = dynamic_cast<AliHLTESDTrackCuts*>(pCDBObject); | |
269 | if (pCuts) { | |
270 | HLTInfo("Received AliHLTESDTrackCuts configuration object : \'%s\'", pCuts->GetTitle()); | |
271 | if (fHLTESDTrackCuts) | |
272 | delete fHLTESDTrackCuts; | |
273 | fHLTESDTrackCuts = pCuts; | |
274 | } | |
275 | else { | |
276 | TObjString* pString = dynamic_cast<TObjString*>(pCDBObject); | |
277 | if (pString) { | |
278 | HLTInfo("Received configuration object string: \'%s\'", pString->GetString().Data()); | |
279 | arguments+=pString->GetString().Data(); | |
280 | } | |
281 | else { | |
282 | HLTError("Configuration object \"%s\" has wrong type, required AliHLTESDTrackCuts or TObjString", cdbPath.Data()); | |
283 | iResult=-EINVAL; | |
284 | } | |
285 | } | |
286 | } | |
287 | else { | |
288 | HLTError("Can not fetch object \"%s\" from CDB", cdbPath.Data()); | |
289 | iResult=-ENOENT; | |
290 | } | |
291 | ||
292 | if ( iResult>=0 && !arguments.IsNull() ) { | |
293 | const Char_t* array = arguments.Data(); | |
294 | iResult = ConfigureFromArgumentString(1, &array); | |
295 | } | |
296 | ||
297 | return iResult; | |
298 | } | |
299 | ||
f1574126 | 300 | int AliHLTTriggerBarrelMultiplicity::ScanConfigurationArgument(int argc, const char** argv) |
301 | { | |
302 | // see header file for class documentation | |
303 | if (argc<=0) return 0; | |
304 | int i=0; | |
305 | TString argument=argv[i]; | |
306 | ||
7fe93db6 | 307 | if (!fHLTESDTrackCuts) |
308 | fHLTESDTrackCuts = new AliHLTESDTrackCuts("AliHLTESDTrackCuts","No track cuts"); | |
309 | ||
f1574126 | 310 | // -maxpt |
311 | if (argument.CompareTo("-maxpt")==0) { | |
312 | if (++i>=argc) return -EPROTO; | |
313 | argument=argv[i]; | |
7fe93db6 | 314 | |
315 | Float_t minPt, maxPt; | |
316 | fHLTESDTrackCuts->GetPtRange(minPt,maxPt); | |
317 | maxPt = argument.Atof(); | |
318 | fHLTESDTrackCuts->SetPtRange(minPt,maxPt); | |
319 | ||
320 | TString title = fHLTESDTrackCuts->GetTitle(); | |
321 | if (!title.CompareTo("No track cuts")) title = ""; | |
322 | else title += " && "; | |
323 | title += Form("p_t < %f", maxPt); | |
324 | fHLTESDTrackCuts->SetTitle(title); | |
f1574126 | 325 | return 2; |
326 | } | |
327 | ||
328 | // -minpt | |
329 | if (argument.CompareTo("-minpt")==0) { | |
330 | if (++i>=argc) return -EPROTO; | |
331 | argument=argv[i]; | |
7fe93db6 | 332 | |
333 | Float_t minPt, maxPt; | |
334 | fHLTESDTrackCuts->GetPtRange(minPt,maxPt); | |
335 | minPt = argument.Atof(); | |
336 | fHLTESDTrackCuts->SetPtRange(minPt,maxPt); | |
337 | ||
338 | TString title = fHLTESDTrackCuts->GetTitle(); | |
339 | if (!title.CompareTo("No track cuts")) title = ""; | |
340 | else title += " && "; | |
341 | title += Form("p_t > %f", minPt); | |
342 | fHLTESDTrackCuts->SetTitle(title); | |
f1574126 | 343 | return 2; |
344 | } | |
345 | ||
346 | // -mintracks | |
347 | if (argument.CompareTo("-mintracks")==0) { | |
348 | if (++i>=argc) return -EPROTO; | |
349 | argument=argv[i]; | |
350 | fMinTracks=argument.Atoi(); | |
351 | return 2; | |
352 | } | |
5299dd39 | 353 | |
5299dd39 | 354 | // -min-ldca |
7fe93db6 | 355 | // minimum longitudinal dca to vertex |
5299dd39 | 356 | if (argument.CompareTo("-min-ldca")==0) { |
357 | if (++i>=argc) return -EPROTO; | |
358 | argument=argv[i]; | |
7fe93db6 | 359 | |
360 | fHLTESDTrackCuts->SetMinDCAToVertexZ(argument.Atof()); | |
361 | TString title = fHLTESDTrackCuts->GetTitle(); | |
362 | if (!title.CompareTo("No track cuts")) title = ""; | |
363 | else title += " && "; | |
364 | title += Form("DCAz > %f", argument.Atof()); | |
365 | fHLTESDTrackCuts->SetTitle(title); | |
5299dd39 | 366 | return 2; |
367 | } | |
f1574126 | 368 | |
5299dd39 | 369 | // -max-ldca |
7fe93db6 | 370 | // maximum longitudinal dca to vertex |
5299dd39 | 371 | if (argument.CompareTo("-max-ldca")==0) { |
372 | if (++i>=argc) return -EPROTO; | |
373 | argument=argv[i]; | |
7fe93db6 | 374 | |
375 | fHLTESDTrackCuts->SetMaxDCAToVertexZ(argument.Atof()); | |
376 | TString title = fHLTESDTrackCuts->GetTitle(); | |
377 | if (!title.CompareTo("No track cuts")) title = ""; | |
378 | else title += " && "; | |
379 | title += Form("DCAz < %f", argument.Atof()); | |
380 | fHLTESDTrackCuts->SetTitle(title); | |
5299dd39 | 381 | return 2; |
382 | } | |
383 | ||
384 | // -min-tdca | |
7fe93db6 | 385 | // minimum transverse dca to vertex |
5299dd39 | 386 | if (argument.CompareTo("-min-tdca")==0) { |
387 | if (++i>=argc) return -EPROTO; | |
388 | argument=argv[i]; | |
7fe93db6 | 389 | |
390 | fHLTESDTrackCuts->SetMinDCAToVertexXY(argument.Atof()); | |
391 | TString title = fHLTESDTrackCuts->GetTitle(); | |
392 | if (!title.CompareTo("No track cuts")) title = ""; | |
393 | else title += " && "; | |
394 | title += Form("DCAr > %f", argument.Atof()); | |
395 | fHLTESDTrackCuts->SetTitle(title); | |
5299dd39 | 396 | return 2; |
397 | } | |
398 | ||
399 | // -max-tdca | |
7fe93db6 | 400 | // maximum transverse dca to vertex |
5299dd39 | 401 | if (argument.CompareTo("-max-tdca")==0) { |
402 | if (++i>=argc) return -EPROTO; | |
403 | argument=argv[i]; | |
7fe93db6 | 404 | |
405 | fHLTESDTrackCuts->SetMaxDCAToVertexXY(argument.Atof()); | |
406 | TString title = fHLTESDTrackCuts->GetTitle(); | |
407 | if (!title.CompareTo("No track cuts")) title = ""; | |
408 | else title += " && "; | |
409 | title += Form("DCAr < %f", argument.Atof()); | |
410 | fHLTESDTrackCuts->SetTitle(title); | |
411 | return 2; | |
412 | } | |
413 | ||
414 | // -- deprecated | |
415 | ||
416 | // -dca-reference | |
417 | // reference point for the transverse and longitudinal dca cut | |
418 | if (argument.CompareTo("-dca-reference")==0) { | |
419 | if (++i>=argc) return -EPROTO; | |
420 | HLTWarning("argument -dca-reference deprecated, ESDTrackCuts only allow for DCA to vertex"); | |
5299dd39 | 421 | return 2; |
422 | } | |
423 | ||
424 | // -solenoidBz | |
425 | if (argument.CompareTo("-solenoidBz")==0) { | |
426 | if (++i>=argc) return -EPROTO; | |
75970b8d | 427 | HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz()); |
5299dd39 | 428 | return 2; |
429 | } | |
430 | ||
f1574126 | 431 | // unknown argument |
432 | return -EINVAL; | |
433 | } |