test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  const float PI=TMath::Pi();
34 
35  nstation = geom.regions()[0]->stations().size();
36  if ( detailPlot_) {
37  for( unsigned int j=0 ; j<nstation ; j++) {
38  string track_eta_name = string("track_eta")+s_suffix[j];
39  string track_eta_title = string("track_eta")+";SimTrack |#eta|;# of tracks";
40  track_eta[j] = ibooker.book1D(track_eta_name.c_str(), track_eta_title.c_str(),140,minEta_,maxEta_);
41 
42  for ( unsigned int k = 0 ; k<3 ; k++) {
43  string suffix = string(s_suffix[j])+ string(c_suffix[k]);
44  string track_phi_name = string("track_phi")+suffix;
45  string track_phi_title = string("track_phi")+suffix+";SimTrack #phi;# of tracks";
46  track_phi[j][k] = ibooker.book1D(track_phi_name.c_str(), track_phi_title.c_str(),200,-PI,PI);
47  }
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 }
91 
93 
95 {
97  iSetup.get<MuonGeometryRecord>().get(hGeom);
98  const GEMGeometry& geom = *hGeom;
99 
103  iEvent.getByToken(simHitsToken_, simhits);
104  iEvent.getByToken(simTracksToken_, sim_tracks);
105  iEvent.getByToken(simVerticesToken_, sim_vertices);
106  if ( !simhits.isValid() || !sim_tracks.isValid() || !sim_vertices.isValid()) return;
107 
108  if ( detailPlot_) {
109 
113  iEvent.getByToken(simHitsToken_, simhits);
114  iEvent.getByToken(simTracksToken_, sim_tracks);
115  iEvent.getByToken(simVerticesToken_, sim_vertices);
116  if ( !simhits.isValid() || !sim_tracks.isValid() || !sim_vertices.isValid()) return;
117 
118  //const edm::SimVertexContainer & sim_vert = *sim_vertices.product();
119  const edm::SimTrackContainer & sim_trks = *sim_tracks.product();
120  MySimTrack track_;
121  for (auto& t: sim_trks)
122  {
123  if (!isSimTrackGood(t))
124  { continue; }
125 
126  // match hits and digis to this SimTrack
127 
128  const SimHitMatcher& match_sh = SimHitMatcher( t, iEvent, geom, cfg_, simHitsToken_, simTracksToken_, simVerticesToken_);
129  const GEMDigiMatcher& match_gd = GEMDigiMatcher( match_sh, iEvent, geom, cfg_ ,gem_digiToken_, gem_padToken_, gem_copadToken_);
130 
131  track_.pt = t.momentum().pt();
132  track_.phi = t.momentum().phi();
133  track_.eta = t.momentum().eta();
134  std::fill( std::begin(track_.hitOdd), std::end(track_.hitOdd),false);
135  std::fill( std::begin(track_.hitEven), std::end(track_.hitEven),false);
136 
137  for ( int i= 0 ; i< 3 ; i++) {
138  for ( int j= 0 ; j<2 ; j++) {
139  track_.gem_sh[i][j] = false;
140  track_.gem_dg[i][j] = false;
141  track_.gem_pad[i][j] = false;
142  }
143  }
144 
145  // ** GEM SimHits ** //
146  const auto gem_sh_ids_ch = match_sh.chamberIdsGEM();
147  for(auto d: gem_sh_ids_ch)
148  {
149  const GEMDetId id(d);
150  if ( id.chamber() %2 ==0 ) track_.hitEven[id.station()-1] = true;
151  else if ( id.chamber() %2 ==1 ) track_.hitOdd[id.station()-1] = true;
152  else { std::cout<<"Error to get chamber id"<<std::endl;}
153 
154  track_.gem_sh[ id.station()-1][ (id.layer()-1)] = true;
155 
156  }
157  // ** GEM Digis, Pads and CoPads ** //
158  const auto gem_dg_ids_ch = match_gd.chamberIds();
159 
160  for(auto d: gem_dg_ids_ch)
161  {
162  const GEMDetId id(d);
163  track_.gem_dg[ id.station()-1][ (id.layer()-1)] = true;
164  }
165  const auto gem_pad_ids_ch = match_gd.chamberIdsWithPads();
166  for(auto d: gem_pad_ids_ch)
167  {
168  const GEMDetId id(d);
169  track_.gem_pad[ id.station()-1][ (id.layer()-1)] = true;
170  }
171 
172 
173  FillWithTrigger( track_eta, fabs(track_.eta)) ;
174  FillWithTrigger( track_phi, fabs(track_.eta), track_.phi, track_.hitOdd, track_.hitEven);
175 
176 
177  FillWithTrigger( dg_sh_eta, track_.gem_sh , fabs( track_.eta) );
178  FillWithTrigger( dg_eta, track_.gem_dg , fabs( track_.eta) );
179  FillWithTrigger( pad_eta, track_.gem_pad , fabs( track_.eta) );
180  FillWithTrigger( copad_eta, track_.gem_pad , fabs( track_.eta) );
181 
182  // Separate station.
183 
184  FillWithTrigger( dg_sh_phi, track_.gem_sh ,fabs(track_.eta), track_.phi , track_.hitOdd, track_.hitEven);
185  FillWithTrigger( dg_phi, track_.gem_dg ,fabs(track_.eta), track_.phi , track_.hitOdd, track_.hitEven);
186  FillWithTrigger( pad_phi, track_.gem_pad ,fabs(track_.eta), track_.phi , track_.hitOdd, track_.hitEven);
187  FillWithTrigger( copad_phi, track_.gem_pad ,fabs(track_.eta), track_.phi , track_.hitOdd, track_.hitEven);
188 
189 
190  }
191  }
192 }
const double Pi
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
string fill
Definition: lumiContext.py:319
unsigned int nstation
Definition: GEMTrackMatch.h:80
#define PI
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
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]
tuple d
Definition: ztail.py:151
void setGeometry(const GEMGeometry &geom)
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:115
int j
Definition: DBlmapReader.cc:9
bool gem_dg[3][2]
Definition: GEMTrackMatch.h:35
#define end
Definition: vmac.h:37
bool isValid() const
Definition: HandleBase.h:75
edm::EDGetToken gem_copadToken_
edm::EDGetToken gem_digiToken_
static const std::string l_suffix[4]
Definition: GEMDetLabel.h:2
bool hitEven[3]
Definition: GEMTrackMatch.h:39
MonitorElement * track_phi[3][3]
Float_t pt
Definition: GEMTrackMatch.h:27
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:56
GEMDigiTrackMatch(const edm::ParameterSet &ps)
void FillWithTrigger(MonitorElement *me[3], Float_t eta)
MonitorElement * dg_eta[4][3]
static const std::string c_suffix[3]
Definition: GEMDetLabel.h:4
bool gem_pad[3][2]
Definition: GEMTrackMatch.h:36
#define begin
Definition: vmac.h:30
std::set< unsigned int > chamberIdsWithPads() const
static const std::string s_suffix[3]
Definition: GEMDetLabel.h:3
Float_t phi
Definition: GEMTrackMatch.h:27
bool isSimTrackGood(const SimTrack &)
std::set< unsigned int > chamberIds() const
tuple cout
Definition: gather_cfg.py:145
bool gem_sh[3][2]
Definition: GEMTrackMatch.h:34
edm::EDGetToken gem_padToken_
std::vector< SimTrack > SimTrackContainer
MonitorElement * dg_sh_eta[4][3]
Definition: Run.h:43
MonitorElement * copad_eta[4][3]