Skip to content

Commit

Permalink
code checks
Browse files Browse the repository at this point in the history
  • Loading branch information
oljemark committed Jun 2, 2023
1 parent f6823b1 commit 2cbcb3f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 33 deletions.
29 changes: 14 additions & 15 deletions DQM/CTPPS/plugins/TotemT2DQMSource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class TotemT2DQMSource : public DQMEDAnalyzer {
static constexpr double T2_BIN_WIDTH_NS_ = 25. / 4;
MonitorElement* totemT2ErrorFlags_2D_ = nullptr;

enum evFlag{t2TE=0, t2LE, t2MT, t2ML};
enum evFlag { t2TE = 0, t2LE, t2MT, t2ML };

const unsigned int nbinsx_, nbinsy_;
const unsigned int windowsNum_;
Expand Down Expand Up @@ -136,7 +136,6 @@ TotemT2DQMSource::SectorPlots::SectorPlots(

for (unsigned short flag_index = 1; flag_index <= 4; ++flag_index)
eventFlags->setBinLabel(flag_index, "Flag " + std::to_string(flag_index));

}

TotemT2DQMSource::PlanePlots::PlanePlots(DQMStore::IBooker& ibooker,
Expand Down Expand Up @@ -323,7 +322,7 @@ void TotemT2DQMSource::fillErrorFlagsHistogram(const TotemT2Digi& digi, const To
// readout flags histogram filling
for (unsigned int i = 0; i < 4; i++) {
if (digi.getStatus() & (1 << i))
totemT2ErrorFlags_2D_->Fill(i+0.0,detid.arm()+0.0);
totemT2ErrorFlags_2D_->Fill(i + 0.0, detid.arm() + 0.0);
}
}

Expand All @@ -345,27 +344,27 @@ void TotemT2DQMSource::fillFlags(const TotemT2Digi& digi, const TotemT2DetId& de
const TotemT2DetId secId(detid.armId());
const TotemT2DetId planeId(detid.planeId());
if (digi.hasTE()) {
sectorPlots_[secId].eventFlags->Fill(t2TE+0.0);
planePlots_[planeId].eventFlagsPl->Fill(t2TE+0.0);
channelPlots_[detid].eventFlagsCh->Fill(t2TE+0.0);
sectorPlots_[secId].eventFlags->Fill(t2TE + 0.0);
planePlots_[planeId].eventFlagsPl->Fill(t2TE + 0.0);
channelPlots_[detid].eventFlagsCh->Fill(t2TE + 0.0);
}

if (digi.hasLE()) {
sectorPlots_[secId].eventFlags->Fill(t2LE+0.0);
planePlots_[planeId].eventFlagsPl->Fill(t2LE+0.0);
channelPlots_[detid].eventFlagsCh->Fill(t2LE+0.0);
sectorPlots_[secId].eventFlags->Fill(t2LE + 0.0);
planePlots_[planeId].eventFlagsPl->Fill(t2LE + 0.0);
channelPlots_[detid].eventFlagsCh->Fill(t2LE + 0.0);
}

if (digi.hasManyTE()) {
sectorPlots_[secId].eventFlags->Fill(t2MT+0.0);
planePlots_[planeId].eventFlagsPl->Fill(t2MT+0.0);
channelPlots_[detid].eventFlagsCh->Fill(t2MT+0.0);
sectorPlots_[secId].eventFlags->Fill(t2MT + 0.0);
planePlots_[planeId].eventFlagsPl->Fill(t2MT + 0.0);
channelPlots_[detid].eventFlagsCh->Fill(t2MT + 0.0);
}

if (digi.hasManyLE()) {
sectorPlots_[secId].eventFlags->Fill(t2ML+0.0);
planePlots_[planeId].eventFlagsPl->Fill(t2ML+0.0);
channelPlots_[detid].eventFlagsCh->Fill(t2ML+0.0);
sectorPlots_[secId].eventFlags->Fill(t2ML + 0.0);
planePlots_[planeId].eventFlagsPl->Fill(t2ML + 0.0);
channelPlots_[detid].eventFlagsCh->Fill(t2ML + 0.0);
}
}

Expand Down
3 changes: 2 additions & 1 deletion DataFormats/TotemReco/src/TotemT2Digi.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "DataFormats/TotemReco/interface/TotemT2Digi.h"

TotemT2Digi::TotemT2Digi(unsigned short id, unsigned char marker, unsigned short le, unsigned short te, unsigned char status)
TotemT2Digi::TotemT2Digi(
unsigned short id, unsigned char marker, unsigned short le, unsigned short te, unsigned char status)
: id_(id), marker_(marker), lead_edge_(le), trail_edge_(te), status_(status) {}

bool operator<(const TotemT2Digi& lhs, const TotemT2Digi& rhs) {
Expand Down
4 changes: 1 addition & 3 deletions EventFilter/CTPPSRawToDigi/interface/TotemT2VFATFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ namespace totem::nt2::vfat {
}

/// retrieve the header status flags
inline uint8_t statusMarker(const VFATFrame& frame) {
return (frame.getData()[header_offset - 1] >> 8)& 0xf;
}
inline uint8_t statusMarker(const VFATFrame& frame) { return (frame.getData()[header_offset - 1] >> 8) & 0xf; }

/// retrieve the HW identifier for this channel, in firmware >2.1
inline uint16_t newChannelId(const VFATFrame& frame, size_t ch_id) {
Expand Down
2 changes: 1 addition & 1 deletion EventFilter/CTPPSRawToDigi/src/RawDataUnpacker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ int RawDataUnpacker::processOptoRxFrameSampic(const word *buf,
// save frame to output
frame.setPresenceFlags(1);
if ((optoRxId >= FEDNumbering::MINTotemT2FEDID && optoRxId <= FEDNumbering::MAXTotemT2FEDID)) {
frame.setPresenceFlags(15); // check three VFAT signature digits, CRC present
frame.setPresenceFlags(15); // check three VFAT signature digits, CRC present
if (verbosity > 0)
edm::LogWarning("Totem") << "T2 Frame Positions created: " << fp2a << "/" << fp2b << std::endl;

Expand Down
20 changes: 9 additions & 11 deletions EventFilter/CTPPSRawToDigi/src/RawToDigiConverter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ RawToDigiConverter::RawToDigiConverter(const edm::ParameterSet &conf)
EC_fraction(conf.getUntrackedParameter<double>("EC_fraction", 0.6)),
BC_fraction(conf.getUntrackedParameter<double>("BC_fraction", 0.6)),

olderTotemT2FileTest(conf.existsAs<bool>("useOlderT2TestFile", true)
? conf.getParameter<bool>("useOlderT2TestFile")
: false) {}
olderTotemT2FileTest(
conf.existsAs<bool>("useOlderT2TestFile", true) ? conf.getParameter<bool>("useOlderT2TestFile") : false) {}

void RawToDigiConverter::runCommon(const VFATFrameCollection &input,
const TotemDAQMapping &mapping,
Expand Down Expand Up @@ -88,12 +87,12 @@ void RawToDigiConverter::runCommon(const VFATFrameCollection &input,
record.status.setNumberOfClusters(record.frame->getNumberOfClusters());

// check for T2 payload bits
int rawT2=fr.Position().getRawPosition();
bool isT2Frame=(rawT2 >> 18);
int rawT2 = fr.Position().getRawPosition();
bool isT2Frame = (rawT2 >> 18);

// check footprint
if (((!isT2Frame) && testFootprint != tfNoTest && !record.frame->checkFootprint()) ||
(isT2Frame && testFootprint != tfNoTest && !record.frame->checkFootprintT2())) {
(isT2Frame && testFootprint != tfNoTest && !record.frame->checkFootprintT2())) {
problemsPresent = true;

if (verbosity > 0)
Expand All @@ -107,7 +106,7 @@ void RawToDigiConverter::runCommon(const VFATFrameCollection &input,

// check CRC
if (((!isT2Frame) && (testCRC != tfNoTest && !record.frame->checkCRC())) ||
(isT2Frame && testCRC != tfNoTest && !record.frame->checkCRCT2())) {
(isT2Frame && testCRC != tfNoTest && !record.frame->checkCRCT2())) {
problemsPresent = true;

if (verbosity > 0)
Expand Down Expand Up @@ -137,7 +136,7 @@ void RawToDigiConverter::runCommon(const VFATFrameCollection &input,
string message = (stopProcessing) ? "(and will be dropped)" : "(but will be used though)";
if (verbosity > 2) {
if (isT2Frame && verbosity > 3)
record.frame->PrintT2();
record.frame->PrintT2();
ees << " Frame at " << fr.Position() << " seems corrupted " << message << ":" << endl;
ees << fes.rdbuf();
} else
Expand Down Expand Up @@ -410,8 +409,7 @@ void RawToDigiConverter::run(const VFATFrameCollection &coll,
int allT2 = 0;
int goodT2 = 0;
int foundT2 = 0;
const int T2shiftOld =
(olderTotemT2FileTest ? 8 : 0); //Run on TOTEM T2 test file (ver 2.1) or final T2 data ver 2.3
const int T2shiftOld = (olderTotemT2FileTest ? 8 : 0); //Run on TOTEM T2 test file (ver 2.1) or final T2 data ver 2.3

// second loop over data
for (auto &p : records) {
Expand Down Expand Up @@ -447,7 +445,7 @@ void RawToDigiConverter::run(const VFATFrameCollection &coll,
totem::nt2::vfat::channelMarker(*record.frame, frame_id),
totem::nt2::vfat::leadingEdgeTime(*record.frame, frame_id),
totem::nt2::vfat::trailingEdgeTime(*record.frame, frame_id),
totem::nt2::vfat::statusMarker(*record.frame));
totem::nt2::vfat::statusMarker(*record.frame));
foundT2++;
} else {
if (verbosity > 2)
Expand Down
3 changes: 1 addition & 2 deletions EventFilter/CTPPSRawToDigi/src/VFATFrame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ void VFATFrame::PrintT2(bool binary) const {
for (int i = 0; i < 11; i++)
crc_fin = calculateCRC(crc_fin, data[i]);

printf("CRC = %04x ",
getCRCT2());
printf("CRC = %04x ", getCRCT2());

if (checkCRCT2())
printf("( OK), footprint ");
Expand Down

0 comments on commit 2cbcb3f

Please sign in to comment.