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: Svein Lindal <svein.lindal@gmail.com> *
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 AliHLTTriggerCaloClusterEnergy.cxx
19 /// @author Svein Lindal <slindal@fys.uio.no>
21 /// @brief BASE class for energy threshold trigger for Calorimeters
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
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"
42 /** ROOT macro for the implementation of ROOT specific class methods */
43 ClassImp(AliHLTTriggerCaloClusterEnergy)
45 AliHLTTriggerCaloClusterEnergy::AliHLTTriggerCaloClusterEnergy(TString detector) :
54 // see header file for class documentation
56 // refer to README to build package
58 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlts
60 fClusterReader = new AliHLTCaloClusterReader();
61 fClustersRefs = new TRefArray();
66 AliHLTTriggerCaloClusterEnergy::~AliHLTTriggerCaloClusterEnergy() {
67 // see header file for class documentation
69 delete fClusterReader;
70 fClusterReader = NULL;
77 Int_t AliHLTTriggerCaloClusterEnergy::DoTrigger() {
78 // see header file for class documentation
83 if ( GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ) )
86 //Try the caloclusterstruct input
89 for (const AliHLTComponentBlockData* pBlock=GetFirstInputBlock(fInputDataType); pBlock!=NULL; pBlock=GetNextInputBlock()) {
90 AliHLTCaloClusterHeaderStruct *caloClusterHeader = reinterpret_cast<AliHLTCaloClusterHeaderStruct*>(pBlock->fPtr);
91 fClusterReader->SetMemory(caloClusterHeader);
93 AliHLTCaloClusterDataStruct * caloClusterStruct;
94 while( (caloClusterStruct = fClusterReader->NextCluster()) != 0) {
95 if (TriggerOnCluster(caloClusterStruct)) {
102 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
103 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
106 esd->GetStdContent();
108 Int_t ncc = GetClustersFromEsd(esd, fClustersRefs);
110 for (Int_t i = 0; i < ncc ; i++) {
112 AliESDCaloCluster * cluster = static_cast<AliESDCaloCluster*>(fClustersRefs->At(i));
113 if(TriggerOnCluster(cluster)) {
119 // If we got to this point then we did not find any clusters with E > fEThreshold
120 // generate negative trigger decision
122 description.Form("No %s clusters containing energy > %.02f GeV found.", fDetector.Data(), fEThreshold);
123 SetDescription(description.Data());
131 Bool_t AliHLTTriggerCaloClusterEnergy::TriggerOnCluster(T* cluster) {
133 if (cluster->E() > fEThreshold) {
135 //We have a cluster satisfying trigger criteria
137 description.Form("Event contains at least one %s cluster with energy > %.02f GeV.", fDetector.Data(), fEThreshold);
138 SetDescription(description.Data());
140 // Enable the detectors for readout.
141 GetReadoutList().Enable( AliHLTReadoutList::kPHOS );
143 // Add the available HLT information for readout too.
144 GetTriggerDomain().Add(kAliHLTAnyDataTypeID, fDetector.Data());
146 //Set trigger decision
160 int AliHLTTriggerCaloClusterEnergy::DoInit(int argc, const char** argv) {
161 // see header file for class documentation
163 // first configure the default
164 int iResult=ConfigureFromCDBTObjString(fOCDBEntry);
166 // configure from the command line parameters if specified
167 if (iResult>=0 && argc>0) {
168 iResult=ConfigureFromArgumentString(argc, argv);
169 HLTImportant("Trigger threshold set from argument string: %.02f GeV:", fEThreshold );
170 } else if ( iResult >=0 ) {
171 HLTImportant("Trigger threshold set from OCDB database entry: %.02f GeV:", fEThreshold );
176 int AliHLTTriggerCaloClusterEnergy::DoDeinit() {
178 // see header file for class documentation
183 int AliHLTTriggerCaloClusterEnergy::Reconfigure(const char* cdbEntry, const char* /*chainId*/) {
184 // see header file for class documentation
186 // configure from the specified antry or the default one
187 const char* entry=cdbEntry;
188 if (!entry || entry[0]==0) entry=fOCDBEntry;
190 return ConfigureFromCDBTObjString(entry);
193 int AliHLTTriggerCaloClusterEnergy::ScanConfigurationArgument(int argc, const char** argv) {
194 // see header file for class documentation
195 if (argc<=0) return 0;
197 TString argument=argv[i];
200 if (argument.CompareTo("-energy")==0) {
201 if (++i>=argc) return -EPROTO;
203 fEThreshold=argument.Atof();
211 void AliHLTTriggerCaloClusterEnergy::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier) {
212 // see header file for documentation
213 constBase = sizeof(AliHLTTriggerDecision) + sizeof(AliHLTDomainEntry)*14;
218 void AliHLTTriggerCaloClusterEnergy::GetOCDBObjectDescription( TMap* const targetMap) {
219 // Get a list of OCDB object description.
220 if (!targetMap) return;
221 targetMap->Add(new TObjString(fOCDBEntry),
222 new TObjString(Form("%s threshold trigger OCDB object", fDetector.Data()) )