2 //**************************************************************************
3 //* This file is property of and copyright by the ALICE HLT Project *
4 //* ALICE Experiment at CERN, All rights reserved. *
6 //* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
7 //* Jochen Thaeder <jochen@thaeder.de> *
8 //* for The ALICE HLT Project. *
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 //**************************************************************************
19 /// @file AliHLTTriggerBarrelMultiplicity.cxx
20 /// @author Matthias Richter, Jochen Thaeder
22 /// @brief HLT trigger component for charged particle multiplicity in
23 /// the central barrel.
25 // see header file for class documentation
27 // refer to README to build package
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
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"
42 /** ROOT macro for the implementation of ROOT specific class methods */
43 ClassImp(AliHLTTriggerBarrelMultiplicity)
45 AliHLTTriggerBarrelMultiplicity::AliHLTTriggerBarrelMultiplicity()
47 , fHLTESDTrackCuts(NULL)
51 // see header file for class documentation
53 // refer to README to build package
55 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
58 const char* AliHLTTriggerBarrelMultiplicity::fgkDefaultOCDBEntry="HLT/ConfigHLT/BarrelMultiplicityTrigger";
60 AliHLTTriggerBarrelMultiplicity::~AliHLTTriggerBarrelMultiplicity()
62 // see header file for class documentation
65 const char* AliHLTTriggerBarrelMultiplicity::GetTriggerName() const
67 // see header file for class documentation
72 return "BarrelMultiplicityTrigger";
75 AliHLTComponent* AliHLTTriggerBarrelMultiplicity::Spawn()
77 // see header file for class documentation
78 return new AliHLTTriggerBarrelMultiplicity;
81 int AliHLTTriggerBarrelMultiplicity::DoTrigger()
83 // see header file for class documentation
86 IgnoreEvent(); // dont generate any trigger decision.
90 int numberOfTracks=-1;
92 // try the ESD as input
93 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
94 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
100 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
101 AliESDtrack *esdTrack = esd->GetTrack(i);
105 if ( fHLTESDTrackCuts->IsSelected(esdTrack) )
110 // try the AliHLTExternal track data as input
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
117 if (iResult>=0 && numberOfTracks<0) {
118 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack);
119 pBlock!=NULL; pBlock=GetNextInputBlock()) {
120 if (numberOfTracks<0) numberOfTracks=0;
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++) {
125 ALIHLTERRORGUARD(1, "component needs to be revised to work with track array as input");
126 // TODO CHECK CONDITION HERE
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);
135 bool condition=false;
138 if (iResult>=0 && numberOfTracks>=0) {
139 if (numberOfTracks>=fMinTracks) {
140 description.Form("Event contains %d track(s) with : ", numberOfTracks);
141 description += fHLTESDTrackCuts->GetTitle();
144 description.Form("No tracks matching the tresholds found in the central barrel (min tracks %d) with : ", fMinTracks);
145 description += fHLTESDTrackCuts->GetTitle();
149 description.Form("No input blocks found");
151 description.Form("No DataEvent found");
155 SetDescription(description.Data());
157 // add a specific trigger decision object with initialized name
158 // the readout list however is fixed
159 AliHLTTriggerDecision decision(
165 TriggerEvent(&decision, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
170 int AliHLTTriggerBarrelMultiplicity::DoInit(int argc, const char** argv)
172 // see header file for class documentation
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];
182 HLTError("invalid parameter for argument '-triggername', string expected");
187 remainingArgs.push_back(argv[i]);
190 // get path from triggername, use default object otherwise
192 if (!fName.IsNull()) {
193 cdbPath="HLT/ConfigHLT/";
196 cdbPath=fgkDefaultOCDBEntry;
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);
203 // -- Configure from the command line parameters if specified
204 if (iResult>=0 && argc>0)
205 iResult=ConfigureFromArgumentString(remainingArgs.size(), &(remainingArgs[0]));
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.");
213 if (!fName.IsNull()) {
214 if (fName.Contains("Barrel_pT_Single"))
222 int AliHLTTriggerBarrelMultiplicity::DoDeinit()
224 // see header file for class documentation
226 if (fHLTESDTrackCuts)
227 delete fHLTESDTrackCuts;
228 fHLTESDTrackCuts = NULL;
233 int AliHLTTriggerBarrelMultiplicity::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
235 // see header file for class documentation
237 // configure from the specified antry or the default one
239 if (!cdbEntry || cdbEntry[0]==0) {
240 if (!fName.IsNull()) {
241 cdbPath="HLT/ConfigHLT/";
244 cdbPath=fgkDefaultOCDBEntry;
250 return ConfigureFromCDBObject(cdbPath);
253 int AliHLTTriggerBarrelMultiplicity::ReadPreprocessorValues(const char* /*modules*/)
255 // see header file for class documentation
257 // nothing to do for the moment
261 Int_t AliHLTTriggerBarrelMultiplicity::ConfigureFromCDBObject(TString cdbPath)
263 // see header file for class documentation
268 // -- check for "-" and replace by "_._" in the path name
269 cdbPath.ReplaceAll("-",1,"_._",3);
271 TObject* pCDBObject = LoadAndExtractOCDBObject(cdbPath);
273 AliHLTESDTrackCuts *pCuts = dynamic_cast<AliHLTESDTrackCuts*>(pCDBObject);
275 HLTInfo("Received AliHLTESDTrackCuts configuration object : \'%s\'", pCuts->GetTitle());
276 if (fHLTESDTrackCuts)
277 delete fHLTESDTrackCuts;
278 fHLTESDTrackCuts = pCuts;
281 TObjString* pString = dynamic_cast<TObjString*>(pCDBObject);
283 HLTInfo("Received configuration object string: \'%s\'", pString->GetString().Data());
284 arguments+=pString->GetString().Data();
287 HLTError("Configuration object \"%s\" has wrong type, required AliHLTESDTrackCuts or TObjString", cdbPath.Data());
293 HLTError("Can not fetch object \"%s\" from CDB", cdbPath.Data());
297 if ( iResult>=0 && !arguments.IsNull() ) {
298 const Char_t* array = arguments.Data();
299 iResult = ConfigureFromArgumentString(1, &array);
305 int AliHLTTriggerBarrelMultiplicity::ScanConfigurationArgument(int argc, const char** argv)
307 // see header file for class documentation
308 if (argc<=0) return 0;
310 TString argument=argv[i];
312 if (!fHLTESDTrackCuts)
313 fHLTESDTrackCuts = new AliHLTESDTrackCuts("AliHLTESDTrackCuts","No track cuts");
316 if (argument.CompareTo("-maxpt")==0) {
317 if (++i>=argc) return -EPROTO;
320 Float_t minPt, maxPt;
321 fHLTESDTrackCuts->GetPtRange(minPt,maxPt);
322 maxPt = argument.Atof();
323 fHLTESDTrackCuts->SetPtRange(minPt,maxPt);
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);
334 if (argument.CompareTo("-minpt")==0) {
335 if (++i>=argc) return -EPROTO;
338 Float_t minPt, maxPt;
339 fHLTESDTrackCuts->GetPtRange(minPt,maxPt);
340 minPt = argument.Atof();
341 fHLTESDTrackCuts->SetPtRange(minPt,maxPt);
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);
352 if (argument.CompareTo("-mintracks")==0) {
353 if (++i>=argc) return -EPROTO;
355 fMinTracks=argument.Atoi();
360 // minimum longitudinal dca to vertex
361 if (argument.CompareTo("-min-ldca")==0) {
362 if (++i>=argc) return -EPROTO;
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);
375 // maximum longitudinal dca to vertex
376 if (argument.CompareTo("-max-ldca")==0) {
377 if (++i>=argc) return -EPROTO;
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);
390 // minimum transverse dca to vertex
391 if (argument.CompareTo("-min-tdca")==0) {
392 if (++i>=argc) return -EPROTO;
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);
405 // maximum transverse dca to vertex
406 if (argument.CompareTo("-max-tdca")==0) {
407 if (++i>=argc) return -EPROTO;
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);
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");
430 if (argument.CompareTo("-solenoidBz")==0) {
431 if (++i>=argc) return -EPROTO;
432 HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());