 |
Belle II Software
release-05-02-19
|
13 #include <klm/modules/KLMReconstructor/KLMReconstructorModule.h>
16 #include <klm/bklm/geometry/Module.h>
17 #include <klm/dataobjects/eklm/EKLMElementNumbers.h>
20 #include <framework/gearbox/Const.h>
21 #include <framework/logging/Logger.h>
24 #include <CLHEP/Vector/ThreeVector.h>
27 using namespace Belle2::bklm;
67 m_CoincidenceWindow(0),
70 m_bklmGeoPar(nullptr),
73 m_eklmGeoDat(nullptr),
75 m_eklmTransformData(nullptr),
76 m_eklmTimeCalibrationData(nullptr)
78 setDescription(
"Create BKLMHit1ds from KLMDigits and then create BKLMHit2ds from BKLMHit1ds; create EKLMHit2ds from KLMDigits.");
81 "Perform alignment correction (true) or not (false).",
84 "Ignore scintillators (to debug their electronics mapping).",
87 "Check if segments intersect.",
true);
89 "Use only Normal and Dead (for debugging) channels during 2d hit reconstruction",
115 B2FATAL(
"It is not possible to run EKLM reconstruction with 1 plane.");
123 B2FATAL(
"KLM channel status data are not available.");
125 B2FATAL(
"KLM time window data are not available.");
133 B2FATAL(
"EKLM digitization parameters are not available.");
135 B2FATAL(
"EKLM time calibration data is not available.");
141 B2FATAL(
"EKLM time calibration data is missing for strip "
163 uint16_t channel = m_ElementNumbers->
channelNumber(subdetector, section, sector, layer, plane, strip);
166 B2FATAL(
"Incomplete KLM channel status data.");
176 std::map<uint16_t, int> channelDigitMap;
177 for (
int index = 0; index <
m_Digits.getEntries(); ++index) {
192 channelDigitMap.insert(std::pair<uint16_t, int>(channel, index));
195 if (channelDigitMap.empty())
197 std::vector<const KLMDigit*> digitCluster;
198 uint16_t previousChannel = channelDigitMap.begin()->first;
199 double averageTime =
m_Digits[channelDigitMap.begin()->second]->getTime();
200 for (std::map<uint16_t, int>::iterator it = channelDigitMap.begin(); it != channelDigitMap.end(); ++it) {
202 double digitTime = digit->
getTime();
203 if ((it->first > previousChannel + 1) || (std::fabs(digitTime - averageTime) >
m_CoincidenceWindow)) {
205 digitCluster.clear();
207 previousChannel = it->first;
208 double n = (double)(digitCluster.size());
209 averageTime = (n * averageTime + digitTime) / (n + 1.0);
210 digitCluster.push_back(digit);
220 for (
int j = i + 1; j <
m_bklmHit1ds.getEntries(); ++j) {
226 int phiIndex = isPhiReadout ? i : j;
227 int zIndex = isPhiReadout ? j : i;
231 CLHEP::Hep3Vector propagationTimes;
234 propagationTimes = m->getPropagationTimes(
238 propagationTimes = m->getPropagationTimes(
243 propagationTimes = m->getPropagationTimes(local);
245 double phiTime = phiHit->
getTime() - propagationTimes.y();
246 double zTime = zHit->
getTime() - propagationTimes.z();
250 CLHEP::Hep3Vector global = m->localToGlobal(local + m->getLocalReconstructionShift(),
m_bklmIfAlign);
263 d->getSection(), d->getLayer(), d->getSector(),
264 d->getPlane(), d->getStrip()) - 1;
265 return d->getTime() -
278 double d1, d2, t, t1, t2, sd;
279 std::vector<KLMDigit*> digitVector;
280 std::vector<KLMDigit*>::iterator it1, it2, it3, it4, it5, it6, it7, it8, it9;
282 for (i = 0; i < n; i++) {
291 digitVector.push_back(digit);
294 sort(digitVector.begin(), digitVector.end(), compareSector);
295 it1 = digitVector.begin();
296 while (it1 != digitVector.end()) {
300 if (it2 == digitVector.end())
302 if (!sameSector(*it1, *it2))
306 sort(it1, it2, comparePlane);
308 if ((*it1)->getPlane() != 1) {
317 if ((*it3)->getPlane() != (*it1)->getPlane())
329 sort(it1, it3, compareStrip);
330 sort(it3, it2, compareStrip);
339 if ((*it5)->getStrip() != (*it4)->getStrip() ||
340 (*it5)->getPlane() != (*it4)->getPlane())
344 sort(it4, it5, compareTime);
355 if ((*it5)->getStrip() != (*it4)->getStrip())
365 if ((*it7)->getStrip() != (*it6)->getStrip())
380 for (it8 = it4; it8 != it5; ++it8) {
381 for (it9 = it6; it9 != it7; ++it9) {
388 hit2d->
setEnergyDeposit((*it8)->getEnergyDeposit() + (*it9)->getEnergyDeposit());
389 hit2d->
setPosition(crossPoint.x(), crossPoint.y(), crossPoint.z());
390 hit2d->
setChiSq((t1 - t2) * (t1 - t2) /
394 hit2d->
setMCTime(((*it8)->getMCTime() + (*it9)->getMCTime()) / 2);
397 for (i = 0; i < 2; i++) {
int getSubdetector() const
Get subdetector number.
int getPlane() const
Get plane number.
Store one reconstructed BKLM 1D hit as a ROOT object.
bool inRPC() const
Determine whether the hit is in RPC or scintillator.
StoreArray< KLMDigit > m_Digits
KLM digits.
void reconstructEKLMHits()
Reconstruct EKLMHit2d.
void setEnergyDeposit(float eDep)
Set EnergyDeposit.
virtual void endRun() override
Called if the current run ends.
float getTime() const
Get reconstructed hit time.
double m_CoincidenceWindow
Half-width of the time coincidence window used to create a 2D hit from 1D digits/hits.
void setDescription(const std::string &description)
Sets the description of the module.
DBObjPtr< KLMTimeWindow > m_TimeWindow
KLM time window.
void setTime(float time)
Set hit time.
DBObjPtr< KLMChannelStatus > m_ChannelStatus
Channel status.
int getNPlanes() const
Get number of planes.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
ChannelStatus
Channel status.
const EKLMElementNumbers * m_eklmElementNumbers
Element numbers.
double m_PromptWindow
Half-width of the time window relative to the prompt time for BKLMHit2ds.
void addRelationTo(const RelationsInterface< BASE > *object, float weight=1.0, const std::string &namedRelation="") const
Add a relation from this object to another object (with caching).
double getTime(KLMDigit *d, double dist)
Get 2d hit time corresponding to EKLM digit.
int getSection() const
Get section number.
uint16_t channelNumber(int subdetector, int section, int sector, int layer, int plane, int strip) const
Get channel number.
int getSector() const
Get sector number.
virtual void beginRun() override
Called when entering a new run.
float getTime() const
Get hit time.
int getLayer() const
Get layer number.
float getTimeShift() const
Get time shift.
DBObjPtr< EKLMTimeCalibration > m_eklmTimeCalibration
Time calibration data.
This dataobject is used only for EKLM alignment.
Define the geometry of a BKLM module Each sector [octant] contains Modules.
KLM digit (class representing a digitized hit in RPCs or scintillators).
int sectorNumber(int section, int layer, int sector) const
Get sector number.
bklm::GeometryPar * m_bklmGeoPar
BKLM GeometryPar singleton.
@ c_Dead
Dead channel (no signal).
static constexpr int getMaximalStripGlobalNumber()
Get maximal strip global number.
bool m_bklmIfAlign
Perform alignment correction (true) or not (false).
virtual void event() override
Called for each event.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
static const double speedOfLight
[cm/ns]
bool m_eklmCheckSegmentIntersection
Check if segments intersect.
StoreArray< BKLMHit2d > m_bklmHit2ds
BKLM 2d hits.
static GeometryPar * instance(void)
Static method to get a reference to the singleton GeometryPar instance.
Abstract base class for different kinds of events.
bool isMultiStrip() const
Determine whether this digit is a multi-strip one or not.
StoreArray< EKLMAlignmentHit > m_eklmAlignmentHits
Alignment Hits.
bool m_IgnoreHotChannels
Use only Normal and Dead (for debugging) channels during 2d hit reconstruction.
void setChiSq(float chisq)
Set Chi^2 of the crossing point.
bool isGood() const
Whether hit could be used late (if it passed discriminator threshold)
static const EKLMElementNumbers & Instance()
Instantiation.
DBObjPtr< EKLMReconstructionParameters > m_eklmRecPar
Reconstruction parameters.
bool isNormal(const KLMDigit *digit) const
Check if channel is normal or dead.
int stripNumber(int section, int layer, int sector, int plane, int strip) const
Get strip number.
virtual void initialize() override
Initializer.
bool isOutOfTime()
Determine whether this 2D hit is outside the trigger-coincidence window.
bool m_bklmIgnoreScintillators
Ignore scintillators (to debug their electronics mapping).
virtual void terminate() override
Called at the end of the event processing.
void setMCTime(float t)
Set MC time.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
int m_eklmNStrip
Number of strips.
static bool hitsFromSameModule(int module1, int module2)
Check whether the hits are from the same module.
StoreArray< BKLMHit1d > m_bklmHit1ds
BKLM 1d hits.
@ c_Unknown
Unknown status (no data).
EKLM time calibration data (for one strip).
double getStripAve() const
Get average strip number.
EKLM::TransformData * m_eklmTransformData
Transformation data.
void setPosition(float x, float y, float z)
Set hit global position.
int getStrip() const
Get strip number.
virtual ~KLMReconstructorModule()
Destructor.
@ c_FirstRPCLayer
First RPC layer.
const EKLMTimeCalibrationData ** m_eklmTimeCalibrationData
Time calibration data for individual strips.
@ c_Normal
Normally operating channel.
const Module * findModule(int section, int sector, int layer) const
Get the pointer to the definition of a module.
static uint16_t channelNumber(int section, int sector, int layer, int plane, int strip)
Get channel number.
void reconstructBKLMHits()
Reconstruct BKLMHit1d and BKLMHit2d.
Store one BKLM strip hit as a ROOT object.
StoreArray< EKLMHit2d > m_eklmHit2ds
EKLM 2d hits.
KLMReconstructorModule()
Constructor.
static const GeometryData & Instance(enum DataSource dataSource=c_Database, const GearDir *gearDir=nullptr)
Instantiation.
double m_PromptTime
Nominal time of prompt BKLMHit2ds.
Class for 2d hits handling.
const EKLM::GeometryData * m_eklmGeoDat
Geometry data.
EKLMTimeCalibrationData m_eklmDefaultTimeCalibrationData
Default time calibration data.