 |
Belle II Software
release-05-02-19
|
1 #include "trg/cdc/modules/trgcdc/CDCTriggerTSFModule.h"
3 #include <cdc/dataobjects/CDCSimHit.h>
4 #include <mdst/dataobjects/MCParticle.h>
6 #include <cdc/geometry/CDCGeometryPar.h>
7 #include <trg/cdc/Layer.h>
8 #include <trg/cdc/Wire.h>
9 #include <trg/cdc/WireHit.h>
10 #include <trg/cdc/Segment.h>
14 #define P3D HepGeom::Point3D<double>
26 "The Track Segment Finder module of the CDC trigger.\n"
27 "Combines CDCHits from the same super layer to CDCTriggerSegmentHits.\n"
32 "Name of the input StoreArray of CDCHits.",
36 "Name of the output StoreArray of CDCTriggerSegmentHits.",
40 "The filename of LUT for track segments from the inner-most super layer",
44 "The filename of LUT for track segments from the outer super layers",
48 "Switch to simulate each data clock cycle separately.",
52 "Switch to create a table of hit pattern <-> "
53 "number of true left / true right, which is needed to create the LUT",
57 "Filename for the true left/right table for the innermost super layer.",
58 string(
"innerTrueLRTable.dat"));
61 "Filename for the true left/right table for the outer super layers.",
62 string(
"outerTrueLRTable.dat"));
86 const unsigned nLayers = cdc.nWireLayers();
87 TRGClock* clockTDC =
new TRGClock(
"CDCTrigger TDC clock", 0, 500. / cdc.getTdcBinWidth());
88 TRGClock* clockData =
new TRGClock(
"CDCTrigger data clock", *clockTDC, 1, 16);
89 clocks.push_back(clockTDC);
90 clocks.push_back(clockData);
93 int superLayerId = -1;
94 unsigned lastNWires = 0;
95 int lastShifts = -1000;
102 unsigned axialStereoLayerId;
103 unsigned axialStereoSuperLayerId = 0;
105 for (
unsigned i = 0; i < nLayers; i++) {
106 const unsigned nWiresInLayer = cdc.nWiresInLayer(i);
109 int nShifts = cdc.nShifts(i);
110 bool axial = (nShifts == 0);
113 axialStereoLayerId = (axial) ? ia : is;
116 if ((lastNWires != nWiresInLayer) || (lastShifts != nShifts)) {
121 axialStereoSuperLayerId = (axial) ? ias : iss;
122 lastNWires = nWiresInLayer;
123 lastShifts = nShifts;
127 const float swr = cdc.senseWireR(i);
128 const float innerRadius = cdc.fieldWireR(i - 1);
129 const float outerRadius = (i < nLayers - 1) ?
131 swr + (swr - innerRadius);
138 axialStereoSuperLayerId,
139 cdc.zOffsetWireLayer(i),
141 M_PI * swr * swr / nWiresInLayer,
148 for (
unsigned j = 0; j < nWiresInLayer; j++) {
149 const P3D fp = P3D(cdc.wireForwardPosition(i, j).x(),
150 cdc.wireForwardPosition(i, j).y(),
151 cdc.wireForwardPosition(i, j).z());
152 const P3D bp = P3D(cdc.wireBackwardPosition(i, j).x(),
153 cdc.wireBackwardPosition(i, j).y(),
154 cdc.wireBackwardPosition(i, j).z());
156 layer->push_back(tw);
161 const unsigned nWiresInTS[2] = {15, 11};
162 const int shape[2][30] = {
198 const int layerOffset[2] = {5, 2};
201 for (
unsigned i = 0; i <
superLayers.size(); i++) {
202 unsigned tsType = (i) ? 1 : 0;
210 const unsigned nWiresInLayer = ww->
layer().
nCells();
211 B2DEBUG(100,
"SL " << i <<
" layerOffset " << layerOffset[tsType] <<
", "
212 <<
superLayers[i].size() <<
" layers, " << nWiresInLayer <<
" wires");
213 for (
unsigned j = 0; j < nWiresInLayer; j++) {
217 const unsigned localId = w.localId();
218 const unsigned layerId = w.localLayerId();
219 vector<const TRGCDCWire*> cells;
221 B2DEBUG(110,
"TS localId " << localId <<
" layerId " << layerId);
223 for (
unsigned k = 0; k < nWiresInTS[tsType]; k++) {
224 const int laid = layerId + shape[tsType][k * 2];
225 const int loid = localId + shape[tsType][k * 2 + 1];
227 B2DEBUG(120,
"cell localId " << loid <<
" layerId " << laid);
236 if (w.superLayerId()) {
252 layer->push_back(ts);
265 for (
int i = 0; i <
m_cdcHits.getEntries(); ++i) {
272 const int tdcCount = floor((cdc.getT0(
WireID(h.getID())) / cdc.getTdcBinWidth()
273 - h.getTDCCount() + 0.5) / 2);
274 TRGTime rise =
TRGTime(tdcCount,
true, w.signal().clock(), w.name());
280 if (w.hit())
continue;
284 0, 0, 0, 0, 0, 0, 0, 0);
291 unsigned neibor_hit[10][1000] = {};
292 for (
unsigned isl = 0; isl <
tsLayers.size(); ++isl) {
293 for (
unsigned its = 0; its <
tsLayers[isl]->nCells(); ++its) {
300 neibor_hit[isl][its] = 1;
306 for (
unsigned isl = 0; isl <
tsLayers.size(); ++isl) {
307 for (
unsigned its = 0; its <
tsLayers[isl]->nCells(); ++its) {
319 if (s.priorityPosition() != 3 && (neibor_hit[isl][(its - 1) %
tsLayers[isl]->nCells()] == 1
320 || neibor_hit[isl][(its + 1) %
tsLayers[isl]->nCells()] == 1))
continue;
326 s.priorityPosition(),
327 s.LUT()->getValue(s.lutPattern()),
332 for (
unsigned iw = 0; iw < s.wires().size(); ++iw) {
336 double weight = (wire == &(s.priority())) ? 2. : 1.;
342 for (
unsigned imc = 0; imc < mcrel.
size(); ++imc) {
343 mcrel[imc]->addRelationTo(tsHit, mcrel.
weight(imc));
372 for (
unsigned ic = 0; ic <
clocks.size(); ++ic) {
378 for (
unsigned isl = 0; isl <
superLayers.size(); ++isl) {
379 for (
unsigned il = 0; il <
superLayers[isl].size(); ++il) {
380 for (
unsigned iw = 0; iw <
superLayers[isl][il]->nCells(); ++iw) {
390 for (
unsigned isl = 0; isl <
tsLayers.size(); ++isl) {
391 for (
unsigned its = 0; its <
tsLayers[isl]->nCells(); ++its) {
401 ostream_iterator<unsigned> innerIterator(innerFile,
" ");
408 ostream_iterator<unsigned> outerIterator(outerFile,
" ");
420 for (
unsigned isl = 0; isl <
superLayers.size(); ++isl) {
421 for (
unsigned il = 0; il <
superLayers[isl].size(); ++il) {
422 for (
unsigned iw = 0; iw <
superLayers[isl][il]->nCells(); ++iw) {
428 for (
unsigned its = 0; its <
tsLayers[isl]->nCells(); ++its) {
size_t size() const
Get number of relations.
A class to represent a digitized signal. Unit is nano second.
Class to identify a wire inside the CDC.
std::vector< std::vector< unsigned > > innerTrueLRTable
list of (# true right, # true left, # true background) for the inner-most super layer
bool m_makeTrueLRTable
switch for saving the number of true left/right for each pattern
unsigned nCells(void) const
returns # of cells.
TRGTime & shift(int unit)
delays by clock unit.
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
void setDescription(const std::string &description)
Sets the description of the module.
const TRGCDCLayer & layer(void) const
returns a pointer to a layer.
#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...
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
std::vector< TRGCDCLayer * > tsLayers
structure to hold pointers to all track segment shapes
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).
StoreArray< CDCHit > m_cdcHits
list of input CDC hits
A class to represent a wire in CDC.
std::string m_outerTrueLRTableFilename
filename for the table which contains the number of true left/right for each pattern in the outer sup...
A class to represent a cell layer.
std::string m_innerTSLUTFilename
The filename of LUT for the inner-most track segments.
bool active(void) const
returns true if there is a signal.
std::vector< std::vector< TRGCDCLayer * > > superLayers
structure to hold pointers to all wires in the CDC
A class to represent a wire in CDC.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
std::string m_CDCHitCollectionName
name of the input StoreArray
The Class for CDC Geometry Parameters.
unsigned iCDCHit(void) const
returns an index to CDCHit.
Class for type safe access to objects that are referred to in relations.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
Abstract base class for different kinds of events.
virtual void initialize() override
Initialize the module and register DataStore arrays.
RelationVector< FROM > getRelationsFrom(const std::string &name="", const std::string &namedRelation="") const
Get the relations that point from another store array to this object.
A class to represent a wire hit in CDC.
int getLeftRightPassage() const
The method to get new left/right info. for tracking.
std::string m_TSHitCollectionName
name of the output StoreArray
virtual void event() override
Run the TSF for an event.
const TRGCDCWireHit * hit(void) const
returns a pointer to a TRGCDCWireHit.
bool m_clockSimulation
switch for simulating clock by clock
A class to represent a wire in CDC.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
std::vector< std::vector< unsigned > > outerTrueLRTable
list of (# true right, # true left, # true background) for the outer super layers
void clear()
remove hit information from last event
std::string m_outerTSLUTFilename
The filename of LUT for outer track segments.
float weight(int index) const
Get weight with index.
virtual unsigned short getBackgroundTag() const
Get background tag.
A Class to store the Monte Carlo particle information.
Accessor to arrays stored in the data store.
const TRGSignal & signal(void) const override
returns an input to the trigger. This is sync'ed to 1GHz clock.
A class to represent a signal timing in the trigger system.
Combination of several CDCHits to a track segment hit for the trigger.
std::string m_innerTrueLRTableFilename
filename for the table which contains the number of true left/right for each pattern in the inner-mos...
virtual void terminate() override
Clean up pointers.
A class to represent a digitized signal. Unit is nano second.
StoreArray< CDCTriggerSegmentHit > m_segmentHits
list of output track segment hits
std::vector< TRGClock * > clocks
list of clocks used in the TSF
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
TRGTime & reverse(void)
reverse edge.