739{
741 const EventContext& ctx = Gaudi::Hive::currentContext();
742 ATHRNG::RNGWrapper* wrapper =
m_rndmSvc->getEngine(
this);
743 wrapper->
setSeed (rngname, ctx);
745
746 SG::ReadCondHandle<TileEMScale> emScale(
m_emScaleKey, ctx);
747
748
749 int nTwo = 0;
750 int nCell = 0;
751 int nFake = 0;
752 int nMBTS = 0;
753 int nE4pr = 0;
754 int nChan = 0;
755 float eCh = 0.0;
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
762 DataPool<TileCell> tileCellsP(5217);
763#endif
764
765
766
767
768
769 bool overflow = false;
770 bool underflow = false;
771 bool overfit = false;
773
774 std::vector<TileCell*> allCells (
m_tileID->cell_hash_max(),
nullptr);
775 std::vector<TileCell*> MBTSVec;
776 if (MBTSCells) {
778 }
779 std::vector<TileCell*> E4prVec;
780 if (E4prCells) {
782 }
783
784 for (ITERATOR hitItr = begin; hitItr !=
end; ++hitItr) {
785
786 const TileHit* pHit = (*hitItr);
787
788
789 Identifier cell_id = pHit->
identify();
790
791 double ehit = 0.;
792 double thit = 0.;
793
794 int hitsize = pHit->
size();
795 for (int ind = 0; ind < hitsize; ++ind) {
796 float tim = pHit->
time(ind);
798 float ene = pHit->
energy(ind);
799 ehit += ene;
800 thit += tim*ene;
801 }
802 }
803
804 float ener = ener_min;
808 bool good_time = false;
809 bool non_zero_time = (ehit!=0.0);
810
816
817 if (non_zero_time) {
819
821 if (ener > 10000. * MeV) {
823 }
824 good_time = (fabs(time) < 25.);
825 }
826
827 bool MBTS = false, E4pr = false, E1_CELL = false;
829
830
832
838 MBTS = true;
840 } else {
841 E4pr = true;
843 }
844
845 } else {
846
847 MBTS = false;
848 E4pr = false;
849
851
852 cell_id =
m_tileID->cell_id(cell_id);
854
860
861
862
868 }
869
870 ++nChan;
871 eCh += ener;
872
873 if (E4pr) {
874
875 if (E4prCells) {
876 ++nE4pr;
877
878 eE4prTot += ener;
879 unsigned char iqual =
iquality(qual);
880
881 unsigned char qbit =
qbits(drawerEvtStatus,
883 , overflow, underflow, overfit);
887
889
890
891 pCell->
set(NULL, cell_id);
898
899 if (msgLvl(MSG::VERBOSE)) {
900 msg(MSG::VERBOSE) <<
" E4' cell_id=" <<
m_tileTBID->to_string(cell_id)
902 << " ene= " << ener
903 << " ehit= " << ehit
905 <<
" iqual= " << (
int) iqual
906 <<
" qbit = 0x" << MSG::hex << (
int) qbit << MSG::dec <<
endmsg;
907 }
908
909 if (E4prVec[index]) {
910 msg(MSG::WARNING) <<
" double E4' cell_id=" <<
m_tileTBID->to_string(cell_id)
911 <<
" ignoring previous value" <<
endmsg;
912 }
913 E4prVec[
index] = pCell;
914 }
915
916 } else if (MBTS) {
917
918 if (MBTSCells) {
919 ++nMBTS;
920
921
922 ener /= emScale->calibrateChannel(drawerIdx, channel, gain, 1.,
926 eMBTSTot += ener;
927 unsigned char iqual =
iquality(qual);
928
929 unsigned char qbit =
qbits(drawerEvtStatus,
930 ros, drawer, false, (good_time && non_zero_time)
935
937
938
946
947 if (msgLvl(MSG::VERBOSE)) {
948 msg(MSG::VERBOSE) <<
" MBTS cell_id=" <<
m_tileTBID->to_string(cell_id)
950 << " ene= " << ener
951 << " ehit= " << ehit
953 <<
" iqual= " << (
int) iqual
954 <<
" qbit = 0x" << MSG::hex << (
int) qbit << MSG::dec <<
endmsg;
955 }
956
957 if (MBTSVec[index]) {
958 msg(MSG::WARNING) <<
" double MBTS cell_id=" <<
m_tileTBID->to_string(cell_id)
959 <<
" ignoring previous value" <<
endmsg;
960 }
961 MBTSVec[
index] = pCell;
962 }
963 } else {
964
965 eCellTot += ener;
966
967 unsigned char iqual =
iquality(qual);
968
969 unsigned char qbit =
qbits(drawerEvtStatus, ros, drawer,
true, non_zero_time,
971
973
974 int drawer2 =
m_cabling->E1_merged_with_run2plus(ros,drawer);
975 if (drawer2 != 0) {
979 ++nCell;
980 allCells[
index2] = pCell2;
981 const CaloDetDescrElement* dde2 =
m_tileMgr->get_cell_element(index2);
982 pCell2->
set(dde2, cell_id2);
984 int pmt2(0);
985 ener *= 0.5F;
986 correctCell(pCell2, 1, pmt2, gain, ener, time, iqual, qbit);
987
989 <<
" split into " <<
m_tileID->to_string(cell_id2));
990 }
991 }
992
993 TileCell* pCell = allCells[
index];
994 if (pCell) {
995 ++nTwo;
996 correctCell(pCell, 2, pmt, gain, ener, time, iqual, qbit);
997 } else {
998 ++nCell;
1000 const CaloDetDescrElement* dde =
m_tileMgr->get_cell_element(index);
1001 pCell->
set(dde, cell_id);
1003 correctCell(pCell, 1, pmt, gain, ener, time, iqual, qbit);
1004 }
1005
1006 if (msgLvl(MSG::VERBOSE)) {
1007 float calib1 = (ehit != 0.0) ? ener / ehit : 0.0;
1008 msg(MSG::VERBOSE) <<
" cell_id=" <<
m_tileID->to_string(cell_id, -2)
1010 << " calib=" << calib1
1011 << " nCell=" << nCell
1012 <<
" energy=" << ener <<
" (" << pCell->
energy() <<
", " << pCell->
eneDiff() <<
")" <<
endmsg;
1013
1014 msg(MSG::VERBOSE) <<
" ehit= " << ehit
1015 <<
" time= " <<
time
1016 <<
" iqual= " << (
int) iqual
1017 <<
" qbit = 0x" << MSG::hex << (
int) qbit << MSG::dec <<
endmsg;
1018 }
1019 }
1020 }
1021
1022
1023
1024 unsigned char iqual = 0;
1026
1027
1028
1029
1030 for (
unsigned int index = 0;
index < allCells.size(); ++
index) {
1031
1032 TileCell * pCell = allCells[
index];
1033 const CaloDetDescrElement* dde =
m_tileMgr->get_cell_element(index);
1034 if(!dde)
1035 {
1037 continue;
1038 }
1039 Identifier cell_id = dde->
identify();
1040
1045
1049 bool single_PMT = Ecell || single_PMT_C10;
1050
1051 if (!pCell) {
1052
1053 if ( ! missing_D4 ) {
1054
1055 ++nCell;
1056 if (!single_PMT) ++nTwo;
1057
1059 pCell->
set(dde, cell_id);
1060
1065
1067 }
1068 }
1069
1070 if (pCell) {
1071
1075 <<
" bad channels masked, new energy=" << pCell->
energy() );
1076
1077 bool bad1=pCell->
badch1();
1078 bool bad2=pCell->
badch2();
1079
1080 if (! (bad1 && bad2) ) {
1081
1083 if (caloNoise) {
1085 }
1086
1087 if (bad1 || bad2 || single_PMT) {
1088
1089 float ene = RandGaussQ::shoot(engine, 0.0, noiseSigma);
1090
1092 << " sigma " << noiseSigma << " noise " << ene );
1093 if (Ecell)
1095 else
1097
1098 } else {
1099
1102
1103 if (gain1!=gain2) {
1104
1105 float ene = RandGaussQ::shoot(engine, 0.0, noiseSigma);
1107 << " sigma " << noiseSigma << " noise " << ene );
1108
1111 else
1113
1114 } else {
1115
1116 noiseSigma *= M_SQRT1_2;
1117 float ene1 = RandGaussQ::shoot(engine, 0.0, noiseSigma);
1118 float ene2 = RandGaussQ::shoot(engine, 0.0, noiseSigma);
1119
1121 << " sigma " << noiseSigma*M_SQRT2 << " noise " << ene1+ene2 << " noise1 " << ene1 << " noise2 " << ene2 );
1122
1125 }
1126 }
1127 }
1128 coll->push_back(pCell);
1129 allCells[
index] = 0;
1130 }
1131 }
1132
1133
1134 if (MBTSCells) {
1135
1139
1141 TileCell * pCell = MBTSVec[
index];
1142
1143 bool merged_MBTS = (
eta == 1 && (
phi&1) == 1 &&
m_RUN2);
1144
1145 if (!pCell && !merged_MBTS) {
1146
1147 ++nMBTS;
1149
1150 Identifier cell_id =
m_tileTBID->channel_id((side > 0) ? 1 : -1,
phi,
eta);
1156 }
1157
1158 if (pCell) {
1161 <<
" bad channel masked, new energy=" << pCell->
energy() );
1162
1165 }
1166 }
1167 }
1168 }
1169 }
1170
1171 if (E4prCells) {
1172
1174
1176 TileCell * pCell = E4prVec[
index];
1177
1178 if (!pCell) {
1179
1180 ++nE4pr;
1182
1188 }
1189
1190 if (pCell) {
1193 <<
" bad channel masked, new energy=" << pCell->
energy() );
1194
1197 }
1198 }
1199 }
1200
1201 if (msgLvl(MSG::DEBUG)) {
1202 msg(MSG::DEBUG) <<
" nChan=" << nChan
1203 << " RawChSum=" << eCh
1204 << " nCell=" << nCell
1205 << " n2=" << nTwo
1206 << " nFake=" << nFake
1207 << " eneTot=" << eCellTot;
1208
1209 if (MBTSCells)
1210 msg(MSG::DEBUG) <<
" nMBTS=" << nMBTS
1211 << " eMBTS=" << eMBTSTot;
1212 if (E4prCells)
1213 msg(MSG::DEBUG) <<
" nE4pr=" << nE4pr
1214 << " eE4pr=" << eE4prTot;
1215
1217 }
1218}
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
method to check if channels are good or bad.
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
bool maskBadChannels(TileDrawerEvtStatusArray &drawerEvtStatus, TileCell *pCell, bool single_PMT_C10, bool Ecell) const
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)