]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/trigger/AliHLTTriggerBarrelMultiplicity.cxx
Adding kAliHLTDataTypeTrack as valid input. Conversion of the input data to
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTriggerBarrelMultiplicity.cxx
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"
34 #include "AliHLTGlobalBarrelTrack.h"
35
36 /** ROOT macro for the implementation of ROOT specific class methods */
37 ClassImp(AliHLTTriggerBarrelMultiplicity)
38
39 AliHLTTriggerBarrelMultiplicity::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
52 const char* AliHLTTriggerBarrelMultiplicity::fgkOCDBEntry="HLT/ConfigHLT/BarrelMultiplicityTrigger";
53
54 AliHLTTriggerBarrelMultiplicity::~AliHLTTriggerBarrelMultiplicity()
55 {
56   // see header file for class documentation
57 }
58
59 const char* AliHLTTriggerBarrelMultiplicity::GetTriggerName() const
60 {
61   // see header file for class documentation
62   return "BarrelMultiplicityTrigger";
63 }
64
65 AliHLTComponent* AliHLTTriggerBarrelMultiplicity::Spawn()
66 {
67   // see header file for class documentation
68   return new AliHLTTriggerBarrelMultiplicity;
69 }
70
71 int AliHLTTriggerBarrelMultiplicity::DoTrigger()
72 {
73   // see header file for class documentation
74   int iResult=0;
75   int numberOfTracks=-1;
76
77   // try the ESD as input
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) {
83     numberOfTracks=0;
84     esd->GetStdContent();
85     
86     for (Int_t i = 0; i < esd->GetNumberOfTracks(); i++) {
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()) {
95       vector<AliHLTGlobalBarrelTrack> tracks;
96       if ((iResult=AliHLTGlobalBarrelTrack::ConvertTrackDataArray(reinterpret_cast<const AliHLTTracksData*>(pBlock->fPtr), pBlock->fSize, tracks))>0) {
97         for (vector<AliHLTGlobalBarrelTrack>::iterator element=tracks.begin();
98              element!=tracks.end(); element++) {
99           if (CheckCondition(&(*element))) numberOfTracks++;
100         }
101       } else if (iResult<0) {
102         HLTError("can not extract tracks from data block of type %s (specification %08x) of size %d: error %d", 
103                  DataType2Text(pBlock->fDataType).c_str(), pBlock->fSpecification, pBlock->fSize, iResult);
104       }
105     }
106   }
107
108   if (iResult>=0 && numberOfTracks>=0) {
109     if (fPtMax>fPtMin) {
110       ptcut.Form(" %.02f GeV/c <= pt < %.02f GeV/c", fPtMin, fPtMax);
111     } else {
112       ptcut.Form(" pt >= %.02f GeV/c", fPtMin);
113     }
114     if (numberOfTracks>=fMinTracks) {
115       description.Form("Event contains %d track(s) with ", numberOfTracks);
116       description+=ptcut;
117       SetDescription(description.Data());
118       // Enable the central detectors for readout.
119       GetReadoutList().Enable(
120                               AliHLTReadoutList::kITSSPD |
121                               AliHLTReadoutList::kITSSDD |
122                               AliHLTReadoutList::kITSSSD |
123                               AliHLTReadoutList::kTPC |
124                               AliHLTReadoutList::kTRD |
125                               AliHLTReadoutList::kTOF |
126                               AliHLTReadoutList::kHMPID |
127                               AliHLTReadoutList::kPHOS
128                               );
129       // Add the available HLT information for readout too.
130       GetTriggerDomain().Add("CLUSTERS", "TPC ");
131       TriggerEvent(true);
132       return 0;
133     }
134     description.Form("No tracks matching the tresholds found in the central barrel (min tracks %d, %s)",
135                      fMinTracks, ptcut.Data());
136   } else {
137     description.Form("No input blocks found");
138   }
139   SetDescription(description.Data());
140   TriggerEvent(false);
141   return iResult;
142 }
143
144 template<class T>
145 bool AliHLTTriggerBarrelMultiplicity::CheckCondition(T* track)
146 {
147   // see header file for class documentation
148   if (track && track->Pt() >= fPtMin &&
149       (fPtMax<=fPtMin || track->Pt() < fPtMax)) {
150     return true;
151   }
152   return false;
153 }
154
155 int AliHLTTriggerBarrelMultiplicity::DoInit(int argc, const char** argv)
156 {
157   // see header file for class documentation
158
159   // first configure the default
160   int iResult=ConfigureFromCDBTObjString(fgkOCDBEntry);
161
162   // configure from the command line parameters if specified
163   if (iResult>=0 && argc>0)
164     iResult=ConfigureFromArgumentString(argc, argv);
165   return iResult;
166 }
167
168 int AliHLTTriggerBarrelMultiplicity::DoDeinit()
169 {
170   // see header file for class documentation
171   return 0;
172 }
173
174 int AliHLTTriggerBarrelMultiplicity::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
175 {
176   // see header file for class documentation
177
178   // configure from the specified antry or the default one
179   const char* entry=cdbEntry;
180   if (!entry || entry[0]==0) entry=fgkOCDBEntry;
181
182   return ConfigureFromCDBTObjString(entry);
183 }
184
185 int AliHLTTriggerBarrelMultiplicity::ScanConfigurationArgument(int argc, const char** argv)
186 {
187   // see header file for class documentation
188   if (argc<=0) return 0;
189   int i=0;
190   TString argument=argv[i];
191
192   // -maxpt
193   if (argument.CompareTo("-maxpt")==0) {
194     if (++i>=argc) return -EPROTO;
195     argument=argv[i];
196     fPtMax=argument.Atof();
197     return 2;
198   }    
199
200   // -minpt
201   if (argument.CompareTo("-minpt")==0) {
202     if (++i>=argc) return -EPROTO;
203     argument=argv[i];
204     fPtMin=argument.Atof();
205     return 2;
206   }    
207
208   // -mintracks
209   if (argument.CompareTo("-mintracks")==0) {
210     if (++i>=argc) return -EPROTO;
211     argument=argv[i];
212     fMinTracks=argument.Atoi();
213     return 2;
214   }    
215   
216   // unknown argument
217   return -EINVAL;
218 }