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
85 int numberOfTracks=-1;
87 // try the ESD as input
88 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
89 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
95 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
96 AliESDtrack *esdTrack = esd->GetTrack(i);
100 if ( fHLTESDTrackCuts->IsSelected(esdTrack) )
105 // try the AliHLTExternal track data as input
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
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);
130 bool condition=false;
133 if (iResult>=0 && numberOfTracks>=0) {
134 if (numberOfTracks>=fMinTracks) {
135 description.Form("Event contains %d track(s) with : ", numberOfTracks);
136 description += fHLTESDTrackCuts->GetTitle();
139 description.Form("No tracks matching the tresholds found in the central barrel (min tracks %d) with : ", fMinTracks);
140 description += fHLTESDTrackCuts->GetTitle();
144 description.Form("No input blocks found");
146 description.Form("No DataEvent found");
150 SetDescription(description.Data());
152 // add a specific trigger decision object with initialized name
153 // the readout list however is fixed
154 AliHLTTriggerDecision decision(
160 TriggerEvent(&decision, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
165 int AliHLTTriggerBarrelMultiplicity::DoInit(int argc, const char** argv)
167 // see header file for class documentation
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];
177 HLTError("invalid parameter for argument '-triggername', string expected");
182 remainingArgs.push_back(argv[i]);
185 // get path from triggername, use default object otherwise
187 if (!fName.IsNull()) {
188 cdbPath="HLT/ConfigHLT/";
191 cdbPath=fgkDefaultOCDBEntry;
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);
198 // -- Configure from the command line parameters if specified
199 if (iResult>=0 && argc>0)
200 iResult=ConfigureFromArgumentString(remainingArgs.size(), &(remainingArgs[0]));
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.");
208 if (!fName.IsNull()) {
209 if (fName.Contains("Barrel_pT_Single"))
217 int AliHLTTriggerBarrelMultiplicity::DoDeinit()
219 // see header file for class documentation
221 if (fHLTESDTrackCuts)
222 delete fHLTESDTrackCuts;
223 fHLTESDTrackCuts = NULL;
228 int AliHLTTriggerBarrelMultiplicity::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
230 // see header file for class documentation
232 // configure from the specified antry or the default one
234 if (!cdbEntry || cdbEntry[0]==0) {
235 if (!fName.IsNull()) {
236 cdbPath="HLT/ConfigHLT/";
239 cdbPath=fgkDefaultOCDBEntry;
245 return ConfigureFromCDBObject(cdbPath);
248 int AliHLTTriggerBarrelMultiplicity::ReadPreprocessorValues(const char* /*modules*/)
250 // see header file for class documentation
252 // nothing to do for the moment
256 Int_t AliHLTTriggerBarrelMultiplicity::ConfigureFromCDBObject(TString cdbPath)
258 // see header file for class documentation
263 // -- check for "-" and replace by "_._" in the path name
264 cdbPath.ReplaceAll("-",1,"_._",3);
266 TObject* pCDBObject = LoadAndExtractOCDBObject(cdbPath);
268 AliHLTESDTrackCuts *pCuts = dynamic_cast<AliHLTESDTrackCuts*>(pCDBObject);
270 HLTInfo("Received AliHLTESDTrackCuts configuration object : \'%s\'", pCuts->GetTitle());
271 if (fHLTESDTrackCuts)
272 delete fHLTESDTrackCuts;
273 fHLTESDTrackCuts = pCuts;
276 TObjString* pString = dynamic_cast<TObjString*>(pCDBObject);
278 HLTInfo("Received configuration object string: \'%s\'", pString->GetString().Data());
279 arguments+=pString->GetString().Data();
282 HLTError("Configuration object \"%s\" has wrong type, required AliHLTESDTrackCuts or TObjString", cdbPath.Data());
288 HLTError("Can not fetch object \"%s\" from CDB", cdbPath.Data());
292 if ( iResult>=0 && !arguments.IsNull() ) {
293 const Char_t* array = arguments.Data();
294 iResult = ConfigureFromArgumentString(1, &array);
300 int AliHLTTriggerBarrelMultiplicity::ScanConfigurationArgument(int argc, const char** argv)
302 // see header file for class documentation
303 if (argc<=0) return 0;
305 TString argument=argv[i];
307 if (!fHLTESDTrackCuts)
308 fHLTESDTrackCuts = new AliHLTESDTrackCuts("AliHLTESDTrackCuts","No track cuts");
311 if (argument.CompareTo("-maxpt")==0) {
312 if (++i>=argc) return -EPROTO;
315 Float_t minPt, maxPt;
316 fHLTESDTrackCuts->GetPtRange(minPt,maxPt);
317 maxPt = argument.Atof();
318 fHLTESDTrackCuts->SetPtRange(minPt,maxPt);
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);
329 if (argument.CompareTo("-minpt")==0) {
330 if (++i>=argc) return -EPROTO;
333 Float_t minPt, maxPt;
334 fHLTESDTrackCuts->GetPtRange(minPt,maxPt);
335 minPt = argument.Atof();
336 fHLTESDTrackCuts->SetPtRange(minPt,maxPt);
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);
347 if (argument.CompareTo("-mintracks")==0) {
348 if (++i>=argc) return -EPROTO;
350 fMinTracks=argument.Atoi();
355 // minimum longitudinal dca to vertex
356 if (argument.CompareTo("-min-ldca")==0) {
357 if (++i>=argc) return -EPROTO;
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);
370 // maximum longitudinal dca to vertex
371 if (argument.CompareTo("-max-ldca")==0) {
372 if (++i>=argc) return -EPROTO;
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);
385 // minimum transverse dca to vertex
386 if (argument.CompareTo("-min-tdca")==0) {
387 if (++i>=argc) return -EPROTO;
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);
400 // maximum transverse dca to vertex
401 if (argument.CompareTo("-max-tdca")==0) {
402 if (++i>=argc) return -EPROTO;
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);
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");
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());