12 #include "Identifier/Identifier.h"
71 std::string OccupancyCacheName =
"GlobalTRTOccupancyData";
77 return StatusCode::SUCCESS;
81 std::vector<float>
output ;
83 ATH_MSG_INFO(
"Cannot compute Global Occupancies in trigger environment! Returning empty vector");
89 ATH_MSG_INFO(
"Cannot get occupancy data. Returning empty vector.");
93 output.push_back(
data->m_occ_total[0]*1.e-2 ) ;
94 output.push_back(
data->m_occ_total[1]*1.e-2 ) ;
95 output.push_back(
data->m_occ_total[2]*1.e-2 ) ;
96 output.push_back(
data->m_occ_total[3]*1.e-2 ) ;
97 output.push_back(
data->m_occ_total[4]*1.e-2 ) ;
98 output.push_back(
data->m_occ_total[5]*1.e-2 ) ;
99 output.push_back(
data->m_occ_total[6]*1.e-2 ) ;
103 <<
"\t EndcapA C: " <<
output.at(2) <<
"\t EndcapB C: "
105 <<
"\t EndcapA A: " <<
output.at(5)
106 <<
"\t EndcapB A: " <<
output.at(6));
112 ATH_MSG_DEBUG(
"Compute LocalOccupancy(const Trk::Track& track ) for tool: " <<
name());
119 for (;tsos!=tsosEnd;++tsos) {
142 track_local[i_total-1][phi] +=1;
146 std::unique_ptr<OccupancyData> data_ptr;
151 data = data_ptr.get();
157 ATH_MSG_INFO(
"Cannot get occupancy data. Returning 0.");
161 float averageocc = 0;
163 const std::array<std::array<int,NLOCALPHI>,
NLOCAL> &stw_local =
data->m_stw_local;
165 for (
int i=0;
i<6; ++
i){
166 for (
int j = 0; j < 32; j++){
168 float hits_array = track_local[
i][j] ;
169 if (hits_array<1)
continue;
171 occ = (
data->m_occ_local [
i][j])*1.
e-2 ;
172 if (stw_local[
i][j] != 0){
173 if(occ == 0 &&
float(hits_array)/stw_local[
i][j] > 0.01){
174 ATH_MSG_DEBUG(
"Occupancy is 0 for : " <<
i <<
" " << j <<
" BUT THERE ARE HITS!!!: " << hits_array);
178 averageocc += (occ*hits_array);
181 ATH_MSG_DEBUG(
"new track: " <<
i <<
" " << j <<
"\t" << hits_array <<
"\t" << occ );
184 if (nhits>0) averageocc = averageocc / nhits;
185 ATH_MSG_DEBUG(
"Compute LocalOccupancy(const Trk::Track& track ) for tool: " << averageocc <<
" is over" );
197 std::map<int,int> hitCounter;
198 std::map<int,double> occResults;
202 for ( ; RDO_collection_iter!= RDO_collection_end; ++RDO_collection_iter) {
204 if (!RDO_Collection)
continue;
205 if (!RDO_Collection->
empty()){
222 unsigned int word = (*r)->getWord();
226 unsigned mask = 0x02000000;
227 bool SawZero =
false;
229 for(tdcvalue=0;tdcvalue<24;++tdcvalue)
231 if ( (word &
mask) && SawZero)
break;
232 if ( !(word &
mask) ) SawZero =
true;
234 if(tdcvalue==7 || tdcvalue==15)
mask>>=1;
236 if(tdcvalue!=0 && tdcvalue!=24) {
251 const std::array<int,TRTCond::AliveStraws::NTOTAL> &straws = strawCounts->
getStwTotal();
253 occResults[-1] = (
double)hitCounter[-1]/(
double)straws[1];
254 occResults[-2] = (
double)hitCounter[-2]/(
double)(straws[2] + straws[3]);
255 occResults[1] = (
double)hitCounter[1] /(
double)straws[4];
256 occResults[2] = (
double)hitCounter[2] /(
double)(straws[5] + straws[6]);
264 int track_local[NLOCAL][NLOCALPHI])
const
268 if (!driftCircleContainer.
isValid()){
273 bool allOfEndcapAFound[2][
NLOCALPHI] = {{
false}};
279 if (track_local[
i][j] < 1)
continue;
282 if (
data.m_hit_local[
i][j] > 0)
continue;
285 if (!colNext)
continue;
288 for(; p_rdo!=p_rdo_end; ++p_rdo){
299 if (i_total !=
i || phi != j)
continue;
301 if (
i%3==1 && lay>4) allOfEndcapAFound[(
i<3?0:1)][phi]=
true;
303 data.m_hit_local[i_total][phi] +=1;
308 int stws =
data.m_stw_local[
i][j];
319 if (
i%3!=1)
continue;
321 if (track_local[
i][j] < 1)
continue;
322 if (!allOfEndcapAFound[(
i<3?0:1)][j] && !region_rescaled[
i][j]){
326 data.m_occ_local[
i][j]/=(
data.m_stws_ratio[(
i<3?0:1)][j]);
327 region_rescaled[
i][j]=
true;
329 else if (allOfEndcapAFound[(
i<3?0:1)][j] && region_rescaled[
i][j]){
333 data.m_occ_local[
i][j]*=(
data.m_stws_ratio[(
i<3?0:1)][j]);
334 region_rescaled[
i][j]=
false;
343 const double t_phi)
const {
362 return data->m_occ_total[0]*1.e-2 ;
365 float mapped_occ =
data->m_occ_local[
partition][phisector]*1.e-2;
375 unsigned mask = 0x00010000;
377 for (
i=0;
i<8; ++
i) {
378 if (word &
mask)
return true;
385 bool foundInterval =
false;
386 unsigned mask = 0x02000000;
388 while ( !foundInterval && (
i < 24) ) {
390 float thisTime = ((0.5+
i)*3.125)-t0;
394 if (
i == 7 ||
i == 15)
398 return foundInterval;
407 if (
det == -1) arrayindex = 1;
408 else if (
det == -2) {
409 if (lay < 6) arrayindex = 2;
412 else if (
det == 1) arrayindex = 4;
414 if (lay < 6) arrayindex = 5;
417 else ATH_MSG_WARNING(
" detector value is: " <<
det <<
", out of range -2, -1, 1, 2, so THIS IS NOT TRT!!!");
428 double phi2pi = (t_phi > 0) ? t_phi : t_phi + 2*
M_PI;
430 phisector =
int ( (phi2pi + dphi)*32./(2*
M_PI) );
438 double abseta = fabs(t_eta);
442 else if ( abseta > 0.90 && abseta <= 1.55 )
partition = 1;
443 else if ( abseta > 1.55 && abseta <= 2.00 )
partition = 2;
464 std::unique_ptr<TRT_LocalOccupancy::OccupancyData>
471 auto data = std::make_unique<OccupancyData>(strawCounts->getStwLocal());
478 if ( driftCircleContainer.
isValid() ) {
481 if(!colNext)
continue;
485 for(; p_rdo!=p_rdo_end; ++p_rdo){
495 data->m_hit_total[0] +=1;
496 data->m_hit_total[i_total] +=1;
497 data->m_hit_local[i_total-1][phi] +=1;
505 const std::array<int,NTOTAL> &stw_total = strawCounts->getStwTotal();
506 const std::array<std::array<int,NLOCALPHI>,
NLOCAL> &stw_local = strawCounts->getStwLocal();
512 int stws = stw_total[
i];
520 int stws = stw_local[
i][j];
526 ATH_MSG_DEBUG(
"Active straws: " << stw_total[0] <<
"\t total number of hits: "
527 <<
data->m_hit_total[0]
528 <<
"\t occ: " <<
data->m_occ_total[0]);
533 std::unique_ptr<TRT_LocalOccupancy::OccupancyData>
539 auto data = std::make_unique<OccupancyData>(strawCounts->getStwLocal());
540 const std::array<std::array<int,NLOCALPHI>,
NLOCAL> &stw_local = strawCounts->getStwLocal();;
541 const std::array<std::array<int,NLOCALPHI>,
NWHEEL> &stw_wheel = strawCounts->getStwWheel();
543 for (
int i=0;
i<5; ++
i){
545 data->m_stws_ratio[0][j]+=
float(stw_wheel[
i+3 ][j])/stw_local[1][j];
546 data->m_stws_ratio[1][j]+=
float(stw_wheel[
i+20][j])/stw_local[4][j];