ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/grimes/L1Menu/src/TriggerMenu.cpp
(Generate patch)

Comparing UserCode/grimes/L1Menu/src/TriggerMenu.cpp (file contents):
Revision 1.5 by grimes, Tue Jun 18 10:18:23 2013 UTC vs.
Revision 1.10 by grimes, Sat Jun 29 16:14:45 2013 UTC

# Line 5 | Line 5
5   #include <sstream>
6   #include <iostream>
7   #include "l1menu/ITrigger.h"
8 + #include "l1menu/tools/tools.h"
9  
10   namespace // Use the unnamed namespace for things only used in this file
11   {
# Line 49 | Line 50 | namespace // Use the unnamed namespace f
50          return returnValue;
51      }
52  
52    /** @brief Converts a value in absolute eta to the calorimeter region. */
53    float convertEtaCutToRegionCut( float etaCut )
54    {
55        return 0;
56    }
57
58    /** @brief Converts a value in calorimeter region to absolute eta. */
59    float convertRegionCutToEtaCut( float regionCut )
60    {
61        return 0;
62    }
53   } // end of the unnamed namespace
54  
55  
# Line 149 | Line 139 | l1menu::ITrigger& l1menu::TriggerMenu::a
139          return *triggers_.back();
140   }
141  
142 + l1menu::ITrigger& l1menu::TriggerMenu::addTrigger( const l1menu::ITrigger& triggerToCopy )
143 + {
144 +        std::unique_ptr<l1menu::ITrigger> pNewTrigger=triggerTable_.copyTrigger( triggerToCopy );
145 +        if( pNewTrigger.get()==NULL ) throw std::range_error( "Trigger requested that does not exist" );
146 +
147 +        triggers_.push_back( std::move(pNewTrigger) );
148 +
149 +        // Make sure triggerResults_ is always the same size as triggers_
150 +        triggerResults_.resize( triggers_.size() );
151 +        return *triggers_.back();
152 + }
153 +
154   size_t l1menu::TriggerMenu::numberOfTriggers() const
155   {
156          return triggers_.size();
# Line 175 | Line 177 | std::unique_ptr<l1menu::ITrigger> l1menu
177          return triggerTable_.copyTrigger(*triggers_[position]);
178   }
179  
180 < bool l1menu::TriggerMenu::apply( const l1menu::IEvent& event ) const
180 > bool l1menu::TriggerMenu::apply( const l1menu::L1TriggerDPGEvent& event ) const
181   {
182          bool atLeastOneTriggerHasFired=false;
183  
# Line 225 | Line 227 | void l1menu::TriggerMenu::loadMenuInOldF
227                                          //std::cout << "Added trigger \"" << tableColumns[0] << "\"" << std::endl;
228                                          l1menu::ITrigger& newTrigger=addTrigger( triggerName ); // Try and create a trigger with the name supplied
229  
230 <                                        // Try and set all of the relevant parameters. I know not all triggers have these parameters
231 <                                        // so wrap in individual try/catch blocks.
232 <                                        try{ newTrigger.parameter("threshold1")=::convertStringToFloat( tableColumns[3] ); }
233 <                                        catch( std::exception& error ) { } // Do nothing, just try and convert the other parameters
234 <
235 <                                        try{ newTrigger.parameter("threshold2")=::convertStringToFloat( tableColumns[4] ); }
236 <                                        catch( std::exception& error ) { } // Do nothing, just try and convert the other parameters
237 <
236 <                                        try{ newTrigger.parameter("threshold3")=::convertStringToFloat( tableColumns[5] ); }
237 <                                        catch( std::exception& error ) { } // Do nothing, just try and convert the other parameters
238 <
239 <                                        try{ newTrigger.parameter("threshold4")=::convertStringToFloat( tableColumns[6] ); }
240 <                                        catch( std::exception& error ) { } // Do nothing, just try and convert the other parameters
230 >                                        // Different triggers will have different numbers of thresholds, and even different names. E.g. Single triggers
231 >                                        // will have "threshold1" whereas a cross trigger will have "leg1threshold1", "leg2threshold1" etcetera. This
232 >                                        // utility function will get the threshold names in the correct order.
233 >                                        const auto& thresholdNames=l1menu::tools::getThresholdNames(newTrigger);
234 >                                        if( thresholdNames.size()>=1 ) newTrigger.parameter(thresholdNames[0])=::convertStringToFloat( tableColumns[3] );
235 >                                        if( thresholdNames.size()>=2 ) newTrigger.parameter(thresholdNames[1])=::convertStringToFloat( tableColumns[4] );
236 >                                        if( thresholdNames.size()>=3 ) newTrigger.parameter(thresholdNames[2])=::convertStringToFloat( tableColumns[5] );
237 >                                        if( thresholdNames.size()>=4 ) newTrigger.parameter(thresholdNames[3])=::convertStringToFloat( tableColumns[6] );
238  
239                                          float etaOrRegionCut=::convertStringToFloat( tableColumns[7] );
240                                          // For most triggers, I can just try and set both the etaCut and regionCut parameters
# Line 247 | Line 244 | void l1menu::TriggerMenu::loadMenuInOldF
244                                          // value to be the regionCut, except for L1_SingleMu_CJet which expects it as the etaCut.
245                                          if( triggerName=="L1_SingleMu_CJet" )
246                                          {
247 <                                                newTrigger.parameter("etaCut")=etaOrRegionCut;
248 <                                                newTrigger.parameter("regionCut")=convertEtaCutToRegionCut( etaOrRegionCut );
247 >                                                newTrigger.parameter("leg1etaCut")=etaOrRegionCut;
248 >                                                newTrigger.parameter("leg2regionCut")=l1menu::tools::convertEtaCutToRegionCut( etaOrRegionCut );
249 >                                        }
250 >                                        else if( triggerName=="L1_isoMu_EG" )
251 >                                        {
252 >                                                newTrigger.parameter("leg1etaCut")=l1menu::tools::convertRegionCutToEtaCut( etaOrRegionCut );
253 >                                                newTrigger.parameter("leg2regionCut")=etaOrRegionCut;
254                                          }
255 <                                        else if( triggerName=="L1_SingleIsoEG_CJet" )
255 >                                        else if( triggerName=="L1_isoEG_Mu" )
256                                          {
257 <                                                newTrigger.parameter("etaCut")=etaOrRegionCut;
258 <                                                newTrigger.parameter("regionCut")=convertEtaCutToRegionCut( etaOrRegionCut );
257 >                                                newTrigger.parameter("leg1regionCut")=etaOrRegionCut;
258 >                                                newTrigger.parameter("leg2etaCut")=l1menu::tools::convertRegionCutToEtaCut( etaOrRegionCut );
259 >                                        }
260 >                                        else if( triggerName=="L1_isoMu_Tau" )
261 >                                        {
262 >                                                newTrigger.parameter("leg1etaCut")=l1menu::tools::convertRegionCutToEtaCut( etaOrRegionCut );
263 >                                                newTrigger.parameter("leg2regionCut")=etaOrRegionCut;
264                                          }
265                                          else
266                                          {
267                                                  // Any remaining triggers should only have one of these parameters and won't
268                                                  // need conversion. I'll just try and set them both, not a problem if one fails.
269 +                                                // The cross triggers will have e.g. "leg1" prefixed to the parameter name so I'll
270 +                                                // also try for those.
271                                                  try{ newTrigger.parameter("etaCut")=etaOrRegionCut; }
272                                                  catch( std::exception& error ) { } // Do nothing, just try and convert the other parameters
273  
274                                                  try{ newTrigger.parameter("regionCut")=etaOrRegionCut; }
275                                                  catch( std::exception& error ) { } // Do nothing, just try and convert the other parameters
276 +
277 +                                                try{ newTrigger.parameter("leg1etaCut")=etaOrRegionCut; }
278 +                                                catch( std::exception& error ) { } // Do nothing, just try and convert the other parameters
279 +
280 +                                                try{ newTrigger.parameter("leg1regionCut")=etaOrRegionCut; }
281 +                                                catch( std::exception& error ) { } // Do nothing, just try and convert the other parameters
282 +
283 +                                                try{ newTrigger.parameter("leg2etaCut")=etaOrRegionCut; }
284 +                                                catch( std::exception& error ) { } // Do nothing, just try and convert the other parameters
285 +
286 +                                                try{ newTrigger.parameter("leg2regionCut")=etaOrRegionCut; }
287 +                                                catch( std::exception& error ) { } // Do nothing, just try and convert the other parameters
288                                          }
289  
290 +                                        // The trigger may or may not have a muon quality cut. I also don't know if its name
291 +                                        // is prefixed with e.g. "leg1". I'll try setting all combinations, but wrap individually
292 +                                        // in a try block so that it doesn't matter if it fails.
293                                          try{ newTrigger.parameter("muonQuality")=::convertStringToFloat( tableColumns[8] ); }
294                                          catch( std::exception& error ) { } // Do nothing, just try and convert the other parameters
295  
296 <                                } // end of "if able to add trigger"
296 >                                        try{ newTrigger.parameter("leg1muonQuality")=::convertStringToFloat( tableColumns[8] ); }
297 >                                        catch( std::exception& error ) { } // Do nothing, just try and convert the other parameters
298 >
299 >                                        try{ newTrigger.parameter("leg2muonQuality")=::convertStringToFloat( tableColumns[8] ); }
300 >                                        catch( std::exception& error ) { } // Do nothing, just try and convert the other parameters
301 >
302 >                                } // end of try block
303                                  catch( std::exception& error )
304                                  {
305                                          std::cerr << "Unable to add trigger \"" << tableColumns[0] << "\" because: " << error.what() << std::endl;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines