Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:06:32

0001 /*
0002  * \file MuNtupleUtils.cc
0003  *
0004  * \author C. Battilana - INFN (BO)
0005  * \author L. Giuducci - INFN (BO)
0006 */
0007 
0008 #include "DPGAnalysis/MuonTools/interface/MuNtupleUtils.h"
0009 
0010 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhDigi.h"
0011 #include "DataFormats/L1DTTrackFinder/interface/L1Phase2MuDTPhDigi.h"
0012 
0013 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
0014 
0015 // CB
0016 // formulas to be re-checked
0017 // can use template is_same, static_assert, enable_if ...
0018 
0019 nano_mu::DTTrigGeomUtils::DTTrigGeomUtils(edm::ConsumesCollector&& collector, bool dirInDeg)
0020     : m_dtGeom{std::move(collector), "idealForDigi"} {}
0021 
0022 nano_mu::DTTrigGeomUtils::chambCoord nano_mu::DTTrigGeomUtils::trigToReco(const L1MuDTChambPhDigi* trig) {
0023   auto wh{trig->whNum()};
0024   auto sec{trig->scNum() + 1};
0025   auto st{trig->stNum()};
0026   auto phi{trig->phi()};
0027   auto phib{trig->phiB()};
0028 
0029   auto recoChamb = [&]() {
0030     if (st != 4) {
0031       return DTChamberId(wh, st, sec);
0032     }
0033     int reco_sec{(sec == 4 && phi > 0) ? 13 : (sec == 10 && phi > 0) ? 14 : sec};
0034     return DTChamberId(wh, st, reco_sec);
0035   };
0036 
0037   auto gpos{m_dtGeom->chamber(recoChamb())->position()};
0038   auto r{gpos.perp()};
0039 
0040   auto delta_phi{gpos.phi() - (sec - 1) * Geom::pi() / 6};
0041 
0042   // zcn is in local coordinates -> z invreases approching to vertex
0043   // LG: zcn offset was removed <- CB do we need to fix this?
0044   float x = r * tan((phi - (phi < 0 ? 1 : 0)) / PH1_PHI_R) * cos(delta_phi) - r * sin(delta_phi);
0045   float dir = (phib / PH1_PHIB_R + phi / PH1_PHI_R);
0046 
0047   // change sign in case of positive wheels
0048   if (hasPosRF(wh, sec)) {
0049     x = -x;
0050   } else {
0051     dir = -dir;
0052   }
0053 
0054   return {x, dir};
0055 }
0056 
0057 nano_mu::DTTrigGeomUtils::chambCoord nano_mu::DTTrigGeomUtils::trigToReco(const L1Phase2MuDTPhDigi* trig) {
0058   auto wh{trig->whNum()};
0059   auto sec{trig->scNum() + 1};
0060   auto st{trig->stNum()};
0061   auto phi{trig->phi()};
0062   auto phib{trig->phiBend()};
0063   auto quality{trig->quality()};
0064   auto sl{trig->slNum()};
0065 
0066   auto recoChamb = [&]() {
0067     if (st != 4) {
0068       return DTChamberId(wh, st, sec);
0069     }
0070     int reco_sec{(sec == 4 && phi > 0) ? 13 : (sec == 10 && phi > 0) ? 14 : sec};
0071     return DTChamberId(wh, st, reco_sec);
0072   };
0073 
0074   auto gpos{m_dtGeom->chamber(recoChamb())->position()};
0075   auto r{gpos.perp()};
0076 
0077   auto delta_phi{gpos.phi() - (sec - 1) * Geom::pi() / 6};
0078 
0079   // CB to be potentially updated based on Silvia's results
0080   double zRF = 0;
0081   if (quality >= 6 && quality != 7)
0082     zRF = m_zcn[st - 1];
0083   if ((quality < 6 || quality == 7) && sl == 1)
0084     zRF = m_zsl1[st - 1];
0085   if ((quality < 6 || quality == 7) && sl == 3)
0086     zRF = m_zsl3[st - 1];
0087 
0088   // zcn is in local coordinates -> z invreases approching to vertex
0089   // LG: zcn offset was removed <- CB Mist confirm it is tryly accurate?
0090   float x = r * tan((phi - (phi < 0 ? 1 : 0)) / PH1_PHI_R) * (cos(delta_phi) - zRF) - r * sin(delta_phi);
0091   float dir = (phib / PH2_PHIB_R + phi / PH2_PHI_R);
0092 
0093   // change sign in case of positive wheels
0094   if (hasPosRF(wh, sec)) {
0095     x = -x;
0096   } else {
0097     dir = -dir;
0098   }
0099 
0100   return {x, dir};
0101 }