1 //**************************************************************************
2 //* This file is property of and copyright by the ALICE HLT Project *
3 //* ALICE Experiment at CERN, All rights reserved. *
5 //* Primary Authors: Oystein Djuvsland *
6 //* for The ALICE HLT Project. *
8 //* Permission to use, copy, modify and distribute this software and its *
9 //* documentation strictly for non-commercial purposes is hereby granted *
10 //* without fee, provided that the above copyright notice appears in all *
11 //* copies and that both the copyright notice and this permission notice *
12 //* appear in the supporting documentation. The authors make no claims *
13 //* about the suitability of this software for any purpose. It is *
14 //* provided "as is" without express or implied warranty. *
15 //**************************************************************************
17 /// @file AliHLTTriggerBarrelGeomMultiplicity.cxx
18 /// @author Oystein Djuvsland
20 /// @brief HLT trigger component for charged particle multiplicity
21 /// within a geometrical acceptance in the central barrel.
23 // see header file for class documentation
25 // refer to README to build package
27 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
29 #include "AliHLTTriggerBarrelGeomMultiplicity.h"
30 #include "AliHLTTriggerDetectorGeom.h"
31 #include "AliHLTTriggerDecisionParameters.h"
32 #include "AliESDEvent.h"
33 #include "AliHLTTriggerDecision.h"
34 #include "AliHLTDomainEntry.h"
35 #include "AliHLTGlobalBarrelTrack.h"
36 #include "TObjArray.h"
37 #include "TObjString.h"
38 #include "TObjArray.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
61 fDetectorArray = new TObjArray(1);
63 fDetectorArray = new TObjArray;
67 AliHLTTriggerBarrelGeomMultiplicity::~AliHLTTriggerBarrelGeomMultiplicity()
69 // see header file for class documentation
72 const char* AliHLTTriggerBarrelGeomMultiplicity::GetTriggerName() const
74 // see header file for class documentation
75 return "BarrelGeomMultiplicityTrigger";
78 AliHLTComponent* AliHLTTriggerBarrelGeomMultiplicity::Spawn()
80 // see header file for class documentation
81 return new AliHLTTriggerBarrelGeomMultiplicity;
84 int AliHLTTriggerBarrelGeomMultiplicity::Reconfigure(const char *cdbEntry, const char *chainId)
86 // see header file for class documentation
88 // configure from the specified entry or the default
89 const char* entry=cdbEntry;
93 HLTDebug("No CDB path specified");
97 return GetDetectorGeomsFromCDBObject(entry, chainId);
100 int AliHLTTriggerBarrelGeomMultiplicity::DoTrigger()
102 // see header file for class documentation
104 int numberOfTracks=-1;
106 // try the ESD as input
107 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
108 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
114 esd->GetStdContent();
115 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++)
117 if (CheckCondition(esd->GetTrack(i), esd->GetMagneticField())) numberOfTracks++;
121 // try the AliHLTExternal track data as input
122 if (iResult>=0 && numberOfTracks<0)
124 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack);
125 pBlock!=NULL; pBlock=GetNextInputBlock())
127 if (numberOfTracks<0) numberOfTracks=0;
128 vector<AliHLTGlobalBarrelTrack> tracks;
129 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0)
131 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
132 element!=tracks.end(); element++)
134 if (CheckCondition(&(*element), fSolenoidBz)) numberOfTracks++;
139 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
140 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
145 if (numberOfTracks>=fMinTracks)
147 if(fTriggerDecisionPars)
150 SetDescription(fTriggerDecisionPars->GetDescription());
151 AliHLTReadoutList readout(fTriggerDecisionPars->GetReadoutListParameter());
152 AliHLTTriggerDecision decision(
154 fTriggerDecisionPars->GetTriggerName().Data(),
155 AliHLTTriggerDomain(readout),
156 fTriggerDecisionPars->GetDescription()
158 TriggerEvent(&decision);
159 HLTDebug("Geometrical acceptance trigger %s triggered", fTriggerDecisionPars->GetTriggerName().Data());
163 HLTError("Trigger decision parameters not set, event not triggered");
171 bool AliHLTTriggerBarrelGeomMultiplicity::CheckCondition(T* track, float b)
175 // see header file for class documentation
176 if (!track) return false;
178 ret = IsInDetectors(track, b);
185 bool AliHLTTriggerBarrelGeomMultiplicity::IsInDetectors(T* track, float b)
187 // See header file for class documentation
188 for(Int_t i = 0; i < fDetectorArray->GetEntries(); i++)
190 AliHLTTriggerDetectorGeom *det = static_cast<AliHLTTriggerDetectorGeom*>(fDetectorArray->At(i));
192 Double_t trackPoint[3];
193 Double_t normVector[3];
195 det->GetInitialPoint(trackPoint);
196 det->GetNormVector(normVector);
198 bool ret = track->Intersect(trackPoint, normVector, b);
202 if(det->IsInDetector(trackPoint)) return true;
208 int AliHLTTriggerBarrelGeomMultiplicity::DoInit(int argc, const char** argv)
210 // see header file for class documentation
212 // first configure the default
215 if (iResult>=0 && argc>0)
216 iResult=ConfigureFromArgumentString(argc, argv);
221 int AliHLTTriggerBarrelGeomMultiplicity::DoDeinit()
223 // see header file for class documentation
227 int AliHLTTriggerBarrelGeomMultiplicity::ReadPreprocessorValues(const char* /*modules*/)
229 // see header file for class documentation
231 // TODO 2009-10-10: implementation
232 // for the moment very quick, just reload the magnetic field
233 return ConfigureFromCDBTObjString(kAliHLTCDBSolenoidBz);
236 int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromCDBObject(const char *cdbEntry, const char* chainId)
238 // see header file for function documentation
239 int nDetectorGeoms=0;
243 fDetectorArray->Clear();
247 fDetectorArray = new TObjArray();
250 const char *path = cdbEntry;
252 if(!path) path = fOCDBEntry;
256 // const char* chainId=GetChainId();
257 HLTInfo("configure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
258 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
261 TObjArray* pArr=dynamic_cast<TObjArray*>(pEntry->GetObject());
265 for(int i = 0; i < pArr->GetEntries(); i++)
267 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters"))
269 fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i));
271 else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom"))
273 fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
275 HLTDebug("received detector geometry of type %s", pArr->At(i)->ClassName());
279 HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName());
285 HLTError("configuration object \"%s\" has wrong type, required TObjArray", path);
286 nDetectorGeoms=-EINVAL;
291 HLTError("can not fetch object \"%s\" from OCDB", path);
292 nDetectorGeoms=-ENOENT;
296 HLTInfo("received %d detector geometries", nDetectorGeoms);
298 return nDetectorGeoms;
301 int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromFile(const char *filename)
303 // see header file for function documentation
304 int nDetectorGeoms=0;
308 fDetectorArray->Clear();
312 fDetectorArray = new TObjArray();
318 TFile *geomfile = TFile::Open(filename, "READ");
322 HLTInfo("configure from file \"%s\"", filename);
323 TObjArray* pArr=dynamic_cast<TObjArray*>(geomfile->Get("GeomConf"));
327 for(int i = 0; i < pArr->GetEntries(); i++)
329 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters"))
331 fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i));
333 else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom"))
335 fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
337 HLTDebug("received detector geometry of type %s", pArr->At(i)->ClassName());
341 HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName());
347 HLTError("configuration object has wrong type, required TObjArray");
348 nDetectorGeoms=-EINVAL;
353 HLTError("could not open file \"%s\"", filename);
354 nDetectorGeoms=-ENOENT;
359 HLTError("ROOT file name not specified");
361 HLTInfo("received %d detector geometries", nDetectorGeoms);
364 return nDetectorGeoms;
367 int AliHLTTriggerBarrelGeomMultiplicity::ScanConfigurationArgument(int argc, const char** argv)
369 // See header file for class documentation
370 if (argc<=0) return 0;
372 TString argument=argv[i];
374 if (argument.CompareTo("-geomfile")==0)
376 if (++i>=argc) return -EPROTO;
378 GetDetectorGeomsFromFile(argv[i]);
383 if (argument.CompareTo("-triggername")==0)
385 if (++i>=argc) return -EPROTO;
387 fTriggerName = new char[128];
388 sprintf(fTriggerName, argv[i]);
390 fOCDBEntry = fTriggerName;