CMS 3D CMS Logo

TotemRPLocalTrackFitter.cc
Go to the documentation of this file.
1 /****************************************************************************
2 *
3 * This is a part of TOTEM offline software.
4 * Authors:
5 * Hubert Niewiadomski
6 * Jan Kašpar (jan.kaspar@gmail.com)
7 *
8 ****************************************************************************/
9 
11 
18 
23 
26 
28 
29 //----------------------------------------------------------------------------------------------------
30 
35 {
36  public:
37  explicit TotemRPLocalTrackFitter(const edm::ParameterSet& conf);
38 
40 
41  virtual void produce(edm::Event& e, const edm::EventSetup& c) override;
42 
43  private:
45 
48 
50 
53 
56 };
57 
58 //----------------------------------------------------------------------------------------------------
59 //----------------------------------------------------------------------------------------------------
60 
61 using namespace std;
62 using namespace edm;
63 
64 //----------------------------------------------------------------------------------------------------
65 
67  : verbosity_(conf.getParameter<int>("verbosity")), fitter_(conf)
68 {
69  tagUVPattern = conf.getParameter<edm::InputTag>("tagUVPattern");
70  patternCollectionToken = consumes<DetSetVector<TotemRPUVPattern>>(tagUVPattern);
71 
72  produces<DetSetVector<TotemRPLocalTrack>>();
73 }
74 
75 //----------------------------------------------------------------------------------------------------
76 
78 {
79  if (verbosity_ > 5)
80  LogVerbatim("TotemRPLocalTrackFitter") << ">> TotemRPLocalTrackFitter::produce";
81 
82  // get geometry
84  setup.get<VeryForwardRealGeometryRecord>().get(geometry);
85 
86  if (geometryWatcher.check(setup))
87  fitter_.reset();
88 
89  // get input
92 
93  // run fit for each RP
95 
96  for (const auto &rpv : *input)
97  {
98  unsigned int rpDecId = rpv.detId();
99 
100  // is U-V association unique?
101  unsigned int n_U=0, n_V=0;
102  unsigned int idx_U=0, idx_V=0;
103  for (unsigned int pi = 0; pi < rpv.size(); pi++)
104  {
105  const TotemRPUVPattern &pattern = rpv[pi];
106 
107  // here it would make sense to skip non-fittable patterns, but to keep the logic
108  // equivalent to version 7_0_4, nothing is skipped
109  /*
110  if (pattern.getFittable() == false)
111  continue;
112  */
113 
114  switch (pattern.getProjection())
115  {
117  n_U++;
118  idx_U=pi;
119  break;
120 
122  n_V++;
123  idx_V=pi;
124  break;
125 
126  default:
127  break;
128  }
129  }
130 
131  if (n_U != 1 || n_V != 1)
132  {
133  if (verbosity_)
134  LogVerbatim("TotemRPLocalTrackFitter")
135  << ">> TotemRPLocalTrackFitter::produce > Impossible to combine U and V patterns in RP " << rpDecId
136  << " (n_U=" << n_U << ", n_V=" << n_V << ").";
137 
138  continue;
139  }
140 
141  // again, to follow the logic from version 7_0_4, skip the non-fittable patterns here
142  if (!rpv[idx_U].getFittable() || !rpv[idx_V].getFittable())
143  continue;
144 
145  // combine U and V hits
147  for (auto &ids : rpv[idx_U].getHits())
148  {
149  auto &ods = hits.find_or_insert(ids.detId());
150  for (auto &h : ids)
151  ods.push_back(h);
152  }
153 
154  for (auto &ids : rpv[idx_V].getHits())
155  {
156  auto &ods = hits.find_or_insert(ids.detId());
157  for (auto &h : ids)
158  ods.push_back(h);
159  }
160 
161  // run fit
162  const unsigned int armIdx = rpDecId / 100;
163  const unsigned int stIdx = (rpDecId / 10) % 10;
164  const unsigned int rpIdx = rpDecId % 10;
165  TotemRPDetId rpId(armIdx, stIdx, rpIdx);
166 
167  double z0 = geometry->GetRPGlobalTranslation(rpId).z();
168 
170  fitter_.fitTrack(hits, z0, *geometry, track);
171 
172  DetSet<TotemRPLocalTrack> &ds = output.find_or_insert(rpDecId);
173  ds.push_back(track);
174 
175  if (verbosity_ > 5)
176  {
177  unsigned int n_hits = 0;
178  for (auto &hds : track.getHits())
179  n_hits += hds.size();
180 
181  LogVerbatim("TotemRPLocalTrackFitter")
182  << " track in RP " << rpDecId << ": valid = " << track.isValid() << ", hits = " << n_hits;
183  }
184  }
185 
186  // save results
187  e.put(make_unique<DetSetVector<TotemRPLocalTrack>>(output));
188 }
189 
190 //----------------------------------------------------------------------------------------------------
191 
Detector ID class for TOTEM Si strip detectors.
Definition: TotemRPDetId.h:30
T getParameter(std::string const &) const
TotemRPLocalTrackFitter(const edm::ParameterSet &conf)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
void push_back(const T &t)
Definition: DetSet.h:68
bool isValid() const
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
CLHEP::Hep3Vector GetRPGlobalTranslation(int copy_no) const
position of a RP package (translation z corresponds to the first plane - TODO check it) ...
edm::ESWatcher< VeryForwardRealGeometryRecord > geometryWatcher
A watcher to detect geometry changes.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void reset()
Resets the reconstruction-data cache.
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
ProjectionType getProjection() const
Fits tracks trough a single RP.
A track fit through a single RP.
Event setup record containing the real (actual) geometry information.
static std::string const input
Definition: EdmProvDump.cc:44
reference find_or_insert(det_id_type id)
Definition: DetSetVector.h:254
const Double_t pi
const edm::DetSetVector< FittedRecHit > & getHits() const
bool fitTrack(const edm::DetSetVector< TotemRPRecHit > &hits, double z_0, const TotemRPGeometry &tot_geom, TotemRPLocalTrack &fitted_track)
performs the track fit, returns true if successful
A linear pattern in U or V projection. The intercept b is taken at the middle of a RP: (geometry->Get...
TotemRPLocalTrackFitterAlgorithm fitter_
The instance of the fitter module.
const T & get() const
Definition: EventSetup.h:56
Algorithm for fitting tracks through a single RP.
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
ESHandle< TrackerGeometry > geometry
HLT enums.
edm::InputTag tagUVPattern
Selection of the pattern-recognition module.
edm::EDGetTokenT< edm::DetSetVector< TotemRPUVPattern > > patternCollectionToken