]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/trigger/AliHLTTriggerCaloClusterEnergy.cxx
Merge branch 'trigger'
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTriggerCaloClusterEnergy.cxx
CommitLineData
739e2587 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: Svein Lindal <svein.lindal@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/// @file AliHLTTriggerCaloClusterEnergy.cxx
19/// @author Svein Lindal <slindal@fys.uio.no>
20/// @date 2009-08-17
21/// @brief BASE class for energy threshold trigger for Calorimeters
22///
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
31#include "AliHLTTriggerCaloClusterEnergy.h"
32#include "AliESDEvent.h"
33#include "AliESDCaloCluster.h"
34#include "AliHLTTriggerDecision.h"
35#include "AliHLTDomainEntry.h"
36#include "AliHLTCaloClusterReader.h"
37#include "AliHLTCaloClusterDataStruct.h"
38#include "TRefArray.h"
39#include "TString.h"
40
41/** ROOT macro for the implementation of ROOT specific class methods */
42ClassImp(AliHLTTriggerCaloClusterEnergy)
43
44AliHLTTriggerCaloClusterEnergy::AliHLTTriggerCaloClusterEnergy(TString detector) :
45 AliHLTTrigger(),
46 fEThreshold(0.0),
47 fClustersRefs(NULL),
48 fDetector(detector),
49 fClusterReader(NULL),
50 fgkOCDBEntry(""),
51 fgkInputDataType()
52{
53 // see header file for class documentation
54 // or
55 // refer to README to build package
56 // or
57 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlts
58
59 fClusterReader = new AliHLTCaloClusterReader();
60 fClustersRefs = new TRefArray();
61
62}
63
64//const char* AliHLTTriggerCaloClusterEnergy::fgkOCDBEntry="HLT/ConfigHLT/CaloClusterEnergyTrigger";
65
66AliHLTTriggerCaloClusterEnergy::~AliHLTTriggerCaloClusterEnergy() {
67 // see header file for class documentation
68}
69
70Int_t AliHLTTriggerCaloClusterEnergy::DoTrigger() {
71 // see header file for class documentation
72
73 Int_t iResult = 0;
74
75
76 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
77 return 0;
78
79 //Try the caloclusterstruct input
80
81
82 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(fgkInputDataType); pBlock!=NULL; pBlock=GetNextInputBlock()) {
83 AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
84 fClusterReader->SetMemory(caloClusterHeader);
85
86 AliHLTCaloClusterDataStruct * caloClusterStruct;
87 while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
88 if (TriggerOnCluster(caloClusterStruct)) {
89 return iResult;
90 }
91 }
92 }
93
94 //Try the ESD input
95 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
96 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
97
98 if (esd != NULL) {
99 esd->GetStdContent();
100
101 Int_t ncc = GetClustersFromEsd(esd, fClustersRefs);
102
103 for (Int_t i = 0; i < ncc ; i++) {
104
105 AliESDCaloCluster * cluster = static_cast<AliESDCaloCluster*>(fClustersRefs->At(i));
106 if(TriggerOnCluster(cluster)) {
107 return iResult;
108 }
109 }
110 }
111
112 // If we got to this point then we did not find any clusters with E > fEThreshold
113 // generate negative trigger decision
114 TString description;
115 description.Form("No %s clusters containing energy > %.02f GeV found.", fDetector.Data(), fEThreshold);
116 SetDescription(description.Data());
117 TriggerEvent(false);
118 return iResult;
119
120}
121
122
123template <class T>
124Bool_t AliHLTTriggerCaloClusterEnergy::TriggerOnCluster(T* cluster) {
125
126 if (cluster->E() > fEThreshold) {
127
128 //We have a cluster satisfying trigger criteria
129 TString description;
130 description.Form("Event contains at least one %s cluster with energy > %.02f GeV.", fDetector.Data(), fEThreshold);
131 SetDescription(description.Data());
132
133 // Enable the detectors for readout.
134 GetReadoutList().Enable( AliHLTReadoutList::kPHOS );
135
136 // Add the available HLT information for readout too.
137 GetTriggerDomain().Add(kAliHLTAnyDataTypeID, fDetector.Data());
138
139 //Set trigger decision
140 TriggerEvent(kTRUE);
141
142 return kTRUE;
143 }
144
145
146 return kFALSE;
147
148}
149
150
151
152
153int AliHLTTriggerCaloClusterEnergy::DoInit(int argc, const char** argv) {
154 // see header file for class documentation
155
156 // first configure the default
157 int iResult=ConfigureFromCDBTObjString(fgkOCDBEntry);
158
159 // configure from the command line parameters if specified
160 if (iResult>=0 && argc>0) {
161 iResult=ConfigureFromArgumentString(argc, argv);
162 HLTImportant("Trigger threshold set from argument string: %.02f GeV:", fEThreshold );
163 } else if ( iResult >=0 ) {
164 HLTImportant("Trigger threshold set from OCDB database entry: %.02f GeV:", fEThreshold );
165 }
166 return iResult;
167}
168
169int AliHLTTriggerCaloClusterEnergy::DoDeinit() {
170 // see header file for class documentation
171 return 0;
172}
173
174int AliHLTTriggerCaloClusterEnergy::Reconfigure(const char* cdbEntry, const char* /*chainId*/) {
175 // see header file for class documentation
176
177 // configure from the specified antry or the default one
178 const char* entry=cdbEntry;
179 if (!entry || entry[0]==0) entry=fgkOCDBEntry;
180
181 return ConfigureFromCDBTObjString(entry);
182}
183
184int AliHLTTriggerCaloClusterEnergy::ScanConfigurationArgument(int argc, const char** argv) {
185 // see header file for class documentation
186 if (argc<=0) return 0;
187 int i=0;
188 TString argument=argv[i];
189
190 // -maxpt
191 if (argument.CompareTo("-energy")==0) {
192 if (++i>=argc) return -EPROTO;
193 argument=argv[i];
194 fEThreshold=argument.Atof();
195 return 2;
196 }
197
198 // unknown argument
199 return -EINVAL;
200}
201
202void AliHLTTriggerCaloClusterEnergy::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) {
203 // see header file for class documentation
204 constBase = sizeof(AliHLTTriggerDecision) + sizeof(AliHLTDomainEntry)*14;
205 inputMultiplier = 1;
206}