CMS 3D CMS Logo

GEMDigiTrackMatch.cc
Go to the documentation of this file.
7 #include <TH1F.h>
8 #include <TMath.h>
9 
10 using namespace std;
11 using namespace GEMDetLabel;
13  std::string simInputLabel_ = ps.getUntrackedParameter<std::string>("simInputLabel");
14  simHitsToken_ = consumes<edm::PSimHitContainer>(edm::InputTag(simInputLabel_, "MuonGEMHits"));
15  simTracksToken_ = consumes<edm::SimTrackContainer>(ps.getParameter<edm::InputTag>("simTrackCollection"));
16  simVerticesToken_ = consumes<edm::SimVertexContainer>(ps.getParameter<edm::InputTag>("simVertexCollection"));
17 
18  gem_digiToken_ = consumes<GEMDigiCollection>(ps.getParameter<edm::InputTag>("gemDigiInput"));
19  gem_padToken_ = consumes<GEMPadDigiCollection>(ps.getParameter<edm::InputTag>("gemPadDigiInput"));
20  gem_copadToken_ = consumes<GEMCoPadDigiCollection>(ps.getParameter<edm::InputTag>("gemCoPadDigiInput"));
21  detailPlot_ = ps.getParameter<bool>("detailPlot");
22  cfg_ = ps;
23 }
24 
27  iSetup.get<MuonGeometryRecord>().get(hGeom);
28  const GEMGeometry &geom = *hGeom;
29  setGeometry(geom);
30 
31  ibooker.setCurrentFolder("MuonGEMDigisV/GEMDigisTask");
32  LogDebug("GEMDigiTrackMatch") << "ibooker set current folder\n";
33 
34  const float PI = TMath::Pi();
35 
36  nstation = geom.regions()[0]->stations().size();
37  if (detailPlot_) {
38  for (unsigned int j = 0; j < nstation; j++) {
39  string track_eta_name = string("track_eta") + s_suffix[j];
40  string track_eta_title = string("track_eta") + ";SimTrack |#eta|;# of tracks";
41  track_eta[j] = ibooker.book1D(track_eta_name.c_str(), track_eta_title.c_str(), 140, minEta_, maxEta_);
42 
43  for (unsigned int k = 0; k < 3; k++) {
44  string suffix = string(s_suffix[j]) + string(c_suffix[k]);
45  string track_phi_name = string("track_phi") + suffix;
46  string track_phi_title = string("track_phi") + suffix + ";SimTrack #phi;# of tracks";
47  track_phi[j][k] = ibooker.book1D(track_phi_name.c_str(), track_phi_title.c_str(), 200, -PI, PI);
48  }
49 
50  for (unsigned int i = 0; i < 4; i++) {
51  string suffix = string(s_suffix[j]) + string(l_suffix[i]);
52  string dg_eta_name = string("dg_eta") + suffix;
53  string dg_eta_title = dg_eta_name + "; tracks |#eta|; # of tracks";
54  dg_eta[i][j] = ibooker.book1D(dg_eta_name.c_str(), dg_eta_title.c_str(), 140, minEta_, maxEta_);
55 
56  string dg_sh_eta_name = string("dg_sh_eta") + suffix;
57  string dg_sh_eta_title = dg_sh_eta_name + "; tracks |#eta|; # of tracks";
58  dg_sh_eta[i][j] = ibooker.book1D(dg_sh_eta_name.c_str(), dg_sh_eta_title.c_str(), 140, minEta_, maxEta_);
59 
60  string pad_eta_name = string("pad_eta") + suffix;
61  string pad_eta_title = pad_eta_name + "; tracks |#eta|; # of tracks";
62  pad_eta[i][j] = ibooker.book1D(pad_eta_name.c_str(), pad_eta_title.c_str(), 140, minEta_, maxEta_);
63 
64  string copad_eta_name = string("copad_eta") + suffix;
65  string copad_eta_title = copad_eta_name + "; tracks |#eta|; # of tracks";
66  copad_eta[i][j] = ibooker.book1D(copad_eta_name.c_str(), copad_eta_title.c_str(), 140, minEta_, maxEta_);
67 
68  for (unsigned int k = 0; k < 3; k++) {
69  suffix = string(s_suffix[j]) + string(l_suffix[i]) + string(c_suffix[k]);
70  string dg_phi_name = string("dg_phi") + suffix;
71  string dg_phi_title = dg_phi_name + "; tracks #phi; # of tracks";
72  dg_phi[i][j][k] = ibooker.book1D((dg_phi_name).c_str(), dg_phi_title.c_str(), 200, -PI, PI);
73 
74  string dg_sh_phi_name = string("dg_sh_phi") + suffix;
75  string dg_sh_phi_title = dg_sh_phi_name + "; tracks #phi; # of tracks";
76  dg_sh_phi[i][j][k] = ibooker.book1D((dg_sh_phi_name).c_str(), dg_sh_phi_title.c_str(), 200, -PI, PI);
77 
78  string pad_phi_name = string("pad_phi") + suffix;
79  string pad_phi_title = pad_phi_name + "; tracks #phi; # of tracks";
80  pad_phi[i][j][k] = ibooker.book1D((pad_phi_name).c_str(), pad_phi_title.c_str(), 200, -PI, PI);
81 
82  string copad_phi_name = string("copad_phi") + suffix;
83  string copad_phi_title = copad_phi_name + "; tracks #phi; # of tracks";
84  copad_phi[i][j][k] = ibooker.book1D((copad_phi_name).c_str(), copad_phi_title.c_str(), 200, -PI, PI);
85  }
86  }
87  }
88  }
89 }
90 
92 
95  iSetup.get<MuonGeometryRecord>().get(hGeom);
96  const GEMGeometry &geom = *hGeom;
97 
101  iEvent.getByToken(simHitsToken_, simhits);
102  iEvent.getByToken(simTracksToken_, sim_tracks);
103  iEvent.getByToken(simVerticesToken_, sim_vertices);
104  if (!simhits.isValid() || !sim_tracks.isValid() || !sim_vertices.isValid())
105  return;
106 
107  if (detailPlot_) {
111  iEvent.getByToken(simHitsToken_, simhits);
112  iEvent.getByToken(simTracksToken_, sim_tracks);
113  iEvent.getByToken(simVerticesToken_, sim_vertices);
114  if (!simhits.isValid() || !sim_tracks.isValid() || !sim_vertices.isValid())
115  return;
116 
117  // const edm::SimVertexContainer & sim_vert = *sim_vertices.product();
118  const edm::SimTrackContainer &sim_trks = *sim_tracks.product();
119  MySimTrack track_;
120  for (auto &t : sim_trks) {
121  if (!isSimTrackGood(t)) {
122  continue;
123  }
124 
125  // match hits and digis to this SimTrack
126 
127  const SimHitMatcher &match_sh =
129  const GEMDigiMatcher &match_gd =
130  GEMDigiMatcher(match_sh, iEvent, geom, cfg_, gem_digiToken_, gem_padToken_, gem_copadToken_);
131 
132  track_.pt = t.momentum().pt();
133  track_.phi = t.momentum().phi();
134  track_.eta = t.momentum().eta();
135  std::fill(std::begin(track_.hitOdd), std::end(track_.hitOdd), false);
136  std::fill(std::begin(track_.hitEven), std::end(track_.hitEven), false);
137 
138  for (int i = 0; i < 3; i++) {
139  for (int j = 0; j < 2; j++) {
140  track_.gem_sh[i][j] = false;
141  track_.gem_dg[i][j] = false;
142  track_.gem_pad[i][j] = false;
143  }
144  }
145 
146  // ** GEM SimHits ** //
147  const auto gem_sh_ids_ch = match_sh.chamberIdsGEM();
148  for (auto d : gem_sh_ids_ch) {
149  const GEMDetId id(d);
150  if (id.chamber() % 2 == 0)
151  track_.hitEven[id.station() - 1] = true;
152  else if (id.chamber() % 2 == 1)
153  track_.hitOdd[id.station() - 1] = true;
154  else {
155  std::cout << "Error to get chamber id" << std::endl;
156  }
157 
158  track_.gem_sh[id.station() - 1][(id.layer() - 1)] = true;
159  }
160  // ** GEM Digis, Pads and CoPads ** //
161  const auto gem_dg_ids_ch = match_gd.chamberIds();
162 
163  for (auto d : gem_dg_ids_ch) {
164  const GEMDetId id(d);
165  track_.gem_dg[id.station() - 1][(id.layer() - 1)] = true;
166  }
167  const auto gem_pad_ids_ch = match_gd.chamberIdsWithPads();
168  for (auto d : gem_pad_ids_ch) {
169  const GEMDetId id(d);
170  track_.gem_pad[id.station() - 1][(id.layer() - 1)] = true;
171  }
172 
173  FillWithTrigger(track_eta, fabs(track_.eta));
174  FillWithTrigger(track_phi, fabs(track_.eta), track_.phi, track_.hitOdd, track_.hitEven);
175 
176  FillWithTrigger(dg_sh_eta, track_.gem_sh, fabs(track_.eta));
177  FillWithTrigger(dg_eta, track_.gem_dg, fabs(track_.eta));
178  FillWithTrigger(pad_eta, track_.gem_pad, fabs(track_.eta));
179  FillWithTrigger(copad_eta, track_.gem_pad, fabs(track_.eta));
180 
181  // Separate station.
182 
183  FillWithTrigger(dg_sh_phi, track_.gem_sh, fabs(track_.eta), track_.phi, track_.hitOdd, track_.hitEven);
184  FillWithTrigger(dg_phi, track_.gem_dg, fabs(track_.eta), track_.phi, track_.hitOdd, track_.hitEven);
185  FillWithTrigger(pad_phi, track_.gem_pad, fabs(track_.eta), track_.phi, track_.hitOdd, track_.hitEven);
186  FillWithTrigger(copad_phi, track_.gem_pad, fabs(track_.eta), track_.phi, track_.hitOdd, track_.hitEven);
187  }
188  }
189 }
#define LogDebug(id)
const double Pi
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
unsigned int nstation
Definition: GEMTrackMatch.h:80
static const std::array< std::string, 4 > l_suffix
Definition: GEMDetLabel.h:4
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::ParameterSet cfg_
Definition: GEMTrackMatch.h:63
std::set< unsigned int > chamberIdsGEM() const
GEM chamber detIds with SimHits.
edm::EDGetToken simHitsToken_
Definition: GEMTrackMatch.h:64
edm::EDGetToken simVerticesToken_
Definition: GEMTrackMatch.h:66
MonitorElement * pad_phi[4][3][3]
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
void analyze(const edm::Event &e, const edm::EventSetup &) override
bool hitOdd[3]
Definition: GEMTrackMatch.h:38
Float_t eta
Definition: GEMTrackMatch.h:27
MonitorElement * dg_phi[4][3][3]
MonitorElement * copad_phi[4][3][3]
void setGeometry(const GEMGeometry &geom)
static const std::array< std::string, 2 > s_suffix
Definition: GEMDetLabel.h:5
int iEvent
Definition: GenABIO.cc:224
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
edm::EDGetToken simTracksToken_
Definition: GEMTrackMatch.h:65
MonitorElement * track_eta[3]
const std::vector< const GEMRegion * > & regions() const
Return a vector of all GEM regions.
Definition: GEMGeometry.cc:43
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
bool gem_dg[3][2]
Definition: GEMTrackMatch.h:35
#define end
Definition: vmac.h:39
bool isValid() const
Definition: HandleBase.h:74
edm::EDGetToken gem_copadToken_
#define PI
Definition: QcdUeDQM.h:36
edm::EDGetToken gem_digiToken_
int k[5][pyjets_maxn]
bool hitEven[3]
Definition: GEMTrackMatch.h:39
MonitorElement * track_phi[3][3]
~GEMDigiTrackMatch() override
Float_t pt
Definition: GEMTrackMatch.h:27
MonitorElement * pad_eta[4][3]
T const * product() const
Definition: Handle.h:74
MonitorElement * dg_sh_phi[4][3][3]
GEMDigiTrackMatch(const edm::ParameterSet &ps)
void FillWithTrigger(MonitorElement *me[3], Float_t eta)
MonitorElement * dg_eta[4][3]
bool gem_pad[3][2]
Definition: GEMTrackMatch.h:36
#define begin
Definition: vmac.h:32
std::set< unsigned int > chamberIdsWithPads() const
T get() const
Definition: EventSetup.h:71
Float_t phi
Definition: GEMTrackMatch.h:27
bool isSimTrackGood(const SimTrack &)
std::set< unsigned int > chamberIds() const
bool gem_sh[3][2]
Definition: GEMTrackMatch.h:34
edm::EDGetToken gem_padToken_
std::vector< SimTrack > SimTrackContainer
MonitorElement * dg_sh_eta[4][3]
static const std::array< std::string, 3 > c_suffix
Definition: GEMDetLabel.h:6
Definition: Run.h:45
MonitorElement * copad_eta[4][3]