adding Mimimum Ionizing Particle trigger for PHOS inclduing configuration object...
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTriggerPhosMip.cxx
CommitLineData
f86ecd3e 1// $Id$
2//-*- Mode: C++ -*-
3//**************************************************************************
4//* This file is property of and copyright by the ALICE HLT Project *
5//* ALICE Experiment at CERN, All rights reserved. *
6//* *
7//* Primary Authors: Svein Lindal <svein.lindal@fys.uio.no> *
8//* for The ALICE HLT Project. *
9//* *
10//* Permission to use, copy, modify and distribute this software and its *
11//* documentation strictly for non-commercial purposes is hereby granted *
12//* without fee, provided that the above copyright notice appears in all *
13//* copies and that both the copyright notice and this permission notice *
14//* appear in the supporting documentation. The authors make no claims *
15//* about the suitability of this software for any purpose. It is *
16//* provided "as is" without express or implied warranty. *
17//**************************************************************************
18
19/// @file AliHLTTriggerPhosMip.cxx
20/// @author Svein Lindal
21/// @date 2009-08-19
22/// @brief HLT Minimum Ionizing Particle (MIP) trigger for PHOS
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 "AliHLTTriggerPhosMip.h"
32#include "AliESDEvent.h"
33#include "AliESDCaloCluster.h"
34#include "AliHLTTriggerDecision.h"
35#include "AliHLTDomainEntry.h"
36
37/** ROOT macro for the implementation of ROOT specific class methods */
38ClassImp(AliHLTTriggerPhosMip)
39
40AliHLTTriggerPhosMip::AliHLTTriggerPhosMip()
41 : AliHLTTrigger()
42 , fEMin(0.0)
43 , fEMax(0.0)
44 , fNCellsMax(0)
45{
46 // see header file for class documentation
47 // or
48 // refer to README to build package
49 // or
50 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlts
51}
52
53const char* AliHLTTriggerPhosMip::fgkOCDBEntry="HLT/ConfigHLT/PhosMipTrigger";
54
55AliHLTTriggerPhosMip::~AliHLTTriggerPhosMip()
56{
57 // see header file for class documentation
58}
59
60const char* AliHLTTriggerPhosMip::GetTriggerName() const
61{
62 // see header file for class documentation
63 return "PhosMipTrigger";
64}
65
66AliHLTComponent* AliHLTTriggerPhosMip::Spawn()
67{
68 // see header file for class documentation
69 return new AliHLTTriggerPhosMip;
70}
71
72int AliHLTTriggerPhosMip::DoTrigger()
73{
74 // see header file for class documentation
75
76 TString description;
77
78 const TObject* obj = GetFirstInputObject(kAliHLTAllDataTypes, "AliESDEvent");
79 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(const_cast<TObject*>(obj));
80
81 if (esd != NULL) {
82 esd->GetStdContent();
83
84 //Loop over Calorimeter clusters
85 Int_t ncc = esd->GetNumberOfCaloClusters();
86 for (Int_t i = 0; i < ncc ; i++) {
87 AliESDCaloCluster * cluster = esd->GetCaloCluster(i);
88
89 // Trigger condition: PHOS clusters within energy range, cells < fNCellsMax
90 if ( cluster->IsPHOS() &&
91 cluster->E() > fEMin &&
92 cluster->E() < fEMax &&
93 cluster->GetNCells() <= fNCellsMax ) {
94
95 description.Form("Event contains at least one PHOS cluster satisfying MIP criteria");
96 SetDescription(description.Data());
97
98 // Enable the detectors for readout.
99 GetReadoutList().Enable( AliHLTReadoutList::kPHOS );
100
101 // Add the available HLT information for readout too.
102 GetTriggerDomain().Add(kAliHLTAnyDataTypeID, "PHOS");
103
104 //Set trigger decision
105 TriggerEvent(true);
106
107 return 0;
108 } /// if trigger criteria
109 } /// cluster loop
110 }
111
112 // If we got to this point then we did not find any good MIP candidates
113 // generate negative trigger decision
114 description.Form("No PHOS clusters satisfying MIP criteria found");
115 SetDescription(description.Data());
116 TriggerEvent(false);
117 return 0;
118}
119
120int AliHLTTriggerPhosMip::DoInit(int argc, const char** argv) {
121 // see header file for class documentation
122
123 // first configure the default
124 int iResult=ConfigureFromCDBTObjString(fgkOCDBEntry);
125
126 // configure from the command line parameters if specified
127 if (iResult>=0 && argc>0) {
128 HLTInfo("Trigger configuration from OCDB database entry: emin %.03f GeV \n emax %.03f, \n ncells: %i", fEMin, fEMax, fNCellsMax );
129 iResult=ConfigureFromArgumentString(argc, argv);
130 HLTInfo("Trigger configuration overwritten from command line: emin %.03f GeV \n emax %.03f, \n ncells: %i", fEMin, fEMax, fNCellsMax );
131 } else if ( iResult >=0 ) {
132 HLTInfo("Trigger configuration from OCDB database entry: emin %.03f GeV \n emax %.03f, \n ncells: %i", fEMin, fEMax, fNCellsMax );
133 }
134 return iResult;
135}
136
137int AliHLTTriggerPhosMip::DoDeinit()
138{
139 // see header file for class documentation
140 return 0;
141}
142
143int AliHLTTriggerPhosMip::Reconfigure(const char* cdbEntry, const char* /*chainId*/)
144{
145 // see header file for class documentation
146
147 // configure from the specified antry or the default one
148 const char* entry=cdbEntry;
149 if (!entry || entry[0]==0) entry=fgkOCDBEntry;
150
151 return ConfigureFromCDBTObjString(entry);
152}
153
154int AliHLTTriggerPhosMip::ScanConfigurationArgument(int argc, const char** argv)
155{
156 // see header file for class documentation
157 if (argc<=0) return 0;
158 int i=0;
159 TString argument=argv[i];
160
161 // -mine
162 if (argument.CompareTo("-emin")==0) {
163 if (++i>=argc) return -EPROTO;
164 argument=argv[i];
165 fEMin=argument.Atof();
166 return 2;
167 }
168
169 ///-maxe
170 else if (argument.CompareTo("-emax")==0) {
171 if (++i>=argc) return -EPROTO;
172 argument=argv[i];
173 fEMax=argument.Atof();
174 return 2;
175 }
176
177 ///-ncells
178 else if (argument.CompareTo("-ncells")==0) {
179 if (++i>=argc) return -EPROTO;
180 argument=argv[i];
181 fNCellsMax=argument.Atof();
182 return 2;
183 }
184
185 // unknown argument
186 return -EINVAL;
187}
188
189void AliHLTTriggerPhosMip::GetOutputDataSize(unsigned long& constBase, double& inputMultiplier)
190{
191 // see header file for class documentation
192 constBase = sizeof(AliHLTTriggerDecision) + sizeof(AliHLTDomainEntry)*14;
193 inputMultiplier = 1;
194}