20#include <unordered_map>
50 std::vector<TH1F> histos;
52 std::array<std::string, 4> names{
"nFiredBP",
"nFiredNBP",
"nFiredBoth",
"nTot"};
54 std::array<std::string, 3> elName{
"Board",
"RPC",
"Plane"};
56 std::array<double, 3> firstVal{1., 0., 0.};
57 for (
size_t iel = 0; iel < elTypes.size(); ++iel) {
58 for (
size_t itype = 0; itype <
types.size(); ++itype) {
59 std::string
name = names[itype] +
"per";
61 histos.emplace_back(
name.c_str(),
name.c_str(), nBins[iel], firstVal[iel], nBins[iel] +
static_cast<int>(firstVal[iel]));
62 histos.back().GetXaxis()->SetTitle(elName[iel].c_str());
64 int ibin =
count.deId + 1;
69 histos.back().SetBinContent(ibin,
count.getCounts(
types[itype]));
85 auto stop = [
this]() {
86 TFile fout(
"mid-efficiency.root",
"RECREATE");
88 for (
auto& histo : histos) {
100 auto midTracks = pc.
inputs().
get<gsl::span<mid::Track>>(
"midtracks");
101 if (mSelectMatched) {
102 auto matchTracks = pc.
inputs().
get<gsl::span<dataformats::TrackMCHMID>>(
"matchtracks");
103 mSelectedTracks.clear();
104 mSelectedTracks.reserve(midTracks.size());
105 for (
auto& matchTrack : matchTracks) {
106 auto idx = matchTrack.getMIDRef().getIndex();
107 mSelectedTracks.emplace_back(midTracks[idx]);
109 midTracks = gsl::span<mid::Track>(mSelectedTracks);
112 mEfficiency.
process(midTracks);
118 std::vector<mid::Track> mSelectedTracks{};
124 Inputs inputSpecs{
InputSpec{
"midtracks",
"MID",
"TRACKS", 0, Lifetime::Timeframe}};
127 "matchtracks",
"GLO",
"MTC_MCHMID", 0, Lifetime::Timeframe});
136 {
"mid-eff", VariantType::String,
"mid-efficiency.root", {
"Root MID RPCs Efficiency"}}}};
Useful detector parameters for MID.
Computes the MID chamber efficiency.
Definition of the MUON track.
ServiceRegistryRef services()
InputRecord & inputs()
The inputs associated with this processing context.
std::vector< ChEffCounter > getCountersAsVector() const
void init(InitContext &ic)
prepare the efficiency
EfficiencyTask(bool selectMatched)
std::vector< TH1F > buildHistos()
void run(ProcessingContext &pc)
run the efficiency
Class to estimate the MID chamber efficiency.
const ChamberEfficiency & getChamberEfficiency(ElementType et) const
Returns the chamber efficiency.
void process(gsl::span< const mid::Track > midTracks)
Fill the counters to estimate the chamber efficiency.
@ Plane
Efficiency per RPC.
@ RPC
Efficiency per board.
int getBoardId(int line, int column, int deId, bool warn=true) const
GLsizei GLenum GLenum * types
GLuint const GLchar * name
Defining PrimaryVertex explicitly as messageable.
std::vector< ConfigParamSpec > Options
std::vector< InputSpec > Inputs
std::vector< OutputSpec > Outputs
constexpr int NDetectionElements
Number of RPCs.
constexpr int NChambers
Number of chambers.
constexpr int NLocalBoards
Number of local boards per chamber.
@ BendPlane
Bending plane counters.
@ BothPlanes
Both plane counters.
@ AllTracks
All tracks counters.
@ NonBendPlane
Non-bending plane counters.
DataProcessorSpec getChamberEfficiencySpec(bool selectMatched)
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...