Belle II Software  release-06-01-15
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 <reconstruction/modules/CDCDedxPID/CDCDedxScanModule.h>
10 #include <reconstruction/modules/CDCDedxPID/LineHelper.h>
11 
12 #include <reconstruction/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 <boost/shared_ptr.hpp>
21 #include <boost/make_shared.hpp>
22 
23 #include <cmath>
24 #include <stdlib.h>
25 #include <time.h>
26 
27 using namespace Belle2;
28 using namespace CDC;
29 using namespace Dedx;
30 
31 REG_MODULE(CDCDedxScan)
32 
34 {
35 
36  setDescription("Extract dE/dx and corresponding log-likelihood from fitted tracks and hits in the CDC, SVD and PXD.");
37 }
38 
40 
42 {
43 
44  // register outputs
45  m_dedxArray.registerInDataStore();
46 
47  // create instances here to not confuse profiling
50 
51  if (!genfit::MaterialEffects::getInstance()->isInitialized()) {
52  B2FATAL("Need to have SetupGenfitExtrapolationModule in path before this one");
53  }
54 }
55 
57 {
58 
59  // get the geometry of the cdc
60  static CDCGeometryPar& cdcgeo = CDCGeometryPar::Instance();
61 
62  // **************************************************
63  //
64  // GENERATE PARAMETERS OVER THE FULL RANGE
65  //
66  // **************************************************
67 
68  srand(time(NULL));
69 
70  boost::shared_ptr<CDCDedxTrack> dedxTrack = boost::make_shared<CDCDedxTrack>();
71 
72  for (int i = 0; i < 56; ++i) {
73  int nWires = cdcgeo.nWiresInLayer(i);
74 
75  // position of a sense wire in this layer at endpoints
76  const TVector3& wirePosF = cdcgeo.wireForwardPosition(i, 0);
77  const TVector3& wirePosB = cdcgeo.wireBackwardPosition(i, 0);
78  const TVector3 wireDir = (wirePosB - wirePosF).Unit();
79 
80  // radii of field wires for this layer
81  double inner = cdcgeo.innerRadiusWireLayer()[i];
82  double outer = cdcgeo.outerRadiusWireLayer()[i];
83 
84  double cellHeight = outer - inner;
85  double topHeight = outer - wirePosF.Perp();
86  double bottomHeight = wirePosF.Perp() - inner;
87  double topHalfWidth = M_PI * outer / nWires;
88  double bottomHalfWidth = M_PI * inner / nWires;
89  double cellHalfWidth = M_PI * wirePosF.Perp() / nWires;
90 
91  // first construct the boundary lines, then create the cell
92  const DedxPoint tl = DedxPoint(-topHalfWidth, topHeight);
93  const DedxPoint tr = DedxPoint(topHalfWidth, topHeight);
94  const DedxPoint br = DedxPoint(bottomHalfWidth, -bottomHeight);
95  const DedxPoint bl = DedxPoint(-bottomHalfWidth, -bottomHeight);
96  DedxDriftCell c = DedxDriftCell(tl, tr, br, bl);
97 
98  for (int j = 0; j < 100; ++j) {
99  for (int k = 0; k < 100; ++k) {
100  double doca = j * cellHalfWidth / 50.0 - cellHalfWidth;
101  double entAng = k * 3.14159265 / 100.0 - 3.14159265 / 2.0;
102 
103  // re-scaled (RS) doca and entAng variable: map to square cell
104  double cellR = 2 * cellHalfWidth / cellHeight;
105  double tana = 100.0;
106  if (std::abs(2 * atan(1) - std::abs(entAng)) < 0.01)tana = 100 * (entAng / std::abs(entAng)); //avoid infinity at pi/2
107  else tana = std::tan(entAng);
108  double docaRS = doca * std::sqrt((1 + cellR * cellR * tana * tana) / (1 + tana * tana));
109  double entAngRS = std::atan(tana / cellR);
110 
111  // now calculate the path length for this hit
112  double celldx = c.dx(doca, entAng);
113  if (!c.isValid()) continue;
114 
115  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,
116  1.0, 0, 0.0, 0.0, 0.0);
117  }
118  }
119  m_dedxArray.appendNew(*dedxTrack);
120  }
121 }
122 
124 {
125 
126  B2INFO("CDCDedxScanModule exiting");
127 }
This class performs the same function as CDCDedxPIDModule, but does so without using real objects fro...
virtual void initialize() override
Initialize the module.
virtual void event() override
This method is called for each event.
virtual void terminate() override
End of the event processing.
virtual ~CDCDedxScanModule()
Destructor.
The Class for CDC Geometry Parameters.
const TVector3 wireBackwardPosition(int layerId, int cellId, EWirePosition set=c_Base) const
Returns the backward position of the input sense wire.
const TVector3 wireForwardPosition(int 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
The Unit class.
Definition: Unit.h:40
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:213
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.