StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StBfcTriggerFilterMaker.cxx
1 //
2 // Pibero Djawotho <pibero@tamu.edu>
3 // Texas A&M University
4 // 10 Dec 2009
5 //
6 
7 // C++ STL
8 #include <sstream>
9 
10 // STAR
11 #include "StTriggerUtilities/StTriggerSimuMaker.h"
12 #include "StTriggerUtilities/Emc/StEmcTriggerSimu.h"
13 #include "StTriggerUtilities/Bemc/StBemcTriggerSimu.h"
14 #include "StTriggerUtilities/Eemc/StEemcTriggerSimu.h"
15 #include "StEmcTriggerMaker/StEmcTriggerMaker.h"
16 
17 // Local
18 #include "StBfcTriggerFilterMaker.h"
19 
20 ClassImp(StBfcTriggerFilterMaker);
21 
22 int StBfcTriggerFilterMaker::Init()
23 {
24  // Allow maker to abort events
25  SetAttr(".Privilege",1);
26 
27  // Print mask
28  LOG_INFO << Form("MASK: BHT0=%d BHT1=%d BHT2=%d BHT3=%d EHT0=%d EHT1=%d JP1=%d JP2=%d BJP1=%d BJP2=%d EJP1=%d EJP2=%d AJP=%d BAJP=%d EAJP=%d JP0=%d",
29  mMask.test(0),
30  mMask.test(1),
31  mMask.test(2),
32  mMask.test(3),
33  mMask.test(4),
34  mMask.test(5),
35  mMask.test(6),
36  mMask.test(7),
37  mMask.test(8),
38  mMask.test(9),
39  mMask.test(10),
40  mMask.test(11),
41  mMask.test(12),
42  mMask.test(13),
43  mMask.test(14),
44  mMask.test(15)) << endm;
45 
46  // Print triggers (year < 2009)
47  ostringstream os;
48  copy(mTriggers.begin(),mTriggers.end(),ostream_iterator<int>(os," "));
49  LOG_INFO << "Triggers: " << os.str() << endm;
50 
51  return kStOk;
52 }
53 
54 // Print format: trigger ID (trigger decision)
55 // where trigger decision is 1=yes, 0=no, -1=unknown
56 struct PrintTrigger {
57  ostream& out;
58  StEmcTriggerMaker* emcTrig;
59 
60  PrintTrigger(ostream& out, StEmcTriggerMaker* emcTrig) : out(out), emcTrig(emcTrig) {}
61 
62  ostream& operator()(int trigId) const { return out << trigId << "(" << emcTrig->isTrigger(trigId) << ") "; }
63 };
64 
66 {
67  if (mOkAllEvents ) return kStOk ;
68  if (mSkipAllEvents) return kStSkip;
69 
70  const TDatime& datime = GetDBTime();
71 
72  LOG_INFO << "DB Time = " << datime.AsSQLString() << endm;
73 
74  if (datime.GetYear() < 2009) {
75  StEmcTriggerMaker* emcTrig = (StEmcTriggerMaker*)GetMakerInheritsFrom("StEmcTriggerMaker");
76  if (!emcTrig) {
77  LOG_ERROR << "Missing StEmcTriggerMaker" << endm;
78  return kStErr;
79  }
80 
81  // Print trigger ID and decision for each trigger
82  ostringstream os;
83  for_each(mTriggers.begin(),mTriggers.end(),PrintTrigger(os,emcTrig));
84  LOG_INFO << "Triggers: " << os.str() << endm;
85 
86  // If at least one trigger fired (trigger decision == 1), process event. Otherwise, skip.
87  return os.str().find("(1)") != string::npos ? kStOk : kStSkip;
88  }
89 
90  // Get trigger simulator
91  StTriggerSimuMaker* trgsim = (StTriggerSimuMaker*)GetMakerInheritsFrom("StTriggerSimuMaker");
92  if (!trgsim) {
93  LOG_ERROR << "Missing StTriggerSimuMaker" << endm;
94  return kStErr;
95  }
96 
97  // Get output of EMC L2 DSM
98  bitset<16> emc(trgsim->emc->EM201output());
99 
100  // Mask out any uninteresting bits
101  emc &= mMask;
102 
103  // If any of the interesting bits are on, accept, else reject
104  return emc.any() ? kStOk : kStSkip;
105 }
106 
107 void StBfcTriggerFilterMaker::changeJPThresh(int dsm)
108 {
109  StTriggerSimuMaker* trgsim = (StTriggerSimuMaker*)GetMakerInheritsFrom("StTriggerSimuMaker");
110  trgsim->changeJPThresh(dsm);
111 }
Definition: Stypes.h:49
Definition: Stypes.h:44
int isTrigger(int trigId)
1==Yes,0==No,-1==Don&#39;t Know. Same convention holds for other methods where appropriate.
Definition: Stypes.h:41