CMS 3D CMS Logo

GEMTrackMatch.cc
Go to the documentation of this file.
4 
5 
7 {
8  minPt_ = ps.getUntrackedParameter<double>("gemMinPt",5.0);
9  minEta_ = ps.getUntrackedParameter<double>("gemMinEta",1.55);
10  maxEta_ = ps.getUntrackedParameter<double>("gemMaxEta",2.45);
11 }
12 
13 
15 }
16 
18 {
19  for( unsigned int i=0 ; i<nstation ; i++) {
20  hist[i]->Fill(eta);
21  }
22  return;
23 }
24 
25 void GEMTrackMatch::FillWithTrigger( MonitorElement* hist[3][3],Float_t eta, Float_t phi, bool odd[3], bool even[3])
26 {
27  for( unsigned int i=0 ; i<nstation ; i++) {
28  int station = i+1;
29  if ( odd[i] && eta > getEtaRange(station,1).first&& eta < getEtaRange(station,1).second ) {
30  hist[i][0]->Fill(phi);
31  if( hist[i][1] != nullptr) hist[i][1]->Fill(phi);
32  }
33  if ( even[i] && eta > getEtaRange(station,2).first&& eta < getEtaRange(station,2).second ) {
34  hist[i][0]->Fill(phi);
35  if( hist[i][2] != nullptr) hist[i][2]->Fill(phi);
36  }
37  }
38  return;
39 }
40 
41 void GEMTrackMatch::FillWithTrigger( MonitorElement* hist[4][3], bool array[3][2], Float_t value)
42 {
43  for( unsigned int i=0 ; i<nstation ; i++) {
44  if ( array[i][0] ) hist[0][i]->Fill(value);
45  if ( array[i][1] ) hist[1][i]->Fill(value);
46  if ( array[i][0] || array[i][1] ) hist[2][i]->Fill(value);
47  if ( array[i][0] && array[i][1] ) hist[3][i]->Fill(value);
48  }
49  return;
50 }
51 
52 void GEMTrackMatch::FillWithTrigger( MonitorElement* hist[4][3][3], bool array[3][2], Float_t eta, Float_t phi, bool odd[3], bool even[3])
53 {
54  for( unsigned int i=0 ; i<nstation ; i++) {
55  int station = i+1;
56  if ( odd[i] && eta > getEtaRange(station,1).first&& eta < getEtaRange(station,1).second ) {
57  if ( array[i][0] ) {
58  hist[0][i][0]->Fill(phi);
59  if ( hist[0][i][1] != nullptr) hist[0][i][1]->Fill(phi);
60  }
61  if ( array[i][1] ) {
62  hist[1][i][0]->Fill(phi);
63  if( hist[1][i][1] != nullptr ) hist[1][i][1]->Fill(phi);
64  }
65  if ( array[i][0] || array[i][1] ) {
66  hist[2][i][0]->Fill(phi);
67  if ( hist[2][i][1] != nullptr) hist[2][i][1]->Fill(phi);
68  }
69  if ( array[i][0] && array[i][1] ) {
70  hist[3][i][0]->Fill(phi);
71  if ( hist[3][i][1] != nullptr) hist[3][i][1]->Fill(phi);
72  }
73  }
74  if ( even[i] && eta > getEtaRange(station,2).first&& eta < getEtaRange(station,2).second ) {
75  if ( array[i][0] ) {
76  hist[0][i][0]->Fill(phi);
77  if ( hist[0][i][2]!=nullptr) hist[0][i][2]->Fill(phi);
78  }
79  if ( array[i][1] ) {
80  hist[1][i][0]->Fill(phi);
81  if( hist[1][i][2]!=nullptr ) hist[1][i][2]->Fill(phi);
82  }
83  if ( array[i][0] || array[i][1] ) {
84  hist[2][i][0]->Fill(phi);
85  if( hist[2][i][2]!=nullptr) hist[2][i][2]->Fill(phi);
86  }
87  if ( array[i][0] && array[i][1] ) {
88  hist[3][i][0]->Fill(phi);
89  if( hist[3][i][2]!=nullptr) hist[3][i][2]->Fill(phi);
90  }
91  }
92  }
93  return;
94 }
95 
96 std::pair<double,double> GEMTrackMatch::getEtaRange( int station, int chamber )
97 {
98  if( gem_geom_ != nullptr) {
99  auto& ch = gem_geom_->chambers().front();
100  auto& roll1 = ch->etaPartitions().front(); //.begin();
101  auto& roll2 = ch->etaPartitions()[ch->nEtaPartitions()-1];
102  const BoundPlane& bSurface1(roll1->surface());
103  const BoundPlane& bSurface2(roll2->surface());
104  auto& parameters1( roll1->specs()->parameters());
105  float height1(parameters1[2]);
106  auto& parameters2( roll2->specs()->parameters());
107  float height2(parameters2[2]);
108  LocalPoint lTop1( 0., height1, 0.);
109  GlobalPoint gTop1(bSurface1.toGlobal(lTop1));
110  //LocalPoint lBottom1( 0., -height1, 0.);
111  //GlobalPoint gBottom1(bSurface1.toGlobal(lBottom1));
112  //LocalPoint lTop2( 0., height2, 0.);
113  //GlobalPoint gTop2(bSurface2.toGlobal(lTop2));
114  LocalPoint lBottom2( 0., -height2, 0.);
115  GlobalPoint gBottom2(bSurface2.toGlobal(lBottom2));
116  double eta1 = fabs(gTop1.eta()) - 0.01;
117  double eta2 = fabs(gBottom2.eta()) + 0.01;
118  return std::make_pair(eta1,eta2);
119  }
120  else { std::cout<<"Failed to get geometry information"<<std::endl;
121  return std::make_pair(0,0);
122  }
123 }
124 
125 
127 {
128 
129  // SimTrack selection
130  if (t.noVertex()) return false;
131  if (t.noGenpart()) return false;
132  if (std::abs(t.type()) != 13) return false; // only interested in direct muon simtracks
133  if (t.momentum().pt() < minPt_ ) return false;
134  const float eta(std::abs(t.momentum().eta()));
135  if (eta > maxEta_ || eta < minEta_ ) return false; // no GEMs could be in such eta
136  return true;
137 }
138 
139 
140 void GEMTrackMatch::buildLUT(const int maxChamberId)
141 {
142  edm::LogInfo("GEMTrackMatch")<<"GEMTrackMatch::buildLUT"<<std::endl;
143  edm::LogInfo("GEMTrackMatch")<<"max chamber "<<maxChamberId<<"\n";
144 
145  std::vector<int> pos_ids, neg_ids;
146  std::vector<float> phis_pos;
147  std::vector<float> phis_neg;
148  LocalPoint lCentre( 0., 0., 0. );
149 
150  for(auto it : gem_geom_->chambers()) {
151  if(it->id().region()>0) {
152  pos_ids.push_back(it->id().rawId());
153  edm::LogInfo("GEMTrackMatch")<<"added id = "<<it->id()<<" = "<<it->id().rawId()<<" to pos ids"<<std::endl;
154  const BoundPlane& bSurface(it->surface());
155  GlobalPoint gCentre(bSurface.toGlobal(lCentre));
156  int cphi(gCentre.phi().degrees());
157  if (cphi < 0) cphi += 360;
158  phis_pos.push_back(cphi);
159  edm::LogInfo("GEMTrackMatch")<<"added phi = "<<cphi<<" to phi pos vector"<<std::endl;
160  }
161  else if(it->id().region()<0) {
162  neg_ids.push_back(it->id().rawId());
163  edm::LogInfo("GEMTrackMatch")<<"added id = "<<it->id()<<" = "<<it->id().rawId()<<" to neg ids"<<std::endl;
164  const BoundPlane& bSurface(it->surface());
165  GlobalPoint gCentre(bSurface.toGlobal(lCentre));
166  int cphi(gCentre.phi().degrees());
167  if (cphi < 0) cphi += 360;
168  phis_neg.push_back(cphi);
169  edm::LogInfo("GEMTrackMatch")<<"added phi = "<<cphi<<" to phi neg vector"<<std::endl;
170  }
171  }
172  positiveLUT_ = std::make_pair(phis_pos,pos_ids);
173  negativeLUT_ = std::make_pair(phis_neg,neg_ids);
174 }
175 
176 
178 {
179  edm::LogInfo("GEMTrackMatch")<<"GEMTrackMatch :: setGeometry"<<std::endl;
180  gem_geom_ = &geom;
181  GEMDetId chId(gem_geom_->chambers().front()->id());
182  useRoll_ = 1;
183  const auto top_chamber = static_cast<const GEMEtaPartition*>(geom.idToDetUnit(GEMDetId(chId.region(),chId.ring(),chId.station(),chId.layer(),chId.chamber(),useRoll_)));
184  const int nEtaPartitions(gem_geom_->chambers().front()->nEtaPartitions());
185  const auto bottom_chamber = static_cast<const GEMEtaPartition*>(geom.idToDetUnit(GEMDetId(chId.region(),chId.ring(),chId.station(),chId.layer(),chId.chamber(),nEtaPartitions)));
186  const float top_half_striplength = top_chamber->specs()->specificTopology().stripLength()/2.;
187  const float bottom_half_striplength = bottom_chamber->specs()->specificTopology().stripLength()/2.;
188  const LocalPoint lp_top(0., top_half_striplength, 0.);
189  const LocalPoint lp_bottom(0., -bottom_half_striplength, 0.);
190  const GlobalPoint gp_top = top_chamber->toGlobal(lp_top);
191  const GlobalPoint gp_bottom = bottom_chamber->toGlobal(lp_bottom);
192 
193  radiusCenter_ = (gp_bottom.perp() + gp_top.perp())/2.;
194  chamberHeight_ = gp_top.perp() - gp_bottom.perp();
195 
196  const int maxChamberId = geom.regions()[0]->stations()[0]->superChambers().size();
197  edm::LogInfo("GEMTrackMatch")<<"GEMTrackMatch :: setGeometry --> Calling buildLUT"<<std::endl;
198  buildLUT(maxChamberId);
199 }
200 
201 
202 std::pair<int,int> GEMTrackMatch::getClosestChambers(const int maxChamberId , int region, float phi)
203 {
204  auto& phis(positiveLUT_.first);
205  auto upper = std::upper_bound(phis.begin(), phis.end(), phi);
206  auto& LUT = (region == 1 ? positiveLUT_.second : negativeLUT_.second);
207  return std::make_pair(LUT.at(upper - phis.begin()), (LUT.at((upper - phis.begin() + 1)%maxChamberId)));
208 }
209 
210 std::pair<double, double> GEMTrackMatch::getEtaRangeForPhi( int station )
211 {
212  std::pair<double, double> range;
213  if( station== 0 ) range = std::make_pair( etaRangeForPhi[0],etaRangeForPhi[1]) ;
214  else if( station== 1 ) range = std::make_pair( etaRangeForPhi[2],etaRangeForPhi[3]) ;
215  else if( station== 2 ) range = std::make_pair( etaRangeForPhi[4],etaRangeForPhi[5]) ;
216 
217  return range;
218 }
219 
T getUntrackedParameter(std::string const &, T const &) const
float radiusCenter_
Definition: GEMTrackMatch.h:77
virtual float stripLength() const =0
unsigned int nstation
Definition: GEMTrackMatch.h:80
T perp() const
Definition: PV3DBase.h:72
void buildLUT(const int maxChamberId)
std::pair< std::vector< float >, std::vector< int > > negativeLUT_
Definition: GEMTrackMatch.h:69
float chamberHeight_
Definition: GEMTrackMatch.h:77
std::vector< double > etaRangeForPhi
Definition: GEMTrackMatch.h:71
void Fill(long long x)
U second(std::pair< T, U > const &p)
const StripTopology & specificTopology() const
void setGeometry(const GEMGeometry &geom)
bool noGenpart() const
Definition: SimTrack.h:34
const GeomDetUnit * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: GEMGeometry.cc:33
const std::vector< const GEMRegion * > & regions() const
Return a vector of all GEM regions.
Definition: GEMGeometry.cc:43
GEMTrackMatch(const edm::ParameterSet &cfg)
Definition: GEMTrackMatch.cc:6
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool noVertex() const
Definition: SimTrack.h:30
Definition: value.py:1
std::pair< double, double > getEtaRange(int station, int chamber)
const GEMEtaPartitionSpecs * specs() const
void FillWithTrigger(MonitorElement *me[3], Float_t eta)
const std::vector< const GEMChamber * > & chambers() const
Return a vector of all GEM chambers.
Definition: GEMGeometry.cc:59
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:25
const GEMGeometry * gem_geom_
Definition: GEMTrackMatch.h:79
std::pair< int, int > getClosestChambers(const int maxChamberId, int region, float phi)
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:22
std::pair< std::vector< float >, std::vector< int > > positiveLUT_
Definition: GEMTrackMatch.h:68
virtual ~GEMTrackMatch()
bool isSimTrackGood(const SimTrack &)
std::pair< double, double > getEtaRangeForPhi(int station)
std::vector< unsigned short int > LUT
Definition: DTTracoLUTs.h:32