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"
40 #include "AliCDBEntry.h"
41 #include "AliCDBManager.h"
43 #include "AliHLTTrigger.h"
45 /** ROOT macro for the implementation of ROOT specific class methods */
46 ClassImp(AliHLTTriggerBarrelGeomMultiplicity)
48 AliHLTTriggerBarrelGeomMultiplicity::AliHLTTriggerBarrelGeomMultiplicity()
53 , fTriggerDecisionPars(0)
57 // see header file for class documentation
59 // refer to README to build package
61 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
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);
146 if (numberOfTracks>=fMinTracks)
148 SetDescription(fTriggerDecisionPars->GetDescription());
149 AliHLTReadoutList readout(fTriggerDecisionPars->GetReadoutListParameter());
150 AliHLTTriggerDecision decision(
152 fTriggerDecisionPars->GetTriggerName().Data(),
153 AliHLTTriggerDomain(readout),
154 fTriggerDecisionPars->GetDescription()
156 TriggerEvent(&decision);
164 bool AliHLTTriggerBarrelGeomMultiplicity::CheckCondition(T* track, float b)
168 // see header file for class documentation
169 if (!track) return false;
171 ret = IsInDetectors(track, b);
178 bool AliHLTTriggerBarrelGeomMultiplicity::IsInDetectors(T* track, float b)
180 // See header file for class documentation
181 for(Int_t i = 0; i < fDetectorArray->GetEntries(); i++)
183 AliHLTTriggerDetectorGeom *det = static_cast<AliHLTTriggerDetectorGeom*>(fDetectorArray->At(i));
185 Double_t trackPoint[3];
186 Double_t normVector[3];
188 det->GetInitialPoint(trackPoint);
189 det->GetNormVector(normVector);
191 bool ret = track->Intersect(trackPoint, normVector, b);
195 if(det->IsInDetector(trackPoint)) return true;
201 int AliHLTTriggerBarrelGeomMultiplicity::DoInit(int argc, const char** argv)
203 // see header file for class documentation
205 // first configure the default
208 if (iResult>=0 && argc>0)
209 iResult=ConfigureFromArgumentString(argc, argv);
214 int AliHLTTriggerBarrelGeomMultiplicity::DoDeinit()
216 // see header file for class documentation
220 int AliHLTTriggerBarrelGeomMultiplicity::ReadPreprocessorValues(const char* /*modules*/)
222 // see header file for class documentation
224 // TODO 2009-10-10: implementation
225 // for the moment very quick, just reload the magnetic field
226 return ConfigureFromCDBTObjString(kAliHLTCDBSolenoidBz);
229 int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromCDBObject(const char *cdbEntry, const char* chainId)
231 // see header file for function documentation
232 int nDetectorGeoms=0;
233 const char *path = cdbEntry;
234 if(!path) path = fOCDBEntry;
238 // const char* chainId=GetChainId();
239 HLTInfo("configure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
240 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
243 TObjArray* pArr=dynamic_cast<TObjArray*>(pEntry->GetObject());
247 for(int i = 0; i < pArr->GetEntries(); i++)
249 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters"))
251 fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i));
253 else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom"))
255 fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
257 HLTWarning("received detector geometry of type %s", pArr->At(i)->ClassName());
261 HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName());
267 HLTError("configuration object \"%s\" has wrong type, required TObjArray", path);
268 nDetectorGeoms=-EINVAL;
273 HLTError("can not fetch object \"%s\" from OCDB", path);
274 nDetectorGeoms=-ENOENT;
277 return nDetectorGeoms;
280 int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromFile(const char *filename)
282 // see header file for function documentation
283 int nDetectorGeoms=0;
287 TFile *geomfile = TFile::Open(filename, "READ");
291 HLTInfo("configure from file \"%s\"", filename);
292 TObjArray* pArr=dynamic_cast<TObjArray*>(geomfile->Get("GeomConf"));
296 for(int i = 0; i < pArr->GetEntries(); i++)
298 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters"))
300 fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i));
302 else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom"))
304 fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
306 HLTWarning("received detector geometry of type %s", pArr->At(i)->ClassName());
310 HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName());
316 HLTError("configuration object has wrong type, required TObjArray");
317 nDetectorGeoms=-EINVAL;
322 HLTError("could not open file \"%s\"", filename);
323 nDetectorGeoms=-ENOENT;
326 HLTWarning("received TObjArray with %d detector geometries", nDetectorGeoms);
328 return nDetectorGeoms;
331 int AliHLTTriggerBarrelGeomMultiplicity::ScanConfigurationArgument(int argc, const char** argv)
333 // See header file for class documentation
334 if (argc<=0) return 0;
336 TString argument=argv[i];
338 if (argument.CompareTo("-geomfile")==0)
340 if (++i>=argc) return -EPROTO;
342 GetDetectorGeomsFromFile(argv[i]);
347 if (argument.CompareTo("-triggername")==0)
349 if (++i>=argc) return -EPROTO;
351 fTriggerName = new char[128];
352 sprintf(fTriggerName, argv[i]);
354 fOCDBEntry = fTriggerName;