Project

General

Profile

Trigger Filter Instructions

A trigger filter permits selection of triggers for analysis based on whether or not their trigger inputs satisfy a user-provided filter pattern. Currently (August 25th), this is located in the LArIATFilterModules directory of LArIATSoft.

How To Use TriggerFilterModule

Below is an example .fcl file for doing some beamline reconstruction with trigger pattern filtering applied first:


#include "lariat_reco_algs.fcl" 
#include "lariatbeamlinereco.fcl" 
#include "services_lariat.fcl" 
#include "lariatfiltermodules.fcl" 

process_name: LArIATFullReco

services:
{
  # Load the service that manages root files for histograms.
  TFileService: { fileName: "reco_hist.root" }
  Timing:       {}
  RandomNumberGenerator: {} #ART native random number generator
  message:      @local::standard_info
  user:         @local::lariat_services
}

#source is now a root file
source:
{
  module_type: RootInput
  maxEvents:  -1        # Number of events to create
}

# Define and configure some modules to do work on each event.
# First modules are defined; they are scheduled later.
# Modules are grouped by type.
physics:
{

 producers:
 {
  wctrack:     @local::lariat_wctrackbuilder
  tof:         @local::lariat_tof
  murs:        @local::lariat_murs
  agcounter:   @local::lariat_aerogel
 }

 analyzers:
 {
 }

 filters:
 {
   trigpattern: @local::lariat_triggerpattern
 }

 #define the producer and filter modules for this path, order matters,
 #filters reject all following items.  see lines starting physics.producers below
 reco: [ trigpattern, wctrack, tof, murs, agcounter ]
 ana:  [  ]

 #define the output stream, there could be more than one if using filters
 stream1:  [ out1 ]

 #trigger_paths is a keyword and contains the paths that modify the art::event,
 #ie filters and producers
 trigger_paths: [reco]

 #end_paths is a keyword and contains the paths that do not modify the art::Event,
 #ie analyzers and output streams.  these all run simultaneously
 end_paths:     [ ana, stream1]
}

#block to define where the output goes.  if you defined a filter in the physics
#block and put it in the trigger_paths then you need to put a SelectEvents: {SelectEvents: [XXX]}
#entry in the output stream you want those to go to, where XXX is the label of the filter module(s)
outputs:
{
 out1:
 {
   SelectEvents:
   {
     SelectEvents: [ reco ]
   }
   module_type: RootOutput
   fileName:      "reconstructed_beamline.root" 
 }
}

physics.filters.trigpattern.TriggerPattern: "<+BEAMON-PILEUP><+COSMICON+COSMIC><+WC2>" 
physics.filters.trigpattern.TriggerFilterAlg.Verbosity: true

The segments of interest to you, dear filterer, are:
  • The "filters" sub-block in the physics block: this defines the trigger pattern filter module, and looks in the included file "lariatfiltermodules.fcl" to do so.
  • The "SelectEvents" sub-block in the outputs: this makes sure that your filtering actually eliminates the events you don't care about from the event record. If you don't include this block, you won't run the beamline reconstruction modules (or your own modules following the filter module) on the undesirable events, but they will still exist in the event record.
  • The "TriggerPattern" parameter in the second-to-last line is how you choose what trigger patterns you want. The syntax is as follows.
    • An input with a "+" in front (like "+BEAMON") means it's a trigger. An input with a "-" means it's a veto.
    • Enclose inputs with which you want to make a logical AND inside angle brackets "<" and ">". Even if it's just a single input, use the angle brackets.
    • The filter module will return the logical OR between all angle-bracketed groups of inputs.
  • Lastly, if you want to debug, Verbosity can be toggled on.

In this module's case, the filter first finds the AND of BEAMON and no PILEUP, an AND of COSMICON and COSMIC, and whether there is a WC2 trigger bit set. If any of them is true, it returns true.

!!!!! EVERYTHING BELOW IS SUPER DEPRECATED!!!! USE THE ABOVE MODULE! IT'S EASIER!

The trigger filter is currently (July 17th) an algorithm located in the LArIATRecoAlg directory of LArIATSoft.

How To Use TriggerFilterAlg
Two steps are necessary to use the TriggerFilterAlg within an analysis module:-
  • Call the loadXMLDatabaseTable function within the module's beginRun() method, as below (fTrigFiltAlg is the algorithm, instantiated as any other):
    void lrm::MyAnalysisMod::beginRun(art::Run & r)
    {
    fTrigFiltAlg.loadXMLDatabaseTable( r.run() );
    }
    

    Since different runs can have different devices associated with the same trigger input, this call is used to specify the run number and load the trigger input information from the XML database table corresponding to that run.
  • Call the doesTriggerPassFilter function when you need to determine if a trigger satisfies a filter pattern:
    .
    .
    .
    std::string myFilterPattern = "+USTOF+DSTOF+WC1-HALO" 
    bool filterPassed = fTrigFiltAlg.doesTriggerPassFilter( theTrigger, myFilterPattern );
    .
    .
    .
    

    Here, theTrigger is a raw::Trigger object. The doesTriggerPassFilter function returns false if any of the filter pattern's criteria is not met by the trigger, and true otherwise. The filter pattern must be written such that a "+" before a word indicates a trigger, and a "-" indicates a veto. Do not include spaces in the filter pattern. If there is a word in the trigger pattern that is not present in the current run's trigger inputs, the filter defaults to false (for now).

Troubleshooting
Here are some fixes to common errors regarding this triggerfilter:

  • Error message:
    cet::exception caught in art
    ---- ServiceNotFound BEGIN
      Service  unable to find requested service with compiler type name 'util::DatabaseUtilityT1034'.
    ---- ServiceNotFound END
    

    Solution: make sure you have the following line in the services block of your fhicl file:
     
    user: @local::lariat_simulation_services
    

    and make sure you also have in your fhicl file:
    #include "lariat_reco_algs.fcl" 
    #include "databaseutility_lariat.fcl" 
    
  • Error message: something along the lines of
    %MSG
    %MSG-i DatabaseUtil:  PostSourceRun 22-Jul-2015 14:33:39 CDT run: 6111
    Not connecting to DB by choice. 
    
    %MSG
    beginning run...
    Attempting to connect to database...
    Connection to database failed: fe_sendauth: no password supplied
    
    Attempting to reconnect to database... attempt number 1
    Connection to database failed: fe_sendauth: no password supplied
    
    Attempting to reconnect to database... attempt number 2
    Connection to database failed: fe_sendauth: no password supplied
    
    Attempting to reconnect to database... attempt number 3
    Connection to database failed: fe_sendauth: no password supplied
    
    %MSG-e DatabaseUtilityT1034:  test2:test2@BeginRun 22-Jul-2015 14:34:09 CDT  run: 6111
    Too many attempts made to connect to the database... Aborting.
    

    Solution: the password is located in a file that should be included in the FW_SEARCH_PATH environmental variable. If this error is appearing, it probably means that your FW_SEARCH_PATH variable does not include the directory where the password file is located. Execute the following to add it manually:
     export FW_SEARCH_PATH=/lariat/data:$FW_SEARCH_PATH