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>
31 using 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,
"useLayers"),
78 "List of layers to be used. "
79 "If a layer number is given in 'ignoreLayers', too, this will result on a B2FATAL. "
80 "Either use 'useLayers' and provide a set of layers to be used, "
81 "or use 'ignoreLayers' and provide a list of layers to be ignored, but not both at the same time.",
84 moduleParamList->
addParameter(prefixed(prefix,
"ignoreLayers"),
86 "List of layers to be ignored. "
87 "If a layer number is given in 'useLayers', too, this will result on a B2FATAL. "
88 "Either use 'useLayers' and provide a set of layers to be used, "
89 "or use 'ignoreLayers' and provide a list of layers to be ignored, but not both at the same time.",
92 moduleParamList->
addParameter(prefixed(prefix,
"useSecondHits"),
94 "Use the second hit information in the track finding.",
97 moduleParamList->
addParameter(prefixed(prefix,
"useBadWires"),
99 "Also create the hits that are on bad wires.",
102 moduleParamList->
addParameter(prefixed(prefix,
"useDegreeSector"),
104 "To angles in degrees for which hits should be created - mostly for debugging",
107 moduleParamList->
addParameter(prefixed(prefix,
"useMCParticleIds"),
109 "Ids of the MC particles to use. Default does not look at the MCParticles - most for debugging",
137 }
catch (std::invalid_argument& e) {
165 if (useLayer == ingoreLayer) {
166 B2FATAL(
"You chose to use and ignore CDC layer " << useLayer <<
" at the same time. "
167 "Please decide to either use or to ignore the layer.");
205 if (not outputWireHits.empty())
return;
214 std::size_t nHits = hits.getEntries();
216 B2WARNING(
"Event with no hits");
217 outputWireHits.clear();
220 std::map<int, size_t> nHitsByMCParticleId;
222 outputWireHits.reserve(nHits);
223 for (
const CDCHit& hit : hits) {
235 nHitsByMCParticleId[mcParticleId]++;
240 if (not useMCParticleId)
continue;
243 WireID wireID(hit.getID());
245 B2WARNING(
"Skip invalid wire id " << hit.getID());
271 nHitsByMCParticleId[mcParticleId]++;
276 if (not useMCParticleId)
continue;
283 const double alpha = isIncoming ? M_PI : 0;
284 const double beta = 1;
285 const double flightTimeEstimate =
288 const double driftTime = tdcCountTranslator.
getDriftTime(hit.getTDCCount(),
293 const bool left =
false;
294 const bool right =
true;
295 const double theta = M_PI / 2;
297 const double leftRefDriftLength =
306 const double rightRefDriftLength =
315 const double refDriftLength =
316 (leftRefDriftLength + rightRefDriftLength) / 2.0;
318 const double leftRefDriftLengthVariance =
326 const double rightRefDriftLengthVariance =
334 const double refDriftLengthVariance =
335 (leftRefDriftLengthVariance + rightRefDriftLengthVariance) / 2.0;
337 const double leftRefChargeDeposit =
338 adcCountTranslator.
getCharge(hit.getADCCount(),
344 const double rightRefChargeDeposit =
345 adcCountTranslator.
getCharge(hit.getADCCount(),
351 const double refChargeDeposit =
352 (leftRefChargeDeposit + rightRefChargeDeposit) / 2.0;
354 outputWireHits.emplace_back(&hit, refDriftLength, refDriftLengthVariance, refChargeDeposit, driftTime);
357 std::sort(outputWireHits.begin(), outputWireHits.end());
360 for (
const std::pair<int, size_t> nHitsForMCParticleId : nHitsByMCParticleId) {
362 "MC particle " << nHitsForMCParticleId.first <<
" #hits "
363 << 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.
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.
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 representating the sense wire arrangement in the whole of the central drift chamber.
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 convinience object.
const CDCWire & getWire(const WireID &wireId) const
Getter for wire getter by wireID object.
Class representing a sense wire in the central drift chamber.
const Vector2D & 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.
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 handeling of orientation relat...
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)
Constucts a unit vector with azimuth angle equal to phi.
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::array< bool, 56 > m_useLayers
Bits for the used layers ATTENTION: hardcoded value for number of layers.
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.
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.
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.
bool m_param_useBadWires
Parameter : If true, the hits on bad wires are not ignored.
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.
HepGeom::Vector3D< double > Vector3D
3D Vector
Abstract base class for different kinds of events.