11 #include "CLHEP/Random/RandFlat.h" 
   12 #include "CLHEP/Random/RandGaussZiggurat.h" 
   13 #include "CLHEP/Random/RandomEngine.h" 
   15 #include "GaudiKernel/ISvcLocator.h" 
   16 #include "GaudiKernel/StatusCode.h" 
   62     return StatusCode::SUCCESS;
 
   71     return StatusCode::SUCCESS;
 
   81     rngWrapper->
setSeed(
name(), Gaudi::Hive::currentContext());
 
   82     CLHEP::HepRandomEngine* rndmEngine = *rngWrapper;
 
   92     ATH_CHECK(rdoContainer.
record(std::make_unique<CscRawDataContainer>()));
 
  105     collection_iterator it_coll = container->
begin();
 
  106     collection_iterator it_coll_e = container->
end();
 
  108     for (; it_coll != it_coll_e; ++it_coll) {
 
  121         std::vector<uint16_t> samples;
 
  133         digit_iterator it_dig = cscCollection->
begin();
 
  134         digit_iterator it_dig_e = cscCollection->
end();
 
  138         unsigned int count = 0;
 
  139         unsigned int size = cscCollection->
size();
 
  141         for (; it_dig != it_dig_e; ++it_dig) {
 
  153             if (!
m_idHelperSvc->cscIdHelper().get_hash(offlineChannelId, cscOfflineChannelHashId, &cscContext)) {
 
  155                               << cscOfflineChannelHashId << 
" for " 
  156                               << 
m_idHelperSvc->cscIdHelper().show_to_string(offlineChannelId, &cscContext));
 
  159             int currentStrip = 
m_idHelperSvc->cscIdHelper().strip(offlineChannelId);
 
  162             int currentLayer = 
m_idHelperSvc->cscIdHelper().wireLayer(offlineChannelId);
 
  163             int measuresPhi = 
m_idHelperSvc->cscIdHelper().measuresPhi(offlineChannelId);
 
  166             int stationId = 
m_idHelperSvc->cscIdHelper().stationName(offlineChannelId);
 
  167             uint16_t subDetectorId = (
eta == -1) ? 0x6A : 0x69;
 
  170                 if (stationId == 0x32) rodId = (0x10 | (
phi - 1));
 
  171                 if (stationId == 0x33) rodId = (0x18 | (
phi - 1));
 
  183                 double flat = CLHEP::RandFlat::shoot(rndmEngine, 0.0, 1.0);  
 
  189             bool sparsified = 
true;
 
  192             bool enableCal = 
false;
 
  195                                  ((
neutron & 1) << 23) | ((calAmplitude & 0x3f) << 24) | ((enableCal & 1) << 30) |
 
  209             if (currentStrip != (oldStrip + 1) || currentLayer != oldLayer) {
 
  210                 if (currentLayer != oldLayer) oldLayer = currentLayer;
 
  214                     int mphi = ((
address & 0x00000100) >> 8);
 
  215                     int zEta = (((
address & 0x00001000) >> 12) == 0x0) ? -1 : 1;
 
  217                     if (zEta > 0 && mphi == 1) {
 
  218                         int istat = ((
address & 0x00010000) >> 16) + 50;
 
  219                         int phisector = ((
address & 0x0000E000) >> 13) + 1;
 
  220                         int chamLayer = ((
address & 0x00000800) >> 11) + 1;
 
  221                         int wlayer = ((
address & 0x00000600) >> 9) + 1;
 
  223                         int beforestrip = (
address & 0x000000FF) + 1;
 
  224                         int afterstrip = beforestrip - 
width + 1;
 
  227                             m_idHelperSvc->cscIdHelper().channelID(istat, zEta, phisector, chamLayer, wlayer, mphi, afterstrip);
 
  228                         address = rodReadOut.
address(newOnlineChannelId, zEta, phisector);
 
  231                     ATH_MSG_DEBUG(
"At Creation of CscRawData, SPU ID = " << spuID);
 
  243                 if (measuresPhi == 0)
 
  252                 Identifier onlineChannelId = offlineChannelId;  
 
  253                 if (
eta > 0 && measuresPhi == 1) {
 
  254                     int chamberLayer = 
m_idHelperSvc->cscIdHelper().chamberLayer(offlineChannelId);  
 
  255                     int strip = 49 - currentStrip;
 
  266                 if (!
m_idHelperSvc->cscIdHelper().get_hash(offlineChannelId, cscRawDataOfflineHashId, &cscContext)) {
 
  267                     ATH_MSG_DEBUG(
"HashId off CscRawData (still offline hashId) is " 
  268                                   << cscRawDataOfflineHashId << 
" for " 
  269                                   << 
m_idHelperSvc->cscIdHelper().show_to_string(offlineChannelId, &cscContext));
 
  281             int zsec = 
m_idHelperSvc->cscIdHelper().stationEta(offlineChannelId);
 
  282             int phisec = 
m_idHelperSvc->cscIdHelper().stationPhi(offlineChannelId);
 
  283             int istation = 
m_idHelperSvc->cscIdHelper().stationName(offlineChannelId) - 49;
 
  284             int sector = zsec * (2 * phisec - istation + 1);
 
  285             int wlay = 
m_idHelperSvc->cscIdHelper().wireLayer(offlineChannelId);
 
  286             int measphi = 
m_idHelperSvc->cscIdHelper().measuresPhi(offlineChannelId);
 
  287             int istrip = 
m_idHelperSvc->cscIdHelper().strip(offlineChannelId);
 
  291             double noiseADC = 
m_cscCalibTool->stripNoise(cscOfflineChannelHashId, 
false);
 
  293             double pedestalADC = 
m_cscCalibTool->stripPedestal(cscOfflineChannelHashId, 
false);
 
  294             double phaseOffset = (cscRdoCollection->
samplingPhase()) ? 25 : 0;
 
  297                 std::vector<float> cscDigitSamples = cscDigit->
sampleCharges();
 
  301                     double theNoise = (
m_addNoise) ? CLHEP::RandGaussZiggurat::shoot(rndmEngine, 0.0, noiseADC) : 0.0;
 
  302                     double rawAmpl = cscDigitSamples[
i];
 
  303                     double ampl = rawAmpl;
 
  304                     double charge_to_adcCount =
 
  305                         m_cscCalibTool->numberOfElectronsToADCCount(cscOfflineChannelHashId, ampl) + theNoise + pedestalADC;
 
  308                     if (charge_to_adcCount < 0) charge_to_adcCount = 0;
 
  312                     samples.push_back(adcCount);
 
  316                                                            << 
" charge to ADC = " 
  317                                                            << charge_to_adcCount
 
  319                                                            << 
" raw amplitude (double) = " << rawAmpl << 
" theNoise (ADC) = " << theNoise);
 
  322                 double charge_to_adcCount = 
m_cscCalibTool->numberOfElectronsToADCCount(cscOfflineChannelHashId, cscDigit->
charge());
 
  329                     double theNoise = (
m_addNoise) ? CLHEP::RandGaussZiggurat::shoot(rndmEngine, 0.0, noiseADC) : 0.0;
 
  331                     double ampl = charge_to_adcCount * rawAmpl + theNoise + pedestalADC;
 
  337                     samples.push_back(adcCount);
 
  339                     ATH_MSG_DEBUG(
"amplitude :: index =  " << (
i + 1) << 
" sampling time (ns) = " << samplingTime
 
  340                                                            << 
" charge to ADC (double) = " << charge_to_adcCount
 
  341                                                            << 
" amplitude (double) = " << ampl << 
" raw amplitude (double) = " << rawAmpl
 
  342                                                            << 
" theNoise (double) = " << theNoise);
 
  347             ATH_MSG_DEBUG(
"CSC Digit zsec:phisec:station:sector:measphi:wlay:istrip:charge " 
  348                           << zsec << 
" " << phisec << 
" " << istation << 
" " << sector << 
" " << measphi << 
" " << wlay << 
" " << istrip
 
  349                           << 
" " << samples[0] << 
" " << samples[1] << 
" " << samples[2] << 
" " << samples[3] << 
" ");
 
  353             oldStrip = currentStrip;
 
  358                 ATH_MSG_DEBUG(
"End of DigitCollection : SPU ID = " << spuID);
 
  362                 else if (spuID > 4 && spuID <= 9)
 
  366                 cscRdoCollection->
addRPU(rpuID);
 
  370                 int mphi = ((
address & 0x00000100) >> 8);
 
  371                 int zEta = (((
address & 0x00001000) >> 12) == 0x0) ? -1 : 1;
 
  373                 if (zEta > 0 && mphi == 1) {
 
  374                     int istat = ((
address & 0x00010000) >> 16) + 50;
 
  375                     int phisector = ((
address & 0x0000E000) >> 13) + 1;
 
  376                     int chamLayer = ((
address & 0x00000800) >> 11) + 1;
 
  377                     int wlayer = ((
address & 0x00000600) >> 9) + 1;
 
  379                     int beforestrip = (
address & 0x000000FF) + 1;
 
  380                     int afterstrip = beforestrip - 
width + 1;
 
  383                         m_idHelperSvc->cscIdHelper().channelID(istat, zEta, phisector, chamLayer, wlayer, mphi, afterstrip);
 
  384                     address = rodReadOut.
address(newOnlineChannelId, zEta, phisector);
 
  401     for (; itM != itM_e; ++itM) {
 
  403         uint16_t clusterCounts[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
 
  406         for (; itD != itD_e; ++itD) {
 
  408             clusterCounts[spuID] += 1;
 
  410         for (
unsigned int i = 0; 
i < 10; ++
i) (itM->second)->set_spuCount(
i, clusterCounts[
i]);
 
  417     return StatusCode::SUCCESS;
 
  424     ATH_MSG_DEBUG(
"This collection online identifier is " << onlineColId);
 
  440     ATH_MSG_DEBUG(
"online ROD id = " << onlineRodId << 
" offline ROD id " << rodId);