42#include <CLHEP/Random/Randomize.h>
45using CLHEP::RandGaussQ;
57 std::vector<HWIdentifier *>::iterator itr =
m_all_ids.begin();
58 std::vector<HWIdentifier *>::iterator last =
m_all_ids.end();
60 for (; itr != last; ++itr) {
110 <<
", tileNoise=" << ((
m_tileNoise) ?
"true" :
"false")
111 <<
", tileThresh=" <<
"true, thresh_hi=" <<
m_threshHi );
114 <<
", tileNoise=" << ((
m_tileNoise) ?
"true" :
"false")
115 <<
", tileThresh=" <<
"false" );
125 for (
int dr = 0; dr < ndrawers; ++dr) {
128 m_tileHWID->get_id(dr, drawer_id, &drawer_context);
132 for (
int ch = 0; ch < nchannels; ++ch) {
142 ATH_MSG_INFO(
"TileHitToRawChannel initialization completed" );
144 return StatusCode::SUCCESS;
157 CLHEP::HepRandomEngine* rndmEngine = rngWrapper->
getEngine(ctx);
179 const int nChMax = 48;
180 double random[nChMax];
181 memset(random, 0,
sizeof(random));
183 int adc_gain[nChMax];
184 double adc_ampl[nChMax];
185 double adc_time[nChMax];
186 double adc_qual[nChMax];
191 auto rawChannelContainer = std::make_unique<TileMutableRawChannelContainer>(
true,
m_rChType,
m_rChUnit);
192 ATH_CHECK( rawChannelContainer->status() );
203 <<
" drawer " << drawer
204 <<
" is connected" );
211 <<
"Collection = 0x" << hitCollection->identify() << MSG::dec
213 <<
", drawer=" << drawer );
216 m_tileHWID->get_hash(drawer_id, idhash, &drawer_context);
222 RandGaussQ::shootArray(rndmEngine, nChMax, random, 0.0, 1.0);
224 for (ch = 0; ch < nChMax; ++ch) {
231 memset(adc_gain, -1,
sizeof(adc_gain));
232 memset(adc_ampl, 0,
sizeof(adc_ampl));
235 memset(adc_time, 0,
sizeof(adc_time));
236 memset(adc_qual, 0,
sizeof(adc_qual));
239 for (
const TileHit* tile_hit : *hitCollection) {
249 double e_hit = tile_hit->energy();
250 double time = tile_hit->time();
256 double etime = e_hit * time;
257 for (
int i = tile_hit->size() - 1; i > 0; --i) {
258 double en = tile_hit->energy(i);
259 double ti = tile_hit->time(i);
260 if (fabs(ti) <
m_deltaT && en > 0.0) {
266 time = etime / e_hit;
271 double hit_calib = samplingFraction->getSamplingFraction(drawerIdx, ch);
272 double e_ch = e_hit * hit_calib;
277 double amp_ch = e_ch / emScale->calibrateChannel(drawerIdx, ch, gain, 1.,
m_rChUnit
284 amp_ch = e_ch / emScale->calibrateChannel(drawerIdx, ch, gain, 1.,
m_rChUnit
296 noise = adc_ampl[ch];
297 adc_ampl[ch] += amp_ch;
300 <<
" pmt=" <<
m_tileID->to_string(pmt_id, -1)
301 <<
" adc=" <<
m_tileHWID->to_string(channel_id, -1) <<
"/" << gain
302 <<
" noise=" << noise
304 <<
" tot=" << adc_ampl[ch]);
313 for (
int ch = 0; ch < nChMax; ++ch) {
315 int gain = adc_gain[ch];
322 double amp = adc_ampl[ch];
325 double thresh = -99999;
336 if (fabs(amp) < fabs(thresh))
347 auto rawChannel = std::make_unique<TileRawChannel>(adc_id, amp, adc_time[ch], adc_qual[ch]);
348 ATH_CHECK( rawChannelContainer->push_back(std::move(rawChannel)) );
358 ATH_MSG_VERBOSE(
"Accept RC thr=" << ((thresh < 0) ?
"+" :
"" ) << thresh
360 <<
", amp=" << amp );
364 ATH_MSG_VERBOSE(
"Reject RC thr=" << ((thresh < 0) ?
"+" :
"") << thresh
366 <<
", amp=" << amp );
375 msg(MSG::DEBUG) <<
"TileHitToRawChannel execution completed." <<
endmsg;
376 msg(MSG::DEBUG) <<
" nChan=" << nChan
377 <<
" eHitTot=" << eHitTot
379 <<
" nchLG=" << nChLG
380 <<
" eChLG=" << eChLG
381 <<
" nchHG=" << nChHG
382 <<
" eChHG=" << eChHG <<
endmsg;
389 return StatusCode::SUCCESS;
396 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_VERBOSE(x,...)
#define ATH_MSG_INFO(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.
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
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.
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.
virtual StatusCode execute(const EventContext &ctx) override
execute method
SG::ReadHandleKey< TileHitContainer > m_hitContainerKey
Gaudi::Property< 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.
ServiceHandle< TileCablingSvc > m_cablingSvc
Name of Tile cabling service.
virtual StatusCode finalize() override
finalize method
TileHitToRawChannel(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
const TileInfo * m_tileInfo
Pointer to TileInfo.
Gaudi::Property< std::string > m_randomStreamName
Random Stream Name.
Gaudi::Property< bool > m_calibrateEnergy
if true, amplitude is converted to pCb
const TileID * m_tileID
Pointer to TileID helper.
virtual StatusCode initialize() override
initialize 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).
Gaudi::Property< double > m_deltaT
if true, keep only hits in deltaT range