lcsim/src/org/lcsim/digisim
diff -u -r1.3 -r1.4
--- Digitizer.java 25 May 2005 17:50:22 -0000 1.3
+++ Digitizer.java 27 Jun 2005 22:03:58 -0000 1.4
@@ -15,12 +15,15 @@
import org.lcsim.digisim.MyRawCalorimeterHit;
import org.lcsim.digisim.MyLCRelation;
+import org.lcsim.util.aida.AIDA;
+import hep.aida.ICloud1D;
+
/**
* A subdetector digitizer. This class manages the digitization
* simulation process for a specific subdetector.
*
* @author Guilherme Lima
- * @version $Id: Digitizer.java,v 1.3 2005/05/25 17:50:22 lima Exp $
+ * @version $Id: Digitizer.java,v 1.4 2005/06/27 22:03:58 lima Exp $
*/
class Digitizer {
@@ -93,7 +96,7 @@
// create a raw hit for each temp hit
long id = chanID.longValue();
- MyRawCalorimeterHit rawhit = new MyRawCalorimeterHit(id,adc,time);
+ RawCalorimeterHit rawhit = new MyRawCalorimeterHit(id,adc,time);
rawVec.add( rawhit );
// System.out.println(" rawhit:"+ rawhit.getCellID()
@@ -113,14 +116,12 @@
for(int i=0; i<ids.size(); ++i) {
// fetch each sim hit
Long simid = ids.get(i);
- SimCalorimeterHit ihit = simHits.get(simid);
+ SimCalorimeterHit simhit = simHits.get(simid);
// calculate weight
double weight = energies.get(i) / etot;
// create a LCRelation object
- LCRelation prel = new MyLCRelation( (RawCalorimeterHit)rawhit,
- (SimCalorimeterHit)ihit,
- (float)weight );
+ LCRelation prel = new MyLCRelation( rawhit, simhit, (float)weight );
// debug
// cout<<"a relation: weight="<< prel.getWeight() <<" "<< weight << endl;
@@ -183,8 +184,9 @@
public void init(Vector<String> config) {
// System.out.println("*** Initializing digitizer "+_name);
// This vector stores the parameters for each valid modifier
- Vector<ModifierParameters> modifParams= new Vector<ModifierParameters>();
Vector<String> modifRequested = new Vector<String>();
+ Vector<ModifierParameters> modifParams= new Vector<ModifierParameters>();
+
for(String line : config) {
String[] tokens = line.split("[ ]");
@@ -223,11 +225,14 @@
// You have been warned!!
for( String itypeName
: AbstractCalHitModifier._modifiersAvailable.keySet() ) {
+
AbstractCalHitModifier pmod;
pmod=AbstractCalHitModifier._modifiersAvailable.get(itypeName);
if( pmod.getType().toString().equals(typename) ) {
+ // create config stuff for this modifier
ModifierParameters parms;
parms = new ModifierParameters(name, pmod.getType(), pars);
+ // and save it
modifParams.add( parms );
}
} // end loop over availability modifiers
@@ -236,19 +241,23 @@
} // end loop over config lines
// Make sure all requested modifiers were found
+ Vector<ModifierParameters> orderedModifs
+ = new Vector<ModifierParameters>();
for( String modreq : modifRequested ) {
boolean found = false;
for( ModifierParameters modcfg : modifParams ) {
if( modcfg.getName().equals(modreq) ) {
found = true;
+ orderedModifs.add(modcfg);
break;
}
}
if(!found) throw new RuntimeException("Configuration error: requested modifier "+modreq+" not configured properly.\n Please check your DigiSim configuration file.");
+ // trouble? Check if modifier has been registered in DigiSimMain
}
// At this point we should have everything we need!
- initialize(modifParams);
+ initialize(orderedModifs);
}
/**
@@ -361,6 +370,8 @@
/** Called for every event - the event loop */
public void process( EventHeader evt ) {
++_nEvt;
+ double lntolog10 = 1/Math.log(10);
+
String detName = evt.getDetectorName();
// _det = null;
@@ -379,8 +390,14 @@
Map<Long,TempCalHit> tmpHits = createTempHits( hits );
//*** Call processHits method for each modifier
+ AIDA aida = AIDA.defaultInstance();
for( CalHitModifier modifier : _modifs ) {
modifier.processHits( tmpHits );
+ ICloud1D cloud = aida.cloud1D(((AbstractCalHitModifier)modifier).getName());
+ for( long cellid : tmpHits.keySet() ) {
+ TempCalHit hit = tmpHits.get(cellid);
+ cloud.fill( Math.log(hit.getTotalEnergy())*lntolog10 );
+ }
}
// create output collections and append them to the LCEvent