|
ATLAS Offline Software
|
Go to the documentation of this file.
19 #include "GaudiKernel/ThreadLocalContext.h"
22 static const InterfaceID IID_ITileRawChannelBuilder(
"TileRawChannelBuilder", 1, 0);
25 return IID_ITileRawChannelBuilder;
50 ,
const std::string&
name,
const IInterface*
parent)
70 , m_notUpgradeCabling(true)
132 ATH_MSG_DEBUG(
"Obsolete calibrateEnergy flag is set to True in jobOptions - disabling it" );
156 msg(
MSG::DEBUG) <<
"TileRawChannelBuilder created, storing rc in '"
170 return StatusCode::FAILURE;
176 std::ostringstream
os;
179 std::vector<int>
v = { 0x10d };
187 os <<
" (frag IDs):";
190 os <<
" 0x" << std::hex <<
fragID << std::dec;
194 ATH_MSG_INFO(
"Enable special treatment for demonstrator modules" <<
os.str());
225 return StatusCode::SUCCESS;
230 return StatusCode::SUCCESS;
243 return StatusCode::SUCCESS;
269 const unsigned int *cispar = DQstatus->
cispar();
270 if (0 == cispar[7]) {
277 m_capdaq = (cispar[7] < 10) ? 5.2 : 100.0;
282 <<
"; dophys is " << ((
m_idophys) ?
"true" :
"false")
283 <<
"; dolas is " << ((
m_idolas) ?
"true" :
"false")
284 <<
"; doped is " << ((
m_idoped) ?
"true" :
"false")
285 <<
"; docis is " << ((
m_idocis) ?
"true" :
"false")
306 int ros = (frag >> 8);
307 int drawer = (frag & 0xff);
327 <<
" is bad - skipping bad patterns check " );
332 <<
" looking for bad patterns in digits" );
335 float mindig, maxdig;
336 int nchbad[2] = { 0, 0 };
342 for (; digitItr != lastDigit; ++digitItr) {
352 <<
"/" <<
gain <<
" BAD DQ STATUS ");
380 std::vector<float> digits = pDigits->
samples();
381 for (
unsigned int i = 0;
i < digits.size(); ++
i) {
388 if (mindig < 0.01)
err += 1;
398 int ndmubad[2] = { 0, 0 };
409 int ndmulimit[2] = { 3, 3 };
412 if (frag == 0x30e || frag == 0x411)
418 bool printall =
true;
419 for (
int p = 0;
p < 2; ++
p) {
420 if (ndmubad[
p] > ndmulimit[
p] && nchbad[
p] > 0) {
423 <<
" masking whole " << ((
p) ?
"second" :
"first")
442 <<
" bad patterns" <<
endmsg;
459 static const char *
const errname[26] = {
463 "-7 - underflow and overflow",
464 "-6 - constant signal",
465 "-5 - disconnected channel",
466 "-4 - half a drawer masked",
467 "-3 - bad DQ status",
468 "-2 - underflow in all samples",
469 "-1 - overflow in all samples",
471 "1 - jump from zero to saturation",
472 "2 - samples with zeros",
473 "3 - at least two saturated. others - close to pedestal",
474 "4 - two distinct levels with at least 2 samples each",
475 "5 - pedestal with jump up in one sample",
476 "6 - pedestal with jump down in one sample",
477 "7 - signal with jump up in one sample",
478 "8 - signal with jump down in one sample",
479 "9 - base line above threshold in low gain",
480 "10 - jump down in first sample in low gain",
481 "11 - jump down in last sample in low gain",
482 "12 - jump up in one sample above const",
483 "13 - jump down in one sample below const",
484 "14 - unrecoverable timing jump",
506 for (; digitItr != lastDigit; ++digitItr) {
515 if (
err == -8 ||
err == -7)
m_overflows.push_back(std::make_pair(rch, (*digitItr)));
541 return StatusCode::SUCCESS;
556 ATH_MSG_DEBUG(
"Incomplete container - use noise filter corrections from DSP container" );
562 ATH_MSG_WARNING(
"Problem in applying noise corrections: DSP container ("
564 }
else if (
hashes != dspHashes) {
566 "hash vectors do not match.");
575 ATH_MSG_ERROR(
" Error in applying noise corrections " << MSG::hex
576 <<
" collection IDs 0x" << coll->
identify() <<
" and 0x" << dcoll->
identify()
577 <<
" do not match " << MSG::dec );
587 while (dspItr != dspLast && adc_id != (*dspItr)->adc_HWID()) {
590 if (dspItr != dspLast) {
591 float corr = (*dspItr)->pedestal();
593 <<
" amp " << rch->amplitude() <<
" ped " << rch->pedestal()
594 <<
" corr " << corr );
596 rch->setAmplitude (rch->amplitude() - corr);
597 rch->setPedestal (rch->pedestal() + corr);
599 float ped = rch->pedestal();
601 rch->setPedestal (fmod(
ped,10000.) +
int(corr)/10000 * 10000);
607 <<
" can not find channel in DSP container with HWID "
609 dspItr = dcoll->
begin();
618 if (noiseFilterTool->process(*
m_rawChannelCnt.get(), ctx).isFailure()) {
619 ATH_MSG_ERROR(
" Error status returned from noise filter " );
636 return StatusCode::SUCCESS;
667 a1 =
phase < 0.0 ? 0.000940774 : 0.00102111;
668 a2 =
phase < 0.0 ? 0.000759051 : 0.000689625;
669 b =
phase < 0.0 ? -2.0 * 7.0 * (a1 - a2) : 2.0 * 12.5 * (a1 - a2);
670 c =
phase < 0.0 ? 1.0 - 7.0 * 7.0 * (a1-a2) : 1.0 - 12.5 * 12.5 * (a1-a2);
671 if (phase < 12.5 && phase > -7.0) corr = a1 *
phase *
phase + 1.0;
690 double k1 = (
phase < 0.0 ? -0.0000326707:0.000380336);
691 double k2 = (
phase < 0.0 ? -0.000560962:-0.000670487);
692 double k3 = (
phase < 0.0 ? -0.00000807869:0.00000501773);
693 double k4 = (
phase < 0.0 ? -0.000000145008:0.0000000584647);
724 const std::vector<float> & digits,
float &dmin,
float &dmax,
float ADCmaxMinusEps,
float ADCmaskValueMinusEps) {
727 bool empty = ((eb && ((
channel > 23 && channel < 30) || channel > 41)) || (ebsp &&
channel < 3));
731 const float epsilon = 4.1;
732 const float delta[4] = { 29.9, 29.9, 49.9, 99.9 };
733 const float level1 = 99.9;
734 const float level2 = 149.9;
735 const float narrowLevel[2] = { 29.9, 49.9 };
737 std::min(narrowLevel[0], narrowLevel[1]));
738 const float secondMaxLevel = 0.3;
742 unsigned int nSamp = digits.size();
744 dmin = dmax = digits[0];
745 unsigned int pmin = 0;
746 unsigned int pmax = 0;
747 unsigned int nzero = (dmin < 0.01) ? 1 : 0;
748 unsigned int nover = (dmax > ADCmaxMinusEps) ? 1 : 0;
750 for (
unsigned int i = 1;
i < nSamp; ++
i) {
751 float dig = digits[
i];
755 }
else if (dig < dmin) {
759 if (dig < 0.01) ++nzero;
760 else if (dig > ADCmaxMinusEps) ++nover;
763 float dmaxmin = dmax - dmin;
766 if (dmin > ADCmaxMinusEps) {
767 error = (dmin > ADCmaskValueMinusEps) ? -3 : -1;
769 }
else if (dmax < 0.01) {
772 }
else if (dmaxmin < 0.01) {
775 }
else if (nzero && nover) {
778 }
else if ((nzero && (not_gap ||
empty)) || nzero > 1) {
781 }
else if (
gain == 0 && dmin > level2) {
784 }
else if (dmaxmin > delt) {
786 float abovemin = dmax;
787 float belowmax = dmin;
788 unsigned int nmin = 0;
789 unsigned int nmax = 0;
790 for (
unsigned int i = 0;
i < nSamp; ++
i) {
791 float smp = digits[
i];
792 if (smp - dmin < epsilon) {
795 if (dmax - smp < epsilon) {
798 if (smp < abovemin && smp > dmin) {
801 if (smp > belowmax && smp < dmax) {
806 int gainInd = (abovemin != dmax || belowmax != dmin) ?
gain + 2 :
gain;
807 bool big_jump = (dmaxmin > delta[gainInd]);
808 bool max_in_middle = (pmax > 0 && pmax < nSamp - 1);
809 bool min_in_middle = (pmin > 0 && pmin < nSamp - 1);
811 if (nover > 1 && belowmax < level1) {
813 }
else if (
nmax + nmin == nSamp && big_jump) {
814 if (
nmax > 1 && nmin > 1) {
816 }
else if (
nmax == 1) {
820 }
else if (nmin == 1) {
824 if (
error == 0 && dmaxmin > narrowLevel[
gain]) {
825 float secondMax = dmaxmin * secondMaxLevel;
826 float dminPlus = dmin + secondMax;
827 float dmaxMinus = dmax - secondMax;
829 if (max_in_middle &&
std::max(digits[pmax - 1], digits[pmax + 1]) < dminPlus) {
831 }
else if (min_in_middle &&
std::min(digits[pmin - 1], digits[pmin + 1]) > dmaxMinus) {
833 }
else if (big_jump &&
gain == 0) {
834 if (pmin == 0 && digits[1] > dmax - secondMax) {
836 }
else if (pmin == nSamp - 1 && digits[pmin - 1] > dmax - secondMax) {
841 if (!
error && big_jump) {
842 if ((max_in_middle ||
gain == 0) &&
nmax == 1 && belowmax < dminPlus) {
844 }
else if ((min_in_middle ||
gain == 0) && nmin == 1 && abovemin > dmaxMinus) {
def retrieve(aClass, aKey=None)
JetConstituentVector::iterator iterator
static int CorruptedData(int ros, int drawer, int channel, int gain, const std::vector< float > &digits, float &dmin, float &dmax, float ADCmaxMinusEps, float ADCmaskValueMinusEps)
void setRODBCID(uint32_t rodBCID)
Setter for BCID from ROD header.
Const iterator class for DataVector/DataList.
TileRawChannelBuilder(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
ToolHandleArray< ITileRawChannelTool > m_noiseFilterTools
ToolHandle< TileCondToolEmscale > m_tileToolEmscale
void setDetEvType(uint32_t detEvType)
Setter for detector event type from ROD header.
int NdigitSamples() const
Returns the number of sammples (digits) per event.
float m_ampMinThresh
correct amplitude if it's above amplitude threshold (in ADC counts)
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
const TileCablingService * m_cabling
TileCabling instance.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
float pedestal(void) const
virtual StatusCode finalize()
const TileHWID * m_tileHWID
uint32_t calibMode() const
Calibration mode.
std::unique_ptr< TileMutableRawChannelContainer > m_rawChannelCnt
bool isBiGain() const
returns gain mode of run
virtual StatusCode initialize()
Initializer.
bool msgLvl(const MSG::Level lvl) const
void setPedestal(float ped)
ServiceHandle< TileCablingSvc > m_cablingSvc
Name of Tile cabling service.
#define ATH_MSG_VERBOSE(x)
const std::string & key() const
Return the StoreGate ID for the referenced object.
Hash table for Tile fragments (==drawers ==collections in StoreGate)
HWIdentifier adc_HWID(void) const
static const InterfaceID & interfaceID()
AlgTool InterfaceID.
Gaudi::Property< std::vector< int > > m_demoFragIDs
virtual ~TileRawChannelBuilder()
Destructor.
ToolHandle< TileCondToolTiming > m_tileToolTiming
float m_ADCmaskValueMinusEps
indicates channels which were masked in background dataset
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
SG::ReadHandleKey< TileRawChannelContainer > m_DSPContainerKey
std::vector< std::pair< TileRawChannel *, const TileDigits * > > Overflows_t
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
void assign(const HWIdentifier &id, float amplitude, float time, float quality, float ped=0.0)
int ADCmaskValue() const
Returns the overlay magic number that indicates channels which were masked in background dataset.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
int trigType() const
Trigger type.
bool incompleteDigits() const
A few extra items (from TileBeamInfoProvider).
Handle class for recording to StoreGate.
Class that holds Data Quality fragment information and provides functions to extract the data quality...
TileFragHash::TYPE m_rChType
int adc(const HWIdentifier &id) const
extract adc field from HW identifier
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
virtual std::vector< IdentifierHash > GetAllCurrentHashes() const override final
Returns a collection of all hashes availiable in this IDC.
SG::WriteHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
::StatusCode StatusCode
StatusCode definition for legacy code.
uint32_t get_bsflags() const
StatusCode build(const TileDigitsCollection *collection, const EventContext &ctx)
ToolHandle< TileCondIdTransforms > m_tileIdTransforms
uint32_t getLvl1Id() const
Getter for level1 id.
TileRawChannelUnit::UNIT m_rChUnit
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
void fill_drawer_errors(const EventContext &ctx, const TileDigitsCollection *collection)
const std::vector< float > & samples() const
static const int MAX_CHANNELS
virtual StatusCode createContainer(const EventContext &ctx)
Create container in SG with name given by parameter (m_rawChannelContainerKey)
bool isAdcDQgood(int partition, int drawer, int ch, int gain) const
returns status of single ADC returns False if there are any errors
const TileInfo * m_tileInfo
void resetOverflows(void)
int getCablingType() const
static double correctAmp(double phase, bool of2=true)
Amplitude correction factor according to the time when using weights for tau=0 without iterations.
Helpers for checking error return status codes and reporting errors.
uint32_t getLvl1Type() const
Getter for level1 type.
const uint32_t * cispar() const
CIS parameters.
float m_timeMaxThresh
correct amplitude is time is below time max threshold
static const char * BadPatternName(float ped)
virtual TileRawChannel * rawChannel(const TileDigits *digits, const EventContext &ctx)
Builder virtual method to be implemented by subclasses.
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
virtual const T * indexFindPtr(IdentifierHash hashId) const override final
return pointer on the found entry or null if out of range using hashed index - fast version,...
static double correctTime(double phase, bool of2=true)
Time correction factor.
size_type channel_hash_max(void) const
channel hash table max size
std::string getTileRawChannelContainerID(void)
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
virtual StatusCode commitContainer(const EventContext &ctx)
Commit RawChannelContiner in SG and make const.
unsigned int m_evtCounter
uint32_t getDetEvType() const
Getter for detector event type.
SG::ReadHandleKey< TileDQstatus > m_DQstatusKey
#define ATH_MSG_WARNING(x)
void initLog(const EventContext &ctx)
static const int MAX_DMUS
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
void setLvl1Id(uint32_t lvl1Id)
Setter for level1 id from ROD header.
std::string to_string(const HWIdentifier &id, int level=0) const
extract all fields from HW identifier HWIdentifier get_all_fields ( const HWIdentifier & id,...
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
uint32_t getRODBCID() const
Getter for BCID from.
Overflows_t & getOverflowedChannels(void)
float m_timeMinThresh
correct amplitude is time is above time min threshold
int ADCmax() const
Returns the maximum ADC output (10 bits --> 1023)
void setLvl1Type(uint32_t lvl1Type)
Setter for level1 type from ROD header.
int m_error[MAX_CHANNELS]
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.