Main algorithm creating the wire hits.
219{
220
221 if (not outputWireHits.empty()) return;
222
227
228
229 StoreArray<CDCHit> hits;
231 if (nHits == 0) {
232 B2WARNING("Event with no hits");
233 outputWireHits.clear();
234 }
235
236 std::map<int, size_t> nHitsByMCParticleId;
237
238 outputWireHits.reserve(nHits);
239
240
242 B2FATAL("CDClayerTimeCut DB object is invalid");
243 }
244
245 for (const CDCHit& hit : hits) {
246
249 continue;
250 }
251
252
254 continue;
255 }
256
257
259 const MCParticle* mcParticle = hit.getRelated<MCParticle>();
260
261 int mcParticleId = mcParticle ? mcParticle->
getArrayIndex() : -1;
262 if (mcParticle) {
263 nHitsByMCParticleId[mcParticleId]++;
264 }
267 mcParticleId);
268 if (not useMCParticleId) continue;
269 }
270
271 WireID wireID(hit.getID());
273 B2WARNING("Skip invalid wire id " << hit.getID());
274 continue;
275 }
276
277
279 continue;
280 }
281
282
283
284 const double approxDriftTime = tdcCountTranslator.
getDriftTime(hit.getTDCCount(), wireID, 0, 0, hit.getADCCount());
286
287
290 } else {
292 }
293
295 unsigned short layer = wireID.getICLayer();
297
298 const CDCWire& wire = wireTopology.
getWire(wireID);
299
300 const ROOT::Math::XYVector& pos2D = wire.
getRefPos2D();
301
302
304
305
307 const MCParticle* mcParticle = hit.
getRelated<MCParticle>();
308
309 int mcParticleId = mcParticle ? mcParticle->
getArrayIndex() : -1;
310 if (mcParticle) {
311 nHitsByMCParticleId[mcParticleId]++;
312 }
315 mcParticleId);
316 if (not useMCParticleId) continue;
317 }
318
319
320
321
323 const double alpha = isIncoming ? M_PI : 0;
324 const double beta = 1;
325 const double flightTimeEstimate =
327
328 const double driftTime = tdcCountTranslator.
getDriftTime(hit.getTDCCount(),
330 flightTimeEstimate,
332 hit.getADCCount());
333 const bool left = false;
334 const bool right = true;
335 const double theta = M_PI / 2;
336
337 const double leftRefDriftLength =
340 flightTimeEstimate,
341 left,
343 alpha,
344 theta);
345
346 const double rightRefDriftLength =
349 flightTimeEstimate,
350 right,
352 alpha,
353 theta);
354
355 const double refDriftLength =
356 (leftRefDriftLength + rightRefDriftLength) / 2.0;
357
358 const double leftRefDriftLengthVariance =
361 left,
363 alpha,
364 theta);
365
366 const double rightRefDriftLengthVariance =
369 right,
371 alpha,
372 theta);
373
374 const double refDriftLengthVariance =
375 (leftRefDriftLengthVariance + rightRefDriftLengthVariance) / 2.0;
376
377 const double leftRefChargeDeposit =
378 adcCountTranslator.
getCharge(hit.getADCCount(),
380 left,
382 theta);
383
384 const double rightRefChargeDeposit =
385 adcCountTranslator.
getCharge(hit.getADCCount(),
387 right,
389 theta);
390
391 const double refChargeDeposit =
392 (leftRefChargeDeposit + rightRefChargeDeposit) / 2.0;
393
394 outputWireHits.emplace_back(&hit, refDriftLength, refDriftLengthVariance, refChargeDeposit, driftTime);
395 }
396
397 std::sort(outputWireHits.begin(), outputWireHits.end());
398
400 for (const std::pair<int, size_t> nHitsForMCParticleId : nHitsByMCParticleId) {
401 B2DEBUG(25,
402 "MC particle " << nHitsForMCParticleId.first << " #hits "
403 << nHitsForMCParticleId.second);
404 }
405 }
406}
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.
static const FlightTimeEstimator & instance(std::unique_ptr< FlightTimeEstimator > replacement=nullptr)
Getter for the instance.
virtual double getFlightTime2D(const ROOT::Math::XYVector &, double, double=1) const
Default estimator for the flight time.
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< ROOT::Math::XYVector, 2 > m_useSector
Unit vectors denoting the sector for which hits should be created.
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.
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.
signed short ISuperLayer
The type of the layer and superlayer ids.