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