CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
MkFitIterationConfigESProducer.cc
Go to the documentation of this file.
3 
5 
7 
8 // mkFit includes
9 #include "Track.h"
10 #include "TrackerInfo.h"
11 #include "mkFit/HitStructures.h"
12 #include "mkFit/IterationConfig.h"
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,
20  IterationSeedPartition &part) {
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].GetHit(hot.index).eta();
30 
31  // Region to be defined by propagation / intersection tests
32  TrackerInfo::EtaRegion reg;
33 
34  // Max eta used for region sorting
35  constexpr float maxEta_regSort = 7.0;
36 
37  const LayerInfo &outer_brl = trk_info.outer_barrel_layer();
38 
39  // Define first (mkFit) layer IDs for each strip subdetector.
40  constexpr int tib1_id = 4;
41  constexpr int tob1_id = 10;
42  constexpr int tecp1_id = 27;
43  constexpr int tecn1_id = 54;
44 
45  const LayerInfo &tib1 = trk_info.m_layers[tib1_id];
46  const LayerInfo &tob1 = trk_info.m_layers[tob1_id];
47 
48  const LayerInfo &tecp1 = trk_info.m_layers[tecp1_id];
49  const LayerInfo &tecn1 = trk_info.m_layers[tecn1_id];
50 
51  const LayerInfo &tec_first = z_dir_pos ? tecp1 : tecn1;
52 
53  const float maxR = S.maxReachRadius();
54  float z_at_maxr;
55 
56  bool can_reach_outer_brl = S.canReachRadius(outer_brl.m_rout);
57  float z_at_outer_brl;
58  bool misses_first_tec;
59  if (can_reach_outer_brl) {
60  z_at_outer_brl = S.zAtR(outer_brl.m_rout);
61  if (z_dir_pos)
62  misses_first_tec = z_at_outer_brl < tec_first.m_zmin;
63  else
64  misses_first_tec = z_at_outer_brl > tec_first.m_zmax;
65  } else {
66  z_at_maxr = S.zAtR(maxR);
67  if (z_dir_pos)
68  misses_first_tec = z_at_maxr < tec_first.m_zmin;
69  else
70  misses_first_tec = z_at_maxr > tec_first.m_zmax;
71  }
72 
73  if (misses_first_tec) {
74  reg = TrackerInfo::Reg_Barrel;
75  } else {
76  if ((S.canReachRadius(tib1.m_rin) && tib1.is_within_z_limits(S.zAtR(tib1.m_rin))) ||
77  (S.canReachRadius(tob1.m_rin) && tob1.is_within_z_limits(S.zAtR(tob1.m_rin)))) {
78  reg = z_dir_pos ? TrackerInfo::Reg_Transition_Pos : TrackerInfo::Reg_Transition_Neg;
79  } else {
80  reg = z_dir_pos ? TrackerInfo::Reg_Endcap_Pos : TrackerInfo::Reg_Endcap_Neg;
81  }
82  }
83 
84  part.m_region[i] = reg;
85 
86  // TrackerInfo::EtaRegion is enum from 0 to 5 (Reg_Endcap_Neg,Reg_Transition_Neg,Reg_Barrel,Reg_Transition_Pos,Reg_Endcap_Pos)
87  // Symmetrization around TrackerInfo::Reg_Barrel for sorting is required
88  part.m_sort_score[i] = maxEta_regSort * (reg - TrackerInfo::Reg_Barrel) + eta;
89  }
90  }
91 
92  [[maybe_unused]] void partitionSeeds1(const TrackerInfo &trk_info,
93  const TrackVec &in_seeds,
94  const EventOfHits &eoh,
95  IterationSeedPartition &part) {
96  // Define first (mkFit) layer IDs for each strip subdetector.
97  constexpr int tib1_id = 4;
98  constexpr int tob1_id = 10;
99  constexpr int tidp1_id = 21;
100  constexpr int tidn1_id = 48;
101  constexpr int tecp1_id = 27;
102  constexpr int tecn1_id = 54;
103 
104  const LayerInfo &tib1 = trk_info.m_layers[tib1_id];
105  const LayerInfo &tob1 = trk_info.m_layers[tob1_id];
106 
107  const LayerInfo &tidp1 = trk_info.m_layers[tidp1_id];
108  const LayerInfo &tidn1 = trk_info.m_layers[tidn1_id];
109 
110  const LayerInfo &tecp1 = trk_info.m_layers[tecp1_id];
111  const LayerInfo &tecn1 = trk_info.m_layers[tecn1_id];
112 
113  // Merge first two layers to account for mono/stereo coverage.
114  // TrackerInfo could hold joint limits for sub-detectors.
115  const auto &L = trk_info.m_layers;
116  const float tidp_rin = std::min(L[tidp1_id].m_rin, L[tidp1_id + 1].m_rin);
117  const float tidp_rout = std::max(L[tidp1_id].m_rout, L[tidp1_id + 1].m_rout);
118  const float tecp_rin = std::min(L[tecp1_id].m_rin, L[tecp1_id + 1].m_rin);
119  const float tecp_rout = std::max(L[tecp1_id].m_rout, L[tecp1_id + 1].m_rout);
120  const float tidn_rin = std::min(L[tidn1_id].m_rin, L[tidn1_id + 1].m_rin);
121  const float tidn_rout = std::max(L[tidn1_id].m_rout, L[tidn1_id + 1].m_rout);
122  const float tecn_rin = std::min(L[tecn1_id].m_rin, L[tecn1_id + 1].m_rin);
123  const float tecn_rout = std::max(L[tecn1_id].m_rout, L[tecn1_id + 1].m_rout);
124 
125  // Bias towards more aggressive transition-region assignemnts.
126  // With current tunning it seems to make things a bit worse.
127  const float tid_z_extra = 0.0f; // 5.0f;
128  const float tec_z_extra = 0.0f; // 10.0f;
129 
130  const size_t size = in_seeds.size();
131 
132  auto barrel_pos_check = [](const Track &S, float maxR, float rin, float zmax) -> bool {
133  bool inside = maxR > rin && S.zAtR(rin) < zmax;
134  return inside;
135  };
136 
137  auto barrel_neg_check = [](const Track &S, float maxR, float rin, float zmin) -> bool {
138  bool inside = maxR > rin && S.zAtR(rin) > zmin;
139  return inside;
140  };
141 
142  auto endcap_pos_check = [](const Track &S, float maxR, float rout, float rin, float zmin) -> bool {
143  bool inside = maxR > rout ? S.zAtR(rout) > zmin : (maxR > rin && S.zAtR(maxR) > zmin);
144  return inside;
145  };
146 
147  auto endcap_neg_check = [](const Track &S, float maxR, float rout, float rin, float zmax) -> bool {
148  bool inside = maxR > rout ? S.zAtR(rout) < zmax : (maxR > rin && S.zAtR(maxR) < zmax);
149  return inside;
150  };
151 
152  for (size_t i = 0; i < size; ++i) {
153  const Track &S = in_seeds[i];
154 
155  const auto &hot = S.getLastHitOnTrack();
156  const float eta = eoh[hot.layer].GetHit(hot.index).eta();
157 
158  // Region to be defined by propagation / intersection tests
159  TrackerInfo::EtaRegion reg;
160 
161  // Max eta used for region sorting
162  constexpr float maxEta_regSort = 7.0;
163 
164  const bool z_dir_pos = S.pz() > 0;
165  const float maxR = S.maxReachRadius();
166 
167  if (z_dir_pos) {
168  const bool in_tib = barrel_pos_check(S, maxR, tib1.m_rin, tib1.m_zmax);
169  const bool in_tob = barrel_pos_check(S, maxR, tob1.m_rin, tob1.m_zmax);
170 
171  if (!in_tib && !in_tob) {
172  reg = TrackerInfo::Reg_Endcap_Pos;
173  } else {
174  const bool in_tid = endcap_pos_check(S, maxR, tidp_rout, tidp_rin, tidp1.m_zmin - tid_z_extra);
175  const bool in_tec = endcap_pos_check(S, maxR, tecp_rout, tecp_rin, tecp1.m_zmin - tec_z_extra);
176 
177  if (!in_tid && !in_tec) {
178  reg = TrackerInfo::Reg_Barrel;
179  } else {
180  reg = TrackerInfo::Reg_Transition_Pos;
181  }
182  }
183  } else {
184  const bool in_tib = barrel_neg_check(S, maxR, tib1.m_rin, tib1.m_zmin);
185  const bool in_tob = barrel_neg_check(S, maxR, tob1.m_rin, tob1.m_zmin);
186 
187  if (!in_tib && !in_tob) {
188  reg = TrackerInfo::Reg_Endcap_Neg;
189  } else {
190  const bool in_tid = endcap_neg_check(S, maxR, tidn_rout, tidn_rin, tidn1.m_zmax + tid_z_extra);
191  const bool in_tec = endcap_neg_check(S, maxR, tecn_rout, tecn_rin, tecn1.m_zmax + tec_z_extra);
192 
193  if (!in_tid && !in_tec) {
194  reg = TrackerInfo::Reg_Barrel;
195  } else {
196  reg = TrackerInfo::Reg_Transition_Neg;
197  }
198  }
199  }
200 
201  part.m_region[i] = reg;
202 
203  // TrackerInfo::EtaRegion is enum from 0 to 5 (Reg_Endcap_Neg,Reg_Transition_Neg,Reg_Barrel,Reg_Transition_Pos,Reg_Endcap_Pos)
204  // Symmetrization around TrackerInfo::Reg_Barrel for sorting is required
205  part.m_sort_score[i] = maxEta_regSort * (reg - TrackerInfo::Reg_Barrel) + eta;
206  }
207  }
208 } // namespace
209 
211 public:
213 
214  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
215 
216  std::unique_ptr<mkfit::IterationConfig> produce(const TrackerRecoGeometryRecord &iRecord);
217 
218 private:
221 };
222 
224  : geomToken_{setWhatProduced(this, iConfig.getParameter<std::string>("ComponentName")).consumes()},
225  configFile_{iConfig.getParameter<edm::FileInPath>("config").fullPath()} {}
226 
229  desc.add<std::string>("ComponentName")->setComment("Product label");
230  desc.add<edm::FileInPath>("config")->setComment("Path to the JSON file for the mkFit configuration parameters");
231  descriptions.addWithDefaultLabel(desc);
232 }
233 
234 std::unique_ptr<mkfit::IterationConfig> MkFitIterationConfigESProducer::produce(
235  const TrackerRecoGeometryRecord &iRecord) {
236  auto it_conf = mkfit::ConfigJson_Load_File(configFile_);
237  it_conf->m_partition_seeds = partitionSeeds1;
238  return it_conf;
239 }
240 
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:163
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
std::unique_ptr< mkfit::IterationConfig > produce(const TrackerRecoGeometryRecord &iRecord)
T min(T a, T b)
Definition: MathUtil.h:58
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< Track > TrackVec
const edm::ESGetToken< MkFitGeometry, TrackerRecoGeometryRecord > geomToken_
part
Definition: HCALResponse.h:20
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
#define DEFINE_FWK_EVENTSETUP_MODULE(type)
Definition: ModuleFactory.h:60
double S(const TLorentzVector &, const TLorentzVector &)
Definition: Particle.cc:97
tuple size
Write out results.
MkFitIterationConfigESProducer(const edm::ParameterSet &iConfig)