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: Matthias Richter <Matthias.Richter@ift.uib.no> *
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()
54 // see header file for class documentation
56 // refer to README to build package
58 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
59 fDetectorArray = new TObjArray;
63 AliHLTTriggerBarrelGeomMultiplicity::~AliHLTTriggerBarrelGeomMultiplicity()
65 // see header file for class documentation
68 const char* AliHLTTriggerBarrelGeomMultiplicity::GetTriggerName() const
70 // see header file for class documentation
71 // const char* name = fTriggerName;
72 // if(name) return name;
73 return "BarrelGeomMultiplicityTrigger";
76 AliHLTComponent* AliHLTTriggerBarrelGeomMultiplicity::Spawn()
78 // see header file for class documentation
79 return new AliHLTTriggerBarrelGeomMultiplicity;
82 int AliHLTTriggerBarrelGeomMultiplicity::Reconfigure(const char *cdbEntry, const char *chainId)
84 // see header file for class documentation
86 // configure from the specified entry or the default
87 const char* entry=cdbEntry;
91 HLTDebug("No CDB path specified");
95 return GetDetectorGeomsFromCDBObject(entry, chainId);
98 int AliHLTTriggerBarrelGeomMultiplicity::DoTrigger()
100 // see header file for class documentation
102 int numberOfTracks=-1;
104 // try the ESD as input
105 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
106 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
111 esd->GetStdContent();
113 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++)
115 if (CheckCondition(esd->GetTrack(i), esd->GetMagneticField())) numberOfTracks++;
119 // try the AliHLTExternal track data as input
120 if (iResult>=0 && numberOfTracks<0)
122 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack);
123 pBlock!=NULL; pBlock=GetNextInputBlock())
125 if (numberOfTracks<0) numberOfTracks=0;
126 vector<AliHLTGlobalBarrelTrack> tracks;
127 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0)
129 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
130 element!=tracks.end(); element++)
132 if (CheckCondition(&(*element), fSolenoidBz)) numberOfTracks++;
137 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
138 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
142 if (numberOfTracks>=fMinTracks)
145 SetDescription(fTriggerDecisionPars->GetDescription());
146 AliHLTReadoutList readout(fTriggerDecisionPars->GetReadoutListParameter());
147 AliHLTTriggerDecision decision(
149 fTriggerDecisionPars->GetTriggerName().Data(),
150 AliHLTTriggerDomain(readout),
151 fTriggerDecisionPars->GetDescription()
153 TriggerEvent(&decision);
161 bool AliHLTTriggerBarrelGeomMultiplicity::CheckCondition(T* track, float b)
165 // see header file for class documentation
166 if (!track) return false;
168 ret = IsInDetectors(track, b);
175 bool AliHLTTriggerBarrelGeomMultiplicity::IsInDetectors(T* track, float b)
177 // See header file for class documentation
178 for(Int_t i = 0; i < fDetectorArray->GetEntries(); i++)
180 AliHLTTriggerDetectorGeom *det = static_cast<AliHLTTriggerDetectorGeom*>(fDetectorArray->At(i));
181 Double_t trackPoint[3];
183 det->GetInitialPoint(trackPoint);
185 bool ret = track->Intersect(trackPoint, det->NormVector(), b);
191 int AliHLTTriggerBarrelGeomMultiplicity::DoInit(int argc, const char** argv)
193 // see header file for class documentation
195 // first configure the default
198 if (iResult>=0 && argc>0)
199 iResult=ConfigureFromArgumentString(argc, argv);
205 int AliHLTTriggerBarrelGeomMultiplicity::DoDeinit()
207 // see header file for class documentation
211 int AliHLTTriggerBarrelGeomMultiplicity::ReadPreprocessorValues(const char* /*modules*/)
213 // see header file for class documentation
215 // TODO 2009-10-10: implementation
216 // for the moment very quick, just reload the magnetic field
217 return ConfigureFromCDBTObjString(kAliHLTCDBSolenoidBz);
220 int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromCDBObject(const char *cdbEntry, const char* chainId)
222 // see header file for function documentation
223 int nDetectorGeoms=0;
224 const char *path = cdbEntry;
225 if(!path) path = fOCDBEntry;
229 // const char* chainId=GetChainId();
230 HLTInfo("configure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
231 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
234 TObjArray* pArr=dynamic_cast<TObjArray*>(pEntry->GetObject());
238 for(int i = 0; i < pArr->GetEntries(); i++)
240 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecision"))
242 fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i));
244 else if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDetectorGeom"))
246 fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
248 HLTWarning("received TObjArray of %d detector geometries", nDetectorGeoms);
252 HLTWarning("Unknown object in configuration object");
258 HLTError("configuration object \"%s\" has wrong type, required TObjArray", path);
259 nDetectorGeoms=-EINVAL;
264 HLTError("can not fetch object \"%s\" from OCDB", path);
265 nDetectorGeoms=-ENOENT;
268 return nDetectorGeoms;
271 int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromFile(const char *filename)
273 // see header file for function documentation
274 int nDetectorGeoms=0;
278 TFile *geomfile = TFile::Open(filename, "READ");
283 HLTInfo("configure from file \"%s\"", filename);
284 TObjArray* pArr=dynamic_cast<TObjArray*>(geomfile->Get("GeomConf"));
288 for(int i = 0; i < pArr->GetEntries(); i++)
290 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters"))
292 fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i));
294 else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom"))
296 fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
298 HLTWarning("received detector geometry of type %s", pArr->At(i)->ClassName());
302 HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName());
308 HLTError("configuration object has wrong type, required TObjArray");
309 nDetectorGeoms=-EINVAL;
314 HLTError("could not open file \"%s\"", filename);
315 nDetectorGeoms=-ENOENT;
318 HLTWarning("received TObjArray with %d detector geometries", nDetectorGeoms);
320 return nDetectorGeoms;
323 int AliHLTTriggerBarrelGeomMultiplicity::ScanConfigurationArgument(int argc, const char** argv)
325 // See header file for class documentation
326 if (argc<=0) return 0;
328 TString argument=argv[i];
331 if (argument.CompareTo("-geomfile")==0)
333 if (++i>=argc) return -EPROTO;
335 GetDetectorGeomsFromFile(argv[i]);
340 if (argument.CompareTo("-trgname")==0)
342 if (++i>=argc) return -EPROTO;
344 fTriggerName = new char[128];
345 sprintf(fTriggerName, argv[i]);
347 fOCDBEntry = fTriggerName;