Belle II Software development
CDCDedxScanModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <cdc/modules/CDCDedxPID/CDCDedxScanModule.h>
10#include <cdc/modules/CDCDedxPID/LineHelper.h>
11
12#include <cdc/dataobjects/CDCDedxTrack.h>
13#include <reconstruction/dataobjects/DedxConstants.h>
14
15#include <cdc/geometry/CDCGeometryPar.h>
16#include <vxd/geometry/GeoCache.h>
17
18#include <genfit/MaterialEffects.h>
19
20#include <cmath>
21#include <stdlib.h>
22#include <time.h>
23
24using namespace Belle2;
25using namespace CDC;
26using namespace Dedx;
27
28REG_MODULE(CDCDedxScan);
29
31{
32
33 setDescription("Extract dE/dx and corresponding log-likelihood from fitted tracks and hits in the CDC, SVD and PXD.");
34}
35
37
39{
40
41 // register outputs
42 m_dedxArray.registerInDataStore();
43
44 // create instances here to not confuse profiling
47
48 if (!genfit::MaterialEffects::getInstance()->isInitialized()) {
49 B2FATAL("Need to have SetupGenfitExtrapolationModule in path before this one");
50 }
51}
52
54{
55
56 // get the geometry of the cdc
58
59 // **************************************************
60 //
61 // GENERATE PARAMETERS OVER THE FULL RANGE
62 //
63 // **************************************************
64
65 srand(time(NULL));
66
67 CDCDedxTrack dedxTrack;
68
69 for (int i = 0; i < 56; ++i) {
70 int nWires = cdcgeo.nWiresInLayer(i);
71
72 // position of a sense wire in this layer at endpoints
73 const ROOT::Math::XYZVector& wirePosF = cdcgeo.wireForwardPosition(i, 0);
74
75 // radii of field wires for this layer
76 double inner = cdcgeo.innerRadiusWireLayer()[i];
77 double outer = cdcgeo.outerRadiusWireLayer()[i];
78
79 double cellHeight = outer - inner;
80 double topHeight = outer - wirePosF.Rho();
81 double bottomHeight = wirePosF.Rho() - inner;
82 double topHalfWidth = M_PI * outer / nWires;
83 double bottomHalfWidth = M_PI * inner / nWires;
84 double cellHalfWidth = M_PI * wirePosF.Rho() / nWires;
85
86 // first construct the boundary lines, then create the cell
87 const DedxPoint tl = DedxPoint(-topHalfWidth, topHeight);
88 const DedxPoint tr = DedxPoint(topHalfWidth, topHeight);
89 const DedxPoint br = DedxPoint(bottomHalfWidth, -bottomHeight);
90 const DedxPoint bl = DedxPoint(-bottomHalfWidth, -bottomHeight);
91 DedxDriftCell c = DedxDriftCell(tl, tr, br, bl);
92
93 for (int j = 0; j < 100; ++j) {
94 for (int k = 0; k < 100; ++k) {
95 double doca = j * cellHalfWidth / 50.0 - cellHalfWidth;
96 double entAng = k * M_PI / 100.0 - M_PI_2;
97
98 // re-scaled (RS) doca and entAng variable: map to square cell
99 double cellR = 2 * cellHalfWidth / cellHeight;
100 double tana = 100.0;
101 if (std::abs(2 * atan(1) - std::abs(entAng)) < 0.01)tana = 100 * (entAng / std::abs(entAng)); //avoid infinity at pi/2
102 else tana = std::tan(entAng);
103 double docaRS = doca * std::sqrt((1 + cellR * cellR * tana * tana) / (1 + tana * tana));
104 double entAngRS = std::atan(tana / cellR);
105
106 // now calculate the path length for this hit
107 double celldx = c.dx(doca, entAng);
108 if (!c.isValid()) continue;
109
110 dedxTrack.addHit(0, 0, i, doca, docaRS, entAng, entAngRS, 0, 0, 0.0, celldx, 0.0, cellHeight, cellHalfWidth, 0, 0.0, 0.0, 1.0, 1.0,
111 1.0, 0, 0.0, 0.0, 0.0);
112 }
113 }
114 m_dedxArray.appendNew(dedxTrack);
115 }
116}
117
119{
120
121 B2INFO("CDCDedxScanModule exiting");
122}
virtual void initialize() override
Initialize the module.
virtual void event() override
This method is called for each event.
CDCDedxScanModule()
Default constructor.
StoreArray< CDCDedxTrack > m_dedxArray
array of output dE/dx tracks
virtual void terminate() override
End of the event processing.
virtual ~CDCDedxScanModule()
Destructor.
Debug output for CDCDedxPID module.
Definition: CDCDedxTrack.h:25
void addHit(int lwire, int wire, int layer, double doca, double docaRS, double enta, double entaRS, int adcCount, int adcbaseCount, double dE, double path, double dedx, double cellHeight, double cellHalfWidth, int driftT, double driftD, double driftDRes, double wiregain, double twodcor, double onedcor, int foundByTrackFinder, double weightPionHypo, double weightKaonHypo, double weightProtHypo)
Add a single hit to the object.
Definition: CDCDedxTrack.h:65
The Class for CDC Geometry Parameters.
const B2Vector3D wireForwardPosition(uint layerId, int cellId, EWirePosition set=c_Base) const
Returns the forward position of the input sense wire.
unsigned nWiresInLayer(int layerId) const
Returns wire numbers in a layer.
const double * innerRadiusWireLayer() const
Returns an array of inner radius of wire layers.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
const double * outerRadiusWireLayer() const
Returns an array of outer radius of wire layers.
A class to hold the geometry of a cell.
Definition: LineHelper.h:186
A collection of classes that are useful for making a simple path length correction to the dE/dx measu...
Definition: LineHelper.h:29
Base class for Modules.
Definition: Module.h:72
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:649
double atan(double a)
atan for double
Definition: beamHelpers.h:34
Abstract base class for different kinds of events.