740{
742 const EventContext& ctx = Gaudi::Hive::currentContext();
743 ATHRNG::RNGWrapper* wrapper =
m_rndmSvc->getEngine(
this);
744 wrapper->
setSeed (rngname, ctx);
746
747 SG::ReadCondHandle<TileEMScale> emScale(
m_emScaleKey, ctx);
748
749
750 int nTwo = 0;
751 int nCell = 0;
752 int nFake = 0;
753 int nMBTS = 0;
754 int nE4pr = 0;
755 int nChan = 0;
756 float eCh = 0.0;
757 float eCellTot = 0.0;
758 float eMBTSTot = 0.0;
759 float eE4prTot = 0.0;
760 bool EBdrawerPresent[128];
761 memset(EBdrawerPresent, 0, sizeof(EBdrawerPresent));
762#ifdef USE_TILECELLS_DATAPOOL
763 DataPool<TileCell> tileCellsP(5217);
764#endif
765
766
767
768
769
770 bool overflow = false;
771 bool underflow = false;
772 bool overfit = false;
774
775 std::vector<TileCell*> allCells (
m_tileID->cell_hash_max(),
nullptr);
776 std::vector<TileCell*> MBTSVec;
777 if (MBTSCells) {
779 }
780 std::vector<TileCell*> E4prVec;
781 if (E4prCells) {
783 }
784
785 for (ITERATOR hitItr = begin; hitItr !=
end; ++hitItr) {
786
787 const TileHit* pHit = (*hitItr);
788
789
790 Identifier cell_id = pHit->
identify();
791
792 double ehit = 0.;
793 double thit = 0.;
794
795 int hitsize = pHit->
size();
796 for (
int ind = 0;
ind < hitsize; ++
ind) {
797 float tim = pHit->
time(ind);
799 float ene = pHit->
energy(ind);
800 ehit += ene;
801 thit += tim*ene;
802 }
803 }
804
805 float ener = ener_min;
809 bool good_time = false;
810 bool non_zero_time = (ehit!=0.0);
811
817
818 if (non_zero_time) {
820
822 if (ener > 10000. *
MeV) {
824 }
825 good_time = (fabs(time) < 25.);
826 }
827
828 bool MBTS = false, E4pr = false, E1_CELL = false;
830
831
833
839 MBTS = true;
841 } else {
842 E4pr = true;
844 }
845
846 } else {
847
848 MBTS = false;
849 E4pr = false;
850
852
853 cell_id =
m_tileID->cell_id(cell_id);
855
861
862
863
869 }
870
871 ++nChan;
872 eCh += ener;
873
874 if (E4pr) {
875
876 if (E4prCells) {
877 ++nE4pr;
878
879 eE4prTot += ener;
880 unsigned char iqual =
iquality(qual);
881
882 unsigned char qbit =
qbits(drawerEvtStatus,
884 , overflow, underflow, overfit);
888
890
891
892 pCell->
set(NULL, cell_id);
899
900 if (msgLvl(MSG::VERBOSE)) {
901 msg(MSG::VERBOSE) <<
" E4' cell_id=" <<
m_tileTBID->to_string(cell_id)
903 << " ene= " << ener
904 << " ehit= " << ehit
906 <<
" iqual= " << (
int) iqual
907 <<
" qbit = 0x" << MSG::hex << (
int) qbit << MSG::dec <<
endmsg;
908 }
909
910 if (E4prVec[index]) {
911 msg(MSG::WARNING) <<
" double E4' cell_id=" <<
m_tileTBID->to_string(cell_id)
912 <<
" ignoring previous value" <<
endmsg;
913 }
914 E4prVec[
index] = pCell;
915 }
916
917 } else if (MBTS) {
918
919 if (MBTSCells) {
920 ++nMBTS;
921
922
923 ener /= emScale->calibrateChannel(drawerIdx, channel, gain, 1.,
927 eMBTSTot += ener;
928 unsigned char iqual =
iquality(qual);
929
930 unsigned char qbit =
qbits(drawerEvtStatus,
931 ros, drawer, false, (good_time && non_zero_time)
936
938
939
947
948 if (msgLvl(MSG::VERBOSE)) {
949 msg(MSG::VERBOSE) <<
" MBTS cell_id=" <<
m_tileTBID->to_string(cell_id)
951 << " ene= " << ener
952 << " ehit= " << ehit
954 <<
" iqual= " << (
int) iqual
955 <<
" qbit = 0x" << MSG::hex << (
int) qbit << MSG::dec <<
endmsg;
956 }
957
958 if (MBTSVec[index]) {
959 msg(MSG::WARNING) <<
" double MBTS cell_id=" <<
m_tileTBID->to_string(cell_id)
960 <<
" ignoring previous value" <<
endmsg;
961 }
962 MBTSVec[
index] = pCell;
963 }
964 } else {
965
966 eCellTot += ener;
967
968 unsigned char iqual =
iquality(qual);
969
970 unsigned char qbit =
qbits(drawerEvtStatus, ros, drawer,
true, non_zero_time,
972
974
975 int drawer2 =
m_cabling->E1_merged_with_run2plus(ros,drawer);
976 if (drawer2 != 0) {
980 ++nCell;
981 allCells[
index2] = pCell2;
982 const CaloDetDescrElement* dde2 =
m_tileMgr->get_cell_element(index2);
983 pCell2->
set(dde2, cell_id2);
985 int pmt2(0);
986 ener *= 0.5F;
987 correctCell(pCell2, 1, pmt2, gain, ener, time, iqual, qbit);
988
990 <<
" split into " <<
m_tileID->to_string(cell_id2));
991 }
992 }
993
994 TileCell* pCell = allCells[
index];
995 if (pCell) {
996 ++nTwo;
997 correctCell(pCell, 2, pmt, gain, ener, time, iqual, qbit);
998 } else {
999 ++nCell;
1001 const CaloDetDescrElement* dde =
m_tileMgr->get_cell_element(index);
1002 pCell->
set(dde, cell_id);
1004 correctCell(pCell, 1, pmt, gain, ener, time, iqual, qbit);
1005 }
1006
1007 if (msgLvl(MSG::VERBOSE)) {
1008 float calib1 = (ehit != 0.0) ? ener / ehit : 0.0;
1009 msg(MSG::VERBOSE) <<
" cell_id=" <<
m_tileID->to_string(cell_id, -2)
1011 << " calib=" << calib1
1012 << " nCell=" << nCell
1013 <<
" energy=" << ener <<
" (" << pCell->
energy() <<
", " << pCell->
eneDiff() <<
")" <<
endmsg;
1014
1015 msg(MSG::VERBOSE) <<
" ehit= " << ehit
1016 <<
" time= " <<
time
1017 <<
" iqual= " << (
int) iqual
1018 <<
" qbit = 0x" << MSG::hex << (
int) qbit << MSG::dec <<
endmsg;
1019 }
1020 }
1021 }
1022
1023
1024
1025 unsigned char iqual = 0;
1027
1028
1029
1030
1031 for (
unsigned int index = 0;
index < allCells.size(); ++
index) {
1032
1033 TileCell * pCell = allCells[
index];
1034 const CaloDetDescrElement* dde =
m_tileMgr->get_cell_element(index);
1035 if(!dde)
1036 {
1038 continue;
1039 }
1040 Identifier cell_id = dde->
identify();
1041
1046
1050 bool single_PMT = Ecell || single_PMT_C10;
1051
1052 if (!pCell) {
1053
1054 if ( ! missing_D4 ) {
1055
1056 ++nCell;
1057 if (!single_PMT) ++nTwo;
1058
1060 pCell->
set(dde, cell_id);
1061
1066
1068 }
1069 }
1070
1071 if (pCell) {
1072
1074 if (
maskBadChannels (drawerEvtStatus, pCell, single_PMT_C10, Ecell, ctx))
1076 <<
" bad channels masked, new energy=" << pCell->
energy() );
1077
1078 bool bad1=pCell->
badch1();
1079 bool bad2=pCell->
badch2();
1080
1081 if (! (bad1 && bad2) ) {
1082
1084 if (caloNoise) {
1086 }
1087
1088 if (bad1 || bad2 || single_PMT) {
1089
1090 float ene = RandGaussQ::shoot(engine, 0.0, noiseSigma);
1091
1093 << " sigma " << noiseSigma << " noise " << ene );
1094 if (Ecell)
1096 else
1098
1099 } else {
1100
1103
1104 if (gain1!=gain2) {
1105
1106 float ene = RandGaussQ::shoot(engine, 0.0, noiseSigma);
1108 << " sigma " << noiseSigma << " noise " << ene );
1109
1112 else
1114
1115 } else {
1116
1117 noiseSigma *= M_SQRT1_2;
1118 float ene1 = RandGaussQ::shoot(engine, 0.0, noiseSigma);
1119 float ene2 = RandGaussQ::shoot(engine, 0.0, noiseSigma);
1120
1122 << " sigma " << noiseSigma*M_SQRT2 << " noise " << ene1+ene2 << " noise1 " << ene1 << " noise2 " << ene2 );
1123
1126 }
1127 }
1128 }
1129 coll->push_back(pCell);
1130 allCells[
index] = 0;
1131 }
1132 }
1133
1134
1135 if (MBTSCells) {
1136
1140
1142 TileCell * pCell = MBTSVec[
index];
1143
1144 bool merged_MBTS = (
eta == 1 && (
phi&1) == 1 &&
m_RUN2);
1145
1146 if (!pCell && !merged_MBTS) {
1147
1148 ++nMBTS;
1150
1151 Identifier cell_id =
m_tileTBID->channel_id((side > 0) ? 1 : -1,
phi,
eta);
1157 }
1158
1159 if (pCell) {
1162 <<
" bad channel masked, new energy=" << pCell->
energy() );
1163
1166 }
1167 }
1168 }
1169 }
1170 }
1171
1172 if (E4prCells) {
1173
1175
1177 TileCell * pCell = E4prVec[
index];
1178
1179 if (!pCell) {
1180
1181 ++nE4pr;
1183
1189 }
1190
1191 if (pCell) {
1194 <<
" bad channel masked, new energy=" << pCell->
energy() );
1195
1198 }
1199 }
1200 }
1201
1202 if (msgLvl(MSG::DEBUG)) {
1203 msg(MSG::DEBUG) <<
" nChan=" << nChan
1204 << " RawChSum=" << eCh
1205 << " nCell=" << nCell
1206 << " n2=" << nTwo
1207 << " nFake=" << nFake
1208 << " eneTot=" << eCellTot;
1209
1210 if (MBTSCells)
1211 msg(MSG::DEBUG) <<
" nMBTS=" << nMBTS
1212 << " eMBTS=" << eMBTSTot;
1213 if (E4prCells)
1214 msg(MSG::DEBUG) <<
" nE4pr=" << nE4pr
1215 << " eE4pr=" << eE4prTot;
1216
1218 }
1219}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_MSG_VERBOSE(x)
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.
double energy() const
get energy (data member)
void set(const CaloDetDescrElement *caloDDE, const Identifier &ID)
Fast method to change the identity of a cell.
CaloGain::CaloGain gain() const
get gain (data member )
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
Identifier identify() const override final
cell identifier
float getEffectiveSigma(const Identifier id, const int gain, const float energy) const
static std::string name()
Return the name of class T as a string.
value_type push_back(value_type pElem)
static unsigned int getDrawerIdx(unsigned int ros, unsigned int drawer)
Returns a drawer hash.
const MbtsDetDescrManager * m_mbtsMgr
Pointer to MbtsDetDescrManager.
unsigned char iquality(float qual) const
bool maskBadChannel(TileDrawerEvtStatusArray &drawerEvtStatus, TileCell *pCell, const EventContext &ctx) const
method to check if channels are good or bad.
bool maskBadChannels(TileDrawerEvtStatusArray &drawerEvtStatus, TileCell *pCell, bool single_PMT_C10, bool Ecell, const EventContext &ctx) const
const TileTBID * m_tileTBID
Pointer to TileTBID.
static const int NCELLMBTS
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
SG::ReadCondHandleKey< TileEMScale > m_emScaleKey
Name of TileEMScale in condition store.
const TileDetDescrManager * m_tileMgr
Pointer to TileDetDescrManager.
static const int NCELLE4PR
const TileID * m_tileID
Pointer to TileID.
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 TileHWID * m_tileHWID
Pointer to TileHWID.
const TileCablingService * m_cabling
Pointer to TileCabling.
int e4pr_index(int phi) const
SG::ReadCondHandleKey< CaloNoise > m_caloNoiseKey
int mbts_index(int side, int phi, int eta) const
ServiceHandle< IAthRNGSvc > m_rndmSvc
< Random number service to use
void addEnergy(float e, int pmt, int gain)
set energy and gain for one PMT
void setEnergy_nonvirt(float e1, float e2, int gain1, int gain2)
void setQual2(unsigned char qual)
set quality of second PMT
void setTime_nonvirt(float t)
float eneDiff(void) const
all get methods
int gain2(void) const
get gain of second PMT
bool badch1(void) const
check if first PMT is in bad channel list and masked
int gain1(void) const
get gain of first PMT
void setQbit1(unsigned char qbit)
set quality bits of first PMT
void setQbit2(unsigned char qbit)
set quality bits of second PMT
void setQuality(unsigned char qual, unsigned char qbit, int pmt)
set quality value and quality bits for one PMT (TileCell specific overloads)
void setQual1(unsigned char qual)
set quality of first PMT
bool badch2(void) const
check if second PMT is in bad channel list and masked
float time(int ind=0) const
Return time of ind-th sub-hit.
float energy(int ind=0) const
Return energy of ind-th sub-hit.
Identifier identify(void) const
Return logical ID of the pmt.
int size(void) const
Return length of energy/time vectors.
float getSamplingFraction(unsigned int drawerIdx, unsigned int channel) const
Return Tile Calorimeter sampling fraction.
time(flags, cells_name, *args, **kw)