]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTTriggerBarrelMultiplicity.cxx
Update of the SSD on-line clusterfinder:
[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> *
7//* for The ALICE HLT Project. *
8//* *
9//* Permission to use, copy, modify and distribute this software and its *
10//* documentation strictly for non-commercial purposes is hereby granted *
11//* without fee, provided that the above copyright notice appears in all *
12//* copies and that both the copyright notice and this permission notice *
13//* appear in the supporting documentation. The authors make no claims *
14//* about the suitability of this software for any purpose. It is *
15//* provided "as is" without express or implied warranty. *
16//**************************************************************************
17
18/// @file AliHLTTriggerBarrelMultiplicity.cxx
19/// @author Matthias Richter
20/// @date 2009-06-30
21/// @brief HLT trigger component for charged particle multiplicity in
22/// the central barrel.
23
24// see header file for class documentation
25// or
26// refer to README to build package
27// or
28// visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
29
30#include "AliHLTTriggerBarrelMultiplicity.h"
31#include "AliESDEvent.h"
32#include "AliHLTTriggerDecision.h"
33#include "AliHLTDomainEntry.h"
f1574126 34#include "AliHLTGlobalBarrelTrack.h"
5299dd39 35#include "TObjArray.h"
36#include "TObjString.h"
cafc1a86 37
38/** ROOT macro for the implementation of ROOT specific class methods */
39ClassImp(AliHLTTriggerBarrelMultiplicity)
40
41AliHLTTriggerBarrelMultiplicity::AliHLTTriggerBarrelMultiplicity()
42 : AliHLTTrigger()
43 , fPtMin(0.0)
44 , fPtMax(0.0)
45 , fMinTracks(1)
5299dd39 46 , fDCAReference()
47 , fMinLDca(-1.)
48 , fMaxLDca(-1.)
49 , fMinTDca(-1.)
50 , fMaxTDca(-1.)
51 , fSolenoidBz(0.0)
508ca723 52 , fName()
cafc1a86 53{
54 // see header file for class documentation
55 // or
56 // refer to README to build package
57 // or
58 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
5299dd39 59
60 for (int i=0; i<fgkDCAReferenceSize; i++) fDCAReference[i]=0.0;
cafc1a86 61}
62
508ca723 63const char* AliHLTTriggerBarrelMultiplicity::fgkDefaultOCDBEntry="HLT/ConfigHLT/BarrelMultiplicityTrigger";
f1574126 64
cafc1a86 65AliHLTTriggerBarrelMultiplicity::~AliHLTTriggerBarrelMultiplicity()
66{
67 // see header file for class documentation
68}
69
70const char* AliHLTTriggerBarrelMultiplicity::GetTriggerName() const
71{
72 // see header file for class documentation
73 return "BarrelMultiplicityTrigger";
74}
75
76AliHLTComponent* AliHLTTriggerBarrelMultiplicity::Spawn()
77{
78 // see header file for class documentation
79 return new AliHLTTriggerBarrelMultiplicity;
80}
81
82int AliHLTTriggerBarrelMultiplicity::DoTrigger()
83{
84 // see header file for class documentation
f1574126 85 int iResult=0;
86 int numberOfTracks=-1;
87
88 // try the ESD as input
cafc1a86 89 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
90 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
91 TString description;
5299dd39 92 TString ptcut,tdca,ldca,dcaref,op1st,op2nd;
cafc1a86 93 if (esd != NULL) {
f1574126 94 numberOfTracks=0;
cafc1a86 95 esd->GetStdContent();
96
cafc1a86 97 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
5299dd39 98 if (CheckCondition(esd->GetTrack(i), esd->GetMagneticField())) numberOfTracks++;
f1574126 99 }
100 }
101
102 // try the AliHLTExternal track data as input
103 if (iResult>=0 && numberOfTracks<0) {
104 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack);
105 pBlock!=NULL; pBlock=GetNextInputBlock()) {
b97c19da 106 if (numberOfTracks<0) numberOfTracks=0;
f1574126 107 vector<AliHLTGlobalBarrelTrack> tracks;
108 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) {
109 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
110 element!=tracks.end(); element++) {
5299dd39 111 if (CheckCondition(&(*element), fSolenoidBz)) numberOfTracks++;
f1574126 112 }
113 } else if (iResult<0) {
114 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
115 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
cafc1a86 116 }
117 }
f1574126 118 }
cafc1a86 119
508ca723 120 bool condition=false;
f1574126 121 if (iResult>=0 && numberOfTracks>=0) {
cafc1a86 122 if (fPtMax>fPtMin) {
123 ptcut.Form(" %.02f GeV/c <= pt < %.02f GeV/c", fPtMin, fPtMax);
124 } else {
125 ptcut.Form(" pt >= %.02f GeV/c", fPtMin);
126 }
5299dd39 127
128 if (fMinTDca>=0.0) {
129 if (fMaxTDca>=0.0) {
130 tdca.Form(", %.02f<=transverse_dca<=%.02f", fMinTDca, fMaxTDca);
131 } else {
132 tdca.Form(" transverse_dca >= %.02f", fMinTDca);
133 }
134 } else if (fMaxTDca>=0.0) {
135 tdca.Form(" transverse_dca<=%.02f", fMaxTDca);
136 }
137 if (!tdca.IsNull()) {
138 if (op1st.IsNull()) op1st=" && ";
139 else op2nd=" && ";
140 }
141
142 if (fMinLDca>=0.0) {
143 if (fMaxLDca>=0.0) {
144 ldca.Form(" %.02f<=longitudinal_dca<=%.02f", fMinLDca, fMaxLDca);
145 } else {
146 ldca.Form(" longitudinal_dca >= %.02f", fMinLDca);
147 }
148 } else if (fMaxLDca>=0.0) {
149 ldca.Form(" longitudinal_dca<=%.02f", fMaxLDca);
150 }
151 if (!ldca.IsNull()) {
152 if (op1st.IsNull()) op1st=" && ";
153 else op2nd=" && ";
154 }
155
156 if (fMinTDca>=0.0 || fMaxTDca>=0 || fMinLDca>=0.0 || fMaxLDca>=0) {
157 dcaref.Form(" (%.01f,%.01f,%.01f)", fDCAReference[0], fDCAReference[1], fDCAReference[2]);
158 }
159
cafc1a86 160 if (numberOfTracks>=fMinTracks) {
161 description.Form("Event contains %d track(s) with ", numberOfTracks);
162 description+=ptcut;
5299dd39 163 description+=op1st;
164 description+=ldca;
165 description+=op2nd;
166 description+=tdca;
167 description+=dcaref;
cafc1a86 168 SetDescription(description.Data());
169 // Enable the central detectors for readout.
170 GetReadoutList().Enable(
171 AliHLTReadoutList::kITSSPD |
172 AliHLTReadoutList::kITSSDD |
173 AliHLTReadoutList::kITSSSD |
174 AliHLTReadoutList::kTPC |
175 AliHLTReadoutList::kTRD |
176 AliHLTReadoutList::kTOF |
177 AliHLTReadoutList::kHMPID |
508ca723 178 AliHLTReadoutList::kPHOS |
179 AliHLTReadoutList::kEMCAL
cafc1a86 180 );
508ca723 181 condition=true;
182 } else {
5299dd39 183 description.Form("No tracks matching the tresholds found in the central barrel (min tracks %d, ", fMinTracks);
184 description+=ptcut;
185 description+=op1st;
186 description+=ldca;
187 description+=op2nd;
188 description+=tdca;
189 description+=dcaref;
190 description+=")";
508ca723 191 }
f1574126 192 } else {
193 description.Form("No input blocks found");
cafc1a86 194 }
508ca723 195
196 // add a specific trigger decision object with initialized name
197 // the readout list however is fixed
198 AliHLTTriggerDecision decision(
199 condition,
200 fName.IsNull()?GetTriggerName():fName.Data(),
201 GetReadoutList(),
202 description.Data()
203 );
204 TriggerEvent(&decision, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
205
f1574126 206 return iResult;
207}
208
209template<class T>
5299dd39 210bool AliHLTTriggerBarrelMultiplicity::CheckCondition(T* track, float b)
f1574126 211{
212 // see header file for class documentation
5299dd39 213 if (!track) return false;
214
215 // check on ptransverse momentum
216 if (TMath::Abs(track->Pt()) < fPtMin || (fPtMax>fPtMin && TMath::Abs(track->Pt()) > fPtMax)) {
217 return false;
218 }
219
220 // check on transverse and longitudinal DCA
221 if (fMinTDca>=0.0 || fMaxTDca>=0 || fMinLDca>=0.0 || fMaxLDca>=0) {
222 Float_t dz[2]={0.0,0.0};
223 track->GetDZ(fDCAReference[0], fDCAReference[1], fDCAReference[2], b, dz);
224 HLTDebug("checking dca condition: transversal %f logitudinal %f", dz[0], dz[1]);
225 if (fMinTDca>=0 && TMath::Abs(dz[0])<fMinTDca) return false;
226 if (fMaxTDca>=0 && TMath::Abs(dz[0])>fMaxTDca) return false;
227 if (fMinLDca>=0 && TMath::Abs(dz[1])<fMinLDca) return false;
228 if (fMaxLDca>=0 && TMath::Abs(dz[1])>fMaxLDca) return false;
f1574126 229 }
5299dd39 230
231 return true;
f1574126 232}
233
234int AliHLTTriggerBarrelMultiplicity::DoInit(int argc, const char** argv)
235{
236 // see header file for class documentation
508ca723 237 int iResult=0;
238
239 // check if the -triggername argument is used
240 // the name of the trigger determines the following initialization
241 vector<const char*> remainingArgs;
242 for (int i=0; i<argc; i++) {
243 if (strcmp(argv[i], "-triggername")==0) {
244 if (++i<argc) fName=argv[i];
245 else {
246 HLTError("invalid parameter for argument '-triggername', string expected");
247 return -EINVAL;
248 }
249 continue;
250 }
251 remainingArgs.push_back(argv[i]);
252 }
f1574126 253
254 // first configure the default
508ca723 255 TString cdbPath;
256 if (!fName.IsNull()) {
257 cdbPath="HLT/ConfigHLT/";
258 cdbPath+=fName;
259 } else {
260 cdbPath=fgkDefaultOCDBEntry;
261 }
262 iResult=ConfigureFromCDBTObjString(cdbPath);
f1574126 263
264 // configure from the command line parameters if specified
265 if (iResult>=0 && argc>0)
508ca723 266 iResult=ConfigureFromArgumentString(remainingArgs.size(), &(remainingArgs[0]));
75970b8d 267
268 fSolenoidBz=GetBz();
508ca723 269 return iResult;
f1574126 270}
271
272int AliHLTTriggerBarrelMultiplicity::DoDeinit()
273{
274 // see header file for class documentation
cafc1a86 275 return 0;
276}
f1574126 277
278int AliHLTTriggerBarrelMultiplicity::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
279{
280 // see header file for class documentation
281
282 // configure from the specified antry or the default one
508ca723 283 TString cdbPath;
284 if (!cdbEntry || cdbEntry[0]==0) {
285 if (!fName.IsNull()) {
286 cdbPath="HLT/ConfigHLT/";
287 cdbPath+=fName;
288 } else {
289 cdbPath=fgkDefaultOCDBEntry;
290 }
291 } else {
292 cdbPath=cdbEntry;
5299dd39 293 }
f1574126 294
508ca723 295 return ConfigureFromCDBTObjString(cdbPath);
f1574126 296}
297
5299dd39 298int AliHLTTriggerBarrelMultiplicity::ReadPreprocessorValues(const char* /*modules*/)
299{
300 // see header file for class documentation
301
75970b8d 302 // nothing to do for the moment
303 return 0;
5299dd39 304}
305
f1574126 306int AliHLTTriggerBarrelMultiplicity::ScanConfigurationArgument(int argc, const char** argv)
307{
308 // see header file for class documentation
309 if (argc<=0) return 0;
310 int i=0;
311 TString argument=argv[i];
312
313 // -maxpt
314 if (argument.CompareTo("-maxpt")==0) {
315 if (++i>=argc) return -EPROTO;
316 argument=argv[i];
317 fPtMax=argument.Atof();
318 return 2;
319 }
320
321 // -minpt
322 if (argument.CompareTo("-minpt")==0) {
323 if (++i>=argc) return -EPROTO;
324 argument=argv[i];
325 fPtMin=argument.Atof();
326 return 2;
327 }
328
329 // -mintracks
330 if (argument.CompareTo("-mintracks")==0) {
331 if (++i>=argc) return -EPROTO;
332 argument=argv[i];
333 fMinTracks=argument.Atoi();
334 return 2;
335 }
5299dd39 336
337 // -dca-reference
338 // reference point for the transverse and longitudinal dca cut
339 if (argument.CompareTo("-dca-reference")==0) {
340 if (++i>=argc) return -EPROTO;
341 argument=argv[i];
342 // scan x,y,z
343 TObjArray* pTokens=argument.Tokenize("'");
344 if (pTokens) {
345 for (int c=0; c<pTokens->GetEntriesFast() && c<fgkDCAReferenceSize; c++) {
346 argument=((TObjString*)pTokens->At(c))->GetString();
347 fDCAReference[i]=argument.Atof();
348 }
349 delete pTokens;
350 }
351 return 2;
352 }
353
354 // -min-ldca
355 // minimum longitudinal dca to reference point
356 if (argument.CompareTo("-min-ldca")==0) {
357 if (++i>=argc) return -EPROTO;
358 argument=argv[i];
359 fMinLDca=argument.Atof();
360 return 2;
361 }
f1574126 362
5299dd39 363 // -max-ldca
364 // maximum longitudinal dca to reference point
365 if (argument.CompareTo("-max-ldca")==0) {
366 if (++i>=argc) return -EPROTO;
367 argument=argv[i];
368 fMaxLDca=argument.Atof();
369 return 2;
370 }
371
372 // -min-tdca
373 // minimum transverse dca to reference point
374 if (argument.CompareTo("-min-tdca")==0) {
375 if (++i>=argc) return -EPROTO;
376 argument=argv[i];
377 fMinTDca=argument.Atof();
378 return 2;
379 }
380
381 // -max-tdca
382 // maximum transverse dca to reference point
383 if (argument.CompareTo("-max-tdca")==0) {
384 if (++i>=argc) return -EPROTO;
385 argument=argv[i];
386 fMaxTDca=argument.Atof();
387 return 2;
388 }
389
390 // -solenoidBz
391 if (argument.CompareTo("-solenoidBz")==0) {
392 if (++i>=argc) return -EPROTO;
75970b8d 393 HLTWarning("argument -solenoidBz is deprecated, magnetic field set up globally (%f)", GetBz());
5299dd39 394 return 2;
395 }
396
f1574126 397 // unknown argument
398 return -EINVAL;
399}