]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTTriggerBarrelGeomMultiplicity.cxx
Move to the CommoonFileName output
[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 "AliCDBEntry.h"
40#include "AliCDBManager.h"
41#include "TFile.h"
42#include "AliHLTTrigger.h"
46906312 43
44/** ROOT macro for the implementation of ROOT specific class methods */
45ClassImp(AliHLTTriggerBarrelGeomMultiplicity)
46
47AliHLTTriggerBarrelGeomMultiplicity::AliHLTTriggerBarrelGeomMultiplicity()
48 : AliHLTTrigger()
1ecefac2 49 , fSolenoidBz(0)
fde46e9e 50 , fMinTracks(1)
1ecefac2 51 , fDetectorArray(0)
c308d915 52 , fTriggerDecisionPars(0)
53 , fTriggerName(0)
54 , fOCDBEntry(0)
46906312 55{
56 // see header file for class documentation
57 // or
58 // refer to README to build package
59 // or
60 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
4a6363a6 61 fDetectorArray = new TObjArray(1);
21463652 62
b850c417 63 fDetectorArray = new TObjArray(1);
d3c57a43 64
ef882581 65 fDetectorArray = new TObjArray;
46906312 66
67}
68
46906312 69AliHLTTriggerBarrelGeomMultiplicity::~AliHLTTriggerBarrelGeomMultiplicity()
70{
71 // see header file for class documentation
72}
73
9f7b505a 74const char* AliHLTTriggerBarrelGeomMultiplicity::GetTriggerName() const
46906312 75{
76 // see header file for class documentation
f461a2cb 77
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");
398faf4c 115 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
1260b409 176
46906312 177template<class T>
178bool AliHLTTriggerBarrelGeomMultiplicity::CheckCondition(T* track, float b)
179{
21463652 180
1ecefac2 181 bool ret = false;
182
46906312 183 // see header file for class documentation
184 if (!track) return false;
185
186 ret = IsInDetectors(track, b);
187
188 return ret;
189
190}
191
192template<class T>
1ecefac2 193bool AliHLTTriggerBarrelGeomMultiplicity::IsInDetectors(T* track, float b)
46906312 194{
1ecefac2 195 // See header file for class documentation
196 for(Int_t i = 0; i < fDetectorArray->GetEntries(); i++)
46906312 197 {
1ecefac2 198 AliHLTTriggerDetectorGeom *det = static_cast<AliHLTTriggerDetectorGeom*>(fDetectorArray->At(i));
c308d915 199
46906312 200 Double_t trackPoint[3];
c308d915 201 Double_t normVector[3];
202
46906312 203 det->GetInitialPoint(trackPoint);
c308d915 204 det->GetNormVector(normVector);
46906312 205
c308d915 206 bool ret = track->Intersect(trackPoint, normVector, b);
207
208 if(ret)
209 {
210 if(det->IsInDetector(trackPoint)) return true;
211 }
46906312 212 }
213 return false;
214}
215
216int AliHLTTriggerBarrelGeomMultiplicity::DoInit(int argc, const char** argv)
217{
218 // see header file for class documentation
219
220 // first configure the default
221 int iResult=0;
46906312 222
46906312 223 if (iResult>=0 && argc>0)
224 iResult=ConfigureFromArgumentString(argc, argv);
1ecefac2 225
fb50cb46 226 if (!fTriggerDecisionPars) {
227 HLTError("decision parameter not initialized");
228 iResult=-ENODEV;
229 }
230
46906312 231 return iResult;
232}
233
234int AliHLTTriggerBarrelGeomMultiplicity::DoDeinit()
24a39a2c 235 {
46906312 236 // see header file for class documentation
237 return 0;
238}
239
1ecefac2 240int AliHLTTriggerBarrelGeomMultiplicity::ReadPreprocessorValues(const char* /*modules*/)
46906312 241{
9f7b505a 242 // see header file for function documentation
46906312 243
1ecefac2 244 // TODO 2009-10-10: implementation
245 // for the moment very quick, just reload the magnetic field
246 return ConfigureFromCDBTObjString(kAliHLTCDBSolenoidBz);
247}
248
249int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromCDBObject(const char *cdbEntry, const char* chainId)
250{
251 // see header file for function documentation
252 int nDetectorGeoms=0;
b850c417 253
254 if(fDetectorArray)
255 {
256 fDetectorArray->Clear();
257 }
258 else
259 {
260 fDetectorArray = new TObjArray();
261 }
262
1ecefac2 263 const char *path = cdbEntry;
46906312 264
b850c417 265 if(!path) path = fOCDBEntry;
266
1ecefac2 267 if(path)
268 {
269 // const char* chainId=GetChainId();
270 HLTInfo("configure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
271 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
272 if (pEntry)
273 {
274 TObjArray* pArr=dynamic_cast<TObjArray*>(pEntry->GetObject());
275 if (pArr)
276 {
277
278 for(int i = 0; i < pArr->GetEntries(); i++)
279 {
c308d915 280 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters"))
1ecefac2 281 {
fde46e9e 282 fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i));
1ecefac2 283 }
c308d915 284 else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom"))
1ecefac2 285 {
286 fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
287 nDetectorGeoms++;
b850c417 288 HLTDebug("received detector geometry of type %s", pArr->At(i)->ClassName());
1ecefac2 289 }
290 else
291 {
c308d915 292 HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName());
1ecefac2 293 }
294 }
295 }
296 else
297 {
298 HLTError("configuration object \"%s\" has wrong type, required TObjArray", path);
299 nDetectorGeoms=-EINVAL;
300 }
301 }
302 else
303 {
304 HLTError("can not fetch object \"%s\" from OCDB", path);
305 nDetectorGeoms=-ENOENT;
306 }
307 }
b850c417 308
309 HLTInfo("received %d detector geometries", nDetectorGeoms);
310
1ecefac2 311 return nDetectorGeoms;
46906312 312}
313
1ecefac2 314int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromFile(const char *filename)
46906312 315{
1ecefac2 316 // see header file for function documentation
317 int nDetectorGeoms=0;
46906312 318
b850c417 319 if(fDetectorArray)
320 {
321 fDetectorArray->Clear();
322 }
323 else
324 {
325 fDetectorArray = new TObjArray();
326 }
327
328
1ecefac2 329 if (filename)
330 {
331 TFile *geomfile = TFile::Open(filename, "READ");
332
333 if(geomfile)
334 {
1ecefac2 335 HLTInfo("configure from file \"%s\"", filename);
fde46e9e 336 TObjArray* pArr=dynamic_cast<TObjArray*>(geomfile->Get("GeomConf"));
1ecefac2 337 if (pArr)
338 {
339
340 for(int i = 0; i < pArr->GetEntries(); i++)
341 {
fde46e9e 342 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters"))
1ecefac2 343 {
fde46e9e 344 fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i));
1ecefac2 345 }
fde46e9e 346 else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom"))
1ecefac2 347 {
348 fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
349 nDetectorGeoms++;
b850c417 350 HLTDebug("received detector geometry of type %s", pArr->At(i)->ClassName());
1ecefac2 351 }
352 else
353 {
fde46e9e 354 HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName());
1ecefac2 355 }
356 }
357 }
358 else
359 {
360 HLTError("configuration object has wrong type, required TObjArray");
361 nDetectorGeoms=-EINVAL;
362 }
363 }
364 else
365 {
fde46e9e 366 HLTError("could not open file \"%s\"", filename);
1ecefac2 367 nDetectorGeoms=-ENOENT;
368 }
369 }
b850c417 370 else
371 {
372 HLTError("ROOT file name not specified");
373 }
374 HLTInfo("received %d detector geometries", nDetectorGeoms);
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
5af7c3ac 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