]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - HLT/trigger/AliHLTTriggerBarrelMultiplicity.cxx
changed bining
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTriggerBarrelMultiplicity.cxx
... / ...
CommitLineData
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> *
7//* Jochen Thaeder <jochen@thaeder.de> *
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
20/// @author Matthias Richter, Jochen Thaeder
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"
32#include "AliHLTESDTrackCuts.h"
33#include "AliESDtrack.h"
34#include "AliESDEvent.h"
35#include "AliHLTTriggerDecision.h"
36#include "AliHLTDomainEntry.h"
37#include "AliHLTGlobalBarrelTrack.h"
38#include "AliHLTErrorGuard.h"
39#include "TObjArray.h"
40#include "TObjString.h"
41
42/** ROOT macro for the implementation of ROOT specific class methods */
43ClassImp(AliHLTTriggerBarrelMultiplicity)
44
45AliHLTTriggerBarrelMultiplicity::AliHLTTriggerBarrelMultiplicity()
46 : AliHLTTrigger()
47 , fHLTESDTrackCuts(NULL)
48 , fMinTracks(1)
49 , fName()
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
58const char* AliHLTTriggerBarrelMultiplicity::fgkDefaultOCDBEntry="HLT/ConfigHLT/BarrelMultiplicityTrigger";
59
60AliHLTTriggerBarrelMultiplicity::~AliHLTTriggerBarrelMultiplicity()
61{
62 // see header file for class documentation
63}
64
65const char* AliHLTTriggerBarrelMultiplicity::GetTriggerName() const
66{
67 // see header file for class documentation
68
69 if (!fName.IsNull())
70 return fName.Data();
71 else
72 return "BarrelMultiplicityTrigger";
73}
74
75AliHLTComponent* AliHLTTriggerBarrelMultiplicity::Spawn()
76{
77 // see header file for class documentation
78 return new AliHLTTriggerBarrelMultiplicity;
79}
80
81int AliHLTTriggerBarrelMultiplicity::DoTrigger()
82{
83 // see header file for class documentation
84 int iResult=0;
85 int numberOfTracks=-1;
86
87 // try the ESD as input
88 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
89 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
90
91 if (esd != NULL) {
92 numberOfTracks=0;
93 esd->GetStdContent();
94
95 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
96 AliESDtrack *esdTrack = esd->GetTrack(i);
97 if ( !esdTrack )
98 continue;
99
100 if ( fHLTESDTrackCuts->IsSelected(esdTrack) )
101 numberOfTracks++;
102 }
103 }
104
105 // try the AliHLTExternal track data as input
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
112 if (iResult>=0 && numberOfTracks<0) {
113 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack);
114 pBlock!=NULL; pBlock=GetNextInputBlock()) {
115 if (numberOfTracks<0) numberOfTracks=0;
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++) {
120 ALIHLTERRORGUARD(1, "component needs to be revised to work with track array as input");
121 // TODO CHECK CONDITION HERE
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);
126 }
127 }
128 }
129
130 bool condition=false;
131 TString description;
132
133 if (iResult>=0 && numberOfTracks>=0) {
134 if (numberOfTracks>=fMinTracks) {
135 description.Form("Event contains %d track(s) with : ", numberOfTracks);
136 description += fHLTESDTrackCuts->GetTitle();
137 condition=true;
138 } else {
139 description.Form("No tracks matching the tresholds found in the central barrel (min tracks %d) with : ", fMinTracks);
140 description += fHLTESDTrackCuts->GetTitle();
141 }
142 } else {
143 if(IsDataEvent()) {
144 description.Form("No input blocks found");
145 } else {
146 description.Form("No DataEvent found");
147 }
148 }
149
150 SetDescription(description.Data());
151
152 // add a specific trigger decision object with initialized name
153 // the readout list however is fixed
154 AliHLTTriggerDecision decision(
155 condition,
156 GetTriggerName(),
157 GetReadoutList(),
158 GetDescription()
159 );
160 TriggerEvent(&decision, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
161
162 return iResult;
163}
164
165int AliHLTTriggerBarrelMultiplicity::DoInit(int argc, const char** argv)
166{
167 // see header file for class documentation
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 }
184
185 // get path from triggername, use default object otherwise
186 TString cdbPath;
187 if (!fName.IsNull()) {
188 cdbPath="HLT/ConfigHLT/";
189 cdbPath+=fName;
190 } else {
191 cdbPath=fgkDefaultOCDBEntry;
192 }
193
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
199 if (iResult>=0 && argc>0)
200 iResult=ConfigureFromArgumentString(remainingArgs.size(), &(remainingArgs[0]));
201
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
214 return iResult;
215}
216
217int AliHLTTriggerBarrelMultiplicity::DoDeinit()
218{
219 // see header file for class documentation
220
221 if (fHLTESDTrackCuts)
222 delete fHLTESDTrackCuts;
223 fHLTESDTrackCuts = NULL;
224
225 return 0;
226}
227
228int 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
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;
243 }
244
245 return ConfigureFromCDBObject(cdbPath);
246}
247
248int AliHLTTriggerBarrelMultiplicity::ReadPreprocessorValues(const char* /*modules*/)
249{
250 // see header file for class documentation
251
252 // nothing to do for the moment
253 return 0;
254}
255
256Int_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
300int 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
307 if (!fHLTESDTrackCuts)
308 fHLTESDTrackCuts = new AliHLTESDTrackCuts("AliHLTESDTrackCuts","No track cuts");
309
310 // -maxpt
311 if (argument.CompareTo("-maxpt")==0) {
312 if (++i>=argc) return -EPROTO;
313 argument=argv[i];
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);
325 return 2;
326 }
327
328 // -minpt
329 if (argument.CompareTo("-minpt")==0) {
330 if (++i>=argc) return -EPROTO;
331 argument=argv[i];
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);
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 }
353
354 // -min-ldca
355 // minimum longitudinal dca to vertex
356 if (argument.CompareTo("-min-ldca")==0) {
357 if (++i>=argc) return -EPROTO;
358 argument=argv[i];
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);
366 return 2;
367 }
368
369 // -max-ldca
370 // maximum longitudinal dca to vertex
371 if (argument.CompareTo("-max-ldca")==0) {
372 if (++i>=argc) return -EPROTO;
373 argument=argv[i];
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);
381 return 2;
382 }
383
384 // -min-tdca
385 // minimum transverse dca to vertex
386 if (argument.CompareTo("-min-tdca")==0) {
387 if (++i>=argc) return -EPROTO;
388 argument=argv[i];
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);
396 return 2;
397 }
398
399 // -max-tdca
400 // maximum transverse dca to vertex
401 if (argument.CompareTo("-max-tdca")==0) {
402 if (++i>=argc) return -EPROTO;
403 argument=argv[i];
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");
421 return 2;
422 }
423
424 // -solenoidBz
425 if (argument.CompareTo("-solenoidBz")==0) {
426 if (++i>=argc) return -EPROTO;
427 HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
428 return 2;
429 }
430
431 // unknown argument
432 return -EINVAL;
433}