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)->tdcTimeStamp() != -1)
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;
270 float phi = global_coords[0];
271 float phiB = global_coords[1];
275 if (
ChId.station() == 3
or ChId.station() == 4) {
279 int thisec =
ChId.sector();
284 float phi_cmssw = jm_x_cmssw_global.
phi() -
PHI_CONV * (thisec - 1);
285 float psi = atan(slope_f);
288 metaPrimitives.emplace_back(
metaPrimitive({MuonPathSLId.rawId(),
290 (double)(fit_common_out.position),
291 (double)fit_common_out.slope,
298 inMPath->primitive(0)->channelId(),
299 inMPath->primitive(0)->tdcTimeStamp(),
301 inMPath->primitive(1)->channelId(),
302 inMPath->primitive(1)->tdcTimeStamp(),
304 inMPath->primitive(2)->channelId(),
305 inMPath->primitive(2)->tdcTimeStamp(),
307 inMPath->primitive(3)->channelId(),
308 inMPath->primitive(3)->tdcTimeStamp(),
324 metaPrimitives.emplace_back(
metaPrimitive({MuonPathSLId.rawId(),
326 (double)(fit_common_out.position),
327 (double)fit_common_out.slope,
346 inMPath->primitive(0)->channelId(),
347 inMPath->primitive(0)->tdcTimeStamp(),
349 inMPath->primitive(1)->channelId(),
350 inMPath->primitive(1)->tdcTimeStamp(),
352 inMPath->primitive(2)->channelId(),
353 inMPath->primitive(2)->tdcTimeStamp(),
355 inMPath->primitive(3)->channelId(),
356 inMPath->primitive(3)->tdcTimeStamp(),
365 double jm_y =
hasPosRF(MuonPathSLId.wheel(), MuonPathSLId.sector()) ? z_shift - pos_cm : z_shift + pos_cm;
370 double k_fromfw =
hasPosRF(MuonPathSLId.wheel(), MuonPathSLId.sector()) ? slope_f : -slope_f;
377 double x_shift = wire1_in_sl.
x();
389 double r_cmssw =
sqrt(x_cmssw * x_cmssw + y_cmssw * y_cmssw);
390 double k_cmssw = jm_y / r_cmssw;
391 phiB_cmssw = k_cmssw;
393 metaPrimitives.emplace_back(
metaPrimitive({MuonPathSLId.rawId(),
395 (double)(fit_common_out.position),
396 (double)fit_common_out.slope,
403 inMPath->primitive(0)->channelId(),
404 inMPath->primitive(0)->tdcTimeStamp(),
406 inMPath->primitive(1)->channelId(),
407 inMPath->primitive(1)->tdcTimeStamp(),
409 inMPath->primitive(2)->channelId(),
410 inMPath->primitive(2)->tdcTimeStamp(),
412 inMPath->primitive(3)->channelId(),
413 inMPath->primitive(3)->tdcTimeStamp(),
437 while (ifinsl1.good()) {
440 std::vector<int> myNumbers;
441 for (
size_t i = 0;
i <
line.size();
i++) {
443 myNumbers.push_back(
line[
i] -
'0');
450 while (ifinsl2.good()) {
453 std::vector<int> myNumbers;
454 for (
size_t i = 0;
i <
line.size();
i++) {
456 myNumbers.push_back(
line[
i] -
'0');
463 while (ifinsl3.good()) {
466 std::vector<int> myNumbers;
467 for (
size_t i = 0;
i <
line.size();
i++) {
469 myNumbers.push_back(
line[
i] -
'0');
479 std::vector<int> rom_addr;
480 auto missing_layer = inMPath->missingLayer();
481 if (missing_layer == -1) {
482 rom_addr.push_back(1);
483 rom_addr.push_back(0);
485 if (missing_layer == 0) {
486 rom_addr.push_back(0);
487 rom_addr.push_back(0);
488 }
else if (missing_layer == 1) {
489 rom_addr.push_back(0);
490 rom_addr.push_back(1);
491 }
else if (missing_layer == 2) {
492 rom_addr.push_back(1);
493 rom_addr.push_back(0);
495 rom_addr.push_back(1);
496 rom_addr.push_back(1);
499 for (
size_t ilat = 0; ilat < lats.size(); ilat++) {
500 if ((
int)ilat == missing_layer)
502 auto lat = lats[ilat];
505 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
std::string fullPath() const
constexpr int PRECISSION_SL_POSITION
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Geom::Phi< T > phi() const
static const double slope[3]
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 INCREASED_RES_SLOPE_POW
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
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.