StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StTriggerSimuResult.cxx
1 // $Id: StTriggerSimuResult.cxx,v 1.9 2016/03/18 22:49:38 zchang Exp $
2 
3 #include <utility>
4 using std::make_pair;
5 
6 #include "StMessMgr.h"
7 #include "StTriggerSimuResult.h"
8 
9 #include "StDaqLib/TRG/trgStructures2005.h"
10 #include "StDaqLib/TRG/trgStructures2009.h"
11 
12 #ifndef L2RESULTS_2009_OFFSET_DIJET_HIGH
13 #define L2RESULTS_2009_OFFSET_DIJET_HIGH 25
14 #endif // L2RESULTS_2009_OFFSET_DIJET_HIGH
15 
16 #include "L2Emulator/L2pedAlgo/L2pedResults2006.h"
17 #include "L2Emulator/L2jetAlgo/L2jetResults2006.h"
18 #include "L2Emulator/L2gammaAlgo/L2gammaResult2006.h"
19 #include "L2Emulator/L2upsilon/L2upsilonResult2006.h"
20 #include <cstring>
21 
22 //ClassImp(HttpResult)
23 ClassImp(StTriggerSimuResult)
24 
25 StTriggerSimuResult::StTriggerSimuResult() : TObject(), mBbcDecision(kDoNotCare),
26  mBemcDecision(kDoNotCare), mEemcDecision(kDoNotCare), mL2Decision(kDoNotCare) { }
27 
28 int StTriggerSimuResult::highTowerAdc(short towerId) const {
29  for(unsigned i=0; i<mHighTowerIds.size(); i++) {
30  if(mHighTowerIds[i] == towerId) return mHighTowerAdcs[i];
31  }
32  return -1;
33 }
34 
35 int StTriggerSimuResult::triggerPatchAdc(short patchId) const {
36  for(unsigned i=0; i<mTriggerPatchIds.size(); i++) {
37  if(mTriggerPatchIds[i] == patchId) return mTriggerPatchAdcs[i];
38  }
39  return -1;
40 }
41 
42 
43 int StTriggerSimuResult::jetPatchAdc(short jetPatchId) const {
44  for(unsigned i=0; i<mJetPatchIds.size(); i++) {
45  if(mJetPatchIds[i] == jetPatchId) return mJetPatchAdcs[i];
46  }
47  return -1;
48 }
49 
51  HttpResult result;
52  result.towerId = -1;
53  result.towerAdc = -1;
54  result.triggerPatchId = -1;
55  result.triggerPatchAdc = -1;
56  for(unsigned i=0; i<mHighTowerIds.size(); i++) {
57  if(mHighTowerIds[i] == towerId) {
58  result.towerId = towerId;
59  result.towerAdc = mHighTowerAdcs[i];
60  if(i<mTriggerPatchAdcs.size()) {
61  result.triggerPatchId = mTriggerPatchIds[i];
62  result.triggerPatchAdc = mTriggerPatchAdcs[i];
63  }
64  else {
65  LOG_WARN << "No matching TP is available for " << towerId << endm;
66  }
67  }
68  }
69  return result;
70 }
71 
72 const unsigned int* StTriggerSimuResult::l2Result(L2ResultType algo, int year) const {
73  switch(algo) {
74  case kPed:
75  if(year==2006) return mL2Result + L2RESULTS_OFFSET_EMC_PED;
76  if(year==2009) return mL2Result + L2RESULTS_2009_OFFSET_EMC_PED;
77  break;
78  case kJet:
79  if(year==2006) return mL2Result + L2RESULTS_OFFSET_DIJET;
80  if(year==2009) return mL2Result + L2RESULTS_2009_OFFSET_DIJET_HIGH;
81  break;
82  case kGammaBemc:
83  if(year==2006) return mL2Result + L2RESULTS_OFFSET_PIG;
84  if(year==2009) return mL2Result + L2RESULTS_2009_OFFSET_BGAMMA;
85  break;
86  case kGammaEemc:
87  if(year==2006) return mL2Result + L2RESULTS_OFFSET_PIG + 2;
88  if(year==2009) return mL2Result + L2RESULTS_2009_OFFSET_EGAMMA;
89  break;
90  case kUpsilon:
91  if(year==2006) return mL2Result + L2RESULTS_OFFSET_UPS;
92  if(year==2009) return mL2Result + L2RESULTS_2009_OFFSET_UPSILON;
93  break;
94  }
95  return 0;
96 }
97 
98 const unsigned int* StTriggerSimuResult::l2Result() const {
99  return mL2Result;
100 }
101 
102 void StTriggerSimuResult::addHighTower(int towerId, int dsmAdc) {
103  mHighTowerIds.push_back(towerId);
104  mHighTowerAdcs.push_back(dsmAdc);
105 }
106 
107 void StTriggerSimuResult::addTriggerPatch(int patchId, int dsmAdc) {
108  mTriggerPatchIds.push_back(patchId);
109  mTriggerPatchAdcs.push_back(dsmAdc);
110 }
111 
112 void StTriggerSimuResult::addJetPatch(int jetPatchId, int dsmAdc) {
113  mJetPatchIds.push_back(jetPatchId);
114  mJetPatchAdcs.push_back(dsmAdc);
115 }
116 
117 void StTriggerSimuResult::setL2Result(const unsigned int* result) {
118  memcpy(mL2Result, result, sizeof(mL2Result));
119 }
120 
121 
122 /*****************************************************************************
123  * $Log: StTriggerSimuResult.cxx,v $
124  * Revision 1.9 2016/03/18 22:49:38 zchang
125  * updating trigger simulator for run12 analysis
126  *
127  * Revision 1.8 2011/04/01 03:56:41 pibero
128  * Fix L2
129  *
130  * Revision 1.7 2010/08/13 00:20:20 rfatemi
131  * Changed the PIG+2 address from BEMC to EEMC based on structure in StTriggerData2005::isL2Trigger()
132  *
133  * Revision 1.6 2010/04/29 10:34:34 pibero
134  * Preserve backward compatibility with reading of Run 6 skim trees
135  *
136  * Revision 1.5 2010/02/18 20:07:03 pibero
137  * Run 9 updates
138  *
139  * Revision 1.4 2009/09/23 23:22:42 fine
140  * add the missed cstring header file
141  *
142  * Revision 1.3 2008/01/30 15:09:24 balewski
143  * Added upsilon2006, needs cleaunp in few days
144  *
145  * Revision 1.2 2008/01/17 17:04:08 kocolosk
146  * some revisions to StTriggerSimuResult structure to hopefully improve clarity and maintainability
147  *
148  * Revision 1.1 2008/01/17 01:58:25 kocolosk
149  * StTriggerSimuResult makes detailed emulation results persistent
150  *
151  *
152  *****************************************************************************/
simple struct to return HHTP tower - trigger patch pairs
int jetPatchAdc(short jetPatchId) const
returns DSM ADC if above trigger threshold, otherwise -1
int highTowerAdc(short towerId) const
returns DSM ADC if above trigger threshold, otherwise -1
HttpResult httpPair(short towerId) const
returns simple struct encapsulating (id,adc) of HT and TP pair
int triggerPatchAdc(short patchId) const
returns DSM ADC if above trigger threshold, otherwise -1
const unsigned int * l2Result(L2ResultType algo, int year=2006) const
returns address of specific L2 result struct – cast it yourself