StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTriggerFilterMaker.cxx
1 // $Id: StTriggerFilterMaker.cxx,v 1.3 2021/04/19 18:49:54 akio Exp $
2 
3 #include "StTriggerFilterMaker.h"
4 #include "StMuDSTMaker/COMMON/StMuDst.h"
5 #include "StMuDSTMaker/COMMON/StMuEvent.h"
6 #include "StRoot/StEvent/StEvent.h"
7 #include "StRoot/StEvent/StTriggerData.h"
8 #include <functional>
9 
10 ClassImp(StTriggerFilterMaker)
11 
12 StTriggerFilterMaker::StTriggerFilterMaker(const char *name) : StMaker(name), mPrint(0) { }
13 
14 StTriggerFilterMaker::~StTriggerFilterMaker() {
15  mGoodTriggers.clear();
16  mVetoTriggers.clear();
17 }
18 
19 Int_t StTriggerFilterMaker::Init() {
20  // this allows us to skip an event for other Makers
21  SetAttr(".Privilege",1);
22  return kStOk;
23 }
24 
26  StEvent* event= (StEvent*)GetInputDS("StEvent");
27  vector<unsigned int> triggerIds;
28  std::function<bool(unsigned int)> isTrigger;
29  const StTriggerData* trgdata;
30  if(event){
31  StTriggerIdCollection* trgIdColl = event->triggerIdCollection();
32  triggerIds = trgIdColl->nominal()->triggerIds();
33  isTrigger = std::bind(&StTriggerId::isTrigger, trgIdColl->nominal(), std::placeholders::_1);
34  trgdata = event->triggerData();
35 
36  }else if(StMuDst::event()){
37  StMuTriggerIdCollection& trgIdColl = StMuDst::event()->triggerIdCollection();
38  triggerIds = trgIdColl.nominal().triggerIds();
39  isTrigger = std::bind(&StTriggerId::isTrigger, &trgIdColl.nominal(), std::placeholders::_1);
40  trgdata = StMuDst::event()->triggerData();
41  }else{
42  LOG_INFO << "No StEvent nor Mudst" << endm;
43  return kStSkip;
44  }
45  if(mPrint){
46  LOG_INFO << "Offline Trigger Id = ";
47  for(unsigned int id : triggerIds) LOG_INFO << id << " ";
48  LOG_INFO << endm;
49  }
50  if(mTofUpperLimit>0){
51  if(!trgdata){
52  LOG_INFO << "No TriggerData found but needed for TOF cut" << endm;
53  return kStSkip;
54  }
55  unsigned int tof = trgdata->tofMultiplicity();
56  if(tof >= mTofUpperLimit){
57  LOG_INFO << Form(" Rejected with TOFmult uppter limit TOFM=%d < UpperLimit=%d",
58  tof,mTofUpperLimit) << endm;
59  return kStSkip;
60  }
61  }
62  for(unsigned int id_veto : mVetoTriggers) {
63  if(isTrigger(id_veto)){
64  if(mPrint) LOG_INFO << " Vetoed by id= " << id_veto << endm;
65  return kStSkip;
66  }
67  }
68  for(unsigned int id_good : mGoodTriggers){
69  if(isTrigger(id_good)){
70  if (mPrint) LOG_INFO << " Accepted with id=" << id_good << endm;
71  return kStOk;
72  }
73  }
74  if(mPrint) LOG_INFO << "Skip (no good triggerId)" << endm;
75  return kStSkip;
76 }
77 
78 /*****************************************************************************
79  * $Log: StTriggerFilterMaker.cxx,v $
80  * Revision 1.3 2021/04/19 18:49:54 akio
81  * Getting info from StEvent as well when not reading from Mudst file
82  *
83  * Revision 1.2 2015/09/09 20:29:39 akio
84  * Adding Vetoing TriggerId
85  * Also adding printing if option is set
86  *
87  * Revision 1.1 2008/01/23 04:45:07 kocolosk
88  * Privileged Maker which skips events unless they fired any one of a set of supplied trigIDs
89  *
90  *****************************************************************************/
Definition: tof.h:15
Collection of trigger ids as stored in StEvent.
Definition: Stypes.h:49
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
Collection of trigger ids as stored in MuDst.
Definition: Stypes.h:41