CMS 3D CMS Logo

MkFitIterationConfigESProducer.cc
Go to the documentation of this file.
3 
5 
7 
8 // mkFit includes
13 
14 namespace {
15  using namespace mkfit;
16 
17  [[maybe_unused]] void partitionSeeds0(const TrackerInfo &trk_info,
18  const TrackVec &in_seeds,
19  const EventOfHits &eoh,
21  const size_t size = in_seeds.size();
22 
23  for (size_t i = 0; i < size; ++i) {
24  const Track &S = in_seeds[i];
25 
26  const bool z_dir_pos = S.pz() > 0;
27 
28  const auto &hot = S.getLastHitOnTrack();
29  const float eta = eoh[hot.layer].refHit(hot.index).eta();
30 
31  // Region to be defined by propagation / intersection tests
33 
34  const LayerInfo &outer_brl = trk_info.outer_barrel_layer();
35 
36  // Define first (mkFit) layer IDs for each strip subdetector.
37  constexpr int tib1_id = 4;
38  constexpr int tob1_id = 10;
39  constexpr int tecp1_id = 27;
40  constexpr int tecn1_id = 54;
41 
42  const LayerInfo &tib1 = trk_info.layer(tib1_id);
43  const LayerInfo &tob1 = trk_info.layer(tob1_id);
44 
45  const LayerInfo &tecp1 = trk_info.layer(tecp1_id);
46  const LayerInfo &tecn1 = trk_info.layer(tecn1_id);
47 
48  const LayerInfo &tec_first = z_dir_pos ? tecp1 : tecn1;
49 
50  const float maxR = S.maxReachRadius();
51  float z_at_maxr;
52 
53  bool can_reach_outer_brl = S.canReachRadius(outer_brl.rout());
54  float z_at_outer_brl;
55  bool misses_first_tec;
56  if (can_reach_outer_brl) {
57  z_at_outer_brl = S.zAtR(outer_brl.rout());
58  if (z_dir_pos)
59  misses_first_tec = z_at_outer_brl < tec_first.zmin();
60  else
61  misses_first_tec = z_at_outer_brl > tec_first.zmax();
62  } else {
63  z_at_maxr = S.zAtR(maxR);
64  if (z_dir_pos)
65  misses_first_tec = z_at_maxr < tec_first.zmin();
66  else
67  misses_first_tec = z_at_maxr > tec_first.zmax();
68  }
69 
70  if (misses_first_tec) {
72  } else {
73  if ((S.canReachRadius(tib1.rin()) && tib1.is_within_z_limits(S.zAtR(tib1.rin()))) ||
74  (S.canReachRadius(tob1.rin()) && tob1.is_within_z_limits(S.zAtR(tob1.rin())))) {
76  } else {
78  }
79  }
80 
81  part.m_region[i] = reg;
82  if (part.m_phi_eta_foo)
83  part.m_phi_eta_foo(eoh[hot.layer].refHit(hot.index).phi(), eta);
84  }
85  }
86 
87  [[maybe_unused]] void partitionSeeds1(const TrackerInfo &trk_info,
88  const TrackVec &in_seeds,
89  const EventOfHits &eoh,
91  // Define first (mkFit) layer IDs for each strip subdetector.
92  constexpr int tib1_id = 4;
93  constexpr int tob1_id = 10;
94  constexpr int tidp1_id = 21;
95  constexpr int tidn1_id = 48;
96  constexpr int tecp1_id = 27;
97  constexpr int tecn1_id = 54;
98 
99  const LayerInfo &tib1 = trk_info.layer(tib1_id);
100  const LayerInfo &tob1 = trk_info.layer(tob1_id);
101 
102  const LayerInfo &tidp1 = trk_info.layer(tidp1_id);
103  const LayerInfo &tidn1 = trk_info.layer(tidn1_id);
104 
105  const LayerInfo &tecp1 = trk_info.layer(tecp1_id);
106  const LayerInfo &tecn1 = trk_info.layer(tecn1_id);
107 
108  // Merge first two layers to account for mono/stereo coverage.
109  // TrackerInfo could hold joint limits for sub-detectors.
110  const auto &L = trk_info;
111  const float tidp_rin = std::min(L[tidp1_id].rin(), L[tidp1_id + 1].rin());
112  const float tidp_rout = std::max(L[tidp1_id].rout(), L[tidp1_id + 1].rout());
113  const float tecp_rin = std::min(L[tecp1_id].rin(), L[tecp1_id + 1].rin());
114  const float tecp_rout = std::max(L[tecp1_id].rout(), L[tecp1_id + 1].rout());
115  const float tidn_rin = std::min(L[tidn1_id].rin(), L[tidn1_id + 1].rin());
116  const float tidn_rout = std::max(L[tidn1_id].rout(), L[tidn1_id + 1].rout());
117  const float tecn_rin = std::min(L[tecn1_id].rin(), L[tecn1_id + 1].rin());
118  const float tecn_rout = std::max(L[tecn1_id].rout(), L[tecn1_id + 1].rout());
119 
120  // Bias towards more aggressive transition-region assignemnts.
121  // With current tunning it seems to make things a bit worse.
122  const float tid_z_extra = 0.0f; // 5.0f;
123  const float tec_z_extra = 0.0f; // 10.0f;
124 
125  const size_t size = in_seeds.size();
126 
127  auto barrel_pos_check = [](const Track &S, float maxR, float rin, float zmax) -> bool {
128  bool inside = maxR > rin && S.zAtR(rin) < zmax;
129  return inside;
130  };
131 
132  auto barrel_neg_check = [](const Track &S, float maxR, float rin, float zmin) -> bool {
133  bool inside = maxR > rin && S.zAtR(rin) > zmin;
134  return inside;
135  };
136 
137  auto endcap_pos_check = [](const Track &S, float maxR, float rout, float rin, float zmin) -> bool {
138  bool inside = maxR > rout ? S.zAtR(rout) > zmin : (maxR > rin && S.zAtR(maxR) > zmin);
139  return inside;
140  };
141 
142  auto endcap_neg_check = [](const Track &S, float maxR, float rout, float rin, float zmax) -> bool {
143  bool inside = maxR > rout ? S.zAtR(rout) < zmax : (maxR > rin && S.zAtR(maxR) < zmax);
144  return inside;
145  };
146 
147  for (size_t i = 0; i < size; ++i) {
148  const Track &S = in_seeds[i];
149 
150  const auto &hot = S.getLastHitOnTrack();
151  const float eta = eoh[hot.layer].refHit(hot.index).eta();
152 
153  // Region to be defined by propagation / intersection tests
155 
156  const bool z_dir_pos = S.pz() > 0;
157  const float maxR = S.maxReachRadius();
158 
159  if (z_dir_pos) {
160  const bool in_tib = barrel_pos_check(S, maxR, tib1.rin(), tib1.zmax());
161  const bool in_tob = barrel_pos_check(S, maxR, tob1.rin(), tob1.zmax());
162 
163  if (!in_tib && !in_tob) {
165  } else {
166  const bool in_tid = endcap_pos_check(S, maxR, tidp_rout, tidp_rin, tidp1.zmin() - tid_z_extra);
167  const bool in_tec = endcap_pos_check(S, maxR, tecp_rout, tecp_rin, tecp1.zmin() - tec_z_extra);
168 
169  if (!in_tid && !in_tec) {
171  } else {
173  }
174  }
175  } else {
176  const bool in_tib = barrel_neg_check(S, maxR, tib1.rin(), tib1.zmin());
177  const bool in_tob = barrel_neg_check(S, maxR, tob1.rin(), tob1.zmin());
178 
179  if (!in_tib && !in_tob) {
181  } else {
182  const bool in_tid = endcap_neg_check(S, maxR, tidn_rout, tidn_rin, tidn1.zmax() + tid_z_extra);
183  const bool in_tec = endcap_neg_check(S, maxR, tecn_rout, tecn_rin, tecn1.zmax() + tec_z_extra);
184 
185  if (!in_tid && !in_tec) {
187  } else {
189  }
190  }
191  }
192 
193  part.m_region[i] = reg;
194  if (part.m_phi_eta_foo)
195  part.m_phi_eta_foo(eoh[hot.layer].refHit(hot.index).phi(), eta);
196  }
197  }
198 } // namespace
199 
201 public:
203 
204  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
205 
206  std::unique_ptr<mkfit::IterationConfig> produce(const TrackerRecoGeometryRecord &iRecord);
207 
208 private:
211  const float minPtCut_;
212  const unsigned int maxClusterSize_;
213 };
214 
216  : geomToken_{setWhatProduced(this, iConfig.getParameter<std::string>("ComponentName")).consumes()},
217  configFile_{iConfig.getParameter<edm::FileInPath>("config").fullPath()},
218  minPtCut_{(float)iConfig.getParameter<double>("minPt")},
219  maxClusterSize_{iConfig.getParameter<unsigned int>("maxClusterSize")} {}
220 
223  desc.add<std::string>("ComponentName")->setComment("Product label");
224  desc.add<edm::FileInPath>("config")->setComment("Path to the JSON file for the mkFit configuration parameters");
225  desc.add<double>("minPt", 0.0)->setComment("min pT cut applied during track building");
226  desc.add<unsigned int>("maxClusterSize", 8)->setComment("Max cluster size of SiStrip hits");
227  descriptions.addWithDefaultLabel(desc);
228 }
229 
230 std::unique_ptr<mkfit::IterationConfig> MkFitIterationConfigESProducer::produce(
231  const TrackerRecoGeometryRecord &iRecord) {
233  auto it_conf = cj.load_File(configFile_);
234  it_conf->m_params.minPtCut = minPtCut_;
235  it_conf->m_backward_params.minPtCut = minPtCut_;
236  it_conf->m_partition_seeds = partitionSeeds1;
237  it_conf->m_params.maxClusterSize = maxClusterSize_;
238  it_conf->m_backward_params.maxClusterSize = maxClusterSize_;
239  return it_conf;
240 }
241 
size
Write out results.
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
float rin() const
Definition: TrackerInfo.h:58
std::unique_ptr< mkfit::IterationConfig > produce(const TrackerRecoGeometryRecord &iRecord)
const LayerInfo & outer_barrel_layer() const
Definition: TrackerInfo.h:169
float zmax() const
Definition: TrackerInfo.h:62
bool is_within_z_limits(float z) const
Definition: TrackerInfo.h:72
float zmin() const
Definition: TrackerInfo.h:61
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const LayerInfo & layer(int l) const
Definition: TrackerInfo.h:162
std::vector< Track > TrackVec
const edm::ESGetToken< MkFitGeometry, TrackerRecoGeometryRecord > geomToken_
std::unique_ptr< IterationConfig > load_File(const std::string &fname)
part
Definition: HCALResponse.h:20
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
float rout() const
Definition: TrackerInfo.h:59
MkFitIterationConfigESProducer(const edm::ParameterSet &iConfig)