75 m_token{
config, consumesCollector(),
"src"},
76 m_fillHits{
config.getParameter<
bool>(
"fillHits")},
77 m_fillExtr{
config.getParameter<
bool>(
"fillExtrapolation")},
78 m_dtGeometry{consumesCollector()},
79 m_trackingGeometry{consumesCollector()} {
80 produces<nanoaod::FlatTable>();
82 produces<nanoaod::FlatTable>(
"hits");
85 produces<nanoaod::FlatTable>(
"extr");
98 desc.add<
bool>(
"fillExtrapolation",
true);
99 desc.add<
bool>(
"fillHits",
true);
104 tTrigModeParams.
add<
bool>(
"doTOFCorrection",
true);
105 tTrigModeParams.add<
int>(
"tofCorrType", 2);
107 tTrigModeParams.add<
double>(
"vPropWire", 24.4);
108 tTrigModeParams.add<
bool>(
"doWirePropCorrection",
true);
109 tTrigModeParams.add<
int>(
"wirePropCorrType", 0);
111 tTrigModeParams.add<
std::string>(
"tTrigLabel",
"");
112 tTrigModeParams.add<
bool>(
"doT0Correction",
true);
114 tTrigModeParams.addUntracked<
bool>(
"debug",
false);
131 unsigned int nSegments{0};
133 std::vector<float> seg4D_posLoc_x_SL1;
134 std::vector<float> seg4D_posLoc_x_SL3;
135 std::vector<float> seg4D_posLoc_x_midPlane;
137 std::vector<uint32_t> seg4D_extr_begin;
138 std::vector<uint32_t> seg4D_extr_end;
140 std::vector<uint32_t> seg2D_hits_begin;
141 std::vector<uint32_t> seg2D_hits_end;
144 unsigned int nExtr{0};
146 std::vector<float> seg4D_hitsExpPos;
147 std::vector<float> seg4D_hitsExpPosCh;
148 std::vector<int8_t> seg4D_hitsExpWire;
151 unsigned int nHits{0};
153 std::vector<float> seg2D_hits_pos;
154 std::vector<float> seg2D_hits_posCh;
155 std::vector<float> seg2D_hits_posErr;
156 std::vector<int8_t> seg2D_hits_side;
157 std::vector<int8_t> seg2D_hits_wire;
158 std::vector<int8_t> seg2D_hits_wirePos;
159 std::vector<int8_t> seg2D_hits_layer;
160 std::vector<int8_t> seg2D_hits_superLayer;
161 std::vector<float> seg2D_hits_time;
162 std::vector<float> seg2D_hits_timeCali;
170 const auto wireId =
recHit.wireId();
171 const auto layerId = wireId.layerId();
174 seg2D_hits_pos.push_back(
recHit.localPosition().x());
175 seg2D_hits_posCh.push_back(chamb->toLocal(
layer->toGlobal(
recHit.localPosition())).x());
176 seg2D_hits_posErr.push_back(
recHit.localPositionError().xx());
178 seg2D_hits_side.push_back(
recHit.lrSide());
179 seg2D_hits_wire.push_back(wireId.wire());
180 seg2D_hits_wirePos.push_back(
layer->specificTopology().wirePosition(wireId.wire()));
181 seg2D_hits_layer.push_back(layerId.layer());
182 seg2D_hits_superLayer.push_back(layerId.superlayer());
184 auto digiTime =
recHit.digiTime();
188 seg2D_hits_time.push_back(digiTime);
189 seg2D_hits_timeCali.push_back(digiTime -
tTrig);
195 if (segments4D.isValid()) {
196 auto chambIt = segments4D->id_begin();
197 const auto chambEnd = segments4D->id_end();
199 for (; chambIt != chambEnd; ++chambIt) {
200 const auto&
range = segments4D->get(*chambIt);
202 for (
auto segment4D =
range.first; segment4D !=
range.second; ++segment4D) {
203 auto station = (*chambIt).station();
204 auto wheel = (*chambIt).wheel();
205 auto sector = (*chambIt).sector();
207 bool hasPhi = segment4D->hasPhi();
208 bool hasZed = segment4D->hasZed();
210 auto pos = segment4D->localPosition();
211 auto dir = segment4D->localDirection();
214 std::array<bool, 2> hasPptSL{{
false,
false}};
220 chamb->toGlobal(
pos).basicVector(), chamb->toGlobal(
dir).basicVector(),
anyDirection};
223 for (
int iSL = 0; iSL < 2; ++iSL) {
224 const auto* sl = chamb->superLayer(1 + iSL * 2);
226 auto pptSL = segmentPlaneCrossing.position(sl->surface());
227 hasPptSL[iSL] = pptSL.first;
231 xPosLocSL[iSL] = chamb->toLocal(segExrapolationToSL).x();
236 seg4D_posLoc_x_SL1.push_back(xPosLocSL[0]);
237 seg4D_posLoc_x_SL3.push_back(xPosLocSL[1]);
239 if (hasPptSL[0] && hasPptSL[1])
240 xPosLocMidPlane = (xPosLocSL[0] + xPosLocSL[1]) * 0.5;
242 seg4D_posLoc_x_midPlane.push_back(xPosLocMidPlane);
244 const auto begin = seg4D_hitsExpPos.size();
249 seg4D_extr_begin.push_back(begin);
250 seg4D_extr_end.push_back(begin +
size);
255 for (
const auto iSL : iSLs) {
267 LocalPoint segPosAtZWireLayer =
layer->toLocal(segExrapolationToLayer);
268 LocalPoint segPosAtZWireChamber = chamb->toLocal(segExrapolationToLayer);
271 expPos = segPosAtZWireLayer.
x();
272 expPosCh = segPosAtZWireChamber.
x();
273 expWire =
layer->specificTopology().channel(segPosAtZWireLayer);
274 }
else if (hasZed && iSL ==
THETA_SL) {
275 expPos = segPosAtZWireLayer.
x();
276 expPosCh = segPosAtZWireChamber.
y();
277 expWire =
layer->specificTopology().channel(segPosAtZWireLayer);
281 seg4D_hitsExpPos.push_back(expPos);
282 seg4D_hitsExpPosCh.push_back(expPosCh);
283 seg4D_hitsExpWire.push_back(expWire);
287 seg2D_hits_begin.push_back(seg2D_hits_pos.size());
291 fillHits(segment4D->phiSegment(), geomDet);
295 fillHits(segment4D->zSegment(), geomDet);
298 seg2D_hits_end.push_back(seg2D_hits_pos.size());
304 auto table = std::make_unique<nanoaod::FlatTable>(nSegments,
m_name,
false,
true);
306 table->setDoc(
"DT segment information");
308 addColumn(
table,
"seg4D_posLoc_x_SL1", seg4D_posLoc_x_SL1,
"position x at SL1 in local coordinates - cm");
309 addColumn(
table,
"seg4D_posLoc_x_SL3", seg4D_posLoc_x_SL3,
"position x at SL3 in local coordinates - cm");
311 "seg4D_posLoc_x_midPlane",
312 seg4D_posLoc_x_midPlane,
313 "position x at SL1 - SL3 mid plane in local coordinates - cm");
315 addColumn(
table,
"seg2D_hits_begin", seg2D_hits_begin,
"begin() of range of quantities in the *_hits_* vectors");
316 addColumn(
table,
"seg2D_hits_end", seg2D_hits_end,
"end() of range of quantities in the *_hits_* vectors");
318 addColumn(
table,
"seg4D_extr_begin", seg4D_extr_begin,
"begin() of range of quantities in the *_extr_* vectors");
319 addColumn(
table,
"seg4D_extr_end", seg4D_extr_end,
"end() of range of quantities in the *_extr_* vectors");
324 auto tabHits = std::make_unique<nanoaod::FlatTable>(
nHits,
m_name +
"_hits",
false,
false);
326 tabHits->setDoc(
"Size of DT segment *_hits_* vectors");
328 addColumn(tabHits,
"pos", seg2D_hits_pos,
"local x position of a hit in layer local coordinates");
329 addColumn(tabHits,
"posCh", seg2D_hits_posCh,
"local x position of a hit in chamber local coordinates");
333 "local position error of a hit in layer local coordinates - xx component of error matrix");
334 addColumn(tabHits,
"side", seg2D_hits_side,
"is hit on L/R side of a cell wire - 1/2 is R/L");
335 addColumn(tabHits,
"wire", seg2D_hits_wire,
"hit wire number - range depends on chamber size");
336 addColumn(tabHits,
"wirePos", seg2D_hits_wirePos,
"hit wire x position in layer local coordinates");
337 addColumn(tabHits,
"layer", seg2D_hits_layer,
"hit layer number - range [1:4]");
340 seg2D_hits_superLayer,
341 "hit superlayer - [1:3] range" 342 "<br />SL 1 and 3 are phi SLs" 343 "<br />SL 2 is theta SL");
344 addColumn(tabHits,
"time", seg2D_hits_time,
"digi time - ns, pedestal not subtracted");
345 addColumn(tabHits,
"timeCali", seg2D_hits_timeCali,
"digi time - ns, pedestal subtracted");
351 auto tabExtr = std::make_unique<nanoaod::FlatTable>(nExtr,
m_name +
"_extr",
false,
false);
353 tabExtr->setDoc(
"Size of DT segment *_extr_* vectors");
357 "expected position of segment extrapolated" 358 "<br />to a given layer in layer local coordinates - cm");
363 "expected position of segment extrapolated" 364 "<br />to a given layer in chhamber local coordinates - cm");
369 "expected wire crossed by segment extrapolated" 370 "<br />to a given layer - range depends on chamber size");
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
void fillTable(edm::Event &) final
Fill tree branches for a given event.
nano_mu::ESTokenHandle< GlobalTrackingGeometry, GlobalTrackingGeometryRecord > m_trackingGeometry
Tracking Geometry.
dictionary config
Read in AllInOne config in JSON format.
void getFromES(const edm::Run &, const edm::EventSetup &) final
Get info from the ES by run.
MuDTSegmentExtTableProducer(const edm::ParameterSet &)
Constructor.
auto conditionalGet(const edm::Event &ev) const
static constexpr double DEFAULT_DOUBLE_VAL
Definition of default values for float variables.
const GeomDet * idToDet(DetId) const override
void addColumn(std::unique_ptr< nanoaod::FlatTable > &table, const std::string name, const std::vector< T > &vec, const std::string descr)
static const int THETA_SL
static const int LAST_LAYER
static const int FIRST_LAYER
#define DEFINE_FWK_MODULE(type)
nano_mu::EDTokenHandle< DTRecSegment4DCollection > m_token
The segment token.
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool m_fillExtr
Fill segment extrapolation table.
static constexpr int DEFAULT_INT_VAL_POS
Definition of default values for positive int variables.
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
std::string m_name
The label name of the FlatTableProducer.
static void fillDescriptions(edm::ConfigurationDescriptions &)
Fill descriptors.
void getFromES(const edm::EventSetup &environment)
Get Handle from ES.
const Surface::PositionType & position() const
The position (origin of the R.F.)
std::unique_ptr< DTTTrigBaseSync > m_dtSync
Handle DT trigger time pedestals.
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits
bool m_fillHits
Fill rec-hit table.
nano_mu::ESTokenHandle< DTGeometry, MuonGeometryRecord, edm::Transition::BeginRun > m_dtGeometry
DT Geometry.
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.