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  void produce(edm::Event& e, const edm::EventSetup& c) override;
43 
44  private:
46 
49 
51 
54 
57 };
58 
59 //----------------------------------------------------------------------------------------------------
60 //----------------------------------------------------------------------------------------------------
61 
62 using namespace std;
63 using namespace edm;
64 
65 //----------------------------------------------------------------------------------------------------
66 
68  : verbosity_(conf.getParameter<int>("verbosity")), fitter_(conf)
69 {
70  tagUVPattern = conf.getParameter<edm::InputTag>("tagUVPattern");
71  patternCollectionToken = consumes<DetSetVector<TotemRPUVPattern>>(tagUVPattern);
72 
73  produces<DetSetVector<TotemRPLocalTrack>>();
74 }
75 
76 //----------------------------------------------------------------------------------------------------
77 
79 {
80  if (verbosity_ > 5)
81  LogVerbatim("TotemRPLocalTrackFitter") << ">> TotemRPLocalTrackFitter::produce";
82 
83  // get geometry
85  setup.get<VeryForwardRealGeometryRecord>().get(geometry);
86 
87  if (geometryWatcher.check(setup))
88  fitter_.reset();
89 
90  // get input
93 
94  // run fit for each RP
96 
97  for (const auto &rpv : *input)
98  {
99  CTPPSDetId rpId(rpv.detId());
100 
101  // is U-V association unique?
102  unsigned int n_U=0, n_V=0;
103  unsigned int idx_U=0, idx_V=0;
104  for (unsigned int pi = 0; pi < rpv.size(); pi++)
105  {
106  const TotemRPUVPattern &pattern = rpv[pi];
107 
108  // here it would make sense to skip non-fittable patterns, but to keep the logic
109  // equivalent to version 7_0_4, nothing is skipped
110  /*
111  if (pattern.getFittable() == false)
112  continue;
113  */
114 
115  switch (pattern.getProjection())
116  {
118  n_U++;
119  idx_U=pi;
120  break;
121 
123  n_V++;
124  idx_V=pi;
125  break;
126 
127  default:
128  break;
129  }
130  }
131 
132  if (n_U != 1 || n_V != 1)
133  {
134  if (verbosity_)
135  LogVerbatim("TotemRPLocalTrackFitter")
136  << ">> TotemRPLocalTrackFitter::produce > Impossible to combine U and V patterns in RP " << rpId
137  << " (n_U=" << n_U << ", n_V=" << n_V << ").";
138 
139  continue;
140  }
141 
142  // again, to follow the logic from version 7_0_4, skip the non-fittable patterns here
143  if (!rpv[idx_U].getFittable() || !rpv[idx_V].getFittable())
144  continue;
145 
146  // combine U and V hits
148  for (auto &ids : rpv[idx_U].getHits())
149  {
150  auto &ods = hits.find_or_insert(ids.detId());
151  for (auto &h : ids)
152  ods.push_back(h);
153  }
154 
155  for (auto &ids : rpv[idx_V].getHits())
156  {
157  auto &ods = hits.find_or_insert(ids.detId());
158  for (auto &h : ids)
159  ods.push_back(h);
160  }
161 
162  // run fit
163  double z0 = geometry->getRPTranslation(rpId).z();
164 
166  fitter_.fitTrack(hits, z0, *geometry, track);
167 
168  DetSet<TotemRPLocalTrack> &ds = output.find_or_insert(rpId);
169  ds.push_back(track);
170 
171  if (verbosity_ > 5)
172  {
173  unsigned int n_hits = 0;
174  for (auto &hds : track.getHits())
175  n_hits += hds.size();
176 
177  LogVerbatim("TotemRPLocalTrackFitter")
178  << " track in RP " << rpId << ": valid = " << track.isValid() << ", hits = " << n_hits;
179  }
180  }
181 
182  // save results
183  e.put(make_unique<DetSetVector<TotemRPLocalTrack>>(output));
184 }
185 
186 //----------------------------------------------------------------------------------------------------
187 
188 void
190 {
192 
193  desc.add<edm::InputTag>( "tagUVPattern", edm::InputTag( "totemRPUVPatternFinder" ) )
194  ->setComment( "input U-V patterns collection to retrieve" );
195  desc.add<int>( "verbosity", 0 );
196 
197  descr.add( "totemRPLocalTrackFitter", desc );
198 }
199 
200 //----------------------------------------------------------------------------------------------------
201 
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:125
void push_back(const T &t)
Definition: DetSet.h:68
bool isValid() const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
void produce(edm::Event &e, const edm::EventSetup &c) override
edm::ESWatcher< VeryForwardRealGeometryRecord > geometryWatcher
A watcher to detect geometry changes.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
void reset()
Resets the reconstruction-data cache.
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
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:48
reference find_or_insert(det_id_type id)
Definition: DetSetVector.h:254
const Double_t pi
const edm::DetSetVector< FittedRecHit > & getHits() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
A linear pattern in U or V projection. The intercept b is taken at the middle of a RP: (geometry->Get...
CLHEP::Hep3Vector getRPTranslation(unsigned int id) const
TotemRPLocalTrackFitterAlgorithm fitter_
The instance of the fitter module.
bool fitTrack(const edm::DetSetVector< TotemRPRecHit > &hits, double z_0, const CTPPSGeometry &tot_geom, TotemRPLocalTrack &fitted_track)
performs the track fit, returns true if successful
Algorithm for fitting tracks through a single RP.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:52
Base class for CTPPS detector IDs.
Definition: CTPPSDetId.h:32
ESHandle< TrackerGeometry > geometry
HLT enums.
T get() const
Definition: EventSetup.h:71
edm::InputTag tagUVPattern
Selection of the pattern-recognition module.
edm::EDGetTokenT< edm::DetSetVector< TotemRPUVPattern > > patternCollectionToken