- adding AliHLTTriggerDecisionParameters to configure the geom trigger from OCDB.
[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"
fde46e9e 37#include "TVector3.h"
cafc1a86 38
39/** ROOT macro for the implementation of ROOT specific class methods */
40ClassImp(AliHLTTriggerBarrelMultiplicity)
41
42AliHLTTriggerBarrelMultiplicity::AliHLTTriggerBarrelMultiplicity()
43 : AliHLTTrigger()
44 , fPtMin(0.0)
45 , fPtMax(0.0)
46 , fMinTracks(1)
5299dd39 47 , fDCAReference()
48 , fMinLDca(-1.)
49 , fMaxLDca(-1.)
50 , fMinTDca(-1.)
51 , fMaxTDca(-1.)
52 , fSolenoidBz(0.0)
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
f1574126 63const char* AliHLTTriggerBarrelMultiplicity::fgkOCDBEntry="HLT/ConfigHLT/BarrelMultiplicityTrigger";
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
f1574126 120 if (iResult>=0 && numberOfTracks>=0) {
cafc1a86 121 if (fPtMax>fPtMin) {
122 ptcut.Form(" %.02f GeV/c <= pt < %.02f GeV/c", fPtMin, fPtMax);
123 } else {
124 ptcut.Form(" pt >= %.02f GeV/c", fPtMin);
125 }
5299dd39 126
127 if (fMinTDca>=0.0) {
128 if (fMaxTDca>=0.0) {
129 tdca.Form(", %.02f<=transverse_dca<=%.02f", fMinTDca, fMaxTDca);
130 } else {
131 tdca.Form(" transverse_dca >= %.02f", fMinTDca);
132 }
133 } else if (fMaxTDca>=0.0) {
134 tdca.Form(" transverse_dca<=%.02f", fMaxTDca);
135 }
136 if (!tdca.IsNull()) {
137 if (op1st.IsNull()) op1st=" && ";
138 else op2nd=" && ";
139 }
140
141 if (fMinLDca>=0.0) {
142 if (fMaxLDca>=0.0) {
143 ldca.Form(" %.02f<=longitudinal_dca<=%.02f", fMinLDca, fMaxLDca);
144 } else {
145 ldca.Form(" longitudinal_dca >= %.02f", fMinLDca);
146 }
147 } else if (fMaxLDca>=0.0) {
148 ldca.Form(" longitudinal_dca<=%.02f", fMaxLDca);
149 }
150 if (!ldca.IsNull()) {
151 if (op1st.IsNull()) op1st=" && ";
152 else op2nd=" && ";
153 }
154
155 if (fMinTDca>=0.0 || fMaxTDca>=0 || fMinLDca>=0.0 || fMaxLDca>=0) {
156 dcaref.Form(" (%.01f,%.01f,%.01f)", fDCAReference[0], fDCAReference[1], fDCAReference[2]);
157 }
158
cafc1a86 159 if (numberOfTracks>=fMinTracks) {
160 description.Form("Event contains %d track(s) with ", numberOfTracks);
161 description+=ptcut;
5299dd39 162 description+=op1st;
163 description+=ldca;
164 description+=op2nd;
165 description+=tdca;
166 description+=dcaref;
cafc1a86 167 SetDescription(description.Data());
168 // Enable the central detectors for readout.
169 GetReadoutList().Enable(
170 AliHLTReadoutList::kITSSPD |
171 AliHLTReadoutList::kITSSDD |
172 AliHLTReadoutList::kITSSSD |
173 AliHLTReadoutList::kTPC |
174 AliHLTReadoutList::kTRD |
175 AliHLTReadoutList::kTOF |
176 AliHLTReadoutList::kHMPID |
177 AliHLTReadoutList::kPHOS
178 );
179 // Add the available HLT information for readout too.
180 GetTriggerDomain().Add("CLUSTERS", "TPC ");
181 TriggerEvent(true);
182 return 0;
183 }
5299dd39 184 description.Form("No tracks matching the tresholds found in the central barrel (min tracks %d, ", fMinTracks);
185 description+=ptcut;
186 description+=op1st;
187 description+=ldca;
188 description+=op2nd;
189 description+=tdca;
190 description+=dcaref;
191 description+=")";
f1574126 192 } else {
193 description.Form("No input blocks found");
cafc1a86 194 }
cafc1a86 195 SetDescription(description.Data());
196 TriggerEvent(false);
f1574126 197 return iResult;
198}
199
200template<class T>
5299dd39 201bool AliHLTTriggerBarrelMultiplicity::CheckCondition(T* track, float b)
f1574126 202{
203 // see header file for class documentation
5299dd39 204 if (!track) return false;
205
206 // check on ptransverse momentum
207 if (TMath::Abs(track->Pt()) < fPtMin || (fPtMax>fPtMin && TMath::Abs(track->Pt()) > fPtMax)) {
208 return false;
209 }
210
211 // check on transverse and longitudinal DCA
212 if (fMinTDca>=0.0 || fMaxTDca>=0 || fMinLDca>=0.0 || fMaxLDca>=0) {
213 Float_t dz[2]={0.0,0.0};
214 track->GetDZ(fDCAReference[0], fDCAReference[1], fDCAReference[2], b, dz);
215 HLTDebug("checking dca condition: transversal %f logitudinal %f", dz[0], dz[1]);
216 if (fMinTDca>=0 && TMath::Abs(dz[0])<fMinTDca) return false;
217 if (fMaxTDca>=0 && TMath::Abs(dz[0])>fMaxTDca) return false;
218 if (fMinLDca>=0 && TMath::Abs(dz[1])<fMinLDca) return false;
219 if (fMaxLDca>=0 && TMath::Abs(dz[1])>fMaxLDca) return false;
f1574126 220 }
5299dd39 221
222 return true;
f1574126 223}
224
225int AliHLTTriggerBarrelMultiplicity::DoInit(int argc, const char** argv)
226{
227 // see header file for class documentation
228
229 // first configure the default
5299dd39 230 int iResult=0;
231 iResult=ConfigureFromCDBTObjString(kAliHLTCDBSolenoidBz);
232 if (iResult>=0) iResult=ConfigureFromCDBTObjString(fgkOCDBEntry);
f1574126 233
234 // configure from the command line parameters if specified
235 if (iResult>=0 && argc>0)
236 iResult=ConfigureFromArgumentString(argc, argv);
237 return iResult;
238}
239
240int AliHLTTriggerBarrelMultiplicity::DoDeinit()
241{
242 // see header file for class documentation
cafc1a86 243 return 0;
244}
f1574126 245
246int AliHLTTriggerBarrelMultiplicity::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
247{
248 // see header file for class documentation
249
250 // configure from the specified antry or the default one
251 const char* entry=cdbEntry;
5299dd39 252 if (!entry || entry[0]==0) {
253 ConfigureFromCDBTObjString(kAliHLTCDBSolenoidBz);
254 entry=fgkOCDBEntry;
255 }
f1574126 256
257 return ConfigureFromCDBTObjString(entry);
258}
259
5299dd39 260int AliHLTTriggerBarrelMultiplicity::ReadPreprocessorValues(const char* /*modules*/)
261{
262 // see header file for class documentation
263
264 // TODO 2009-09-10: implementation
265 // for the moment very quick, just reload the magnetic field
266 return ConfigureFromCDBTObjString(kAliHLTCDBSolenoidBz);
267}
268
f1574126 269int AliHLTTriggerBarrelMultiplicity::ScanConfigurationArgument(int argc, const char** argv)
270{
271 // see header file for class documentation
272 if (argc<=0) return 0;
273 int i=0;
274 TString argument=argv[i];
275
276 // -maxpt
277 if (argument.CompareTo("-maxpt")==0) {
278 if (++i>=argc) return -EPROTO;
279 argument=argv[i];
280 fPtMax=argument.Atof();
281 return 2;
282 }
283
284 // -minpt
285 if (argument.CompareTo("-minpt")==0) {
286 if (++i>=argc) return -EPROTO;
287 argument=argv[i];
288 fPtMin=argument.Atof();
289 return 2;
290 }
291
292 // -mintracks
293 if (argument.CompareTo("-mintracks")==0) {
294 if (++i>=argc) return -EPROTO;
295 argument=argv[i];
296 fMinTracks=argument.Atoi();
297 return 2;
298 }
5299dd39 299
300 // -dca-reference
301 // reference point for the transverse and longitudinal dca cut
302 if (argument.CompareTo("-dca-reference")==0) {
303 if (++i>=argc) return -EPROTO;
304 argument=argv[i];
305 // scan x,y,z
306 TObjArray* pTokens=argument.Tokenize("'");
307 if (pTokens) {
308 for (int c=0; c<pTokens->GetEntriesFast() && c<fgkDCAReferenceSize; c++) {
309 argument=((TObjString*)pTokens->At(c))->GetString();
310 fDCAReference[i]=argument.Atof();
311 }
312 delete pTokens;
313 }
314 return 2;
315 }
316
317 // -min-ldca
318 // minimum longitudinal dca to reference point
319 if (argument.CompareTo("-min-ldca")==0) {
320 if (++i>=argc) return -EPROTO;
321 argument=argv[i];
322 fMinLDca=argument.Atof();
323 return 2;
324 }
f1574126 325
5299dd39 326 // -max-ldca
327 // maximum longitudinal dca to reference point
328 if (argument.CompareTo("-max-ldca")==0) {
329 if (++i>=argc) return -EPROTO;
330 argument=argv[i];
331 fMaxLDca=argument.Atof();
332 return 2;
333 }
334
335 // -min-tdca
336 // minimum transverse dca to reference point
337 if (argument.CompareTo("-min-tdca")==0) {
338 if (++i>=argc) return -EPROTO;
339 argument=argv[i];
340 fMinTDca=argument.Atof();
341 return 2;
342 }
343
344 // -max-tdca
345 // maximum transverse dca to reference point
346 if (argument.CompareTo("-max-tdca")==0) {
347 if (++i>=argc) return -EPROTO;
348 argument=argv[i];
349 fMaxTDca=argument.Atof();
350 return 2;
351 }
352
353 // -solenoidBz
354 if (argument.CompareTo("-solenoidBz")==0) {
355 if (++i>=argc) return -EPROTO;
356 argument=argv[i];
357 fSolenoidBz=argument.Atof();
358 return 2;
359 }
360
f1574126 361 // unknown argument
362 return -EINVAL;
363}