]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTTriggerBarrelMultiplicity.cxx
including the CTPData to the input objects of the HLTGlobalTriggerDecision
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTriggerBarrelMultiplicity.cxx
CommitLineData
cafc1a86 1// $Id$
2//**************************************************************************
3//* This file is property of and copyright by the ALICE HLT Project *
4//* ALICE Experiment at CERN, All rights reserved. *
5//* *
6//* Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
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 AliHLTTriggerBarrelMultiplicity.cxx
19/// @author Matthias Richter
20/// @date 2009-06-30
21/// @brief HLT trigger component for charged particle multiplicity in
22/// the central barrel.
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 "AliHLTTriggerBarrelMultiplicity.h"
31#include "AliESDEvent.h"
32#include "AliHLTTriggerDecision.h"
33#include "AliHLTDomainEntry.h"
f1574126 34#include "AliHLTGlobalBarrelTrack.h"
cafc1a86 35
36/** ROOT macro for the implementation of ROOT specific class methods */
37ClassImp(AliHLTTriggerBarrelMultiplicity)
38
39AliHLTTriggerBarrelMultiplicity::AliHLTTriggerBarrelMultiplicity()
40 : AliHLTTrigger()
41 , fPtMin(0.0)
42 , fPtMax(0.0)
43 , fMinTracks(1)
44{
45 // see header file for class documentation
46 // or
47 // refer to README to build package
48 // or
49 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
50}
51
f1574126 52const char* AliHLTTriggerBarrelMultiplicity::fgkOCDBEntry="HLT/ConfigHLT/BarrelMultiplicityTrigger";
53
cafc1a86 54AliHLTTriggerBarrelMultiplicity::~AliHLTTriggerBarrelMultiplicity()
55{
56 // see header file for class documentation
57}
58
59const char* AliHLTTriggerBarrelMultiplicity::GetTriggerName() const
60{
61 // see header file for class documentation
62 return "BarrelMultiplicityTrigger";
63}
64
65AliHLTComponent* AliHLTTriggerBarrelMultiplicity::Spawn()
66{
67 // see header file for class documentation
68 return new AliHLTTriggerBarrelMultiplicity;
69}
70
71int AliHLTTriggerBarrelMultiplicity::DoTrigger()
72{
73 // see header file for class documentation
f1574126 74 int iResult=0;
75 int numberOfTracks=-1;
76
77 // try the ESD as input
cafc1a86 78 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
79 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
80 TString description;
81 TString ptcut;
82 if (esd != NULL) {
f1574126 83 numberOfTracks=0;
cafc1a86 84 esd->GetStdContent();
85
cafc1a86 86 for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
f1574126 87 if (CheckCondition(esd->GetTrack(i))) numberOfTracks++;
88 }
89 }
90
91 // try the AliHLTExternal track data as input
92 if (iResult>=0 && numberOfTracks<0) {
93 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(kAliHLTDataTypeTrack);
94 pBlock!=NULL; pBlock=GetNextInputBlock()) {
b97c19da 95 if (numberOfTracks<0) numberOfTracks=0;
f1574126 96 vector<AliHLTGlobalBarrelTrack> tracks;
97 if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) {
98 for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
99 element!=tracks.end(); element++) {
100 if (CheckCondition(&(*element))) numberOfTracks++;
101 }
102 } else if (iResult<0) {
103 HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d",
104 DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
cafc1a86 105 }
106 }
f1574126 107 }
cafc1a86 108
f1574126 109 if (iResult>=0 && numberOfTracks>=0) {
cafc1a86 110 if (fPtMax>fPtMin) {
111 ptcut.Form(" %.02f GeV/c <= pt < %.02f GeV/c", fPtMin, fPtMax);
112 } else {
113 ptcut.Form(" pt >= %.02f GeV/c", fPtMin);
114 }
115 if (numberOfTracks>=fMinTracks) {
116 description.Form("Event contains %d track(s) with ", numberOfTracks);
117 description+=ptcut;
118 SetDescription(description.Data());
119 // Enable the central detectors for readout.
120 GetReadoutList().Enable(
121 AliHLTReadoutList::kITSSPD |
122 AliHLTReadoutList::kITSSDD |
123 AliHLTReadoutList::kITSSSD |
124 AliHLTReadoutList::kTPC |
125 AliHLTReadoutList::kTRD |
126 AliHLTReadoutList::kTOF |
127 AliHLTReadoutList::kHMPID |
128 AliHLTReadoutList::kPHOS
129 );
130 // Add the available HLT information for readout too.
131 GetTriggerDomain().Add("CLUSTERS", "TPC ");
132 TriggerEvent(true);
133 return 0;
134 }
f1574126 135 description.Form("No tracks matching the tresholds found in the central barrel (min tracks %d, %s)",
136 fMinTracks, ptcut.Data());
137 } else {
138 description.Form("No input blocks found");
cafc1a86 139 }
cafc1a86 140 SetDescription(description.Data());
141 TriggerEvent(false);
f1574126 142 return iResult;
143}
144
145template<class T>
146bool AliHLTTriggerBarrelMultiplicity::CheckCondition(T* track)
147{
148 // see header file for class documentation
149 if (track && track->Pt() >= fPtMin &&
150 (fPtMax<=fPtMin || track->Pt() < fPtMax)) {
151 return true;
152 }
153 return false;
154}
155
156int AliHLTTriggerBarrelMultiplicity::DoInit(int argc, const char** argv)
157{
158 // see header file for class documentation
159
160 // first configure the default
161 int iResult=ConfigureFromCDBTObjString(fgkOCDBEntry);
162
163 // configure from the command line parameters if specified
164 if (iResult>=0 && argc>0)
165 iResult=ConfigureFromArgumentString(argc, argv);
166 return iResult;
167}
168
169int AliHLTTriggerBarrelMultiplicity::DoDeinit()
170{
171 // see header file for class documentation
cafc1a86 172 return 0;
173}
f1574126 174
175int AliHLTTriggerBarrelMultiplicity::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
176{
177 // see header file for class documentation
178
179 // configure from the specified antry or the default one
180 const char* entry=cdbEntry;
181 if (!entry || entry[0]==0) entry=fgkOCDBEntry;
182
183 return ConfigureFromCDBTObjString(entry);
184}
185
186int AliHLTTriggerBarrelMultiplicity::ScanConfigurationArgument(int argc, const char** argv)
187{
188 // see header file for class documentation
189 if (argc<=0) return 0;
190 int i=0;
191 TString argument=argv[i];
192
193 // -maxpt
194 if (argument.CompareTo("-maxpt")==0) {
195 if (++i>=argc) return -EPROTO;
196 argument=argv[i];
197 fPtMax=argument.Atof();
198 return 2;
199 }
200
201 // -minpt
202 if (argument.CompareTo("-minpt")==0) {
203 if (++i>=argc) return -EPROTO;
204 argument=argv[i];
205 fPtMin=argument.Atof();
206 return 2;
207 }
208
209 // -mintracks
210 if (argument.CompareTo("-mintracks")==0) {
211 if (++i>=argc) return -EPROTO;
212 argument=argv[i];
213 fMinTracks=argument.Atoi();
214 return 2;
215 }
216
217 // unknown argument
218 return -EINVAL;
219}