64{
65
66
67
68
69
70
71
72
73
74
75
77
84 ATH_CHECK(topoData.
record(std::make_unique<JetCMXTopoDataCollection>()));
85
86
88 std::vector< std::vector<int> > crateHits;
89 std::vector<int> Hits;
90
91 bool jetOverflow = false;
92
93 Hits.resize(25);
94
95 crateHits.resize(2);
96 for (int crate = 0; crate < 2; ++crate) {
97 crateHits[crate].resize(25);
98 }
99
100
101
102 for (int crate = 0; crate < 2; ++crate) {
103 topoData->push_back(std::make_unique<JetCMXTopoData>(crate));
104 }
105
109
110 for (const LVL1::JetCMXData* bpData : *bpDataVec) {
111 int crate = bpData->crate();
112 std::vector<unsigned int> tobWords = bpData->TopoTOBs();
113
114
115 bool overflow = bpData->overflow();
116 if (overflow) {
117 (*topoData)[crate]->setOverflow(true);
118 jetOverflow = true;
119 }
120
121 for (std::vector<unsigned int>::const_iterator word = tobWords.begin();
122 word != tobWords.end(); ++word) {
123
124
125 (*topoData)[crate]->addTOB( (*word) );
126
127
128 JetTopoTOB tob( crate, (*word) );
129 int etaindex = tob.etaIndex();
130 int ieta = 2*(etaindex-15) + (etaindex > 15 ? 0 : -1);
131 if (etaindex < 2 || etaindex > 28) {
132 if (etaindex == 0) ieta = -40;
133 else if (etaindex == 1) ieta = -30;
134 else if (etaindex == 29) ieta = 29;
135 else if (etaindex >= 30) ieta = 39;
136 }
137 int iphi = tob.iphi();
138 if (iphi < 0) iphi += 64;
139 int etLarge = tob.etLarge();
140
141
143 float jepScale = l1Menu->thrExtraInfo().JET().jetScale();
144
145 std::vector<std::shared_ptr<TrigConf::L1Threshold>> allThresholds = l1Menu->thresholds();
146
147 for ( const auto& thresh : allThresholds ) {
149
150
151 int etCut =
thresh->thrValue(ieta)*jepScale;
152 if (etLarge > etCut) {
154 if (num < 25) {
155 if ( num < 10 && crateHits[crate][num] < 7 ) crateHits[crate][
num]++;
156 else if ( num >= 10 && crateHits[crate][num] < 3 ) crateHits[crate][
num]++;
157 if ( num < 10 && Hits[num] < 7 ) Hits[
num]++;
158 else if ( num >= 10 && Hits[num] < 3 ) Hits[
num]++;
159 }
161 }
162 }
163
164 }
165
166 }
167
168
169 unsigned int cableWord0 = 0;
170 unsigned int cableWord1 = 0;
171
172 if (!jetOverflow) {
173 for (
int i = 0;
i < 10; ++
i) cableWord0 |= ( Hits[i]<<(3*i) );
174 for (
int i = 10;
i < 25; ++
i) cableWord1 |= ( Hits[i]<<(2*(i-10)) );
175 }
176 else {
177 cableWord0 = 0x3fffffff;
178 cableWord1 = 0x3fffffff;
179 }
180
182 ATH_CHECK(jetCTP.
record(std::make_unique<JetCTP>(cableWord0, cableWord1)));
183
184
185 std::vector<int> error0;
186 std::vector<int> error1;
187
188
189 std::vector<unsigned int> cratehits0;
190 std::vector<unsigned int> cratehits1;
191 const int peak = 0;
192 const int system_crate = 1;
193
194
195 for (int crate = 0; crate < 2; ++crate) {
196
197 cratehits0.assign(1,0);
198 cratehits1.assign(1,0);
199 for (
int i = 0;
i < 5; ++
i) {
200 cratehits0[0] |= ( crateHits[crate][
i]<<(3*
i) );
201 cratehits1[0] |= ( crateHits[crate][
i+5]<<(3*
i) );
202 }
204 cratehits0, cratehits1, error0, error1, peak));
205 if (crate != system_crate) {
207 cratehits0, cratehits1, error0, error1, peak));
208 }
209
210 cratehits0.assign(1,0);
211 cratehits1.assign(1,0);
212 for (
int i = 0;
i < 8; ++
i) cratehits0[0] |= ( crateHits[crate][i+10]<<(2*i) );
213 for (
int i = 0;
i < 7; ++
i) cratehits1[0] |= ( crateHits[crate][i+18]<<(2*i) );
215 cratehits0, cratehits1, error0, error1, peak));
216 if (crate != system_crate) {
218 cratehits0, cratehits1, error0, error1, peak));
219 }
220 }
221
222
223 cratehits0.assign(1,0);
224 cratehits1.assign(1,0);
225 for (
int i = 0;
i < 5; ++
i) {
226 cratehits0[0] |= ( Hits[
i]<<(3*
i) );
227 cratehits1[0] |= ( Hits[
i+5]<<(3*
i) );
228 }
230 cratehits0, cratehits1, error0, error1, peak));
231
232 cratehits0.assign(1,0);
233 cratehits1.assign(1,0);
234 for (
int i = 0;
i < 8; ++
i) cratehits0[0] |= ( Hits[i+10]<<(2*i) );
235 for (
int i = 0;
i < 7; ++
i) cratehits1[0] |= ( Hits[i+18]<<(2*i) );
237 cratehits0, cratehits1, error0, error1, peak));
238
239 }
240 else {
244 }
245
246 return StatusCode::SUCCESS ;
247}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
SG::WriteHandleKey< JetCMXTopoDataCollection > m_TopoOutputLocation
SG::WriteHandleKey< CMXJetTobCollection > m_CMXJetTobLocation
SG::ReadHandleKey< TrigConf::L1Menu > m_L1MenuKey
SG::WriteHandleKey< JetCTP > m_CTPOutputLocation
SG::ReadHandleKey< JetCMXDataCollection > m_JetCMXDataLocation
SG::WriteHandleKey< CMXJetHitsCollection > m_CMXJetHitsLocation
virtual bool isValid() override final
Can the handle be successfully dereferenced?
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
static std::string & typeAsString(TriggerType tt)
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())