Belle II Software  release-05-02-19
CDCJobCntlParModifierModule.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2012 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: CDC group *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <cdc/modules/cdcJobCntlParModifier/CDCJobCntlParModifierModule.h>
12 //#include <framework/logging/Logger.h>
13 
14 using namespace std;
15 using namespace Belle2;
16 using namespace CDC;
17 
18 // register module
19 REG_MODULE(CDCJobCntlParModifier)
21  m_gcp(CDCGeoControlPar::getInstance()), m_timeWalk(), m_wireSag(), m_modLeftRightFlag(), m_debug4Sim(), m_thresholdEnergyDeposit(),
22  m_minTrackLength(), m_maxSpaceResol(), m_addFudgeFactorForSigmaForData(), m_addFudgeFactorForSigmaForMC(),
23  m_mapperGeometry(), m_mapperPhiAngle(), m_debug4Geo(), m_printMaterialTable(),
24  m_materialDefinitionMode(), m_senseWireZposMode(),
25  m_displacement(),
26  m_alignment(),
27  m_misalignment(),
28  m_displacementInputType(), m_alignmentInputType(), m_misalignmentInputType(), m_xtInputType(), m_sigmaInputType(),
29  m_propSpeedInputType(), m_t0InputType(), m_twInputType(), m_bwInputType(), m_chMapInputType(), m_eDepToADCInputType(),
30  m_displacementFile(),
31  m_alignmentFile(), m_misalignmentFile(), m_xtFile(), m_sigmaFile(), m_propSpeedFile(), m_t0File(), m_twFile(), m_bwFile(),
32  m_chMapFile(), m_eDepToADCFile()
33 
34 {
35  // B2INFO("CDCJobCntlParModifierModule::constructor called.");
36  // Set description
37  setDescription("Change job contorol parameters. Please put this module in the path (before Geometry module) with specified input parameters when you want to change them.");
38  setPropertyFlags(c_ParallelProcessingCertified);
39 
40  //N.B. The following default values must be identical to the ones in xxControlPar objects.
41  //For Simulation
42  //Switch for debug
43  addParam("Debug4Sim", m_debug4Sim, "Switch on/off debug in FullSim.", false);
44  //Switch for time walk in translator
45  addParam("TimeWalkInTranslator", m_timeWalk,
46  "Switch on/off time-walk correction in the TDC-count translator for MC events. Use the CDCDigitizer's flag if you want to add/not add time walk in digitization.",
47  true);
48  //Switch for wire sag
49  addParam("WireSag", m_wireSag,
50  "Switch on/off sense wire (gravitational) sag in FullSim. Here, sag means the main part which corresponds to design+displacement in case of wire position. You can control the perturbative part (corresponting to (mis)alignment in case of wire-position) of sag in Digitizer.",
51  true);
52  //Switch for modified left/right flag
53  addParam("ModLeftRightFlag", m_modLeftRightFlag, "Switch on/off calculation of modified left/right flag in FullSim.", false);
54  //energy thresh
55  addParam("ThresholdEnergyDeposit", m_thresholdEnergyDeposit,
56  "Energy deposite (edep) thresh. for G4 step (GeV). All hits with smaller edep will be dropped at FullSim level. Set this to a negative value if you want to keep simhits with edep=0.",
57  0.0);
58  //min. track length
59  addParam("MinTrackLength", m_minTrackLength,
60  "Minimum track length (cm) required for saving in MCParticle.; to be applied to all particles other than primaries and decay-daughters.",
61  15.0);
62 
63  //For Geometry
64  //Switch for debug
65  addParam("Debug4Geo", m_debug4Geo, "Switch on/off debug in Geo.", false);
66  //Switch for printing material table
67  addParam("PrintMaterialTable", m_printMaterialTable,
68  "Switch on/off printing the G4 material table at the stage of CDC geometry creation.", false);
69  //material definition mode
70  addParam("MaterialDefinitionMode", m_materialDefinitionMode,
71  "Material definition mode: =0: define a mixture of gases and wires in the entire tracking volume; =1: dummy; =2: define all sense and field wires explicitly in the volume.",
72  0);
73  //sense wire z pos mode
74  addParam("SenseWireZposMode", m_senseWireZposMode,
75  "Sense wire z position mode: =1: correct for feedthrough effect; =0: not correct.", 1);
76  //displacement switch
77  addParam("Displacement", m_displacement, "Switch for wire displacement: on/off.", true);
78  //alignmentt switch
79  addParam("Alignment", m_alignment, "Switch for wire alignment: on/off.", true);
80  //misalignment switch
81  // addParam("Misalignment", m_misalignment, "Switch for wire misalignment: on/off.", true);
82  m_misalignment = false;
83 
84 
85  //input type for displacement
86  addParam("DisplacementInputType", m_displacementInputType, "Input type for wire displacement; db-object (true); text-file (false).",
87  true);
88  //input type for alignment
89  addParam("AlignmentInputType", m_alignmentInputType, "Input type for wire alignment; db-object (true); text-file (false).", true);
90  //input type for misalignment
91  // addParam("MisalignmentInputType", m_misalignmentInputType, "Input type for wire misalignment; db-object (true); text-file (false).", true);
92  m_misalignmentInputType = true;
93  //input type for xt-relation
94  addParam("XtInputType", m_xtInputType, "Input type for xt-relations; db-object (true); text-file (false).", true);
95  //input type for sigma
96  addParam("SigmaInputType", m_sigmaInputType, "Input type for sigmas; db-object (true); text-file (false).", true);
97  //input type for prop-speed
98  addParam("PropSpeedInputType", m_propSpeedInputType, "Input type for prop-speeds; db-object (true); text-file (false).", true);
99  //input type for t0
100  addParam("T0InputType", m_t0InputType, "Input type for t0s; db-object (true); text-file (false).", true);
101  //input type for time walk
102  addParam("TimeWalkInputType", m_twInputType, "Input type for time walks; db-object (true); text-file (false).", true);
103  //input type for bad wire
104  addParam("BadWireInputType", m_bwInputType, "Input type for bad wires; db-object (true); text-file (false).", true);
105  //input type for channel map
106  addParam("ChannelMapInputType", m_chMapInputType, "Input type for channel map; db-object (true); text-file (false).", true);
107  //input type for edep-to-adc
108  addParam("EDepToADCInputType", m_eDepToADCInputType, "Input type for edep-to-adc; db-object (true); text-file (false).", true);
109 
110 
111  //displacement file
112  addParam("DisplacementFile", m_displacementFile, "Input file name (on cdc/data) for wire displacement.",
113  string("displacement_v2.2.1.dat"));
114  //alignment file
115  addParam("AlignmentFile", m_alignmentFile, "Input file name (on cdc/data) for wire alignment.", string("alignment_v2.dat"));
116  //misalignment file
117  // addParam("MisalignmentFile", m_misalignmentFile, "Input file name (on cdc/data) for wire misalignment.", string("misalignment_v2.dat"));
118  m_misalignmentFile = string("misalignment_v2.dat");
119  //xt-relation
120  addParam("XtFile", m_xtFile, "Input file name (on cdc/data) for xt-relations. You can specify either an uncompressed or gzip file.",
121  string("xt_v3_chebyshev.dat.gz"));
122  //sigma
123  addParam("SigmaFile", m_sigmaFile, "Input file name (on cdc/data) for sigmas.", string("sigma_v2.dat"));
124  //prop-speed
125  addParam("PropSpeedFile", m_propSpeedFile, "Input file name (on cdc/data) for prop-speeds.", string("propspeed_v0.dat"));
126  //t0
127  addParam("T0File", m_t0File, "Input file name (on cdc/data) for t0s.", string("t0_v1.dat"));
128  //time walk
129  addParam("TimeWalkFile", m_twFile, "Input file name (on cdc/data) for time walks.", string("tw_off.dat"));
130  //bad wire
131  addParam("BadWireFile", m_bwFile, "Input file name (on cdc/data) for bad wires.", string("badwire_v1.dat"));
132  //channel map
133  addParam("ChannelMapFile", m_chMapFile, "Input file name (on cdc/data) for channel map.", string("ch_map.dat"));
134  //edep-to-adc
135  addParam("EDepToADCFile", m_eDepToADCFile, "Input file name (on cdc/data) for edep-to-adc.", string("edeptoadc.dat"));
136 
137  //max. space resolution
138  addParam("MaxSpaceResol", m_maxSpaceResol,
139  "Maximum space resolution (cm) in CDCGeometryPar::getSigma() to avoid a too large value; from 2011 beam test; a bit larger value may be better...",
140  double(2.5 * 0.0130));
141 
142  //additional fudge factor for data
143  addParam("AddFudgeFactorForSigmaForData", m_addFudgeFactorForSigmaForData,
144  "Additional fudge factor for space resol. used in real data event reconstruction (common to all cells).",
145  double(1.));
146 
147  //additional fudge factor for MC
148  addParam("AddFudgeFactorForSigmaForMC", m_addFudgeFactorForSigmaForMC,
149  "Additional fudge factor for space resol. used in MC event reconstruction (common to all cells). N.B. This factor is not applied in digitization; only applied in reconstruction. Pplease set the fudge parameter of digitizer instead if you want to change the digitization sigma indep. of sigma used in reconstruction.",
150  double(1.));
151 
152  //mapper geometry flag
153  addParam("MapperGeometry", m_mapperGeometry, "Define B-field mapper geometry used in GCR in 2017 summer. Tentative option.",
154  bool(false));
155 
156  //mapper phi-angle
157  addParam("MapperPhiAngle", m_mapperPhiAngle, "Phi-angle (deg.) of B-field mapper used in GCR in 2017 summer. Tentative option.",
158  double(16.7));
159 
160 }
161 
162 void CDCJobCntlParModifierModule::initialize()
163 {
164  // B2INFO("CDCJobCntlParModifierModule::initialize() called.");
165  //For Simulation
166  if (m_scp.getTimeWalk() != m_timeWalk) {
167  B2INFO("CDCJobCntlParModifier: timeWalk modified: " << m_scp.getTimeWalk() << " to " << m_timeWalk);
168  m_scp.setTimeWalk(m_timeWalk);
169  }
170 
171  if (m_scp.getWireSag() != m_wireSag) {
172  B2INFO("CDCJobCntlParModifier: wireSag modified: " << m_scp.getWireSag() << " to " << m_wireSag);
173  m_scp.setWireSag(m_wireSag);
174  }
175 
176  if (m_scp.getModLeftRightFlag() != m_modLeftRightFlag) {
177  B2INFO("CDCJobCntlParModifier: modLeftRightFlag modified: " << m_scp.getModLeftRightFlag() << " to " << m_modLeftRightFlag);
178  m_scp.setModLeftRightFlag(m_modLeftRightFlag);
179  }
180 
181  if (m_scp.getDebug() != m_debug4Sim) {
182  B2INFO("CDCJobCntlParModifier: debug4Sim modified: " << m_scp.getDebug() << " to " << m_debug4Sim);
183  m_scp.setDebug(m_debug4Sim);
184  }
185 
186  if (m_scp.getThresholdEnergyDeposit() != m_thresholdEnergyDeposit) {
187  B2INFO("CDCJobCntlParModifier: thresholdEnergyDeposit modified: " << m_scp.getThresholdEnergyDeposit() << " to " <<
188  m_thresholdEnergyDeposit);
189  m_scp.setThresholdEnergyDeposit(m_thresholdEnergyDeposit);
190  }
191 
192  if (m_scp.getMinTrackLength() != m_minTrackLength) {
193  B2INFO("CDCJobCntlParModifier: minTrackLength modified: " << m_scp.getMinTrackLength() << " to " << m_minTrackLength);
194  m_scp.setMinTrackLength(m_minTrackLength);
195  }
196 
197  //For Geometry
198  if (m_gcp.getMaterialDefinitionMode() != m_materialDefinitionMode) {
199  B2INFO("CDCJobCntlParModifier: materialDefinitionMode modified: " << m_gcp.getMaterialDefinitionMode() << " to " <<
200  m_materialDefinitionMode);
201  m_gcp.setMaterialDefinitionMode(m_materialDefinitionMode);
202  }
203 
204  if (m_gcp.getSenseWireZposMode() != m_senseWireZposMode) {
205  B2INFO("CDCJobCntlParModifier: senseWireZposMode modified: " << m_gcp.getSenseWireZposMode() << " " << m_senseWireZposMode);
206  m_gcp.setSenseWireZposMode(m_senseWireZposMode);
207  }
208 
209  if (m_gcp.getPrintMaterialTable() != m_printMaterialTable) {
210  B2INFO("CDCJobCntlParModifier: printMaterialTable modified: " << m_gcp.getPrintMaterialTable() << " to " << m_printMaterialTable);
211  m_gcp.setPrintMaterialTable(m_printMaterialTable);
212  }
213 
214  if (m_gcp.getDebug() != m_debug4Geo) {
215  B2INFO("CDCJobCntlParModifier: debug4Geo modified: " << m_gcp.getDebug() << " to " << m_debug4Geo);
216  m_gcp.setDebug(m_debug4Geo);
217  }
218 
219  if (m_gcp.getDisplacement() != m_displacement) {
220  B2INFO("CDCJobCntlParModifier: displacement switch modified: " << m_gcp.getDisplacement() << " to " << m_displacement);
221  m_gcp.setDisplacement(m_displacement);
222  }
223 
224  if (m_gcp.getAlignment() != m_alignment) {
225  B2INFO("CDCJobCntlParModifier: alignment switch modified: " << m_gcp.getAlignment() << " to " << m_alignment);
226  m_gcp.setAlignment(m_alignment);
227  }
228 
229  if (m_gcp.getMisalignment() != m_misalignment) {
230  B2INFO("CDCJobCntlParModifier: misalignment switch modified: " << m_gcp.getMisalignment() << " to " << m_misalignment);
231  m_gcp.setMisalignment(m_misalignment);
232  }
233 
234  if (m_gcp.getDisplacementInputType() != m_displacementInputType) {
235  B2INFO("CDCJobCntlParModifier: displacementInputType modified: " << m_gcp.getDisplacementInputType() << " to " <<
236  m_displacementInputType);
237  m_gcp.setDisplacementInputType(m_displacementInputType);
238  }
239 
240  if (m_gcp.getAlignmentInputType() != m_alignmentInputType) {
241  B2INFO("CDCJobCntlParModifier: alignmentInputType modified: " << m_gcp.getAlignmentInputType() << " to " << m_alignmentInputType);
242  m_gcp.setAlignmentInputType(m_alignmentInputType);
243  }
244 
245  if (m_gcp.getMisalignmentInputType() != m_misalignmentInputType) {
246  B2INFO("CDCJobCntlParModifier: misalignmentInputType modified: " << m_gcp.getMisalignmentInputType() << " to " <<
247  m_misalignmentInputType);
248  m_gcp.setMisalignmentInputType(m_misalignmentInputType);
249  }
250 
251  if (m_gcp.getXtInputType() != m_xtInputType) {
252  B2INFO("CDCJobCntlParModifier: xtInputType modified: " << m_gcp.getXtInputType() << " to " << m_xtInputType);
253  m_gcp.setXtInputType(m_xtInputType);
254  }
255 
256  if (m_gcp.getSigmaInputType() != m_sigmaInputType) {
257  B2INFO("CDCJobCntlParModifier: sigmaInputType modified: " << m_gcp.getSigmaInputType() << " to " << m_sigmaInputType);
258  m_gcp.setSigmaInputType(m_sigmaInputType);
259  }
260 
261  if (m_gcp.getPropSpeedInputType() != m_propSpeedInputType) {
262  B2INFO("CDCJobCntlParModifier: propSpeedInputType modified: " << m_gcp.getPropSpeedInputType() << " to " << m_propSpeedInputType);
263  m_gcp.setPropSpeedInputType(m_propSpeedInputType);
264  }
265 
266  if (m_gcp.getT0InputType() != m_t0InputType) {
267  B2INFO("CDCJobCntlParModifier: t0InputType modified: " << m_gcp.getT0InputType() << " to " << m_t0InputType);
268  m_gcp.setT0InputType(m_t0InputType);
269  }
270 
271  if (m_gcp.getTwInputType() != m_twInputType) {
272  B2INFO("CDCJobCntlParModifier: twInputType modified: " << m_gcp.getTwInputType() << " to " << m_twInputType);
273  m_gcp.setTwInputType(m_twInputType);
274  }
275 
276  if (m_gcp.getBwInputType() != m_bwInputType) {
277  B2INFO("CDCJobCntlParModifier: bwInputType modified: " << m_gcp.getBwInputType() << " to " << m_bwInputType);
278  m_gcp.setBwInputType(m_bwInputType);
279  }
280 
281  if (m_gcp.getChMapInputType() != m_chMapInputType) {
282  B2INFO("CDCJobCntlParModifier: chMapInputType modified: " << m_gcp.getChMapInputType() << " to " << m_chMapInputType);
283  m_gcp.setChMapInputType(m_chMapInputType);
284  }
285 
286  if (m_gcp.getEDepToADCInputType() != m_eDepToADCInputType) {
287  B2INFO("CDCJobCntlParModifier: edep-to-adc modified: " << m_gcp.getEDepToADCInputType() << " to " << m_eDepToADCInputType);
288  m_gcp.setEDepToADCInputType(m_eDepToADCInputType);
289  }
290 
291  if (m_gcp.getDisplacementFile() != m_displacementFile) {
292  B2INFO("CDCJobCntlParModifier: displacementFile modified: " << m_gcp.getDisplacementFile() << " to " << m_displacementFile);
293  m_gcp.setDisplacementFile(m_displacementFile);
294  }
295 
296  if (m_gcp.getAlignmentFile() != m_alignmentFile) {
297  B2INFO("CDCJobCntlParModifier: alignmentFile modified: " << m_gcp.getAlignmentFile() << " to " << m_alignmentFile);
298  m_gcp.setAlignmentFile(m_alignmentFile);
299  }
300 
301  if (m_gcp.getMisalignmentFile() != m_misalignmentFile) {
302  B2INFO("CDCJobCntlParModifier: misalignmentFile modified: " << m_gcp.getMisalignmentFile() << " to " << m_misalignmentFile);
303  m_gcp.setMisalignmentFile(m_misalignmentFile);
304  }
305 
306  if (m_gcp.getXtFile() != m_xtFile) {
307  B2INFO("CDCJobCntlParModifier: xtFile modified: " << m_gcp.getXtFile() << " to " << m_xtFile);
308  m_gcp.setXtFile(m_xtFile);
309  }
310 
311  if (m_gcp.getSigmaFile() != m_sigmaFile) {
312  B2INFO("CDCJobCntlParModifier: sigmaFile modified: " << m_gcp.getSigmaFile() << " to " << m_sigmaFile);
313  m_gcp.setSigmaFile(m_sigmaFile);
314  }
315 
316  if (m_gcp.getPropSpeedFile() != m_propSpeedFile) {
317  B2INFO("CDCJobCntlParModifier: propSpeedFile modified: " << m_gcp.getPropSpeedFile() << " to " << m_propSpeedFile);
318  m_gcp.setPropSpeedFile(m_propSpeedFile);
319  }
320 
321  if (m_gcp.getT0File() != m_t0File) {
322  B2INFO("CDCJobCntlParModifier: t0File modified: " << m_gcp.getT0File() << " to " << m_t0File);
323  m_gcp.setT0File(m_t0File);
324  }
325 
326  if (m_gcp.getTwFile() != m_twFile) {
327  B2INFO("CDCJobCntlParModifier: timeWalkFile modified: " << m_gcp.getTwFile() << " to " << m_twFile);
328  m_gcp.setTwFile(m_twFile);
329  }
330 
331  if (m_gcp.getBwFile() != m_bwFile) {
332  B2INFO("CDCJobCntlParModifier: badWireFile modified: " << m_gcp.getBwFile() << " to " << m_bwFile);
333  m_gcp.setBwFile(m_bwFile);
334  }
335 
336  if (m_gcp.getChMapFile() != m_chMapFile) {
337  B2INFO("CDCJobCntlParModifier: chMapFile modified: " << m_gcp.getChMapFile() << " to " << m_chMapFile);
338  m_gcp.setChMapFile(m_chMapFile);
339  }
340 
341  if (m_gcp.getEDepToADCFile() != m_eDepToADCFile) {
342  B2INFO("CDCJobCntlParModifier: edep-to-adcFile modified: " << m_gcp.getEDepToADCFile() << " to " << m_eDepToADCFile);
343  m_gcp.setEDepToADCFile(m_eDepToADCFile);
344  }
345 
346  if (m_gcp.getMaxSpaceResolution() != m_maxSpaceResol) {
347  B2INFO("CDCJobCntlParModifier: maxSpaceResol modified: " << m_gcp.getMaxSpaceResolution() << " to " << m_maxSpaceResol);
348  m_gcp.setMaxSpaceResolution(m_maxSpaceResol);
349  }
350 
351  if (m_gcp.getAddFudgeFactorForSigmaForData() != m_addFudgeFactorForSigmaForData) {
352  B2INFO("CDCJobCntlParModifier: addFudgeFactorForSigmaForData modified: " << m_gcp.getAddFudgeFactorForSigmaForData() << " to "
353  << m_addFudgeFactorForSigmaForData);
354  m_gcp.setAddFudgeFactorForSigmaForData(m_addFudgeFactorForSigmaForData);
355  }
356 
357  if (m_gcp.getAddFudgeFactorForSigmaForMC() != m_addFudgeFactorForSigmaForMC) {
358  B2INFO("CDCJobCntlParModifier: addFudgeFactorForSigmaForMC modified: " << m_gcp.getAddFudgeFactorForSigmaForMC() << " to " <<
359  m_addFudgeFactorForSigmaForMC);
360  m_gcp.setAddFudgeFactorForSigmaForMC(m_addFudgeFactorForSigmaForMC);
361  }
362 
363  if (m_gcp.getMapperGeometry() != m_mapperGeometry) {
364  B2INFO("CDCJobCntlParModifier: mapper geometry flag modified: " << m_gcp.getMapperGeometry() << " to " << m_mapperGeometry);
365  m_gcp.setMapperGeometry(m_mapperGeometry);
366  }
367 
368  if (m_gcp.getMapperPhiAngle() != m_mapperPhiAngle) {
369  B2INFO("CDCJobCntlParModifier: mapper phi-angle modified: " << m_gcp.getMapperPhiAngle() << " to " << m_mapperPhiAngle);
370  m_gcp.setMapperPhiAngle(m_mapperPhiAngle);
371  }
372 }
373 
374 void CDCJobCntlParModifierModule::event()
375 {
376 }
Belle2::CDCJobCntlParModifierModule
The Class for Detailed Digitization of CDC.
Definition: CDCJobCntlParModifierModule.h:43
REG_MODULE
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:652
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::CDC::CDCSimControlPar
The Class for CDC Simulation Control Parameters.
Definition: CDCSimControlPar.h:31
Belle2::CDC::CDCGeoControlPar
The Class for CDC Geometry Control Parameters.
Definition: CDCGeoControlPar.h:33