clean up ECal classes, start organizing steering files, make a huge mess
diff -u -r1.13 -r1.14 --- ecal_fadc_bkgd.lcsim 20 Nov 2012 23:32:22 -0000 1.13 +++ ecal_fadc_bkgd.lcsim 25 Feb 2013 22:39:24 -0000 1.14 @@ -1,7 +1,7 @@
<!-- Example LCSim steering file to run trigger rate studies @author Sho Uemura <[log in to unmask]>
- @version $Id: ecal_fadc_bkgd.lcsim,v 1.13 2012/11/20 23:32:22 meeg Exp $
+ @version $Id: ecal_fadc_bkgd.lcsim,v 1.14 2013/02/25 22:39:24 meeg Exp $
--> <lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd">
@@ -9,7 +9,7 @@
<printInputFiles>true</printInputFiles> </control> <execute>
- <driver name="HPSCalibrationDriver"/>
+ <driver name="CalibrationDriver"/>
<driver name="EventMarkerDriver"/> <driver name="EcalReadout"/> <driver name="EcalConverter"/>
@@ -24,13 +24,13 @@
<driver name="ClockDriver"/> </execute> <drivers>
- <driver name="HPSCalibrationDriver" type="org.lcsim.hps.monitoring.HPSCalibrationDriver"/>
+ <driver name="CalibrationDriver" type="org.lcsim.hps.monitoring.CalibrationDriver"/>
<driver name="Writer" type="org.lcsim.util.loop.LCIODriver"> <outputFilePath>${outputFile}_ecalClusters</outputFilePath> </driver> <driver name="EcalReadout"
- type="org.lcsim.hps.recon.ecal.HPSEcalFADCReadoutDriver">
+ type="org.lcsim.hps.readout.ecal.FADCEcalReadoutDriver">
<readoutPeriod>4.0</readoutPeriod> <coincidenceWindow>2</coincidenceWindow> <ecalName>Ecal</ecalName>
@@ -48,12 +48,12 @@
<gain>0.15</gain> </driver> <driver name="EcalClusterer"
- type="org.lcsim.hps.recon.ecal.HPSEcalCTPClusterer">
+ type="org.lcsim.hps.recon.ecal.CTPEcalClusterer">
<ecalName>Ecal</ecalName> <ecalCollectionName>EcalCorrectedHits</ecalCollectionName> </driver> <driver name="EcalTrigger"
- type="org.lcsim.hps.recon.ecal.HPSFADCTriggerDriver">
+ type="org.lcsim.hps.readout.ecal.FADCTriggerDriver">
<clusterCollectionName>EcalClusters</clusterCollectionName> <outputFileName>${outputFile}.triggers</outputFileName> <deadTime>10</deadTime>
diff -u -r1.5 -r1.6 --- OfflineTrackingAxial.lcsim 26 Nov 2012 18:12:36 -0000 1.5 +++ OfflineTrackingAxial.lcsim 25 Feb 2013 22:39:24 -0000 1.6 @@ -44,7 +44,6 @@
<driver name="SVTHitRecoPlots" type="org.lcsim.hps.monitoring.svt.SVTHitReconstructionPlots">
- <rawTrackerHitCollectionName>SVTRawTrackerHits</rawTrackerHitCollectionName>
<fittedTrackerHitCollectionName>SVTFittedRawTrackerHits</fittedTrackerHitCollectionName> <outputPlots>svtHitRecoPlots.aida</outputPlots> </driver>
diff -u -r1.2 -r1.3 --- raw_triggers.lcsim 27 Aug 2012 22:42:19 -0000 1.2 +++ raw_triggers.lcsim 25 Feb 2013 22:39:24 -0000 1.3 @@ -1,20 +1,13 @@
<!-- steering file used for PAC 39 analysis @author Sho Uemura <[log in to unmask]>
- @version $Id: raw_triggers.lcsim,v 1.2 2012/08/27 22:42:19 meeg Exp $
+ @version $Id: raw_triggers.lcsim,v 1.3 2013/02/25 22:39:24 meeg Exp $
--> <lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd">
- <inputFiles> - <file>${inputFile}</file> - </inputFiles>
<control>
- <numberOfEvents>-1</numberOfEvents>
<printInputFiles>true</printInputFiles> </control>
- <classpath> - <jar>~/.m2/repository/org/lcsim/hps-java/1.0-SNAPSHOT/hps-java-1.0-SNAPSHOT.jar</jar> - </classpath>
<execute> <!-- <driver name="HPSCalibrationDriver"/> --> <!-- <driver name="EventMarkerDriver"/>-->
@@ -33,7 +26,7 @@
<addEMin>0.075</addEMin> </driver> <driver name="EcalTrigger"
- type="org.lcsim.hps.recon.ecal.TestRunRateAnalysis">
+ type="org.lcsim.hps.analysis.ecal.TestRunRateAnalysis">
<clusterCollectionName>EcalClusters</clusterCollectionName> <clusterEnergyLow>0.6</clusterEnergyLow> </driver>
diff -u -r1.16 -r1.17 --- OnlineTracking.lcsim 26 Nov 2012 18:12:36 -0000 1.16 +++ OnlineTracking.lcsim 25 Feb 2013 22:39:24 -0000 1.17 @@ -55,7 +55,6 @@
<driver name="SVTHitRecoPlots" type="org.lcsim.hps.monitoring.svt.SVTHitReconstructionPlots">
- <rawTrackerHitCollectionName>SVTRawTrackerHits</rawTrackerHitCollectionName>
<fittedTrackerHitCollectionName>SVTFittedRawTrackerHits</fittedTrackerHitCollectionName> <outputPlots>svtHitRecoPlots.aida</outputPlots> </driver>
diff -N HPS2014ReadoutToEvio.lcsim --- HPS2014ReadoutToEvio.lcsim 20 Dec 2012 08:31:34 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,97 +0,0 @@
-<!-- - Execute full trigger+readout simulation and write the results as an EVIO file. - @author Sho Uemura <[log in to unmask]> - @version $Id: HPS2014ReadoutToEvio.lcsim,v 1.4 2012/12/20 08:31:34 omoreno Exp $ ---> -<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" - xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> - <execute> - <driver name="EventMarkerDriver"/> - - <driver name="HPSCalibrationDriver"/> - <driver name="EcalReadout"/> - <driver name="EcalConverter"/> - <driver name="EcalClusterer"/> - <driver name="EcalTrigger"/> - -<!-- <driver name="SimpleSVTReadout"/>--> - - <driver name="SVTReadout"/> - <driver name="Digitization"/> - <driver name="DataProcessing"/> - <driver name="TestRunReconToEvio"/> - - <driver name="ClockDriver"/> - <driver name="CleanupDriver"/> - </execute> - - <drivers> - <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> - <eventInterval>1000</eventInterval> - </driver> - <driver name="HPSCalibrationDriver" type="org.lcsim.hps.monitoring.HPSCalibrationDriver"> -<!-- <runNumber>1351</runNumber> --> - </driver> - <driver name="TestRunReconToEvio" type="org.lcsim.hps.evio.TestRunTriggeredReconToEvio"> - <evioOutputFile>${outputFile}</evioOutputFile> - </driver> - - <driver name="EcalReadout" type="org.lcsim.hps.recon.ecal.HPSEcalFADCReadoutDriver"> - <readoutPeriod>4.0</readoutPeriod> - <coincidenceWindow>2</coincidenceWindow> - <ecalName>Ecal</ecalName> - <ecalCollectionName>EcalHits</ecalCollectionName> - <ecalRawCollectionName>EcalRawHits</ecalRawCollectionName> - <triggerThreshold>50</triggerThreshold> - <readoutThreshold>50</readoutThreshold> - <constantTriggerWindow>true</constantTriggerWindow> - <scaleFactor>1</scaleFactor> - <fixedGain>0.15</fixedGain> -<!-- <debug>true</debug>--> - </driver> - - <driver name="EcalConverter" type="org.lcsim.hps.recon.ecal.HPSEcalRawConverterDriver"> - <rawCollectionName>EcalRawHits</rawCollectionName> - <ecalCollectionName>EcalCorrectedHits</ecalCollectionName> - <gain>0.15</gain> - <applyBadCrystalMap>false</applyBadCrystalMap> -<!-- <debug>true</debug>--> - </driver> - - <driver name="EcalClusterer" type="org.lcsim.hps.recon.ecal.HPSEcalCTPClusterer"> - <ecalName>Ecal</ecalName> - <clusterWindow>32.0</clusterWindow> - <ecalCollectionName>EcalCorrectedHits</ecalCollectionName> - </driver> - - <driver name="EcalTrigger" type="org.lcsim.hps.recon.ecal.HPSFADCTriggerDriver"> - <clusterCollectionName>EcalClusters</clusterCollectionName> - <deadTime>10</deadTime> - <outputFileName>${outputFile}.triggers</outputFileName> - </driver> - <driver name="SimpleSVTReadout" type="org.lcsim.hps.recon.tracking.SimpleSvtReadout"> - </driver> - - <driver name="SVTReadout" type="org.lcsim.hps.recon.tracking.apv25.SvtReadout"> - <debug>false</debug> - <pedestalRun>false</pedestalRun> - <triggerLatencyTime>240</triggerLatencyTime> - </driver> - - <driver name="Digitization" type="org.lcsim.hps.recon.tracking.RearTransitionModule" /> - - <driver name="DataProcessing" type="org.lcsim.hps.recon.tracking.TestRunDataProcessingModule" > - <enablePileUpCut>true</enablePileUpCut> - <enableThresholdCut>true</enableThresholdCut> - <noiseThreshold>2</noiseThreshold> - <numberOfSamplesAboveThreshold>3</numberOfSamplesAboveThreshold> - <numberOfSamplesToReadOut>6</numberOfSamplesToReadOut> - </driver> - - <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"/> - <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver"> - <collectionNames>TrackerHits</collectionNames> - </driver> - </drivers> -</lcsim> -
diff -N HPSTestRunPairTrigger.lcsim --- HPSTestRunPairTrigger.lcsim 25 Nov 2012 21:57:42 -0000 1.5 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,75 +0,0 @@
- -<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" - xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> - <inputFiles> - <!--<fileRegExp baseDir="./../data/mc/Reach-2pt2" >.*gev60.*</fileRegExp>--> -<!-- <fileRegExp baseDir="./../data/mc/Reach-2pt2" >.*gev100.*</fileRegExp>--> - </inputFiles> - <control> -<!-- <numberOfEvents>10000</numberOfEvents>--> - <printInputFiles>true</printInputFiles> - <printDriversDetailed>true</printDriversDetailed> - </control> - <execute> - <driver name="EventMarkerDriver"/> - <driver name="HPSCalibrationDriver"/> - <driver name="EcalRawConverter"/> -<!-- <driver name="HPSEcalRawConverterDriver"/> --> -<!-- <driver name="EcalTriggerFilter"/> --> - <driver name="EcalTriggerClusterer"/> -<!-- <driver name="SimpleSVTReadout"/> --> - <driver name="EcalTrigger"/> - <driver name="ClockDriver"/> -<!-- <driver name="MCParticlePlots"/>--> -<!-- <driver name="TriggerTurnOnAnalysis"/>--> - - </execute> - <drivers> - <driver name="HPSCalibrationDriver" type="org.lcsim.hps.monitoring.HPSCalibrationDriver"> - </driver> - <driver name="EcalRawConverter" type="org.lcsim.hps.recon.ecal.HPSEcalEdepToTriggerConverterDriver"> - <readoutCollection>EcalReadoutAnalogHits</readoutCollection> - <applyBadCrystalMap>false</applyBadCrystalMap> - <truncateScale>1</truncateScale> - <constantGain>0.15</constantGain> - </driver> -<!-- <driver name="HPSEcalRawConverterDriver" type="org.lcsim.hps.recon.ecal.HPSEcalRawConverterDriver"> - <runBackwards>true</runBackwards> - <rawCollectionName>EcalReadoutHits</rawCollectionName> - <ecalCollectionName>EcalReadoutAnalogHits</ecalCollectionName> - </driver>--> -<!-- <driver name="EcalTriggerFilter" type="org.lcsim.hps.recon.ecal.HPSEcalTriggerFilterDriver"> - <inputCollection>EcalTriggerHits</inputCollection> - <outputCollection>EcalFilteredHits</outputCollection> - </driver>--> - <driver name="EcalTriggerClusterer" type="org.lcsim.hps.recon.ecal.HPSEcalCTPClusterer"> - <ecalName>Ecal</ecalName> - <ecalCollectionName>EcalReadoutAnalogHits</ecalCollectionName> -<!-- <ecalCollectionName>EcalFilteredHits</ecalCollectionName>--> - <clusterCollectionName>EcalTriggerClusters</clusterCollectionName> - </driver> -<!-- <driver name="EcalTrigger" type="org.lcsim.hps.recon.ecal.TestRunTriggerDriver">--> - <driver name="EcalTrigger" type="org.lcsim.hps.recon.ecal.HPSFADCTriggerDriver"> - <!--<driver name="EcalTrigger" type="org.lcsim.hps.recon.ecal.HPSFADCSingleTriggerDriver">--> - <clusterCollectionName>EcalTriggerClusters</clusterCollectionName> - <outputFileName>${outputFile}.triggers</outputFileName> - <deadTime>0</deadTime> - <!--<lcioFile>${outputFile}</lcioFile>--> - </driver> - <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> - <eventInterval>1000</eventInterval> - </driver> - - <driver name="SimpleSVTReadout" type="org.lcsim.hps.recon.tracking.SimpleSvtReadout"> - <noPileup>true</noPileup> - </driver> - <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"/> - <driver name="MCParticlePlots" type="org.lcsim.hps.analysis.ecal.HPSMCParticlePlotsDriver"> - <hideFrame>true</hideFrame> - </driver> - <driver name="TriggerTurnOnAnalysis" type="org.lcsim.hps.users.phansson.TriggerTurnOnAnalysis"> - <aidaFileName>${outputFile}</aidaFileName> - <hideFrame>true</hideFrame> - </driver> - </drivers> -</lcsim>
diff -N HPSTestRunReconToLcio.lcsim --- HPSTestRunReconToLcio.lcsim 18 Dec 2012 23:49:29 -0000 1.11 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,91 +0,0 @@
-<!-- - Execute test run full recon and write the results as an LCIO file. ---> -<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" - xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> - <execute> -<!-- <driver name="EventMarkerDriver"/>--> - <driver name="HPSCalibrationDriver"/> - <driver name="EcalReadout"/> - <driver name="EcalConverter"/> - <driver name="EcalTriggerFilter"/> - <driver name="EcalClusterer"/> - <driver name="EcalTrigger"/> -<!-- <driver name="SimpleSVTReadout"/>--> - <driver name="SVTReadout"/> - <driver name="Digitization"/> - <driver name="DataProcessing"/> - <driver name="ClockDriver"/> - <driver name="TestRunReconToLcio"/> - <driver name="CleanupDriver"/> - </execute> - - <drivers> -<!-- <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> - <eventInterval>1</eventInterval> - </driver> --> - <driver name="HPSCalibrationDriver" type="org.lcsim.hps.monitoring.HPSCalibrationDriver"> -<!-- <runNumber>1351</runNumber> --> - </driver> - <driver name="TestRunReconToLcio" type="org.lcsim.hps.evio.TestRunTriggeredReconToLcio"> - <outputFile>${outputFile}</outputFile> - </driver> - - <driver name="EcalReadout" type="org.lcsim.hps.recon.ecal.HPSEcalFADCReadoutDriver"> - <readoutPeriod>4.0</readoutPeriod> - <coincidenceWindow>2</coincidenceWindow> - <ecalName>Ecal</ecalName> - <ecalCollectionName>EcalHits</ecalCollectionName> - <ecalRawCollectionName>EcalRawHits</ecalRawCollectionName> - <triggerThreshold>80</triggerThreshold> - <readoutThreshold>50</readoutThreshold> - </driver> - - <driver name="EcalConverter" type="org.lcsim.hps.recon.ecal.HPSEcalConverterDriver"> - <rawCollectionName>EcalRawHits</rawCollectionName> - <ecalCollectionName>EcalCorrectedHits</ecalCollectionName> - <scale>1</scale> - </driver> - - <driver name="EcalTriggerFilter" type="org.lcsim.hps.recon.ecal.HPSEcalTriggerFilterDriver"> - <inputCollection>EcalCorrectedHits</inputCollection> - <outputCollection>EcalFilteredHits</outputCollection> - </driver> - - <driver name="EcalClusterer" type="org.lcsim.hps.recon.ecal.HPSEcalCTPClusterer"> - <ecalName>Ecal</ecalName> - <clusterWindow>32.0</clusterWindow> - <ecalCollectionName>EcalFilteredHits</ecalCollectionName> - </driver> - - <driver name="EcalTrigger" type="org.lcsim.hps.recon.ecal.TestRunTriggerDriver"> - <clusterCollectionName>EcalClusters</clusterCollectionName> - <deadTime>10</deadTime> - <outputFileName>${outputFile}.triggers</outputFileName> - </driver> - <driver name="SimpleSVTReadout" type="org.lcsim.hps.recon.tracking.SimpleSvtReadout"> - </driver> - - <driver name="SVTReadout" type="org.lcsim.hps.recon.tracking.apv25.SvtReadout"> - <debug>false</debug> - <pedestalRun>false</pedestalRun> - <triggerLatencyTime>288</triggerLatencyTime> - </driver> - - <driver name="Digitization" type="org.lcsim.hps.recon.tracking.RearTransitionModule" /> - - <driver name="DataProcessing" type="org.lcsim.hps.recon.tracking.TestRunDataProcessingModule" > - <enablePileUpCut>true</enablePileUpCut> - <enableThresholdCut>true</enableThresholdCut> - <noiseThreshold>2</noiseThreshold> - <numberOfSamplesAboveThreshold>3</numberOfSamplesAboveThreshold> - <numberOfSamplesToReadOut>6</numberOfSamplesToReadOut> - </driver> - - <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"/> - <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver"> - <collectionNames>TrackerHits</collectionNames> - </driver> - </drivers> -</lcsim> -
diff -N HPSTestRunReconToEvio.lcsim --- HPSTestRunReconToEvio.lcsim 18 Dec 2012 23:49:29 -0000 1.20 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,91 +0,0 @@
-<!-- - Execute test run full recon and write the results as an EVIO file. ---> -<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" - xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> - <execute> -<!-- <driver name="EventMarkerDriver"/>--> - <driver name="HPSCalibrationDriver"/> - <driver name="EcalReadout"/> - <driver name="EcalConverter"/> - <driver name="EcalTriggerFilter"/> - <driver name="EcalClusterer"/> - <driver name="EcalTrigger"/> -<!-- <driver name="SimpleSVTReadout"/>--> - <driver name="SVTReadout"/> - <driver name="Digitization"/> - <driver name="DataProcessing"/> - <driver name="ClockDriver"/> - <driver name="TestRunReconToEvio"/> - <driver name="CleanupDriver"/> - </execute> - - <drivers> - <!--<driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> - <eventInterval>1</eventInterval> - </driver> --> - <driver name="HPSCalibrationDriver" type="org.lcsim.hps.monitoring.HPSCalibrationDriver"> -<!-- <runNumber>1351</runNumber> --> - </driver> - <driver name="TestRunReconToEvio" type="org.lcsim.hps.evio.TestRunTriggeredReconToEvio"> - <evioOutputFile>${evioFile}</evioOutputFile> - </driver> - - <driver name="EcalReadout" type="org.lcsim.hps.recon.ecal.HPSEcalFADCReadoutDriver"> - <readoutPeriod>4.0</readoutPeriod> - <coincidenceWindow>2</coincidenceWindow> - <ecalName>Ecal</ecalName> - <ecalCollectionName>EcalHits</ecalCollectionName> - <ecalRawCollectionName>EcalRawHits</ecalRawCollectionName> - <triggerThreshold>80</triggerThreshold> - <readoutThreshold>50</readoutThreshold> - </driver> - - <driver name="EcalConverter" type="org.lcsim.hps.recon.ecal.HPSEcalConverterDriver"> - <rawCollectionName>EcalRawHits</rawCollectionName> - <ecalCollectionName>EcalCorrectedHits</ecalCollectionName> - <scale>1</scale> - </driver> - - <driver name="EcalTriggerFilter" type="org.lcsim.hps.recon.ecal.HPSEcalTriggerFilterDriver"> - <inputCollection>EcalCorrectedHits</inputCollection> - <outputCollection>EcalFilteredHits</outputCollection> - </driver> - - <driver name="EcalClusterer" type="org.lcsim.hps.recon.ecal.HPSEcalCTPClusterer"> - <ecalName>Ecal</ecalName> - <clusterWindow>32.0</clusterWindow> - <ecalCollectionName>EcalFilteredHits</ecalCollectionName> - </driver> - - <driver name="EcalTrigger" type="org.lcsim.hps.recon.ecal.TestRunTriggerDriver"> - <clusterCollectionName>EcalClusters</clusterCollectionName> - <deadTime>10</deadTime> - <outputFileName>${evioFile}.triggers</outputFileName> - </driver> - <driver name="SimpleSVTReadout" type="org.lcsim.hps.recon.tracking.SimpleSvtReadout"> - </driver> - - <driver name="SVTReadout" type="org.lcsim.hps.recon.tracking.apv25.SvtReadout"> - <debug>false</debug> - <pedestalRun>false</pedestalRun> - <triggerLatencyTime>288</triggerLatencyTime> - </driver> - - <driver name="Digitization" type="org.lcsim.hps.recon.tracking.RearTransitionModule" /> - - <driver name="DataProcessing" type="org.lcsim.hps.recon.tracking.TestRunDataProcessingModule" > - <enablePileUpCut>true</enablePileUpCut> - <enableThresholdCut>true</enableThresholdCut> - <noiseThreshold>2</noiseThreshold> - <numberOfSamplesAboveThreshold>3</numberOfSamplesAboveThreshold> - <numberOfSamplesToReadOut>6</numberOfSamplesToReadOut> - </driver> - - <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"/> - <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver"> - <collectionNames>TrackerHits</collectionNames> - </driver> - </drivers> -</lcsim> -
diff -N HPSTestRunLcioToEvio.lcsim --- HPSTestRunLcioToEvio.lcsim 31 Aug 2012 01:30:47 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,24 +0,0 @@
-<!-- - Convert LCIO file to EVIO file. ---> -<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" - xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> - <execute> - <driver name="DummyTrigger"/> - <driver name="TestRunReconToEvio"/> - <driver name="ClockDriver"/> - </execute> - - <drivers> - <driver name="DummyTrigger" type="org.lcsim.hps.recon.ecal.HPSDummyTriggerDriver"> - <period>1</period> - <deadTime>0</deadTime> - </driver> - <driver name="TestRunReconToEvio" type="org.lcsim.hps.evio.TestRunTriggeredReconToEvio"> - <evioOutputFile>${evioFile}</evioOutputFile> - </driver> - <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"> - </driver> - </drivers> -</lcsim> -
diff -N HpsTestRunSim.lcsim --- HpsTestRunSim.lcsim 18 Dec 2012 23:49:29 -0000 1.5 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,126 +0,0 @@
- -<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> - - <inputFiles> - <file>${inputFile}</file> - </inputFiles> - - <control> - <printInputFiles>true</printInputFiles> - <printDriversDetailed>true</printDriversDetailed> - </control> - - <execute> - <driver name="HPSCalibrations" /> - <driver name="EventMarkerDriver" /> - <!-- Ecal --> - <driver name="EcalReadout" /> - <driver name="EcalConverter" /> - <driver name="EcalTriggerFilter"/> - <driver name="EcalClusterer" /> - <driver name="EcalTrigger" /> - <!-- SVT --> - <driver name="SVTReadout" /> - <driver name="Digitization" /> - <driver name="DataProcessing" /> - <!-- Recon --> - <driver name="RawTrackerHitFitterDriver" /> - <driver name="TrackerHitDriver" /> - <driver name="HelicalTrackHitDriver" /> - <driver name="TrackerReconDriver" /> - <driver name="ClockDriver" /> - <driver name="CleanupDriver" /> - </execute> - - <drivers> - - <driver name="HPSCalibrations" type="org.lcsim.hps.monitoring.HPSCalibrationDriver"> - <runNumber>1351</runNumber> - </driver> - - <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> - <eventInterval>1000</eventInterval> - </driver> - - <driver name="EcalReadout" type="org.lcsim.hps.recon.ecal.HPSEcalFADCReadoutDriver"> - <readoutPeriod>4.0</readoutPeriod> - <coincidenceWindow>2</coincidenceWindow> - <ecalName>Ecal</ecalName> - <ecalCollectionName>EcalHits</ecalCollectionName> - <ecalRawCollectionName>EcalRawHits</ecalRawCollectionName> - <triggerThreshold>80</triggerThreshold> - <readoutThreshold>50</readoutThreshold> - </driver> - - <driver name="EcalConverter" type="org.lcsim.hps.recon.ecal.HPSEcalConverterDriver"> - <rawCollectionName>EcalRawHits</rawCollectionName> - <ecalCollectionName>EcalCorrectedHits</ecalCollectionName> - <scale>1</scale> - </driver> - - <driver name="EcalTriggerFilter" type="org.lcsim.hps.recon.ecal.HPSEcalTriggerFilterDriver"> - <inputCollection>EcalCorrectedHits</inputCollection> - <outputCollection>EcalFilteredHits</outputCollection> - </driver> - - <driver name="EcalClusterer" - type="org.lcsim.hps.recon.ecal.HPSEcalCTPClusterer"> - <ecalName>Ecal</ecalName> - <ecalCollectionName>EcalFilteredHits</ecalCollectionName> - </driver> - - <driver name="EcalTrigger" type="org.lcsim.hps.recon.ecal.TestRunTriggerDriver"> - <clusterCollectionName>EcalClusters</clusterCollectionName> - <deadTime>10</deadTime> - </driver> - - <driver name="SVTReadout" type="org.lcsim.hps.recon.tracking.apv25.SvtReadout"> - <debug>false</debug> - <pedestalRun>false</pedestalRun> - <triggerLatencyTime>288</triggerLatencyTime> - </driver> - - <driver name="Digitization" type="org.lcsim.hps.recon.tracking.RearTransitionModule" /> - - <driver name="DataProcessing" type="org.lcsim.hps.recon.tracking.TestRunDataProcessingModule" > - <enablePileUpCut>true</enablePileUpCut> - <enableThresholdCut>true</enableThresholdCut> - <noiseThreshold>2</noiseThreshold> - <numberOfSamplesAboveThreshold>3</numberOfSamplesAboveThreshold> - <numberOfSamplesToReadOut>6</numberOfSamplesToReadOut> - </driver> - - - <driver name="RawTrackerHitFitterDriver" type="org.lcsim.hps.recon.tracking.HPSRawTrackerHitFitterDriver"> - <debug>false</debug> - <rawHitCollectionName>SVTRawTrackerHits</rawHitCollectionName> - <fittedHitCollectionName>SVTFittedRawTrackerHits</fittedHitCollectionName> - <fitAlgorithm>Analytic</fitAlgorithm> - </driver> - - - <driver name="TrackerHitDriver" type="org.lcsim.hps.users.mgraham.DataTrackerHitDriver" > - <debug>false</debug> - </driver> - - <driver name="HelicalTrackHitDriver" - type="org.lcsim.hps.recon.tracking.HelicalTrackHitDriver"> - <debug>false</debug> - <layerGeometryType>Common</layerGeometryType> - <maxSeperation>20.0</maxSeperation> - <tolerance>1.0</tolerance> - </driver> - - <driver name="TrackerReconDriver" type="org.lcsim.hps.recon.tracking.TrackerReconDriver"> - <debug>false</debug> - <strategyResource> </strategyResource> - </driver> - - <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver" /> - - <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver"> - <collectionNames>TrackerHits SVTRawTrackerHits SVTFittedRawTrackerHits</collectionNames> - </driver> - - </drivers> -</lcsim>
diff -N HPS2014ReadoutNoPileup.lcsim --- HPS2014ReadoutNoPileup.lcsim 21 Nov 2012 00:50:08 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,56 +0,0 @@
-<!-- - Execute trigger+readout simulation without pileup (event by event) and write the results as an LCIO file. - @author Sho Uemura <[log in to unmask]> - @version $Id: HPS2014ReadoutNoPileup.lcsim,v 1.1 2012/11/21 00:50:08 meeg Exp $ ---> -<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" - xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> - <control> - <printInputFiles>true</printInputFiles> - <printDriversDetailed>true</printDriversDetailed> - </control> - <execute> - <driver name="EventMarkerDriver"/> - <driver name="HPSCalibrationDriver"/> - <driver name="EcalEdepToTriggerConverterDriver"/> - <driver name="HPSEcalReadoutConverterDriver"/> - <driver name="EcalTriggerClusterer"/> - <driver name="SimpleSVTReadout"/> - <driver name="EcalTrigger"/> - <driver name="ClockDriver"/> - </execute> - <drivers> - <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> - <eventInterval>1000</eventInterval> - </driver> - <driver name="HPSCalibrationDriver" type="org.lcsim.hps.monitoring.HPSCalibrationDriver"> - </driver> - <driver name="EcalEdepToTriggerConverterDriver" type="org.lcsim.hps.recon.ecal.HPSEcalEdepToTriggerConverterDriver"> - <readoutCollection>EcalReadoutAnalogHits</readoutCollection> - <applyBadCrystalMap>false</applyBadCrystalMap> - <truncateScale>1</truncateScale> - <constantGain>0.15</constantGain> - </driver> - <driver name="HPSEcalReadoutConverterDriver" type="org.lcsim.hps.recon.ecal.HPSEcalRawConverterDriver"> - <runBackwards>true</runBackwards> - <rawCollectionName>EcalReadoutHits</rawCollectionName> - <ecalCollectionName>EcalReadoutAnalogHits</ecalCollectionName> - </driver> - <driver name="EcalTriggerClusterer" type="org.lcsim.hps.recon.ecal.HPSEcalCTPClusterer"> - <ecalName>Ecal</ecalName> - <ecalCollectionName>EcalReadoutAnalogHits</ecalCollectionName> - <clusterCollectionName>EcalTriggerClusters</clusterCollectionName> - </driver> - <driver name="EcalTrigger" type="org.lcsim.hps.recon.ecal.HPSFADCTriggerDriver"> - <clusterCollectionName>EcalTriggerClusters</clusterCollectionName> - <outputFileName>${outputFile}.triggers</outputFileName> - <deadTime>0</deadTime> - <lcioFile>${outputFile}</lcioFile> - </driver> - - <driver name="SimpleSVTReadout" type="org.lcsim.hps.recon.tracking.SimpleSvtReadout"> - <noPileup>true</noPileup> - </driver> - <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"/> - </drivers> -</lcsim>
diff -N HPSTestRunNoPileup.lcsim --- HPSTestRunNoPileup.lcsim 20 Nov 2012 23:32:22 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,53 +0,0 @@
- -<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" - xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> - <control> - <printInputFiles>true</printInputFiles> - <printDriversDetailed>true</printDriversDetailed> - </control> - <execute> - <driver name="EventMarkerDriver"/> - <driver name="HPSCalibrationDriver"/> - <driver name="EcalRawConverter"/> - <driver name="HPSEcalRawConverterDriver"/> - <driver name="EcalTriggerFilter"/> - <driver name="EcalTriggerClusterer"/> - <driver name="SimpleSVTReadout"/> - <driver name="EcalTrigger"/> - <driver name="ClockDriver"/> - </execute> - <drivers> - <driver name="HPSCalibrationDriver" type="org.lcsim.hps.monitoring.HPSCalibrationDriver"> - </driver> - <driver name="EcalRawConverter" type="org.lcsim.hps.recon.ecal.HPSEcalEdepToTriggerConverterDriver"> - <readoutCollection>EcalReadoutAnalogHits</readoutCollection> - </driver> - <driver name="HPSEcalRawConverterDriver" type="org.lcsim.hps.recon.ecal.HPSEcalRawConverterDriver"> - <runBackwards>true</runBackwards> - <rawCollectionName>EcalReadoutHits</rawCollectionName> - <ecalCollectionName>EcalReadoutAnalogHits</ecalCollectionName> - </driver> - <driver name="EcalTriggerFilter" type="org.lcsim.hps.recon.ecal.HPSEcalTriggerFilterDriver"> - <inputCollection>EcalTriggerHits</inputCollection> - <outputCollection>EcalFilteredHits</outputCollection> - </driver> - <driver name="EcalTriggerClusterer" type="org.lcsim.hps.recon.ecal.HPSEcalCTPClusterer"> - <ecalName>Ecal</ecalName> - <ecalCollectionName>EcalFilteredHits</ecalCollectionName> - <clusterCollectionName>EcalTriggerClusters</clusterCollectionName> - </driver> - <driver name="EcalTrigger" type="org.lcsim.hps.recon.ecal.TestRunTriggerDriver"> - <clusterCollectionName>EcalTriggerClusters</clusterCollectionName> - <deadTime>0</deadTime> - <lcioFile>${outputFile}</lcioFile> - </driver> - <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> - <eventInterval>1000</eventInterval> - </driver> - - <driver name="SimpleSVTReadout" type="org.lcsim.hps.recon.tracking.SimpleSvtReadout"> - <noPileup>true</noPileup> - </driver> - <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"/> - </drivers> -</lcsim>
diff -N HPS2014ReadoutToLcio.lcsim --- HPS2014ReadoutToLcio.lcsim 20 Dec 2012 08:31:35 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,104 +0,0 @@
-<!-- - Execute full trigger+readout simulation and write the results as an LCIO file. - @author Sho Uemura <[log in to unmask]> - @version $Id: HPS2014ReadoutToLcio.lcsim,v 1.4 2012/12/20 08:31:35 omoreno Exp $ ---> -<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" - xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> - <execute> - <driver name="EventMarkerDriver"/> - - <driver name="HPSCalibrationDriver"/> - <driver name="EcalReadout"/> - <driver name="EcalConverter"/> - <driver name="EcalClusterer"/> - <driver name="EcalTrigger"/> - -<!-- <driver name="SimpleSVTReadout"/>--> - - <driver name="SVTReadout"/> - <driver name="Digitization"/> - <driver name="DataProcessing"/> - <driver name="TestRunReconToLcio"/> - - <driver name="AidaSaveDriver"/> - - <driver name="ClockDriver"/> - <driver name="CleanupDriver"/> - </execute> - - <drivers> - <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> - <eventInterval>1000</eventInterval> - </driver> - <driver name="HPSCalibrationDriver" type="org.lcsim.hps.monitoring.HPSCalibrationDriver"> -<!-- <runNumber>1351</runNumber> --> - </driver> - <driver name="TestRunReconToLcio" type="org.lcsim.hps.evio.TestRunTriggeredReconToLcio"> - <outputFile>${outputFile}.slcio</outputFile> - </driver> - - <driver name="EcalReadout" type="org.lcsim.hps.recon.ecal.HPSEcalFADCReadoutDriver"> - <readoutPeriod>4.0</readoutPeriod> - <coincidenceWindow>2</coincidenceWindow> - <ecalName>Ecal</ecalName> - <ecalCollectionName>EcalHits</ecalCollectionName> - <ecalRawCollectionName>EcalRawHits</ecalRawCollectionName> - <triggerThreshold>50</triggerThreshold> - <readoutThreshold>50</readoutThreshold> - <constantTriggerWindow>true</constantTriggerWindow> - <scaleFactor>1</scaleFactor> -<!-- <fixedGain>0.15</fixedGain>--> -<!-- <debug>true</debug>--> - </driver> - - <driver name="EcalConverter" type="org.lcsim.hps.recon.ecal.HPSEcalRawConverterDriver"> - <rawCollectionName>EcalRawHits</rawCollectionName> - <ecalCollectionName>EcalCorrectedHits</ecalCollectionName> -<!-- <gain>0.15</gain>--> - <applyBadCrystalMap>false</applyBadCrystalMap> -<!-- <debug>true</debug>--> - </driver> - - <driver name="EcalClusterer" type="org.lcsim.hps.recon.ecal.HPSEcalCTPClusterer"> - <ecalName>Ecal</ecalName> - <clusterWindow>8.0</clusterWindow> - <ecalCollectionName>EcalCorrectedHits</ecalCollectionName> - </driver> - - <driver name="EcalTrigger" type="org.lcsim.hps.recon.ecal.HPSFADCTriggerDriver"> - <clusterCollectionName>EcalClusters</clusterCollectionName> - <deadTime>10</deadTime> - <outputFileName>${outputFile}.triggers</outputFileName> - </driver> - <driver name="SimpleSVTReadout" type="org.lcsim.hps.recon.tracking.SimpleSvtReadout"> - </driver> - - <driver name="SVTReadout" type="org.lcsim.hps.recon.tracking.apv25.SvtReadout"> - <debug>false</debug> - <pedestalRun>false</pedestalRun> - <triggerLatencyTime>240</triggerLatencyTime> - </driver> - - <driver name="Digitization" type="org.lcsim.hps.recon.tracking.RearTransitionModule" /> - - <driver name="DataProcessing" type="org.lcsim.hps.recon.tracking.TestRunDataProcessingModule" > - <enablePileUpCut>true</enablePileUpCut> - <enableThresholdCut>true</enableThresholdCut> - <noiseThreshold>2</noiseThreshold> - <numberOfSamplesAboveThreshold>3</numberOfSamplesAboveThreshold> - <numberOfSamplesToReadOut>6</numberOfSamplesToReadOut> - </driver> - - <driver name="AidaSaveDriver" - type="org.lcsim.job.AidaSaveDriver"> - <outputFileName>${outputFile}_triggerPlots</outputFileName> - </driver> - - <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"/> - <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver"> - <collectionNames>TrackerHits</collectionNames> - </driver> - </drivers> -</lcsim> -
diff -u -r1.6 -r1.7 --- EcalWindowPlots.java 27 Aug 2012 21:53:47 -0000 1.6 +++ EcalWindowPlots.java 25 Feb 2013 22:39:24 -0000 1.7 @@ -14,7 +14,7 @@
import org.lcsim.event.RawTrackerHit; import org.lcsim.geometry.Detector; import org.lcsim.hps.monitoring.AIDAFrame;
-import org.lcsim.hps.recon.ecal.HPSEcalConditions;
+import org.lcsim.hps.recon.ecal.EcalConditions;
import org.lcsim.util.Driver; import org.lcsim.util.aida.AIDA;
@@ -130,10 +130,10 @@
if (event.hasCollection(RawTrackerHit.class, inputCollection)) { List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollection); for (RawTrackerHit hit : hits) {
- Long daqId = HPSEcalConditions.physicalToDaqID(hit.getCellID()); - int crate = HPSEcalConditions.getCrate(daqId); - int slot = HPSEcalConditions.getSlot(daqId); - int channel = HPSEcalConditions.getChannel(daqId);
+ Long daqId = EcalConditions.physicalToDaqID(hit.getCellID()); + int crate = EcalConditions.getCrate(daqId); + int slot = EcalConditions.getSlot(daqId); + int channel = EcalConditions.getChannel(daqId);
// System.out.println("got hit: crate " + crate + ", slot " + slot + ", channel " + channel); if (hit.getADCValues().length != window) { throw new RuntimeException("Hit has unexpected window length " + hit.getADCValues().length + ", not " + window);
diff -u -r1.10 -r1.11 --- EcalEvsX.java 8 Dec 2012 01:12:18 -0000 1.10 +++ EcalEvsX.java 25 Feb 2013 22:39:24 -0000 1.11 @@ -15,7 +15,7 @@
import org.lcsim.geometry.Detector; import org.lcsim.geometry.subdetector.HPSEcal3; import org.lcsim.geometry.subdetector.HPSEcal3.NeighborMap;
-import org.lcsim.hps.recon.ecal.HPSEcalConditions;
+import org.lcsim.hps.recon.ecal.EcalConditions;
import org.lcsim.util.Driver; import org.lcsim.util.aida.AIDA;
@@ -163,7 +163,7 @@
} public boolean isGoodCluster(Cluster cluster) {
- NeighborMap map = ((HPSEcal3) HPSEcalConditions.getSubdetector()).getNeighborMap();
+ NeighborMap map = ((HPSEcal3) EcalConditions.getSubdetector()).getNeighborMap();
for (CalorimeterHit hit : cluster.getCalorimeterHits()) { if (map.get(hit.getCellID()).size() > 6) { return true;
diff -u -r1.8 -r1.9 --- EcalClusterPlots.java 8 Dec 2012 01:12:18 -0000 1.8 +++ EcalClusterPlots.java 25 Feb 2013 22:39:24 -0000 1.9 @@ -14,7 +14,7 @@
import org.lcsim.hps.evio.TriggerData; import org.lcsim.hps.monitoring.AIDAFrame; import org.lcsim.hps.monitoring.Resettable;
-import org.lcsim.hps.recon.ecal.HPSECalUtils;
+import org.lcsim.hps.recon.ecal.ECalUtils;
import org.lcsim.util.Driver; import org.lcsim.util.aida.AIDA;
@@ -32,7 +32,7 @@
IHistogram1D clusterTimeSigma; IHistogram2D edgePlot; int eventn = 0;
- double maxE = 5000 * HPSECalUtils.MeV;
+ double maxE = 5000 * ECalUtils.MeV;
boolean logScale = false; public void setInputCollection(String inputCollection) {
diff -u -r1.8 -r1.9 --- EcalHitPlots.java 8 Dec 2012 01:12:18 -0000 1.8 +++ EcalHitPlots.java 25 Feb 2013 22:39:24 -0000 1.9 @@ -12,7 +12,7 @@
import org.lcsim.hps.evio.TriggerData; import org.lcsim.hps.monitoring.AIDAFrame; import org.lcsim.hps.monitoring.Resettable;
-import org.lcsim.hps.recon.ecal.HPSECalUtils;
+import org.lcsim.hps.recon.ecal.ECalUtils;
import org.lcsim.util.Driver; import org.lcsim.util.aida.AIDA;
@@ -32,7 +32,7 @@
// IHistogram2D topX, botX, topY, botY; IHistogram2D edgePlot; int eventn = 0;
- double maxE = 5000 * HPSECalUtils.MeV;
+ double maxE = 5000 * ECalUtils.MeV;
boolean logScale = false; public void setInputCollection(String inputCollection) {
diff -u -r1.6 -r1.7 --- EcalDaqPlots.java 13 May 2012 21:39:24 -0000 1.6 +++ EcalDaqPlots.java 25 Feb 2013 22:39:24 -0000 1.7 @@ -15,7 +15,7 @@
import org.lcsim.geometry.Detector; import org.lcsim.geometry.compact.Subdetector; import org.lcsim.hps.monitoring.Resettable;
-import org.lcsim.hps.recon.ecal.HPSEcalConditions;
+import org.lcsim.hps.recon.ecal.EcalConditions;
import org.lcsim.util.Driver; import org.lcsim.util.aida.AIDA;
@@ -104,10 +104,10 @@
if (event.hasCollection(RawCalorimeterHit.class, inputCollection)) { List<RawCalorimeterHit> hits = event.get(RawCalorimeterHit.class, inputCollection); for (RawCalorimeterHit hit : hits) {
- Long daqId = HPSEcalConditions.physicalToDaqID(hit.getCellID()); - int crate = HPSEcalConditions.getCrate(daqId); - int slot = HPSEcalConditions.getSlot(daqId); - int channel = HPSEcalConditions.getChannel(daqId);
+ Long daqId = EcalConditions.physicalToDaqID(hit.getCellID()); + int crate = EcalConditions.getCrate(daqId); + int slot = EcalConditions.getSlot(daqId); + int channel = EcalConditions.getChannel(daqId);
//System.out.println("crate="+crate+"; slot="+slot+"; channel="+channel); //System.out.println("filling plot: " + "ECAL: Crate " + crate + "; Slot " + slot); aida.histogram1D("ECAL: Crate " + crate + "; Slot " + slot).fill(channel);
@@ -116,10 +116,10 @@
if (event.hasCollection(RawTrackerHit.class, inputCollection)) { List<RawTrackerHit> hits = event.get(RawTrackerHit.class, inputCollection); for (RawTrackerHit hit : hits) {
- Long daqId = HPSEcalConditions.physicalToDaqID(hit.getCellID()); - int crate = HPSEcalConditions.getCrate(daqId); - int slot = HPSEcalConditions.getSlot(daqId); - int channel = HPSEcalConditions.getChannel(daqId);
+ Long daqId = EcalConditions.physicalToDaqID(hit.getCellID()); + int crate = EcalConditions.getCrate(daqId); + int slot = EcalConditions.getSlot(daqId); + int channel = EcalConditions.getChannel(daqId);
//System.out.println("crate="+crate+"; slot="+slot+"; channel="+channel); //System.out.println("filling plot: " + "ECAL: Crate " + crate + "; Slot " + slot); aida.histogram1D("ECAL: Crate " + crate + "; Slot " + slot).fill(channel);
diff -u -r1.11 -r1.12 --- EcalPedestalPlots.java 8 Dec 2012 01:12:18 -0000 1.11 +++ EcalPedestalPlots.java 25 Feb 2013 22:39:24 -0000 1.12 @@ -18,8 +18,8 @@
import org.lcsim.hps.monitoring.AIDAFrame; import org.lcsim.hps.monitoring.Redrawable; import org.lcsim.hps.monitoring.Resettable;
-import org.lcsim.hps.recon.ecal.HPSECalUtils; -import org.lcsim.hps.recon.ecal.HPSEcalConditions;
+import org.lcsim.hps.recon.ecal.ECalUtils; +import org.lcsim.hps.recon.ecal.EcalConditions;
import org.lcsim.util.Driver; import org.lcsim.util.aida.AIDA;
@@ -46,7 +46,7 @@
int eventn = 0; boolean hide = false; int calWindow = 0;
- double maxE = 1000 * HPSECalUtils.MeV;
+ double maxE = 1000 * ECalUtils.MeV;
public EcalPedestalPlots() { int count = 0;
@@ -181,8 +181,8 @@
for (int crate = 1; crate < 3; crate++) { for (short slot = 0; slot < 20; slot++) { for (short ch = 0; ch < 16; ch++) {
- Long id = HPSEcalConditions.daqToPhysicalID(crate, slot, ch); - IIdentifierHelper helper = HPSEcalConditions.getHelper();
+ Long id = EcalConditions.daqToPhysicalID(crate, slot, ch); + IIdentifierHelper helper = EcalConditions.getHelper();
if (id == null) { continue; }
diff -N EcalReadoutToTriggerConverterDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EcalReadoutToTriggerConverterDriver.java 25 Feb 2013 22:39:24 -0000 1.1 @@ -0,0 +1,189 @@
+package org.lcsim.hps.recon.ecal; + +import java.util.ArrayList; +import java.util.List; +import org.lcsim.event.CalorimeterHit; +import org.lcsim.event.EventHeader; +import org.lcsim.event.base.BaseRawCalorimeterHit; +import org.lcsim.geometry.Detector; +import org.lcsim.util.Driver; + +/** + * + * @version $Id: HPSEcalRawConverterDriver.java,v 1.2 2012/05/03 00:17:54 + * phansson Exp $ + */ +public class EcalReadoutToTriggerConverterDriver extends Driver { + + String rawCollectionName = "EcalReadoutHits"; + String ecalReadoutName = "EcalHits"; + String ecalCollectionName = "EcalCalHits"; + int integralWindow = 30; + boolean debug = false; + double threshold = Double.NEGATIVE_INFINITY; + boolean applyBadCrystalMap = true; + boolean dropBadFADC = false; + double tp = 14.0; + double readoutPeriod = 4.0; + private int readoutThreshold = 50; + private int triggerThreshold = 80; + private double timeShift = 0; + private int truncateScale = 128; + + public EcalReadoutToTriggerConverterDriver() { + } + + public void setTp(double tp) { + this.tp = tp; + } + + public void setDropBadFADC(boolean dropBadFADC) { + this.dropBadFADC = dropBadFADC; + } + + public void setThreshold(double threshold) { + this.threshold = threshold; + } + + public void setIntegralWindow(int integralWindow) { + this.integralWindow = integralWindow; + } + + public void setEcalCollectionName(String ecalCollectionName) { + this.ecalCollectionName = ecalCollectionName; + } + + public void setRawCollectionName(String rawCollectionName) { + this.rawCollectionName = rawCollectionName; + } + + public void setApplyBadCrystalMap(boolean apply) { + this.applyBadCrystalMap = apply; + } + + public void setTruncateScale(int truncateScale) { + this.truncateScale = truncateScale; + } + + @Override + public void startOfData() { + if (ecalCollectionName == null) { + throw new RuntimeException("The parameter ecalCollectionName was not set!"); + } + } + + @Override + public void detectorChanged(Detector detector) { + } + + public boolean isBadCrystal(CalorimeterHit hit) { + return EcalConditions.badChannelsLoaded() ? EcalConditions.isBadChannel(hit.getCellID()) : false; + } + + public boolean isBadFADC(CalorimeterHit hit) { + long daqID = EcalConditions.physicalToDaqID(hit.getCellID()); + return (EcalConditions.getCrate(daqID) == 1 && EcalConditions.getSlot(daqID) == 3); + } + + @Override + public void process(EventHeader event) { + ArrayList<CalorimeterHit> newHits = new ArrayList<CalorimeterHit>(); + + if (event.hasCollection(BaseRawCalorimeterHit.class, rawCollectionName)) { + List<BaseRawCalorimeterHit> hits = event.get(BaseRawCalorimeterHit.class, rawCollectionName); + + for (BaseRawCalorimeterHit hit : hits) { + CalorimeterHit newHit = HitDtoA(hit, integralWindow); + if (newHit != null && newHit.getRawEnergy() > threshold) { + if (applyBadCrystalMap && isBadCrystal(newHit)) { + continue; + } + if (dropBadFADC && isBadFADC(newHit)) { + continue; + } + newHits.add(newHit); + } + } + } + int flags = 0; + event.put(ecalCollectionName, newHits, CalorimeterHit.class, flags, ecalReadoutName); + } + + public CalorimeterHit HitDtoA(BaseRawCalorimeterHit hit, int window) { + double integral = tp * Math.E / readoutPeriod; + double readoutIntegral = (hit.getAmplitude() - window * EcalConditions.physicalToPedestal(hit.getCellID())); + double amplitude = readoutIntegral / integral; + +// double time = readoutPeriod * (Math.random() - 1); + double time = 0 - timeShift; + timeShift += 0.01; + if (timeShift > readoutPeriod) { + timeShift = 0; + } + double triggerIntegral = 0; + boolean overThreshold = false; +// double readoutTime = -1; +// double triggerTime = -1; + while (true) { + double currentValue = amplitude * pulseAmplitude(time); +// if (readoutTime < 0 && currentValue > readoutThreshold) { +// readoutTime = time; +// } + if (!overThreshold && currentValue > triggerThreshold) { + overThreshold = true; +// triggerTime = time; + } + if (overThreshold) { + triggerIntegral += amplitude * pulseAmplitude(time); + if (currentValue < triggerThreshold) { + break; + } + } + time += readoutPeriod; + + if (time > 200.0) { + break; + } + } + +// System.out.format("%f %f %f\n", readoutIntegral, amplitude, triggerIntegral); + + if (hit.getTimeStamp() % 64 != 0) { + System.out.println("unexpected timestamp " + hit.getTimeStamp()); + } + int truncatedIntegral = (int) Math.floor(triggerIntegral / truncateScale) * truncateScale; + double hitTime = hit.getTimeStamp() / 16.0; +// if (readoutTime >= 0 && triggerTime >= 0) { +// hitTime += triggerTime - readoutTime; +// } + long id = hit.getCellID(); +// Hep3Vector pvec = hit.getDetectorElement().getGeometry().getPosition(); +// double [] pos = new double[3]; +// pos[0] = pvec.x(); +// pos[1] = pvec.y(); +// pos[2] = pvec.z(); +// if (truncatedIntegral<=0) return null; + if (truncatedIntegral <= 0) { + truncatedIntegral = 0; + } + CalorimeterHit h = new HPSCalorimeterHit(truncatedIntegral, hitTime, id, 0); +// CalorimeterHit h = new HPSRawCalorimeterHit(triggerIntegral + 0.0000001, hit.getPosition(), hitTime, id, 0); + //+0.0000001 is a horrible hack to ensure rawEnergy!=BaseCalorimeterHit.UNSET_CORRECTED_ENERGY + return h; + } + + private double pulseAmplitude(double time) { + if (time <= 0.0) { + return 0.0; + } + if (tp > 0.0) { + return (time / tp) * Math.exp(1.0 - time / tp); + } else { + if (time < -tp) { + return 1.0; + } else { + return 0.0; + } + } + } +}
diff -N ECalUtils.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ ECalUtils.java 25 Feb 2013 22:39:24 -0000 1.1 @@ -0,0 +1,61 @@
+package org.lcsim.hps.recon.ecal; + +import org.lcsim.event.CalorimeterHit; + +/** + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: ECalUtils.java,v 1.1 2013/02/25 22:39:24 meeg Exp $ + */ +public class ECalUtils { + + public static final double GeV = 1.0; + public static final double MeV = 0.001; + + /** + * Returns the quadrant which contains the ECal cluster + * + * @param ecalCluster : ECal cluster + * @return Quadrant number + */ + public static int getQuadrant(HPSEcalCluster ecalCluster) { + return getQuadrant(ecalCluster.getSeedHit()); + } + + public static int getQuadrant(CalorimeterHit hit) { + int ix = hit.getIdentifierFieldValue("ix"); + int iy = hit.getIdentifierFieldValue("iy"); + return getQuadrant(ix, iy); + } + + public static int getQuadrant(int x, int y) { + if (x > 0) { + if (y > 0) { + return 1; + } else { + return 4; + } + } else { + if (y > 0) { + return 2; + } else { + return 3; + } + } + } + + public static int getHVGroup(int x, int y) { + int absy = Math.abs(y); + if (x > 0 || x <= -8) { + return (23 - Math.abs(x)) / 2 + 1; + } else { + if (x == -7 && absy == 5) { + return 8; + } else if (x >= -4) { + return 12 - Math.max(x + 4, absy - 2); + } else { + return 12 - Math.max(-5 - x, absy - 2); + } + } + } +}
diff -N EcalConverterDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EcalConverterDriver.java 25 Feb 2013 22:39:24 -0000 1.1 @@ -0,0 +1,86 @@
+package org.lcsim.hps.recon.ecal; + +import java.util.ArrayList; +import java.util.List; +import org.lcsim.event.CalorimeterHit; +import org.lcsim.event.EventHeader; +import org.lcsim.event.RawCalorimeterHit; +import org.lcsim.util.Driver; +import org.lcsim.util.lcio.LCIOConstants; + +/** + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: EcalConverterDriver.java,v 1.1 2013/02/25 22:39:24 meeg Exp $ + */ +public class EcalConverterDriver extends Driver { + + String rawCollectionName; + String ecalReadoutName = "EcalHits"; + String ecalCollectionName = "EcalCorrectedHits"; + int flags; + double scale = 1.0; +// double pedestal = 0.0; + double period = 4.0; + double dt = 0.0; + + public EcalConverterDriver() { + flags = 0; + flags += 1 << LCIOConstants.CHBIT_LONG; //store position + flags += 1 << LCIOConstants.RCHBIT_ID1; //store cell ID + } + +// public void setPedestal(double pedestal) { +// this.pedestal = pedestal; +// } + public void setScale(double scale) { + this.scale = scale; + } + + public void setEcalCollectionName(String ecalCollectionName) { + this.ecalCollectionName = ecalCollectionName; + } + + public void setRawCollectionName(String rawCollectionName) { + this.rawCollectionName = rawCollectionName; + } + + @Override + public void startOfData() { + if (ecalCollectionName == null) { + throw new RuntimeException("The parameter ecalCollectionName was not set!"); + } + } + + @Override + public void process(EventHeader event) { + if (event.hasCollection(HPSRawCalorimeterHit.class, rawCollectionName)) { + // Get the list of ECal hits. + List<HPSRawCalorimeterHit> hits = event.get(HPSRawCalorimeterHit.class, rawCollectionName); + + ArrayList<CalorimeterHit> newHits = new ArrayList<CalorimeterHit>(); + + for (HPSRawCalorimeterHit hit : hits) { + newHits.add(HitDtoA(hit)); + } + + event.put(ecalCollectionName, newHits, CalorimeterHit.class, flags, ecalReadoutName); + } + } + +// private int AtoD(double amplitude, long cellID) { +// return (int) Math.round(amplitude / scale); +// } + + private double DtoA(int amplitude, long cellID) { + return scale * amplitude; + } + + private CalorimeterHit HitDtoA(RawCalorimeterHit hit) { + return new HPSCalorimeterHit(DtoA(hit.getAmplitude(), hit.getCellID()), period * hit.getTimeStamp() + dt, hit.getCellID(), 0); + } + +// private RawCalorimeterHit HitAtoD(CalorimeterHit hit) { +// return new HPSFADCCalorimeterHit(hit.getCellID(), AtoD(hit.getRawEnergy(), hit.getCellID()), (int) Math.round(hit.getTime() / period), 0); +// } +}
diff -N EcalRawConverterDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EcalRawConverterDriver.java 25 Feb 2013 22:39:24 -0000 1.1 @@ -0,0 +1,158 @@
+package org.lcsim.hps.recon.ecal; + +import java.util.ArrayList; +import java.util.List; +import org.lcsim.event.CalorimeterHit; +import org.lcsim.event.EventHeader; +import org.lcsim.event.RawCalorimeterHit; +import org.lcsim.event.RawTrackerHit; +import org.lcsim.geometry.Detector; +import org.lcsim.util.Driver; + +/** + * + * @version $Id: HPSEcalRawConverterDriver.java,v 1.2 2012/05/03 00:17:54 + * phansson Exp $ + */ +public class EcalRawConverterDriver extends Driver { + + EcalRawConverter converter = null; + String rawCollectionName = "EcalReadoutHits"; + String ecalReadoutName = "EcalHits"; + String ecalCollectionName = "EcalCalHits"; + int integralWindow = 35; + boolean debug = false; + double threshold = Double.NEGATIVE_INFINITY; + boolean applyBadCrystalMap = true; + boolean dropBadFADC = false; + private boolean runBackwards = false; + + public EcalRawConverterDriver() { + converter = new EcalRawConverter(); + } + + public void setRunBackwards(boolean runBackwards) { + this.runBackwards = runBackwards; + } + + public void setDropBadFADC(boolean dropBadFADC) { + this.dropBadFADC = dropBadFADC; + } + + public void setThreshold(double threshold) { + this.threshold = threshold; + } + + public void setGain(double gain) { + converter.setGain(gain); + } + + public void setIntegralWindow(int integralWindow) { + this.integralWindow = integralWindow; + } + + public void setEcalCollectionName(String ecalCollectionName) { + this.ecalCollectionName = ecalCollectionName; + } + + public void setRawCollectionName(String rawCollectionName) { + this.rawCollectionName = rawCollectionName; + } + + public void setApplyBadCrystalMap(boolean apply) { + this.applyBadCrystalMap = apply; + } + + public void setDebug(boolean debug) { + this.debug = debug; + } + + @Override + public void startOfData() { + if (ecalCollectionName == null) { + throw new RuntimeException("The parameter ecalCollectionName was not set!"); + } + } + + @Override + public void detectorChanged(Detector detector) { + } + + public static boolean isBadCrystal(CalorimeterHit hit) { + return EcalConditions.badChannelsLoaded() ? EcalConditions.isBadChannel(hit.getCellID()) : false; + } + + public static boolean isBadFADC(CalorimeterHit hit) { + long daqID = EcalConditions.physicalToDaqID(hit.getCellID()); + return (EcalConditions.getCrate(daqID) == 1 && EcalConditions.getSlot(daqID) == 3); + } + + @Override + public void process(EventHeader event) { + if (!runBackwards) { + ArrayList<CalorimeterHit> newHits = new ArrayList<CalorimeterHit>(); + + // Get the list of ECal hits. + if (event.hasCollection(RawTrackerHit.class, rawCollectionName)) { + List<RawTrackerHit> hits = event.get(RawTrackerHit.class, rawCollectionName); + + for (RawTrackerHit hit : hits) { + CalorimeterHit newHit = converter.HitDtoA(hit); + if (applyBadCrystalMap && isBadCrystal(newHit)) { + continue; + } + if (dropBadFADC && isBadFADC(newHit)) { + continue; + } + if (newHit.getRawEnergy() > threshold) { + newHits.add(newHit); + } + } + } + if (event.hasCollection(RawCalorimeterHit.class, rawCollectionName)) { + List<RawCalorimeterHit> hits = event.get(RawCalorimeterHit.class, rawCollectionName); + + for (RawCalorimeterHit hit : hits) { + if (debug) { + System.out.format("old hit energy %d\n", hit.getAmplitude()); + } + CalorimeterHit newHit = converter.HitDtoA(hit, integralWindow); + if (newHit.getRawEnergy() > threshold) { + if (applyBadCrystalMap && isBadCrystal(newHit)) { + continue; + } + if (dropBadFADC && isBadFADC(newHit)) { + continue; + } + if (debug) { + System.out.format("new hit energy %f\n", newHit.getRawEnergy()); + } + newHits.add(newHit); + } + } + } + int flags = 0; + event.put(ecalCollectionName, newHits, CalorimeterHit.class, flags, ecalReadoutName); + } else { + ArrayList<RawCalorimeterHit> newHits = new ArrayList<RawCalorimeterHit>(); + if (event.hasCollection(CalorimeterHit.class, ecalCollectionName)) { + List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName); + + for (CalorimeterHit hit : hits) { + if (debug) { + System.out.format("old hit energy %f\n", hit.getRawEnergy()); + } + RawCalorimeterHit newHit = converter.HitAtoD(hit, integralWindow); + if (newHit.getAmplitude() > 0) { + if (debug) { + System.out.format("new hit energy %d\n", newHit.getAmplitude()); + } + newHits.add(newHit); + } + } + } + int flags = 0; + event.put(rawCollectionName, newHits, RawCalorimeterHit.class, flags, ecalReadoutName); + } + } +}
diff -N EcalClusterer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EcalClusterer.java 25 Feb 2013 22:39:24 -0000 1.1 @@ -0,0 +1,171 @@
+package org.lcsim.hps.recon.ecal; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.lcsim.event.CalorimeterHit; +import org.lcsim.event.EventHeader; +import org.lcsim.geometry.Detector; +import org.lcsim.geometry.subdetector.HPSEcal3.NeighborMap; +import org.lcsim.geometry.subdetector.HPSEcal3; +import org.lcsim.util.Driver; +import org.lcsim.util.lcio.LCIOConstants; + +/** + * This Driver creates clusters from the CalorimeterHits of an + * {@link org.lcsim.geometry.subdetectur.HPSEcal3} detector. + * + * The clustering algorithm is from pages 83 and 84 of the HPS Proposal. + * + * @author Jeremy McCormick <[log in to unmask]> + * @author Tim Nelson <[log in to unmask]> + * + * @version $Id: EcalClusterer.java,v 1.1 2013/02/25 22:39:24 meeg Exp $ + */ +public class EcalClusterer extends Driver { + + HPSEcal3 ecal; + String ecalCollectionName; + String ecalName = "Ecal"; + String clusterCollectionName = "EcalClusters"; + // Minimum E for cluster seed. + double seedEMin = .05 * ECalUtils.GeV; + // Minimum E to add hit to cluster. + double addEMin = .03 * ECalUtils.GeV; + // Odd or even number of crystals in X. + boolean oddX; + // Map of crystals to their neighbors. + NeighborMap neighborMap = null; + + public EcalClusterer() { + } + + public void setClusterCollectionName(String clusterCollectionName) { + this.clusterCollectionName = clusterCollectionName; + } + + public void setSeedEMin(double seedEMin) { + this.seedEMin = seedEMin; + } + + public void setAddEMin(double addEMin) { + this.addEMin = addEMin; + if (seedEMin < addEMin) { + seedEMin = addEMin; + } + } + + public void setEcalCollectionName(String ecalCollectionName) { + this.ecalCollectionName = ecalCollectionName; + } + + public void setEcalName(String ecalName) { + this.ecalName = ecalName; + } + + public void startOfData() { + if (ecalCollectionName == null) { + throw new RuntimeException("The parameter ecalCollectionName was not set!"); + } + + if (ecalName == null) { + throw new RuntimeException("The parameter ecalName was not set!"); + } + } + + public void detectorChanged(Detector detector) { + // Get the Subdetector. + ecal = (HPSEcal3) detector.getSubdetector(ecalName); + + // Cache ref to neighbor map. + neighborMap = ecal.getNeighborMap(); + + //System.out.println(ecal.getName()); + //System.out.println(" nx="+ecal.nx()); + //System.out.println(" ny="+ecal.ny()); + //System.out.println(" beamgap="+ecal.beamGap()); + //System.out.println(" dface="+ecal.distanceToFace()); + + //System.out.println(neighborMap.toString()); + } + + public void process(EventHeader event) { + //System.out.println(this.getClass().getCanonicalName() + " - process"); + + if (event.hasCollection(CalorimeterHit.class, ecalCollectionName)) { + // Get the list of raw ECal hits. + List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName); + + // Make a hit map for quick lookup by ID. + Map<Long, CalorimeterHit> hitMap = new HashMap<Long, CalorimeterHit>(); + for (CalorimeterHit hit : hits) { + hitMap.put(hit.getCellID(), hit); + } + + // Put Cluster collection into event. + int flag = 1 << LCIOConstants.CLBIT_HITS; + event.put(clusterCollectionName, createClusters(hitMap), HPSEcalCluster.class, flag); + } + } + + public List<HPSEcalCluster> createClusters(Map<Long, CalorimeterHit> map) { + + // New Cluster list to be added to event. + List<HPSEcalCluster> clusters = new ArrayList<HPSEcalCluster>(); + + // Loop over ECal hits to find cluster seeds. + for (CalorimeterHit hit : map.values()) { + // Cut on min seed E. + if (hit.getRawEnergy() < seedEMin) { + continue; + } + + // Get neighbor crystal IDs. + Set<Long> neighbors = neighborMap.get(hit.getCellID()); + + if (neighbors == null) { + throw new RuntimeException("Oops! Set of neighbors is null!"); + } + + // List for neighboring hits. + List<CalorimeterHit> neighborHits = new ArrayList<CalorimeterHit>(); + + // Loop over neighbors to make hit list for cluster. + boolean isSeed = true; + for (Long neighborId : neighbors) { + // Find the neighbor hit in the event if it exists. + CalorimeterHit neighborHit = map.get(neighborId); + + // Was this neighbor cell hit? + if (neighborHit != null) { + // Check if neighbor cell has more energy. + if (neighborHit.getRawEnergy() > hit.getRawEnergy()) { + // Neighbor has more energy, so cell is not a seed. + isSeed = false; + break; + } + + // Add to cluster if above min E. + if (neighborHit.getRawEnergy() >= addEMin) { + neighborHits.add(neighborHit); + } + } + } + + // Did we find a seed? + if (isSeed) { + // Make a cluster from the hit list. + HPSEcalCluster cluster = new HPSEcalCluster(hit); + cluster.addHit(hit); + for (CalorimeterHit clusHit : neighborHits) { + cluster.addHit(clusHit); + } + clusters.add(cluster); + } + } + return clusters; + } +}
\ No newline at end of file
diff -N CTPEcalClusterer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ CTPEcalClusterer.java 25 Feb 2013 22:39:24 -0000 1.1 @@ -0,0 +1,308 @@
+package org.lcsim.hps.recon.ecal; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.PriorityQueue; +import java.util.Set; + +import org.lcsim.event.CalorimeterHit; +//import org.lcsim.event.Cluster; +import org.lcsim.event.EventHeader; +import org.lcsim.geometry.Detector; +import org.lcsim.geometry.IDDecoder; +import org.lcsim.geometry.subdetector.HPSEcal3.NeighborMap; +import org.lcsim.geometry.subdetector.HPSEcal3; +import org.lcsim.hps.recon.ecal.CTPEcalClusterer.TimeComparator; +import org.lcsim.util.Driver; +import org.lcsim.util.lcio.LCIOConstants; + +/** + * Creates clusters from CalorimeterHits in the HPSEcal detector. + * + * The clustering algorithm is from JLab Hall B 6 GeV DVCS Trigger Design doc. + * + * @author Jeremy McCormick <[log in to unmask]> + * @author Tim Nelson <[log in to unmask]> + * @author Sho Uemura <[log in to unmask]> + * @version $Id: CTPEcalClusterer.java,v 1.1 2013/02/25 22:39:24 meeg Exp $ + */ +public class CTPEcalClusterer extends Driver { + + HPSEcal3 ecal; + IDDecoder dec; + String ecalName; + String ecalCollectionName; + String clusterCollectionName = "EcalClusters"; + Set<Long> clusterCenters = null; + Map<Long, Double> hitSums = null; + Map<Long, CalorimeterHit> hitMap = null; + // Map of crystals to their neighbors. + NeighborMap neighborMap = null; + double clusterWindow = -1; + double addEMin = 0; + + public CTPEcalClusterer() { + } + + public void setAddEMin(double addEMin) { + this.addEMin = addEMin; + } + + public void setClusterWindow(double clusterWindow) { + this.clusterWindow = clusterWindow; + } + + public void setClusterCollectionName(String clusterCollectionName) { + this.clusterCollectionName = clusterCollectionName; + } + + public void setEcalCollectionName(String ecalCollectionName) { + this.ecalCollectionName = ecalCollectionName; + } + + public void setEcalName(String ecalName) { + this.ecalName = ecalName; + } + + @Override + public void startOfData() { + if (ecalCollectionName == null) { + throw new RuntimeException("The parameter ecalCollectionName was not set!"); + } + + if (ecalName == null) { + throw new RuntimeException("The parameter ecalName was not set!"); + } + } + + @Override + public void detectorChanged(Detector detector) { + // Get the Subdetector. + ecal = (HPSEcal3) detector.getSubdetector(ecalName); + + // Get the decoder for the ECal IDs. + dec = ecal.getIDDecoder(); + + // Cache ref to neighbor map. + neighborMap = ecal.getNeighborMap(); + + clusterCenters = new HashSet<Long>(); + //Make set of valid cluster centers. + for (Long cellID : neighborMap.keySet()) { + boolean isValidCenter = true; + Set<Long> neighbors = neighborMap.get(cellID); + for (Long neighborID : neighbors) { + Set<Long> neighborneighbors = new HashSet<Long>(); + neighborneighbors.addAll(neighborMap.get(neighborID)); + neighborneighbors.add(neighborID); + + if (neighborneighbors.containsAll(neighbors)) { + isValidCenter = false; + break; + } + } + if (isValidCenter) { + clusterCenters.add(cellID); + } + } + + //System.out.println(ecal.getName()); + //System.out.println(" nx="+ecal.nx()); + //System.out.println(" ny="+ecal.ny()); + //System.out.println(" beamgap="+ecal.beamGap()); + //System.out.println(" dface="+ecal.distanceToFace()); + + //System.out.println(neighborMap.toString()); + } + + @Override + public void process(EventHeader event) { + //System.out.println(this.getClass().getCanonicalName() + " - process"); + + if (event.hasCollection(CalorimeterHit.class, ecalCollectionName)) { + // Get the list of raw ECal hits. + List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName); + + List<HPSEcalCluster> clusters; + + if (clusterWindow >= 0) { + PriorityQueue<CalorimeterHit> futureHits = new PriorityQueue<CalorimeterHit>(10, new TimeComparator()); + PriorityQueue<CalorimeterHit> pastHits = new PriorityQueue<CalorimeterHit>(10, new TimeComparator()); + clusters = new ArrayList<HPSEcalCluster>(); + + for (CalorimeterHit hit : hits) { + if (hit.getRawEnergy() > addEMin) { + futureHits.add(hit); + } + } + + while (!futureHits.isEmpty()) { + CalorimeterHit nextHit = futureHits.poll(); + pastHits.add(nextHit); + while (!futureHits.isEmpty() && futureHits.peek().getTime() == nextHit.getTime()) { + pastHits.add(futureHits.poll()); + } + while (pastHits.peek().getTime() < nextHit.getTime() - clusterWindow) { + pastHits.poll(); + } + sumHits(pastHits); + clusters.addAll(createClusters()); + } + } else { + sumHits(hits); + clusters = createClusters(); + } + + // Put Cluster collection into event. + int flag = 1 << LCIOConstants.CLBIT_HITS; + event.put(clusterCollectionName, clusters, HPSEcalCluster.class, flag); + } + } + + public void sumHits(Collection<CalorimeterHit> hits) { + // Hit map. + hitMap = new HashMap<Long, CalorimeterHit>(); + + hitSums = new HashMap<Long, Double>(); + // Loop over ECal hits to compute energy sums + for (CalorimeterHit hit : hits) { +// System.out.format("hit: %f\n",hit.getRawEnergy()); + // Make a hit map for quick lookup by ID. + hitMap.put(hit.getCellID(), hit); + + // Get neighbor crystal IDs. + Set<Long> neighbors = neighborMap.get(hit.getCellID()); + + if (neighbors == null) { + throw new RuntimeException("Oops! Set of neighbors is null!"); + } + + Double hitSum; + + if (clusterCenters.contains(hit.getCellID())) { + hitSum = hitSums.get(hit.getCellID()); + if (hitSum == null) { + hitSums.put(hit.getCellID(), hit.getRawEnergy()); + } else { + hitSums.put(hit.getCellID(), hitSum + hit.getRawEnergy()); + } + } + + // Loop over neighbors to make hit list for cluster. + for (Long neighborId : neighbors) { + if (!clusterCenters.contains(neighborId)) { + continue; + } + hitSum = hitSums.get(neighborId); + if (hitSum == null) { + hitSums.put(neighborId, hit.getRawEnergy()); + } else { + hitSums.put(neighborId, hitSum + hit.getRawEnergy()); + } + } + } + } + + public List<HPSEcalCluster> createClusters() { +// boolean printClusters; + // New Cluster list to be added to event. + List<HPSEcalCluster> clusters = new ArrayList<HPSEcalCluster>(); + //System.out.println("New event"); + //for each crystal with a nonzero hit count, test for cluster + for (Long possibleCluster : hitSums.keySet()) { + Double thisSum = hitSums.get(possibleCluster); + + // Get neighbor crystal IDs. + Set<Long> neighbors = neighborMap.get(possibleCluster); + + if (neighbors == null) { + throw new RuntimeException("Oops! Set of neighbors is null!"); + } + + //Apply peak detector scheme. + // Set the ID. + dec.setID(possibleCluster); + int x1 = dec.getValue("ix"); + int y1 = dec.getValue("iy"); +// System.out.printf("\nThis cluster: E= %f, ID=%d, x=%d, y=%d, neighbors=%d\n", thisSum, possibleCluster, x1, y1, neighbors.size()); + boolean isCluster = true; + for (Long neighborId : neighbors) { + // Set the ID. + dec.setID(neighborId); + int x2 = dec.getValue("ix"); + int y2 = dec.getValue("iy"); + + Double neighborSum = hitSums.get(neighborId); + if (neighborSum == null) { + continue; + } + +// System.out.printf("Neighbor cluster: E= %f, ID=%d, x=%d, y=%d, neighbors=%d\n", neighborSum, neighborId, x2, y2, neighborMap.get(neighborId).size()); + + if (neighborSum > thisSum) { +// System.out.println("Reject cluster: sum cut"); + isCluster = false; + break; + } // else if (false) { //ctp + // else if (neighborSum.equals(thisSum) && neighborId > possibleCluster) { //id + // else if (neighborSum.equals(thisSum) && (x1<x2 || (x1==x2 && Math.abs(y1)>Math.abs(y2)))) { //right_in + // else if (neighborSum.equals(thisSum) && (x1<x2 || (x1==x2 && Math.abs(y1)<Math.abs(y2)))) { //right_out + // else if (neighborSum.equals(thisSum) && (x1>x2 || (x1==x2 && Math.abs(y1)>Math.abs(y2)))) { //left_in + else if (neighborSum.equals(thisSum) && (x1 > x2 || (x1 == x2 && Math.abs(y1) < Math.abs(y2)))) { //left_out +// else if (neighborSum.equals(thisSum) && (x1<x2 || (x1==x2 && y1<y2))) { //right_up +// else if (neighborSum.equals(thisSum) && (x1>x2 || (x1==x2 && y1<y2))) { //left_up +// System.out.println("Reject cluster: tie-breaker cut"); + isCluster = false; + break; + } + } + + if (isCluster) { + List<CalorimeterHit> hits = new ArrayList<CalorimeterHit>(); + double clusterTime = Double.NEGATIVE_INFINITY; + CalorimeterHit hit = hitMap.get(possibleCluster); + if (hit != null) { + hits.add(hit); + if (hit.getTime() > clusterTime) { + clusterTime = hit.getTime(); + } + } + for (Long neighborId : neighbors) { + hit = hitMap.get(neighborId); + if (hit != null) { + hits.add(hit); + if (hit.getTime() > clusterTime) { + clusterTime = hit.getTime(); + } + } + } + CalorimeterHit seedHit = new HPSCalorimeterHit(0.0, clusterTime, possibleCluster, hits.get(0).getType()); + seedHit.setMetaData(hits.get(0).getMetaData()); + HPSEcalCluster cluster = new HPSEcalCluster(seedHit); + for (CalorimeterHit clusterHit : hits) { + cluster.addHit(clusterHit); + } + clusters.add(cluster); +// System.out.println(cluster.getEnergy()); + } + } + return clusters; + } + + static class TimeComparator implements Comparator<CalorimeterHit> { + + @Override + public int compare(CalorimeterHit o1, CalorimeterHit o2) { + if (o1.getTime() == o2.getTime()) { + return 0; + } else { + return (o1.getTime() > o2.getTime()) ? 1 : -1; + } + } + } +}
diff -N EcalConditions.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EcalConditions.java 25 Feb 2013 22:39:24 -0000 1.1 @@ -0,0 +1,342 @@
+package org.lcsim.hps.recon.ecal; + +import java.io.BufferedReader; +import org.lcsim.geometry.compact.Subdetector; +import java.io.IOException; +import java.io.Reader; +import java.util.HashMap; +import java.util.HashSet; +import java.util.StringTokenizer; +import org.lcsim.conditions.ConditionsManager; +import org.lcsim.detector.identifier.ExpandedIdentifier; +import org.lcsim.detector.identifier.IExpandedIdentifier; +import org.lcsim.detector.identifier.IIdentifierHelper; +import org.lcsim.geometry.Detector; +import org.lcsim.util.Driver; + +/** + * + * @author meeg + * @version $Id: EcalConditions.java,v 1.1 2013/02/25 22:39:24 meeg Exp $ + */ +public class EcalConditions extends Driver { + + //DAQ channel map + private static HashMap<Long, Long> daqToPhysicalMap = new HashMap<Long, Long>(); + private static HashMap<Long, Long> physicalToDaqMap = new HashMap<Long, Long>(); + //pedestals + private static HashMap<Long, Double> daqToPedestalMap = new HashMap<Long, Double>(); + private static HashMap<Long, Double> daqToNoiseMap = new HashMap<Long, Double>(); + //set of bad channels to ignore + private static HashSet<Long> badChannelsSet = new HashSet<Long>(); + private static boolean badChannelsLoaded = false; + private static IIdentifierHelper helper = null; + //gain + private static HashMap<Long, Double> physicalToGainMap = new HashMap<Long, Double>(); + //subdetector name (for when this is used as a driver) + private String subdetectorName = "Ecal"; + private static Subdetector subdetector; + private static boolean debug = false; + private static boolean calibrationLoaded = false; + + public EcalConditions() { + } + + @Override + public void detectorChanged(Detector detector) { + detectorChanged(detector, subdetectorName); + } + + public static void detectorChanged(Detector detector, String ecalName) { + subdetector = detector.getSubdetector(ecalName); + if (subdetector == null) { + throw new RuntimeException("Subdetector " + ecalName + " not found"); + } + helper = subdetector.getDetectorElement().getIdentifierHelper(); + } + + public static boolean calibrationLoaded() { + return calibrationLoaded; + } + + public static void loadDaqMap(Detector detector, String ecalName) { + detectorChanged(detector, ecalName); + fillDaqCellMap(subdetector); + } + + public static void loadCalibration() { + fillDaqCellMap(subdetector); + loadBadChannels(subdetector); + loadGains(); + loadPedestals(); + calibrationLoaded = true; + } + + public void setSubdetectorName(String subdetectorName) { + this.subdetectorName = subdetectorName; + } + + public static IIdentifierHelper getHelper() { + return helper; + } + + public static Subdetector getSubdetector() { + return subdetector; + } + + public static boolean badChannelsLoaded() { + return badChannelsLoaded; + } + + public static void loadPedestals() { + ConditionsManager conditions = ConditionsManager.defaultInstance(); + try { + Reader pedestalsReader = conditions.getRawConditions("calibECal/default01.ped").getReader(); + loadPedestals(pedestalsReader, 1); + pedestalsReader = conditions.getRawConditions("calibECal/default02.ped").getReader(); + loadPedestals(pedestalsReader, 2); + } catch (IOException e) { + throw new RuntimeException("couldn't get pedestals file", e); + } + } + + public static void loadPedestals(Reader reader, int crate) { + + System.out.println("reading pedestals for ECal"); + + BufferedReader bufferedReader = new BufferedReader(reader); + String line; + while (true) { + try { + line = bufferedReader.readLine(); + } catch (IOException e) { + throw new RuntimeException("couldn't parse pedestals file", e); + } + if (line == null) { + break; + } + + if (line.indexOf("#") != -1) { + line = line.substring(0, line.indexOf("#")); + } + + StringTokenizer lineTok = new StringTokenizer(line); + + if (lineTok.countTokens() != 0) { + if (lineTok.countTokens() != 4) { + throw new RuntimeException("Invalid line in pedestals file: " + line); + } else { + short slot = Short.valueOf(lineTok.nextToken()); + short channel = Short.valueOf(lineTok.nextToken()); + double pedestal = Double.valueOf(lineTok.nextToken()); + double noise = Double.valueOf(lineTok.nextToken()); + long daqid = getDaqID(crate, slot, channel); + daqToPedestalMap.put(daqid, pedestal); + daqToNoiseMap.put(daqid, noise); + if (debug) { + System.out.printf("Channel %d: pede %.2f noise %.2f (crate %d slot %d channel %d)\n", daqid,pedestal,noise,crate,slot,channel); + } + } + } + } + } + + private static void loadBadChannels(Subdetector ecal) { + + System.out.println("reading ECal bad channels"); + + IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields()); + expId.setValue(helper.getFieldIndex("system"), ecal.getSystemID()); + ConditionsManager conditions = ConditionsManager.defaultInstance(); + BufferedReader bufferedReader; + try { + bufferedReader = new BufferedReader(conditions.getRawConditions("daqmap/ecal.badchannels").getReader()); + } catch (IOException e) { + throw new RuntimeException("couldn't get ECal bad channels from conditions manager", e); + } + String line; + while (true) { + try { + line = bufferedReader.readLine(); + } catch (IOException e) { + throw new RuntimeException("couldn't parse ECal bad channels", e); + } + if (line == null) { + break; + } + + if (line.indexOf("#") != -1) { + line = line.substring(0, line.indexOf("#")); + } + + StringTokenizer lineTok = new StringTokenizer(line); + + if (lineTok.countTokens() != 0) { + if (lineTok.countTokens() != 2) { + throw new RuntimeException("Invalid line in ECal bad channels: " + line); + } else { + int x = Integer.valueOf(lineTok.nextToken()); + int y = Integer.valueOf(lineTok.nextToken()); + expId.setValue(helper.getFieldIndex("ix"), x); + expId.setValue(helper.getFieldIndex("iy"), y); + badChannelsSet.add(helper.pack(expId).getValue()); + if (debug) { + System.out.printf("Channel %d is bad (x=%d y=%d)\n", helper.pack(expId).getValue(),x,y); + } + } + } + } + badChannelsLoaded = true; + } + + public static void loadGains() { + if (debug) { + System.out.println("Loading gains"); + } + BufferedReader bufferedReader; + ConditionsManager conditions = ConditionsManager.defaultInstance(); + try { + bufferedReader = new BufferedReader(conditions.getRawConditions("calibECal/default.gain").getReader()); + } catch (IOException e) { + throw new RuntimeException("couldn't get gain file", e); + } + + String line; + while (true) { + try { + line = bufferedReader.readLine(); + } catch (IOException e) { + throw new RuntimeException("couldn't parse gain file", e); + } + if (line == null) { + break; + } + + if (line.indexOf("#") != -1) { + line = line.substring(0, line.indexOf("#")); + } + + StringTokenizer lineTok = new StringTokenizer(line); + + if (lineTok.countTokens() != 0) { + if (lineTok.countTokens() != 3) { + throw new RuntimeException("Invalid line in gain file: " + line); + } else { + int x = Integer.valueOf(lineTok.nextToken()); + int y = Integer.valueOf(lineTok.nextToken()); + double gain = Double.valueOf(lineTok.nextToken()); + physicalToGainMap.put(makePhysicalID(x, y), gain); + if (debug) { + System.out.printf("Channel %d: gain %.2f (x=%d y=%d)\n", makePhysicalID(x, y),gain,x,y); + } + } + } + } + } + + public static boolean isBadChannel(long id) { + return badChannelsSet.contains(id); + } + + private static void fillDaqCellMap(Subdetector ecal) { + + System.out.println("reading ECal DAQ map"); + + IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields()); + expId.setValue(helper.getFieldIndex("system"), ecal.getSystemID()); + + ConditionsManager conditions = ConditionsManager.defaultInstance(); + BufferedReader bufferedReader; + try { + bufferedReader = new BufferedReader(conditions.getRawConditions("daqmap/ecal.txt").getReader()); + } catch (IOException e) { + throw new RuntimeException("couldn't get DAQ map from conditions manager", e); + } + String line; + while (true) { + try { + line = bufferedReader.readLine(); + } catch (IOException e) { + throw new RuntimeException("couldn't parse ECal DAQ map", e); + } + if (line == null) { + break; + } + + if (line.indexOf("#") != -1) { + line = line.substring(0, line.indexOf("#")); + } + + StringTokenizer lineTok = new StringTokenizer(line); + + if (lineTok.countTokens() != 0) { + if (lineTok.countTokens() != 5) { + throw new RuntimeException("Invalid line in ECal DAQ map: " + line); + } else { + int x = Integer.valueOf(lineTok.nextToken()); + int y = Integer.valueOf(lineTok.nextToken()); +// if (x>0 && y>0) x = 24-x; + expId.setValue(helper.getFieldIndex("ix"), x); + expId.setValue(helper.getFieldIndex("iy"), y); + int crate = Integer.valueOf(lineTok.nextToken()); + short slot = Short.valueOf(lineTok.nextToken()); + short channel = Short.valueOf(lineTok.nextToken()); + addMapEntry(helper.pack(expId).getValue(), getDaqID(crate, slot, channel)); + } + } + } + } + + public static long makePhysicalID(int ix, int iy) { + IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields()); + expId.setValue(helper.getFieldIndex("system"), subdetector.getSystemID()); + expId.setValue(helper.getFieldIndex("ix"), ix); + expId.setValue(helper.getFieldIndex("iy"), iy); + return helper.pack(expId).getValue(); + } + + private static void addMapEntry(long physicalID, long daqID) { + daqToPhysicalMap.put(daqID, physicalID); + physicalToDaqMap.put(physicalID, daqID); + } + + public static long getDaqID(int crate, short slot, short channel) { + return (((long) crate) << 32) | ((long) slot << 16) | (long) channel; + } + + public static Long daqToPhysicalID(int crate, short slot, short channel) { + return daqToPhysicalMap.get(getDaqID(crate, slot, channel)); + } + + public static int getCrate(long daqID) { + return (int) (daqID >>> 32); + } + + public static short getSlot(long daqID) { + return (short) ((daqID >>> 16) & 0xFFFF); + } + + public static short getChannel(long daqID) { + return (short) (daqID & 0xFFFF); + } + + public static Long physicalToDaqID(long physicalID) { + return physicalToDaqMap.get(physicalID); + } + + public static Long daqToPhysicalID(long daqID) { + return daqToPhysicalMap.get(daqID); + } + + public static Double daqToPedestal(long daqID) { + return daqToPedestalMap.get(daqID); + } + + public static Double physicalToPedestal(long physicalID) { + return daqToPedestalMap.get(physicalToDaqMap.get(physicalID)); + } + + public static Double physicalToGain(long physicalID) { + return physicalToGainMap.get(physicalID); + } +}
diff -N EcalTriggerFilterDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EcalTriggerFilterDriver.java 25 Feb 2013 22:39:24 -0000 1.1 @@ -0,0 +1,108 @@
+package org.lcsim.hps.recon.ecal; + +import java.util.ArrayList; +import java.util.List; +import java.util.Queue; +import java.util.concurrent.ArrayBlockingQueue; +import org.lcsim.event.CalorimeterHit; +import org.lcsim.event.EventHeader; +import org.lcsim.geometry.Detector; +import org.lcsim.util.Driver; + +/** + * Changes ECal hit IDs to match what the test run trigger sees. + * @version $Id: HPSEcalRawConverterDriver.java,v 1.2 2012/05/03 00:17:54 + * phansson Exp $ + */ +public class EcalTriggerFilterDriver extends Driver { + + private String ecalReadoutName = "EcalHits"; + private String inputCollection = "EcalReadoutHits"; + private String outputCollection = "EcalCalHits"; + private int topDelay = 0; + private int bottomDelay = 5; + private Queue<List<CalorimeterHit>> topHitsQueue = null; + private Queue<List<CalorimeterHit>> bottomHitsQueue = null; + + public EcalTriggerFilterDriver() { + } + + public void setOutputCollection(String outputCollection) { + this.outputCollection = outputCollection; + } + + public void setInputCollection(String inputCollection) { + this.inputCollection = inputCollection; + } + + @Override + public void startOfData() { + if (outputCollection == null) { + throw new RuntimeException("The parameter ecalCollectionName was not set!"); + } + + topHitsQueue = new ArrayBlockingQueue<List<CalorimeterHit>>(topDelay + 1); + for (int i = 0; i < topDelay; i++) { + topHitsQueue.add(new ArrayList<CalorimeterHit>()); + } + bottomHitsQueue = new ArrayBlockingQueue<List<CalorimeterHit>>(bottomDelay + 1); + for (int i = 0; i < bottomDelay; i++) { + bottomHitsQueue.add(new ArrayList<CalorimeterHit>()); + } + } + + @Override + public void detectorChanged(Detector detector) { + } + + @Override + public void process(EventHeader event) { + if (event.hasCollection(CalorimeterHit.class, inputCollection)) { + ArrayList<CalorimeterHit> newHits = new ArrayList<CalorimeterHit>(); + + ArrayList<CalorimeterHit> topHits = new ArrayList<CalorimeterHit>(); + ArrayList<CalorimeterHit> bottomHits = new ArrayList<CalorimeterHit>(); + + List<CalorimeterHit> hits = event.get(CalorimeterHit.class, inputCollection); + for (CalorimeterHit hit : hits) { + CalorimeterHit newHit = filterHit(hit); + if (newHit != null) { + if (hit.getIdentifierFieldValue("iy") > 0) { //should really be checking newHit, but it doesn't have metadata yet + topHits.add(newHit); + } else { + bottomHits.add(newHit); + } + } + } + topHitsQueue.add(topHits); + bottomHitsQueue.add(bottomHits); + newHits.addAll(topHitsQueue.poll()); + newHits.addAll(bottomHitsQueue.poll()); + int flags = 0; + event.put(outputCollection, newHits, CalorimeterHit.class, flags, ecalReadoutName); + } + } + + private CalorimeterHit filterHit(CalorimeterHit hit) { + int ix = hit.getIdentifierFieldValue("ix"); + int iy = hit.getIdentifierFieldValue("iy"); + long daqID = EcalConditions.physicalToDaqID(hit.getCellID()); + int crate = EcalConditions.getCrate(daqID); + short slot = EcalConditions.getSlot(daqID); + short channel = EcalConditions.getChannel(daqID); + + int delay = iy>0?topDelay:bottomDelay; + // no triggers from crate 1, slot 3 + if (crate == 1 && slot == 3) { + return null; + } + + // flip quadrant + if (ix > 0 && iy > 0) { + ix = 24 - ix; + } + long newID = EcalConditions.makePhysicalID(ix, iy); + //make new hit; set position to null so it gets recalculated + return new HPSCalorimeterHit(hit.getRawEnergy(), hit.getTime()+delay*4, newID, hit.getType()); + } +}
diff -N EcalEdepToTriggerConverterDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EcalEdepToTriggerConverterDriver.java 25 Feb 2013 22:39:24 -0000 1.1 @@ -0,0 +1,188 @@
+package org.lcsim.hps.recon.ecal; + +import java.util.ArrayList; +import java.util.List; +import org.lcsim.event.CalorimeterHit; +import org.lcsim.event.EventHeader; +import org.lcsim.geometry.Detector; +import org.lcsim.util.Driver; + +/** + * + * @version $Id: HPSEcalRawConverterDriver.java,v 1.2 2012/05/03 00:17:54 + * phansson Exp $ + */ +public class EcalEdepToTriggerConverterDriver extends Driver { + + private String ecalReadoutName = "EcalHits"; + private String inputCollection = "EcalHits"; + private String readoutCollection = "EcalCalHits"; + private String triggerCollection = "EcalTriggerHits"; + private boolean applyBadCrystalMap = true; + private double tp = 14.0; + private double readoutPeriod = 4.0; + private int readoutThreshold = 50; + private int triggerThreshold = 80; + private int truncateScale = 128; + private double pulseIntegral = tp * Math.E / readoutPeriod; + private double gainScale = 1.0; //gain miscalibration factor + private double _gain = -1.0; //constant gain, activated if >0 + + public EcalEdepToTriggerConverterDriver() { + } + + public void setTp(double tp) { + this.tp = tp; + } + + public void setReadoutCollection(String readoutCollection) { + this.readoutCollection = readoutCollection; + } + + public void setTriggerCollection(String triggerCollection) { + this.triggerCollection = triggerCollection; + } + + public void setInputCollection(String inputCollection) { + this.inputCollection = inputCollection; + } + + public void setApplyBadCrystalMap(boolean apply) { + this.applyBadCrystalMap = apply; + } + + public void setTruncateScale(int truncateScale) { + this.truncateScale = truncateScale; + } + + public void setConstantGain(double gain) { + this._gain = gain; + } + + @Override + public void startOfData() { + if (readoutCollection == null) { + throw new RuntimeException("The parameter ecalCollectionName was not set!"); + } + } + + @Override + public void detectorChanged(Detector detector) { + } + + public boolean isBadCrystal(CalorimeterHit hit) { + return EcalConditions.badChannelsLoaded() ? EcalConditions.isBadChannel(hit.getCellID()) : false; + } + + @Override + public void process(EventHeader event) { + ArrayList<CalorimeterHit> triggerHits = new ArrayList<CalorimeterHit>(); + ArrayList<CalorimeterHit> readoutHits = new ArrayList<CalorimeterHit>(); + + if (event.hasCollection(CalorimeterHit.class, inputCollection)) { + List<CalorimeterHit> hits = event.get(CalorimeterHit.class, inputCollection); + + for (CalorimeterHit hit : hits) { + if (applyBadCrystalMap && isBadCrystal(hit)) { + continue; + } + CalorimeterHit triggerHit = makeTriggerHit(hit); + if (triggerHit != null) { + triggerHits.add(triggerHit); + } + CalorimeterHit readoutHit = makeReadoutHit(hit); + if (readoutHit != null) { + readoutHits.add(readoutHit); + } + } + } + int flags = 0; + event.put(triggerCollection, triggerHits, CalorimeterHit.class, flags, ecalReadoutName); + event.put(readoutCollection, readoutHits, CalorimeterHit.class, flags, ecalReadoutName); + } + + public CalorimeterHit makeTriggerHit(CalorimeterHit hit) { + double amplitude = hitAmplitude(hit); + +// double time = readoutPeriod * (Math.random() - 1); + double time = 0 - hit.getTime(); + double triggerIntegral = 0; + boolean overThreshold = false; + while (true) { + double currentValue = amplitude * pulseAmplitude(time); + if (!overThreshold && currentValue > triggerThreshold) { + overThreshold = true; + } + if (overThreshold) { + triggerIntegral += amplitude * pulseAmplitude(time); + if (currentValue < triggerThreshold) { + break; + } + } + time += readoutPeriod; + + if (time > 200.0) { + break; + } + } + +// System.out.format("%f %f %f\n", readoutIntegral, amplitude, triggerIntegral); + + int truncatedIntegral = (int) Math.floor(triggerIntegral / truncateScale); + if (truncatedIntegral > 0) { + return new HPSCalorimeterHit(truncatedIntegral, hit.getTime(), hit.getCellID(), 0); + } + return null; + } + + public CalorimeterHit makeReadoutHit(CalorimeterHit hit) { + double amplitude = hitAmplitude(hit); + if (amplitude < readoutThreshold) { + return null; + } + double integral = hit.getRawEnergy()/ECalUtils.GeV * gainScale; + +// double thresholdCrossingTime = 0 - hit.getTime(); +// while (true) { +// double currentValue = amplitude * pulseAmplitude(thresholdCrossingTime); +// if (currentValue > readoutThreshold) { +// break; +// } +// thresholdCrossingTime += readoutPeriod; +// +// if (thresholdCrossingTime > 200.0) { +// break; +// } +// } +// +// double readoutIntegral = 0; +// for (int i = 0; i < 35; i++) { +// readoutIntegral += amplitude * pulseAmplitude(thresholdCrossingTime + (i - 5) * readoutPeriod); +// } +//// double integral = readoutIntegral * HPSEcalConditions.physicalToGain(id); +// System.out.format("dumb: %f, full: %f\n",hit.getRawEnergy() * 1000.0,readoutIntegral * HPSEcalConditions.physicalToGain(id)); + + CalorimeterHit h = new HPSCalorimeterHit(integral, hit.getTime(), hit.getCellID(), 0); + return h; + } + + private double hitAmplitude(CalorimeterHit hit) { + double gain = _gain > 0 ? _gain : EcalConditions.physicalToGain(hit.getCellID()); + return (hit.getRawEnergy() /ECalUtils.MeV) / (gain * pulseIntegral); + } + + private double pulseAmplitude(double time) { + if (time <= 0.0) { + return 0.0; + } + if (tp > 0.0) { + return (time / tp) * Math.exp(1.0 - time / tp); + } else { + if (time < -tp) { + return 1.0; + } else { + return 0.0; + } + } + } +}
diff -N EcalRawConverter.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EcalRawConverter.java 25 Feb 2013 22:39:24 -0000 1.1 @@ -0,0 +1,101 @@
+package org.lcsim.hps.recon.ecal; + +import org.lcsim.event.CalorimeterHit; +import org.lcsim.event.RawCalorimeterHit; +import org.lcsim.event.RawTrackerHit; +import org.lcsim.event.base.BaseRawCalorimeterHit; + +/** + * + * @version $Id: HPSEcalRawConverterDriver.java,v 1.2 2012/05/03 00:17:54 + * phansson Exp $ + */ +public class EcalRawConverter { + + private boolean debug = false; + private boolean constantGain = false; + private double gain; + + public EcalRawConverter() { + } + + public void setGain(double gain) { + constantGain = true; + this.gain = gain; + } + + public short sumADC(RawTrackerHit hit) { + //Sum all pedestal subtracted ADC values + //return scale * (amplitude + 0.5) + pedestal; + if (debug) { + System.out.println("Summing ADC for hit: " + hit.toString()); + } + double pedestal = EcalConditions.physicalToPedestal(hit.getCellID()); + short sum = 0; + short samples[] = hit.getADCValues(); + for (int isample = 0; isample < samples.length; ++isample) { + sum += (samples[isample] - pedestal); + if (debug) { + System.out.println("Sample " + isample + " " + samples[isample] + " pedestal " + pedestal + " (" + sum + ")"); + } + } + return sum; + } + + public CalorimeterHit HitDtoA(RawTrackerHit hit) { + double time = hit.getTime(); + long id = hit.getCellID(); + double rawEnergy; + if (constantGain) { + rawEnergy = gain * sumADC(hit) * ECalUtils.MeV; + } else { + rawEnergy = EcalConditions.physicalToGain(id) * sumADC(hit) * ECalUtils.MeV; + } +// double[] pos = hit.getDetectorElement().getGeometry().getPosition().v(); + CalorimeterHit h = new HPSCalorimeterHit(rawEnergy + 0.0000001, time, id, 0); + //+0.0000001 is a horrible hack to ensure rawEnergy!=BaseCalorimeterHit.UNSET_CORRECTED_ENERGY + return h; + } + + public CalorimeterHit HitDtoA(RawCalorimeterHit hit, int window) { + if (hit.getTimeStamp() % 64 != 0) { + System.out.println("unexpected timestamp " + hit.getTimeStamp()); + } + double time = hit.getTimeStamp() / 16.0; + long id = hit.getCellID(); + double rawEnergy; + if (constantGain) { + rawEnergy = gain * (hit.getAmplitude() - window * EcalConditions.physicalToPedestal(id)) * ECalUtils.MeV; + } else { + rawEnergy = EcalConditions.physicalToGain(id) * (hit.getAmplitude() - window * EcalConditions.physicalToPedestal(id)) * ECalUtils.MeV; + } + CalorimeterHit h = new HPSCalorimeterHit(rawEnergy + 0.0000001, time, id, 0); + //+0.0000001 is a horrible hack to ensure rawEnergy!=BaseCalorimeterHit.UNSET_CORRECTED_ENERGY + return h; + } + + public RawCalorimeterHit HitAtoD(CalorimeterHit hit, int window) { + int time = (int) (hit.getTime() * 16.0); + long id = hit.getCellID(); + int amplitude; + if (constantGain) { + amplitude = (int) Math.round((hit.getRawEnergy() / ECalUtils.MeV) / gain + window * EcalConditions.physicalToPedestal(id)); + } else { + amplitude = (int) Math.round((hit.getRawEnergy() / ECalUtils.MeV) / EcalConditions.physicalToGain(id) + window * EcalConditions.physicalToPedestal(id)); + } + RawCalorimeterHit h = new BaseRawCalorimeterHit(id, amplitude, time); + return h; + } + + public static CalorimeterHit HitDtoA(RawCalorimeterHit hit, int window, double g) { + if (hit.getTimeStamp() % 64 != 0) { + System.out.println("unexpected timestamp " + hit.getTimeStamp()); + } + double time = hit.getTimeStamp() / 16.0; + long id = hit.getCellID(); + double rawEnergy = g * (hit.getAmplitude() - window * EcalConditions.physicalToPedestal(id)) * ECalUtils.MeV; + CalorimeterHit h = new HPSCalorimeterHit(rawEnergy + 0.0000001, time, id, 0); + //+0.0000001 is a horrible hack to ensure rawEnergy!=BaseCalorimeterHit.UNSET_CORRECTED_ENERGY + return h; + } +}
diff -N HPSCalorimeterHit.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSCalorimeterHit.java 25 Feb 2013 22:39:24 -0000 1.1 @@ -0,0 +1,72 @@
+package org.lcsim.hps.recon.ecal; + +import hep.physics.vec.Hep3Vector; +import java.util.Comparator; +import org.lcsim.detector.IDetectorElement; +import org.lcsim.detector.IDetectorElementContainer; +import org.lcsim.event.CalorimeterHit; +import org.lcsim.event.base.BaseCalorimeterHit; + +/** + * An implementation of CalorimeterHit, with a constructor that sets rawEnergy + * for use in ECalReadout + * + * @author Sho Uemura + * @version $Id: HPSCalorimeterHit.java,v 1.1 2013/02/25 22:39:24 meeg Exp $ + */ +public class HPSCalorimeterHit extends BaseCalorimeterHit { + + /** + * Fully qualified constructor that sets rawEnergy + * + * @param energy Raw energy for this cell + * @param position Global Cartesian coordinate for this cell + * @param time Time of energy deposition + * @param id Cell ID + * @param type Type + */ + public HPSCalorimeterHit(double energy, double time, long id, int type) { + this.rawEnergy = energy; +// if (position != null) { +// this.positionVec = new BasicHep3Vector(position); +// } else { +// positionVec = null; +// } + this.time = time; + this.id = id; + this.type = type; + } + + @Override + public IDetectorElement getDetectorElement() { + if (de == null) { +// findDetectorElementByPosition(); + IDetectorElementContainer detectorElements = EcalConditions.getSubdetector().getDetectorElement().findDetectorElement(getIdentifier()); + if (detectorElements.size() != 1) { + throw new RuntimeException("Expected exactly one DetectorElement matching ID " + getIdentifier() + ", got " + detectorElements.size()); + } else { + de = detectorElements.get(0); + } + } + // setupDetectorElement(); + return de; + } + + @Override + public double[] getPosition() { + return getPositionVec().v(); + } + + @Override + public Hep3Vector getPositionVec() { + return this.getDetectorElement().getGeometry().getPosition(); + } + + static class TimeComparator implements Comparator<CalorimeterHit> { + + @Override + public int compare(CalorimeterHit o1, CalorimeterHit o2) { + return Double.compare(o1.getTime(), o2.getTime()); + } + } +}
diff -u -r1.6 -r1.7 --- EcalCrystalFilter.java 8 Dec 2012 01:12:17 -0000 1.6 +++ EcalCrystalFilter.java 25 Feb 2013 22:39:24 -0000 1.7 @@ -589,7 +589,7 @@
} } if (ok) {
- IIdentifierHelper helper = HPSEcalConditions.getHelper();
+ IIdentifierHelper helper = EcalConditions.getHelper();
IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields()); //expId.setValue(helper.getFieldIndex("system"), ecal.getSystemID()); expId.setValue(helper.getFieldIndex("ix"), x);
@@ -597,7 +597,7 @@
Long id = helper.pack(expId).getValue();
- System.out.printf("[%d,%d]\t%d\t%d\t%d\tTime:%f +- %f\tAmp:%f +- %f\n", x, y, HPSEcalConditions.getCrate(id), HPSEcalConditions.getSlot(id), HPSEcalConditions.getChannel(id), tPlots[x + 23][y + 5].mean(), tPlots[x + 23][y + 5].rms(), aPlots[x + 23][y + 5].mean(), aPlots[x + 23][y + 5].rms());
+ System.out.printf("[%d,%d]\t%d\t%d\t%d\tTime:%f +- %f\tAmp:%f +- %f\n", x, y, EcalConditions.getCrate(id), EcalConditions.getSlot(id), EcalConditions.getChannel(id), tPlots[x + 23][y + 5].mean(), tPlots[x + 23][y + 5].rms(), aPlots[x + 23][y + 5].mean(), aPlots[x + 23][y + 5].rms());
pWriter.printf("%d %d\n", x, y); }
@@ -618,8 +618,8 @@
for (int crate = 1; crate < 3; crate++) { for (short slot = 0; slot < 20; slot++) { for (short ch = 0; ch < 16; ch++) {
- Long id = HPSEcalConditions.daqToPhysicalID(crate, slot, ch); - IIdentifierHelper helper = HPSEcalConditions.getHelper();
+ Long id = EcalConditions.daqToPhysicalID(crate, slot, ch); + IIdentifierHelper helper = EcalConditions.getHelper();
if (id == null) { continue; }
diff -u -r1.3 -r1.4 --- FADCConverterDriver.java 13 May 2012 21:39:24 -0000 1.3 +++ FADCConverterDriver.java 25 Feb 2013 22:39:24 -0000 1.4 @@ -10,7 +10,7 @@
/** *
- * @version $Id: FADCConverterDriver.java,v 1.3 2012/05/13 21:39:24 meeg Exp $
+ * @version $Id: FADCConverterDriver.java,v 1.4 2013/02/25 22:39:24 meeg Exp $
*/ public class FADCConverterDriver extends Driver {
@@ -73,7 +73,7 @@
short[] window = hit.getADCValues(); long id = hit.getCellID(); //do DAQ readout
- double crystalThreshold = HPSEcalConditions.physicalToPedestal(id) + threshold;
+ double crystalThreshold = EcalConditions.physicalToPedestal(id) + threshold;
int adcSum = 0; int pointerOffset = 0; int numSamplesToRead = 0;
diff -u -r1.10 -r1.11 --- HPSEcalCluster.java 8 Dec 2012 01:12:16 -0000 1.10 +++ HPSEcalCluster.java 25 Feb 2013 22:39:24 -0000 1.11 @@ -13,14 +13,14 @@
* Cluster with position defined by seed hit (for 1-bit trigger) * * @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcalCluster.java,v 1.10 2012/12/08 01:12:16 meeg Exp $
+ * @version $Id: HPSEcalCluster.java,v 1.11 2013/02/25 22:39:24 meeg Exp $
*/ public class HPSEcalCluster extends BasicCluster { private CalorimeterHit seedHit = null; private long cellID;
- static final double eCriticalW = 800.0*HPSECalUtils.MeV/(74+1);
+ static final double eCriticalW = 800.0*ECalUtils.MeV/(74+1);
static final double radLenW = 8.8; //mm double[] electronPosAtDepth = new double[3]; private boolean needsElectronPosCalculation = true;
@@ -42,7 +42,7 @@
if (hit == null) { throw new RuntimeException("HPSEcalCluster has no hits"); }
- seedHit = new HPSRawCalorimeterHit(0.0, 0.0, cellID, hit.getType());
+ seedHit = new HPSCalorimeterHit(0.0, 0.0, cellID, hit.getType());
seedHit.setMetaData(hit.getMetaData()); } return seedHit;
diff -u -r1.8 -r1.9 --- HPSRawCalorimeterHit.java 1 Oct 2012 21:22:54 -0000 1.8 +++ HPSRawCalorimeterHit.java 25 Feb 2013 22:39:24 -0000 1.9 @@ -1,72 +1,60 @@
package org.lcsim.hps.recon.ecal;
-import hep.physics.vec.Hep3Vector;
import java.util.Comparator;
-import org.lcsim.detector.IDetectorElement; -import org.lcsim.detector.IDetectorElementContainer;
import org.lcsim.event.CalorimeterHit;
-import org.lcsim.event.base.BaseCalorimeterHit;
+import org.lcsim.event.RawCalorimeterHit;
/**
- * An implementation of CalorimeterHit, with a constructor that sets rawEnergy - * for use in ECalReadout
*
- * @author Sho Uemura - * @version $Id: HPSRawCalorimeterHit.java,v 1.8 2012/10/01 21:22:54 phansson Exp $
+ * @author Sho Uemura <[log in to unmask]> + * @version $Id: HPSRawCalorimeterHit.java,v 1.9 2013/02/25 22:39:24 meeg Exp $
*/
-public class HPSRawCalorimeterHit extends BaseCalorimeterHit {
+public class HPSRawCalorimeterHit implements RawCalorimeterHit {
- /** - * Fully qualified constructor that sets rawEnergy - * - * @param energy Raw energy for this cell - * @param position Global Cartesian coordinate for this cell - * @param time Time of energy deposition - * @param id Cell ID - * @param type Type - */ - public HPSRawCalorimeterHit(double energy, double time, long id, int type) { - this.rawEnergy = energy; -// if (position != null) { -// this.positionVec = new BasicHep3Vector(position); -// } else { -// positionVec = null; -// } - this.time = time; - this.id = id; - this.type = type; - }
+ long cellID; + int amplitude; + int timeStamp; + int windowSize; + CalorimeterHit analogHit = null; + + public HPSRawCalorimeterHit(long cellID, int amplitude, int timeStamp, int windowSize) { + this.cellID = cellID; + this.amplitude = amplitude; + this.timeStamp = timeStamp; + this.windowSize = windowSize; + }
@Override
- public IDetectorElement getDetectorElement() { - if (de == null) { -// findDetectorElementByPosition(); - IDetectorElementContainer detectorElements = HPSEcalConditions.getSubdetector().getDetectorElement().findDetectorElement(getIdentifier()); - if (detectorElements.size() != 1) { - throw new RuntimeException("Expected exactly one DetectorElement matching ID " + getIdentifier() + ", got " + detectorElements.size()); - } else { - de = detectorElements.get(0); - } - } - // setupDetectorElement(); - return de; - }
+ public long getCellID() { + return cellID; + }
@Override
- public double[] getPosition() { - return getPositionVec().v(); - }
+ public int getAmplitude() { + return amplitude; + }
@Override
- public Hep3Vector getPositionVec() { - return this.getDetectorElement().getGeometry().getPosition(); - } - - static class TimeComparator implements Comparator<CalorimeterHit> { - - @Override - public int compare(CalorimeterHit o1, CalorimeterHit o2) { - return Double.compare(o1.getTime(), o2.getTime()); - } - } -}
+ public int getTimeStamp() { + return timeStamp; + } + + public int getWindowSize() { + return windowSize; + } + + public CalorimeterHit getAnalogHit() { + return analogHit; + } + + public void setAnalogHit(CalorimeterHit analogHit) { + this.analogHit = analogHit; + } + + public static class TimeComparator implements Comparator<RawCalorimeterHit> { + + public int compare(RawCalorimeterHit o1, RawCalorimeterHit o2) { + return o1.getTimeStamp() - o2.getTimeStamp(); + } + } +}
\ No newline at end of file
diff -N HPSEcal1BitClusterer.java --- HPSEcal1BitClusterer.java 8 Dec 2012 01:12:17 -0000 1.20 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,380 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.lcsim.event.CalorimeterHit; -import org.lcsim.event.Cluster; -import org.lcsim.event.EventHeader; -import org.lcsim.geometry.Detector; -import org.lcsim.geometry.IDDecoder; -import org.lcsim.geometry.subdetector.HPSEcal3.NeighborMap; -import org.lcsim.geometry.subdetector.HPSEcal3; -import org.lcsim.util.Driver; -import org.lcsim.util.lcio.LCIOConstants; - -/** - * Creates clusters from CalorimeterHits in the HPSEcal detector. - * - * The clustering algorithm is from JLab Hall B 6 GeV DVCS Trigger Design doc. - * - * @author Jeremy McCormick <[log in to unmask]> - * @author Tim Nelson <[log in to unmask]> - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSEcal1BitClusterer.java,v 1.20 2012/12/08 01:12:17 meeg Exp $ - */ -public class HPSEcal1BitClusterer extends Driver { - - HPSEcal3 ecal; - IDDecoder dec; - String ecalName; - String ecalCollectionName; - String vetoCollectionName; - String clusterCollectionName = "EcalClusters"; - //set bounds for a range of crystals to turn off in the clusterer - int xMin = 0; - int xMax = 0; - Map<Long, Integer> hitCounts = null; - Map<Long, CalorimeterHit> hitMap = null; - // Threshold hit count for cluster. Cluster must have more than this many hits. - int clusterThreshold = 5; - // Map of crystals to their neighbors. - NeighborMap neighborMap = null; - - public HPSEcal1BitClusterer() { - } - - public void setClusterCollectionName(String clusterCollectionName) { - this.clusterCollectionName = clusterCollectionName; - } - - public void setEcalCollectionName(String ecalCollectionName) { - this.ecalCollectionName = ecalCollectionName; - } - - public void setVetoCollectionName(String vetoCollectionName) { - this.vetoCollectionName = vetoCollectionName; - } - - public void setxMax(int xMax) { - this.xMax = xMax; - } - - public void setxMin(int xMin) { - this.xMin = xMin; - } - - public void setClusterThreshold(int clusterThreshold) { - this.clusterThreshold = clusterThreshold; - } - - public void setEcalName(String ecalName) { - this.ecalName = ecalName; - } - - @Override - public void startOfData() { - if (ecalCollectionName == null) { - throw new RuntimeException("The parameter ecalCollectionName was not set!"); - } - - if (ecalName == null) { - throw new RuntimeException("The parameter ecalName was not set!"); - } - } - - @Override - public void detectorChanged(Detector detector) { - // Get the Subdetector. - ecal = (HPSEcal3) detector.getSubdetector(ecalName); - - // Get the decoder for the ECal IDs. - dec = ecal.getIDDecoder(); - - // Cache ref to neighbor map. - neighborMap = ecal.getNeighborMap(); - - //System.out.println(ecal.getName()); - //System.out.println(" nx="+ecal.nx()); - //System.out.println(" ny="+ecal.ny()); - //System.out.println(" beamgap="+ecal.beamGap()); - //System.out.println(" dface="+ecal.distanceToFace()); - - //System.out.println(neighborMap.toString()); - } - - @Override - public void process(EventHeader event) { - //System.out.println(this.getClass().getCanonicalName() + " - process"); - - // Get the list of raw ECal hits. - List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName); - if (hits == null) { - throw new RuntimeException("Event is missing ECal raw hits collection!"); - } - List<CalorimeterHit> vetoHits = null; - - // Get the list of raw ECal hits. - if (vetoCollectionName != null) { - vetoHits = event.get(CalorimeterHit.class, vetoCollectionName); - if (vetoHits == null) { - throw new RuntimeException("Event is missing ECal veto hits collection!"); - } - } - - countHits(hits, vetoHits); - - // Put Cluster collection into event. - int flag = 1 << LCIOConstants.CLBIT_HITS; - event.put(clusterCollectionName, createClusters(), Cluster.class, flag); - } - - public void countHits(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) { - // Hit map. - hitMap = new HashMap<Long, CalorimeterHit>(); - HashMap<Long, CalorimeterHit> vetoMap = new HashMap<Long, CalorimeterHit>(); - - if (vetoHits != null) { - for (CalorimeterHit hit : vetoHits) { - vetoMap.put(hit.getCellID(), hit); - } - } - - hitCounts = new HashMap<Long, Integer>(); - // Loop over ECal hits to count hit towers - for (CalorimeterHit hit : hits) { - if (vetoMap.get(hit.getCellID()) != null) { - continue; - } - - int ix = hit.getIdentifierFieldValue("ix"); - if (ix >= xMin && ix <= xMax) { - continue; - } - - // Make a hit map for quick lookup by ID. - hitMap.put(hit.getCellID(), hit); - - // Get neighbor crystal IDs. - Set<Long> neighbors = neighborMap.get(hit.getCellID()); - - if (neighbors == null) { - throw new RuntimeException("Oops! Set of neighbors is null!"); - } - - Integer hitCount = hitCounts.get(hit.getCellID()); - if (hitCount == null) { - hitCounts.put(hit.getCellID(), 1); - } else { - hitCounts.put(hit.getCellID(), hitCount + 1); - } - - // Loop over neighbors to make hit list for cluster. - for (Long neighborId : neighbors) { - hitCount = hitCounts.get(neighborId); - if (hitCount == null) { - hitCounts.put(neighborId, 1); - } else { - hitCounts.put(neighborId, hitCount + 1); - } - } - } - } - - public List<Cluster> createClusters() { - // New Cluster list to be added to event. - List<Cluster> clusters = new ArrayList<Cluster>(); - - //for each crystal with a nonzero hit count, test for cluster - for (Long possibleCluster : hitCounts.keySet()) { - //System.out.printf("%d, %d hits\n",possibleCluster,hitCounts.get(possibleCluster)); - if (hitCounts.get(possibleCluster) <= clusterThreshold) { - continue; - } - - // Get neighbor crystal IDs. - Set<Long> neighbors = neighborMap.get(possibleCluster); - - if (neighbors == null) { - throw new RuntimeException("Oops! Set of neighbors is null!"); - } - - //Apply peak detector scheme. - // Set the ID. - dec.setID(possibleCluster); - // Get ID field values. - int x1 = dec.getValue("ix"); - int y1 = dec.getValue("iy"); - Integer hitCount = hitCounts.get(possibleCluster); - - //System.out.printf("Possible cluster: x: %d, y: %d, hits: %d\n",x1,y1,hitCount); - boolean isCluster = true; - for (Long neighborId : neighbors) { - // Set the ID. - dec.setID(neighborId); - Integer neighborHitCount = hitCounts.get(neighborId); - if (neighborHitCount == null) { - continue; - } - // Get ID field values. - int x2 = dec.getValue("ix"); - int y2 = dec.getValue("iy"); - if (y1 > 0) { - if (x1 > 0) { - //quadrant 1 - if (x1 == 1) { - //special case: left edge of quadrant - if (x1 > x2 && y1 < y2) { - if (hitCount > neighborHitCount) { - continue; - } - } else if (x1 > x2) { - if (hitCount >= neighborHitCount) { - continue; - } - } else if (x1 < x2) { - if (hitCount > neighborHitCount) { - continue; - } - } else if (y1 < y2) { - if (hitCount >= neighborHitCount) { - continue; - } - } else { - if (hitCount > neighborHitCount) { - continue; - } - } - } else { - if (x1 > x2) { - if (hitCount >= neighborHitCount) { - continue; - } - } else if (x1 < x2) { - if (hitCount > neighborHitCount) { - continue; - } - } else if (y1 < y2) { - if (hitCount >= neighborHitCount) { - continue; - } - } else { - if (hitCount > neighborHitCount) { - continue; - } - } - } - } else { - //quadrant 2 - if (y1 > y2) { - if (hitCount >= neighborHitCount) { - continue; - } - } else if (y1 < y2) { - if (hitCount > neighborHitCount) { - continue; - } - } else if (x1 > x2) { - if (hitCount >= neighborHitCount) { - continue; - } - } else { - if (hitCount > neighborHitCount) { - continue; - } - } - } - } else { - if (x1 < 0) { - //quadrant 3 - if (x1 == 1) { - //special case: left edge of quadrant - if (x1 < x2 && y1 > y2) { - if (hitCount > neighborHitCount) { - continue; - } - } else if (x1 < x2) { - if (hitCount >= neighborHitCount) { - continue; - } - } else if (x1 > x2) { - if (hitCount > neighborHitCount) { - continue; - } - } else if (y1 > y2) { - if (hitCount >= neighborHitCount) { - continue; - } - } else { - if (hitCount > neighborHitCount) { - continue; - } - } - } else { - if (x1 < x2) { - if (hitCount >= neighborHitCount) { - continue; - } - } else if (x1 > x2) { - if (hitCount > neighborHitCount) { - continue; - } - } else if (y1 > y2) { - if (hitCount >= neighborHitCount) { - continue; - } - } else { - if (hitCount > neighborHitCount) { - continue; - } - } - } - } else { - //quadrant 4 - if (y1 < y2) { - if (hitCount >= neighborHitCount) { - continue; - } - } else if (y1 > y2) { - if (hitCount > neighborHitCount) { - continue; - } - } else if (x1 < x2) { - if (hitCount >= neighborHitCount) { - continue; - } - } else { - if (hitCount > neighborHitCount) { - continue; - } - } - } - } - isCluster = false; - break; - } - - if (isCluster) { - //System.out.printf("Cluster: x: %d, y: %d, side:%d, hits: %d\n",x1,y1,side1,hitCount); - HPSEcalCluster cluster = new HPSEcalCluster(possibleCluster); - CalorimeterHit hit = hitMap.get(possibleCluster); - if (hit != null /*&& hit.getRawEnergy() > hitEMin && hit.getRawEnergy() < hitEMax*/) { - cluster.addHit(hit); - } - - for (Long neighborId : neighbors) { - // Find the neighbor hit in the event if it exists. - hit = hitMap.get(neighborId); - if (hit != null /*&& hit.getRawEnergy() > hitEMin && hit.getRawEnergy() < hitEMax*/) { - cluster.addHit(hit); - } - } - clusters.add(cluster); - } - } - return clusters; - } -}
diff -N HPSEcalSimpleReadoutDriver.java --- HPSEcalSimpleReadoutDriver.java 8 Dec 2012 01:12:17 -0000 1.10 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,58 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.lcsim.event.CalorimeterHit; - -/** - * Performs readout of ECal hits. - * No time evolution - this just integrates all hits in a cycle. - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSEcalSimpleReadoutDriver.java,v 1.10 2012/12/08 01:12:17 meeg Exp $ - */ -public class HPSEcalSimpleReadoutDriver extends HPSEcalReadoutDriver<HPSRawCalorimeterHit> { - //buffer for deposited energy - Map<Long, Double> eDepMap = null; - - public HPSEcalSimpleReadoutDriver() { - hitClass = HPSRawCalorimeterHit.class; - } - - @Override - protected void readHits(List<HPSRawCalorimeterHit> hits) { - for (Long cellID : eDepMap.keySet()) { -// int ix = dec.getValue("ix"); -// int iy = dec.getValue("iy"); -// //temporary hack to disable crystals and flip X coordinate -// int side = dec.getValue("side"); -// if (iy == 1 && ix*side >= -10 && ix*side <= -2) -// continue; - if (eDepMap.get(cellID) > threshold) - hits.add(new HPSRawCalorimeterHit(eDepMap.get(cellID), readoutTime(), cellID, hitType)); - } - //reset hit integration - eDepMap = new HashMap<Long, Double>(); - } - - @Override - protected void putHits(List<CalorimeterHit> hits) { - //fill the readout buffers - for (CalorimeterHit hit : hits) { - Double eDep = eDepMap.get(hit.getCellID()); - if (eDep == null) { - eDepMap.put(hit.getCellID(), hit.getRawEnergy()); - } else { - eDepMap.put(hit.getCellID(), eDep + hit.getRawEnergy()); - } - } - } - - @Override - protected void initReadout() { - //initialize buffers - eDepMap = new HashMap<Long, Double>(); - } -}
diff -N HPSEcalCTPClusterer.java --- HPSEcalCTPClusterer.java 20 Nov 2012 23:25:09 -0000 1.8 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,308 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.PriorityQueue; -import java.util.Set; - -import org.lcsim.event.CalorimeterHit; -//import org.lcsim.event.Cluster; -import org.lcsim.event.EventHeader; -import org.lcsim.geometry.Detector; -import org.lcsim.geometry.IDDecoder; -import org.lcsim.geometry.subdetector.HPSEcal3.NeighborMap; -import org.lcsim.geometry.subdetector.HPSEcal3; -import org.lcsim.hps.recon.ecal.HPSEcalCTPClusterer.TimeComparator; -import org.lcsim.util.Driver; -import org.lcsim.util.lcio.LCIOConstants; - -/** - * Creates clusters from CalorimeterHits in the HPSEcal detector. - * - * The clustering algorithm is from JLab Hall B 6 GeV DVCS Trigger Design doc. - * - * @author Jeremy McCormick <[log in to unmask]> - * @author Tim Nelson <[log in to unmask]> - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSEcalCTPClusterer.java,v 1.8 2012/11/20 23:25:09 meeg Exp $ - */ -public class HPSEcalCTPClusterer extends Driver { - - HPSEcal3 ecal; - IDDecoder dec; - String ecalName; - String ecalCollectionName; - String clusterCollectionName = "EcalClusters"; - Set<Long> clusterCenters = null; - Map<Long, Double> hitSums = null; - Map<Long, CalorimeterHit> hitMap = null; - // Map of crystals to their neighbors. - NeighborMap neighborMap = null; - double clusterWindow = -1; - double addEMin = 0; - - public HPSEcalCTPClusterer() { - } - - public void setAddEMin(double addEMin) { - this.addEMin = addEMin; - } - - public void setClusterWindow(double clusterWindow) { - this.clusterWindow = clusterWindow; - } - - public void setClusterCollectionName(String clusterCollectionName) { - this.clusterCollectionName = clusterCollectionName; - } - - public void setEcalCollectionName(String ecalCollectionName) { - this.ecalCollectionName = ecalCollectionName; - } - - public void setEcalName(String ecalName) { - this.ecalName = ecalName; - } - - @Override - public void startOfData() { - if (ecalCollectionName == null) { - throw new RuntimeException("The parameter ecalCollectionName was not set!"); - } - - if (ecalName == null) { - throw new RuntimeException("The parameter ecalName was not set!"); - } - } - - @Override - public void detectorChanged(Detector detector) { - // Get the Subdetector. - ecal = (HPSEcal3) detector.getSubdetector(ecalName); - - // Get the decoder for the ECal IDs. - dec = ecal.getIDDecoder(); - - // Cache ref to neighbor map. - neighborMap = ecal.getNeighborMap(); - - clusterCenters = new HashSet<Long>(); - //Make set of valid cluster centers. - for (Long cellID : neighborMap.keySet()) { - boolean isValidCenter = true; - Set<Long> neighbors = neighborMap.get(cellID); - for (Long neighborID : neighbors) { - Set<Long> neighborneighbors = new HashSet<Long>(); - neighborneighbors.addAll(neighborMap.get(neighborID)); - neighborneighbors.add(neighborID); - - if (neighborneighbors.containsAll(neighbors)) { - isValidCenter = false; - break; - } - } - if (isValidCenter) { - clusterCenters.add(cellID); - } - } - - //System.out.println(ecal.getName()); - //System.out.println(" nx="+ecal.nx()); - //System.out.println(" ny="+ecal.ny()); - //System.out.println(" beamgap="+ecal.beamGap()); - //System.out.println(" dface="+ecal.distanceToFace()); - - //System.out.println(neighborMap.toString()); - } - - @Override - public void process(EventHeader event) { - //System.out.println(this.getClass().getCanonicalName() + " - process"); - - if (event.hasCollection(CalorimeterHit.class, ecalCollectionName)) { - // Get the list of raw ECal hits. - List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName); - - List<HPSEcalCluster> clusters; - - if (clusterWindow >= 0) { - PriorityQueue<CalorimeterHit> futureHits = new PriorityQueue<CalorimeterHit>(10, new TimeComparator()); - PriorityQueue<CalorimeterHit> pastHits = new PriorityQueue<CalorimeterHit>(10, new TimeComparator()); - clusters = new ArrayList<HPSEcalCluster>(); - - for (CalorimeterHit hit : hits) { - if (hit.getRawEnergy() > addEMin) { - futureHits.add(hit); - } - } - - while (!futureHits.isEmpty()) { - CalorimeterHit nextHit = futureHits.poll(); - pastHits.add(nextHit); - while (!futureHits.isEmpty() && futureHits.peek().getTime() == nextHit.getTime()) { - pastHits.add(futureHits.poll()); - } - while (pastHits.peek().getTime() < nextHit.getTime() - clusterWindow) { - pastHits.poll(); - } - sumHits(pastHits); - clusters.addAll(createClusters()); - } - } else { - sumHits(hits); - clusters = createClusters(); - } - - // Put Cluster collection into event. - int flag = 1 << LCIOConstants.CLBIT_HITS; - event.put(clusterCollectionName, clusters, HPSEcalCluster.class, flag); - } - } - - public void sumHits(Collection<CalorimeterHit> hits) { - // Hit map. - hitMap = new HashMap<Long, CalorimeterHit>(); - - hitSums = new HashMap<Long, Double>(); - // Loop over ECal hits to compute energy sums - for (CalorimeterHit hit : hits) { -// System.out.format("hit: %f\n",hit.getRawEnergy()); - // Make a hit map for quick lookup by ID. - hitMap.put(hit.getCellID(), hit); - - // Get neighbor crystal IDs. - Set<Long> neighbors = neighborMap.get(hit.getCellID()); - - if (neighbors == null) { - throw new RuntimeException("Oops! Set of neighbors is null!"); - } - - Double hitSum; - - if (clusterCenters.contains(hit.getCellID())) { - hitSum = hitSums.get(hit.getCellID()); - if (hitSum == null) { - hitSums.put(hit.getCellID(), hit.getRawEnergy()); - } else { - hitSums.put(hit.getCellID(), hitSum + hit.getRawEnergy()); - } - } - - // Loop over neighbors to make hit list for cluster. - for (Long neighborId : neighbors) { - if (!clusterCenters.contains(neighborId)) { - continue; - } - hitSum = hitSums.get(neighborId); - if (hitSum == null) { - hitSums.put(neighborId, hit.getRawEnergy()); - } else { - hitSums.put(neighborId, hitSum + hit.getRawEnergy()); - } - } - } - } - - public List<HPSEcalCluster> createClusters() { -// boolean printClusters; - // New Cluster list to be added to event. - List<HPSEcalCluster> clusters = new ArrayList<HPSEcalCluster>(); - //System.out.println("New event"); - //for each crystal with a nonzero hit count, test for cluster - for (Long possibleCluster : hitSums.keySet()) { - Double thisSum = hitSums.get(possibleCluster); - - // Get neighbor crystal IDs. - Set<Long> neighbors = neighborMap.get(possibleCluster); - - if (neighbors == null) { - throw new RuntimeException("Oops! Set of neighbors is null!"); - } - - //Apply peak detector scheme. - // Set the ID. - dec.setID(possibleCluster); - int x1 = dec.getValue("ix"); - int y1 = dec.getValue("iy"); -// System.out.printf("\nThis cluster: E= %f, ID=%d, x=%d, y=%d, neighbors=%d\n", thisSum, possibleCluster, x1, y1, neighbors.size()); - boolean isCluster = true; - for (Long neighborId : neighbors) { - // Set the ID. - dec.setID(neighborId); - int x2 = dec.getValue("ix"); - int y2 = dec.getValue("iy"); - - Double neighborSum = hitSums.get(neighborId); - if (neighborSum == null) { - continue; - } - -// System.out.printf("Neighbor cluster: E= %f, ID=%d, x=%d, y=%d, neighbors=%d\n", neighborSum, neighborId, x2, y2, neighborMap.get(neighborId).size()); - - if (neighborSum > thisSum) { -// System.out.println("Reject cluster: sum cut"); - isCluster = false; - break; - } // else if (false) { //ctp - // else if (neighborSum.equals(thisSum) && neighborId > possibleCluster) { //id - // else if (neighborSum.equals(thisSum) && (x1<x2 || (x1==x2 && Math.abs(y1)>Math.abs(y2)))) { //right_in - // else if (neighborSum.equals(thisSum) && (x1<x2 || (x1==x2 && Math.abs(y1)<Math.abs(y2)))) { //right_out - // else if (neighborSum.equals(thisSum) && (x1>x2 || (x1==x2 && Math.abs(y1)>Math.abs(y2)))) { //left_in - else if (neighborSum.equals(thisSum) && (x1 > x2 || (x1 == x2 && Math.abs(y1) < Math.abs(y2)))) { //left_out -// else if (neighborSum.equals(thisSum) && (x1<x2 || (x1==x2 && y1<y2))) { //right_up -// else if (neighborSum.equals(thisSum) && (x1>x2 || (x1==x2 && y1<y2))) { //left_up -// System.out.println("Reject cluster: tie-breaker cut"); - isCluster = false; - break; - } - } - - if (isCluster) { - List<CalorimeterHit> hits = new ArrayList<CalorimeterHit>(); - double clusterTime = Double.NEGATIVE_INFINITY; - CalorimeterHit hit = hitMap.get(possibleCluster); - if (hit != null) { - hits.add(hit); - if (hit.getTime() > clusterTime) { - clusterTime = hit.getTime(); - } - } - for (Long neighborId : neighbors) { - hit = hitMap.get(neighborId); - if (hit != null) { - hits.add(hit); - if (hit.getTime() > clusterTime) { - clusterTime = hit.getTime(); - } - } - } - CalorimeterHit seedHit = new HPSRawCalorimeterHit(0.0, clusterTime, possibleCluster, hits.get(0).getType()); - seedHit.setMetaData(hits.get(0).getMetaData()); - HPSEcalCluster cluster = new HPSEcalCluster(seedHit); - for (CalorimeterHit clusterHit : hits) { - cluster.addHit(clusterHit); - } - clusters.add(cluster); -// System.out.println(cluster.getEnergy()); - } - } - return clusters; - } - - static class TimeComparator implements Comparator<CalorimeterHit> { - - @Override - public int compare(CalorimeterHit o1, CalorimeterHit o2) { - if (o1.getTime() == o2.getTime()) { - return 0; - } else { - return (o1.getTime() > o2.getTime()) ? 1 : -1; - } - } - } -}
diff -N HPSEcalFADCReadoutDriver.java --- HPSEcalFADCReadoutDriver.java 8 Dec 2012 01:12:17 -0000 1.22 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,466 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import java.util.PriorityQueue; -import java.util.Set; -import org.lcsim.event.CalorimeterHit; -import org.lcsim.event.EventHeader; -import org.lcsim.event.RawCalorimeterHit; -import org.lcsim.event.RawTrackerHit; -import org.lcsim.event.base.BaseRawCalorimeterHit; -import org.lcsim.event.base.BaseRawTrackerHit; -import org.lcsim.geometry.Detector; -import org.lcsim.geometry.Subdetector; -import org.lcsim.geometry.subdetector.HPSEcal3; -import org.lcsim.hps.evio.EventConstants; -import org.lcsim.hps.util.ClockSingleton; -import org.lcsim.hps.util.RingBuffer; -import org.lcsim.util.lcio.LCIOConstants; - -/** - * Performs readout of ECal hits. - * Simulates time evolution of preamp output pulse. - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSEcalFADCReadoutDriver.java,v 1.22 2012/12/08 01:12:17 meeg Exp $ - */ -public class HPSEcalFADCReadoutDriver extends HPSEcalReadoutDriver<RawCalorimeterHit> { - - String ecalName = "Ecal"; - Subdetector ecal; - //buffer for deposited energy - private Map<Long, RingBuffer> eDepMap = null; - //ADC pipeline for readout - private Map<Long, FADCPipeline> pipelineMap = null; - //buffer for window sums - private Map<Long, Double> sumMap = null; - //buffer for timestamps - private Map<Long, Integer> timeMap = null; - //queue for hits to be output to clusterer - private PriorityQueue<HPSFADCCalorimeterHit> outputQueue = null; - //length of ring buffer (in readout cycles) - private int bufferLength = 100; - //length of readout pipeline (in readout cycles) - private int pipelineLength = 2000; - //shaper time constant in ns; negative values generate square pulses of the given width - private double tp = 14.0; - //delay (number of readout periods) between start of summing window and output of hit to clusterer - private int delay0 = 32; - //start of readout window relative to trigger time (in readout cycles) - //in FADC documentation, "Programmable Latency" or PL - private int readoutLatency = 100; - //number of ADC samples to read out - //in FADC documentation, "Programmable Trigger Window" or PTW - private int readoutWindow = 100; - //number of ADC samples to read out before each rising threshold crossing - //in FADC documentation, "number of samples before" or NSB - private int numSamplesBefore = 5; - //number of ADC samples to read out after each rising threshold crossing - //in FADC documentation, "number of samples before" or NSA - private int numSamplesAfter = 30; -// private HPSEcalConverter converter = null; - //output buffer for hits - private LinkedList<HPSFADCCalorimeterHit> buffer = new LinkedList<HPSFADCCalorimeterHit>(); - //number of readout periods for which a given hit stays in the buffer - private int coincidenceWindow = 2; - private double pulseIntegral; - //output collection name for hits read out from trigger - private String ecalReadoutCollectionName = "EcalReadoutHits"; - private int mode = EventConstants.ECAL_PULSE_INTEGRAL_MODE; - private int readoutThreshold = (int) threshold; - private int triggerThreshold = (int) threshold; - //amplitude ADC counts/GeV -// private double gain = 0.5*1000 * 80.0 / 60; - private double scaleFactor = 128; - private double fixedGain = -1; - private boolean constantTriggerWindow = false; - - public HPSEcalFADCReadoutDriver() { - flags = 0; - flags += 1 << LCIOConstants.RCHBIT_TIME; //store cell ID - hitClass = HPSFADCCalorimeterHit.class; -// converter = new HPSEcalConverter(null); - } - - public void setConstantTriggerWindow(boolean constantTriggerWindow) { - this.constantTriggerWindow = constantTriggerWindow; - } - - public void setFixedGain(double fixedGain) { - this.fixedGain = fixedGain; - } - - public void setEcalName(String ecalName) { - this.ecalName = ecalName; - } - - public void setReadoutThreshold(int readoutThreshold) { - this.readoutThreshold = readoutThreshold; - } - - public void setScaleFactor(double scaleFactor) { - this.scaleFactor = scaleFactor; - } - - public void setTriggerThreshold(int triggerThreshold) { - this.triggerThreshold = triggerThreshold; - } - - public void setEcalReadoutCollectionName(String ecalReadoutCollectionName) { - this.ecalReadoutCollectionName = ecalReadoutCollectionName; - } - - public void setNumSamplesAfter(int numSamplesAfter) { - this.numSamplesAfter = numSamplesAfter; - } - - public void setNumSamplesBefore(int numSamplesBefore) { - this.numSamplesBefore = numSamplesBefore; - } - - public void setReadoutLatency(int readoutLatency) { - this.readoutLatency = readoutLatency; - } - - public void setReadoutWindow(int readoutWindow) { - this.readoutWindow = readoutWindow; - } - - public void setCoincidenceWindow(int coincidenceWindow) { - this.coincidenceWindow = coincidenceWindow; - } - - public void setTp(double tp) { - this.tp = tp; - } - - public void setDelay0(int delay0) { - this.delay0 = delay0; - } - - public void setBufferLength(int bufferLength) { - this.bufferLength = bufferLength; - resetFADCBuffers(); - } - - public void setPipelineLength(int pipelineLength) { - this.pipelineLength = pipelineLength; - resetFADCBuffers(); - } - - public void setMode(int mode) { - this.mode = mode; - if (mode != EventConstants.ECAL_WINDOW_MODE && mode != EventConstants.ECAL_PULSE_MODE && mode != EventConstants.ECAL_PULSE_INTEGRAL_MODE) { - throw new IllegalArgumentException("invalid mode " + mode); - } - } - - @Override - protected void readHits(List<RawCalorimeterHit> hits) { - - for (Long cellID : eDepMap.keySet()) { - RingBuffer eDepBuffer = eDepMap.get(cellID); - - FADCPipeline pipeline = pipelineMap.get(cellID); - pipeline.step(); - double pedestal = HPSEcalConditions.physicalToPedestal(cellID); - //normalization constant from cal gain (MeV/integral bit) to amplitude gain (amplitude bit/GeV) - double gain; - if (fixedGain > 0) { - gain = 1.0 / (fixedGain * HPSECalUtils.MeV * pulseIntegral); - } else { - gain = 1.0 / (HPSEcalConditions.physicalToGain(cellID) * HPSECalUtils.MeV * pulseIntegral); - } - - double currentValue = gain * eDepBuffer.currentValue(); - pipeline.writeValue((int) Math.round(pedestal + currentValue)); - - Double sum = sumMap.get(cellID); - if (sum == null && currentValue > triggerThreshold) { - timeMap.put(cellID, readoutCounter); - if (constantTriggerWindow) { - double sumBefore = 0; - for (int i = 0; i < numSamplesBefore; i++) { - if (debug) { - System.out.format("trigger %d, %d: %d\n", cellID, i, pipeline.getValue(numSamplesBefore - i - 1)); - } - sumBefore += pipeline.getValue(numSamplesBefore - i - 1); - } - sumMap.put(cellID, sumBefore); - } else { - sumMap.put(cellID, currentValue); - } - } - if (sum != null) { - if (constantTriggerWindow) { - if (timeMap.get(cellID) + numSamplesAfter >= readoutCounter) { - if (debug) { - System.out.format("trigger %d, %d: %d\n", cellID, readoutCounter - timeMap.get(cellID) + numSamplesBefore - 1, pipeline.getValue(0)); - } - sumMap.put(cellID, sum + pipeline.getValue(0)); - } else if (timeMap.get(cellID) + delay0 <= readoutCounter) { -// System.out.printf("sum = %f\n", sum); - outputQueue.add(new HPSFADCCalorimeterHit(cellID, - (int) Math.round(sum / scaleFactor), - 64 * timeMap.get(cellID), - readoutCounter - timeMap.get(cellID) + 1)); - sumMap.remove(cellID); - } - } else { - if (currentValue < triggerThreshold || timeMap.get(cellID) + delay0 == readoutCounter) { -// System.out.printf("sum = %f\n",sum); - outputQueue.add(new HPSFADCCalorimeterHit(cellID, - (int) Math.round((sum + currentValue) / scaleFactor), - 64 * timeMap.get(cellID), - readoutCounter - timeMap.get(cellID) + 1)); - sumMap.remove(cellID); - } else { - sumMap.put(cellID, sum + currentValue); - } - } - } - eDepBuffer.step(); - } - while (outputQueue.peek() != null && outputQueue.peek().getTimeStamp() / 64 <= readoutCounter - delay0) { - if (outputQueue.peek().getTimeStamp() / 64 < readoutCounter - delay0) { - System.out.println("Stale hit in output queue"); - outputQueue.poll(); - } else { - buffer.add(outputQueue.poll()); - } - } - while (!buffer.isEmpty() && buffer.peek().getTimeStamp() / 64 <= readoutCounter - delay0 - coincidenceWindow) { - buffer.remove(); - } - if (debug) { - for (RawCalorimeterHit hit : buffer) { - System.out.format("new hit: energy %d\n", hit.getAmplitude()); - } - } - - hits.addAll(buffer); - } - - @Override - public void startOfData() { - super.startOfData(); - if (ecalReadoutCollectionName == null) { - throw new RuntimeException("The parameter ecalReadoutCollectionName was not set!"); - } - } - - @Override - protected void processTrigger(EventHeader event) { - switch (mode) { - case EventConstants.ECAL_WINDOW_MODE: - if (debug) { - System.out.println("Reading out ECal in window mode"); - } - event.put(ecalReadoutCollectionName, readWindow(), RawTrackerHit.class, 0, ecalReadoutName); - break; - case EventConstants.ECAL_PULSE_MODE: - if (debug) { - System.out.println("Reading out ECal in pulse mode"); - } - event.put(ecalReadoutCollectionName, readPulses(), RawTrackerHit.class, 0, ecalReadoutName); - break; - case EventConstants.ECAL_PULSE_INTEGRAL_MODE: - if (debug) { - System.out.println("Reading out ECal in integral mode"); - } - event.put(ecalReadoutCollectionName, readIntegrals(), RawCalorimeterHit.class, 0, ecalReadoutName); - break; - } - } - - protected short[] getWindow(long cellID) { - FADCPipeline pipeline = pipelineMap.get(cellID); - short[] adcValues = new short[readoutWindow]; - for (int i = 0; i < readoutWindow; i++) { - adcValues[i] = (short) pipeline.getValue(readoutLatency - i - 1); -// if (adcValues[i] != 0) { -// System.out.println("getWindow: " + adcValues[i] + " at i = " + i); -// } - } - return adcValues; - } - - protected List<RawTrackerHit> readWindow() { -// System.out.println("Reading FADC data"); - List<RawTrackerHit> hits = new ArrayList<RawTrackerHit>(); - for (Long cellID : pipelineMap.keySet()) { - short[] adcValues = getWindow(cellID); - hits.add(new BaseRawTrackerHit(cellID, 0, adcValues)); - } - return hits; - } - - protected List<RawTrackerHit> readPulses() { -// System.out.println("Reading FADC data"); - List<RawTrackerHit> hits = new ArrayList<RawTrackerHit>(); - for (Long cellID : pipelineMap.keySet()) { - short[] window = getWindow(cellID); - short[] adcValues = null; - int pointerOffset = 0; - int numSamplesToRead = 0; - int thresholdCrossing = 0; - for (int i = 0; i < readoutWindow; i++) { - if (numSamplesToRead != 0) { - adcValues[adcValues.length - numSamplesToRead] = window[i - pointerOffset]; - numSamplesToRead--; - if (numSamplesToRead == 0) { - hits.add(new BaseRawTrackerHit(cellID, thresholdCrossing, adcValues)); - } - } else if ((i == 0 || window[i - 1] <= HPSEcalConditions.physicalToPedestal(cellID) + readoutThreshold) && window[i] > HPSEcalConditions.physicalToPedestal(cellID) + readoutThreshold) { - thresholdCrossing = i; - pointerOffset = Math.min(numSamplesBefore, i); - numSamplesToRead = pointerOffset + Math.min(numSamplesAfter, readoutWindow - i - pointerOffset - 1); - adcValues = new short[numSamplesToRead]; - } - } - } - return hits; - } - - protected List<RawCalorimeterHit> readIntegrals() { -// System.out.println("Reading FADC data"); - List<RawCalorimeterHit> hits = new ArrayList<RawCalorimeterHit>(); - for (Long cellID : pipelineMap.keySet()) { - short[] window = getWindow(cellID); - int adcSum = 0; - int pointerOffset = 0; - int numSamplesToRead = 0; - int thresholdCrossing = 0; - if (window != null) { - for (int i = 0; i < readoutWindow; i++) { - if (numSamplesToRead != 0) { - if (debug) { - System.out.format("readout %d, %d: %d\n", cellID, numSamplesBefore + numSamplesAfter - numSamplesToRead, window[i - pointerOffset]); - } - adcSum += window[i - pointerOffset]; - numSamplesToRead--; - if (numSamplesToRead == 0) { - hits.add(new BaseRawCalorimeterHit(cellID, adcSum, 64 * thresholdCrossing)); - } - } else if ((i == 0 || window[i - 1] <= HPSEcalConditions.physicalToPedestal(cellID) + readoutThreshold) && window[i] > HPSEcalConditions.physicalToPedestal(cellID) + readoutThreshold) { - thresholdCrossing = i; - pointerOffset = Math.min(numSamplesBefore, i); - numSamplesToRead = pointerOffset + Math.min(numSamplesAfter, readoutWindow - i - pointerOffset - 1); - adcSum = 0; - } - } - } - } - return hits; - } - - @Override - protected void putHits(List<CalorimeterHit> hits) { - //fill the readout buffers - for (CalorimeterHit hit : hits) { - RingBuffer eDepBuffer = eDepMap.get(hit.getCellID()); - for (int i = 0; i < bufferLength; i++) { - eDepBuffer.addToCell(i, hit.getRawEnergy() * pulseAmplitude((i + 1) * readoutPeriod + readoutTime() - (ClockSingleton.getTime() + hit.getTime()))); - } - } - } - - @Override - protected void initReadout() { - //initialize buffers - sumMap = new HashMap<Long, Double>(); - timeMap = new HashMap<Long, Integer>(); - outputQueue = new PriorityQueue(20, new HPSFADCCalorimeterHit.TimeComparator()); - pulseIntegral = tp * Math.E / readoutPeriod; - resetFADCBuffers(); - } - - @Override - public void detectorChanged(Detector detector) { - // Get the Subdetector. - ecal = detector.getSubdetector(ecalName); - resetFADCBuffers(); - } - - private boolean resetFADCBuffers() { - if (ecal == null) { - return false; - } - eDepMap = new HashMap<Long, RingBuffer>(); - pipelineMap = new HashMap<Long, FADCPipeline>(); - Set<Long> cells = ((HPSEcal3) ecal).getNeighborMap().keySet(); - for (Long cellID : cells) { - eDepMap.put(cellID, new RingBuffer(bufferLength)); - pipelineMap.put(cellID, new FADCPipeline(pipelineLength, (int) Math.round(HPSEcalConditions.physicalToPedestal(cellID)))); - } - return true; - } - - private double pulseAmplitude(double time) { - if (time <= 0.0) { - return 0.0; - } - if (tp > 0.0) { - return (time / tp) * Math.exp(1.0 - time / tp); - } else { - if (time < -tp) { - return 1.0; - } else { - return 0.0; - } - } - } - - private class FADCPipeline { - - private int[] array; - private int size; - private int ptr; - - public FADCPipeline(int size) { - this.size = size; - array = new int[size]; //initialized to 0 - ptr = 0; - } - - //construct pipeline with a nonzero initial value - public FADCPipeline(int size, int init) { - this.size = size; - array = new int[size]; - for (int i = 0; i < size; i++) { - array[i] = init; - } - ptr = 0; - } - - /** - * Write value to current cell - */ - public void writeValue(int val) { - array[ptr] = val; - } - - /** - * Write value to current cell - */ - public void step() { - ptr++; - if (ptr == size) { - ptr = 0; - } - } - - //return content of specified cell (pos=0 for current cell) - public int getValue(int pos) { - if (pos >= size || pos < 0) { - throw new ArrayIndexOutOfBoundsException(); - } - return array[((ptr - pos) % size + size) % size]; - } - } -}
\ No newline at end of file
diff -N TestRunRateAnalysis.java --- TestRunRateAnalysis.java 8 Dec 2012 01:12:17 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,169 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import hep.aida.IHistogram1D; -import hep.aida.IHistogram2D; -import java.util.List; -import org.lcsim.event.CalorimeterHit; -import org.lcsim.event.EventHeader; -import org.lcsim.event.MCParticle; -import org.lcsim.event.util.ParticleTypeClassifier; -import org.lcsim.util.Driver; -import org.lcsim.util.aida.AIDA; - -/** - * Reads clusters and makes trigger decision using opposite quadrant criterion. - * Prints triggers to file if file path specified. - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: TestRunRateAnalysis.java,v 1.4 2012/12/08 01:12:17 meeg Exp $ - */ -public class TestRunRateAnalysis extends Driver { - - AIDA aida = AIDA.defaultInstance(); - IHistogram2D eClusterVsP, photonEClusterVsP, electronEClusterVsP, positronEClusterVsP; - IHistogram2D eVsP, photonEVsP, electronEVsP, positronEVsP; - IHistogram1D eClusterOverP, photonEClusterOverP, electronEClusterOverP, positronEClusterOverP; - IHistogram1D eOverP, photonEOverP, electronEOverP, positronEOverP; - private String clusterCollectionName; - private String hitCollectionName = "EcalHits"; - int nTriggers; - private double clusterEnergyLow = 10; // - int deadtimelessTriggerCount; - int[] triggersY = new int[5]; - - public TestRunRateAnalysis() { - } - - @Override - public void startOfData() { - deadtimelessTriggerCount = 0; - - eClusterVsP = aida.histogram2D("All Cluster E vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); - photonEClusterVsP = aida.histogram2D("Photon Cluster E vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); - electronEClusterVsP = aida.histogram2D("Electron Cluster E vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); - positronEClusterVsP = aida.histogram2D("Positron Cluster E vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); - - eClusterOverP = aida.histogram1D("Cluster E over Pz, Pz > 0.6", 100, 0.0, 2.0); - photonEClusterOverP = aida.histogram1D("Photon Cluster E over Pz, Pz > 0.6", 100, 0.0, 2.0); - electronEClusterOverP = aida.histogram1D("Electron Cluster E over Pz, Pz > 0.6", 100, 0.0, 2.0); - positronEClusterOverP = aida.histogram1D("Positron Cluster E over Pz, Pz > 0.6", 100, 0.0, 2.0); - - eVsP = aida.histogram2D("All Edep vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); - photonEVsP = aida.histogram2D("Photon Edep vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); - electronEVsP = aida.histogram2D("Electron Edep vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); - positronEVsP = aida.histogram2D("Positron Edep vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); - - eOverP = aida.histogram1D("All Edep over Pz, Pz > 0.6", 100, 0.0, 2.0); - photonEOverP = aida.histogram1D("Photon Edep over Pz, Pz > 0.6", 100, 0.0, 2.0); - electronEOverP = aida.histogram1D("Electron Edep over Pz, Pz > 0.6", 100, 0.0, 2.0); - positronEOverP = aida.histogram1D("Positron Edep over Pz, Pz > 0.6", 100, 0.0, 2.0); - } - - public void setClusterEnergyLow(double clusterEnergyLow) { - this.clusterEnergyLow = clusterEnergyLow; - } - - public void setClusterCollectionName(String clusterCollectionName) { - this.clusterCollectionName = clusterCollectionName; - } - - @Override - public void process(EventHeader event) { - //System.out.println(this.getClass().getCanonicalName() + " - process"); - - // MCParticles - List<MCParticle> mcparticles = event.get(MCParticle.class).get(0); - - if (mcparticles.isEmpty()) { - return; - } -// if (mcparticles.size() != 1) { -// throw new RuntimeException("expected exactly 1 MCParticle"); -// } -// MCParticle particle = mcparticles.get(0); - - // Get the list of raw ECal hits. - List<HPSEcalCluster> clusters = event.get(HPSEcalCluster.class, clusterCollectionName); - if (clusters == null) { - throw new RuntimeException("Event is missing ECal clusters collection!"); - } - - boolean trigger = false; - - for (HPSEcalCluster cluster : clusters) { - if (cluster.getEnergy() > clusterEnergyLow && cluster.getSeedHit().getIdentifierFieldValue("ix") < 0) { -// if (cluster.getEnergy() > clusterEnergyLow && cluster.getSeedHit().getIdentifierFieldValue("iy")>0 && cluster.getSeedHit().getIdentifierFieldValue("ix")<0) { - triggersY[Math.abs(cluster.getSeedHit().getIdentifierFieldValue("iy")) - 1]++; - if (Math.abs(cluster.getSeedHit().getIdentifierFieldValue("iy")) > 1) { - trigger = true; - } - } - if (cluster.getSeedHit().getIdentifierFieldValue("ix") < 0 && Math.abs(cluster.getSeedHit().getIdentifierFieldValue("iy")) > 1) { - for (MCParticle particle : mcparticles) { - if (ParticleTypeClassifier.isElectron(particle.getPDGID())) { - electronEClusterVsP.fill(1000.0 * particle.getPZ(), 1000.0 * cluster.getEnergy()); - if (particle.getPZ() > 0.6) { - electronEClusterOverP.fill(cluster.getEnergy() / particle.getPZ()); - } - } else if (ParticleTypeClassifier.isPositron(particle.getPDGID())) { - positronEClusterVsP.fill(1000.0 * particle.getPZ(), 1000.0 * cluster.getEnergy()); - if (particle.getPZ() > 0.6) { - positronEClusterOverP.fill(cluster.getEnergy() / particle.getPZ()); - } - } else if (ParticleTypeClassifier.isPhoton(particle.getPDGID())) { - photonEClusterVsP.fill(1000.0 * particle.getPZ(), 1000.0 * cluster.getEnergy()); - if (particle.getPZ() > 0.6) { - photonEClusterOverP.fill(cluster.getEnergy() / particle.getPZ()); - } - } - eClusterVsP.fill(1000.0 * particle.getPZ(), 1000.0 * cluster.getEnergy()); - if (particle.getPZ() > 0.6) { - eClusterOverP.fill(cluster.getEnergy() / particle.getPZ()); - } - } - } - } - if (trigger) { - deadtimelessTriggerCount++; - } - - List<CalorimeterHit> hits = event.get(CalorimeterHit.class, hitCollectionName); - if (hits == null) { - throw new RuntimeException("Event is missing ECal hits collection!"); - } - double totalE = 0; - for (CalorimeterHit hit : hits) { - totalE += hit.getRawEnergy(); - } - - for (MCParticle particle : mcparticles) { - if (ParticleTypeClassifier.isElectron(particle.getPDGID())) { - electronEVsP.fill(1000.0 * particle.getPZ(), 1000.0 * totalE); - if (particle.getPZ() > 0.6) { - electronEOverP.fill(totalE / particle.getPZ()); - } - } else if (ParticleTypeClassifier.isPositron(particle.getPDGID())) { - positronEVsP.fill(1000.0 * particle.getPZ(), 1000.0 * totalE); - if (particle.getPZ() > 0.6) { - positronEOverP.fill(totalE / particle.getPZ()); - } - } else if (ParticleTypeClassifier.isPhoton(particle.getPDGID())) { - photonEVsP.fill(1000.0 * particle.getPZ(), 1000.0 * totalE); - if (particle.getPZ() > 0.6) { - photonEOverP.fill(totalE / particle.getPZ()); - } - } - eVsP.fill(1000.0 * particle.getPZ(), 1000.0 * totalE); - if (particle.getPZ() > 0.6) { - eOverP.fill(totalE / particle.getPZ()); - } - } - } - - @Override - public void endOfData() { - System.out.printf("Trigger count without dead time: %d\n", deadtimelessTriggerCount); - System.out.format("Triggers vs. Y: %d\t%d\t%d\t%d\t%d, total %d\n", triggersY[0], triggersY[1], triggersY[2], triggersY[3], triggersY[4], deadtimelessTriggerCount); - super.endOfData(); - } -}
\ No newline at end of file
diff -N HPSEcalReadoutDriver.java --- HPSEcalReadoutDriver.java 6 Nov 2012 02:06:14 -0000 1.21 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,152 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.ArrayList; -import java.util.List; - -import org.lcsim.event.CalorimeterHit; -import org.lcsim.event.EventHeader; -import org.lcsim.hps.util.ClockSingleton; -import org.lcsim.util.Driver; -import org.lcsim.util.lcio.LCIOConstants; - -/** - * Performs readout of ECal hits. - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSEcalReadoutDriver.java,v 1.21 2012/11/06 02:06:14 meeg Exp $ - */ -public abstract class HPSEcalReadoutDriver<T> extends Driver { - - String ecalCollectionName; - String ecalRawCollectionName = "EcalRawHits"; - String ecalReadoutName = "EcalHits"; - Class hitClass; - //hit type as in org.lcsim.recon.calorimetry.CalorimeterHitType - int hitType = 0; - //number of bunches in readout cycle - int readoutCycle = 1; - //minimum readout value to write a hit - double threshold = 0.0; - //LCIO flags - int flags = 0; - //readout period in ns - double readoutPeriod = 2.0; - //readout period time offset in ns - double readoutOffset = 0.0; - //readout period counter - int readoutCounter; - public static boolean readoutBit = false; - protected boolean debug = false; - - public HPSEcalReadoutDriver() { - flags += 1 << LCIOConstants.CHBIT_LONG; //store position - flags += 1 << LCIOConstants.RCHBIT_ID1; //store cell ID - - } - - public void setDebug(boolean debug) { - this.debug = debug; - } - - public void setEcalReadoutName(String ecalReadoutName) { - this.ecalReadoutName = ecalReadoutName; - } - - public void setEcalRawCollectionName(String ecalRawCollectionName) { - this.ecalRawCollectionName = ecalRawCollectionName; - } - - public void setEcalCollectionName(String ecalCollectionName) { - this.ecalCollectionName = ecalCollectionName; - } - - public void setReadoutCycle(int readoutCycle) { - this.readoutCycle = readoutCycle; - if (readoutCycle > 0) { - this.readoutPeriod = readoutCycle * ClockSingleton.getDt(); - } - } - - public void setReadoutOffset(double readoutOffset) { - this.readoutOffset = readoutOffset; - } - - public void setReadoutPeriod(double readoutPeriod) { - this.readoutPeriod = readoutPeriod; - this.readoutCycle = -1; - } - - public void setThreshold(double threshold) { - this.threshold = threshold; - } - - @Override - public void startOfData() { - if (ecalCollectionName == null) { - throw new RuntimeException("The parameter ecalCollectionName was not set!"); - } - - readoutCounter = 0; - - initReadout(); - } - - @Override - public void process(EventHeader event) { - //System.out.println(this.getClass().getCanonicalName() + " - process"); - // Get the list of ECal hits. - if (event.hasCollection(CalorimeterHit.class, ecalCollectionName)) { - List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName); - - //write hits into buffers - putHits(hits); - } - - ArrayList<T> newHits = null; - - //if at the end of a readout cycle, write buffers to hits - if (readoutCycle > 0) { - if ((ClockSingleton.getClock() + 1) % readoutCycle == 0) { - if (newHits == null) { - newHits = new ArrayList<T>(); - } - readHits(newHits); - readoutCounter++; - } - } else { - while (ClockSingleton.getTime() - readoutTime() + ClockSingleton.getDt() >= readoutPeriod) { - if (newHits == null) { - newHits = new ArrayList<T>(); - } - readHits(newHits); - readoutCounter++; - } - } - - if (newHits != null) { - event.put(ecalRawCollectionName, newHits, hitClass, flags, ecalReadoutName); - } - - if (readoutBit) { - processTrigger(event); - readoutBit = false; - } - } - - protected double readoutTime() { - return readoutCounter * readoutPeriod + readoutOffset; - } - - //read analog signal out of buffers and make hits; reset buffers - protected abstract void readHits(List<T> hits); - - //add deposited energy to buffers - //must be run every event, even if the list is empty - protected abstract void putHits(List<CalorimeterHit> hits); - - protected void processTrigger(EventHeader event) { - } - - //initialize buffers - protected abstract void initReadout(); -}
\ No newline at end of file
diff -N TestRunTriggerDriver.java --- TestRunTriggerDriver.java 26 Sep 2012 23:31:10 -0000 1.9 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,100 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.ArrayList; -import java.util.List; -import org.lcsim.event.EventHeader; -import org.lcsim.hps.evio.TriggerData; - -/** - * Reads clusters and makes trigger decision using opposite quadrant criterion. - * Prints triggers to file if file path specified. - * - * @author Omar Moreno <[log in to unmask]> - * @author Sho Uemura <[log in to unmask]> - * @version $Id: TestRunTriggerDriver.java,v 1.9 2012/09/26 23:31:10 meeg Exp $ - */ -public class TestRunTriggerDriver extends HPSTriggerDriver { - - boolean triggerThisCycle = false; - int cycleCounter = 0; - private double clusterEnergyLow = 10; // - int deadtimelessTriggerCount; - private int topBits = 0, botBits = 0; - - public TestRunTriggerDriver() { - } - - @Override - protected void makeTriggerData(EventHeader event, String collectionName) { - int[] trigArray = new int[8]; - trigArray[TriggerData.TOP_TRIG] = topBits; - trigArray[TriggerData.BOT_TRIG] = botBits; - trigArray[TriggerData.AND_TRIG] = topBits & botBits; - trigArray[TriggerData.OR_TRIG] = topBits | botBits; - TriggerData tData = new TriggerData(trigArray); - List<TriggerData> triggerList = new ArrayList<TriggerData>(); - triggerList.add(tData); - event.put(collectionName, triggerList, TriggerData.class, 0); - } - - @Override - public void startOfData() { - super.startOfData(); - - deadtimelessTriggerCount = 0; - } - - @Override - protected boolean triggerDecision(EventHeader event) { - if (event.hasCollection(HPSEcalCluster.class, clusterCollectionName)) { - cycleCounter++; - if (testTrigger(event.get(HPSEcalCluster.class, clusterCollectionName))) { - triggerThisCycle = true; - } - } - - if (cycleCounter % 4 == 0) { - boolean trigger = triggerThisCycle; - triggerThisCycle = false; - return trigger; - } else { - return false; - } - } - - @Override - public boolean testTrigger(List<HPSEcalCluster> clusters) { - boolean trigger = false; - - topBits <<= 1; - botBits <<= 1; - for (HPSEcalCluster cluster : clusters) { - if (cluster.getEnergy() > clusterEnergyLow) { - if (cluster.getPosition()[1] > 0) { - topBits |= 1; - } else { - botBits |= 1; - } - trigger = true; - } - } - if (trigger) { - deadtimelessTriggerCount++; - } - return trigger; - } - - @Override - public void endOfData() { - if (outputStream != null) { - outputStream.printf("Number of cluster pairs after successive trigger conditions:\n"); - outputStream.printf("Trigger count without dead time: %d\n", deadtimelessTriggerCount); - outputStream.printf("Trigger count: %d\n", numTriggers); - outputStream.close(); - } - System.out.printf("Number of cluster pairs after successive trigger conditions:\n"); - System.out.printf("Trigger count without dead time: %d\n", deadtimelessTriggerCount); - System.out.printf("Trigger count: %d\n", numTriggers); - super.endOfData(); - } -}
\ No newline at end of file
diff -N HPSEcalConverterDriver.java --- HPSEcalConverterDriver.java 21 Nov 2012 00:29:53 -0000 1.6 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,86 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.ArrayList; -import java.util.List; -import org.lcsim.event.CalorimeterHit; -import org.lcsim.event.EventHeader; -import org.lcsim.event.RawCalorimeterHit; -import org.lcsim.util.Driver; -import org.lcsim.util.lcio.LCIOConstants; - -/** - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSEcalConverterDriver.java,v 1.6 2012/11/21 00:29:53 meeg Exp $ - */ -public class HPSEcalConverterDriver extends Driver { - - String rawCollectionName; - String ecalReadoutName = "EcalHits"; - String ecalCollectionName = "EcalCorrectedHits"; - int flags; - double scale = 1.0; -// double pedestal = 0.0; - double period = 4.0; - double dt = 0.0; - - public HPSEcalConverterDriver() { - flags = 0; - flags += 1 << LCIOConstants.CHBIT_LONG; //store position - flags += 1 << LCIOConstants.RCHBIT_ID1; //store cell ID - } - -// public void setPedestal(double pedestal) { -// this.pedestal = pedestal; -// } - public void setScale(double scale) { - this.scale = scale; - } - - public void setEcalCollectionName(String ecalCollectionName) { - this.ecalCollectionName = ecalCollectionName; - } - - public void setRawCollectionName(String rawCollectionName) { - this.rawCollectionName = rawCollectionName; - } - - @Override - public void startOfData() { - if (ecalCollectionName == null) { - throw new RuntimeException("The parameter ecalCollectionName was not set!"); - } - } - - @Override - public void process(EventHeader event) { - if (event.hasCollection(HPSFADCCalorimeterHit.class, rawCollectionName)) { - // Get the list of ECal hits. - List<HPSFADCCalorimeterHit> hits = event.get(HPSFADCCalorimeterHit.class, rawCollectionName); - - ArrayList<CalorimeterHit> newHits = new ArrayList<CalorimeterHit>(); - - for (HPSFADCCalorimeterHit hit : hits) { - newHits.add(HitDtoA(hit)); - } - - event.put(ecalCollectionName, newHits, CalorimeterHit.class, flags, ecalReadoutName); - } - } - -// private int AtoD(double amplitude, long cellID) { -// return (int) Math.round(amplitude / scale); -// } - - private double DtoA(int amplitude, long cellID) { - return scale * amplitude; - } - - private CalorimeterHit HitDtoA(RawCalorimeterHit hit) { - return new HPSRawCalorimeterHit(DtoA(hit.getAmplitude(), hit.getCellID()), period * hit.getTimeStamp() + dt, hit.getCellID(), 0); - } - -// private RawCalorimeterHit HitAtoD(CalorimeterHit hit) { -// return new HPSFADCCalorimeterHit(hit.getCellID(), AtoD(hit.getRawEnergy(), hit.getCellID()), (int) Math.round(hit.getTime() / period), 0); -// } -}
diff -N HPSEcalRawConverter.java --- HPSEcalRawConverter.java 8 Dec 2012 01:12:17 -0000 1.14 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,101 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import org.lcsim.event.CalorimeterHit; -import org.lcsim.event.RawCalorimeterHit; -import org.lcsim.event.RawTrackerHit; -import org.lcsim.event.base.BaseRawCalorimeterHit; - -/** - * - * @version $Id: HPSEcalRawConverterDriver.java,v 1.2 2012/05/03 00:17:54 - * phansson Exp $ - */ -public class HPSEcalRawConverter { - - private boolean debug = false; - private boolean constantGain = false; - private double gain; - - public HPSEcalRawConverter() { - } - - public void setGain(double gain) { - constantGain = true; - this.gain = gain; - } - - public short sumADC(RawTrackerHit hit) { - //Sum all pedestal subtracted ADC values - //return scale * (amplitude + 0.5) + pedestal; - if (debug) { - System.out.println("Summing ADC for hit: " + hit.toString()); - } - double pedestal = HPSEcalConditions.physicalToPedestal(hit.getCellID()); - short sum = 0; - short samples[] = hit.getADCValues(); - for (int isample = 0; isample < samples.length; ++isample) { - sum += (samples[isample] - pedestal); - if (debug) { - System.out.println("Sample " + isample + " " + samples[isample] + " pedestal " + pedestal + " (" + sum + ")"); - } - } - return sum; - } - - public CalorimeterHit HitDtoA(RawTrackerHit hit) { - double time = hit.getTime(); - long id = hit.getCellID(); - double rawEnergy; - if (constantGain) { - rawEnergy = gain * sumADC(hit) * HPSECalUtils.MeV; - } else { - rawEnergy = HPSEcalConditions.physicalToGain(id) * sumADC(hit) * HPSECalUtils.MeV; - } -// double[] pos = hit.getDetectorElement().getGeometry().getPosition().v(); - CalorimeterHit h = new HPSRawCalorimeterHit(rawEnergy + 0.0000001, time, id, 0); - //+0.0000001 is a horrible hack to ensure rawEnergy!=BaseCalorimeterHit.UNSET_CORRECTED_ENERGY - return h; - } - - public CalorimeterHit HitDtoA(RawCalorimeterHit hit, int window) { - if (hit.getTimeStamp() % 64 != 0) { - System.out.println("unexpected timestamp " + hit.getTimeStamp()); - } - double time = hit.getTimeStamp() / 16.0; - long id = hit.getCellID(); - double rawEnergy; - if (constantGain) { - rawEnergy = gain * (hit.getAmplitude() - window * HPSEcalConditions.physicalToPedestal(id)) * HPSECalUtils.MeV; - } else { - rawEnergy = HPSEcalConditions.physicalToGain(id) * (hit.getAmplitude() - window * HPSEcalConditions.physicalToPedestal(id)) * HPSECalUtils.MeV; - } - CalorimeterHit h = new HPSRawCalorimeterHit(rawEnergy + 0.0000001, time, id, 0); - //+0.0000001 is a horrible hack to ensure rawEnergy!=BaseCalorimeterHit.UNSET_CORRECTED_ENERGY - return h; - } - - public RawCalorimeterHit HitAtoD(CalorimeterHit hit, int window) { - int time = (int) (hit.getTime() * 16.0); - long id = hit.getCellID(); - int amplitude; - if (constantGain) { - amplitude = (int) Math.round((hit.getRawEnergy() / HPSECalUtils.MeV) / gain + window * HPSEcalConditions.physicalToPedestal(id)); - } else { - amplitude = (int) Math.round((hit.getRawEnergy() / HPSECalUtils.MeV) / HPSEcalConditions.physicalToGain(id) + window * HPSEcalConditions.physicalToPedestal(id)); - } - RawCalorimeterHit h = new BaseRawCalorimeterHit(id, amplitude, time); - return h; - } - - public static CalorimeterHit HitDtoA(RawCalorimeterHit hit, int window, double g) { - if (hit.getTimeStamp() % 64 != 0) { - System.out.println("unexpected timestamp " + hit.getTimeStamp()); - } - double time = hit.getTimeStamp() / 16.0; - long id = hit.getCellID(); - double rawEnergy = g * (hit.getAmplitude() - window * HPSEcalConditions.physicalToPedestal(id)) * HPSECalUtils.MeV; - CalorimeterHit h = new HPSRawCalorimeterHit(rawEnergy + 0.0000001, time, id, 0); - //+0.0000001 is a horrible hack to ensure rawEnergy!=BaseCalorimeterHit.UNSET_CORRECTED_ENERGY - return h; - } -}
diff -N HPSEcalWindowDiscriminatorReadoutDriver.java --- HPSEcalWindowDiscriminatorReadoutDriver.java 8 Dec 2012 01:12:17 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,92 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.lcsim.event.CalorimeterHit; -import org.lcsim.hps.util.ClockSingleton; -import org.lcsim.hps.util.RingBuffer; - -/** - * Performs readout of ECal hits. - * Simulates time evolution of preamp output pulse and leading-edge discriminator. - * Uses lower and upper thresholds, with upper discriminator acting as a veto. - * - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSEcalWindowDiscriminatorReadoutDriver.java,v 1.4 2012/12/08 01:12:17 meeg Exp $ - */ -public class HPSEcalWindowDiscriminatorReadoutDriver extends HPSEcalDiscriminatorReadoutDriver { - //last time we saw a rising edge - - Map<Long, Double> lowTimeMap = null; - //last time we saw a rising edge - Map<Long, Double> highTimeMap = null; - double highThreshold = 10.0 * HPSECalUtils.GeV; - - public HPSEcalWindowDiscriminatorReadoutDriver() { - } - - public void setHighThreshold(double highThreshold) { - this.highThreshold = highThreshold; - } - - @Override - protected void readHits(List<HPSRawCalorimeterHit> hits) { - for (Long cellID : lowTimeMap.keySet()) { - //if there's an output pulse, make a hit - if (ClockSingleton.getTime() - lowTimeMap.get(cellID) < outputWidth) { - if (highTimeMap.containsKey(cellID) && ClockSingleton.getTime() - highTimeMap.get(cellID) < outputWidth) { - continue; - } - hits.add(new HPSRawCalorimeterHit(outputEnergy, readoutTime(), cellID, hitType)); - } - } - } - - @Override - protected void putHits(List<CalorimeterHit> hits) { - //fill the readout buffers - for (CalorimeterHit hit : hits) { -// int ix = dec.getValue("ix"); -// int iy = dec.getValue("iy"); -// //temporary hack to disable crystals and flip X coordinate -// int side = dec.getValue("side"); -// if (iy == 1 && ix * side >= -10 && ix * side <= -2) -// continue; - - RingBuffer eDepBuffer = eDepMap.get(hit.getCellID()); - if (eDepBuffer == null) { - eDepBuffer = new RingBuffer(bufferLength); - eDepMap.put(hit.getCellID(), eDepBuffer); - } - for (int i = 0; i < bufferLength; i++) { - eDepBuffer.addToCell(i, hit.getRawEnergy() * pulseAmplitude(i * ClockSingleton.getDt() - hit.getTime())); - } - } - - //check for rising edges - for (Long cellID : eDepMap.keySet()) { - RingBuffer eDepBuffer = eDepMap.get(cellID); - //if there's a rising edge between now and the next time step, note the time - if ((eDepBuffer.currentValue() < threshold) - && (eDepBuffer.getValue(1) > threshold)) { - lowTimeMap.put(cellID, ClockSingleton.getTime()); - } - if ((eDepBuffer.currentValue() < highThreshold) - && (eDepBuffer.getValue(1) > highThreshold)) { - highTimeMap.put(cellID, ClockSingleton.getTime()); - } - eDepBuffer.step(); - } - } - - @Override - protected void initReadout() { - //initialize buffers - eDepMap = new HashMap<Long, RingBuffer>(); - lowTimeMap = new HashMap<Long, Double>(); - highTimeMap = new HashMap<Long, Double>(); - } -}
diff -N HPSECalUtils.java --- HPSECalUtils.java 8 Dec 2012 01:12:17 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,61 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import org.lcsim.event.CalorimeterHit; - -/** - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSECalUtils.java,v 1.3 2012/12/08 01:12:17 meeg Exp $ - */ -public class HPSECalUtils { - - public static final double GeV = 1.0; - public static final double MeV = 0.001; - - /** - * Returns the quadrant which contains the ECal cluster - * - * @param ecalCluster : ECal cluster - * @return Quadrant number - */ - public static int getQuadrant(HPSEcalCluster ecalCluster) { - return getQuadrant(ecalCluster.getSeedHit()); - } - - public static int getQuadrant(CalorimeterHit hit) { - int ix = hit.getIdentifierFieldValue("ix"); - int iy = hit.getIdentifierFieldValue("iy"); - return getQuadrant(ix, iy); - } - - public static int getQuadrant(int x, int y) { - if (x > 0) { - if (y > 0) { - return 1; - } else { - return 4; - } - } else { - if (y > 0) { - return 2; - } else { - return 3; - } - } - } - - public static int getHVGroup(int x, int y) { - int absy = Math.abs(y); - if (x > 0 || x <= -8) { - return (23 - Math.abs(x)) / 2 + 1; - } else { - if (x == -7 && absy == 5) { - return 8; - } else if (x >= -4) { - return 12 - Math.max(x + 4, absy - 2); - } else { - return 12 - Math.max(-5 - x, absy - 2); - } - } - } -}
diff -N HPS1BitTriggerDriver.java --- HPS1BitTriggerDriver.java 23 Aug 2012 18:48:18 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,30 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.List; - -/** - * Reads clusters and makes trigger decision using opposite quadrant criterion. - * Prints triggers to file if file path specified. - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPS1BitTriggerDriver.java,v 1.3 2012/08/23 18:48:18 meeg Exp $ - */ -public class HPS1BitTriggerDriver extends HPSTriggerDriver { - - public HPS1BitTriggerDriver() { - } - - @Override - public boolean testTrigger(List<HPSEcalCluster> clusters) { - - boolean quadrants[] = new boolean[4]; - - for (HPSEcalCluster clus : clusters) { -// int ix = clus.getSeedHit().getIdentifierFieldValue("ix"); -// int iy = clus.getSeedHit().getIdentifierFieldValue("iy"); - //System.out.printf("ix = %d, iy = %d\n", ix, iy); - quadrants[HPSECalUtils.getQuadrant(clus)] = true; - } - return (quadrants[0] && quadrants[2]) || (quadrants[1] && quadrants[3]); - } -}
diff -N HPSFADCSingleTriggerDriver.java --- HPSFADCSingleTriggerDriver.java 8 Dec 2012 01:12:17 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,128 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; - -import org.lcsim.event.EventHeader; -import org.lcsim.hps.evio.TriggerData; -import org.lcsim.hps.util.ClockSingleton; - -/** - * Reads clusters and makes trigger decision using opposite quadrant criterion. - * Prints triggers to file if file path specified. - * TODO: Redundant with TestRunTriggerDriver. - * - * @author Omar Moreno <[log in to unmask]> - * @author Sho Uemura <[log in to unmask]> - * @author Per Hansson Adrian <[log in to unmask]> - * @version $Id: HPSFADCSingleTriggerDriver.java,v 1.2 2012/12/08 01:12:17 meeg Exp $ - */ -public class HPSFADCSingleTriggerDriver extends HPSTriggerDriver { - // A list to contain all cluster pairs in an event - List<HPSEcalCluster[]> clusterPairs; - int nTriggers; - int totalEvents; - private double clusterEnergyHigh = 1.85 * HPSECalUtils.GeV; // GeV - private double clusterEnergyLow = .1 * HPSECalUtils.GeV; // GeV - int allClusters; - int clusterEnergyCount; - int deadtimelessTriggerCount; - - public HPSFADCSingleTriggerDriver() { - clusterPairs = new LinkedList<HPSEcalCluster[]>(); - } - - @Override - public void startOfData() { - super.startOfData(); - - allClusters = 0; - clusterEnergyCount = 0; - deadtimelessTriggerCount = 0; - } - - @Override - public boolean testTrigger(List<HPSEcalCluster> clusters) { - boolean trigger = false; - - //--- Apply Trigger Cuts ---// - - // Iterate through all clusters present in the event. - //If at least one of the clusters satisfies all of the trigger conditions, - // a trigger signal is sent to all other detectors. - for (HPSEcalCluster cluster : clusters) { - - - if (outputStream != null) { - outputStream.printf("Event %d: cluster energy %f in quadrant %d (%s)\n", - ClockSingleton.getClock(), - cluster.getEnergy(), HPSECalUtils.getQuadrant(cluster),cluster.getSeedHit().getPositionVec().toString()); - - } - - allClusters++; - - - // Require the componets of a cluster pair to have an energy in - // the range of 100 MeV to 1.85 GeV - if (!clusterECut(cluster)) { - if (outputStream != null) { - outputStream.println("Failed cluster energy cut"); - } - continue; - } - clusterEnergyCount++; - - // If all cuts are pased, we have a trigger - if (outputStream != null) { - outputStream.println("Passed all cuts"); - } - trigger = true; - } - if (trigger) { - deadtimelessTriggerCount++; - } - return trigger; - } - - @Override - public void endOfData() { - if (outputStream != null) { - outputStream.printf("%s: Number of clusters: %d\n",this.getClass().getSimpleName(),allClusters); - outputStream.printf("%s: Number of cluster pairs after successive trigger conditions:\n",this.getClass().getSimpleName()); - outputStream.printf("%s: Cluster energy: %d\n",this.getClass().getSimpleName(), clusterEnergyCount); - outputStream.printf("%s: Trigger count without dead time: %d\n",this.getClass().getSimpleName(), deadtimelessTriggerCount); - outputStream.printf("%s: Trigger count: %d\n",this.getClass().getSimpleName(), numTriggers); - outputStream.close(); - } - System.out.printf("%s: Number of pairs: %d\n",this.getClass().getSimpleName(),allClusters); - System.out.printf("%s: Number of cluster pairs after successive trigger conditions:\n",this.getClass().getSimpleName()); - System.out.printf("%s: Cluster energy: %d\n",this.getClass().getSimpleName(), clusterEnergyCount); - System.out.printf("%s: Trigger count without dead time: %d\n",this.getClass().getSimpleName(), deadtimelessTriggerCount); - System.out.printf("%s: Trigger count: %d\n",this.getClass().getSimpleName(), numTriggers); - super.endOfData(); - } - - /** - * Checks if the ECal clusters making up a cluster pair lie above the low - * energy threshold and below the high energy threshold - * - * @param clusterPair : pair of clusters - * @return true if a pair is found, false otherwise - */ - private boolean clusterECut(HPSEcalCluster cluster) { - return (cluster.getEnergy() < clusterEnergyHigh && cluster.getEnergy() > clusterEnergyLow); - } - - /** - * Make a dummy TriggerData - */ - @Override - protected void makeTriggerData(EventHeader event, String collectionName) { - TriggerData tData = new TriggerData(new int[8]); - List<TriggerData> triggerList = new ArrayList<TriggerData>(); - triggerList.add(tData); - event.put(collectionName, triggerList, TriggerData.class, 0); - } -}
\ No newline at end of file
diff -N HPSEcalDiscriminatorReadoutDriver.java --- HPSEcalDiscriminatorReadoutDriver.java 8 Dec 2012 01:12:17 -0000 1.6 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,119 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.lcsim.event.CalorimeterHit; -import org.lcsim.hps.util.ClockSingleton; -import org.lcsim.hps.util.RingBuffer; - -/** - * Performs readout of ECal hits. - * Simulates time evolution of preamp output pulse and leading-edge discriminator. - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSEcalDiscriminatorReadoutDriver.java,v 1.6 2012/12/08 01:12:17 meeg Exp $ - */ -public class HPSEcalDiscriminatorReadoutDriver extends HPSEcalReadoutDriver<HPSRawCalorimeterHit> { - - //buffer for deposited energy - Map<Long, RingBuffer> eDepMap = null; - //last time we saw a rising edge - Map<Long, Double> edgeTimeMap = null; - //length of ring buffer (in multiples of bunch spacing) - int bufferLength = 200; - //shaper time constant in ns - double t0 = 18.0; - //discriminator output pulse width in ns - double outputWidth = 32.0; - //output hit "energy" in GeV - double outputEnergy = 10.0*HPSECalUtils.GeV; - - public HPSEcalDiscriminatorReadoutDriver() { - hitClass = HPSRawCalorimeterHit.class; - } - - public void setBufferLength(int bufferLength) { - this.bufferLength = bufferLength; - eDepMap = new HashMap<Long, RingBuffer>(); - } - - public void setOutputWidth(double outputWidth) { - this.outputWidth = outputWidth; - } - - /* - * Set shaper time constant. - * Positive values interpreted as shaping time of CR-RC pulse; - * negative values interpreted as width of rectangular pulse. - */ - public void setT0(double t0) { - this.t0 = t0; - } - - @Override - protected void readHits(List<HPSRawCalorimeterHit> hits) { - for (Long cellID : edgeTimeMap.keySet()) { - //if there's an output pulse, make a hit - if (ClockSingleton.getTime() - edgeTimeMap.get(cellID) < outputWidth) { - hits.add(new HPSRawCalorimeterHit(outputEnergy, readoutTime(), cellID, hitType)); - } - } - } - - @Override - protected void putHits(List<CalorimeterHit> hits) { - //fill the readout buffers - for (CalorimeterHit hit : hits) { -// int ix = dec.getValue("ix"); -// int iy = dec.getValue("iy"); -// //temporary hack to disable crystals and flip X coordinate -// int side = dec.getValue("side"); -// if (iy == 1 && ix * side >= -10 && ix * side <= -2) -// continue; - - RingBuffer eDepBuffer = eDepMap.get(hit.getCellID()); - if (eDepBuffer == null) { - eDepBuffer = new RingBuffer(bufferLength); - eDepMap.put(hit.getCellID(), eDepBuffer); - } - for (int i = 0; i < bufferLength; i++) { - eDepBuffer.addToCell(i, hit.getRawEnergy() * pulseAmplitude(i * ClockSingleton.getDt() - hit.getTime())); - } - } - - //check for rising edges - for (Long cellID : eDepMap.keySet()) { - RingBuffer eDepBuffer = eDepMap.get(cellID); - //if there's a rising edge between now and the next time step, note the time - if ((eDepBuffer.currentValue() < threshold) - && (eDepBuffer.getValue(1) > threshold)) - edgeTimeMap.put(cellID, ClockSingleton.getTime()); - eDepBuffer.step(); - } - } - - @Override - protected void initReadout() { - //initialize buffers - eDepMap = new HashMap<Long, RingBuffer>(); - edgeTimeMap = new HashMap<Long, Double>(); - } - - /* - * Pulse shape as a function of time; normalized to have a peak height of 1. - */ - protected double pulseAmplitude(double time) { - if (time < 0.0) - return 0.0; - if (t0 > 0.0) { - return (time / t0) * Math.exp(1.0 - time / t0); - } else { - if (time < -t0) - return 1.0; - else - return 0.0; - } - } -}
diff -N HPSEcalClusterer.java --- HPSEcalClusterer.java 8 Dec 2012 01:12:17 -0000 1.25 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,171 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.lcsim.event.CalorimeterHit; -import org.lcsim.event.EventHeader; -import org.lcsim.geometry.Detector; -import org.lcsim.geometry.subdetector.HPSEcal3.NeighborMap; -import org.lcsim.geometry.subdetector.HPSEcal3; -import org.lcsim.util.Driver; -import org.lcsim.util.lcio.LCIOConstants; - -/** - * This Driver creates clusters from the CalorimeterHits of an - * {@link org.lcsim.geometry.subdetectur.HPSEcal3} detector. - * - * The clustering algorithm is from pages 83 and 84 of the HPS Proposal. - * - * @author Jeremy McCormick <[log in to unmask]> - * @author Tim Nelson <[log in to unmask]> - * - * @version $Id: HPSEcalClusterer.java,v 1.25 2012/12/08 01:12:17 meeg Exp $ - */ -public class HPSEcalClusterer extends Driver { - - HPSEcal3 ecal; - String ecalCollectionName; - String ecalName = "Ecal"; - String clusterCollectionName = "EcalClusters"; - // Minimum E for cluster seed. - double seedEMin = .05 * HPSECalUtils.GeV; - // Minimum E to add hit to cluster. - double addEMin = .03 * HPSECalUtils.GeV; - // Odd or even number of crystals in X. - boolean oddX; - // Map of crystals to their neighbors. - NeighborMap neighborMap = null; - - public HPSEcalClusterer() { - } - - public void setClusterCollectionName(String clusterCollectionName) { - this.clusterCollectionName = clusterCollectionName; - } - - public void setSeedEMin(double seedEMin) { - this.seedEMin = seedEMin; - } - - public void setAddEMin(double addEMin) { - this.addEMin = addEMin; - if (seedEMin < addEMin) { - seedEMin = addEMin; - } - } - - public void setEcalCollectionName(String ecalCollectionName) { - this.ecalCollectionName = ecalCollectionName; - } - - public void setEcalName(String ecalName) { - this.ecalName = ecalName; - } - - public void startOfData() { - if (ecalCollectionName == null) { - throw new RuntimeException("The parameter ecalCollectionName was not set!"); - } - - if (ecalName == null) { - throw new RuntimeException("The parameter ecalName was not set!"); - } - } - - public void detectorChanged(Detector detector) { - // Get the Subdetector. - ecal = (HPSEcal3) detector.getSubdetector(ecalName); - - // Cache ref to neighbor map. - neighborMap = ecal.getNeighborMap(); - - //System.out.println(ecal.getName()); - //System.out.println(" nx="+ecal.nx()); - //System.out.println(" ny="+ecal.ny()); - //System.out.println(" beamgap="+ecal.beamGap()); - //System.out.println(" dface="+ecal.distanceToFace()); - - //System.out.println(neighborMap.toString()); - } - - public void process(EventHeader event) { - //System.out.println(this.getClass().getCanonicalName() + " - process"); - - if (event.hasCollection(CalorimeterHit.class, ecalCollectionName)) { - // Get the list of raw ECal hits. - List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName); - - // Make a hit map for quick lookup by ID. - Map<Long, CalorimeterHit> hitMap = new HashMap<Long, CalorimeterHit>(); - for (CalorimeterHit hit : hits) { - hitMap.put(hit.getCellID(), hit); - } - - // Put Cluster collection into event. - int flag = 1 << LCIOConstants.CLBIT_HITS; - event.put(clusterCollectionName, createClusters(hitMap), HPSEcalCluster.class, flag); - } - } - - public List<HPSEcalCluster> createClusters(Map<Long, CalorimeterHit> map) { - - // New Cluster list to be added to event. - List<HPSEcalCluster> clusters = new ArrayList<HPSEcalCluster>(); - - // Loop over ECal hits to find cluster seeds. - for (CalorimeterHit hit : map.values()) { - // Cut on min seed E. - if (hit.getRawEnergy() < seedEMin) { - continue; - } - - // Get neighbor crystal IDs. - Set<Long> neighbors = neighborMap.get(hit.getCellID()); - - if (neighbors == null) { - throw new RuntimeException("Oops! Set of neighbors is null!"); - } - - // List for neighboring hits. - List<CalorimeterHit> neighborHits = new ArrayList<CalorimeterHit>(); - - // Loop over neighbors to make hit list for cluster. - boolean isSeed = true; - for (Long neighborId : neighbors) { - // Find the neighbor hit in the event if it exists. - CalorimeterHit neighborHit = map.get(neighborId); - - // Was this neighbor cell hit? - if (neighborHit != null) { - // Check if neighbor cell has more energy. - if (neighborHit.getRawEnergy() > hit.getRawEnergy()) { - // Neighbor has more energy, so cell is not a seed. - isSeed = false; - break; - } - - // Add to cluster if above min E. - if (neighborHit.getRawEnergy() >= addEMin) { - neighborHits.add(neighborHit); - } - } - } - - // Did we find a seed? - if (isSeed) { - // Make a cluster from the hit list. - HPSEcalCluster cluster = new HPSEcalCluster(hit); - cluster.addHit(hit); - for (CalorimeterHit clusHit : neighborHits) { - cluster.addHit(clusHit); - } - clusters.add(cluster); - } - } - return clusters; - } -}
\ No newline at end of file
diff -N HPSEcalReadoutToTriggerConverterDriver.java --- HPSEcalReadoutToTriggerConverterDriver.java 27 Aug 2012 22:42:20 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,189 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.ArrayList; -import java.util.List; -import org.lcsim.event.CalorimeterHit; -import org.lcsim.event.EventHeader; -import org.lcsim.event.base.BaseRawCalorimeterHit; -import org.lcsim.geometry.Detector; -import org.lcsim.util.Driver; - -/** - * - * @version $Id: HPSEcalRawConverterDriver.java,v 1.2 2012/05/03 00:17:54 - * phansson Exp $ - */ -public class HPSEcalReadoutToTriggerConverterDriver extends Driver { - - String rawCollectionName = "EcalReadoutHits"; - String ecalReadoutName = "EcalHits"; - String ecalCollectionName = "EcalCalHits"; - int integralWindow = 30; - boolean debug = false; - double threshold = Double.NEGATIVE_INFINITY; - boolean applyBadCrystalMap = true; - boolean dropBadFADC = false; - double tp = 14.0; - double readoutPeriod = 4.0; - private int readoutThreshold = 50; - private int triggerThreshold = 80; - private double timeShift = 0; - private int truncateScale = 128; - - public HPSEcalReadoutToTriggerConverterDriver() { - } - - public void setTp(double tp) { - this.tp = tp; - } - - public void setDropBadFADC(boolean dropBadFADC) { - this.dropBadFADC = dropBadFADC; - } - - public void setThreshold(double threshold) { - this.threshold = threshold; - } - - public void setIntegralWindow(int integralWindow) { - this.integralWindow = integralWindow; - } - - public void setEcalCollectionName(String ecalCollectionName) { - this.ecalCollectionName = ecalCollectionName; - } - - public void setRawCollectionName(String rawCollectionName) { - this.rawCollectionName = rawCollectionName; - } - - public void setApplyBadCrystalMap(boolean apply) { - this.applyBadCrystalMap = apply; - } - - public void setTruncateScale(int truncateScale) { - this.truncateScale = truncateScale; - } - - @Override - public void startOfData() { - if (ecalCollectionName == null) { - throw new RuntimeException("The parameter ecalCollectionName was not set!"); - } - } - - @Override - public void detectorChanged(Detector detector) { - } - - public boolean isBadCrystal(CalorimeterHit hit) { - return HPSEcalConditions.badChannelsLoaded() ? HPSEcalConditions.isBadChannel(hit.getCellID()) : false; - } - - public boolean isBadFADC(CalorimeterHit hit) { - long daqID = HPSEcalConditions.physicalToDaqID(hit.getCellID()); - return (HPSEcalConditions.getCrate(daqID) == 1 && HPSEcalConditions.getSlot(daqID) == 3); - } - - @Override - public void process(EventHeader event) { - ArrayList<CalorimeterHit> newHits = new ArrayList<CalorimeterHit>(); - - if (event.hasCollection(BaseRawCalorimeterHit.class, rawCollectionName)) { - List<BaseRawCalorimeterHit> hits = event.get(BaseRawCalorimeterHit.class, rawCollectionName); - - for (BaseRawCalorimeterHit hit : hits) { - CalorimeterHit newHit = HitDtoA(hit, integralWindow); - if (newHit != null && newHit.getRawEnergy() > threshold) { - if (applyBadCrystalMap && isBadCrystal(newHit)) { - continue; - } - if (dropBadFADC && isBadFADC(newHit)) { - continue; - } - newHits.add(newHit); - } - } - } - int flags = 0; - event.put(ecalCollectionName, newHits, CalorimeterHit.class, flags, ecalReadoutName); - } - - public CalorimeterHit HitDtoA(BaseRawCalorimeterHit hit, int window) { - double integral = tp * Math.E / readoutPeriod; - double readoutIntegral = (hit.getAmplitude() - window * HPSEcalConditions.physicalToPedestal(hit.getCellID())); - double amplitude = readoutIntegral / integral; - -// double time = readoutPeriod * (Math.random() - 1); - double time = 0 - timeShift; - timeShift += 0.01; - if (timeShift > readoutPeriod) { - timeShift = 0; - } - double triggerIntegral = 0; - boolean overThreshold = false; -// double readoutTime = -1; -// double triggerTime = -1; - while (true) { - double currentValue = amplitude * pulseAmplitude(time); -// if (readoutTime < 0 && currentValue > readoutThreshold) { -// readoutTime = time; -// } - if (!overThreshold && currentValue > triggerThreshold) { - overThreshold = true; -// triggerTime = time; - } - if (overThreshold) { - triggerIntegral += amplitude * pulseAmplitude(time); - if (currentValue < triggerThreshold) { - break; - } - } - time += readoutPeriod; - - if (time > 200.0) { - break; - } - } - -// System.out.format("%f %f %f\n", readoutIntegral, amplitude, triggerIntegral); - - if (hit.getTimeStamp() % 64 != 0) { - System.out.println("unexpected timestamp " + hit.getTimeStamp()); - } - int truncatedIntegral = (int) Math.floor(triggerIntegral / truncateScale) * truncateScale; - double hitTime = hit.getTimeStamp() / 16.0; -// if (readoutTime >= 0 && triggerTime >= 0) { -// hitTime += triggerTime - readoutTime; -// } - long id = hit.getCellID(); -// Hep3Vector pvec = hit.getDetectorElement().getGeometry().getPosition(); -// double [] pos = new double[3]; -// pos[0] = pvec.x(); -// pos[1] = pvec.y(); -// pos[2] = pvec.z(); -// if (truncatedIntegral<=0) return null; - if (truncatedIntegral <= 0) { - truncatedIntegral = 0; - } - CalorimeterHit h = new HPSRawCalorimeterHit(truncatedIntegral, hitTime, id, 0); -// CalorimeterHit h = new HPSRawCalorimeterHit(triggerIntegral + 0.0000001, hit.getPosition(), hitTime, id, 0); - //+0.0000001 is a horrible hack to ensure rawEnergy!=BaseCalorimeterHit.UNSET_CORRECTED_ENERGY - return h; - } - - private double pulseAmplitude(double time) { - if (time <= 0.0) { - return 0.0; - } - if (tp > 0.0) { - return (time / tp) * Math.exp(1.0 - time / tp); - } else { - if (time < -tp) { - return 1.0; - } else { - return 0.0; - } - } - } -}
diff -N HPSFADCCalorimeterHit.java --- HPSFADCCalorimeterHit.java 9 Dec 2011 23:40:21 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,61 +0,0 @@
-/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package org.lcsim.hps.recon.ecal; - -import java.util.Comparator; -import org.lcsim.event.CalorimeterHit; -import org.lcsim.event.RawCalorimeterHit; - -/** - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSFADCCalorimeterHit.java,v 1.3 2011/12/09 23:40:21 meeg Exp $ - */ -public class HPSFADCCalorimeterHit implements RawCalorimeterHit { - - long cellID; - int amplitude; - int timeStamp; - int windowSize; - CalorimeterHit analogHit = null; - - public HPSFADCCalorimeterHit(long cellID, int amplitude, int timeStamp, int windowSize) { - this.cellID = cellID; - this.amplitude = amplitude; - this.timeStamp = timeStamp; - this.windowSize = windowSize; - } - - public long getCellID() { - return cellID; - } - - public int getAmplitude() { - return amplitude; - } - - public int getTimeStamp() { - return timeStamp; - } - - public int getWindowSize() { - return windowSize; - } - - public CalorimeterHit getAnalogHit() { - return analogHit; - } - - public void setAnalogHit(CalorimeterHit analogHit) { - this.analogHit = analogHit; - } - - static class TimeComparator implements Comparator<RawCalorimeterHit> { - - public int compare(RawCalorimeterHit o1, RawCalorimeterHit o2) { - return o1.getTimeStamp() - o2.getTimeStamp(); - } - } -}
\ No newline at end of file
diff -N HPSEcal1BitClusterVetoClusterer.java --- HPSEcal1BitClusterVetoClusterer.java 8 Dec 2012 01:12:16 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,81 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.HashMap; -import java.util.List; -import java.util.Set; - -import org.lcsim.event.CalorimeterHit; - -/** - * Creates clusters from CalorimeterHits in the HPSEcal detector. - * - * A veto hit vetoes clusters in the crystal with the veto hit and all its neighbors. - * - * The clustering algorithm is from JLab Hall B 6 GeV DVCS Trigger Design doc. - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSEcal1BitClusterVetoClusterer.java,v 1.4 2012/12/08 01:12:16 meeg Exp $ - */ -public class HPSEcal1BitClusterVetoClusterer extends HPSEcal1BitClusterer { - - public HPSEcal1BitClusterVetoClusterer() { - } - - @Override - public void countHits(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) { - // Hit map. - hitMap = new HashMap<Long, CalorimeterHit>(); - - hitCounts = new HashMap<Long, Integer>(); - // Loop over ECal hits to count hit towers - for (CalorimeterHit hit : hits) { - int ix = hit.getIdentifierFieldValue("ix"); - if (ix >= xMin && ix <= xMax) { - continue; - } - - // Make a hit map for quick lookup by ID. - hitMap.put(hit.getCellID(), hit); - - // Get neighbor crystal IDs. - Set<Long> neighbors = neighborMap.get(hit.getCellID()); - - if (neighbors == null) { - throw new RuntimeException("Oops! Set of neighbors is null!"); - } - - Integer hitCount = hitCounts.get(hit.getCellID()); - if (hitCount == null) { - hitCounts.put(hit.getCellID(), 1); - } else { - hitCounts.put(hit.getCellID(), hitCount + 1); - } - - // Loop over neighbors to make hit list for cluster. - for (Long neighborId : neighbors) { - hitCount = hitCounts.get(neighborId); - if (hitCount == null) { - hitCounts.put(neighborId, 1); - } else { - hitCounts.put(neighborId, hitCount + 1); - } - } - } - if (vetoHits != null) { - for (CalorimeterHit hit : vetoHits) { - //Get neighbor crystal IDs. - Set<Long> neighbors = neighborMap.get(hit.getCellID()); - - if (neighbors == null) { - throw new RuntimeException("Oops! Set of neighbors is null!"); - } - - // Veto the hit towers for the vetoed crystal and all neighbors. - hitCounts.remove(hit.getCellID()); - for (Long neighborId : neighbors) { - hitCounts.remove(neighborId); - } - } - } - } -}
diff -N HPSEcalTimeEvolutionReadoutDriver.java --- HPSEcalTimeEvolutionReadoutDriver.java 27 Aug 2012 21:53:47 -0000 1.11 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,93 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.lcsim.event.CalorimeterHit; -import org.lcsim.hps.util.ClockSingleton; -import org.lcsim.hps.util.RingBuffer; - -/** - * Performs readout of ECal hits. - * Simulates time evolution of preamp output pulse. - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSEcalTimeEvolutionReadoutDriver.java,v 1.11 2012/08/27 21:53:47 meeg Exp $ - */ -public class HPSEcalTimeEvolutionReadoutDriver extends HPSEcalReadoutDriver<HPSRawCalorimeterHit> { - - //buffer for deposited energy - Map<Long, RingBuffer> eDepMap = null; - //length of ring buffer (in readout cycles) - int bufferLength = 20; - //shaper time constant in ns; negative values generate square pulses of the given width - double t0 = 18.0; - - public HPSEcalTimeEvolutionReadoutDriver() { - hitClass = HPSRawCalorimeterHit.class; - } - - public void setT0(double t0) { - this.t0 = t0; - } - - public void setBufferLength(int bufferLength) { - this.bufferLength = bufferLength; - eDepMap = new HashMap<Long, RingBuffer>(); - } - - @Override - protected void readHits(List<HPSRawCalorimeterHit> hits) { - for (Long cellID : eDepMap.keySet()) { - RingBuffer eDepBuffer = eDepMap.get(cellID); - if (eDepBuffer.currentValue() > threshold) { -// int ix = dec.getValue("ix"); -// int iy = dec.getValue("iy"); -// if (iy == 1 && ix == -2) -// System.out.printf("Time %f, output signal %f\n", ClockSingleton.getTime(), eDepBuffer.currentValue()); - hits.add(new HPSRawCalorimeterHit(eDepBuffer.currentValue(), readoutTime(), cellID, hitType)); - } - eDepBuffer.step(); - } - } - - @Override - protected void putHits(List<CalorimeterHit> hits) { - //fill the readout buffers - for (CalorimeterHit hit : hits) { -// int ix = dec.getValue("ix"); -// int iy = dec.getValue("iy"); -// if (iy == 1 && ix == -2) -// System.out.printf("Time %f, input hit %f)\n", ClockSingleton.getTime() + hit.getTime(), hit.getRawEnergy()); - - RingBuffer eDepBuffer = eDepMap.get(hit.getCellID()); - if (eDepBuffer == null) { - eDepBuffer = new RingBuffer(bufferLength); - eDepMap.put(hit.getCellID(), eDepBuffer); - } - for (int i = 0; i < bufferLength; i++) { - eDepBuffer.addToCell(i, hit.getRawEnergy() * pulseAmplitude((i + 1) * readoutPeriod + readoutTime() - (ClockSingleton.getTime() + hit.getTime()))); - } - } - } - - @Override - protected void initReadout() { - //initialize buffers - eDepMap = new HashMap<Long, RingBuffer>(); - } - - private double pulseAmplitude(double time) { - if (time < 0.0) - return 0.0; - if (t0 > 0.0) { - return (time / t0) * Math.exp(1.0 - time / t0); - } else { - if (time < -t0) - return 1.0; - else - return 0.0; - } - } -}
diff -N HPSFADCTriggerDriver.java --- HPSFADCTriggerDriver.java 22 Dec 2012 00:54:16 -0000 1.20 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,475 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import hep.aida.IHistogram1D; -import hep.aida.IHistogram2D; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.EnumSet; -import java.util.LinkedList; -import java.util.List; - -import org.lcsim.event.Cluster; -import org.lcsim.event.EventHeader; -import org.lcsim.geometry.Detector; -import org.lcsim.hps.evio.TriggerData; -import org.lcsim.hps.util.ClockSingleton; -import org.lcsim.util.aida.AIDA; - -/** - * Reads clusters and makes trigger decision using opposite quadrant criterion. - * Prints triggers to file if file path specified. - * - * @author Omar Moreno <[log in to unmask]> - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSFADCTriggerDriver.java,v 1.20 2012/12/22 00:54:16 meeg Exp $ - */ -public class HPSFADCTriggerDriver extends HPSTriggerDriver { - - // A list to contain all cluster pairs in an event - List<HPSEcalCluster[]> clusterPairs; - int nTriggers; - int totalEvents; - private double beamEnergy = 2.2 * HPSECalUtils.GeV; - private double clusterEnergyHigh = 1.85 / 2.2; - private double clusterEnergyLow = .1 / 2.2; - private double energySumThreshold = 1.0; - private double energyDifferenceThreshold = 1.5 / 2.2; - private double maxCoplanarityAngle = 35; // degrees -// private double energyDistanceDistance = 250; // mm -// private double energyDistanceThreshold = 0.8 / 2.2; - private double energyDistanceDistance = 200; // mm - private double energyDistanceThreshold = 0.5; - int allPairs; - int oppositeQuadrantCount; - int clusterEnergyCount; - int energySumCount; - int energyDifferenceCount; - int energyDistanceCount; - int coplanarityCount; - AIDA aida = AIDA.defaultInstance(); - IHistogram2D clusterEnergy2DAll, clusterSumDiff2DAll, energyDistance2DAll, clusterAngles2DAll, clusterCoplanarity2DAll; - IHistogram2D clusterEnergy2D, clusterSumDiff2D, energyDistance2D, clusterAngles2D, clusterCoplanarity2D; - IHistogram1D triggerBits1D, triggerTimes1D; - private boolean useQuadrants = false; - - private enum Flag { - - CLUSTER_ENERGY(3), ENERGY_SUM_DIFF(2), ENERGY_DISTANCE(1), COPLANARITY(0); - private final int index; - - Flag(int i) { - index = i; - } - - static int bitmask(EnumSet<Flag> flags) { - int mask = 0; - for (Flag flag : flags) { - mask |= 1 << flag.index; - } - return mask; - } - } - - public HPSFADCTriggerDriver() { - clusterPairs = new LinkedList<HPSEcalCluster[]>(); - } - - public void setBeamEnergy(double beamEnergy) { - if (beamEnergy == 1.1) { - System.out.println(this.getClass().getSimpleName() + ": Setting trigger for 1.1 GeV beam"); - maxCoplanarityAngle = 90; - clusterEnergyHigh = .7 / beamEnergy; - clusterEnergyLow = .1 / beamEnergy; - energySumThreshold = 0.8 / beamEnergy; - } else if (beamEnergy == 2.2) { - System.out.println(this.getClass().getSimpleName() + ": Setting trigger for 2.2 GeV beam"); - maxCoplanarityAngle = 45; - clusterEnergyHigh = 1.6 / beamEnergy; - clusterEnergyLow = .1 / beamEnergy; - energySumThreshold = 1.7 / beamEnergy; - } else if (beamEnergy == 6.6) { - System.out.println(this.getClass().getSimpleName() + ": Setting trigger for 6.6 GeV beam"); - maxCoplanarityAngle = 60; - clusterEnergyHigh = 5.0 / beamEnergy; - clusterEnergyLow = .1 / beamEnergy; - energySumThreshold = 5.5 / beamEnergy; - } - this.beamEnergy = beamEnergy * HPSECalUtils.GeV; - } - - @Override - public void detectorChanged(Detector detector) { - if (detector.getName().contains("1pt1")) { - setBeamEnergy(1.1); - } else if (detector.getName().contains("2pt2")) { - setBeamEnergy(2.2); - } else if (detector.getName().contains("6pt6")) { - setBeamEnergy(6.6); - } - - clusterSumDiff2DAll = aida.histogram2D("All cluster pairs: energy difference vs. sum", 100, 0.0, 2 * beamEnergy, 100, 0.0, beamEnergy); - clusterEnergy2DAll = aida.histogram2D("All cluster pairs: energy (less energetic vs. more energetic)", 100, 0.0, 2 * beamEnergy, 100, 0.0, beamEnergy); - energyDistance2DAll = aida.histogram2D("All cluster pairs: distance vs. energy (less energetic cluster)", 100, 0.0, 0.5 * beamEnergy, 25, 0.0, 400.0); - clusterCoplanarity2DAll = aida.histogram2D("All cluster pairs: cluster angle uncoplanarity vs. less energetic cluster angle", 100, -180.0, 180.0, 100, -180.0, 180.0); - clusterAngles2DAll = aida.histogram2D("All cluster pairs: cluster angle (less energetic vs. more energetic)", 100, -180.0, 180.0, 100, -180.0, 180.0); - - clusterSumDiff2D = aida.histogram2D("Passed other cuts: energy difference vs. sum", 100, 0.0, 2 * beamEnergy, 100, 0.0, beamEnergy); - clusterEnergy2D = aida.histogram2D("Passed other cuts: energy (less energetic vs. more energetic)", 100, 0.0, 2 * beamEnergy, 100, 0.0, beamEnergy); - energyDistance2D = aida.histogram2D("Passed other cuts: distance vs. energy (less energetic cluster)", 100, 0.0, 0.5 * beamEnergy, 25, 0.0, 400.0); - clusterCoplanarity2D = aida.histogram2D("Passed other cuts: cluster angle uncoplanarity vs. less energetic cluster angle", 100, -180.0, 180.0, 100, -180.0, 180.0); - clusterAngles2D = aida.histogram2D("Passed other cuts: cluster angle (less energetic vs. more energetic)", 100, -180.0, 180.0, 100, -180.0, 180.0); - - triggerBits1D = aida.histogram1D(detector.getDetectorName() + " : " + clusterCollectionName + " : trigger bits", 17, -1.5, 15.5); - triggerTimes1D = aida.histogram1D(detector.getDetectorName() + " : " + clusterCollectionName + " : trigger times", 500, -0.5, 499.5); - } - - @Override - public void startOfData() { - super.startOfData(); - - allPairs = 0; - oppositeQuadrantCount = 0; - clusterEnergyCount = 0; - energySumCount = 0; - energyDifferenceCount = 0; - energyDistanceCount = 0; - coplanarityCount = 0; - } - - @Override - public boolean testTrigger(List<HPSEcalCluster> clusters) { - boolean trigger = false; - - if (useQuadrants) { - getClusterPairs(clusters); - } else { - getClusterPairsTopBot(clusters); - } - - //--- Apply Trigger Cuts ---// - - // Iterate through all cluster pairs present in the event. If at least - // one of the cluster pairs satisfies all of the trigger conditions, - // a trigger signal is sent to all other detectors. - for (HPSEcalCluster[] clusterPair : clusterPairs) { - - EnumSet<Flag> bits = EnumSet.noneOf(Flag.class); - - if (outputStream != null) { - outputStream.printf("Event %d: cluster pair (energy %f in quadrant %d (%s), energy %f in quadrant %d (%s))\n", - ClockSingleton.getClock(), - clusterPair[0].getEnergy(), HPSECalUtils.getQuadrant(clusterPair[0]), clusterPair[0].getSeedHit().getPositionVec().toString(), - clusterPair[1].getEnergy(), HPSECalUtils.getQuadrant(clusterPair[1]), clusterPair[1].getSeedHit().getPositionVec().toString()); - } - - allPairs++; - - if (useQuadrants) { - // Require that the event have at least two clusters in opposite - // quadrants - if (!oppositeQuadrantsCut(clusterPair)) { - if (outputStream != null) { - outputStream.println("Failed opposite quadrant cut"); - } - continue; - } - oppositeQuadrantCount++; - } - - // Require the components of a cluster pair to have an energy in - // the range of 100 MeV to 1.85 GeV - if (clusterECut(clusterPair)) { - bits.add(Flag.CLUSTER_ENERGY); - } - - bits.add(Flag.ENERGY_SUM_DIFF); - // Require the sum of the energies of the components of the - // cluster pair to be less than the - // (Beam Energy)*(Sampling Fraction) ( 2 GeV for the Test Run ) - if (!energySum(clusterPair)) { - bits.remove(Flag.ENERGY_SUM_DIFF); - } - - // Require the difference in energy of the components of the - // cluster pair to be less than 1.5 GeV - if (!energyDifference(clusterPair)) { - bits.remove(Flag.ENERGY_SUM_DIFF); - } - - // Apply a low energy cluster vs. distance cut of the form - // E_low + .0032 GeV/mm < .8 GeV - if (energyDistanceCut(clusterPair)) { - bits.add(Flag.ENERGY_DISTANCE); - } - - // Require that the two clusters are coplanar with the beam within - // 35 degrees - if (coplanarityCut(clusterPair)) { - bits.add(Flag.COPLANARITY); - } - - if (bits.contains(Flag.CLUSTER_ENERGY)) { - clusterEnergyCount++; - if (energySum(clusterPair)) { - energySumCount++; - if (energyDifference(clusterPair)) { - energyDifferenceCount++; - if (bits.contains(Flag.ENERGY_DISTANCE)) { - energyDistanceCount++; - if (bits.contains(Flag.COPLANARITY)) { - coplanarityCount++; - } else if (outputStream != null) { - outputStream.println("Failed coplanarity cut"); - } - } else if (outputStream != null) { - outputStream.println("Failed energy-distance cut"); - } - } else if (outputStream != null) { - outputStream.println("Failed energy difference cut"); - } - } else if (outputStream != null) { - outputStream.println("Failed energy sum cut"); - } - } else if (outputStream != null) { - outputStream.println("Failed cluster energy cut"); - } - - clusterSumDiff2DAll.fill(clusterPair[0].getEnergy() + clusterPair[1].getEnergy(), clusterPair[0].getEnergy() - clusterPair[1].getEnergy()); - clusterEnergy2DAll.fill(clusterPair[0].getEnergy(), clusterPair[1].getEnergy()); - energyDistance2DAll.fill(clusterPair[1].getEnergy(), getClusterDistance(clusterPair[1])); - clusterCoplanarity2DAll.fill(getClusterAngle(clusterPair[1]), pairUncoplanarity(clusterPair)); - clusterAngles2DAll.fill(getClusterAngle(clusterPair[0]), getClusterAngle(clusterPair[1])); - - if (bits.containsAll(EnumSet.complementOf(EnumSet.of(Flag.ENERGY_SUM_DIFF, Flag.CLUSTER_ENERGY)))) { //cluster energy, energy-distance, coplanarity - clusterSumDiff2D.fill(clusterPair[0].getEnergy() + clusterPair[1].getEnergy(), clusterPair[0].getEnergy() - clusterPair[1].getEnergy()); - clusterEnergy2D.fill(clusterPair[0].getEnergy(), clusterPair[1].getEnergy()); - } - if (bits.containsAll(EnumSet.complementOf(EnumSet.of(Flag.ENERGY_DISTANCE)))) { - energyDistance2D.fill(clusterPair[1].getEnergy(), getClusterDistance(clusterPair[1])); - } - if (bits.containsAll(EnumSet.complementOf(EnumSet.of(Flag.COPLANARITY)))) { - clusterCoplanarity2D.fill(getClusterAngle(clusterPair[1]), pairUncoplanarity(clusterPair)); - clusterAngles2D.fill(getClusterAngle(clusterPair[0]), getClusterAngle(clusterPair[1])); - } - - triggerBits1D.fill(Flag.bitmask(bits)); - - if (bits.containsAll(EnumSet.allOf(Flag.class))) { - // If all cuts are pased, we have a trigger - if (outputStream != null) { - outputStream.println("Passed all cuts"); - } - trigger = true; - } - } - if (trigger) { - triggerBits1D.fill(-1); - triggerTimes1D.fill(ClockSingleton.getClock() % 500); - } - return trigger; - } - - @Override - public void endOfData() { - if (outputStream != null) { - printCounts(outputStream); - } - printCounts(new PrintWriter(System.out)); - super.endOfData(); - } - - private void printCounts(PrintWriter writer) { - writer.printf("Number of pairs: %d\n", allPairs); - writer.printf("Number of cluster pairs after successive trigger conditions:\n"); - if (useQuadrants) { - writer.printf("Opposite quadrants: %d\n", oppositeQuadrantCount); - } - writer.printf("Cluster energy: %d\n", clusterEnergyCount); - writer.printf("Energy sum: %d\n", energySumCount); - writer.printf("Energy difference: %d\n", energyDifferenceCount); - writer.printf("Energy-distance cut: %d\n", energyDistanceCount); - writer.printf("Coplanarity: %d\n", coplanarityCount); - writer.printf("Trigger count: %d\n", numTriggers); - writer.close(); - } - - /** - * Get a list of all unique cluster pairs in the event - * - * @param ecalClusters : List of ECal clusters - * @return true if there are any cluster pairs - */ - private boolean getClusterPairs(List<HPSEcalCluster> ecalClusters) { - // Create a list which will hold all neighboring cluster to the cluster - // of interest - List< HPSEcalCluster> ecalClusterNeighbors = new LinkedList< HPSEcalCluster>(); - ecalClusterNeighbors.addAll(ecalClusters); - - // Clear the list of cluster pairs - clusterPairs.clear(); - - for (HPSEcalCluster ecalCluster : ecalClusters) { - // Create a list of neighbors to the cluster of interest - ecalClusterNeighbors.remove(ecalCluster); - - // Loop over all neigboring clusters and check to see if there is - // any which lie in opposing quadrants to the cluster of interest. - // If so, add them to the list of cluster pairs - for (HPSEcalCluster ecalClusterNeighbor : ecalClusterNeighbors) { - if (ecalCluster.getEnergy() > ecalClusterNeighbor.getEnergy()) { - HPSEcalCluster[] clusterPair = {ecalCluster, ecalClusterNeighbor}; - clusterPairs.add(clusterPair); - } else { - HPSEcalCluster[] clusterPair = {ecalClusterNeighbor, ecalCluster}; - clusterPairs.add(clusterPair); - } - } - } - - return !clusterPairs.isEmpty(); - } - - private boolean getClusterPairsTopBot(List<HPSEcalCluster> ecalClusters) { - // Create a list which will hold all neighboring cluster to the cluster - // of interest - List< HPSEcalCluster> topClusters = new ArrayList< HPSEcalCluster>(); - List< HPSEcalCluster> botClusters = new ArrayList< HPSEcalCluster>(); - for (HPSEcalCluster ecalCluster : ecalClusters) { - if (ecalCluster.getSeedHit().getIdentifierFieldValue("iy") > 0) { - topClusters.add(ecalCluster); - } else { - botClusters.add(ecalCluster); - } - } - // Clear the list of cluster pairs - clusterPairs.clear(); - - // Loop over all top-bottom pairs of clusters; higher-energy cluster goes first in the pair - for (HPSEcalCluster topCluster : topClusters) { - for (HPSEcalCluster botCluster : botClusters) { - if (topCluster.getEnergy() > botCluster.getEnergy()) { - HPSEcalCluster[] clusterPair = {topCluster, botCluster}; - clusterPairs.add(clusterPair); - } else { - HPSEcalCluster[] clusterPair = {botCluster, topCluster}; - clusterPairs.add(clusterPair); - } - } - } - return !clusterPairs.isEmpty(); - } - - /** - * Checks if the ECal clusters making up a cluster pair lie in opposite - * quadrants - * - * @param clusterPair : pair of clusters - * @return true if opposite quadrants, false otherwise - */ - private boolean oppositeQuadrantsCut(HPSEcalCluster[] clusterPair) { - int quad1 = HPSECalUtils.getQuadrant(clusterPair[0]); - int quad2 = HPSECalUtils.getQuadrant(clusterPair[1]); - - //if clusters are in the same quadrant, they're not opposite quadrants - if (quad1 == quad2) { - return false; - } //opposite pairs of quadrants are either both even (2 and 4) or both odd (1 and 3) - else { - return ((quad1 & 1) == (quad2 & 1)); - } - } - - /** - * Checks if the ECal clusters making up a cluster pair lie above the low - * energy threshold and below the high energy threshold - * - * @param clusterPair : pair of clusters - * @return true if a pair is found, false otherwise - */ - private boolean clusterECut(HPSEcalCluster[] clusterPair) { - return (clusterPair[0].getEnergy() < beamEnergy * clusterEnergyHigh - && clusterPair[1].getEnergy() < beamEnergy * clusterEnergyHigh - && clusterPair[0].getEnergy() > beamEnergy * clusterEnergyLow - && clusterPair[1].getEnergy() > beamEnergy * clusterEnergyLow); - } - - /** - * Checks if the sum of the energies of ECal clusters making up a cluster - * pair is below an energy sum threshold - * - * @param clusterPair : pair of clusters - * @return true if a pair is found, false otherwise - */ - private boolean energySum(Cluster[] clusterPair) { - double clusterESum = clusterPair[0].getEnergy() + clusterPair[1].getEnergy(); - return (clusterESum < beamEnergy * energySumThreshold); - } - - /** - * Checks if the energy difference between the ECal clusters making up a - * cluster pair is below an energy difference threshold - * - * @param clusterPair : pair of clusters - * @return true if pair is found, false otherwise - */ - private boolean energyDifference(HPSEcalCluster[] clusterPair) { - double clusterEDifference = clusterPair[0].getEnergy() - clusterPair[1].getEnergy(); - - return (clusterEDifference < beamEnergy * energyDifferenceThreshold); - } - - /** - * Require that the distance from the beam of the lowest energy cluster in a - * cluster pair satisfies the following E_low + d_b*.0032 GeV/mm < .8 GeV - * - * @param clusterPair : pair of clusters - * @return true if pair is found, false otherwise - */ - private boolean energyDistanceCut(HPSEcalCluster[] clusterPair) { - HPSEcalCluster lowEnergyCluster = clusterPair[1]; - - // Calculate its position - double lowEClusterDistance = getClusterDistance(clusterPair[1]); - // event passes cut if above the line with X- and Y-intercepts defined by energyDistanceDistance and beamEnergy*energyDistanceThreshold - double clusterDistvsE = lowEnergyCluster.getEnergy() + lowEClusterDistance * beamEnergy * energyDistanceThreshold / energyDistanceDistance; - - return (clusterDistvsE > beamEnergy * energyDistanceThreshold); - } - - /** - * Checks if a cluster pair is coplanar to the beam within a given angle - * - * @param clusterPair : pair of clusters - * @return true if pair is found, false otherwise - */ - private boolean coplanarityCut(HPSEcalCluster[] clusterPair) { - return (Math.abs(pairUncoplanarity(clusterPair)) < maxCoplanarityAngle); - } - - private double pairUncoplanarity(HPSEcalCluster[] clusterPair) { // Find the angle between clusters in the pair - double cluster1Angle = (getClusterAngle(clusterPair[0]) + 180.0) % 180.0; - double cluster2Angle = (getClusterAngle(clusterPair[1]) + 180.0) % 180.0; - - return cluster2Angle - cluster1Angle; - } - - private double getClusterAngle(HPSEcalCluster cluster) { //returns angle in range of -180 to 180 - double position[] = cluster.getSeedHit().getPosition(); - return Math.toDegrees(Math.atan2(position[1], position[0])); - } - - private double getClusterDistance(HPSEcalCluster cluster) { - return Math.hypot(cluster.getSeedHit().getPosition()[0], cluster.getSeedHit().getPosition()[1]); - } - - /** - * Make a dummy TriggerData - */ - @Override - protected void makeTriggerData(EventHeader event, String collectionName) { - TriggerData tData = new TriggerData(new int[8]); - List<TriggerData> triggerList = new ArrayList<TriggerData>(); - triggerList.add(tData); - event.put(collectionName, triggerList, TriggerData.class, 0); - } -}
\ No newline at end of file
diff -N HPSEcal1BitEventVetoClusterer.java --- HPSEcal1BitEventVetoClusterer.java 8 Dec 2012 01:12:17 -0000 1.4 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,69 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.HashMap; -import java.util.List; -import java.util.Set; - -import org.lcsim.event.CalorimeterHit; - -/** - * Creates clusters from CalorimeterHits in the HPSEcal detector. - * - * A veto hit vetoes all clusters in the event. - * - * The clustering algorithm is from JLab Hall B 6 GeV DVCS Trigger Design doc. - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSEcal1BitEventVetoClusterer.java,v 1.4 2012/12/08 01:12:17 meeg Exp $ - */ -public class HPSEcal1BitEventVetoClusterer extends HPSEcal1BitClusterer { - - public HPSEcal1BitEventVetoClusterer() { - } - - @Override - public void countHits(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) { - // Hit map. - hitMap = new HashMap<Long, CalorimeterHit>(); - - hitCounts = new HashMap<Long, Integer>(); - if (vetoHits != null && !vetoHits.isEmpty()) { - return; - } - - // Loop over ECal hits to count hit towers - for (CalorimeterHit hit : hits) { - int ix = hit.getIdentifierFieldValue("ix"); - if (ix >= xMin && ix <= xMax) { - continue; - } - - // Make a hit map for quick lookup by ID. - hitMap.put(hit.getCellID(), hit); - - // Get neighbor crystal IDs. - Set<Long> neighbors = neighborMap.get(hit.getCellID()); - - if (neighbors == null) { - throw new RuntimeException("Oops! Set of neighbors is null!"); - } - - Integer hitCount = hitCounts.get(hit.getCellID()); - if (hitCount == null) { - hitCounts.put(hit.getCellID(), 1); - } else { - hitCounts.put(hit.getCellID(), hitCount + 1); - } - - // Loop over neighbors to make hit list for cluster. - for (Long neighborId : neighbors) { - hitCount = hitCounts.get(neighborId); - if (hitCount == null) { - hitCounts.put(neighborId, 1); - } else { - hitCounts.put(neighborId, hitCount + 1); - } - } - } - } -}
diff -N HPSEcalTriggerFilterDriver.java --- HPSEcalTriggerFilterDriver.java 21 Sep 2012 23:16:02 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,108 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.ArrayList; -import java.util.List; -import java.util.Queue; -import java.util.concurrent.ArrayBlockingQueue; -import org.lcsim.event.CalorimeterHit; -import org.lcsim.event.EventHeader; -import org.lcsim.geometry.Detector; -import org.lcsim.util.Driver; - -/** - * Changes ECal hit IDs to match what the test run trigger sees. - * @version $Id: HPSEcalRawConverterDriver.java,v 1.2 2012/05/03 00:17:54 - * phansson Exp $ - */ -public class HPSEcalTriggerFilterDriver extends Driver { - - private String ecalReadoutName = "EcalHits"; - private String inputCollection = "EcalReadoutHits"; - private String outputCollection = "EcalCalHits"; - private int topDelay = 0; - private int bottomDelay = 5; - private Queue<List<CalorimeterHit>> topHitsQueue = null; - private Queue<List<CalorimeterHit>> bottomHitsQueue = null; - - public HPSEcalTriggerFilterDriver() { - } - - public void setOutputCollection(String outputCollection) { - this.outputCollection = outputCollection; - } - - public void setInputCollection(String inputCollection) { - this.inputCollection = inputCollection; - } - - @Override - public void startOfData() { - if (outputCollection == null) { - throw new RuntimeException("The parameter ecalCollectionName was not set!"); - } - - topHitsQueue = new ArrayBlockingQueue<List<CalorimeterHit>>(topDelay + 1); - for (int i = 0; i < topDelay; i++) { - topHitsQueue.add(new ArrayList<CalorimeterHit>()); - } - bottomHitsQueue = new ArrayBlockingQueue<List<CalorimeterHit>>(bottomDelay + 1); - for (int i = 0; i < bottomDelay; i++) { - bottomHitsQueue.add(new ArrayList<CalorimeterHit>()); - } - } - - @Override - public void detectorChanged(Detector detector) { - } - - @Override - public void process(EventHeader event) { - if (event.hasCollection(CalorimeterHit.class, inputCollection)) { - ArrayList<CalorimeterHit> newHits = new ArrayList<CalorimeterHit>(); - - ArrayList<CalorimeterHit> topHits = new ArrayList<CalorimeterHit>(); - ArrayList<CalorimeterHit> bottomHits = new ArrayList<CalorimeterHit>(); - - List<CalorimeterHit> hits = event.get(CalorimeterHit.class, inputCollection); - for (CalorimeterHit hit : hits) { - CalorimeterHit newHit = filterHit(hit); - if (newHit != null) { - if (hit.getIdentifierFieldValue("iy") > 0) { //should really be checking newHit, but it doesn't have metadata yet - topHits.add(newHit); - } else { - bottomHits.add(newHit); - } - } - } - topHitsQueue.add(topHits); - bottomHitsQueue.add(bottomHits); - newHits.addAll(topHitsQueue.poll()); - newHits.addAll(bottomHitsQueue.poll()); - int flags = 0; - event.put(outputCollection, newHits, CalorimeterHit.class, flags, ecalReadoutName); - } - } - - private CalorimeterHit filterHit(CalorimeterHit hit) { - int ix = hit.getIdentifierFieldValue("ix"); - int iy = hit.getIdentifierFieldValue("iy"); - long daqID = HPSEcalConditions.physicalToDaqID(hit.getCellID()); - int crate = HPSEcalConditions.getCrate(daqID); - short slot = HPSEcalConditions.getSlot(daqID); - short channel = HPSEcalConditions.getChannel(daqID); - - int delay = iy>0?topDelay:bottomDelay; - // no triggers from crate 1, slot 3 - if (crate == 1 && slot == 3) { - return null; - } - - // flip quadrant - if (ix > 0 && iy > 0) { - ix = 24 - ix; - } - long newID = HPSEcalConditions.makePhysicalID(ix, iy); - //make new hit; set position to null so it gets recalculated - return new HPSRawCalorimeterHit(hit.getRawEnergy(), hit.getTime()+delay*4, newID, hit.getType()); - } -}
diff -N HPSEcalEdepToTriggerConverterDriver.java --- HPSEcalEdepToTriggerConverterDriver.java 8 Dec 2012 01:12:17 -0000 1.7 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,188 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.ArrayList; -import java.util.List; -import org.lcsim.event.CalorimeterHit; -import org.lcsim.event.EventHeader; -import org.lcsim.geometry.Detector; -import org.lcsim.util.Driver; - -/** - * - * @version $Id: HPSEcalRawConverterDriver.java,v 1.2 2012/05/03 00:17:54 - * phansson Exp $ - */ -public class HPSEcalEdepToTriggerConverterDriver extends Driver { - - private String ecalReadoutName = "EcalHits"; - private String inputCollection = "EcalHits"; - private String readoutCollection = "EcalCalHits"; - private String triggerCollection = "EcalTriggerHits"; - private boolean applyBadCrystalMap = true; - private double tp = 14.0; - private double readoutPeriod = 4.0; - private int readoutThreshold = 50; - private int triggerThreshold = 80; - private int truncateScale = 128; - private double pulseIntegral = tp * Math.E / readoutPeriod; - private double gainScale = 1.0; //gain miscalibration factor - private double _gain = -1.0; //constant gain, activated if >0 - - public HPSEcalEdepToTriggerConverterDriver() { - } - - public void setTp(double tp) { - this.tp = tp; - } - - public void setReadoutCollection(String readoutCollection) { - this.readoutCollection = readoutCollection; - } - - public void setTriggerCollection(String triggerCollection) { - this.triggerCollection = triggerCollection; - } - - public void setInputCollection(String inputCollection) { - this.inputCollection = inputCollection; - } - - public void setApplyBadCrystalMap(boolean apply) { - this.applyBadCrystalMap = apply; - } - - public void setTruncateScale(int truncateScale) { - this.truncateScale = truncateScale; - } - - public void setConstantGain(double gain) { - this._gain = gain; - } - - @Override - public void startOfData() { - if (readoutCollection == null) { - throw new RuntimeException("The parameter ecalCollectionName was not set!"); - } - } - - @Override - public void detectorChanged(Detector detector) { - } - - public boolean isBadCrystal(CalorimeterHit hit) { - return HPSEcalConditions.badChannelsLoaded() ? HPSEcalConditions.isBadChannel(hit.getCellID()) : false; - } - - @Override - public void process(EventHeader event) { - ArrayList<CalorimeterHit> triggerHits = new ArrayList<CalorimeterHit>(); - ArrayList<CalorimeterHit> readoutHits = new ArrayList<CalorimeterHit>(); - - if (event.hasCollection(CalorimeterHit.class, inputCollection)) { - List<CalorimeterHit> hits = event.get(CalorimeterHit.class, inputCollection); - - for (CalorimeterHit hit : hits) { - if (applyBadCrystalMap && isBadCrystal(hit)) { - continue; - } - CalorimeterHit triggerHit = makeTriggerHit(hit); - if (triggerHit != null) { - triggerHits.add(triggerHit); - } - CalorimeterHit readoutHit = makeReadoutHit(hit); - if (readoutHit != null) { - readoutHits.add(readoutHit); - } - } - } - int flags = 0; - event.put(triggerCollection, triggerHits, CalorimeterHit.class, flags, ecalReadoutName); - event.put(readoutCollection, readoutHits, CalorimeterHit.class, flags, ecalReadoutName); - } - - public CalorimeterHit makeTriggerHit(CalorimeterHit hit) { - double amplitude = hitAmplitude(hit); - -// double time = readoutPeriod * (Math.random() - 1); - double time = 0 - hit.getTime(); - double triggerIntegral = 0; - boolean overThreshold = false; - while (true) { - double currentValue = amplitude * pulseAmplitude(time); - if (!overThreshold && currentValue > triggerThreshold) { - overThreshold = true; - } - if (overThreshold) { - triggerIntegral += amplitude * pulseAmplitude(time); - if (currentValue < triggerThreshold) { - break; - } - } - time += readoutPeriod; - - if (time > 200.0) { - break; - } - } - -// System.out.format("%f %f %f\n", readoutIntegral, amplitude, triggerIntegral); - - int truncatedIntegral = (int) Math.floor(triggerIntegral / truncateScale); - if (truncatedIntegral > 0) { - return new HPSRawCalorimeterHit(truncatedIntegral, hit.getTime(), hit.getCellID(), 0); - } - return null; - } - - public CalorimeterHit makeReadoutHit(CalorimeterHit hit) { - double amplitude = hitAmplitude(hit); - if (amplitude < readoutThreshold) { - return null; - } - double integral = hit.getRawEnergy()/HPSECalUtils.GeV * gainScale; - -// double thresholdCrossingTime = 0 - hit.getTime(); -// while (true) { -// double currentValue = amplitude * pulseAmplitude(thresholdCrossingTime); -// if (currentValue > readoutThreshold) { -// break; -// } -// thresholdCrossingTime += readoutPeriod; -// -// if (thresholdCrossingTime > 200.0) { -// break; -// } -// } -// -// double readoutIntegral = 0; -// for (int i = 0; i < 35; i++) { -// readoutIntegral += amplitude * pulseAmplitude(thresholdCrossingTime + (i - 5) * readoutPeriod); -// } -//// double integral = readoutIntegral * HPSEcalConditions.physicalToGain(id); -// System.out.format("dumb: %f, full: %f\n",hit.getRawEnergy() * 1000.0,readoutIntegral * HPSEcalConditions.physicalToGain(id)); - - CalorimeterHit h = new HPSRawCalorimeterHit(integral, hit.getTime(), hit.getCellID(), 0); - return h; - } - - private double hitAmplitude(CalorimeterHit hit) { - double gain = _gain > 0 ? _gain : HPSEcalConditions.physicalToGain(hit.getCellID()); - return (hit.getRawEnergy() /HPSECalUtils.MeV) / (gain * pulseIntegral); - } - - private double pulseAmplitude(double time) { - if (time <= 0.0) { - return 0.0; - } - if (tp > 0.0) { - return (time / tp) * Math.exp(1.0 - time / tp); - } else { - if (time < -tp) { - return 1.0; - } else { - return 0.0; - } - } - } -}
diff -N HPSEcalConditions.java --- HPSEcalConditions.java 16 Oct 2012 20:00:39 -0000 1.21 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,342 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.io.BufferedReader; -import org.lcsim.geometry.compact.Subdetector; -import java.io.IOException; -import java.io.Reader; -import java.util.HashMap; -import java.util.HashSet; -import java.util.StringTokenizer; -import org.lcsim.conditions.ConditionsManager; -import org.lcsim.detector.identifier.ExpandedIdentifier; -import org.lcsim.detector.identifier.IExpandedIdentifier; -import org.lcsim.detector.identifier.IIdentifierHelper; -import org.lcsim.geometry.Detector; -import org.lcsim.util.Driver; - -/** - * - * @author meeg - * @version $Id: HPSEcalConditions.java,v 1.21 2012/10/16 20:00:39 phansson Exp $ - */ -public class HPSEcalConditions extends Driver { - - //DAQ channel map - private static HashMap<Long, Long> daqToPhysicalMap = new HashMap<Long, Long>(); - private static HashMap<Long, Long> physicalToDaqMap = new HashMap<Long, Long>(); - //pedestals - private static HashMap<Long, Double> daqToPedestalMap = new HashMap<Long, Double>(); - private static HashMap<Long, Double> daqToNoiseMap = new HashMap<Long, Double>(); - //set of bad channels to ignore - private static HashSet<Long> badChannelsSet = new HashSet<Long>(); - private static boolean badChannelsLoaded = false; - private static IIdentifierHelper helper = null; - //gain - private static HashMap<Long, Double> physicalToGainMap = new HashMap<Long, Double>(); - //subdetector name (for when this is used as a driver) - private String subdetectorName = "Ecal"; - private static Subdetector subdetector; - private static boolean debug = false; - private static boolean calibrationLoaded = false; - - public HPSEcalConditions() { - } - - @Override - public void detectorChanged(Detector detector) { - detectorChanged(detector, subdetectorName); - } - - public static void detectorChanged(Detector detector, String ecalName) { - subdetector = detector.getSubdetector(ecalName); - if (subdetector == null) { - throw new RuntimeException("Subdetector " + ecalName + " not found"); - } - helper = subdetector.getDetectorElement().getIdentifierHelper(); - } - - public static boolean calibrationLoaded() { - return calibrationLoaded; - } - - public static void loadDaqMap(Detector detector, String ecalName) { - detectorChanged(detector, ecalName); - fillDaqCellMap(subdetector); - } - - public static void loadCalibration() { - fillDaqCellMap(subdetector); - loadBadChannels(subdetector); - loadGains(); - loadPedestals(); - calibrationLoaded = true; - } - - public void setSubdetectorName(String subdetectorName) { - this.subdetectorName = subdetectorName; - } - - public static IIdentifierHelper getHelper() { - return helper; - } - - public static Subdetector getSubdetector() { - return subdetector; - } - - public static boolean badChannelsLoaded() { - return badChannelsLoaded; - } - - public static void loadPedestals() { - ConditionsManager conditions = ConditionsManager.defaultInstance(); - try { - Reader pedestalsReader = conditions.getRawConditions("calibECal/default01.ped").getReader(); - loadPedestals(pedestalsReader, 1); - pedestalsReader = conditions.getRawConditions("calibECal/default02.ped").getReader(); - loadPedestals(pedestalsReader, 2); - } catch (IOException e) { - throw new RuntimeException("couldn't get pedestals file", e); - } - } - - public static void loadPedestals(Reader reader, int crate) { - - System.out.println("reading pedestals for ECal"); - - BufferedReader bufferedReader = new BufferedReader(reader); - String line; - while (true) { - try { - line = bufferedReader.readLine(); - } catch (IOException e) { - throw new RuntimeException("couldn't parse pedestals file", e); - } - if (line == null) { - break; - } - - if (line.indexOf("#") != -1) { - line = line.substring(0, line.indexOf("#")); - } - - StringTokenizer lineTok = new StringTokenizer(line); - - if (lineTok.countTokens() != 0) { - if (lineTok.countTokens() != 4) { - throw new RuntimeException("Invalid line in pedestals file: " + line); - } else { - short slot = Short.valueOf(lineTok.nextToken()); - short channel = Short.valueOf(lineTok.nextToken()); - double pedestal = Double.valueOf(lineTok.nextToken()); - double noise = Double.valueOf(lineTok.nextToken()); - long daqid = getDaqID(crate, slot, channel); - daqToPedestalMap.put(daqid, pedestal); - daqToNoiseMap.put(daqid, noise); - if (debug) { - System.out.printf("Channel %d: pede %.2f noise %.2f (crate %d slot %d channel %d)\n", daqid,pedestal,noise,crate,slot,channel); - } - } - } - } - } - - private static void loadBadChannels(Subdetector ecal) { - - System.out.println("reading ECal bad channels"); - - IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields()); - expId.setValue(helper.getFieldIndex("system"), ecal.getSystemID()); - ConditionsManager conditions = ConditionsManager.defaultInstance(); - BufferedReader bufferedReader; - try { - bufferedReader = new BufferedReader(conditions.getRawConditions("daqmap/ecal.badchannels").getReader()); - } catch (IOException e) { - throw new RuntimeException("couldn't get ECal bad channels from conditions manager", e); - } - String line; - while (true) { - try { - line = bufferedReader.readLine(); - } catch (IOException e) { - throw new RuntimeException("couldn't parse ECal bad channels", e); - } - if (line == null) { - break; - } - - if (line.indexOf("#") != -1) { - line = line.substring(0, line.indexOf("#")); - } - - StringTokenizer lineTok = new StringTokenizer(line); - - if (lineTok.countTokens() != 0) { - if (lineTok.countTokens() != 2) { - throw new RuntimeException("Invalid line in ECal bad channels: " + line); - } else { - int x = Integer.valueOf(lineTok.nextToken()); - int y = Integer.valueOf(lineTok.nextToken()); - expId.setValue(helper.getFieldIndex("ix"), x); - expId.setValue(helper.getFieldIndex("iy"), y); - badChannelsSet.add(helper.pack(expId).getValue()); - if (debug) { - System.out.printf("Channel %d is bad (x=%d y=%d)\n", helper.pack(expId).getValue(),x,y); - } - } - } - } - badChannelsLoaded = true; - } - - public static void loadGains() { - if (debug) { - System.out.println("Loading gains"); - } - BufferedReader bufferedReader; - ConditionsManager conditions = ConditionsManager.defaultInstance(); - try { - bufferedReader = new BufferedReader(conditions.getRawConditions("calibECal/default.gain").getReader()); - } catch (IOException e) { - throw new RuntimeException("couldn't get gain file", e); - } - - String line; - while (true) { - try { - line = bufferedReader.readLine(); - } catch (IOException e) { - throw new RuntimeException("couldn't parse gain file", e); - } - if (line == null) { - break; - } - - if (line.indexOf("#") != -1) { - line = line.substring(0, line.indexOf("#")); - } - - StringTokenizer lineTok = new StringTokenizer(line); - - if (lineTok.countTokens() != 0) { - if (lineTok.countTokens() != 3) { - throw new RuntimeException("Invalid line in gain file: " + line); - } else { - int x = Integer.valueOf(lineTok.nextToken()); - int y = Integer.valueOf(lineTok.nextToken()); - double gain = Double.valueOf(lineTok.nextToken()); - physicalToGainMap.put(makePhysicalID(x, y), gain); - if (debug) { - System.out.printf("Channel %d: gain %.2f (x=%d y=%d)\n", makePhysicalID(x, y),gain,x,y); - } - } - } - } - } - - public static boolean isBadChannel(long id) { - return badChannelsSet.contains(id); - } - - private static void fillDaqCellMap(Subdetector ecal) { - - System.out.println("reading ECal DAQ map"); - - IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields()); - expId.setValue(helper.getFieldIndex("system"), ecal.getSystemID()); - - ConditionsManager conditions = ConditionsManager.defaultInstance(); - BufferedReader bufferedReader; - try { - bufferedReader = new BufferedReader(conditions.getRawConditions("daqmap/ecal.txt").getReader()); - } catch (IOException e) { - throw new RuntimeException("couldn't get DAQ map from conditions manager", e); - } - String line; - while (true) { - try { - line = bufferedReader.readLine(); - } catch (IOException e) { - throw new RuntimeException("couldn't parse ECal DAQ map", e); - } - if (line == null) { - break; - } - - if (line.indexOf("#") != -1) { - line = line.substring(0, line.indexOf("#")); - } - - StringTokenizer lineTok = new StringTokenizer(line); - - if (lineTok.countTokens() != 0) { - if (lineTok.countTokens() != 5) { - throw new RuntimeException("Invalid line in ECal DAQ map: " + line); - } else { - int x = Integer.valueOf(lineTok.nextToken()); - int y = Integer.valueOf(lineTok.nextToken()); -// if (x>0 && y>0) x = 24-x; - expId.setValue(helper.getFieldIndex("ix"), x); - expId.setValue(helper.getFieldIndex("iy"), y); - int crate = Integer.valueOf(lineTok.nextToken()); - short slot = Short.valueOf(lineTok.nextToken()); - short channel = Short.valueOf(lineTok.nextToken()); - addMapEntry(helper.pack(expId).getValue(), getDaqID(crate, slot, channel)); - } - } - } - } - - public static long makePhysicalID(int ix, int iy) { - IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields()); - expId.setValue(helper.getFieldIndex("system"), subdetector.getSystemID()); - expId.setValue(helper.getFieldIndex("ix"), ix); - expId.setValue(helper.getFieldIndex("iy"), iy); - return helper.pack(expId).getValue(); - } - - private static void addMapEntry(long physicalID, long daqID) { - daqToPhysicalMap.put(daqID, physicalID); - physicalToDaqMap.put(physicalID, daqID); - } - - public static long getDaqID(int crate, short slot, short channel) { - return (((long) crate) << 32) | ((long) slot << 16) | (long) channel; - } - - public static Long daqToPhysicalID(int crate, short slot, short channel) { - return daqToPhysicalMap.get(getDaqID(crate, slot, channel)); - } - - public static int getCrate(long daqID) { - return (int) (daqID >>> 32); - } - - public static short getSlot(long daqID) { - return (short) ((daqID >>> 16) & 0xFFFF); - } - - public static short getChannel(long daqID) { - return (short) (daqID & 0xFFFF); - } - - public static Long physicalToDaqID(long physicalID) { - return physicalToDaqMap.get(physicalID); - } - - public static Long daqToPhysicalID(long daqID) { - return daqToPhysicalMap.get(daqID); - } - - public static Double daqToPedestal(long daqID) { - return daqToPedestalMap.get(daqID); - } - - public static Double physicalToPedestal(long physicalID) { - return daqToPedestalMap.get(physicalToDaqMap.get(physicalID)); - } - - public static Double physicalToGain(long physicalID) { - return physicalToGainMap.get(physicalID); - } -}
diff -N HPSTriggerDriver.java --- HPSTriggerDriver.java 11 Dec 2012 00:04:30 -0000 1.22 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,222 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.io.File; -import java.io.IOException; -import java.io.PrintStream; -import java.io.PrintWriter; -import java.util.LinkedList; -import java.util.List; -import java.util.Queue; - - -import java.util.logging.Level; -import java.util.logging.Logger; -import org.lcsim.event.EventHeader; -import org.lcsim.hps.recon.tracking.apv25.Apv25Full; -import org.lcsim.hps.recon.tracking.apv25.HPSAPV25; -import org.lcsim.hps.util.ClockSingleton; -import org.lcsim.util.Driver; -import org.lcsim.util.lcio.LCIOWriter; - -/** - * Reads clusters and makes trigger decision using opposite quadrant criterion. - * Prints triggers to file if file path specified. - * Applies SVT trigger latency and sends trigger signal to SVT - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSTriggerDriver.java,v 1.22 2012/12/11 00:04:30 meeg Exp $ - */ -public abstract class HPSTriggerDriver extends Driver { - - private boolean _DEBUG = false; - protected String clusterCollectionName = "EcalClusters"; - private String outputFileName = null; - protected PrintWriter outputStream = null; - protected int numTriggers; - private int lastTrigger; - private int deadTime = 0; - // FIFO queue to store the svt trigger time stamp - private Queue<Double> svtTriggerTimeStamp = new LinkedList<Double>(); - // SVT trigger latency - public static final double svtTriggerLatency = 100.0; // [ns] - // FIFO queue to store the ECal trigger time stamp - private Queue<Double> ecalTriggerTimestamps = null; - // ECal trigger latency - private static final double ecalTriggerLatency = 100.0; // [ns] - // FIFO queue to store the trigger bank trigger time stamp - private Queue<Double> triggerTriggerTimestamps = null; - // trigger bank trigger latency - public static final double triggerTriggerLatency = 50.0; // [ns] - private static boolean triggerBit = false; - private String lcioFile = null; - LCIOWriter lcioWriter = null; - - public HPSTriggerDriver() { - } - - public void setLcioFile(String lcioFile) { - this.lcioFile = lcioFile; - } - - /** - * Set dead time; 0 for no dead time - * @param deadTime Minimum number of clock ticks between triggers - */ - public void setDeadTime(int deadTime) { - this.deadTime = deadTime; - } - - public void setClusterCollectionName(String clusterCollectionName) { - this.clusterCollectionName = clusterCollectionName; - } - - public void setOutputFileName(String outputFileName) { - this.outputFileName = outputFileName; - } - - @Override - public void startOfData() { - if (clusterCollectionName == null) { - throw new RuntimeException("The parameter clusterCollectionName was not set!"); - } - - if (outputFileName != null) { - try { - outputStream = new PrintWriter(new PrintStream(outputFileName), true); - } catch (IOException ex) { - throw new RuntimeException("Invalid outputFilePath!"); - } - } else { - if (_DEBUG) { - outputStream = new PrintWriter(System.out, true); - } - } - - if (lcioFile != null) { - try { - lcioWriter = new LCIOWriter(new File(lcioFile)); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - numTriggers = 0; - - ecalTriggerTimestamps = new LinkedList<Double>(); - triggerTriggerTimestamps = new LinkedList<Double>(); - } - - @Override - public void process(EventHeader event) { - triggerBit = false; //reset trigger - //System.out.println(this.getClass().getCanonicalName() + " - process"); - - if (ClockSingleton.getClock() - lastTrigger > deadTime && triggerDecision(event)) { - triggerBit = true; - lastTrigger = ClockSingleton.getClock(); - numTriggers++; - if (_DEBUG) { - System.out.printf(this.getClass().getSimpleName() + ": Trigger on event %d\n", event.getEventNumber()); - } - if (outputStream != null) { - outputStream.printf("Trigger on event %d\n", event.getEventNumber()); - } - - // If an ECal trigger signal has been sent store the trigger - // time offset by the trigger latencies - svtTriggerTimeStamp.add(ClockSingleton.getTime() + svtTriggerLatency); - ecalTriggerTimestamps.add(ClockSingleton.getTime() + ecalTriggerLatency); - triggerTriggerTimestamps.add(ClockSingleton.getTime() + triggerTriggerLatency); - if (_DEBUG) { - System.out.println(this.getClass().getSimpleName() + ": Trigger added on event " + event.getEventNumber()); - } - - if (outputStream != null) { - outputStream.printf("trigger sent to ET event builder on event %d\n", event.getEventNumber()); - } - makeTriggerData(event, "TriggerStatus"); - if (lcioWriter != null) { - try { - lcioWriter.write(event); - } catch (IOException ex) { - Logger.getLogger(HPSTriggerDriver.class.getName()).log(Level.SEVERE, null, ex); - } - } - } - - // Check if there are any pending SVT triggers to process - if (svtTriggerTimeStamp.peek() != null - && ClockSingleton.getTime() >= svtTriggerTimeStamp.peek()) { - - if (outputStream != null) { - outputStream.printf("SVT trigger sent on event %d\n", event.getEventNumber()); - } - - // Send a trigger signal to the SVT - HPSAPV25.readoutBit = true; - Apv25Full.readoutBit = true; - svtTriggerTimeStamp.remove(); - } - - // Check if there are any pending ECal triggers to process - if (ecalTriggerTimestamps.peek() != null - && ClockSingleton.getTime() >= ecalTriggerTimestamps.peek()) { - - if (outputStream != null) { - outputStream.printf("ECal trigger sent on event %d\n", event.getEventNumber()); - } - - // Send a trigger signal to the ECal - HPSEcalReadoutDriver.readoutBit = true; - ecalTriggerTimestamps.remove(); - } - - - // Check if there are any pending trigger bank triggers to process - if (triggerTriggerTimestamps.peek() != null - && ClockSingleton.getTime() >= triggerTriggerTimestamps.peek()) { - - if (outputStream != null) { - outputStream.printf("Trigger bank trigger sent on event %d\n", event.getEventNumber()); - } - - // Make trigger bank - makeTriggerData(event, "TriggerBank"); - triggerTriggerTimestamps.remove(); - } - } - - protected boolean triggerDecision(EventHeader event) { - // Get the list of raw ECal hits. - if (event.hasCollection(HPSEcalCluster.class, clusterCollectionName)) { - return testTrigger(event.get(HPSEcalCluster.class, clusterCollectionName)); - } else { - return false; - } - } - - public abstract boolean testTrigger(List<HPSEcalCluster> clusters); - - protected void makeTriggerData(EventHeader event, String collectionName) { - } - - @Override - public void endOfData() { - if (outputStream != null) { - outputStream.printf("Trigger count: %d\n", numTriggers); - outputStream.close(); - } - if (lcioWriter != null) { - try { - lcioWriter.close(); - } catch (IOException ex) { - Logger.getLogger(HPSTriggerDriver.class.getName()).log(Level.SEVERE, null, ex); - } - } - System.out.printf(this.getClass().getSimpleName() + ": Trigger count: %d\n", numTriggers); - } - - public static boolean triggerBit() { - return triggerBit; - } -}
\ No newline at end of file
diff -N HPSEcalRawConverterDriver.java --- HPSEcalRawConverterDriver.java 20 Nov 2012 23:25:09 -0000 1.16 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,158 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.ArrayList; -import java.util.List; -import org.lcsim.event.CalorimeterHit; -import org.lcsim.event.EventHeader; -import org.lcsim.event.RawCalorimeterHit; -import org.lcsim.event.RawTrackerHit; -import org.lcsim.geometry.Detector; -import org.lcsim.util.Driver; - -/** - * - * @version $Id: HPSEcalRawConverterDriver.java,v 1.2 2012/05/03 00:17:54 - * phansson Exp $ - */ -public class HPSEcalRawConverterDriver extends Driver { - - HPSEcalRawConverter converter = null; - String rawCollectionName = "EcalReadoutHits"; - String ecalReadoutName = "EcalHits"; - String ecalCollectionName = "EcalCalHits"; - int integralWindow = 35; - boolean debug = false; - double threshold = Double.NEGATIVE_INFINITY; - boolean applyBadCrystalMap = true; - boolean dropBadFADC = false; - private boolean runBackwards = false; - - public HPSEcalRawConverterDriver() { - converter = new HPSEcalRawConverter(); - } - - public void setRunBackwards(boolean runBackwards) { - this.runBackwards = runBackwards; - } - - public void setDropBadFADC(boolean dropBadFADC) { - this.dropBadFADC = dropBadFADC; - } - - public void setThreshold(double threshold) { - this.threshold = threshold; - } - - public void setGain(double gain) { - converter.setGain(gain); - } - - public void setIntegralWindow(int integralWindow) { - this.integralWindow = integralWindow; - } - - public void setEcalCollectionName(String ecalCollectionName) { - this.ecalCollectionName = ecalCollectionName; - } - - public void setRawCollectionName(String rawCollectionName) { - this.rawCollectionName = rawCollectionName; - } - - public void setApplyBadCrystalMap(boolean apply) { - this.applyBadCrystalMap = apply; - } - - public void setDebug(boolean debug) { - this.debug = debug; - } - - @Override - public void startOfData() { - if (ecalCollectionName == null) { - throw new RuntimeException("The parameter ecalCollectionName was not set!"); - } - } - - @Override - public void detectorChanged(Detector detector) { - } - - public static boolean isBadCrystal(CalorimeterHit hit) { - return HPSEcalConditions.badChannelsLoaded() ? HPSEcalConditions.isBadChannel(hit.getCellID()) : false; - } - - public static boolean isBadFADC(CalorimeterHit hit) { - long daqID = HPSEcalConditions.physicalToDaqID(hit.getCellID()); - return (HPSEcalConditions.getCrate(daqID) == 1 && HPSEcalConditions.getSlot(daqID) == 3); - } - - @Override - public void process(EventHeader event) { - if (!runBackwards) { - ArrayList<CalorimeterHit> newHits = new ArrayList<CalorimeterHit>(); - - // Get the list of ECal hits. - if (event.hasCollection(RawTrackerHit.class, rawCollectionName)) { - List<RawTrackerHit> hits = event.get(RawTrackerHit.class, rawCollectionName); - - for (RawTrackerHit hit : hits) { - CalorimeterHit newHit = converter.HitDtoA(hit); - if (applyBadCrystalMap && isBadCrystal(newHit)) { - continue; - } - if (dropBadFADC && isBadFADC(newHit)) { - continue; - } - if (newHit.getRawEnergy() > threshold) { - newHits.add(newHit); - } - } - } - if (event.hasCollection(RawCalorimeterHit.class, rawCollectionName)) { - List<RawCalorimeterHit> hits = event.get(RawCalorimeterHit.class, rawCollectionName); - - for (RawCalorimeterHit hit : hits) { - if (debug) { - System.out.format("old hit energy %d\n", hit.getAmplitude()); - } - CalorimeterHit newHit = converter.HitDtoA(hit, integralWindow); - if (newHit.getRawEnergy() > threshold) { - if (applyBadCrystalMap && isBadCrystal(newHit)) { - continue; - } - if (dropBadFADC && isBadFADC(newHit)) { - continue; - } - if (debug) { - System.out.format("new hit energy %f\n", newHit.getRawEnergy()); - } - newHits.add(newHit); - } - } - } - int flags = 0; - event.put(ecalCollectionName, newHits, CalorimeterHit.class, flags, ecalReadoutName); - } else { - ArrayList<RawCalorimeterHit> newHits = new ArrayList<RawCalorimeterHit>(); - if (event.hasCollection(CalorimeterHit.class, ecalCollectionName)) { - List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName); - - for (CalorimeterHit hit : hits) { - if (debug) { - System.out.format("old hit energy %f\n", hit.getRawEnergy()); - } - RawCalorimeterHit newHit = converter.HitAtoD(hit, integralWindow); - if (newHit.getAmplitude() > 0) { - if (debug) { - System.out.format("new hit energy %d\n", newHit.getAmplitude()); - } - newHits.add(newHit); - } - } - } - int flags = 0; - event.put(rawCollectionName, newHits, RawCalorimeterHit.class, flags, ecalReadoutName); - } - } -}
diff -N HPSDummyTriggerDriver.java --- HPSDummyTriggerDriver.java 8 Dec 2012 01:12:17 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,30 +0,0 @@
-package org.lcsim.hps.recon.ecal; - -import java.util.List; -import org.lcsim.event.EventHeader; -import org.lcsim.hps.util.ClockSingleton; - -/** - * Free-running trigger - triggers on every Nth event - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSDummyTriggerDriver.java,v 1.3 2012/12/08 01:12:17 meeg Exp $ - */ -public class HPSDummyTriggerDriver extends HPSTriggerDriver { - - int period = 100; - - public void setPeriod(int period) { - this.period = period; - } - - @Override - public boolean triggerDecision(EventHeader event) { - return (ClockSingleton.getClock() % period == 0); - } - - @Override - public boolean testTrigger(List<HPSEcalCluster> clusters) { - return false; - } -}
diff -N HPS1BitTriggerDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPS1BitTriggerDriver.java 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,32 @@
+package org.lcsim.hps.readout.ecal; + +import java.util.List; +import org.lcsim.hps.recon.ecal.HPSECalUtils; +import org.lcsim.hps.recon.ecal.HPSEcalCluster; + +/** + * Reads clusters and makes trigger decision using opposite quadrant criterion. + * Prints triggers to file if file path specified. + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: HPS1BitTriggerDriver.java,v 1.1 2013/02/25 22:39:25 meeg Exp $ + */ +public class HPS1BitTriggerDriver extends HPSTriggerDriver { + + public HPS1BitTriggerDriver() { + } + + @Override + public boolean testTrigger(List<HPSEcalCluster> clusters) { + + boolean quadrants[] = new boolean[4]; + + for (HPSEcalCluster clus : clusters) { +// int ix = clus.getSeedHit().getIdentifierFieldValue("ix"); +// int iy = clus.getSeedHit().getIdentifierFieldValue("iy"); + //System.out.printf("ix = %d, iy = %d\n", ix, iy); + quadrants[HPSECalUtils.getQuadrant(clus)] = true; + } + return (quadrants[0] && quadrants[2]) || (quadrants[1] && quadrants[3]); + } +}
diff -N HPSEcalWindowDiscriminatorReadoutDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSEcalWindowDiscriminatorReadoutDriver.java 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,94 @@
+package org.lcsim.hps.readout.ecal; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.lcsim.event.CalorimeterHit; +import org.lcsim.hps.recon.ecal.HPSECalUtils; +import org.lcsim.hps.recon.ecal.HPSRawCalorimeterHit; +import org.lcsim.hps.util.ClockSingleton; +import org.lcsim.hps.util.RingBuffer; + +/** + * Performs readout of ECal hits. + * Simulates time evolution of preamp output pulse and leading-edge discriminator. + * Uses lower and upper thresholds, with upper discriminator acting as a veto. + * + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: HPSEcalWindowDiscriminatorReadoutDriver.java,v 1.1 2013/02/25 22:39:25 meeg Exp $ + */ +public class HPSEcalWindowDiscriminatorReadoutDriver extends HPSEcalDiscriminatorReadoutDriver { + //last time we saw a rising edge + + Map<Long, Double> lowTimeMap = null; + //last time we saw a rising edge + Map<Long, Double> highTimeMap = null; + double highThreshold = 10.0 * HPSECalUtils.GeV; + + public HPSEcalWindowDiscriminatorReadoutDriver() { + } + + public void setHighThreshold(double highThreshold) { + this.highThreshold = highThreshold; + } + + @Override + protected void readHits(List<HPSRawCalorimeterHit> hits) { + for (Long cellID : lowTimeMap.keySet()) { + //if there's an output pulse, make a hit + if (ClockSingleton.getTime() - lowTimeMap.get(cellID) < outputWidth) { + if (highTimeMap.containsKey(cellID) && ClockSingleton.getTime() - highTimeMap.get(cellID) < outputWidth) { + continue; + } + hits.add(new HPSRawCalorimeterHit(outputEnergy, readoutTime(), cellID, hitType)); + } + } + } + + @Override + protected void putHits(List<CalorimeterHit> hits) { + //fill the readout buffers + for (CalorimeterHit hit : hits) { +// int ix = dec.getValue("ix"); +// int iy = dec.getValue("iy"); +// //temporary hack to disable crystals and flip X coordinate +// int side = dec.getValue("side"); +// if (iy == 1 && ix * side >= -10 && ix * side <= -2) +// continue; + + RingBuffer eDepBuffer = eDepMap.get(hit.getCellID()); + if (eDepBuffer == null) { + eDepBuffer = new RingBuffer(bufferLength); + eDepMap.put(hit.getCellID(), eDepBuffer); + } + for (int i = 0; i < bufferLength; i++) { + eDepBuffer.addToCell(i, hit.getRawEnergy() * pulseAmplitude(i * ClockSingleton.getDt() - hit.getTime())); + } + } + + //check for rising edges + for (Long cellID : eDepMap.keySet()) { + RingBuffer eDepBuffer = eDepMap.get(cellID); + //if there's a rising edge between now and the next time step, note the time + if ((eDepBuffer.currentValue() < threshold) + && (eDepBuffer.getValue(1) > threshold)) { + lowTimeMap.put(cellID, ClockSingleton.getTime()); + } + if ((eDepBuffer.currentValue() < highThreshold) + && (eDepBuffer.getValue(1) > highThreshold)) { + highTimeMap.put(cellID, ClockSingleton.getTime()); + } + eDepBuffer.step(); + } + } + + @Override + protected void initReadout() { + //initialize buffers + eDepMap = new HashMap<Long, RingBuffer>(); + lowTimeMap = new HashMap<Long, Double>(); + highTimeMap = new HashMap<Long, Double>(); + } +}
diff -N HPSEcalDiscriminatorReadoutDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSEcalDiscriminatorReadoutDriver.java 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,121 @@
+package org.lcsim.hps.readout.ecal; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.lcsim.event.CalorimeterHit; +import org.lcsim.hps.recon.ecal.HPSECalUtils; +import org.lcsim.hps.recon.ecal.HPSRawCalorimeterHit; +import org.lcsim.hps.util.ClockSingleton; +import org.lcsim.hps.util.RingBuffer; + +/** + * Performs readout of ECal hits. + * Simulates time evolution of preamp output pulse and leading-edge discriminator. + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: HPSEcalDiscriminatorReadoutDriver.java,v 1.1 2013/02/25 22:39:25 meeg Exp $ + */ +public class HPSEcalDiscriminatorReadoutDriver extends HPSEcalReadoutDriver<HPSRawCalorimeterHit> { + + //buffer for deposited energy + Map<Long, RingBuffer> eDepMap = null; + //last time we saw a rising edge + Map<Long, Double> edgeTimeMap = null; + //length of ring buffer (in multiples of bunch spacing) + int bufferLength = 200; + //shaper time constant in ns + double t0 = 18.0; + //discriminator output pulse width in ns + double outputWidth = 32.0; + //output hit "energy" in GeV + double outputEnergy = 10.0*HPSECalUtils.GeV; + + public HPSEcalDiscriminatorReadoutDriver() { + hitClass = HPSRawCalorimeterHit.class; + } + + public void setBufferLength(int bufferLength) { + this.bufferLength = bufferLength; + eDepMap = new HashMap<Long, RingBuffer>(); + } + + public void setOutputWidth(double outputWidth) { + this.outputWidth = outputWidth; + } + + /* + * Set shaper time constant. + * Positive values interpreted as shaping time of CR-RC pulse; + * negative values interpreted as width of rectangular pulse. + */ + public void setT0(double t0) { + this.t0 = t0; + } + + @Override + protected void readHits(List<HPSRawCalorimeterHit> hits) { + for (Long cellID : edgeTimeMap.keySet()) { + //if there's an output pulse, make a hit + if (ClockSingleton.getTime() - edgeTimeMap.get(cellID) < outputWidth) { + hits.add(new HPSRawCalorimeterHit(outputEnergy, readoutTime(), cellID, hitType)); + } + } + } + + @Override + protected void putHits(List<CalorimeterHit> hits) { + //fill the readout buffers + for (CalorimeterHit hit : hits) { +// int ix = dec.getValue("ix"); +// int iy = dec.getValue("iy"); +// //temporary hack to disable crystals and flip X coordinate +// int side = dec.getValue("side"); +// if (iy == 1 && ix * side >= -10 && ix * side <= -2) +// continue; + + RingBuffer eDepBuffer = eDepMap.get(hit.getCellID()); + if (eDepBuffer == null) { + eDepBuffer = new RingBuffer(bufferLength); + eDepMap.put(hit.getCellID(), eDepBuffer); + } + for (int i = 0; i < bufferLength; i++) { + eDepBuffer.addToCell(i, hit.getRawEnergy() * pulseAmplitude(i * ClockSingleton.getDt() - hit.getTime())); + } + } + + //check for rising edges + for (Long cellID : eDepMap.keySet()) { + RingBuffer eDepBuffer = eDepMap.get(cellID); + //if there's a rising edge between now and the next time step, note the time + if ((eDepBuffer.currentValue() < threshold) + && (eDepBuffer.getValue(1) > threshold)) + edgeTimeMap.put(cellID, ClockSingleton.getTime()); + eDepBuffer.step(); + } + } + + @Override + protected void initReadout() { + //initialize buffers + eDepMap = new HashMap<Long, RingBuffer>(); + edgeTimeMap = new HashMap<Long, Double>(); + } + + /* + * Pulse shape as a function of time; normalized to have a peak height of 1. + */ + protected double pulseAmplitude(double time) { + if (time < 0.0) + return 0.0; + if (t0 > 0.0) { + return (time / t0) * Math.exp(1.0 - time / t0); + } else { + if (time < -t0) + return 1.0; + else + return 0.0; + } + } +}
diff -N HPSEcal1BitClusterer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSEcal1BitClusterer.java 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,380 @@
+package org.lcsim.hps.recon.ecal; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.lcsim.event.CalorimeterHit; +import org.lcsim.event.Cluster; +import org.lcsim.event.EventHeader; +import org.lcsim.geometry.Detector; +import org.lcsim.geometry.IDDecoder; +import org.lcsim.geometry.subdetector.HPSEcal3.NeighborMap; +import org.lcsim.geometry.subdetector.HPSEcal3; +import org.lcsim.util.Driver; +import org.lcsim.util.lcio.LCIOConstants; + +/** + * Creates clusters from CalorimeterHits in the HPSEcal detector. + * + * The clustering algorithm is from JLab Hall B 6 GeV DVCS Trigger Design doc. + * + * @author Jeremy McCormick <[log in to unmask]> + * @author Tim Nelson <[log in to unmask]> + * @author Sho Uemura <[log in to unmask]> + * @version $Id: HPSEcal1BitClusterer.java,v 1.1 2013/02/25 22:39:25 meeg Exp $ + */ +public class HPSEcal1BitClusterer extends Driver { + + HPSEcal3 ecal; + IDDecoder dec; + String ecalName; + String ecalCollectionName; + String vetoCollectionName; + String clusterCollectionName = "EcalClusters"; + //set bounds for a range of crystals to turn off in the clusterer + int xMin = 0; + int xMax = 0; + Map<Long, Integer> hitCounts = null; + Map<Long, CalorimeterHit> hitMap = null; + // Threshold hit count for cluster. Cluster must have more than this many hits. + int clusterThreshold = 5; + // Map of crystals to their neighbors. + NeighborMap neighborMap = null; + + public HPSEcal1BitClusterer() { + } + + public void setClusterCollectionName(String clusterCollectionName) { + this.clusterCollectionName = clusterCollectionName; + } + + public void setEcalCollectionName(String ecalCollectionName) { + this.ecalCollectionName = ecalCollectionName; + } + + public void setVetoCollectionName(String vetoCollectionName) { + this.vetoCollectionName = vetoCollectionName; + } + + public void setxMax(int xMax) { + this.xMax = xMax; + } + + public void setxMin(int xMin) { + this.xMin = xMin; + } + + public void setClusterThreshold(int clusterThreshold) { + this.clusterThreshold = clusterThreshold; + } + + public void setEcalName(String ecalName) { + this.ecalName = ecalName; + } + + @Override + public void startOfData() { + if (ecalCollectionName == null) { + throw new RuntimeException("The parameter ecalCollectionName was not set!"); + } + + if (ecalName == null) { + throw new RuntimeException("The parameter ecalName was not set!"); + } + } + + @Override + public void detectorChanged(Detector detector) { + // Get the Subdetector. + ecal = (HPSEcal3) detector.getSubdetector(ecalName); + + // Get the decoder for the ECal IDs. + dec = ecal.getIDDecoder(); + + // Cache ref to neighbor map. + neighborMap = ecal.getNeighborMap(); + + //System.out.println(ecal.getName()); + //System.out.println(" nx="+ecal.nx()); + //System.out.println(" ny="+ecal.ny()); + //System.out.println(" beamgap="+ecal.beamGap()); + //System.out.println(" dface="+ecal.distanceToFace()); + + //System.out.println(neighborMap.toString()); + } + + @Override + public void process(EventHeader event) { + //System.out.println(this.getClass().getCanonicalName() + " - process"); + + // Get the list of raw ECal hits. + List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName); + if (hits == null) { + throw new RuntimeException("Event is missing ECal raw hits collection!"); + } + List<CalorimeterHit> vetoHits = null; + + // Get the list of raw ECal hits. + if (vetoCollectionName != null) { + vetoHits = event.get(CalorimeterHit.class, vetoCollectionName); + if (vetoHits == null) { + throw new RuntimeException("Event is missing ECal veto hits collection!"); + } + } + + countHits(hits, vetoHits); + + // Put Cluster collection into event. + int flag = 1 << LCIOConstants.CLBIT_HITS; + event.put(clusterCollectionName, createClusters(), Cluster.class, flag); + } + + public void countHits(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) { + // Hit map. + hitMap = new HashMap<Long, CalorimeterHit>(); + HashMap<Long, CalorimeterHit> vetoMap = new HashMap<Long, CalorimeterHit>(); + + if (vetoHits != null) { + for (CalorimeterHit hit : vetoHits) { + vetoMap.put(hit.getCellID(), hit); + } + } + + hitCounts = new HashMap<Long, Integer>(); + // Loop over ECal hits to count hit towers + for (CalorimeterHit hit : hits) { + if (vetoMap.get(hit.getCellID()) != null) { + continue; + } + + int ix = hit.getIdentifierFieldValue("ix"); + if (ix >= xMin && ix <= xMax) { + continue; + } + + // Make a hit map for quick lookup by ID. + hitMap.put(hit.getCellID(), hit); + + // Get neighbor crystal IDs. + Set<Long> neighbors = neighborMap.get(hit.getCellID()); + + if (neighbors == null) { + throw new RuntimeException("Oops! Set of neighbors is null!"); + } + + Integer hitCount = hitCounts.get(hit.getCellID()); + if (hitCount == null) { + hitCounts.put(hit.getCellID(), 1); + } else { + hitCounts.put(hit.getCellID(), hitCount + 1); + } + + // Loop over neighbors to make hit list for cluster. + for (Long neighborId : neighbors) { + hitCount = hitCounts.get(neighborId); + if (hitCount == null) { + hitCounts.put(neighborId, 1); + } else { + hitCounts.put(neighborId, hitCount + 1); + } + } + } + } + + public List<Cluster> createClusters() { + // New Cluster list to be added to event. + List<Cluster> clusters = new ArrayList<Cluster>(); + + //for each crystal with a nonzero hit count, test for cluster + for (Long possibleCluster : hitCounts.keySet()) { + //System.out.printf("%d, %d hits\n",possibleCluster,hitCounts.get(possibleCluster)); + if (hitCounts.get(possibleCluster) <= clusterThreshold) { + continue; + } + + // Get neighbor crystal IDs. + Set<Long> neighbors = neighborMap.get(possibleCluster); + + if (neighbors == null) { + throw new RuntimeException("Oops! Set of neighbors is null!"); + } + + //Apply peak detector scheme. + // Set the ID. + dec.setID(possibleCluster); + // Get ID field values. + int x1 = dec.getValue("ix"); + int y1 = dec.getValue("iy"); + Integer hitCount = hitCounts.get(possibleCluster); + + //System.out.printf("Possible cluster: x: %d, y: %d, hits: %d\n",x1,y1,hitCount); + boolean isCluster = true; + for (Long neighborId : neighbors) { + // Set the ID. + dec.setID(neighborId); + Integer neighborHitCount = hitCounts.get(neighborId); + if (neighborHitCount == null) { + continue; + } + // Get ID field values. + int x2 = dec.getValue("ix"); + int y2 = dec.getValue("iy"); + if (y1 > 0) { + if (x1 > 0) { + //quadrant 1 + if (x1 == 1) { + //special case: left edge of quadrant + if (x1 > x2 && y1 < y2) { + if (hitCount > neighborHitCount) { + continue; + } + } else if (x1 > x2) { + if (hitCount >= neighborHitCount) { + continue; + } + } else if (x1 < x2) { + if (hitCount > neighborHitCount) { + continue; + } + } else if (y1 < y2) { + if (hitCount >= neighborHitCount) { + continue; + } + } else { + if (hitCount > neighborHitCount) { + continue; + } + } + } else { + if (x1 > x2) { + if (hitCount >= neighborHitCount) { + continue; + } + } else if (x1 < x2) { + if (hitCount > neighborHitCount) { + continue; + } + } else if (y1 < y2) { + if (hitCount >= neighborHitCount) { + continue; + } + } else { + if (hitCount > neighborHitCount) { + continue; + } + } + } + } else { + //quadrant 2 + if (y1 > y2) { + if (hitCount >= neighborHitCount) { + continue; + } + } else if (y1 < y2) { + if (hitCount > neighborHitCount) { + continue; + } + } else if (x1 > x2) { + if (hitCount >= neighborHitCount) { + continue; + } + } else { + if (hitCount > neighborHitCount) { + continue; + } + } + } + } else { + if (x1 < 0) { + //quadrant 3 + if (x1 == 1) { + //special case: left edge of quadrant + if (x1 < x2 && y1 > y2) { + if (hitCount > neighborHitCount) { + continue; + } + } else if (x1 < x2) { + if (hitCount >= neighborHitCount) { + continue; + } + } else if (x1 > x2) { + if (hitCount > neighborHitCount) { + continue; + } + } else if (y1 > y2) { + if (hitCount >= neighborHitCount) { + continue; + } + } else { + if (hitCount > neighborHitCount) { + continue; + } + } + } else { + if (x1 < x2) { + if (hitCount >= neighborHitCount) { + continue; + } + } else if (x1 > x2) { + if (hitCount > neighborHitCount) { + continue; + } + } else if (y1 > y2) { + if (hitCount >= neighborHitCount) { + continue; + } + } else { + if (hitCount > neighborHitCount) { + continue; + } + } + } + } else { + //quadrant 4 + if (y1 < y2) { + if (hitCount >= neighborHitCount) { + continue; + } + } else if (y1 > y2) { + if (hitCount > neighborHitCount) { + continue; + } + } else if (x1 < x2) { + if (hitCount >= neighborHitCount) { + continue; + } + } else { + if (hitCount > neighborHitCount) { + continue; + } + } + } + } + isCluster = false; + break; + } + + if (isCluster) { + //System.out.printf("Cluster: x: %d, y: %d, side:%d, hits: %d\n",x1,y1,side1,hitCount); + HPSEcalCluster cluster = new HPSEcalCluster(possibleCluster); + CalorimeterHit hit = hitMap.get(possibleCluster); + if (hit != null /*&& hit.getRawEnergy() > hitEMin && hit.getRawEnergy() < hitEMax*/) { + cluster.addHit(hit); + } + + for (Long neighborId : neighbors) { + // Find the neighbor hit in the event if it exists. + hit = hitMap.get(neighborId); + if (hit != null /*&& hit.getRawEnergy() > hitEMin && hit.getRawEnergy() < hitEMax*/) { + cluster.addHit(hit); + } + } + clusters.add(cluster); + } + } + return clusters; + } +}
diff -N HPSEcal1BitClusterVetoClusterer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSEcal1BitClusterVetoClusterer.java 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,81 @@
+package org.lcsim.hps.recon.ecal; + +import java.util.HashMap; +import java.util.List; +import java.util.Set; + +import org.lcsim.event.CalorimeterHit; + +/** + * Creates clusters from CalorimeterHits in the HPSEcal detector. + * + * A veto hit vetoes clusters in the crystal with the veto hit and all its neighbors. + * + * The clustering algorithm is from JLab Hall B 6 GeV DVCS Trigger Design doc. + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: HPSEcal1BitClusterVetoClusterer.java,v 1.1 2013/02/25 22:39:25 meeg Exp $ + */ +public class HPSEcal1BitClusterVetoClusterer extends HPSEcal1BitClusterer { + + public HPSEcal1BitClusterVetoClusterer() { + } + + @Override + public void countHits(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) { + // Hit map. + hitMap = new HashMap<Long, CalorimeterHit>(); + + hitCounts = new HashMap<Long, Integer>(); + // Loop over ECal hits to count hit towers + for (CalorimeterHit hit : hits) { + int ix = hit.getIdentifierFieldValue("ix"); + if (ix >= xMin && ix <= xMax) { + continue; + } + + // Make a hit map for quick lookup by ID. + hitMap.put(hit.getCellID(), hit); + + // Get neighbor crystal IDs. + Set<Long> neighbors = neighborMap.get(hit.getCellID()); + + if (neighbors == null) { + throw new RuntimeException("Oops! Set of neighbors is null!"); + } + + Integer hitCount = hitCounts.get(hit.getCellID()); + if (hitCount == null) { + hitCounts.put(hit.getCellID(), 1); + } else { + hitCounts.put(hit.getCellID(), hitCount + 1); + } + + // Loop over neighbors to make hit list for cluster. + for (Long neighborId : neighbors) { + hitCount = hitCounts.get(neighborId); + if (hitCount == null) { + hitCounts.put(neighborId, 1); + } else { + hitCounts.put(neighborId, hitCount + 1); + } + } + } + if (vetoHits != null) { + for (CalorimeterHit hit : vetoHits) { + //Get neighbor crystal IDs. + Set<Long> neighbors = neighborMap.get(hit.getCellID()); + + if (neighbors == null) { + throw new RuntimeException("Oops! Set of neighbors is null!"); + } + + // Veto the hit towers for the vetoed crystal and all neighbors. + hitCounts.remove(hit.getCellID()); + for (Long neighborId : neighbors) { + hitCounts.remove(neighborId); + } + } + } + } +}
diff -N HPSEcal1BitEventVetoClusterer.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSEcal1BitEventVetoClusterer.java 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,69 @@
+package org.lcsim.hps.recon.ecal; + +import java.util.HashMap; +import java.util.List; +import java.util.Set; + +import org.lcsim.event.CalorimeterHit; + +/** + * Creates clusters from CalorimeterHits in the HPSEcal detector. + * + * A veto hit vetoes all clusters in the event. + * + * The clustering algorithm is from JLab Hall B 6 GeV DVCS Trigger Design doc. + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: HPSEcal1BitEventVetoClusterer.java,v 1.1 2013/02/25 22:39:25 meeg Exp $ + */ +public class HPSEcal1BitEventVetoClusterer extends HPSEcal1BitClusterer { + + public HPSEcal1BitEventVetoClusterer() { + } + + @Override + public void countHits(List<CalorimeterHit> hits, List<CalorimeterHit> vetoHits) { + // Hit map. + hitMap = new HashMap<Long, CalorimeterHit>(); + + hitCounts = new HashMap<Long, Integer>(); + if (vetoHits != null && !vetoHits.isEmpty()) { + return; + } + + // Loop over ECal hits to count hit towers + for (CalorimeterHit hit : hits) { + int ix = hit.getIdentifierFieldValue("ix"); + if (ix >= xMin && ix <= xMax) { + continue; + } + + // Make a hit map for quick lookup by ID. + hitMap.put(hit.getCellID(), hit); + + // Get neighbor crystal IDs. + Set<Long> neighbors = neighborMap.get(hit.getCellID()); + + if (neighbors == null) { + throw new RuntimeException("Oops! Set of neighbors is null!"); + } + + Integer hitCount = hitCounts.get(hit.getCellID()); + if (hitCount == null) { + hitCounts.put(hit.getCellID(), 1); + } else { + hitCounts.put(hit.getCellID(), hitCount + 1); + } + + // Loop over neighbors to make hit list for cluster. + for (Long neighborId : neighbors) { + hitCount = hitCounts.get(neighborId); + if (hitCount == null) { + hitCounts.put(neighborId, 1); + } else { + hitCounts.put(neighborId, hitCount + 1); + } + } + } + } +}
diff -N HPSFADCSingleTriggerDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSFADCSingleTriggerDriver.java 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,128 @@
+package org.lcsim.hps.recon.ecal; + +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + +import org.lcsim.event.EventHeader; +import org.lcsim.hps.evio.TriggerData; +import org.lcsim.hps.util.ClockSingleton; + +/** + * Reads clusters and makes trigger decision using opposite quadrant criterion. + * Prints triggers to file if file path specified. + * TODO: Redundant with TestRunTriggerDriver. + * + * @author Omar Moreno <[log in to unmask]> + * @author Sho Uemura <[log in to unmask]> + * @author Per Hansson Adrian <[log in to unmask]> + * @version $Id: HPSFADCSingleTriggerDriver.java,v 1.1 2013/02/25 22:39:25 meeg Exp $ + */ +public class HPSFADCSingleTriggerDriver extends HPSTriggerDriver { + // A list to contain all cluster pairs in an event + List<HPSEcalCluster[]> clusterPairs; + int nTriggers; + int totalEvents; + private double clusterEnergyHigh = 1.85 * HPSECalUtils.GeV; // GeV + private double clusterEnergyLow = .1 * HPSECalUtils.GeV; // GeV + int allClusters; + int clusterEnergyCount; + int deadtimelessTriggerCount; + + public HPSFADCSingleTriggerDriver() { + clusterPairs = new LinkedList<HPSEcalCluster[]>(); + } + + @Override + public void startOfData() { + super.startOfData(); + + allClusters = 0; + clusterEnergyCount = 0; + deadtimelessTriggerCount = 0; + } + + @Override + public boolean testTrigger(List<HPSEcalCluster> clusters) { + boolean trigger = false; + + //--- Apply Trigger Cuts ---// + + // Iterate through all clusters present in the event. + //If at least one of the clusters satisfies all of the trigger conditions, + // a trigger signal is sent to all other detectors. + for (HPSEcalCluster cluster : clusters) { + + + if (outputStream != null) { + outputStream.printf("Event %d: cluster energy %f in quadrant %d (%s)\n", + ClockSingleton.getClock(), + cluster.getEnergy(), HPSECalUtils.getQuadrant(cluster),cluster.getSeedHit().getPositionVec().toString()); + + } + + allClusters++; + + + // Require the componets of a cluster pair to have an energy in + // the range of 100 MeV to 1.85 GeV + if (!clusterECut(cluster)) { + if (outputStream != null) { + outputStream.println("Failed cluster energy cut"); + } + continue; + } + clusterEnergyCount++; + + // If all cuts are pased, we have a trigger + if (outputStream != null) { + outputStream.println("Passed all cuts"); + } + trigger = true; + } + if (trigger) { + deadtimelessTriggerCount++; + } + return trigger; + } + + @Override + public void endOfData() { + if (outputStream != null) { + outputStream.printf("%s: Number of clusters: %d\n",this.getClass().getSimpleName(),allClusters); + outputStream.printf("%s: Number of cluster pairs after successive trigger conditions:\n",this.getClass().getSimpleName()); + outputStream.printf("%s: Cluster energy: %d\n",this.getClass().getSimpleName(), clusterEnergyCount); + outputStream.printf("%s: Trigger count without dead time: %d\n",this.getClass().getSimpleName(), deadtimelessTriggerCount); + outputStream.printf("%s: Trigger count: %d\n",this.getClass().getSimpleName(), numTriggers); + outputStream.close(); + } + System.out.printf("%s: Number of pairs: %d\n",this.getClass().getSimpleName(),allClusters); + System.out.printf("%s: Number of cluster pairs after successive trigger conditions:\n",this.getClass().getSimpleName()); + System.out.printf("%s: Cluster energy: %d\n",this.getClass().getSimpleName(), clusterEnergyCount); + System.out.printf("%s: Trigger count without dead time: %d\n",this.getClass().getSimpleName(), deadtimelessTriggerCount); + System.out.printf("%s: Trigger count: %d\n",this.getClass().getSimpleName(), numTriggers); + super.endOfData(); + } + + /** + * Checks if the ECal clusters making up a cluster pair lie above the low + * energy threshold and below the high energy threshold + * + * @param clusterPair : pair of clusters + * @return true if a pair is found, false otherwise + */ + private boolean clusterECut(HPSEcalCluster cluster) { + return (cluster.getEnergy() < clusterEnergyHigh && cluster.getEnergy() > clusterEnergyLow); + } + + /** + * Make a dummy TriggerData + */ + @Override + protected void makeTriggerData(EventHeader event, String collectionName) { + TriggerData tData = new TriggerData(new int[8]); + List<TriggerData> triggerList = new ArrayList<TriggerData>(); + triggerList.add(tData); + event.put(collectionName, triggerList, TriggerData.class, 0); + } +}
\ No newline at end of file
diff -u -r1.3 -r1.4 --- ECalHitWriter.java 16 Aug 2012 01:06:30 -0000 1.3 +++ ECalHitWriter.java 25 Feb 2013 22:39:25 -0000 1.4 @@ -14,7 +14,7 @@
import org.lcsim.event.EventHeader; import org.lcsim.event.RawCalorimeterHit; import org.lcsim.geometry.IDDecoder;
-import org.lcsim.hps.recon.ecal.HPSEcalConditions;
+import org.lcsim.hps.recon.ecal.EcalConditions;
import static org.lcsim.hps.evio.EventConstants.ECAL_BANK_NUMBER; import static org.lcsim.hps.evio.EventConstants.ECAL_BOTTOM_BANK_TAG;
@@ -25,7 +25,7 @@
/** * * @author Sho Uemura <[log in to unmask]>
- * @version $Id: ECalHitWriter.java,v 1.3 2012/08/16 01:06:30 meeg Exp $
+ * @version $Id: ECalHitWriter.java,v 1.4 2013/02/25 22:39:25 meeg Exp $
*/ public class ECalHitWriter implements HitWriter {
@@ -88,8 +88,8 @@
List<Object> topHits = new ArrayList<Object>(); List<Object> bottomHits = new ArrayList<Object>(); for (Object hit : rawCalorimeterHits) {
- Long daqID = HPSEcalConditions.physicalToDaqID(getCellID(hit)); - int crate = HPSEcalConditions.getCrate(daqID);
+ Long daqID = EcalConditions.physicalToDaqID(getCellID(hit)); + int crate = EcalConditions.getCrate(daqID);
if (crate == ECAL_BOTTOM_BANK_TAG) { bottomHits.add(hit); } else {
@@ -165,7 +165,7 @@
} // Get the ID decoder.
- IDDecoder dec = HPSEcalConditions.getSubdetector().getIDDecoder();
+ IDDecoder dec = EcalConditions.getSubdetector().getIDDecoder();
// Make a hit map; allow for multiple hits in a crystal. Map<Long, List<RawCalorimeterHit>> hitMap = new HashMap<Long, List<RawCalorimeterHit>>();
@@ -184,9 +184,9 @@
dec.setID(id); // System.out.println(dec.getIDDescription()); // System.out.printf("ix = %d, iy = %d\n", dec.getValue("ix"), dec.getValue("iy"));
- Long daqID = HPSEcalConditions.physicalToDaqID(id);
+ Long daqID = EcalConditions.physicalToDaqID(id);
// System.out.printf("physicalID %d, daqID %d\n", id, daqID);
- int slot = HPSEcalConditions.getSlot(daqID);
+ int slot = EcalConditions.getSlot(daqID);
if (slotMap.get(slot) == null) { slotMap.put(slot, new ArrayList<Long>()); }
@@ -210,7 +210,7 @@
data.addN(nhits); // number of channels for (Long id : hitIDs) { dec.setID(id);
- int channel = HPSEcalConditions.getChannel(HPSEcalConditions.physicalToDaqID(id));
+ int channel = EcalConditions.getChannel(EcalConditions.physicalToDaqID(id));
data.addUchar((byte) channel); // channel # List<RawCalorimeterHit> channelHits = hitMap.get(id); data.addN(channelHits.size()); // number of pulses
@@ -244,7 +244,7 @@
} // Get the ID decoder.
- IDDecoder dec = HPSEcalConditions.getSubdetector().getIDDecoder();
+ IDDecoder dec = EcalConditions.getSubdetector().getIDDecoder();
// Make a hit map; allow for multiple hits in a crystal. Map<Long, List<RawTrackerHit>> hitMap = new HashMap<Long, List<RawTrackerHit>>();
@@ -263,9 +263,9 @@
dec.setID(id); // System.out.println(dec.getIDDescription()); // System.out.printf("ix = %d, iy = %d\n", dec.getValue("ix"), dec.getValue("iy"));
- Long daqID = HPSEcalConditions.physicalToDaqID(id);
+ Long daqID = EcalConditions.physicalToDaqID(id);
// System.out.printf("physicalID %d, daqID %d\n", id, daqID);
- int slot = HPSEcalConditions.getSlot(daqID);
+ int slot = EcalConditions.getSlot(daqID);
if (slotMap.get(slot) == null) { slotMap.put(slot, new ArrayList<Long>()); }
@@ -294,7 +294,7 @@
data.addN(nhits); // number of channels for (Long id : hitIDs) { dec.setID(id);
- int channel = HPSEcalConditions.getChannel(HPSEcalConditions.physicalToDaqID(id));
+ int channel = EcalConditions.getChannel(EcalConditions.physicalToDaqID(id));
data.addUchar((byte) channel); // channel # List<RawTrackerHit> channelHits = hitMap.get(id); data.addN(channelHits.size()); // number of pulses
@@ -331,7 +331,7 @@
} // Get the ID decoder.
- IDDecoder dec = HPSEcalConditions.getSubdetector().getIDDecoder();
+ IDDecoder dec = EcalConditions.getSubdetector().getIDDecoder();
// Make a hit map; allow for multiple hits in a crystal. Map<Long, RawTrackerHit> hitMap = new HashMap<Long, RawTrackerHit>();
@@ -346,9 +346,9 @@
dec.setID(id); // System.out.println(dec.getIDDescription()); // System.out.printf("ix = %d, iy = %d\n", dec.getValue("ix"), dec.getValue("iy"));
- Long daqID = HPSEcalConditions.physicalToDaqID(id);
+ Long daqID = EcalConditions.physicalToDaqID(id);
// System.out.printf("physicalID %d, daqID %d\n", id, daqID);
- int slot = HPSEcalConditions.getSlot(daqID);
+ int slot = EcalConditions.getSlot(daqID);
if (slotMap.get(slot) == null) { slotMap.put(slot, new ArrayList<Long>()); }
@@ -377,7 +377,7 @@
data.addN(nhits); // number of channels for (Long id : hitIDs) { dec.setID(id);
- int channel = HPSEcalConditions.getChannel(HPSEcalConditions.physicalToDaqID(id));
+ int channel = EcalConditions.getChannel(EcalConditions.physicalToDaqID(id));
data.addUchar((byte) channel); // channel # RawTrackerHit hit = hitMap.get(id); data.addN(hit.getADCValues().length); // number of samples
@@ -414,7 +414,7 @@
@Override public void writeData(EventHeader event, EventHeader toEvent) {
- String readoutName = HPSEcalConditions.getSubdetector().getReadout().getName();
+ String readoutName = EcalConditions.getSubdetector().getReadout().getName();
switch (mode) { case EventConstants.ECAL_WINDOW_MODE: case EventConstants.ECAL_PULSE_MODE:
diff -u -r1.21 -r1.22 --- TestRunTriggeredReconToEvio.java 21 Sep 2012 23:22:18 -0000 1.21 +++ TestRunTriggeredReconToEvio.java 25 Feb 2013 22:39:25 -0000 1.22 @@ -8,9 +8,9 @@
import java.util.Queue; import org.jlab.coda.jevio.*; import org.lcsim.event.EventHeader;
-import org.lcsim.hps.monitoring.HPSCalibrationDriver; -import org.lcsim.hps.recon.ecal.HPSEcalConditions; -import org.lcsim.hps.recon.ecal.HPSTriggerDriver;
+import org.lcsim.hps.monitoring.CalibrationDriver; +import org.lcsim.hps.recon.ecal.EcalConditions; +import org.lcsim.hps.readout.ecal.TriggerDriver;
import org.lcsim.util.Driver; /**
@@ -28,7 +28,7 @@
Queue<QueuedEtEvent> builderQueue = null; private int eventsWritten = 0; private int eventNum = 0;
- HPSEcalConditions ecalIDConverter = null;
+ EcalConditions ecalIDConverter = null;
ECalHitWriter ecalWriter = null; SVTHitWriter_RTH svtWriter = null; TriggerDataWriter triggerWriter = null;
@@ -99,7 +99,7 @@
@Override protected void process(EventHeader event) {
- if (HPSTriggerDriver.triggerBit()) {
+ if (TriggerDriver.triggerBit()) {
// Make a new EVIO event. EventBuilder builder = new EventBuilder(EventConstants.PHYSICS_EVENT_TAG, DataType.BANK, EventConstants.EVENT_BANK_NUM); builderQueue.add(new QueuedEtEvent(builder, writers.size(), eventNum));
@@ -164,7 +164,7 @@
EventBuilder builder = new EventBuilder(EventConstants.PRESTART_EVENT_TAG, DataType.UINT32, EventConstants.EVENT_BANK_NUM); int[] prestartData = new int[3]; prestartData[0] = EventConstants.MC_TIME; //Unix time in seconds - this value for MC data
- prestartData[1] = HPSCalibrationDriver.runNumber(); //run number
+ prestartData[1] = CalibrationDriver.runNumber(); //run number
prestartData[2] = 0; //run type try {
diff -u -r1.10 -r1.11 --- TestRunTriggeredReconToLcio.java 14 Dec 2012 01:29:31 -0000 1.10 +++ TestRunTriggeredReconToLcio.java 25 Feb 2013 22:39:25 -0000 1.11 @@ -13,8 +13,8 @@
import org.lcsim.event.SimCalorimeterHit; import org.lcsim.event.SimTrackerHit; import org.lcsim.hps.conditions.QuietBaseLCSimEvent;
-import org.lcsim.hps.monitoring.HPSCalibrationDriver; -import org.lcsim.hps.recon.ecal.HPSTriggerDriver;
+import org.lcsim.hps.monitoring.CalibrationDriver; +import org.lcsim.hps.readout.ecal.TriggerDriver;
import org.lcsim.util.Driver; import org.lcsim.util.lcio.LCIOWriter;
@@ -111,8 +111,8 @@
}
- if (HPSTriggerDriver.triggerBit()) { - EventHeader lcsimEvent = new QuietBaseLCSimEvent(HPSCalibrationDriver.runNumber(), event.getEventNumber(), event.getDetectorName());
+ if (TriggerDriver.triggerBit()) { + EventHeader lcsimEvent = new QuietBaseLCSimEvent(CalibrationDriver.runNumber(), event.getEventNumber(), event.getDetectorName());
events.add(lcsimEvent); System.out.println("Creating LCIO event " + eventNum); lcsimEvent.put(MCEvent.MC_PARTICLES, mcParticles);
diff -u -r1.21 -r1.22 --- ECalEvioReader.java 21 Sep 2012 23:22:18 -0000 1.21 +++ ECalEvioReader.java 25 Feb 2013 22:39:25 -0000 1.22 @@ -9,12 +9,12 @@
import org.lcsim.event.SimTrackerHit; import org.lcsim.event.base.BaseRawCalorimeterHit; import org.lcsim.event.base.BaseRawTrackerHit;
-import org.lcsim.hps.recon.ecal.HPSEcalConditions;
+import org.lcsim.hps.recon.ecal.EcalConditions;
/** * * @author Sho Uemura <[log in to unmask]>
- * @version $Id: ECalEvioReader.java,v 1.21 2012/09/21 23:22:18 meeg Exp $
+ * @version $Id: ECalEvioReader.java,v 1.22 2013/02/25 22:39:25 meeg Exp $
*/ public class ECalEvioReader extends EvioReader { // Names of subdetectors.
@@ -81,7 +81,7 @@
} } }
- String readoutName = HPSEcalConditions.getSubdetector().getReadout().getName();
+ String readoutName = EcalConditions.getSubdetector().getReadout().getName();
lcsimEvent.put(hitCollectionName, hits, hitClass, 0, readoutName); // for (Object hit : hits) { // System.out.println(((RawTrackerHit) hit).getIDDecoder().getIDDescription().toString());
@@ -116,7 +116,7 @@
if (debug) { System.out.println(" channel=" + channel + "; nSamples=" + nSamples); }
- Long id = HPSEcalConditions.daqToPhysicalID(crate, slot, channel);
+ Long id = EcalConditions.daqToPhysicalID(crate, slot, channel);
short[] adcValues = new short[nSamples]; for (int i = 0; i < nSamples; i++) {
@@ -125,7 +125,7 @@
if (id == null) { System.out.printf("Crate %d, slot %d, channel %d not found in map\n", crate, slot, channel); } else {
- hits.add(new BaseRawTrackerHit(0, id, adcValues, new ArrayList<SimTrackerHit>(), HPSEcalConditions.getSubdetector().getDetectorElement().findDetectorElement(new Identifier(id)).get(0)));
+ hits.add(new BaseRawTrackerHit(0, id, adcValues, new ArrayList<SimTrackerHit>(), EcalConditions.getSubdetector().getDetectorElement().findDetectorElement(new Identifier(id)).get(0)));
} } }
@@ -158,7 +158,7 @@
if (debug) { System.out.println(" channel=" + channel + "; npulses=" + npulses); }
- Long id = HPSEcalConditions.daqToPhysicalID(crate, slot, channel);
+ Long id = EcalConditions.daqToPhysicalID(crate, slot, channel);
for (int k = 0; k < npulses; k++) { short pulseNum = cdata.getByte(); int sampleCount = cdata.getNValue();
@@ -169,7 +169,7 @@
if (id == null) { System.out.printf("Crate %d, slot %d, channel %d not found in map\n", crate, slot, channel); } else {
- hits.add(new BaseRawTrackerHit(pulseNum, id, adcValues, new ArrayList<SimTrackerHit>(), HPSEcalConditions.getSubdetector().getDetectorElement().findDetectorElement(new Identifier(id)).get(0)));
+ hits.add(new BaseRawTrackerHit(pulseNum, id, adcValues, new ArrayList<SimTrackerHit>(), EcalConditions.getSubdetector().getDetectorElement().findDetectorElement(new Identifier(id)).get(0)));
} } }
@@ -203,7 +203,7 @@
if (debug) { System.out.println(" channel=" + channel + "; npulses=" + npulses); }
- Long id = HPSEcalConditions.daqToPhysicalID(crate, slot, channel);
+ Long id = EcalConditions.daqToPhysicalID(crate, slot, channel);
for (int k = 0; k < npulses; k++) { short pulseTime = cdata.getShort();
diff -u -r1.24 -r1.25 --- TestRunEvioToLcio.java 6 Nov 2012 03:56:55 -0000 1.24 +++ TestRunEvioToLcio.java 25 Feb 2013 22:39:25 -0000 1.25 @@ -17,7 +17,7 @@
import org.lcsim.event.EventHeader; import org.lcsim.geometry.util.DetectorLocator; import org.lcsim.hps.monitoring.RunControlDialog;
-import org.lcsim.hps.recon.ecal.HPSEcalConditions;
+import org.lcsim.hps.recon.ecal.EcalConditions;
import org.lcsim.job.JobControlManager; import org.lcsim.util.lcio.LCIOWriter;
@@ -174,7 +174,7 @@
LCSimEventBuilder eventBuilder = new LCSimTestRunEventBuilder(); eventBuilder.setDetectorName(detectorName);
- HPSEcalConditions.loadDaqMap(DetectorLocator.findDetector(detectorName), "Ecal");
+ EcalConditions.loadDaqMap(DetectorLocator.findDetector(detectorName), "Ecal");
for (String evioFileName : cl.getArgs()) { // EVIO input file.
diff -N TestRunNoPileup.lcsim --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ TestRunNoPileup.lcsim 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,53 @@
+ +<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> + <control> + <printInputFiles>true</printInputFiles> + <printDriversDetailed>true</printDriversDetailed> + </control> + <execute> + <driver name="EventMarkerDriver"/> + <driver name="CalibrationDriver"/> + <driver name="EcalRawConverter"/> + <driver name="EcalRawConverterDriver"/> + <driver name="EcalTriggerFilter"/> + <driver name="EcalTriggerClusterer"/> + <driver name="SimpleSVTReadout"/> + <driver name="EcalTrigger"/> + <driver name="ClockDriver"/> + </execute> + <drivers> + <driver name="CalibrationDriver" type="org.lcsim.hps.monitoring.CalibrationDriver"> + </driver> + <driver name="EcalRawConverter" type="org.lcsim.hps.recon.ecal.EcalEdepToTriggerConverterDriver"> + <readoutCollection>EcalReadoutAnalogHits</readoutCollection> + </driver> + <driver name="EcalRawConverterDriver" type="org.lcsim.hps.recon.ecal.EcalRawConverterDriver"> + <runBackwards>true</runBackwards> + <rawCollectionName>EcalReadoutHits</rawCollectionName> + <ecalCollectionName>EcalReadoutAnalogHits</ecalCollectionName> + </driver> + <driver name="EcalTriggerFilter" type="org.lcsim.hps.recon.ecal.HPSEcalTriggerFilterDriver"> + <inputCollection>EcalTriggerHits</inputCollection> + <outputCollection>EcalFilteredHits</outputCollection> + </driver> + <driver name="EcalTriggerClusterer" type="org.lcsim.hps.recon.ecal.CTPEcalClusterer"> + <ecalName>Ecal</ecalName> + <ecalCollectionName>EcalFilteredHits</ecalCollectionName> + <clusterCollectionName>EcalTriggerClusters</clusterCollectionName> + </driver> + <driver name="EcalTrigger" type="org.lcsim.hps.readout.ecal.TestRunTriggerDriver"> + <clusterCollectionName>EcalTriggerClusters</clusterCollectionName> + <deadTime>0</deadTime> + <lcioFile>${outputFile}</lcioFile> + </driver> + <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> + <eventInterval>1000</eventInterval> + </driver> + + <driver name="SimpleSVTReadout" type="org.lcsim.hps.recon.tracking.SimpleSvtReadout"> + <noPileup>true</noPileup> + </driver> + <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"/> + </drivers> +</lcsim>
diff -N HPS2014ReadoutNoPileup.lcsim --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPS2014ReadoutNoPileup.lcsim 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,56 @@
+<!-- + Execute trigger+readout simulation without pileup (event by event) and write the results as an LCIO file. + @author Sho Uemura <[log in to unmask]> + @version $Id: HPS2014ReadoutNoPileup.lcsim,v 1.1 2013/02/25 22:39:25 meeg Exp $ +--> +<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> + <control> + <printInputFiles>true</printInputFiles> + <printDriversDetailed>true</printDriversDetailed> + </control> + <execute> + <driver name="EventMarkerDriver"/> + <driver name="CalibrationDriver"/> + <driver name="EcalEdepToTriggerConverterDriver"/> + <driver name="EcalReadoutConverterDriver"/> + <driver name="EcalTriggerClusterer"/> + <driver name="SimpleSVTReadout"/> + <driver name="EcalTrigger"/> + <driver name="ClockDriver"/> + </execute> + <drivers> + <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> + <eventInterval>1000</eventInterval> + </driver> + <driver name="CalibrationDriver" type="org.lcsim.hps.monitoring.CalibrationDriver"> + </driver> + <driver name="EcalEdepToTriggerConverterDriver" type="org.lcsim.hps.recon.ecal.EcalEdepToTriggerConverterDriver"> + <readoutCollection>EcalReadoutAnalogHits</readoutCollection> + <applyBadCrystalMap>false</applyBadCrystalMap> + <truncateScale>1</truncateScale> + <constantGain>0.15</constantGain> + </driver> + <driver name="EcalReadoutConverterDriver" type="org.lcsim.hps.recon.ecal.HPSEcalRawConverterDriver"> + <runBackwards>true</runBackwards> + <rawCollectionName>EcalReadoutHits</rawCollectionName> + <ecalCollectionName>EcalReadoutAnalogHits</ecalCollectionName> + </driver> + <driver name="EcalTriggerClusterer" type="org.lcsim.hps.recon.ecal.CTPEcalClusterer"> + <ecalName>Ecal</ecalName> + <ecalCollectionName>EcalReadoutAnalogHits</ecalCollectionName> + <clusterCollectionName>EcalTriggerClusters</clusterCollectionName> + </driver> + <driver name="EcalTrigger" type="org.lcsim.hps.readout.ecal.FADCTriggerDriver"> + <clusterCollectionName>EcalTriggerClusters</clusterCollectionName> + <outputFileName>${outputFile}.triggers</outputFileName> + <deadTime>0</deadTime> + <lcioFile>${outputFile}</lcioFile> + </driver> + + <driver name="SimpleSVTReadout" type="org.lcsim.hps.recon.tracking.SimpleSvtReadout"> + <noPileup>true</noPileup> + </driver> + <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"/> + </drivers> +</lcsim>
diff -N TestRunSim.lcsim --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ TestRunSim.lcsim 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,126 @@
+ +<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> + + <inputFiles> + <file>${inputFile}</file> + </inputFiles> + + <control> + <printInputFiles>true</printInputFiles> + <printDriversDetailed>true</printDriversDetailed> + </control> + + <execute> + <driver name="Calibrations" /> + <driver name="EventMarkerDriver" /> + <!-- Ecal --> + <driver name="EcalReadout" /> + <driver name="EcalConverter" /> + <driver name="EcalTriggerFilter"/> + <driver name="EcalClusterer" /> + <driver name="EcalTrigger" /> + <!-- SVT --> + <driver name="SVTReadout" /> + <driver name="Digitization" /> + <driver name="DataProcessing" /> + <!-- Recon --> + <driver name="RawTrackerHitFitterDriver" /> + <driver name="TrackerHitDriver" /> + <driver name="HelicalTrackHitDriver" /> + <driver name="TrackerReconDriver" /> + <driver name="ClockDriver" /> + <driver name="CleanupDriver" /> + </execute> + + <drivers> + + <driver name="Calibrations" type="org.lcsim.hps.monitoring.CalibrationDriver"> + <runNumber>1351</runNumber> + </driver> + + <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> + <eventInterval>1000</eventInterval> + </driver> + + <driver name="EcalReadout" type="org.lcsim.hps.readout.ecal.FADCEcalReadoutDriver"> + <readoutPeriod>4.0</readoutPeriod> + <coincidenceWindow>2</coincidenceWindow> + <ecalName>Ecal</ecalName> + <ecalCollectionName>EcalHits</ecalCollectionName> + <ecalRawCollectionName>EcalRawHits</ecalRawCollectionName> + <triggerThreshold>80</triggerThreshold> + <readoutThreshold>50</readoutThreshold> + </driver> + + <driver name="EcalConverter" type="org.lcsim.hps.recon.ecal.EcalConverterDriver"> + <rawCollectionName>EcalRawHits</rawCollectionName> + <ecalCollectionName>EcalCorrectedHits</ecalCollectionName> + <scale>1</scale> + </driver> + + <driver name="EcalTriggerFilter" type="org.lcsim.hps.recon.ecal.EcalTriggerFilterDriver"> + <inputCollection>EcalCorrectedHits</inputCollection> + <outputCollection>EcalFilteredHits</outputCollection> + </driver> + + <driver name="EcalClusterer" + type="org.lcsim.hps.recon.ecal.CTPEcalClusterer"> + <ecalName>Ecal</ecalName> + <ecalCollectionName>EcalFilteredHits</ecalCollectionName> + </driver> + + <driver name="EcalTrigger" type="org.lcsim.hps.readout.ecal.TestRunTriggerDriver"> + <clusterCollectionName>EcalClusters</clusterCollectionName> + <deadTime>10</deadTime> + </driver> + + <driver name="SVTReadout" type="org.lcsim.hps.recon.tracking.apv25.SvtReadout"> + <debug>false</debug> + <pedestalRun>false</pedestalRun> + <triggerLatencyTime>288</triggerLatencyTime> + </driver> + + <driver name="Digitization" type="org.lcsim.hps.recon.tracking.RearTransitionModule" /> + + <driver name="DataProcessing" type="org.lcsim.hps.recon.tracking.TestRunDataProcessingModule" > + <enablePileUpCut>true</enablePileUpCut> + <enableThresholdCut>true</enableThresholdCut> + <noiseThreshold>2</noiseThreshold> + <numberOfSamplesAboveThreshold>3</numberOfSamplesAboveThreshold> + <numberOfSamplesToReadOut>6</numberOfSamplesToReadOut> + </driver> + + + <driver name="RawTrackerHitFitterDriver" type="org.lcsim.hps.recon.tracking.HPSRawTrackerHitFitterDriver"> + <debug>false</debug> + <rawHitCollectionName>SVTRawTrackerHits</rawHitCollectionName> + <fittedHitCollectionName>SVTFittedRawTrackerHits</fittedHitCollectionName> + <fitAlgorithm>Analytic</fitAlgorithm> + </driver> + + + <driver name="TrackerHitDriver" type="org.lcsim.hps.users.mgraham.DataTrackerHitDriver" > + <debug>false</debug> + </driver> + + <driver name="HelicalTrackHitDriver" + type="org.lcsim.hps.recon.tracking.HelicalTrackHitDriver"> + <debug>false</debug> + <layerGeometryType>Common</layerGeometryType> + <maxSeperation>20.0</maxSeperation> + <tolerance>1.0</tolerance> + </driver> + + <driver name="TrackerReconDriver" type="org.lcsim.hps.recon.tracking.TrackerReconDriver"> + <debug>false</debug> + <strategyResource> </strategyResource> + </driver> + + <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver" /> + + <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver"> + <collectionNames>TrackerHits SVTRawTrackerHits SVTFittedRawTrackerHits</collectionNames> + </driver> + + </drivers> +</lcsim>
diff -N TestRunReadoutToEvio.lcsim --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ TestRunReadoutToEvio.lcsim 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,91 @@
+<!-- + Execute test run full recon and write the results as an EVIO file. +--> +<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> + <execute> +<!-- <driver name="EventMarkerDriver"/>--> + <driver name="CalibrationDriver"/> + <driver name="EcalReadout"/> + <driver name="EcalConverter"/> + <driver name="EcalTriggerFilter"/> + <driver name="EcalClusterer"/> + <driver name="EcalTrigger"/> +<!-- <driver name="SimpleSVTReadout"/>--> + <driver name="SVTReadout"/> + <driver name="Digitization"/> + <driver name="DataProcessing"/> + <driver name="ClockDriver"/> + <driver name="TestRunReconToEvio"/> + <driver name="CleanupDriver"/> + </execute> + + <drivers> + <!--<driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> + <eventInterval>1</eventInterval> + </driver> --> + <driver name="CalibrationDriver" type="org.lcsim.hps.monitoring.CalibrationDriver"> +<!-- <runNumber>1351</runNumber> --> + </driver> + <driver name="TestRunReconToEvio" type="org.lcsim.hps.evio.TestRunTriggeredReconToEvio"> + <evioOutputFile>${evioFile}</evioOutputFile> + </driver> + + <driver name="EcalReadout" type="org.lcsim.hps.readout.ecal.FADCEcalReadoutDriver"> + <readoutPeriod>4.0</readoutPeriod> + <coincidenceWindow>2</coincidenceWindow> + <ecalName>Ecal</ecalName> + <ecalCollectionName>EcalHits</ecalCollectionName> + <ecalRawCollectionName>EcalRawHits</ecalRawCollectionName> + <triggerThreshold>80</triggerThreshold> + <readoutThreshold>50</readoutThreshold> + </driver> + + <driver name="EcalConverter" type="org.lcsim.hps.recon.ecal.EcalConverterDriver"> + <rawCollectionName>EcalRawHits</rawCollectionName> + <ecalCollectionName>EcalCorrectedHits</ecalCollectionName> + <scale>1</scale> + </driver> + + <driver name="EcalTriggerFilter" type="org.lcsim.hps.recon.ecal.EcalTriggerFilterDriver"> + <inputCollection>EcalCorrectedHits</inputCollection> + <outputCollection>EcalFilteredHits</outputCollection> + </driver> + + <driver name="EcalClusterer" type="org.lcsim.hps.recon.ecal.CTPEcalClusterer"> + <ecalName>Ecal</ecalName> + <clusterWindow>32.0</clusterWindow> + <ecalCollectionName>EcalFilteredHits</ecalCollectionName> + </driver> + + <driver name="EcalTrigger" type="org.lcsim.hps.readout.ecal.TestRunTriggerDriver"> + <clusterCollectionName>EcalClusters</clusterCollectionName> + <deadTime>10</deadTime> + <outputFileName>${evioFile}.triggers</outputFileName> + </driver> + <driver name="SimpleSVTReadout" type="org.lcsim.hps.recon.tracking.SimpleSvtReadout"> + </driver> + + <driver name="SVTReadout" type="org.lcsim.hps.recon.tracking.apv25.SvtReadout"> + <debug>false</debug> + <pedestalRun>false</pedestalRun> + <triggerLatencyTime>288</triggerLatencyTime> + </driver> + + <driver name="Digitization" type="org.lcsim.hps.recon.tracking.RearTransitionModule" /> + + <driver name="DataProcessing" type="org.lcsim.hps.recon.tracking.TestRunDataProcessingModule" > + <enablePileUpCut>true</enablePileUpCut> + <enableThresholdCut>true</enableThresholdCut> + <noiseThreshold>2</noiseThreshold> + <numberOfSamplesAboveThreshold>3</numberOfSamplesAboveThreshold> + <numberOfSamplesToReadOut>6</numberOfSamplesToReadOut> + </driver> + + <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"/> + <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver"> + <collectionNames>TrackerHits</collectionNames> + </driver> + </drivers> +</lcsim> +
diff -N TestRunReadoutToLcio.lcsim --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ TestRunReadoutToLcio.lcsim 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,91 @@
+<!-- + Execute test run full recon and write the results as an LCIO file. +--> +<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> + <execute> +<!-- <driver name="EventMarkerDriver"/>--> + <driver name="CalibrationDriver"/> + <driver name="EcalReadout"/> + <driver name="EcalConverter"/> + <driver name="EcalTriggerFilter"/> + <driver name="EcalClusterer"/> + <driver name="EcalTrigger"/> +<!-- <driver name="SimpleSVTReadout"/>--> + <driver name="SVTReadout"/> + <driver name="Digitization"/> + <driver name="DataProcessing"/> + <driver name="ClockDriver"/> + <driver name="TestRunReconToLcio"/> + <driver name="CleanupDriver"/> + </execute> + + <drivers> +<!-- <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> + <eventInterval>1</eventInterval> + </driver> --> + <driver name="CalibrationDriver" type="org.lcsim.hps.monitoring.CalibrationDriver"> +<!-- <runNumber>1351</runNumber> --> + </driver> + <driver name="TestRunReconToLcio" type="org.lcsim.hps.evio.TestRunTriggeredReconToLcio"> + <outputFile>${outputFile}</outputFile> + </driver> + + <driver name="EcalReadout" type="org.lcsim.hps.readout.ecal.FADCEcalReadoutDriver"> + <readoutPeriod>4.0</readoutPeriod> + <coincidenceWindow>2</coincidenceWindow> + <ecalName>Ecal</ecalName> + <ecalCollectionName>EcalHits</ecalCollectionName> + <ecalRawCollectionName>EcalRawHits</ecalRawCollectionName> + <triggerThreshold>80</triggerThreshold> + <readoutThreshold>50</readoutThreshold> + </driver> + + <driver name="EcalConverter" type="org.lcsim.hps.recon.ecal.EcalConverterDriver"> + <rawCollectionName>EcalRawHits</rawCollectionName> + <ecalCollectionName>EcalCorrectedHits</ecalCollectionName> + <scale>1</scale> + </driver> + + <driver name="EcalTriggerFilter" type="org.lcsim.hps.recon.ecal.EcalTriggerFilterDriver"> + <inputCollection>EcalCorrectedHits</inputCollection> + <outputCollection>EcalFilteredHits</outputCollection> + </driver> + + <driver name="EcalClusterer" type="org.lcsim.hps.recon.ecal.CTPEcalClusterer"> + <ecalName>Ecal</ecalName> + <clusterWindow>32.0</clusterWindow> + <ecalCollectionName>EcalFilteredHits</ecalCollectionName> + </driver> + + <driver name="EcalTrigger" type="org.lcsim.hps.readout.ecal.TestRunTriggerDriver"> + <clusterCollectionName>EcalClusters</clusterCollectionName> + <deadTime>10</deadTime> + <outputFileName>${outputFile}.triggers</outputFileName> + </driver> + <driver name="SimpleSVTReadout" type="org.lcsim.hps.recon.tracking.SimpleSvtReadout"> + </driver> + + <driver name="SVTReadout" type="org.lcsim.hps.recon.tracking.apv25.SvtReadout"> + <debug>false</debug> + <pedestalRun>false</pedestalRun> + <triggerLatencyTime>288</triggerLatencyTime> + </driver> + + <driver name="Digitization" type="org.lcsim.hps.recon.tracking.RearTransitionModule" /> + + <driver name="DataProcessing" type="org.lcsim.hps.recon.tracking.TestRunDataProcessingModule" > + <enablePileUpCut>true</enablePileUpCut> + <enableThresholdCut>true</enableThresholdCut> + <noiseThreshold>2</noiseThreshold> + <numberOfSamplesAboveThreshold>3</numberOfSamplesAboveThreshold> + <numberOfSamplesToReadOut>6</numberOfSamplesToReadOut> + </driver> + + <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"/> + <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver"> + <collectionNames>TrackerHits</collectionNames> + </driver> + </drivers> +</lcsim> +
diff -N HPS2014ReadoutToLcio.lcsim --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPS2014ReadoutToLcio.lcsim 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,104 @@
+<!-- + Execute full trigger+readout simulation and write the results as an LCIO file. + @author Sho Uemura <[log in to unmask]> + @version $Id: HPS2014ReadoutToLcio.lcsim,v 1.1 2013/02/25 22:39:25 meeg Exp $ +--> +<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> + <execute> + <driver name="EventMarkerDriver"/> + + <driver name="CalibrationDriver"/> + <driver name="EcalReadout"/> + <driver name="EcalConverter"/> + <driver name="EcalClusterer"/> + <driver name="EcalTrigger"/> + +<!-- <driver name="SimpleSVTReadout"/>--> + + <driver name="SVTReadout"/> + <driver name="Digitization"/> + <driver name="DataProcessing"/> + <driver name="TestRunReconToLcio"/> + + <driver name="AidaSaveDriver"/> + + <driver name="ClockDriver"/> + <driver name="CleanupDriver"/> + </execute> + + <drivers> + <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> + <eventInterval>1000</eventInterval> + </driver> + <driver name="CalibrationDriver" type="org.lcsim.hps.monitoring.CalibrationDriver"> +<!-- <runNumber>1351</runNumber> --> + </driver> + <driver name="TestRunReconToLcio" type="org.lcsim.hps.evio.TestRunTriggeredReconToLcio"> + <outputFile>${outputFile}.slcio</outputFile> + </driver> + + <driver name="EcalReadout" type="org.lcsim.hps.readout.ecal.FADCEcalReadoutDriver"> + <readoutPeriod>4.0</readoutPeriod> + <coincidenceWindow>2</coincidenceWindow> + <ecalName>Ecal</ecalName> + <ecalCollectionName>EcalHits</ecalCollectionName> + <ecalRawCollectionName>EcalRawHits</ecalRawCollectionName> + <triggerThreshold>50</triggerThreshold> + <readoutThreshold>50</readoutThreshold> + <constantTriggerWindow>true</constantTriggerWindow> + <scaleFactor>1</scaleFactor> +<!-- <fixedGain>0.15</fixedGain>--> +<!-- <debug>true</debug>--> + </driver> + + <driver name="EcalConverter" type="org.lcsim.hps.recon.ecal.EcalRawConverterDriver"> + <rawCollectionName>EcalRawHits</rawCollectionName> + <ecalCollectionName>EcalCorrectedHits</ecalCollectionName> +<!-- <gain>0.15</gain>--> + <applyBadCrystalMap>false</applyBadCrystalMap> +<!-- <debug>true</debug>--> + </driver> + + <driver name="EcalClusterer" type="org.lcsim.hps.recon.ecal.CTPEcalClusterer"> + <ecalName>Ecal</ecalName> + <clusterWindow>8.0</clusterWindow> + <ecalCollectionName>EcalCorrectedHits</ecalCollectionName> + </driver> + + <driver name="EcalTrigger" type="org.lcsim.hps.readout.ecal.FADCTriggerDriver"> + <clusterCollectionName>EcalClusters</clusterCollectionName> + <deadTime>10</deadTime> + <outputFileName>${outputFile}.triggers</outputFileName> + </driver> + <driver name="SimpleSVTReadout" type="org.lcsim.hps.recon.tracking.SimpleSvtReadout"> + </driver> + + <driver name="SVTReadout" type="org.lcsim.hps.recon.tracking.apv25.SvtReadout"> + <debug>false</debug> + <pedestalRun>false</pedestalRun> + <triggerLatencyTime>240</triggerLatencyTime> + </driver> + + <driver name="Digitization" type="org.lcsim.hps.recon.tracking.RearTransitionModule" /> + + <driver name="DataProcessing" type="org.lcsim.hps.recon.tracking.TestRunDataProcessingModule" > + <enablePileUpCut>true</enablePileUpCut> + <enableThresholdCut>true</enableThresholdCut> + <noiseThreshold>2</noiseThreshold> + <numberOfSamplesAboveThreshold>3</numberOfSamplesAboveThreshold> + <numberOfSamplesToReadOut>6</numberOfSamplesToReadOut> + </driver> + + <driver name="AidaSaveDriver" + type="org.lcsim.job.AidaSaveDriver"> + <outputFileName>${outputFile}_triggerPlots</outputFileName> + </driver> + + <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"/> + <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver"> + <collectionNames>TrackerHits</collectionNames> + </driver> + </drivers> +</lcsim> +
diff -N TestRunPairTrigger.lcsim --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ TestRunPairTrigger.lcsim 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,75 @@
+ +<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> + <inputFiles> + <!--<fileRegExp baseDir="./../data/mc/Reach-2pt2" >.*gev60.*</fileRegExp>--> +<!-- <fileRegExp baseDir="./../data/mc/Reach-2pt2" >.*gev100.*</fileRegExp>--> + </inputFiles> + <control> +<!-- <numberOfEvents>10000</numberOfEvents>--> + <printInputFiles>true</printInputFiles> + <printDriversDetailed>true</printDriversDetailed> + </control> + <execute> + <driver name="EventMarkerDriver"/> + <driver name="CalibrationDriver"/> + <driver name="EcalRawConverter"/> +<!-- <driver name="HPSEcalRawConverterDriver"/> --> +<!-- <driver name="EcalTriggerFilter"/> --> + <driver name="EcalTriggerClusterer"/> +<!-- <driver name="SimpleSVTReadout"/> --> + <driver name="EcalTrigger"/> + <driver name="ClockDriver"/> +<!-- <driver name="MCParticlePlots"/>--> +<!-- <driver name="TriggerTurnOnAnalysis"/>--> + + </execute> + <drivers> + <driver name="CalibrationDriver" type="org.lcsim.hps.monitoring.CalibrationDriver"> + </driver> + <driver name="EcalRawConverter" type="org.lcsim.hps.recon.ecal.EcalEdepToTriggerConverterDriver"> + <readoutCollection>EcalReadoutAnalogHits</readoutCollection> + <applyBadCrystalMap>false</applyBadCrystalMap> + <truncateScale>1</truncateScale> + <constantGain>0.15</constantGain> + </driver> +<!-- <driver name="HPSEcalRawConverterDriver" type="org.lcsim.hps.recon.ecal.HPSEcalRawConverterDriver"> + <runBackwards>true</runBackwards> + <rawCollectionName>EcalReadoutHits</rawCollectionName> + <ecalCollectionName>EcalReadoutAnalogHits</ecalCollectionName> + </driver>--> +<!-- <driver name="EcalTriggerFilter" type="org.lcsim.hps.recon.ecal.HPSEcalTriggerFilterDriver"> + <inputCollection>EcalTriggerHits</inputCollection> + <outputCollection>EcalFilteredHits</outputCollection> + </driver>--> + <driver name="EcalTriggerClusterer" type="org.lcsim.hps.recon.ecal.CTPEcalClusterer"> + <ecalName>Ecal</ecalName> + <ecalCollectionName>EcalReadoutAnalogHits</ecalCollectionName> +<!-- <ecalCollectionName>EcalFilteredHits</ecalCollectionName>--> + <clusterCollectionName>EcalTriggerClusters</clusterCollectionName> + </driver> +<!-- <driver name="EcalTrigger" type="org.lcsim.hps.recon.ecal.TestRunTriggerDriver">--> + <driver name="EcalTrigger" type="org.lcsim.hps.readout.ecal.FADCTriggerDriver"> + <!--<driver name="EcalTrigger" type="org.lcsim.hps.recon.ecal.HPSFADCSingleTriggerDriver">--> + <clusterCollectionName>EcalTriggerClusters</clusterCollectionName> + <outputFileName>${outputFile}.triggers</outputFileName> + <deadTime>0</deadTime> + <!--<lcioFile>${outputFile}</lcioFile>--> + </driver> + <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> + <eventInterval>1000</eventInterval> + </driver> + + <driver name="SimpleSVTReadout" type="org.lcsim.hps.recon.tracking.SimpleSvtReadout"> + <noPileup>true</noPileup> + </driver> + <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"/> + <driver name="MCParticlePlots" type="org.lcsim.hps.analysis.ecal.HPSMCParticlePlotsDriver"> + <hideFrame>true</hideFrame> + </driver> + <driver name="TriggerTurnOnAnalysis" type="org.lcsim.hps.users.phansson.TriggerTurnOnAnalysis"> + <aidaFileName>${outputFile}</aidaFileName> + <hideFrame>true</hideFrame> + </driver> + </drivers> +</lcsim>
diff -N HPS2014ReadoutToEvio.lcsim --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPS2014ReadoutToEvio.lcsim 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,97 @@
+<!-- + Execute full trigger+readout simulation and write the results as an EVIO file. + @author Sho Uemura <[log in to unmask]> + @version $Id: HPS2014ReadoutToEvio.lcsim,v 1.1 2013/02/25 22:39:25 meeg Exp $ +--> +<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> + <execute> + <driver name="EventMarkerDriver"/> + + <driver name="CalibrationDriver"/> + <driver name="EcalReadout"/> + <driver name="EcalConverter"/> + <driver name="EcalClusterer"/> + <driver name="EcalTrigger"/> + +<!-- <driver name="SimpleSVTReadout"/>--> + + <driver name="SVTReadout"/> + <driver name="Digitization"/> + <driver name="DataProcessing"/> + <driver name="TestRunReconToEvio"/> + + <driver name="ClockDriver"/> + <driver name="CleanupDriver"/> + </execute> + + <drivers> + <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> + <eventInterval>1000</eventInterval> + </driver> + <driver name="CalibrationDriver" type="org.lcsim.hps.monitoring.CalibrationDriver"> +<!-- <runNumber>1351</runNumber> --> + </driver> + <driver name="TestRunReconToEvio" type="org.lcsim.hps.evio.TestRunTriggeredReconToEvio"> + <evioOutputFile>${outputFile}</evioOutputFile> + </driver> + + <driver name="EcalReadout" type="org.lcsim.hps.readout.ecal.FADCEcalReadoutDriver"> + <readoutPeriod>4.0</readoutPeriod> + <coincidenceWindow>2</coincidenceWindow> + <ecalName>Ecal</ecalName> + <ecalCollectionName>EcalHits</ecalCollectionName> + <ecalRawCollectionName>EcalRawHits</ecalRawCollectionName> + <triggerThreshold>50</triggerThreshold> + <readoutThreshold>50</readoutThreshold> + <constantTriggerWindow>true</constantTriggerWindow> + <scaleFactor>1</scaleFactor> + <fixedGain>0.15</fixedGain> +<!-- <debug>true</debug>--> + </driver> + + <driver name="EcalConverter" type="org.lcsim.hps.recon.ecal.EcalRawConverterDriver"> + <rawCollectionName>EcalRawHits</rawCollectionName> + <ecalCollectionName>EcalCorrectedHits</ecalCollectionName> + <gain>0.15</gain> + <applyBadCrystalMap>false</applyBadCrystalMap> +<!-- <debug>true</debug>--> + </driver> + + <driver name="EcalClusterer" type="org.lcsim.hps.recon.ecal.CTPEcalClusterer"> + <ecalName>Ecal</ecalName> + <clusterWindow>32.0</clusterWindow> + <ecalCollectionName>EcalCorrectedHits</ecalCollectionName> + </driver> + + <driver name="EcalTrigger" type="org.lcsim.hps.readout.ecal.FADCTriggerDriver"> + <clusterCollectionName>EcalClusters</clusterCollectionName> + <deadTime>10</deadTime> + <outputFileName>${outputFile}.triggers</outputFileName> + </driver> + <driver name="SimpleSVTReadout" type="org.lcsim.hps.recon.tracking.SimpleSvtReadout"> + </driver> + + <driver name="SVTReadout" type="org.lcsim.hps.recon.tracking.apv25.SvtReadout"> + <debug>false</debug> + <pedestalRun>false</pedestalRun> + <triggerLatencyTime>240</triggerLatencyTime> + </driver> + + <driver name="Digitization" type="org.lcsim.hps.recon.tracking.RearTransitionModule" /> + + <driver name="DataProcessing" type="org.lcsim.hps.recon.tracking.TestRunDataProcessingModule" > + <enablePileUpCut>true</enablePileUpCut> + <enableThresholdCut>true</enableThresholdCut> + <noiseThreshold>2</noiseThreshold> + <numberOfSamplesAboveThreshold>3</numberOfSamplesAboveThreshold> + <numberOfSamplesToReadOut>6</numberOfSamplesToReadOut> + </driver> + + <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"/> + <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver"> + <collectionNames>TrackerHits</collectionNames> + </driver> + </drivers> +</lcsim> +
diff -N HPSTestRunLcioToEvio.lcsim --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ HPSTestRunLcioToEvio.lcsim 25 Feb 2013 22:39:25 -0000 1.1 @@ -0,0 +1,24 @@
+<!-- + Convert LCIO file to EVIO file. +--> +<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> + <execute> + <driver name="DummyTrigger"/> + <driver name="TestRunReconToEvio"/> + <driver name="ClockDriver"/> + </execute> + + <drivers> + <driver name="DummyTrigger" type="org.lcsim.hps.readout.ecal.DummyTriggerDriver"> + <period>1</period> + <deadTime>0</deadTime> + </driver> + <driver name="TestRunReconToEvio" type="org.lcsim.hps.evio.TestRunTriggeredReconToEvio"> + <evioOutputFile>${evioFile}</evioOutputFile> + </driver> + <driver name="ClockDriver" type="org.lcsim.hps.util.ClockDriver"> + </driver> + </drivers> +</lcsim> +
diff -u -r1.22 -r1.23 --- HPSSVTCalibrationConstants.java 18 Dec 2012 19:53:07 -0000 1.22 +++ HPSSVTCalibrationConstants.java 25 Feb 2013 22:39:26 -0000 1.23 @@ -8,13 +8,13 @@
import org.lcsim.detector.identifier.IIdentifier; import org.lcsim.detector.identifier.IIdentifierHelper; import org.lcsim.detector.tracker.silicon.SiSensor;
-import org.lcsim.hps.monitoring.HPSCalibrationDriver;
+import org.lcsim.hps.monitoring.CalibrationDriver;
import org.lcsim.hps.util.Pair; /** * * @author Mathew Graham <[log in to unmask]>
- * $Id: HPSSVTCalibrationConstants.java,v 1.22 2012/12/18 19:53:07 omoreno Exp $
+ * $Id: HPSSVTCalibrationConstants.java,v 1.23 2013/02/25 22:39:26 meeg Exp $
*/ public class HPSSVTCalibrationConstants {
@@ -47,7 +47,7 @@
ConditionsManager conditions = ConditionsManager.defaultInstance(); String filePath = null;
- filePath = HPSCalibrationDriver.getCalibForRun("calibSVT/base", run);
+ filePath = CalibrationDriver.getCalibForRun("calibSVT/base", run);
if (filePath == null) { filePath = "calibSVT/default.base";
@@ -61,7 +61,7 @@
}
- filePath = HPSCalibrationDriver.getCalibForRun("calibSVT/tp", run);
+ filePath = CalibrationDriver.getCalibForRun("calibSVT/tp", run);
if (filePath == null) { filePath = "calibSVT/default.tp";
diff -N FADCTriggerDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ FADCTriggerDriver.java 25 Feb 2013 22:39:26 -0000 1.1 @@ -0,0 +1,477 @@
+package org.lcsim.hps.readout.ecal; + +import hep.aida.IHistogram1D; +import hep.aida.IHistogram2D; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.EnumSet; +import java.util.LinkedList; +import java.util.List; + +import org.lcsim.event.Cluster; +import org.lcsim.event.EventHeader; +import org.lcsim.geometry.Detector; +import org.lcsim.hps.evio.TriggerData; +import org.lcsim.hps.recon.ecal.ECalUtils; +import org.lcsim.hps.recon.ecal.HPSEcalCluster; +import org.lcsim.hps.util.ClockSingleton; +import org.lcsim.util.aida.AIDA; + +/** + * Reads clusters and makes trigger decision using opposite quadrant criterion. + * Prints triggers to file if file path specified. + * + * @author Omar Moreno <[log in to unmask]> + * @author Sho Uemura <[log in to unmask]> + * @version $Id: FADCTriggerDriver.java,v 1.1 2013/02/25 22:39:26 meeg Exp $ + */ +public class FADCTriggerDriver extends TriggerDriver { + + // A list to contain all cluster pairs in an event + List<HPSEcalCluster[]> clusterPairs; + int nTriggers; + int totalEvents; + private double beamEnergy = 2.2 * ECalUtils.GeV; + private double clusterEnergyHigh = 1.85 / 2.2; + private double clusterEnergyLow = .1 / 2.2; + private double energySumThreshold = 1.0; + private double energyDifferenceThreshold = 1.5 / 2.2; + private double maxCoplanarityAngle = 35; // degrees +// private double energyDistanceDistance = 250; // mm +// private double energyDistanceThreshold = 0.8 / 2.2; + private double energyDistanceDistance = 200; // mm + private double energyDistanceThreshold = 0.5; + int allPairs; + int oppositeQuadrantCount; + int clusterEnergyCount; + int energySumCount; + int energyDifferenceCount; + int energyDistanceCount; + int coplanarityCount; + AIDA aida = AIDA.defaultInstance(); + IHistogram2D clusterEnergy2DAll, clusterSumDiff2DAll, energyDistance2DAll, clusterAngles2DAll, clusterCoplanarity2DAll; + IHistogram2D clusterEnergy2D, clusterSumDiff2D, energyDistance2D, clusterAngles2D, clusterCoplanarity2D; + IHistogram1D triggerBits1D, triggerTimes1D; + private boolean useQuadrants = false; + + private enum Flag { + + CLUSTER_ENERGY(3), ENERGY_SUM_DIFF(2), ENERGY_DISTANCE(1), COPLANARITY(0); + private final int index; + + Flag(int i) { + index = i; + } + + static int bitmask(EnumSet<Flag> flags) { + int mask = 0; + for (Flag flag : flags) { + mask |= 1 << flag.index; + } + return mask; + } + } + + public FADCTriggerDriver() { + clusterPairs = new LinkedList<HPSEcalCluster[]>(); + } + + public void setBeamEnergy(double beamEnergy) { + if (beamEnergy == 1.1) { + System.out.println(this.getClass().getSimpleName() + ": Setting trigger for 1.1 GeV beam"); + maxCoplanarityAngle = 90; + clusterEnergyHigh = .7 / beamEnergy; + clusterEnergyLow = .1 / beamEnergy; + energySumThreshold = 0.8 / beamEnergy; + } else if (beamEnergy == 2.2) { + System.out.println(this.getClass().getSimpleName() + ": Setting trigger for 2.2 GeV beam"); + maxCoplanarityAngle = 45; + clusterEnergyHigh = 1.6 / beamEnergy; + clusterEnergyLow = .1 / beamEnergy; + energySumThreshold = 1.7 / beamEnergy; + } else if (beamEnergy == 6.6) { + System.out.println(this.getClass().getSimpleName() + ": Setting trigger for 6.6 GeV beam"); + maxCoplanarityAngle = 60; + clusterEnergyHigh = 5.0 / beamEnergy; + clusterEnergyLow = .1 / beamEnergy; + energySumThreshold = 5.5 / beamEnergy; + } + this.beamEnergy = beamEnergy * ECalUtils.GeV; + } + + @Override + public void detectorChanged(Detector detector) { + if (detector.getName().contains("1pt1")) { + setBeamEnergy(1.1); + } else if (detector.getName().contains("2pt2")) { + setBeamEnergy(2.2); + } else if (detector.getName().contains("6pt6")) { + setBeamEnergy(6.6); + } + + clusterSumDiff2DAll = aida.histogram2D("All cluster pairs: energy difference vs. sum", 100, 0.0, 2 * beamEnergy, 100, 0.0, beamEnergy); + clusterEnergy2DAll = aida.histogram2D("All cluster pairs: energy (less energetic vs. more energetic)", 100, 0.0, 2 * beamEnergy, 100, 0.0, beamEnergy); + energyDistance2DAll = aida.histogram2D("All cluster pairs: distance vs. energy (less energetic cluster)", 100, 0.0, 0.5 * beamEnergy, 25, 0.0, 400.0); + clusterCoplanarity2DAll = aida.histogram2D("All cluster pairs: cluster angle uncoplanarity vs. less energetic cluster angle", 100, -180.0, 180.0, 100, -180.0, 180.0); + clusterAngles2DAll = aida.histogram2D("All cluster pairs: cluster angle (less energetic vs. more energetic)", 100, -180.0, 180.0, 100, -180.0, 180.0); + + clusterSumDiff2D = aida.histogram2D("Passed other cuts: energy difference vs. sum", 100, 0.0, 2 * beamEnergy, 100, 0.0, beamEnergy); + clusterEnergy2D = aida.histogram2D("Passed other cuts: energy (less energetic vs. more energetic)", 100, 0.0, 2 * beamEnergy, 100, 0.0, beamEnergy); + energyDistance2D = aida.histogram2D("Passed other cuts: distance vs. energy (less energetic cluster)", 100, 0.0, 0.5 * beamEnergy, 25, 0.0, 400.0); + clusterCoplanarity2D = aida.histogram2D("Passed other cuts: cluster angle uncoplanarity vs. less energetic cluster angle", 100, -180.0, 180.0, 100, -180.0, 180.0); + clusterAngles2D = aida.histogram2D("Passed other cuts: cluster angle (less energetic vs. more energetic)", 100, -180.0, 180.0, 100, -180.0, 180.0); + + triggerBits1D = aida.histogram1D(detector.getDetectorName() + " : " + clusterCollectionName + " : trigger bits", 17, -1.5, 15.5); + triggerTimes1D = aida.histogram1D(detector.getDetectorName() + " : " + clusterCollectionName + " : trigger times", 500, -0.5, 499.5); + } + + @Override + public void startOfData() { + super.startOfData(); + + allPairs = 0; + oppositeQuadrantCount = 0; + clusterEnergyCount = 0; + energySumCount = 0; + energyDifferenceCount = 0; + energyDistanceCount = 0; + coplanarityCount = 0; + } + + @Override + public boolean testTrigger(List<HPSEcalCluster> clusters) { + boolean trigger = false; + + if (useQuadrants) { + getClusterPairs(clusters); + } else { + getClusterPairsTopBot(clusters); + } + + //--- Apply Trigger Cuts ---// + + // Iterate through all cluster pairs present in the event. If at least + // one of the cluster pairs satisfies all of the trigger conditions, + // a trigger signal is sent to all other detectors. + for (HPSEcalCluster[] clusterPair : clusterPairs) { + + EnumSet<Flag> bits = EnumSet.noneOf(Flag.class); + + if (outputStream != null) { + outputStream.printf("Event %d: cluster pair (energy %f in quadrant %d (%s), energy %f in quadrant %d (%s))\n", + ClockSingleton.getClock(), + clusterPair[0].getEnergy(), ECalUtils.getQuadrant(clusterPair[0]), clusterPair[0].getSeedHit().getPositionVec().toString(), + clusterPair[1].getEnergy(), ECalUtils.getQuadrant(clusterPair[1]), clusterPair[1].getSeedHit().getPositionVec().toString()); + } + + allPairs++; + + if (useQuadrants) { + // Require that the event have at least two clusters in opposite + // quadrants + if (!oppositeQuadrantsCut(clusterPair)) { + if (outputStream != null) { + outputStream.println("Failed opposite quadrant cut"); + } + continue; + } + oppositeQuadrantCount++; + } + + // Require the components of a cluster pair to have an energy in + // the range of 100 MeV to 1.85 GeV + if (clusterECut(clusterPair)) { + bits.add(Flag.CLUSTER_ENERGY); + } + + bits.add(Flag.ENERGY_SUM_DIFF); + // Require the sum of the energies of the components of the + // cluster pair to be less than the + // (Beam Energy)*(Sampling Fraction) ( 2 GeV for the Test Run ) + if (!energySum(clusterPair)) { + bits.remove(Flag.ENERGY_SUM_DIFF); + } + + // Require the difference in energy of the components of the + // cluster pair to be less than 1.5 GeV + if (!energyDifference(clusterPair)) { + bits.remove(Flag.ENERGY_SUM_DIFF); + } + + // Apply a low energy cluster vs. distance cut of the form + // E_low + .0032 GeV/mm < .8 GeV + if (energyDistanceCut(clusterPair)) { + bits.add(Flag.ENERGY_DISTANCE); + } + + // Require that the two clusters are coplanar with the beam within + // 35 degrees + if (coplanarityCut(clusterPair)) { + bits.add(Flag.COPLANARITY); + } + + if (bits.contains(Flag.CLUSTER_ENERGY)) { + clusterEnergyCount++; + if (energySum(clusterPair)) { + energySumCount++; + if (energyDifference(clusterPair)) { + energyDifferenceCount++; + if (bits.contains(Flag.ENERGY_DISTANCE)) { + energyDistanceCount++; + if (bits.contains(Flag.COPLANARITY)) { + coplanarityCount++; + } else if (outputStream != null) { + outputStream.println("Failed coplanarity cut"); + } + } else if (outputStream != null) { + outputStream.println("Failed energy-distance cut"); + } + } else if (outputStream != null) { + outputStream.println("Failed energy difference cut"); + } + } else if (outputStream != null) { + outputStream.println("Failed energy sum cut"); + } + } else if (outputStream != null) { + outputStream.println("Failed cluster energy cut"); + } + + clusterSumDiff2DAll.fill(clusterPair[0].getEnergy() + clusterPair[1].getEnergy(), clusterPair[0].getEnergy() - clusterPair[1].getEnergy()); + clusterEnergy2DAll.fill(clusterPair[0].getEnergy(), clusterPair[1].getEnergy()); + energyDistance2DAll.fill(clusterPair[1].getEnergy(), getClusterDistance(clusterPair[1])); + clusterCoplanarity2DAll.fill(getClusterAngle(clusterPair[1]), pairUncoplanarity(clusterPair)); + clusterAngles2DAll.fill(getClusterAngle(clusterPair[0]), getClusterAngle(clusterPair[1])); + + if (bits.containsAll(EnumSet.complementOf(EnumSet.of(Flag.ENERGY_SUM_DIFF, Flag.CLUSTER_ENERGY)))) { //cluster energy, energy-distance, coplanarity + clusterSumDiff2D.fill(clusterPair[0].getEnergy() + clusterPair[1].getEnergy(), clusterPair[0].getEnergy() - clusterPair[1].getEnergy()); + clusterEnergy2D.fill(clusterPair[0].getEnergy(), clusterPair[1].getEnergy()); + } + if (bits.containsAll(EnumSet.complementOf(EnumSet.of(Flag.ENERGY_DISTANCE)))) { + energyDistance2D.fill(clusterPair[1].getEnergy(), getClusterDistance(clusterPair[1])); + } + if (bits.containsAll(EnumSet.complementOf(EnumSet.of(Flag.COPLANARITY)))) { + clusterCoplanarity2D.fill(getClusterAngle(clusterPair[1]), pairUncoplanarity(clusterPair)); + clusterAngles2D.fill(getClusterAngle(clusterPair[0]), getClusterAngle(clusterPair[1])); + } + + triggerBits1D.fill(Flag.bitmask(bits)); + + if (bits.containsAll(EnumSet.allOf(Flag.class))) { + // If all cuts are pased, we have a trigger + if (outputStream != null) { + outputStream.println("Passed all cuts"); + } + trigger = true; + } + } + if (trigger) { + triggerBits1D.fill(-1); + triggerTimes1D.fill(ClockSingleton.getClock() % 500); + } + return trigger; + } + + @Override + public void endOfData() { + if (outputStream != null) { + printCounts(outputStream); + } + printCounts(new PrintWriter(System.out)); + super.endOfData(); + } + + private void printCounts(PrintWriter writer) { + writer.printf("Number of pairs: %d\n", allPairs); + writer.printf("Number of cluster pairs after successive trigger conditions:\n"); + if (useQuadrants) { + writer.printf("Opposite quadrants: %d\n", oppositeQuadrantCount); + } + writer.printf("Cluster energy: %d\n", clusterEnergyCount); + writer.printf("Energy sum: %d\n", energySumCount); + writer.printf("Energy difference: %d\n", energyDifferenceCount); + writer.printf("Energy-distance cut: %d\n", energyDistanceCount); + writer.printf("Coplanarity: %d\n", coplanarityCount); + writer.printf("Trigger count: %d\n", numTriggers); + writer.close(); + } + + /** + * Get a list of all unique cluster pairs in the event + * + * @param ecalClusters : List of ECal clusters + * @return true if there are any cluster pairs + */ + private boolean getClusterPairs(List<HPSEcalCluster> ecalClusters) { + // Create a list which will hold all neighboring cluster to the cluster + // of interest + List< HPSEcalCluster> ecalClusterNeighbors = new LinkedList< HPSEcalCluster>(); + ecalClusterNeighbors.addAll(ecalClusters); + + // Clear the list of cluster pairs + clusterPairs.clear(); + + for (HPSEcalCluster ecalCluster : ecalClusters) { + // Create a list of neighbors to the cluster of interest + ecalClusterNeighbors.remove(ecalCluster); + + // Loop over all neigboring clusters and check to see if there is + // any which lie in opposing quadrants to the cluster of interest. + // If so, add them to the list of cluster pairs + for (HPSEcalCluster ecalClusterNeighbor : ecalClusterNeighbors) { + if (ecalCluster.getEnergy() > ecalClusterNeighbor.getEnergy()) { + HPSEcalCluster[] clusterPair = {ecalCluster, ecalClusterNeighbor}; + clusterPairs.add(clusterPair); + } else { + HPSEcalCluster[] clusterPair = {ecalClusterNeighbor, ecalCluster}; + clusterPairs.add(clusterPair); + } + } + } + + return !clusterPairs.isEmpty(); + } + + private boolean getClusterPairsTopBot(List<HPSEcalCluster> ecalClusters) { + // Create a list which will hold all neighboring cluster to the cluster + // of interest + List< HPSEcalCluster> topClusters = new ArrayList< HPSEcalCluster>(); + List< HPSEcalCluster> botClusters = new ArrayList< HPSEcalCluster>(); + for (HPSEcalCluster ecalCluster : ecalClusters) { + if (ecalCluster.getSeedHit().getIdentifierFieldValue("iy") > 0) { + topClusters.add(ecalCluster); + } else { + botClusters.add(ecalCluster); + } + } + // Clear the list of cluster pairs + clusterPairs.clear(); + + // Loop over all top-bottom pairs of clusters; higher-energy cluster goes first in the pair + for (HPSEcalCluster topCluster : topClusters) { + for (HPSEcalCluster botCluster : botClusters) { + if (topCluster.getEnergy() > botCluster.getEnergy()) { + HPSEcalCluster[] clusterPair = {topCluster, botCluster}; + clusterPairs.add(clusterPair); + } else { + HPSEcalCluster[] clusterPair = {botCluster, topCluster}; + clusterPairs.add(clusterPair); + } + } + } + return !clusterPairs.isEmpty(); + } + + /** + * Checks if the ECal clusters making up a cluster pair lie in opposite + * quadrants + * + * @param clusterPair : pair of clusters + * @return true if opposite quadrants, false otherwise + */ + private boolean oppositeQuadrantsCut(HPSEcalCluster[] clusterPair) { + int quad1 = ECalUtils.getQuadrant(clusterPair[0]); + int quad2 = ECalUtils.getQuadrant(clusterPair[1]); + + //if clusters are in the same quadrant, they're not opposite quadrants + if (quad1 == quad2) { + return false; + } //opposite pairs of quadrants are either both even (2 and 4) or both odd (1 and 3) + else { + return ((quad1 & 1) == (quad2 & 1)); + } + } + + /** + * Checks if the ECal clusters making up a cluster pair lie above the low + * energy threshold and below the high energy threshold + * + * @param clusterPair : pair of clusters + * @return true if a pair is found, false otherwise + */ + private boolean clusterECut(HPSEcalCluster[] clusterPair) { + return (clusterPair[0].getEnergy() < beamEnergy * clusterEnergyHigh + && clusterPair[1].getEnergy() < beamEnergy * clusterEnergyHigh + && clusterPair[0].getEnergy() > beamEnergy * clusterEnergyLow + && clusterPair[1].getEnergy() > beamEnergy * clusterEnergyLow); + } + + /** + * Checks if the sum of the energies of ECal clusters making up a cluster + * pair is below an energy sum threshold + * + * @param clusterPair : pair of clusters + * @return true if a pair is found, false otherwise + */ + private boolean energySum(Cluster[] clusterPair) { + double clusterESum = clusterPair[0].getEnergy() + clusterPair[1].getEnergy(); + return (clusterESum < beamEnergy * energySumThreshold); + } + + /** + * Checks if the energy difference between the ECal clusters making up a + * cluster pair is below an energy difference threshold + * + * @param clusterPair : pair of clusters + * @return true if pair is found, false otherwise + */ + private boolean energyDifference(HPSEcalCluster[] clusterPair) { + double clusterEDifference = clusterPair[0].getEnergy() - clusterPair[1].getEnergy(); + + return (clusterEDifference < beamEnergy * energyDifferenceThreshold); + } + + /** + * Require that the distance from the beam of the lowest energy cluster in a + * cluster pair satisfies the following E_low + d_b*.0032 GeV/mm < .8 GeV + * + * @param clusterPair : pair of clusters + * @return true if pair is found, false otherwise + */ + private boolean energyDistanceCut(HPSEcalCluster[] clusterPair) { + HPSEcalCluster lowEnergyCluster = clusterPair[1]; + + // Calculate its position + double lowEClusterDistance = getClusterDistance(clusterPair[1]); + // event passes cut if above the line with X- and Y-intercepts defined by energyDistanceDistance and beamEnergy*energyDistanceThreshold + double clusterDistvsE = lowEnergyCluster.getEnergy() + lowEClusterDistance * beamEnergy * energyDistanceThreshold / energyDistanceDistance; + + return (clusterDistvsE > beamEnergy * energyDistanceThreshold); + } + + /** + * Checks if a cluster pair is coplanar to the beam within a given angle + * + * @param clusterPair : pair of clusters + * @return true if pair is found, false otherwise + */ + private boolean coplanarityCut(HPSEcalCluster[] clusterPair) { + return (Math.abs(pairUncoplanarity(clusterPair)) < maxCoplanarityAngle); + } + + private double pairUncoplanarity(HPSEcalCluster[] clusterPair) { // Find the angle between clusters in the pair + double cluster1Angle = (getClusterAngle(clusterPair[0]) + 180.0) % 180.0; + double cluster2Angle = (getClusterAngle(clusterPair[1]) + 180.0) % 180.0; + + return cluster2Angle - cluster1Angle; + } + + private double getClusterAngle(HPSEcalCluster cluster) { //returns angle in range of -180 to 180 + double position[] = cluster.getSeedHit().getPosition(); + return Math.toDegrees(Math.atan2(position[1], position[0])); + } + + private double getClusterDistance(HPSEcalCluster cluster) { + return Math.hypot(cluster.getSeedHit().getPosition()[0], cluster.getSeedHit().getPosition()[1]); + } + + /** + * Make a dummy TriggerData + */ + @Override + protected void makeTriggerData(EventHeader event, String collectionName) { + TriggerData tData = new TriggerData(new int[8]); + List<TriggerData> triggerList = new ArrayList<TriggerData>(); + triggerList.add(tData); + event.put(collectionName, triggerList, TriggerData.class, 0); + } +}
\ No newline at end of file
diff -N TimeEvolutionEcalReadoutDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ TimeEvolutionEcalReadoutDriver.java 25 Feb 2013 22:39:26 -0000 1.1 @@ -0,0 +1,94 @@
+package org.lcsim.hps.readout.ecal; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.lcsim.event.CalorimeterHit; +import org.lcsim.hps.recon.ecal.HPSCalorimeterHit; +import org.lcsim.hps.util.ClockSingleton; +import org.lcsim.hps.util.RingBuffer; + +/** + * Performs readout of ECal hits. + * Simulates time evolution of preamp output pulse. + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: TimeEvolutionEcalReadoutDriver.java,v 1.1 2013/02/25 22:39:26 meeg Exp $ + */ +public class TimeEvolutionEcalReadoutDriver extends EcalReadoutDriver<HPSCalorimeterHit> { + + //buffer for deposited energy + Map<Long, RingBuffer> eDepMap = null; + //length of ring buffer (in readout cycles) + int bufferLength = 20; + //shaper time constant in ns; negative values generate square pulses of the given width + double t0 = 18.0; + + public TimeEvolutionEcalReadoutDriver() { + hitClass = HPSCalorimeterHit.class; + } + + public void setT0(double t0) { + this.t0 = t0; + } + + public void setBufferLength(int bufferLength) { + this.bufferLength = bufferLength; + eDepMap = new HashMap<Long, RingBuffer>(); + } + + @Override + protected void readHits(List<HPSCalorimeterHit> hits) { + for (Long cellID : eDepMap.keySet()) { + RingBuffer eDepBuffer = eDepMap.get(cellID); + if (eDepBuffer.currentValue() > threshold) { +// int ix = dec.getValue("ix"); +// int iy = dec.getValue("iy"); +// if (iy == 1 && ix == -2) +// System.out.printf("Time %f, output signal %f\n", ClockSingleton.getTime(), eDepBuffer.currentValue()); + hits.add(new HPSCalorimeterHit(eDepBuffer.currentValue(), readoutTime(), cellID, hitType)); + } + eDepBuffer.step(); + } + } + + @Override + protected void putHits(List<CalorimeterHit> hits) { + //fill the readout buffers + for (CalorimeterHit hit : hits) { +// int ix = dec.getValue("ix"); +// int iy = dec.getValue("iy"); +// if (iy == 1 && ix == -2) +// System.out.printf("Time %f, input hit %f)\n", ClockSingleton.getTime() + hit.getTime(), hit.getRawEnergy()); + + RingBuffer eDepBuffer = eDepMap.get(hit.getCellID()); + if (eDepBuffer == null) { + eDepBuffer = new RingBuffer(bufferLength); + eDepMap.put(hit.getCellID(), eDepBuffer); + } + for (int i = 0; i < bufferLength; i++) { + eDepBuffer.addToCell(i, hit.getRawEnergy() * pulseAmplitude((i + 1) * readoutPeriod + readoutTime() - (ClockSingleton.getTime() + hit.getTime()))); + } + } + } + + @Override + protected void initReadout() { + //initialize buffers + eDepMap = new HashMap<Long, RingBuffer>(); + } + + private double pulseAmplitude(double time) { + if (time < 0.0) + return 0.0; + if (t0 > 0.0) { + return (time / t0) * Math.exp(1.0 - time / t0); + } else { + if (time < -t0) + return 1.0; + else + return 0.0; + } + } +}
diff -N TestRunTriggerDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ TestRunTriggerDriver.java 25 Feb 2013 22:39:26 -0000 1.1 @@ -0,0 +1,102 @@
+package org.lcsim.hps.readout.ecal; + +import org.lcsim.hps.readout.ecal.TriggerDriver; +import java.util.ArrayList; +import java.util.List; +import org.lcsim.event.EventHeader; +import org.lcsim.hps.evio.TriggerData; +import org.lcsim.hps.recon.ecal.HPSEcalCluster; + +/** + * Reads clusters and makes trigger decision using opposite quadrant criterion. + * Prints triggers to file if file path specified. + * + * @author Omar Moreno <[log in to unmask]> + * @author Sho Uemura <[log in to unmask]> + * @version $Id: TestRunTriggerDriver.java,v 1.1 2013/02/25 22:39:26 meeg Exp $ + */ +public class TestRunTriggerDriver extends TriggerDriver { + + boolean triggerThisCycle = false; + int cycleCounter = 0; + private double clusterEnergyLow = 10; // + int deadtimelessTriggerCount; + private int topBits = 0, botBits = 0; + + public TestRunTriggerDriver() { + } + + @Override + protected void makeTriggerData(EventHeader event, String collectionName) { + int[] trigArray = new int[8]; + trigArray[TriggerData.TOP_TRIG] = topBits; + trigArray[TriggerData.BOT_TRIG] = botBits; + trigArray[TriggerData.AND_TRIG] = topBits & botBits; + trigArray[TriggerData.OR_TRIG] = topBits | botBits; + TriggerData tData = new TriggerData(trigArray); + List<TriggerData> triggerList = new ArrayList<TriggerData>(); + triggerList.add(tData); + event.put(collectionName, triggerList, TriggerData.class, 0); + } + + @Override + public void startOfData() { + super.startOfData(); + + deadtimelessTriggerCount = 0; + } + + @Override + protected boolean triggerDecision(EventHeader event) { + if (event.hasCollection(HPSEcalCluster.class, clusterCollectionName)) { + cycleCounter++; + if (testTrigger(event.get(HPSEcalCluster.class, clusterCollectionName))) { + triggerThisCycle = true; + } + } + + if (cycleCounter % 4 == 0) { + boolean trigger = triggerThisCycle; + triggerThisCycle = false; + return trigger; + } else { + return false; + } + } + + @Override + public boolean testTrigger(List<HPSEcalCluster> clusters) { + boolean trigger = false; + + topBits <<= 1; + botBits <<= 1; + for (HPSEcalCluster cluster : clusters) { + if (cluster.getEnergy() > clusterEnergyLow) { + if (cluster.getPosition()[1] > 0) { + topBits |= 1; + } else { + botBits |= 1; + } + trigger = true; + } + } + if (trigger) { + deadtimelessTriggerCount++; + } + return trigger; + } + + @Override + public void endOfData() { + if (outputStream != null) { + outputStream.printf("Number of cluster pairs after successive trigger conditions:\n"); + outputStream.printf("Trigger count without dead time: %d\n", deadtimelessTriggerCount); + outputStream.printf("Trigger count: %d\n", numTriggers); + outputStream.close(); + } + System.out.printf("Number of cluster pairs after successive trigger conditions:\n"); + System.out.printf("Trigger count without dead time: %d\n", deadtimelessTriggerCount); + System.out.printf("Trigger count: %d\n", numTriggers); + super.endOfData(); + } +}
\ No newline at end of file
diff -N TriggerDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ TriggerDriver.java 25 Feb 2013 22:39:26 -0000 1.1 @@ -0,0 +1,223 @@
+package org.lcsim.hps.readout.ecal; + +import java.io.File; +import java.io.IOException; +import java.io.PrintStream; +import java.io.PrintWriter; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; + + +import java.util.logging.Level; +import java.util.logging.Logger; +import org.lcsim.event.EventHeader; +import org.lcsim.hps.recon.ecal.HPSEcalCluster; +import org.lcsim.hps.recon.tracking.apv25.Apv25Full; +import org.lcsim.hps.recon.tracking.apv25.HPSAPV25; +import org.lcsim.hps.util.ClockSingleton; +import org.lcsim.util.Driver; +import org.lcsim.util.lcio.LCIOWriter; + +/** + * Reads clusters and makes trigger decision using opposite quadrant criterion. + * Prints triggers to file if file path specified. + * Applies SVT trigger latency and sends trigger signal to SVT + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: TriggerDriver.java,v 1.1 2013/02/25 22:39:26 meeg Exp $ + */ +public abstract class TriggerDriver extends Driver { + + private boolean _DEBUG = false; + protected String clusterCollectionName = "EcalClusters"; + private String outputFileName = null; + protected PrintWriter outputStream = null; + protected int numTriggers; + private int lastTrigger; + private int deadTime = 0; + // FIFO queue to store the svt trigger time stamp + private Queue<Double> svtTriggerTimeStamp = new LinkedList<Double>(); + // SVT trigger latency + public static final double svtTriggerLatency = 100.0; // [ns] + // FIFO queue to store the ECal trigger time stamp + private Queue<Double> ecalTriggerTimestamps = null; + // ECal trigger latency + private static final double ecalTriggerLatency = 100.0; // [ns] + // FIFO queue to store the trigger bank trigger time stamp + private Queue<Double> triggerTriggerTimestamps = null; + // trigger bank trigger latency + public static final double triggerTriggerLatency = 50.0; // [ns] + private static boolean triggerBit = false; + private String lcioFile = null; + LCIOWriter lcioWriter = null; + + public TriggerDriver() { + } + + public void setLcioFile(String lcioFile) { + this.lcioFile = lcioFile; + } + + /** + * Set dead time; 0 for no dead time + * @param deadTime Minimum number of clock ticks between triggers + */ + public void setDeadTime(int deadTime) { + this.deadTime = deadTime; + } + + public void setClusterCollectionName(String clusterCollectionName) { + this.clusterCollectionName = clusterCollectionName; + } + + public void setOutputFileName(String outputFileName) { + this.outputFileName = outputFileName; + } + + @Override + public void startOfData() { + if (clusterCollectionName == null) { + throw new RuntimeException("The parameter clusterCollectionName was not set!"); + } + + if (outputFileName != null) { + try { + outputStream = new PrintWriter(new PrintStream(outputFileName), true); + } catch (IOException ex) { + throw new RuntimeException("Invalid outputFilePath!"); + } + } else { + if (_DEBUG) { + outputStream = new PrintWriter(System.out, true); + } + } + + if (lcioFile != null) { + try { + lcioWriter = new LCIOWriter(new File(lcioFile)); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + numTriggers = 0; + + ecalTriggerTimestamps = new LinkedList<Double>(); + triggerTriggerTimestamps = new LinkedList<Double>(); + } + + @Override + public void process(EventHeader event) { + triggerBit = false; //reset trigger + //System.out.println(this.getClass().getCanonicalName() + " - process"); + + if (ClockSingleton.getClock() - lastTrigger > deadTime && triggerDecision(event)) { + triggerBit = true; + lastTrigger = ClockSingleton.getClock(); + numTriggers++; + if (_DEBUG) { + System.out.printf(this.getClass().getSimpleName() + ": Trigger on event %d\n", event.getEventNumber()); + } + if (outputStream != null) { + outputStream.printf("Trigger on event %d\n", event.getEventNumber()); + } + + // If an ECal trigger signal has been sent store the trigger + // time offset by the trigger latencies + svtTriggerTimeStamp.add(ClockSingleton.getTime() + svtTriggerLatency); + ecalTriggerTimestamps.add(ClockSingleton.getTime() + ecalTriggerLatency); + triggerTriggerTimestamps.add(ClockSingleton.getTime() + triggerTriggerLatency); + if (_DEBUG) { + System.out.println(this.getClass().getSimpleName() + ": Trigger added on event " + event.getEventNumber()); + } + + if (outputStream != null) { + outputStream.printf("trigger sent to ET event builder on event %d\n", event.getEventNumber()); + } + makeTriggerData(event, "TriggerStatus"); + if (lcioWriter != null) { + try { + lcioWriter.write(event); + } catch (IOException ex) { + Logger.getLogger(TriggerDriver.class.getName()).log(Level.SEVERE, null, ex); + } + } + } + + // Check if there are any pending SVT triggers to process + if (svtTriggerTimeStamp.peek() != null + && ClockSingleton.getTime() >= svtTriggerTimeStamp.peek()) { + + if (outputStream != null) { + outputStream.printf("SVT trigger sent on event %d\n", event.getEventNumber()); + } + + // Send a trigger signal to the SVT + HPSAPV25.readoutBit = true; + Apv25Full.readoutBit = true; + svtTriggerTimeStamp.remove(); + } + + // Check if there are any pending ECal triggers to process + if (ecalTriggerTimestamps.peek() != null + && ClockSingleton.getTime() >= ecalTriggerTimestamps.peek()) { + + if (outputStream != null) { + outputStream.printf("ECal trigger sent on event %d\n", event.getEventNumber()); + } + + // Send a trigger signal to the ECal + EcalReadoutDriver.readoutBit = true; + ecalTriggerTimestamps.remove(); + } + + + // Check if there are any pending trigger bank triggers to process + if (triggerTriggerTimestamps.peek() != null + && ClockSingleton.getTime() >= triggerTriggerTimestamps.peek()) { + + if (outputStream != null) { + outputStream.printf("Trigger bank trigger sent on event %d\n", event.getEventNumber()); + } + + // Make trigger bank + makeTriggerData(event, "TriggerBank"); + triggerTriggerTimestamps.remove(); + } + } + + protected boolean triggerDecision(EventHeader event) { + // Get the list of raw ECal hits. + if (event.hasCollection(HPSEcalCluster.class, clusterCollectionName)) { + return testTrigger(event.get(HPSEcalCluster.class, clusterCollectionName)); + } else { + return false; + } + } + + public abstract boolean testTrigger(List<HPSEcalCluster> clusters); + + protected void makeTriggerData(EventHeader event, String collectionName) { + } + + @Override + public void endOfData() { + if (outputStream != null) { + outputStream.printf("Trigger count: %d\n", numTriggers); + outputStream.close(); + } + if (lcioWriter != null) { + try { + lcioWriter.close(); + } catch (IOException ex) { + Logger.getLogger(TriggerDriver.class.getName()).log(Level.SEVERE, null, ex); + } + } + System.out.printf(this.getClass().getSimpleName() + ": Trigger count: %d\n", numTriggers); + } + + public static boolean triggerBit() { + return triggerBit; + } +}
\ No newline at end of file
diff -N FADCEcalReadoutDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ FADCEcalReadoutDriver.java 25 Feb 2013 22:39:26 -0000 1.1 @@ -0,0 +1,469 @@
+package org.lcsim.hps.readout.ecal; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import java.util.PriorityQueue; +import java.util.Set; +import org.lcsim.event.CalorimeterHit; +import org.lcsim.event.EventHeader; +import org.lcsim.event.RawCalorimeterHit; +import org.lcsim.event.RawTrackerHit; +import org.lcsim.event.base.BaseRawCalorimeterHit; +import org.lcsim.event.base.BaseRawTrackerHit; +import org.lcsim.geometry.Detector; +import org.lcsim.geometry.Subdetector; +import org.lcsim.geometry.subdetector.HPSEcal3; +import org.lcsim.hps.evio.EventConstants; +import org.lcsim.hps.recon.ecal.ECalUtils; +import org.lcsim.hps.recon.ecal.EcalConditions; +import org.lcsim.hps.recon.ecal.HPSRawCalorimeterHit; +import org.lcsim.hps.util.ClockSingleton; +import org.lcsim.hps.util.RingBuffer; +import org.lcsim.util.lcio.LCIOConstants; + +/** + * Performs readout of ECal hits. + * Simulates time evolution of preamp output pulse. + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: FADCEcalReadoutDriver.java,v 1.1 2013/02/25 22:39:26 meeg Exp $ + */ +public class FADCEcalReadoutDriver extends EcalReadoutDriver<RawCalorimeterHit> { + + String ecalName = "Ecal"; + Subdetector ecal; + //buffer for deposited energy + private Map<Long, RingBuffer> eDepMap = null; + //ADC pipeline for readout + private Map<Long, FADCPipeline> pipelineMap = null; + //buffer for window sums + private Map<Long, Double> sumMap = null; + //buffer for timestamps + private Map<Long, Integer> timeMap = null; + //queue for hits to be output to clusterer + private PriorityQueue<HPSRawCalorimeterHit> outputQueue = null; + //length of ring buffer (in readout cycles) + private int bufferLength = 100; + //length of readout pipeline (in readout cycles) + private int pipelineLength = 2000; + //shaper time constant in ns; negative values generate square pulses of the given width + private double tp = 14.0; + //delay (number of readout periods) between start of summing window and output of hit to clusterer + private int delay0 = 32; + //start of readout window relative to trigger time (in readout cycles) + //in FADC documentation, "Programmable Latency" or PL + private int readoutLatency = 100; + //number of ADC samples to read out + //in FADC documentation, "Programmable Trigger Window" or PTW + private int readoutWindow = 100; + //number of ADC samples to read out before each rising threshold crossing + //in FADC documentation, "number of samples before" or NSB + private int numSamplesBefore = 5; + //number of ADC samples to read out after each rising threshold crossing + //in FADC documentation, "number of samples before" or NSA + private int numSamplesAfter = 30; +// private HPSEcalConverter converter = null; + //output buffer for hits + private LinkedList<HPSRawCalorimeterHit> buffer = new LinkedList<HPSRawCalorimeterHit>(); + //number of readout periods for which a given hit stays in the buffer + private int coincidenceWindow = 2; + private double pulseIntegral; + //output collection name for hits read out from trigger + private String ecalReadoutCollectionName = "EcalReadoutHits"; + private int mode = EventConstants.ECAL_PULSE_INTEGRAL_MODE; + private int readoutThreshold = (int) threshold; + private int triggerThreshold = (int) threshold; + //amplitude ADC counts/GeV +// private double gain = 0.5*1000 * 80.0 / 60; + private double scaleFactor = 128; + private double fixedGain = -1; + private boolean constantTriggerWindow = false; + + public FADCEcalReadoutDriver() { + flags = 0; + flags += 1 << LCIOConstants.RCHBIT_TIME; //store cell ID + hitClass = HPSRawCalorimeterHit.class; +// converter = new HPSEcalConverter(null); + } + + public void setConstantTriggerWindow(boolean constantTriggerWindow) { + this.constantTriggerWindow = constantTriggerWindow; + } + + public void setFixedGain(double fixedGain) { + this.fixedGain = fixedGain; + } + + public void setEcalName(String ecalName) { + this.ecalName = ecalName; + } + + public void setReadoutThreshold(int readoutThreshold) { + this.readoutThreshold = readoutThreshold; + } + + public void setScaleFactor(double scaleFactor) { + this.scaleFactor = scaleFactor; + } + + public void setTriggerThreshold(int triggerThreshold) { + this.triggerThreshold = triggerThreshold; + } + + public void setEcalReadoutCollectionName(String ecalReadoutCollectionName) { + this.ecalReadoutCollectionName = ecalReadoutCollectionName; + } + + public void setNumSamplesAfter(int numSamplesAfter) { + this.numSamplesAfter = numSamplesAfter; + } + + public void setNumSamplesBefore(int numSamplesBefore) { + this.numSamplesBefore = numSamplesBefore; + } + + public void setReadoutLatency(int readoutLatency) { + this.readoutLatency = readoutLatency; + } + + public void setReadoutWindow(int readoutWindow) { + this.readoutWindow = readoutWindow; + } + + public void setCoincidenceWindow(int coincidenceWindow) { + this.coincidenceWindow = coincidenceWindow; + } + + public void setTp(double tp) { + this.tp = tp; + } + + public void setDelay0(int delay0) { + this.delay0 = delay0; + } + + public void setBufferLength(int bufferLength) { + this.bufferLength = bufferLength; + resetFADCBuffers(); + } + + public void setPipelineLength(int pipelineLength) { + this.pipelineLength = pipelineLength; + resetFADCBuffers(); + } + + public void setMode(int mode) { + this.mode = mode; + if (mode != EventConstants.ECAL_WINDOW_MODE && mode != EventConstants.ECAL_PULSE_MODE && mode != EventConstants.ECAL_PULSE_INTEGRAL_MODE) { + throw new IllegalArgumentException("invalid mode " + mode); + } + } + + @Override + protected void readHits(List<RawCalorimeterHit> hits) { + + for (Long cellID : eDepMap.keySet()) { + RingBuffer eDepBuffer = eDepMap.get(cellID); + + FADCPipeline pipeline = pipelineMap.get(cellID); + pipeline.step(); + double pedestal = EcalConditions.physicalToPedestal(cellID); + //normalization constant from cal gain (MeV/integral bit) to amplitude gain (amplitude bit/GeV) + double gain; + if (fixedGain > 0) { + gain = 1.0 / (fixedGain * ECalUtils.MeV * pulseIntegral); + } else { + gain = 1.0 / (EcalConditions.physicalToGain(cellID) * ECalUtils.MeV * pulseIntegral); + } + + double currentValue = gain * eDepBuffer.currentValue(); + pipeline.writeValue((int) Math.round(pedestal + currentValue)); + + Double sum = sumMap.get(cellID); + if (sum == null && currentValue > triggerThreshold) { + timeMap.put(cellID, readoutCounter); + if (constantTriggerWindow) { + double sumBefore = 0; + for (int i = 0; i < numSamplesBefore; i++) { + if (debug) { + System.out.format("trigger %d, %d: %d\n", cellID, i, pipeline.getValue(numSamplesBefore - i - 1)); + } + sumBefore += pipeline.getValue(numSamplesBefore - i - 1); + } + sumMap.put(cellID, sumBefore); + } else { + sumMap.put(cellID, currentValue); + } + } + if (sum != null) { + if (constantTriggerWindow) { + if (timeMap.get(cellID) + numSamplesAfter >= readoutCounter) { + if (debug) { + System.out.format("trigger %d, %d: %d\n", cellID, readoutCounter - timeMap.get(cellID) + numSamplesBefore - 1, pipeline.getValue(0)); + } + sumMap.put(cellID, sum + pipeline.getValue(0)); + } else if (timeMap.get(cellID) + delay0 <= readoutCounter) { +// System.out.printf("sum = %f\n", sum); + outputQueue.add(new HPSRawCalorimeterHit(cellID, + (int) Math.round(sum / scaleFactor), + 64 * timeMap.get(cellID), + readoutCounter - timeMap.get(cellID) + 1)); + sumMap.remove(cellID); + } + } else { + if (currentValue < triggerThreshold || timeMap.get(cellID) + delay0 == readoutCounter) { +// System.out.printf("sum = %f\n",sum); + outputQueue.add(new HPSRawCalorimeterHit(cellID, + (int) Math.round((sum + currentValue) / scaleFactor), + 64 * timeMap.get(cellID), + readoutCounter - timeMap.get(cellID) + 1)); + sumMap.remove(cellID); + } else { + sumMap.put(cellID, sum + currentValue); + } + } + } + eDepBuffer.step(); + } + while (outputQueue.peek() != null && outputQueue.peek().getTimeStamp() / 64 <= readoutCounter - delay0) { + if (outputQueue.peek().getTimeStamp() / 64 < readoutCounter - delay0) { + System.out.println("Stale hit in output queue"); + outputQueue.poll(); + } else { + buffer.add(outputQueue.poll()); + } + } + while (!buffer.isEmpty() && buffer.peek().getTimeStamp() / 64 <= readoutCounter - delay0 - coincidenceWindow) { + buffer.remove(); + } + if (debug) { + for (RawCalorimeterHit hit : buffer) { + System.out.format("new hit: energy %d\n", hit.getAmplitude()); + } + } + + hits.addAll(buffer); + } + + @Override + public void startOfData() { + super.startOfData(); + if (ecalReadoutCollectionName == null) { + throw new RuntimeException("The parameter ecalReadoutCollectionName was not set!"); + } + } + + @Override + protected void processTrigger(EventHeader event) { + switch (mode) { + case EventConstants.ECAL_WINDOW_MODE: + if (debug) { + System.out.println("Reading out ECal in window mode"); + } + event.put(ecalReadoutCollectionName, readWindow(), RawTrackerHit.class, 0, ecalReadoutName); + break; + case EventConstants.ECAL_PULSE_MODE: + if (debug) { + System.out.println("Reading out ECal in pulse mode"); + } + event.put(ecalReadoutCollectionName, readPulses(), RawTrackerHit.class, 0, ecalReadoutName); + break; + case EventConstants.ECAL_PULSE_INTEGRAL_MODE: + if (debug) { + System.out.println("Reading out ECal in integral mode"); + } + event.put(ecalReadoutCollectionName, readIntegrals(), RawCalorimeterHit.class, 0, ecalReadoutName); + break; + } + } + + protected short[] getWindow(long cellID) { + FADCPipeline pipeline = pipelineMap.get(cellID); + short[] adcValues = new short[readoutWindow]; + for (int i = 0; i < readoutWindow; i++) { + adcValues[i] = (short) pipeline.getValue(readoutLatency - i - 1); +// if (adcValues[i] != 0) { +// System.out.println("getWindow: " + adcValues[i] + " at i = " + i); +// } + } + return adcValues; + } + + protected List<RawTrackerHit> readWindow() { +// System.out.println("Reading FADC data"); + List<RawTrackerHit> hits = new ArrayList<RawTrackerHit>(); + for (Long cellID : pipelineMap.keySet()) { + short[] adcValues = getWindow(cellID); + hits.add(new BaseRawTrackerHit(cellID, 0, adcValues)); + } + return hits; + } + + protected List<RawTrackerHit> readPulses() { +// System.out.println("Reading FADC data"); + List<RawTrackerHit> hits = new ArrayList<RawTrackerHit>(); + for (Long cellID : pipelineMap.keySet()) { + short[] window = getWindow(cellID); + short[] adcValues = null; + int pointerOffset = 0; + int numSamplesToRead = 0; + int thresholdCrossing = 0; + for (int i = 0; i < readoutWindow; i++) { + if (numSamplesToRead != 0) { + adcValues[adcValues.length - numSamplesToRead] = window[i - pointerOffset]; + numSamplesToRead--; + if (numSamplesToRead == 0) { + hits.add(new BaseRawTrackerHit(cellID, thresholdCrossing, adcValues)); + } + } else if ((i == 0 || window[i - 1] <= EcalConditions.physicalToPedestal(cellID) + readoutThreshold) && window[i] > EcalConditions.physicalToPedestal(cellID) + readoutThreshold) { + thresholdCrossing = i; + pointerOffset = Math.min(numSamplesBefore, i); + numSamplesToRead = pointerOffset + Math.min(numSamplesAfter, readoutWindow - i - pointerOffset - 1); + adcValues = new short[numSamplesToRead]; + } + } + } + return hits; + } + + protected List<RawCalorimeterHit> readIntegrals() { +// System.out.println("Reading FADC data"); + List<RawCalorimeterHit> hits = new ArrayList<RawCalorimeterHit>(); + for (Long cellID : pipelineMap.keySet()) { + short[] window = getWindow(cellID); + int adcSum = 0; + int pointerOffset = 0; + int numSamplesToRead = 0; + int thresholdCrossing = 0; + if (window != null) { + for (int i = 0; i < readoutWindow; i++) { + if (numSamplesToRead != 0) { + if (debug) { + System.out.format("readout %d, %d: %d\n", cellID, numSamplesBefore + numSamplesAfter - numSamplesToRead, window[i - pointerOffset]); + } + adcSum += window[i - pointerOffset]; + numSamplesToRead--; + if (numSamplesToRead == 0) { + hits.add(new BaseRawCalorimeterHit(cellID, adcSum, 64 * thresholdCrossing)); + } + } else if ((i == 0 || window[i - 1] <= EcalConditions.physicalToPedestal(cellID) + readoutThreshold) && window[i] > EcalConditions.physicalToPedestal(cellID) + readoutThreshold) { + thresholdCrossing = i; + pointerOffset = Math.min(numSamplesBefore, i); + numSamplesToRead = pointerOffset + Math.min(numSamplesAfter, readoutWindow - i - pointerOffset - 1); + adcSum = 0; + } + } + } + } + return hits; + } + + @Override + protected void putHits(List<CalorimeterHit> hits) { + //fill the readout buffers + for (CalorimeterHit hit : hits) { + RingBuffer eDepBuffer = eDepMap.get(hit.getCellID()); + for (int i = 0; i < bufferLength; i++) { + eDepBuffer.addToCell(i, hit.getRawEnergy() * pulseAmplitude((i + 1) * readoutPeriod + readoutTime() - (ClockSingleton.getTime() + hit.getTime()))); + } + } + } + + @Override + protected void initReadout() { + //initialize buffers + sumMap = new HashMap<Long, Double>(); + timeMap = new HashMap<Long, Integer>(); + outputQueue = new PriorityQueue(20, new HPSRawCalorimeterHit.TimeComparator()); + pulseIntegral = tp * Math.E / readoutPeriod; + resetFADCBuffers(); + } + + @Override + public void detectorChanged(Detector detector) { + // Get the Subdetector. + ecal = detector.getSubdetector(ecalName); + resetFADCBuffers(); + } + + private boolean resetFADCBuffers() { + if (ecal == null) { + return false; + } + eDepMap = new HashMap<Long, RingBuffer>(); + pipelineMap = new HashMap<Long, FADCPipeline>(); + Set<Long> cells = ((HPSEcal3) ecal).getNeighborMap().keySet(); + for (Long cellID : cells) { + eDepMap.put(cellID, new RingBuffer(bufferLength)); + pipelineMap.put(cellID, new FADCPipeline(pipelineLength, (int) Math.round(EcalConditions.physicalToPedestal(cellID)))); + } + return true; + } + + private double pulseAmplitude(double time) { + if (time <= 0.0) { + return 0.0; + } + if (tp > 0.0) { + return (time / tp) * Math.exp(1.0 - time / tp); + } else { + if (time < -tp) { + return 1.0; + } else { + return 0.0; + } + } + } + + private class FADCPipeline { + + private int[] array; + private int size; + private int ptr; + + public FADCPipeline(int size) { + this.size = size; + array = new int[size]; //initialized to 0 + ptr = 0; + } + + //construct pipeline with a nonzero initial value + public FADCPipeline(int size, int init) { + this.size = size; + array = new int[size]; + for (int i = 0; i < size; i++) { + array[i] = init; + } + ptr = 0; + } + + /** + * Write value to current cell + */ + public void writeValue(int val) { + array[ptr] = val; + } + + /** + * Write value to current cell + */ + public void step() { + ptr++; + if (ptr == size) { + ptr = 0; + } + } + + //return content of specified cell (pos=0 for current cell) + public int getValue(int pos) { + if (pos >= size || pos < 0) { + throw new ArrayIndexOutOfBoundsException(); + } + return array[((ptr - pos) % size + size) % size]; + } + } +}
\ No newline at end of file
diff -N SimpleEcalReadoutDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ SimpleEcalReadoutDriver.java 25 Feb 2013 22:39:26 -0000 1.1 @@ -0,0 +1,59 @@
+package org.lcsim.hps.readout.ecal; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.lcsim.event.CalorimeterHit; +import org.lcsim.hps.recon.ecal.HPSCalorimeterHit; + +/** + * Performs readout of ECal hits. + * No time evolution - this just integrates all hits in a cycle. + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: SimpleEcalReadoutDriver.java,v 1.1 2013/02/25 22:39:26 meeg Exp $ + */ +public class SimpleEcalReadoutDriver extends EcalReadoutDriver<HPSCalorimeterHit> { + //buffer for deposited energy + Map<Long, Double> eDepMap = null; + + public SimpleEcalReadoutDriver() { + hitClass = HPSCalorimeterHit.class; + } + + @Override + protected void readHits(List<HPSCalorimeterHit> hits) { + for (Long cellID : eDepMap.keySet()) { +// int ix = dec.getValue("ix"); +// int iy = dec.getValue("iy"); +// //temporary hack to disable crystals and flip X coordinate +// int side = dec.getValue("side"); +// if (iy == 1 && ix*side >= -10 && ix*side <= -2) +// continue; + if (eDepMap.get(cellID) > threshold) + hits.add(new HPSCalorimeterHit(eDepMap.get(cellID), readoutTime(), cellID, hitType)); + } + //reset hit integration + eDepMap = new HashMap<Long, Double>(); + } + + @Override + protected void putHits(List<CalorimeterHit> hits) { + //fill the readout buffers + for (CalorimeterHit hit : hits) { + Double eDep = eDepMap.get(hit.getCellID()); + if (eDep == null) { + eDepMap.put(hit.getCellID(), hit.getRawEnergy()); + } else { + eDepMap.put(hit.getCellID(), eDep + hit.getRawEnergy()); + } + } + } + + @Override + protected void initReadout() { + //initialize buffers + eDepMap = new HashMap<Long, Double>(); + } +}
diff -N EcalReadoutDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ EcalReadoutDriver.java 25 Feb 2013 22:39:26 -0000 1.1 @@ -0,0 +1,152 @@
+package org.lcsim.hps.readout.ecal; + +import java.util.ArrayList; +import java.util.List; + +import org.lcsim.event.CalorimeterHit; +import org.lcsim.event.EventHeader; +import org.lcsim.hps.util.ClockSingleton; +import org.lcsim.util.Driver; +import org.lcsim.util.lcio.LCIOConstants; + +/** + * Performs readout of ECal hits. + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: EcalReadoutDriver.java,v 1.1 2013/02/25 22:39:26 meeg Exp $ + */ +public abstract class EcalReadoutDriver<T> extends Driver { + + String ecalCollectionName; + String ecalRawCollectionName = "EcalRawHits"; + String ecalReadoutName = "EcalHits"; + Class hitClass; + //hit type as in org.lcsim.recon.calorimetry.CalorimeterHitType + int hitType = 0; + //number of bunches in readout cycle + int readoutCycle = 1; + //minimum readout value to write a hit + double threshold = 0.0; + //LCIO flags + int flags = 0; + //readout period in ns + double readoutPeriod = 2.0; + //readout period time offset in ns + double readoutOffset = 0.0; + //readout period counter + int readoutCounter; + public static boolean readoutBit = false; + protected boolean debug = false; + + public EcalReadoutDriver() { + flags += 1 << LCIOConstants.CHBIT_LONG; //store position + flags += 1 << LCIOConstants.RCHBIT_ID1; //store cell ID + + } + + public void setDebug(boolean debug) { + this.debug = debug; + } + + public void setEcalReadoutName(String ecalReadoutName) { + this.ecalReadoutName = ecalReadoutName; + } + + public void setEcalRawCollectionName(String ecalRawCollectionName) { + this.ecalRawCollectionName = ecalRawCollectionName; + } + + public void setEcalCollectionName(String ecalCollectionName) { + this.ecalCollectionName = ecalCollectionName; + } + + public void setReadoutCycle(int readoutCycle) { + this.readoutCycle = readoutCycle; + if (readoutCycle > 0) { + this.readoutPeriod = readoutCycle * ClockSingleton.getDt(); + } + } + + public void setReadoutOffset(double readoutOffset) { + this.readoutOffset = readoutOffset; + } + + public void setReadoutPeriod(double readoutPeriod) { + this.readoutPeriod = readoutPeriod; + this.readoutCycle = -1; + } + + public void setThreshold(double threshold) { + this.threshold = threshold; + } + + @Override + public void startOfData() { + if (ecalCollectionName == null) { + throw new RuntimeException("The parameter ecalCollectionName was not set!"); + } + + readoutCounter = 0; + + initReadout(); + } + + @Override + public void process(EventHeader event) { + //System.out.println(this.getClass().getCanonicalName() + " - process"); + // Get the list of ECal hits. + if (event.hasCollection(CalorimeterHit.class, ecalCollectionName)) { + List<CalorimeterHit> hits = event.get(CalorimeterHit.class, ecalCollectionName); + + //write hits into buffers + putHits(hits); + } + + ArrayList<T> newHits = null; + + //if at the end of a readout cycle, write buffers to hits + if (readoutCycle > 0) { + if ((ClockSingleton.getClock() + 1) % readoutCycle == 0) { + if (newHits == null) { + newHits = new ArrayList<T>(); + } + readHits(newHits); + readoutCounter++; + } + } else { + while (ClockSingleton.getTime() - readoutTime() + ClockSingleton.getDt() >= readoutPeriod) { + if (newHits == null) { + newHits = new ArrayList<T>(); + } + readHits(newHits); + readoutCounter++; + } + } + + if (newHits != null) { + event.put(ecalRawCollectionName, newHits, hitClass, flags, ecalReadoutName); + } + + if (readoutBit) { + processTrigger(event); + readoutBit = false; + } + } + + protected double readoutTime() { + return readoutCounter * readoutPeriod + readoutOffset; + } + + //read analog signal out of buffers and make hits; reset buffers + protected abstract void readHits(List<T> hits); + + //add deposited energy to buffers + //must be run every event, even if the list is empty + protected abstract void putHits(List<CalorimeterHit> hits); + + protected void processTrigger(EventHeader event) { + } + + //initialize buffers + protected abstract void initReadout(); +}
\ No newline at end of file
diff -N DummyTriggerDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ DummyTriggerDriver.java 25 Feb 2013 22:39:26 -0000 1.1 @@ -0,0 +1,31 @@
+package org.lcsim.hps.readout.ecal; + +import java.util.List; +import org.lcsim.event.EventHeader; +import org.lcsim.hps.recon.ecal.HPSEcalCluster; +import org.lcsim.hps.util.ClockSingleton; + +/** + * Free-running trigger - triggers on every Nth event + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: DummyTriggerDriver.java,v 1.1 2013/02/25 22:39:26 meeg Exp $ + */ +public class DummyTriggerDriver extends TriggerDriver { + + int period = 100; + + public void setPeriod(int period) { + this.period = period; + } + + @Override + public boolean triggerDecision(EventHeader event) { + return (ClockSingleton.getClock() % period == 0); + } + + @Override + public boolean testTrigger(List<HPSEcalCluster> clusters) { + return false; + } +}
diff -N CalibrationDriver.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ CalibrationDriver.java 25 Feb 2013 22:39:26 -0000 1.1 @@ -0,0 +1,105 @@
+package org.lcsim.hps.monitoring; + +import org.lcsim.conditions.ConditionsEvent; +import org.lcsim.conditions.ConditionsListener; +import org.lcsim.conditions.ConditionsManager; +import org.lcsim.conditions.ConditionsSet; +import org.lcsim.event.EventHeader; +import org.lcsim.geometry.Detector; +import org.lcsim.hps.recon.ecal.EcalConditions; +import org.lcsim.hps.recon.tracking.FieldMap; +import org.lcsim.hps.recon.tracking.HPSSVTCalibrationConstants; +import org.lcsim.hps.recon.tracking.HPSSVTSensorSetup; +import org.lcsim.util.Driver; + +/** + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: CalibrationDriver.java,v 1.1 2013/02/25 22:39:26 meeg Exp $ + */ +public class CalibrationDriver extends Driver implements ConditionsListener { + + // The test run number of interest. If it equals -1, the default calibrations + // are loaded + private static int runNumber = -1; + private boolean fixRunNumber = false; + + public CalibrationDriver() { + add(new EcalConditions()); + add(new HPSSVTSensorSetup()); + } + + public void setRunNumber(int runNumber) { + CalibrationDriver.runNumber = runNumber; + fixRunNumber = true; + } + + public static int runNumber() { + return runNumber; + } + + @Override + protected void process(EventHeader event) { + super.process(event); + if (!fixRunNumber && runNumber != event.getRunNumber()) { + runNumber = event.getRunNumber(); + } + } + + @Override + protected void detectorChanged(Detector detector) { + super.detectorChanged(detector); + + if (!EcalConditions.calibrationLoaded()) { + EcalConditions.loadCalibration(); + } + if (fixRunNumber && (!HPSSVTCalibrationConstants.pedestalLoaded() || !HPSSVTCalibrationConstants.tpLoaded())) { + System.out.println("Loading calibration for set run: " + runNumber); + loadCalibsByRun(runNumber); + } + } + + @Override + protected void startOfData() { + ConditionsManager.defaultInstance().addConditionsListener(this); + } + + @Override + public void conditionsChanged(ConditionsEvent ce) { + if (!fixRunNumber) { + System.out.println("Got ConditionsEvent with run: " + ce.getConditionsManager().getRun()); + runNumber = ce.getConditionsManager().getRun(); + loadCalibsByRun(runNumber); + } + } + + private void loadCalibsByRun(int run) { + HPSSVTCalibrationConstants.loadCalibration(run); + FieldMap.loadFieldMap(run); + } + + /** + * get specified conditions list, parse as a map of run numbers to calibration file paths; get the appropriate file + * @param calibName + * @param run + * @return + */ + public static String getCalibForRun(String calibName, int run) { + System.out.println("Reading calibrations " + calibName + " for run: " + run); + + ConditionsSet calibSet = ConditionsManager.defaultInstance().getConditions(calibName); + + int mostRecentValid = Integer.MIN_VALUE; + String filePath = null; + for (Object key : calibSet.keySet()) { + int keyRun = Integer.parseInt((String) key); +// System.out.println("Available calibration for run: " + keyRun); + if (keyRun > mostRecentValid && keyRun <= run) { + mostRecentValid = keyRun; + filePath = calibSet.getString((String) key); + } + } + System.out.println("Use this calibration from run " + mostRecentValid + ": " + filePath); + return filePath; + } +}
diff -N HPSCalibrationDriver.java --- HPSCalibrationDriver.java 21 Sep 2012 23:22:18 -0000 1.8 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,105 +0,0 @@
-package org.lcsim.hps.monitoring; - -import org.lcsim.conditions.ConditionsEvent; -import org.lcsim.conditions.ConditionsListener; -import org.lcsim.conditions.ConditionsManager; -import org.lcsim.conditions.ConditionsSet; -import org.lcsim.event.EventHeader; -import org.lcsim.geometry.Detector; -import org.lcsim.hps.recon.ecal.HPSEcalConditions; -import org.lcsim.hps.recon.tracking.FieldMap; -import org.lcsim.hps.recon.tracking.HPSSVTCalibrationConstants; -import org.lcsim.hps.recon.tracking.HPSSVTSensorSetup; -import org.lcsim.util.Driver; - -/** - * - * @author Sho Uemura <[log in to unmask]> - * @version $Id: HPSCalibrationDriver.java,v 1.8 2012/09/21 23:22:18 meeg Exp $ - */ -public class HPSCalibrationDriver extends Driver implements ConditionsListener { - - // The test run number of interest. If it equals -1, the default calibrations - // are loaded - private static int runNumber = -1; - private boolean fixRunNumber = false; - - public HPSCalibrationDriver() { - add(new HPSEcalConditions()); - add(new HPSSVTSensorSetup()); - } - - public void setRunNumber(int runNumber) { - HPSCalibrationDriver.runNumber = runNumber; - fixRunNumber = true; - } - - public static int runNumber() { - return runNumber; - } - - @Override - protected void process(EventHeader event) { - super.process(event); - if (!fixRunNumber && runNumber != event.getRunNumber()) { - runNumber = event.getRunNumber(); - } - } - - @Override - protected void detectorChanged(Detector detector) { - super.detectorChanged(detector); - - if (!HPSEcalConditions.calibrationLoaded()) { - HPSEcalConditions.loadCalibration(); - } - if (fixRunNumber && (!HPSSVTCalibrationConstants.pedestalLoaded() || !HPSSVTCalibrationConstants.tpLoaded())) { - System.out.println("Loading calibration for set run: " + runNumber); - loadCalibsByRun(runNumber); - } - } - - @Override - protected void startOfData() { - ConditionsManager.defaultInstance().addConditionsListener(this); - } - - @Override - public void conditionsChanged(ConditionsEvent ce) { - if (!fixRunNumber) { - System.out.println("Got ConditionsEvent with run: " + ce.getConditionsManager().getRun()); - runNumber = ce.getConditionsManager().getRun(); - loadCalibsByRun(runNumber); - } - } - - private void loadCalibsByRun(int run) { - HPSSVTCalibrationConstants.loadCalibration(run); - FieldMap.loadFieldMap(run); - } - - /** - * get specified conditions list, parse as a map of run numbers to calibration file paths; get the appropriate file - * @param calibName - * @param run - * @return - */ - public static String getCalibForRun(String calibName, int run) { - System.out.println("Reading calibrations " + calibName + " for run: " + run); - - ConditionsSet calibSet = ConditionsManager.defaultInstance().getConditions(calibName); - - int mostRecentValid = Integer.MIN_VALUE; - String filePath = null; - for (Object key : calibSet.keySet()) { - int keyRun = Integer.parseInt((String) key); -// System.out.println("Available calibration for run: " + keyRun); - if (keyRun > mostRecentValid && keyRun <= run) { - mostRecentValid = keyRun; - filePath = calibSet.getString((String) key); - } - } - System.out.println("Use this calibration from run " + mostRecentValid + ": " + filePath); - return filePath; - } -}
diff -u -r1.7 -r1.8 --- MultScatAnalysis.java 9 Sep 2012 02:50:00 -0000 1.7 +++ MultScatAnalysis.java 25 Feb 2013 22:39:26 -0000 1.8 @@ -23,7 +23,7 @@
import org.lcsim.hps.evio.TriggerData; import org.lcsim.hps.monitoring.AIDAFrame; import org.lcsim.hps.recon.ecal.HPSEcalCluster;
-import org.lcsim.hps.recon.ecal.HPSEcalConditions;
+import org.lcsim.hps.recon.ecal.EcalConditions;
import org.lcsim.hps.recon.tracking.EcalTrackMatch; import org.lcsim.hps.recon.tracking.SvtTrackExtrapolator; import org.lcsim.util.Driver;
@@ -2149,9 +2149,9 @@
private boolean hasBadNeighbours(HPSEcalCluster cluster) { //check if this cluster has a neighbour that is dead or bad
- if(!HPSEcalConditions.badChannelsLoaded()) return false;
+ if(!EcalConditions.badChannelsLoaded()) return false;
List<CalorimeterHit> hits = cluster.getCalorimeterHits();
- IIdentifierHelper helper = HPSEcalConditions.getHelper();
+ IIdentifierHelper helper = EcalConditions.getHelper();
IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields()); expId.setValue(helper.getFieldIndex("system"), ecal.getSystemID());
@@ -2162,7 +2162,7 @@
for(CalorimeterHit hit : hits) { IIdentifier compactId = hit.getIdentifier(); //x-check
- if(HPSEcalConditions.isBadChannel(hit.getCellID())) {
+ if(EcalConditions.isBadChannel(hit.getCellID())) {
System.out.println("This cluster has a bad channel hit included!? "); int x = helper.getValue(compactId, "ix"); int y = helper.getValue(compactId, "iy");
@@ -2182,7 +2182,7 @@
expId.setValue(helper.getFieldIndex("iy"), iy); IIdentifier compactId_t = helper.pack(expId); System.out.println("Check" + ix + "," + iy + " id " + compactId_t.getValue());
- if(HPSEcalConditions.isBadChannel(compactId_t.getValue())) {
+ if(EcalConditions.isBadChannel(compactId_t.getValue())) {
System.out.println("This cell was BAD!"); return true; }
diff -u -r1.5 -r1.6 --- TrigRateDriver.java 1 Oct 2012 21:26:31 -0000 1.5 +++ TrigRateDriver.java 25 Feb 2013 22:39:26 -0000 1.6 @@ -23,7 +23,7 @@
import org.lcsim.geometry.Subdetector; import org.lcsim.hps.monitoring.AIDAFrame; import org.lcsim.hps.recon.ecal.HPSEcalCluster;
-import org.lcsim.hps.recon.ecal.HPSEcalConditions;
+import org.lcsim.hps.recon.ecal.EcalConditions;
import org.lcsim.hps.recon.tracking.EcalTrackMatch; import org.lcsim.util.Driver; import org.lcsim.util.aida.AIDA;
@@ -380,9 +380,9 @@
private boolean hasBadNeighbours(HPSEcalCluster cluster) { //check if this cluster has a neighbour that is dead or bad
- if(!HPSEcalConditions.badChannelsLoaded()) return false;
+ if(!EcalConditions.badChannelsLoaded()) return false;
List<CalorimeterHit> hits = cluster.getCalorimeterHits();
- IIdentifierHelper helper = HPSEcalConditions.getHelper();
+ IIdentifierHelper helper = EcalConditions.getHelper();
IExpandedIdentifier expId = new ExpandedIdentifier(helper.getIdentifierDictionary().getNumberOfFields()); expId.setValue(helper.getFieldIndex("system"), ecal.getSystemID());
@@ -393,7 +393,7 @@
for(CalorimeterHit hit : hits) { IIdentifier compactId = hit.getIdentifier(); //x-check
- if(HPSEcalConditions.isBadChannel(hit.getCellID())) {
+ if(EcalConditions.isBadChannel(hit.getCellID())) {
System.out.println("This cluster has a bad channel hit included!? "); int x = helper.getValue(compactId, "ix"); int y = helper.getValue(compactId, "iy");
@@ -413,7 +413,7 @@
expId.setValue(helper.getFieldIndex("iy"), iy); IIdentifier compactId_t = helper.pack(expId); System.out.println("Check" + ix + "," + iy + " id " + compactId_t.getValue());
- if(HPSEcalConditions.isBadChannel(compactId_t.getValue())) {
+ if(EcalConditions.isBadChannel(compactId_t.getValue())) {
System.out.println("This cell was BAD!"); return true; }
diff -u -r1.9 -r1.10 --- ecalGainAna.java 20 Nov 2012 20:00:36 -0000 1.9 +++ ecalGainAna.java 25 Feb 2013 22:39:26 -0000 1.10 @@ -7,8 +7,8 @@
import java.util.logging.Logger; import org.apache.commons.cli.*; import org.lcsim.geometry.util.DetectorLocator;
-import org.lcsim.hps.recon.ecal.HPSECalUtils; -import org.lcsim.hps.recon.ecal.HPSEcalConditions;
+import org.lcsim.hps.recon.ecal.ECalUtils; +import org.lcsim.hps.recon.ecal.EcalConditions;
/** *
@@ -134,8 +134,8 @@
detectorName = cmd.getOptionValue("d"); }
- HPSEcalConditions.detectorChanged(DetectorLocator.findDetector(detectorName), "Ecal"); - HPSEcalConditions.loadCalibration();
+ EcalConditions.detectorChanged(DetectorLocator.findDetector(detectorName), "Ecal"); + EcalConditions.loadCalibration();
IHistogramFactory hf = af.createHistogramFactory(null);
@@ -244,12 +244,12 @@
} for (int x = -23; x <= 23; x++) { for (int y = -5; y <= 5; y++) {
- pePlotsHVSim[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1].add(pePlotsSim[x + 23][y + 5][0]); - pePlotsHVReal[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1].add(pePlotsReal[x + 23][y + 5][0]); - weightsHVSim[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1] += weightPlotSim.binHeight(x + 23, y + 5); - sumsHVSim[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1] += sumPlotSim.binHeight(x + 23, y + 5); - weightsHVReal[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1] += weightPlotReal.binHeight(x + 23, y + 5); - sumsHVReal[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1] += sumPlotReal.binHeight(x + 23, y + 5);
+ pePlotsHVSim[ECalUtils.getQuadrant(x, y) - 1][ECalUtils.getHVGroup(x, y) - 1].add(pePlotsSim[x + 23][y + 5][0]); + pePlotsHVReal[ECalUtils.getQuadrant(x, y) - 1][ECalUtils.getHVGroup(x, y) - 1].add(pePlotsReal[x + 23][y + 5][0]); + weightsHVSim[ECalUtils.getQuadrant(x, y) - 1][ECalUtils.getHVGroup(x, y) - 1] += weightPlotSim.binHeight(x + 23, y + 5); + sumsHVSim[ECalUtils.getQuadrant(x, y) - 1][ECalUtils.getHVGroup(x, y) - 1] += sumPlotSim.binHeight(x + 23, y + 5); + weightsHVReal[ECalUtils.getQuadrant(x, y) - 1][ECalUtils.getHVGroup(x, y) - 1] += weightPlotReal.binHeight(x + 23, y + 5); + sumsHVReal[ECalUtils.getQuadrant(x, y) - 1][ECalUtils.getHVGroup(x, y) - 1] += sumPlotReal.binHeight(x + 23, y + 5);
allWeightsReal += weightPlotReal.binHeight(x + 23, y + 5); allWeightsSim += weightPlotSim.binHeight(x + 23, y + 5); }
@@ -257,7 +257,7 @@
for (int x = -23; x <= 23; x++) { for (int y = -5; y <= 5; y++) {
- Double gain = HPSEcalConditions.physicalToGain(HPSEcalConditions.makePhysicalID(x, y));
+ Double gain = EcalConditions.physicalToGain(EcalConditions.makePhysicalID(x, y));
if (gain != null) { ecalPlot.fill(x, y, gain); // gainsPlot.fill(x, y, HPSECalUtils.getHVGroup(x, y));
@@ -317,15 +317,15 @@
for (int x = -23; x <= 23; x++) { for (int iy = 1; iy <= 5; iy++) { int y = side == 0 ? iy : -iy;
- Double gain = HPSEcalConditions.physicalToGain(HPSEcalConditions.makePhysicalID(x, y));
+ Double gain = EcalConditions.physicalToGain(EcalConditions.makePhysicalID(x, y));
IHistogram1D peSim = pePlotsSim[x + 23][y + 5][0]; IHistogram1D peReal = pePlotsReal[x + 23][y + 5][0];
- IHistogram1D peHVSim = pePlotsHVSim[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1]; - IHistogram1D peHVReal = pePlotsHVReal[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1]; - double weightHVReal = weightsHVReal[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1]; - double sumHVReal = sumsHVReal[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1]; - double weightHVSim = weightsHVSim[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1]; - double sumHVSim = sumsHVSim[HPSECalUtils.getQuadrant(x, y) - 1][HPSECalUtils.getHVGroup(x, y) - 1];
+ IHistogram1D peHVSim = pePlotsHVSim[ECalUtils.getQuadrant(x, y) - 1][ECalUtils.getHVGroup(x, y) - 1]; + IHistogram1D peHVReal = pePlotsHVReal[ECalUtils.getQuadrant(x, y) - 1][ECalUtils.getHVGroup(x, y) - 1]; + double weightHVReal = weightsHVReal[ECalUtils.getQuadrant(x, y) - 1][ECalUtils.getHVGroup(x, y) - 1]; + double sumHVReal = sumsHVReal[ECalUtils.getQuadrant(x, y) - 1][ECalUtils.getHVGroup(x, y) - 1]; + double weightHVSim = weightsHVSim[ECalUtils.getQuadrant(x, y) - 1][ECalUtils.getHVGroup(x, y) - 1]; + double sumHVSim = sumsHVSim[ECalUtils.getQuadrant(x, y) - 1][ECalUtils.getHVGroup(x, y) - 1];
if (gain != null) { if (weightPlotSim.binHeight(x + 23, y + 5) > minCount && weightPlotReal.binHeight(x + 23, y + 5) > minCount) { gain *= (corrPlotSim.binHeight(x + 23, y + 5) / corrPlotReal.binHeight(x + 23, y + 5));
diff -u -r1.11 -r1.12 --- ECalGainDriver.java 8 Sep 2012 00:17:53 -0000 1.11 +++ ECalGainDriver.java 25 Feb 2013 22:39:26 -0000 1.12 @@ -429,7 +429,7 @@
gainWriter.print(event.getEventNumber() + " " + P + " " + E + " " + pos[0] + " " + pos[1]); for (CalorimeterHit hit : bestCl.getCalorimeterHits()) {
- gainWriter.print(" " + hit.getIdentifierFieldValue("ix") + " " + hit.getIdentifierFieldValue("iy") + " " + hit.getRawEnergy() + " " + HPSEcalConditions.physicalToGain(hit.getCellID()));
+ gainWriter.print(" " + hit.getIdentifierFieldValue("ix") + " " + hit.getIdentifierFieldValue("iy") + " " + hit.getRawEnergy() + " " + EcalConditions.physicalToGain(hit.getCellID()));
} gainWriter.println(""); }
@@ -458,7 +458,7 @@
//displayFastTrackingPlots(); for (int x = -23; x <= 23; x++) { // slot for (int y = -5; y <= 5; y++) { // crate
- if (HPSEcalConditions.physicalToGain(HPSEcalConditions.makePhysicalID(x, y)) != null) {
+ if (EcalConditions.physicalToGain(EcalConditions.makePhysicalID(x, y)) != null) {
System.out.printf("%d\t%d\t%d\t%f\t%f\n", x, y, pePlots[x + 23][y + 5][0].allEntries(), pePlots[x + 23][y + 5][0].mean(), pePlots[x + 23][y + 5][0].rms()); } }
diff -N TestRunRateAnalysis.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ TestRunRateAnalysis.java 25 Feb 2013 22:39:26 -0000 1.1 @@ -0,0 +1,170 @@
+package org.lcsim.hps.analysis.ecal; + +import hep.aida.IHistogram1D; +import hep.aida.IHistogram2D; +import java.util.List; +import org.lcsim.event.CalorimeterHit; +import org.lcsim.event.EventHeader; +import org.lcsim.event.MCParticle; +import org.lcsim.event.util.ParticleTypeClassifier; +import org.lcsim.hps.recon.ecal.HPSEcalCluster; +import org.lcsim.util.Driver; +import org.lcsim.util.aida.AIDA; + +/** + * Reads clusters and makes trigger decision using opposite quadrant criterion. + * Prints triggers to file if file path specified. + * + * @author Sho Uemura <[log in to unmask]> + * @version $Id: TestRunRateAnalysis.java,v 1.1 2013/02/25 22:39:26 meeg Exp $ + */ +public class TestRunRateAnalysis extends Driver { + + AIDA aida = AIDA.defaultInstance(); + IHistogram2D eClusterVsP, photonEClusterVsP, electronEClusterVsP, positronEClusterVsP; + IHistogram2D eVsP, photonEVsP, electronEVsP, positronEVsP; + IHistogram1D eClusterOverP, photonEClusterOverP, electronEClusterOverP, positronEClusterOverP; + IHistogram1D eOverP, photonEOverP, electronEOverP, positronEOverP; + private String clusterCollectionName; + private String hitCollectionName = "EcalHits"; + int nTriggers; + private double clusterEnergyLow = 10; // + int deadtimelessTriggerCount; + int[] triggersY = new int[5]; + + public TestRunRateAnalysis() { + } + + @Override + public void startOfData() { + deadtimelessTriggerCount = 0; + + eClusterVsP = aida.histogram2D("All Cluster E vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); + photonEClusterVsP = aida.histogram2D("Photon Cluster E vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); + electronEClusterVsP = aida.histogram2D("Electron Cluster E vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); + positronEClusterVsP = aida.histogram2D("Positron Cluster E vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); + + eClusterOverP = aida.histogram1D("Cluster E over Pz, Pz > 0.6", 100, 0.0, 2.0); + photonEClusterOverP = aida.histogram1D("Photon Cluster E over Pz, Pz > 0.6", 100, 0.0, 2.0); + electronEClusterOverP = aida.histogram1D("Electron Cluster E over Pz, Pz > 0.6", 100, 0.0, 2.0); + positronEClusterOverP = aida.histogram1D("Positron Cluster E over Pz, Pz > 0.6", 100, 0.0, 2.0); + + eVsP = aida.histogram2D("All Edep vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); + photonEVsP = aida.histogram2D("Photon Edep vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); + electronEVsP = aida.histogram2D("Electron Edep vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); + positronEVsP = aida.histogram2D("Positron Edep vs. Pz", 100, 0.0, 2000.0, 100, 0.0, 2000.0); + + eOverP = aida.histogram1D("All Edep over Pz, Pz > 0.6", 100, 0.0, 2.0); + photonEOverP = aida.histogram1D("Photon Edep over Pz, Pz > 0.6", 100, 0.0, 2.0); + electronEOverP = aida.histogram1D("Electron Edep over Pz, Pz > 0.6", 100, 0.0, 2.0); + positronEOverP = aida.histogram1D("Positron Edep over Pz, Pz > 0.6", 100, 0.0, 2.0); + } + + public void setClusterEnergyLow(double clusterEnergyLow) { + this.clusterEnergyLow = clusterEnergyLow; + } + + public void setClusterCollectionName(String clusterCollectionName) { + this.clusterCollectionName = clusterCollectionName; + } + + @Override + public void process(EventHeader event) { + //System.out.println(this.getClass().getCanonicalName() + " - process"); + + // MCParticles + List<MCParticle> mcparticles = event.get(MCParticle.class).get(0); + + if (mcparticles.isEmpty()) { + return; + } +// if (mcparticles.size() != 1) { +// throw new RuntimeException("expected exactly 1 MCParticle"); +// } +// MCParticle particle = mcparticles.get(0); + + // Get the list of raw ECal hits. + List<HPSEcalCluster> clusters = event.get(HPSEcalCluster.class, clusterCollectionName); + if (clusters == null) { + throw new RuntimeException("Event is missing ECal clusters collection!"); + } + + boolean trigger = false; + + for (HPSEcalCluster cluster : clusters) { + if (cluster.getEnergy() > clusterEnergyLow && cluster.getSeedHit().getIdentifierFieldValue("ix") < 0) { +// if (cluster.getEnergy() > clusterEnergyLow && cluster.getSeedHit().getIdentifierFieldValue("iy")>0 && cluster.getSeedHit().getIdentifierFieldValue("ix")<0) { + triggersY[Math.abs(cluster.getSeedHit().getIdentifierFieldValue("iy")) - 1]++; + if (Math.abs(cluster.getSeedHit().getIdentifierFieldValue("iy")) > 1) { + trigger = true; + } + } + if (cluster.getSeedHit().getIdentifierFieldValue("ix") < 0 && Math.abs(cluster.getSeedHit().getIdentifierFieldValue("iy")) > 1) { + for (MCParticle particle : mcparticles) { + if (ParticleTypeClassifier.isElectron(particle.getPDGID())) { + electronEClusterVsP.fill(1000.0 * particle.getPZ(), 1000.0 * cluster.getEnergy()); + if (particle.getPZ() > 0.6) { + electronEClusterOverP.fill(cluster.getEnergy() / particle.getPZ()); + } + } else if (ParticleTypeClassifier.isPositron(particle.getPDGID())) { + positronEClusterVsP.fill(1000.0 * particle.getPZ(), 1000.0 * cluster.getEnergy()); + if (particle.getPZ() > 0.6) { + positronEClusterOverP.fill(cluster.getEnergy() / particle.getPZ()); + } + } else if (ParticleTypeClassifier.isPhoton(particle.getPDGID())) { + photonEClusterVsP.fill(1000.0 * particle.getPZ(), 1000.0 * cluster.getEnergy()); + if (particle.getPZ() > 0.6) { + photonEClusterOverP.fill(cluster.getEnergy() / particle.getPZ()); + } + } + eClusterVsP.fill(1000.0 * particle.getPZ(), 1000.0 * cluster.getEnergy()); + if (particle.getPZ() > 0.6) { + eClusterOverP.fill(cluster.getEnergy() / particle.getPZ()); + } + } + } + } + if (trigger) { + deadtimelessTriggerCount++; + } + + List<CalorimeterHit> hits = event.get(CalorimeterHit.class, hitCollectionName); + if (hits == null) { + throw new RuntimeException("Event is missing ECal hits collection!"); + } + double totalE = 0; + for (CalorimeterHit hit : hits) { + totalE += hit.getRawEnergy(); + } + + for (MCParticle particle : mcparticles) { + if (ParticleTypeClassifier.isElectron(particle.getPDGID())) { + electronEVsP.fill(1000.0 * particle.getPZ(), 1000.0 * totalE); + if (particle.getPZ() > 0.6) { + electronEOverP.fill(totalE / particle.getPZ()); + } + } else if (ParticleTypeClassifier.isPositron(particle.getPDGID())) { + positronEVsP.fill(1000.0 * particle.getPZ(), 1000.0 * totalE); + if (particle.getPZ() > 0.6) { + positronEOverP.fill(totalE / particle.getPZ()); + } + } else if (ParticleTypeClassifier.isPhoton(particle.getPDGID())) { + photonEVsP.fill(1000.0 * particle.getPZ(), 1000.0 * totalE); + if (particle.getPZ() > 0.6) { + photonEOverP.fill(totalE / particle.getPZ()); + } + } + eVsP.fill(1000.0 * particle.getPZ(), 1000.0 * totalE); + if (particle.getPZ() > 0.6) { + eOverP.fill(totalE / particle.getPZ()); + } + } + } + + @Override + public void endOfData() { + System.out.printf("Trigger count without dead time: %d\n", deadtimelessTriggerCount); + System.out.format("Triggers vs. Y: %d\t%d\t%d\t%d\t%d, total %d\n", triggersY[0], triggersY[1], triggersY[2], triggersY[3], triggersY[4], deadtimelessTriggerCount); + super.endOfData(); + } +}
\ No newline at end of file
diff -u -r1.6 -r1.7 --- HPSEcalTriggerPlotsDriver.java 22 Dec 2012 00:54:15 -0000 1.6 +++ HPSEcalTriggerPlotsDriver.java 25 Feb 2013 22:39:26 -0000 1.7 @@ -9,10 +9,10 @@
import org.lcsim.event.CalorimeterHit; import org.lcsim.event.EventHeader; import org.lcsim.geometry.IDDecoder;
-import org.lcsim.hps.recon.ecal.HPSECalUtils;
+import org.lcsim.hps.recon.ecal.ECalUtils;
import org.lcsim.hps.recon.ecal.HPSEcalCluster;
-import org.lcsim.hps.recon.ecal.HPSRawCalorimeterHit; -import org.lcsim.hps.recon.ecal.HPSTriggerDriver;
+import org.lcsim.hps.recon.ecal.HPSCalorimeterHit; +import org.lcsim.hps.readout.ecal.TriggerDriver;
import org.lcsim.util.Driver; import org.lcsim.util.aida.AIDA;
@@ -20,7 +20,7 @@
* Diagnostic plots for HPS ECal. * * @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcalTriggerPlotsDriver.java,v 1.6 2012/12/22 00:54:15 meeg Exp $
+ * @version $Id: HPSEcalTriggerPlotsDriver.java,v 1.7 2013/02/25 22:39:26 meeg Exp $
*/ public class HPSEcalTriggerPlotsDriver extends Driver {
@@ -40,7 +40,7 @@
IDDecoder dec = null; private int coincidenceWindow = 2; private double tp = 14.0;
- private double threshold = 50 * 10 * 0.15 * HPSECalUtils.MeV;
+ private double threshold = 50 * 10 * 0.15 * ECalUtils.MeV;
public void setEcalCollectionName(String ecalCollectionName) { this.ecalCollectionName = ecalCollectionName;
@@ -104,13 +104,13 @@
int ix = hit.getIdentifierFieldValue("ix"); int iy = hit.getIdentifierFieldValue("iy"); hitXYPlot.fill(ix-0.5*Math.signum(ix), iy, 1.0 / coincidenceWindow);
- if (hit.getRawEnergy() > 100.0 * HPSECalUtils.MeV) {
+ if (hit.getRawEnergy() > 100.0 * ECalUtils.MeV) {
hitXYPlot100.fill(ix-0.5*Math.signum(ix), iy, 1.0 / coincidenceWindow);
- if (hit.getRawEnergy() > 200.0 * HPSECalUtils.MeV) {
+ if (hit.getRawEnergy() > 200.0 * ECalUtils.MeV) {
hitXYPlot200.fill(ix-0.5*Math.signum(ix), iy, 1.0 / coincidenceWindow);
- if (hit.getRawEnergy() > 500.0 * HPSECalUtils.MeV) {
+ if (hit.getRawEnergy() > 500.0 * ECalUtils.MeV) {
hitXYPlot500.fill(ix-0.5*Math.signum(ix), iy, 1.0 / coincidenceWindow);
- if (hit.getRawEnergy() > 1000.0 * HPSECalUtils.MeV) {
+ if (hit.getRawEnergy() > 1000.0 * ECalUtils.MeV) {
hitXYPlot1000.fill(ix-0.5*Math.signum(ix), iy, 1.0 / coincidenceWindow); } }
@@ -128,7 +128,7 @@
} for (HPSEcalCluster clus : clusters) {
- HPSRawCalorimeterHit seedHit = (HPSRawCalorimeterHit) clus.getSeedHit();
+ HPSCalorimeterHit seedHit = (HPSCalorimeterHit) clus.getSeedHit();
IIdentifier id = seedHit.getIdentifier(); int ix = helper.unpack(id).getValue(helper.getFieldIndex("ix")); int iy = helper.unpack(id).getValue(helper.getFieldIndex("iy"));
@@ -145,9 +145,9 @@
} }
- if (HPSTriggerDriver.triggerBit()) {
+ if (TriggerDriver.triggerBit()) {
for (HPSEcalCluster clus : clusters) {
- HPSRawCalorimeterHit seedHit = (HPSRawCalorimeterHit) clus.getSeedHit();
+ HPSCalorimeterHit seedHit = (HPSCalorimeterHit) clus.getSeedHit();
IIdentifier id = seedHit.getIdentifier(); int ix = helper.unpack(id).getValue(helper.getFieldIndex("ix")); int iy = helper.unpack(id).getValue(helper.getFieldIndex("iy"));
diff -u -r1.15 -r1.16 --- HPSEcalPlotsDriver.java 30 Jul 2012 23:31:45 -0000 1.15 +++ HPSEcalPlotsDriver.java 25 Feb 2013 22:39:26 -0000 1.16 @@ -22,8 +22,8 @@
import org.lcsim.event.EventHeader; import org.lcsim.event.MCParticle; import org.lcsim.hps.recon.ecal.HPSEcalCluster;
-import org.lcsim.hps.recon.ecal.HPSRawCalorimeterHit; -import org.lcsim.hps.recon.ecal.HPSTriggerDriver;
+import org.lcsim.hps.recon.ecal.HPSCalorimeterHit; +import org.lcsim.hps.readout.ecal.TriggerDriver;
import org.lcsim.hps.util.ClockSingleton; import org.lcsim.units.SystemOfUnits; import org.lcsim.util.Driver;
@@ -33,7 +33,7 @@
* Diagnostic plots for HPS ECal. * * @author Jeremy McCormick <[log in to unmask]>
- * @version $Id: HPSEcalPlotsDriver.java,v 1.15 2012/07/30 23:31:45 meeg Exp $
+ * @version $Id: HPSEcalPlotsDriver.java,v 1.16 2013/02/25 22:39:26 meeg Exp $
*/ public class HPSEcalPlotsDriver extends Driver {
@@ -191,7 +191,7 @@
} public void process(EventHeader event) {
- if (HPSTriggerDriver.triggerBit()) numTriggers++;
+ if (TriggerDriver.triggerBit()) numTriggers++;
// MCParticles List<MCParticle> mcparticles = event.get(MCParticle.class).get(0);
@@ -238,7 +238,7 @@
double e = clus.getEnergy(); clusEPlot.fill(e); clusE += e;
- HPSRawCalorimeterHit seedHit = (HPSRawCalorimeterHit) clus.getSeedHit();
+ HPSCalorimeterHit seedHit = (HPSCalorimeterHit) clus.getSeedHit();
//double maxe = 0; for (CalorimeterHit hit : clus.getCalorimeterHits()) { if (hitClusMap.containsKey(hit)) {
@@ -293,7 +293,7 @@
int nhits100MeV = 0; int nhitsOver100MeV = 0;
- if (HPSTriggerDriver.triggerBit() && numTriggers <= 100) {
+ if (TriggerDriver.triggerBit() && numTriggers <= 100) {
hitXYPlot = aida.histogram2D( ecalCollectionName + " : hit E, event " + String.format("%07d", ClockSingleton.getClock()), 47, -23.5, 23.5, 11, -5.5, 5.5);
@@ -347,7 +347,7 @@
crystalXPlot.fill(ix); crystalYPlot.fill(iy); crystalXYPlot.fill(ix, iy);
- if (HPSTriggerDriver.triggerBit() && numTriggers <= 100)
+ if (TriggerDriver.triggerBit() && numTriggers <= 100)
hitXYPlot.fill(ix, iy, eraw); }
diff -u -r1.3 -r1.4 --- HPSEcalFADCPlotsDriver.java 9 Dec 2011 23:40:21 -0000 1.3 +++ HPSEcalFADCPlotsDriver.java 25 Feb 2013 22:39:26 -0000 1.4 @@ -9,7 +9,7 @@
import org.lcsim.event.Cluster; import org.lcsim.event.EventHeader; import org.lcsim.hps.recon.ecal.HPSEcalCluster;
-import org.lcsim.hps.recon.ecal.HPSFADCCalorimeterHit;
+import org.lcsim.hps.recon.ecal.HPSRawCalorimeterHit;
import org.lcsim.util.Driver; import org.lcsim.util.aida.AIDA;
@@ -17,7 +17,7 @@
* Diagnostic plots for HPS ECal. * * @author Sho Uemura <[log in to unmask]>
- * @version $Id: HPSEcalFADCPlotsDriver.java,v 1.3 2011/12/09 23:40:21 meeg Exp $
+ * @version $Id: HPSEcalFADCPlotsDriver.java,v 1.4 2013/02/25 22:39:26 meeg Exp $
*/ public class HPSEcalFADCPlotsDriver extends Driver {
@@ -79,11 +79,11 @@
throw new RuntimeException("Missing hit collection!"); if (rawCollectionName != null) {
- List<HPSFADCCalorimeterHit> rawHits = event.get(HPSFADCCalorimeterHit.class, rawCollectionName);
+ List<HPSRawCalorimeterHit> rawHits = event.get(HPSRawCalorimeterHit.class, rawCollectionName);
if (rawHits == null) throw new RuntimeException("Missing hit collection!");
- for (HPSFADCCalorimeterHit hit : rawHits) {
+ for (HPSRawCalorimeterHit hit : rawHits) {
rawE.fill(hit.getAmplitude()); window_E.fill(hit.getAmplitude(),hit.getWindowSize()); }
diff -u -r1.1 -r1.2 --- MainTrackingDriver.java 28 Nov 2012 06:42:05 -0000 1.1 +++ MainTrackingDriver.java 25 Feb 2013 22:39:26 -0000 1.2 @@ -4,7 +4,7 @@
*/ package org.lcsim.hps.recon.tracking;
-import org.lcsim.hps.monitoring.HPSCalibrationDriver;
+import org.lcsim.hps.monitoring.CalibrationDriver;
import org.lcsim.hps.users.mgraham.DataTrackerHitDriver; import org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup; import org.lcsim.util.Driver;
@@ -21,7 +21,7 @@
public MainTrackingDriver() { //Setup the sensors and calibrations
- HPSCalibrationDriver calibDriver = new HPSCalibrationDriver();
+ CalibrationDriver calibDriver = new CalibrationDriver();
calibDriver.setRunNumber(1351); //not sure what should be done here!? -> FIX THIS! add(calibDriver); add(new RawTrackerHitSensorSetup());
Use REPLY-ALL to reply to list
To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1