13 std::shared_ptr<GlobalCoordsObtainer> &globalcoordsobtainer)
16 LogDebug(
"MuonPathSLFitter") <<
"MuonPathSLFitter: constructor";
28 while (ifin4.good()) {
46 LogDebug(
"MuonPathSLFitter") <<
"MuonPathSLFitter: destructor";
54 LogDebug(
"MuonPathSLFitter") <<
"MuonPathSLFitter::initialiase";
63 std::vector<lat_vector> &lateralities,
64 std::vector<metaPrimitive> &metaPrimitives) {
66 LogDebug(
"MuonPathSLFitter") <<
"MuonPathSLFitter: run";
70 if (!muonpaths.empty()) {
71 auto muonpath = muonpaths[0];
72 int rawId = muonpath->primitive(0)->cameraId();
73 if (muonpath->primitive(0)->cameraId() == -1) {
74 rawId = muonpath->primitive(1)->cameraId();
80 for (
size_t i = 0;
i < muonpaths.size();
i++) {
81 auto muonpath = muonpaths[
i];
82 auto lats = lateralities[
i];
83 analyze(muonpath, lats, metaPrimitives);
89 LogDebug(
"MuonPathSLFitter") <<
"MuonPathSLFitter: finish";
98 std::vector<cmsdt::metaPrimitive> &metaPrimitives) {
99 auto sl = inMPath->primitive(0)->superLayerId();
101 int selected_lay = 1;
102 if (inMPath->primitive(0)->cameraId() > 0)
105 int dumLayId = inMPath->primitive(selected_lay)->cameraId();
107 DTSuperLayerId MuonPathSLId(dtDumlayerId.wheel(), dtDumlayerId.station(), dtDumlayerId.sector(), sl + 1);
109 DTChamberId ChId(MuonPathSLId.wheel(), MuonPathSLId.station(), MuonPathSLId.sector());
111 DTSuperLayerId MuonPathSL1Id(dtDumlayerId.wheel(), dtDumlayerId.station(), dtDumlayerId.sector(), 1);
112 DTSuperLayerId MuonPathSL2Id(dtDumlayerId.wheel(), dtDumlayerId.station(), dtDumlayerId.sector(), 2);
113 DTSuperLayerId MuonPathSL3Id(dtDumlayerId.wheel(), dtDumlayerId.station(), dtDumlayerId.sector(), 3);
114 DTWireId wireIdSL1(MuonPathSL1Id, 2, 1);
115 DTWireId wireIdSL2(MuonPathSL2Id, 2, 1);
116 DTWireId wireIdSL3(MuonPathSL3Id, 2, 1);
122 fit_common_in.
hits = {};
126 if (inMPath->missingLayer() != -1)
136 for (
int isl = minISL; isl < maxISL; isl++) {
138 if (isl == sl && inMPath->missingLayer() !=
i) {
140 auto ti = inMPath->primitive(
i)->tdcTimeStamp();
143 auto wi = inMPath->primitive(
i)->channelId();
144 auto ly = inMPath->primitive(
i)->layerId();
158 fit_common_in.
hits.push_back({ti, wi, ly,
wp});
160 if (inMPath->missingLayer() ==
i)
165 fit_common_in.
hits.push_back({-1, -1, -1, -1});
171 int smallest_time = 999999, tmp_coarse_wirepos_1 = -1, tmp_coarse_wirepos_3 = -1;
173 for (
int isl = 0; isl < 3; isl++) {
176 int myisl = isl < 2 ? 0 : 1;
180 else if (fit_common_in.
hits[
NUM_LAYERS * myisl +
i].ti < smallest_time)
184 tmp_coarse_wirepos_1 = fit_common_in.
hits[
NUM_LAYERS * myisl + 0].wp;
186 tmp_coarse_wirepos_1 = fit_common_in.
hits[
NUM_LAYERS * myisl + 1].wp;
188 tmp_coarse_wirepos_3 = fit_common_in.
hits[
NUM_LAYERS * myisl + 3].wp;
190 tmp_coarse_wirepos_3 = fit_common_in.
hits[
NUM_LAYERS * myisl + 2].wp;
196 fit_common_in.
coarse_wirepos = (tmp_coarse_wirepos_1 + tmp_coarse_wirepos_3) >> 1;
198 for (
auto &lat_comb : lat_combs) {
199 if (lat_comb[0] == 0 && lat_comb[1] == 0 && lat_comb[2] == 0 && lat_comb[3] == 0)
208 }
else if (sl == 1) {
223 for (
int isl = minISL; isl < maxISL; isl++) {
231 fit_common_in.
coeffs = coeffs;
233 auto fit_common_out =
fit(fit_common_in,
247 if (fit_common_out.valid_fit == 1) {
254 DTWireId wireId(MuonPathSLId, 2, 1);
262 float pos_sl_f = pos_ch_f - (sl - 1) * slope_f *
VERT_PHI1_PHI3 / 2;
269 <<
"========================= SUPERLAYER PRIMITIVE =================================";
270 LogDebug(
"MuonPathSLFitter") <<
"WHEEL = " <<
ChId.wheel();
271 LogDebug(
"MuonPathSLFitter") <<
"SECTOR = " <<
ChId.sector();
272 LogDebug(
"MuonPathSLFitter") <<
"STATION = " <<
ChId.station();
273 LogDebug(
"MuonPathSLFitter") <<
"SUPERLAYER = " << sl;
275 LogDebug(
"MuonPathSLFitter") <<
"POSITION = " << (double)fit_common_out.position;
276 LogDebug(
"MuonPathSLFitter") <<
"SLOPE = " << (double)fit_common_out.slope;
279 ChId.rawId(), sl + 1, fit_common_out.position, fit_common_out.slope);
280 float phi = global_coords[0];
281 float phiB = global_coords[1];
285 if (
ChId.station() == 3
or ChId.station() == 4) {
289 int thisec =
ChId.sector();
294 float phi_cmssw = jm_x_cmssw_global.
phi() -
PHI_CONV * (thisec - 1);
295 float psi = atan(slope_f);
298 metaPrimitives.emplace_back(
metaPrimitive({MuonPathSLId.rawId(),
300 (double)(fit_common_out.position),
301 (double)fit_common_out.slope,
308 inMPath->primitive(0)->channelId(),
309 inMPath->primitive(0)->tdcTimeStamp(),
311 inMPath->primitive(1)->channelId(),
312 inMPath->primitive(1)->tdcTimeStamp(),
314 inMPath->primitive(2)->channelId(),
315 inMPath->primitive(2)->tdcTimeStamp(),
317 inMPath->primitive(3)->channelId(),
318 inMPath->primitive(3)->tdcTimeStamp(),
334 metaPrimitives.emplace_back(
metaPrimitive({MuonPathSLId.rawId(),
336 (double)(fit_common_out.position),
337 (double)fit_common_out.slope,
356 inMPath->primitive(0)->channelId(),
357 inMPath->primitive(0)->tdcTimeStamp(),
359 inMPath->primitive(1)->channelId(),
360 inMPath->primitive(1)->tdcTimeStamp(),
362 inMPath->primitive(2)->channelId(),
363 inMPath->primitive(2)->tdcTimeStamp(),
365 inMPath->primitive(3)->channelId(),
366 inMPath->primitive(3)->tdcTimeStamp(),
375 double jm_y =
hasPosRF(MuonPathSLId.wheel(), MuonPathSLId.sector()) ? z_shift - pos_cm : z_shift + pos_cm;
380 double k_fromfw =
hasPosRF(MuonPathSLId.wheel(), MuonPathSLId.sector()) ? slope_f : -slope_f;
387 double x_shift = wire1_in_sl.
x();
399 double r_cmssw =
sqrt(x_cmssw * x_cmssw + y_cmssw * y_cmssw);
400 double k_cmssw = jm_y / r_cmssw;
401 phiB_cmssw = k_cmssw;
403 metaPrimitives.emplace_back(
metaPrimitive({MuonPathSLId.rawId(),
405 (double)(fit_common_out.position),
406 (double)fit_common_out.slope,
413 inMPath->primitive(0)->channelId(),
414 inMPath->primitive(0)->tdcTimeStamp(),
416 inMPath->primitive(1)->channelId(),
417 inMPath->primitive(1)->tdcTimeStamp(),
419 inMPath->primitive(2)->channelId(),
420 inMPath->primitive(2)->tdcTimeStamp(),
422 inMPath->primitive(3)->channelId(),
423 inMPath->primitive(3)->tdcTimeStamp(),
447 while (ifinsl1.good()) {
450 std::vector<int> myNumbers;
451 for (
size_t i = 0;
i <
line.size();
i++) {
453 myNumbers.push_back(
line[
i] -
'0');
460 while (ifinsl2.good()) {
463 std::vector<int> myNumbers;
464 for (
size_t i = 0;
i <
line.size();
i++) {
466 myNumbers.push_back(
line[
i] -
'0');
473 while (ifinsl3.good()) {
476 std::vector<int> myNumbers;
477 for (
size_t i = 0;
i <
line.size();
i++) {
479 myNumbers.push_back(
line[
i] -
'0');
489 std::vector<int> rom_addr;
490 auto missing_layer = inMPath->missingLayer();
491 if (missing_layer == -1) {
492 rom_addr.push_back(1);
493 rom_addr.push_back(0);
495 if (missing_layer == 0) {
496 rom_addr.push_back(0);
497 rom_addr.push_back(0);
498 }
else if (missing_layer == 1) {
499 rom_addr.push_back(0);
500 rom_addr.push_back(1);
501 }
else if (missing_layer == 2) {
502 rom_addr.push_back(1);
503 rom_addr.push_back(0);
505 rom_addr.push_back(1);
506 rom_addr.push_back(1);
509 for (
size_t ilat = 0; ilat < lats.size(); ilat++) {
510 if ((
int)ilat == missing_layer)
512 auto lat = lats[ilat];
515 rom_addr.push_back(
lat);
constexpr int COEFF_WIDTH_SL_POSITION
void setChi2Th(double chi2Th)
int station() const
Return the station number.
int maxdriftinfo_[5][4][14]
std::vector< int > lateralities
std::vector< SLhitP > hits
Point3DBase< Scalar, LocalTag > LocalPoint
edm::FileInPath shift_theta_filename_
constexpr int PROD_RESIZE_SL2_POSITION
edm::ESGetToken< DTGeometry, MuonGeometryRecord > dtGeomH
constexpr int PROD_RESIZE_SL_SLOPE
constexpr int PRECISSION_SL_POSITION
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Geom::Phi< T > phi() const
std::vector< MuonPathPtr > MuonPathPtrs
int get_rom_addr(MuonPathPtr &inMPath, latcomb lats)
constexpr int WIDTH_COARSED_TIME
constexpr int PROD_RESIZE_SL_POSITION
constexpr int WIREPOS_WIDTH
std::map< std::string, int, std::less< std::string > > psi
std::map< int, float > shiftinfo_
constexpr int CELL_LENGTH
std::vector< short > latcomb
constexpr int CELL_SEMILENGTH
int vhdl_unsigned_to_int(std::vector< int > v)
~MuonPathSLFitter() override
void run(edm::Event &iEvent, const edm::EventSetup &iEventSetup, MuonPathPtrs &inMpath, std::vector< cmsdt::metaPrimitive > &metaPrimitives) override
const DTSuperLayer * superLayer(const DTSuperLayerId &id) const
Return a DTSuperLayer given its id.
constexpr int COEFF_WIDTH_SL_T0
bool hasPosRF(int wh, int sec)
void initialise(const edm::EventSetup &iEventSetup) override
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
constexpr int SL1_CELLS_OFFSET
constexpr int COEFF_WIDTH_SL_SLOPE
constexpr float Z_SHIFT_MB4
std::vector< std::vector< int > > lut_sl1
Abs< T >::type abs(const T &t)
constexpr int WIDTH_FULL_TIME
std::vector< std::vector< int > > lut_sl3
void setTanPhiTh(double tanPhiTh)
const DTTopology & specificTopology() const
std::map< int, float > shiftthetainfo_
MuonPathSLFitter(const edm::ParameterSet &pset, edm::ConsumesCollector &iC, std::shared_ptr< GlobalCoordsObtainer > &globalcoordsobtainer)
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
std::shared_ptr< GlobalCoordsObtainer > globalcoordsobtainer_
coeffs_t RomDataConvert(std::vector< int > slv, short COEFF_WIDTH_T0, short COEFF_WIDTH_POSITION, short COEFF_WIDTH_SLOPE, short LOLY, short HILY)
constexpr float CELL_SEMIHEIGHT
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
std::vector< latcomb > lat_vector
constexpr double PHI_CONV
constexpr int COEFF_WIDTH_SL2_POSITION
constexpr int TIME_TO_TDC_COUNTS
constexpr int PROD_RESIZE_SL_T0
constexpr uint32_t rawId() const
get the raw id
constexpr float VERT_PHI1_PHI3
constexpr int LHC_CLK_FREQ
edm::FileInPath sl3_filename_
int wheel() const
Return the wheel number.
edm::FileInPath sl1_filename_
void analyze(MuonPathPtr &inMPath, lat_vector lat_combs, std::vector< cmsdt::metaPrimitive > &metaPrimitives)
std::shared_ptr< MuonPath > MuonPathPtr
constexpr int PRECISSION_SL_T0
constexpr int PRECISSION_SL_SLOPE
constexpr int XI_SL_WIDTH
static unsigned int const shift
constexpr int INCREASED_RES_POS_POW
DTGeometry const * dtGeo_
constexpr int WIREPOS_NORM_LSB_IGNORED
const std::string & fullPath() const
fit_common_out_t fit(fit_common_in_t fit_common_in, int XI_WIDTH, int COEFF_WIDTH_T0, int COEFF_WIDTH_POSITION, int COEFF_WIDTH_SLOPE, int PRECISSION_T0, int PRECISSION_POSITION, int PRECISSION_SLOPE, int PROD_RESIZE_T0, int PROD_RESIZE_POSITION, int PROD_RESIZE_SLOPE, int MAX_DRIFT_TDC, int sl)
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Power< A, B >::type pow(const A &a, const B &b)
edm::FileInPath sl2_filename_
std::vector< int > hits_valid
std::vector< std::vector< int > > lut_sl2
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
constexpr int INCREASED_RES_POS
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.