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