]>
Commit | Line | Data |
---|---|---|
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 */ | |
45 | ClassImp(AliHLTTriggerBarrelGeomMultiplicity) | |
46 | ||
47 | AliHLTTriggerBarrelGeomMultiplicity::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 | |
d3c57a43 | 61 | |
ef882581 | 62 | fDetectorArray = new TObjArray; |
46906312 | 63 | |
64 | } | |
65 | ||
46906312 | 66 | AliHLTTriggerBarrelGeomMultiplicity::~AliHLTTriggerBarrelGeomMultiplicity() |
67 | { | |
68 | // see header file for class documentation | |
b09d01b5 | 69 | |
70 | if (fDetectorArray != NULL) delete fDetectorArray; | |
46906312 | 71 | } |
72 | ||
9f7b505a | 73 | const char* AliHLTTriggerBarrelGeomMultiplicity::GetTriggerName() const |
46906312 | 74 | { |
75 | // see header file for class documentation | |
f461a2cb | 76 | |
46906312 | 77 | return "BarrelGeomMultiplicityTrigger"; |
78 | } | |
79 | ||
80 | AliHLTComponent* AliHLTTriggerBarrelGeomMultiplicity::Spawn() | |
81 | { | |
82 | // see header file for class documentation | |
83 | return new AliHLTTriggerBarrelGeomMultiplicity; | |
84 | } | |
85 | ||
1ecefac2 | 86 | int AliHLTTriggerBarrelGeomMultiplicity::Reconfigure(const char *cdbEntry, const char *chainId) |
87 | { | |
88 | // see header file for class documentation | |
89 | ||
90 | // configure from the specified entry or the default | |
91 | const char* entry=cdbEntry; | |
92 | ||
93 | if (!entry) | |
94 | { | |
95 | HLTDebug("No CDB path specified"); | |
96 | entry = fOCDBEntry; | |
97 | } | |
98 | ||
99 | return GetDetectorGeomsFromCDBObject(entry, chainId); | |
100 | } | |
101 | ||
46906312 | 102 | int AliHLTTriggerBarrelGeomMultiplicity::DoTrigger() |
103 | { | |
104 | // see header file for class documentation | |
105 | int iResult=0; | |
106 | int numberOfTracks=-1; | |
107 | ||
fb50cb46 | 108 | if (!fTriggerDecisionPars) { |
109 | iResult=-ENODEV; | |
110 | } | |
111 | ||
46906312 | 112 | // try the ESD as input |
113 | const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent"); | |
398faf4c | 114 | AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj)); |
46906312 | 115 | TString description; |
d3c57a43 | 116 | |
1ecefac2 | 117 | if (esd != NULL) |
118 | { | |
119 | numberOfTracks=0; | |
120 | esd->GetStdContent(); | |
1ecefac2 | 121 | for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) |
122 | { | |
123 | if (CheckCondition(esd->GetTrack(i), esd->GetMagneticField())) numberOfTracks++; | |
124 | } | |
46906312 | 125 | } |
46906312 | 126 | |
127 | // try the AliHLTExternal track data as input | |
1ecefac2 | 128 | if (iResult>=0 && numberOfTracks<0) |
129 | { | |
130 | for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack); | |
131 | pBlock!=NULL; pBlock=GetNextInputBlock()) | |
132 | { | |
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) | |
136 | { | |
137 | for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin(); | |
138 | element!=tracks.end(); element++) | |
139 | { | |
140 | if (CheckCondition(&(*element), fSolenoidBz)) numberOfTracks++; | |
141 | } | |
142 | } | |
143 | else if (iResult<0) | |
144 | { | |
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); | |
147 | } | |
46906312 | 148 | } |
46906312 | 149 | } |
c308d915 | 150 | |
fb50cb46 | 151 | bool condition=false; |
152 | description="Geometrical conditions not matched"; | |
153 | AliHLTReadoutList readout; | |
154 | ||
1ecefac2 | 155 | if (numberOfTracks>=fMinTracks) |
156 | { | |
fb50cb46 | 157 | condition=true; |
158 | description=fTriggerDecisionPars->GetDescription(); | |
159 | readout=fTriggerDecisionPars->GetReadoutListParameter(); | |
160 | HLTDebug("Geometrical acceptance trigger %s triggered", fTriggerDecisionPars->GetTriggerName().Data()); | |
46906312 | 161 | } |
fb50cb46 | 162 | |
163 | AliHLTTriggerDecision decision( | |
164 | condition, | |
165 | fTriggerDecisionPars->GetTriggerName().Data(), | |
166 | AliHLTTriggerDomain(readout), | |
167 | description.Data() | |
168 | ); | |
169 | TriggerEvent(&decision, kAliHLTDataTypeTObject|kAliHLTDataOriginOut); | |
170 | ||
46906312 | 171 | return iResult; |
4bb9ea62 | 172 | |
46906312 | 173 | } |
174 | ||
1260b409 | 175 | |
46906312 | 176 | template<class T> |
177 | bool AliHLTTriggerBarrelGeomMultiplicity::CheckCondition(T* track, float b) | |
178 | { | |
21463652 | 179 | |
1ecefac2 | 180 | bool ret = false; |
181 | ||
46906312 | 182 | // see header file for class documentation |
183 | if (!track) return false; | |
184 | ||
185 | ret = IsInDetectors(track, b); | |
186 | ||
187 | return ret; | |
188 | ||
189 | } | |
190 | ||
191 | template<class T> | |
1ecefac2 | 192 | bool AliHLTTriggerBarrelGeomMultiplicity::IsInDetectors(T* track, float b) |
46906312 | 193 | { |
1ecefac2 | 194 | // See header file for class documentation |
195 | for(Int_t i = 0; i < fDetectorArray->GetEntries(); i++) | |
46906312 | 196 | { |
1ecefac2 | 197 | AliHLTTriggerDetectorGeom *det = static_cast<AliHLTTriggerDetectorGeom*>(fDetectorArray->At(i)); |
c308d915 | 198 | |
46906312 | 199 | Double_t trackPoint[3]; |
c308d915 | 200 | Double_t normVector[3]; |
201 | ||
46906312 | 202 | det->GetInitialPoint(trackPoint); |
c308d915 | 203 | det->GetNormVector(normVector); |
46906312 | 204 | |
c308d915 | 205 | bool ret = track->Intersect(trackPoint, normVector, b); |
206 | ||
207 | if(ret) | |
208 | { | |
209 | if(det->IsInDetector(trackPoint)) return true; | |
210 | } | |
46906312 | 211 | } |
212 | return false; | |
213 | } | |
214 | ||
215 | int AliHLTTriggerBarrelGeomMultiplicity::DoInit(int argc, const char** argv) | |
216 | { | |
217 | // see header file for class documentation | |
218 | ||
219 | // first configure the default | |
220 | int iResult=0; | |
46906312 | 221 | |
a3ec8572 | 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!"); | |
225 | ||
46906312 | 226 | if (iResult>=0 && argc>0) |
227 | iResult=ConfigureFromArgumentString(argc, argv); | |
1ecefac2 | 228 | |
fb50cb46 | 229 | if (!fTriggerDecisionPars) { |
230 | HLTError("decision parameter not initialized"); | |
231 | iResult=-ENODEV; | |
232 | } | |
75970b8d | 233 | fSolenoidBz=GetBz(); |
fb50cb46 | 234 | |
46906312 | 235 | return iResult; |
236 | } | |
237 | ||
238 | int AliHLTTriggerBarrelGeomMultiplicity::DoDeinit() | |
24a39a2c | 239 | { |
46906312 | 240 | // see header file for class documentation |
a3ec8572 | 241 | if (fTriggerName) delete fTriggerName; |
242 | fTriggerName=NULL; | |
46906312 | 243 | return 0; |
244 | } | |
245 | ||
1ecefac2 | 246 | int AliHLTTriggerBarrelGeomMultiplicity::ReadPreprocessorValues(const char* /*modules*/) |
46906312 | 247 | { |
9f7b505a | 248 | // see header file for function documentation |
46906312 | 249 | |
75970b8d | 250 | // nothing to do for the moment |
251 | return 0; | |
1ecefac2 | 252 | } |
253 | ||
254 | int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromCDBObject(const char *cdbEntry, const char* chainId) | |
255 | { | |
256 | // see header file for function documentation | |
257 | int nDetectorGeoms=0; | |
b850c417 | 258 | |
259 | if(fDetectorArray) | |
260 | { | |
261 | fDetectorArray->Clear(); | |
262 | } | |
263 | else | |
264 | { | |
265 | fDetectorArray = new TObjArray(); | |
266 | } | |
267 | ||
1ecefac2 | 268 | const char *path = cdbEntry; |
46906312 | 269 | |
b850c417 | 270 | if(!path) path = fOCDBEntry; |
271 | ||
1ecefac2 | 272 | if(path) |
273 | { | |
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()*/); | |
277 | if (pEntry) | |
278 | { | |
279 | TObjArray* pArr=dynamic_cast<TObjArray*>(pEntry->GetObject()); | |
280 | if (pArr) | |
281 | { | |
282 | ||
283 | for(int i = 0; i < pArr->GetEntries(); i++) | |
284 | { | |
c308d915 | 285 | if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters")) |
1ecefac2 | 286 | { |
fde46e9e | 287 | fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i)); |
1ecefac2 | 288 | } |
c308d915 | 289 | else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom")) |
1ecefac2 | 290 | { |
291 | fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i))); | |
292 | nDetectorGeoms++; | |
b850c417 | 293 | HLTDebug("received detector geometry of type %s", pArr->At(i)->ClassName()); |
1ecefac2 | 294 | } |
295 | else | |
296 | { | |
c308d915 | 297 | HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName()); |
1ecefac2 | 298 | } |
299 | } | |
300 | } | |
301 | else | |
302 | { | |
303 | HLTError("configuration object \"%s\" has wrong type, required TObjArray", path); | |
304 | nDetectorGeoms=-EINVAL; | |
305 | } | |
306 | } | |
307 | else | |
308 | { | |
309 | HLTError("can not fetch object \"%s\" from OCDB", path); | |
310 | nDetectorGeoms=-ENOENT; | |
311 | } | |
312 | } | |
b850c417 | 313 | |
314 | HLTInfo("received %d detector geometries", nDetectorGeoms); | |
315 | ||
1ecefac2 | 316 | return nDetectorGeoms; |
46906312 | 317 | } |
318 | ||
1ecefac2 | 319 | int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromFile(const char *filename) |
46906312 | 320 | { |
1ecefac2 | 321 | // see header file for function documentation |
322 | int nDetectorGeoms=0; | |
46906312 | 323 | |
b850c417 | 324 | if(fDetectorArray) |
325 | { | |
326 | fDetectorArray->Clear(); | |
327 | } | |
328 | else | |
329 | { | |
330 | fDetectorArray = new TObjArray(); | |
331 | } | |
332 | ||
333 | ||
1ecefac2 | 334 | if (filename) |
335 | { | |
336 | TFile *geomfile = TFile::Open(filename, "READ"); | |
337 | ||
338 | if(geomfile) | |
339 | { | |
1ecefac2 | 340 | HLTInfo("configure from file \"%s\"", filename); |
fde46e9e | 341 | TObjArray* pArr=dynamic_cast<TObjArray*>(geomfile->Get("GeomConf")); |
1ecefac2 | 342 | if (pArr) |
343 | { | |
344 | ||
345 | for(int i = 0; i < pArr->GetEntries(); i++) | |
346 | { | |
fde46e9e | 347 | if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters")) |
1ecefac2 | 348 | { |
fde46e9e | 349 | fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i)); |
1ecefac2 | 350 | } |
fde46e9e | 351 | else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom")) |
1ecefac2 | 352 | { |
353 | fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i))); | |
354 | nDetectorGeoms++; | |
b850c417 | 355 | HLTDebug("received detector geometry of type %s", pArr->At(i)->ClassName()); |
1ecefac2 | 356 | } |
357 | else | |
358 | { | |
fde46e9e | 359 | HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName()); |
1ecefac2 | 360 | } |
361 | } | |
362 | } | |
363 | else | |
364 | { | |
365 | HLTError("configuration object has wrong type, required TObjArray"); | |
366 | nDetectorGeoms=-EINVAL; | |
367 | } | |
368 | } | |
369 | else | |
370 | { | |
fde46e9e | 371 | HLTError("could not open file \"%s\"", filename); |
1ecefac2 | 372 | nDetectorGeoms=-ENOENT; |
373 | } | |
374 | } | |
b850c417 | 375 | else |
376 | { | |
377 | HLTError("ROOT file name not specified"); | |
378 | } | |
379 | HLTInfo("received %d detector geometries", nDetectorGeoms); | |
380 | ||
1ecefac2 | 381 | return nDetectorGeoms; |
46906312 | 382 | } |
383 | ||
384 | int AliHLTTriggerBarrelGeomMultiplicity::ScanConfigurationArgument(int argc, const char** argv) | |
385 | { | |
4bb9ea62 | 386 | // See header file for class documentation |
46906312 | 387 | if (argc<=0) return 0; |
388 | int i=0; | |
389 | TString argument=argv[i]; | |
390 | ||
1ecefac2 | 391 | if (argument.CompareTo("-geomfile")==0) |
392 | { | |
393 | if (++i>=argc) return -EPROTO; | |
394 | ||
395 | GetDetectorGeomsFromFile(argv[i]); | |
396 | ||
397 | return 2; | |
398 | } | |
46906312 | 399 | |
5af7c3ac | 400 | if (argument.CompareTo("-triggername")==0) |
1ecefac2 | 401 | { |
a3ec8572 | 402 | if (++i>=argc || argv[i]==NULL) return -EPROTO; |
403 | ||
404 | int namelen=strlen(argv[i])+1; | |
405 | fTriggerName = new char[namelen]; | |
406 | if (!fTriggerName) return -ENOMEM; | |
407 | snprintf(fTriggerName, namelen, "%s", argv[i]); | |
1ecefac2 | 408 | |
409 | fOCDBEntry = fTriggerName; | |
410 | ||
411 | return 2; | |
46906312 | 412 | } |
b210e538 | 413 | return 0; |
46906312 | 414 | } |
b850c417 | 415 |