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  CTPPSDetId rpId(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 " << rpId
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  double z0 = geometry->GetRPGlobalTranslation(rpId).z();
163 
165  fitter_.fitTrack(hits, z0, *geometry, track);
166 
167  DetSet<TotemRPLocalTrack> &ds = output.find_or_insert(rpId);
168  ds.push_back(track);
169 
170  if (verbosity_ > 5)
171  {
172  unsigned int n_hits = 0;
173  for (auto &hds : track.getHits())
174  n_hits += hds.size();
175 
176  LogVerbatim("TotemRPLocalTrackFitter")
177  << " track in RP " << rpId << ": valid = " << track.isValid() << ", hits = " << n_hits;
178  }
179  }
180 
181  // save results
182  e.put(make_unique<DetSetVector<TotemRPLocalTrack>>(output));
183 }
184 
185 //----------------------------------------------------------------------------------------------------
186 
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
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
ESHandle< TrackerGeometry > geometry
HLT enums.
edm::InputTag tagUVPattern
Selection of the pattern-recognition module.
edm::EDGetTokenT< edm::DetSetVector< TotemRPUVPattern > > patternCollectionToken