CMS 3D CMS Logo

CTPPSLocalTrackLiteProducer.cc
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * This is a part of TOTEM offline software.
4  * Authors:
5  * Jan Kašpar (jan.kaspar@gmail.com)
6  * Laurent Forthomme
7  *
8  ****************************************************************************/
9 
15 
20 
23 
25 
26 //----------------------------------------------------------------------------------------------------
27 
32 public:
34 
35  void produce(edm::Event &, const edm::EventSetup &) override;
37 
38 private:
40  static constexpr float HPTDC_TIME_SLICE_WIDTH = 25.;
41 
44 
48 
51 
54 };
55 
56 //----------------------------------------------------------------------------------------------------
57 
59  const edm::ParameterSet &iConfig)
60  : includeStrips_(iConfig.getParameter<bool>("includeStrips")),
61  includeDiamonds_(iConfig.getParameter<bool>("includeDiamonds")),
62  includePixels_(iConfig.getParameter<bool>("includePixels")),
63  pixelTrackTxMin_(iConfig.getParameter<double>("pixelTrackTxMin")),
64  pixelTrackTxMax_(iConfig.getParameter<double>("pixelTrackTxMax")),
65  pixelTrackTyMin_(iConfig.getParameter<double>("pixelTrackTyMin")),
66  pixelTrackTyMax_(iConfig.getParameter<double>("pixelTrackTyMax")),
67  timingTrackTMin_(iConfig.getParameter<double>("timingTrackTMin")),
68  timingTrackTMax_(iConfig.getParameter<double>("timingTrackTMax")) {
69  auto tagSiStripTrack = iConfig.getParameter<edm::InputTag>("tagSiStripTrack");
70  if (!tagSiStripTrack.label().empty())
72  consumes<edm::DetSetVector<TotemRPLocalTrack>>(tagSiStripTrack);
73 
74  auto tagDiamondTrack = iConfig.getParameter<edm::InputTag>("tagDiamondTrack");
75  if (!tagDiamondTrack.label().empty())
77  consumes<edm::DetSetVector<CTPPSDiamondLocalTrack>>(tagDiamondTrack);
78 
79  auto tagPixelTrack = iConfig.getParameter<edm::InputTag>("tagPixelTrack");
80  if (!tagPixelTrack.label().empty())
83 
84  produces<CTPPSLocalTrackLiteCollection>();
85 }
86 
87 //----------------------------------------------------------------------------------------------------
88 
90  const edm::EventSetup &) {
91  // prepare output
92  auto pOut = std::make_unique<CTPPSLocalTrackLiteCollection>();
93 
94  //----- TOTEM strips
95 
96  // get input from Si strips
97  if (includeStrips_) {
99  iEvent.getByToken(siStripTrackToken_, inputSiStripTracks);
100 
101  // process tracks from Si strips
102  for (const auto &rpv : *inputSiStripTracks) {
103  const uint32_t rpId = rpv.detId();
104  for (const auto &trk : rpv) {
105  if (!trk.isValid())
106  continue;
107 
108  float roundedX0 =
109  MiniFloatConverter::reduceMantissaToNbitsRounding<14>(trk.getX0());
110  float roundedX0Sigma =
111  MiniFloatConverter::reduceMantissaToNbitsRounding<8>(
112  trk.getX0Sigma());
113  float roundedY0 =
114  MiniFloatConverter::reduceMantissaToNbitsRounding<13>(trk.getY0());
115  float roundedY0Sigma =
116  MiniFloatConverter::reduceMantissaToNbitsRounding<8>(
117  trk.getY0Sigma());
118  float roundedTx =
119  MiniFloatConverter::reduceMantissaToNbitsRounding<11>(trk.getTx());
120  float roundedTxSigma =
121  MiniFloatConverter::reduceMantissaToNbitsRounding<8>(
122  trk.getTxSigma());
123  float roundedTy =
124  MiniFloatConverter::reduceMantissaToNbitsRounding<11>(trk.getTy());
125  float roundedTySigma =
126  MiniFloatConverter::reduceMantissaToNbitsRounding<8>(
127  trk.getTySigma());
128  float roundedChiSquaredOverNDF =
129  MiniFloatConverter::reduceMantissaToNbitsRounding<8>(
130  trk.getChiSquaredOverNDF());
131 
132  pOut->emplace_back(rpId, // detector info
133  // spatial info
134  roundedX0, roundedX0Sigma, roundedY0, roundedY0Sigma,
135  // angular info
136  roundedTx, roundedTxSigma, roundedTy, roundedTySigma,
137  // reconstruction info
138  roundedChiSquaredOverNDF,
140  trk.getNumberOfPointsUsedForFit(),
141  // timing info
142  0., 0.);
143  }
144  }
145  }
146 
147  //----- diamond detectors
148 
149  if (includeDiamonds_) {
150  // get input from diamond detectors
152  iEvent.getByToken(diamondTrackToken_, inputDiamondTracks);
153 
154  // process tracks from diamond detectors
155  for (const auto &rpv : *inputDiamondTracks) {
156  const unsigned int rpId = rpv.detId();
157  for (const auto &trk : rpv) {
158  if (!trk.isValid())
159  continue;
160 
161  const float abs_time =
162  trk.getT() + trk.getOOTIndex() * HPTDC_TIME_SLICE_WIDTH;
163  if (abs_time < timingTrackTMin_ || abs_time > timingTrackTMax_)
164  continue;
165 
166  float roundedX0 =
167  MiniFloatConverter::reduceMantissaToNbitsRounding<16>(trk.getX0());
168  float roundedX0Sigma =
169  MiniFloatConverter::reduceMantissaToNbitsRounding<8>(
170  trk.getX0Sigma());
171  float roundedY0 =
172  MiniFloatConverter::reduceMantissaToNbitsRounding<13>(trk.getY0());
173  float roundedY0Sigma =
174  MiniFloatConverter::reduceMantissaToNbitsRounding<8>(
175  trk.getY0Sigma());
176  float roundedT =
177  MiniFloatConverter::reduceMantissaToNbitsRounding<16>(abs_time);
178  float roundedTSigma =
179  MiniFloatConverter::reduceMantissaToNbitsRounding<13>(
180  trk.getTSigma());
181 
182  pOut->emplace_back(rpId, // detector info
183  // spatial info
184  roundedX0, roundedX0Sigma, roundedY0, roundedY0Sigma,
185  // angular info
186  0., 0., 0., 0.,
187  // reconstruction info
189  trk.getNumOfPlanes(),
190  // timing info
191  roundedT, roundedTSigma);
192  }
193  }
194  }
195 
196  //----- pixel detectors
197 
198  if (includePixels_) {
201  iEvent.getByToken(pixelTrackToken_, inputPixelTracks);
202 
203  // process tracks from pixels
204  for (const auto &rpv : *inputPixelTracks) {
205  const uint32_t rpId = rpv.detId();
206  for (const auto &trk : rpv) {
207  if (!trk.isValid())
208  continue;
209  if (trk.getTx() > pixelTrackTxMin_ &&
210  trk.getTx() < pixelTrackTxMax_ &&
211  trk.getTy() > pixelTrackTyMin_ &&
212  trk.getTy() < pixelTrackTyMax_) {
213  float roundedX0 =
214  MiniFloatConverter::reduceMantissaToNbitsRounding<16>(
215  trk.getX0());
216  float roundedX0Sigma =
217  MiniFloatConverter::reduceMantissaToNbitsRounding<8>(
218  trk.getX0Sigma());
219  float roundedY0 =
220  MiniFloatConverter::reduceMantissaToNbitsRounding<13>(
221  trk.getY0());
222  float roundedY0Sigma =
223  MiniFloatConverter::reduceMantissaToNbitsRounding<8>(
224  trk.getY0Sigma());
225  float roundedTx =
226  MiniFloatConverter::reduceMantissaToNbitsRounding<11>(
227  trk.getTx());
228  float roundedTxSigma =
229  MiniFloatConverter::reduceMantissaToNbitsRounding<8>(
230  trk.getTxSigma());
231  float roundedTy =
232  MiniFloatConverter::reduceMantissaToNbitsRounding<11>(
233  trk.getTy());
234  float roundedTySigma =
235  MiniFloatConverter::reduceMantissaToNbitsRounding<8>(
236  trk.getTySigma());
237  float roundedChiSquaredOverNDF =
238  MiniFloatConverter::reduceMantissaToNbitsRounding<8>(
239  trk.getChiSquaredOverNDF());
240 
241  pOut->emplace_back(
242  rpId, // detector info
243  // spatial info
244  roundedX0, roundedX0Sigma, roundedY0, roundedY0Sigma,
245  // angular info
246  roundedTx, roundedTxSigma, roundedTy, roundedTySigma,
247  // reconstruction info
248  roundedChiSquaredOverNDF, trk.getRecoInfo(),
249  trk.getNumberOfPointsUsedForFit(),
250  // timing info
251  0., 0.);
252  }
253  }
254  }
255  }
256  }
257 
258  // save output to event
259  iEvent.put(std::move(pOut));
260 }
261 
262 //----------------------------------------------------------------------------------------------------
263 
267 
268  // By default: all includeXYZ flags set to false.
269  // The includeXYZ are switched on when the "ctpps_2016" era is declared in
270  // python config, see:
271  // RecoCTPPS/TotemRPLocal/python/ctppsLocalTrackLiteProducer_cff.py
272 
273  desc.add<bool>("includeStrips", false)
274  ->setComment("whether tracks from Si strips should be included");
275  desc.add<edm::InputTag>("tagSiStripTrack",
276  edm::InputTag("totemRPLocalTrackFitter"))
277  ->setComment("input TOTEM strips' local tracks collection to retrieve");
278 
279  desc.add<bool>("includeDiamonds", false)
280  ->setComment("whether tracks from diamonds strips should be included");
281  desc.add<edm::InputTag>("tagDiamondTrack",
282  edm::InputTag("ctppsDiamondLocalTracks"))
283  ->setComment(
284  "input diamond detectors' local tracks collection to retrieve");
285 
286  desc.add<bool>("includePixels", false)
287  ->setComment("whether tracks from pixels should be included");
288  desc.add<edm::InputTag>("tagPixelTrack",
289  edm::InputTag("ctppsPixelLocalTracks"))
290  ->setComment(
291  "input pixel detectors' local tracks collection to retrieve");
292  desc.add<double>("timingTrackTMin", -12.5)
293  ->setComment("minimal track time selection for timing detectors, in ns");
294  desc.add<double>("timingTrackTMax", +12.5)
295  ->setComment("maximal track time selection for timing detectors, in ns");
296 
297  desc.add<double>("pixelTrackTxMin", -10.0);
298  desc.add<double>("pixelTrackTxMax", 10.0);
299  desc.add<double>("pixelTrackTyMin", -10.0);
300  desc.add<double>("pixelTrackTyMax", 10.0);
301 
302  descr.add("ctppsLocalTrackLiteDefaultProducer", desc);
303 }
304 
305 //----------------------------------------------------------------------------------------------------
306 
T getParameter(std::string const &) const
void setComment(std::string const &value)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
static float HPTDC_TIME_SLICE_WIDTH
HPTDC time slice width, in ns.
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void produce(edm::Event &, const edm::EventSetup &) override
CTPPSLocalTrackLiteProducer(const edm::ParameterSet &)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< edm::DetSetVector< CTPPSDiamondLocalTrack > > diamondTrackToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< edm::DetSetVector< CTPPSPixelLocalTrack > > pixelTrackToken_
Distills the essential track data from all RPs.
bool isUninitialized() const
Definition: EDGetToken.h:70
edm::EDGetTokenT< edm::DetSetVector< TotemRPLocalTrack > > siStripTrackToken_
static void fillDescriptions(edm::ConfigurationDescriptions &)
def move(src, dest)
Definition: eostools.py:511
#define constexpr