lcsim/src/org/lcsim/digisim
diff -u -r1.14 -r1.15
--- DigiSimMain.java 17 Jan 2006 17:59:12 -0000 1.14
+++ DigiSimMain.java 18 Jan 2006 00:25:54 -0000 1.15
@@ -22,7 +22,7 @@
* The main driver for standalone digitization simulation
*
* @author Guilherme Lima
- * @version $Id: DigiSimMain.java,v 1.14 2006/01/17 17:59:12 lima Exp $
+ * @version $Id: DigiSimMain.java,v 1.15 2006/01/18 00:25:54 lima Exp $
*/
public class DigiSimMain extends Driver {
@@ -47,12 +47,10 @@
// instantiate all needed drivers
_hitmgr = new CalHitMapDriver();
+ _digi = new DigiSimDriver();
if( args.length>0 ) {
// Config file given in CL. Pass it to the driver
- _digi = new DigiSimDriver(args[0]);
- }
- else {
- _digi = new DigiSimDriver();
+ _digi.setSteeringFile(args[0]);
}
_calhit = new CalorimeterHitsDriver();
lcsim/src/org/lcsim/digisim
diff -u -r1.16 -r1.17
--- DigiSimDriver.java 17 Jan 2006 19:24:43 -0000 1.16
+++ DigiSimDriver.java 18 Jan 2006 00:25:54 -0000 1.17
@@ -16,34 +16,17 @@
* both parameters and events from the framework.
*
* @author Guilherme Lima
- * @version $Id: DigiSimDriver.java,v 1.16 2006/01/17 19:24:43 tonyj Exp $
+ * @version $Id: DigiSimDriver.java,v 1.17 2006/01/18 00:25:54 lima Exp $
*/
public class DigiSimDriver extends Driver implements ConditionsListener {
/**
- * Basic constructor
- * @param name A unique name, typically contains the corresponding
- * subdetector name as a substring.
-
+ * Basic constructor.
+ * By default, takes the steering file from the ConditionsManager
*/
- public DigiSimDriver(String name) {
- _name = "";
- _digitizers = new Vector<Digitizer>();
-
- // open released config file from lcsim.jar
-// _confReader = new ConfigReader(DigiSimDriver.class.getResourceAsStream(_name+".steer"));
- // user-provided config file (current dir or full path)
- _confReader = new ConfigReader(name);
- _useConditions = false;
- }
-
- /** By default, takes the steering file from the ConditionsManager */
public DigiSimDriver() {
// _name will store detector name at first process(evt) call
- _name = "";
-
_digitizers = new Vector<Digitizer>();
- _useConditions = true;
getConditionsManager().registerConditionsConverter(new DigiSimConditionsConverter());
}
@@ -56,13 +39,15 @@
// FIXME: This should be using conditions system
System.out.println("DigiSimDriver.init(): _name=<"+_name+">");
System.out.println("DigiSimDriver.init(): _file=<"+_file+">");
- if(_name.equals("")) return;
+ if(_name == null) return;
+
if (_file != null)
{
// open released config file from lcsim.jar
ConfigReader reader = new ConfigReader(_file);
- DigiSimSetup setup = reader.digiSimParse();
- calculateDerivedConditions(setup);
+ _setup = reader.digiSimParse();
+ reader.close();
+ calculateDerivedConditions(_setup);
}
else
{
@@ -72,21 +57,29 @@
_cachedConditions.addConditionsListener(this);
}
}
+
public void conditionsChanged(ConditionsEvent event)
{
- if (_file != null) calculateDerivedConditions(_cachedConditions.getCachedData());
- }
- private void calculateDerivedConditions(DigiSimSetup setup)
- {
- // read config file
- if(_useConditions) {
- // use conditions system
- setup = getConditionsManager().getCachedConditions(DigiSimSetup.class, "digisim/digisim.steer").getCachedData();
+ _name = null;
+ if(_file == null) {
+ calculateDerivedConditions( _cachedConditions.getCachedData() );
}
else {
- // use user-provided steering file
- setup = _confReader.digiSimParse();
+ // keep user-provided steering file conditions, but
+ // update digisim config for a new detector geometry
+ calculateDerivedConditions( _setup );
}
+ }
+
+ private void calculateDerivedConditions(DigiSimSetup setup)
+ {
+ System.out.println("DSDriver.calculateDerivedConds: name="+_name+", file="+_file);
+
+// // read config file
+// if(_file==null) {
+// // use conditions system
+// setup = getConditionsManager().getCachedConditions(DigiSimSetup.class, "digisim/digisim.steer").getCachedData();
+// }
Map<String,Vector<String>> sections = setup.getSections();
// find digitizers to be instantiated
@@ -102,10 +95,10 @@
}
}
- _digitizers.clear();
// Instantiate subdetector digitizers. All active names will
// be called, but only the ones compatible with being a
// digitizer will be actually used
+ _digitizers.clear();
for( String digiName : active ) {
Vector<String> configSection = sections.get(digiName);
@@ -125,14 +118,14 @@
}
} // end loop for instantiating subdetector digitizers
- // set debuggin state in digitizers, as per user request
+ // set debugging state in digitizers, as per user request
setDigitizersDebugState();
}
-
+
/** Called for every event - the event loop */
protected void process( EventHeader event ) {
- if(_name.equals("")) {
+ if(_name==null) {
_name = event.getDetectorName();
System.out.println("Detector name: <"+_name+">");
this.init();
@@ -171,20 +164,23 @@
}
}
}
- /** Set the name of the steering file to use. This should be the full path
- * to the steering file. If set to null (the default) the steering file will
- * be read from the conditions system based on the current detector.
+
+ /** Set the name of the steering file to use. This should be the
+ * full path to the steering file. If set to null (the default)
+ * the steering file will be read from the conditions system based
+ * on the current detector.
*/
- public void setSteeringFile(String name)
+ public void setSteeringFile(String file)
{
- _file = name;
- // Fixme: I am not sure if calling init more than once will work.
- init();
+ if( file==null || file=="" ) _file = null;
+ else _file = file;
+ // _name="" will flag call to init() when next event is available
+ _name = null;
}
public String getSteeringFile()
{
- return _file;
+ return _file;
}
// *** FIELDS ***
@@ -192,7 +188,7 @@
/** Event number */
private int _nEvt ;
/** Name of this DigiSimDriver object */
- private String _name;
+ private String _name = null;
/** Name of steering file to read (null means use conditions manager) */
private String _file;
/** modifiers */
@@ -203,7 +199,8 @@
private Map<String,Integer> _debugMap = new HashMap<String,Integer>();
private boolean _useConditions = true;
- private ConfigReader _confReader = null;
+// private ConfigReader _confReader = null;
+ private DigiSimSetup _setup = null;
// static registration globals
private static boolean _gaindisc = GainDiscrimination.registerMe();