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: Oystein Djuvsland *
7 //* for The ALICE HLT Project. *
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 //**************************************************************************
18 /// @file AliHLTTriggerBarrelGeomMultiplicity.cxx
19 /// @author Oystein Djuvsland
21 /// @brief HLT trigger component for charged particle multiplicity
22 /// within a geometrical acceptance in the central barrel.
24 // see header file for class documentation
26 // refer to README to build package
28 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
30 #include "AliHLTTriggerBarrelGeomMultiplicity.h"
31 #include "AliHLTTriggerDetectorGeom.h"
32 #include "AliHLTTriggerDecisionParameters.h"
33 #include "AliESDEvent.h"
34 #include "AliHLTTriggerDecision.h"
35 #include "AliHLTDomainEntry.h"
36 #include "AliHLTGlobalBarrelTrack.h"
37 #include "TObjArray.h"
38 #include "TObjString.h"
39 #include "AliCDBEntry.h"
40 #include "AliCDBManager.h"
42 #include "AliHLTTrigger.h"
44 /** ROOT macro for the implementation of ROOT specific class methods */
45 ClassImp(AliHLTTriggerBarrelGeomMultiplicity)
47 AliHLTTriggerBarrelGeomMultiplicity::AliHLTTriggerBarrelGeomMultiplicity()
52 , fTriggerDecisionPars(0)
56 // see header file for class documentation
58 // refer to README to build package
60 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
62 fDetectorArray = new TObjArray;
66 AliHLTTriggerBarrelGeomMultiplicity::~AliHLTTriggerBarrelGeomMultiplicity()
68 // see header file for class documentation
70 if (fDetectorArray != NULL) delete fDetectorArray;
73 const char* AliHLTTriggerBarrelGeomMultiplicity::GetTriggerName() const
75 // see header file for class documentation
77 return "BarrelGeomMultiplicityTrigger";
80 AliHLTComponent* AliHLTTriggerBarrelGeomMultiplicity::Spawn()
82 // see header file for class documentation
83 return new AliHLTTriggerBarrelGeomMultiplicity;
86 int AliHLTTriggerBarrelGeomMultiplicity::Reconfigure(const char *cdbEntry, const char *chainId)
88 // see header file for class documentation
90 // configure from the specified entry or the default
91 const char* entry=cdbEntry;
95 HLTDebug("No CDB path specified");
99 return GetDetectorGeomsFromCDBObject(entry, chainId);
102 int AliHLTTriggerBarrelGeomMultiplicity::DoTrigger()
104 // see header file for class documentation
106 int numberOfTracks=-1;
108 if (!fTriggerDecisionPars) {
112 // try the ESD as input
113 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
114 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
120 esd->GetStdContent();
121 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++)
123 if (CheckCondition(esd->GetTrack(i), esd->GetMagneticField())) numberOfTracks++;
127 // try the AliHLTExternal track data as input
128 if (iResult>=0 && numberOfTracks<0)
130 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack);
131 pBlock!=NULL; pBlock=GetNextInputBlock())
133 if (numberOfTracks<0) numberOfTracks=0;
134 vector<AliHLTGlobalBarrelTrack> tracks;
135 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0)
137 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
138 element!=tracks.end(); element++)
140 if (CheckCondition(&(*element), fSolenoidBz)) numberOfTracks++;
145 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
146 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
151 bool condition=false;
152 description="Geometrical conditions not matched";
153 AliHLTReadoutList readout;
155 if (numberOfTracks>=fMinTracks)
158 description=fTriggerDecisionPars->GetDescription();
159 readout=fTriggerDecisionPars->GetReadoutListParameter();
160 HLTDebug("Geometrical acceptance trigger %s triggered", fTriggerDecisionPars->GetTriggerName().Data());
163 AliHLTTriggerDecision decision(
165 fTriggerDecisionPars->GetTriggerName().Data(),
166 AliHLTTriggerDomain(readout),
169 TriggerEvent(&decision, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
177 bool AliHLTTriggerBarrelGeomMultiplicity::CheckCondition(T* track, float b)
182 // see header file for class documentation
183 if (!track) return false;
185 ret = IsInDetectors(track, b);
192 bool AliHLTTriggerBarrelGeomMultiplicity::IsInDetectors(T* track, float b)
194 // See header file for class documentation
195 for(Int_t i = 0; i < fDetectorArray->GetEntries(); i++)
197 AliHLTTriggerDetectorGeom *det = static_cast<AliHLTTriggerDetectorGeom*>(fDetectorArray->At(i));
199 Double_t trackPoint[3];
200 Double_t normVector[3];
202 det->GetInitialPoint(trackPoint);
203 det->GetNormVector(normVector);
205 bool ret = track->Intersect(trackPoint, normVector, b);
209 if(det->IsInDetector(trackPoint)) return true;
215 int AliHLTTriggerBarrelGeomMultiplicity::DoInit(int argc, const char** argv)
217 // see header file for class documentation
219 // first configure the default
222 // Matthias 05.04.2011 code audit
223 // looks like somebody has to commission this component
224 HLTWarning("this component is not tested and needs most likely a major revision!");
226 if (iResult>=0 && argc>0)
227 iResult=ConfigureFromArgumentString(argc, argv);
229 if (!fTriggerDecisionPars) {
230 HLTError("decision parameter not initialized");
238 int AliHLTTriggerBarrelGeomMultiplicity::DoDeinit()
240 // see header file for class documentation
241 if (fTriggerName) delete fTriggerName;
246 int AliHLTTriggerBarrelGeomMultiplicity::ReadPreprocessorValues(const char* /*modules*/)
248 // see header file for function documentation
250 // nothing to do for the moment
254 int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromCDBObject(const char *cdbEntry, const char* chainId)
256 // see header file for function documentation
257 int nDetectorGeoms=0;
261 fDetectorArray->Clear();
265 fDetectorArray = new TObjArray();
268 const char *path = cdbEntry;
270 if(!path) path = fOCDBEntry;
274 // const char* chainId=GetChainId();
275 HLTInfo("configure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
276 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
279 TObjArray* pArr=dynamic_cast<TObjArray*>(pEntry->GetObject());
283 for(int i = 0; i < pArr->GetEntries(); i++)
285 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters"))
287 fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i));
289 else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom"))
291 fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
293 HLTDebug("received detector geometry of type %s", pArr->At(i)->ClassName());
297 HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName());
303 HLTError("configuration object \"%s\" has wrong type, required TObjArray", path);
304 nDetectorGeoms=-EINVAL;
309 HLTError("can not fetch object \"%s\" from OCDB", path);
310 nDetectorGeoms=-ENOENT;
314 HLTInfo("received %d detector geometries", nDetectorGeoms);
316 return nDetectorGeoms;
319 int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromFile(const char *filename)
321 // see header file for function documentation
322 int nDetectorGeoms=0;
326 fDetectorArray->Clear();
330 fDetectorArray = new TObjArray();
336 TFile *geomfile = TFile::Open(filename, "READ");
340 HLTInfo("configure from file \"%s\"", filename);
341 TObjArray* pArr=dynamic_cast<TObjArray*>(geomfile->Get("GeomConf"));
345 for(int i = 0; i < pArr->GetEntries(); i++)
347 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters"))
349 fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i));
351 else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom"))
353 fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
355 HLTDebug("received detector geometry of type %s", pArr->At(i)->ClassName());
359 HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName());
365 HLTError("configuration object has wrong type, required TObjArray");
366 nDetectorGeoms=-EINVAL;
371 HLTError("could not open file \"%s\"", filename);
372 nDetectorGeoms=-ENOENT;
377 HLTError("ROOT file name not specified");
379 HLTInfo("received %d detector geometries", nDetectorGeoms);
381 return nDetectorGeoms;
384 int AliHLTTriggerBarrelGeomMultiplicity::ScanConfigurationArgument(int argc, const char** argv)
386 // See header file for class documentation
387 if (argc<=0) return 0;
389 TString argument=argv[i];
391 if (argument.CompareTo("-geomfile")==0)
393 if (++i>=argc) return -EPROTO;
395 GetDetectorGeomsFromFile(argv[i]);
400 if (argument.CompareTo("-triggername")==0)
402 if (++i>=argc || argv[i]==NULL) return -EPROTO;
404 int namelen=strlen(argv[i])+1;
405 fTriggerName = new char[namelen];
406 if (!fTriggerName) return -ENOMEM;
407 snprintf(fTriggerName, namelen, "%s", argv[i]);
409 fOCDBEntry = fTriggerName;