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
61 fDetectorArray = new TObjArray(1);
63 fDetectorArray = new TObjArray(1);
65 fDetectorArray = new TObjArray;
69 AliHLTTriggerBarrelGeomMultiplicity::~AliHLTTriggerBarrelGeomMultiplicity()
71 // see header file for class documentation
74 const char* AliHLTTriggerBarrelGeomMultiplicity::GetTriggerName() const
76 // see header file for class documentation
78 return "BarrelGeomMultiplicityTrigger";
81 AliHLTComponent* AliHLTTriggerBarrelGeomMultiplicity::Spawn()
83 // see header file for class documentation
84 return new AliHLTTriggerBarrelGeomMultiplicity;
87 int AliHLTTriggerBarrelGeomMultiplicity::Reconfigure(const char *cdbEntry, const char *chainId)
89 // see header file for class documentation
91 // configure from the specified entry or the default
92 const char* entry=cdbEntry;
96 HLTDebug("No CDB path specified");
100 return GetDetectorGeomsFromCDBObject(entry, chainId);
103 int AliHLTTriggerBarrelGeomMultiplicity::DoTrigger()
105 // see header file for class documentation
107 int numberOfTracks=-1;
109 if (!fTriggerDecisionPars) {
113 // try the ESD as input
114 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
115 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
121 esd->GetStdContent();
122 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++)
124 if (CheckCondition(esd->GetTrack(i), esd->GetMagneticField())) numberOfTracks++;
128 // try the AliHLTExternal track data as input
129 if (iResult>=0 && numberOfTracks<0)
131 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack);
132 pBlock!=NULL; pBlock=GetNextInputBlock())
134 if (numberOfTracks<0) numberOfTracks=0;
135 vector<AliHLTGlobalBarrelTrack> tracks;
136 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0)
138 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
139 element!=tracks.end(); element++)
141 if (CheckCondition(&(*element), fSolenoidBz)) numberOfTracks++;
146 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
147 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
152 bool condition=false;
153 description="Geometrical conditions not matched";
154 AliHLTReadoutList readout;
156 if (numberOfTracks>=fMinTracks)
159 description=fTriggerDecisionPars->GetDescription();
160 readout=fTriggerDecisionPars->GetReadoutListParameter();
161 HLTDebug("Geometrical acceptance trigger %s triggered", fTriggerDecisionPars->GetTriggerName().Data());
164 AliHLTTriggerDecision decision(
166 fTriggerDecisionPars->GetTriggerName().Data(),
167 AliHLTTriggerDomain(readout),
170 TriggerEvent(&decision, kAliHLTDataTypeTObject|kAliHLTDataOriginOut);
178 bool AliHLTTriggerBarrelGeomMultiplicity::CheckCondition(T* track, float b)
183 // see header file for class documentation
184 if (!track) return false;
186 ret = IsInDetectors(track, b);
193 bool AliHLTTriggerBarrelGeomMultiplicity::IsInDetectors(T* track, float b)
195 // See header file for class documentation
196 for(Int_t i = 0; i < fDetectorArray->GetEntries(); i++)
198 AliHLTTriggerDetectorGeom *det = static_cast<AliHLTTriggerDetectorGeom*>(fDetectorArray->At(i));
200 Double_t trackPoint[3];
201 Double_t normVector[3];
203 det->GetInitialPoint(trackPoint);
204 det->GetNormVector(normVector);
206 bool ret = track->Intersect(trackPoint, normVector, b);
210 if(det->IsInDetector(trackPoint)) return true;
216 int AliHLTTriggerBarrelGeomMultiplicity::DoInit(int argc, const char** argv)
218 // see header file for class documentation
220 // first configure the default
223 if (iResult>=0 && argc>0)
224 iResult=ConfigureFromArgumentString(argc, argv);
226 if (!fTriggerDecisionPars) {
227 HLTError("decision parameter not initialized");
234 int AliHLTTriggerBarrelGeomMultiplicity::DoDeinit()
236 // see header file for class documentation
240 int AliHLTTriggerBarrelGeomMultiplicity::ReadPreprocessorValues(const char* /*modules*/)
242 // see header file for function documentation
244 // TODO 2009-10-10: implementation
245 // for the moment very quick, just reload the magnetic field
246 return ConfigureFromCDBTObjString(kAliHLTCDBSolenoidBz);
249 int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromCDBObject(const char *cdbEntry, const char* chainId)
251 // see header file for function documentation
252 int nDetectorGeoms=0;
256 fDetectorArray->Clear();
260 fDetectorArray = new TObjArray();
263 const char *path = cdbEntry;
265 if(!path) path = fOCDBEntry;
269 // const char* chainId=GetChainId();
270 HLTInfo("configure from entry %s, chain id %s", path, (chainId!=NULL && chainId[0]!=0)?chainId:"<none>");
271 AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
274 TObjArray* pArr=dynamic_cast<TObjArray*>(pEntry->GetObject());
278 for(int i = 0; i < pArr->GetEntries(); i++)
280 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters"))
282 fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i));
284 else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom"))
286 fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
288 HLTDebug("received detector geometry of type %s", pArr->At(i)->ClassName());
292 HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName());
298 HLTError("configuration object \"%s\" has wrong type, required TObjArray", path);
299 nDetectorGeoms=-EINVAL;
304 HLTError("can not fetch object \"%s\" from OCDB", path);
305 nDetectorGeoms=-ENOENT;
309 HLTInfo("received %d detector geometries", nDetectorGeoms);
311 return nDetectorGeoms;
314 int AliHLTTriggerBarrelGeomMultiplicity::GetDetectorGeomsFromFile(const char *filename)
316 // see header file for function documentation
317 int nDetectorGeoms=0;
321 fDetectorArray->Clear();
325 fDetectorArray = new TObjArray();
331 TFile *geomfile = TFile::Open(filename, "READ");
335 HLTInfo("configure from file \"%s\"", filename);
336 TObjArray* pArr=dynamic_cast<TObjArray*>(geomfile->Get("GeomConf"));
340 for(int i = 0; i < pArr->GetEntries(); i++)
342 if(!strcmp(pArr->At(i)->ClassName(), "AliHLTTriggerDecisionParameters"))
344 fTriggerDecisionPars = dynamic_cast<AliHLTTriggerDecisionParameters*>(pArr->At(i));
346 else if(pArr->At(i)->InheritsFrom("AliHLTTriggerDetectorGeom"))
348 fDetectorArray->AddLast(dynamic_cast<AliHLTTriggerDetectorGeom*>(pArr->At(i)));
350 HLTDebug("received detector geometry of type %s", pArr->At(i)->ClassName());
354 HLTWarning("Unknown object of type %s in configuration object", pArr->At(i)->ClassName());
360 HLTError("configuration object has wrong type, required TObjArray");
361 nDetectorGeoms=-EINVAL;
366 HLTError("could not open file \"%s\"", filename);
367 nDetectorGeoms=-ENOENT;
372 HLTError("ROOT file name not specified");
374 HLTInfo("received %d detector geometries", nDetectorGeoms);
376 return nDetectorGeoms;
379 int AliHLTTriggerBarrelGeomMultiplicity::ScanConfigurationArgument(int argc, const char** argv)
381 // See header file for class documentation
382 if (argc<=0) return 0;
384 TString argument=argv[i];
386 if (argument.CompareTo("-geomfile")==0)
388 if (++i>=argc) return -EPROTO;
390 GetDetectorGeomsFromFile(argv[i]);
395 if (argument.CompareTo("-triggername")==0)
397 if (++i>=argc) return -EPROTO;
399 fTriggerName = new char[128];
400 sprintf(fTriggerName, argv[i]);
402 fOCDBEntry = fTriggerName;