Main algorithm creating the wire hits.
213{
214
215 if (not outputWireHits.empty()) return;
216
221
222
223 StoreArray<CDCHit> hits;
224 std::size_t nHits = hits.getEntries();
225 if (nHits == 0) {
226 B2WARNING("Event with no hits");
227 outputWireHits.clear();
228 }
229
230 std::map<int, size_t> nHitsByMCParticleId;
231
232 outputWireHits.reserve(nHits);
233
234
236 B2FATAL("CDClayerTimeCut DB object is invalid");
237 }
238
239 for (const CDCHit& hit : hits) {
240
243 continue;
244 }
245
246
248 continue;
249 }
250
251
253 MCParticle* mcParticle = hit.getRelated<MCParticle>();
255 if (mcParticle) {
256 nHitsByMCParticleId[mcParticleId]++;
257 }
260 mcParticleId);
261 if (not useMCParticleId) continue;
262 }
263
264 WireID wireID(hit.getID());
266 B2WARNING("Skip invalid wire id " << hit.getID());
267 continue;
268 }
269
270
272 continue;
273 }
274
275
276
277 const double approxDriftTime = tdcCountTranslator.
getDriftTime(hit.getTDCCount(), wireID, 0, 0, hit.getADCCount());
278 ISuperLayer iSL = wireID.getISuperLayer();
279
280
283 } else {
285 }
286
288 unsigned short layer = wireID.getICLayer();
290
291 const CDCWire& wire = wireTopology.
getWire(wireID);
292
294
295
297
298
300 MCParticle* mcParticle = hit.getRelated<MCParticle>();
302 if (mcParticle) {
303 nHitsByMCParticleId[mcParticleId]++;
304 }
307 mcParticleId);
308 if (not useMCParticleId) continue;
309 }
310
311
312
313
315 const double alpha = isIncoming ? M_PI : 0;
316 const double beta = 1;
317 const double flightTimeEstimate =
319
320 const double driftTime = tdcCountTranslator.
getDriftTime(hit.getTDCCount(),
322 flightTimeEstimate,
324 hit.getADCCount());
325 const bool left = false;
326 const bool right = true;
327 const double theta = M_PI / 2;
328
329 const double leftRefDriftLength =
332 flightTimeEstimate,
333 left,
335 alpha,
336 theta);
337
338 const double rightRefDriftLength =
341 flightTimeEstimate,
342 right,
344 alpha,
345 theta);
346
347 const double refDriftLength =
348 (leftRefDriftLength + rightRefDriftLength) / 2.0;
349
350 const double leftRefDriftLengthVariance =
353 left,
355 alpha,
356 theta);
357
358 const double rightRefDriftLengthVariance =
361 right,
363 alpha,
364 theta);
365
366 const double refDriftLengthVariance =
367 (leftRefDriftLengthVariance + rightRefDriftLengthVariance) / 2.0;
368
369 const double leftRefChargeDeposit =
370 adcCountTranslator.
getCharge(hit.getADCCount(),
372 left,
374 theta);
375
376 const double rightRefChargeDeposit =
377 adcCountTranslator.
getCharge(hit.getADCCount(),
379 right,
381 theta);
382
383 const double refChargeDeposit =
384 (leftRefChargeDeposit + rightRefChargeDeposit) / 2.0;
385
386 outputWireHits.emplace_back(&hit, refDriftLength, refDriftLengthVariance, refChargeDeposit, driftTime);
387 }
388
389 std::sort(outputWireHits.begin(), outputWireHits.end());
390
392 for (const std::pair<int, size_t> nHitsForMCParticleId : nHitsByMCParticleId) {
393 B2DEBUG(25,
394 "MC particle " << nHitsForMCParticleId.first << " #hits "
395 << nHitsForMCParticleId.second);
396 }
397 }
398}
virtual float getCharge(unsigned short adcCount=0, const WireID &wireID=WireID(), bool ambiguityDiscriminator=false, float z=0, float theta=static_cast< float >(TMath::Pi()/2.))=0
Function, for which this actually was meant.
ushort getOffsetOfFirstLayer() const
Get the offset of the first layer.
bool isBadWire(const WireID &wid)
Inquire if the wire is totally-dead.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
ushort getOffsetOfFirstSuperLayer() const
Get the offset of the first super layer.
virtual double getDriftLength(unsigned short tdcCount=0, const WireID &wireID=WireID(), double timeOfFlightEstimator=0., bool ambiguityDiscriminator=false, double z=0, double alpha=0, double theta=static_cast< double >(TMath::Pi()/2.), unsigned short adcCount=0)=0
Function for getting a drift length estimation.
virtual double getDriftLengthResolution(double driftLength=0., const WireID &wireID=WireID(), bool ambiguityDiscriminator=false, double z=0, double alpha=0, double theta=static_cast< double >(TMath::Pi()/2.))=0
Uncertainty corresponding to drift length from getDriftLength of this class.
virtual double getDriftTime(unsigned short tdcCount, const WireID &wireID, double timeOfFlightEstimator, double z, unsigned short adcCount)=0
Get Drift time.
int getArrayIndex() const
Get 0-based index of the particle in the corresponding MCParticle list.
const CDCWire & getWire(const WireID &wireId) const
Getter for wire getter by wireID object.
static CDCWireTopology & getInstance()
Getter for the singleton instance of the wire topology.
bool isValidWireID(const WireID &wireID) const
Checks the validity of a wireID convenience object.
const WireID & getWireID() const
Getter for the wire id.
const Vector2D & getRefPos2D() const
Getter for the wire reference position for 2D tracking Gives the wire's reference position projected ...
double getRefZ() const
Getter for the wire reference z coordinate Gives the wire's reference z coordinate.
static const FlightTimeEstimator & instance(std::unique_ptr< FlightTimeEstimator > replacement=nullptr)
Getter for the instance.
virtual double getFlightTime2D(const Vector2D &, double, double=1) const
Default estimator for the flight time.
bool isBetween(const Vector2D &lower, const Vector2D &upper) const
Checks if this vector is between two other vectors Between means here that when rotating the lower ve...
double y() const
Getter for the y coordinate.
EPreferredDirection m_flightTimeEstimation
Method for the initial time of flight estimation.
std::array< bool, ISuperLayerUtil::c_N > m_useSuperLayers
Bits for the used super layers.
std::vector< int > m_param_useMCParticleIds
Parameter : Indices of the Monte Carlo particles for which hits should be used.
std::unique_ptr< CDC::TDCCountTranslatorBase > m_tdcCountTranslator
TDC Count translator to be used to calculate the initial dirft length estiamtes.
DBObjPtr< CDClayerTimeCut > m_DBCDClayerTimeCut
Cut for approximate drift time (super-layer dependent)
std::array< bool, c_maxNSenseLayers > m_useLayers
Bits for the used layers.
std::unique_ptr< CDC::ADCCountTranslatorBase > m_adcCountTranslator
ADC Count translator to be used to calculate the charge deposit in the drift cell.
std::array< Vector2D, 2 > m_useSector
Unit vectors denoting the sector for which hits should be created.
std::array< float, ISuperLayerUtil::c_N > m_maxDriftTimes
Cut for approximate drift time (super-layer dependent)
bool m_param_useBadWires
Parameter : If true, the hits on bad wires are not ignored.
bool m_param_useSecondHits
Parameter : If true, the second hit information will be used to create Wire Hits.