13#define TRGCDC_SHORT_NAMES
16#include "G4RunManager.hh"
18#include "trg/cdc/modules/trgcdc/TRGCDCModule.h"
19#include "trg/trg/Debug.h"
21#include <framework/datastore/StoreArray.h>
22#include <mdst/dataobjects/MCParticle.h>
23#include <cdc/dataobjects/CDCHit.h>
24#include <trg/cdc/dataobjects/CDCTriggerSegmentHit.h>
25#include <trg/cdc/dataobjects/CDCTriggerTrack.h>
26#include <trg/trg/dataobjects/TRGTiming.h>
28#include <cdc/geometry/CDCGeometryPar.h>
44 return string(
"TRGCDCModule 5.07");
50 _configFilename(
"TRGCDCConfig.dat"),
51 _innerTSLUTFilename(
"undefined"),
52 _outerTSLUTFilename(
"undefined"),
53 _rootTRGCDCFilename(
"undefined"),
54 _rootFitter3DFilename(
"undefined"),
57 _fastSimulationMode(0),
58 _firmwareSimulationMode(0),
59 _firmwareSimulationStart(0),
60 _firmwareSimulationStop(32 * 32 - 1),
62 _perfect2DFinder(false),
63 _perfect3DFinder(false),
65 _hFinderMappingFilePlus(
"HoughMappingPlus20160223.dat"),
66 _hFinderMappingFileMinus(
"HoughMappingMinus20160223.dat"),
72 _fFitter3Ds2DFitDrift(0),
73 _wireHitInefficiency(0.),
81 _fXtSimpleFitter3D(0),
82 _trgCDCDataInputMode(0),
87 string desc =
"TRGCDCModule(" +
version() +
")";
91 vector<string> emptyvector;
96 "The filename of CDC trigger config file",
99 "Chooses modules for return value. Can be a list of [TSF, ETF, 2DFind, 2DFit, 3DFind, 3DFit]. If empty list then returnValue will be for all modules.",
103 "The filename of LUT for inner-most track segments",
107 "The filename of LUT for outer track segments",
111 "The filename of root file for TRGCDC",
112 string(
"TRGCDC.root"));
115 "The filename of root file for Fitter3D",
116 string(
"Fitter3D.root"));
119 "Curl back stop parameter",
123 "TRGCDC simulation switch",
127 "TRGCDC fast simulation mode",
131 "TRGCDC firmware simulation mode",
135 "TRGCDC firmware simulation start clock of CDC FE",
139 "TRGCDC firmware simulation stop clock of CDC FE",
143 "Flag for making TRGCDC.root",
147 "Use logic or LUT for TSF",
151 "2D finder perfect option",
155 "3D finder perfect option",
159 "Hough finder min. peak height",
161 addParam(
"HoughFinderMappingFilePlus",
163 "Hough finder cell mapping file for charge plus",
165 addParam(
"HoughFinderMappingFileMinus",
167 "Hough finder cell mapping file for charge minus",
171 "Hough finder doit() version",
175 "Using L/R LUT in fitter3D",
179 "Using MC L/R information for Fitter3D",
183 "Using 1: 2D fit or 0: Hough Finder results for Fitter3D",
187 "Using 1: drift 2D fit or 0: wire 2D fit for Fitter3D",
191 "wire hit inefficiency",
195 "Flag for making TSF.root",
199 "Flag for making ETF.root",
203 "Select ETF ver, 0:histogram, 1:old Version, 2:True T0",
207 "Flag for printing Firmware inputs for ETF",
211 "Flag for making Hough3D.root",
219 "Flag for making Fitter3D.root",
223 "0: Use simple xt curve table. 1: use non-linear xt curve table.",
227 "Flag for TRG CDC input mode",
230 "Name of the CDCHit StoreArray to be used as input.",
233 "Name of the StoreArray holding the tracks made by the 2D finder.",
234 string(
"Trg2DFinderTracks"));
236 "Name of the StoreArray holding the tracks made by the 2D fitter.",
237 string(
"Trg2DFitterTracks"));
239 "Name of the StoreArray holding the tracks made by the 3D fitter.",
240 string(
"Trg3DFitterTracks"));
244 cout <<
"TRGCDCModule ... created" << endl;
253 cout <<
"TRGCDCModule ... destructed " << endl;
262 G4RunManager* g4rm = G4RunManager::GetRunManager();
264 if (g4rm->GetUserPhysicsList() != 0) {
265 _sa =
new TCSAction();
266 g4rm->SetUserAction(
_sa);
273 cout <<
"TRGCDCModule::initialize ... options" << endl;
346 cdc.getTdcBinWidth(),
356 cout <<
"TRGCDCModule ... beginRun called " << endl;
378 string const& moduleName = *it;
379 if (moduleName ==
"TSF") mask |= TRGCDC::EReturnValueType::TSF;
380 else if (moduleName ==
"ETF") mask |= TRGCDC::EReturnValueType::ETF;
381 else if (moduleName ==
"find2D") mask |= TRGCDC::EReturnValueType::find2D;
382 else if (moduleName ==
"fit2D") mask |= TRGCDC::EReturnValueType::fit2D;
383 else if (moduleName ==
"find3D") mask |= TRGCDC::EReturnValueType::find3D;
384 else if (moduleName ==
"fit3D") mask |= TRGCDC::EReturnValueType::fit3D;
386 if (mask != 0) returnValue &= mask;
394 cout <<
"TRGCDCModule ... endRun called " << endl;
404 cout <<
"TRGCDCModule ... terminate called " << endl;
The Class for CDC Geometry Parameters.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
void setReturnValue(int value)
Sets the return value for this module as integer.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
bool registerInDataStore(DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut)
Register the object/array in the DataStore.
Accessor to arrays stored in the data store.
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.
Type-safe access to single objects in the data store.
int _curlBackStop
Curl back stop parameter. 0:do nothing, 1:stop curling. Default is 0.
bool _fileFitter3D
Switch for Fitter3D.root file.
bool _fFitter3Ds2DFitDrift
Switch to us wire 2D fit or drift 2D fit.
bool _fFitter3Ds2DFit
Switch to us 2D fit or Hough finder results.
std::string _configFilename
Config. file name.
int _trgCDCDataInputMode
Switch for TRG CDC input mode.
std::string _hFinderMappingFilePlus
Hough mapping file for charge plus.
std::string m_3DfitterCollectionName
Name of the StoreArray holding the tracks made by the 3D fitter.
int _debugLevel
Debug level.
int _finder3DMode
Sets mode of 3DFinder.
bool _fXtSimpleFitter3D
Switch for using simple x-t curve or non-linear x-t curve. 0: non-linear 1: simple.
std::string _outerTSLUTFilename
The filename of LUT for outer track segments.(tmp)
int _simulationMode
Mode for TRGCDC simulation. 0th bit : fast simulation switch, 1st bit : firmware simulation switch.
std::string _innerTSLUTFilename
The filename of LUT for the inner-most track segments.(tmp)
bool _fLogicLUTTSF
Switch for the Logic/LUT TSF.
TRGCDCSteppingAction * _sa
A pointer to a TRGCDCSteppingAction which stops curl backs.
int _fverETF
Switch for selecting ETF version.
bool _fileHough3D
Switch for Hough3D.root file.
bool _fileTSF
Switch for TSF.root file.
bool _fileETF
Switch for ETF.root file.
std::string _rootTRGCDCFilename
The filename of root file for TRGCDC.
int _hFinderPeakMin
Min. peak height for the Hough finder.
bool _fprintFirmETF
Switch for printing Firmware inputs for ETF.
std::string m_inputCollectionName
Name of the CDCHit StoreArray used as input.
bool _fileTRGCDC
Switch for TRGCDC.root file.
std::string m_2DfinderCollectionName
Name of the StoreArray holding the tracks made by the 2D finder.
int _firmwareSimulationMode
Switch for the firmware simulation. 0:do nothing, 1:do everything.
bool _perfect2DFinder
Switch to activate perfect 2D finder.
double _wireHitInefficiency
Parameter for Hit inefficiency.
TRGCDC * _cdc
A pointer to a TRGCDC;.
int _hFinderDoit
Hough finder doit version.
int _firmwareSimulationStop
Stop clock for the firmware simultion. (clock=cdcfe)
int _firmwareSimulationStart
Start clock for the firmware simultion. (clock=cdcfe)
int _fastSimulationMode
Switch for the fast simulation. 0:do everything, 1:stop after the track segment simulation....
bool _perfect3DFinder
Switch to activate perfect 3D finder.
std::string m_2DfitterCollectionName
Name of the StoreArray holding the tracks made by the 2D fitter.
std::string _rootFitter3DFilename
The filename of root file for Fitter3D.
bool _fFitter3Dsmclr
Switch for Fitter3D's MC L/R information.
std::vector< std::string > _returnValueModuleNames
returnValue module's name. Can be ["", "TSF", "ETF", "find2D", "fit2D", "find3D", "fit3D"]....
bool _fLRLUT
Switch for the LR LUT in Fitter3D.
std::string _hFinderMappingFileMinus
Hough mapping file for charge minus.
The instance of TRGCDC is a singleton.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
virtual void initialize() override
Initilizes TRGCDCModule.
virtual ~TRGCDCModule()
Destructor.
virtual void event() override
Called event by event.
virtual void endRun() override
Called when run ended.
virtual void terminate() override
Called when processing ended.
TRGCDCModule()
Constructor.
virtual void beginRun() override
Called when new run started.
std::string version(void) const
returns version of TRGCDCModule.
static std::string tab(void)
returns tab spaces.
static TRGCDC * getTRGCDC(void)
returns TRGCDC object.
void setReturnValue(EReturnValueType const &moduleName, bool flag)
sets return value for trg cdc module.
void terminate(void)
terminates when run is finished
static int level(void)
returns the debug level.
int getReturnValue(void) const
gets return value for trg cdc module.
void update()
updates TRGCDC wire information. clear() is called in this function.
void simulate(void)
fast trigger simulation.
void storeSimulationResults(std::string collection2Dfinder, std::string collection2Dfitter, std::string collection3Dfitter)
Save results of fast simulation to data store (segment hits & tracks).
Abstract base class for different kinds of events.