]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/trigger/AliHLTTriggerMonitoringComponent.cxx
Update of the SSD on-line clusterfinder:
[u/mrichter/AliRoot.git] / HLT / trigger / AliHLTTriggerMonitoringComponent.cxx
1 //-*- Mode: C++ -*-
2 // $Id: AliHLTTriggerMonitoringComponent.cxx 24328 2008-03-06 13:26:00Z richterm $
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: Jochen Thaeder <thaeder@kip.uni-heidelberg.de>        *
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   AliHLTTriggerMonitoringComponent.cxx
20     @author Jochen Thaeder
21     @date   
22     @brief  Produces a event summary as @see AliHLTEventSummary
23 */
24
25 // see header file for class documentation
26 // or
27 // refer to README to build package
28 // or
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt   
30
31 #if __GNUC__ >= 3
32 using namespace std;
33 #endif
34
35 #include "AliHLTTriggerMonitoringComponent.h"
36 #include "AliHLTTPCEventStatistics.h"
37 #include "AliHLTEventStatistics.h"
38 #include <cerrno>
39
40 // ** This is a global object used for automatic component registration, do not use this
41 AliHLTTriggerMonitoringComponent gAliHLTTriggerMonitoringComponent;
42
43 ClassImp(AliHLTTriggerMonitoringComponent)
44
45 /*
46  * ---------------------------------------------------------------------------------
47  *                            Constructor / Destructor
48  * ---------------------------------------------------------------------------------
49  */
50    
51 // ------------------------------------------------------------------------------------------
52 AliHLTTriggerMonitoringComponent::AliHLTTriggerMonitoringComponent() : 
53   fTotalTrackCut(-1),
54   fLongTrackCut(-1),
55   fEventSummary(NULL) {
56   // see header file for class documentation
57   // or
58   // refer to README to build package
59   // or
60   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
61 }
62
63 // ------------------------------------------------------------------------------------------
64 AliHLTTriggerMonitoringComponent::~AliHLTTriggerMonitoringComponent() {
65   // see header file for class documentation
66 }
67
68 /*
69  * ---------------------------------------------------------------------------------
70  * Public functions to implement AliHLTComponent's interface.
71  * These functions are required for the registration process
72  * ---------------------------------------------------------------------------------
73  */
74
75 // ------------------------------------------------------------------------------------------
76 const char* AliHLTTriggerMonitoringComponent::GetComponentID() {
77   // see header file for class documentation
78   return "TriggerMonitoring"; 
79 }
80
81 // ------------------------------------------------------------------------------------------
82 void AliHLTTriggerMonitoringComponent::GetInputDataTypes(AliHLTComponentDataTypeList& list) {
83   // see header file for class documentation
84
85   list.clear(); 
86   list.push_back( kAliHLTDataTypeEventSummary );
87 }
88
89 // ------------------------------------------------------------------------------------------
90 AliHLTComponentDataType AliHLTTriggerMonitoringComponent::GetOutputDataType() {
91   // see header file for class documentation
92
93   return kAliHLTDataTypeEventSummary;
94 }
95
96 // ------------------------------------------------------------------------------------------
97 void AliHLTTriggerMonitoringComponent::GetOutputDataSize( unsigned long& constBase, 
98                                                           double& inputMultiplier ) {
99   // see header file for class documentation
100
101   constBase = sizeof( AliHLTEventSummary );
102   inputMultiplier = 0.0;
103 }
104
105 // ------------------------------------------------------------------------------------------
106 AliHLTComponent* AliHLTTriggerMonitoringComponent::Spawn() {
107   // Spawn function, return new instance of this class
108   // see header file for class documentation
109
110   return new AliHLTTriggerMonitoringComponent;
111 }
112
113
114 // ------------------------------------------------------------------------------------------
115 Int_t AliHLTTriggerMonitoringComponent::DoInit( int argc, const char** argv ) {
116   // see header file for class documentation
117
118   Int_t iResult = 0;
119  
120   // ** Argument handling
121
122   TString argument = "";
123   TString parameter = "";
124   Int_t bMissingParam=0;
125   
126   for ( Int_t ii=0; ii<argc && iResult>=0; ii++ ) {
127   
128     argument = argv[ii];
129
130     if ( argument.IsNull() ) continue;
131
132     // -triggerTotalTracks
133     if ( ! argument.CompareTo("-triggerTotalTracks") ) {
134
135       if ( ( bMissingParam=( ++ii >= argc ) ) ) break;
136       parameter = argv[ii];  
137       parameter.Remove( TString::kLeading, ' ' );
138       
139       if  (parameter.IsDigit() ) {
140         fTotalTrackCut = (Int_t) parameter.Atoi();
141         HLTInfo( "Trigger on total number of tracks is activated, and threshold is set to  %d.", fTotalTrackCut );
142       } 
143       else {
144         HLTError( "Cannot convert triggerTotalTracks specifier '%s'.", parameter.Data() );
145         iResult = -EINVAL;
146         break;
147       }
148       
149     } // if ( ! argument.CompareTo("-triggerTotalTracks") ) {
150
151     // -triggerLongTracks
152     else if ( ! argument.CompareTo("-triggerLongTracks") ) {
153
154       if ( ( bMissingParam=( ++ii >= argc ) ) ) break;
155       parameter = argv[ii];  
156       parameter.Remove( TString::kLeading, ' ' );
157       
158       if  (parameter.IsDigit() ) {
159         fLongTrackCut = (Int_t) parameter.Atoi();
160         HLTInfo( "Trigger on number of long tracks is activated, and threshold is set to  %d.", fTotalTrackCut );
161       } 
162       else {
163         HLTError( "Cannot convert triggerLongTracks specifier '%s'.", parameter.Data() );
164         iResult = -EINVAL;
165         break;
166       }
167     } // if ( ! argument.CompareTo("-triggerLongTracks") ) {
168     // - unknow parameter
169     else {
170       iResult = -EINVAL;
171       HLTError("Unknown argument '%s'", argument.Data() );
172     }
173
174   } // for ( Int_t ii=0; ii<argc && iResult>=0; ii++ ) {
175
176   if ( bMissingParam ) {
177     HLTError( "Missing parameter for argument '%s'.", argument.Data() );
178     iResult = -EPROTO;
179   }
180
181   return iResult;
182 }
183
184 // ------------------------------------------------------------------------------------------
185 Int_t AliHLTTriggerMonitoringComponent::DoDeinit() {
186   // see header file for class documentation
187
188   if ( fEventSummary )
189     delete fEventSummary;
190   fEventSummary = NULL;
191
192   return 0;
193 }
194
195 // ------------------------------------------------------------------------------------------
196 Int_t AliHLTTriggerMonitoringComponent::DoEvent( const AliHLTComponentEventData& /*evtData*/, AliHLTComponentTriggerData& /*trigData*/ ) {
197   // see header file for class documentation
198
199   if(GetFirstInputBlock( kAliHLTDataTypeSOR ) || GetFirstInputBlock( kAliHLTDataTypeEOR ))
200     return 0;
201  
202   const TObject* iter = NULL;
203   iter = GetFirstInputObject(kAliHLTDataTypeEventSummary|kAliHLTDataOriginAny);
204
205   fEventSummary = (AliHLTEventSummary*) iter;
206     
207   // Trigger on eventSummary
208   Trigger();
209   
210   if (fEventSummary->IsAccepted()) {
211     HLTWarning( "Triggered" );
212   } else {
213     HLTWarning( "Discarded" );
214   }
215
216   HLTWarning( "RunNumber %d ", GetRunNo() );
217   
218   // ** PushBack Event Summary
219   PushBack ( (TObject*) fEventSummary, sizeof(AliHLTEventSummary), kAliHLTDataTypeEventSummary, (AliHLTUInt32_t) 0 );
220
221   return 0;
222 }
223
224 // -- **********************************************************************************************
225 // -- *******************************   Processing Functions  **************************************
226 // -- **********************************************************************************************
227
228 // -- **********************************************************************************************
229 void AliHLTTriggerMonitoringComponent::Trigger() {
230   // see header file for class documentation
231   
232   TObjArray* detArray = fEventSummary->GetDetectorArray();
233
234   for ( Int_t iter = 0; iter <= detArray->GetLast(); iter++ ) {
235       
236     AliHLTEventStatistics* evStat = (AliHLTEventStatistics*) (*detArray)[iter];
237     TString detName = evStat->GetDetectorName();
238     
239     if ( detName.CompareTo("TPC") )
240       continue;
241     
242     HLTWarning("TPC statistics found...");
243     
244     AliHLTTPCEventStatistics* tpcStat = (AliHLTTPCEventStatistics*) (*detArray)[iter];
245     
246     if ( fLongTrackCut != -1 && tpcStat->GetNTracksAboveClusterThreshold() < fLongTrackCut ) {
247       fEventSummary->RejectEvent();
248       return;
249     }
250     
251     if ( fTotalTrackCut != -1 && tpcStat->GetNTotalTracks() < fTotalTrackCut ) {
252       fEventSummary->RejectEvent();
253       return;
254     }
255
256   } // for ( Int_t iter = 0; iter <= detArray->GetLast(); iter++ ) {
257
258 }