55 const unsigned NTRAINS = 4;
56 enum { FRONT, MIDDLE, END, NPOS } position = NPOS;
149 lb = eventInfo->lumiBlock();
150 lbAToF = eventInfo->lumiBlock();
151 lbCToF = eventInfo->lumiBlock();
152 lbAToFEvents = eventInfo->lumiBlock();
153 lbCToFEvents = eventInfo->lumiBlock();
154 lbAandCToFEvents = eventInfo->lumiBlock();
157 if (muPerBXToF == 0.0) {
158 ATH_MSG_DEBUG(
"AverageInteractionsPerCrossing is 0, forcing to 1.0");
163 ToFHits_MU_Weight = 1/muPerBXToF;
164 lbAToF_Weight = 1/muPerBXToF;
165 lbCToF_Weight = 1/muPerBXToF;
166 lbAToF_TAll_Weight = 1/muPerBXToF;
167 lbCToF_TAll_Weight = 1/muPerBXToF;
168 lbAToF_TWeight[FRONT] = 1/muPerBXToF;
169 lbAToF_TWeight[MIDDLE] = 1/muPerBXToF;
170 lbAToF_TWeight[END] = 1/muPerBXToF;
171 lbCToF_TWeight[FRONT] = 1/muPerBXToF;
172 lbCToF_TWeight[MIDDLE] = 1/muPerBXToF;
173 lbCToF_TWeight[END] = 1/muPerBXToF;
175 fill(
"AFPToFTool",
lb, muPerBXToF);
178 const unsigned int tempBCID = eventInfo->bcid();
181 ATH_MSG_ERROR(
"Unable to retrieve BunchCrossing conditions object (ToF)" );
188 bcidAllToF = tempBCID;
189 fill(
"AFPToFTool", bcidAllToF);
190 if(!bcDataToF->
isFilled(tempBCID-1))
194 else if(bcDataToF->
isFilled(tempBCID+1))
202 bcidToF[position] = tempBCID;
203 fill(
"AFPToFTool", bcidToF[position]);
208 if(! afpToFHitContainer.
isValid())
211 return StatusCode::SUCCESS;
217 if ( !afpTrackContainer.
isValid() ) {
219 return StatusCode::SUCCESS;
223 nTofHits = afpToFHitContainer->size();
224 fill(
"AFPToFTool",
lb, nTofHits);
226 int eventsInStations[4] = {};
230 trainID = hitsItr->trainID();
231 barInTrainID = hitsItr->barInTrainID();
232 ++eventsInStations[hitsItr->stationID()];
234 if(hitsItr->isSideA())
236 numberOfHit_S0 = hitsItr->trainID();
237 fill(
"AFPToFTool", numberOfHit_S0);
239 barInTrainIDA = hitsItr->barInTrainID();
241 barInTrainAllA = (hitsItr->trainID()*4)+barInTrainIDA;
242 fill(
"AFPToFTool", barInTrainAllA);
244 ToFHits_sideA = eventInfo->lumiBlock();
245 fill(
"AFPToFTool", ToFHits_sideA, ToFHits_MU_Weight);
247 else if(hitsItr->isSideC())
249 numberOfHit_S3 = hitsItr->trainID();
250 fill(
"AFPToFTool", numberOfHit_S3);
252 barInTrainIDC = hitsItr->barInTrainID();
254 barInTrainAllC = (hitsItr->trainID()*4)+barInTrainIDC;
255 fill(
"AFPToFTool", barInTrainAllC);
257 ToFHits_sideC = eventInfo->lumiBlock();
258 fill(
"AFPToFTool", ToFHits_sideC, ToFHits_MU_Weight);
261 if(hitsItr->isSideA() || hitsItr->isSideC())
263 auto& lbToF_T = hitsItr->isSideA() ? lbAToF_T : lbCToF_T;
264 auto& lbToF_TP = hitsItr->isSideA() ? lbAToF_TP : lbCToF_TP;
265 auto& lbToF_TAll_Weight = hitsItr->isSideA() ? lbAToF_TAll_Weight : lbCToF_TAll_Weight;
266 auto& lbToF_TWeight = hitsItr->isSideA() ? lbAToF_TWeight : lbCToF_TWeight;
268 unsigned int train = hitsItr->trainID();
271 lbToF_T[train] = eventInfo->lumiBlock();
272 fill(
"AFPToFTool", lbToF_T[train], lbToF_TAll_Weight);
276 lbToF_TP[train][position] = eventInfo->lumiBlock();
277 fill(
"AFPToFTool", lbToF_TP[train][position], lbToF_TWeight[position]);
282 if (hitsItr->stationID() == 0 || hitsItr->stationID() == 3)
286 if(hitsItr->stationID() == 0)
298 if(eventsInStations[0] > 0 || eventsInStations[3] > 0)
300 fill(
"AFPToFTool", lbAandCToFEvents);
302 if(eventsInStations[0] > 0)
304 fill(
"AFPToFTool", lbAToFEvents);
306 if(eventsInStations[3] > 0)
308 fill(
"AFPToFTool", lbCToFEvents);
324 bool channel_present[2][16] = {};
325 bool multihit[2] = {};
326 std::size_t track_count[2] = {};
327 std::size_t train_count[2][4] = {};
331 const auto side = tracksItr->stationID() == 3;
333 if (tracksItr->stationID() != 0 && tracksItr->stationID() != 3)
339 auto times = std::vector<std::vector<std::vector<float>>>(2, std::vector<std::vector<float>>(4, std::vector<float>(4, -10000)));
342 const auto side = hitsItr->stationID() == 3;
343 const auto train = hitsItr->trainID();
344 const auto bar = hitsItr->barInTrainID();
345 const auto channel = 4 * train + bar;
346 const auto tof_time = hitsItr->time();
347 const auto TimePs=(tof_time)*1000;
349 if (track_count[side] != 1)
continue;
351 if (hitsItr->stationID() != 0 && hitsItr->stationID() != 3)
353 if (channel >= 16)
continue;
354 if (channel_present[side][channel])
355 multihit[side] =
true;
356 channel_present[side][channel] =
true;
357 ++train_count[side][train];
359 times[side][train][bar]=TimePs;
363 for (uint8_t side : {0, 1})
366 if (track_count[side] != 1)
continue;
368 if (multihit[side])
continue;
370 uint8_t multrain[2] = {};
371 for (uint8_t train = 0; train < 4; ++train) {
372 if (train_count[side][train]>1) {
376 if (multrain[side]>1)
continue;
378 for (uint8_t train = 0; train < 4; ++train) {
379 for (uint8_t bar1 = 0; bar1 < 4; ++bar1) {
380 for (uint8_t bar2 = 0; bar2 < 4; ++bar2) {
382 int comb = bar1*bar2+bar2-1;
383 if (comb==5) {comb=4;}
384 if (comb==8) {comb=5;}
385 int global_comb = train*6 + comb;
386 if (times[side][train][bar1]>-10000 && times[side][train][bar2]>-10000) {
387 crossBarDeltaT[side] = (times[side][train][bar1] - times[side][train][bar2]);
396 return StatusCode::SUCCESS;