Belle II Software  release-05-01-25
EKLMAlignmentAlongStripsCollectorModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Kirill Chilikin *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 /* Own header. */
12 #include <klm/eklm/modules/EKLMAlignmentAlongStrips/EKLMAlignmentAlongStripsCollectorModule.h>
13 
14 /* Belle 2 headers. */
15 #include <framework/gearbox/Unit.h>
16 #include <tracking/dataobjects/ExtHit.h>
17 
18 /* ROOT headers. */
19 #include <TTree.h>
20 
21 using namespace Belle2;
22 
23 REG_MODULE(EKLMAlignmentAlongStripsCollector)
24 
28  m_ElementNumbers(&(EKLMElementNumbers::Instance())),
29  m_GeoDat(nullptr),
30  m_TransformData(nullptr),
31  m_Event(new EKLMAlignmentAlongStripsAlgorithm::Event)
32 {
33  setDescription("Module for EKLM alignment along strip (data collection).");
35 }
36 
39 {
40  delete m_Event;
41 }
42 
44 {
45  TTree* t;
49  m_KLMDigits.isRequired();
50  m_Tracks.isRequired();
51  StoreArray<ExtHit> extHits;
52  m_Tracks.requireRelationTo(extHits);
53  t = new TTree("calibration_data", "");
54  t->Branch("event", &m_Event);
55  registerObject<TTree>("calibration_data", t);
56 }
57 
59 {
60  /* cppcheck-suppress variableScope */
61  int i, j, n, n2, vol;
62  double l;
63  const HepGeom::Transform3D* tr;
64  TVector3 hitPosition;
65  HepGeom::Point3D<double> hitGlobal, hitLocal;
66  std::multimap<int, ExtHit*> mapExtHit;
67  std::multimap<int, ExtHit*>::iterator it, it2, itLower, itUpper;
68  std::set<int> digitVolumes;
69  ExtHit* extHit;
70  TTree* calibrationData = getObjectPtr<TTree>("calibration_data");
71  /* Create volume - extHit map. */
72  n = m_Tracks.getEntries();
73  for (i = 0; i < n; i++) {
74  RelationVector<ExtHit> extHits = m_Tracks[i]->getRelationsTo<ExtHit>();
75  n2 = extHits.size();
76  for (j = 0; j < n2; j++) {
77  if (extHits[j]->getDetectorID() != Const::EDetector::EKLM)
78  continue;
79  if (!m_GeoDat->hitInEKLM(extHits[j]->getPosition().Z()))
80  continue;
81  mapExtHit.insert(std::pair<int, ExtHit*>(extHits[j]->getCopyID(),
82  extHits[j]));
83  }
84  }
85  /* Create set of strips with signal. */
86  n = m_KLMDigits.getEntries();
87  for (i = 0; i < n; i++) {
88  if (m_KLMDigits[i]->getSubdetector() != KLMElementNumbers::c_EKLM)
89  continue;
91  m_KLMDigits[i]->getSection(), m_KLMDigits[i]->getLayer(),
92  m_KLMDigits[i]->getSector(), m_KLMDigits[i]->getPlane(),
93  m_KLMDigits[i]->getStrip());
94  digitVolumes.insert(vol);
95  }
96  /* Search for strips with extHits, but without signal. */
97  for (it = mapExtHit.begin(); it != mapExtHit.end();) {
98  itLower = it;
99  do {
100  ++it;
101  } while ((it != mapExtHit.end()) && (it->first == itLower->first));
102  itUpper = it;
103  if (digitVolumes.find(itLower->first) != digitVolumes.end())
104  continue;
105  /* Found: write all extHits to the data tree. */
106  for (it2 = itLower; it2 != itUpper; ++it2) {
107  extHit = it2->second;
108  hitPosition = extHit->getPosition();
109  m_Event->x = hitPosition.X();
110  m_Event->y = hitPosition.Y();
111  m_Event->z = hitPosition.Z();
112  hitGlobal.setX(hitPosition.X() / Unit::mm * CLHEP::mm);
113  hitGlobal.setY(hitPosition.Y() / Unit::mm * CLHEP::mm);
114  hitGlobal.setZ(hitPosition.Z() / Unit::mm * CLHEP::mm);
115  m_Event->stripGlobal = it2->first;
121  m_Event->strip);
122  hitLocal = (*tr) * hitGlobal;
123  l = m_GeoDat->getStripLength(m_Event->strip) / CLHEP::mm * Unit::mm;
124  m_Event->distSiPM = 0.5 * l - hitLocal.x() / CLHEP::mm * Unit::mm;
125  m_Event->distFarEnd = 0.5 * l + hitLocal.x() / CLHEP::mm * Unit::mm;
130  calibrationData->Fill();
131  }
132  }
133 }
134 
136 {
137  delete m_TransformData;
138 }
139 
Belle2::CalibrationCollectorModule
Calibration collector module base class.
Definition: CalibrationCollectorModule.h:44
Belle2::RelationVector::size
size_t size() const
Get number of relations.
Definition: RelationVector.h:98
Belle2::EKLM::TransformData
Transformation data.
Definition: TransformData.h:37
Belle2::EKLMAlignmentAlongStripsAlgorithm
EKLM time calibration algorithm.
Definition: EKLMAlignmentAlongStripsAlgorithm.h:33
Belle2::EKLMAlignmentAlongStripsAlgorithm::Event::plane
int plane
Plane number.
Definition: EKLMAlignmentAlongStripsAlgorithm.h:44
Belle2::EKLMElementNumbers
EKLM element numbers.
Definition: EKLMElementNumbers.h:34
Belle2::Module::setDescription
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:216
Belle2::ExtHit::getPosition
TVector3 getPosition() const
Get position of this extrapolation hit.
Definition: ExtHit.h:153
Belle2::EKLMAlignmentAlongStripsAlgorithm::Event::x
float x
Hit X coordinate.
Definition: EKLMAlignmentAlongStripsAlgorithm.h:48
Belle2::EKLMElementNumbers::stripNumberToElementNumbers
void stripNumberToElementNumbers(int stripGlobal, int *section, int *layer, int *sector, int *plane, int *strip) const
Get element numbers by strip global number.
Definition: EKLMElementNumbers.cc:220
Belle2::EKLM::TransformData::c_Alignment
@ c_Alignment
Use alignment data (for everything else).
Definition: TransformData.h:47
Belle2::EKLMAlignmentAlongStripsCollectorModule::~EKLMAlignmentAlongStripsCollectorModule
~EKLMAlignmentAlongStripsCollectorModule()
Destructor.
Definition: EKLMAlignmentAlongStripsCollectorModule.cc:38
Belle2::EKLM::TransformData::getStripGlobalToLocal
const HepGeom::Transform3D * getStripGlobalToLocal(KLMDigit *hit) const
Get strip global to local transformation by hit.
Definition: TransformData.cc:336
Belle2::EKLMAlignmentAlongStripsCollectorModule::m_Event
struct EKLMAlignmentAlongStripsAlgorithm::Event * m_Event
Event.
Definition: EKLMAlignmentAlongStripsCollectorModule.h:100
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module::c_ParallelProcessingCertified
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:82
Belle2::EKLMAlignmentAlongStripsCollectorModule::collect
void collect() override
This method is called for each event.
Definition: EKLMAlignmentAlongStripsCollectorModule.cc:58
Belle2::EKLMAlignmentAlongStripsCollectorModule::m_ElementNumbers
const EKLMElementNumbers * m_ElementNumbers
Element numbers.
Definition: EKLMAlignmentAlongStripsCollectorModule.h:85
Belle2::KLMElementNumbers::c_EKLM
@ c_EKLM
EKLM.
Definition: KLMElementNumbers.h:50
Belle2::EKLMAlignmentAlongStripsAlgorithm::Event::segmentGlobal
int segmentGlobal
Segment global number.
Definition: EKLMAlignmentAlongStripsAlgorithm.h:47
Belle2::EKLMAlignmentAlongStripsCollectorModule::EKLMAlignmentAlongStripsCollectorModule
EKLMAlignmentAlongStripsCollectorModule()
Constructor.
Definition: EKLMAlignmentAlongStripsCollectorModule.cc:26
Belle2::EKLMAlignmentAlongStripsAlgorithm::Event::z
float z
Hit Z coordinate.
Definition: EKLMAlignmentAlongStripsAlgorithm.h:50
Belle2::Module::setPropertyFlags
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:210
Belle2::ExtHit
Store one Ext hit as a ROOT object.
Definition: ExtHit.h:40
Belle2::RelationVector
Class for type safe access to objects that are referred to in relations.
Definition: DataStore.h:38
Belle2::EKLMAlignmentAlongStripsAlgorithm::Event::strip
int strip
Strip number.
Definition: EKLMAlignmentAlongStripsAlgorithm.h:45
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::EKLM::GeometryData::getStripLength
double getStripLength(int strip) const
Get strip length.
Definition: GeometryData.h:73
Belle2::EKLMAlignmentAlongStripsAlgorithm::Event::layer
int layer
Layer number.
Definition: EKLMAlignmentAlongStripsAlgorithm.h:42
Belle2::EKLM::GeometryData::hitInEKLM
bool hitInEKLM(double z) const
Check if z coordinate may be in EKLM.
Definition: GeometryData.cc:639
Belle2::EKLMAlignmentAlongStripsAlgorithm::Event::section
int section
Section number.
Definition: EKLMAlignmentAlongStripsAlgorithm.h:41
Belle2::EKLMElementNumbers::segmentNumber
int segmentNumber(int section, int layer, int sector, int plane, int segment) const
Get segment number.
Definition: EKLMElementNumbers.cc:191
Belle2::EKLMElementNumbers::stripNumber
int stripNumber(int section, int layer, int sector, int plane, int strip) const
Get strip number.
Definition: EKLMElementNumbers.cc:212
Belle2::EKLMAlignmentAlongStripsAlgorithm::Event::sector
int sector
Sector number.
Definition: EKLMAlignmentAlongStripsAlgorithm.h:43
Belle2::EKLMAlignmentAlongStripsCollectorModule::finish
void finish() override
This method is called at the end of the event processing.
Definition: EKLMAlignmentAlongStripsCollectorModule.cc:135
Belle2::EKLMAlignmentAlongStripsCollectorModule::m_KLMDigits
StoreArray< KLMDigit > m_KLMDigits
EKLM digits.
Definition: EKLMAlignmentAlongStripsCollectorModule.h:94
Belle2::EKLMAlignmentAlongStripsAlgorithm::Event::distSiPM
float distSiPM
Distance from hit to the SiPM.
Definition: EKLMAlignmentAlongStripsAlgorithm.h:51
Belle2::EKLMElementNumbers::getNStripsSegment
static constexpr int getNStripsSegment()
Get number of strips in a segment.
Definition: EKLMElementNumbers.h:401
Belle2::EKLMAlignmentAlongStripsCollectorModule::m_Tracks
StoreArray< Track > m_Tracks
Tracks.
Definition: EKLMAlignmentAlongStripsCollectorModule.h:97
Belle2::Unit::mm
static const double mm
[millimeters]
Definition: Unit.h:80
HepGeom::Point3D< double >
Belle2::StoreArray
Accessor to arrays stored in the data store.
Definition: ECLMatchingPerformanceExpertModule.h:33
Belle2::EKLMAlignmentAlongStripsAlgorithm::Event::y
float y
Hit Y coordinate.
Definition: EKLMAlignmentAlongStripsAlgorithm.h:49
Belle2::EKLMAlignmentAlongStripsCollectorModule::m_GeoDat
const EKLM::GeometryData * m_GeoDat
Geometry data.
Definition: EKLMAlignmentAlongStripsCollectorModule.h:88
Belle2::EKLMAlignmentAlongStripsAlgorithm::Event::distFarEnd
float distFarEnd
Distance from hit to the far end of the strip.
Definition: EKLMAlignmentAlongStripsAlgorithm.h:52
Belle2::EKLMAlignmentAlongStripsCollectorModule::m_TransformData
EKLM::TransformData * m_TransformData
Transformation data.
Definition: EKLMAlignmentAlongStripsCollectorModule.h:91
Belle2::EKLM::GeometryData::Instance
static const GeometryData & Instance(enum DataSource dataSource=c_Database, const GearDir *gearDir=nullptr)
Instantiation.
Definition: GeometryData.cc:35
Belle2::EKLMAlignmentAlongStripsCollectorModule::prepare
void prepare() override
Initializer.
Definition: EKLMAlignmentAlongStripsCollectorModule.cc:43
Belle2::EKLMAlignmentAlongStripsAlgorithm::Event::stripGlobal
int stripGlobal
Strip global number.
Definition: EKLMAlignmentAlongStripsAlgorithm.h:46