42#include <CLHEP/Random/Randomize.h>
45using CLHEP::RandGaussQ;
71 std::vector<HWIdentifier *>::iterator itr =
m_all_ids.begin();
72 std::vector<HWIdentifier *>::iterator last =
m_all_ids.end();
74 for (; itr != last; ++itr) {
124 <<
", tileNoise=" << ((
m_tileNoise) ?
"true" :
"false")
125 <<
", tileThresh=" <<
"true, thresh_hi=" <<
m_threshHi );
128 <<
", tileNoise=" << ((
m_tileNoise) ?
"true" :
"false")
129 <<
", tileThresh=" <<
"false" );
139 for (
int dr = 0; dr < ndrawers; ++dr) {
142 m_tileHWID->get_id(dr, drawer_id, &drawer_context);
146 for (
int ch = 0; ch < nchannels; ++ch) {
156 ATH_MSG_INFO(
"TileHitToRawChannel initialization completed" );
158 return StatusCode::SUCCESS;
168 const EventContext& ctx = Gaudi::Hive::currentContext();
193 const int nChMax = 48;
194 double random[nChMax];
195 memset(random, 0,
sizeof(random));
197 int adc_gain[nChMax];
198 double adc_ampl[nChMax];
199 double adc_time[nChMax];
200 double adc_qual[nChMax];
205 auto rawChannelContainer = std::make_unique<TileMutableRawChannelContainer>(
true,
m_rChType,
m_rChUnit);
206 ATH_CHECK( rawChannelContainer->status() );
217 <<
" drawer " << drawer
218 <<
" is connected" );
225 <<
"Collection = 0x" << hitCollection->identify() << MSG::dec
227 <<
", drawer=" << drawer );
230 m_tileHWID->get_hash(drawer_id, idhash, &drawer_context);
236 RandGaussQ::shootArray(*rngWrapper, nChMax, random, 0.0, 1.0);
238 for (ch = 0; ch < nChMax; ++ch) {
245 memset(adc_gain, -1,
sizeof(adc_gain));
246 memset(adc_ampl, 0,
sizeof(adc_ampl));
249 memset(adc_time, 0,
sizeof(adc_time));
250 memset(adc_qual, 0,
sizeof(adc_qual));
253 for (
const TileHit* tile_hit : *hitCollection) {
263 double e_hit = tile_hit->energy();
264 double time = tile_hit->time();
270 double etime = e_hit * time;
271 for (
int i = tile_hit->size() - 1; i > 0; --i) {
272 double en = tile_hit->energy(i);
273 double ti = tile_hit->time(i);
274 if (fabs(ti) <
m_deltaT && en > 0.0) {
280 time = etime / e_hit;
285 double hit_calib = samplingFraction->getSamplingFraction(drawerIdx, ch);
286 double e_ch = e_hit * hit_calib;
291 double amp_ch = e_ch / emScale->calibrateChannel(drawerIdx, ch, gain, 1.,
m_rChUnit
298 amp_ch = e_ch / emScale->calibrateChannel(drawerIdx, ch, gain, 1.,
m_rChUnit
310 noise = adc_ampl[ch];
311 adc_ampl[ch] += amp_ch;
314 <<
" pmt=" <<
m_tileID->to_string(pmt_id, -1)
315 <<
" adc=" <<
m_tileHWID->to_string(channel_id, -1) <<
"/" << gain
316 <<
" noise=" << noise
318 <<
" tot=" << adc_ampl[ch]);
327 for (
int ch = 0; ch < nChMax; ++ch) {
329 int gain = adc_gain[ch];
336 double amp = adc_ampl[ch];
339 double thresh = -99999;
350 if (fabs(amp) < fabs(thresh))
361 auto rawChannel = std::make_unique<TileRawChannel>(adc_id, amp, adc_time[ch], adc_qual[ch]);
362 ATH_CHECK( rawChannelContainer->push_back(std::move(rawChannel)) );
372 ATH_MSG_VERBOSE(
"Accept RC thr=" << ((thresh < 0) ?
"+" :
"" ) << thresh
374 <<
", amp=" << amp );
378 ATH_MSG_VERBOSE(
"Reject RC thr=" << ((thresh < 0) ?
"+" :
"") << thresh
380 <<
", amp=" << amp );
389 msg(MSG::DEBUG) <<
"TileHitToRawChannel execution completed." <<
endmsg;
390 msg(MSG::DEBUG) <<
" nChan=" << nChan
391 <<
" eHitTot=" << eHitTot
393 <<
" nchLG=" << nChLG
394 <<
" eChLG=" << eChLG
395 <<
" nchHG=" << nChHG
396 <<
" eChHG=" << eChHG <<
endmsg;
403 return StatusCode::SUCCESS;
410 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
Helpers for checking error return status codes and reporting errors.
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
Helper for holding non-const raw data prior to recording in SG.
A wrapper class for event-slot-local random engines.
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
This is a "hash" representation of an Identifier.
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 unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
Hash table for Tile fragments (==drawers ==collections in StoreGate)
bool m_tileThresh
If true => apply threshold on the conversion to raw channels.
ServiceHandle< IAthRNGSvc > m_atRndmGenSvc
Random number generator engine to use.
double m_ampMaxHi
Value of the maximum amplitude to be stored as a high gain channel.
double m_threshHi
Value of the mimimal amplitude required to do the conversion to raw channel in high gain (not used fo...
SG::ReadCondHandleKey< TileSamplingFraction > m_samplingFractionKey
Name of TileSamplingFraction in condition store.
SG::WriteHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
TileFragHash::TYPE m_rChType
Type of TileRawChannels (Digitizar, OF1, OF2, Fit, etc.)(see TileFragHash.h)
std::vector< HWIdentifier * > m_all_ids
Vector to store all the drawer ids.
SG::ReadHandleKey< TileHitContainer > m_hitContainerKey
std::string m_infoName
name of the TileInfo object
SG::ReadCondHandleKey< TileEMScale > m_emScaleKey
Name of TileEMScale in condition store.
const TileCablingService * m_cabling
Pointer to the TileCablingService instance.
virtual ~TileHitToRawChannel()
Destructor.
bool m_calibrateEnergy
if true, amplitude is converted to pCb
ServiceHandle< TileCablingSvc > m_cablingSvc
Name of Tile cabling service.
virtual StatusCode finalize() override
finalize method
TileHitToRawChannel(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
double m_deltaT
if true, keep only hits in deltaT range
const TileInfo * m_tileInfo
Pointer to TileInfo.
Gaudi::Property< std::string > m_randomStreamName
Random Stream Name.
const TileID * m_tileID
Pointer to TileID helper.
virtual StatusCode initialize() override
initialize method
virtual StatusCode execute() override
execute method
const TileTBID * m_tileTBID
Pointer to TileID helper.
ToolHandle< TileCondToolNoiseSample > m_tileToolNoiseSample
bool m_tileNoise
If true => generate noise for the TileRawChannel creation.
const TileHWID * m_tileHWID
Pointer to TileHWID helper.
TileRawChannelUnit::UNIT m_rChUnit
Units used for the TileRawChannels (ADC, pCb, etc.)(see TileInfo.h)