Skip to content
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions DataFormats/L1Scouting/interface/L1ScoutingCaloTower.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef DataFormats_L1Scouting_L1ScoutingCaloTower_h
#define DataFormats_L1Scouting_L1ScoutingCaloTower_h

#include "DataFormats/L1Scouting/interface/OrbitCollection.h"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of int16_t, this file should now include

#include <cstdint>

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Do you know why the compiler does not complain about this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. I guess it's because OrbitCollection.h (which is also included) happens to include itself cstdint.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So should I still add it to this file, or is it not needed? Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally the best practice is for every header and source file to #include the headers that it needs rather than rely on transitive #includes. E.g. hypothetically changing OrbitCollection.h to not #include <cstdint> would result in compilation failures here.

namespace l1ScoutingRun3 {

class CaloTower {
public:
CaloTower() : hwEt_(0), erBits_(0), miscBits_(0), hwEta_(0), hwPhi_(0) {}

CaloTower(int16_t hwEt, int16_t erBits, int16_t miscBits, int16_t hwEta, int16_t hwPhi)
: hwEt_(hwEt), erBits_(erBits), miscBits_(miscBits), hwEta_(hwEta), hwPhi_(hwPhi) {}

void setHwEt(int16_t hwEt) { hwEt_ = hwEt; }
void setErBits(int16_t erBits) { erBits_ = erBits; }
void setMiscBits(int16_t miscBits) { miscBits_ = miscBits; }
void setHwEta(int16_t hwEta) { hwEta_ = hwEta; }
void setHwPhi(int16_t hwPhi) { hwPhi_ = hwPhi; }

int16_t hwEt() const { return hwEt_; }
int16_t erBits() const { return erBits_; }
int16_t miscBits() const { return miscBits_; }
int16_t hwEta() const { return hwEta_; }
int16_t hwPhi() const { return hwPhi_; }

private:
int16_t hwEt_;
int16_t erBits_;
int16_t miscBits_;
int16_t hwEta_;
int16_t hwPhi_;
};

typedef OrbitCollection<CaloTower> CaloTowerOrbitCollection;

} // namespace l1ScoutingRun3
#endif // DataFormats_L1Scouting_L1ScoutingCaloTower_h
41 changes: 41 additions & 0 deletions DataFormats/L1Scouting/interface/L1ScoutingFastJet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef DataFormats_L1Scouting_L1ScoutingFastJet_h
#define DataFormats_L1Scouting_L1ScoutingFastJet_h

#include "DataFormats/L1Scouting/interface/OrbitCollection.h"

namespace l1ScoutingRun3 {

class FastJet {
public:
FastJet() : et_(0), eta_(0), phi_(0), mass_(0), nConst_(0), area_(0) {}

FastJet(float et, float eta, float phi, float mass, int nConst, float area)
: et_(et), eta_(eta), phi_(phi), mass_(mass), nConst_(nConst), area_(area) {}

void setEt(float et) { et_ = et; }
void setEta(float eta) { eta_ = eta; }
void setPhi(float phi) { phi_ = phi; }
void setMass(float mass) { mass_ = mass; }
void setNConst(int nConst) { nConst_ = nConst; }
void setArea(float area) { area_ = area; }

float et() const { return et_; }
float eta() const { return eta_; }
float phi() const { return phi_; }
float mass() const { return mass_; }
int nConst() const { return nConst_; }
float area() const { return area_; }

private:
float et_;
float eta_;
float phi_;
float mass_;
int nConst_;
float area_;
};

typedef OrbitCollection<FastJet> FastJetOrbitCollection;

} // namespace l1ScoutingRun3
#endif // DataFormats_L1Scouting_L1ScoutingFastJet_h
2 changes: 1 addition & 1 deletion DataFormats/L1Scouting/interface/OrbitCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class OrbitCollection {
// The method fillAndClear will be used, meaning that, after copying the objects,
// orbitBuffer's vectors will be cleared.
OrbitCollection(std::vector<std::vector<T>>& orbitBuffer, unsigned nObjects = 0)
: bxOffsets_(orbitBufferSize_ + 1, 0), data_(nObjects) {
: bxOffsets_(orbitBufferSize_ + 1, 0), data_() {
fillAndClear(orbitBuffer, nObjects);
}

Expand Down
2 changes: 2 additions & 0 deletions DataFormats/L1Scouting/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
#include "DataFormats/L1Scouting/interface/L1ScoutingMuon.h"
#include "DataFormats/L1Scouting/interface/L1ScoutingCalo.h"
#include "DataFormats/L1Scouting/interface/L1ScoutingBMTFStub.h"
#include "DataFormats/L1Scouting/interface/L1ScoutingCaloTower.h"
#include "DataFormats/L1Scouting/interface/L1ScoutingFastJet.h"
20 changes: 17 additions & 3 deletions DataFormats/L1Scouting/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,39 +10,53 @@

<class name="l1ScoutingRun3::CaloObject"/>

<class name="l1ScoutingRun3::CaloTower" ClassVersion="3">
<version ClassVersion="3" checksum="4158775224"/>
</class>

<class name="l1ScoutingRun3::EGamma" ClassVersion="3">
<version ClassVersion="3" checksum="1578240696"/>
</class>

<class name="l1ScoutingRun3::FastJet" ClassVersion="3">
<version ClassVersion="3" checksum="2288624047"/>
</class>

<class name="l1ScoutingRun3::Jet" ClassVersion="3">
<version ClassVersion="3" checksum="1391509699"/>
</class>

<class name="l1ScoutingRun3::Muon" ClassVersion="3">
<version ClassVersion="3" checksum="3886315831"/>
</class>

<class name="l1ScoutingRun3::Tau" ClassVersion="3">
<version ClassVersion="3" checksum="2889952120"/>
</class>

<class name="std::vector<l1ScoutingRun3::BMTFStub>"/>
<class name="std::vector<l1ScoutingRun3::BxSums>"/>
<class name="std::vector<l1ScoutingRun3::CaloTower>"/>
<class name="std::vector<l1ScoutingRun3::EGamma>"/>
<class name="std::vector<l1ScoutingRun3::FastJet>"/>
<class name="std::vector<l1ScoutingRun3::Jet>"/>
<class name="std::vector<l1ScoutingRun3::Muon>"/>
<class name="std::vector<l1ScoutingRun3::Tau>"/>

<class name="l1ScoutingRun3::BMTFStubOrbitCollection"/>
<class name="l1ScoutingRun3::BxSumsOrbitCollection"/>
<class name="l1ScoutingRun3::CaloTowerOrbitCollection"/>
<class name="l1ScoutingRun3::EGammaOrbitCollection"/>
<class name="l1ScoutingRun3::FastJetOrbitCollection"/>
<class name="l1ScoutingRun3::JetOrbitCollection"/>
<class name="l1ScoutingRun3::MuonOrbitCollection"/>
<class name="l1ScoutingRun3::TauOrbitCollection"/>

<class name="edm::Wrapper<l1ScoutingRun3::BMTFStubOrbitCollection>"/>
<class name="edm::Wrapper<l1ScoutingRun3::BxSumsOrbitCollection>"/>
<class name="edm::Wrapper<l1ScoutingRun3::CaloTowerOrbitCollection>"/>
<class name="edm::Wrapper<l1ScoutingRun3::EGammaOrbitCollection>"/>
<class name="edm::Wrapper<l1ScoutingRun3::FastJetOrbitCollection>"/>
<class name="edm::Wrapper<l1ScoutingRun3::JetOrbitCollection>"/>
<class name="edm::Wrapper<l1ScoutingRun3::MuonOrbitCollection>"/>
<class name="edm::Wrapper<l1ScoutingRun3::TauOrbitCollection>"/>
Expand Down
11 changes: 9 additions & 2 deletions DataFormats/L1Scouting/test/TestL1ScoutingFormat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,21 @@ cmsRun ${LOCAL_TEST_DIR}/read_L1Scouting_cfg.py --inputFile "$file" || die "Fail
oldFiles="testL1Scouting_v3_v3_v3_v3_v3_14_0_0_split_99.root testL1Scouting_v3_v3_v3_v3_v3_14_0_0_split_0.root"
for file in $oldFiles; do
inputfile=$(edmFileInPath DataFormats/L1Scouting/data/$file) || die "Failure edmFileInPath DataFormats/L1Scouting/data/$file" $?
cmsRun ${LOCAL_TEST_DIR}/read_L1Scouting_cfg.py --inputFile "$inputfile" --bmtfStubVersion 0 || die "Failed to read old file $file" $?
cmsRun ${LOCAL_TEST_DIR}/read_L1Scouting_cfg.py --inputFile "$inputfile" --bmtfStubVersion 0 --caloTowerVersion 0 || die "Failed to read old file $file" $?
done

# added BMTF input stubs data format
oldFiles="testL1Scouting_v3_v3_v3_v3_v3_v3_14_1_0_pre5_split_99.root testL1Scouting_v3_v3_v3_v3_v3_v3_14_1_0_pre5_split_0.root"
for file in $oldFiles; do
inputfile=$(edmFileInPath DataFormats/L1Scouting/data/$file) || die "Failure edmFileInPath DataFormats/L1Scouting/data/$file" $?
cmsRun ${LOCAL_TEST_DIR}/read_L1Scouting_cfg.py --inputFile "$inputfile" --bmtfStubVersion 3 || die "Failed to read old file $file" $?
cmsRun ${LOCAL_TEST_DIR}/read_L1Scouting_cfg.py --inputFile "$inputfile" --bmtfStubVersion 3 --caloTowerVersion 0 || die "Failed to read old file $file" $?
done

# added Calo tower data format
oldFiles="testL1Scouting_v3_v3_v3_v3_v3_v3_v3_15_1_0_split_99.root testL1Scouting_v3_v3_v3_v3_v3_v3_v3_15_1_0_split_0.root"
for file in $oldFiles; do
inputfile=$(edmFileInPath DataFormats/L1Scouting/data/$file) || die "Failure edmFileInPath DataFormats/L1Scouting/data/$file" $?
cmsRun ${LOCAL_TEST_DIR}/read_L1Scouting_cfg.py --inputFile "$inputfile" --bmtfStubVersion 3 --caloTowerVersion 3 || die "Failed to read old file $file" $?
done

exit 0
50 changes: 48 additions & 2 deletions DataFormats/L1Scouting/test/TestReadL1Scouting.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "DataFormats/L1Scouting/interface/L1ScoutingBMTFStub.h"
#include "DataFormats/L1Scouting/interface/L1ScoutingMuon.h"
#include "DataFormats/L1Scouting/interface/L1ScoutingCalo.h"
#include "DataFormats/L1Scouting/interface/L1ScoutingCaloTower.h"
#include "DataFormats/L1Scouting/interface/OrbitCollection.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
Expand All @@ -19,7 +20,6 @@
#include <vector>

namespace edmtest {
using namespace l1ScoutingRun3;
class TestReadL1Scouting : public edm::global::EDAnalyzer<> {
public:
TestReadL1Scouting(edm::ParameterSet const&);
Expand All @@ -33,6 +33,7 @@ namespace edmtest {
void analyzeTaus(edm::Event const& iEvent) const;
void analyzeBxSums(edm::Event const& iEvent) const;
void analyzeBmtfStubs(edm::Event const& iEvent) const;
void analyzeCaloTowers(edm::Event const& iEvent) const;

void throwWithMessageFromConstructor(const char*) const;
void throwWithMessage(const char*) const;
Expand All @@ -57,6 +58,10 @@ namespace edmtest {
const int bmtfStubClassVersion_;
const std::vector<int> expectedBmtfStubValues_;
const edm::EDGetTokenT<OrbitCollection<l1ScoutingRun3::BMTFStub>> bmtfStubToken_;

const int caloTowerClassVersion_;
const std::vector<int> expectedCaloTowerValues_;
const edm::EDGetTokenT<OrbitCollection<l1ScoutingRun3::CaloTower>> caloTowerToken_;
};

TestReadL1Scouting::TestReadL1Scouting(edm::ParameterSet const& iPSet)
Expand All @@ -73,7 +78,10 @@ namespace edmtest {
bxSumsToken_(consumes(iPSet.getParameter<edm::InputTag>("bxSumsTag"))),
bmtfStubClassVersion_(iPSet.getParameter<int>("bmtfStubClassVersion")),
expectedBmtfStubValues_(iPSet.getParameter<std::vector<int>>("expectedBmtfStubValues")),
bmtfStubToken_(consumes(iPSet.getParameter<edm::InputTag>("bmtfStubTag"))) {
bmtfStubToken_(consumes(iPSet.getParameter<edm::InputTag>("bmtfStubTag"))),
caloTowerClassVersion_(iPSet.getParameter<int>("caloTowerClassVersion")),
expectedCaloTowerValues_(iPSet.getParameter<std::vector<int>>("expectedCaloTowerValues")),
caloTowerToken_(consumes(iPSet.getParameter<edm::InputTag>("caloTowerTag"))) {
if (bxValues_.size() != 2) {
throwWithMessageFromConstructor("bxValues must have 2 elements and it does not");
}
Expand All @@ -95,6 +103,9 @@ namespace edmtest {
if (expectedBmtfStubValues_.size() != 2) {
throwWithMessageFromConstructor("bmtfStubValues_ must have 2 elements and it does not");
}
if (expectedCaloTowerValues_.size() != 2) {
throwWithMessageFromConstructor("caloTowerValues_ must have 2 elements and it does not");
}
}

void TestReadL1Scouting::analyze(edm::StreamID, edm::Event const& iEvent, edm::EventSetup const&) const {
Expand All @@ -104,6 +115,7 @@ namespace edmtest {
analyzeTaus(iEvent);
analyzeBxSums(iEvent);
analyzeBmtfStubs(iEvent);
analyzeCaloTowers(iEvent);
}

void TestReadL1Scouting::analyzeMuons(edm::Event const& iEvent) const {
Expand Down Expand Up @@ -360,6 +372,37 @@ namespace edmtest {
}
}
}
void TestReadL1Scouting::analyzeCaloTowers(edm::Event const& iEvent) const {
if (caloTowerClassVersion_ < 3) {
return;
}
auto const& caloTowersCollection = iEvent.get(caloTowerToken_);
for (const unsigned& bx : bxValues_) {
unsigned nCaloTowers = caloTowersCollection.getBxSize(bx);
if (nCaloTowers != expectedCaloTowerValues_.size()) {
throwWithMessage("analyzeCaloTower, caloTowers do not have the expected bx size");
}

const auto& caloTowers = caloTowersCollection.bxIterator(bx);
for (unsigned i = 0; i < nCaloTowers; i++) {
if (caloTowers[i].hwEt() != expectedCaloTowerValues_[i]) {
throwWithMessage("analyzeCaloTowers, hwEt does not match the expected value");
}
if (caloTowers[i].erBits() != expectedCaloTowerValues_[i]) {
throwWithMessage("analyzeCaloTowers, erBits does not match the expected value");
}
if (caloTowers[i].miscBits() != expectedCaloTowerValues_[i]) {
throwWithMessage("analyzeCaloTowers, miscBits does not match the expected value");
}
if (caloTowers[i].hwEta() != expectedCaloTowerValues_[i]) {
throwWithMessage("analyzeCaloTowers, hwEta does not match the expected value");
}
if (caloTowers[i].hwPhi() != expectedCaloTowerValues_[i]) {
throwWithMessage("analyzeCaloTowers, hwPhi does not match the expected value");
}
}
}
}

void TestReadL1Scouting::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
Expand All @@ -377,6 +420,9 @@ namespace edmtest {
desc.add<int>("bmtfStubClassVersion");
desc.add<std::vector<int>>("expectedBmtfStubValues");
desc.add<edm::InputTag>("bmtfStubTag");
desc.add<int>("caloTowerClassVersion");
desc.add<std::vector<int>>("expectedCaloTowerValues");
desc.add<edm::InputTag>("caloTowerTag");

descriptions.addDefault(desc);
}
Expand Down
Loading