Main algorithm creating the wire hits.
215{
216
217 if (not outputWireHits.empty()) return;
218
223
224
225 StoreArray<CDCHit> hits;
227 if (nHits == 0) {
228 B2WARNING("Event with no hits");
229 outputWireHits.clear();
230 }
231
232 std::map<int, size_t> nHitsByMCParticleId;
233
234 outputWireHits.reserve(nHits);
235
236
238 B2FATAL("CDClayerTimeCut DB object is invalid");
239 }
240
241 for (const CDCHit& hit : hits) {
242
245 continue;
246 }
247
248
250 continue;
251 }
252
253
255 MCParticle* mcParticle = hit.
getRelated<MCParticle>();
257 if (mcParticle) {
258 nHitsByMCParticleId[mcParticleId]++;
259 }
262 mcParticleId);
263 if (not useMCParticleId) continue;
264 }
265
266 WireID wireID(hit.getID());
268 B2WARNING("Skip invalid wire id " << hit.getID());
269 continue;
270 }
271
272
274 continue;
275 }
276
277
278
279 const double approxDriftTime = tdcCountTranslator.
getDriftTime(hit.getTDCCount(), wireID, 0, 0, hit.getADCCount());
281
282
285 } else {
287 }
288
290 unsigned short layer = wireID.getICLayer();
292
293 const CDCWire& wire = wireTopology.
getWire(wireID);
294
296
297
299
300
302 MCParticle* mcParticle = hit.
getRelated<MCParticle>();
304 if (mcParticle) {
305 nHitsByMCParticleId[mcParticleId]++;
306 }
309 mcParticleId);
310 if (not useMCParticleId) continue;
311 }
312
313
314
315
317 const double alpha = isIncoming ? M_PI : 0;
318 const double beta = 1;
319 const double flightTimeEstimate =
321
322 const double driftTime = tdcCountTranslator.
getDriftTime(hit.getTDCCount(),
324 flightTimeEstimate,
326 hit.getADCCount());
327 const bool left = false;
328 const bool right = true;
329 const double theta = M_PI / 2;
330
331 const double leftRefDriftLength =
334 flightTimeEstimate,
335 left,
337 alpha,
338 theta);
339
340 const double rightRefDriftLength =
343 flightTimeEstimate,
344 right,
346 alpha,
347 theta);
348
349 const double refDriftLength =
350 (leftRefDriftLength + rightRefDriftLength) / 2.0;
351
352 const double leftRefDriftLengthVariance =
355 left,
357 alpha,
358 theta);
359
360 const double rightRefDriftLengthVariance =
363 right,
365 alpha,
366 theta);
367
368 const double refDriftLengthVariance =
369 (leftRefDriftLengthVariance + rightRefDriftLengthVariance) / 2.0;
370
371 const double leftRefChargeDeposit =
372 adcCountTranslator.
getCharge(hit.getADCCount(),
374 left,
376 theta);
377
378 const double rightRefChargeDeposit =
379 adcCountTranslator.
getCharge(hit.getADCCount(),
381 right,
383 theta);
384
385 const double refChargeDeposit =
386 (leftRefChargeDeposit + rightRefChargeDeposit) / 2.0;
387
388 outputWireHits.emplace_back(&hit, refDriftLength, refDriftLengthVariance, refChargeDeposit, driftTime);
389 }
390
391 std::sort(outputWireHits.begin(), outputWireHits.end());
392
394 for (const std::pair<int, size_t> nHitsForMCParticleId : nHitsByMCParticleId) {
395 B2DEBUG(25,
396 "MC particle " << nHitsForMCParticleId.first << " #hits "
397 << nHitsForMCParticleId.second);
398 }
399 }
400}
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.
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 ROOT::Math::XYVector & getRefPos2D() const
Getter for the wire reference position for 2D tracking Gives the wire's reference position projected ...
const WireID & getWireID() const
Getter for the wire id.
double getRefZ() const
Getter for the wire reference z coordinate Gives the wire's reference z coordinate.
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.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
int getEntries() const
Get the number of objects in the array.
virtual double getFlightTime2D(const TrackingUtilities::Vector2D &, double, double=1) const
Default estimator for the flight time.
static const FlightTimeEstimator & instance(std::unique_ptr< FlightTimeEstimator > replacement=nullptr)
Getter for the instance.
EPreferredDirection m_flightTimeEstimation
Method for the initial time of flight estimation.
std::vector< int > m_param_useMCParticleIds
Parameter : Indices of the Monte Carlo particles for which hits should be used.
std::array< float, CDC::ISuperLayerUtil::c_N > m_maxDriftTimes
Cut for approximate drift time (super-layer dependent)
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< TrackingUtilities::Vector2D, 2 > m_useSector
Unit vectors denoting the sector for which hits should be created.
bool m_param_useBadWires
Parameter : If true, the hits on bad wires are not ignored.
std::array< bool, CDC::ISuperLayerUtil::c_N > m_useSuperLayers
Bits for the used super layers.
bool m_param_useSecondHits
Parameter : If true, the second hit information will be used to create Wire Hits.
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.
signed short ISuperLayer
The type of the layer and superlayer ids.