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: Matthias Richter <Matthias.Richter@ift.uib.no> *
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 AliHLTTriggerBarrelMultiplicity.cxx
19 /// @author Matthias Richter
21 /// @brief HLT trigger component for charged particle multiplicity in
22 /// 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 "AliHLTTriggerBarrelMultiplicity.h"
31 #include "AliESDEvent.h"
32 #include "AliHLTTriggerDecision.h"
33 #include "AliHLTDomainEntry.h"
34 #include "AliHLTGlobalBarrelTrack.h"
35 #include "TObjArray.h"
36 #include "TObjString.h"
38 /** ROOT macro for the implementation of ROOT specific class methods */
39 ClassImp(AliHLTTriggerBarrelMultiplicity)
41 AliHLTTriggerBarrelMultiplicity::AliHLTTriggerBarrelMultiplicity()
53 // see header file for class documentation
55 // refer to README to build package
57 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
59 for (int i=0; i<fgkDCAReferenceSize; i++) fDCAReference[i]=0.0;
62 const char* AliHLTTriggerBarrelMultiplicity::fgkOCDBEntry="HLT/ConfigHLT/BarrelMultiplicityTrigger";
64 AliHLTTriggerBarrelMultiplicity::~AliHLTTriggerBarrelMultiplicity()
66 // see header file for class documentation
69 const char* AliHLTTriggerBarrelMultiplicity::GetTriggerName() const
71 // see header file for class documentation
72 return "BarrelMultiplicityTrigger";
75 AliHLTComponent* AliHLTTriggerBarrelMultiplicity::Spawn()
77 // see header file for class documentation
78 return new AliHLTTriggerBarrelMultiplicity;
81 int AliHLTTriggerBarrelMultiplicity::DoTrigger()
83 // see header file for class documentation
85 int numberOfTracks=-1;
87 // try the ESD as input
88 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
89 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
91 TString ptcut,tdca,ldca,dcaref,op1st,op2nd;
96 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
97 if (CheckCondition(esd->GetTrack(i), esd->GetMagneticField())) numberOfTracks++;
101 // try the AliHLTExternal track data as input
102 if (iResult>=0 && numberOfTracks<0) {
103 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack);
104 pBlock!=NULL; pBlock=GetNextInputBlock()) {
105 if (numberOfTracks<0) numberOfTracks=0;
106 vector<AliHLTGlobalBarrelTrack> tracks;
107 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) {
108 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
109 element!=tracks.end(); element++) {
110 if (CheckCondition(&(*element), fSolenoidBz)) numberOfTracks++;
112 } else if (iResult<0) {
113 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
114 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
119 if (iResult>=0 && numberOfTracks>=0) {
121 ptcut.Form(" %.02f GeV/c <= pt < %.02f GeV/c", fPtMin, fPtMax);
123 ptcut.Form(" pt >= %.02f GeV/c", fPtMin);
128 tdca.Form(", %.02f<=transverse_dca<=%.02f", fMinTDca, fMaxTDca);
130 tdca.Form(" transverse_dca >= %.02f", fMinTDca);
132 } else if (fMaxTDca>=0.0) {
133 tdca.Form(" transverse_dca<=%.02f", fMaxTDca);
135 if (!tdca.IsNull()) {
136 if (op1st.IsNull()) op1st=" && ";
142 ldca.Form(" %.02f<=longitudinal_dca<=%.02f", fMinLDca, fMaxLDca);
144 ldca.Form(" longitudinal_dca >= %.02f", fMinLDca);
146 } else if (fMaxLDca>=0.0) {
147 ldca.Form(" longitudinal_dca<=%.02f", fMaxLDca);
149 if (!ldca.IsNull()) {
150 if (op1st.IsNull()) op1st=" && ";
154 if (fMinTDca>=0.0 || fMaxTDca>=0 || fMinLDca>=0.0 || fMaxLDca>=0) {
155 dcaref.Form(" (%.01f,%.01f,%.01f)", fDCAReference[0], fDCAReference[1], fDCAReference[2]);
158 if (numberOfTracks>=fMinTracks) {
159 description.Form("Event contains %d track(s) with ", numberOfTracks);
166 SetDescription(description.Data());
167 // Enable the central detectors for readout.
168 GetReadoutList().Enable(
169 AliHLTReadoutList::kITSSPD |
170 AliHLTReadoutList::kITSSDD |
171 AliHLTReadoutList::kITSSSD |
172 AliHLTReadoutList::kTPC |
173 AliHLTReadoutList::kTRD |
174 AliHLTReadoutList::kTOF |
175 AliHLTReadoutList::kHMPID |
176 AliHLTReadoutList::kPHOS
178 // Add the available HLT information for readout too.
179 GetTriggerDomain().Add("CLUSTERS", "TPC ");
183 description.Form("No tracks matching the tresholds found in the central barrel (min tracks %d, ", fMinTracks);
192 description.Form("No input blocks found");
194 SetDescription(description.Data());
200 bool AliHLTTriggerBarrelMultiplicity::CheckCondition(T* track, float b)
202 // see header file for class documentation
203 if (!track) return false;
205 // check on ptransverse momentum
206 if (TMath::Abs(track->Pt()) < fPtMin || (fPtMax>fPtMin && TMath::Abs(track->Pt()) > fPtMax)) {
210 // check on transverse and longitudinal DCA
211 if (fMinTDca>=0.0 || fMaxTDca>=0 || fMinLDca>=0.0 || fMaxLDca>=0) {
212 Float_t dz[2]={0.0,0.0};
213 track->GetDZ(fDCAReference[0], fDCAReference[1], fDCAReference[2], b, dz);
214 HLTDebug("checking dca condition: transversal %f logitudinal %f", dz[0], dz[1]);
215 if (fMinTDca>=0 && TMath::Abs(dz[0])<fMinTDca) return false;
216 if (fMaxTDca>=0 && TMath::Abs(dz[0])>fMaxTDca) return false;
217 if (fMinLDca>=0 && TMath::Abs(dz[1])<fMinLDca) return false;
218 if (fMaxLDca>=0 && TMath::Abs(dz[1])>fMaxLDca) return false;
224 int AliHLTTriggerBarrelMultiplicity::DoInit(int argc, const char** argv)
226 // see header file for class documentation
228 // first configure the default
230 iResult=ConfigureFromCDBTObjString(kAliHLTCDBSolenoidBz);
231 if (iResult>=0) iResult=ConfigureFromCDBTObjString(fgkOCDBEntry);
233 // configure from the command line parameters if specified
234 if (iResult>=0 && argc>0)
235 iResult=ConfigureFromArgumentString(argc, argv);
239 int AliHLTTriggerBarrelMultiplicity::DoDeinit()
241 // see header file for class documentation
245 int AliHLTTriggerBarrelMultiplicity::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
247 // see header file for class documentation
249 // configure from the specified antry or the default one
250 const char* entry=cdbEntry;
251 if (!entry || entry[0]==0) {
252 ConfigureFromCDBTObjString(kAliHLTCDBSolenoidBz);
256 return ConfigureFromCDBTObjString(entry);
259 int AliHLTTriggerBarrelMultiplicity::ReadPreprocessorValues(const char* /*modules*/)
261 // see header file for class documentation
263 // TODO 2009-09-10: implementation
264 // for the moment very quick, just reload the magnetic field
265 return ConfigureFromCDBTObjString(kAliHLTCDBSolenoidBz);
268 int AliHLTTriggerBarrelMultiplicity::ScanConfigurationArgument(int argc, const char** argv)
270 // see header file for class documentation
271 if (argc<=0) return 0;
273 TString argument=argv[i];
276 if (argument.CompareTo("-maxpt")==0) {
277 if (++i>=argc) return -EPROTO;
279 fPtMax=argument.Atof();
284 if (argument.CompareTo("-minpt")==0) {
285 if (++i>=argc) return -EPROTO;
287 fPtMin=argument.Atof();
292 if (argument.CompareTo("-mintracks")==0) {
293 if (++i>=argc) return -EPROTO;
295 fMinTracks=argument.Atoi();
300 // reference point for the transverse and longitudinal dca cut
301 if (argument.CompareTo("-dca-reference")==0) {
302 if (++i>=argc) return -EPROTO;
305 TObjArray* pTokens=argument.Tokenize("'");
307 for (int c=0; c<pTokens->GetEntriesFast() && c<fgkDCAReferenceSize; c++) {
308 argument=((TObjString*)pTokens->At(c))->GetString();
309 fDCAReference[i]=argument.Atof();
317 // minimum longitudinal dca to reference point
318 if (argument.CompareTo("-min-ldca")==0) {
319 if (++i>=argc) return -EPROTO;
321 fMinLDca=argument.Atof();
326 // maximum longitudinal dca to reference point
327 if (argument.CompareTo("-max-ldca")==0) {
328 if (++i>=argc) return -EPROTO;
330 fMaxLDca=argument.Atof();
335 // minimum transverse dca to reference point
336 if (argument.CompareTo("-min-tdca")==0) {
337 if (++i>=argc) return -EPROTO;
339 fMinTDca=argument.Atof();
344 // maximum transverse dca to reference point
345 if (argument.CompareTo("-max-tdca")==0) {
346 if (++i>=argc) return -EPROTO;
348 fMaxTDca=argument.Atof();
353 if (argument.CompareTo("-solenoidBz")==0) {
354 if (++i>=argc) return -EPROTO;
356 fSolenoidBz=argument.Atof();