8#include <tracking/trackFindingCDC/findlets/minimal/WireHitCreator.h>
10#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
11#include <tracking/trackFindingCDC/eventdata/utils/FlightTimeEstimator.h>
13#include <tracking/trackFindingCDC/findlets/minimal/EPreferredDirection.h>
15#include <tracking/trackFindingCDC/topology/CDCWireTopology.h>
17#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
19#include <cdc/translators/RealisticTDCCountTranslator.h>
20#include <cdc/translators/LinearGlobalADCCountTranslator.h>
21#include <cdc/geometry/CDCGeometryPar.h>
23#include <cdc/dataobjects/CDCHit.h>
25#include <framework/datastore/StoreArray.h>
26#include <framework/core/ModuleParamList.templateDetails.h>
28#include <mdst/dataobjects/MCParticle.h>
31using namespace TrackFindingCDC;
38 return "Combines the geometrical information and the raw hit information into wire hits, "
39 "which can be used from all modules after that";
44 moduleParamList->
addParameter(prefixed(prefix,
"wirePosition"),
46 "Set of geometry parameters to be used in the track finding. "
47 "Either 'base', 'misaligned' or 'aligned'.",
50 moduleParamList->
addParameter(prefixed(prefix,
"ignoreWireSag"),
52 "Assume a wire sag coefficient of zero "
53 "such that the wires appear to be straight for "
57 moduleParamList->
addParameter(prefixed(prefix,
"flightTimeEstimation"),
59 "Option which flight direction should be assumed for "
60 "an initial time of flight estimation. Options are: "
61 "'none' (no TOF correction), "
66 moduleParamList->
addParameter(prefixed(prefix,
"triggerPoint"),
68 "Point relative to which the flight times are calculated",
71 moduleParamList->
addParameter(prefixed(prefix,
"useSuperLayers"),
73 "List of super layers to be used.",
76 moduleParamList->
addParameter(prefixed(prefix,
"maxDriftTimes"),
78 "Maximum drift time (nsec) allowed per super layer (in order of super layer#0-8). Default payload-based cut is applied if this value is negative",
81 moduleParamList->
addParameter(prefixed(prefix,
"useLayers"),
83 "List of layers to be used. "
84 "If a layer number is given in 'ignoreLayers', too, this will result on a B2FATAL. "
85 "Either use 'useLayers' and provide a set of layers to be used, "
86 "or use 'ignoreLayers' and provide a list of layers to be ignored, but not both at the same time.",
89 moduleParamList->
addParameter(prefixed(prefix,
"ignoreLayers"),
91 "List of layers to be ignored. "
92 "If a layer number is given in 'useLayers', too, this will result on a B2FATAL. "
93 "Either use 'useLayers' and provide a set of layers to be used, "
94 "or use 'ignoreLayers' and provide a list of layers to be ignored, but not both at the same time.",
97 moduleParamList->
addParameter(prefixed(prefix,
"useSecondHits"),
99 "Use the second hit information in the track finding.",
102 moduleParamList->
addParameter(prefixed(prefix,
"useBadWires"),
104 "Also create the hits that are on bad wires.",
107 moduleParamList->
addParameter(prefixed(prefix,
"useDegreeSector"),
109 "To angles in degrees for which hits should be created - mostly for debugging",
112 moduleParamList->
addParameter(prefixed(prefix,
"useMCParticleIds"),
114 "Ids of the MC particles to use. Default does not look at the MCParticles - most for debugging",
142 }
catch (std::invalid_argument& e) {
160 for (
int iSL = 0; iSL < nSL; ++iSL) {
175 if (useLayer == ingoreLayer) {
176 B2FATAL(
"You chose to use and ignore CDC layer " << useLayer <<
" at the same time. "
177 "Please decide to either use or to ignore the layer.");
215 if (not outputWireHits.empty())
return;
224 std::size_t nHits = hits.getEntries();
226 B2WARNING(
"Event with no hits");
227 outputWireHits.clear();
230 std::map<int, size_t> nHitsByMCParticleId;
232 outputWireHits.reserve(nHits);
236 B2FATAL(
"CDClayerTimeCut DB object is invalid");
239 for (
const CDCHit& hit : hits) {
256 nHitsByMCParticleId[mcParticleId]++;
261 if (not useMCParticleId)
continue;
264 WireID wireID(hit.getID());
266 B2WARNING(
"Skip invalid wire id " << hit.getID());
277 const double approxDriftTime = tdcCountTranslator.
getDriftTime(hit.getTDCCount(), wireID, 0, 0, hit.getADCCount());
303 nHitsByMCParticleId[mcParticleId]++;
308 if (not useMCParticleId)
continue;
315 const double alpha = isIncoming ? M_PI : 0;
316 const double beta = 1;
317 const double flightTimeEstimate =
320 const double driftTime = tdcCountTranslator.
getDriftTime(hit.getTDCCount(),
325 const bool left =
false;
326 const bool right =
true;
327 const double theta = M_PI / 2;
329 const double leftRefDriftLength =
338 const double rightRefDriftLength =
347 const double refDriftLength =
348 (leftRefDriftLength + rightRefDriftLength) / 2.0;
350 const double leftRefDriftLengthVariance =
358 const double rightRefDriftLengthVariance =
366 const double refDriftLengthVariance =
367 (leftRefDriftLengthVariance + rightRefDriftLengthVariance) / 2.0;
369 const double leftRefChargeDeposit =
370 adcCountTranslator.
getCharge(hit.getADCCount(),
376 const double rightRefChargeDeposit =
377 adcCountTranslator.
getCharge(hit.getADCCount(),
383 const double refChargeDeposit =
384 (leftRefChargeDeposit + rightRefChargeDeposit) / 2.0;
386 outputWireHits.emplace_back(&hit, refDriftLength, refDriftLengthVariance, refChargeDeposit, driftTime);
389 std::sort(outputWireHits.begin(), outputWireHits.end());
392 for (
const std::pair<int, size_t> nHitsForMCParticleId : nHitsByMCParticleId) {
394 "MC particle " << nHitsForMCParticleId.first <<
" #hits "
395 << nHitsForMCParticleId.second);
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Abstract Base class for the ADC count translator.
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.
The Class for CDC Geometry Parameters.
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.
This class simply assumes a linear translation through (0,0)
Translator mirroring the realistic Digitization.
Base class for translation of Drift Time into Drift Length.
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.
A Class to store the Monte Carlo particle information.
int getArrayIndex() const
Get 0-based index of the particle in the corresponding MCParticle list.
The Module parameter list class.
Accessor to arrays stored in the data store.
Class representing the sense wire arrangement in the whole of the central drift chamber.
const CDCWire & getWire(const WireID &wireId) const
Getter for wire getter by wireID object.
void reinitialize(EWirePosition wirePosition, bool ignoreWireSag)
Reload all geometry parameters form the CDCGeometryPar to adjust to changes in geometry.
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.
Class representing a sense wire in the central drift chamber.
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.
void initialize() override
Receive and dispatch signal before the start of the event processing.
void beginRun() override
Receive and dispatch signal for the beginning of a new run.
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.
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
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.
static Vector2D Phi(const double phi)
Constructs a unit vector with azimuth angle equal to phi.
A three dimensional vector.
std::string m_param_wirePosition
Parameter : Geometry set to be used. Either "base", "misalign" or " aligned".
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.
void initialize() final
Signals the beginning of the event processing.
void beginRun() final
Signal the beginning of a new run.
EWirePosition m_wirePosition
Geometry set to be used.
std::vector< int > m_param_useMCParticleIds
Parameter : Indices of the Monte Carlo particles for which hits should be used.
std::tuple< double, double, double > m_param_triggerPoint
Parameter : Location of the flight time zero.
std::unique_ptr< CDC::TDCCountTranslatorBase > m_tdcCountTranslator
TDC Count translator to be used to calculate the initial dirft length estiamtes.
std::string getDescription() final
Short description of the findlet.
std::string m_param_flightTimeEstimation
Parameter : Method for the initial time of flight estimation as string.
~WireHitCreator()
Default destructor.
std::vector< uint > m_param_useLayers
Parameter : List of layers to be used.
DBObjPtr< CDClayerTimeCut > m_DBCDClayerTimeCut
Cut for approximate drift time (super-layer dependent)
std::vector< uint > m_param_ignoreLayers
Parameter : List of layers to be ignored in tracking e.g. for simulating too high occupancy.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
std::tuple< double, double > m_param_useDegreeSector
Parameter : Angular range in degrees for which hits should be unpacked.
std::array< bool, c_maxNSenseLayers > m_useLayers
Bits for the used layers.
WireHitCreator()
Default constructor.
std::unique_ptr< CDC::ADCCountTranslatorBase > m_adcCountTranslator
ADC Count translator to be used to calculate the charge deposit in the drift cell.
std::vector< int > m_param_useSuperLayers
Parameter : List of super layers to be used - mostly for debugging.
bool m_param_ignoreWireSag
Parameter : Switch to deactivate the sag of the wires for the concerns of the track finders.
void apply(std::vector< CDCWireHit > &outputWireHits) final
Main algorithm creating the wire hits.
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.
std::vector< float > m_param_maxDriftTimes
Parameter : Cut for approximate drift time (super-layer dependent)
bool m_param_useSecondHits
Parameter : If true, the second hit information will be used to create Wire Hits.
Vector3D m_triggerPoint
Central location of the flight time zero position. Usually the location of the trigger.
static const double deg
degree to radians
Class to identify a wire inside the CDC.
unsigned short getICLayer() const
Getter for continuous layer numbering.
unsigned short getISuperLayer() const
Getter for Super-Layer.
void addParameter(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.