|
ATLAS Offline Software
|
Go to the documentation of this file.
23 #include "CaloDetDescr/CaloDetDescrElement.h"
42 #include <CLHEP/Random/Randomize.h>
43 #include <CLHEP/Units/SystemOfUnits.h>
48 #define USE_TILECELLS_DATAPOOL
51 #ifdef USE_TILECELLS_DATAPOOL
52 #define NEWTILECELL tileCellsP.nextElementPtr
54 #define NEWTILECELL new TileCell
58 using CLHEP::RandGaussQ;
64 static const InterfaceID IID_ITileCellBuilderFromHit(
"TileCellBuilderFromHit", 1, 0);
67 return IID_ITileCellBuilderFromHit;
74 , m_eneForTimeCut(35. *
MeV)
75 , m_eneForTimeCutMBTS(0.03675)
79 , m_maskBadChannels(false)
80 , m_noiseSigma(20.*
MeV)
86 declareInterface<TileCellBuilderFromHit>(
this );
135 ATH_MSG_WARNING(
"Unable to retrieve MbtsDetDescrManager from DetectorStore" );
185 ATH_MSG_INFO(
"TileCellBuilderFromHit initialization completed" );
187 return StatusCode::SUCCESS;
194 return StatusCode::SUCCESS;
198 const EventContext& ctx)
const
220 std::unique_ptr<TileCellContainer> MBTSCells;
225 std::unique_ptr<TileCellContainer> E4prCells;
237 caloNoise = noiseH.
cptr();
242 build (caloNoise, drawerEvtStatus,
begin,
end, theCellContainer,
243 MBTSCells.get(), E4prCells.get(), *samplingFraction);
258 if (theCellContainer->
hasCalo(caloNum)) {
279 unsigned int flag = 0;
281 int drConsecMaxMax = 0;
284 for (
int p = 1;
p < 5; ++
p) {
295 for (
int d = 0;
d < 64; ++
d) {
305 if (drConsec > drConsecMax) {
306 drConsecMax = drConsec;
307 if (drConsecMax > drConsecMaxMax) {
308 drConsecMaxMax = drConsecMax;
309 drConsecNum = ((
p - 1) << 6) | (
d - drConsec);
316 if (
evt[
d].nBadQuality) ++hasBadQ;
317 if (
evt[
d].nOverflow) ++hasOver;
318 if (
evt[
d].nUnderflow) ++hasUnder;
319 if (
evt[
d].nSomeSignal) ++hasSig;
322 if (drConsec != 0 && drConsecMax < 64) {
323 for (
int d = 0;
d < drConsecMax; ++
d) {
330 if (drConsec > drConsecMax) {
331 drConsecMax = drConsec;
344 if (hasBadQ > 15) fl |= 0x00001000;
345 if (hasOver) fl |= 0x00000100;
346 if (hasUnder) fl |= 0x00000010;
347 if (hasSig) fl |= 0x00000001;
349 #ifdef ALLOW_DEBUG_COUT
350 std::cout<<
"partition "<<
p<<
" drAbsent "<<drAbsent<<
" drMasked "<<drMasked<<
" drConsec "<<drConsecMax
351 <<
" hasBadQ "<<hasBadQ<<
" hasOver "<<hasOver<<
" hasUnder "<<hasUnder<<
" hasSig "<<hasSig<<std::endl;
353 flag |= fl << (
p - 1);
364 flag |= (drConsecNum << 20);
365 #ifdef ALLOW_DEBUG_COUT
366 std::cout<<
"warning in partition " << (drConsecNum>>6)+1 <<
" for modules "
367 <<(drConsecNum)%64 <<
" - " <<(drConsecNum+drConsecMaxMax-1)%64 <<std::endl;
371 #ifdef ALLOW_DEBUG_COUT
372 std::cout<<
"partition flag 0x0"<<std::hex<<
flag<<std::dec<<
" error "<<
error<<std::endl;
384 ATH_MSG_DEBUG(
" set eventInfo for Tile for this event to 0x" << MSG::hex <<
flag << MSG::dec );
399 ATH_MSG_WARNING(
" cannot retrieve EventInfo, will not set Tile information " );
403 ATH_MSG_DEBUG(
"TileCellBuilderFromHit execution completed." );
405 return StatusCode::SUCCESS;
410 ,
float ener,
float time,
unsigned char iqual,
unsigned char qbit)
const {
433 ,
bool good_time,
bool good_ener,
bool overflow,
bool underflow,
bool overfit)
const {
435 ++drawerEvtStatus[
ros][
drawer].nChannels;
438 if (overflow) ++drawerEvtStatus[
ros][
drawer].nOverflow;
439 if (underflow) ++drawerEvtStatus[
ros][
drawer].nUnderflow;
441 #ifdef ALLOW_DEBUG_COUT
442 if (overflow) std::cout <<
"channel with overflow " << ((count_over)?
"":
"MBTS") << std::endl;
443 if (underflow) std::cout <<
"channel with underflow " << ((count_over)?
"":
"MBTS") << std::endl;
444 if (overfit) std::cout <<
"channel with corrected overflow " << ((count_over)?
"":
"MBTS") << std::endl;
455 ++drawerEvtStatus[
ros][
drawer].nSomeSignal;
481 ++drawerEvtStatus[
ros][
drawer].nBadQuality;
491 ++drawerEvtStatus[
ros][
drawer].nMaskedChannels;
520 TileCell* pCell,
bool single_PMT_C10,
bool Ecell)
const {
540 ++drawerEvtStatus[ros1][drawer1].nBadQuality;
553 ++drawerEvtStatus[ros1][drawer1].nMaskedChannels;
587 ++drawerEvtStatus[ros2][drawer2].nBadQuality;
595 if (single_PMT_C10) {
601 #ifdef ALLOW_DEBUG_COUT
605 << drawer2+1 <<
" status " <<
chan1 <<
"/" << chan2 <<
" "
606 << (chStatus1.
isBad()?
"bad":
"good") <<
"/"
607 << (chStatus2.
isBad()?
"bad":
"good") <<
"/"
608 << ((
m_RUN2plus)?
" RUN2+ cabling":
"RUN1 cabling")
614 #ifdef ALLOW_DEBUG_COUT
616 std::cout <<
"Ene of chan1 was " << pCell->
ene1() <<
" changing to half of " << pCell->
ene2()
617 <<
" and setting bad1=true" << std::endl;
623 --drawerEvtStatus[ros1][drawer1].nMaskedChannels;
627 #ifdef ALLOW_DEBUG_COUT
629 std::cout <<
"Ene of chan2 was " << pCell->
ene2() <<
" changing to half of " << pCell->
ene1()
630 <<
" and setting bad2=true" << std::endl;
636 --drawerEvtStatus[ros2][drawer2].nMaskedChannels;
642 ++drawerEvtStatus[ros1][drawer1].nMaskedChannels;
643 ++drawerEvtStatus[ros2][drawer2].nMaskedChannels;
658 }
else if (bad1 && !bad2) {
660 ++drawerEvtStatus[ros1][drawer1].nMaskedChannels;
662 float ene2 = pCell->
ene2();
681 }
else if (!bad1 && bad2) {
683 ++drawerEvtStatus[ros2][drawer2].nMaskedChannels;
685 float ene1 = pCell->
ene1();
728 return single_PMT_C10;
732 template<
class ITERATOR,
class COLLECTION>
734 TileDrawerEvtStatusArray& drawerEvtStatus,
735 const ITERATOR &
begin,
const ITERATOR &
end, COLLECTION * coll,
741 const EventContext& ctx = Gaudi::Hive::currentContext();
743 wrapper->
setSeed (rngname, ctx);
744 CLHEP::HepRandomEngine* engine = wrapper->
getEngine (ctx);
756 float eCellTot = 0.0;
757 float eMBTSTot = 0.0;
758 float eE4prTot = 0.0;
759 bool EBdrawerPresent[128];
760 memset(EBdrawerPresent, 0,
sizeof(EBdrawerPresent));
761 #ifdef USE_TILECELLS_DATAPOOL
769 bool overflow =
false;
770 bool underflow =
false;
771 bool overfit =
false;
775 std::vector<TileCell*> MBTSVec;
779 std::vector<TileCell*> E4prVec;
784 for (ITERATOR hitItr =
begin; hitItr !=
end; ++hitItr) {
786 const TileHit* pHit = (*hitItr);
794 int hitsize = pHit->
size();
795 for (
int ind = 0;
ind < hitsize; ++
ind) {
804 float ener = ener_min;
808 bool good_time =
false;
809 bool non_zero_time = (ehit!=0.0);
821 if (ener > 10000. *
MeV) {
824 good_time = (fabs(
time) < 25.);
827 bool MBTS =
false, E4pr =
false, E1_CELL =
false;
881 unsigned char qbit =
qbits(drawerEvtStatus,
883 , overflow, underflow, overfit);
891 pCell->
set(NULL, cell_id);
905 <<
" iqual= " << (
int) iqual
906 <<
" qbit = 0x" << MSG::hex << (
int) qbit << MSG::dec <<
endmsg;
909 if (E4prVec[
index]) {
911 <<
" ignoring previous value" <<
endmsg;
913 E4prVec[
index] = pCell;
929 unsigned char qbit =
qbits(drawerEvtStatus,
930 ros,
drawer,
false, (good_time && non_zero_time)
953 <<
" iqual= " << (
int) iqual
954 <<
" qbit = 0x" << MSG::hex << (
int) qbit << MSG::dec <<
endmsg;
957 if (MBTSVec[
index]) {
959 <<
" ignoring previous value" <<
endmsg;
961 MBTSVec[
index] = pCell;
969 unsigned char qbit =
qbits(drawerEvtStatus,
ros,
drawer,
true, non_zero_time,
980 allCells[
index2] = pCell2;
982 pCell2->
set(dde2, cell_id2);
1001 pCell->
set(dde, cell_id);
1007 float calib1 = (ehit != 0.0) ? ener / ehit : 0.0;
1010 <<
" calib=" << calib1
1011 <<
" nCell=" << nCell
1012 <<
" energy=" << ener <<
" (" << pCell->
energy() <<
", " << pCell->
eneDiff() <<
")" <<
endmsg;
1015 <<
" time= " <<
time
1016 <<
" iqual= " << (
int) iqual
1017 <<
" qbit = 0x" << MSG::hex << (
int) qbit << MSG::dec <<
endmsg;
1024 unsigned char iqual = 0;
1049 bool single_PMT = Ecell || single_PMT_C10;
1053 if ( ! missing_D4 ) {
1056 if (!single_PMT) ++nTwo;
1059 pCell->
set(dde, cell_id);
1075 <<
" bad channels masked, new energy=" << pCell->
energy() );
1077 bool bad1=pCell->
badch1();
1078 bool bad2=pCell->
badch2();
1080 if (! (bad1 && bad2) ) {
1087 if (bad1 || bad2 || single_PMT) {
1089 float ene = RandGaussQ::shoot(engine, 0.0, noiseSigma);
1092 <<
" sigma " << noiseSigma <<
" noise " << ene );
1105 float ene = RandGaussQ::shoot(engine, 0.0, noiseSigma);
1107 <<
" sigma " << noiseSigma <<
" noise " << ene );
1116 noiseSigma *= M_SQRT1_2;
1117 float ene1 = RandGaussQ::shoot(engine, 0.0, noiseSigma);
1118 float ene2 = RandGaussQ::shoot(engine, 0.0, noiseSigma);
1121 <<
" sigma " << noiseSigma*M_SQRT2 <<
" noise " << ene1+ene2 <<
" noise1 " << ene1 <<
" noise2 " << ene2 );
1128 coll->push_back(pCell);
1129 allCells[
index] = 0;
1143 bool merged_MBTS = (
eta == 1 && (
phi&1) == 1 &&
m_RUN2);
1145 if (!pCell && !merged_MBTS) {
1161 <<
" bad channel masked, new energy=" << pCell->
energy() );
1193 <<
" bad channel masked, new energy=" << pCell->
energy() );
1203 <<
" RawChSum=" << eCh
1204 <<
" nCell=" << nCell
1206 <<
" nFake=" << nFake
1207 <<
" eneTot=" << eCellTot;
1211 <<
" eMBTS=" << eMBTSTot;
1214 <<
" eE4pr=" << eE4prTot;
def retrieve(aClass, aKey=None)
SG::ReadCondHandleKey< TileSamplingFraction > m_samplingFractionKey
Name of TileSamplingFraction in condition store.
Identifier identify(void) const
Return logical ID of the pmt.
static const int NCELLMBTS
float getSamplingFraction(unsigned int drawerIdx, unsigned int channel) const
Return Tile Calorimeter sampling fraction.
void setQbit2(unsigned char qbit)
set quality bits of second PMT
void setSeed(const std::string &algName, const EventContext &ctx)
Set the random seed using a string (e.g.
int e4pr_index(int phi) const
IdentifierHash onl2() const
cell online identifier 2
float m_noiseSigma
cell electronic noise if CaloNoise is switched off
unsigned constexpr int nChannels
void setTime_nonvirt(float t)
float time1(void) const
get time of first PMT
Identifier channel_id(int type, int module, int channel) const
identifer for one channel of a Tile testbeam detector
virtual void setTime(float t) override final
set cell time, reset timeDiff
size_type cell_hash_max(void) const
std::string to_string(const Identifier &id, int level=0) const
extract all fields from TileTB identifier Identifier get_all_fields ( const Identifier & id,...
float getEffectiveSigma(const Identifier id, const int gain, const float energy) const
SG::ReadCondHandleKey< CaloNoise > m_caloNoiseKey
Scalar phi() const
phi method
bool is_tiletb(const Identifier &id) const
Test ID if it is TileTBID.
void set(const CaloDetDescrElement *caloDDE, const Identifier &ID)
Fast method to change the identity of a cell.
const_pointer_type cptr()
Dereference the pointer.
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
const TileHWID * m_tileHWID
Pointer to TileHWID.
virtual ~TileCellBuilderFromHit()
Destructor.
Scalar eta() const
pseudorapidity method
float time2(void) const
get time of second PMT
int pmt(const Identifier &id) const
void setQual2(unsigned char qual)
set quality of second PMT
void setHasCalo(const CaloCell_ID::SUBCALO caloNum)
set which calo has been filled.
float ene1(void) const
get energy of first PMT
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
bool badch1(void) const
check if first PMT is in bad channel list and masked
SG::WriteHandleKey< TileCellContainer > m_MBTSContainerKey
Class holding bad channel problems.
int side(const Identifier &id) const
const TileCablingService * m_cabling
Pointer to TileCabling.
int sample(const Identifier &id) const
void build(const CaloNoise *caloNoise, TileDrawerEvtStatusArray &drawerEvtStatus, const ITERATOR &begin, const ITERATOR &end, COLLECTION *coll, TileCellContainer *MBTSCells, TileCellContainer *E4prCells, const TileSamplingFraction *samplingFraction) const
unsigned char qbits(TileDrawerEvtStatusArray &drawerEvtStatus, int ros, int drawer, bool count_over, bool good_time, bool good_ener, bool overflow, bool underflow, bool good_overflowfit) const
method to compute the cell quality bits
@ NotSet
The flag was not set to anything.
const MbtsDetDescrManager * m_mbtsMgr
Pointer to MbtsDetDescrManager.
int tower(const Identifier &id) const
#define ATH_MSG_VERBOSE(x)
SG::ReadCondHandleKey< TileEMScale > m_emScaleKey
Name of TileEMScale in condition store.
const std::string & key() const
Return the StoreGate ID for the referenced object.
Hash table for Tile fragments (==drawers ==collections in StoreGate)
virtual StatusCode finalize() override
bool empty() const
Test if the key is blank.
int type(const Identifier &id) const
extract type field from TileTB identifier
float m_zeroEnergy
energy to store in every PMT if both PMT are bad
bool updateEventFlags(const EventFlagSubDet subDet, const uint32_t flags_in) const
Turn on a set of event flags for one particular sub-detector.
int size(void) const
Return length of energy/time vectors
int module(const Identifier &id) const
extract module field from TileTB identifier
int channel(const HWIdentifier &id) const
extract channel field from HW identifier
void correctCell(TileCell *pCell, int correction, int pmt, int gain, float ener, float time, unsigned char iqual, unsigned char qbit) const
Compute calibrated energy, time, etc.
const TileID * m_tileID
Pointer to TileID.
double energy() const
get energy (data member)
@ Error
The sub-detector issued an error.
int ros(const HWIdentifier &id) const
extract ros field from HW identifier
virtual StatusCode initialize() override
Initializer.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
IdentifierHash onl1() const
cell online identifier 1
TileFragHash::TYPE m_RChType
Type of TileRawChannels (Fit, OF2, etc.)
SG::WriteHandleKey< TileCellContainer > m_E4prContainerKey
void setQbit1(unsigned char qbit)
set quality bits of first PMT
float calibrateChannel(unsigned int drawerIdx, unsigned int channel, unsigned int adc, float amplitude, TileRawChannelUnit::UNIT rawDataUnitIn, TileRawChannelUnit::UNIT rawDataUnitOut) const
Calibrate a Tile channel.
Handle class for recording to StoreGate.
uint8_t qual2(void) const
get quality of second PMT (data member)
Identifier identify() const override final
cell identifier
bool isRun2PlusCabling() const
bool maskBadChannel(TileDrawerEvtStatusArray &drawerEvtStatus, TileCell *pCell) const
method to check if channels are good or bad.
unsigned char iquality(float qual) const
int module(const Identifier &id) const
float m_minTime
minimum time for the PMTs in the cels
Condition object to keep and provide Tile Calorimeter sampling fraction and number of photoelectrons.
An interface for getting the name of a class as a string.
::StatusCode StatusCode
StatusCode definition for legacy code.
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
bool badch2(void) const
check if second PMT is in bad channel list and masked
void setEnergy_nonvirt(float e1, float e2, int gain1, int gain2)
SUBCALO
enumeration of sub calorimeters
static std::string name()
Return the name of class T as a string.
bool maskBadChannels(TileDrawerEvtStatusArray &drawerEvtStatus, TileCell *pCell, bool single_PMT_C10, bool Ecell) const
CaloDetDescrElement * get_element(const Identifier &elementId) const
uint8_t qbit1(void) const
get quality bits of first PMT (data member)
float m_eneForTimeCutMBTS
similar cut for MBTS in pC
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
SG::ReadHandleKey< TileHitContainer > m_hitContainerKey
int gain1(void) const
get gain of first PMT
float eneDiff(void) const
all get methods
EventFlagErrorState
States that a given sub-detector could be in.
int channel(const Identifier &id) const
extract channel field from TileTB identifier
virtual bool isValid() override final
Can the handle be successfully dereferenced?
static const int NCELLE4PR
CaloDetDescrElement * get_cell_element(unsigned int cell_hash) const
TileDrawerEvtStatus TileDrawerEvtStatusArray[5][64]
status of every drawer
int getCablingType() const
A wrapper class for event-slot-local random engines.
ServiceHandle< IAthRNGSvc > m_rndmSvc
< Random number service to use
void setQuality(unsigned char qual, unsigned char qbit, int pmt)
set quality value and quality bits for one PMT
HWIdentifier channel_id(int ros, int drawer, int channel) const
channel HWIdentifer
Helpers for checking error return status codes and reporting errors.
CaloGain::CaloGain gain() const
get gain (data member )
value_type push_back(value_type pElem)
Add an element to the end of the collection.
StatusCode initialize(bool used=true)
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
static const InterfaceID & interfaceID()
Container class for CaloCell.
virtual void addEnergy(float e) override final
add energy, keep eneDiff
virtual void setEnergy(float ene) override final
set total energy, reset eneDiff to zero
CLHEP::HepRandomEngine * getEngine(const EventContext &ctx) const
Retrieve the random engine corresponding to the provided EventContext.
float m_eneForTimeCut
keep time for channels with energy above cut
uint8_t qbit2(void) const
get quality bits of second PMT (data member)
@ Warning
The sub-detector issued a warning.
int gain2(void) const
get gain of second PMT
@ Tile
The Tile calorimeter.
float ene2(void) const
get energy of second PMT
static bool C10_connected(int module)
int drawer(const HWIdentifier &id) const
extract drawer field from HW identifier
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
def time(flags, cells_name, *args, **kw)
std::string to_string(const Identifier &id, int level=0) const
#define ATH_MSG_WARNING(x)
virtual StatusCode process(CaloCellContainer *theCellContainer, const EventContext &ctx) const override
method to process all raw channels and store them in container
float energy(int ind=0) const
Return energy of ind-th sub-hit
This class keep detailed status info about one drawer in a given event.
bool m_maskBadChannels
if true=> bad channels are masked
float m_maxTime
maximum time for the PMTs in the cels
a typed memory pool that saves time spent allocation small object. This is typically used by containe...
uint8_t qual1(void) const
get quality of first PMT (data member)
void setQual1(unsigned char qual)
set quality of first PMT
const TileTBID * m_tileTBID
Pointer to TileTBID.
int m_qualityCut
cut on channel quality (set energy to m_zeroEnergy for them)
bool hasCalo(const CaloCell_ID::SUBCALO caloNum) const
tell wether it has been filled with cells (maybe none) of a given calo
bool updateErrorState(const EventFlagSubDet subDet, const EventFlagErrorState state) const
Update the error state for one particular sub-detector.
ToolHandle< ITileBadChanTool > m_tileBadChanTool
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
IdentifierHash cell_hash(const Identifier &cell_id) const
fast conversion from ID to hash for cells
int section(const Identifier &id) const
Handle class for reading from StoreGate.
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
const TileDetDescrManager * m_tileMgr
Pointer to TileDetDescrManager.
Identifier cell_id(const Identifier &any_id) const
float time(int ind=0) const
Return time of ind-th sub-hit
ServiceHandle< TileCablingSvc > m_cablingSvc
Name of Tile cabling service.
int mbts_index(int side, int phi, int eta) const
int E1_merged_with_run2plus(int ros, int module) const
HWIdentifier s2h_channel_id(const Identifier &id) const
TileCellBuilderFromHit(const std::string &type, const std::string &name, const IInterface *parent)
Contructor.
const_pointer_type cptr()