8#include <tracking/trackFindingCDC/findlets/minimal/WireHitCreator.h>
10#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
11#include <tracking/trackingUtilities/geometry/VectorUtil.h>
12#include <tracking/trackFindingCDC/eventdata/utils/FlightTimeEstimator.h>
14#include <tracking/trackFindingCDC/findlets/minimal/EPreferredDirection.h>
16#include <cdc/topology/CDCWireTopology.h>
18#include <tracking/trackingUtilities/utilities/StringManipulation.h>
20#include <cdc/translators/RealisticTDCCountTranslator.h>
21#include <cdc/translators/LinearGlobalADCCountTranslator.h>
22#include <cdc/geometry/CDCGeometryPar.h>
24#include <cdc/dataobjects/CDCHit.h>
26#include <framework/datastore/StoreArray.h>
27#include <framework/core/ModuleParamList.templateDetails.h>
29#include <mdst/dataobjects/MCParticle.h>
31#include <Math/Vector3D.h>
32#include <Math/Vector2D.h>
36using namespace TrackFindingCDC;
37using namespace TrackingUtilities;
44 return "Combines the geometrical information and the raw hit information into wire hits, "
45 "which can be used from all modules after that";
50 moduleParamList->
addParameter(prefixed(prefix,
"wirePosition"),
52 "Set of geometry parameters to be used in the track finding. "
53 "Either 'base', 'misaligned' or 'aligned'.",
56 moduleParamList->
addParameter(prefixed(prefix,
"ignoreWireSag"),
58 "Assume a wire sag coefficient of zero "
59 "such that the wires appear to be straight for "
63 moduleParamList->
addParameter(prefixed(prefix,
"flightTimeEstimation"),
65 "Option which flight direction should be assumed for "
66 "an initial time of flight estimation. Options are: "
67 "'none' (no TOF correction), "
72 moduleParamList->
addParameter(prefixed(prefix,
"triggerPoint"),
74 "Point relative to which the flight times are calculated",
77 moduleParamList->
addParameter(prefixed(prefix,
"useSuperLayers"),
79 "List of super layers to be used.",
82 moduleParamList->
addParameter(prefixed(prefix,
"maxDriftTimes"),
84 "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",
87 moduleParamList->
addParameter(prefixed(prefix,
"useLayers"),
89 "List of layers to be used. "
90 "If a layer number is given in 'ignoreLayers', too, this will result on a B2FATAL. "
91 "Either use 'useLayers' and provide a set of layers to be used, "
92 "or use 'ignoreLayers' and provide a list of layers to be ignored, but not both at the same time.",
95 moduleParamList->
addParameter(prefixed(prefix,
"ignoreLayers"),
97 "List of layers to be ignored. "
98 "If a layer number is given in 'useLayers', too, this will result on a B2FATAL. "
99 "Either use 'useLayers' and provide a set of layers to be used, "
100 "or use 'ignoreLayers' and provide a list of layers to be ignored, but not both at the same time.",
103 moduleParamList->
addParameter(prefixed(prefix,
"useSecondHits"),
105 "Use the second hit information in the track finding.",
108 moduleParamList->
addParameter(prefixed(prefix,
"useBadWires"),
110 "Also create the hits that are on bad wires.",
113 moduleParamList->
addParameter(prefixed(prefix,
"useDegreeSector"),
115 "To angles in degrees for which hits should be created - mostly for debugging",
118 moduleParamList->
addParameter(prefixed(prefix,
"useMCParticleIds"),
120 "Ids of the MC particles to use. Default does not look at the MCParticles - most for debugging",
148 }
catch (std::invalid_argument& e) {
166 for (
int iSL = 0; iSL < nSL; ++iSL) {
181 if (useLayer == ingoreLayer) {
182 B2FATAL(
"You chose to use and ignore CDC layer " << useLayer <<
" at the same time. "
183 "Please decide to either use or to ignore the layer.");
221 if (not outputWireHits.empty())
return;
232 B2WARNING(
"Event with no hits");
233 outputWireHits.clear();
236 std::map<int, size_t> nHitsByMCParticleId;
238 outputWireHits.reserve(nHits);
242 B2FATAL(
"CDClayerTimeCut DB object is invalid");
245 for (
const CDCHit& hit : hits) {
262 nHitsByMCParticleId[mcParticleId]++;
267 if (not useMCParticleId)
continue;
270 WireID wireID(hit.getID());
272 B2WARNING(
"Skip invalid wire id " << hit.getID());
283 const double approxDriftTime = tdcCountTranslator.
getDriftTime(hit.getTDCCount(), wireID, 0, 0, hit.getADCCount());
299 const ROOT::Math::XYVector& pos2D = wire.
getRefPos2D();
309 nHitsByMCParticleId[mcParticleId]++;
314 if (not useMCParticleId)
continue;
321 const double alpha = isIncoming ? M_PI : 0;
322 const double beta = 1;
323 const double flightTimeEstimate =
326 const double driftTime = tdcCountTranslator.
getDriftTime(hit.getTDCCount(),
331 const bool left =
false;
332 const bool right =
true;
333 const double theta = M_PI / 2;
335 const double leftRefDriftLength =
344 const double rightRefDriftLength =
353 const double refDriftLength =
354 (leftRefDriftLength + rightRefDriftLength) / 2.0;
356 const double leftRefDriftLengthVariance =
364 const double rightRefDriftLengthVariance =
372 const double refDriftLengthVariance =
373 (leftRefDriftLengthVariance + rightRefDriftLengthVariance) / 2.0;
375 const double leftRefChargeDeposit =
376 adcCountTranslator.
getCharge(hit.getADCCount(),
382 const double rightRefChargeDeposit =
383 adcCountTranslator.
getCharge(hit.getADCCount(),
389 const double refChargeDeposit =
390 (leftRefChargeDeposit + rightRefChargeDeposit) / 2.0;
392 outputWireHits.emplace_back(&hit, refDriftLength, refDriftLengthVariance, refChargeDeposit, driftTime);
395 std::sort(outputWireHits.begin(), outputWireHits.end());
398 for (
const std::pair<int, size_t> nHitsForMCParticleId : nHitsByMCParticleId) {
400 "MC particle " << nHitsForMCParticleId.first <<
" #hits "
401 << 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.
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 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.
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.
T * getRelated(const std::string &name="", const std::string &namedRelation="") const
Get the object to or from which this object has a relation.
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
Accessor to arrays stored in the data store.
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.
void apply(std::vector< TrackingUtilities::CDCWireHit > &outputWireHits) final
Main algorithm creating the wire hits.
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.
void initialize() final
Signals the beginning of the event processing.
void beginRun() final
Signal the beginning of a new run.
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::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.
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.
ROOT::Math::XYZVector m_triggerPoint
Central location of the flight time zero position. Usually the location of the trigger.
bool m_param_ignoreWireSag
Parameter : Switch to deactivate the sag of the wires for the concerns of the track finders.
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.
CDC::EWirePosition m_wirePosition
Geometry set to be used.
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.
void initialize() override
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.
signed short ISuperLayer
The type of the layer and superlayer ids.
Abstract base class for different kinds of events.