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