CMS 3D CMS Logo

CSCStubResolutionValidation.cc
Go to the documentation of this file.
1 #include <memory>
2 
5 
8  const auto& simVertex = pset.getParameter<edm::ParameterSet>("simVertex");
9  simVertexInput_ = iC.consumes<edm::SimVertexContainer>(simVertex.getParameter<edm::InputTag>("inputTag"));
10  const auto& simTrack = pset.getParameter<edm::ParameterSet>("simTrack");
11  simTrackInput_ = iC.consumes<edm::SimTrackContainer>(simTrack.getParameter<edm::InputTag>("inputTag"));
12 
13  // Initialize stub matcher
14  cscStubMatcher_ = std::make_unique<CSCStubMatcher>(pset, std::move(iC));
15 }
16 
18 
19 //create folder for resolution histograms and book them
21  for (int i = 1; i <= 10; ++i) {
22  int j = i - 1;
24 
25  //Position resolution; CLCT
26  std::string t1 = "CLCTPosRes_hs_" + cn;
27  std::string t2 = "CLCTPosRes_qs_" + cn;
28  std::string t3 = "CLCTPosRes_es_" + cn;
29 
30  iBooker.setCurrentFolder("MuonCSCDigisV/CSCDigiTask/CLCT/Resolution/");
31  posresCLCT_hs[j] = iBooker.book1D(
32  t1, cn + " CLCT Position Resolution (1/2-strip prec.); Strip_{L1T} - Strip_{SIM}; Entries", 50, -1, 1);
33  posresCLCT_qs[j] = iBooker.book1D(
34  t2, cn + " CLCT Position Resolution (1/4-strip prec.); Strip_{L1T} - Strip_{SIM}; Entries", 50, -1, 1);
35  posresCLCT_es[j] = iBooker.book1D(
36  t3, cn + " CLCT Position Resolution (1/8-strip prec.); Strip_{L1T} - Strip_{SIM}; Entries", 50, -1, 1);
37 
38  //Slope resolution; CLCT
39  std::string t4 = "CLCTBendRes_" + cn;
40 
41  bendresCLCT[j] =
42  iBooker.book1D(t4, cn + " CLCT Bend Resolution; Slope_{L1T} - Slope_{SIM}; Entries", 50, -0.5, 0.5);
43  }
44 }
45 
47  // Define handles
50 
51  // Use token to retreive event information
52  e.getByToken(simTrackInput_, sim_tracks);
53  e.getByToken(simVertexInput_, sim_vertices);
54 
55  // Initialize StubMatcher
57 
58  const edm::SimTrackContainer& sim_track = *sim_tracks.product();
59  const edm::SimVertexContainer& sim_vert = *sim_vertices.product();
60 
61  // select simtracks for true muons
62  edm::SimTrackContainer sim_track_selected;
63  for (const auto& t : sim_track) {
64  if (!isSimTrackGood(t))
65  continue;
66  sim_track_selected.push_back(t);
67  }
68 
69  // Skip events with no selected simtracks
70  if (sim_track_selected.empty())
71  return;
72 
73  // Loop through good tracks, use corresponding vertex to match stubs, then fill hists of chambers where the stub appears.
74  for (const auto& t : sim_track_selected) {
75  std::vector<bool> hitCLCT(10);
76 
77  std::vector<float> delta_fhs_clct(10);
78  std::vector<float> delta_fqs_clct(10);
79  std::vector<float> delta_fes_clct(10);
80 
81  std::vector<float> dslope_clct(10);
82 
83  // Match track to stubs with appropriate vertex
84  cscStubMatcher_->match(t, sim_vert[t.vertIndex()]);
85 
86  // Store matched stubs.
87  // Key: ChamberID, Value : CSCStubDigiContainer
88  const auto& clcts = cscStubMatcher_->clcts();
89 
90  // CLCTs
91  for (auto& [id, container] : clcts) {
92  const CSCDetId cscId(id);
93 
94  // get the best clct in chamber
95  const auto& clct = cscStubMatcher_->bestClctInChamber(id);
96  if (!clct.isValid())
97  continue;
98 
99  // ME1a CLCTs are saved in ME1b container. So the DetId need to be specified
100  const bool isME11(cscId.station() == 1 and (cscId.ring() == 4 or cscId.ring() == 1));
101  const bool isME1a(isME11 and clct.getKeyStrip() > CSCConstants::MAX_HALF_STRIP_ME1B);
102  int ring = cscId.ring();
103  if (isME1a)
104  ring = 4;
105  else if (isME11)
106  ring = 1;
107  CSCDetId cscId2(cscId.endcap(), cscId.station(), ring, cscId.chamber(), 0);
108  auto id2 = cscId2.rawId();
109 
110  // calculate deltastrip for ME1/a. Basically, we need to subtract 64 from the CLCT key strip to
111  // compare with key strip as obtained through the fit to simhits positions.
112  int deltaStrip = 0;
113  if (isME1a)
114  deltaStrip = CSCConstants::NUM_STRIPS_ME1B;
115 
116  // fractional strip
117  const float fhs_clct = clct.getFractionalStrip(2);
118  const float fqs_clct = clct.getFractionalStrip(4);
119  const float fes_clct = clct.getFractionalStrip(8);
120 
121  // in half-strips per layer
122  const float slopeHalfStrip(clct.getFractionalSlope());
123  const float slopeStrip(slopeHalfStrip / 2.);
124 
125  // get the fit hits in chamber for true value
126  float stripIntercept, stripSlope;
127  cscStubMatcher_->cscDigiMatcher()->muonSimHitMatcher()->fitHitsInChamber(id2, stripIntercept, stripSlope);
128 
129  // add offset of +0.25 strips for non-ME1/1 chambers
130  if (!isME11) {
131  stripIntercept -= 0.25;
132  }
133 
134  const float strip_csc_sh = stripIntercept;
135  const float bend_csc_sh = stripSlope;
136 
137  const unsigned chamberType(cscId2.iChamberType());
138  hitCLCT[chamberType - 1] = true;
139 
140  delta_fhs_clct[chamberType - 1] = fhs_clct - deltaStrip - strip_csc_sh;
141  delta_fqs_clct[chamberType - 1] = fqs_clct - deltaStrip - strip_csc_sh;
142  delta_fes_clct[chamberType - 1] = fes_clct - deltaStrip - strip_csc_sh;
143 
144  dslope_clct[chamberType - 1] = slopeStrip - bend_csc_sh;
145  }
146 
147  for (int i = 0; i < 10; i++) {
148  if (hitCLCT[i]) {
149  //fill histograms
150  posresCLCT_hs[i]->Fill(delta_fhs_clct[i]);
151  posresCLCT_qs[i]->Fill(delta_fqs_clct[i]);
152  posresCLCT_es[i]->Fill(delta_fes_clct[i]);
153 
154  bendresCLCT[i]->Fill(dslope_clct[i]);
155  }
156  }
157  }
158 }
CSCStubResolutionValidation(const edm::ParameterSet &pset, edm::ConsumesCollector &&iC)
void bookHistograms(DQMStore::IBooker &)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
T const * product() const
Definition: Handle.h:70
void Fill(long long x)
bool isSimTrackGood(const SimTrack &t) const
std::string chamberName() const
Definition: CSCDetId.cc:92
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
Definition: Activities.doc:12
edm::EDGetTokenT< edm::SimVertexContainer > simVertexInput_
int chamber() const
Definition: CSCDetId.h:62
void analyze(const edm::Event &, const edm::EventSetup &) override
edm::EDGetTokenT< edm::SimTrackContainer > simTrackInput_
int station() const
Definition: CSCDetId.h:79
std::vector< SimVertex > SimVertexContainer
int endcap() const
Definition: CSCDetId.h:85
std::unique_ptr< CSCStubMatcher > cscStubMatcher_
int ring() const
Definition: CSCDetId.h:68
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
std::vector< SimTrack > SimTrackContainer
def move(src, dest)
Definition: eostools.py:511