test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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_->regions()[0]->stations()[station-1]->rings()[0]->superChambers()[chamber-1]->chambers()[0];
100  auto& roll1 = ch->etaPartitions()[0]; //.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 
143  edm::LogInfo("GEMTrackMatch")<<"max chamber "<<maxChamberId<<"\n";
144 
145  std::vector<int> pos_ids;
146  pos_ids.push_back(GEMDetId(1,1,1,1,maxChamberId,useRoll_).rawId());
147 
148  std::vector<int> neg_ids;
149  neg_ids.push_back(GEMDetId(-1,1,1,1,maxChamberId,useRoll_).rawId());
150 
151  // VK: I would really suggest getting phis from GEMGeometry
152 
153  std::vector<float> phis;
154  phis.push_back(0.);
155  for(int i=1; i<maxChamberId+1; ++i)
156  {
157  pos_ids.push_back(GEMDetId(1,1,1,1,i,useRoll_).rawId());
158  neg_ids.push_back(GEMDetId(-1,1,1,1,i,useRoll_).rawId());
159  phis.push_back(i*10.);
160  }
161  positiveLUT_ = std::make_pair(phis,pos_ids);
162  negativeLUT_ = std::make_pair(phis,neg_ids);
163 }
164 
165 
167 {
168  gem_geom_ = &geom;
169  bool isEvenOK = true;
170  bool isOddOK = true;
171  useRoll_=1;
172  if ( geom.etaPartition( GEMDetId(1,1,1,1,1,1) ) == nullptr) isOddOK = false;
173  if ( geom.etaPartition( GEMDetId(1,1,1,1,2,1) ) == nullptr) isEvenOK = false;
174  if ( !isEvenOK || !isOddOK) useRoll_=2;
175 
176  const auto top_chamber = static_cast<const GEMEtaPartition*>(geom.idToDetUnit(GEMDetId(1,1,1,1,1,useRoll_)));
177  const int nEtaPartitions(geom.chamber(GEMDetId(1,1,1,1,1,useRoll_))->nEtaPartitions());
178  const auto bottom_chamber = static_cast<const GEMEtaPartition*>(geom.idToDetUnit(GEMDetId(1,1,1,1,1,nEtaPartitions)));
179  const float top_half_striplength = top_chamber->specs()->specificTopology().stripLength()/2.;
180  const float bottom_half_striplength = bottom_chamber->specs()->specificTopology().stripLength()/2.;
181  const LocalPoint lp_top(0., top_half_striplength, 0.);
182  const LocalPoint lp_bottom(0., -bottom_half_striplength, 0.);
183  const GlobalPoint gp_top = top_chamber->toGlobal(lp_top);
184  const GlobalPoint gp_bottom = bottom_chamber->toGlobal(lp_bottom);
185 
186  radiusCenter_ = (gp_bottom.perp() + gp_top.perp())/2.;
187  chamberHeight_ = gp_top.perp() - gp_bottom.perp();
188 
189  const int maxChamberId = geom.regions()[0]->stations()[0]->superChambers().size();
190  buildLUT(maxChamberId);
191 }
192 
193 
194 std::pair<int,int> GEMTrackMatch::getClosestChambers(const int maxChamberId , int region, float phi)
195 {
196  auto& phis(positiveLUT_.first);
197  auto upper = std::upper_bound(phis.begin(), phis.end(), phi);
198  auto& LUT = (region == 1 ? positiveLUT_.second : negativeLUT_.second);
199  return std::make_pair(LUT.at(upper - phis.begin()), (LUT.at((upper - phis.begin() + 1)%maxChamberId)));
200 }
201 
202 std::pair<double, double> GEMTrackMatch::getEtaRangeForPhi( int station )
203 {
204  std::pair<double, double> range;
205  if( station== 0 ) range = std::make_pair( etaRangeForPhi[0],etaRangeForPhi[1]) ;
206  else if( station== 1 ) range = std::make_pair( etaRangeForPhi[2],etaRangeForPhi[3]) ;
207  else if( station== 2 ) range = std::make_pair( etaRangeForPhi[4],etaRangeForPhi[5]) ;
208 
209  return range;
210 }
211 
T getUntrackedParameter(std::string const &, T const &) const
float radiusCenter_
Definition: GEMTrackMatch.h:77
int i
Definition: DBlmapReader.cc:9
tuple array
Definition: mps_check.py:181
unsigned int nstation
Definition: GEMTrackMatch.h:80
T perp() const
Definition: PV3DBase.h:72
virtual const GeomDetUnit * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
Definition: GEMGeometry.cc:33
void buildLUT(const int maxChamberId)
std::pair< std::vector< float >, std::vector< int > > negativeLUT_
Definition: GEMTrackMatch.h:69
float chamberHeight_
Definition: GEMTrackMatch.h:77
const GEMEtaPartition * etaPartition(GEMDetId id) const
Return a GEMEtaPartition given its id.
Definition: GEMGeometry.cc:103
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
virtual float stripLength() const =0
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
std::pair< double, double > getEtaRange(int station, int chamber)
const GEMEtaPartitionSpecs * specs() const
const GEMChamber * chamber(GEMDetId id) const
Definition: GEMGeometry.cc:99
void FillWithTrigger(MonitorElement *me[3], Float_t eta)
Geom::Phi< T > phi() const
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)
int nEtaPartitions() const
Retunr numbers of eta partitions.
Definition: GEMChamber.cc:43
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 &)
tuple cout
Definition: gather_cfg.py:145
std::pair< double, double > getEtaRangeForPhi(int station)
std::vector< unsigned short int > LUT
Definition: DTTracoLUTs.h:32