StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TCU.cc
1 //
2 // Pibero Djawotho <pibero@comp.tamu.edu>
3 // Texas A&M University Cyclotron Institute
4 // 7 Jan 2009
5 //
6 
7 #include "TriggerDefinition.hh"
8 #include "TCU.hh"
9 
10 #include<iostream> //A
11 using std::cout; //A
12 
13 //void TCU::defineTrigger(const TriggerDefinition& triggerDef)
14 void TCU::defineTrigger(TriggerDefinition& triggerDef)
15 {
16  mTriggers.insert(make_pair(triggerDef.triggerId, triggerDef));
17 }
18 
19 bool TCU::isOnBits(int onbits) const
20 {
21 // std::cout<<"Input: "<<hex<<mInput<<" Onbits: "<<hex<<onbits<<"\n";
22  if(onbits != 0){
23  return (mInput & onbits) == onbits;
24  }
25  return 0;
26 }
27 
28 bool TCU::isTrigger(int triggerId) const
29 {
30  typedef multimap<int, TriggerDefinition>::const_iterator MI;
31  pair<MI, MI> p = mTriggers.equal_range(triggerId);
32  //cout << "Danny was HERE" << endl;
33  for (MI i = p.first; i != p.second; ++i)
34  //include onbits1 comparision for run11 and run12
35  {
36 
37  if (i->second.onbits&&isOnBits(i->second.onbits)) {
38 // std::cout<<"TriggerID: "<<dec<<triggerId<<" Onbits: "<<hex<<i->second.onbits<<"\n";
39  return true;
40  }
41  /*
42  if(i->second.onbits1&&isOnBits(i->second.onbits1)){
43  std::cout<<"TriggerID: "<<dec<<triggerId<<" Onbits: "<<hex<<i->second.onbits1<<"\n";
44  return true;
45  }
46  */
47  }
48  return false;
49 }
50 
51 set<int> TCU::triggerIds() const
52 {
53  set<int> s;
54  for (multimap<int, TriggerDefinition>::const_iterator i = mTriggers.begin(); i != mTriggers.end(); ++i)
55  if (isTrigger(i->first)) s.insert(i->first);
56  return s;
57 }