5 #include "GaudiKernel/ConcurrencyFlags.h" 
   14         std::shared_ptr<PadOfflineData> 
t_pad;
 
   27     using PAD_MAP=std::map < Identifier,std::vector<PadHits> >;
 
   35         declareInterface<NSWL1::IPadTdsTool>(
this);
 
   61         return StatusCode::SUCCESS;
 
   65         ATH_MSG_DEBUG( 
"gather_pad_data: start gathering the PAD hits for side " << 
side << 
", sector " << sector );
 
   67         if ( side <-1 || side >1 ) {
 
   68             ATH_MSG_ERROR( 
"requested side " << 
side << 
" is out of range: [-1==All, 0==side C, 1==side A]");
 
   69             return StatusCode::FAILURE;
 
   72         if ( sector <-1 || sector >15 ) {
 
   73             ATH_MSG_ERROR( 
"requested sector " << sector << 
" is out of range: [-1==All, 0 - 15]");
 
   74             return StatusCode::FAILURE;
 
   81         const bool anySide = (
side==-1);
 
   82         const bool anySector = (sector==-1);
 
   83         if (anySide && anySector) {
 
   87               std::vector<std::shared_ptr<PadData>>& pad_sec = pad_cache.at(
i);
 
   88               pads.insert( pads.end(), std::make_move_iterator(pad_sec.begin()), std::make_move_iterator(pad_sec.end()));
 
   91         else if (anySector and not anySide) {
 
   97               std::vector<std::shared_ptr<PadData>>& pad_sec = pad_cache.at(
i);
 
   98               pads.insert( pads.end(), std::make_move_iterator(pad_sec.begin()), std::make_move_iterator(pad_sec.end()));
 
  101         else if (anySide and not anySector) {
 
  103             ATH_MSG_DEBUG( 
"copying the PAD hit set of all trigger sector " << sector << 
" in both side" );
 
  105             std::vector<std::shared_ptr<PadData>>& pad_secA = pad_cache.at(sectorA);
 
  106             pads.insert( pads.end(), std::make_move_iterator(pad_secA.begin()), std::make_move_iterator(pad_secA.end()));
 
  109             std::vector<std::shared_ptr<PadData>>& pad_secC = pad_cache.at(sectorC);
 
  110             pads.insert( pads.end(), std::make_move_iterator(pad_secC.begin()), std::make_move_iterator(pad_secC.end()));
 
  114             ATH_MSG_DEBUG(
"copying the PAD hit set of all trigger sector "<<sector
 
  117             std::vector<std::shared_ptr<PadData>>& pad_secAorC = pad_cache.at(sectorAorC);
 
  118             pads.insert( pads.end(), std::make_move_iterator(pad_secAorC.begin()), std::make_move_iterator(pad_secAorC.end()));
 
  120         ATH_MSG_DEBUG( 
"delivered n. " << pads.size() << 
" PAD hits." );
 
  122         return StatusCode::SUCCESS;
 
  128         if(!digit_container.
isValid()){
 
  129           ATH_MSG_ERROR(
"could not retrieve the sTGC Digit container: cannot return the STRIP hits");
 
  130           return StatusCode::FAILURE;
 
  138         std::vector<PadHits> pad_hits;
 
  139         uint16_t BC0 = 0, BCP1 = 1, BCP2 = 2, BCP3 = 3, BCP4 = 4, BCM1 = ~BCP1, BCM2 = ~BCP2, BCM3 = ~BCP3;
 
  140         std::vector<uint16_t> bcWindow={BC0, BCP1, BCP2, BCP3, BCP4, BCM1, BCM2, BCM3};
 
  142         for(; 
it!=it_e; ++
it) {
 
  150                         if (
std::find(bcWindow.begin(), bcWindow.end(), 
digit->bcTag()) != bcWindow.end()){
 
  155                             auto pad=std::make_shared<PadOfflineData>(Id, 
digit->time(), 
digit->bcTag(), *detManager);
 
  168         return StatusCode::SUCCESS;
 
  180         double distance = std::sqrt( pad_gpos.x()*pad_gpos.x() +
 
  181                                     pad_gpos.y()*pad_gpos.y() +
 
  182                                     pad_gpos.z()*pad_gpos.z() );
 
  188       CLHEP::HepRandomEngine * engine = rngWrapper->
getEngine(Gaudi::Hive::currentContext());
 
  189       return CLHEP::RandGauss::shoot(engine, 0, 
m_timeJitter);
 
  196         for (
unsigned int i=0; 
i<
h.size(); 
i++) {
 
  199             if ( 
it!=channel_map.end() ) {
 
  200                 (*it).second.push_back(
h[
i]);
 
  202                 std::vector<PadHits> 
tmp;
 
  210         while ( 
it!=channel_map.end() ) {
 
  211             std::vector<PadHits>& 
hits = (*it).second;
 
  214             while ( p_next!=
hits.end() ) {
 
  215                 if (std::fabs((*p_next).t_pad->time()-(*p).t_pad->time())<=
m_vmmDeadTime){
 
  216                     p_next = 
hits.erase(p_next);
 
  224         it = channel_map.begin();
 
  225         while ( 
it!=channel_map.end() ) {
 
  226             std::vector<PadHits> 
hits = (*it).second;
 
  240         int stationEta = 
m_idHelperSvc->stgcIdHelper().stationEta(Id);
 
  241         int stationPhi = 
m_idHelperSvc->stgcIdHelper().stationPhi(Id);
 
  244         int trigger_sector = (
isSmall)? stationPhi*2-1 : stationPhi*2-2;
 
  245         return (stationEta>0)? trigger_sector + 16 : trigger_sector;
 
  251                          double &delayed_time, 
uint16_t &BCtag)
 const 
  253         bool success = 
false;
 
  254         if(!
digit) 
return success;
 
  256         double arrival_time = 
digit->time();
 
  257         delayed_time = arrival_time;
 
  261         if((delayed_time>200 || delayed_time<-200) ||
 
  262         (capture_time>200 || capture_time<-200) ){
 
  263             ATH_MSG_WARNING(
"sTGC Pad hit "<<pad_hit_number<<
" time outside of the range -200 ns / +200 ns," 
  265             ATH_MSG_WARNING(
"sTGC Pad hit "<<pad_hit_number<<
": delayed time ["<<delayed_time<<
" ns]" 
  266                             " capture time ["<<capture_time<<
" ns]");
 
  269         for (
unsigned int i=0; 
i<16; 
i++) {
 
  270             double bunch_start  = 
i*25;
 
  271             double bunch_stop   = (
i+1)*25;
 
  272             double signal_start = delayed_time + 200;
 
  273             double signal_stop  = capture_time + 200;
 
  274             if ((signal_start>=bunch_start && signal_start<bunch_stop) ||
 
  275                 (signal_stop>=bunch_start && signal_stop<bunch_stop)   ){
 
  276                 BCtag = BCtag | (0x1<<
i);
 
  279             if(bunch_start>=signal_start && bunch_stop<signal_stop){
 
  280                 BCtag = BCtag | (0x1<<
i);
 
  283         std::string bctag = 
"";
 
  285         for(
unsigned int i=0; 
i<16; 
i++) {
 
  286           if(BCtag & (last_bit>>
i)) bctag += 
"1";
 
  289         ATH_MSG_DEBUG(
"sTGC Pad hit " << pad_hit_number << 
":  arrival time [" << arrival_time << 
" ns]" 
  290                     << 
"  delayed time ["  << delayed_time << 
" ns]" 
  291                     << 
"  capture time ["  << capture_time << 
" ns]" 
  292                     << 
"  BC tag [" << bctag << 
"]" );
 
  304             ATH_MSG_WARNING(
"could not retrieve the sTGC SDO container: it will not be possible to associate the MC truth");
 
  307           ptrMuonSimDataCollection = sdo_container.
cptr();
 
  317         for (
unsigned int i=0; 
i<pad_hits.size(); 
i++) {
 
  318             const std::vector<std::shared_ptr<PadData>>& pads = pad_cache.at(pad_hits[
i].t_cache_index);
 
  319             bool fill = pads.empty();
 
  320             for(
unsigned int p=0; 
p<pads.size(); 
p++)  {
 
  322                 if(Id==pad_hits[
i].t_id) {
 
  324                     ATH_MSG_WARNING( 
"Pad Hits entered multiple times Discarding!!! Id:" << Id );
 
  327             if( 
fill ) pad_cache.at(pad_hits[
i].t_cache_index).push_back(pad_hits[
i].t_pad);
 
  336         int stationEta     = 
m_idHelperSvc->stgcIdHelper().stationEta(Id);
 
  337         int stationPhi     = 
m_idHelperSvc->stgcIdHelper().stationPhi(Id);
 
  338         int multiplet      = 
m_idHelperSvc->stgcIdHelper().multilayer(Id);
 
  347                     <<
" Station Name [" <<
stName          <<
"]" 
  348                     <<
" Station Eta ["  <<stationEta      <<
"]" 
  349                     <<
" Station Phi ["  <<stationPhi      <<
"]" 
  350                     <<
" Multiplet ["    <<multiplet       <<
"]" 
  351                     <<
" GasGap ["       <<gas_gap         <<
"]" 
  354                     <<
" Pad Eta ["      <<pad_eta         <<
"]" 
  355                     <<
" Pad Phi ["      <<pad_phi         <<
"]" 
  356                     <<
" BCTag ["        <<
digit->bcTag()  <<
"]" 
  357                     <<
" Id Hash ["      <<Id              <<
"]");
 
  362         for (
const auto &hit : pad_hits) 
ATH_MSG_DEBUG(
"pad hit has time "<< hit.t_pad->time());
 
  367         for (
const std::vector<std::shared_ptr<PadData>>& pad : pad_cache) {
 
  368           for (
const auto &
padhit : pad)
 
  370                           << 
", trigger sector " << 
padhit->sectorId()
 
  371                           << 
", module " << 
padhit->moduleId()
 
  372                           << 
", multiplet " << 
padhit->multipletId()
 
  373                           << 
", gas gap " << 
padhit->gasGapId()
 
  374                           << 
", pad eta " << 
padhit->padEtaId()
 
  375                           << 
", pad phi " << 
padhit->padPhiId());