]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTTriggerBarrelGeomMultiplicity.cxx
Modifications to the geometry trigger classes. The trigger has now been tested with...
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTriggerBarrelGeomMultiplicity.cxx
CommitLineData
fb50cb46 1// $Id$
46906312 2//**************************************************************************
3//* This file is property of and copyright by the ALICE HLT Project *
4//* ALICE Experiment at CERN, All rights reserved. *
5//* *
c308d915 6//* Primary Authors: Oystein Djuvsland *
46906312 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 AliHLTTriggerBarrelGeomMultiplicity.cxx
19/// @author Oystein Djuvsland
20/// @date 2009-10-08
1ecefac2 21/// @brief HLT trigger component for charged particle multiplicity
22/// within a geometrical acceptance in the central barrel.
46906312 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 "AliHLTTriggerBarrelGeomMultiplicity.h"
1ecefac2 31#include "AliHLTTriggerDetectorGeom.h"
fde46e9e 32#include "AliHLTTriggerDecisionParameters.h"
46906312 33#include "AliESDEvent.h"
34#include "AliHLTTriggerDecision.h"
35#include "AliHLTDomainEntry.h"
36#include "AliHLTGlobalBarrelTrack.h"
37#include "TObjArray.h"
38#include "TObjString.h"
1ecefac2 39#include "TObjArray.h"
1ecefac2 40#include "AliCDBEntry.h"
41#include "AliCDBManager.h"
42#include "TFile.h"
43#include "AliHLTTrigger.h"
46906312 44
45/** ROOT macro for the implementation of ROOT specific class methods */
46ClassImp(AliHLTTriggerBarrelGeomMultiplicity)
47
48AliHLTTriggerBarrelGeomMultiplicity::AliHLTTriggerBarrelGeomMultiplicity()
49 : AliHLTTrigger()
1ecefac2 50 , fSolenoidBz(0)
fde46e9e 51 , fMinTracks(1)
1ecefac2 52 , fDetectorArray(0)
c308d915 53 , fTriggerDecisionPars(0)
54 , fTriggerName(0)
55 , fOCDBEntry(0)
46906312 56{
57 // see header file for class documentation
58 // or
59 // refer to README to build package
60 // or
61 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
b850c417 62 fDetectorArray = new TObjArray(1);
d3c57a43 63
ef882581 64 fDetectorArray = new TObjArray;
46906312 65
66}
67
46906312 68AliHLTTriggerBarrelGeomMultiplicity::~AliHLTTriggerBarrelGeomMultiplicity()
69{
70 // see header file for class documentation
71}
72
9f7b505a 73const char* AliHLTTriggerBarrelGeomMultiplicity::GetTriggerName() const
46906312 74{
75 // see header file for class documentation
56cff424 76 // const char* name = fTriggerName;
77 // if(name) return name;
46906312 78 return "BarrelGeomMultiplicityTrigger";
79}
80
81AliHLTComponent* AliHLTTriggerBarrelGeomMultiplicity::Spawn()
82{
83 // see header file for class documentation
84 return new AliHLTTriggerBarrelGeomMultiplicity;
85}
86
1ecefac2 87int AliHLTTriggerBarrelGeomMultiplicity::Reconfigure(const char *cdbEntry, const char *chainId)
88{
89 // see header file for class documentation
90
91 // configure from the specified entry or the default
92 const char* entry=cdbEntry;
93
94 if (!entry)
95 {
96 HLTDebug("No CDB path specified");
97 entry = fOCDBEntry;
98 }
99
100 return GetDetectorGeomsFromCDBObject(entry, chainId);
101}
102
46906312 103int AliHLTTriggerBarrelGeomMultiplicity::DoTrigger()
104{
105 // see header file for class documentation
106 int iResult=0;
107 int numberOfTracks=-1;
108
fb50cb46 109 if (!fTriggerDecisionPars) {
110 iResult=-ENODEV;
111 }
112
46906312 113 // try the ESD as input
114 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
b0fb4405 115n AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
46906312 116 TString description;
d3c57a43 117
1ecefac2 118 if (esd != NULL)
119 {
120 numberOfTracks=0;
121 esd->GetStdContent();
1ecefac2 122 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++)
123 {
124 if (CheckCondition(esd->GetTrack(i), esd->GetMagneticField())) numberOfTracks++;
125 }
46906312 126 }
46906312 127
128 // try the AliHLTExternal track data as input
1ecefac2 129 if (iResult>=0 && numberOfTracks<0)
130 {
131 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack);
132 pBlock!=NULL; pBlock=GetNextInputBlock())
133 {
134 if (numberOfTracks<0) numberOfTracks=0;
135 vector<AliHLTGlobalBarrelTrack> tracks;
136 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0)
137 {
138 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
139 element!=tracks.end(); element++)
140 {
141 if (CheckCondition(&(*element), fSolenoidBz)) numberOfTracks++;
142 }
143 }
144 else if (iResult<0)
145 {
146 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
147 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
148 }
46906312 149 }
46906312 150 }
c308d915 151
fb50cb46 152 bool condition=false;
153 description="Geometrical conditions not matched";
154 AliHLTReadoutList readout;
155
1ecefac2 156 if (numberOfTracks>=fMinTracks)
157 {
fb50cb46 158 condition=true;
159 description=fTriggerDecisionPars->GetDescription();
160 readout=fTriggerDecisionPars->GetReadoutListParameter();
161 HLTDebug("Geometrical acceptance trigger %s triggered", fTriggerDecisionPars->GetTriggerName().Data());
46906312 162 }
fb50cb46 163
164 AliHLTTriggerDecision decision(
165 condition,
166 fTriggerDecisionPars->GetTriggerName().Data(),
167 AliHLTTriggerDomain(readout),
168 description.Data()
169 );
170 TriggerEvent(&decision, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
171
46906312 172 return iResult;
4bb9ea62 173
46906312 174}
175
176template<class T>
177bool AliHLTTriggerBarrelGeomMultiplicity::CheckCondition(T* track, float b)
178{
1ecefac2 179 bool ret = false;
180
46906312 181 // see header file for class documentation
182 if (!track) return false;
183
184 ret = IsInDetectors(track, b);
185
186 return ret;
187
188}
189
190template<class T>
1ecefac2 191bool AliHLTTriggerBarrelGeomMultiplicity::IsInDetectors(T* track, float b)
46906312 192{
1ecefac2 193 // See header file for class documentation
194 for(Int_t i = 0; i < fDetectorArray->GetEntries(); i++)
46906312 195 {
1ecefac2 196 AliHLTTriggerDetectorGeom *det = static_cast<AliHLTTriggerDetectorGeom*>(fDetectorArray->At(i));
c308d915 197
46906312 198 Double_t trackPoint[3];
c308d915 199 Double_t normVector[3];
200
46906312 201 det->GetInitialPoint(trackPoint);
c308d915 202 det->GetNormVector(normVector);
46906312 203
c308d915 204 bool ret = track->Intersect(trackPoint, normVector, b);
205
206 if(ret)
207 {
208 if(det->IsInDetector(trackPoint)) return true;
209 }
46906312 210 }
211 return false;
212}
213
214int AliHLTTriggerBarrelGeomMultiplicity::DoInit(int argc, const char** argv)
215{
216 // see header file for class documentation
217
218 // first configure the default
219 int iResult=0;
46906312 220
46906312 221 if (iResult>=0 && argc>0)
222 iResult=ConfigureFromArgumentString(argc, argv);
1ecefac2 223
fb50cb46 224 if (!fTriggerDecisionPars) {
225 HLTError("decision parameter not initialized");
226 iResult=-ENODEV;
227 }
228
46906312 229 return iResult;
230}
231
232int AliHLTTriggerBarrelGeomMultiplicity::DoDeinit()
4bb9ea62 233 {
46906312 234 // see header file for class documentation
235 return 0;
236}
237
1ecefac2 238int AliHLTTriggerBarrelGeomMultiplicity::ReadPreprocessorValues(const char* /*modules*/)
46906312 239{
9f7b505a 240 // see header file for function documentation
241 int nDetectorGeoms=0;
46906312 242
1ecefac2 243 // TODO 2009-10-10: implementation
244 // for the moment very quick, just reload the magnetic field
245 return ConfigureFromCDBTObjString(kAliHLTCDBSolenoidBz);
246}
247
248int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromCDBObject(const char *cdbEntry, const char* chainId)
249{
250 // see header file for function documentation
251 int nDetectorGeoms=0;
b850c417 252
253 if(fDetectorArray)
254 {
255 fDetectorArray->Clear();
256 }
257 else
258 {
259 fDetectorArray = new TObjArray();
260 }
261
1ecefac2 262 const char *path = cdbEntry;
46906312 263
b850c417 264 if(!path) path = fOCDBEntry;
265
1ecefac2 266 if(path)
267 {
268 // const char* chainId=GetChainId();
269 HLTInfo("configure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
270 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
271 if (pEntry)
272 {
273 TObjArray* pArr=dynamic_cast<TObjArray*>(pEntry->GetObject());
274 if (pArr)
275 {
276
277 for(int i = 0; i < pArr->GetEntries(); i++)
278 {
c308d915 279 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters"))
1ecefac2 280 {
fde46e9e 281 fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i));
1ecefac2 282 }
c308d915 283 else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom"))
1ecefac2 284 {
285 fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
286 nDetectorGeoms++;
b850c417 287 HLTDebug("received detector geometry of type %s", pArr->At(i)->ClassName());
1ecefac2 288 }
289 else
290 {
c308d915 291 HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName());
1ecefac2 292 }
293 }
294 }
295 else
296 {
297 HLTError("configuration object \"%s\" has wrong type, required TObjArray", path);
298 nDetectorGeoms=-EINVAL;
299 }
300 }
301 else
302 {
303 HLTError("can not fetch object \"%s\" from OCDB", path);
304 nDetectorGeoms=-ENOENT;
305 }
306 }
b850c417 307
308 HLTInfo("received %d detector geometries", nDetectorGeoms);
309
1ecefac2 310 return nDetectorGeoms;
46906312 311}
312
1ecefac2 313int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromFile(const char *filename)
46906312 314{
1ecefac2 315 // see header file for function documentation
316 int nDetectorGeoms=0;
46906312 317
b850c417 318 if(fDetectorArray)
319 {
320 fDetectorArray->Clear();
321 }
322 else
323 {
324 fDetectorArray = new TObjArray();
325 }
326
327
1ecefac2 328 if (filename)
329 {
330 TFile *geomfile = TFile::Open(filename, "READ");
331
332 if(geomfile)
333 {
1ecefac2 334 HLTInfo("configure from file \"%s\"", filename);
fde46e9e 335 TObjArray* pArr=dynamic_cast<TObjArray*>(geomfile->Get("GeomConf"));
1ecefac2 336 if (pArr)
337 {
338
339 for(int i = 0; i < pArr->GetEntries(); i++)
340 {
fde46e9e 341 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters"))
1ecefac2 342 {
fde46e9e 343 fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i));
1ecefac2 344 }
fde46e9e 345 else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom"))
1ecefac2 346 {
347 fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
348 nDetectorGeoms++;
b850c417 349 HLTDebug("received detector geometry of type %s", pArr->At(i)->ClassName());
1ecefac2 350 }
351 else
352 {
fde46e9e 353 HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName());
1ecefac2 354 }
355 }
356 }
357 else
358 {
359 HLTError("configuration object has wrong type, required TObjArray");
360 nDetectorGeoms=-EINVAL;
361 }
362 }
363 else
364 {
fde46e9e 365 HLTError("could not open file \"%s\"", filename);
1ecefac2 366 nDetectorGeoms=-ENOENT;
367 }
368 }
b850c417 369 else
370 {
371 HLTError("ROOT file name not specified");
372 }
373 HLTInfo("received %d detector geometries", nDetectorGeoms);
374
fde46e9e 375
1ecefac2 376 return nDetectorGeoms;
46906312 377}
378
379int AliHLTTriggerBarrelGeomMultiplicity::ScanConfigurationArgument(int argc, const char** argv)
380{
4bb9ea62 381 // See header file for class documentation
46906312 382 if (argc<=0) return 0;
383 int i=0;
384 TString argument=argv[i];
385
1ecefac2 386 if (argument.CompareTo("-geomfile")==0)
387 {
388 if (++i>=argc) return -EPROTO;
389
390 GetDetectorGeomsFromFile(argv[i]);
391
392 return 2;
393 }
46906312 394
b0fb4405 395 if (argument.CompareTo("-triggername")==0)
1ecefac2 396 {
397 if (++i>=argc) return -EPROTO;
398
399 fTriggerName = new char[128];
400 sprintf(fTriggerName, argv[i]);
401
402 fOCDBEntry = fTriggerName;
403
404 return 2;
46906312 405 }
b210e538 406 return 0;
46906312 407}
b850c417 408