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 
47 
50 
53 };
54 
55 //----------------------------------------------------------------------------------------------------
56 
58  : includeStrips_(iConfig.getParameter<bool>("includeStrips")),
59  includeDiamonds_(iConfig.getParameter<bool>("includeDiamonds")),
60  includePixels_(iConfig.getParameter<bool>("includePixels")),
61  pixelTrackTxMin_(iConfig.getParameter<double>("pixelTrackTxMin")),
62  pixelTrackTxMax_(iConfig.getParameter<double>("pixelTrackTxMax")),
63  pixelTrackTyMin_(iConfig.getParameter<double>("pixelTrackTyMin")),
64  pixelTrackTyMax_(iConfig.getParameter<double>("pixelTrackTyMax")),
65  timingTrackTMin_(iConfig.getParameter<double>("timingTrackTMin")),
66  timingTrackTMax_(iConfig.getParameter<double>("timingTrackTMax")) {
67  auto tagSiStripTrack = iConfig.getParameter<edm::InputTag>("tagSiStripTrack");
68  if (!tagSiStripTrack.label().empty())
70 
71  auto tagDiamondTrack = iConfig.getParameter<edm::InputTag>("tagDiamondTrack");
72  if (!tagDiamondTrack.label().empty())
74 
75  auto tagPixelTrack = iConfig.getParameter<edm::InputTag>("tagPixelTrack");
76  if (!tagPixelTrack.label().empty())
78 
79  produces<CTPPSLocalTrackLiteCollection>();
80 }
81 
82 //----------------------------------------------------------------------------------------------------
83 
85  // prepare output
86  auto pOut = std::make_unique<CTPPSLocalTrackLiteCollection>();
87 
88  //----- TOTEM strips
89 
90  // get input from Si strips
91  if (includeStrips_) {
93  iEvent.getByToken(siStripTrackToken_, inputSiStripTracks);
94 
95  // process tracks from Si strips
96  for (const auto &rpv : *inputSiStripTracks) {
97  const uint32_t rpId = rpv.detId();
98  for (const auto &trk : rpv) {
99  if (!trk.isValid())
100  continue;
101 
102  float roundedX0 = MiniFloatConverter::reduceMantissaToNbitsRounding<14>(trk.x0());
103  float roundedX0Sigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.x0Sigma());
104  float roundedY0 = MiniFloatConverter::reduceMantissaToNbitsRounding<13>(trk.y0());
105  float roundedY0Sigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.y0Sigma());
106  float roundedTx = MiniFloatConverter::reduceMantissaToNbitsRounding<11>(trk.tx());
107  float roundedTxSigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.txSigma());
108  float roundedTy = MiniFloatConverter::reduceMantissaToNbitsRounding<11>(trk.ty());
109  float roundedTySigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.tySigma());
110  float roundedChiSquaredOverNDF = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.chiSquaredOverNDF());
111 
112  pOut->emplace_back(rpId, // detector info
113  // spatial info
114  roundedX0,
115  roundedX0Sigma,
116  roundedY0,
117  roundedY0Sigma,
118  // angular info
119  roundedTx,
120  roundedTxSigma,
121  roundedTy,
122  roundedTySigma,
123  // reconstruction info
124  roundedChiSquaredOverNDF,
126  trk.numberOfPointsUsedForFit(),
127  // timing info
128  0.,
129  0.);
130  }
131  }
132  }
133 
134  //----- diamond detectors
135 
136  if (includeDiamonds_) {
137  // get input from diamond detectors
139  iEvent.getByToken(diamondTrackToken_, inputDiamondTracks);
140 
141  // process tracks from diamond detectors
142  for (const auto &rpv : *inputDiamondTracks) {
143  const unsigned int rpId = rpv.detId();
144  for (const auto &trk : rpv) {
145  if (!trk.isValid())
146  continue;
147 
148  const float abs_time = trk.time() + trk.ootIndex() * HPTDC_TIME_SLICE_WIDTH;
149  if (abs_time < timingTrackTMin_ || abs_time > timingTrackTMax_)
150  continue;
151 
152  float roundedX0 = MiniFloatConverter::reduceMantissaToNbitsRounding<16>(trk.x0());
153  float roundedX0Sigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.x0Sigma());
154  float roundedY0 = MiniFloatConverter::reduceMantissaToNbitsRounding<13>(trk.y0());
155  float roundedY0Sigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.y0Sigma());
156  float roundedT = MiniFloatConverter::reduceMantissaToNbitsRounding<16>(abs_time);
157  float roundedTSigma = MiniFloatConverter::reduceMantissaToNbitsRounding<13>(trk.timeSigma());
158 
159  pOut->emplace_back(rpId, // detector info
160  // spatial info
161  roundedX0,
162  roundedX0Sigma,
163  roundedY0,
164  roundedY0Sigma,
165  // angular info
166  0.,
167  0.,
168  0.,
169  0.,
170  // reconstruction info
171  0.,
173  trk.numberOfPlanes(),
174  // timing info
175  roundedT,
176  roundedTSigma);
177  }
178  }
179  }
180 
181  //----- pixel detectors
182 
183  if (includePixels_) {
186  iEvent.getByToken(pixelTrackToken_, inputPixelTracks);
187 
188  // process tracks from pixels
189  for (const auto &rpv : *inputPixelTracks) {
190  const uint32_t rpId = rpv.detId();
191  for (const auto &trk : rpv) {
192  if (!trk.isValid())
193  continue;
194  if (trk.tx() > pixelTrackTxMin_ && trk.tx() < pixelTrackTxMax_ && trk.ty() > pixelTrackTyMin_ &&
195  trk.ty() < pixelTrackTyMax_) {
196  float roundedX0 = MiniFloatConverter::reduceMantissaToNbitsRounding<16>(trk.x0());
197  float roundedX0Sigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.x0Sigma());
198  float roundedY0 = MiniFloatConverter::reduceMantissaToNbitsRounding<13>(trk.y0());
199  float roundedY0Sigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.y0Sigma());
200  float roundedTx = MiniFloatConverter::reduceMantissaToNbitsRounding<11>(trk.tx());
201  float roundedTxSigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.txSigma());
202  float roundedTy = MiniFloatConverter::reduceMantissaToNbitsRounding<11>(trk.ty());
203  float roundedTySigma = MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.tySigma());
204  float roundedChiSquaredOverNDF =
205  MiniFloatConverter::reduceMantissaToNbitsRounding<8>(trk.chiSquaredOverNDF());
206 
207  pOut->emplace_back(rpId, // detector info
208  // spatial info
209  roundedX0,
210  roundedX0Sigma,
211  roundedY0,
212  roundedY0Sigma,
213  // angular info
214  roundedTx,
215  roundedTxSigma,
216  roundedTy,
217  roundedTySigma,
218  // reconstruction info
219  roundedChiSquaredOverNDF,
220  trk.recoInfo(),
221  trk.numberOfPointsUsedForFit(),
222  // timing info
223  0.,
224  0.);
225  }
226  }
227  }
228  }
229  }
230 
231  // save output to event
232  iEvent.put(std::move(pOut));
233 }
234 
235 //----------------------------------------------------------------------------------------------------
236 
239 
240  // By default: all includeXYZ flags set to false.
241  // The includeXYZ are switched on when the "ctpps" era modifier is declared in
242  // python config, see:
243  // RecoPPS/Local/python/ctppsLocalTrackLiteProducer_cff.py
244 
245  desc.add<bool>("includeStrips", false)->setComment("whether tracks from Si strips should be included");
246  desc.add<edm::InputTag>("tagSiStripTrack", edm::InputTag("totemRPLocalTrackFitter"))
247  ->setComment("input TOTEM strips' local tracks collection to retrieve");
248 
249  desc.add<bool>("includeDiamonds", false)->setComment("whether tracks from diamonds strips should be included");
250  desc.add<edm::InputTag>("tagDiamondTrack", edm::InputTag("ctppsDiamondLocalTracks"))
251  ->setComment("input diamond detectors' local tracks collection to retrieve");
252 
253  desc.add<bool>("includePixels", false)->setComment("whether tracks from pixels should be included");
254  desc.add<edm::InputTag>("tagPixelTrack", edm::InputTag("ctppsPixelLocalTracks"))
255  ->setComment("input pixel detectors' local tracks collection to retrieve");
256  desc.add<double>("timingTrackTMin", -12.5)->setComment("minimal track time selection for timing detectors, in ns");
257  desc.add<double>("timingTrackTMax", +12.5)->setComment("maximal track time selection for timing detectors, in ns");
258 
259  desc.add<double>("pixelTrackTxMin", -10.0);
260  desc.add<double>("pixelTrackTxMax", 10.0);
261  desc.add<double>("pixelTrackTyMin", -10.0);
262  desc.add<double>("pixelTrackTyMax", 10.0);
263 
264  descr.add("ctppsLocalTrackLiteDefaultProducer", desc);
265 }
266 
267 //----------------------------------------------------------------------------------------------------
268 
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:98
static constexpr float HPTDC_TIME_SLICE_WIDTH
HPTDC time slice width, in ns.
int iEvent
Definition: GenABIO.cc:224
void produce(edm::Event &, const edm::EventSetup &) override
CTPPSLocalTrackLiteProducer(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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.
edm::EDGetTokenT< edm::DetSetVector< TotemRPLocalTrack > > siStripTrackToken_
static void fillDescriptions(edm::ConfigurationDescriptions &)
def move(src, dest)
Definition: eostools.py:511