]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTTriggerEmcalElectron.cxx
Fixing broken code with temporary fix.
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTriggerEmcalElectron.cxx
CommitLineData
5d8d9319 1// $Id: AliHLTTriggerEmcalElectron.cxx 50471 2011-07-07 09:50:47Z fronchet $
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: marcelfigueredo@gmail.com *
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#include "AliHLTTriggerEmcalElectron.h"
19#include "AliESDEvent.h"
20#include "AliESDCaloCluster.h"
21#include "AliHLTTriggerDecision.h"
22#include "AliHLTDomainEntry.h"
23#include "AliHLTCaloClusterReader.h"
24#include "AliHLTCaloClusterDataStruct.h"
25#include "TRefArray.h"
26#include "TString.h"
27#include "TMap.h"
28#include "AliESDtrack.h"
29
30/** ROOT macro for the implementation of ROOT specific class methods */
31ClassImp(AliHLTTriggerEmcalElectron)
32
33AliHLTTriggerEmcalElectron::AliHLTTriggerEmcalElectron() :
34 AliHLTTrigger(),
35 fEThreshold(0.0),
36 fEoverPThreshold(0.8),
37 fEoverPLimit(1.2),
38 fClustersRefs(NULL),
39 fDetector("EMCAL"),
40 fClusterReader(NULL),
41 fOCDBEntry(""),
42 fInputDataType()
43{
44 // see header file for class documentation
45 // or
46 // refer to README to build package
47 // or
48 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlts
49
50 fClusterReader = new AliHLTCaloClusterReader();
51 fClustersRefs = new TRefArray();
52
53}
54
55
56AliHLTTriggerEmcalElectron::~AliHLTTriggerEmcalElectron() {
57 // see header file for class documentation
58 if (fClusterReader)
59 delete fClusterReader;
60 fClusterReader = NULL;
61
62 if(fClustersRefs)
63 delete fClustersRefs;
64 fClustersRefs = NULL;
65}
66
67//Trigger name
68const char* AliHLTTriggerEmcalElectron::GetTriggerName() const {
69 // see header file for class documentation
70 return "EmcalElectronTrigger";
71}
72
8ffa7c29 73AliHLTComponent* AliHLTTriggerEmcalElectron::Spawn() {
74 // see header file for class documentation
75 return new AliHLTTriggerEmcalElectron;
76}
5d8d9319 77
78Int_t AliHLTTriggerEmcalElectron::DoTrigger() {
79 // see header file for class documentation
80
81 Int_t iResult = 0;
82
83
84 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
85 return 0;
86
87 //Try the caloclusterstruct input
88
89/*
90 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(fInputDataType); pBlock!=NULL; pBlock=GetNextInputBlock()) {
91 AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
92 fClusterReader->SetMemory(caloClusterHeader);
93
94 AliHLTCaloClusterDataStruct * caloClusterStruct;
95 while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
96 if (TriggerOnEoverP(caloClusterStruct)) {
97 return iResult;
98 }
99 }
100 }*/
101
102 //Try the ESD input
103 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
104 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
105
106 if (esd != NULL) {
107 esd->GetStdContent();
108
32df6809 109 Int_t ncc = 0; //GetClustersFromEsd(esd, fClustersRefs);
5d8d9319 110
111 for (Int_t i = 0; i < ncc ; i++) {
112
113 AliESDCaloCluster * cluster = static_cast<AliESDCaloCluster*>(fClustersRefs->At(i));
114 if(TriggerOnEoverP(cluster,esd)) {
115 return iResult;
116 }
117 }
118 }
119
120 // If we got to this point then we did not find any clusters with E > fEThreshold
121 // generate negative trigger decision
122 TString description;
123 description.Form("No %s clusters corresponding to Energy > %.02f GeV and %.02f < E/P < %.02f", fDetector.Data(),fEThreshold,fEoverPThreshold,fEoverPLimit);
124 SetDescription(description.Data());
125 TriggerEvent(false);
126 return iResult;
127
128}
129
130
131template <class T>
132Bool_t AliHLTTriggerEmcalElectron::TriggerOnEoverP(T* cluster,AliESDEvent *esd) {
133
134 if (cluster->E() > fEThreshold) {
135
136 if(!cluster->IsEMCAL()) return kFALSE;
137 //Double_t clusterEnergy=cluster->E();
138 //Int_t nmatched=cluster->GetNTracksMatched();
139 Int_t trackindex=cluster->GetTrackMatchedIndex();
140 if(trackindex<0)return kFALSE;
141 AliESDtrack* track = esd->GetTrack(trackindex);
142 if(!track)return kFALSE;
143 Double_t EoverP=cluster->E()/track->P();
144 if(EoverP<fEoverPThreshold)return kFALSE;
145 if(EoverP>fEoverPLimit)return kFALSE;
146
147 //We have a cluster satisfying trigger criteria
148 TString description;
149 description.Form("Event contains at least one %s cluster with energy greater than %.02f corresponding to %.02f < E/P < %.02f", fDetector.Data(),fEThreshold,fEoverPThreshold,fEoverPLimit);
150 SetDescription(description.Data());
151
152
153 // Enable the detectors for readout.
154
155 //GetReadoutList().Enable(AliHLTReadoutList::kPHOS);
156// SetCaloReadoutList("EMCAL"); //FR
32df6809 157// SetCaloReadoutList(); //FR
5d8d9319 158
159
160
161 // Add the available HLT information for readout too.
162 GetTriggerDomain().Add(kAliHLTAnyDataTypeID, fDetector.Data());
163
164 //Set trigger decision
165 TriggerEvent(kTRUE);
166
167 return kTRUE;
168 }
169
170
171 return kFALSE;
172
173}
174
175int AliHLTTriggerEmcalElectron::DoInit(int argc, const char** argv) {
176 // see header file for class documentation
177
178 // first configure the default
179 int iResult=ConfigureFromCDBTObjString(fOCDBEntry);
180
181 // configure from the command line parameters if specified
182 if (iResult>=0 && argc>0) {
183 iResult=ConfigureFromArgumentString(argc, argv);
184 HLTImportant("Trigger threshold set from argument string: %.02f GeV: E/P:%.02f and %.02f", fEThreshold,fEoverPThreshold,fEoverPLimit);
185 } else if ( iResult >=0 ) {
186 HLTImportant("Trigger threshold set from OCDB database entry: %.02f GeV: E/P:%.02f and %.02f", fEThreshold,fEoverPThreshold,fEoverPLimit);
187 }
188 return iResult;
189}
190
191int AliHLTTriggerEmcalElectron::DoDeinit() {
192
193 // see header file for class documentation
194
195 return 0;
196}
197
198int AliHLTTriggerEmcalElectron::Reconfigure(const char* cdbEntry, const char* /*chainId*/) {
199 // see header file for class documentation
200
201 // configure from the specified antry or the default one
202 const char* entry=cdbEntry;
203 if (!entry || entry[0]==0) entry=fOCDBEntry;
204
205 return ConfigureFromCDBTObjString(entry);
206}
207
208int AliHLTTriggerEmcalElectron::ScanConfigurationArgument(int argc, const char** argv) {
209 // see header file for class documentation
210 if (argc<=0) return 0;
211 int i=2;
212 TString argument=argv[i];
213
214 // -maxpt
215 if (argument.CompareTo("-energy")==0) {
216 if (++i>=argc) return -EPROTO;
217 argument=argv[i];
218 fEThreshold=argument.Atof(); //
219 return 2;
220 }
221
222 if (argument.CompareTo("-minEoverP")==0) {
223 if (++i>=argc) return -EPROTO;
224 argument=argv[i];
225 fEoverPThreshold=argument.Atof(); //
226 return 2;
227 }
228
229 if (argument.CompareTo("-maxEoverP")==0) {
230 if (++i>=argc) return -EPROTO;
231 argument=argv[i];
232 fEoverPLimit=argument.Atof(); //
233 return 2;
234 }
235 // unknown argument
236 return -EINVAL;
237}
238
239void AliHLTTriggerEmcalElectron::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) {
240 // see header file for documentation
241 constBase = sizeof(AliHLTTriggerDecision) + sizeof(AliHLTDomainEntry)*14;
242 inputMultiplier = 1;
243}
244
245
246void AliHLTTriggerEmcalElectron::GetOCDBObjectDescription( TMap* const targetMap) {
247 // Get a list of OCDB object description.
248 if (!targetMap) return;
249 targetMap->Add(new TObjString(fOCDBEntry),
250 new TObjString(Form("%s threshold trigger OCDB object", fDetector.Data()) )
251 );
252}
8ffa7c29 253
254