CMS 3D CMS Logo

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