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 MCParticle* mcParticle = hit.
getRelated<MCParticle>();
261 if (mcParticle) {
262 nHitsByMCParticleId[mcParticleId]++;
263 }
266 mcParticleId);
267 if (not useMCParticleId) continue;
268 }
269
270 WireID wireID(hit.getID());
272 B2WARNING("Skip invalid wire id " << hit.getID());
273 continue;
274 }
275
276
278 continue;
279 }
280
281
282
283 const double approxDriftTime = tdcCountTranslator.
getDriftTime(hit.getTDCCount(), wireID, 0, 0, hit.getADCCount());
285
286
289 } else {
291 }
292
294 unsigned short layer = wireID.getICLayer();
296
297 const CDCWire& wire = wireTopology.
getWire(wireID);
298
299 const ROOT::Math::XYVector& pos2D = wire.
getRefPos2D();
300
301
303
304
306 MCParticle* mcParticle = hit.
getRelated<MCParticle>();
308 if (mcParticle) {
309 nHitsByMCParticleId[mcParticleId]++;
310 }
313 mcParticleId);
314 if (not useMCParticleId) continue;
315 }
316
317
318
319
321 const double alpha = isIncoming ? M_PI : 0;
322 const double beta = 1;
323 const double flightTimeEstimate =
325
326 const double driftTime = tdcCountTranslator.
getDriftTime(hit.getTDCCount(),
328 flightTimeEstimate,
330 hit.getADCCount());
331 const bool left = false;
332 const bool right = true;
333 const double theta = M_PI / 2;
334
335 const double leftRefDriftLength =
338 flightTimeEstimate,
339 left,
341 alpha,
342 theta);
343
344 const double rightRefDriftLength =
347 flightTimeEstimate,
348 right,
350 alpha,
351 theta);
352
353 const double refDriftLength =
354 (leftRefDriftLength + rightRefDriftLength) / 2.0;
355
356 const double leftRefDriftLengthVariance =
359 left,
361 alpha,
362 theta);
363
364 const double rightRefDriftLengthVariance =
367 right,
369 alpha,
370 theta);
371
372 const double refDriftLengthVariance =
373 (leftRefDriftLengthVariance + rightRefDriftLengthVariance) / 2.0;
374
375 const double leftRefChargeDeposit =
376 adcCountTranslator.
getCharge(hit.getADCCount(),
378 left,
380 theta);
381
382 const double rightRefChargeDeposit =
383 adcCountTranslator.
getCharge(hit.getADCCount(),
385 right,
387 theta);
388
389 const double refChargeDeposit =
390 (leftRefChargeDeposit + rightRefChargeDeposit) / 2.0;
391
392 outputWireHits.emplace_back(&hit, refDriftLength, refDriftLengthVariance, refChargeDeposit, driftTime);
393 }
394
395 std::sort(outputWireHits.begin(), outputWireHits.end());
396
398 for (const std::pair<int, size_t> nHitsForMCParticleId : nHitsByMCParticleId) {
399 B2DEBUG(25,
400 "MC particle " << nHitsForMCParticleId.first << " #hits "
401 << nHitsForMCParticleId.second);
402 }
403 }
404}
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.