Skip to content

Commit

Permalink
Update to analyses: inclusive and selected bx paths
Browse files Browse the repository at this point in the history
  • Loading branch information
gpetruc committed Sep 9, 2024
1 parent 691b9ce commit a910185
Show file tree
Hide file tree
Showing 11 changed files with 410 additions and 174 deletions.
2 changes: 1 addition & 1 deletion DataFormats/L1Scouting/interface/OrbitCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class OrbitCollection {

// there are 3564 BX in one orbtit [1,3564], one extra
// count added to keep first entry of the vector
static constexpr int orbitBufferSize_ = NBX+1;
static constexpr int orbitBufferSize_ = NBX + 1;
};

#endif // DataFormats_L1Scouting_OrbitCollection_h
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ class DataModeScoutingPhase2 : public DataMode {
unsigned int currOrbit = 0xFFFFFFFF;
};

#endif // EventFilter_Utilities_DAQSourceModelsScoutingPhase2_h
#endif // EventFilter_Utilities_DAQSourceModelsScoutingPhase2_h
99 changes: 99 additions & 0 deletions L1TriggerScouting/OnlineProcessing/interface/MaskOrbitBx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#ifndef L1TriggerSccouting_OnlineProcessing_MaskOrbitBx_h
#define L1TriggerSccouting_OnlineProcessing_MaskOrbitBx_h

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/EDPutToken.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/StreamID.h"
#include "FWCore/Utilities/interface/Span.h"

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

#include <vector>
#include <set>

template <typename T>
class MaskOrbitBx : public edm::stream::EDProducer<> {
public:
explicit MaskOrbitBx(const edm::ParameterSet&);
~MaskOrbitBx() {}
static void fillDescriptions(edm::ConfigurationDescriptions&);

private:
void produce(edm::Event&, const edm::EventSetup&) override;

std::vector<std::vector<T>> orbitBuffer_;

// tokens for scouting data
edm::EDGetTokenT<OrbitCollection<T>> tokenData_;

// BX to be keep
edm::EDGetTokenT<std::vector<unsigned>> tokenSelBxs_;

std::string productLabel_;

const int NBX = 3565;
};

template <typename T>
MaskOrbitBx<T>::MaskOrbitBx(const edm::ParameterSet& iPSet)
: tokenData_(consumes<OrbitCollection<T>>(iPSet.getParameter<edm::InputTag>("dataTag"))),
tokenSelBxs_(consumes<std::vector<unsigned>>(iPSet.getParameter<edm::InputTag>("selectBxs"))),
productLabel_(iPSet.getParameter<std::string>("productLabel")) {
// prepare module buffer
orbitBuffer_ = std::vector<std::vector<T>>(NBX);

// products
produces<OrbitCollection<T>>(productLabel_).setBranchAlias(productLabel_ + "OrbitCollection");
}

// ------------ method called for each ORBIT ------------
template <typename T>
void MaskOrbitBx<T>::produce(edm::Event& iEvent, const edm::EventSetup&) {
// get selected BXs
edm::Handle<std::vector<unsigned>> selBxs;
iEvent.getByToken(tokenSelBxs_, selBxs);

// get the data
edm::Handle<OrbitCollection<T>> objCollection;
iEvent.getByToken(tokenData_, objCollection);

// prepare new collections
std::unique_ptr<OrbitCollection<T>> selectedObjs(new OrbitCollection<T>);

int nObjOrbit_ = 0;

// fill collections with objects
for (const unsigned& bx : *selBxs) {
for (const auto& obj : objCollection->bxIterator(bx)) {
orbitBuffer_[bx].push_back(obj);
nObjOrbit_++;
}
}

// fill orbit collection and clear the Bx buffer vector
selectedObjs->fillAndClear(orbitBuffer_, nObjOrbit_);

// store collections in the event
iEvent.put(std::move(selectedObjs), productLabel_);

} // end produce

template <typename T>
void MaskOrbitBx<T>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<edm::InputTag>("dataTag");
desc.add<edm::InputTag>("selectBxs");
desc.add<std::string>("productLabel", "");
descriptions.addDefault(desc);
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ bool FinalBxSelector::filter(edm::Event& iEvent, const edm::EventSetup&) {

void FinalBxSelector::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.setUnknown();
desc.add<std::vector<edm::InputTag>>("analysisLabels");
descriptions.addDefault(desc);
}

Expand Down
98 changes: 3 additions & 95 deletions L1TriggerScouting/OnlineProcessing/plugins/MaskOrbitBx.cc
Original file line number Diff line number Diff line change
@@ -1,101 +1,9 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/EDPutToken.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/StreamID.h"
#include "FWCore/Utilities/interface/Span.h"
#include "L1TriggerScouting/OnlineProcessing/interface/MaskOrbitBx.h"

// L1 scouting
#include "DataFormats/L1Scouting/interface/L1ScoutingMuon.h"
#include "DataFormats/L1Scouting/interface/L1ScoutingCalo.h"
#include "DataFormats/L1Scouting/interface/L1ScoutingBMTFStub.h"
#include "DataFormats/L1Scouting/interface/OrbitCollection.h"

#include <vector>
#include <set>

using namespace l1ScoutingRun3;

template <typename T>
class MaskOrbitBx : public edm::stream::EDProducer<> {
public:
explicit MaskOrbitBx(const edm::ParameterSet&);
~MaskOrbitBx() {}
static void fillDescriptions(edm::ConfigurationDescriptions&);

private:
void produce(edm::Event&, const edm::EventSetup&) override;

std::vector<std::vector<T>> orbitBuffer_;

// tokens for scouting data
edm::EDGetTokenT<OrbitCollection<T>> tokenData_;

// BX to be keep
edm::EDGetTokenT<std::vector<unsigned>> tokenSelBxs_;

std::string productLabel_;

const int NBX = 3565;
};

template <typename T>
MaskOrbitBx<T>::MaskOrbitBx(const edm::ParameterSet& iPSet)
: tokenData_(consumes<OrbitCollection<T>>(iPSet.getParameter<edm::InputTag>("dataTag"))),
tokenSelBxs_(consumes<std::vector<unsigned>>(iPSet.getParameter<edm::InputTag>("selectBxs"))),
productLabel_(iPSet.getParameter<std::string>("productLabel")) {
// prepare module buffer
orbitBuffer_ = std::vector<std::vector<T>>(NBX);

// products
produces<OrbitCollection<T>>(productLabel_).setBranchAlias(productLabel_ + "OrbitCollection");
}

// ------------ method called for each ORBIT ------------
template <typename T>
void MaskOrbitBx<T>::produce(edm::Event& iEvent, const edm::EventSetup&) {
// get selected BXs
edm::Handle<std::vector<unsigned>> selBxs;
iEvent.getByToken(tokenSelBxs_, selBxs);

// get the data
edm::Handle<OrbitCollection<T>> objCollection;
iEvent.getByToken(tokenData_, objCollection);

// prepare new collections
std::unique_ptr<OrbitCollection<T>> selectedObjs(new OrbitCollection<T>);

int nObjOrbit_ = 0;

// fill collections with objects
for (const unsigned& bx : *selBxs) {
for (const auto& obj : objCollection->bxIterator(bx)) {
orbitBuffer_[bx].push_back(obj);
nObjOrbit_++;
}
}

// fill orbit collection and clear the Bx buffer vector
selectedObjs->fillAndClear(orbitBuffer_, nObjOrbit_);

// store collections in the event
iEvent.put(std::move(selectedObjs), productLabel_);

} // end produce

template <typename T>
void MaskOrbitBx<T>::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.setUnknown();
descriptions.addDefault(desc);
}
#include "FWCore/Framework/interface/MakerMacros.h"

typedef MaskOrbitBx<l1ScoutingRun3::Muon> MaskOrbitBxScoutingMuon;
typedef MaskOrbitBx<l1ScoutingRun3::Jet> MaskOrbitBxScoutingJet;
Expand All @@ -109,4 +17,4 @@ DEFINE_FWK_MODULE(MaskOrbitBxScoutingJet);
DEFINE_FWK_MODULE(MaskOrbitBxScoutingEGamma);
DEFINE_FWK_MODULE(MaskOrbitBxScoutingTau);
DEFINE_FWK_MODULE(MaskOrbitBxScoutingBxSums);
DEFINE_FWK_MODULE(MaskOrbitBxScoutingBMTFStub);
DEFINE_FWK_MODULE(MaskOrbitBxScoutingBMTFStub);
64 changes: 64 additions & 0 deletions L1TriggerScouting/Phase2/plugins/GoodOrbitNBxSelector.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/global/EDFilter.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Utilities/interface/EDGetToken.h"
#include "FWCore/Utilities/interface/EDPutToken.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "FWCore/Utilities/interface/StreamID.h"
#include "FWCore/Utilities/interface/Span.h"

#include <vector>
#include <set>

/*
* Filter orbits that don't contain at least one selected BX
* from a BxSelector module and produce a vector of selected BXs
*/
class GoodOrbitNBxSelector : public edm::global::EDFilter<> {
public:
explicit GoodOrbitNBxSelector(const edm::ParameterSet&);
~GoodOrbitNBxSelector() {}
static void fillDescriptions(edm::ConfigurationDescriptions&);

private:
bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;

// tokens for BX selected by each analysis
std::vector<edm::EDGetTokenT<unsigned int>> nbxTokens_;
unsigned int threshold_;
};

GoodOrbitNBxSelector::GoodOrbitNBxSelector(const edm::ParameterSet& iPSet)
: threshold_(iPSet.getParameter<unsigned int>("nbxMin")) {
// get the list of selected BXs
std::vector<edm::InputTag> bxLabels = iPSet.getParameter<std::vector<edm::InputTag>>("unpackers");
for (const auto& bxLabel : bxLabels) {
edm::InputTag tag{bxLabel.label(), "nbx", bxLabel.process()};
nbxTokens_.push_back(consumes<unsigned int>(tag));
}
}

// ------------ method called for each ORBIT ------------
bool GoodOrbitNBxSelector::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup&) const {
for (const auto& token : nbxTokens_) {
edm::Handle<unsigned> nbx;
iEvent.getByToken(token, nbx);
if (*nbx < threshold_)
return false;
}
return true;
}

void GoodOrbitNBxSelector::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.add<std::vector<edm::InputTag>>("unpackers");
desc.add<unsigned int>("nbxMin", 3564); // BXs in one orbit
descriptions.addDefault(desc);
}

DEFINE_FWK_MODULE(GoodOrbitNBxSelector);
13 changes: 13 additions & 0 deletions L1TriggerScouting/Phase2/plugins/MaskOrbitBx.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "L1TriggerScouting/OnlineProcessing/interface/MaskOrbitBx.h"

#include "DataFormats/L1TParticleFlow/interface/L1ScoutingPuppi.h"
#include "DataFormats/L1TParticleFlow/interface/L1ScoutingTkEm.h"
#include "FWCore/Framework/interface/MakerMacros.h"

typedef MaskOrbitBx<l1Scouting::Puppi> MaskOrbitBxScoutingPuppi;
typedef MaskOrbitBx<l1Scouting::TkEm> MaskOrbitBxScoutingTkEm;
typedef MaskOrbitBx<l1Scouting::TkEle> MaskOrbitBxScoutingTkEle;

DEFINE_FWK_MODULE(MaskOrbitBxScoutingPuppi);
DEFINE_FWK_MODULE(MaskOrbitBxScoutingTkEm);
DEFINE_FWK_MODULE(MaskOrbitBxScoutingTkEle);
6 changes: 3 additions & 3 deletions L1TriggerScouting/Phase2/plugins/ScPhase2PuppiW3PiDemo.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ void ScPhase2PuppiW3PiDemo::produce(edm::Event &iEvent, const edm::EventSetup &i

void ScPhase2PuppiW3PiDemo::endStream() {
if (doCandidate_)
std::cout << "Candidate analysis: " << countCandidate_ << " -> " << passCandidate_ << std::endl;
std::cout << "W3Pi Candidate analysis: " << countCandidate_ << " -> " << passCandidate_ << std::endl;
if (doStruct_)
std::cout << "Struct analysis: " << countStruct_ << " -> " << passStruct_ << std::endl;
std::cout << "W3Pi Struct analysis: " << countStruct_ << " -> " << passStruct_ << std::endl;
if (doSOA_)
std::cout << "SOA analysis: " << countSOA_ << " -> " << passSOA_ << std::endl;
std::cout << "W3Pi SOA analysis: " << countSOA_ << " -> " << passSOA_ << std::endl;
}

template <typename T>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void ScPhase2PuppiWDsGammaDemo::produce(edm::Event &iEvent, const edm::EventSetu

void ScPhase2PuppiWDsGammaDemo::endStream() {
if (doStruct_)
std::cout << "Struct analysis: " << countStruct_ << " -> " << passStruct_ << std::endl;
std::cout << "WDsGammma Struct analysis: " << countStruct_ << " -> " << passStruct_ << std::endl;
}

template <typename T, typename U>
Expand Down
Loading

0 comments on commit a910185

Please sign in to comment.