Author: [log in to unmask] Date: Fri Jun 12 15:27:10 2015 New Revision: 3143 Log: Merge trunk changes into conditions branch. Added: java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/PlotAndFitUtilities.java - copied unchanged from r3142, java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/PlotAndFitUtilities.java java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/SVTOpeningStudies.java - copied unchanged from r3142, java/trunk/analysis/src/main/java/org/hps/analysis/dataquality/SVTOpeningStudies.java java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/examples/StripGoldenEventsDriver.java - copied unchanged from r3142, java/trunk/analysis/src/main/java/org/hps/analysis/examples/StripGoldenEventsDriver.java java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/examples/StripMollerEventsDriver.java - copied unchanged from r3142, java/trunk/analysis/src/main/java/org/hps/analysis/examples/StripMollerEventsDriver.java java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/run/ - copied from r3142, java/trunk/conditions/src/main/java/org/hps/conditions/run/ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/MotorPositionLoader.java - copied unchanged from r3142, java/trunk/conditions/src/main/java/org/hps/conditions/svt/MotorPositionLoader.java java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/OpeningAngleLoader.java - copied unchanged from r3142, java/trunk/conditions/src/main/java/org/hps/conditions/svt/OpeningAngleLoader.java java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtBiasConditionsLoader.java - copied unchanged from r3142, java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBiasConditionsLoader.java java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtBiasConstant.java - copied unchanged from r3142, java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBiasConstant.java java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtBiasMyaDumpReader.java - copied unchanged from r3142, java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtBiasMyaDumpReader.java java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtTimingConstants.java - copied unchanged from r3142, java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtTimingConstants.java java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtTimingConstantsLoader.java - copied unchanged from r3142, java/trunk/conditions/src/main/java/org/hps/conditions/svt/SvtTimingConstantsLoader.java java/branches/HPSJAVA-488/conditions/src/test/java/org/hps/conditions/svt/SvtTimingConstantsTest.java - copied unchanged from r3142, java/trunk/conditions/src/test/java/org/hps/conditions/svt/SvtTimingConstantsTest.java java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-1_5mm-v0/SamplingFractions/Ecal.properties - copied unchanged from r3142, java/trunk/detector-data/detectors/HPS-EngRun2015-1_5mm-v0/SamplingFractions/Ecal.properties java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-1_5mm-v1/ - copied from r3142, java/trunk/detector-data/detectors/HPS-EngRun2015-1_5mm-v1/ java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-2_5mm-v0/SamplingFractions/Ecal.properties - copied unchanged from r3142, java/trunk/detector-data/detectors/HPS-EngRun2015-2_5mm-v0/SamplingFractions/Ecal.properties java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-2_5mm-v1/ - copied from r3142, java/trunk/detector-data/detectors/HPS-EngRun2015-2_5mm-v1/ java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-2mm-v0/SamplingFractions/Ecal.properties - copied unchanged from r3142, java/trunk/detector-data/detectors/HPS-EngRun2015-2mm-v0/SamplingFractions/Ecal.properties java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-2mm-v1/ - copied from r3142, java/trunk/detector-data/detectors/HPS-EngRun2015-2mm-v1/ java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-2mmPreRun5216-v1/ - copied from r3142, java/trunk/detector-data/detectors/HPS-EngRun2015-2mmPreRun5216-v1/ java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-3mm-v0/SamplingFractions/Ecal.properties - copied unchanged from r3142, java/trunk/detector-data/detectors/HPS-EngRun2015-3mm-v0/SamplingFractions/Ecal.properties java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-3mm-v1/ - copied from r3142, java/trunk/detector-data/detectors/HPS-EngRun2015-3mm-v1/ java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-4mm-v0/SamplingFractions/Ecal.properties - copied unchanged from r3142, java/trunk/detector-data/detectors/HPS-EngRun2015-4mm-v0/SamplingFractions/Ecal.properties java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-4mm-v1/ - copied from r3142, java/trunk/detector-data/detectors/HPS-EngRun2015-4mm-v1/ java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-Nominal-v1/ - copied from r3142, java/trunk/detector-data/detectors/HPS-EngRun2015-Nominal-v1/ java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-Nominal-v1-dev/ - copied from r3142, java/trunk/detector-data/detectors/HPS-EngRun2015-Nominal-v1-dev/ java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-Open-v0/SamplingFractions/Ecal.properties - copied unchanged from r3142, java/trunk/detector-data/detectors/HPS-EngRun2015-Open-v0/SamplingFractions/Ecal.properties java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-Open-v1/ - copied from r3142, java/trunk/detector-data/detectors/HPS-EngRun2015-Open-v1/ java/branches/HPSJAVA-488/detector-model/ - copied from r3142, java/trunk/detector-model/ java/branches/HPSJAVA-488/ecal-readout-sim/src/main/java/org/hps/readout/ecal/ReadoutTrigger.java - copied unchanged from r3142, java/trunk/ecal-readout-sim/src/main/java/org/hps/readout/ecal/ReadoutTrigger.java java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/Ecal3PoleFunction.java - copied unchanged from r3142, java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/Ecal3PoleFunction.java java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalPulseFitter.java - copied unchanged from r3142, java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/EcalPulseFitter.java java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/CopyClusterCollectionDriver.java - copied unchanged from r3142, java/trunk/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/CopyClusterCollectionDriver.java java/branches/HPSJAVA-488/evio/src/test/java/org/hps/evio/EpicsDataTest.java - copied unchanged from r3142, java/trunk/evio/src/test/java/org/hps/evio/EpicsDataTest.java java/branches/HPSJAVA-488/evio/src/test/java/org/hps/evio/ScalersTest.java - copied unchanged from r3142, java/trunk/evio/src/test/java/org/hps/evio/ScalersTest.java java/branches/HPSJAVA-488/integration-tests/src/main/java/org/ - copied from r3142, java/trunk/integration-tests/src/main/java/org/ java/branches/HPSJAVA-488/integration-tests/src/test/java/org/hps/test/ - copied from r3142, java/trunk/integration-tests/src/test/java/org/hps/test/ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/scalers/ - copied from r3142, java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/scalers/ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SvtClusterPlots.java - copied unchanged from r3142, java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SvtClusterPlots.java java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SvtPlotUtils.java - copied unchanged from r3142, java/trunk/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SvtPlotUtils.java java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/trigger/ShifterTrigPanel.java - copied unchanged from r3142, java/trunk/monitoring-util/src/main/java/org/hps/monitoring/trigger/ShifterTrigPanel.java java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/trigger/ShifterTrigWindow.java - copied unchanged from r3142, java/trunk/monitoring-util/src/main/java/org/hps/monitoring/trigger/ShifterTrigWindow.java java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/epics/EpicsData.java - copied unchanged from r3142, java/trunk/record-util/src/main/java/org/hps/record/epics/EpicsData.java java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EventTagBitMask.java - copied unchanged from r3142, java/trunk/record-util/src/main/java/org/hps/record/evio/EventTagBitMask.java java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EventTagConstant.java - copied unchanged from r3142, java/trunk/record-util/src/main/java/org/hps/record/evio/EventTagConstant.java java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioEventSkimmer.java - copied unchanged from r3142, java/trunk/record-util/src/main/java/org/hps/record/evio/EvioEventSkimmer.java java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/crawler/ - copied from r3142, java/trunk/record-util/src/main/java/org/hps/record/evio/crawler/ java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/scalers/ - copied from r3142, java/trunk/record-util/src/main/java/org/hps/record/scalers/ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/EcalLedSequenceMonitoringApp.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/monitoring/EcalLedSequenceMonitoringApp.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/EcalLedSequenceStandalone.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/monitoring/EcalLedSequenceStandalone.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/EcalMonitoringOnly.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/monitoring/EcalMonitoringOnly.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/SvtOnlineMonitoring.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/monitoring/SvtOnlineMonitoring.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/SvtTimingInMonitoring.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/monitoring/SvtTimingInMonitoring.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/production/DataQualityReconMC.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/production/DataQualityReconMC.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/EngineeringRun2015TrigPairs1.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/readout/EngineeringRun2015TrigPairs1.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/EngineeringRun2015TrigSingles1.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/readout/EngineeringRun2015TrigSingles1.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullReconGbl2.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullReconGbl2.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullReconMC.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullReconMC.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullReconOutsideIn.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullReconOutsideIn.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015HitRecon.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015HitRecon.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/TriggerDiagnosticsAnalysis.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/recon/TriggerDiagnosticsAnalysis.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/baltzell/EcalReconPulseFit.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/users/baltzell/EcalReconPulseFit.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/baltzell/EngineeringRun2014EcalRecon_FitPulses.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/users/baltzell/EngineeringRun2014EcalRecon_FitPulses.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/holly/EcalReadoutNoPileUp.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/users/holly/EcalReadoutNoPileUp.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/holly/EngineeringRun2015EcalOnly.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/users/holly/EngineeringRun2015EcalOnly.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/meeg/SmallHits.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/users/meeg/SmallHits.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/mgraham/AlignmentStudies.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/users/mgraham/AlignmentStudies.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/mgraham/PlotsOnRecon.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/users/mgraham/PlotsOnRecon.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/mgraham/ReadoutAndTrackingAndReconMonitoring.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/users/mgraham/ReadoutAndTrackingAndReconMonitoring.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/mgraham/TestReadoutEngRun2015.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/users/mgraham/TestReadoutEngRun2015.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/mgraham/TrackTriggerStudy.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/users/mgraham/TrackTriggerStudy.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/phansson/GenericTrackingAndReconMonitoring.lcsim - copied unchanged from r3142, java/trunk/steering-files/src/main/resources/org/hps/steering/users/phansson/GenericTrackingAndReconMonitoring.lcsim java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackData.java - copied unchanged from r3142, java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackData.java java/branches/HPSJAVA-488/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-OutsideIn.xml - copied unchanged from r3142, java/trunk/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-OutsideIn.xml java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/baltzell/Ecal3PoleFunction.java - copied unchanged from r3142, java/trunk/users/src/main/java/org/hps/users/baltzell/Ecal3PoleFunction.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/baltzell/EcalPulseFitter.java - copied unchanged from r3142, java/trunk/users/src/main/java/org/hps/users/baltzell/EcalPulseFitter.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/baltzell/EcalRawConverter.java - copied unchanged from r3142, java/trunk/users/src/main/java/org/hps/users/baltzell/EcalRawConverter.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/baltzell/EcalRawConverterDriver.java - copied unchanged from r3142, java/trunk/users/src/main/java/org/hps/users/baltzell/EcalRawConverterDriver.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/holly/ClusterDriver.java - copied unchanged from r3142, java/trunk/users/src/main/java/org/hps/users/holly/ClusterDriver.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/holly/EcalRawConverter.java - copied unchanged from r3142, java/trunk/users/src/main/java/org/hps/users/holly/EcalRawConverter.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/jeremym/EvioFileScanner.java - copied unchanged from r3142, java/trunk/users/src/main/java/org/hps/users/jeremym/EvioFileScanner.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/jeremym/PatchLcioFile.java - copied unchanged from r3142, java/trunk/users/src/main/java/org/hps/users/jeremym/PatchLcioFile.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/luca/FeeCalibHistCreator.java - copied unchanged from r3142, java/trunk/users/src/main/java/org/hps/users/luca/FeeCalibHistCreator.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/meeg/EcalTruthMatchingDriver.java - copied unchanged from r3142, java/trunk/users/src/main/java/org/hps/users/meeg/EcalTruthMatchingDriver.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/meeg/SVTSmallHitsDriver.java - copied unchanged from r3142, java/trunk/users/src/main/java/org/hps/users/meeg/SVTSmallHitsDriver.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/mgraham/PositronDebug.java - copied unchanged from r3142, java/trunk/users/src/main/java/org/hps/users/mgraham/PositronDebug.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/mgraham/ProfileDriver.java - copied unchanged from r3142, java/trunk/users/src/main/java/org/hps/users/mgraham/ProfileDriver.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/mgraham/SplitHitsOnTracks.java - copied unchanged from r3142, java/trunk/users/src/main/java/org/hps/users/mgraham/SplitHitsOnTracks.java Removed: java/branches/HPSJAVA-488/detector-data/detectors/HPS-EngRun2015-3_5mm-v0/ java/branches/HPSJAVA-488/evio/src/test/java/org/hps/evio/EpicsScalarDataTest.java java/branches/HPSJAVA-488/evio/src/test/java/org/hps/evio/ScalarsTest.java java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/ecal/ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/scalars/ java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/epics/EpicsScalarData.java java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/scalars/ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/EcalLedSequenceMonitor.lcsim Modified: java/branches/HPSJAVA-488/ (props changed) java/branches/HPSJAVA-488/analysis/pom.xml java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/EcalMonitoring.java java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/FinalStateMonitoring.java java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/SvtMonitoring.java java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/TrackingMonitoring.java java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/TrackingResiduals.java java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/TridentMonitoring.java java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/V0Monitoring.java java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/ecal/EcalHitPlots.java java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/examples/EcalScoringMatchDriver.java java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/examples/StripEventDriver.java java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/trigger/TriggerDiagnosticDriver.java java/branches/HPSJAVA-488/conditions/ (props changed) java/branches/HPSJAVA-488/conditions/pom.xml java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsRecord.java java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/ConnectionParameters.java java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtDetectorSetup.java java/branches/HPSJAVA-488/conditions/src/test/java/org/hps/conditions/EngRunConditionsTest.java java/branches/HPSJAVA-488/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtBadChannelsTest.java java/branches/HPSJAVA-488/datacat/pom.xml java/branches/HPSJAVA-488/detector-data/pom.xml java/branches/HPSJAVA-488/distribution/ (props changed) java/branches/HPSJAVA-488/distribution/pom.xml java/branches/HPSJAVA-488/ecal-event-display/pom.xml java/branches/HPSJAVA-488/ecal-readout-sim/pom.xml java/branches/HPSJAVA-488/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCEcalReadoutDriver.java java/branches/HPSJAVA-488/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCPrimaryTriggerDriver.java java/branches/HPSJAVA-488/ecal-recon/pom.xml java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalEdepToTriggerConverterDriver.java java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRunningPedestalDriver.java java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterDriver.java java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterUtilities.java java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/GTPClusterDriver.java java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/GTPClusterer.java java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/LegacyClusterer.java java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/triggerbank/SSPData.java java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/triggerbank/SSPSinglesTrigger.java java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/triggerbank/TestRunTriggerData.java java/branches/HPSJAVA-488/ecal-recon/src/test/java/org/hps/recon/ecal/cluster/ClustererTest.java java/branches/HPSJAVA-488/evio/pom.xml java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/BasicEvioFileReader.java java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EcalEvioReader.java java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EcalHitWriter.java java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EventConstants.java java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EvioToLcio.java java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/LCSimTestRunEventBuilder.java java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/SvtEvioReader.java java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToEvio.java java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToLcio.java java/branches/HPSJAVA-488/integration-tests/ (props changed) java/branches/HPSJAVA-488/integration-tests/pom.xml java/branches/HPSJAVA-488/monitoring-app/ (props changed) java/branches/HPSJAVA-488/monitoring-app/pom.xml java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/MonitoringApplication.java java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/MonitoringApplicationFrame.java java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/PlotPanel.java java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusPanel.java java/branches/HPSJAVA-488/monitoring-app/src/main/scripts/evio_file_producer.sh java/branches/HPSJAVA-488/monitoring-drivers/pom.xml java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/example/ExamplePlotDriver.java java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/GblTrackingReconstructionPlots.java java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/PedestalPlots.java java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/PopupPlotterListener.java java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SamplesPlots.java java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SensorOccupancyPlotsDriver.java java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SvtHitPlots.java java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackTimePlots.java java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackingReconPlots.java java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalHitPlots.java java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalLedSequenceMonitor.java java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringPlots.java java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringUtilities.java java/branches/HPSJAVA-488/monitoring-util/pom.xml java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/plotting/ExportPdf.java java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/plotting/PlotterRegistry.java java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/subsys/et/EtSystemMonitor.java java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/trigger/AbstractTablePanel.java java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/trigger/AbstractTriggerTablePanel.java java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/trigger/EfficiencyTablePanel.java java/branches/HPSJAVA-488/parent/pom.xml java/branches/HPSJAVA-488/plugin/pom.xml java/branches/HPSJAVA-488/pom.xml java/branches/HPSJAVA-488/recon/pom.xml java/branches/HPSJAVA-488/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java java/branches/HPSJAVA-488/record-util/pom.xml java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/epics/EpicsEtProcessor.java java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/epics/EpicsEvioProcessor.java java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/epics/EpicsGenericObject.java java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioEventConstants.java java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioEventUtilities.java java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioFileProducer.java java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioFileSource.java java/branches/HPSJAVA-488/steering-files/pom.xml java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/DeadtimeMonitor.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/Layers4to6TrackingMonitoring.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/LooseTrackingAndReconMonitoring.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/TrackingAndReconMonitoring.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/production/DataQualityRecon.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014ReadoutNoPileup.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014ReadoutToEvio.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014ReadoutToLcio.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014TruthReadoutToLcio.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullRecon.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineNoPileupRecon.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineRecon.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineTruthRecon.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPSTrackingDefaultsRecon.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/mgraham/TrackingAndReconMonitoring.lcsim java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/phansson/HPSTrackingDefaults.lcsim java/branches/HPSJAVA-488/tracking/pom.xml java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/readout/svt/SimpleSvtReadout.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/BeamlineConstants.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/DataTrackerHitDriver.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/HelicalTrackHitDriver.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/MaterialSupervisor.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/RawTrackerHitFitterDriver.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/ShaperAnalyticFitAlgorithm.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackDataDriver.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackTimeData.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackerReconDriver.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLFileIO.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutput.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/HpsGblRefitter.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/MakeGblTracks.java java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/svt/alignment/BuildMillepedeCompact.java java/branches/HPSJAVA-488/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L1-3.xml java/branches/HPSJAVA-488/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L4-6.xml java/branches/HPSJAVA-488/users/pom.xml java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/celentan/DummyDriverRaw.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/luca/CalibClusterAnalyzerEngRun.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/luca/rate.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/luca/ratetest.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/omoreno/SvtClusterAnalysis.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/omoreno/SvtHitEfficiency.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/omoreno/SvtTrackAnalysis.java java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/phansson/TrackingReconstructionPlots.java java/branches/HPSJAVA-488/util/pom.xml java/branches/HPSJAVA-488/util/src/main/java/org/hps/util/BasicLogFormatter.java Modified: java/branches/HPSJAVA-488/analysis/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/analysis/pom.xml (original) +++ java/branches/HPSJAVA-488/analysis/pom.xml Fri Jun 12 15:27:10 2015 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/analysis/</url> Modified: java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java ============================================================================= --- java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java (original) +++ java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/DataQualityMonitor.java Fri Jun 12 15:27:10 2015 @@ -3,9 +3,14 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; +import org.hps.recon.ecal.triggerbank.AbstractIntData; +import org.hps.recon.ecal.triggerbank.TIData; +import org.lcsim.event.EventHeader; +import org.lcsim.event.GenericObject; import org.lcsim.util.Driver; import org.lcsim.util.aida.AIDA; @@ -26,18 +31,24 @@ protected boolean connectToDB = false; protected boolean printDQMStrings = false; protected Map<String, Double> monitoredQuantityMap = new HashMap<>(); - protected boolean debug=false; + protected boolean debug = false; protected boolean outputPlots = false; protected String outputPlotDir = "DQMOutputPlots/"; - + + String triggerType = "all";//allowed types are "" (blank) or "all", singles0, singles1, pairs0,pairs1 + + public void setTriggerType(String type) { + this.triggerType = type; + } + public void setRecoVersion(String recoVersion) { this.recoVersion = recoVersion; } - public void setDebug(boolean debug){ - this.debug=debug; - } - + public void setDebug(boolean debug) { + this.debug = debug; + } + public void setRunNumber(int run) { this.runNumber = run; } @@ -54,14 +65,14 @@ this.printDQMStrings = print; } - public void setOutputPlots(boolean out){ - this.outputPlots=out; - } - public void setOutputPlotDir(String dir){ - this.outputPlotDir=dir; - } - - + public void setOutputPlots(boolean out) { + this.outputPlots = out; + } + + public void setOutputPlotDir(String dir) { + this.outputPlotDir = dir; + } + public void DataQualityMonitor() { } @@ -114,13 +125,13 @@ } public boolean checkSelectionIsNULL(String var) throws SQLException { - String ins = "select "+var+" from dqm where " + getRunRecoString(); + String ins = "select " + var + " from dqm where " + getRunRecoString(); ResultSet res = manager.selectQuery(ins); res.next(); - double result=res.getDouble(var); - if(res.wasNull()) - return true; - System.out.println("checkSelectionIsNULL::"+var+" = "+result); + double result = res.getDouble(var); + if (res.wasNull()) + return true; + System.out.println("checkSelectionIsNULL::" + var + " = " + result); return false; } @@ -138,30 +149,60 @@ public void calculateEndOfRunQuantities() { } - public void dumpDQMData() { for (Map.Entry<String, Double> entry : monitoredQuantityMap.entrySet()) { String name = entry.getKey(); double val = entry.getValue(); - boolean isnull=false; - try { - isnull=checkSelectionIsNULL(name); + boolean isnull = false; + try { + isnull = checkSelectionIsNULL(name); } catch (SQLException ex) { Logger.getLogger(SvtMonitoring.class.getName()).log(Level.SEVERE, null, ex); } - if (!overwriteDB&&!isnull){ - System.out.println("Not writing because "+name+" is already filled for this entry"); + if (!overwriteDB && !isnull) { + System.out.println("Not writing because " + name + " is already filled for this entry"); continue; //entry exists and I don't want to overwrite } - String put = "update dqm SET "+name+" = " + val + " WHERE " + getRunRecoString(); + String put = "update dqm SET " + name + " = " + val + " WHERE " + getRunRecoString(); System.out.println(put); - manager.updateQuery(put); - + manager.updateQuery(put); + } } + public boolean matchTriggerType(TIData triggerData) { + if (triggerType.contentEquals("") || triggerType.contentEquals("all")) + return true; + if (triggerData.isSingle0Trigger() && triggerType.contentEquals("singles0")) + return true; + if (triggerData.isSingle1Trigger() && triggerType.contentEquals("singles1")) + return true; + if (triggerData.isPair0Trigger() && triggerType.contentEquals("pairs0")) + return true; + if (triggerData.isPair1Trigger() && triggerType.contentEquals("pairs1")) + return true; + return false; + + } + + public boolean matchTrigger(EventHeader event) { + boolean match = true; + if (event.hasCollection(GenericObject.class, "TriggerBank")) { + List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank"); + for (GenericObject data : triggerList) + if (AbstractIntData.getTag(data) == TIData.BANK_TAG) { + TIData triggerData = new TIData(data); + if (!matchTriggerType(triggerData))//only process singles0 triggers... + match = false; + } + } else if (debug) + System.out.println(this.getClass().getSimpleName() + ": No trigger bank found...running over all trigger types"); + return match; + } + //override this method to do something interesting //like print the DQM data log file + public void printDQMData() { } Modified: java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/EcalMonitoring.java ============================================================================= --- java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/EcalMonitoring.java (original) +++ java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/EcalMonitoring.java Fri Jun 12 15:27:10 2015 @@ -6,9 +6,13 @@ import java.util.List; import java.util.Map; import org.apache.commons.math.stat.StatUtils; +import org.hps.recon.ecal.triggerbank.AbstractIntData; +import org.hps.recon.ecal.triggerbank.TIData; +import org.hps.recon.ecal.triggerbank.TestRunTriggerData; import org.lcsim.event.CalorimeterHit; import org.lcsim.event.Cluster; import org.lcsim.event.EventHeader; +import org.lcsim.event.GenericObject; import org.lcsim.geometry.Detector; /** @@ -51,21 +55,24 @@ IHistogram2D fiducialenergyVsX; IHistogram2D energyVsY; IHistogram2D energyVsX; - - int nEvents = 0; + IHistogram2D xVsY; + IHistogram2D pairsE1vsE2; + + int nEvents = 0; int nTotHits = 0; - int nTotClusters = 0; - double sumHitE = 0; + int nTotClusters = 0; + double sumHitE = 0; double sumHitPerCluster = 0; double sumClusterEnergy = 0; - double sumClusterTime=0; + double sumClusterTime = 0; boolean fillHitPlots = true; private Map<String, Double> monitoredQuantityMap = new HashMap<>(); - String[] ecalQuantNames = {"avg_N_hits","avg_Hit_Energy", - "avg_N_clusters", "avg_N_hitsPerCluster","avg_Cluster_Energy","avg_ClusterTime"}; - double maxE = 2.5; + String[] ecalQuantNames = {"avg_N_hits", "avg_Hit_Energy", + "avg_N_clusters", "avg_N_hitsPerCluster", "avg_Cluster_Energy", "avg_ClusterTime"}; + double maxE = 1.1; private final String plotHitsDir = "EcalHits/"; private final String plotClustersDir = "EcalClusters/"; + private final String plotFidCutDir = "FiducialCut/"; public void setReadoutHitCollectionName(String readoutHitCollectionName) { this.readoutHitCollectionName = readoutHitCollectionName; @@ -88,33 +95,36 @@ aida.tree().cd("/"); if (fillHitPlots) { // Setup hit plots. - hitCountPlot = aida.histogram1D(plotHitsDir + calibratedHitCollectionName + " Hit Count In Event", 40, -0.5, 39.5); - hitTimePlot = aida.histogram1D(plotHitsDir + calibratedHitCollectionName + " Hit Time", 50, 0 * 4.0, 50 * 4.0); - hitEnergyPlot = aida.histogram1D(plotHitsDir + calibratedHitCollectionName + " Hit Energy", 100, -0.1, maxE); - fiducialHitCountPlot = aida.histogram1D(plotHitsDir + calibratedHitCollectionName + " Hit Count with Fiducial Cut", 10, -0.5, 9.5); - fiducialEnergyPlot = aida.histogram1D(plotHitsDir + calibratedHitCollectionName + " Hit Energy with Fiducial Cut", 100, -0.1, maxE); + hitCountPlot = aida.histogram1D(plotHitsDir + triggerType + "/"+ calibratedHitCollectionName + " Hit Count In Event", 40, -0.5, 39.5); + hitTimePlot = aida.histogram1D(plotHitsDir + triggerType + "/"+calibratedHitCollectionName + " Hit Time", 50, 0 * 4.0, 50 * 4.0); + hitEnergyPlot = aida.histogram1D(plotHitsDir + triggerType + "/"+calibratedHitCollectionName + " Hit Energy", 100, -0.1, maxE); + fiducialHitCountPlot = aida.histogram1D(plotHitsDir + triggerType + "/"+calibratedHitCollectionName + " Hit Count with Fiducial Cut", 10, -0.5, 9.5); + fiducialEnergyPlot = aida.histogram1D(plotHitsDir + triggerType + "/"+calibratedHitCollectionName + " Hit Energy with Fiducial Cut", 100, -0.1, maxE); } // Setup cluster plots - clusterCountPlot = aida.histogram1D(plotClustersDir + clusterCollectionName + " Cluster Count per Event", 10, -0.5, 9.5); - clusterSizePlot = aida.histogram1D(plotClustersDir + clusterCollectionName + " Cluster Size", 10, -0.5, 9.5); - clusterEnergyPlot = aida.histogram1D(plotClustersDir + clusterCollectionName + " Cluster Energy", 100, -0.1, maxE); - clusterTimes = aida.histogram1D(plotClustersDir + clusterCollectionName + " Cluster Time Mean", 200, 0, 4.0 * 50); - clusterTimeSigma = aida.histogram1D(plotClustersDir + clusterCollectionName + " Cluster Time Sigma", 100, 0, 10); - twoclusterTotEnergy = aida.histogram1D(plotClustersDir + clusterCollectionName + " Two Cluster Energy Sum", 100, 0, maxE); - twoclusterEnergyAsymmetry = aida.histogram1D(plotClustersDir + clusterCollectionName + " Two Cluster Energy Asymmetry", 100, 0, 1.0); - energyVsX = aida.histogram2D(plotClustersDir + clusterCollectionName + " Energy vs X", 50, 0, 1.6, 50, .0, 200.0); - energyVsY = aida.histogram2D(plotClustersDir + clusterCollectionName + " Energy vs Y", 50, 0, 1.6, 50, 20.0, 85.0); - - fiducialClusterCountPlot = aida.histogram1D(plotClustersDir + clusterCollectionName + " Cluster Count with Fiducal Cut", 10, -0.5, 9.5); - fiducialClusterSizePlot = aida.histogram1D(plotClustersDir + clusterCollectionName + " Cluster Size with Fiducal Cut", 10, -0.5, 9.5); - fiducialClusterEnergyPlot = aida.histogram1D(plotClustersDir + clusterCollectionName + " Cluster Energy with Fiducal Cut", 100, -0.1, maxE); - fiducialenergyVsY = aida.histogram2D(plotClustersDir + clusterCollectionName + " Energy vs Y with Fiducial Cuts", 50, 0, 1.6, 50, 45.0, 85.0); - fiducialenergyVsX = aida.histogram2D(plotClustersDir + clusterCollectionName + " Energy vs X with Fiducial Cuts", 50, 0, 1.6, 50, 0.0, 200.0); + clusterCountPlot = aida.histogram1D(plotClustersDir + triggerType + "/"+clusterCollectionName + " Cluster Count per Event", 10, -0.5, 9.5); + clusterSizePlot = aida.histogram1D(plotClustersDir + triggerType + "/"+clusterCollectionName + " Cluster Size", 10, -0.5, 9.5); + clusterEnergyPlot = aida.histogram1D(plotClustersDir + triggerType + "/"+clusterCollectionName + " Cluster Energy", 100, -0.1, maxE); + clusterTimes = aida.histogram1D(plotClustersDir + triggerType + "/"+clusterCollectionName + " Cluster Time Mean", 200, 0, 4.0 * 50); + clusterTimeSigma = aida.histogram1D(plotClustersDir + triggerType + "/"+clusterCollectionName + " Cluster Time Sigma", 100, 0, 10); + twoclusterTotEnergy = aida.histogram1D(plotClustersDir + triggerType + "/"+clusterCollectionName + " Two Cluster Energy Sum", 100, 0, maxE); + twoclusterEnergyAsymmetry = aida.histogram1D(plotClustersDir + triggerType + "/"+clusterCollectionName + " Two Cluster Energy Asymmetry", 100, 0, 1.0); + xVsY = aida.histogram2D(plotClustersDir + triggerType + "/"+clusterCollectionName + "X vs Y (NHits >1)", 200, -200.0, 200.0, 85, -85.0, 85.0); + energyVsX = aida.histogram2D(plotClustersDir + triggerType + "/"+clusterCollectionName + " Energy vs X", 50, 0, 1.6, 50, .0, 200.0); + energyVsY = aida.histogram2D(plotClustersDir + triggerType + "/"+clusterCollectionName + " Energy vs Y", 50, 0, 1.6, 50, 20.0, 85.0); + pairsE1vsE2 = aida.histogram2D(plotClustersDir + triggerType + "/"+clusterCollectionName + "Pair E1 vs E2", 50, 0, 2, 50, 0, 2); + + fiducialClusterCountPlot = aida.histogram1D(plotClustersDir + triggerType + "/"+plotFidCutDir + clusterCollectionName + " Cluster Count with Fiducal Cut", 10, -0.5, 9.5); + fiducialClusterSizePlot = aida.histogram1D(plotClustersDir+ triggerType + "/" +plotFidCutDir + clusterCollectionName + " Cluster Size with Fiducal Cut", 10, -0.5, 9.5); + fiducialClusterEnergyPlot = aida.histogram1D(plotClustersDir + triggerType + "/"+plotFidCutDir + clusterCollectionName + " Cluster Energy with Fiducal Cut", 100, -0.1, maxE); + fiducialenergyVsY = aida.histogram2D(plotClustersDir + triggerType + "/"+plotFidCutDir + clusterCollectionName + " Energy vs Y with Fiducial Cuts", 50, 0, 1.6, 50, 45.0, 85.0); + fiducialenergyVsX = aida.histogram2D(plotClustersDir+ triggerType + "/" +plotFidCutDir + clusterCollectionName + " Energy vs X with Fiducial Cuts", 50, 0, 1.6, 50, 0.0, 200.0); } @Override public void process(EventHeader event) { + /* make sure everything is there */ List<CalorimeterHit> hits; if (event.hasCollection(CalorimeterHit.class, calibratedHitCollectionName)) @@ -122,6 +132,10 @@ else return; //this might be a non-data event + //check to see if this event is from the correct trigger (or "all"); + if (!matchTrigger(event)) + return; + if (fillHitPlots) { hitCountPlot.fill(hits.size()); int fidHitCount = 0; @@ -136,9 +150,9 @@ fiducialEnergyPlot.fill(hit.getCorrectedEnergy()); } fiducialHitCountPlot.fill(fidHitCount); - sumHitE+=hit.getCorrectedEnergy(); - } - nTotHits+=hits.size(); + sumHitE += hit.getCorrectedEnergy(); + } + nTotHits += hits.size(); } @@ -155,11 +169,11 @@ } nEvents++; clusterCountPlot.fill(clusters.size()); - nTotClusters+=clusters.size(); + nTotClusters += clusters.size(); int fidcnt = 0; for (Cluster cluster : clusters) { clusterEnergyPlot.fill(cluster.getEnergy()); - sumClusterEnergy+=cluster.getEnergy(); + sumClusterEnergy += cluster.getEnergy(); double[] times = new double[cluster.getCalorimeterHits().size()]; double[] energies = new double[cluster.getCalorimeterHits().size()]; CalorimeterHit seed = cluster.getCalorimeterHits().get(0); @@ -168,13 +182,16 @@ if (cluster.getCalorimeterHits().size() > 1) { energyVsX.fill(cluster.getEnergy(), Math.abs(cluster.getPosition()[0])); energyVsY.fill(cluster.getEnergy(), Math.abs(cluster.getPosition()[1])); + xVsY.fill(cluster.getPosition()[0], cluster.getPosition()[1]); } if (Math.abs(iy) > 2 && cluster.getCalorimeterHits().size() > 1) { fidcnt++; fiducialClusterSizePlot.fill(cluster.getCalorimeterHits().size()); fiducialClusterEnergyPlot.fill(cluster.getEnergy()); - if (cluster.getCalorimeterHits().size() > 1) + if (cluster.getCalorimeterHits().size() > 1) { fiducialenergyVsY.fill(cluster.getEnergy(), Math.abs(cluster.getPosition()[1])); + fiducialenergyVsX.fill(cluster.getEnergy(), Math.abs(cluster.getPosition()[0])); + } } int size = 0; @@ -186,9 +203,9 @@ clusterTimes.fill(StatUtils.mean(times, 0, size)); clusterSizePlot.fill(size); //The number of "hits" in a "cluster" clusterTimeSigma.fill(Math.sqrt(StatUtils.variance(times, 0, size))); - sumHitPerCluster+=size; - sumClusterTime+=StatUtils.mean(times, 0, size); - + sumHitPerCluster += size; + sumClusterTime += StatUtils.mean(times, 0, size); + } fiducialClusterCountPlot.fill(fidcnt); //make some interesting 2-cluster plots @@ -201,6 +218,8 @@ double e2 = cl2.getEnergy(); twoclusterTotEnergy.fill(e1 + e2); twoclusterEnergyAsymmetry.fill(Math.abs(e1 - e2) / (e1 + e2)); + pairsE1vsE2.fill(e1, e2); + } } @@ -213,9 +232,8 @@ @Override public void printDQMData() { System.out.println("EcalMonitoring::printDQMData"); - for (Map.Entry<String, Double> entry : monitoredQuantityMap.entrySet()) { + for (Map.Entry<String, Double> entry : monitoredQuantityMap.entrySet()) System.out.println(entry.getKey() + " = " + entry.getValue()); - } System.out.println("*******************************"); } @@ -224,14 +242,14 @@ */ @Override public void calculateEndOfRunQuantities() { - if(fillHitPlots){ - monitoredQuantityMap.put(calibratedHitCollectionName+" " +ecalQuantNames[0], (double) nTotHits / nEvents); - monitoredQuantityMap.put(calibratedHitCollectionName+" " +ecalQuantNames[1], (double) sumHitE / nTotHits); - } - monitoredQuantityMap.put(clusterCollectionName+" " +ecalQuantNames[2], (double) nTotClusters / nEvents); - monitoredQuantityMap.put(clusterCollectionName+" " +ecalQuantNames[3], (double) sumHitPerCluster / nTotClusters); - monitoredQuantityMap.put(clusterCollectionName+" " +ecalQuantNames[4], (double) sumClusterEnergy / nTotClusters); - monitoredQuantityMap.put(clusterCollectionName+" " +ecalQuantNames[5], (double) sumClusterTime / nTotClusters); + if (fillHitPlots) { + monitoredQuantityMap.put(calibratedHitCollectionName + " " + triggerType+" " + ecalQuantNames[0], (double) nTotHits / nEvents); + monitoredQuantityMap.put(calibratedHitCollectionName + " " + triggerType+" " + ecalQuantNames[1], (double) sumHitE / nTotHits); + } + monitoredQuantityMap.put(clusterCollectionName + " " + triggerType+" "+ ecalQuantNames[2], (double) nTotClusters / nEvents); + monitoredQuantityMap.put(clusterCollectionName + " " + triggerType+" "+ ecalQuantNames[3], (double) sumHitPerCluster / nTotClusters); + monitoredQuantityMap.put(clusterCollectionName + " " + triggerType+" "+ ecalQuantNames[4], (double) sumClusterEnergy / nTotClusters); + monitoredQuantityMap.put(clusterCollectionName + " " + triggerType+" "+ ecalQuantNames[5], (double) sumClusterTime / nTotClusters); } @Override Modified: java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/FinalStateMonitoring.java ============================================================================= --- java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/FinalStateMonitoring.java (original) +++ java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/FinalStateMonitoring.java Fri Jun 12 15:27:10 2015 @@ -15,9 +15,12 @@ import java.util.Map.Entry; import java.util.logging.Level; import java.util.logging.Logger; +import org.hps.recon.ecal.triggerbank.AbstractIntData; +import org.hps.recon.ecal.triggerbank.TIData; import org.hps.recon.tracking.TrackUtils; import org.lcsim.event.Cluster; import org.lcsim.event.EventHeader; +import org.lcsim.event.GenericObject; import org.lcsim.event.ReconstructedParticle; import org.lcsim.event.Track; import org.lcsim.geometry.Detector; @@ -51,9 +54,16 @@ //some summers double sumdelX = 0.0; double sumdelY = 0.0; - double sumEoverP = 0.0; + double sumEoverP = 0.0; private String plotDir = "FinalStateParticles/"; - + double beamEnergy = 1.05; //GeV + double maxFactor = 2.5; + double feeMomentumCut = 0.8; //GeV + + public void setFinalStateParticlesColName(String fsp){ + this.finalStateParticlesColName=fsp; + } + @Override protected void detectorChanged(Detector detector) { System.out.println("FinalStateMonitoring::detectorChanged Setting up the plotter"); @@ -61,39 +71,52 @@ /* Final State Particle Quantities */ /* plot electron & positron momentum separately */ - IHistogram1D elePx = aida.histogram1D(plotDir + "Electron Px (GeV)", 50, -0.1, 0.200); - IHistogram1D elePy = aida.histogram1D(plotDir + "Electron Py (GeV)", 50, -0.1, 0.1); - IHistogram1D elePz = aida.histogram1D(plotDir + "Electron Pz (GeV)", 50, 0, 2.5); - IHistogram1D elePzBeam = aida.histogram1D(plotDir + "Beam Electrons Pz (GeV)", 50, 1.8, 2.5); - - IHistogram1D posPx = aida.histogram1D(plotDir + "Positron Px (GeV)", 50, -0.1, 0.200); - IHistogram1D posPy = aida.histogram1D(plotDir + "Positron Py (GeV)", 50, -0.1, 0.1); - IHistogram1D posPz = aida.histogram1D(plotDir + "Positron Pz (GeV)", 50, 0, 2.5); + IHistogram1D elePx = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType + "/" + "Electron Px (GeV)", 100, -0.1, 0.200); + IHistogram1D elePy = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Electron Py (GeV)", 100, -0.1, 0.1); + IHistogram1D elePz = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Electron Pz (GeV)", 100, 0, beamEnergy * maxFactor); + IHistogram1D elePzBeam = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Beam Electrons Total P (GeV)", 100, feeMomentumCut, beamEnergy * maxFactor); + IHistogram1D elePzBeamTop = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Beam Electrons Total P (GeV): Top", 100, feeMomentumCut, beamEnergy * maxFactor); + IHistogram1D elePzBeamBottom = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Beam Electrons Total P (GeV): Bottom", 100, feeMomentumCut, beamEnergy * maxFactor); + IHistogram1D elePTop = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Electron Total P (GeV): Top", 100, 0, beamEnergy * maxFactor); + IHistogram1D elePBottom = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Electron Total P (GeV): Bottom", 100, 0, beamEnergy * maxFactor); + + IHistogram1D posPx = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Positron Px (GeV)", 50, -0.1, 0.200); + IHistogram1D posPy = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Positron Py (GeV)", 50, -0.1, 0.1); + IHistogram1D posPz = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Positron Pz (GeV)", 50, 0, beamEnergy * maxFactor); + IHistogram1D posPTop = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Positron Total P (GeV): Top", 100, 0, beamEnergy * maxFactor); + IHistogram1D posPBottom = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Positron Total P (GeV): Bottom", 100, 0, beamEnergy * maxFactor); + /* photon quanties (...right now, just unassociated clusters) */ - IHistogram1D nPhotonsHisto = aida.histogram1D(plotDir + "Number of photons per event", 15, 0, 15); - IHistogram1D enePhoton = aida.histogram1D(plotDir + "Photon Energy (GeV)", 50, 0, 2.4); - IHistogram1D xPhoton = aida.histogram1D(plotDir + "Photon X position (mm)", 50, -100, 100); - IHistogram1D yPhoton = aida.histogram1D(plotDir + "Photon Y position (mm)", 50, -100, 100); + IHistogram1D nPhotonsHisto = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Number of photons per event", 15, 0, 15); + IHistogram1D enePhoton = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Photon Energy (GeV)", 50, 0, 2.4); + IHistogram1D xPhoton = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Photon X position (mm)", 50, -200, 200); + IHistogram1D yPhoton = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Photon Y position (mm)", 50, -100, 100); /* tracks with associated clusters */ - IHistogram1D eneOverp = aida.histogram1D(plotDir + "Cluster Energy Over TrackMomentum", 50, 0, 2.0); - IHistogram1D deltaXAtCal = aida.histogram1D(plotDir + "delta X @ ECal (mm)", 50, -100, 100.0); - IHistogram1D deltaYAtCal = aida.histogram1D(plotDir + "delta Y @ ECal (mm)", 50, -100, 100.0); - //IHistogram2D trackXvsECalX = aida.histogram2D(plotDir + "track X vs ECal X", 50, -300, 300.0, 50, -300, 300.0); - //IHistogram2D trackYvsECalY = aida.histogram2D(plotDir + "track Y vs ECal Y", 50, -100, 100.0, 50, -100, 100.0); - IHistogram2D trackPvsECalE = aida.histogram2D(plotDir + "track mom vs ECal E", 50, 0, 2.5, 50, 0, 2.5); + IHistogram1D eneOverp = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Cluster Energy Over TrackMomentum", 50, 0, 2.0); + IHistogram1D deltaXAtCal = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "delta X @ ECal (mm)", 50, -50, 50.0); + IHistogram1D deltaYAtCal = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "delta Y @ ECal (mm)", 50, -50, 50.0); + //IHistogram2D trackXvsECalX = aida.histogram2D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "track X vs ECal X", 50, -300, 300.0, 50, -300, 300.0); + //IHistogram2D trackYvsECalY = aida.histogram2D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "track Y vs ECal Y", 50, -100, 100.0, 50, -100, 100.0); + IHistogram2D trackPvsECalE = aida.histogram2D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "track mom vs ECal E", 50, 0.1, beamEnergy * maxFactor, 50, 0.1, beamEnergy * maxFactor); /* number of unassocaited tracks/event */ - IHistogram1D nUnAssTracksHisto = aida.histogram1D(plotDir + "Number of unassociated tracks per event", 5, 0, 5); + IHistogram1D nUnAssTracksHisto = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Number of unassociated tracks per event", 5, 0, 5); } @Override public void process(EventHeader event) { /* make sure everything is there */ - if (!event.hasCollection(ReconstructedParticle.class, finalStateParticlesColName)){ - if(debug) - System.out.println(finalStateParticlesColName+" collection not found???"); + + if (!event.hasCollection(ReconstructedParticle.class, finalStateParticlesColName)) { + if (debug) + System.out.println(finalStateParticlesColName + " collection not found???"); return; } + + //check to see if this event is from the correct trigger (or "all"); + if (!matchTrigger(event)) + return; + nRecoEvents++; int nPhotons = 0; //number of photons int nUnAssTracks = 0; //number of tracks w/o clusters @@ -111,7 +134,6 @@ Cluster fsCluster = null; //TODO: mg-May 14, 2014 use PID to do this instead...not sure if that's implemented yet if (fsPart.getTracks().size() == 1)//should always be 1 or zero for final state particles - fsTrack = fsPart.getTracks().get(0); else isPhoton = true; @@ -127,15 +149,27 @@ Hep3Vector mom = fsPart.getMomentum(); if (charge < 0) { nTotEle++; - aida.histogram1D(plotDir + "Electron Px (GeV)").fill(mom.x()); - aida.histogram1D(plotDir + "Electron Py (GeV)").fill(mom.y()); - aida.histogram1D(plotDir + "Electron Pz (GeV)").fill(mom.z()); - aida.histogram1D(plotDir + "Beam Electrons Pz (GeV)").fill(mom.z()); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Electron Px (GeV)").fill(mom.x()); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Electron Py (GeV)").fill(mom.y()); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Electron Pz (GeV)").fill(mom.z()); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Beam Electrons Total P (GeV)").fill(mom.magnitude()); + if (mom.y() > 0){ + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Beam Electrons Total P (GeV): Top").fill(mom.magnitude()); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Electron Total P (GeV): Top").fill(mom.magnitude()); + } else{ + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Beam Electrons Total P (GeV): Bottom").fill(mom.magnitude()); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Electron Total P (GeV): Bottom").fill(mom.magnitude()); + } } else { nTotPos++; - aida.histogram1D(plotDir + "Positron Px (GeV)").fill(mom.x()); - aida.histogram1D(plotDir + "Positron Py (GeV)").fill(mom.y()); - aida.histogram1D(plotDir + "Positron Pz (GeV)").fill(mom.z()); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Positron Px (GeV)").fill(mom.x()); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Positron Py (GeV)").fill(mom.y()); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Positron Pz (GeV)").fill(mom.z()); + if (mom.y() > 0){ + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Positron Total P (GeV): Top").fill(mom.magnitude()); + } else{ + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Positron Total P (GeV): Bottom").fill(mom.magnitude()); + } } } @@ -151,9 +185,9 @@ double ypos = clusterPosition.y(); nPhotons++; nTotPhotons++; - aida.histogram1D(plotDir + "Photon Energy (GeV)").fill(ene); - aida.histogram1D(plotDir + "Photon X position (mm)").fill(xpos); - aida.histogram1D(plotDir + "Photon Y position (mm)").fill(ypos); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Photon Energy (GeV)").fill(ene); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Photon X position (mm)").fill(xpos); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Photon Y position (mm)").fill(ypos); } if (hasCluster && !isPhoton) { @@ -170,13 +204,13 @@ sumdelY += dy; sumEoverP += eOverP; - aida.histogram1D(plotDir + "Cluster Energy Over TrackMomentum").fill(eOverP); - aida.histogram1D(plotDir + "delta X @ ECal (mm)").fill(dx); - aida.histogram1D(plotDir + "delta Y @ ECal (mm)").fill(dy); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Cluster Energy Over TrackMomentum").fill(eOverP); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "delta X @ ECal (mm)").fill(dx); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "delta Y @ ECal (mm)").fill(dy); /* here are some plots for debugging track-cluster matching */ - // aida.histogram2D(plotDir + "track X vs ECal X").fill(trackPosAtEcal.x(), clusterPosition.x()); - // aida.histogram2D(plotDir + "track Y vs ECal Y").fill(trackPosAtEcal.y(), clusterPosition.y()); - aida.histogram2D(plotDir + "track mom vs ECal E").fill(fsPart.getMomentum().magnitude(), fsPart.getEnergy()); + // aida.histogram2D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "track X vs ECal X").fill(trackPosAtEcal.x(), clusterPosition.x()); + // aida.histogram2D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "track Y vs ECal Y").fill(trackPosAtEcal.y(), clusterPosition.y()); + aida.histogram2D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "track mom vs ECal E").fill(fsPart.getMomentum().magnitude(), fsPart.getEnergy()); // if(dy<-20) // System.out.println("Big deltaY...") @@ -186,8 +220,8 @@ nTotUnAss++; //and keep a running total for averaging } } - aida.histogram1D(plotDir + "Number of unassociated tracks per event").fill(nUnAssTracks); - aida.histogram1D(plotDir + "Number of photons per event").fill(nPhotons); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Number of unassociated tracks per event").fill(nUnAssTracks); + aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Number of photons per event").fill(nPhotons); } @Override @@ -206,21 +240,23 @@ IAnalysisFactory analysisFactory = IAnalysisFactory.create(); IFitFactory fitFactory = analysisFactory.createFitFactory(); IFitter fitter = fitFactory.createFitter("chi2"); - IHistogram1D beamE = aida.histogram1D(plotDir + "Beam Electrons Pz (GeV)"); + IHistogram1D beamE = aida.histogram1D(plotDir + finalStateParticlesColName + "/" + triggerType+ "/" + "Beam Electrons Total P (GeV)"); IFitResult result = fitBeamEnergyPeak(beamE, fitter, "range=\"(-10.0,10.0)\""); - double[] pars = result.fittedParameters(); - for (int i = 0; i < 5; i++) - System.out.println("Beam Energy Peak: " + result.fittedParameterNames()[i] + " = " + pars[i]); - - monitoredQuantityMap.put(fpQuantNames[0], (double) nTotEle / nRecoEvents); - monitoredQuantityMap.put(fpQuantNames[1], (double) nTotPos / nRecoEvents); - monitoredQuantityMap.put(fpQuantNames[2], (double) nTotPhotons / nRecoEvents); - monitoredQuantityMap.put(fpQuantNames[3], (double) nTotUnAss / nRecoEvents); - monitoredQuantityMap.put(fpQuantNames[4], (double) sumdelX / nTotAss); - monitoredQuantityMap.put(fpQuantNames[5], (double) sumdelY / nTotAss); - monitoredQuantityMap.put(fpQuantNames[6], (double) sumEoverP / nTotAss); - monitoredQuantityMap.put(fpQuantNames[7], (double) pars[1]); - monitoredQuantityMap.put(fpQuantNames[8], (double) pars[2]); + if (result != null) { + double[] pars = result.fittedParameters(); + for (int i = 0; i < 5; i++) + System.out.println("Beam Energy Peak: " + result.fittedParameterNames()[i] + " = " + pars[i]); + monitoredQuantityMap.put(finalStateParticlesColName + " " + triggerType + " " + fpQuantNames[7], (double) pars[1]); + monitoredQuantityMap.put(finalStateParticlesColName + " " + triggerType + " " + fpQuantNames[8], (double) pars[2]); + } + monitoredQuantityMap.put(finalStateParticlesColName + " " + triggerType + " " + fpQuantNames[0], (double) nTotEle / nRecoEvents); + monitoredQuantityMap.put(finalStateParticlesColName + " " + triggerType + " " + fpQuantNames[1], (double) nTotPos / nRecoEvents); + monitoredQuantityMap.put(finalStateParticlesColName + " " + triggerType + " " + fpQuantNames[2], (double) nTotPhotons / nRecoEvents); + monitoredQuantityMap.put(finalStateParticlesColName + " " + triggerType + " " + fpQuantNames[3], (double) nTotUnAss / nRecoEvents); + monitoredQuantityMap.put(finalStateParticlesColName + " " + triggerType + " " + fpQuantNames[4], (double) sumdelX / nTotAss); + monitoredQuantityMap.put(finalStateParticlesColName + " " + triggerType + " " + fpQuantNames[5], (double) sumdelY / nTotAss); + monitoredQuantityMap.put(finalStateParticlesColName + " " + triggerType + " " + fpQuantNames[6], (double) sumEoverP / nTotAss); + IPlotter plotter = analysisFactory.createPlotterFactory().create("Beam Energy Electrons"); IPlotterStyle pstyle = plotter.style(); @@ -228,7 +264,7 @@ pstyle.dataStyle().fillStyle().setColor("green"); pstyle.dataStyle().lineStyle().setColor("black"); plotter.region(0).plot(beamE); - plotter.region(0).plot(result.fittedFunction()); +// plotter.region(0).plot(result.fittedFunction()); if (outputPlots) try { plotter.writeToFile(outputPlotDir + "beamEnergyElectrons.png"); @@ -249,7 +285,14 @@ // return fitter.fit(h1d, "g+p1", init, range); double[] init = {20.0, 2.2, 0.12, 10, 0.0}; // double[] init = {20.0, 2.2, 0.1}; - return fitter.fit(h1d, "g+p1", init); + IFitResult ifr = null; + try { + ifr = fitter.fit(h1d, "g+p1", init); + } catch (RuntimeException ex) { + System.out.println(this.getClass().getSimpleName() + ": caught exception in fitGaussian"); + } + + return ifr; } } Modified: java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/SvtMonitoring.java ============================================================================= --- java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/SvtMonitoring.java (original) +++ java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/SvtMonitoring.java Fri Jun 12 15:27:10 2015 @@ -8,14 +8,11 @@ import hep.aida.IHistogram2D; import hep.aida.IPlotter; import hep.aida.IPlotterStyle; -import hep.physics.vec.BasicHep3Vector; -import hep.physics.vec.Hep3Vector; import java.io.IOException; import java.sql.SQLException; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import org.hps.recon.tracking.FittedRawTrackerHit; @@ -26,7 +23,6 @@ import org.lcsim.event.LCRelation; import org.lcsim.event.RawTrackerHit; import org.lcsim.event.RelationalTable; -import org.lcsim.event.SimTrackerHit; import org.lcsim.event.TrackerHit; import org.lcsim.event.base.BaseRelationalTable; import org.lcsim.geometry.Detector; @@ -90,22 +86,22 @@ aida.tree().cd("/"); for (HpsSiSensor sensor : sensors) { //IHistogram1D occupancyPlot = aida.histogram1D(sensor.getName().replaceAll("Tracker_TestRunModule_", ""), 640, 0, 639); - IHistogram1D occupancyPlot = createSensorPlot(plotDir + "occupancy_", sensor, maxChannels, 0, maxChannels - 1); - IHistogram1D t0Plot = createSensorPlot(plotDir + "t0Hit_", sensor, 400, -100., 100.); - IHistogram1D nHits = createSensorPlot(plotDir + "nHitsPerEvent_", sensor, 100, -0.5, 99.5); - IHistogram1D pileup = createSensorPlot(plotDir + "nFitsPerHit_", sensor, 3, 0.5, 3.5); - - IHistogram1D amplitudePlot = createSensorPlot(plotDir + "amplitude_", sensor, 50, 0, 4000.0); - IHistogram2D t0AmpPlot = createSensorPlot2D(plotDir + "t0AmpHit_", sensor, 200, -100., 100., 50, 0, 4000.0); - IHistogram2D t0ChanPlot = createSensorPlot2D(plotDir + "t0ChanBigHit_", sensor, 640, -0.5, 639.5, 200, -100., 100.); - IHistogram2D ampChanPlot = createSensorPlot2D(plotDir + "ampChanHit_", sensor, 640, -0.5, 639.5, 50, 0, 4000); - IHistogram2D chiprobChanPlot = createSensorPlot2D(plotDir + "chiprobChanBigHit_", sensor, 640, -0.5, 639.5, 50, 0, 1.0); - IHistogram2D t0TrigTimeHitPlot = createSensorPlot2D(plotDir + "t0BigHitTrigTime_", sensor, 400, -100., 100., 6, -2, 22); - - IHistogram1D chiProbPlot = createSensorPlot(plotDir + "chiProb_", sensor, 50, 0, 1.0); - IHistogram1D t0ClusterPlot = createSensorPlot(plotDir + "t0Cluster_", sensor, 400, -100., 100.); - IHistogram2D t0TrigTimePlot = createSensorPlot2D(plotDir + "t0ClusterTrigTime_", sensor, 400, -100., 100., 6, -2, 22); - IHistogram1D dedxClusterPlot = createSensorPlot(plotDir + "electrons_", sensor, 50, 0., 10.); + IHistogram1D occupancyPlot = createSensorPlot(plotDir + triggerType + "/"+"occupancy_", sensor, maxChannels, 0, maxChannels - 1); + IHistogram1D t0Plot = createSensorPlot(plotDir + triggerType + "/"+"t0Hit_", sensor, 400, -100., 100.); + IHistogram1D nHits = createSensorPlot(plotDir + triggerType + "/"+"nHitsPerEvent_", sensor, 100, -0.5, 99.5); + IHistogram1D pileup = createSensorPlot(plotDir + triggerType + "/"+"nFitsPerHit_", sensor, 3, 0.5, 3.5); + + IHistogram1D amplitudePlot = createSensorPlot(plotDir + triggerType + "/"+"amplitude_", sensor, 50, 0, 4000.0); + IHistogram2D t0AmpPlot = createSensorPlot2D(plotDir + triggerType + "/"+"t0AmpHit_", sensor, 200, -100., 100., 50, 0, 4000.0); + IHistogram2D t0ChanPlot = createSensorPlot2D(plotDir + triggerType + "/"+"t0ChanBigHit_", sensor, 640, -0.5, 639.5, 200, -100., 100.); + IHistogram2D ampChanPlot = createSensorPlot2D(plotDir + triggerType + "/"+"ampChanHit_", sensor, 640, -0.5, 639.5, 50, 0, 4000); + IHistogram2D chiprobChanPlot = createSensorPlot2D(plotDir + triggerType + "/"+"chiprobChanBigHit_", sensor, 640, -0.5, 639.5, 50, 0, 1.0); + IHistogram2D t0TrigTimeHitPlot = createSensorPlot2D(plotDir + triggerType + "/"+"t0BigHitTrigTime_", sensor, 400, -100., 100., 6, 0, 24); + + IHistogram1D chiProbPlot = createSensorPlot(plotDir + triggerType + "/"+"chiProb_", sensor, 50, 0, 1.0); + IHistogram1D t0ClusterPlot = createSensorPlot(plotDir + triggerType + "/"+"t0Cluster_", sensor, 400, -100., 100.); + IHistogram2D t0TrigTimePlot = createSensorPlot2D(plotDir + triggerType + "/"+"t0ClusterTrigTime_", sensor, 400, -100., 100., 6, 0, 24); + IHistogram1D dedxClusterPlot = createSensorPlot(plotDir + triggerType + "/"+"electrons_", sensor, 50, 0., 10.); occupancyPlot.reset(); } @@ -115,6 +111,11 @@ } public void process(EventHeader event) { + + //check to see if this event is from the correct trigger (or "all"); + if (!matchTrigger(event)) + return; + /* increment the strip occupancy arrays */ Map<String, Integer> hitsPerSensor = new HashMap<String, Integer>(); @@ -135,7 +136,7 @@ ++eventCountRaw; } for (HpsSiSensor sensor : sensors) { - IHistogram1D sensorHist = getSensorPlot(plotDir + "nHitsPerEvent_", sensor); + IHistogram1D sensorHist = getSensorPlot(plotDir + triggerType + "/"+"nHitsPerEvent_", sensor); Integer nHits = hitsPerSensor.get(sensor.getName()); if (nHits == null) { sensorHist.fill(0); @@ -162,16 +163,16 @@ double amp = ShapeFitParameters.getAmp(pars); double chiProb = ShapeFitParameters.getChiProb(pars); int channel = rth.getIdentifierFieldValue("strip"); - getSensorPlot(plotDir + "nFitsPerHit_", sensorName).fill(rthtofit.allFrom(rth).size()); - getSensorPlot(plotDir + "t0Hit_", sensorName).fill(t0); - getSensorPlot(plotDir + "amplitude_", sensorName).fill(amp); - getSensorPlot2D(plotDir + "t0AmpHit_", sensorName).fill(t0, amp); - getSensorPlot(plotDir + "chiProb_", sensorName).fill(chiProb); - getSensorPlot2D(plotDir + "ampChanHit_", sensorName).fill(channel, amp); + getSensorPlot(plotDir + triggerType + "/"+"nFitsPerHit_", sensorName).fill(rthtofit.allFrom(rth).size()); + getSensorPlot(plotDir + triggerType + "/"+"t0Hit_", sensorName).fill(t0); + getSensorPlot(plotDir + triggerType + "/"+"amplitude_", sensorName).fill(amp); + getSensorPlot2D(plotDir + triggerType + "/"+"t0AmpHit_", sensorName).fill(t0, amp); + getSensorPlot(plotDir + triggerType + "/"+"chiProb_", sensorName).fill(chiProb); + getSensorPlot2D(plotDir + triggerType + "/"+"ampChanHit_", sensorName).fill(channel, amp); if (amp > 1000.0) { - getSensorPlot2D(plotDir + "t0ChanBigHit_", sensorName).fill(channel, t0); - getSensorPlot2D(plotDir + "chiprobChanBigHit_", sensorName).fill(channel, chiProb); - getSensorPlot2D(plotDir + "t0BigHitTrigTime_", sensorName).fill(t0, event.getTimeStamp() % 24); + getSensorPlot2D(plotDir + triggerType + "/"+"t0ChanBigHit_", sensorName).fill(channel, t0); + getSensorPlot2D(plotDir + triggerType + "/"+"chiprobChanBigHit_", sensorName).fill(channel, chiProb); + getSensorPlot2D(plotDir + triggerType + "/"+"t0BigHitTrigTime_", sensorName).fill(t0, event.getTimeStamp() % 24); } } ++eventCountFit; @@ -185,9 +186,9 @@ double t0 = cluster.getTime(); double dedx = cluster.getdEdx() * 1e6; // System.out.println("dedx = "+dedx); - getSensorPlot(plotDir + "t0Cluster_", sensorName).fill(t0); - getSensorPlot2D(plotDir + "t0ClusterTrigTime_", sensorName).fill(t0, event.getTimeStamp() % 24); - getSensorPlot(plotDir + "electrons_", sensorName).fill(dedx); + getSensorPlot(plotDir + triggerType + "/"+"t0Cluster_", sensorName).fill(t0); + getSensorPlot2D(plotDir + triggerType + "/"+"t0ClusterTrigTime_", sensorName).fill(t0, event.getTimeStamp() % 24); + getSensorPlot(plotDir + triggerType + "/"+"electrons_", sensorName).fill(dedx); } } } @@ -274,7 +275,7 @@ for (HpsSiSensor sensor : sensors) { Double avg = 0.0; //IHistogram1D sensorHist = aida.histogram1D(sensor.getName()); - IHistogram1D sensorHist = getSensorPlot(plotDir + "occupancy_", sensor); + IHistogram1D sensorHist = getSensorPlot(plotDir + triggerType + "/"+"occupancy_", sensor); sensorHist.reset(); int[] strips = occupancyMap.get(sensor.getName()); for (int i = 0; i < strips.length; i++) { @@ -309,7 +310,7 @@ int irTop = 0; int irBot = 0; for (HpsSiSensor sensor : sensors) { - IHistogram1D sensPlot = getSensorPlot(plotDir + "t0Hit_", sensor); + IHistogram1D sensPlot = getSensorPlot(plotDir + triggerType + "/"+"t0Hit_", sensor); IFitResult result = fitGaussian(sensPlot, fitter, "range=\"(-8.0,8.0)\""); boolean isTop = sensor.isTopLayer(); @@ -357,9 +358,9 @@ @Override public void printDQMData() { for (HpsSiSensor sensor : sensors) { - System.out.println(avgOccupancyNames.get(sensor.getName()) + ": " + avgOccupancyMap.get(sensor.getName())); - System.out.println(avgt0Names.get(sensor.getName()) + ": " + avgt0Map.get(sensor.getName())); - System.out.println(sigt0Names.get(sensor.getName()) + ": " + sigt0Map.get(sensor.getName())); + System.out.println(avgOccupancyNames.get(sensor.getName()) + " " +triggerType+" " + avgOccupancyMap.get(sensor.getName())); + System.out.println(avgt0Names.get(sensor.getName()) + " " +triggerType+" " + avgt0Map.get(sensor.getName())); + System.out.println(sigt0Names.get(sensor.getName()) + " " +triggerType+" " + sigt0Map.get(sensor.getName())); } } Modified: java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/TrackingMonitoring.java ============================================================================= --- java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/TrackingMonitoring.java (original) +++ java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/TrackingMonitoring.java Fri Jun 12 15:27:10 2015 @@ -1,10 +1,15 @@ package org.hps.analysis.dataquality; +import hep.aida.IFitFactory; +import hep.aida.IFitResult; +import hep.aida.IFitter; import hep.aida.IHistogram1D; import hep.aida.IHistogram2D; +import hep.physics.vec.Hep3Vector; import java.util.Collection; import java.util.List; import java.util.Map; +import org.hps.recon.tracking.TrackUtils; import org.lcsim.detector.tracker.silicon.HpsSiSensor; import org.lcsim.event.EventHeader; import org.lcsim.event.LCRelation; @@ -15,6 +20,7 @@ import org.lcsim.event.base.BaseRelationalTable; import org.lcsim.geometry.Detector; import org.lcsim.geometry.IDDecoder; +import org.lcsim.util.aida.AIDA; /** * DQM driver for reconstructed track quantities plots things like number of @@ -46,7 +52,92 @@ double sumslope = 0; double sumchisq = 0; private final String plotDir = "Tracks/"; + private final String positronDir = "Positrons/"; + private final String electronDir = "Electrons/"; + private final String topDir = "Top/"; + private final String botDir = "Bottom/"; + private final String hthplotDir = "HelicalTrackHits/"; + private final String timeresidDir = "HitTimeResiduals/"; String[] trackingQuantNames = {"avg_N_tracks", "avg_N_hitsPerTrack", "avg_d0", "avg_z0", "avg_absslope", "avg_chi2"}; + int nmodules = 6; + IHistogram1D[] hthTop = new IHistogram1D[nmodules]; + IHistogram1D[] hthBot = new IHistogram1D[nmodules]; + IHistogram2D[] xvsyTop = new IHistogram2D[nmodules]; + IHistogram2D[] xvsyBot = new IHistogram2D[nmodules]; + IHistogram2D[] xvsyOnTrackTop = new IHistogram2D[nmodules]; + IHistogram2D[] xvsyOnTrackBot = new IHistogram2D[nmodules]; + IHistogram2D[] timevstimeTop = new IHistogram2D[nmodules]; + IHistogram2D[] timevstimeBot = new IHistogram2D[nmodules]; + IHistogram2D[] timevstimeOnTrackTop = new IHistogram2D[nmodules]; + IHistogram2D[] timevstimeOnTrackBot = new IHistogram2D[nmodules]; + IHistogram1D[] deltaTOnTrackTop = new IHistogram1D[nmodules]; + IHistogram1D[] deltaTOnTrackBot = new IHistogram1D[nmodules]; + + IHistogram1D trkYAtECALTop; + IHistogram1D trkYAtECALBot; + + IHistogram1D trkChi2Pos; + IHistogram1D trkChi2Ele; + IHistogram1D trkChi2Top; + IHistogram1D trkChi2Bot; + + IHistogram1D nTracksPos; + IHistogram1D nTracksEle; + IHistogram1D nTracksTop; + IHistogram1D nTracksBot; + + IHistogram1D trkd0Pos; + IHistogram1D trkd0Ele; + IHistogram1D trkd0Top; + IHistogram1D trkd0Bot; + + IHistogram1D trkphiPos; + IHistogram1D trkphiEle; + IHistogram1D trkphiTop; + IHistogram1D trkphiBot; + + IHistogram1D trkomegaPos; + IHistogram1D trkomegaEle; + IHistogram1D trkomegaTop; + IHistogram1D trkomegaBot; + + IHistogram1D trklamPos; + IHistogram1D trklamEle; + IHistogram1D trklamTop; + IHistogram1D trklamBot; + + IHistogram1D trkz0Pos; + IHistogram1D trkz0Ele; + IHistogram1D trkz0Top; + IHistogram1D trkz0Bot; + + IHistogram1D nHitsPos; + IHistogram1D nHitsEle; + IHistogram1D nHitsTop; + IHistogram1D nHitsBot; + + IHistogram1D trkTimePos; + IHistogram1D trkTimeEle; + IHistogram1D trkTimeTop; + IHistogram1D trkTimeBot; + + IHistogram2D d0VsPhi0; + IHistogram2D d0Vsomega; + IHistogram2D d0Vslambda; + IHistogram2D d0Vsz0; + IHistogram2D phi0Vsomega; + IHistogram2D phi0Vslambda; + IHistogram2D phi0Vsz0; + IHistogram2D omegaVslambda; + IHistogram2D omegaVsz0; + IHistogram2D lamdbaVsz0; + + double d0Cut = 5.0; + double phiCut = 0.2; + double omegaCut = 0.0005; + double lambdaCut = 0.1; + double z0Cut = 1.0; + double timeCut=24.0; public void setHelicalTrackHitCollectionName(String helicalTrackHitCollectionName) { this.helicalTrackHitCollectionName = helicalTrackHitCollectionName; @@ -61,18 +152,89 @@ this.detector = detector; aida.tree().cd("/"); - IHistogram1D trkChi2 = aida.histogram1D(plotDir + "Track Chi2", 25, 0, 25.0); - IHistogram1D nTracks = aida.histogram1D(plotDir + "Tracks per Event", 6, 0, 6); - IHistogram1D trkd0 = aida.histogram1D(plotDir + "d0 ", 25, -5.0, 5.0); - IHistogram1D trkphi = aida.histogram1D(plotDir + "sinphi ", 25, -0.2, 0.2); - IHistogram1D trkomega = aida.histogram1D(plotDir + "omega ", 25, -0.00025, 0.00025); - IHistogram1D trklam = aida.histogram1D(plotDir + "tan(lambda) ", 25, -0.1, 0.1); - IHistogram1D trkz0 = aida.histogram1D(plotDir + "z0 ", 25, -1.0, 1.0); - IHistogram1D nHits = aida.histogram1D(plotDir + "Hits per Track", 2, 5, 7); - IHistogram1D trackMeanTime = aida.histogram1D(plotDir + "Mean time of hits on track", 400, -100., 100.); - IHistogram1D trackRMSTime = aida.histogram1D(plotDir + "RMS time of hits on track", 200, 0., 15.); - IHistogram2D trackChi2RMSTime = aida.histogram2D(plotDir + "Track chi2 vs. RMS time of hits", 200, 0., 15., 25, 0, 25.0); - IHistogram1D seedRMSTime = aida.histogram1D(plotDir + "RMS time of hits on seed layers", 200, 0., 15.); + IHistogram1D trkChi2 = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Track Chi2", 50, 0, 25.0); + IHistogram1D nTracks = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Tracks per Event", 6, 0, 6); + IHistogram1D trkd0 = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "d0 ", 50, -d0Cut, d0Cut); + IHistogram1D trkphi = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "sinphi ", 50, -phiCut, phiCut); + IHistogram1D trkomega = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "omega ", 50, -omegaCut, omegaCut); + IHistogram1D trklam = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "tan(lambda) ", 50, -lambdaCut, lambdaCut); + IHistogram1D trkz0 = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "z0 ", 50, -z0Cut, z0Cut); + IHistogram1D nHits = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Hits per Track", 4, 3, 7); + IHistogram1D trackMeanTime = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Mean time of hits on track", 100, -timeCut, timeCut); + IHistogram1D trackRMSTime = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "RMS time of hits on track", 100, 0., 15.); + IHistogram2D trackChi2RMSTime = aida.histogram2D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Track chi2 vs. RMS time of hits", 100, 0., 15., 25, 0, 25.0); + IHistogram1D seedRMSTime = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "RMS time of hits on seed layers", 100, 0., 15.); + trkYAtECALTop = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Track Y at ECAL: Top", 100, 0, 100); + trkYAtECALBot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Track Y at ECAL: Bot", 100, 0, 100); + for (int i = 1; i <= nmodules; i++) { + xvsyTop[i - 1] = aida.histogram2D(plotDir + triggerType + "/" + hthplotDir + "Module " + i + " Top", 250, -100, 150, 30, 0, 60); + xvsyBot[i - 1] = aida.histogram2D(plotDir + triggerType + "/" + hthplotDir + "Module " + i + " Bottom", 250, -100, 150, 30, 0, 60); + xvsyOnTrackTop[i - 1] = aida.histogram2D(plotDir + triggerType + "/" + hthplotDir + "Module " + i + " Top, Hits On Tracks", 250, -100, 150, 30, 0, 60); + xvsyOnTrackBot[i - 1] = aida.histogram2D(plotDir + triggerType + "/" + hthplotDir + "Module " + i + " Bottom, Hits On Tracks", 250, -100, 150, 30, 0, 60); + timevstimeTop[i - 1] = aida.histogram2D(plotDir + triggerType + "/" + hthplotDir + "Module " + i + " Top: Hit Times", 30, -15, 15, 30, -15, 15); + timevstimeBot[i - 1] = aida.histogram2D(plotDir + triggerType + "/" + hthplotDir + "Module " + i + " Bottom: Hit Times", 30, -15, 15, 30, -15, 15); + hthTop[i - 1] = aida.histogram1D(plotDir + triggerType + "/" + hthplotDir + "Module " + i + " Top: Track Hits", 25, 0, 25); + hthBot[i - 1] = aida.histogram1D(plotDir + triggerType + "/" + hthplotDir + "Module " + i + " Bottom: Track Hits", 25, 0, 25); + timevstimeOnTrackTop[i - 1] = aida.histogram2D(plotDir + triggerType + "/" + hthplotDir + "Module " + i + " Top: Hit Times, Hits On Tracks", 30, -15, 15, 30, -15, 15); + timevstimeOnTrackBot[i - 1] = aida.histogram2D(plotDir + triggerType + "/" + hthplotDir + "Module " + i + " Bottom: Hit Times, Hits On Tracks", 30, -15, 15, 30, -15, 15); + deltaTOnTrackTop[i - 1] = aida.histogram1D(plotDir + triggerType + "/" + hthplotDir + "Module " + i + " Top: Hit Time Differences, Hits On Tracks", 50, -25, 25); + deltaTOnTrackBot[i - 1] = aida.histogram1D(plotDir + triggerType + "/" + hthplotDir + "Module " + i + " Bottom: Hit Time Differences, Hits On Tracks", 50, -25, 25); + } + + trkChi2Pos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "Track Chi2", 25, 0, 25.0); + nTracksPos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "Tracks per Event", 6, 0, 6); + trkd0Pos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "d0 ", 50, -d0Cut, d0Cut); + trkphiPos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "sinphi ", 50, -phiCut, phiCut); + trkomegaPos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "omega ", 50, -omegaCut, omegaCut); + trklamPos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "tan(lambda) ", 50, -lambdaCut, lambdaCut); + trkz0Pos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "z0 ", 50, -z0Cut, z0Cut); + nHitsPos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "Hits per Track", 4, 3, 7); + trkTimePos = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + positronDir + "Mean time of hits on track", 100, -timeCut, timeCut); + + trkChi2Ele = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "Track Chi2", 25, 0, 25.0); + nTracksEle = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "Tracks per Event", 6, 0, 6); + trkd0Ele = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "d0 ", 50, -d0Cut, d0Cut); + trkphiEle = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "sinphi ", 50, -phiCut, phiCut); + trkomegaEle = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "omega ", 50, -omegaCut, omegaCut); + trklamEle = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "tan(lambda) ", 50, -lambdaCut, lambdaCut); + trkz0Ele = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "z0 ", 50, -z0Cut, z0Cut); + nHitsEle = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "Hits per Track", 4, 3, 7); + trkTimeEle = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + electronDir + "Mean time of hits on track", 100, -timeCut, timeCut); + + trkChi2Top = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "Track Chi2", 25, 0, 25.0); + nTracksTop = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "Tracks per Event", 6, 0, 6); + trkd0Top = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "d0 ", 50, -d0Cut, d0Cut); + trkphiTop = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "sinphi ", 50, -phiCut, phiCut); + trkomegaTop = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "omega ", 50, -omegaCut, omegaCut); + trklamTop = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "tan(lambda) ", 50, 0.0, lambdaCut); + trkz0Top = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "z0 ", 50, -z0Cut, z0Cut); + nHitsTop = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "Hits per Track", 4, 3, 7); + trkTimeTop = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + topDir + "Mean time of hits on track", 100, -timeCut, timeCut); + + trkChi2Bot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "Track Chi2", 25, 0, 25.0); + nTracksBot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "Tracks per Event", 6, 0, 6); + trkd0Bot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "d0 ", 50, -d0Cut, d0Cut); + trkphiBot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "sinphi ", 50, -phiCut, phiCut); + trkomegaBot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "omega ", 50, -omegaCut, omegaCut); + trklamBot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "tan(lambda) ", 50, 0, lambdaCut); + trkz0Bot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "z0 ", 50, -z0Cut, z0Cut); + nHitsBot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "Hits per Track", 4, 3, 7); + trkTimeBot = aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + botDir + "Mean time of hits on track", 100, -timeCut, timeCut); + + //correlation plots + d0VsPhi0 = aida.histogram2D(plotDir + trackCollectionName + "/" + triggerType + "/" + "d0 vs sinphi", 50, -d0Cut, d0Cut, 50, -phiCut, phiCut); + d0Vsomega = aida.histogram2D(plotDir + trackCollectionName + "/" + triggerType + "/" + "d0 vs omega", 50, -d0Cut, d0Cut, 50, -omegaCut, omegaCut); + d0Vslambda = aida.histogram2D(plotDir + trackCollectionName + "/" + triggerType + "/" + "d0 vs tan(lambda)", 50, -d0Cut, d0Cut, 50, -lambdaCut, lambdaCut); + d0Vsz0 = aida.histogram2D(plotDir + trackCollectionName + "/" + triggerType + "/" + "d0 vs z0", 50, -d0Cut, d0Cut, 50, -z0Cut, z0Cut); + + phi0Vsomega = aida.histogram2D(plotDir + trackCollectionName + "/" + triggerType + "/" + "phi0 vs omega", 50, -phiCut, phiCut, 50, -omegaCut, omegaCut); + phi0Vslambda = aida.histogram2D(plotDir + trackCollectionName + "/" + triggerType + "/" + "phi0 vs tan(lambda)", 50, -phiCut, phiCut, 50, -lambdaCut, lambdaCut); + phi0Vsz0 = aida.histogram2D(plotDir + trackCollectionName + "/" + triggerType + "/" + "phi0 vs z0", 50, -phiCut, phiCut, 50, -z0Cut, z0Cut); + + omegaVslambda = aida.histogram2D(plotDir + trackCollectionName + "/" + triggerType + "/" + "omega vs tan(lambda)", 50, -omegaCut, omegaCut, 50, -lambdaCut, lambdaCut); + omegaVsz0 = aida.histogram2D(plotDir + trackCollectionName + "/" + triggerType + "/" + "omega vs z0", 50, -omegaCut, omegaCut, 50, -z0Cut, z0Cut); + + lamdbaVsz0 = aida.histogram2D(plotDir + trackCollectionName + "/" + triggerType + "/" + "lambda vs z0", 50, -lambdaCut, lambdaCut, 50, -z0Cut, z0Cut); // Make a list of SiSensors in the SVT. sensors = this.detector.getSubdetector(trackerName).getDetectorElement().findDescendants(HpsSiSensor.class); @@ -81,7 +243,7 @@ aida.tree().cd("/"); for (HpsSiSensor sensor : sensors) { //IHistogram1D occupancyPlot = aida.histogram1D(sensor.getName().replaceAll("Tracker_TestRunModule_", ""), 640, 0, 639); - IHistogram1D hitTimeResidual = createSensorPlot(plotDir + "hitTimeResidual_", sensor, 100, -20, 20); + IHistogram1D hitTimeResidual = createSensorPlot(plotDir + trackCollectionName + "/" + triggerType + "/" + timeresidDir + "hitTimeResidual_", sensor, 100, -20, 20); } } @@ -91,51 +253,115 @@ aida.tree().cd("/"); + if (!event.hasCollection(LCRelation.class, helicalTrackHitRelationsCollectionName) || !event.hasCollection(LCRelation.class, rotatedHelicalTrackHitRelationsCollectionName)) + return; RelationalTable hittostrip = new BaseRelationalTable(RelationalTable.Mode.MANY_TO_MANY, RelationalTable.Weighting.UNWEIGHTED); List<LCRelation> hitrelations = event.get(LCRelation.class, helicalTrackHitRelationsCollectionName); - for (LCRelation relation : hitrelations) { - if (relation != null && relation.getFrom() != null && relation.getTo() != null) { + for (LCRelation relation : hitrelations) + if (relation != null && relation.getFrom() != null && relation.getTo() != null) hittostrip.add(relation.getFrom(), relation.getTo()); - } - } RelationalTable hittorotated = new BaseRelationalTable(RelationalTable.Mode.ONE_TO_ONE, RelationalTable.Weighting.UNWEIGHTED); List<LCRelation> rotaterelations = event.get(LCRelation.class, rotatedHelicalTrackHitRelationsCollectionName); - for (LCRelation relation : rotaterelations) { - if (relation != null && relation.getFrom() != null && relation.getTo() != null) { + for (LCRelation relation : rotaterelations) + if (relation != null && relation.getFrom() != null && relation.getTo() != null) hittorotated.add(relation.getFrom(), relation.getTo()); + + if (!event.hasCollection(TrackerHit.class, helicalTrackHitCollectionName)) + return; + + //check to see if this event is from the correct trigger (or "all"); + if (!matchTrigger(event)) + return; + /* This doesn't work on reco'ed files...fix me! */ + int[] topHits = {0, 0, 0, 0, 0, 0}; + int[] botHits = {0, 0, 0, 0, 0, 0}; + List<TrackerHit> hth = event.get(TrackerHit.class, helicalTrackHitCollectionName); + for (TrackerHit hit : hth) { + int module = -99; + int layer = ((RawTrackerHit) hit.getRawHits().get(0)).getLayerNumber(); + module = layer/2 + 1; + + Collection<TrackerHit> htsList = hittostrip.allFrom(hit); + double hitTimes[] = new double[2]; + for (TrackerHit hts : htsList) { + int stripLayer = ((HpsSiSensor) ((RawTrackerHit) hts.getRawHits().get(0)).getDetectorElement()).getLayerNumber(); + hitTimes[stripLayer%2] = hts.getTime(); } + + if (hit.getPosition()[1] > 0) { + topHits[module - 1]++; + xvsyTop[module - 1].fill(hit.getPosition()[0], hit.getPosition()[1]); + timevstimeTop[module - 1].fill(hitTimes[0],hitTimes[1]); + } else { + botHits[module - 1]++; + xvsyBot[module - 1].fill(hit.getPosition()[0], Math.abs(hit.getPosition()[1])); + timevstimeBot[module - 1].fill(hitTimes[0],hitTimes[1]); + } + } + + for (int i = 0; i < nmodules; i++) { + hthTop[i].fill(topHits[i]); + hthBot[i].fill(botHits[i]); } if (!event.hasCollection(Track.class, trackCollectionName)) { - aida.histogram1D(plotDir + "Tracks per Event").fill(0); + aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Tracks per Event").fill(0); return; } nEvents++; List<Track> tracks = event.get(Track.class, trackCollectionName); nTotTracks += tracks.size(); - aida.histogram1D(plotDir + "Tracks per Event").fill(tracks.size()); + aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Tracks per Event").fill(tracks.size()); + int cntEle = 0; + int cntPos = 0; + int cntTop = 0; + int cntBot = 0; + double ecalFace = 1393.0;//mm for (Track trk : tracks) { + Hep3Vector trackPosAtEcalFace = TrackUtils.extrapolateTrack(trk, ecalFace); + double yAtECal = trackPosAtEcalFace.y(); + if (yAtECal > 0) + trkYAtECALTop.fill(yAtECal); + else + trkYAtECALBot.fill(Math.abs(yAtECal)); nTotHits += trk.getTrackerHits().size(); - aida.histogram1D(plotDir + "Track Chi2").fill(trk.getChi2()); - aida.histogram1D(plotDir + "Hits per Track").fill(trk.getTrackerHits().size()); - aida.histogram1D(plotDir + "d0 ").fill(trk.getTrackStates().get(0).getD0()); - aida.histogram1D(plotDir + "sinphi ").fill(Math.sin(trk.getTrackStates().get(0).getPhi())); - aida.histogram1D(plotDir + "omega ").fill(trk.getTrackStates().get(0).getOmega()); - aida.histogram1D(plotDir + "tan(lambda) ").fill(trk.getTrackStates().get(0).getTanLambda()); - aida.histogram1D(plotDir + "z0 ").fill(trk.getTrackStates().get(0).getZ0()); - sumd0 += trk.getTrackStates().get(0).getD0(); - sumz0 += trk.getTrackStates().get(0).getZ0(); - sumslope += Math.abs(trk.getTrackStates().get(0).getTanLambda()); - sumchisq += trk.getChi2(); - + + double d0 = trk.getTrackStates().get(0).getD0(); + double sinphi0 = Math.sin(trk.getTrackStates().get(0).getPhi()); + double omega = trk.getTrackStates().get(0).getOmega(); + double lambda = trk.getTrackStates().get(0).getTanLambda(); + double z0 = trk.getTrackStates().get(0).getZ0(); + aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Track Chi2").fill(trk.getChi2()); + aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Hits per Track").fill(trk.getTrackerHits().size()); + aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "d0 ").fill(trk.getTrackStates().get(0).getD0()); + aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "sinphi ").fill(Math.sin(trk.getTrackStates().get(0).getPhi())); + aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "omega ").fill(trk.getTrackStates().get(0).getOmega()); + aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "tan(lambda) ").fill(trk.getTrackStates().get(0).getTanLambda()); + aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "z0 ").fill(trk.getTrackStates().get(0).getZ0()); + d0VsPhi0.fill(d0, sinphi0); + d0Vsomega.fill(d0, omega); + d0Vslambda.fill(d0, lambda); + d0Vsz0.fill(d0, z0); + phi0Vsomega.fill(sinphi0, omega); + phi0Vslambda.fill(sinphi0, lambda); + phi0Vsz0.fill(sinphi0, z0); + omegaVslambda.fill(omega, lambda); + omegaVsz0.fill(omega, z0); + lamdbaVsz0.fill(lambda, z0); + + //below does not work on recon'ed files int nStrips = 0; int nSeedStrips = 0; double meanTime = 0; double meanSeedTime = 0; for (TrackerHit hit : trk.getTrackerHits()) { Collection<TrackerHit> htsList = hittostrip.allFrom(hittorotated.from(hit)); + double hitTimes[] = new double[2]; for (TrackerHit hts : htsList) { + int stripLayer = ((HpsSiSensor) ((RawTrackerHit) hts.getRawHits().get(0)).getDetectorElement()).getLayerNumber(); + hitTimes[stripLayer % 2] = hts.getTime(); + nStrips++; meanTime += hts.getTime(); int layer = ((HpsSiSensor) ((RawTrackerHit) hts.getRawHits().get(0)).getDetectorElement()).getLayerNumber(); @@ -144,6 +370,17 @@ meanSeedTime += hts.getTime(); } } + int module = ((RawTrackerHit) hit.getRawHits().get(0)).getLayerNumber() / 2 + 1; + + if (hit.getPosition()[2] > 0) { + xvsyOnTrackTop[module - 1].fill(hit.getPosition()[1], hit.getPosition()[2]); + timevstimeOnTrackTop[module - 1].fill(hitTimes[0], hitTimes[1]); + deltaTOnTrackTop[module - 1].fill(hitTimes[0] - hitTimes[1]); + } else { + xvsyOnTrackBot[module - 1].fill(hit.getPosition()[1], Math.abs(hit.getPosition()[2])); + timevstimeOnTrackBot[module - 1].fill(hitTimes[0], hitTimes[1]); + deltaTOnTrackBot[module - 1].fill(hitTimes[0] - hitTimes[1]); + } } meanTime /= nStrips; meanSeedTime /= nSeedStrips; @@ -156,50 +393,125 @@ rmsTime += Math.pow(hts.getTime() - meanTime, 2); HpsSiSensor sensor = (HpsSiSensor) ((RawTrackerHit) hts.getRawHits().get(0)).getDetectorElement(); int layer = sensor.getLayerNumber(); - if (layer <= 6) { + if (layer <= 6) rmsSeedTime += Math.pow(hts.getTime() - meanSeedTime, 2); - } String sensorName = getNiceSensorName(sensor); - getSensorPlot(plotDir + "hitTimeResidual_", sensorName).fill(hts.getTime() - meanTime); + getSensorPlot(plotDir + trackCollectionName + "/" + triggerType + "/" + timeresidDir + "hitTimeResidual_", sensorName).fill((hts.getTime() - meanTime) * nStrips / (nStrips - 1)); //correct residual for bias } } rmsTime = Math.sqrt(rmsTime / nStrips); - aida.histogram1D(plotDir + "Mean time of hits on track").fill(meanTime); - aida.histogram1D(plotDir + "RMS time of hits on track").fill(rmsTime); - aida.histogram2D(plotDir + "Track chi2 vs. RMS time of hits").fill(rmsTime, trk.getChi2()); + aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Mean time of hits on track").fill(meanTime); + aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "RMS time of hits on track").fill(rmsTime); + aida.histogram2D(plotDir + trackCollectionName + "/" + triggerType + "/" + "Track chi2 vs. RMS time of hits").fill(rmsTime, trk.getChi2()); rmsSeedTime = Math.sqrt(rmsSeedTime / nSeedStrips); - aida.histogram1D(plotDir + "RMS time of hits on seed layers").fill(rmsSeedTime); + aida.histogram1D(plotDir + trackCollectionName + "/" + triggerType + "/" + "RMS time of hits on seed layers").fill(rmsSeedTime); + + if (trk.getTrackStates().get(0).getOmega() < 0) {//positrons + trkChi2Pos.fill(trk.getChi2()); + nHitsPos.fill(trk.getTrackerHits().size()); + trkd0Pos.fill(trk.getTrackStates().get(0).getD0()); + trkphiPos.fill(Math.sin(trk.getTrackStates().get(0).getPhi())); + trkomegaPos.fill(trk.getTrackStates().get(0).getOmega()); + trklamPos.fill(trk.getTrackStates().get(0).getTanLambda()); + trkz0Pos.fill(trk.getTrackStates().get(0).getZ0()); + trkTimePos.fill(meanTime); + cntPos++; + } else { + trkChi2Ele.fill(trk.getChi2()); + nHitsEle.fill(trk.getTrackerHits().size()); + trkd0Ele.fill(trk.getTrackStates().get(0).getD0()); + trkphiEle.fill(Math.sin(trk.getTrackStates().get(0).getPhi())); + trkomegaEle.fill(trk.getTrackStates().get(0).getOmega()); + trklamEle.fill(trk.getTrackStates().get(0).getTanLambda()); + trkz0Ele.fill(trk.getTrackStates().get(0).getZ0()); + trkTimeEle.fill(meanTime); + cntEle++; + } + + if (trk.getTrackStates().get(0).getTanLambda() < 0) { + trkChi2Bot.fill(trk.getChi2()); + nHitsBot.fill(trk.getTrackerHits().size()); + trkd0Bot.fill(trk.getTrackStates().get(0).getD0()); + trkphiBot.fill(Math.sin(trk.getTrackStates().get(0).getPhi())); + trkomegaBot.fill(trk.getTrackStates().get(0).getOmega()); + trklamBot.fill(Math.abs(trk.getTrackStates().get(0).getTanLambda())); + trkz0Bot.fill(trk.getTrackStates().get(0).getZ0()); + trkTimeBot.fill(meanTime); + + cntBot++; + } else { + trkChi2Top.fill(trk.getChi2()); + nHitsTop.fill(trk.getTrackerHits().size()); + trkd0Top.fill(trk.getTrackStates().get(0).getD0()); + trkphiTop.fill(Math.sin(trk.getTrackStates().get(0).getPhi())); + trkomegaTop.fill(trk.getTrackStates().get(0).getOmega()); + trklamTop.fill(Math.abs(trk.getTrackStates().get(0).getTanLambda())); + trkz0Top.fill(trk.getTrackStates().get(0).getZ0()); + trkTimeTop.fill(meanTime); + cntTop++; + } + + sumd0 += trk.getTrackStates().get(0).getD0(); + sumz0 += trk.getTrackStates().get(0).getZ0(); + sumslope += Math.abs(trk.getTrackStates().get(0).getTanLambda()); + sumchisq += trk.getChi2(); + // System.out.format("%d seed strips, RMS time %f\n", nSeedStrips, rmsSeedTime); - // System.out.format("%d strips, mean time %f, RMS time %f\n", nStrips, meanTime, rmsTime); } + nTracksTop.fill(cntTop); + nTracksBot.fill(cntBot); + nTracksPos.fill(cntPos); + nTracksEle.fill(cntEle); } @Override public void calculateEndOfRunQuantities() { - monitoredQuantityMap.put(trackingQuantNames[0], (double) nTotTracks / nEvents); - monitoredQuantityMap.put(trackingQuantNames[1], (double) nTotHits / nTotTracks); - monitoredQuantityMap.put(trackingQuantNames[2], sumd0 / nTotTracks); - monitoredQuantityMap.put(trackingQuantNames[3], sumz0 / nTotTracks); - monitoredQuantityMap.put(trackingQuantNames[4], sumslope / nTotTracks); - monitoredQuantityMap.put(trackingQuantNames[5], sumchisq / nTotTracks); + IFitFactory fitFactory = AIDA.defaultInstance().analysisFactory().createFitFactory(); + IFitter fitter = fitFactory.createFitter("chi2"); + + for (HpsSiSensor sensor : sensors) { + //IHistogram1D occupancyPlot = aida.histogram1D(sensor.getName().replaceAll("Tracker_TestRunModule_", ""), 640, 0, 639); + IHistogram1D hitTimeResidual = getSensorPlot(plotDir + trackCollectionName + "/" + triggerType + "/" + timeresidDir + "hitTimeResidual_", getNiceSensorName(sensor)); + IFitResult result = fitGaussian(hitTimeResidual, fitter, "range=\"(-20.0,20.0)\""); + if (result != null) + System.out.format("%s\t%f\t%f\t%d\t%d\n", getNiceSensorName(sensor), result.fittedParameters()[1], result.fittedParameters()[2], sensor.getFebID(), sensor.getFebHybridID()); + } + + monitoredQuantityMap.put(trackCollectionName + " " + triggerType + " " + trackingQuantNames[0], (double) nTotTracks / nEvents); + monitoredQuantityMap.put(trackCollectionName + " " + triggerType + " " + trackingQuantNames[1], (double) nTotHits / nTotTracks); + monitoredQuantityMap.put(trackCollectionName + " " + triggerType + " " + trackingQuantNames[2], sumd0 / nTotTracks); + monitoredQuantityMap.put(trackCollectionName + " " + triggerType + " " + trackingQuantNames[3], sumz0 / nTotTracks); + monitoredQuantityMap.put(trackCollectionName + " " + triggerType + " " + trackingQuantNames[4], sumslope / nTotTracks); + monitoredQuantityMap.put(trackCollectionName + " " + triggerType + " " + trackingQuantNames[5], sumchisq / nTotTracks); + } + + IFitResult fitGaussian(IHistogram1D h1d, IFitter fitter, String range) { + double[] init = {h1d.maxBinHeight(), h1d.mean(), h1d.rms()}; + IFitResult ifr = null; + try { + ifr = fitter.fit(h1d, "g", init, range); + } catch (RuntimeException ex) { + System.out.println(this.getClass().getSimpleName() + ": caught exception in fitGaussian"); + } + return ifr; +// double[] init = {20.0, 0.0, 1.0, 20, -1}; +// return fitter.fit(h1d, "g+p1", init, range); } @Override public void printDQMData() { System.out.println("ReconMonitoring::printDQMData"); - for (Map.Entry<String, Double> entry : monitoredQuantityMap.entrySet()) { + for (Map.Entry<String, Double> entry : monitoredQuantityMap.entrySet()) System.out.println(entry.getKey() + " = " + entry.getValue()); - } System.out.println("*******************************"); } @Override public void printDQMStrings() { - for (Map.Entry<String, Double> entry : monitoredQuantityMap.entrySet()) { + for (Map.Entry<String, Double> entry : monitoredQuantityMap.entrySet()) System.out.println("ALTER TABLE dqm ADD " + entry.getKey() + " double;"); - } } private IHistogram1D getSensorPlot(String prefix, HpsSiSensor sensor) { Modified: java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/TrackingResiduals.java ============================================================================= --- java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/TrackingResiduals.java (original) +++ java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/TrackingResiduals.java Fri Jun 12 15:27:10 2015 @@ -55,16 +55,16 @@ aida.tree().cd("/"); resetOccupancyMap(); for (int i = 1; i <= nmodules; i++) { - IHistogram1D xresid = aida.histogram1D(plotDir + posresDir + "Module " + i + " Top x Residual", 50, -getRange(i, true), getRange(i, true)); - IHistogram1D yresid = aida.histogram1D(plotDir + posresDir + "Module " + i + " Top y Residual", 50, -getRange(i, false), getRange(i, false)); - IHistogram1D xresidbot = aida.histogram1D(plotDir + posresDir + "Module " + i + " Bot x Residual", 50, -getRange(i, true), getRange(i, true)); - IHistogram1D yresidbot = aida.histogram1D(plotDir + posresDir + "Module " + i + " Bot y Residual", 50, -getRange(i, false), getRange(i, false)); + IHistogram1D xresid = aida.histogram1D(plotDir + triggerType + "/"+posresDir + "Module " + i + " Top x Residual", 50, -getRange(i, true), getRange(i, true)); + IHistogram1D yresid = aida.histogram1D(plotDir + triggerType + "/"+posresDir + "Module " + i + " Top y Residual", 50, -getRange(i, false), getRange(i, false)); + IHistogram1D xresidbot = aida.histogram1D(plotDir + triggerType + "/"+posresDir + "Module " + i + " Bot x Residual", 50, -getRange(i, true), getRange(i, true)); + IHistogram1D yresidbot = aida.histogram1D(plotDir + triggerType + "/"+posresDir + "Module " + i + " Bot y Residual", 50, -getRange(i, false), getRange(i, false)); } for (int i = 1; i <= nmodules * 2; i++) { - IHistogram1D tresid = aida.histogram1D(plotDir + timeresDir + "HalfModule " + i + " t Residual", 50, -20, 20); - IHistogram1D utopresid = aida.histogram1D(plotDir + uresDir + "HalfModule " + i + " Top u Residual", 50, -getRange((i + 1) / 2, false), getRange((i + 1) / 2, false)); - IHistogram1D ubotresid = aida.histogram1D(plotDir + uresDir + "HalfModule " + i + " Bot u Residual", 50, -getRange((i + 1) / 2, false), getRange((i + 1) / 2, false)); + IHistogram1D tresid = aida.histogram1D(plotDir + triggerType + "/"+timeresDir + "HalfModule " + i + " t Residual", 50, -20, 20); + IHistogram1D utopresid = aida.histogram1D(plotDir + triggerType + "/"+uresDir + "HalfModule " + i + " Top u Residual", 50, -getRange((i + 1) / 2, false), getRange((i + 1) / 2, false)); + IHistogram1D ubotresid = aida.histogram1D(plotDir + triggerType + "/"+uresDir + "HalfModule " + i + " Bot u Residual", 50, -getRange((i + 1) / 2, false), getRange((i + 1) / 2, false)); } } @@ -75,7 +75,10 @@ return; if (!event.hasCollection(GenericObject.class, trackResidualsCollectionName)) return; - nEvents++; + //check to see if this event is from the correct trigger (or "all"); + if (!matchTrigger(event)) + return; + nEvents++; List<GenericObject> trdList = event.get(GenericObject.class, trackResidualsCollectionName); for (GenericObject trd : trdList) { int nResid = trd.getNDouble(); @@ -83,11 +86,11 @@ for (int i = 1; i <= nResid; i++) if (isBot == 1) { - aida.histogram1D(plotDir + posresDir + "Module " + i + " Bot x Residual").fill(trd.getDoubleVal(i - 1));//x is the double value in the generic object - aida.histogram1D(plotDir + posresDir + "Module " + i + " Bot y Residual").fill(trd.getFloatVal(i - 1));//y is the float value in the generic object + aida.histogram1D(plotDir + triggerType + "/"+posresDir + "Module " + i + " Bot x Residual").fill(trd.getDoubleVal(i - 1));//x is the double value in the generic object + aida.histogram1D(plotDir + triggerType + "/"+posresDir + "Module " + i + " Bot y Residual").fill(trd.getFloatVal(i - 1));//y is the float value in the generic object } else { - aida.histogram1D(plotDir + posresDir + "Module " + i + " Top x Residual").fill(trd.getDoubleVal(i - 1));//x is the double value in the generic object - aida.histogram1D(plotDir + posresDir + "Module " + i + " Top y Residual").fill(trd.getFloatVal(i - 1));//y is the float value in the generic object + aida.histogram1D(plotDir + triggerType + "/"+posresDir + "Module " + i + " Top x Residual").fill(trd.getDoubleVal(i - 1));//x is the double value in the generic object + aida.histogram1D(plotDir + triggerType + "/"+posresDir + "Module " + i + " Top y Residual").fill(trd.getFloatVal(i - 1));//y is the float value in the generic object } } @@ -95,7 +98,7 @@ for (GenericObject ttd : ttdList) { int nResid = ttd.getNDouble(); for (int i = 1; i <= nResid; i++) - aida.histogram1D(plotDir + timeresDir + "HalfModule " + i + " t Residual").fill(ttd.getDoubleVal(i - 1));//x is the double value in the generic object + aida.histogram1D(plotDir + triggerType + "/"+timeresDir + "HalfModule " + i + " t Residual").fill(ttd.getDoubleVal(i - 1));//x is the double value in the generic object } if (!event.hasCollection(GenericObject.class, gblStripClusterDataCollectionName)) return; @@ -108,9 +111,9 @@ int i = gblSCD.getIntVal(0);//implement generic methods into GBLStripClusterData so this isn't hard coded if (tanlambda > 0) - aida.histogram1D(plotDir + uresDir + "HalfModule " + i + " Top u Residual").fill(resid);//x is the double value in the generic object + aida.histogram1D(plotDir + triggerType + "/"+uresDir + "HalfModule " + i + " Top u Residual").fill(resid);//x is the double value in the generic object else - aida.histogram1D(plotDir + uresDir + "HalfModule " + i + " Bot u Residual").fill(resid);//x is the double value in the generic object + aida.histogram1D(plotDir + triggerType + "/"+uresDir + "HalfModule " + i + " Bot u Residual").fill(resid);//x is the double value in the generic object } } @@ -150,54 +153,61 @@ int irYTop = 0; int irYBot = 0; for (int i = 1; i <= nmodules; i++) { - IHistogram1D xresidTop = aida.histogram1D(plotDir + posresDir + "Module " + i + " Top x Residual"); - IHistogram1D yresidTop = aida.histogram1D(plotDir + posresDir + "Module " + i + " Top y Residual"); - IHistogram1D xresidBot = aida.histogram1D(plotDir + posresDir + "Module " + i + " Bot x Residual"); - IHistogram1D yresidBot = aida.histogram1D(plotDir + posresDir + "Module " + i + " Bot y Residual"); + IHistogram1D xresidTop = aida.histogram1D(plotDir + triggerType + "/"+posresDir + "Module " + i + " Top x Residual"); + IHistogram1D yresidTop = aida.histogram1D(plotDir + triggerType + "/"+posresDir + "Module " + i + " Top y Residual"); + IHistogram1D xresidBot = aida.histogram1D(plotDir + triggerType + "/"+posresDir + "Module " + i + " Bot x Residual"); + IHistogram1D yresidBot = aida.histogram1D(plotDir + triggerType + "/"+posresDir + "Module " + i + " Bot y Residual"); IFitResult xresultTop = fitGaussian(xresidTop, fitter, "range=\"(-1.0,1.0)\""); IFitResult yresultTop = fitGaussian(yresidTop, fitter, "range=\"(-0.5,0.5)\""); IFitResult xresultBot = fitGaussian(xresidBot, fitter, "range=\"(-1.0,1.0)\""); IFitResult yresultBot = fitGaussian(yresidBot, fitter, "range=\"(-8.0,8.0)\""); - double[] parsXTop = xresultTop.fittedParameters(); - double[] parsYTop = yresultTop.fittedParameters(); - double[] parsXBot = xresultBot.fittedParameters(); - double[] parsYBot = yresultBot.fittedParameters(); - - plotterXTop.region(irXTop).plot(xresidTop); - plotterXTop.region(irXTop).plot(xresultTop.fittedFunction()); - irXTop++; - plotterXBottom.region(irXBot).plot(xresidBot); - plotterXBottom.region(irXBot).plot(xresultBot.fittedFunction()); - irXBot++; - - plotterYTop.region(irYTop).plot(yresidTop); - plotterYTop.region(irYTop).plot(yresultTop.fittedFunction()); - irYTop++; - plotterYBottom.region(irYBot).plot(yresidBot); - plotterYBottom.region(irYBot).plot(yresultBot.fittedFunction()); - irYBot++; - - xposTopMeanResidMap.put(getQuantityName(0, 0, 1, i) + "_x", parsXTop[1]); - xposTopSigmaResidMap.put(getQuantityName(0, 1, 1, i) + "_x", parsXTop[2]); - yposTopMeanResidMap.put(getQuantityName(0, 0, 1, i) + "_y", parsYTop[1]); - yposTopSigmaResidMap.put(getQuantityName(0, 1, 1, i) + "_y", parsYTop[2]); - xposBotMeanResidMap.put(getQuantityName(0, 0, 0, i) + "_x", parsXBot[1]); - xposBotSigmaResidMap.put(getQuantityName(0, 1, 0, i) + "_x", parsXBot[2]); - yposBotMeanResidMap.put(getQuantityName(0, 0, 0, i) + "_y", parsYBot[1]); - yposBotSigmaResidMap.put(getQuantityName(0, 1, 0, i) + "_y", parsYBot[2]); + if (xresultTop != null) { + double[] parsXTop = xresultTop.fittedParameters(); + plotterXTop.region(irXTop).plot(xresidTop); + plotterXTop.region(irXTop).plot(xresultTop.fittedFunction()); + irXTop++; + xposTopMeanResidMap.put(trackResidualsCollectionName+" " +triggerType+" " +getQuantityName(0, 0, 1, i) + "_x", parsXTop[1]); + xposTopSigmaResidMap.put(trackResidualsCollectionName+" " +triggerType+" " +getQuantityName(0, 1, 1, i) + "_x", parsXTop[2]); + } + if (yresultTop != null) { + double[] parsYTop = yresultTop.fittedParameters(); + + plotterYTop.region(irYTop).plot(yresidTop); + plotterYTop.region(irYTop).plot(yresultTop.fittedFunction()); + irYTop++; + yposTopMeanResidMap.put(trackResidualsCollectionName+" " +triggerType+" " +getQuantityName(0, 0, 1, i) + "_y", parsYTop[1]); + yposTopSigmaResidMap.put(trackResidualsCollectionName+" " +triggerType+" " +getQuantityName(0, 1, 1, i) + "_y", parsYTop[2]); + } + if (xresultBot != null) { + double[] parsXBot = xresultBot.fittedParameters(); + plotterXBottom.region(irXBot).plot(xresidBot); + plotterXBottom.region(irXBot).plot(xresultBot.fittedFunction()); + irXBot++; + xposBotMeanResidMap.put(trackResidualsCollectionName+" " +triggerType+" " +getQuantityName(0, 0, 0, i) + "_x", parsXBot[1]); + xposBotSigmaResidMap.put(trackResidualsCollectionName+" " +triggerType+" " +getQuantityName(0, 1, 0, i) + "_x", parsXBot[2]); + } + if (yresultBot != null) { + double[] parsYBot = yresultBot.fittedParameters(); + plotterYBottom.region(irYBot).plot(yresidBot); + plotterYBottom.region(irYBot).plot(yresultBot.fittedFunction()); + irYBot++; + yposBotMeanResidMap.put(trackResidualsCollectionName+" " +triggerType+" " +getQuantityName(0, 0, 0, i) + "_y", parsYBot[1]); + yposBotSigmaResidMap.put(trackResidualsCollectionName+" " +triggerType+" " +getQuantityName(0, 1, 0, i) + "_y", parsYBot[2]); + } } int iTime = 0; for (int i = 1; i <= nmodules * 2; i++) { - IHistogram1D tresid = aida.histogram1D(plotDir + timeresDir + "HalfModule " + i + " t Residual"); + IHistogram1D tresid = aida.histogram1D(plotDir + triggerType + "/"+timeresDir + "HalfModule " + i + " t Residual"); IFitResult tresult = fitGaussian(tresid, fitter, "range=\"(-15.0,15.0)\""); - double[] parsTime = tresult.fittedParameters(); - plotterTime.region(iTime).plot(tresid); - plotterTime.region(iTime).plot(tresult.fittedFunction()); - iTime++; - - timeMeanResidMap.put(getQuantityName(1, 0, 2, i) + "_dt", parsTime[1]); - timeSigmaResidMap.put(getQuantityName(1, 1, 2, i) + "_dt", parsTime[2]); + if (tresult != null) { + double[] parsTime = tresult.fittedParameters(); + plotterTime.region(iTime).plot(tresid); + plotterTime.region(iTime).plot(tresult.fittedFunction()); + iTime++; + timeMeanResidMap.put(trackTimeDataCollectionName+" " +triggerType+" " +getQuantityName(1, 0, 2, i) + "_dt", parsTime[1]); + timeSigmaResidMap.put(trackTimeDataCollectionName+" " +triggerType+" " +getQuantityName(1, 1, 2, i) + "_dt", parsTime[2]); + } } @@ -331,7 +341,13 @@ IFitResult fitGaussian(IHistogram1D h1d, IFitter fitter, String range) { double[] init = {20.0, 0.0, 0.2}; - return fitter.fit(h1d, "g", init, range); + IFitResult ifr = null; + try { + ifr = fitter.fit(h1d, "g", init, range); + } catch (RuntimeException ex) { + System.out.println(this.getClass().getSimpleName() + ": caught exception in fitGaussian"); + } + return ifr; // double[] init = {20.0, 0.0, 1.0, 20, -1}; // return fitter.fit(h1d, "g+p1", init, range); } Modified: java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/TridentMonitoring.java ============================================================================= --- java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/TridentMonitoring.java (original) +++ java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/TridentMonitoring.java Fri Jun 12 15:27:10 2015 @@ -6,6 +6,8 @@ import hep.aida.IFitter; import hep.aida.IHistogram1D; import hep.aida.IHistogram2D; +import hep.physics.vec.Hep3Vector; +import hep.physics.vec.VecOp; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -31,21 +33,13 @@ private final String helicalTrackHitRelationsCollectionName = "HelicalTrackHitRelations"; private final String rotatedHelicalTrackHitRelationsCollectionName = "RotatedHelicalTrackHitRelations"; - private double ebeam = 2.2; + private double ebeam = 1.05; String finalStateParticlesColName = "FinalStateParticles"; String unconstrainedV0CandidatesColName = "UnconstrainedV0Candidates"; String beamConV0CandidatesColName = "BeamspotConstrainedV0Candidates"; String targetV0ConCandidatesColName = "TargetConstrainedV0Candidates"; + String trackListName = "MatchedTracks"; String[] fpQuantNames = {"nV0_per_Event", "avg_BSCon_mass", "avg_BSCon_Vx", "avg_BSCon_Vy", "avg_BSCon_Vz", "sig_BSCon_Vx", "sig_BSCon_Vy", "sig_BSCon_Vz", "avg_BSCon_Chi2"}; - //some counters - int nRecoEvents = 0; - int nTotV0 = 0; - //some summers - double sumMass = 0.0; - double sumVx = 0.0; - double sumVy = 0.0; - double sumVz = 0.0; - double sumChi2 = 0.0; boolean debug = false; private String plotDir = "TridentMonitoring/"; @@ -53,8 +47,54 @@ IHistogram1D trackTimeDiff; IHistogram2D vertexMassMomentum; IHistogram2D vertexedTrackMomentum2D; + IHistogram2D pyEleVspyPos; + IHistogram2D pxEleVspxPos; IHistogram2D vertexPxPy; IHistogram1D goodVertexMass; + IHistogram1D vertexX; + IHistogram1D vertexY; + IHistogram1D vertexZ; + + IHistogram1D deltaP; + IHistogram1D deltaPRad; + IHistogram1D sumP; + IHistogram2D vertexedTrackMomentum2DRad; + + //clean up event first + int nTrkMax = 3; + int nPosMax = 1; + //v0 cuts + double v0Chi2 = 10; + double v0PzMax = 1.25 * ebeam;//GeV + double v0PzMin = 0.1;// GeV + double v0PyMax = 0.2;//GeV absolute value + double v0PxMax = 0.2;//GeV absolute value + double v0VzMax = 25.0;// mm from target...someday make mass dependent + double v0VyMax = 1.0;// mm from target...someday make mass dependent + double v0VxMax = 2.0;// mm from target...someday make mass dependent + // track quality cuts + double trkChi2 = 10; + double trkPzMax = 0.9 * ebeam;//GeV + double trkPzMin = 0.1;//GeV + double trkPyMax = 0.2;//GeV absolute value + double trkPxMax = 0.2;//GeV absolute value + double trkTimeDiff = 5.0; +//cut for the radiative-enhanced sample + double radCut = 0.8 * ebeam; +//cluster matching + boolean reqCluster = false; + int nClustMax = 3; + double eneLossFactor = 0.7; //average E/p roughly + double eneOverPCut = 0.3; //|(E/p)_meas - (E/p)_mean|<eneOverPCut + +//counters + int nRecoEvents = 0; + int nPassBasicCuts = 0; + int nPassV0PCuts = 0; + int nPassV0VCuts = 0; + int nPassTrkCuts = 0; + + int nPassClusterCuts = 0; @Override protected void detectorChanged(Detector detector) { @@ -64,100 +104,115 @@ /* V0 Quantities */ /* Mass, vertex, chi^2 of fit */ /* beamspot constrained */ -// IHistogram1D nV0 = aida.histogram1D(plotDir + "Number of V0 per event", 10, 0, 10); -// IHistogram1D bsconMass = aida.histogram1D(plotDir + "BS Constrained Mass (GeV)", 100, 0, 0.200); -// IHistogram1D bsconVx = aida.histogram1D(plotDir + "BS Constrained Vx (mm)", 50, -1, 1); -// IHistogram1D bsconVy = aida.histogram1D(plotDir + "BS Constrained Vy (mm)", 50, -1, 1); -// IHistogram1D bsconVz = aida.histogram1D(plotDir + "BS Constrained Vz (mm)", 50, -10, 10); -// IHistogram1D bsconChi2 = aida.histogram1D(plotDir + "BS Constrained Chi2", 25, 0, 25); +// IHistogram1D nV0 = aida.histogram1D(plotDir + triggerType + "/"+"Number of V0 per event", 10, 0, 10); +// IHistogram1D bsconMass = aida.histogram1D(plotDir + triggerType + "/"+"BS Constrained Mass (GeV)", 100, 0, 0.200); +// IHistogram1D bsconVx = aida.histogram1D(plotDir + triggerType + "/"+"BS Constrained Vx (mm)", 50, -1, 1); +// IHistogram1D bsconVy = aida.histogram1D(plotDir + triggerType + "/"+"BS Constrained Vy (mm)", 50, -1, 1); +// IHistogram1D bsconVz = aida.histogram1D(plotDir + triggerType + "/"+"BS Constrained Vz (mm)", 50, -10, 10); +// IHistogram1D bsconChi2 = aida.histogram1D(plotDir + triggerType + "/"+"BS Constrained Chi2", 25, 0, 25); // /* target constrained */ -// IHistogram1D tarconMass = aida.histogram1D(plotDir + "Target Constrained Mass (GeV)", 100, 0, 0.200); -// IHistogram1D tarconVx = aida.histogram1D(plotDir + "Target Constrained Vx (mm)", 50, -1, 1); -// IHistogram1D tarconVy = aida.histogram1D(plotDir + "Target Constrained Vy (mm)", 50, -1, 1); -// IHistogram1D tarconVz = aida.histogram1D(plotDir + "Target Constrained Vz (mm)", 50, -10, 10); -// IHistogram1D tarconChi2 = aida.histogram1D(plotDir + "Target Constrained Chi2", 25, 0, 25); - trackTimeDiff = aida.histogram1D(plotDir + "Track time difference", 100, -25, 25); - trackTime2D = aida.histogram2D(plotDir + "Track time vs. track time", 100, -50, 100, 100, -50, 100); - vertexMassMomentum = aida.histogram2D(plotDir + "Vertex mass vs. vertex momentum", 100, 0, 4.0, 100, 0, 1.0); - vertexedTrackMomentum2D = aida.histogram2D(plotDir + "Positron vs. electron momentum", 100, 0, 2.5, 100, 0, 2.5); - vertexPxPy = aida.histogram2D(plotDir + "Vertex Py vs. Px", 100, -0.1, 0.2, 100, -0.1, 0.1); - goodVertexMass = aida.histogram1D(plotDir + "Good vertex mass", 100, 0, 0.5); - +// IHistogram1D tarconMass = aida.histogram1D(plotDir + triggerType + "/"+"Target Constrained Mass (GeV)", 100, 0, 0.200); +// IHistogram1D tarconVx = aida.histogram1D(plotDir + triggerType + "/"+ triggerType + "/"+"Target Constrained Vx (mm)", 50, -1, 1); +// IHistogram1D tarconVy = aida.histogram1D(plotDir + triggerType + "/"+ triggerType + "/"+"Target Constrained Vy (mm)", 50, -1, 1); +// IHistogram1D tarconVz = aida.histogram1D(plotDir + triggerType + "/"+ triggerType + "/"+"Target Constrained Vz (mm)", 50, -10, 10); +// IHistogram1D tarconChi2 = aida.histogram1D(plotDir + triggerType + "/"+ triggerType + "/"+"Target Constrained Chi2", 25, 0, 25); + pyEleVspyPos = aida.histogram2D(plotDir + triggerType + "/" + "Py(e) vs Py(p)", 50, -0.04, 0.04, 50, -0.04, 0.04); + pxEleVspxPos = aida.histogram2D(plotDir + triggerType + "/" + "Px(e) vs Px(p)", 50, -0.02, 0.06, 50, -0.02, 0.06); + trackTimeDiff = aida.histogram1D(plotDir + triggerType + "/" + "Track time difference", 100, -10, 10); + trackTime2D = aida.histogram2D(plotDir + triggerType + "/" + "Track time vs. track time", 100, -10, 10, 100, -10, 10); + vertexMassMomentum = aida.histogram2D(plotDir + triggerType + "/" + "Vertex mass vs. vertex momentum", 100, 0, 1.1, 100, 0, 0.1); + vertexedTrackMomentum2D = aida.histogram2D(plotDir + triggerType + "/" + "Positron vs. electron momentum", 100, 0, 1.1, 100, 0, 1.1); + vertexedTrackMomentum2DRad = aida.histogram2D(plotDir + triggerType + "/" + "Positron vs. electron momentum: Radiative", 100, 0, 1.1, 100, 0, 1.1); + vertexPxPy = aida.histogram2D(plotDir + triggerType + "/" + "Vertex Py vs. Px", 100, -0.02, 0.06, 100, -0.04, 0.04); + goodVertexMass = aida.histogram1D(plotDir + triggerType + "/" + "Good vertex mass", 100, 0, 0.11); + deltaP = aida.histogram1D(plotDir + triggerType + "/" + "Positron - electron momentum", 100, -1., 1.0); + deltaPRad = aida.histogram1D(plotDir + triggerType + "/" + "Positron - electron momentum", 100, -1., 1.0); + sumP = aida.histogram1D(plotDir + triggerType + "/" + "Positron + electron momentum", 100, 0.2, 1.25); + vertexX = aida.histogram1D(plotDir + triggerType + "/" + "Vertex X Position (mm)", 100, -v0VxMax, v0VxMax); + vertexY = aida.histogram1D(plotDir + triggerType + "/" + "Vertex Y Position (mm)", 100, -v0VyMax, v0VyMax); + vertexZ = aida.histogram1D(plotDir + triggerType + "/" + "Vertex Z Position (mm)", 100, -v0VzMax, v0VzMax); } @Override public void process(EventHeader event) { /* make sure everything is there */ - if (!event.hasCollection(ReconstructedParticle.class, finalStateParticlesColName)) { - return; - } - if (!event.hasCollection(ReconstructedParticle.class, unconstrainedV0CandidatesColName)) { - return; - } - if (!event.hasCollection(ReconstructedParticle.class, beamConV0CandidatesColName)) { - return; - } - if (!event.hasCollection(ReconstructedParticle.class, targetV0ConCandidatesColName)) { - return; - } + if (!event.hasCollection(ReconstructedParticle.class, finalStateParticlesColName)) + return; + if (!event.hasCollection(ReconstructedParticle.class, unconstrainedV0CandidatesColName)) + return; + if (!event.hasCollection(ReconstructedParticle.class, beamConV0CandidatesColName)) + return; + if (!event.hasCollection(ReconstructedParticle.class, targetV0ConCandidatesColName)) + return; + if (!event.hasCollection(Track.class, trackListName)) + return; + + //check to see if this event is from the correct trigger (or "all"); + if (!matchTrigger(event)) + return; + nRecoEvents++; RelationalTable hittostrip = new BaseRelationalTable(RelationalTable.Mode.MANY_TO_MANY, RelationalTable.Weighting.UNWEIGHTED); List<LCRelation> hitrelations = event.get(LCRelation.class, helicalTrackHitRelationsCollectionName); - for (LCRelation relation : hitrelations) { - if (relation != null && relation.getFrom() != null && relation.getTo() != null) { + for (LCRelation relation : hitrelations) + if (relation != null && relation.getFrom() != null && relation.getTo() != null) hittostrip.add(relation.getFrom(), relation.getTo()); - } - } RelationalTable hittorotated = new BaseRelationalTable(RelationalTable.Mode.ONE_TO_ONE, RelationalTable.Weighting.UNWEIGHTED); List<LCRelation> rotaterelations = event.get(LCRelation.class, rotatedHelicalTrackHitRelationsCollectionName); - for (LCRelation relation : rotaterelations) { - if (relation != null && relation.getFrom() != null && relation.getTo() != null) { + for (LCRelation relation : rotaterelations) + if (relation != null && relation.getFrom() != null && relation.getTo() != null) hittorotated.add(relation.getFrom(), relation.getTo()); - } - } - - List<ReconstructedParticle> beamConstrainedV0List = event.get(ReconstructedParticle.class, beamConV0CandidatesColName); -// aida.histogram1D(plotDir + "Number of V0 per event").fill(beamConstrainedV0List.size()); - for (ReconstructedParticle bsV0 : beamConstrainedV0List) { - nTotV0++; - Vertex bsVert = bsV0.getStartVertex(); -// aida.histogram1D(plotDir + "BS Constrained Vx (mm)").fill(bsVert.getPosition().x()); -// aida.histogram1D(plotDir + "BS Constrained Vy (mm)").fill(bsVert.getPosition().y()); -// aida.histogram1D(plotDir + "BS Constrained Vz (mm)").fill(bsVert.getPosition().z()); -// aida.histogram1D(plotDir + "BS Constrained Mass (GeV)").fill(bsV0.getMass()); -// aida.histogram1D(plotDir + "BS Constrained Chi2").fill(bsVert.getChi2()); - sumMass += bsV0.getMass(); - sumVx += bsVert.getPosition().x(); - sumVy += bsVert.getPosition().y(); - sumVz += bsVert.getPosition().z(); - sumChi2 += bsVert.getChi2(); - } - - List<ReconstructedParticle> targetConstrainedV0List = event.get(ReconstructedParticle.class, targetV0ConCandidatesColName); - for (ReconstructedParticle tarV0 : targetConstrainedV0List) { - Vertex tarVert = tarV0.getStartVertex(); -// aida.histogram1D(plotDir + "Target Constrained Vx (mm)").fill(tarVert.getPosition().x()); -// aida.histogram1D(plotDir + "Target Constrained Vy (mm)").fill(tarVert.getPosition().y()); -// aida.histogram1D(plotDir + "Target Constrained Vz (mm)").fill(tarVert.getPosition().z()); -// aida.histogram1D(plotDir + "Target Constrained Mass (GeV)").fill(tarV0.getMass()); -// aida.histogram1D(plotDir + "Target Constrained Chi2").fill(tarVert.getChi2()); + + List<Track> trks = event.get(Track.class, trackListName); + int ntracks = trks.size(); + if (ntracks > nTrkMax || ntracks < 2) + return; + List<ReconstructedParticle> fspList = event.get(ReconstructedParticle.class, finalStateParticlesColName); + int npos = 0; + for (ReconstructedParticle fsp : fspList) + if (fsp.getCharge() > 0) + npos++; + if (npos < 1 || npos > nPosMax) + return; + + nPassBasicCuts++;//passed some basic event-level cuts... + + List<ReconstructedParticle> unConstrainedV0List = event.get(ReconstructedParticle.class, unconstrainedV0CandidatesColName); + for (ReconstructedParticle uncV0 : unConstrainedV0List) { + Vertex uncVert = uncV0.getStartVertex(); +// v0 & vertex-quality cuts +// Hep3Vector v0Mom = uncV0.getMomentum(); + Hep3Vector v0Mom = VecOp.add(uncV0.getParticles().get(1).getMomentum(), uncV0.getParticles().get(0).getMomentum()); + if (v0Mom.z() > v0PzMax || v0Mom.z() < v0PzMin) + break; + if (Math.abs(v0Mom.y()) > v0PyMax) + break; + if (Math.abs(v0Mom.x()) > v0PxMax) + break; + Hep3Vector v0Vtx = uncVert.getPosition(); + if (Math.abs(v0Vtx.z()) > v0VzMax) + break; + if (Math.abs(v0Vtx.y()) > v0VyMax) + break; + if (Math.abs(v0Vtx.x()) > v0VxMax) + break; + List<Track> tracks = new ArrayList<Track>(); ReconstructedParticle electron = null, positron = null; - for (ReconstructedParticle particle : tarV0.getParticles()) { - tracks.addAll(particle.getTracks()); - if (particle.getCharge() > 0) { + for (ReconstructedParticle particle : uncV0.getParticles()) +// tracks.addAll(particle.getTracks()); //add add electron first, then positron...down below + if (particle.getCharge() > 0) positron = particle; - } else if (particle.getCharge() < 0) { + else if (particle.getCharge() < 0) electron = particle; - } else { + else throw new RuntimeException("expected only electron and positron in vertex, got something with charge 0"); - } - } - if (tracks.size() != 2) { + tracks.add(electron.getTracks().get(0)); + tracks.add(positron.getTracks().get(0)); + if (tracks.size() != 2) throw new RuntimeException("expected two tracks in vertex, got " + tracks.size()); - } List<Double> trackTimes = new ArrayList<Double>(); for (Track track : tracks) { int nStrips = 0; @@ -174,15 +229,26 @@ } trackTime2D.fill(trackTimes.get(0), trackTimes.get(1)); trackTimeDiff.fill(trackTimes.get(0) - trackTimes.get(1)); - boolean trackTimeDiffCut = Math.abs(trackTimes.get(0) - trackTimes.get(1)) < 5.0; - boolean pCut = electron.getMomentum().magnitude() > 0.4 && positron.getMomentum().magnitude() > 0.4; - boolean pTotCut = tarV0.getMomentum().magnitude() > 0.8 * 2.2 && tarV0.getMomentum().magnitude() < 2.2; + boolean trackTimeDiffCut = Math.abs(trackTimes.get(0) - trackTimes.get(1)) < trkTimeDiff; + boolean pCut = electron.getMomentum().magnitude() > trkPzMin && positron.getMomentum().magnitude() > trkPzMin; + boolean pTotCut = uncV0.getMomentum().magnitude() > v0PzMin && uncV0.getMomentum().magnitude() < v0PzMax; if (trackTimeDiffCut) { - vertexMassMomentum.fill(tarV0.getMomentum().magnitude(), tarV0.getMass()); + vertexMassMomentum.fill(uncV0.getMomentum().magnitude(), uncV0.getMass()); vertexedTrackMomentum2D.fill(electron.getMomentum().magnitude(), positron.getMomentum().magnitude()); + pyEleVspyPos.fill(electron.getMomentum().y(), positron.getMomentum().y()); + pxEleVspxPos.fill(electron.getMomentum().x(), positron.getMomentum().x()); + sumP.fill(uncV0.getMomentum().magnitude()); + deltaP.fill(positron.getMomentum().magnitude() - electron.getMomentum().magnitude()); + if (uncV0.getMomentum().magnitude() > radCut) { + vertexedTrackMomentum2DRad.fill(electron.getMomentum().magnitude(), positron.getMomentum().magnitude()); + deltaPRad.fill(positron.getMomentum().magnitude() - electron.getMomentum().magnitude()); + } if (pCut && pTotCut) { - vertexPxPy.fill(tarV0.getMomentum().x(), tarV0.getMomentum().y()); - goodVertexMass.fill(tarV0.getMass()); + vertexPxPy.fill(uncV0.getMomentum().x(), uncV0.getMomentum().y()); + goodVertexMass.fill(uncV0.getMass()); + vertexX.fill(v0Vtx.x()); + vertexY.fill(v0Vtx.y()); + vertexZ.fill(v0Vtx.z()); } } // System.out.println(tarV0.getTracks()) @@ -192,9 +258,8 @@ @Override public void printDQMData() { System.out.println("TridentMonitoring::printDQMData"); - for (Entry<String, Double> entry : monitoredQuantityMap.entrySet()) { + for (Entry<String, Double> entry : monitoredQuantityMap.entrySet()) System.out.println(entry.getKey() + " = " + entry.getValue()); - } System.out.println("*******************************"); } @@ -207,66 +272,14 @@ IAnalysisFactory analysisFactory = IAnalysisFactory.create(); IFitFactory fitFactory = analysisFactory.createFitFactory(); IFitter fitter = fitFactory.createFitter("chi2"); -// IHistogram1D bsconVx = aida.histogram1D(plotDir + "BS Constrained Vx (mm)"); -// IHistogram1D bsconVy = aida.histogram1D(plotDir + "BS Constrained Vy (mm)"); -// IHistogram1D bsconVz = aida.histogram1D(plotDir + "BS Constrained Vz (mm)"); -// double[] init = {50.0, 0.0, 0.2, 1.0, 0.0}; -// IFitResult resVx = fitVertexPosition(bsconVx, fitter, init, "range=\"(-0.5,0.5)\""); -// double[] init2 = {50.0, 0.0, 0.04, 1.0, 0.0}; -// IFitResult resVy = fitVertexPosition(bsconVy, fitter, init2, "range=\"(-0.2,0.2)\""); -// double[] init3 = {50.0, 0.0, 3.0, 1.0, 0.0}; -// IFitResult resVz = fitVertexPosition(bsconVz, fitter, init3, "range=\"(-6,6)\""); -// -// double[] parsVx = resVx.fittedParameters(); -// double[] parsVy = resVy.fittedParameters(); -// double[] parsVz = resVz.fittedParameters(); -// -// for (int i = 0; i < 5; i++) { -// System.out.println("Vertex Fit Parameters: " + resVx.fittedParameterNames()[i] + " = " + parsVx[i] + "; " + parsVy[i] + "; " + parsVz[i]); -// } -// -// IPlotter plotter = analysisFactory.createPlotterFactory().create("Vertex Position"); -// plotter.createRegions(1, 3); -// IPlotterStyle pstyle = plotter.style(); -// pstyle.legendBoxStyle().setVisible(false); -// pstyle.dataStyle().fillStyle().setColor("green"); -// pstyle.dataStyle().lineStyle().setColor("black"); -// plotter.region(0).plot(bsconVx); -// plotter.region(0).plot(resVx.fittedFunction()); -// plotter.region(1).plot(bsconVy); -// plotter.region(1).plot(resVy.fittedFunction()); -// plotter.region(2).plot(bsconVz); -// plotter.region(2).plot(resVz.fittedFunction()); -// if (outputPlots) { -// try { -// plotter.writeToFile(outputPlotDir + "vertex.png"); -// } catch (IOException ex) { -// Logger.getLogger(TridentMonitoring.class.getName()).log(Level.SEVERE, null, ex); -// } -// } -// -// monitoredQuantityMap.put(fpQuantNames[0], (double) nTotV0 / nRecoEvents); -// monitoredQuantityMap.put(fpQuantNames[1], sumMass / nTotV0); -//// monitoredQuantityMap.put(fpQuantNames[2], sumVx / nTotV0); -//// monitoredQuantityMap.put(fpQuantNames[3], sumVy / nTotV0); -//// monitoredQuantityMap.put(fpQuantNames[4], sumVz / nTotV0); -// monitoredQuantityMap.put(fpQuantNames[2], parsVx[1]); -// monitoredQuantityMap.put(fpQuantNames[3], parsVy[1]); -// monitoredQuantityMap.put(fpQuantNames[4], parsVz[1]); -// monitoredQuantityMap.put(fpQuantNames[5], parsVx[2]); -// monitoredQuantityMap.put(fpQuantNames[6], parsVy[2]); -// monitoredQuantityMap.put(fpQuantNames[7], parsVz[2]); -// -// monitoredQuantityMap.put(fpQuantNames[8], sumChi2 / nTotV0); } @Override public void printDQMStrings() { for (int i = 0; i < 9; i++)//TODO: do this in a smarter way...loop over the map - { + System.out.println("ALTER TABLE dqm ADD " + fpQuantNames[i] + " double;"); - } } IFitResult fitVertexPosition(IHistogram1D h1d, IFitter fitter, double[] init, String range) { Modified: java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/V0Monitoring.java ============================================================================= --- java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/V0Monitoring.java (original) +++ java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/dataquality/V0Monitoring.java Fri Jun 12 15:27:10 2015 @@ -5,19 +5,29 @@ import hep.aida.IFitResult; import hep.aida.IFitter; import hep.aida.IHistogram1D; +import hep.aida.IHistogram2D; import hep.aida.IPlotter; import hep.aida.IPlotterStyle; +import hep.physics.vec.BasicHep3Vector; +import hep.physics.vec.Hep3Vector; +import hep.physics.vec.VecOp; import java.io.IOException; -import java.util.HashMap; +import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.Map.Entry; import java.util.logging.Level; import java.util.logging.Logger; +import org.hps.recon.particle.HpsReconParticleDriver; +import org.hps.recon.tracking.TrackUtils; +import org.hps.recon.vertexing.BilliorTrack; +import org.hps.recon.vertexing.BilliorVertex; +import org.hps.recon.vertexing.BilliorVertexer; import org.lcsim.event.EventHeader; import org.lcsim.event.ReconstructedParticle; +import org.lcsim.event.Track; import org.lcsim.event.Vertex; import org.lcsim.geometry.Detector; +import org.lcsim.recon.tracking.seedtracker.SeedTrack; /** * DQM driver V0 particles (i.e. e+e- pars) plots @@ -36,6 +46,7 @@ //some counters int nRecoEvents = 0; int nTotV0 = 0; + int nTot2Ele = 0; //some summers double sumMass = 0.0; double sumVx = 0.0; @@ -43,8 +54,57 @@ double sumVz = 0.0; double sumChi2 = 0.0; + IHistogram2D pEleVspPos; + IHistogram2D pEleVspPosWithCut; + IHistogram2D pyEleVspyPos; + IHistogram2D pxEleVspxPos; + + IHistogram2D massVsVtxZ; + IHistogram2D VtxYVsVtxZ; + IHistogram2D VtxXVsVtxZ; + IHistogram2D VtxXVsVtxY; + + IHistogram2D pEleVspEle; + IHistogram2D pyEleVspyEle; + IHistogram2D pxEleVspxEle; + IHistogram2D pEleVspEleNoBeam; + IHistogram2D pyEleVspyEleNoBeam; + IHistogram2D pxEleVspxEleNoBeam; + IHistogram2D pEleVspEleMoller; + IHistogram2D pEleVsthetaMoller; + IHistogram2D thetaEleVsthetaMoller; + IHistogram2D pEleVspEleBeamBeam; + IHistogram2D pEleVsthetaBeamBeam; + IHistogram2D thetaEleVsthetaBeamBeam; + + IHistogram1D mollerMass; + IHistogram1D mollerMassVtxCut; + IHistogram1D mollerVx; + IHistogram1D mollerVy; + IHistogram1D mollerVz; + IHistogram1D mollerVzVtxCut; + IHistogram2D mollerXVsVtxZ; + IHistogram2D mollerYVsVtxZ; + IHistogram2D mollerXVsVtxY; + + IHistogram1D sumChargeHisto; + IHistogram1D numChargeHisto; + boolean debug = false; private String plotDir = "V0Monitoring/"; + + double beamEnergy = 1.05; //GeV + double maxFactor = 1.25; + double feeMomentumCut = 0.8; //GeV + + double v0ESumMinCut = 0.8 * beamEnergy; + double v0ESumMaxCut = 1.25 * beamEnergy; + double v0MaxPCut = 1.1;//GeV + double molPSumMin = 0.85; + double molPSumMax = 1.3; + double beambeamCut = 0.85; + double thetaMax = 0.06; + double thetaMin = 0.015; @Override protected void detectorChanged(Detector detector) { @@ -53,20 +113,59 @@ /* V0 Quantities */ /* Mass, vertex, chi^2 of fit */ + /* unconstrained */ + IHistogram1D unconMass = aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Mass (GeV)", 100, 0, 0.200); + IHistogram1D unconVx = aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Vx (mm)", 50, -10, 10); + IHistogram1D unconVy = aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Vy (mm)", 50, -10, 10); + IHistogram1D unconVz = aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Vz (mm)", 50, -50, 50); + IHistogram1D unconChi2 = aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Chi2", 25, 0, 25); /* beamspot constrained */ - IHistogram1D nV0 = aida.histogram1D(plotDir + "Number of V0 per event", 10, 0, 10); - IHistogram1D bsconMass = aida.histogram1D(plotDir + "BS Constrained Mass (GeV)", 100, 0, 0.200); - IHistogram1D bsconVx = aida.histogram1D(plotDir + "BS Constrained Vx (mm)", 200, -5, 5); - IHistogram1D bsconVy = aida.histogram1D(plotDir + "BS Constrained Vy (mm)", 200, -5, 5); - IHistogram1D bsconVz = aida.histogram1D(plotDir + "BS Constrained Vz (mm)", 200, -50, 50); - IHistogram1D bsconChi2 = aida.histogram1D(plotDir + "BS Constrained Chi2", 100, 0, 100); + + IHistogram1D nV0 = aida.histogram1D(plotDir + triggerType + "/" + "Number of V0 per event", 10, 0, 10); + IHistogram1D bsconMass = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Mass (GeV)", 100, 0, 0.200); + IHistogram1D bsconVx = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vx (mm)", 50, -10, 10); + IHistogram1D bsconVy = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vy (mm)", 50, -10, 10); + IHistogram1D bsconVz = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vz (mm)", 50, -50, 50); + IHistogram1D bsconChi2 = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Chi2", 25, 0, 25); /* target constrained */ - IHistogram1D tarconMass = aida.histogram1D(plotDir + "Target Constrained Mass (GeV)", 100, 0, 0.200); - IHistogram1D tarconVx = aida.histogram1D(plotDir + "Target Constrained Vx (mm)", 200, -5, 5); - IHistogram1D tarconVy = aida.histogram1D(plotDir + "Target Constrained Vy (mm)", 200, -5, 5); - IHistogram1D tarconVz = aida.histogram1D(plotDir + "Target Constrained Vz (mm)", 200, -50, 50); - IHistogram1D tarconChi2 = aida.histogram1D(plotDir + "Target Constrained Chi2", 100, 0, 100); - + IHistogram1D tarconMass = aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Mass (GeV)", 100, 0, 0.200); + IHistogram1D tarconVx = aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Vx (mm)", 50, -1, 1); + IHistogram1D tarconVy = aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Vy (mm)", 50, -1, 1); + IHistogram1D tarconVz = aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Vz (mm)", 50, -10, 10); + IHistogram1D tarconChi2 = aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Chi2", 25, 0, 25); + pEleVspPos = aida.histogram2D(plotDir + triggerType + "/" + "P(e) vs P(p)", 50, 0, beamEnergy * maxFactor, 50, 0, beamEnergy * maxFactor); + pEleVspPosWithCut = aida.histogram2D(plotDir + triggerType + "/" + "P(e) vs P(p): Radiative", 50, 0, beamEnergy * maxFactor, 50, 0, beamEnergy * maxFactor); + pyEleVspyPos = aida.histogram2D(plotDir + triggerType + "/" + "Py(e) vs Py(p)", 50, -0.04, 0.04, 50, -0.04, 0.04); + pxEleVspxPos = aida.histogram2D(plotDir + triggerType + "/" + "Px(e) vs Px(p)", 50, -0.02, 0.06, 50, -0.02, 0.06); + massVsVtxZ = aida.histogram2D(plotDir + triggerType + "/" + "Mass vs Vz", 50, 0, 0.15, 50, -50, 80); + VtxXVsVtxZ = aida.histogram2D(plotDir + triggerType + "/" + "Vx vs Vz", 100, -10, 10, 100, -50, 80); + VtxYVsVtxZ = aida.histogram2D(plotDir + triggerType + "/" + "Vy vs Vz", 100, -5, 5, 100, -50, 80); + VtxXVsVtxY = aida.histogram2D(plotDir + triggerType + "/" + "Vx vs Vy", 100, -10, 10, 100, -5, 5); + pEleVspEle = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron/P(e) vs P(e)", 50, 0, beamEnergy * maxFactor, 50, 0, beamEnergy * maxFactor); + pyEleVspyEle = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron/Py(e) vs Py(e)", 50, -0.04, 0.04, 50, -0.04, 0.04); + pxEleVspxEle = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron/Px(e) vs Px(e)", 50, -0.02, 0.06, 50, -0.02, 0.06); + pEleVspEleNoBeam = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron/P(e) vs P(e) NoBeam", 50, 0, beambeamCut, 50, 0, beambeamCut); + pEleVspEleMoller = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron/P(e) vs P(e) Moller", 50, 0, beambeamCut, 50, 0, beambeamCut); + pEleVspEleBeamBeam = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron/P(e) vs P(e) BeamBeam", 50, beambeamCut, beamEnergy * maxFactor, 50, beambeamCut, beamEnergy * maxFactor); + pyEleVspyEleNoBeam = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron/Py(e) vs Py(e) NoBeam", 50, -0.04, 0.04, 50, -0.04, 0.04); + pxEleVspxEleNoBeam = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron/Px(e) vs Px(e) NoBeam", 50, -0.02, 0.06, 50, -0.02, 0.06); + sumChargeHisto = aida.histogram1D(plotDir + triggerType + "/" + "Total Charge of Event", 5, -2, 3); + numChargeHisto = aida.histogram1D(plotDir + triggerType + "/" + "Number of Charged Particles", 6, 0, 6); + + pEleVsthetaMoller = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron/P(e) vs Theta Moller", 50, 0, beambeamCut, 50, thetaMin, thetaMax); + thetaEleVsthetaMoller = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron/Theta vs Theta Moller", 50, thetaMin, thetaMax, 50, thetaMin, thetaMax); + pEleVsthetaBeamBeam = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron/P(e) vs Theta BeamBeam", 50, beambeamCut, beamEnergy * maxFactor, 50, thetaMin, thetaMax); + thetaEleVsthetaBeamBeam = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron/Theta vs Theta BeamBeam", 50, thetaMin, thetaMax, 50, thetaMin, thetaMax); + + mollerMass = aida.histogram1D(plotDir + triggerType + "/" + "2 Electron/Moller Mass (GeV)", 100, 0, 0.100); + mollerMassVtxCut = aida.histogram1D(plotDir + triggerType + "/" + "2 Electron/Moller Mass (GeV): VtxCut", 100, 0, 0.100); + mollerVx = aida.histogram1D(plotDir + triggerType + "/" + "2 Electron/Moller Vx (mm)", 50, -10, 10); + mollerVy = aida.histogram1D(plotDir + triggerType + "/" + "2 Electron/Moller Vy (mm)", 50, -2, 2); + mollerVz = aida.histogram1D(plotDir + triggerType + "/" + "2 Electron/Moller Vz (mm)", 50, -50, 50); + mollerVzVtxCut = aida.histogram1D(plotDir + triggerType + "/" + "2 Electron/Moller Vz (mm): VtxCut", 50, -50, 50); + mollerXVsVtxZ = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron/Moller Vx vs Vz", 100, -5, 5, 100, -50, 50); + mollerYVsVtxZ = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron/Moller Vy vs Vz", 100, -2, 2, 100, -50, 50); + mollerXVsVtxY = aida.histogram2D(plotDir + triggerType + "/" + "2 Electron/Moller Vx vs Vy", 100, -5, 5, 100, -2, 2); } @Override @@ -80,18 +179,66 @@ return; if (!event.hasCollection(ReconstructedParticle.class, targetV0ConCandidatesColName)) return; + + //check to see if this event is from the correct trigger (or "all"); + if (!matchTrigger(event)) + return; + nRecoEvents++; + List<ReconstructedParticle> unonstrainedV0List = event.get(ReconstructedParticle.class, unconstrainedV0CandidatesColName); + for (ReconstructedParticle uncV0 : unonstrainedV0List) { + Vertex uncVert = uncV0.getStartVertex(); + aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Vx (mm)").fill(uncVert.getPosition().x()); + aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Vy (mm)").fill(uncVert.getPosition().y()); + aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Vz (mm)").fill(uncVert.getPosition().z()); + aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Mass (GeV)").fill(uncV0.getMass()); + aida.histogram1D(plotDir + triggerType + "/" + "Unconstrained Chi2").fill(uncVert.getChi2()); + + aida.histogram2D(plotDir + triggerType + "/" + "Mass vs Vz").fill(uncV0.getMass(), uncVert.getPosition().z()); + VtxXVsVtxZ.fill(uncVert.getPosition().x(), uncVert.getPosition().z()); + VtxYVsVtxZ.fill(uncVert.getPosition().y(), uncVert.getPosition().z()); + VtxXVsVtxY.fill(uncVert.getPosition().x(), uncVert.getPosition().y()); + + //this always has 2 tracks. + List<ReconstructedParticle> trks = uncV0.getParticles(); +// Track ele = trks.get(0).getTracks().get(0); +// Track pos = trks.get(1).getTracks().get(0); +// //if track #0 has charge>0 it's the electron! This seems mixed up, but remember the track +// //charge is assigned assuming a positive B-field, while ours is negative +// if (trks.get(0).getCharge() > 0) { +// pos = trks.get(0).getTracks().get(0); +// ele = trks.get(1).getTracks().get(0); +// } +// aida.histogram2D(plotDir + triggerType + "/" + "P(e) vs P(p)").fill(getMomentum(ele), getMomentum(pos)); +// aida.histogram2D(plotDir + triggerType + "/" + "Px(e) vs Px(p)").fill(ele.getTrackStates().get(0).getMomentum()[1], pos.getTrackStates().get(0).getMomentum()[1]); +// aida.histogram2D(plotDir + triggerType + "/" + "Py(e) vs Py(p)").fill(ele.getTrackStates().get(0).getMomentum()[2], pos.getTrackStates().get(0).getMomentum()[2]); + ReconstructedParticle ele = trks.get(0); + ReconstructedParticle pos = trks.get(1); + //ReconParticles have the charge correct. + if (trks.get(0).getCharge() > 0) { + pos = trks.get(0); + ele = trks.get(1); + } + double pe = ele.getMomentum().magnitude(); + double pp = pos.getMomentum().magnitude(); + aida.histogram2D(plotDir + triggerType + "/" + "P(e) vs P(p)").fill(pe, pp); + aida.histogram2D(plotDir + triggerType + "/" + "Px(e) vs Px(p)").fill(ele.getMomentum().x(), pos.getMomentum().x()); + aida.histogram2D(plotDir + triggerType + "/" + "Py(e) vs Py(p)").fill(ele.getMomentum().y(), pos.getMomentum().y()); + if (pe < v0MaxPCut && pp < v0MaxPCut && (pe + pp) > v0ESumMinCut && (pe + pp) < v0ESumMaxCut)//enrich radiative-like events + aida.histogram2D(plotDir + triggerType + "/" + "P(e) vs P(p): Radiative").fill(pe, pp); + } + List<ReconstructedParticle> beamConstrainedV0List = event.get(ReconstructedParticle.class, beamConV0CandidatesColName); - aida.histogram1D(plotDir + "Number of V0 per event").fill(beamConstrainedV0List.size()); + aida.histogram1D(plotDir + triggerType + "/" + "Number of V0 per event").fill(beamConstrainedV0List.size()); for (ReconstructedParticle bsV0 : beamConstrainedV0List) { nTotV0++; Vertex bsVert = bsV0.getStartVertex(); - aida.histogram1D(plotDir + "BS Constrained Vx (mm)").fill(bsVert.getPosition().x()); - aida.histogram1D(plotDir + "BS Constrained Vy (mm)").fill(bsVert.getPosition().y()); - aida.histogram1D(plotDir + "BS Constrained Vz (mm)").fill(bsVert.getPosition().z()); - aida.histogram1D(plotDir + "BS Constrained Mass (GeV)").fill(bsV0.getMass()); - aida.histogram1D(plotDir + "BS Constrained Chi2").fill(bsVert.getChi2()); + aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vx (mm)").fill(bsVert.getPosition().x()); + aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vy (mm)").fill(bsVert.getPosition().y()); + aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vz (mm)").fill(bsVert.getPosition().z()); + aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Mass (GeV)").fill(bsV0.getMass()); + aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Chi2").fill(bsVert.getChi2()); sumMass += bsV0.getMass(); sumVx += bsVert.getPosition().x(); sumVy += bsVert.getPosition().y(); @@ -102,11 +249,90 @@ List<ReconstructedParticle> targetConstrainedV0List = event.get(ReconstructedParticle.class, targetV0ConCandidatesColName); for (ReconstructedParticle tarV0 : targetConstrainedV0List) { Vertex tarVert = tarV0.getStartVertex(); - aida.histogram1D(plotDir + "Target Constrained Vx (mm)").fill(tarVert.getPosition().x()); - aida.histogram1D(plotDir + "Target Constrained Vy (mm)").fill(tarVert.getPosition().y()); - aida.histogram1D(plotDir + "Target Constrained Vz (mm)").fill(tarVert.getPosition().z()); - aida.histogram1D(plotDir + "Target Constrained Mass (GeV)").fill(tarV0.getMass()); - aida.histogram1D(plotDir + "Target Constrained Chi2").fill(tarVert.getChi2()); + aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Vx (mm)").fill(tarVert.getPosition().x()); + aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Vy (mm)").fill(tarVert.getPosition().y()); + aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Vz (mm)").fill(tarVert.getPosition().z()); + aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Mass (GeV)").fill(tarV0.getMass()); + aida.histogram1D(plotDir + triggerType + "/" + "Target Constrained Chi2").fill(tarVert.getChi2()); + } + List<ReconstructedParticle> finalStateParticles = event.get(ReconstructedParticle.class, finalStateParticlesColName); + if (debug) + System.out.println("This events has " + finalStateParticles.size() + " final state particles"); + + ReconstructedParticle ele1 = null; + ReconstructedParticle ele2 = null; + int sumCharge = 0; + int numChargedParticles = 0; + for (ReconstructedParticle fsPart : finalStateParticles) { + if (debug) + System.out.println("PDGID = " + fsPart.getParticleIDUsed() + "; charge = " + fsPart.getCharge() + "; pz = " + fsPart.getMomentum().x()); + double charge = fsPart.getCharge(); + sumCharge += charge; + if (charge != 0) { + numChargedParticles++; + if (charge < 1) + if (ele1 == null) + ele1 = fsPart; + else + ele2 = fsPart; + } + } + sumChargeHisto.fill(sumCharge); + numChargeHisto.fill(numChargedParticles); + + if (ele1 != null && ele2 != null) { + Hep3Vector p1 = ele1.getMomentum(); + Hep3Vector p2 = ele2.getMomentum(); + Hep3Vector beamAxis = new BasicHep3Vector(Math.sin(0.0305), 0, Math.cos(0.0305)); + double theta1 = Math.acos(VecOp.dot(p1, beamAxis) / p1.magnitude()); + double theta2 = Math.acos(VecOp.dot(p2, beamAxis) / p2.magnitude()); + pEleVspEle.fill(ele1.getMomentum().magnitude(), ele2.getMomentum().magnitude()); + pyEleVspyEle.fill(ele1.getMomentum().y(), ele2.getMomentum().y()); + pxEleVspxEle.fill(ele1.getMomentum().x(), ele2.getMomentum().x()); + //remove beam electrons + if (ele1.getMomentum().magnitude() < beambeamCut && ele2.getMomentum().magnitude() < beambeamCut) { + pEleVspEleNoBeam.fill(ele1.getMomentum().magnitude(), ele2.getMomentum().magnitude()); + pyEleVspyEleNoBeam.fill(ele1.getMomentum().y(), ele2.getMomentum().y()); + pxEleVspxEleNoBeam.fill(ele1.getMomentum().x(), ele2.getMomentum().x()); + } + //look at beam-beam events + if (ele1.getMomentum().magnitude() > beambeamCut && ele2.getMomentum().magnitude() > beambeamCut) { + pEleVspEleBeamBeam.fill(ele1.getMomentum().magnitude(), ele2.getMomentum().magnitude()); + pEleVsthetaBeamBeam.fill(p1.magnitude(), theta1); + pEleVsthetaBeamBeam.fill(p2.magnitude(), theta2); + thetaEleVsthetaBeamBeam.fill(theta1, theta2); + } + + //look at "Moller" events (if that's what they really are + if (ele1.getMomentum().magnitude() + ele2.getMomentum().magnitude() > molPSumMin + && ele1.getMomentum().magnitude() + ele2.getMomentum().magnitude() < molPSumMax + && (p1.magnitude() < beambeamCut && p2.magnitude() < beambeamCut)) { + + Track ele1trk = ele1.getTracks().get(0); + Track ele2trk = ele2.getTracks().get(0); + SeedTrack stEle1 = TrackUtils.makeSeedTrackFromBaseTrack(ele1trk); + SeedTrack stEle2 = TrackUtils.makeSeedTrackFromBaseTrack(ele2trk); + BilliorTrack btEle1 = new BilliorTrack(stEle1.getSeedCandidate().getHelix()); + BilliorTrack btEle2 = new BilliorTrack(stEle2.getSeedCandidate().getHelix()); + BilliorVertex bv = fitVertex(btEle1, btEle2); +// System.out.println("ee vertex: "+bv.toString()); + mollerMass.fill(bv.getParameters().get("invMass")); + mollerVx.fill(bv.getPosition().x()); + mollerVy.fill(bv.getPosition().y()); + mollerVz.fill(bv.getPosition().z()); + mollerXVsVtxZ.fill(bv.getPosition().x(), bv.getPosition().z()); + mollerYVsVtxZ.fill(bv.getPosition().y(), bv.getPosition().z()); + mollerXVsVtxY.fill(bv.getPosition().x(), bv.getPosition().y()); + if (Math.abs(bv.getPosition().x()) < 2 + && Math.abs(bv.getPosition().y()) < 0.5) { + mollerMassVtxCut.fill(bv.getParameters().get("invMass")); + mollerVzVtxCut.fill(bv.getPosition().z()); + } + pEleVspEleMoller.fill(p1.magnitude(), p2.magnitude()); + pEleVsthetaMoller.fill(p1.magnitude(), theta1); + pEleVsthetaMoller.fill(p2.magnitude(), theta2); + thetaEleVsthetaMoller.fill(theta1, theta2); + } } } @@ -127,9 +353,9 @@ IAnalysisFactory analysisFactory = IAnalysisFactory.create(); IFitFactory fitFactory = analysisFactory.createFitFactory(); IFitter fitter = fitFactory.createFitter("chi2"); - IHistogram1D bsconVx = aida.histogram1D(plotDir + "BS Constrained Vx (mm)"); - IHistogram1D bsconVy = aida.histogram1D(plotDir + "BS Constrained Vy (mm)"); - IHistogram1D bsconVz = aida.histogram1D(plotDir + "BS Constrained Vz (mm)"); + IHistogram1D bsconVx = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vx (mm)"); + IHistogram1D bsconVy = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vy (mm)"); + IHistogram1D bsconVz = aida.histogram1D(plotDir + triggerType + "/" + "BS Constrained Vz (mm)"); double[] init = {50.0, 0.0, 0.2, 1.0, 0.0}; IFitResult resVx = fitVertexPosition(bsconVx, fitter, init, "range=\"(-0.5,0.5)\""); double[] init2 = {50.0, 0.0, 0.04, 1.0, 0.0}; @@ -137,46 +363,46 @@ double[] init3 = {50.0, 0.0, 3.0, 1.0, 0.0}; IFitResult resVz = fitVertexPosition(bsconVz, fitter, init3, "range=\"(-6,6)\""); - double[] parsVx = resVx.fittedParameters(); - double[] parsVy = resVy.fittedParameters(); - double[] parsVz = resVz.fittedParameters(); - - for (int i = 0; i < 5; i++) - System.out.println("Vertex Fit Parameters: " + resVx.fittedParameterNames()[i] + " = " + parsVx[i] + "; " + parsVy[i] + "; " + parsVz[i]); - - IPlotter plotter = analysisFactory.createPlotterFactory().create("Vertex Position"); - plotter.createRegions(1, 3); - IPlotterStyle pstyle = plotter.style(); - pstyle.legendBoxStyle().setVisible(false); - pstyle.dataStyle().fillStyle().setColor("green"); - pstyle.dataStyle().lineStyle().setColor("black"); - plotter.region(0).plot(bsconVx); - plotter.region(0).plot(resVx.fittedFunction()); - plotter.region(1).plot(bsconVy); - plotter.region(1).plot(resVy.fittedFunction()); - plotter.region(2).plot(bsconVz); - plotter.region(2).plot(resVz.fittedFunction()); - if(outputPlots){ - try { - plotter.writeToFile(outputPlotDir +"vertex.png"); - } catch (IOException ex) { - Logger.getLogger(V0Monitoring.class.getName()).log(Level.SEVERE, null, ex); - } - } - - monitoredQuantityMap.put(fpQuantNames[0], (double) nTotV0 / nRecoEvents); - monitoredQuantityMap.put(fpQuantNames[1], sumMass / nTotV0); + if (resVx != null && resVy != null & resVz != null) { + double[] parsVx = resVx.fittedParameters(); + double[] parsVy = resVy.fittedParameters(); + double[] parsVz = resVz.fittedParameters(); + + for (int i = 0; i < 5; i++) + System.out.println("Vertex Fit Parameters: " + resVx.fittedParameterNames()[i] + " = " + parsVx[i] + "; " + parsVy[i] + "; " + parsVz[i]); + + IPlotter plotter = analysisFactory.createPlotterFactory().create("Vertex Position"); + plotter.createRegions(1, 3); + IPlotterStyle pstyle = plotter.style(); + pstyle.legendBoxStyle().setVisible(false); + pstyle.dataStyle().fillStyle().setColor("green"); + pstyle.dataStyle().lineStyle().setColor("black"); + plotter.region(0).plot(bsconVx); + plotter.region(0).plot(resVx.fittedFunction()); + plotter.region(1).plot(bsconVy); + plotter.region(1).plot(resVy.fittedFunction()); + plotter.region(2).plot(bsconVz); + plotter.region(2).plot(resVz.fittedFunction()); + if (outputPlots) + try { + plotter.writeToFile(outputPlotDir + "vertex.png"); + } catch (IOException ex) { + Logger.getLogger(V0Monitoring.class.getName()).log(Level.SEVERE, null, ex); + } + // monitoredQuantityMap.put(fpQuantNames[2], sumVx / nTotV0); // monitoredQuantityMap.put(fpQuantNames[3], sumVy / nTotV0); // monitoredQuantityMap.put(fpQuantNames[4], sumVz / nTotV0); - monitoredQuantityMap.put(fpQuantNames[2], parsVx[1]); - monitoredQuantityMap.put(fpQuantNames[3], parsVy[1]); - monitoredQuantityMap.put(fpQuantNames[4], parsVz[1]); - monitoredQuantityMap.put(fpQuantNames[5], parsVx[2]); - monitoredQuantityMap.put(fpQuantNames[6], parsVy[2]); - monitoredQuantityMap.put(fpQuantNames[7], parsVz[2]); - - monitoredQuantityMap.put(fpQuantNames[8], sumChi2 / nTotV0); + monitoredQuantityMap.put(beamConV0CandidatesColName + " " + triggerType + " " + fpQuantNames[2], parsVx[1]); + monitoredQuantityMap.put(beamConV0CandidatesColName + " " + triggerType + " " + fpQuantNames[3], parsVy[1]); + monitoredQuantityMap.put(beamConV0CandidatesColName + " " + triggerType + " " + fpQuantNames[4], parsVz[1]); + monitoredQuantityMap.put(beamConV0CandidatesColName + " " + triggerType + " " + fpQuantNames[5], parsVx[2]); + monitoredQuantityMap.put(beamConV0CandidatesColName + " " + triggerType + " " + fpQuantNames[6], parsVy[2]); + monitoredQuantityMap.put(beamConV0CandidatesColName + " " + triggerType + " " + fpQuantNames[7], parsVz[2]); + } + monitoredQuantityMap.put(beamConV0CandidatesColName + " " + triggerType + " " + fpQuantNames[0], (double) nTotV0 / nRecoEvents); + monitoredQuantityMap.put(beamConV0CandidatesColName + " " + triggerType + " " + fpQuantNames[1], sumMass / nTotV0); + monitoredQuantityMap.put(beamConV0CandidatesColName + " " + triggerType + " " + fpQuantNames[8], sumChi2 / nTotV0); } @@ -186,8 +412,46 @@ System.out.println("ALTER TABLE dqm ADD " + fpQuantNames[i] + " double;"); } - IFitResult fitVertexPosition(IHistogram1D h1d, IFitter fitter, double[] init, String range) { - return fitter.fit(h1d, "g+p1", init, range); + IFitResult fitVertexPosition(IHistogram1D h1d, IFitter fitter, double[] init, String range + ) { + IFitResult ifr = null; + try { + ifr = fitter.fit(h1d, "g+p1", init, range); + } catch (RuntimeException ex) { + System.out.println(this.getClass().getSimpleName() + ": caught exception in fitGaussian"); + } + return ifr; + } + + private double getMomentum(Track trk) { + + double px = trk.getTrackStates().get(0).getMomentum()[0]; + double py = trk.getTrackStates().get(0).getMomentum()[1]; + double pz = trk.getTrackStates().get(0).getMomentum()[2]; + return Math.sqrt(px * px + py * py + pz * pz); + } + + private BilliorVertex fitVertex(BilliorTrack electron, BilliorTrack positron) { + // Create a vertex fitter from the magnetic field. + double bField = 0.24; + double[] beamSize = {0.001, 0.2, 0.02}; + BilliorVertexer vtxFitter = new BilliorVertexer(bField); + // TODO: The beam size should come from the conditions database. + vtxFitter.setBeamSize(beamSize); + + // Perform the vertexing based on the specified constraint. + vtxFitter.doBeamSpotConstraint(false); + + // Add the electron and positron tracks to a track list for + // the vertex fitter. + List<BilliorTrack> billiorTracks = new ArrayList<BilliorTrack>(); + + billiorTracks.add(electron); + + billiorTracks.add(positron); + + // Find and return a vertex based on the tracks. + return vtxFitter.fitVertex(billiorTracks); } } Modified: java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/ecal/EcalHitPlots.java ============================================================================= --- java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/ecal/EcalHitPlots.java (original) +++ java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/ecal/EcalHitPlots.java Fri Jun 12 15:27:10 2015 @@ -157,7 +157,7 @@ for (GenericObject data : triggerList) { if (AbstractIntData.getTag(data) == TestRunTriggerData.BANK_TAG) { TestRunTriggerData triggerData = new TestRunTriggerData(data); - + int orTrig = triggerData.getOrTrig(); if (orTrig != 0) { for (int i = 0; i < 32; i++) { @@ -190,10 +190,12 @@ } break; } else if (AbstractIntData.getTag(data) == SSPData.BANK_TAG) { - SSPData triggerData = new SSPData(data); - - int orTrig = triggerData.getOrTrig(); - if (orTrig != 0) { + //SSPData triggerData = new SSPData(data); + // TODO: TOP, BOTTOM, AND, and OR trigger are test + // run-specific parameters and are not supported by + // SSPData. + int orTrig = 0; //triggerData.getOrTrig(); + if(orTrig != 0) { for (int i = 0; i < 32; i++) { if ((1 << (31 - i) & orTrig) != 0) { orTrigTime = i; @@ -202,7 +204,7 @@ } } } - int topTrig = triggerData.getTopTrig(); + int topTrig = 1; //triggerData.getTopTrig(); if (topTrig != 0) { for (int i = 0; i < 32; i++) { if ((1 << (31 - i) & topTrig) != 0) { @@ -212,7 +214,7 @@ } } } - int botTrig = triggerData.getBotTrig(); + int botTrig = 0; //triggerData.getBotTrig(); if (botTrig != 0) { for (int i = 0; i < 32; i++) { if ((1 << (31 - i) & botTrig) != 0) { @@ -235,13 +237,15 @@ double botTime = Double.POSITIVE_INFINITY; double orTime = Double.POSITIVE_INFINITY; for (CalorimeterHit hit : hits) { -// if (hit.getIdentifierFieldValue("iy") > 0) { -// topX.fill(hit.getIdentifierFieldValue("ix"),hit.getPosition()[0]); -// topY.fill(hit.getIdentifierFieldValue("iy"),hit.getPosition()[1]); -// } else { -// botX.fill(hit.getIdentifierFieldValue("ix"),hit.getPosition()[0]); -// botY.fill(hit.getIdentifierFieldValue("iy"),hit.getPosition()[1]); -// } + /* + if (hit.getIdentifierFieldValue("iy") > 0) { + topX.fill(hit.getIdentifierFieldValue("ix"),hit.getPosition()[0]); + topY.fill(hit.getIdentifierFieldValue("iy"),hit.getPosition()[1]); + } else { + botX.fill(hit.getIdentifierFieldValue("ix"),hit.getPosition()[0]); + botY.fill(hit.getIdentifierFieldValue("iy"),hit.getPosition()[1]); + } + */ hitEnergyPlot.fill(hit.getRawEnergy()); hitTimePlot.fill(hit.getTime()); if (hit.getTime() < orTime) { Modified: java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/examples/EcalScoringMatchDriver.java ============================================================================= --- java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/examples/EcalScoringMatchDriver.java (original) +++ java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/examples/EcalScoringMatchDriver.java Fri Jun 12 15:27:10 2015 @@ -31,42 +31,46 @@ if (hits == null) { throw new RuntimeException("Missing ECal hit collection!"); } - List<SimTrackerHit> scoringHits = event.get(SimTrackerHit.class, "TrackerHitsECal"); - if (scoringHits == null) { - throw new RuntimeException("Missing ECal scoring plane hit collection!"); - } - List<SimTrackerHit> fieldHits = event.get(SimTrackerHit.class, "TrackerHitsFieldDef"); - if (fieldHits == null) { - throw new RuntimeException("Missing field boundary scoring plane hit collection!"); - } Map<MCParticle, SimTrackerHit> scoringHitMap = new HashMap<MCParticle, SimTrackerHit>(); Map<MCParticle, SimTrackerHit> fieldHitMap = new HashMap<MCParticle, SimTrackerHit>(); Map<MCParticle, Double> edepMap = new HashMap<MCParticle, Double>(); //sum of all ECal hit energy contributions from each MCParticle - for (SimTrackerHit scoringHit : scoringHits) { - SimTrackerHit keyHit = scoringHitMap.get(scoringHit.getMCParticle()); + if (!event.hasCollection(SimTrackerHit.class, "TrackerHitsECal")) { + System.out.println("Missing ECal scoring plane hit collection!"); + } else { + List<SimTrackerHit> scoringHits = event.get(SimTrackerHit.class, "TrackerHitsECal"); + for (SimTrackerHit scoringHit : scoringHits) { + SimTrackerHit keyHit = scoringHitMap.get(scoringHit.getMCParticle()); - if (keyHit == null) { - scoringHitMap.put(scoringHit.getMCParticle(), scoringHit); - } else if (scoringHit.getTime() < keyHit.getTime()) { //keep only the earliest hit from each particle - System.out.println("Multiple scoring hits from same particle"); - scoringHitMap.put(scoringHit.getMCParticle(), scoringHit); + if (keyHit == null) { + scoringHitMap.put(scoringHit.getMCParticle(), scoringHit); + } else if (scoringHit.getTime() < keyHit.getTime()) { //keep only the earliest hit from each particle + System.out.println("Multiple scoring hits from same particle"); + scoringHitMap.put(scoringHit.getMCParticle(), scoringHit); + } } } - for (SimTrackerHit fieldHit : fieldHits) { - if (fieldHit.getIdentifierFieldValue("layer") != 2) { //reject hits at the -Z end of the magnet - continue; - } - SimTrackerHit keyHit = fieldHitMap.get(fieldHit.getMCParticle()); - if (keyHit == null) { - fieldHitMap.put(fieldHit.getMCParticle(), fieldHit); - } else if (fieldHit.getTime() < keyHit.getTime()) { //keep only the earliest hit from each particle - System.out.println("Multiple scoring hits from same particle"); - fieldHitMap.put(fieldHit.getMCParticle(), fieldHit); + if (!event.hasCollection(SimTrackerHit.class, "TrackerHitsFieldDef")) { + System.out.println("Missing field boundary scoring plane hit collection!"); + } else { + List<SimTrackerHit> fieldHits = event.get(SimTrackerHit.class, "TrackerHitsFieldDef"); + for (SimTrackerHit fieldHit : fieldHits) { + if (fieldHit.getIdentifierFieldValue("layer") != 2) { //reject hits at the -Z end of the magnet + continue; + } + SimTrackerHit keyHit = fieldHitMap.get(fieldHit.getMCParticle()); + + if (keyHit == null) { + fieldHitMap.put(fieldHit.getMCParticle(), fieldHit); + } else if (fieldHit.getTime() < keyHit.getTime()) { //keep only the earliest hit from each particle + System.out.println("Multiple scoring hits from same particle"); + fieldHitMap.put(fieldHit.getMCParticle(), fieldHit); + } } } + for (SimCalorimeterHit hit : hits) { for (int i = 0; i < hit.getMCParticleCount(); i++) { MCParticle mcParticle = hit.getMCParticle(i); Modified: java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/examples/StripEventDriver.java ============================================================================= --- java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/examples/StripEventDriver.java (original) +++ java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/examples/StripEventDriver.java Fri Jun 12 15:27:10 2015 @@ -3,6 +3,7 @@ import java.util.List; import org.lcsim.event.EventHeader; import org.lcsim.event.Track; +import org.lcsim.event.Vertex; import org.lcsim.util.Driver; /** @@ -17,6 +18,7 @@ private int _minNumberOfTracks = 0; private int _minNumberOfHitsOnTrack = 0; private int _numberOfEventsWritten = 0; + private int _minNumberOfUnconstrainedV0Vertices = 0; @Override protected void process(EventHeader event) @@ -35,6 +37,12 @@ } } } else { + skipEvent = true; + } + } + if (event.hasCollection(Vertex.class, "UnconstrainedV0Vertices")) { + int nVertices = event.get(Vertex.class, "UnconstrainedV0Vertices").size(); + if (nVertices < _minNumberOfUnconstrainedV0Vertices) { skipEvent = true; } } @@ -61,4 +69,9 @@ _minNumberOfHitsOnTrack = nHits; } + public void setMinNumberOfUnconstrainedV0Vertices(int nVertices) + { + _minNumberOfUnconstrainedV0Vertices = nVertices; + } + } Modified: java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/trigger/TriggerDiagnosticDriver.java ============================================================================= --- java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/trigger/TriggerDiagnosticDriver.java (original) +++ java/branches/HPSJAVA-488/analysis/src/main/java/org/hps/analysis/trigger/TriggerDiagnosticDriver.java Fri Jun 12 15:27:10 2015 @@ -1,5 +1,6 @@ package org.hps.analysis.trigger; +import hep.aida.ICloud2D; import hep.aida.IHistogram1D; import hep.aida.IHistogram2D; @@ -45,6 +46,9 @@ import org.lcsim.event.Cluster; import org.lcsim.event.EventHeader; import org.lcsim.event.GenericObject; +import org.lcsim.event.LCRelation; +import org.lcsim.event.base.MyLCRelation; +import org.lcsim.lcio.LCIOConstants; import org.lcsim.util.Driver; import org.lcsim.util.aida.AIDA; @@ -54,12 +58,15 @@ private String bankCollectionName = "TriggerBank"; private String clusterCollectionName = "EcalClusters"; private String diagnosticCollectionName = "DiagnosticSnapshot"; + private static final int clusterCollectionFlag = 1 << LCIOConstants.CLBIT_HITS; + private String[] singlesCandidateCollectionName = { "Singles0TriggerCandidates", "Singles1TriggerCandidates" }; + private String[] pairCandidateCollectionName = { "Pair0TriggerCandidates", "Pair1TriggerCandidates" }; // Store the lists of parsed objects. private TIData tiBank; private SSPData sspBank; + private List<SSPCluster> sspClusters; private List<Cluster> reconClusters = new ArrayList<Cluster>(); - private List<SSPCluster> sspClusters; private List<List<PairTrigger<Cluster[]>>> reconPairsTriggers = new ArrayList<List<PairTrigger<Cluster[]>>>(2); private List<List<PairTrigger<SSPCluster[]>>> sspPairsTriggers = new ArrayList<List<PairTrigger<SSPCluster[]>>>(2); private List<List<SinglesTrigger<Cluster>>> reconSinglesTriggers = new ArrayList<List<SinglesTrigger<Cluster>>>(2); @@ -93,6 +100,10 @@ private RunDiagStats localStats = new RunDiagStats(); private RunDiagStats globalStats = new RunDiagStats(); + // Track which clusters/pairs are trigger candidates. + private List<List<Cluster>> singlesCandidates = new ArrayList<List<Cluster>>(2); + private List<List<LCRelation>> pairCandidates = new ArrayList<List<LCRelation>>(2); + // Verbose settings. private boolean clusterFail = false; private boolean singlesEfficiencyFail = false; @@ -136,56 +147,63 @@ private AIDA aida = AIDA.defaultInstance(); private IHistogram1D[][] clusterHitPlot = { { - aida.histogram1D("cluster/Recon Cluster Hit Count (All)", 9, 0.5, 9.5), - aida.histogram1D("cluster/Recon Cluster Hit Count (Matched)", 9, 0.5, 9.5), - aida.histogram1D("cluster/Recon Cluster Hit Count (Failed)", 9, 0.5, 9.5) + aida.histogram1D("Clustering/Recon Cluster Hit Count (All)", 9, 0.5, 9.5), + aida.histogram1D("Clustering/Recon Cluster Hit Count (Matched)", 9, 0.5, 9.5), + aida.histogram1D("Clustering/Recon Cluster Hit Count (Failed)", 9, 0.5, 9.5) }, { - aida.histogram1D("cluster/SSP Cluster Hit Count (All)", 9, 0.5, 9.5), - aida.histogram1D("cluster/SSP Cluster Hit Count (Matched)", 9, 0.5, 9.5), - aida.histogram1D("cluster/SSP Cluster Hit Count (Failed)", 9, 0.5, 9.5) + aida.histogram1D("Clustering/SSP Cluster Hit Count (All)", 9, 0.5, 9.5), + aida.histogram1D("Clustering/SSP Cluster Hit Count (Matched)", 9, 0.5, 9.5), + aida.histogram1D("Clustering/SSP Cluster Hit Count (Failed)", 9, 0.5, 9.5) } }; private IHistogram1D[][] clusterEnergyPlot = { { - aida.histogram1D("cluster/Recon Cluster Energy (All)", 300, 0.0, 3.0), - aida.histogram1D("cluster/Recon Cluster Energy (Matched)", 300, 0.0, 3.0), - aida.histogram1D("cluster/Recon Cluster Energy (Failed)", 300, 0.0, 3.0) + aida.histogram1D("Clustering/Recon Cluster Energy (All)", 300, 0.0, 3.0), + aida.histogram1D("Clustering/Recon Cluster Energy (Matched)", 300, 0.0, 3.0), + aida.histogram1D("Clustering/Recon Cluster Energy (Failed)", 300, 0.0, 3.0) }, { - aida.histogram1D("cluster/SSP Cluster Energy (All)", 300, 0.0, 3.0), - aida.histogram1D("cluster/SSP Cluster Energy (Matched)", 300, 0.0, 3.0), - aida.histogram1D("cluster/SSP Cluster Energy (Failed)", 300, 0.0, 3.0) + aida.histogram1D("Clustering/SSP Cluster Energy (All)", 300, 0.0, 3.0), + aida.histogram1D("Clustering/SSP Cluster Energy (Matched)", 300, 0.0, 3.0), + aida.histogram1D("Clustering/SSP Cluster Energy (Failed)", 300, 0.0, 3.0) } }; private IHistogram1D[][] clusterTimePlot = { { - aida.histogram1D("cluster/Recon Cluster Time (All)", 115, 0, 460), - aida.histogram1D("cluster/Recon Cluster Time (Matched)", 115, 0, 460), - aida.histogram1D("cluster/Recon Cluster Time (Failed)", 115, 0, 460) + aida.histogram1D("Clustering/Recon Cluster Time (All)", 115, 0, 460), + aida.histogram1D("Clustering/Recon Cluster Time (Matched)", 115, 0, 460), + aida.histogram1D("Clustering/Recon Cluster Time (Failed)", 115, 0, 460) }, { - aida.histogram1D("cluster/SSP Cluster Time (All)", 115, 0, 460), - aida.histogram1D("cluster/SSP Cluster Time (Matched)", 115, 0, 460), - aida.histogram1D("cluster/SSP Cluster Time (Failed)", 115, 0, 460) + aida.histogram1D("Clustering/SSP Cluster Time (All)", 115, 0, 460), + aida.histogram1D("Clustering/SSP Cluster Time (Matched)", 115, 0, 460), + aida.histogram1D("Clustering/SSP Cluster Time (Failed)", 115, 0, 460) } }; private IHistogram2D[][] clusterPositionPlot = { { - aida.histogram2D("cluster/Recon Cluster Position (All)", 47, -23.5, 23.5, 11, -5.5, 5.5), - aida.histogram2D("cluster/Recon Cluster Position (Matched)", 47, -23.5, 23.5, 11, -5.5, 5.5), - aida.histogram2D("cluster/Recon Cluster Position (Failed)", 47, -23.5, 23.5, 11, -5.5, 5.5) + aida.histogram2D("Clustering/Recon Cluster Position (All)", 47, -23.5, 23.5, 11, -5.5, 5.5), + aida.histogram2D("Clustering/Recon Cluster Position (Matched)", 47, -23.5, 23.5, 11, -5.5, 5.5), + aida.histogram2D("Clustering/Recon Cluster Position (Failed)", 47, -23.5, 23.5, 11, -5.5, 5.5) }, { - aida.histogram2D("cluster/SSP Cluster Position (All)", 47, -23.5, 23.5, 11, -5.5, 5.5), - aida.histogram2D("cluster/SSP Cluster Position (Matched)", 47, -23.5, 23.5, 11, -5.5, 5.5), - aida.histogram2D("cluster/SSP Cluster Position (Failed)", 47, -23.5, 23.5, 11, -5.5, 5.5) + aida.histogram2D("Clustering/SSP Cluster Position (All)", 47, -23.5, 23.5, 11, -5.5, 5.5), + aida.histogram2D("Clustering/SSP Cluster Position (Matched)", 47, -23.5, 23.5, 11, -5.5, 5.5), + aida.histogram2D("Clustering/SSP Cluster Position (Failed)", 47, -23.5, 23.5, 11, -5.5, 5.5) } }; private IHistogram2D[] energyhitDiffPlot = { - aida.histogram2D("cluster/Recon-SSP Energy-Hit Difference (All)", 21, -0.010, 0.010, 6, -3, 3), - aida.histogram2D("cluster/Recon-SSP Energy-Hit Difference (Matched)", 21, -0.010, 0.010, 6, -3, 3), - aida.histogram2D("cluster/Recon-SSP Energy-Hit Difference (Failed)", 21, -0.010, 0.010, 6, -3, 3) + aida.histogram2D("Clustering/Recon-SSP Energy-Hit Difference (All)", 21, -0.010, 0.010, 6, -3, 3), + aida.histogram2D("Clustering/Recon-SSP Energy-Hit Difference (Matched)", 21, -0.010, 0.010, 6, -3, 3), + aida.histogram2D("Clustering/Recon-SSP Energy-Hit Difference (Failed)", 21, -0.010, 0.010, 6, -3, 3) + }; + private ICloud2D[] efficiencyTimeHist = { + aida.cloud2D("Clustering/Cluster Efficiency vs. Time"), + aida.cloud2D("Singles Trigger 0/Cluster Efficiency vs. Time"), + aida.cloud2D("Singles Trigger 1/Cluster Efficiency vs. Time"), + aida.cloud2D("Pair Trigger 0/Cluster Efficiency vs. Time"), + aida.cloud2D("Pair Trigger 1/Cluster Efficiency vs. Time") }; /** @@ -355,6 +373,14 @@ } } + // Reset the candidate cluster lists. + singlesCandidates.clear(); + singlesCandidates.add(new ArrayList<Cluster>()); + singlesCandidates.add(new ArrayList<Cluster>()); + pairCandidates.clear(); + pairCandidates.add(new ArrayList<LCRelation>()); + pairCandidates.add(new ArrayList<LCRelation>()); + // Increment the total event count. localStats.sawEvent(event.getTimeStamp()); globalStats.sawEvent(event.getTimeStamp()); @@ -633,9 +659,41 @@ // Push the snapshot to the data stream. event.put(diagnosticCollectionName, snapshotList); + // Record the efficiencies in this time snapshot. + double[] efficiency = new double[5]; + efficiency[0] = 1.0 * localStats.getClusterStats().getMatches() + / localStats.getClusterStats().getReconClusterCount(); + efficiency[1] = 1.0 * localStats.getTriggerStats().getSingles0Stats().getMatchedReconSimulatedTriggers() + / localStats.getTriggerStats().getSingles0Stats().getReconSimulatedTriggers(); + efficiency[2] = 1.0 * localStats.getTriggerStats().getSingles1Stats().getMatchedReconSimulatedTriggers() + / localStats.getTriggerStats().getSingles1Stats().getReconSimulatedTriggers(); + efficiency[3] = 1.0 * localStats.getTriggerStats().getPair0Stats().getMatchedReconSimulatedTriggers() + / localStats.getTriggerStats().getPair0Stats().getReconSimulatedTriggers(); + efficiency[4] = 1.0 * localStats.getTriggerStats().getPair1Stats().getMatchedReconSimulatedTriggers() + / localStats.getTriggerStats().getPair1Stats().getReconSimulatedTriggers(); + + // Get the time for the current snapshot. This is the total + // run time before the snapshot plus half of the snapshot. + long time = globalStats.getDuration() - (localStats.getDuration() / 2); + + // Add them to the appropriate cloud plot. + for(int i = 0; i < 5; i++) { efficiencyTimeHist[i].fill(time, efficiency[i]); } + // Clear the local statistical data. localStats.clear(); } + + + + // ========================================================== + // ==== Write the Candidate Triggers ======================== + // ========================================================== + + // Write the candidates to a collection. + event.put(pairCandidateCollectionName[0], pairCandidates.get(0), LCRelation.class, 0); + event.put(pairCandidateCollectionName[1], pairCandidates.get(1), LCRelation.class, 0); + event.put(singlesCandidateCollectionName[0], singlesCandidates.get(0), Cluster.class, clusterCollectionFlag); + event.put(singlesCandidateCollectionName[1], singlesCandidates.get(1), Cluster.class, clusterCollectionFlag); } public void setPrintResultsEveryNEvents(int n) { @@ -1706,6 +1764,13 @@ trigger.setStateClusterEnergyHigh(passClusterHigh); trigger.setStateHitCount(passHitCount); + // If all the trigger cuts passed, plot this trigger + // in the "triggered" plots. + if(trigger.getTriggerState()) { + globalTriggerPlots.passedTrigger(trigger); + singlesCandidates.get(triggerNum).add(trigger.getTriggerSource()); + } + // A trigger will only be reported by the SSP if it // passes all of the enabled cuts for that trigger. // Check whether this trigger meets these conditions. @@ -1715,12 +1780,6 @@ continue triggerLoop; } if(singlesCutsEnabled[triggerNum][HIT_COUNT] && !trigger.getStateHitCount()) { continue triggerLoop; - } - - // If all the trigger cuts passed, plot this trigger - // in the "triggered" plots. - if(trigger.getTriggerState()) { - globalTriggerPlots.passedTrigger(trigger); } // Store the trigger. @@ -1851,6 +1910,8 @@ // in the "triggered" plots. if(trigger.getTriggerState()) { globalTriggerPlots.passedTrigger(trigger); + LCRelation lcPair = new MyLCRelation(trigger.getTriggerSource()[0], trigger.getTriggerSource()[1]); + pairCandidates.get(triggerIndex).add(lcPair); } // Add the trigger to the list. @@ -1907,6 +1968,12 @@ trigger.setStateEnergySlope(passPairEnergySlope); trigger.setStateCoplanarity(passPairCoplanarity); trigger.setStateTimeCoincidence(passTimeCoincidence); + + // If all the trigger cuts passed, plot this trigger + // in the "triggered" plots. + if(trigger.getTriggerState()) { + globalTriggerPlots.passedTrigger(trigger); + } // A trigger will only be reported by the SSP if it // passes all of the enabled cuts for that trigger. @@ -1925,12 +1992,6 @@ continue pairTriggerLoop; } if(pairCutsEnabled[triggerIndex][3 + COPLANARITY] && !trigger.getStateCoplanarity()) { continue pairTriggerLoop; - } - - // If all the trigger cuts passed, plot this trigger - // in the "triggered" plots. - if(trigger.getTriggerState()) { - globalTriggerPlots.passedTrigger(trigger); } // Add the trigger to the list. Modified: java/branches/HPSJAVA-488/conditions/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/conditions/pom.xml (original) +++ java/branches/HPSJAVA-488/conditions/pom.xml Fri Jun 12 15:27:10 2015 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/conditions/</url> @@ -37,7 +37,7 @@ <exclude>org/hps/conditions/beam/BeamConditionsTest.java</exclude> <exclude>org/hps/conditions/ecal/EcalHardwareConditionsTest.java</exclude> <exclude>org/hps/conditions/database/CollectionIdTest.java</exclude> - <exclude>org/hps/conditions/dummy/**.java</exclude> + <exclude>/org/hps/conditions/svt/SvtTimingConstantsTest.java</exclude> </excludes> </configuration> </plugin> @@ -99,5 +99,10 @@ <groupId>org.reflections</groupId> <artifactId>reflections</artifactId> </dependency> + <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-csv</artifactId> + <version>1.1</version> + </dependency> </dependencies> </project> Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsRecord.java ============================================================================= --- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsRecord.java (original) +++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/api/ConditionsRecord.java Fri Jun 12 15:27:10 2015 @@ -269,6 +269,16 @@ } /** + * Get the collection ID, overriding this method from the parent class. + * + * @return the collection ID + */ + @Field(names = {"collection_id"}) + public Integer getCollectionId() { + return getFieldValue("collection_id"); + } + + /** * Get the date this record was created. * * @return the date this record was created @@ -315,7 +325,7 @@ * @return the ending run number */ @Field(names = {"run_end"}) - public int getRunEnd() { + public Integer getRunEnd() { return getFieldValue("run_end"); } @@ -325,7 +335,7 @@ * @return the starting run number */ @Field(names = {"run_start"}) - public int getRunStart() { + public Integer getRunStart() { return getFieldValue("run_start"); } Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/ConnectionParameters.java ============================================================================= --- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/ConnectionParameters.java (original) +++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/database/ConnectionParameters.java Fri Jun 12 15:27:10 2015 @@ -23,34 +23,101 @@ public static final int DEFAULT_PORT = 3306; /** + * Configure the connection parameters from a properties file. + * + * @param file the properties file + * @return the connection parameters + */ + public static ConnectionParameters fromProperties(final File file) { + FileInputStream fin = null; + try { + fin = new FileInputStream(file); + } catch (final FileNotFoundException e) { + throw new IllegalArgumentException(file.getPath() + " does not exist.", e); + } + return fromProperties(fin); + } + + /** + * Configure the connection parameters from an <code>InputStream</code> of properties. + * + * @param in the InputStream of the properties + * @return the connection parameters + * @throws RuntimeException if the InputStream is invalid + */ + private static ConnectionParameters fromProperties(final InputStream in) { + final Properties properties = new Properties(); + try { + properties.load(in); + } catch (final IOException e) { + throw new RuntimeException(e); + } + final String user = properties.getProperty("user"); + final String password = properties.getProperty("password"); + final String database = properties.getProperty("database"); + final String hostname = properties.getProperty("hostname"); + int port = DEFAULT_PORT; + if (properties.containsKey("port")) { + port = Integer.parseInt(properties.getProperty("port")); + } + return new ConnectionParameters(user, password, database, hostname, port); + } + + /** + * Configure the connection parameters from an embedded classpath resource which should be a properties file. + * + * @param resource the resource path + * @return the connection parameters + */ + public static ConnectionParameters fromResource(final String resource) { + return fromProperties(ConnectionParameters.class.getResourceAsStream(resource)); + } + + /** + * The database name. + */ + private String database; + + /** + * The host name. + */ + private String hostname; + + /** + * The user's password. + */ + private String password; + + /** + * The port. + */ + private int port; + + /** * The user name. */ private String user; /** - * The user's password. - */ - private String password; - - /** - * The port. - */ - private int port; - - /** - * The host name. - */ - private String hostname; - - /** - * The database name. - */ - private String database; - - /** * Protected constructor for sub-classes. */ protected ConnectionParameters() { + } + + /** + * Class constructor using default MySQL port number. + * + * @param user the user name + * @param password the password + * @param hostname the hostname + * @param database the database name + */ + public ConnectionParameters(final String user, final String password, final String database, final String hostname) { + this.user = user; + this.password = password; + this.database = database; + this.hostname = hostname; + this.port = DEFAULT_PORT; } /** @@ -72,74 +139,6 @@ } /** - * Get Properties object for this connection. - * - * @return the Properties for this connection - */ - public Properties getConnectionProperties() { - final Properties p = new Properties(); - p.put("user", user); - p.put("password", password); - return p; - } - - /** - * Get the hostname. - * - * @return the hostname - */ - String getHostname() { - return hostname; - } - - /** - * Get the port number. - * - * @return the port number - */ - int getPort() { - return port; - } - - /** - * Get the name of the database. - * - * @return the name of the database - */ - String getDatabase() { - return database; - } - - /** - * Get the user name. - * - * @return the user name - */ - String getUser() { - return user; - } - - /** - * Get the password. - * - * @return the password - */ - String getPassword() { - return password; - } - - /** - * Get the connection string for these parameters. - * <p> - * This is public because the DQM database manager is using it. - * - * @return the connection string - */ - public String getConnectionString() { - return "jdbc:mysql://" + hostname + ":" + port + "/"; - } - - /** * Create a database connection from these parameters. The caller becomes the "owner" and is responsible for closing * it when finished. * @@ -151,60 +150,77 @@ try { connection = DriverManager.getConnection(getConnectionString(), connectionProperties); connection.createStatement().execute("USE " + getDatabase()); - } catch (SQLException x) { + } catch (final SQLException x) { throw new RuntimeException("Failed to connect to database: " + getConnectionString(), x); } return connection; } /** - * Configure the connection parameters from a properties file. - * - * @param file the properties file - * @return the connection parameters - */ - public static ConnectionParameters fromProperties(final File file) { - FileInputStream fin = null; - try { - fin = new FileInputStream(file); - } catch (FileNotFoundException e) { - throw new IllegalArgumentException(file.getPath() + " does not exist.", e); - } - return fromProperties(fin); - } - - /** - * Configure the connection parameters from an embedded classpath resource which should be a properties file. - * - * @param resource the resource path - * @return the connection parameters - */ - public static ConnectionParameters fromResource(final String resource) { - return fromProperties(ConnectionParameters.class.getResourceAsStream(resource)); - } - - /** - * Configure the connection parameters from an <code>InputStream</code> of properties. - * - * @param in the InputStream of the properties - * @return the connection parameters - * @throws RuntimeException if the InputStream is invalid - */ - private static ConnectionParameters fromProperties(final InputStream in) { - final Properties properties = new Properties(); - try { - properties.load(in); - } catch (IOException e) { - throw new RuntimeException(e); - } - final String user = properties.getProperty("user"); - final String password = properties.getProperty("password"); - final String database = properties.getProperty("database"); - final String hostname = properties.getProperty("hostname"); - int port = DEFAULT_PORT; - if (properties.containsKey("port")) { - port = Integer.parseInt(properties.getProperty("port")); - } - return new ConnectionParameters(user, password, database, hostname, port); + * Get Properties object for this connection. + * + * @return the Properties for this connection + */ + public Properties getConnectionProperties() { + final Properties p = new Properties(); + p.put("user", this.user); + p.put("password", this.password); + return p; + } + + /** + * Get the connection string for these parameters. + * <p> + * This is public because the DQM database manager is using it. + * + * @return the connection string + */ + public String getConnectionString() { + return "jdbc:mysql://" + this.hostname + ":" + this.port + "/"; + } + + /** + * Get the name of the database. + * + * @return the name of the database + */ + String getDatabase() { + return this.database; + } + + /** + * Get the hostname. + * + * @return the hostname + */ + String getHostname() { + return this.hostname; + } + + /** + * Get the password. + * + * @return the password + */ + String getPassword() { + return this.password; + } + + /** + * Get the port number. + * + * @return the port number + */ + int getPort() { + return this.port; + } + + /** + * Get the user name. + * + * @return the user name + */ + String getUser() { + return this.user; } } Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java ============================================================================= --- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java (original) +++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtAlignmentConstant.java Fri Jun 12 15:27:10 2015 @@ -12,7 +12,6 @@ * translation or rotation of a detector component. * <p> * The format of the keys is ABCDE where:<br> - * * <pre> * A == half == [1,2] * B == alignment type == [1,2] @@ -29,164 +28,21 @@ public final class SvtAlignmentConstant extends BaseConditionsObject { /** - * The alignment constant type which is rotation or translation. - */ - public enum AlignmentType { - /** Rotation alignment type. */ - ROTATION(1), - /** Translation alignment type. */ - TRANSLATION(2); - - /** - * The value of the alignment type constants. - */ - private final int value; - - /** - * Constructor that has value of constant. - * - * @param value the value of the constant - */ - private AlignmentType(final int value) { - this.value = value; - } - - /** - * Get the value for the alignment constant type. - * - * @return the value of the constant - */ - int getValue() { - return this.value; - } - } - - /** - * Top or bottom half. - */ - public enum Half { - /** Bottom half. */ - BOTTOM(2), - /** Top half. */ - TOP(1); - - /** - * The integer value designating top or bottom half. - */ - private final int value; - - /** - * Create from top or bottom value. - * - * @param value the value for half - */ - private Half(final int value) { - this.value = value; - } - - /** - * Get the value for the half. - * - * @return the value - */ - int getValue() { - return this.value; - } - }; - - /** * Collection implementation for {@link SvtAlignmentConstant}. */ @SuppressWarnings("serial") public static class SvtAlignmentConstantCollection extends BaseConditionsObjectCollection<SvtAlignmentConstant> { + + public SvtAlignmentConstant find(int id) { + for (SvtAlignmentConstant constant : this) { + if (constant.getParameter().equals(id)) { + return constant; + } + } + return null; + } + }; - - /** - * The unit axis which for translations maps to XYZ. (Convention for rotation???) - */ - public enum UnitAxis { - /** U unit axis. */ - U(1), - /** V unit axis. */ - V(2), - /** W unit axis. */ - W(3); - - /** - * Value for the constant. - */ - private final int value; - - /** - * Create from value. - * - * @param value the value - */ - private UnitAxis(final int value) { - this.value = value; - } - - /** - * Get the value for the unit axis. - * - * @return the value - */ - int getValue() { - return this.value; - } - }; - - /** - * Maximum value of the module number. - */ - private static final int MAX_MODULE_NUMBER = 10; - - /** - * Decode the AlignmentType value from the key. - * - * @return the AlignmentType value from the key - * @see AlignmentType - */ - public AlignmentType getAlignmentType() { - final int alignmentType = Integer.parseInt(getParameter().substring(1, 2)); - if (alignmentType == AlignmentType.TRANSLATION.getValue()) { - return AlignmentType.TRANSLATION; - } else if (alignmentType == AlignmentType.ROTATION.getValue()) { - return AlignmentType.ROTATION; - } else { - throw new IllegalArgumentException("Could not parse valid AlignmentType from " + getParameter()); - } - } - - /** - * Decode the Half value from the key. - * - * @return the Half value from the key - * @see Half - */ - public Half getHalf() { - final int half = Integer.parseInt(getParameter().substring(0, 1)); - if (half == Half.TOP.getValue()) { - return Half.TOP; - } else if (half == Half.BOTTOM.getValue()) { - return Half.BOTTOM; - } else { - throw new IllegalArgumentException("Could not parse valid Half from " + getParameter()); - } - } - - /** - * Decode the module number from the key. - * - * @return the module number from the key - */ - public int getModuleNumber() { - final int moduleNumber = Integer.parseInt(getParameter().substring(3, 5)); - if (moduleNumber > MAX_MODULE_NUMBER || moduleNumber == 0) { - throw new IllegalArgumentException("The decoded module number " + moduleNumber + " is invalid."); - } - return moduleNumber; - } /** * Get the alignment constant's encoded, raw value. @@ -194,27 +50,9 @@ * @return the alignment constant's key */ @Field(names = {"parameter"}) - public String getParameter() { + public Integer getParameter() { + //System.out.println("parameter = " + this.getFieldValues().get("parameter") + "; type = " + this.getFieldValues().get("parameter").getClass()); return getFieldValue("parameter"); - } - - /** - * Decode the UnitAxis from the key. - * - * @return the UnitAxis v - * @see UnitAxis - */ - public UnitAxis getUnitAxis() { - final int unitAxis = Integer.parseInt(getParameter().substring(2, 3)); - if (unitAxis == UnitAxis.U.getValue()) { - return UnitAxis.U; - } else if (unitAxis == UnitAxis.V.getValue()) { - return UnitAxis.V; - } else if (unitAxis == UnitAxis.W.getValue()) { - return UnitAxis.W; - } else { - throw new IllegalArgumentException("Could not parse valid UnitAxis from " + getParameter()); - } } /** @@ -234,12 +72,6 @@ */ @Override public String toString() { - final StringBuffer buff = new StringBuffer(); - buff.append(super.toString()); - buff.append("half: ").append(getHalf().getValue()).append('\n'); - buff.append("alignment_type: ").append(getAlignmentType().getValue()).append('\n'); - buff.append("unit_axis: ").append(getUnitAxis().getValue()).append('\n'); - buff.append("module_number: ").append(getModuleNumber()).append('\n'); - return buff.toString(); + return "SvtAlignmentConstant parameter = " + this.getParameter() + "; value = " + this.getValue(); } } Modified: java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtDetectorSetup.java ============================================================================= --- java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtDetectorSetup.java (original) +++ java/branches/HPSJAVA-488/conditions/src/main/java/org/hps/conditions/svt/SvtDetectorSetup.java Fri Jun 12 15:27:10 2015 @@ -21,7 +21,8 @@ import org.lcsim.util.log.LogUtil; /** - * This class puts {@link SvtConditions} data onto <code>HpsSiSensor</code> objects. + * This class puts {@link SvtConditions} data onto <code>HpsSiSensor</code> + * objects. * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> * @author <a href="mailto:[log in to unmask]">Omar Moreno</a> @@ -55,7 +56,7 @@ /** * Constructor that takes name of SVT. - * + * * @param svtName the name of the SVT subdetector */ public SvtDetectorSetup(final String svtName) { @@ -64,7 +65,7 @@ /** * Set the name of the SVT in the detector model. - * + * * @param svtName the name of the SVt in the detector model. */ public void setSvtName(final String svtName) { @@ -73,7 +74,7 @@ /** * Set whether this class is enabled to be activated on conditions changes. - * + * * @param enabled <code>true</code> to enable */ public void setEnabled(final boolean enabled) { @@ -82,7 +83,7 @@ /** * Set the log level. - * + * * @param level the log level */ public void setLogLevel(final Level level) { @@ -91,7 +92,8 @@ } /** - * Hook that activates this class when conditions change (new detector or run number). + * Hook that activates this class when conditions change (new detector or + * run number). * * @param event the conditions event */ @@ -176,7 +178,6 @@ // // Set conditions data for this channel on the sensor object: // - // Check if the channel was flagged as bad if (constants.isBadChannel()) { sensor.setBadChannel(channelNumber); @@ -203,13 +204,16 @@ // Set the t0 shift for the sensor. final SvtT0Shift sensorT0Shift = t0Shifts.getT0Shift(daqPair); + if (sensorT0Shift == null) { + throw new RuntimeException("Failed to find T0 shift for sensor: " + sensor.getName() + ", FEB hybrid ID " + daqPair.getFirstElement() + ", FEB ID " + daqPair.getSecondElement()); + } sensor.setT0Shift(sensorT0Shift.getT0Shift()); } } /** * Load conditions from Test Run detector. - * + * * @param subdetector the SVT subdetector object * @param conditions the Test Run conditions */ @@ -264,7 +268,6 @@ // // Set conditions data for this channel on the sensor object: // - // Check if the channel was flagged as bad if (constants.isBadChannel()) { sensor.setBadChannel(channelNumber); Modified: java/branches/HPSJAVA-488/conditions/src/test/java/org/hps/conditions/EngRunConditionsTest.java ============================================================================= --- java/branches/HPSJAVA-488/conditions/src/test/java/org/hps/conditions/EngRunConditionsTest.java (original) +++ java/branches/HPSJAVA-488/conditions/src/test/java/org/hps/conditions/EngRunConditionsTest.java Fri Jun 12 15:27:10 2015 @@ -109,6 +109,16 @@ * Answer for pedestal value check of single channel. */ private static final double PEDESTAL_ANSWER = 105.78; + + /** + * Collection ID of calibrations. + */ + private static final Integer CALIBRATIONS_COLLECTION_ID = 4; + + /** + * Collection ID of gains. + */ + private static final Integer GAINS_COLLECTION_ID = 4; /** * Flag if {@link #detectorChanged(Detector)} is activated. Modified: java/branches/HPSJAVA-488/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtBadChannelsTest.java ============================================================================= --- java/branches/HPSJAVA-488/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtBadChannelsTest.java (original) +++ java/branches/HPSJAVA-488/conditions/src/test/java/org/hps/conditions/svt/TestRunSvtBadChannelsTest.java Fri Jun 12 15:27:10 2015 @@ -86,7 +86,7 @@ //System.out.println(collection.getConditionsRecord()); totalBadChannels += collection.size(); } - System.out.println("found " + totalBadChannels + " total bad chanenls"); + System.out.println("found " + totalBadChannels + " total bad channels"); // The run 0 channels are for all runs. int expectedBadChannels = BAD_CHANNEL_COUNTS[0]; Modified: java/branches/HPSJAVA-488/datacat/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/datacat/pom.xml (original) +++ java/branches/HPSJAVA-488/datacat/pom.xml Fri Jun 12 15:27:10 2015 @@ -38,11 +38,6 @@ <groupId>org.lcsim</groupId> <artifactId>lcio</artifactId> <version>2.4.4-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.jlab.coda</groupId> - <artifactId>jevio</artifactId> - <version>4.3.1</version> </dependency> <dependency> <groupId>srs</groupId> Modified: java/branches/HPSJAVA-488/detector-data/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/detector-data/pom.xml (original) +++ java/branches/HPSJAVA-488/detector-data/pom.xml Fri Jun 12 15:27:10 2015 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/detector-data/</url> Modified: java/branches/HPSJAVA-488/distribution/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/distribution/pom.xml (original) +++ java/branches/HPSJAVA-488/distribution/pom.xml Fri Jun 12 15:27:10 2015 @@ -13,7 +13,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/distribution/</url> @@ -84,5 +84,9 @@ <groupId>org.hps</groupId> <artifactId>hps-evio</artifactId> </dependency> + <dependency> + <groupId>org.hps</groupId> + <artifactId>hps-detector-model</artifactId> + </dependency> </dependencies> </project> Modified: java/branches/HPSJAVA-488/ecal-event-display/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/ecal-event-display/pom.xml (original) +++ java/branches/HPSJAVA-488/ecal-event-display/pom.xml Fri Jun 12 15:27:10 2015 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/ecal-event-display/</url> Modified: java/branches/HPSJAVA-488/ecal-readout-sim/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/ecal-readout-sim/pom.xml (original) +++ java/branches/HPSJAVA-488/ecal-readout-sim/pom.xml Fri Jun 12 15:27:10 2015 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/ecal-readout-sim/</url> Modified: java/branches/HPSJAVA-488/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCEcalReadoutDriver.java ============================================================================= --- java/branches/HPSJAVA-488/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCEcalReadoutDriver.java (original) +++ java/branches/HPSJAVA-488/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCEcalReadoutDriver.java Fri Jun 12 15:27:10 2015 @@ -42,48 +42,33 @@ public class FADCEcalReadoutDriver extends EcalReadoutDriver<RawCalorimeterHit> { // Repeated here from EventConstants in evio module to avoid depending on it. - private static final int ECAL_WINDOW_MODE = 1; + private static final int ECAL_RAW_MODE = 1; private static final int ECAL_PULSE_MODE = 2; private static final int ECAL_PULSE_INTEGRAL_MODE = 3; private String ecalName = "Ecal"; private Subdetector ecal; private EcalConditions ecalConditions = null; //buffer for preamp signals (units of volts, no pedestal) - private Map<Long, RingBuffer> signalMap = null; + private Map<Long, RingBuffer> analogPipelines = null; //ADC pipeline for readout (units of ADC counts) - private Map<Long, FADCPipeline> pipelineMap = null; + private Map<Long, FADCPipeline> digitalPipelines = null; //buffer for window sums - private Map<Long, Integer> sumMap = null; + private Map<Long, Integer> triggerPathHitSums = null; //buffer for timestamps - private Map<Long, Integer> timeMap = null; + private Map<Long, Integer> triggerPathHitTimes = null; //queue for hits to be output to clusterer - private PriorityQueue<RawCalorimeterHit> outputQueue = null; - //length of ring buffer (in readout cycles) + private PriorityQueue<RawCalorimeterHit> triggerPathDelayQueue = null; + //output buffer for hits + private LinkedList<RawCalorimeterHit> triggerPathCoincidenceQueue = new LinkedList<RawCalorimeterHit>(); private int bufferLength = 100; - //length of readout pipeline (in readout cycles) private int pipelineLength = 2000; - //shaper time constant in ns - private double tp = 6.95; - //delay (number of readout periods) between start of summing window and output of hit to clusterer + private double tp = 9.6; 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<RawCalorimeterHit> buffer = new LinkedList<RawCalorimeterHit>(); - //number of readout periods for which a given hit stays in the buffer private int coincidenceWindow = 2; - //output collection name for hits read out from trigger private String ecalReadoutCollectionName = "EcalReadoutHits"; private int mode = ECAL_PULSE_INTEGRAL_MODE; private int readoutThreshold = 10; @@ -92,17 +77,8 @@ private double fixedGain = -1; private boolean constantTriggerWindow = true; private boolean addNoise = false; - - // 32.8 p.e./MeV = New detector in 2014 - // 2 p.e./MeV = Test Run detector - private double pePerMeV = 32.8; //photoelectrons per MeV, used to calculate noise - - //switch between test run and 2014 definitions of gain constants - // true = ONLY simulation studies in 2014 - // false = Test Run data/simulations and 2014+ Detector's real data + private double pePerMeV = 32.8; private boolean use2014Gain = false; - - //switch between three pulse shape functions private PulseShape pulseShape = PulseShape.ThreePole; public enum PulseShape { @@ -118,14 +94,34 @@ // converter = new HPSEcalConverter(null); } + /** + * Add noise (photoelectron statistics and readout/preamp noise) to hits + * before adding them to the analog pipeline. + * + * @param addNoise True to add noise, default of false. + */ public void setAddNoise(boolean addNoise) { this.addNoise = addNoise; } + /** + * Sets the trigger-path hit processing algorithm. + * + * @param constantTriggerWindow True for 2014+ FADC behavior, false for test + * run behavior. True by default. + */ public void setConstantTriggerWindow(boolean constantTriggerWindow) { this.constantTriggerWindow = constantTriggerWindow; } + /** + * Override the ECal gains set in the conditions system with a single + * uniform value. + * + * @param fixedGain Units of MeV/(ADC counts in pulse integral). Negative + * value causes the conditions system to be used for gains. Default is + * negative. + */ public void setFixedGain(double fixedGain) { this.fixedGain = fixedGain; } @@ -134,81 +130,179 @@ this.ecalName = ecalName; } + /** + * Threshold for readout-path hits. For 2014+ running this should always + * equal the trigger threshold. + * + * @param readoutThreshold Units of ADC counts, default of 10. + */ public void setReadoutThreshold(int readoutThreshold) { this.readoutThreshold = readoutThreshold; } + /** + * Scale factor for trigger-path hit amplitudes. Only used for test run. + * + * @param scaleFactor Default of 1. + */ public void setScaleFactor(double scaleFactor) { this.scaleFactor = scaleFactor; } + /** + * Threshold for trigger-path hits. For 2014+ running this should always + * equal the readout threshold. + * + * @param triggerThreshold Units of ADC counts, default of 10. + */ public void setTriggerThreshold(int triggerThreshold) { this.triggerThreshold = triggerThreshold; } + /** + * Output collection name for readout-path hits. + * + * @param ecalReadoutCollectionName + */ public void setEcalReadoutCollectionName(String ecalReadoutCollectionName) { this.ecalReadoutCollectionName = ecalReadoutCollectionName; } + /** + * Number of ADC samples to process after each rising threshold crossing. In + * FADC documentation, "number of samples after" or NSA. + * + * @param numSamplesAfter Units of 4 ns FADC clock cycles, default of 30. + */ public void setNumSamplesAfter(int numSamplesAfter) { this.numSamplesAfter = numSamplesAfter; } + /** + * Number of ADC samples to process before each rising threshold crossing. + * In FADC documentation, "number of samples before" or NSB. + * + * @param numSamplesBefore Units of 4 ns FADC clock cycles, default of 5. + */ public void setNumSamplesBefore(int numSamplesBefore) { this.numSamplesBefore = numSamplesBefore; } + /** + * Start of readout window relative to trigger time (in readout cycles). In + * FADC documentation, "Programmable Latency" or PL. + * + * @param readoutLatency Units of 4 ns FADC clock cycles, default of 100. + */ public void setReadoutLatency(int readoutLatency) { this.readoutLatency = readoutLatency; } + /** + * Number of ADC samples to read out. In FADC documentation, "Programmable + * Trigger Window" or PTW. + * + * @param readoutWindow Units of 4 ns FADC clock cycles, default of 100. + */ public void setReadoutWindow(int readoutWindow) { this.readoutWindow = readoutWindow; } + /** + * Number of clock cycles for which the same trigger-path hit is sent to the + * clusterer. Only used for old clusterer simulations (CTPClusterDriver). + * Otherwise this should be set to 1. + * + * @param coincidenceWindow Units of 4 ns FADC clock cycles, default of 1. + */ public void setCoincidenceWindow(int coincidenceWindow) { this.coincidenceWindow = coincidenceWindow; } + /** + * Switch between test run and 2014 definitions of gain constants. True for + * MC studies and mock data in 2014. For all real data (test run and 2014+), + * test run MC, and 2015+ production MC, this should be false. + * + * + * @param use2014Gain True ONLY for simulation studies in 2014. Default of + * false. + */ public void setUse2014Gain(boolean use2014Gain) { this.use2014Gain = use2014Gain; } + /** + * Model used for the preamp pulse shape. + * + * @param pulseShape ThreePole, DoubleGaussian, or CRRC. Default is + * ThreePole. + */ public void setPulseShape(String pulseShape) { this.pulseShape = PulseShape.valueOf(pulseShape); } + /** + * Shaper time constant. Definition depends on the pulse shape. For the + * three-pole function, this is equal to RC, or half the peaking time. + * + * @param tp Units of ns, default of 9.6. + */ public void setTp(double tp) { this.tp = tp; } -// public void setFallTime(double fallTime) { -// this.fallTime = fallTime; -// } + /** + * Photoelectrons per MeV, used to calculate noise due to photoelectron + * statistics. Test run detector had a value of 2 photoelectrons/MeV; new + * 2014 detector has a value of 32.8 photoelectrons/MeV. + * + * @param pePerMeV Units of photoelectrons/MeV, default of 32.8. + */ public void setPePerMeV(double pePerMeV) { this.pePerMeV = pePerMeV; } -// public void setRiseTime(double riseTime) { -// this.riseTime = riseTime; -// } + /** + * Latency between threshold crossing and output of trigger-path hit to + * clusterer. + * + * @param delay0 Units of 4 ns FADC clock cycles, default of 32. + */ public void setDelay0(int delay0) { this.delay0 = delay0; } + /** + * Length of analog pipeline. + * + * @param bufferLength Units of 4 ns FADC clock cycles, default of 100. + */ public void setBufferLength(int bufferLength) { this.bufferLength = bufferLength; resetFADCBuffers(); } + /** + * Length of digital pipeline. The digital pipeline in the FADC is 2000 + * cells long. + * + * @param pipelineLength Units of 4 ns FADC clock cycles, default of 2000. + */ public void setPipelineLength(int pipelineLength) { this.pipelineLength = pipelineLength; resetFADCBuffers(); } + /** + * Mode for readout-path hits. + * + * @param mode 1, 2 or 3. Values correspond to the standard FADC mode + * numbers (1=raw, 2=pulse, 3=pulse integral). + */ public void setMode(int mode) { this.mode = mode; - if (mode != ECAL_WINDOW_MODE && mode != ECAL_PULSE_MODE && mode != ECAL_PULSE_INTEGRAL_MODE) { + if (mode != ECAL_RAW_MODE && mode != ECAL_PULSE_MODE && mode != ECAL_PULSE_INTEGRAL_MODE) { throw new IllegalArgumentException("invalid mode " + mode); } } @@ -219,7 +313,7 @@ * @return */ public Map<Long, RingBuffer> getSignalMap() { - return signalMap; + return analogPipelines; } /** @@ -228,18 +322,25 @@ * @return */ public Map<Long, FADCPipeline> getPipelineMap() { - return pipelineMap; - } - + return digitalPipelines; + } + + /** + * Digitize values in the analog pipelines and append them to the digital + * pipelines. Integrate trigger-path hits and add them to the trigger path + * queues. Read out trigger-path hits to the list sent to the clusterer. + * + * @param hits List to be filled by this method. + */ @Override protected void readHits(List<RawCalorimeterHit> hits) { - for (Long cellID : signalMap.keySet()) { - RingBuffer signalBuffer = signalMap.get(cellID); - - FADCPipeline pipeline = pipelineMap.get(cellID); + for (Long cellID : analogPipelines.keySet()) { + RingBuffer signalBuffer = analogPipelines.get(cellID); + + FADCPipeline pipeline = digitalPipelines.get(cellID); pipeline.step(); - + // Get the channel data. EcalChannelConstants channelData = findChannel(cellID); @@ -250,9 +351,9 @@ int pedestalSubtractedValue = digitizedValue - pedestal; //System.out.println(signalBuffer.currentValue() + " " + currentValue + " " + pipeline.currentValue()); - Integer sum = sumMap.get(cellID); + Integer sum = triggerPathHitSums.get(cellID); if (sum == null && pedestalSubtractedValue > triggerThreshold) { - timeMap.put(cellID, readoutCounter); + triggerPathHitTimes.put(cellID, readoutCounter); if (constantTriggerWindow) { int sumBefore = 0; for (int i = 0; i < numSamplesBefore; i++) { @@ -261,57 +362,57 @@ } sumBefore += pipeline.getValue(numSamplesBefore - i - 1); } - sumMap.put(cellID, sumBefore); + triggerPathHitSums.put(cellID, sumBefore); } else { - sumMap.put(cellID, pedestalSubtractedValue); + triggerPathHitSums.put(cellID, pedestalSubtractedValue); } } if (sum != null) { if (constantTriggerWindow) { - if (timeMap.get(cellID) + numSamplesAfter >= readoutCounter) { + if (triggerPathHitTimes.get(cellID) + numSamplesAfter >= readoutCounter) { if (debug) { - System.out.format("trigger %d, %d: %d\n", cellID, readoutCounter - timeMap.get(cellID) + numSamplesBefore - 1, pipeline.getValue(0)); + System.out.format("trigger %d, %d: %d\n", cellID, readoutCounter - triggerPathHitTimes.get(cellID) + numSamplesBefore - 1, pipeline.getValue(0)); } - sumMap.put(cellID, sum + pipeline.getValue(0)); - } else if (timeMap.get(cellID) + delay0 <= readoutCounter) { + triggerPathHitSums.put(cellID, sum + pipeline.getValue(0)); + } else if (triggerPathHitTimes.get(cellID) + delay0 <= readoutCounter) { // System.out.printf("sum = %f\n", sum); - outputQueue.add(new BaseRawCalorimeterHit(cellID, + triggerPathDelayQueue.add(new BaseRawCalorimeterHit(cellID, (int) Math.round(sum / scaleFactor), - 64 * timeMap.get(cellID))); - sumMap.remove(cellID); + 64 * triggerPathHitTimes.get(cellID))); + triggerPathHitSums.remove(cellID); } } else { - if (pedestalSubtractedValue < triggerThreshold || timeMap.get(cellID) + delay0 == readoutCounter) { + if (pedestalSubtractedValue < triggerThreshold || triggerPathHitTimes.get(cellID) + delay0 == readoutCounter) { // System.out.printf("sum = %f\n",sum); - outputQueue.add(new BaseRawCalorimeterHit(cellID, + triggerPathDelayQueue.add(new BaseRawCalorimeterHit(cellID, (int) Math.round((sum + pedestalSubtractedValue) / scaleFactor), - 64 * timeMap.get(cellID))); - sumMap.remove(cellID); + 64 * triggerPathHitTimes.get(cellID))); + triggerPathHitSums.remove(cellID); } else { - sumMap.put(cellID, sum + pedestalSubtractedValue); + triggerPathHitSums.put(cellID, sum + pedestalSubtractedValue); } } } signalBuffer.step(); } - while (outputQueue.peek() != null && outputQueue.peek().getTimeStamp() / 64 <= readoutCounter - delay0) { - if (outputQueue.peek().getTimeStamp() / 64 < readoutCounter - delay0) { + while (triggerPathDelayQueue.peek() != null && triggerPathDelayQueue.peek().getTimeStamp() / 64 <= readoutCounter - delay0) { + if (triggerPathDelayQueue.peek().getTimeStamp() / 64 < readoutCounter - delay0) { System.out.println(this.getName() + ": Stale hit in output queue"); - outputQueue.poll(); + triggerPathDelayQueue.poll(); } else { - buffer.add(outputQueue.poll()); - } - } - while (!buffer.isEmpty() && buffer.peek().getTimeStamp() / 64 <= readoutCounter - delay0 - coincidenceWindow) { - buffer.remove(); + triggerPathCoincidenceQueue.add(triggerPathDelayQueue.poll()); + } + } + while (!triggerPathCoincidenceQueue.isEmpty() && triggerPathCoincidenceQueue.peek().getTimeStamp() / 64 <= readoutCounter - delay0 - coincidenceWindow) { + triggerPathCoincidenceQueue.remove(); } if (debug) { - for (RawCalorimeterHit hit : buffer) { + for (RawCalorimeterHit hit : triggerPathCoincidenceQueue) { System.out.format("new hit: energy %d\n", hit.getAmplitude()); } } - hits.addAll(buffer); + hits.addAll(triggerPathCoincidenceQueue); } @Override @@ -325,9 +426,9 @@ @Override protected void processTrigger(EventHeader event) { switch (mode) { - case ECAL_WINDOW_MODE: + case ECAL_RAW_MODE: if (debug) { - System.out.println("Reading out ECal in window mode"); + System.out.println("Reading out ECal in raw mode"); } event.put(ecalReadoutCollectionName, readWindow(), RawTrackerHit.class, 0, ecalReadoutName); break; @@ -355,7 +456,7 @@ } protected short[] getWindow(long cellID) { - FADCPipeline pipeline = pipelineMap.get(cellID); + FADCPipeline pipeline = digitalPipelines.get(cellID); short[] adcValues = new short[readoutWindow]; for (int i = 0; i < readoutWindow; i++) { adcValues[i] = (short) pipeline.getValue(readoutLatency - i - 1); @@ -369,9 +470,19 @@ protected List<RawTrackerHit> readWindow() { // System.out.println("Reading FADC data"); List<RawTrackerHit> hits = new ArrayList<RawTrackerHit>(); - for (Long cellID : pipelineMap.keySet()) { + for (Long cellID : digitalPipelines.keySet()) { short[] adcValues = getWindow(cellID); - hits.add(new BaseRawTrackerHit(cellID, 0, adcValues)); + EcalChannelConstants channelData = findChannel(cellID); + boolean isAboveThreshold = false; + for (int i = 0; i < adcValues.length; i++) { + if (adcValues[i] > channelData.getCalibration().getPedestal() + readoutThreshold) { + isAboveThreshold = true; + break; + } + } + if (isAboveThreshold) { + hits.add(new BaseRawTrackerHit(cellID, 0, adcValues)); + } } return hits; } @@ -379,18 +490,21 @@ protected List<RawTrackerHit> readPulses() { // System.out.println("Reading FADC data"); List<RawTrackerHit> hits = new ArrayList<RawTrackerHit>(); - for (Long cellID : pipelineMap.keySet()) { + for (Long cellID : digitalPipelines.keySet()) { short[] window = getWindow(cellID); short[] adcValues = null; int pointerOffset = 0; int numSamplesToRead = 0; int thresholdCrossing = 0; - + // Get the channel data. EcalChannelConstants channelData = findChannel(cellID); - + for (int i = 0; i < readoutWindow; i++) { if (numSamplesToRead != 0) { + if (adcValues == null) { + throw new RuntimeException("expected a pulse buffer, none found (this should never happen)"); + } adcValues[adcValues.length - numSamplesToRead] = window[i - pointerOffset]; numSamplesToRead--; if (numSamplesToRead == 0) { @@ -410,16 +524,16 @@ protected List<RawCalorimeterHit> readIntegrals() { // System.out.println("Reading FADC data"); List<RawCalorimeterHit> hits = new ArrayList<RawCalorimeterHit>(); - for (Long cellID : pipelineMap.keySet()) { + for (Long cellID : digitalPipelines.keySet()) { short[] window = getWindow(cellID); int adcSum = 0; int pointerOffset = 0; int numSamplesToRead = 0; int thresholdCrossing = 0; - + // Get the channel data. EcalChannelConstants channelData = findChannel(cellID); - + if (window != null) { for (int i = 0; i < readoutWindow; i++) { if (numSamplesToRead != 0) { @@ -443,11 +557,17 @@ return hits; } + /** + * Fill the analog pipelines with the preamp pulses generated by hits in the + * ECal. + * + * @param hits ECal hits from SLIC/Geant4. + */ @Override protected void putHits(List<CalorimeterHit> hits) { //fill the readout buffers for (CalorimeterHit hit : hits) { - RingBuffer eDepBuffer = signalMap.get(hit.getCellID()); + RingBuffer eDepBuffer = analogPipelines.get(hit.getCellID()); double energyAmplitude = hit.getRawEnergy(); // Get the channel data. EcalChannelConstants channelData = findChannel(hit.getCellID()); @@ -455,13 +575,16 @@ //add preamp noise and photoelectron Poisson noise in quadrature double noise; if (use2014Gain) { - noise = Math.sqrt(Math.pow(channelData.getCalibration().getNoise() * channelData.getGain().getGain() * EcalUtils.gainFactor * EcalUtils.ecalReadoutPeriod, 2) - + hit.getRawEnergy() / (EcalUtils.lightYield * EcalUtils.quantumEff * EcalUtils.surfRatio)); + noise = Math.sqrt(Math.pow(channelData.getCalibration().getNoise() * channelData.getGain().getGain() * EcalUtils.gainFactor * EcalUtils.ecalReadoutPeriod, 2) + + hit.getRawEnergy() / (EcalUtils.lightYield * EcalUtils.quantumEff * EcalUtils.surfRatio)); } else { - noise = Math.sqrt(Math.pow(channelData.getCalibration().getNoise() * channelData.getGain().getGain() * EcalUtils.MeV, 2) - + hit.getRawEnergy() * EcalUtils.MeV / pePerMeV); + noise = Math.sqrt(Math.pow(channelData.getCalibration().getNoise() * channelData.getGain().getGain() * EcalUtils.MeV, 2) + + hit.getRawEnergy() * EcalUtils.MeV / pePerMeV); } energyAmplitude += RandomGaussian.getGaussian(0, noise); + } + if ((1) * readoutPeriod + readoutTime() - (ClockSingleton.getTime() + hit.getTime()) >= readoutPeriod) { + throw new RuntimeException("trying to add a hit to the analog pipeline, but time seems incorrect"); } for (int i = 0; i < bufferLength; i++) { eDepBuffer.addToCell(i, energyAmplitude * pulseAmplitude((i + 1) * readoutPeriod + readoutTime() - (ClockSingleton.getTime() + hit.getTime()), hit.getCellID())); @@ -472,9 +595,9 @@ @Override protected void initReadout() { //initialize buffers - sumMap = new HashMap<Long, Integer>(); - timeMap = new HashMap<Long, Integer>(); - outputQueue = new PriorityQueue(20, new TimeComparator()); + triggerPathHitSums = new HashMap<Long, Integer>(); + triggerPathHitTimes = new HashMap<Long, Integer>(); + triggerPathDelayQueue = new PriorityQueue(20, new TimeComparator()); resetFADCBuffers(); } @@ -482,10 +605,10 @@ public void detectorChanged(Detector detector) { // Get the Subdetector. ecal = detector.getSubdetector(ecalName); - + // ECAL combined conditions object. ecalConditions = DatabaseConditionsManager.getInstance().getEcalConditions(); - + resetFADCBuffers(); } @@ -493,21 +616,30 @@ if (ecal == null) { return false; } - signalMap = new HashMap<Long, RingBuffer>(); - pipelineMap = new HashMap<Long, FADCPipeline>(); + analogPipelines = new HashMap<Long, RingBuffer>(); + digitalPipelines = new HashMap<Long, FADCPipeline>(); Set<Long> cells = ((HPSEcal3) ecal).getNeighborMap().keySet(); for (Long cellID : cells) { - EcalChannelConstants channelData = findChannel(cellID); - signalMap.put(cellID, new RingBuffer(bufferLength)); - pipelineMap.put(cellID, new FADCPipeline(pipelineLength, (int) Math.round(channelData.getCalibration().getPedestal()))); + EcalChannelConstants channelData = findChannel(cellID); + analogPipelines.put(cellID, new RingBuffer(bufferLength)); + digitalPipelines.put(cellID, new FADCPipeline(pipelineLength, (int) Math.round(channelData.getCalibration().getPedestal()))); } return true; } + /** + * Returns pulse amplitude at the given time (relative to hit time). Gain is + * applied. + * + * @param time Units of ns. Relative to hit time (negative=before the start + * of the pulse). + * @param cellID Crystal ID as returned by hit.getCellID(). + * @return Amplitude, units of volts/GeV. + */ private double pulseAmplitude(double time, long cellID) { // Get the channel data. EcalChannelConstants channelData = findChannel(cellID); - + if (use2014Gain) { //if fixedGain is set, multiply the default gain by this factor double corrGain; @@ -533,10 +665,11 @@ /** * Returns pulse amplitude at the given time (relative to hit time). - * Amplitude is normalized so the pulse integral is 1. - * - * @param time - * @return + * + * @param time Units of ns. Relative to hit time (negative=before the start + * of the pulse). + * @return Amplitude, units of inverse ns. Normalized so the pulse integral + * is 1. */ public static double pulseAmplitude(double time, PulseShape shape, double shapingTime) { if (time <= 0.0) { @@ -615,22 +748,22 @@ return array[((ptr - pos) % size + size) % size]; } } - - /** + + /** * Convert physical ID to gain value. + * * @param cellID (long) * @return channel constants (EcalChannelConstants) */ private EcalChannelConstants findChannel(long cellID) { return ecalConditions.getChannelConstants(ecalConditions.getChannelCollection().findGeometric(cellID)); } - - - public static class TimeComparator implements Comparator<RawCalorimeterHit> { + + public static class TimeComparator implements Comparator<RawCalorimeterHit> { @Override - public int compare(RawCalorimeterHit o1, RawCalorimeterHit o2) { - return o1.getTimeStamp() - o2.getTimeStamp(); - } - } + public int compare(RawCalorimeterHit o1, RawCalorimeterHit o2) { + return o1.getTimeStamp() - o2.getTimeStamp(); + } + } } Modified: java/branches/HPSJAVA-488/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCPrimaryTriggerDriver.java ============================================================================= --- java/branches/HPSJAVA-488/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCPrimaryTriggerDriver.java (original) +++ java/branches/HPSJAVA-488/ecal-readout-sim/src/main/java/org/hps/readout/ecal/FADCPrimaryTriggerDriver.java Fri Jun 12 15:27:10 2015 @@ -70,6 +70,7 @@ private IHistogram1D[] pairCoplanarity; private IHistogram1D[] pairEnergySlope; private IHistogram2D[] clusterDistribution; + private IHistogram2D[] pairEnergySum2DDistribution; /** * Initializes the cluster pair queues and other variables. @@ -106,6 +107,7 @@ pairEnergyDifference = new IHistogram1D[PLOT_COUNT - 1]; pairCoplanarity = new IHistogram1D[PLOT_COUNT - 1]; pairEnergySlope = new IHistogram1D[PLOT_COUNT - 1]; + pairEnergySum2DDistribution = new IHistogram2D[PLOT_COUNT - 1]; // Instantiate the plots. for(int i = 0; i < PLOT_COUNT; i++) { @@ -120,6 +122,7 @@ pairEnergyDifference[i] = aida.histogram1D(plotDir[i] + "Pair Energy Difference" + plotType[i], 176, 0.0, 2.2); pairCoplanarity[i] = aida.histogram1D(plotDir[i] + "Pair Coplanarity" + plotType[i], 180, 0.0, 180.0); pairEnergySlope[i] = aida.histogram1D(plotDir[i] + "Pair Energy Slope" + plotType[i], 200, 0.0, 4.0); + pairEnergySum2DDistribution[i] = aida.histogram2D(plotDir[i] + "Pair Energy Sum 2D" + plotType[i], 176, 0.0, 4.4, 176, 0.0, 4.4); } } @@ -629,6 +632,7 @@ pairEnergyDifference[NO_CUTS].fill(energyDifference); pairEnergySlope[NO_CUTS].fill(energySlope); pairCoplanarity[NO_CUTS].fill(coplanarity); + pairEnergySum2DDistribution[NO_CUTS].fill(clusterPair[0].getEnergy(), clusterPair[1].getEnergy()); // Fill the hit count plots for N > 1. if(clusterPair[0].getCalorimeterHits().size() > 1 && clusterPair[1].getCalorimeterHits().size() > 1) { @@ -637,6 +641,7 @@ pairEnergyDifference[OVER_1HIT].fill(energyDifference); pairEnergySlope[OVER_1HIT].fill(energySlope); pairCoplanarity[OVER_1HIT].fill(coplanarity); + pairEnergySum2DDistribution[OVER_1HIT].fill(clusterPair[0].getEnergy(), clusterPair[1].getEnergy()); // Fill the hit count plots for N > 2. if(clusterPair[0].getCalorimeterHits().size() > 2 && clusterPair[1].getCalorimeterHits().size() > 2) { @@ -645,6 +650,7 @@ pairEnergyDifference[OVER_2HIT].fill(energyDifference); pairEnergySlope[OVER_2HIT].fill(energySlope); pairCoplanarity[OVER_2HIT].fill(coplanarity); + pairEnergySum2DDistribution[OVER_2HIT].fill(clusterPair[0].getEnergy(), clusterPair[1].getEnergy()); } } @@ -716,8 +722,12 @@ pairEnergyDifference[ALL_CUTS].fill(energyDifference, 1); pairEnergySlope[ALL_CUTS].fill(energySlope, 1); pairCoplanarity[ALL_CUTS].fill(coplanarity, 1); + pairEnergySum2DDistribution[ALL_CUTS].fill(clusterPair[0].getEnergy(), clusterPair[1].getEnergy()); // Clusters that pass all of the pair cuts produce a trigger. + if (verbose) { + System.out.format("Passed trigger cuts: cluster 0 (energy %f, ix %d, iy %d, size %d) and cluster 1 (energy %f, ix %d, iy %d, size %d)\n", clusterPair[0].getEnergy(), clusterPair[0].getCalorimeterHits().get(0).getIdentifierFieldValue("ix"), clusterPair[0].getCalorimeterHits().get(0).getIdentifierFieldValue("iy"), clusterPair[0].getSize(), clusterPair[1].getEnergy(), clusterPair[1].getCalorimeterHits().get(0).getIdentifierFieldValue("ix"), clusterPair[1].getCalorimeterHits().get(0).getIdentifierFieldValue("iy"), clusterPair[1].getSize()); + } return true; } Modified: java/branches/HPSJAVA-488/ecal-recon/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/ecal-recon/pom.xml (original) +++ java/branches/HPSJAVA-488/ecal-recon/pom.xml Fri Jun 12 15:27:10 2015 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/ecal-recon/</url> Modified: java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalEdepToTriggerConverterDriver.java ============================================================================= --- java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalEdepToTriggerConverterDriver.java (original) +++ java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalEdepToTriggerConverterDriver.java Fri Jun 12 15:27:10 2015 @@ -15,9 +15,18 @@ /** - * - * @version $Id: HPSEcalRawConverterDriver.java,v 1.2 2012/05/03 00:17:54 - * phansson Exp $ + * This file can be used on Monte Carlo and excludes pile up. This makes + * it useful to study sampling fractions and energy resolution when firing single + * energy particles at the detector. This file takes the geant4 energy deposition, + * and converts it to uits of FADC using the pulse integral value and gain (amplitude). + * The amplitude can include noise if desired. This value is then compared to the + * readout/trigger thresholds in FADC. Finally,this value is converted back into GeV + * energy output which can be used for clustering, etc. + * + * Original author for test run: + * @author phansson + * Modified from test run to Spring 2015 running: + * @author Holly Szumila <[log in to unmask]> */ public class EcalEdepToTriggerConverterDriver extends Driver { @@ -30,16 +39,16 @@ private String readoutCollection = "EcalCalHits"; private String triggerCollection = "EcalTriggerHits"; private boolean applyBadCrystalMap = true; - private double tp = 14.0; + private double tp = 6.95; //14.0 for test run; private final double readoutPeriod = 4.0; - private final int readoutThreshold = 50; - private final int triggerThreshold = 80; + private final int readoutThreshold = 12;//FADC units; 50 for test run; + private final int triggerThreshold = 12;//FADC units; 80; private int truncateScale = 128; - private final double pulseIntegral = tp * Math.E / readoutPeriod; + private final double pulseIntegral = tp * Math.E * Math.E /(2*readoutPeriod);//tp * Math.E / readoutPeriod (test run); private final double gainScale = 1.0; //gain miscalibration factor private double _gain = -1.0; //constant gain, activated if >0 private boolean addNoise = false; - private final double pePerMeV = 2.0; //photoelectrons per MeV, used to calculate noise + private final double pePerMeV = 32.8; //photoelectrons per MeV, used to calculate noise public EcalEdepToTriggerConverterDriver() { } Modified: java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java ============================================================================= --- java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java (original) +++ java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverter.java Fri Jun 12 15:27:10 2015 @@ -1,4 +1,6 @@ package org.hps.recon.ecal; + +import hep.aida.IFitResult; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -27,8 +29,11 @@ * @author Sho Uemura <[log in to unmask]> * @author Andrea Celentano <[log in to unmask]> * @author Nathan Baltzell <[log in to unmask]> + * @author Holly Szumila <[log in to unmask]> * - * baltzell: New in 2015: (default behavior is still unchanged) + * baltzell: May 2015: Pulse Fitting. (default behavior unchanged) + * + * baltzell: Early 2015: (default behavior is still unchanged) * * Implemented conversion of Mode-1 to Mode-3. * @@ -54,6 +59,9 @@ private boolean useDAQConfig = false; private FADCConfig config = null; + private boolean useFit = false; + private EcalPulseFitter pulseFitter = new EcalPulseFitter(); + /* * The time for one FADC sample (units = ns). */ @@ -141,6 +149,19 @@ }); } + public void setUseFit(boolean useFit) { this.useFit=useFit; } + public void setFixShapeParameter(boolean fix) { pulseFitter.fixShapeParameter=fix; } + public void setGlobalFixedPulseWidth(double width) { + pulseFitter.globalThreePoleWidth=width; + pulseFitter.fixShapeParameter=true; + } + public void setFitThresholdTimeLo(int sample) { pulseFitter.threshRange[0]=sample; } + public void setFitThresholdTimeHi(int sample) { pulseFitter.threshRange[1]=sample; } + public void setFitLimitTimeLo(int sample) { pulseFitter.t0limits[0]=sample; } + public void setFitLimitTimeHi(int sample) { pulseFitter.t0limits[1]=sample; } + + + public void setLeadingEdgeThreshold(double thresh) { leadingEdgeThreshold=thresh; } @@ -195,6 +216,8 @@ public void setUseDAQConfig(boolean state) { useDAQConfig = state; } + + /* * This should probably be deprecated. It just integrates the entire window. @@ -286,8 +309,11 @@ * given a time for threshold crossing. */ public double[] convertWaveformToPulse(RawTrackerHit hit,int thresholdCrossing,boolean mode7) { + + double fitQuality = -1; + short samples[] = hit.getADCValues(); - + //System.out.println("NewEvent"); // choose integration range: int firstSample,lastSample; if ((NSA+NSB)/nsPerSample >= samples.length) { @@ -303,14 +329,17 @@ double minADC=0; for (int jj=0; jj<4; jj++) minADC += samples[jj]; // does the firmware's conversion of min to int occur before or after time calculation? undocumented. - minADC=(int)(minADC/4); + //minADC=(int)(minADC/4); + minADC = (minADC/4); + + //System.out.println("Avg pedestal:\t"+minADC); // mode-7's max pulse height: double maxADC=0; int sampleMaxADC=0; // mode-3/7's pulse integral: - short sumADC = 0; + double sumADC = 0; for (int jj=firstSample; jj<=lastSample; jj++) { @@ -319,19 +348,22 @@ // integrate pulse: sumADC += samples[jj]; - - // find pulse maximum: - if (jj>firstSample && jj<samples.length-5) { // The "5" here is a firmware constant. - if (samples[jj+1]<samples[jj]) { - sampleMaxADC=jj; - maxADC=samples[jj]; - } - } - } - + } + + // find pulse maximum: + //if (jj>firstSample && jj<samples.length-5) { // The "5" here is a firmware constant. + for (int jj=thresholdCrossing; jj<samples.length-5; jj++) { // The "5" here is a firmware constant. + if (samples[jj+1]<samples[jj]){ + sampleMaxADC=jj; + maxADC=samples[jj]; + break; + } + } + + // pulse time with 4ns resolution: double pulseTime=thresholdCrossing*nsPerSample; - + // calculate Mode-7 high-resolution time: if (mode7) { if (thresholdCrossing < 4) { @@ -341,22 +373,45 @@ else if (maxADC>0) { // linear interpolation between threshold crossing and // pulse maximum to find time at pulse half-height: - double t0 = thresholdCrossing*nsPerSample; - double a0 = samples[thresholdCrossing]; - double t1 = sampleMaxADC*nsPerSample; - double a1 = maxADC; - double slope = (a1-a0)/(t1-t0); - double halfMax = (maxADC+minADC)/2; - // this is not rigorously firmware-correct, need to find halfMax-crossing. - double tmpTime = t1 - (a1 - halfMax) / slope; - if (slope>0 && tmpTime>0) { - pulseTime = tmpTime; + + final double halfMax = (maxADC+minADC)/2; + int t0 = -1; + for (int ii=thresholdCrossing-1; ii<lastSample; ii++) + { + if (ii>=samples.length-1) break; + if (samples[ii]<=halfMax && samples[ii+1]>halfMax) + { + t0 = ii; + break; + } } - // else another special firmware case - } - } - - return new double []{pulseTime,sumADC,minADC,maxADC}; + if (t0 > 0) + { + final int t1 = t0 + 1; + final int a0 = samples[t0]; + final int a1 = samples[t1]; + final double slope = (a1 - a0); // units = ADC/sample + final double yint = a1 - slope * t1; // units = ADC + pulseTime = ((halfMax - a0)/(a1-a0) + t0)* nsPerSample; + } + } + } + + if (useFit) + { + IFitResult fitResult = pulseFitter.fitPulse(hit,thresholdCrossing,maxADC); + if (fitResult!=null) { + fitQuality = fitResult.quality(); + if (fitQuality > 0) { + pulseTime = fitResult.fittedParameter("time0")*nsPerSample; + sumADC = fitResult.fittedParameter("integral"); + minADC = fitResult.fittedParameter("pedestal"); + maxADC = ((Ecal3PoleFunction)fitResult.fittedFunction()).maximum(); + } + } + } + + return new double []{pulseTime,sumADC,minADC,maxADC,fitQuality}; } @@ -428,9 +483,12 @@ double sum = data[1]; final double min = data[2]; // TODO: stick min and max in a GenericObject with an final double max = data[3]; // LCRelation to finish mode-7 emulation + final double fitQuality = data[4]; - // do pedestal subtraction: - sum -= getPulsePedestal(event, cellID, samples.length, thresholdCrossing); + if (!useFit || fitQuality<=0) { + // do pedestal subtraction: + sum -= getPulsePedestal(event, cellID, samples.length, thresholdCrossing); + } // do gain scaling: double energy = adcToEnergy(sum, cellID); @@ -530,6 +588,7 @@ public void setDetector(Detector detector) { // ECAL combined conditions object. ecalConditions = DatabaseConditionsManager.getInstance().getEcalConditions(); + pulseFitter.setDetector(detector); } /** Modified: java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java ============================================================================= --- java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java (original) +++ java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRawConverterDriver.java Fri Jun 12 15:27:10 2015 @@ -18,17 +18,7 @@ import org.lcsim.util.Driver; /** - * - * - * baltzell New in 2015: (default behavior is unchanged) - * Added firmware emulation for converting from Mode-1 readout (RawTrackerHit) - * to Mode-3 pulse (CalorimeterHit). Turn it on with "emulateFirmware", else - * defaults to previous behavior. - * - * Removed integralWindow in favor of NSA/NSB to allow treating all Modes uniformly. - * (New) NSA+NSB == (Old) integralWindow*4(ns) - * - * Implemented finding multiple peaks for Mode-1. + * baltzell June 2015: removed outdated javadoc comments in the class header */ public class EcalRawConverterDriver extends Driver { @@ -57,6 +47,33 @@ converter = new EcalRawConverter(); } + /* + * Set to <code>true</code> to use pulse fitting instead of arithmetic integration:<br/> + */ + public void setUseFit(boolean useFit) { converter.setUseFit(useFit); } + + /* + * Fix 3-pole function width to be the same for all 442 ECal channels. Units=samples. + */ + public void setGlobalFixedPulseWidth(double width) { converter.setGlobalFixedPulseWidth(width); } + + /* + * Set to <code>true</code> to fix fitted pulse widths to their channel's mean value:<br/> + */ + public void setFixShapeParameter(boolean fix) { converter.setFixShapeParameter(fix); } + + /* + * Limit threshold crossing range that is candidate for pulse-fitting. Units=samples. + */ + public void setFitThresholdTimeLo(int sample) { converter.setFitThresholdTimeLo(sample); } + public void setFitThresholdTimeHi(int sample) { converter.setFitThresholdTimeHi(sample); } + + /* + * Constrain pulse fit time0 parameter. Units=samples. + */ + public void setFitLimitTimeLo(int sample) { converter.setFitLimitTimeLo(sample); } + public void setFitLimitTimeHi(int sample) { converter.setFitLimitTimeHi(sample); } + /** * Set to <code>true</code> to use the "2014" gain formula:<br/> * <pre>channelGain * adcSum * gainFactor * readoutPeriod</pre> Modified: java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRunningPedestalDriver.java ============================================================================= --- java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRunningPedestalDriver.java (original) +++ java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/EcalRunningPedestalDriver.java Fri Jun 12 15:27:10 2015 @@ -12,12 +12,15 @@ import org.lcsim.event.GenericObject; import org.lcsim.event.LCRelation; import org.lcsim.event.RawCalorimeterHit; +import org.lcsim.event.RawTrackerHit; import org.lcsim.geometry.Detector; import org.lcsim.util.Driver; /** * Calculate a running pedestal average for every channel from Mode7 FADCs. Uses * pedestals from the database if not available from the data. + * + * May 2015: Updated to also work on Mode1 data. * * TODO: Use Logger. * @@ -49,6 +52,9 @@ private static final String extraDataRelationsName = "EcalReadoutExtraDataRelations"; private static final String runningPedestalsName = "EcalRunningPedestals"; + // number of samples from the beginning of the time window used to calculate the pedestal: + private static final int nSamples = 4; + // TODO: Get this from somewhere else. private final int nChannels = 442; @@ -57,7 +63,7 @@ nChannels); // recent event-by-event pedestals and timestamps: - private Map<EcalChannel, List<Integer>> eventPedestals = new HashMap<EcalChannel, List<Integer>>(); + private Map<EcalChannel, List<Double>> eventPedestals = new HashMap<EcalChannel, List<Double>>(); private Map<EcalChannel, List<Long>> eventTimestamps = new HashMap<EcalChannel, List<Long>>(); private boolean debug = false; @@ -82,7 +88,7 @@ for (int ii = 0; ii < nChannels; ii++) { EcalChannel chan = findChannel(ii + 1); runningPedestals.put(chan,getStaticPedestal(chan)); - eventPedestals.put(chan,new ArrayList<Integer>()); + eventPedestals.put(chan,new ArrayList<Double>()); eventTimestamps.put(chan,new ArrayList<Long>()); } if (debug) { @@ -127,9 +133,21 @@ System.out.printf("\n"); } + private double getNSampleMinimum(short samples[]) { + double min=99999999; + for (int ii=0; ii<samples.length-nSamples; ii++) { + double tmp=0; + for (int jj=ii; jj<ii+nSamples; jj++) tmp += samples[jj]; + tmp /= nSamples; + if (tmp < min) min=tmp; + } + return min; + } + @Override protected void process(EventHeader event) { + // Mode-7 Input Data: if (event.hasCollection(RawCalorimeterHit.class, rawCollectionName)) { if (event.hasCollection(LCRelation.class, extraDataRelationsName)) { for (LCRelation rel : event.get(LCRelation.class, @@ -140,7 +158,38 @@ } } } + + // Mode-1 Input Data: + else if (event.hasCollection(RawTrackerHit.class, rawCollectionName)) { + List<RawTrackerHit> hits = event.get(RawTrackerHit.class, rawCollectionName); + for (RawTrackerHit hit : hits) { + short samples[] = hit.getADCValues(); + if (nSamples > samples.length) { + System.err.println("NOT ENGOUTH SAMPLES FOR ECAL RUNNING PEDETSAL."); + System.exit(0); + } + + //double ped = getNSampleMinimum(samples); + + boolean good=true; + double ped=0; + for (int ii=0; ii<nSamples; ii++) { + // reject pulses from pedestal calculation: + if (samples[ii] > getStaticPedestal(findChannel(hit))+12) { + good=false; + break; + } + ped += samples[ii]; + } + if (good) { + ped /= nSamples; + updatePedestal(event,findChannel(hit),ped); + } + } + } + event.put(runningPedestalsName, runningPedestals); + if (debug) { printPedestals(); } @@ -149,7 +198,6 @@ private void updatePedestal(EventHeader event, RawCalorimeterHit hit, GenericObject mode7data) { - final long timestamp = event.getTimeStamp(); final int min = ((HitExtraData.Mode7Data) mode7data).getAmplLow(); final int max = ((HitExtraData.Mode7Data) mode7data).getAmplHigh(); @@ -162,7 +210,15 @@ System.err.println("hit doesn't correspond to ecalchannel"); return; } - List<Integer> peds = eventPedestals.get(chan); + + updatePedestal(event,chan,(double)min); + } + + private void updatePedestal(EventHeader event,EcalChannel chan,double min) { + + final long timestamp = event.getTimeStamp(); + + List<Double> peds = eventPedestals.get(chan); List<Long> times = eventTimestamps.get(chan); if (maxLookbackTime > 0) { @@ -214,8 +270,8 @@ } else { ped = getStaticPedestal(chan); } + runningPedestals.put(chan, ped); - } public double getStaticPedestal(EcalChannel chan) { @@ -227,6 +283,10 @@ return ecalConditions.getChannelCollection().findChannel(channel_id); } + public EcalChannel findChannel(RawTrackerHit hit) { + return ecalConditions.getChannelCollection().findGeometric( + hit.getCellID()); + } public EcalChannel findChannel(RawCalorimeterHit hit) { return ecalConditions.getChannelCollection().findGeometric( hit.getCellID()); Modified: java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterDriver.java ============================================================================= --- java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterDriver.java (original) +++ java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterDriver.java Fri Jun 12 15:27:10 2015 @@ -249,7 +249,7 @@ } } } else { - getLogger().info("The input hit collection " + this.inputHitCollectionName + " is missing from the event."); +// getLogger().info("The input hit collection " + this.inputHitCollectionName + " is missing from the event."); if (this.raiseErrorNoHitCollection) { throw new RuntimeException("The expected input hit collection is missing from the event."); } Modified: java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterUtilities.java ============================================================================= --- java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterUtilities.java (original) +++ java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/ClusterUtilities.java Fri Jun 12 15:27:10 2015 @@ -471,5 +471,64 @@ return cluster.getType() == ClusterType.CTP.getType() || cluster.getType() == ClusterType.GTP.getType() || cluster.getType() == ClusterType.GTP_ONLINE.getType(); - } + } + + /** + * Comparator of cluster energies. + */ + static final class ClusterEnergyComparator implements Comparator<Cluster> { + + /** + * Compare cluster energies. + * + * @return -1, 0, or 1 if first cluster's energy is less than, equal to, or greater than the first's + */ + @Override + public int compare(Cluster o1, Cluster o2) { + if (o1.getEnergy() < o2.getEnergy()) { + return -1; + } else if (o1.getEnergy() > o2.getEnergy()) { + return 1; + } else { + return 0; + } + } + } + + /** + * Sort a list of clusters. + * + * @param clusters the list of clusters + * @param comparator the comparator to use for sorting + * @param inPlace <code>true</code> to sort the list in-place and not make a new list + * @param reverse <code>true</code> to use reverse comparator (results in list ordered highest to lowest energy) + * @return the sorted list of clusters + */ + public static List<Cluster> sort(final List<Cluster> clusters, final Comparator<Cluster> comparator, boolean inPlace, boolean reverse) { + List<Cluster> sortedList = null; + if (inPlace) { + sortedList = clusters; + } else { + sortedList = new ArrayList<Cluster>(clusters); + } + if (reverse) { + Collections.sort(clusters, Collections.reverseOrder(comparator)); + } else { + Collections.sort(clusters, comparator); + } + return sortedList; + } + + /** + * Find the highest energy cluster from the list. + * + * @param clusters the list of clusters + * @return the highest energy cluster + */ + public static Cluster findHighestEnergyCluster(final List<Cluster> clusters) { + if (clusters.isEmpty()) { + throw new IllegalArgumentException("The cluster list is empty."); + } + return sort(clusters, new ClusterEnergyComparator(), true, true).get(0); + } } Modified: java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/GTPClusterDriver.java ============================================================================= --- java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/GTPClusterDriver.java (original) +++ java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/GTPClusterDriver.java Fri Jun 12 15:27:10 2015 @@ -23,7 +23,7 @@ public GTPClusterDriver() { clusterer = ClustererFactory.create("GTPClusterer"); gtp = (GTPClusterer) clusterer; - setWriteClusterCollection(false); + setWriteClusterCollection(true); } /** @@ -36,7 +36,7 @@ * false</code> that the symmetric window should be used. */ @Deprecated - void setLimitClusterRange(boolean limitClusterRange) { + public void setLimitClusterRange(boolean limitClusterRange) { gtp.setLimitClusterRange(limitClusterRange); } @@ -86,4 +86,14 @@ public void setVerbose(boolean verbose) { gtp.setVerbose(verbose); } + + @Override + public void setWriteClusterCollection(boolean state) { + // Set the flag as appropriate with the superclass. + super.setWriteClusterCollection(state); + + // Also tell the clusterer whether it should persist its hit + // collection or not. + gtp.setWriteHitCollection(state); + } } Modified: java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/GTPClusterer.java ============================================================================= --- java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/GTPClusterer.java (original) +++ java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/GTPClusterer.java Fri Jun 12 15:27:10 2015 @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -33,7 +34,7 @@ * @author Sho Uemura */ public class GTPClusterer extends AbstractClusterer { - + /** * The minimum energy required for a hit to be considered as a * cluster center. Hits with energy less than this value will be @@ -54,7 +55,7 @@ * clustering. */ private LinkedList<Map<Long, CalorimeterHit>> hitBuffer; - + /** * Whether an asymmetric or symmetric window should be used for * adding hits to a cluster. @@ -66,9 +67,19 @@ */ private boolean verbose = false; + /** + * Sets whether the clusterer should store the collection of hits + * that are part of clusters. This needs to be true if the clusters + * are to be written out to LCIO. + */ + private boolean writeHitCollection = true; + + /** + * Instantiates the clusterer. + */ GTPClusterer() { super(new String[] { "seedEnergyThreshold", "clusterWindow" }, new double[] { 0.00, 2.}); - } + } /** * Sets the clustering algorithm parameters. @@ -276,20 +287,45 @@ // Store each hit in a set by its cell ID so that it may be // easily acquired later. HashMap<Long, CalorimeterHit> hitMap = new HashMap<Long, CalorimeterHit>(); - for (CalorimeterHit hit : hits) { + for(CalorimeterHit hit : hits) { hitMap.put(hit.getCellID(), hit); } - + // Remove the last event from the hit buffer and add the new one. hitBuffer.removeLast(); hitBuffer.addFirst(hitMap); - + // Run the clustering algorithm on the buffer. List<Cluster> clusterList = getClusters(); - + + // The MC GTP algorithm collects hits from across events; to be + // stored in LCIO format properly, it needs to separately store + // its clusters' hits in a collection. + if(writeHitCollection) { + // Create a set to store the hits so that each one may be + // stored only once. + Set<CalorimeterHit> hitSet = new HashSet<CalorimeterHit>(); + + // Loop over all clusters and add their hits to the set. + for(Cluster cluster : clusterList) { + for(CalorimeterHit hit : cluster.getCalorimeterHits()) { + hitSet.add(hit); + } + } + + // Convert the set into a List object so that it can be stored + // in LCIO. + List<CalorimeterHit> clusterHits = new ArrayList<CalorimeterHit>(hitSet.size()); + clusterHits.addAll(hitSet); + + // Place the list of hits into the event stream. + event.put("GTPHits", hits, CalorimeterHit.class, 0); + } + + // Return the clusters. return clusterList; } - + /** * Sets the number of clock cycles before and after a given cycle * that will be used when checking whether a given hit is a local @@ -352,6 +388,17 @@ } /** + * Sets whether the set of hits associated with an event's clusters + * should be written to the data stream and persisted in LCIO. This + * must be true if the clusters are to be persisted. + * @param state - <code>true</code> indicates that the hits will be + * persisted and <code>false</code> that they will not. + */ + void setWriteHitCollection(boolean state) { + writeHitCollection = state; + } + + /** * Indicates the type of cluster that is generated by this algorithm. * @return Returns the type of cluster as a <code>ClusterType</code> * object, specifically, <code>ClusterType.GTP</code>. @@ -359,5 +406,5 @@ @Override public ClusterType getClusterType() { return ClusterType.GTP; - } + } } Modified: java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/LegacyClusterer.java ============================================================================= --- java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/LegacyClusterer.java (original) +++ java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/cluster/LegacyClusterer.java Fri Jun 12 15:27:10 2015 @@ -5,7 +5,6 @@ import java.util.Map; import java.util.Set; -import org.hps.recon.ecal.EcalUtils; import org.lcsim.event.CalorimeterHit; import org.lcsim.event.Cluster; import org.lcsim.event.EventHeader; Modified: java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/triggerbank/SSPData.java ============================================================================= --- java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/triggerbank/SSPData.java (original) +++ java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/triggerbank/SSPData.java Fri Jun 12 15:27:10 2015 @@ -197,22 +197,6 @@ } /** - * Gets the list of triggers reported by the SSP.<br/> - * <br/> - * <b>Note:</b> This method is now deprecated. Singles triggers - * can be obtained with <code>getSinglesTriggers</code>, pair - * triggers with <code>getPairTriggers</code>, and cosmic triggers - * with <code>getCosmicTriggers</code>. - * @return Returns the triggers as a <code>List</code> collection - * of <code>SSPTrigger</code> objects. These can vary in which - * subclass they are, as appropriate to their type code. - */ - @Deprecated - public List<SSPTrigger> getTriggers() { - return triggerList; - } - - /** * Gets the trigger time reported by the SSP. * @return Returns the trigger time as a <code>long</code>. */ @@ -223,99 +207,4 @@ * @return Returns the event number as an <code>int</code>. */ public int getEventNumber() { return eventNumber; } - - // TODO: Get information from Andrea on what this is for. It seems - // to be something specialized. Maybe it should be placed in - // the analysis driver in which it is used? - /** - * Gets the first singles trigger that occurred in either crate. - * If no singles triggered occurred, a value of <code>1025 * 4 = - * 4100</code> will be returned. - * @return Returns the time in nanoseconds of the earliest singles - * trigger that occurred, or <code>4100</code> if no singles trigger - * has occurred. - */ - @Deprecated - public int getOrTrig() { - // Get the earliest time for both the top and bottom triggers. - int topTime = getTopTrig(); - int bottomTime = getBotTrig(); - - // Return whichever crate had the earliest trigger. - if (topTime <= bottomTime) { return topTime; } - else { return bottomTime; } - } - - // TODO: Get information from Andrea on what this is for. It seems - // to be something specialized. Maybe it should be placed in - // the analysis driver in which it is used? - /** - * Gets the first singles trigger that occurred in the top crate. - * If no singles triggered occurred, a value of <code>1025 * 4 = - * 4100</code> will be returned. - * @return Returns the time in nanoseconds of the earliest singles - * trigger that occurred, or <code>4100</code> if no singles trigger - * has occurred. - */ - @Deprecated - public int getTopTrig() { - // Store the smallest found time. The time is a 10 bit value, - // so it must always be less than 1024. Multiply by 4 to convert - // from clock-cycles to nanoseconds. - int topTime = 1025 * 4; - - // Iterate over all triggers. - for(SSPTrigger trigger : triggerList) { - // Select only singles triggers from the top crate. - if(trigger instanceof SSPSinglesTrigger && ((SSPSinglesTrigger) trigger).isTop()) { - // Store the smallest trigger time found. - if(trigger.getTime() < topTime) { - topTime = trigger.getTime(); - } - } - } - - // Return the smallest found time. - return topTime; - } - - // TODO: Get information from Andrea on what this is for. It seems - // to be something specialized. Maybe it should be placed in - // the analysis driver in which it is used? - /** - * Gets the first singles trigger that occurred in the bottom crate. - * If no singles triggered occurred, a value of <code>1025 * 4 = - * 4100</code> will be returned. - * @return Returns the time in nanoseconds of the earliest singles - * trigger that occurred, or <code>4100</code> if no singles trigger - * has occurred. - */ - @Deprecated - public int getBotTrig() { - // Store the smallest found time. The time is a 10 bit value, - // so it must always be less than 1024. Multiply by 4 to convert - // from clock-cycles to nanoseconds. - int bottomTime = 1025 * 4; - - // Iterate over all triggers. - for(SSPTrigger trigger : triggerList) { - // Select only singles triggers from the bottom crate. - if(trigger instanceof SSPSinglesTrigger && ((SSPSinglesTrigger) trigger).isBottom()) { - // Store the smallest trigger time found. - if(trigger.getTime() < bottomTime) { - bottomTime = trigger.getTime(); - } - } - } - - // Return the smallest found time. - return bottomTime; - } - - // TODO: This does not seem to do anything. Can it be deleted? It - // is also not used anywhere. - @Deprecated - public int getAndTrig() { - return 0; - } } Modified: java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/triggerbank/SSPSinglesTrigger.java ============================================================================= --- java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/triggerbank/SSPSinglesTrigger.java (original) +++ java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/triggerbank/SSPSinglesTrigger.java Fri Jun 12 15:27:10 2015 @@ -25,17 +25,6 @@ time, data); } - /** - * Indicates whether the trigger was reported by the bottom SSP - * crate or not. - * @return Returns <code>true</code> if the trigger was reported - * by the bottom crate and <code>false</code> if it was reported - * by the top crate. - */ - public boolean isBottom() { - return (type == SSPData.TRIG_TYPE_SINGLES0_BOT) || (type == SSPData.TRIG_TYPE_SINGLES1_BOT); - } - @Override public boolean isFirstTrigger() { return (type == SSPData.TRIG_TYPE_SINGLES0_BOT) || (type == SSPData.TRIG_TYPE_SINGLES0_TOP); @@ -44,17 +33,6 @@ @Override public boolean isSecondTrigger() { return (type == SSPData.TRIG_TYPE_SINGLES1_BOT) || (type == SSPData.TRIG_TYPE_SINGLES1_TOP); - } - - /** - * Indicates whether the trigger was reported by the top SSP - * crate or not. - * @return Returns <code>true</code> if the trigger was reported - * by the top crate and <code>false</code> if it was reported by - * the bottom crate. - */ - public boolean isTop() { - return (type == SSPData.TRIG_TYPE_SINGLES0_TOP || type == SSPData.TRIG_TYPE_SINGLES1_TOP); } /** Modified: java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/triggerbank/TestRunTriggerData.java ============================================================================= --- java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/triggerbank/TestRunTriggerData.java (original) +++ java/branches/HPSJAVA-488/ecal-recon/src/main/java/org/hps/recon/ecal/triggerbank/TestRunTriggerData.java Fri Jun 12 15:27:10 2015 @@ -8,75 +8,72 @@ * @version $Id: TriggerData.java,v 1.3 2012/08/03 23:14:39 meeg Exp $ */ public class TestRunTriggerData extends AbstractIntData { - + public static final int BANK_TAG = 0xe106; public static final int BANK_SIZE = 8; - + public static final int OR_TRIG = 3; public static final int TOP_TRIG = 4; public static final int BOT_TRIG = 5; public static final int AND_TRIG = 6; public static final int TIME = 7; public static final String TRIG_COLLECTION = "TriggerBank"; - -// protected TestRunTriggerData() { -// super(null); -// } + public TestRunTriggerData(int[] bank) { super(bank); decodeData(); } - + public TestRunTriggerData(GenericObject data) { super(data, BANK_TAG); decodeData(); } - + public long getTime() { return bank[TIME] & 0xffffffffL; } - + public int getOrTrig() { return bank[OR_TRIG]; } - + public int getTopTrig() { return bank[TOP_TRIG]; } - + public int getBotTrig() { return bank[BOT_TRIG]; } - + public int getAndTrig() { return bank[AND_TRIG]; } - + public static long getTime(GenericObject object) { return AbstractIntData.getBankInt(object, TIME) & 0xffffffffL; } - + public static int getOrTrig(GenericObject object) { return AbstractIntData.getBankInt(object, OR_TRIG); } - + public static int getTopTrig(GenericObject object) { return AbstractIntData.getBankInt(object, TOP_TRIG); } - + public static int getBotTrig(GenericObject object) { return AbstractIntData.getBankInt(object, BOT_TRIG); } - + public static int getAndTrig(GenericObject object) { return AbstractIntData.getBankInt(object, AND_TRIG); } - + @Override public int getTag() { return BANK_TAG; } - + @Override protected final void decodeData() { //doesn't actually do anything since there is no decoding done on the ints if (this.bank.length != BANK_SIZE) { Modified: java/branches/HPSJAVA-488/ecal-recon/src/test/java/org/hps/recon/ecal/cluster/ClustererTest.java ============================================================================= --- java/branches/HPSJAVA-488/ecal-recon/src/test/java/org/hps/recon/ecal/cluster/ClustererTest.java (original) +++ java/branches/HPSJAVA-488/ecal-recon/src/test/java/org/hps/recon/ecal/cluster/ClustererTest.java Fri Jun 12 15:27:10 2015 @@ -58,7 +58,8 @@ boolean checkPropCalc; boolean checkClusterPosition; boolean checkNullHits; - boolean checkHitPositions; + boolean checkHitPositions; + boolean checkHitTime; double[] cuts = null; ClusterType clusterType; String clustererName; @@ -87,6 +88,11 @@ ClustererTestConfig checkHitEnergy() { checkHitEnergy = true; + return this; + } + + ClustererTestConfig checkHitTime() { + checkHitTime = true; return this; } @@ -148,7 +154,8 @@ .checkHitEnergy() .checkClusterPosition() .checkNullHits() - .checkHitPositions()); + .checkHitPositions() + .checkHitTime()); } /** @@ -162,7 +169,8 @@ .checkHitEnergy() .checkClusterPosition() .checkNullHits() - .checkHitPositions()); + .checkHitPositions() + .checkHitTime()); } /** @@ -175,7 +183,8 @@ .checkHitEnergy() .checkClusterPosition() .checkHitPositions() - .checkNullHits()); + .checkNullHits() + .checkHitTime()); } /** @@ -188,7 +197,8 @@ .checkHitEnergy() .checkClusterPosition() .checkHitPositions() - .checkNullHits()); + .checkNullHits() + .checkHitTime()); } /** @@ -352,8 +362,10 @@ if (config.checkHitEnergy) { assertTrue("Hit energy " + hit.getCorrectedEnergy() + " is <= 0.", hit.getCorrectedEnergy() > 0.); } - double time = hit.getTime(); - assertTrue("Hit time is invalid.", time != 0.); + if (config.checkHitTime) { + double time = hit.getTime(); + assertTrue("Hit time is invalid.", time != 0.); + } } } } Modified: java/branches/HPSJAVA-488/evio/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/evio/pom.xml (original) +++ java/branches/HPSJAVA-488/evio/pom.xml Fri Jun 12 15:27:10 2015 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/evio/</url> Modified: java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java ============================================================================= --- java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java (original) +++ java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/AbstractSvtEvioReader.java Fri Jun 12 15:27:10 2015 @@ -46,6 +46,9 @@ protected Map<Pair<Integer /* FPGA */, Integer /* Hybrid */>, HpsSiSensor /* Sensor */> daqPairToSensor = new HashMap<Pair<Integer, Integer>, HpsSiSensor>(); + + // A collection of banks that should be processed after all hits have been made + protected List<BassStructure> eventBanks = new ArrayList<BassStructure>(); // Flag indicating whether the DAQ map has been setup protected boolean isDaqMapSetup = false; @@ -112,15 +115,14 @@ */ abstract protected HpsSiSensor getSensor(int[] data); - /** * Check whether a data bank is valid i.e. contains SVT samples only. * * @param dataBank - An EVIO bank containing integer data * @return true if the bank is valid, false otherwise */ - abstract protected boolean isValidDataBank(BaseStructure dataBank); - + abstract protected boolean isValidDataBank(BaseStructure dataBank); + /** * Check whether the samples are valid * @@ -151,6 +153,8 @@ */ public boolean makeHits(EvioEvent event, EventHeader lcsimEvent) { + logger.fine("Physics Event: " + event.toString()); + // Retrieve the ROC banks encapsulated by the physics bank. The ROC // bank range is set in the subclass. List<BassStructure> rocBanks = new ArrayList<BassStructure>(); Modified: java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/BasicEvioFileReader.java ============================================================================= --- java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/BasicEvioFileReader.java (original) +++ java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/BasicEvioFileReader.java Fri Jun 12 15:27:10 2015 @@ -20,7 +20,7 @@ throw new RuntimeException("File " + evioFileName + " does not exist."); } try { - org.jlab.coda.jevio.EvioReader reader = new org.jlab.coda.jevio.EvioReader(evioFile); + org.jlab.coda.jevio.EvioReader reader = new org.jlab.coda.jevio.EvioReader(evioFile,true,false); int eventN = 1; int badEvents = 0; fileLoop: Modified: java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EcalEvioReader.java ============================================================================= --- java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EcalEvioReader.java (original) +++ java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EcalEvioReader.java Fri Jun 12 15:27:10 2015 @@ -39,6 +39,7 @@ * @author Sho Uemura <[log in to unmask]> * @version $Id: ECalEvioReader.java,v 1.23 2013/04/18 20:59:16 meeg Exp $ */ +// TODO: use a logger public class EcalEvioReader extends EvioReader { // Names of subdetectors. @@ -259,7 +260,7 @@ } if (id == null) { - FADCGenericHit hit = makeGenericRawHit(EventConstants.ECAL_WINDOW_MODE, crate, slot, channel, cdata, nSamples); + FADCGenericHit hit = makeGenericRawHit(EventConstants.ECAL_RAW_MODE, crate, slot, channel, cdata, nSamples); processUnrecognizedChannel(hit); } else { BaseRawTrackerHit hit = makeECalRawHit(0, id, cdata, nSamples); Modified: java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EcalHitWriter.java ============================================================================= --- java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EcalHitWriter.java (original) +++ java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EcalHitWriter.java Fri Jun 12 15:27:10 2015 @@ -69,7 +69,7 @@ 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) { + if (mode != EventConstants.ECAL_RAW_MODE && mode != EventConstants.ECAL_PULSE_MODE && mode != EventConstants.ECAL_PULSE_INTEGRAL_MODE) { throw new IllegalArgumentException("invalid mode " + mode); } } @@ -77,7 +77,7 @@ @Override public boolean hasData(EventHeader event) { switch (mode) { - case EventConstants.ECAL_WINDOW_MODE: + case EventConstants.ECAL_RAW_MODE: return event.hasCollection(RawTrackerHit.class, hitCollectionName); case EventConstants.ECAL_PULSE_MODE: return event.hasCollection(RawTrackerHit.class, hitCollectionName); @@ -92,7 +92,7 @@ public void writeData(EventHeader event, EventBuilder builder) { List<Object> hits = new ArrayList<Object>(); switch (mode) { - case EventConstants.ECAL_WINDOW_MODE: + case EventConstants.ECAL_RAW_MODE: hits.addAll(event.get(RawTrackerHit.class, hitCollectionName)); writeHits(hits, builder, mode); break; @@ -160,7 +160,7 @@ } switch (mode) { - case EventConstants.ECAL_WINDOW_MODE: + case EventConstants.ECAL_RAW_MODE: // Write the two collections for top and bottom hits to separate EVIO banks. writeWindowHitCollection(topHits, topBank, builder); writeWindowHitCollection(bottomHits, botBank, builder); @@ -415,7 +415,7 @@ public void writeData(EventHeader event, EventHeader toEvent) { String readoutName = ((org.lcsim.geometry.compact.Subdetector) subDetector).getReadout().getName(); switch (mode) { - case EventConstants.ECAL_WINDOW_MODE: + case EventConstants.ECAL_RAW_MODE: case EventConstants.ECAL_PULSE_MODE: List<RawTrackerHit> rawTrackerHits = event.get(RawTrackerHit.class, hitCollectionName); if (verbosity >= 1) { Modified: java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EventConstants.java ============================================================================= --- java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EventConstants.java (original) +++ java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EventConstants.java Fri Jun 12 15:27:10 2015 @@ -16,7 +16,7 @@ public static final int SVT_BANK_NUMBER = 1; public static final int ECAL_BANK_NUMBER = 1; public static final int TRIGGER_BANK_NUMBER = 1; - public static final int ECAL_WINDOW_MODE = 1; + public static final int ECAL_RAW_MODE = 1; public static final int ECAL_PULSE_MODE = 2; public static final int ECAL_PULSE_INTEGRAL_MODE = 3; //FADC mode 3 public static final int ECAL_PULSE_INTEGRAL_HIGHRESTDC_MODE = 4; //FADC mode 7 Modified: java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EvioToLcio.java ============================================================================= --- java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EvioToLcio.java (original) +++ java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/EvioToLcio.java Fri Jun 12 15:27:10 2015 @@ -36,12 +36,13 @@ import org.lcsim.conditions.ConditionsManager.ConditionsNotFoundException; import org.lcsim.event.EventHeader; import org.lcsim.lcio.LCIOWriter; +import org.lcsim.util.log.DefaultLogFormatter; import org.lcsim.util.log.LogUtil; /** * <p> - * This class converts EVIO to LCIO, performing an LCSim job in the same session. The processed - * events are then (optionally) written to disk using an LCIOWriter. + * This class converts EVIO to LCIO, performing an LCSim job in the same session. The processed events are then (optionally) written to disk using an + * LCIOWriter. * <p> * To run this class from the command line:<br> * java -cp hps-distribution-bin.jar EvioToLcio [options] [evioFiles] @@ -51,9 +52,8 @@ * <p> * Extra arguments are treated as paths to EVIO files. * <p> - * This class attempts to automatically configure itself for Test Run or Engineering Run based on - * the run numbers in the EVIO file. It will use an appropriate default detector unless one is given - * on the command line, and it will also use the correct event builder. It will not handle jobs + * This class attempts to automatically configure itself for Test Run or Engineering Run based on the run numbers in the EVIO file. It will use an + * appropriate default detector unless one is given on the command line, and it will also use the correct event builder. It will not handle jobs * correctly with files from both the Test and Engineering Run, so don't do this! * <p> * The conditions system can be initialized in one of three ways.<br/> @@ -63,77 +63,183 @@ * <li>run number from a header bank in an event</li> * </ol> * <p> - * In the case where a file has no pre start event and there are header banks present, - * the "-m" command line option can be used to buffer a number of EVIO events. If there is a - * head bank found while adding these events to queue, the conditions system will be initialized - * from it. + * In the case where a file has no pre start event and there are header banks present, the "-m" command line option can be used to buffer a number of + * EVIO events. If there is a head bank found while adding these events to queue, the conditions system will be initialized from it. * * @author Jeremy McCormick <[log in to unmask]> * @author Sho Uemura <[log in to unmask]> */ -// TODO: Logger should print tracebacks. See Driver's setup for example of this. public class EvioToLcio { - // The default steering resource, which basically does nothing except print event numbers. + /** + * The default steering resource, which basically does nothing except print event numbers. + */ private static final String DEFAULT_STEERING_RESOURCE = "/org/hps/steering/EventMarker.lcsim"; - // The command line options which will be defined in the constructor. - Options options = null; - - // The class's logger. - static Logger logger = LogUtil.create(EvioToLcio.class); - static { - logger.setLevel(Level.INFO); + /** + * Setup logging for this class. + */ + private static Logger LOGGER = LogUtil.create(EvioToLcio.class, new DefaultLogFormatter(), Level.INFO); + + /** + * Run the EVIO to LCIO converter from the command line. + * + * @param args The command line arguments. + */ + public static void main(final String[] args) { + final EvioToLcio evioToLcio = new EvioToLcio(); + evioToLcio.run(args); } - // The LCSim event builder used to convert from EVIO. - LCSimEventBuilder eventBuilder = null; - - // The detector name for conditions. - String detectorName; - - // The run number for conditions. - Integer runNumber = null; - - /** - * The default constructor, which defines command line arguments and sets the log level. + /** + * The detector name for conditions. + */ + private String detectorName; + + /** + * The LCSim event builder used to convert from EVIO. + */ + private LCSimEventBuilder eventBuilder = null; + + /** + * The command line options which will be defined in the constructor. + */ + private Options options = null; + + /** + * The run number for conditions. + */ + private Integer runNumber = null; + + /** + * The default constructor, which defines command line arguments and sets the default log level. */ protected EvioToLcio() { - logger.config("initializing EVIO to LCIO converter"); + LOGGER.config("initializing EVIO to LCIO converter ..."); options = new Options(); - options.addOption(new Option("d", true, "name of the detector to use for LCSim conditions (required)")); + options.addOption(new Option("d", true, "detector name (required)")); options.getOption("d").setRequired(true); - options.addOption(new Option("f", true, "path to a text file containing a list of EVIO files to process")); - options.addOption(new Option("L", true, "log level (INFO, FINE, FINEST, etc.)")); - options.addOption(new Option("x", true, "XML steeering file for processing LCIO events")); + options.addOption(new Option("f", true, "text file containing a list of EVIO files")); + options.addOption(new Option("L", true, "log level (INFO, FINE, etc.)")); + options.addOption(new Option("x", true, "LCSim steeering file for processing the LCIO events")); options.addOption(new Option("r", false, "interpret steering from -x argument as a resource instead of a file")); - options.addOption(new Option("D", true, "pass a variable to the steering file with format -Dname=value")); + options.addOption(new Option("D", true, "define a steering file variable with format -Dname=value")); options.addOption(new Option("l", true, "path of output LCIO file")); options.addOption(new Option("R", true, "fixed run number which will override run numbers of input files")); options.addOption(new Option("n", true, "maximum number of events to process in the job")); - options.addOption(new Option("b", false, "enable headless mode which will not show plots OR allow writing them to graphics files")); + options.addOption(new Option("b", false, "enable headless mode in which plots will not show")); options.addOption(new Option("v", false, "print EVIO XML for each event")); options.addOption(new Option("m", true, "set the max event buffer size")); - options.addOption(new Option("t", true, "specify a conditions system tag to use")); - logger.setLevel(Level.FINE); + options.addOption(new Option("t", true, "specify a conditions tag to use")); + options.addOption(new Option("M", false, "use memory mapping instead of sequential reading")); } /** - * Run the EVIO to LCIO converter from the command line. + * Buffer up to <code>maxBufferSize</code> events in the <code>eventQueue</code>. This method will also initialize the conditions system using a + * run number if a header bank is found. + * + * @param reader the EVIO reader + * @param eventQueue the event queue + * @param maxBufferSize the maximum number of records to buffer + */ + private void bufferEvents(final EvioReader reader, final EvioEventQueue eventQueue, final int maxBufferSize) { + EvioEvent evioEvent = null; + while (eventQueue.size() < maxBufferSize) { + try { + // Read the next event. + evioEvent = reader.nextEvent(); + + if (evioEvent == null) { // This catches an end of file or bad event. + break; + } + + // Add the event to the queue. + eventQueue.addRecord(evioEvent); + + } catch (IOException | EvioException e) { + LOGGER.log(Level.SEVERE, e.getMessage(), e); + } + + if (evioEvent != null) { + + // Parse the event. + try { + reader.parseEvent(evioEvent); + } catch (final EvioException e) { + LOGGER.log(Level.SEVERE, e.getMessage(), e); + continue; + } + + // Is conditions system not frozen? + if (!DatabaseConditionsManager.getInstance().isFrozen()) { + + // Get head bank from event. + final BaseStructure headBank = EvioEventUtilities.getHeadBank(evioEvent); + + // Is head bank available in this event? + if (headBank != null) { + + // Get the run number from the head bank. + runNumber = headBank.getIntData()[1]; + LOGGER.finer("got head bank with run number " + runNumber); + + // Check if the conditions system needs to be updated from the head bank. + this.checkConditions(runNumber, false); + + } else { + LOGGER.finest("event " + evioEvent.getEventNumber() + " does not have a head bank"); + } + } + } + } + LOGGER.finer("buffered " + eventQueue.size() + " events"); + } + + /** + * Check if the conditions system and event builder need to be initialized or updated given a run number. + * + * @param runNumber The run number. + * @param freeze True to freeze conditions system after it is setup. + */ + private void checkConditions(final int runNumber, final boolean freeze) { + + // Is the event builder uninitialized? + if (eventBuilder == null) { + // Setup event builder. + this.setupEventBuilder(runNumber); + } + + // Update the conditions system with the new run number. + try { + // This call may be ignored by the conditions system if the run number is not new. + ConditionsManager.defaultInstance().setDetector(detectorName, runNumber); + } catch (final ConditionsNotFoundException e) { + throw new RuntimeException("Error initializing conditions system.", e); + } + + if (freeze) { + // Freeze the conditions system so subsequent run numbers are ignored. + DatabaseConditionsManager.getInstance().freeze(); + } + } + + /** + * Print the CLI usage and exit. + */ + private void printUsage() { + System.out.println("EvioToLcio [options] [evioFiles]"); + final HelpFormatter help = new HelpFormatter(); + help.printHelp(" ", options); + System.exit(1); + } + + /** + * This method will execute the EVIO to LCIO conversion and optionally process the events with LCSim Drivers from a steering file. Then the + * resultant LCIO events will be written to disk if this option is enabled in the command line arguments. + * * @param args The command line arguments. */ - public static void main(String[] args) { - EvioToLcio evioToLcio = new EvioToLcio(); - evioToLcio.run(args); - } - - /** - * This method will execute the EVIO to LCIO conversion and optionally process the events with - * LCSim Drivers from a steering file. Then the resultant LCIO events will be written to disk if - * this option is enabled in the command line arguments. - * @param args The command line arguments. - */ - public void run(String[] args) { + public void run(final String[] args) { int maxEvents = -1; int nEvents = 0; @@ -141,47 +247,47 @@ // Parse the command line options. if (args.length == 0) { - printUsage(); - } - CommandLineParser parser = new PosixParser(); + this.printUsage(); + } + final CommandLineParser parser = new PosixParser(); CommandLine cl = null; try { cl = parser.parse(options, args); - } catch (ParseException e) { + } catch (final ParseException e) { throw new RuntimeException("Problem parsing command line options.", e); } // Set the log level. if (cl.hasOption("L")) { - Level level = Level.parse(cl.getOptionValue("L").toUpperCase()); - + final Level level = Level.parse(cl.getOptionValue("L").toUpperCase()); + // Set log level on this class. - logger.config("setting log level to " + level); - logger.setLevel(level); - + LOGGER.config("setting log level to " + level); + LOGGER.setLevel(level); + // Set log level on conditions manager. DatabaseConditionsManager.getInstance().setLogLevel(level); } // Add all extra arguments to the EVIO file list. - List<String> evioFileList = new ArrayList<String>(Arrays.asList(cl.getArgs())); + final List<String> evioFileList = new ArrayList<String>(Arrays.asList(cl.getArgs())); // Process text file containing list of EVIO file paths, one per line. if (cl.hasOption("f")) { // Add additional EVIO files to process from text file. - File file = new File(cl.getOptionValue("f")); + final File file = new File(cl.getOptionValue("f")); if (!file.exists()) { throw new RuntimeException("The file " + file.getPath() + " does not exist."); } - Path filePath = file.toPath(); + final Path filePath = file.toPath(); List<String> lines = null; try { lines = Files.readAllLines(filePath, Charset.defaultCharset()); - } catch (IOException e) { + } catch (final IOException e) { throw new RuntimeException(e); } - for (String line : lines) { - File evioFile = new File(line); + for (final String line : lines) { + final File evioFile = new File(line); if (evioFile.exists()) { evioFileList.add(evioFile.getPath()); } else { @@ -193,8 +299,8 @@ // Is the EVIO file list empty? if (evioFileList.isEmpty()) { // There weren't any EVIO files provided on the command line so exit. - logger.severe("No EVIO files were provided with command line arguments or -f option."); - printUsage(); + LOGGER.severe("No EVIO files were provided with command line arguments or -f option."); + this.printUsage(); } String lcioFileName = null; @@ -203,26 +309,27 @@ // Get the LCIO output file. if (cl.hasOption("l")) { - logger.config("set LCIO file to " + lcioFileName); + LOGGER.config("set LCIO file to " + lcioFileName); lcioFileName = cl.getOptionValue("l"); } // Get the steering file or resource for the LCSim job. if (cl.hasOption("x")) { - String lcsimXmlName = cl.getOptionValue("x"); + final String lcsimXmlName = cl.getOptionValue("x"); if (cl.hasOption("r")) { steeringStream = EvioToLcio.class.getResourceAsStream(lcsimXmlName); if (steeringStream == null) { - logger.severe("LCSim steering resource " + lcsimXmlName + " was not found."); - throw new IllegalArgumentException("XML steering resource was not found."); - } - logger.config("using steering resource " + lcsimXmlName); + IllegalArgumentException e = new IllegalArgumentException("XML steering resource was not found."); + LOGGER.log(Level.SEVERE, "LCSim steering resource " + lcsimXmlName + " was not found.", e); + throw e; + } + LOGGER.config("using steering resource " + lcsimXmlName); } else { try { steeringStream = new FileInputStream(lcsimXmlName); - logger.config("using steering file " + lcsimXmlName); - } catch (FileNotFoundException e) { - logger.severe("The XML steering file " + lcsimXmlName + " does not exist."); + LOGGER.config("using steering file " + lcsimXmlName); + } catch (final FileNotFoundException e) { + LOGGER.severe("The XML steering file " + lcsimXmlName + " does not exist."); throw new IllegalArgumentException("Steering file does not exist.", e); } } @@ -231,7 +338,7 @@ // Setup the default steering which just prints event numbers. if (steeringStream == null) { steeringStream = EvioToLcio.class.getResourceAsStream(DEFAULT_STEERING_RESOURCE); - logger.config("using default steering resource " + DEFAULT_STEERING_RESOURCE); + LOGGER.config("using default steering resource " + DEFAULT_STEERING_RESOURCE); } // Get the max number of events to process. @@ -240,52 +347,53 @@ if (maxEvents <= 0) { throw new IllegalArgumentException("Value of -n option is invalid: " + maxEvents); } - logger.config("set max events to " + maxEvents); + LOGGER.config("set max events to " + maxEvents); } // Setup the LCIO writer. if (lcioFileName != null) { try { - writer = new LCIOWriter(new File(lcioFileName)); - logger.config("initialized LCIO writer with file " + lcioFileName); - } catch (IOException e) { - logger.severe("Problem initializing the LCIO writer."); + writer = new LCIOWriter(lcioFileName); + LOGGER.config("initialized LCIO writer with file " + lcioFileName); + } catch (final IOException e) { + LOGGER.severe("Problem initializing the LCIO writer."); throw new RuntimeException(e); } } // Process the LCSim job variable definitions, if any. - JobManager jobManager = new JobManager(); + final JobManager jobManager = new JobManager(); if (cl.hasOption("D")) { - String[] steeringOptions = cl.getOptionValues("D"); - for (String def : steeringOptions) { - String[] s = def.split("="); + final String[] steeringOptions = cl.getOptionValues("D"); + for (final String def : steeringOptions) { + final String[] s = def.split("="); if (s.length != 2) { - logger.severe("bad variable format: " + def); - throw new IllegalArgumentException("Bad variable format: " + def); - } - String key = s[0]; - String value = s[1]; + IllegalArgumentException e = new IllegalArgumentException("Bad variable format: " + def); + LOGGER.log(Level.SEVERE, "bad variable format: " + def, e); + throw e; + } + final String key = s[0]; + final String value = s[1]; jobManager.addVariableDefinition(key, value); - logger.config("set steering variable: " + key + "=" + value); + LOGGER.config("set steering variable: " + key + "=" + value); } } // Enable headless mode so no plots are shown. if (cl.hasOption("b")) { - logger.config("Headless mode is enabled. No plots will be shown."); + LOGGER.config("Headless mode is enabled. No plots will be shown."); jobManager.enableHeadlessMode(); } // Configure the LCSim job manager. jobManager.setup(steeringStream); jobManager.configure(); - logger.config("LCSim job manager was successfully configured."); + LOGGER.config("LCSim job manager was successfully configured."); // Get the user specified detector name. if (cl.hasOption("d")) { detectorName = cl.getOptionValue("d"); - logger.config("User set detector to " + detectorName + " with command option."); + LOGGER.config("User set detector to " + detectorName + " with command option."); } else { throw new RuntimeException("Missing -d argument with name of detector."); } @@ -293,30 +401,30 @@ // Get the user specified run number. if (cl.hasOption("R")) { runNumber = Integer.parseInt(cl.getOptionValue("R")); - logger.config("User set run number to " + runNumber + " with command option."); - } - + LOGGER.config("User set run number to " + runNumber + " with command option."); + } + // Set the conditions system tag. if (cl.hasOption("t")) { - String tag = cl.getOptionValue("t"); + final String tag = cl.getOptionValue("t"); DatabaseConditionsManager.getInstance().setTag(tag); } // Is there a run number from the command line options? if (runNumber != null) { // Initialize the conditions system before the job starts and freeze it. - checkConditions(runNumber, true); + this.checkConditions(runNumber, true); } // Print out the EVIO file list before the job starts. - StringBuffer buff = new StringBuffer(); + final StringBuffer buff = new StringBuffer(); buff.append("The job will include the following EVIO files ..."); buff.append('\n'); - for (String evioFileName : evioFileList) { + for (final String evioFileName : evioFileList) { buff.append(evioFileName); buff.append('\n'); } - logger.config(buff.toString()); + LOGGER.config(buff.toString()); // Get whether to debug print XML from the EVIO events. boolean printXml = false; @@ -331,19 +439,19 @@ // Loop over the input EVIO files. EvioReader reader = null; - fileLoop: for (String evioFileName : evioFileList) { + fileLoop: for (final String evioFileName : evioFileList) { // Get the next EVIO input file. - File evioFile = new File(evioFileName); + final File evioFile = new File(evioFileName); if (!evioFile.exists()) { throw new RuntimeException("EVIO file " + evioFile.getPath() + " does not exist."); } - logger.info("Opening EVIO file " + evioFileName + " ..."); + LOGGER.info("Opening EVIO file " + evioFileName + " ..."); // Open the EVIO reader. try { - reader = new EvioReader(evioFile); - } catch (Exception e) { + reader = new EvioReader(evioFile, false, !cl.hasOption("M")); + } catch (final Exception e) { throw new RuntimeException("Error opening the EVIO file reader.", e); } @@ -351,11 +459,11 @@ long eventTime = 0; // in ms // Loop over events. - EvioEventQueue eventQueue = new EvioEventQueue(-1L, maxBufferSize); + final EvioEventQueue eventQueue = new EvioEventQueue(-1L, maxBufferSize); eventLoop: for (;;) { // Buffer the EVIO events into the queue. - bufferEvents(reader, eventQueue, maxBufferSize); + this.bufferEvents(reader, eventQueue, maxBufferSize); // Is the event queue empty? if (eventQueue.size() == 0) { @@ -370,70 +478,68 @@ EvioEvent evioEvent = null; try { eventQueue.next(); - evioEvent = (EvioEvent) eventQueue.getCurrentRecord(); + evioEvent = (EvioEvent) eventQueue.getCurrentRecord(); // The parseEvent method does not need to be called here. // The events were already parsed when buffering. if (evioEvent == null) { - new RuntimeException().printStackTrace(); + new RuntimeException("Failed to read EVIO event.").printStackTrace(); continue recordLoop; } - } catch (IOException e) { - // This means the EVIO event has bad data. - logger.severe(e.getMessage()); - e.printStackTrace(); + } catch (final IOException e) { + // This means the EVIO event has bad data. + LOGGER.log(Level.SEVERE, e.getMessage(), e); continue recordLoop; - } catch (NoSuchRecordException e) { + } catch (final NoSuchRecordException e) { // This means the queue does not have any more events. // We checked hasNext() already so it should not happen. - logger.severe(e.getMessage()); - e.printStackTrace(); + LOGGER.log(Level.SEVERE, e.getMessage(), e); break recordLoop; } - + // Print out event XML if enabled. if (printXml) { - logger.info(evioEvent.toXML()); + LOGGER.info(evioEvent.toXML()); } // Is this a pre start event? if (EvioEventUtilities.isPreStartEvent(evioEvent)) { // Get the pre start event's data bank. - int[] data = EvioEventUtilities.getControlEventData(evioEvent); + final int[] data = EvioEventUtilities.getControlEventData(evioEvent); if (data == null) { // This should never happen but just ignore it. - logger.severe("Pre start event is missing a data bank."); + LOGGER.severe("Pre start event is missing a data bank."); } else { // Check if conditions system needs to be updated from the pre start data. - checkConditions(data[1], false); + this.checkConditions(data[1], false); } - } + } // Is this an end event? if (EvioEventUtilities.isEndEvent(evioEvent)) { - int[] data = EvioEventUtilities.getControlEventData(evioEvent); + final int[] data = EvioEventUtilities.getControlEventData(evioEvent); if (data == null) { // This should never happen but just ignore it. - logger.severe("The end event is missing a data bank."); + LOGGER.severe("The end event is missing a data bank."); } else { - int seconds = data[0]; - int totalEvents = data[2]; - logger.info("EVIO end event with " + totalEvents + " events and " + seconds + " seconds"); + final int seconds = data[0]; + final int totalEvents = data[2]; + LOGGER.info("EVIO end event with " + totalEvents + " events and " + seconds + " seconds"); } - } + } // Setup state in the LCSimEventBuilder based on the EVIO control event. if (eventBuilder != null) { eventBuilder.readEvioEvent(evioEvent); - } + } // Is this a physics event? if (EvioEventUtilities.isPhysicsEvent(evioEvent)) { // Print physics event number, which is actually a sequence number from // the reader, not the actual event number from the data. - logger.finest("physics event seq #" + evioEvent.getEventNumber()); + LOGGER.finest("physics event " + evioEvent.getEventNumber()); // Is the event builder initialized? if (eventBuilder == null) { @@ -441,64 +547,64 @@ throw new RuntimeException("The LCSimEventBuilder was never initialized."); } - // Build the LCIO event. - EventHeader lcioEvent = eventBuilder.makeLCSimEvent(evioEvent); - eventTime = (lcioEvent.getTimeStamp() / 1000000); - logger.finest("created LCIO event #" + lcioEvent.getEventNumber() + " with time " + new Date(eventTime)); + // Build the LCIO event. + final EventHeader lcioEvent = eventBuilder.makeLCSimEvent(evioEvent); + eventTime = lcioEvent.getTimeStamp() / 1000000; + LOGGER.finest("created LCIO event " + lcioEvent.getEventNumber() + " with time " + new Date(eventTime)); if (firstEvent) { - logger.info("first physics event time: " + eventTime / 1000 + " - " + new Date(eventTime)); + LOGGER.info("first physics event time: " + eventTime / 1000 + " - " + new Date(eventTime)); firstEvent = false; } // Activate Driver process methods. - logger.finest("jobManager processing event " + lcioEvent.getEventNumber()); + LOGGER.finest("jobManager processing event " + lcioEvent.getEventNumber()); jobManager.processEvent(lcioEvent); // Write out this LCIO event. if (writer != null) { - try { + try { writer.write(lcioEvent); writer.flush(); - } catch (IOException e) { + LOGGER.finest("wrote LCSim event " + lcioEvent.getEventNumber()); + } catch (final IOException e) { throw new RuntimeException("Error writing LCIO file.", e); } - logger.finest("wrote event #" + lcioEvent.getEventNumber()); + LOGGER.finest("wrote event #" + lcioEvent.getEventNumber()); } // Increment number of events processed. - nEvents++; + nEvents++; // Check if max events was reached and end job if this is true. if (maxEvents != -1 && nEvents >= maxEvents) { - logger.info("maxEvents " + maxEvents + " was reached"); + LOGGER.info("maxEvents " + maxEvents + " was reached"); break fileLoop; } } } } // eventLoop - logger.info("Last physics event time: " + eventTime / 1000 + " - " + new Date(eventTime)); + LOGGER.info("Last physics event time: " + eventTime / 1000 + " - " + new Date(eventTime)); // Close the EVIO reader. try { reader.close(); - logger.fine("EVIO reader closed."); - } catch (IOException e) { - logger.warning(e.getMessage()); + LOGGER.fine("EVIO reader closed."); + } catch (final IOException e) { + LOGGER.warning(e.getMessage()); e.printStackTrace(); } } // fileLoop - + // If the processing stopped because of max events then need to cleanup the reader. if (reader != null) { if (!reader.isClosed()) { // Close the EVIO reader. try { reader.close(); - logger.fine("EVIO reader closed."); - } catch (IOException e) { - logger.warning(e.getMessage()); - e.printStackTrace(); - } + LOGGER.fine("EVIO reader closed."); + } catch (final IOException e) { + LOGGER.log(Level.WARNING, e.getMessage(), e); + } } } @@ -509,139 +615,35 @@ if (writer != null) { try { writer.close(); - logger.info("LCIO output writer closed okay."); - } catch (IOException e) { + LOGGER.info("LCIO output writer closed okay."); + } catch (final IOException e) { e.printStackTrace(); - logger.warning(e.getMessage()); - } - } - - logger.info("Job finished successfully!"); + LOGGER.warning(e.getMessage()); + } + } + + LOGGER.info("Job finished successfully!"); } /** - * Buffer up to <code>maxBufferSize</code> events in the <code>eventQueue</code>. - * This method will also initialize the conditions system using a run number - * if a header bank is found. - * @param reader The EVIO reader. - * @param eventQueue The event queue. - * @param maxBufferSize The maximum number of records to buffer. - */ - private void bufferEvents(EvioReader reader, EvioEventQueue eventQueue, int maxBufferSize) { - EvioEvent evioEvent = null; - while (eventQueue.size() < maxBufferSize) { - try { - // Break if no more events from reader. - if (reader.getNumEventsRemaining() == 0) { - break; - } - - // Read the next event. - evioEvent = reader.nextEvent(); - - if (evioEvent == null) { - break; - } - - // Add the event to the queue. - eventQueue.addRecord(evioEvent); - - } catch (IOException | EvioException e) { - logger.severe(e.getMessage()); - e.printStackTrace(); - } - - if (evioEvent != null) { - - // Parse the event. - try { - reader.parseEvent(evioEvent); - } catch (EvioException e) { - logger.severe(e.getMessage()); - e.printStackTrace(); - continue; - } - - // Is conditions system not frozen? - if (!DatabaseConditionsManager.getInstance().isFrozen()) { - - // Get head bank from event. - BaseStructure headBank = EvioEventUtilities.getHeadBank(evioEvent); - - // Is head bank available in this event? - if (headBank != null) { - - // Get the run number from the head bank. - runNumber = headBank.getIntData()[1]; - logger.finer("got head bank with run number " + runNumber); - - // Check if the conditions system needs to be updated from the head bank. - checkConditions(runNumber, false); - } else { - logger.finest("event " + evioEvent.getEventNumber() + " does not have a head bank"); - } - } - } - } - logger.finer("buffered " + eventQueue.size() + " events"); - } - - /** - * Print the CLI usage and exit. - */ - private void printUsage() { - System.out.println("EvioToLcio [options] [evioFiles]"); - HelpFormatter help = new HelpFormatter(); - help.printHelp(" ", options); - System.exit(1); - } - - /** * Setup the LCSimEventBuilder based on the current detector name and run number. + * * @param detectorName The detector name to be assigned to the event builder. * @param runNumber The run number which determines which event builder to use. * @return The LCSimEventBuilder for the Test Run or Engineering Run. */ - private void setupEventBuilder(int runNumber) { + private void setupEventBuilder(final int runNumber) { // Is this run number from the Test Run? if (DatabaseConditionsManager.isTestRun(runNumber)) { // Configure conditions system for Test Run. - logger.info("using Test Run event builder"); + LOGGER.info("using Test Run event builder"); eventBuilder = new LCSimTestRunEventBuilder(); } else { // Configure conditions system for Eng Run or default. - logger.info("using Eng Run event builder"); + LOGGER.info("using Eng Run event builder"); eventBuilder = new LCSimEngRunEventBuilder(); } - ConditionsManager conditions = ConditionsManager.defaultInstance(); - conditions.addConditionsListener(eventBuilder); - } - - /** - * Check if the conditions system and event builder need to be initialized - * or updated given a run number. - * @param runNumber The run number. - * @param freeze True to freeze conditions system after it is setup. - */ - private void checkConditions(int runNumber, boolean freeze) { - - // Is the event builder uninitialized? - if (eventBuilder == null) { - // Setup event builder. - setupEventBuilder(runNumber); - } - - // Update the conditions system with the new run number. - try { - // This call may be ignored by the conditions system if the run number is not new. - ConditionsManager.defaultInstance().setDetector(detectorName, runNumber); - } catch (ConditionsNotFoundException e) { - throw new RuntimeException("Error initializing conditions system.", e); - } - - if (freeze) { - // Freeze the conditions system so subsequent run numbers are ignored. - DatabaseConditionsManager.getInstance().freeze(); - } + final ConditionsManager conditions = ConditionsManager.defaultInstance(); + conditions.addConditionsListener(eventBuilder); } } Modified: java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java ============================================================================= --- java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java (original) +++ java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/LCSimEngRunEventBuilder.java Fri Jun 12 15:27:10 2015 @@ -7,39 +7,39 @@ import org.hps.recon.ecal.triggerbank.AbstractIntData; import org.hps.recon.ecal.triggerbank.SSPData; +import org.hps.recon.ecal.triggerbank.TDCData; import org.hps.recon.ecal.triggerbank.TIData; -import org.hps.recon.ecal.triggerbank.TDCData; +import org.hps.record.epics.EpicsData; import org.hps.record.epics.EpicsEvioProcessor; -import org.hps.record.epics.EpicsScalarData; import org.hps.record.evio.EvioEventUtilities; -import org.hps.record.scalars.ScalarData; -import org.hps.record.scalars.ScalarsEvioProcessor; +import org.hps.record.scalers.ScalersEvioProcessor; import org.jlab.coda.jevio.EvioEvent; import org.lcsim.event.EventHeader; +import org.lcsim.util.log.DefaultLogFormatter; +import org.lcsim.util.log.LogUtil; /** - * This is the {@link org.hps.record.LCSimEventBuilder} implementation for the - * Engineering Run and the Commissioning Run. + * This is the {@link org.hps.record.LCSimEventBuilder} implementation for the Engineering Run and the Commissioning Run. * <p> - * It has several modifications from the Test Run builder including different - * values for certain bank tags. + * It has several modifications from the Test Run builder including different values for certain bank tags. * <p> - * Additionally, this builder will write DAQ config information, EPICS control - * data, and scalar bank data into the output LCSim events if these banks are - * present in the EVIO data. + * Additionally, this builder will write DAQ config information, EPICS control data, and scalar bank data into the output LCSim events if these banks + * are present in the EVIO data. * * @author Sho Uemura <[log in to unmask]> * @author Jeremy McCormick <[log in to unmask]> */ public class LCSimEngRunEventBuilder extends LCSimTestRunEventBuilder { - TriggerConfigEvioReader triggerConfigReader = null; + private static final Logger LOGGER = LogUtil.create(LCSimEngRunEventBuilder.class, new DefaultLogFormatter(), Level.INFO); - EpicsEvioProcessor epicsProcessor = new EpicsEvioProcessor(); - EpicsScalarData epicsData; + private EpicsData epicsData; - ScalarsEvioProcessor scalarProcessor = new ScalarsEvioProcessor(); - ScalarData scalarData; + private final EpicsEvioProcessor epicsProcessor = new EpicsEvioProcessor(); + + private final ScalersEvioProcessor scalerProcessor = new ScalersEvioProcessor(); + + private TriggerConfigEvioReader triggerConfigReader = null; public LCSimEngRunEventBuilder() { ecalReader.setTopBankTag(0x25); @@ -49,18 +49,28 @@ sspCrateBankTag = 0x2E; // A.C. modification after Sergey's confirmation sspBankTag = 0xe10c; intBanks = new ArrayList<IntBankDefinition>(); - intBanks.add(new IntBankDefinition(SSPData.class, new int[]{sspCrateBankTag, sspBankTag})); - intBanks.add(new IntBankDefinition(TIData.class, new int[]{sspCrateBankTag, 0xe10a})); - intBanks.add(new IntBankDefinition(TDCData.class, new int[]{0x3a, 0xe107})); + intBanks.add(new IntBankDefinition(SSPData.class, new int[] {sspCrateBankTag, sspBankTag})); + intBanks.add(new IntBankDefinition(TIData.class, new int[] {sspCrateBankTag, 0xe10a})); + intBanks.add(new IntBankDefinition(TDCData.class, new int[] {0x3a, 0xe107})); // ecalReader = new ECalEvioReader(0x25, 0x27); triggerConfigReader = new TriggerConfigEvioReader(); } + /** + * Create and cache an {@link org.hps.record.epics.EpicsData} object. + * + * @param evioEvent The EVIO event data. + */ + void createEpicsData(final EvioEvent evioEvent) { + epicsProcessor.process(evioEvent); + epicsData = epicsProcessor.getEpicsData(); + } + @Override - protected long getTime(List<AbstractIntData> triggerList) { - for (AbstractIntData data : triggerList) { + protected long getTime(final List<AbstractIntData> triggerList) { + for (final AbstractIntData data : triggerList) { if (data instanceof TIData) { - TIData tiData = (TIData) data; + final TIData tiData = (TIData) data; return tiData.getTime(); } } @@ -68,46 +78,17 @@ } @Override - public void readEvioEvent(EvioEvent evioEvent) { - super.readEvioEvent(evioEvent); + public EventHeader makeLCSimEvent(final EvioEvent evioEvent) { - // Create EPICS data if this is an EPICS control event. - if (EvioEventUtilities.isEpicsEvent(evioEvent)) { - createEpicsScalarData(evioEvent); - } - } + LOGGER.finest("creating LCSim event from EVIO event " + evioEvent.getEventNumber()); - /** - * Create and cache an {@link org.hps.record.epics.EpicsScalarData} object. - * - * @param evioEvent The EVIO event data. - */ - void createEpicsScalarData(EvioEvent evioEvent) { - epicsProcessor.process(evioEvent); - epicsData = epicsProcessor.getEpicsScalarData(); - } - - /** - * Write EVIO scalar data into the LCSim event, if it exists. - * - * @param evioEvent The EVIO event data. - * @param lcsimEvent The output LCSim event. - */ - void writeScalarData(EvioEvent evioEvent, EventHeader lcsimEvent) { - scalarProcessor.process(evioEvent); - if (scalarProcessor.getScalarData() != null) { - scalarProcessor.getScalarData().write(lcsimEvent); - } - } - - @Override - public EventHeader makeLCSimEvent(EvioEvent evioEvent) { if (!EvioEventUtilities.isPhysicsEvent(evioEvent)) { throw new RuntimeException("Not a physics event: event tag " + evioEvent.getHeader().getTag()); } // Create a new LCSimEvent. - EventHeader lcsimEvent = getEventData(evioEvent); + final EventHeader lcsimEvent = this.getEventData(evioEvent); + LOGGER.finest("created new LCSim event " + lcsimEvent.getEventNumber()); // Put DAQ Configuration info into lcsimEvent. triggerConfigReader.getDAQConfig(evioEvent, lcsimEvent); @@ -116,26 +97,52 @@ // of ECal into one list. try { ecalReader.makeHits(evioEvent, lcsimEvent); - } catch (Exception e) { - Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Error making ECal hits", e); + } catch (final Exception e) { + LOGGER.log(Level.SEVERE, "Error making ECal hits", e); } // Make SVT RawTrackerHits. try { svtReader.makeHits(evioEvent, lcsimEvent); - } catch (Exception e) { - Logger.getLogger(this.getClass().getName()).log(Level.SEVERE, "Error making SVT hits", e); + } catch (final Exception e) { + LOGGER.log(Level.SEVERE, "Error making SVT hits", e); } - + // Write the current EPICS data into this event. if (epicsData != null) { + LOGGER.finest("writing EPICS data to lcsim event " + lcsimEvent.getEventNumber()); epicsData.write(lcsimEvent); epicsData = null; } - // Write scalars into the event, if they exist in this EVIO data. - writeScalarData(evioEvent, lcsimEvent); + // Write scalers into the event, if they exist in this EVIO data. + this.writeScalerData(evioEvent, lcsimEvent); return lcsimEvent; } + + @Override + public void readEvioEvent(final EvioEvent evioEvent) { + super.readEvioEvent(evioEvent); + + // Create EPICS data if this is an EPICS control event. + if (EvioEventUtilities.isEpicsEvent(evioEvent)) { + LOGGER.finest("creating data from EPICS event"); + this.createEpicsData(evioEvent); + } + } + + /** + * Write EVIO scaler data into the LCSim event, if it exists. + * + * @param evioEvent The EVIO event data. + * @param lcsimEvent The output LCSim event. + */ + void writeScalerData(final EvioEvent evioEvent, final EventHeader lcsimEvent) { + scalerProcessor.process(evioEvent); + if (scalerProcessor.getScalerData() != null) { + LOGGER.finest("writing scaler data to lcsim event " + lcsimEvent.getEventNumber() + " from EVIO event " + evioEvent.getEventNumber()); + scalerProcessor.getScalerData().write(lcsimEvent); + } + } } Modified: java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/LCSimTestRunEventBuilder.java ============================================================================= --- java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/LCSimTestRunEventBuilder.java (original) +++ java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/LCSimTestRunEventBuilder.java Fri Jun 12 15:27:10 2015 @@ -18,6 +18,7 @@ import org.lcsim.conditions.ConditionsManager; import org.lcsim.event.EventHeader; import org.lcsim.event.base.BaseLCSimEvent; +import org.lcsim.util.log.DefaultLogFormatter; import org.lcsim.util.log.LogUtil; /** @@ -33,7 +34,7 @@ protected long time = 0; //most recent event time (ns), taken from prestart and end events, and trigger banks (if any) protected int sspCrateBankTag = 0x1; //bank ID of the crate containing the SSP protected int sspBankTag = 0xe106; //SSP bank's tag - protected static Logger logger = LogUtil.create(LCSimTestRunEventBuilder.class); + protected static Logger LOGGER = LogUtil.create(LCSimTestRunEventBuilder.class, new DefaultLogFormatter(), Level.INFO); protected List<IntBankDefinition> intBanks = null; public LCSimTestRunEventBuilder() { @@ -41,7 +42,7 @@ svtReader = new TestRunSvtEvioReader(); intBanks = new ArrayList<IntBankDefinition>(); intBanks.add(new IntBankDefinition(TestRunTriggerData.class, new int[]{sspCrateBankTag, sspBankTag})); - logger.setLevel(Level.FINE); + LOGGER.setLevel(Level.FINE); } public void setEcalHitCollectionName(String ecalHitCollectionName) { @@ -53,33 +54,33 @@ if (EvioEventUtilities.isSyncEvent(evioEvent)) { int[] data = EvioEventUtilities.getControlEventData(evioEvent); int seconds = data[0]; - logger.info("Sync event: time " + seconds + " - " + new Date(((long) seconds) * 1000) + ", event count since last sync " + data[1] + ", event count so far " + data[2] + ", status " + data[3]); + LOGGER.info("Sync event: time " + seconds + " - " + new Date(((long) seconds) * 1000) + ", event count since last sync " + data[1] + ", event count so far " + data[2] + ", status " + data[3]); } else if (EvioEventUtilities.isPreStartEvent(evioEvent)) { int[] data = EvioEventUtilities.getControlEventData(evioEvent); if (data != null) { int seconds = data[0]; time = ((long) seconds) * 1000000000; int run = data[1]; - logger.info("Prestart event: time " + seconds + " - " + new Date(((long) seconds) * 1000) + ", run " + run + ", run type " + data[2]); + LOGGER.info("Prestart event: time " + seconds + " - " + new Date(((long) seconds) * 1000) + ", run " + run + ", run type " + data[2]); } } else if (EvioEventUtilities.isGoEvent(evioEvent)) { int[] data = EvioEventUtilities.getControlEventData(evioEvent); if (data != null) { int seconds = data[0]; time = ((long) seconds) * 1000000000; - logger.info("Go event: time " + seconds + " - " + new Date(((long) seconds) * 1000) + ", event count so far " + data[2]); + LOGGER.info("Go event: time " + seconds + " - " + new Date(((long) seconds) * 1000) + ", event count so far " + data[2]); } } else if (EvioEventUtilities.isPauseEvent(evioEvent)) { int[] data = EvioEventUtilities.getControlEventData(evioEvent); int seconds = data[0]; time = ((long) seconds) * 1000000000; - logger.info("Pause event: time " + seconds + " - " + new Date(((long) seconds) * 1000) + ", event count so far " + data[2]); + LOGGER.info("Pause event: time " + seconds + " - " + new Date(((long) seconds) * 1000) + ", event count so far " + data[2]); } else if (EvioEventUtilities.isEndEvent(evioEvent)) { int[] data = EvioEventUtilities.getControlEventData(evioEvent); int seconds = data[0]; time = ((long) seconds) * 1000000000; //run = 0; - logger.info("End event: time " + seconds + " - " + new Date(((long) seconds) * 1000) + ", event count " + data[2]); + LOGGER.info("End event: time " + seconds + " - " + new Date(((long) seconds) * 1000) + ", event count " + data[2]); } } @@ -124,29 +125,34 @@ } if (eventID == null) { - logger.warning("No event ID bank found"); + // FIXME: Should be a fatal error if this happens? JM + LOGGER.warning("no event ID bank found"); eventID = new int[3]; } else { - logger.finest("Read EVIO event number " + eventID[0]); + LOGGER.finest("read EVIO event number " + eventID[0]); // Stop hardcoding event tags. - //if (eventID[1] != 1) { - // logger.warning("Trigger code is usually 1; got " + eventID[1]); - //} if (eventID[2] != 0) { - logger.warning("Readout status is usually 0; got " + eventID[2]); + LOGGER.warning("Readout status is usually 0 but got " + eventID[2]); } } time = getTime(triggerList); - + + if (eventID[0] != evioEvent.getEventNumber()) { + LOGGER.finest("EVIO event number " + evioEvent.getEventNumber() + " does not match " + eventID[0] + " from event ID bank"); + } + // Create a new LCSimEvent. EventHeader lcsimEvent = new BaseLCSimEvent( ConditionsManager.defaultInstance().getRun(), eventID[0], + // FIXME: This should be used instead for event number. JM + // evioEvent.getEventNumber(), ConditionsManager.defaultInstance().getDetector(), time); lcsimEvent.put("TriggerBank", triggerList, AbstractIntData.class, 0); + return lcsimEvent; } @@ -169,10 +175,10 @@ AbstractIntData data = (AbstractIntData) def.dataClass.getConstructor(int[].class).newInstance(bank.getIntData()); triggerList.add(data); } catch (Exception ex) { - Logger.getLogger(LCSimTestRunEventBuilder.class.getName()).log(Level.SEVERE, null, ex); + LOGGER.log(Level.SEVERE, ex.getMessage(), ex); } } else { - logger.finest("No trigger bank found of type " + def.dataClass.getSimpleName()); + LOGGER.finest("No trigger bank found of type " + def.dataClass.getSimpleName()); } } return triggerList; @@ -203,14 +209,17 @@ searchLoop: for (int bankTag : bankTags) { if (currentBank.getChildCount() > 0) { - for (BaseStructure childBank : currentBank.getChildren()) { - if (childBank.getHeader().getTag() == bankTag) { //found a bank with the right tag; step inside this bank and conitnue searching + for (BaseStructure childBank : currentBank.getChildrenList()) { + if (childBank.getHeader().getTag() == bankTag) { + // Found a bank with the right tag; step inside this bank and continue searching. currentBank = childBank; continue searchLoop; } } - return null; //didn't find a bank with the right tag, give up - } else { //bank has no children, give up + // Didn't find a bank with the right tag so stop. + return null; + } else { + // Bank has no children so stop. return null; } } Modified: java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/SvtEvioReader.java ============================================================================= --- java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/SvtEvioReader.java (original) +++ java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/SvtEvioReader.java Fri Jun 12 15:27:10 2015 @@ -3,10 +3,13 @@ import java.util.List; import org.jlab.coda.jevio.BaseStructure; +import org.jlab.coda.jevio.EvioEvent; import org.lcsim.detector.tracker.silicon.HpsSiSensor; +import org.lcsim.event.EventHeader; import org.lcsim.event.RawTrackerHit; import org.lcsim.geometry.Subdetector; + import org.hps.util.Pair; /** @@ -111,8 +114,8 @@ @Override protected HpsSiSensor getSensor(int[] data) { - logger.fine("FEB ID: " + SvtEvioUtils.getFebID(data) - + " Hybrid ID: " + SvtEvioUtils.getFebHybridID(data)); + //logger.fine("FEB ID: " + SvtEvioUtils.getFebID(data) + // + " Hybrid ID: " + SvtEvioUtils.getFebHybridID(data)); Pair<Integer, Integer> daqPair = new Pair<Integer, Integer>(SvtEvioUtils.getFebID(data), @@ -123,7 +126,7 @@ /** * Check whether a data bank is valid i.e. contains SVT samples only. For - * the engineering run, a valid data bank has a tag of 1. + * the engineering run, a valid data bank has a tag of 3. * * @param dataBank - An EVIO bank containing integer data * @return true if the bank is valid, false otherwise @@ -131,7 +134,17 @@ */ @Override protected boolean isValidDataBank(BaseStructure dataBank) { - if (dataBank.getHeader().getTag() != 3) return false; + + // The SVT configuration is stored in a bank with tag equal to 57614. + // All other event banks are invalid + if (dataBank.getHeader().getTag() == 57614) { + + // Store the event bank for processing later. + eventBanks.add(dataBank); + + return false; + } else if (dataBank.getHeader().getTag() != 3) return false; + return true; } @@ -145,6 +158,41 @@ protected boolean isValidSampleSet(int[] data) { return !(SvtEvioUtils.isApvHeader(data) || SvtEvioUtils.isApvTail(data)); } + + /** + * Process an EVIO event and extract all information relevant to the SVT. + * + * @param event - EVIO event to process + * @param lcsimEvent - LCSim event to put collections into + * @return true if the EVIO was processed successfully, false otherwise + */ + @Override + public boolean processEvent(EvioEvent event, EventHeader lcsimEvent) { + + // Make RawTrackerHits. This will also search for and store banks containing + // the configuration of the SVT. + boolean success = super.processEvent(event, lcsimEvent); + + /*logger.fine("Event contains " + eventBanks.size() + " event banks"); + // Loop through all of the event banks and process them + for (BaseStructure eventBank : eventBanks) { + logger.fine(eventBank.toString()); + if (eventBank.getHeader().getTag() == 57614) { + logger.fine("Configuration bank found"); + String[] stringData = eventBank.getStringData(); + logger.fine("String data size: " + stringData.length); + System.out.println("Configuration: "); + for (String stringDatum : stringData) { + System.out.println("Data: " + stringDatum); + } + } + }*/ + + // Clear out the event banks after they have been processed + eventBanks.clear(); + + return success; + } /** * Make a {@linkplain RawTrackerHit} from a set of samples. @@ -155,7 +203,7 @@ @Override protected RawTrackerHit makeHit(int[] data) { - logger.fine("Channel: " + SvtEvioUtils.getPhysicalChannelNumber(data)); + //logger.fine("Channel: " + SvtEvioUtils.getPhysicalChannelNumber(data)); return makeHit(data, SvtEvioUtils.getPhysicalChannelNumber(data)); } } Modified: java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToEvio.java ============================================================================= --- java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToEvio.java (original) +++ java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToEvio.java Fri Jun 12 15:27:10 2015 @@ -58,7 +58,7 @@ public void setEcalMode(int ecalMode) { this.ecalMode = ecalMode; - if (ecalMode != EventConstants.ECAL_WINDOW_MODE && ecalMode != EventConstants.ECAL_PULSE_MODE && ecalMode != EventConstants.ECAL_PULSE_INTEGRAL_MODE) { + if (ecalMode != EventConstants.ECAL_RAW_MODE && ecalMode != EventConstants.ECAL_PULSE_MODE && ecalMode != EventConstants.ECAL_PULSE_INTEGRAL_MODE) { throw new IllegalArgumentException("invalid mode " + ecalMode); } if (ecalWriter != null) { Modified: java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToLcio.java ============================================================================= --- java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToLcio.java (original) +++ java/branches/HPSJAVA-488/evio/src/main/java/org/hps/evio/TestRunTriggeredReconToLcio.java Fri Jun 12 15:27:10 2015 @@ -77,7 +77,7 @@ public void setEcalMode(int ecalMode) { this.ecalMode = ecalMode; - if (ecalMode != EventConstants.ECAL_WINDOW_MODE && ecalMode != EventConstants.ECAL_PULSE_MODE && ecalMode != EventConstants.ECAL_PULSE_INTEGRAL_MODE) { + if (ecalMode != EventConstants.ECAL_RAW_MODE && ecalMode != EventConstants.ECAL_PULSE_MODE && ecalMode != EventConstants.ECAL_PULSE_INTEGRAL_MODE) { throw new IllegalArgumentException("invalid mode " + ecalMode); } if (ecalWriter != null) { @@ -287,7 +287,7 @@ @Override protected void processTrigger(EventHeader event) { // Create an LCSim event and pass a flag so that conditions updates are disabled. --JM - EventHeader lcsimEvent = new BaseLCSimEvent(DatabaseConditionsManager.getInstance().getRun(), event.getEventNumber(), event.getDetectorName(), System.currentTimeMillis() * 1000000, false); + EventHeader lcsimEvent = new BaseLCSimEvent(DatabaseConditionsManager.getInstance().getRun(), event.getEventNumber(), event.getDetectorName(), (long) 4 * (Math.round(ClockSingleton.getTime() / 4)), false); events.add(lcsimEvent); if (verbosity >= 1) { System.out.println("Creating LCIO event " + eventNum); Modified: java/branches/HPSJAVA-488/integration-tests/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/integration-tests/pom.xml (original) +++ java/branches/HPSJAVA-488/integration-tests/pom.xml Fri Jun 12 15:27:10 2015 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/integration-tests/</url> @@ -35,11 +35,16 @@ <exclude>org/hps/HPSTestRunTracker2014GeometryTrackReconTest.java</exclude> <exclude>org/hps/HPSTracker2014GeometryTrackReconTest.java</exclude> <exclude>org/hps/MCFilteredReconTest.java</exclude> + <exclude>org/hps/MockDataReconTest.java</exclude> <exclude>org/hps/ReadoutToEvioTest.java</exclude> <exclude>org/hps/ReadoutToLcioTest.java</exclude> <exclude>org/hps/SimpleSvtReadoutTest.java</exclude> <exclude>org/hps/TestRunReadoutToEvioTest.java</exclude> <exclude>org/hps/ReadoutNoPileupTest.java</exclude> + <exclude>org/hps/SteeringFilesTest.java</exclude> + <exclude>org/hps/TestRunEvioToLcioTest.java</exclude> + <exclude>org/hps/TestRunReconTest.java</exclude> + <exclude>org/hps/test/it/EcalSimReconTest.java</exclude> </excludes> <!-- <redirectTestOutputToFile>true</redirectTestOutputToFile> --> <trimStackTrace>false</trimStackTrace> Modified: java/branches/HPSJAVA-488/monitoring-app/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/monitoring-app/pom.xml (original) +++ java/branches/HPSJAVA-488/monitoring-app/pom.xml Fri Jun 12 15:27:10 2015 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/monitoring-app/</url> Modified: java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/MonitoringApplication.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/MonitoringApplication.java (original) +++ java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/MonitoringApplication.java Fri Jun 12 15:27:10 2015 @@ -658,8 +658,8 @@ private void openFile() { final JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); fc.setAcceptAllFileFilterUsed(false); + fc.addChoosableFileFilter(EVIO_FILTER); fc.addChoosableFileFilter(LCIO_FILTER); - fc.addChoosableFileFilter(EVIO_FILTER); fc.setDialogTitle("Select Data File"); final int r = fc.showDialog(this.frame, "Select ..."); if (r == JFileChooser.APPROVE_OPTION) { @@ -753,9 +753,9 @@ private void savePlots() { final JFileChooser fc = new JFileChooser(); fc.addChoosableFileFilter(new FileNameExtensionFilter("ROOT file", "root")); - final FileFilter filter = new FileNameExtensionFilter("AIDA file", "aida"); + final FileFilter filter = new FileNameExtensionFilter("PDF file", "pdf"); fc.addChoosableFileFilter(filter); - fc.addChoosableFileFilter(new FileNameExtensionFilter("PDF file", "pdf")); + fc.addChoosableFileFilter(new FileNameExtensionFilter("AIDA file", "aida")); fc.setAcceptAllFileFilterUsed(false); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setFileFilter(filter); @@ -770,8 +770,10 @@ } try { if ("pdf".equals(extension)) { - // Write to a single PDF file. - ExportPdf.write(MonitoringPlotFactory.getPlotterRegistry().getPlotters(), fileName, + // Write out all plot graphics from the tabs to a single PDF file. + ExportPdf.write( + MonitoringPlotFactory.getPlotterRegistry().getPlotters(), + fileName, getRunData()); } else { // Save plot object data to AIDA or ROOT file. Modified: java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/MonitoringApplicationFrame.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/MonitoringApplicationFrame.java (original) +++ java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/MonitoringApplicationFrame.java Fri Jun 12 15:27:10 2015 @@ -136,15 +136,15 @@ // Create the tabbed pane for content in bottom of left panel such as log table and system monitor. final JTabbedPane tableTabbedPane = new JTabbedPane(); - // Create the log table and add it to the tabs. - this.logPanel = new LogPanel(application.getConfigurationModel(), application); - tableTabbedPane.addTab("Log Messages", this.logPanel); - // Create the system monitor. // systemStatusTable = new SystemStatusTable(); this.systemStatusPanel = new SystemStatusPanel(); tableTabbedPane.addTab("System Status Monitor", this.systemStatusPanel); + // Create the log table and add it to the tabs. + this.logPanel = new LogPanel(application.getConfigurationModel(), application); + tableTabbedPane.addTab("Log Messages", this.logPanel); + // Add the trigger diagnostics tables. this.triggerPanel = new TriggerDiagnosticsPanel(); tableTabbedPane.addTab("Trigger Diagnostics", this.triggerPanel); @@ -172,11 +172,13 @@ // Create the right panel vertical split pane for displaying plots and their information and statistics. this.rightSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, this.plotPanel, this.plotInfoPanel); this.rightSplitPane.setDividerLocation(680); + this.rightSplitPane.setOneTouchExpandable(true); rightPanel.add(this.rightSplitPane, BorderLayout.CENTER); // Create the main horizontal split pane for dividing the left and right panels. this.mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel); this.mainSplitPane.setDividerLocation(600); + this.mainSplitPane.setOneTouchExpandable(true); bottomPanel.add(this.mainSplitPane, BorderLayout.CENTER); // Create the menu bar. Modified: java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/PlotPanel.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/PlotPanel.java (original) +++ java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/PlotPanel.java Fri Jun 12 15:27:10 2015 @@ -1,6 +1,4 @@ package org.hps.monitoring.application; - -import hep.aida.IPlotter; import java.awt.BorderLayout; import java.awt.Component; @@ -18,7 +16,6 @@ import org.hps.monitoring.application.util.DialogUtil; import org.hps.monitoring.plotting.ExportPdf; -import org.hps.monitoring.plotting.MonitoringPlotFactory; /** * This is the panel containing the tabs with the monitoring plots. @@ -50,14 +47,8 @@ */ @Override public void actionPerformed(final ActionEvent event) { - if (event.getActionCommand().equals(Commands.SAVE_SELECTED_PLOTS)) { - final int[] indices = this.getSelectedTabIndices(); - final IPlotter plotter = MonitoringPlotFactory.getPlotterRegistry().find(indices[0], indices[1]); - if (plotter != null) { - this.savePlotter(plotter); - } else { - DialogUtil.showErrorDialog(this, "Error Finding Plots", "No plots found in selected tab."); - } + if (event.getActionCommand().equals(Commands.SAVE_SELECTED_PLOTS)) { + saveCurrentPlot(); } } @@ -75,7 +66,7 @@ * * @return the currently selected plot tab */ - Component getSelectedTab() { + Component getSelectedComponent() { return ((JTabbedPane) this.plotPane.getSelectedComponent()).getSelectedComponent(); } @@ -84,15 +75,15 @@ * * @return The indices of the current tabs. */ - private int[] getSelectedTabIndices() { - final int[] indices = new int[2]; - indices[0] = this.plotPane.getSelectedIndex(); - final Component component = this.plotPane.getSelectedComponent(); - if (component instanceof JTabbedPane) { - indices[1] = ((JTabbedPane) component).getSelectedIndex(); - } - return indices; - } + //private int[] getSelectedTabIndices() { + // final int[] indices = new int[2]; + // indices[0] = this.plotPane.getSelectedIndex(); + // final Component component = this.plotPane.getSelectedComponent(); + // if (component instanceof JTabbedPane) { + // indices[1] = ((JTabbedPane) component).getSelectedIndex(); + // } + // return indices; + //} /** * Remove all tabs from the plot pane. @@ -106,10 +97,10 @@ * * @param plotter the plotter to save */ - private void savePlotter(final IPlotter plotter) { + private void saveCurrentPlot() { final JFileChooser fc = new JFileChooser(); fc.setAcceptAllFileFilterUsed(false); - fc.setDialogTitle("Save Plots - " + plotter.title()); + fc.setDialogTitle("Save Plot"); fc.setCurrentDirectory(new File(".")); fc.setAcceptAllFileFilterUsed(false); fc.setFileFilter(new FileNameExtensionFilter("PNG file", "png")); @@ -122,8 +113,8 @@ if (!path.endsWith("." + filter.getExtensions()[0])) { path += "." + filter.getExtensions()[0]; } - final BufferedImage image = ExportPdf.getImage(this.getSelectedTab()); try { + final BufferedImage image = ExportPdf.getImage(this.getSelectedComponent()); ImageIO.write(image, filter.getExtensions()[0], new File(path)); DialogUtil.showInfoDialog(this, "Plots Saved", "Plots from panel were saved to" + '\n' + path); } catch (final IOException e) { Modified: java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusPanel.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusPanel.java (original) +++ java/branches/HPSJAVA-488/monitoring-app/src/main/java/org/hps/monitoring/application/SystemStatusPanel.java Fri Jun 12 15:27:10 2015 @@ -4,17 +4,24 @@ package org.hps.monitoring.application; import java.awt.BorderLayout; +import java.awt.Toolkit; +import java.util.ArrayList; +import java.util.List; +import java.util.Timer; +import java.util.TimerTask; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JSplitPane; import org.hps.monitoring.application.SystemStatusEventsTable.SystemStatusEventsTableModel; +import org.hps.monitoring.subsys.StatusCode; import org.hps.monitoring.subsys.SystemStatus; /** - * This is a panel showing the two tables for viewing the system statuses, one showing the current state of all system - * status monitors and the other with all system status change events. + * This is a panel showing the two tables for viewing the system statuses, one + * showing the current state of all system status monitors and the other with + * all system status change events. * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ @@ -32,14 +39,22 @@ private final SystemStatusTable statusTable = new SystemStatusTable(); /** + * The list of statuses to check. + */ + private final List<SystemStatus> statuses = new ArrayList<SystemStatus>(); + + private final Timer timer = new Timer("System Status Beeper"); + + /** * Class constructor. */ SystemStatusPanel() { super(new BorderLayout()); final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(this.statusTable), new JScrollPane(this.eventsTable)); - splitPane.setDividerLocation(50); + splitPane.setDividerLocation(150); this.add(splitPane, BorderLayout.CENTER); + timer.scheduleAtFixedRate(new SystemStatusBeeper(), 0, 1000); } /** @@ -51,6 +66,7 @@ // Register listeners of table models on this status. this.statusTable.getTableModel().addSystemStatus(status); this.eventsTable.getSystemStatusEventsTableModel().addSystemStatus(status); + this.statuses.add(status); } /** @@ -62,5 +78,23 @@ // Clear the system status events table. ((SystemStatusEventsTableModel) this.eventsTable.getModel()).clear(); + + this.statuses.clear(); + } + + private class SystemStatusBeeper extends TimerTask { + + @Override + public void run() { + boolean isAlarming = false; + for (SystemStatus status : statuses) { + if (status.isActive() && status.getStatusCode() == StatusCode.ALARM) { + isAlarming = true; + } + } + if (isAlarming) { + System.out.println("beep\007"); + } + } } } Modified: java/branches/HPSJAVA-488/monitoring-app/src/main/scripts/evio_file_producer.sh ============================================================================= --- java/branches/HPSJAVA-488/monitoring-app/src/main/scripts/evio_file_producer.sh (original) +++ java/branches/HPSJAVA-488/monitoring-app/src/main/scripts/evio_file_producer.sh Fri Jun 12 15:27:10 2015 @@ -3,14 +3,10 @@ # First argument, with no command switch, is name of EVIO file. eviofile=$1 -# Subsequent arguments are appended to the end of the command. -shift - # Classpath pointing to the hps-evio jar. classpath=${project.build.directory}/${project.artifactId}-${project.version}-bin.jar # Run the file producer, sending any additional arguments to the command. -#prod="java -classpath $classpath org.hps.evio.EvioFileProducer -e ${eviofile} -f ETBuffer -host localhost -s 10000 -d 100 $@" -prod="java -classpath $classpath org.hps.record.evio.EvioFileProducer -e ${eviofile} -f ETBuffer -host localhost -s 200000 $@" +prod="java -classpath $classpath org.hps.record.evio.EvioFileProducer $@" echo $prod exec $prod Modified: java/branches/HPSJAVA-488/monitoring-drivers/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/monitoring-drivers/pom.xml (original) +++ java/branches/HPSJAVA-488/monitoring-drivers/pom.xml Fri Jun 12 15:27:10 2015 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/monitoring-drivers/</url> Modified: java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/example/ExamplePlotDriver.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/example/ExamplePlotDriver.java (original) +++ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/example/ExamplePlotDriver.java Fri Jun 12 15:27:10 2015 @@ -77,9 +77,9 @@ FADCGenericHits - class org.hps.recon.ecal.FADCGenericHit TriggerConfig - class org.hps.recon.ecal.daqconfig.EvioDAQParser EcalReadoutHits - class org.lcsim.event.base.BaseRawCalorimeterHit -EpicsScalarData - interface org.lcsim.event.GenericObject +EpicsData - interface org.lcsim.event.GenericObject EcalCalHits - interface org.lcsim.event.CalorimeterHit -ScalarData - interface org.lcsim.event.GenericObject +ScalerData - interface org.lcsim.event.GenericObject TriggerBank - class org.hps.recon.ecal.triggerbank.AbstractIntData EcalClusters - interface org.lcsim.event.Cluster */ @@ -372,4 +372,4 @@ return fitResult; } -} +} Modified: java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/GblTrackingReconstructionPlots.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/GblTrackingReconstructionPlots.java (original) +++ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/GblTrackingReconstructionPlots.java Fri Jun 12 15:27:10 2015 @@ -2,7 +2,9 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -10,15 +12,29 @@ import hep.aida.IHistogram1D; import hep.aida.IPlotter; import hep.aida.IPlotterStyle; - +import hep.physics.vec.BasicHep3Vector; +import hep.physics.vec.Hep3Vector; + +import org.hps.analysis.ecal.HPSMCParticlePlotsDriver; +import org.hps.recon.tracking.TrackUtils; +import org.hps.recon.tracking.gbl.HpsGblRefitter; +import org.hps.util.BasicLogFormatter; +import org.lcsim.constants.Constants; import org.lcsim.event.EventHeader; +import org.lcsim.event.MCParticle; import org.lcsim.event.Track; +import org.lcsim.event.base.ParticleTypeClassifier; +import org.lcsim.fit.helicaltrack.HelicalTrackFit; import org.lcsim.geometry.Detector; +import org.lcsim.recon.tracking.seedtracker.SeedCandidate; +import org.lcsim.recon.tracking.seedtracker.SeedTrack; import org.lcsim.util.Driver; import org.lcsim.util.aida.AIDA; +import org.lcsim.util.log.LogUtil; public class GblTrackingReconstructionPlots extends Driver { - private Logger logger = getLogger(); + private double _bfield; + private static Logger logger = LogUtil.create(GblTrackingReconstructionPlots.class, new BasicLogFormatter()); private AIDA aida = AIDA.defaultInstance(); private String outputPlots = null; private final String trackCollectionName = "MatchedTracks"; @@ -26,12 +42,34 @@ IHistogram1D nTracks; IHistogram1D nTracksGbl; IHistogram1D nTracksDiff; + IHistogram1D d0Diff; + IHistogram1D z0Diff; + IHistogram1D phiDiff; + IHistogram1D slopeDiff; + IHistogram1D rDiff; + IHistogram1D pDiff; + IHistogram1D d0Diff2; + IHistogram1D z0Diff2; + IHistogram1D phiDiff2; + IHistogram1D slopeDiff2; + IHistogram1D rDiff2; + IHistogram1D pDiff2; + IHistogram1D d0DiffGbl; + IHistogram1D z0DiffGbl; + IHistogram1D phiDiffGbl; + IHistogram1D slopeDiffGbl; + IHistogram1D rDiffGbl; + IHistogram1D pDiffGbl; IPlotter plotter1; + IPlotter plotter2; + IPlotter plotter3; + IPlotter plotter4; + public GblTrackingReconstructionPlots() { // TODO Auto-generated constructor stub - logger.setLevel(Level.WARNING); + logger.setLevel(Level.INFO); } public void setOutputPlots(String output) { @@ -41,6 +79,11 @@ protected void detectorChanged(Detector detector) { aida.tree().cd("/"); IAnalysisFactory fac = aida.analysisFactory(); + + Hep3Vector bfieldvec = detector.getFieldMap().getField(new BasicHep3Vector(0., 0., 1.)); + _bfield = bfieldvec.y(); + //double bfac = 0.0002998 * bfield; + //double bfac = Constants.fieldConversion * bfield; nTracks = aida.histogram1D("Seed tracks per event", 3, 0, 3); nTracksGbl = aida.histogram1D("Gbl tracks per event", 3, 0, 3); @@ -56,7 +99,66 @@ plotter1.region(1).plot(nTracksGbl); plotter1.region(2).plot(nTracksDiff); plotter1.show(); - + + d0Diff = aida.histogram1D("d0Diff", 25, -1.1, 1.1); + z0Diff = aida.histogram1D("z0Diff", 25, -0.8, 0.8); + slopeDiff = aida.histogram1D("slopeDiff", 25, -0.01, 0.01); + phiDiff = aida.histogram1D("phiDiff", 25, -0.01, 0.01); + rDiff = aida.histogram1D("rDiff", 25, -0.0001, 0.0001); + pDiff = aida.histogram1D("pDiff", 25, -0.1, 0.1); + + plotter2 = fac.createPlotterFactory().create("Truth comparison"); + plotter2.setStyle(style1); + plotter2.createRegions(3, 2); + plotter2.region(0).plot(d0Diff); + plotter2.region(1).plot(z0Diff); + plotter2.region(2).plot(phiDiff); + plotter2.region(3).plot(slopeDiff); + plotter2.region(4).plot(rDiff); + plotter2.region(5).plot(pDiff); + plotter2.show(); + + + d0DiffGbl = aida.histogram1D("d0DiffGbl", 25, -1.1, 1.1); + z0DiffGbl = aida.histogram1D("z0DiffGbl", 25, -0.8, 0.8); + slopeDiffGbl = aida.histogram1D("slopeDiffGbl", 25, -0.01, 0.01); + phiDiffGbl = aida.histogram1D("phiDiffGbl", 25, -0.01, 0.01); + rDiffGbl = aida.histogram1D("rDiffGbl", 25, -0.0001, 0.0001); + pDiffGbl = aida.histogram1D("pDiffGbl", 25, -0.1, 0.1); + + + plotter3 = fac.createPlotterFactory().create("Truth comparison GBL"); + plotter3.setStyle(style1); + plotter3.createRegions(3, 2); + plotter3.region(0).plot(d0DiffGbl); + plotter3.region(1).plot(z0DiffGbl); + plotter3.region(2).plot(phiDiffGbl); + plotter3.region(3).plot(slopeDiffGbl); + plotter3.region(4).plot(rDiffGbl); + plotter3.region(5).plot(pDiffGbl); + plotter3.show(); + + + d0Diff2 = aida.histogram1D("d0Diff2", 25, -1.1, 1.1); + z0Diff2 = aida.histogram1D("z0Diff2", 25, -0.8, 0.8); + slopeDiff2 = aida.histogram1D("slopeDiff2", 25, -0.01, 0.01); + phiDiff2 = aida.histogram1D("phiDiff2", 25, -0.01, 0.01); + rDiff2 = aida.histogram1D("rDiff2", 25, -0.0001, 0.0001); + pDiff2 = aida.histogram1D("pDiff2", 25, -0.1, 0.1); + + + plotter4 = fac.createPlotterFactory().create("Seed vs GBL"); + plotter4.setStyle(style1); + plotter4.createRegions(3, 2); + plotter4.region(0).plot(d0Diff2); + plotter4.region(1).plot(z0Diff2); + plotter4.region(2).plot(phiDiff2); + plotter4.region(3).plot(slopeDiff2); + plotter4.region(4).plot(rDiff2); + plotter4.region(5).plot(pDiff2); + plotter4.show(); + + } @@ -76,13 +178,130 @@ logger.warning("no gbl track collection"); gblTracks = new ArrayList<Track>(); } + + List<MCParticle> mcparticles; + List<MCParticle> fsParticles; + if( event.hasCollection(MCParticle.class) ) { + mcparticles = event.get(MCParticle.class).get(0); + fsParticles = HPSMCParticlePlotsDriver.makeGenFSParticleList(mcparticles); + } else { + logger.warning("no gbl track collection"); + mcparticles = new ArrayList<MCParticle>(); + fsParticles = new ArrayList<MCParticle>(); + } + + + + + logger.info("Number of Tracks = " + tracks.size()); + logger.info("Number of GBL Tracks = " + gblTracks.size()); + logger.info("Number of MC particles = " + mcparticles.size()); + logger.info("Number of FS MC particles = " + fsParticles.size()); + + + + Map<Track, MCParticle> trackTruthMatch = new HashMap<Track,MCParticle>(); + + for(Track track : gblTracks) { + MCParticle part = TrackUtils.getMatchedTruthParticle(track); + trackTruthMatch.put(track, part); + if(part!=null) { + logger.info("Match track with q " + track.getCharge() + " p " + track.getMomentum()[0] + "," + track.getMomentum()[1] + "," + track.getMomentum()[2]); + } else { + logger.info("no match for track with q " + track.getCharge() + " p " + track.getMomentum()[0] + "," + track.getMomentum()[1] + "," + track.getMomentum()[2]); + } + } + + for(Track track : gblTracks) { + + logger.info("Track:"); + SeedTrack st = (SeedTrack)track; + SeedCandidate seed = st.getSeedCandidate(); + HelicalTrackFit htf = seed.getHelix(); + logger.info(htf.toString()); + HelicalTrackFit pHTF = null; + double pTruth = -1.; + double pTrackTruth = -1.; + if(trackTruthMatch.get(track)==null) { + logger.info("no truth mc particle for this track"); + } else { + MCParticle part = trackTruthMatch.get(track); + pTruth = part.getMomentum().magnitude(); + pHTF = TrackUtils.getHTF(part,Math.abs(_bfield)); + pTrackTruth = pHTF.p(Math.abs(_bfield)); + logger.info("part: " + trackTruthMatch.get(track).getPDGID()); + logger.info("pHTF:"); + logger.info(pHTF.toString()); + logger.info("pTruth="+pTruth+" pTrackTruth="+pTrackTruth); + } + + + + + double d0 = htf.dca(); + double z0 = htf.z0(); + double C = htf.curvature(); + double phi = htf.phi0(); + double slope = htf.slope(); + double p = htf.p(Math.abs(_bfield)); + double d0Gbl = track.getTrackStates().get(0).getD0(); + double z0Gbl = track.getTrackStates().get(0).getZ0(); + double CGbl = track.getTrackStates().get(0).getOmega(); + double phiGbl = track.getTrackStates().get(0).getPhi(); + double slopeGbl = track.getTrackStates().get(0).getTanLambda(); + double pGbl = getMag(track.getTrackStates().get(0).getMomentum()); + logger.info("pGbl="+pGbl); + + if(pHTF!=null) { + double d0Truth = pHTF.dca(); + double z0Truth = pHTF.z0(); + double CTruth = pHTF.curvature(); + double phiTruth = pHTF.phi0(); + double slopeTruth = pHTF.slope(); + logger.info("d0 " + d0 + " d0 trugh " + d0Truth); + d0Diff.fill(d0-d0Truth); + z0Diff.fill(z0-z0Truth); + phiDiff.fill(phi-phiTruth); + rDiff.fill(C-CTruth); + slopeDiff.fill(slope-slopeTruth); + pDiff.fill(p-pTruth); + + d0DiffGbl.fill(d0Gbl-d0Truth); + z0DiffGbl.fill(z0Gbl-z0Truth); + phiDiffGbl.fill(phiGbl-phiTruth); + rDiffGbl.fill(CGbl-CTruth); + slopeDiffGbl.fill(slopeGbl-slopeTruth); + pDiffGbl.fill(pGbl-pTruth); + } + + + d0Diff2.fill(d0-d0Gbl); + z0Diff2.fill(z0-z0Gbl); + phiDiff2.fill(phi-phiGbl); + rDiff2.fill(C-CGbl); + slopeDiff2.fill(slope-slopeGbl); + pDiff2.fill(p-pGbl); + + + } + + + + + nTracks.fill(tracks.size()); nTracksGbl.fill(gblTracks.size()); nTracksDiff.fill(tracks.size()-gblTracks.size()); - } - + + + } + + + private double getMag(double p[]) { + return Math.sqrt(p[0]*p[0] + p[1]*p[1] + p[2]*p[2]); + } public void endOfData() { if (outputPlots != null) { Modified: java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/PedestalPlots.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/PedestalPlots.java (original) +++ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/PedestalPlots.java Fri Jun 12 15:27:10 2015 @@ -1,11 +1,18 @@ package org.hps.monitoring.drivers.svt; +import hep.aida.IAnalysisFactory; import hep.aida.IDataPoint; import hep.aida.IDataPointSet; import hep.aida.IFitResult; import hep.aida.IFitter; import hep.aida.IHistogram1D; import hep.aida.IHistogram2D; +import hep.aida.IHistogramFactory; +import hep.aida.IPlotter; +import hep.aida.IPlotterFactory; +import hep.aida.ITree; +import hep.aida.jfree.plotter.Plotter; +import hep.aida.jfree.plotter.PlotterRegion; import hep.aida.ref.histogram.DataPoint; import java.io.FileNotFoundException; @@ -15,7 +22,6 @@ import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; - //===> import org.hps.conditions.deprecated.HPSSVTCalibrationConstants; //===> import org.hps.conditions.deprecated.SvtUtils; @@ -33,18 +39,31 @@ */ public class PedestalPlots extends Driver { + static { + hep.aida.jfree.AnalysisFactory.register(); + } + + // Plotting + private static ITree tree = null; + + // Histogram maps + private static Map<String, IPlotter> plotters = new HashMap<String, IPlotter>(); + private static Map<String, IHistogram1D> occupancyPlots = new HashMap<String, IHistogram1D>(); + private AIDA aida = AIDA.defaultInstance(); - private Map<SiSensor, IHistogram2D> hists; - private Map<SiSensor, int[]> counts; - private Map<SiSensor, double[]> means; - private Map<SiSensor, double[]> sumsqs; - private Map<SiSensor, IDataPointSet[]> plots; + List<HpsSiSensor> sensors; + private Map<HpsSiSensor, IHistogram2D> hists; + private Map<HpsSiSensor, int[]> counts; + private Map<HpsSiSensor, double[]> means; + private Map<HpsSiSensor, double[]> sumsqs; + private Map<HpsSiSensor, IDataPointSet[]> plots; private String rawTrackerHitCollectionName = "SVTRawTrackerHits"; private String fitFile = null; private boolean plotTimeSeries = false; private static final String subdetectorName = "Tracker"; - - + private int eventCount = 0; + private int eventRefreshRate = 1; + public void setFitFile(String fitFile) { this.fitFile = fitFile; } @@ -53,22 +72,34 @@ this.plotTimeSeries = plotTimeSeries; } + public void setEventRefreshRate(int eventRefreshRate) { + this.eventRefreshRate = eventRefreshRate; + } + @Override protected void detectorChanged(Detector detector) { + IAnalysisFactory analysisFactory = AIDA.defaultInstance().analysisFactory(); + IPlotterFactory plotterFactory = analysisFactory.createPlotterFactory("SVT Pedestals"); + IHistogramFactory histogramFactory = null; aida.tree().cd("/"); - hists = new HashMap<SiSensor, IHistogram2D>(); - counts = new HashMap<SiSensor, int[]>(); - means = new HashMap<SiSensor, double[]>(); - sumsqs = new HashMap<SiSensor, double[]>(); - plots = new HashMap<SiSensor, IDataPointSet[]>(); - - List<SiSensor> sensors = detector.getSubdetector(subdetectorName).getDetectorElement().findDescendants(SiSensor.class); - + hists = new HashMap<HpsSiSensor, IHistogram2D>(); + counts = new HashMap<HpsSiSensor, int[]>(); + means = new HashMap<HpsSiSensor, double[]>(); + sumsqs = new HashMap<HpsSiSensor, double[]>(); + plots = new HashMap<HpsSiSensor, IDataPointSet[]>(); + + sensors = detector.getSubdetector(subdetectorName).getDetectorElement().findDescendants(HpsSiSensor.class); + + plotters.put("Pedestal vs. channel", plotterFactory.create("Pedestal vs. channel")); + plotters.get("Pedestal vs. channel").createRegions(6, 6); + //===> for (SiSensor sensor : SvtUtils.getInstance().getSensors()) { - for (SiSensor sensor : sensors) { - hists.put(sensor, aida.histogram2D(sensor.getName() + " sample 1 vs. ch", 640, -0.5, 639.5, 500, -500.0, 3000.0)); + for (HpsSiSensor sensor : sensors) { + hists.put(sensor, aida.histogram2D(sensor.getName() + " sample 1 vs. ch", 640, -0.5, 639.5, 100, -500.0, 500.0)); + plotters.get("Pedestal vs. channel").region(SvtPlotUtils.computePlotterRegion(sensor)).plot(hists.get(sensor), SvtPlotUtils.createStyle(plotterFactory, sensor, "Channel", "Sample 1")); + if (plotTimeSeries) { counts.put(sensor, new int[640]); means.put(sensor, new double[640]); @@ -81,8 +112,16 @@ } } - - + for (IPlotter plotter : plotters.values()) { + for (int regionN = 0; regionN < plotter.numberOfRegions(); regionN++) { + PlotterRegion region = ((PlotterRegion) ((Plotter) plotter).region(regionN)); + if (region.getPlottedObjects().isEmpty()) { + continue; + } + region.getPanel().addMouseListener(new PopupPlotterListener(region)); + } + plotter.show(); + } } @Override @@ -90,12 +129,11 @@ if (event.hasCollection(RawTrackerHit.class, rawTrackerHitCollectionName)) { // Get RawTrackerHit collection from event. List<RawTrackerHit> rawTrackerHits = event.get(RawTrackerHit.class, rawTrackerHitCollectionName); - + eventCount++; for (RawTrackerHit hit : rawTrackerHits) { HpsSiSensor sensor = (HpsSiSensor) hit.getDetectorElement(); int strip = hit.getIdentifierFieldValue("strip"); double pedestal = sensor.getPedestal(strip, 0); - //===> double pedestal = HPSSVTCalibrationConstants.getPedestal(sensor, strip); hists.get(sensor).fill(strip, hit.getADCValues()[0] - pedestal); if (plotTimeSeries) { @@ -115,10 +153,52 @@ sumsqs.get(sensor)[strip] = 0; } } - } - } - } - + + } +// if (eventCount % eventRefreshRate == 0) { +// for (HpsSiSensor sensor : sensors) { +// IHistogram2D hist = hists.get(sensor); +//// hist. +// } +// } + + } + } + +// private void getMean2D(IHistogram2D hist2D) { +// int nx = hist2D.xAxis().bins(); +// int ny = hist2D.yAxis().bins(); +// double[][] means = new double[nx][ny]; +// for (int ix = 0; ix < nx; ix++) { +// for (int iy = 0; iy < ny; iy++) { +// means[ix][iy] = hist2D.binHeight(ix, iy) / hist2D.binEntries(ix, iy); +// } +// } +// hist2D.reset(); +// for (int ix = 0; ix < nx; ix++) { +// for (int iy = 0; iy < ny; iy++) { +// double x = hist2D.xAxis().binCenter(ix); +// double y = hist2D.yAxis().binCenter(iy); +// hist2D.fill(x, y, means[ix][iy]); +// } +// } +// +// IFitter fitter = AIDA.defaultInstance().analysisFactory().createFitFactory().createFitter("chi2"); +// +// } +// +// IFitResult fitGaussian(IHistogram1D h1d, IFitter fitter, String range) { +// double[] init = {h1d.maxBinHeight(), h1d.mean(), h1d.rms()}; +// IFitResult ifr = null; +// try { +// ifr = fitter.fit(h1d, "g", init, range); +// } catch (RuntimeException ex) { +// System.out.println(this.getClass().getSimpleName() + ": caught exception in fitGaussian"); +// } +// return ifr; +//// double[] init = {20.0, 0.0, 1.0, 20, -1}; +//// return fitter.fit(h1d, "g+p1", init, range); +// } @Override public void endOfData() { if (fitFile == null) { Modified: java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/PopupPlotterListener.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/PopupPlotterListener.java (original) +++ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/PopupPlotterListener.java Fri Jun 12 15:27:10 2015 @@ -7,8 +7,8 @@ import hep.aida.jfree.plotter.Plotter; import hep.aida.jfree.plotter.PlotterFactory; import hep.aida.jfree.AnalysisFactory; - import hep.aida.IHistogram; +import hep.aida.IPlotterStyle; /** * A MouseListener used to pop up a separate window with a plotter in it when @@ -21,8 +21,8 @@ */ public class PopupPlotterListener extends ChartPanelMouseListener { - PlotterRegion plotterRegion; - Plotter plotter = null; + private PlotterRegion plotterRegion = null; + private static Plotter plotter = null; IHistogram histogram; PlotterFactory plotterFactory = (PlotterFactory) AnalysisFactory.create().createPlotterFactory(); @@ -41,12 +41,45 @@ */ @Override public void mouseClicked(MouseEvent e) { - + + if (plotter == null) { + plotter = (Plotter) plotterFactory.create(); + plotter.createRegion(0); + } else { + ((PlotterRegion) plotter.region(0)).clear(); + } + histogram = ((IHistogram) plotterRegion.getPlottedObjects().get(0)); - plotter = (Plotter) plotterFactory.create(); - plotter.createRegion(); - plotter.region(0).setStyle(plotterRegion.style()); - plotter.region(0).plot(histogram); + plotter.region(0).plot(histogram, this.createStyle()); plotter.show(); } + + /** + * Create a plotter style. + * + * @return plotter style + */ + IPlotterStyle createStyle() { + + // Create a default style + IPlotterStyle style = this.plotterFactory.createPlotterStyle(); + + // Turn off the histogram grid + style.gridStyle().setVisible(false); + + // Set the style of the data + style.dataStyle().lineStyle().setVisible(false); + style.dataStyle().outlineStyle().setVisible(false); + style.dataStyle().outlineStyle().setThickness(3); + style.dataStyle().fillStyle().setVisible(true); + style.dataStyle().fillStyle().setOpacity(.30); + style.dataStyle().fillStyle().setColor("31, 137, 229, 1"); + style.dataStyle().outlineStyle().setColor("31, 137, 229, 1"); + style.dataStyle().errorBarStyle().setVisible(false); + + // Turn off the legend + style.legendBoxStyle().setVisible(false); + + return style; + } } Modified: java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SamplesPlots.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SamplesPlots.java (original) +++ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SamplesPlots.java Fri Jun 12 15:27:10 2015 @@ -11,150 +11,151 @@ import hep.aida.IPlotterFactory; import hep.aida.IPlotterStyle; -import org.lcsim.util.Driver; +import org.lcsim.util.Driver; import org.lcsim.geometry.Detector; import org.lcsim.detector.tracker.silicon.HpsSiSensor; import org.lcsim.event.EventHeader; import org.lcsim.event.RawTrackerHit; - +import org.lcsim.util.aida.AIDA; /** - * Monitoring driver that plots the raw hit samples for each of the hits - * on a sensor. - * - * @author Omar Moreno <[log in to unmask]> + * Monitoring driver that plots the raw hit samples for each of the hits on a + * sensor. + * + * @author Omar Moreno <[log in to unmask]> */ public class SamplesPlots extends Driver { // TODO: Add documentation - static { hep.aida.jfree.AnalysisFactory.register(); - } + } - static IHistogramFactory histogramFactory = IAnalysisFactory.create().createHistogramFactory(null); - IPlotterFactory plotterFactory = IAnalysisFactory.create().createPlotterFactory(); + protected Map<String, IPlotter> plotters = new HashMap<String, IPlotter>(); + protected Map<HpsSiSensor, IHistogram2D> samplesPlots = new HashMap<HpsSiSensor, IHistogram2D>(); + private List<HpsSiSensor> sensors; - protected Map<String, IPlotter> plotters = new HashMap<String, IPlotter>(); - protected Map<HpsSiSensor, IHistogram2D> samplesPlots = new HashMap<HpsSiSensor, IHistogram2D>(); - private List<HpsSiSensor> sensors; - private static final String SUBDETECTOR_NAME = "Tracker"; private String rawTrackerHitCollectionName = "SVTRawTrackerHits"; - + private int computePlotterRegion(HpsSiSensor sensor) { - if (sensor.getLayerNumber() < 7) { - if (sensor.isTopLayer()) { - return 2*(sensor.getLayerNumber() - 1); - } else { - return 2*(sensor.getLayerNumber() - 1) + 1; - } - } else { - - if (sensor.isTopLayer()) { - if (sensor.getSide() == HpsSiSensor.POSITRON_SIDE) { - return 4*(sensor.getLayerNumber() - 7); - } else { - return 4*(sensor.getLayerNumber() - 7) + 1; - } - } else if (sensor.isBottomLayer()) { - if (sensor.getSide() == HpsSiSensor.POSITRON_SIDE) { - return 4*(sensor.getLayerNumber() - 7) + 2; - } else { - return 4*(sensor.getLayerNumber() - 7) + 3; - } - } - } - - return -1; + if (sensor.getLayerNumber() < 7) { + if (sensor.isTopLayer()) { + return 2 * (sensor.getLayerNumber() - 1); + } else { + return 2 * (sensor.getLayerNumber() - 1) + 1; + } + } else { + + if (sensor.isTopLayer()) { + if (sensor.getSide() == HpsSiSensor.POSITRON_SIDE) { + return 4 * (sensor.getLayerNumber() - 7); + } else { + return 4 * (sensor.getLayerNumber() - 7) + 1; + } + } else if (sensor.isBottomLayer()) { + if (sensor.getSide() == HpsSiSensor.POSITRON_SIDE) { + return 4 * (sensor.getLayerNumber() - 7) + 2; + } else { + return 4 * (sensor.getLayerNumber() - 7) + 3; + } + } + } + + return -1; } - + protected void detectorChanged(Detector detector) { - - sensors - = detector.getSubdetector(SUBDETECTOR_NAME).getDetectorElement().findDescendants(HpsSiSensor.class); - + IAnalysisFactory analysisFactory = AIDA.defaultInstance().analysisFactory(); + IPlotterFactory plotterFactory = analysisFactory.createPlotterFactory("SVT Raw Samples"); + IHistogramFactory histogramFactory = AIDA.defaultInstance().histogramFactory(); + + sensors + = detector.getSubdetector(SUBDETECTOR_NAME).getDetectorElement().findDescendants(HpsSiSensor.class); + if (sensors.size() == 0) { throw new RuntimeException("No sensors were found in this detector."); } - + plotters.put("L1-L3 Raw hit samples", plotterFactory.create("L1-L3 Raw hit samples")); plotters.get("L1-L3 Raw hit samples").createRegions(6, 2); - + plotters.put("L4-L6 Raw hit samples", plotterFactory.create("L4-L6 Raw hit samples")); plotters.get("L4-L6 Raw hit samples").createRegions(6, 4); - for (HpsSiSensor sensor : sensors) { - - samplesPlots.put(sensor, - histogramFactory.createHistogram2D(sensor.getName() + " - Samples", 6, 0, 6, 1000, 1000, 7000)); - + for (HpsSiSensor sensor : sensors) { + + samplesPlots.put(sensor, + histogramFactory.createHistogram2D(sensor.getName() + " - Samples", 6, 0, 6, 1000, -200.0, 3000)); + if (sensor.getLayerNumber() < 7) { plotters.get("L1-L3 Raw hit samples").region(this.computePlotterRegion(sensor)) - .plot(samplesPlots.get(sensor), this.createStyle("Sample Number", "Amplitude [ADC Counts]")); - } else { + .plot(samplesPlots.get(sensor), this.createStyle(plotterFactory, "Sample Number", "Amplitude [ADC Counts]")); + } else { plotters.get("L4-L6 Raw hit samples").region(this.computePlotterRegion(sensor)) - .plot(samplesPlots.get(sensor), this.createStyle("Sample Number", "Amplitude [ADC Counts]")); + .plot(samplesPlots.get(sensor), this.createStyle(plotterFactory, "Sample Number", "Amplitude [ADC Counts]")); } } - - for (IPlotter plotter : plotters.values()) { - plotter.show(); - } + + for (IPlotter plotter : plotters.values()) { + plotter.show(); + } } public void process(EventHeader event) { - - if (!event.hasCollection(RawTrackerHit.class, rawTrackerHitCollectionName)) - return; - + + if (!event.hasCollection(RawTrackerHit.class, rawTrackerHitCollectionName)) { + return; + } + // Get RawTrackerHit collection from event. List<RawTrackerHit> rawHits = event.get(RawTrackerHit.class, rawTrackerHitCollectionName); - - for (RawTrackerHit rawHit : rawHits) { - - HpsSiSensor sensor = (HpsSiSensor) rawHit.getDetectorElement(); - short[] adcValues = rawHit.getADCValues(); - - for (int sampleN = 0; sampleN < 6; sampleN++) { - samplesPlots.get(sensor).fill(sampleN, adcValues[sampleN]); - } - } + + for (RawTrackerHit rawHit : rawHits) { + + HpsSiSensor sensor = (HpsSiSensor) rawHit.getDetectorElement(); + short[] adcValues = rawHit.getADCValues(); + int strip = rawHit.getIdentifierFieldValue("strip"); + double pedestal = sensor.getPedestal(strip, 0); + for (int sampleN = 0; sampleN < 6; sampleN++) { + samplesPlots.get(sensor).fill(sampleN, adcValues[sampleN] - pedestal); + } + } } - - IPlotterStyle createStyle(String xAxisTitle, String yAxisTitle) { - + + IPlotterStyle createStyle(IPlotterFactory plotterFactory, String xAxisTitle, String yAxisTitle) { + // Create a default style - IPlotterStyle style = this.plotterFactory.createPlotterStyle(); - + IPlotterStyle style = plotterFactory.createPlotterStyle(); + // Set the style of the X axis style.xAxisStyle().setLabel(xAxisTitle); style.xAxisStyle().labelStyle().setFontSize(14); style.xAxisStyle().setVisible(true); - + // Set the style of the Y axis style.yAxisStyle().setLabel(yAxisTitle); style.yAxisStyle().labelStyle().setFontSize(14); style.yAxisStyle().setVisible(true); - + // Set the z axis to log scale style.zAxisStyle().setScaling("log"); - + // Turn off the histogram grid style.gridStyle().setVisible(false); - + // Set the style of the data style.dataStyle().lineStyle().setVisible(false); style.dataStyle().outlineStyle().setVisible(false); style.dataStyle().outlineStyle().setThickness(3); style.dataStyle().fillStyle().setVisible(false); style.dataStyle().errorBarStyle().setVisible(false); - + // Turn off the legend style.legendBoxStyle().setVisible(true); - + return style; } - + } Modified: java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SensorOccupancyPlotsDriver.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SensorOccupancyPlotsDriver.java (original) +++ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SensorOccupancyPlotsDriver.java Fri Jun 12 15:27:10 2015 @@ -1,5 +1,4 @@ package org.hps.monitoring.drivers.svt; - import java.io.IOException; import java.util.HashMap; @@ -11,61 +10,105 @@ import hep.aida.IHistogramFactory; import hep.aida.IPlotter; import hep.aida.IPlotterFactory; +import hep.aida.IPlotterRegion; import hep.aida.IPlotterStyle; import hep.aida.ITree; -import hep.aida.ref.rootwriter.RootFileStore; import hep.aida.jfree.plotter.Plotter; import hep.aida.jfree.plotter.PlotterRegion; - +import hep.aida.ref.rootwriter.RootFileStore; import hep.physics.vec.Hep3Vector; +import java.util.HashSet; +import java.util.Set; +import org.hps.monitoring.subsys.StatusCode; +import org.hps.monitoring.subsys.Subsystem; +import org.hps.monitoring.subsys.SystemStatus; +import org.hps.monitoring.subsys.SystemStatusImpl; import org.lcsim.detector.tracker.silicon.HpsSiSensor; import org.lcsim.detector.tracker.silicon.ChargeCarrier; import org.lcsim.detector.tracker.silicon.SiStrips; import org.lcsim.detector.ITransform3D; import org.lcsim.event.EventHeader; +import org.lcsim.event.GenericObject; import org.lcsim.event.RawTrackerHit; import org.lcsim.geometry.Detector; import org.lcsim.util.Driver; +import org.hps.recon.ecal.triggerbank.AbstractIntData; +import org.hps.recon.ecal.triggerbank.TIData; +import org.lcsim.util.aida.AIDA; + /** - * This Driver makes plots of sensor occupancies across a run. It is intended to - * be used with the monitoring system. - * + * This Driver makes plots of SVT sensor occupancies across a run. + * * @author Omar Moreno <[log in to unmask]> */ public class SensorOccupancyPlotsDriver extends Driver { // TODO: Add documentation - static { + static { hep.aida.jfree.AnalysisFactory.register(); - } - - ITree tree; - IHistogramFactory histogramFactory; - IPlotterFactory plotterFactory = IAnalysisFactory.create().createPlotterFactory(); - - protected Map<String, IPlotter> plotters = new HashMap<String, IPlotter>(); - protected Map<HpsSiSensor, IHistogram1D> occupancyPlots = new HashMap<HpsSiSensor, IHistogram1D>(); - protected Map<HpsSiSensor, IHistogram1D> occupancyVPositionPlots = new HashMap<HpsSiSensor, IHistogram1D>(); - protected Map<HpsSiSensor, int[]> occupancyMap = new HashMap<HpsSiSensor, int[]>(); + } + + // Plotting + private static ITree tree = null; + private IAnalysisFactory analysisFactory = AIDA.defaultInstance().analysisFactory(); + private IPlotterFactory plotterFactory = analysisFactory.createPlotterFactory("SVT Occupancy"); + private IHistogramFactory histogramFactory = null; + + // Histogram maps + private static Map<String, IPlotter> plotters = new HashMap<String, IPlotter>(); + private static Map<String, IHistogram1D> occupancyPlots = new HashMap<String, IHistogram1D>(); + private static Map<String, IHistogram1D> positionPlots = new HashMap<String, IHistogram1D>(); + private static Map<String, int[]> occupancyMap = new HashMap<String, int[]>(); + private static Map<String, IHistogram1D> maxSamplePositionPlots = new HashMap<String, IHistogram1D>(); + private List<HpsSiSensor> sensors; - private Map<HpsSiSensor, Map<Integer, Hep3Vector>> stripPositions = new HashMap<HpsSiSensor, Map<Integer, Hep3Vector>>(); + private Map<HpsSiSensor, Map<Integer, Hep3Vector>> stripPositions = new HashMap<HpsSiSensor, Map<Integer, Hep3Vector>>(); private static final String SUBDETECTOR_NAME = "Tracker"; private String rawTrackerHitCollectionName = "SVTRawTrackerHits"; - + private String triggerBankCollectionName = "TriggerBank"; + String rootFile = null; private int maxSamplePosition = -1; - private int timeWindowWeight = 1; + private int timeWindowWeight = 1; private int eventCount = 0; private int eventRefreshRate = 1; private int runNumber = -1; - + private int resetPeriod = -1; + private boolean enablePositionPlots = false; - + private boolean enableMaxSamplePlots = false; + private boolean enableTriggerFilter = false; + private boolean filterPulserTriggers = false; + private boolean filterSingle0Triggers = false; + private boolean filterSingle1Triggers = false; + private boolean filterPair0Triggers = false; + private boolean filterPair1Triggers = false; + + SystemStatus maxSampleStatus; + private int maxSampleMonitorStart = 1000; + private int maxSampleMonitorPeriod = 100; + + SystemStatus occupancyStatus; + private int occupancyMonitorStart = 5000; + private int occupancyMonitorPeriod = 100; + private double minPeakOccupancy = 0.0001; + private double maxPeakOccupancy = 0.01; + + private boolean dropSmallHitEvents = true; + public SensorOccupancyPlotsDriver() { + maxSampleStatus = new SystemStatusImpl(Subsystem.SVT, "Checks that SVT is timed in (max sample plot)", true); + maxSampleStatus.setStatus(StatusCode.UNKNOWN, "Status is unknown."); + occupancyStatus = new SystemStatusImpl(Subsystem.SVT, "Checks SVT occupancy", true); + occupancyStatus.setStatus(StatusCode.UNKNOWN, "Status is unknown."); + } + + public void setDropSmallHitEvents(boolean dropSmallHitEvents) { + this.dropSmallHitEvents = dropSmallHitEvents; } public void setRawTrackerHitCollectionName(String rawTrackerHitCollectionName) { @@ -75,227 +118,585 @@ public void setEventRefreshRate(int eventRefreshRate) { this.eventRefreshRate = eventRefreshRate; } - - public void setEnablePositionPlots(boolean enablePositionPlots) { - this.enablePositionPlots = enablePositionPlots; - } - - public void setMaxSamplePosition(int maxSamplePosition) { + + public void setResetPeriod(int resetPeriod) { + this.resetPeriod = resetPeriod; + } + + public void setEnablePositionPlots(boolean enablePositionPlots) { + this.enablePositionPlots = enablePositionPlots; + } + + public void setEnableMaxSamplePlots(boolean enableMaxSamplePlots) { + this.enableMaxSamplePlots = enableMaxSamplePlots; + } + + public void setEnableTriggerFilter(boolean enableTriggerFilter) { + this.enableTriggerFilter = enableTriggerFilter; + } + + public void setFilterPulserTriggers(boolean filterPulserTriggers) { + this.filterPulserTriggers = filterPulserTriggers; + } + + public void setFilterSingle0Triggers(boolean filterSingle0Triggers) { + this.filterSingle0Triggers = filterSingle0Triggers; + } + + public void setFilterSingle1Triggers(boolean filterSingle1Triggers) { + this.filterSingle1Triggers = filterSingle1Triggers; + } + + public void setFilterPair0Triggers(boolean filterPair0Triggers) { + this.filterPair0Triggers = filterPair0Triggers; + } + + public void setFilterPair1Triggers(boolean filterPair1Triggers) { + this.filterPair1Triggers = filterPair1Triggers; + } + + public void setMaxSamplePosition(int maxSamplePosition) { this.maxSamplePosition = maxSamplePosition; } - - public void setTimeWindowWeight(int timeWindowWeight) { - this.timeWindowWeight = timeWindowWeight; - } - - private int computePlotterRegion(HpsSiSensor sensor) { - - if (sensor.getLayerNumber() < 7) { - if (sensor.isTopLayer()) { - return 6 * (sensor.getLayerNumber() - 1); - } else { - return 6 * (sensor.getLayerNumber() - 1) + 1; - } + + public void setTimeWindowWeight(int timeWindowWeight) { + this.timeWindowWeight = timeWindowWeight; + } + + public void setMaxSampleMonitorStart(int maxSampleMonitorStart) { + this.maxSampleMonitorStart = maxSampleMonitorStart; + } + + public void setMaxSampleMonitorPeriod(int maxSampleMonitorPeriod) { + this.maxSampleMonitorPeriod = maxSampleMonitorPeriod; + } + + public void setOccupancyMonitorStart(int occupancyMonitorStart) { + this.occupancyMonitorStart = occupancyMonitorStart; + } + + public void setOccupancyMonitorPeriod(int occupancyMonitorPeriod) { + this.occupancyMonitorPeriod = occupancyMonitorPeriod; + } + + public void setMinPeakOccupancy(double minPeakOccupancy) { + this.minPeakOccupancy = minPeakOccupancy; + } + + public void setMaxPeakOccupancy(double maxPeakOccupancy) { + this.maxPeakOccupancy = maxPeakOccupancy; + } + + /** + * Get the global strip position of a physical channel number for a given + * sensor. + * + * @param sensor : HpsSiSensor + * @param physicalChannel : physical channel number + * @return The strip position (mm) in the global coordinate system + */ + private Hep3Vector getStripPosition(HpsSiSensor sensor, int physicalChannel) { + return stripPositions.get(sensor).get(physicalChannel); + } + + /** + * For each sensor, create a mapping between a physical channel number and + * it's global strip position. + */ + // TODO: Move this to a utility class + private void createStripPositionMap() { + for (HpsSiSensor sensor : sensors) { + stripPositions.put(sensor, createStripPositionMap(sensor)); + } + } + + public static Map<Integer, Hep3Vector> createStripPositionMap(HpsSiSensor sensor) { + Map<Integer, Hep3Vector> positionMap = new HashMap<Integer, Hep3Vector>(); + for (ChargeCarrier carrier : ChargeCarrier.values()) { + if (sensor.hasElectrodesOnSide(carrier)) { + SiStrips strips = (SiStrips) sensor.getReadoutElectrodes(carrier); + ITransform3D parentToLocal = sensor.getReadoutElectrodes(carrier).getParentToLocal(); + ITransform3D localToGlobal = sensor.getReadoutElectrodes(carrier).getLocalToGlobal(); + for (int physicalChannel = 0; physicalChannel < 640; physicalChannel++) { + Hep3Vector localStripPosition = strips.getCellPosition(physicalChannel); + Hep3Vector stripPosition = parentToLocal.transformed(localStripPosition); + Hep3Vector globalStripPosition = localToGlobal.transformed(stripPosition); + positionMap.put(physicalChannel, globalStripPosition); + } + } + } + return positionMap; + } + + /** + * Create a plotter style. + * + * @param xAxisTitle : Title of the x axis + * @param sensor : HpsSiSensor associated with the plot. This is used to set + * certain attributes based on the position of the sensor. + * @return plotter style + */ + // TODO: Move this to a utilities class + IPlotterStyle createOccupancyPlotStyle(String xAxisTitle, HpsSiSensor sensor, boolean isAlarming) { + // Create a default style + IPlotterStyle style = this.plotterFactory.createPlotterStyle(); + + // Set the style of the X axis + style.xAxisStyle().setLabel(xAxisTitle); + style.xAxisStyle().labelStyle().setFontSize(14); + style.xAxisStyle().setVisible(true); + + // Set the style of the Y axis + style.yAxisStyle().setLabel("Occupancy"); + style.yAxisStyle().labelStyle().setFontSize(14); + style.yAxisStyle().setVisible(true); + + // Turn off the histogram grid + style.gridStyle().setVisible(false); + + // Set the style of the data + style.dataStyle().lineStyle().setVisible(false); + style.dataStyle().outlineStyle().setVisible(false); + style.dataStyle().outlineStyle().setThickness(3); + style.dataStyle().fillStyle().setVisible(true); + style.dataStyle().fillStyle().setOpacity(.30); + if (sensor.isTopLayer()) { + style.dataStyle().fillStyle().setColor("31, 137, 229, 1"); + style.dataStyle().outlineStyle().setColor("31, 137, 229, 1"); } else { - - if (sensor.isTopLayer()) { - if (sensor.getSide() == HpsSiSensor.POSITRON_SIDE) { - return 6 * (sensor.getLayerNumber() - 7) + 2; - } else { - return 6 * (sensor.getLayerNumber() - 7) + 3; - } - } else if (sensor.isBottomLayer()) { - if (sensor.getSide() == HpsSiSensor.POSITRON_SIDE) { - return 6 * (sensor.getLayerNumber() - 7) + 4; - } else { - return 6 * (sensor.getLayerNumber() - 7) + 5; - } - } - } - - return -1; - } - + style.dataStyle().fillStyle().setColor("93, 228, 47, 1"); + style.dataStyle().outlineStyle().setColor("93, 228, 47, 1"); + } + style.dataStyle().errorBarStyle().setVisible(false); + + // Turn off the legend + style.legendBoxStyle().setVisible(false); + + style.regionBoxStyle().backgroundStyle().setOpacity(.20); + setBackgroundColor(style, sensor.isAxial(), isAlarming); + + return style; + } + + private void setBackgroundColor(IPlotterStyle style, boolean isAxial, boolean isAlarming) { + if (isAlarming) { + style.regionBoxStyle().backgroundStyle().setColor("246, 34, 34, 1"); + return; + } + if (isAxial) { + style.regionBoxStyle().backgroundStyle().setColor("246, 246, 34, 1"); + } + } + + /** + * Clear all histograms of it's current data. + */ + private void resetPlots() { + + // Clear the hit counter map of all previously stored data. + occupancyMap.clear(); + + // Since all plots are mapped to the name of a sensor, loop + // through the sensors, get the corresponding plots and clear them. + for (HpsSiSensor sensor : sensors) { + + // Clear the occupancy plots. + occupancyPlots.get(sensor.getName()).reset(); + + if (enablePositionPlots) { + positionPlots.get(sensor.getName()).reset(); + } + + if (enableMaxSamplePlots) { + maxSamplePositionPlots.get(sensor.getName()).reset(); + } + + // Reset the hit counters. + occupancyMap.put(sensor.getName(), new int[640]); + } + } + + private static int getLayerNumber(HpsSiSensor sensor) { + return (int) Math.ceil(((double) sensor.getLayerNumber()) / 2); + } + + @Override protected void detectorChanged(Detector detector) { + // Get the HpsSiSensor objects from the geometry sensors = detector.getSubdetector(SUBDETECTOR_NAME).getDetectorElement().findDescendants(HpsSiSensor.class); - if (sensors.size() == 0) { + // If there were no sensors found, throw an exception + if (sensors.isEmpty()) { throw new RuntimeException("There are no sensors associated with this detector"); } - - // Create a Map from sensor to bad channels and from bad channels to - // strip position - for(ChargeCarrier carrier : ChargeCarrier.values()){ - for(HpsSiSensor sensor : sensors){ - //System.out.println("HpsSiSensor: " + sensor.toString()); - if(sensor.hasElectrodesOnSide(carrier)){ - stripPositions.put(sensor, new HashMap<Integer, Hep3Vector>()); - SiStrips strips = (SiStrips) sensor.getReadoutElectrodes(carrier); - ITransform3D parentToLocal = sensor.getReadoutElectrodes(carrier).getParentToLocal(); - ITransform3D localToGlobal = sensor.getReadoutElectrodes(carrier).getLocalToGlobal(); - for(int physicalChannel = 0; physicalChannel < 640; physicalChannel++){ - Hep3Vector localStripPosition = strips.getCellPosition(physicalChannel); - Hep3Vector stripPosition = parentToLocal.transformed(localStripPosition); - Hep3Vector globalStripPosition = localToGlobal.transformed(stripPosition); - //System.out.println("Channel: " + physicalChannel + " localStripPosition: " + localStripPosition.toString()); - //System.out.println("Channel: " + physicalChannel + " stripPosition: " + stripPosition.toString()); - //System.out.println("Channel: " + physicalChannel + " globalStripPosition: " + globalStripPosition.toString()); - stripPositions.get(sensor).put(physicalChannel, globalStripPosition); - } - } - } - } - - tree = IAnalysisFactory.create().createTreeFactory().create(); - histogramFactory = IAnalysisFactory.create().createHistogramFactory(tree); - + + // For each sensor, create a mapping between a physical channel number + // and the global strip position + this.createStripPositionMap(); + +// // If the tree already exist, clear all existing plots of any old data +// // they might contain. +// if (tree != null) { +// this.resetPlots(); +// return; +// } + tree = analysisFactory.createTreeFactory().create(); + histogramFactory = analysisFactory.createHistogramFactory(tree); + + // Create the plotter and regions. A region is created for each + // sensor for a total of 36. plotters.put("Occupancy", plotterFactory.create("Occupancy")); plotters.get("Occupancy").createRegions(6, 6); - if (enablePositionPlots) { + occupancyStatus.setStatus(StatusCode.UNKNOWN, "Not enough statistics yet."); + + if (enablePositionPlots) { plotters.put("Occupancy vs Position", plotterFactory.create("Occupancy vs Position")); plotters.get("Occupancy vs Position").createRegions(6, 6); } - + + if (enableMaxSamplePlots) { + plotters.put("Max Sample Number", plotterFactory.create("Max Sample Number")); + plotters.get("Max Sample Number").createRegions(6, 6); + maxSampleStatus.setStatus(StatusCode.UNKNOWN, "Not enough statistics yet."); + } else { + maxSampleStatus.setStatus(StatusCode.UNKNOWN, "Monitor disabled in steering file."); + } + for (HpsSiSensor sensor : sensors) { - occupancyPlots.put(sensor, histogramFactory.createHistogram1D(sensor.getName() + " - Occupancy", 640, 0, 640)); - plotters.get("Occupancy").region(this.computePlotterRegion(sensor)) - .plot(occupancyPlots.get(sensor), this.createOccupancyPlotStyle(sensor)); - + occupancyPlots.put(sensor.getName(), histogramFactory.createHistogram1D(sensor.getName() + " - Occupancy", 640, 0, 640)); + plotters.get("Occupancy").region(SvtPlotUtils.computePlotterRegion(sensor)) + .plot(occupancyPlots.get(sensor.getName()), this.createOccupancyPlotStyle("Physical Channel", sensor, false)); + if (enablePositionPlots) { - occupancyVPositionPlots.put(sensor, histogramFactory.createHistogram1D(sensor.getName() + " - Occupancy vs Position", 1000, 0, 60)); - plotters.get("Occupancy vs Position").region(this.computePlotterRegion(sensor)) - .plot(occupancyVPositionPlots.get(sensor), this.createOccupancyPlotStyle(sensor)); - } - - occupancyMap.put(sensor, new int[640]); + if (sensor.isTopLayer()) { + positionPlots.put(sensor.getName(), + histogramFactory.createHistogram1D(sensor.getName() + " - Occupancy vs Position", 1000, 0, 60)); + } else { + positionPlots.put(sensor.getName(), + histogramFactory.createHistogram1D(sensor.getName() + " - Occupancy vs Position", 1000, -60, 0)); + } + + plotters.get("Occupancy vs Position").region(SvtPlotUtils.computePlotterRegion(sensor)) + .plot(positionPlots.get(sensor.getName()), this.createOccupancyPlotStyle("Distance from Beam [mm]", sensor, false)); + } + occupancyMap.put(sensor.getName(), new int[640]); + + if (enableMaxSamplePlots) { + maxSamplePositionPlots.put(sensor.getName(), histogramFactory.createHistogram1D(sensor.getName() + " - Max Sample Number", 6, 0, 6)); + plotters.get("Max Sample Number").region(SvtPlotUtils.computePlotterRegion(sensor)) + .plot(maxSamplePositionPlots.get(sensor.getName()), + this.createOccupancyPlotStyle("Max Sample Number", sensor, false)); + } } for (IPlotter plotter : plotters.values()) { - for (int regionN = 0; regionN < 36; regionN++) { + for (int regionN = 0; regionN < plotter.numberOfRegions(); regionN++) { PlotterRegion region = ((PlotterRegion) ((Plotter) plotter).region(regionN)); + if (region.getPlottedObjects().isEmpty()) { + continue; + } region.getPanel().addMouseListener(new PopupPlotterListener(region)); } plotter.show(); } } + private boolean passTriggerFilter(List<GenericObject> triggerBanks) { + + // Loop through the collection of banks and get the TI banks. + for (GenericObject triggerBank : triggerBanks) { + + // If the bank contains TI data, process it + if (AbstractIntData.getTag(triggerBank) == TIData.BANK_TAG) { + + TIData tiData = new TIData(triggerBank); + + if (filterPulserTriggers && tiData.isPulserTrigger()) { + return false; + } else if (filterSingle0Triggers && tiData.isSingle0Trigger()) { + return false; + } else if (filterSingle1Triggers && tiData.isSingle1Trigger()) { + return false; + } else if (filterPair0Triggers && tiData.isPair0Trigger()) { + return false; + } else if (filterPair1Triggers && tiData.isPair1Trigger()) { + return false; + } + } + } + return true; + } + + @Override public void process(EventHeader event) { - if (runNumber == -1) runNumber = event.getRunNumber(); - - if (!event.hasCollection(RawTrackerHit.class, rawTrackerHitCollectionName)) + // Get the run number from the event and store it. This will be used + // when writing the plots out to a ROOT file + if (runNumber == -1) { + runNumber = event.getRunNumber(); + } + + if (enableTriggerFilter && event.hasCollection(GenericObject.class, triggerBankCollectionName)) { + + // Get the list of trigger banks from the event + List<GenericObject> triggerBanks = event.get(GenericObject.class, triggerBankCollectionName); + + // Apply the trigger filter + if (!passTriggerFilter(triggerBanks)) { + return; + } + } + + // If the event doesn't have a collection of RawTrackerHit's, skip it. + if (!event.hasCollection(RawTrackerHit.class, rawTrackerHitCollectionName)) { return; - - eventCount++; - + } // Get RawTrackerHit collection from event. List<RawTrackerHit> rawHits = event.get(RawTrackerHit.class, rawTrackerHitCollectionName); + if (dropSmallHitEvents && SvtPlotUtils.countSmallHits(rawHits) > 3) { + return; + } + + if (resetPeriod > 0 && eventCount > resetPeriod) { //reset occupancy numbers after resetPeriod events + eventCount = 0; + resetPlots(); + } + + eventCount++; + // Increment strip hit count. for (RawTrackerHit rawHit : rawHits) { - + // Obtain the raw ADC samples for each of the six samples readout short[] adcValues = rawHit.getADCValues(); - + // Find the sample that has the largest amplitude. This should // correspond to the peak of the shaper signal if the SVT is timed // in correctly. Otherwise, the maximum sample value will default // to 0. int maxAmplitude = 0; int maxSamplePositionFound = -1; - for (int sampleN = 0; sampleN < 6; sampleN++) { - if (adcValues[sampleN] > maxAmplitude) { + for (int sampleN = 0; sampleN < 6; sampleN++) { + if (adcValues[sampleN] > maxAmplitude) { maxAmplitude = adcValues[sampleN]; - maxSamplePositionFound = sampleN; - } - } - - if (maxSamplePosition == -1 || maxSamplePosition == maxSamplePositionFound) { - occupancyMap.get((HpsSiSensor) rawHit.getDetectorElement())[rawHit.getIdentifierFieldValue("strip")]++; - } + maxSamplePositionFound = sampleN; + } + } + + if (maxSamplePosition == -1 || maxSamplePosition == maxSamplePositionFound) { + occupancyMap.get(((HpsSiSensor) rawHit.getDetectorElement()).getName())[rawHit.getIdentifierFieldValue("strip")]++; + } + + if (enableMaxSamplePlots) { + maxSamplePositionPlots.get(((HpsSiSensor) rawHit.getDetectorElement()).getName()).fill(maxSamplePositionFound); + } + } + + if (enableMaxSamplePlots && eventCount > maxSampleMonitorStart && eventCount % maxSampleMonitorPeriod == 0) { + checkMaxSample(); + } + + if (eventCount > occupancyMonitorStart && eventCount % occupancyMonitorPeriod == 0) { + checkOccupancy(); } // Plot strip occupancies. if (eventCount % eventRefreshRate == 0) { for (HpsSiSensor sensor : sensors) { - int[] strips = occupancyMap.get(sensor); - occupancyPlots.get(sensor).reset(); - if (enablePositionPlots) occupancyVPositionPlots.get(sensor).reset(); + int[] strips = occupancyMap.get(sensor.getName()); + occupancyPlots.get(sensor.getName()).reset(); + if (enablePositionPlots) { + positionPlots.get(sensor.getName()).reset(); + } for (int channel = 0; channel < strips.length; channel++) { double stripOccupancy = (double) strips[channel] / (double) eventCount; stripOccupancy /= this.timeWindowWeight; - occupancyPlots.get(sensor).fill(channel, stripOccupancy); - + occupancyPlots.get(sensor.getName()).fill(channel, stripOccupancy); + if (enablePositionPlots) { double stripPosition = this.getStripPosition(sensor, channel).y(); - stripPosition = Math.abs(stripPosition); - occupancyVPositionPlots.get(sensor).fill(stripPosition, stripOccupancy); + positionPlots.get(sensor.getName()).fill(stripPosition, stripOccupancy); } } } } - } - - public void endOfData() { - + + if (plotters.get("Occupancy") != null) { + plotters.get("Occupancy").refresh(); + } + } + + private void checkMaxSample() { + StatusCode oldStatus = maxSampleStatus.getStatusCode(); + boolean isSystemOK = true; + for (HpsSiSensor sensor : sensors) { + IHistogram1D maxSamplePlot = maxSamplePositionPlots.get(sensor.getName()); + IPlotterRegion region = plotters.get("Max Sample Number").region(SvtPlotUtils.computePlotterRegion(sensor)); + + boolean isSensorOK = maxSamplePlot.binEntries(maxSamplePosition) > maxSamplePlot.binEntries(maxSamplePosition - 1) + && maxSamplePlot.binEntries(maxSamplePosition) > maxSamplePlot.binEntries(maxSamplePosition + 1); + if (!isSensorOK) { + isSystemOK = false; + if (oldStatus != StatusCode.ALARM) { + maxSampleStatus.setStatus(StatusCode.ALARM, "Sensor " + sensor.getName() + " looks out of time."); + } + IPlotterStyle plotterStyle = createOccupancyPlotStyle("Max Sample Number", sensor, true); +// region.clear(); +// region.plot(maxSamplePlot, plotterStyle); + region.applyStyle(plotterStyle); +// region.style().regionBoxStyle().backgroundStyle().setColor("246, 34, 34, 1"); +// setBackgroundColor(region.style(),sensor.isAxial(),true); + + } else { + IPlotterStyle plotterStyle = createOccupancyPlotStyle("Max Sample Number", sensor, false); +// region.clear(); +// region.plot(maxSamplePlot, plotterStyle); + region.applyStyle(plotterStyle); +// setBackgroundColor(region.style(),sensor.isAxial(),false); + } + } + if (isSystemOK) { + if (oldStatus != StatusCode.OKAY) { + maxSampleStatus.setStatus(StatusCode.OKAY, "All sensors are timed in."); + } + } + } + + private void checkOccupancy() { + StatusCode oldStatus = occupancyStatus.getStatusCode(); + boolean isSystemOK = true; + for (HpsSiSensor sensor : sensors) { + IHistogram1D occupancyPlot = occupancyPlots.get(sensor.getName()); + IPlotterRegion region = plotters.get("Occupancy").region(SvtPlotUtils.computePlotterRegion(sensor)); + + double apvOccupancy[] = new double[5]; + for (int i = 0; i < occupancyPlot.axis().bins(); i++) { + apvOccupancy[i / 128] += occupancyPlot.binHeight(i); + } + for (int i = 0; i < 5; i++) { + apvOccupancy[i] /= 128.0; + } + + boolean isSensorOK = isOccupancyOK(apvOccupancy); + if (!isSensorOK) { + System.out.format("%s: %f %f %f %f %f\n", sensor.getName(), apvOccupancy[0], apvOccupancy[1], apvOccupancy[2], apvOccupancy[3], apvOccupancy[4]); + isSystemOK = false; + if (oldStatus != StatusCode.ALARM) { + occupancyStatus.setStatus(StatusCode.ALARM, "Sensor " + sensor.getName() + " occupancy abnormal."); + } + IPlotterStyle plotterStyle = createOccupancyPlotStyle("Max Sample Number", sensor, true); +// region.clear(); +// region.plot(occupancyPlot, plotterStyle); + region.applyStyle(plotterStyle); + + } else { + IPlotterStyle plotterStyle = createOccupancyPlotStyle("Max Sample Number", sensor, false); +// region.clear(); +// region.plot(occupancyPlot, plotterStyle); + region.applyStyle(plotterStyle); + } + } + if (isSystemOK) { + if (oldStatus != StatusCode.OKAY) { + occupancyStatus.setStatus(StatusCode.OKAY, "Occupancy looks OK."); + } + } + } + + private boolean isOccupancyOK(double[] apvOccupancy) { + double peakOccupancy = 0; + int highestApv = -1; + for (int i = 0; i < 5; i++) { + if (apvOccupancy[i] > peakOccupancy) { + peakOccupancy = apvOccupancy[i]; + highestApv = i; + } + } + if (highestApv != 0 && highestApv != 4) { + System.out.println("peak occupancy not at edge"); + return false; + } + if (peakOccupancy > maxPeakOccupancy || peakOccupancy < minPeakOccupancy) { + System.out.println("peak occupancy out of range"); + return false; + } + if (highestApv == 0) { + for (int i = 4; i > 0; i--) { + if (apvOccupancy[i] < 0.1 * peakOccupancy || apvOccupancy[i] < minPeakOccupancy) { + continue; //skip through the tail end of the sensor + } + if (0.9 * apvOccupancy[i] > apvOccupancy[i - 1]) { + System.out.println("occupancy not monotonic"); + return false; + } + } + } else if (highestApv == 4) { + for (int i = 0; i < 4; i++) { + if (apvOccupancy[i] < 0.1 * peakOccupancy || apvOccupancy[i] < minPeakOccupancy) { + continue; //skip through the tail end of the sensor + } + if (0.9 * apvOccupancy[i] > apvOccupancy[i + 1]) { + System.out.println("occupancy not monotonic"); + return false; + } + } + } + + return true; + } + + @Override + public void endOfData() { + rootFile = "run" + runNumber + "_occupancy.root"; RootFileStore store = new RootFileStore(rootFile); try { store.open(); store.add(tree); - store.close(); + store.close(); } catch (IOException e) { e.printStackTrace(); } - } - - /** - * . - */ - private Hep3Vector getStripPosition(HpsSiSensor sensor, int physicalChannel){ - return stripPositions.get(sensor).get(physicalChannel); - } - - IPlotterStyle createOccupancyPlotStyle(HpsSiSensor sensor) { - // Create a default style - IPlotterStyle style = this.plotterFactory.createPlotterStyle(); - - // Set the style of the X axis - style.xAxisStyle().setLabel("Channel"); - style.xAxisStyle().labelStyle().setFontSize(14); - style.xAxisStyle().setVisible(true); - - // Set the style of the Y axis - style.yAxisStyle().setLabel("Occupancy"); - style.yAxisStyle().labelStyle().setFontSize(14); - style.yAxisStyle().setVisible(true); - - // Turn off the histogram grid - style.gridStyle().setVisible(false); - - // Set the style of the data - style.dataStyle().lineStyle().setVisible(false); - style.dataStyle().outlineStyle().setVisible(true); - style.dataStyle().outlineStyle().setThickness(3); - style.dataStyle().fillStyle().setVisible(true); - style.dataStyle().fillStyle().setOpacity(.10); - if (sensor.isTopLayer()) { - style.dataStyle().fillStyle().setColor("31, 137, 229, 1"); - style.dataStyle().outlineStyle().setColor("31, 137, 229, 1"); - } else { - style.dataStyle().fillStyle().setColor("93, 228, 47, 1"); - style.dataStyle().outlineStyle().setColor("93, 228, 47, 1"); - } - style.dataStyle().errorBarStyle().setVisible(false); - - // Turn off the legend - style.legendBoxStyle().setVisible(false); - - style.regionBoxStyle().backgroundStyle().setOpacity(.10); - if (sensor.isAxial()) style.regionBoxStyle().backgroundStyle().setColor("229, 114, 31, 1"); - - return style; + + System.out.println("%===============================================================================%"); + System.out.println("%======================== Active Edge Sensor Occupancies =======================%"); + System.out.println("%===============================================================================%"); + System.out.println("% Total Events: " + eventCount); + // Calculate the occupancies at the sensor edge + int[] topActiveEdgeStripOccupancy = new int[6]; + int[] bottomActiveEdgeStripOccupancy = new int[6]; + for (HpsSiSensor sensor : sensors) { + if (sensor.isTopLayer() && sensor.isAxial()) { + if (sensor.getSide().equals(HpsSiSensor.ELECTRON_SIDE)) { + System.out.println("% Top Layer " + getLayerNumber(sensor) + " Hit Counts: " + occupancyMap.get(sensor.getName())[1]); + topActiveEdgeStripOccupancy[getLayerNumber(sensor) - 1] += occupancyMap.get(sensor.getName())[1]; + } else { + System.out.println("% Top Layer " + getLayerNumber(sensor) + " Hit Counts: " + occupancyMap.get(sensor.getName())[638]); + topActiveEdgeStripOccupancy[getLayerNumber(sensor) - 1] += occupancyMap.get(sensor.getName())[638]; + } + } else if (sensor.isBottomLayer() && sensor.isAxial()) { + if (sensor.getSide().equals(HpsSiSensor.ELECTRON_SIDE)) { + System.out.println("% Bottom Layer " + getLayerNumber(sensor) + " Hit Counts: " + occupancyMap.get(sensor.getName())[1]); + bottomActiveEdgeStripOccupancy[getLayerNumber(sensor) - 1] += occupancyMap.get(sensor.getName())[1]; + } else { + System.out.println("% Bottom Layer " + getLayerNumber(sensor) + " Hit Counts: " + occupancyMap.get(sensor.getName())[638]); + bottomActiveEdgeStripOccupancy[getLayerNumber(sensor) - 1] += occupancyMap.get(sensor.getName())[638]; + } + } + } + + for (int layerN = 0; layerN < 6; layerN++) { + double topStripOccupancy = (double) topActiveEdgeStripOccupancy[layerN] / (double) eventCount; + topStripOccupancy /= this.timeWindowWeight; + System.out.println("% Top Layer " + (layerN + 1) + ": Occupancy in " + (24 / this.timeWindowWeight) + " ns window: " + topStripOccupancy); + double botStripOccupancy = (double) bottomActiveEdgeStripOccupancy[layerN] / (double) eventCount; + botStripOccupancy /= this.timeWindowWeight; + System.out.println("% Bottom Layer " + (layerN + 1) + ": Occupancy in " + (24 / this.timeWindowWeight) + " ns window: " + botStripOccupancy); + } + System.out.println("%===============================================================================%"); + System.out.println("%===============================================================================%"); } } Modified: java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SvtHitPlots.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SvtHitPlots.java (original) +++ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/svt/SvtHitPlots.java Fri Jun 12 15:27:10 2015 @@ -6,248 +6,300 @@ import hep.aida.IPlotter; import hep.aida.IPlotterFactory; import hep.aida.IPlotterStyle; +import hep.aida.ITree; +import hep.aida.jfree.plotter.Plotter; +import hep.aida.jfree.plotter.PlotterRegion; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import org.lcsim.detector.tracker.silicon.HpsSiSensor; -import org.lcsim.util.Driver; +import org.lcsim.util.Driver; import org.lcsim.geometry.Detector; import org.lcsim.event.EventHeader; import org.lcsim.event.RawTrackerHit; +import org.lcsim.util.aida.AIDA; /** - * Monitoring driver that provides information about the number - * of SVT hits per event. - * - * @author Omar Moreno <[log in to unmask]> + * Monitoring driver that provides information about the number of SVT hits per + * event. + * + * @author Omar Moreno <[log in to unmask]> */ public class SvtHitPlots extends Driver { // TODO: Add documentation - static { hep.aida.jfree.AnalysisFactory.register(); - } - - static IHistogramFactory histogramFactory = IAnalysisFactory.create().createHistogramFactory(null); - IPlotterFactory plotterFactory = IAnalysisFactory.create().createPlotterFactory(); - - protected Map<String, IPlotter> plotters = new HashMap<String, IPlotter>(); + } + + // Plotting + private static ITree tree = null; + private IAnalysisFactory analysisFactory = AIDA.defaultInstance().analysisFactory(); + private IPlotterFactory plotterFactory = analysisFactory.createPlotterFactory("SVT Hits"); + private IHistogramFactory histogramFactory = null; + protected Map<String, IPlotter> plotters = new HashMap<String, IPlotter>(); + + // Histogram Maps + private static Map<String, IHistogram1D> hitsPerSensorPlots = new HashMap<String, IHistogram1D>(); + private static Map<String, int[]> hitsPerSensor = new HashMap<String, int[]>(); + private static Map<String, IHistogram1D> layersHitPlots = new HashMap<String, IHistogram1D>(); + private static Map<String, IHistogram1D> hitCountPlots = new HashMap<String, IHistogram1D>(); + private static Map<String, IHistogram1D> firstSamplePlots = new HashMap<String, IHistogram1D>(); + private List<HpsSiSensor> sensors; - protected Map<HpsSiSensor, IHistogram1D> hitsPerSensorPlots = new HashMap<HpsSiSensor, IHistogram1D>(); - protected Map<HpsSiSensor, int[]> hitsPerSensor = new HashMap<HpsSiSensor, int[]>(); - protected Map<String, IHistogram1D> layersHitPlots = new HashMap<String, IHistogram1D>(); - protected Map<String, IHistogram1D> hitCountPlots = new HashMap<String, IHistogram1D>(); - + private static final String SUBDETECTOR_NAME = "Tracker"; private String rawTrackerHitCollectionName = "SVTRawTrackerHits"; - + // Counters double eventCount = 0; - double totalHitCount = 0; - double totalTopHitCount = 0; - double totalBotHitCount = 0; + double totalHitCount = 0; + double totalTopHitCount = 0; + double totalBotHitCount = 0; + + private boolean dropSmallHitEvents = true; + + public void setDropSmallHitEvents(boolean dropSmallHitEvents) { + this.dropSmallHitEvents = dropSmallHitEvents; + } private int computePlotterRegion(HpsSiSensor sensor) { - if (sensor.getLayerNumber() < 7) { - if (sensor.isTopLayer()) { - return 6*(sensor.getLayerNumber() - 1); - } else { - return 6*(sensor.getLayerNumber() - 1) + 1; - } - } else { - - if (sensor.isTopLayer()) { - if (sensor.getSide() == HpsSiSensor.POSITRON_SIDE) { - return 6*(sensor.getLayerNumber() - 7) + 2; - } else { - return 6*(sensor.getLayerNumber() - 7) + 3; - } - } else if (sensor.isBottomLayer()) { - if (sensor.getSide() == HpsSiSensor.POSITRON_SIDE) { - return 6*(sensor.getLayerNumber() - 7) + 4; - } else { - return 6*(sensor.getLayerNumber() - 7) + 5; - } - } - } - - return -1; - } - - private void clearHitMaps() { - for (HpsSiSensor sensor : sensors) { - hitsPerSensor.get(sensor)[0] = 0; - } + if (sensor.getLayerNumber() < 7) { + if (sensor.isTopLayer()) { + return 6 * (sensor.getLayerNumber() - 1); + } else { + return 6 * (sensor.getLayerNumber() - 1) + 1; + } + } else { + + if (sensor.isTopLayer()) { + if (sensor.getSide() == HpsSiSensor.POSITRON_SIDE) { + return 6 * (sensor.getLayerNumber() - 7) + 2; + } else { + return 6 * (sensor.getLayerNumber() - 7) + 3; + } + } else if (sensor.isBottomLayer()) { + if (sensor.getSide() == HpsSiSensor.POSITRON_SIDE) { + return 6 * (sensor.getLayerNumber() - 7) + 4; + } else { + return 6 * (sensor.getLayerNumber() - 7) + 5; + } + } + } + return -1; + } + + /** + * Create a plotter style. + * + * @param sensor : HpsSiSensor associated with the plot. This is used to set + * certain attributes based on the position of the sensor. + * @param xAxisTitle : Title of the x axis + * @param yAxisTitle : Title of the y axis + * @return plotter style + */ + // TODO: Move this to a utilities class + IPlotterStyle createStyle(HpsSiSensor sensor, String xAxisTitle, String yAxisTitle) { + IPlotterStyle style = SvtPlotUtils.createStyle(plotterFactory, xAxisTitle, yAxisTitle); + + if (sensor.isTopLayer()) { + style.dataStyle().fillStyle().setColor("31, 137, 229, 1"); + style.dataStyle().outlineStyle().setColor("31, 137, 229, 1"); + } else { + style.dataStyle().fillStyle().setColor("93, 228, 47, 1"); + style.dataStyle().outlineStyle().setColor("93, 228, 47, 1"); + } + + return style; + } + + private void clearHitMaps() { + for (HpsSiSensor sensor : sensors) { + hitsPerSensor.get(sensor.getName())[0] = 0; + } + } + + /** + * Clear all histograms of it's current data. + */ + private void resetPlots() { + + // Reset all hit maps + this.clearHitMaps(); + + // Since all plots are mapped to the name of a sensor, loop + // through the sensors, get the corresponding plots and clear them. + for (HpsSiSensor sensor : sensors) { + hitsPerSensorPlots.get(sensor.getName()).reset(); + firstSamplePlots.get(sensor.getName()).reset(); + } + + for (IHistogram1D histogram : layersHitPlots.values()) { + histogram.reset(); + } + + for (IHistogram1D histogram : hitCountPlots.values()) { + histogram.reset(); + } + } protected void detectorChanged(Detector detector) { - sensors - = detector.getSubdetector(SUBDETECTOR_NAME).getDetectorElement().findDescendants(HpsSiSensor.class); - + // Get the HpsSiSensor objects from the geometry + sensors = detector.getSubdetector(SUBDETECTOR_NAME).getDetectorElement().findDescendants(HpsSiSensor.class); + if (sensors.size() == 0) { throw new RuntimeException("No sensors were found in this detector."); } - - plotters.put("Raw hits per sensor", plotterFactory.create("Raw hits per sensor")); - plotters.get("Raw hits per sensor").createRegions(6,6); - - for (HpsSiSensor sensor : sensors) { - hitsPerSensorPlots.put(sensor, - histogramFactory.createHistogram1D(sensor.getName() + " - Raw Hits", 25, 0, 25)); - plotters.get("Raw hits per sensor").region(this.computePlotterRegion(sensor)) - .plot(hitsPerSensorPlots.get(sensor), this.createStyle(sensor, "Number of Raw Hits", "")); - hitsPerSensor.put(sensor, new int[1]); - } - - plotters.put("Number of layers hit", plotterFactory.create("Number of layers hit")); - plotters.get("Number of layers hit").createRegions(1,2); - - layersHitPlots.put("Top", - histogramFactory.createHistogram1D("Top Layers Hit", 12, 0, 12)); - plotters.get("Number of layers hit").region(0).plot(layersHitPlots.get("Top"), this.createStyle("Number of Top Layers Hit","")); - layersHitPlots.put("Bottom", - histogramFactory.createHistogram1D("Bottom Layers Hit", 12, 0, 12)); - plotters.get("Number of layers hit").region(1).plot(layersHitPlots.get("Bottom"), this.createStyle("Number of Bottom Layers Hit","")); - - plotters.put("Raw hit counts/Event", plotterFactory.create("Raw hit counts/Event")); - plotters.get("Raw hit counts/Event").createRegions(2, 2); - - hitCountPlots.put("Raw hit counts/Event", - histogramFactory.createHistogram1D("Raw hit counts", 100, 0, 100)); - plotters.get("Raw hit counts/Event").region(0).plot(hitCountPlots.get("Raw hit counts/Event"), this.createStyle("Number of Raw Hits", "")); - hitCountPlots.put("SVT top raw hit counts/Event", - histogramFactory.createHistogram1D("SVT top raw hit counts", 100, 0, 100)); - plotters.get("Raw hit counts/Event").region(1).plot(hitCountPlots.get("SVT top raw hit counts/Event"), this.createStyle("Number of Raw Hits in Top Volume", "")); - hitCountPlots.put("SVT bottom raw hit counts/Event", - histogramFactory.createHistogram1D("SVT bottom raw hit counts", 100, 0, 100)); - plotters.get("Raw hit counts/Event").region(2).plot(hitCountPlots.get("SVT bottom raw hit counts/Event"), this.createStyle("Number of Raw Bits in the Bottom Volume", "")); - - for (IPlotter plotter : plotters.values()) { - plotter.show(); - } - } - + +// // If the tree already exist, clear all existing plots of any old data +// // they might contain. +// if (tree != null) { +// this.resetPlots(); +// return; +// } + tree = analysisFactory.createTreeFactory().create(); + histogramFactory = analysisFactory.createHistogramFactory(tree); + + plotters.put("Raw hits per sensor", plotterFactory.create("Raw hits per sensor")); + plotters.get("Raw hits per sensor").createRegions(6, 6); + + for (HpsSiSensor sensor : sensors) { + hitsPerSensorPlots.put(sensor.getName(), + histogramFactory.createHistogram1D(sensor.getName() + " - Raw Hits", 25, 0, 25)); + plotters.get("Raw hits per sensor").region(SvtPlotUtils.computePlotterRegion(sensor)) + .plot(hitsPerSensorPlots.get(sensor.getName()), this.createStyle(sensor, "Number of Raw Hits", "")); + hitsPerSensor.put(sensor.getName(), new int[1]); + } + + plotters.put("Number of layers hit", plotterFactory.create("Number of layers hit")); + plotters.get("Number of layers hit").createRegions(1, 2); + + layersHitPlots.put("Top", + histogramFactory.createHistogram1D("Top Layers Hit", 12, 0, 12)); + plotters.get("Number of layers hit").region(0).plot(layersHitPlots.get("Top"), SvtPlotUtils.createStyle(plotterFactory, "Number of Top Layers Hit", "")); + layersHitPlots.put("Bottom", + histogramFactory.createHistogram1D("Bottom Layers Hit", 12, 0, 12)); + plotters.get("Number of layers hit").region(1).plot(layersHitPlots.get("Bottom"), SvtPlotUtils.createStyle(plotterFactory, "Number of Bottom Layers Hit", "")); + + plotters.put("Raw hit counts/Event", plotterFactory.create("Raw hit counts/Event")); + plotters.get("Raw hit counts/Event").createRegions(2, 2); + + hitCountPlots.put("Raw hit counts/Event", + histogramFactory.createHistogram1D("Raw hit counts", 100, 0, 100)); + plotters.get("Raw hit counts/Event").region(0).plot(hitCountPlots.get("Raw hit counts/Event"), SvtPlotUtils.createStyle(plotterFactory, "Number of Raw Hits", "")); + hitCountPlots.put("SVT top raw hit counts/Event", + histogramFactory.createHistogram1D("SVT top raw hit counts", 100, 0, 100)); + plotters.get("Raw hit counts/Event").region(2).plot(hitCountPlots.get("SVT top raw hit counts/Event"), SvtPlotUtils.createStyle(plotterFactory, "Number of Raw Hits in Top Volume", "")); + hitCountPlots.put("SVT bottom raw hit counts/Event", + histogramFactory.createHistogram1D("SVT bottom raw hit counts", 100, 0, 100)); + plotters.get("Raw hit counts/Event").region(3).plot(hitCountPlots.get("SVT bottom raw hit counts/Event"), SvtPlotUtils.createStyle(plotterFactory, "Number of Raw Bits in the Bottom Volume", "")); + + plotters.put("First sample distributions (pedestal shifts)", plotterFactory.create("First sample distributions (pedestal shifts)")); + plotters.get("First sample distributions (pedestal shifts)").createRegions(6, 6); + for (HpsSiSensor sensor : sensors) { + firstSamplePlots.put(sensor.getName(), + histogramFactory.createHistogram1D(sensor.getName() + " - first sample", 100, -500.0, 2000.0)); + plotters.get("First sample distributions (pedestal shifts)").region(this.computePlotterRegion(sensor)) + .plot(firstSamplePlots.get(sensor.getName()), this.createStyle(sensor, "First sample - pedestal [ADC counts]", "")); + } + + for (IPlotter plotter : plotters.values()) { + for (int regionN = 0; regionN < plotter.numberOfRegions(); regionN++) { + PlotterRegion region = ((PlotterRegion) ((Plotter) plotter).region(regionN)); + if (region.getPlottedObjects().size() == 0) { + continue; + } + region.getPanel().addMouseListener(new PopupPlotterListener(region)); + } + plotter.show(); + } + } + public void process(EventHeader event) { - - if (!event.hasCollection(RawTrackerHit.class, rawTrackerHitCollectionName)) - return; - - eventCount++; - + + if (!event.hasCollection(RawTrackerHit.class, rawTrackerHitCollectionName)) { + return; + } + + eventCount++; + // Get RawTrackerHit collection from event. List<RawTrackerHit> rawHits = event.get(RawTrackerHit.class, rawTrackerHitCollectionName); - + + if (dropSmallHitEvents && SvtPlotUtils.countSmallHits(rawHits) > 3) { + return; + } + this.clearHitMaps(); - for (RawTrackerHit rawHit : rawHits) { + for (RawTrackerHit rawHit : rawHits) { HpsSiSensor sensor = (HpsSiSensor) rawHit.getDetectorElement(); - hitsPerSensor.get(sensor)[0]++; - } - + hitsPerSensor.get(sensor.getName())[0]++; + firstSamplePlots.get(sensor.getName()).fill(rawHit.getADCValues()[0] - sensor.getPedestal(rawHit.getIdentifierFieldValue("strip"), 0)); + } + int[] topLayersHit = new int[12]; - int[] botLayersHit = new int[12]; + int[] botLayersHit = new int[12]; int eventHitCount = 0; int topEventHitCount = 0; int botEventHitCount = 0; - for (HpsSiSensor sensor : sensors) { - int hitCount = hitsPerSensor.get(sensor)[0]; - hitsPerSensorPlots.get(sensor).fill(hitCount); - + for (HpsSiSensor sensor : sensors) { + int hitCount = hitsPerSensor.get(sensor.getName())[0]; + hitsPerSensorPlots.get(sensor.getName()).fill(hitCount); + eventHitCount += hitCount; - - if (hitsPerSensor.get(sensor)[0] > 0) { - if (sensor.isTopLayer()) { + + if (hitsPerSensor.get(sensor.getName())[0] > 0) { + if (sensor.isTopLayer()) { topLayersHit[sensor.getLayerNumber() - 1]++; topEventHitCount += hitCount; - } - else { - botLayersHit[sensor.getLayerNumber() - 1]++; + } else { + botLayersHit[sensor.getLayerNumber() - 1]++; botEventHitCount += hitCount; } } } - - totalHitCount += eventHitCount; - totalTopHitCount += topEventHitCount; + + totalHitCount += eventHitCount; + totalTopHitCount += topEventHitCount; totalBotHitCount += botEventHitCount; - + hitCountPlots.get("Raw hit counts/Event").fill(eventHitCount); hitCountPlots.get("SVT top raw hit counts/Event").fill(topEventHitCount); hitCountPlots.get("SVT bottom raw hit counts/Event").fill(botEventHitCount); - - int totalTopLayersHit = 0; - int totalBotLayersHit = 0; - for(int layerN = 0; layerN < 12; layerN++) { - if (topLayersHit[layerN] > 0) totalTopLayersHit++; - if (botLayersHit[layerN] > 0) totalBotLayersHit++; - } - + + int totalTopLayersHit = 0; + int totalBotLayersHit = 0; + for (int layerN = 0; layerN < 12; layerN++) { + if (topLayersHit[layerN] > 0) { + totalTopLayersHit++; + } + if (botLayersHit[layerN] > 0) { + totalBotLayersHit++; + } + } + layersHitPlots.get("Top").fill(totalTopLayersHit); layersHitPlots.get("Bottom").fill(totalBotLayersHit); - - } - + + } + @Override protected void endOfData() { - + System.out.println("%================================================%"); System.out.println("%============ SVT Raw Hit Statistics ============%"); System.out.println("%================================================%\n%"); - System.out.println("% Total Hits/Event: " + totalHitCount/eventCount); - System.out.println("% Total Top SVT Hits/Event: " + totalTopHitCount/eventCount); - System.out.println("% Total Bottom SVT Hits/Event: " + totalBotHitCount/eventCount); + System.out.println("% Total Hits/Event: " + totalHitCount / eventCount); + System.out.println("% Total Top SVT Hits/Event: " + totalTopHitCount / eventCount); + System.out.println("% Total Bottom SVT Hits/Event: " + totalBotHitCount / eventCount); System.out.println("\n%================================================%"); } - - IPlotterStyle createStyle(String xAxisTitle, String yAxisTitle) { - - // Create a default style - IPlotterStyle style = this.plotterFactory.createPlotterStyle(); - - // Set the style of the X axis - style.xAxisStyle().setLabel(xAxisTitle); - style.xAxisStyle().labelStyle().setFontSize(14); - style.xAxisStyle().setVisible(true); - - // Set the style of the Y axis - style.yAxisStyle().setLabel(yAxisTitle); - style.yAxisStyle().labelStyle().setFontSize(14); - style.yAxisStyle().setVisible(true); - - // Turn off the histogram grid - style.gridStyle().setVisible(false); - - // Set the style of the data - style.dataStyle().lineStyle().setVisible(false); - style.dataStyle().outlineStyle().setVisible(false); - style.dataStyle().outlineStyle().setThickness(3); - style.dataStyle().fillStyle().setVisible(true); - style.dataStyle().fillStyle().setOpacity(.30); - style.dataStyle().fillStyle().setColor("31, 137, 229, 1"); - style.dataStyle().outlineStyle().setColor("31, 137, 229, 1"); - style.dataStyle().errorBarStyle().setVisible(false); - - // Turn off the legend - style.legendBoxStyle().setVisible(false); - - return style; - } - - IPlotterStyle createStyle(HpsSiSensor sensor, String xAxisTitle, String yAxisTitle) { - IPlotterStyle style = this.createStyle(xAxisTitle, yAxisTitle); - - if (sensor.isTopLayer()) { - style.dataStyle().fillStyle().setColor("31, 137, 229, 1"); - style.dataStyle().outlineStyle().setColor("31, 137, 229, 1"); - } else { - style.dataStyle().fillStyle().setColor("93, 228, 47, 1"); - style.dataStyle().outlineStyle().setColor("93, 228, 47, 1"); - } - - return style; - } + } Modified: java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackTimePlots.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackTimePlots.java (original) +++ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackTimePlots.java Fri Jun 12 15:27:10 2015 @@ -48,11 +48,12 @@ private IHistogram2D[] trackTimeMinMax = new IHistogram2D[4]; private static final String subdetectorName = "Tracker"; - int nlayers=12; - - public void setTrackCollectionName(String name){ - this.trackCollectionName=name; - } + int nlayers = 12; + + public void setTrackCollectionName(String name) { + this.trackCollectionName = name; + } + @Override protected void detectorChanged(Detector detector) { @@ -70,14 +71,13 @@ //style2d.zAxisStyle().setParameter("scale", "log"); style2d.zAxisStyle().setVisible(false); style2d.dataBoxStyle().setVisible(false); - - + IPlotterStyle styleOverlay = store.getStyle("DefaultHistogram1DStyle"); styleOverlay.dataStyle().errorBarStyle().setVisible(true); - styleOverlay.dataStyle().fillStyle().setVisible(false); + styleOverlay.dataStyle().fillStyle().setVisible(false); styleOverlay.legendBoxStyle().setVisible(false); styleOverlay.dataStyle().outlineStyle().setVisible(false); - + plotter = fac.create("Hit Times"); plotter.createRegions(3, 4); @@ -110,16 +110,14 @@ plot(plotter3, trackHitT0[module][layer], styleOverlay, region); trackHitDt[module][layer] = aida.histogram1D(sensor.getName() + "_trackHit_dt", 50, -20, 20.0); plot(plotter4, trackHitDt[module][layer], styleOverlay, region); - - } - - - - for (int i=0; i<nlayers;i++) { - int region = computePlotterRegion(i); - trackHit2D[i] = aida.histogram2D("Layer "+i+" trackHit vs dt", 75, -50, 100.0, 50, -20, 20.0); + + } + + for (int i = 0; i < nlayers; i++) { + int region = computePlotterRegion(i); + trackHit2D[i] = aida.histogram2D("Layer " + i + " trackHit vs dt", 75, -50, 100.0, 50, -20, 20.0); plot(plotter5, trackHit2D[i], style2d, region); - trackHitDtChan[i] = aida.histogram2D("Layer "+i+" dt vs position", 200, -20, 20, 50, -20, 20.0); + trackHitDtChan[i] = aida.histogram2D("Layer " + i + " dt vs position", 200, -20, 20, 50, -20, 20.0); plot(plotter6, trackHitDtChan[i], style2d, region); } plotter.show(); @@ -131,7 +129,7 @@ for (int module = 0; module < 2; module++) { trackT0[module] = aida.histogram1D((module == 0 ? "Top" : "Bottom") + " Track Time", 75, -50, 100.0); plot(plotter2, trackT0[module], null, module); - trackTrigTime[module] = aida.histogram2D((module == 0 ? "Top" : "Bottom") + " Track Time vs. Trig Time", 75, -50, 100.0, 33, -1, 32); + trackTrigTime[module] = aida.histogram2D((module == 0 ? "Top" : "Bottom") + " Track Time vs. Trig Time", 75, -50, 100.0, 6, -2, 22); plot(plotter2, trackTrigTime[module], style2d, module + 2); trackTimeRange[module] = aida.histogram1D((module == 0 ? "Top" : "Bottom") + " Track Hit Time Range", 75, 0, 30.0); @@ -148,47 +146,9 @@ this.hitCollection = hitCollection; } - - @Override public void process(EventHeader event) { - int orTrig = 0; - int topTrig = 0; - int botTrig = 0; - - int orTrigTime = -1; - int topTrigTime = -1; - int botTrigTime = -1; - if (event.hasCollection(GenericObject.class, "TriggerBank")) { - List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank"); - for (GenericObject data : triggerList) - if (AbstractIntData.getTag(data) == TestRunTriggerData.BANK_TAG) { - TestRunTriggerData triggerData = new TestRunTriggerData(data); - - orTrig = triggerData.getOrTrig(); - if (orTrig != 0) - for (int i = 0; i < 32; i++) - if ((1 << (31 - i) & orTrig) != 0) { - orTrigTime = i; - break; - } - topTrig = triggerData.getTopTrig(); - if (topTrig != 0) - for (int i = 0; i < 32; i++) - if ((1 << (31 - i) & topTrig) != 0) { - topTrigTime = i; - break; - } - botTrig = triggerData.getBotTrig(); - if (botTrig != 0) - for (int i = 0; i < 32; i++) - if ((1 << (31 - i) & botTrig) != 0) { - botTrigTime = i; - break; - } - break; - } - } + int trigTime = (int) (event.getTimeStamp() % 24); //===> IIdentifierHelper helper = SvtUtils.getInstance().getHelper(); List<SiTrackerHitStrip1D> hits = event.get(SiTrackerHitStrip1D.class, hitCollection); @@ -206,40 +166,46 @@ List<Track> tracks = event.get(Track.class, trackCollectionName); for (Track track : tracks) { int trackModule = -1; - if (track.getTrackerHits().get(0).getPosition()[2] > 0) + if (track.getTrackerHits().get(0).getPosition()[2] > 0) { trackModule = 0; - else + } else { trackModule = 1; + } double minTime = Double.POSITIVE_INFINITY; double maxTime = Double.NEGATIVE_INFINITY; int hitCount = 0; double trackTime = 0; - for (TrackerHit hitCross : track.getTrackerHits()) + for (TrackerHit hitCross : track.getTrackerHits()) { for (HelicalTrackStrip hit : ((HelicalTrackCross) hitCross).getStrips()) { int layer = hit.layer(); trackHitT0[trackModule][layer - 1].fill(hit.dEdx() / DopedSilicon.ENERGY_EHPAIR); trackTime += hit.time(); hitCount++; - if (hit.time() > maxTime) + if (hit.time() > maxTime) { maxTime = hit.time(); - if (hit.time() < minTime) + } + if (hit.time() < minTime) { minTime = hit.time(); + } } + } trackTimeMinMax[trackModule].fill(minTime, maxTime); trackTimeRange[trackModule].fill(maxTime - minTime); trackTime /= hitCount; trackT0[trackModule].fill(trackTime); - if (trackModule == 0) - trackTrigTime[trackModule].fill(trackTime, topTrigTime); - else - trackTrigTime[trackModule].fill(trackTime, botTrigTime); - for (TrackerHit hitCross : track.getTrackerHits()) + if (trackModule == 0) { + trackTrigTime[trackModule].fill(trackTime, trigTime); + } else { + trackTrigTime[trackModule].fill(trackTime, trigTime); + } + for (TrackerHit hitCross : track.getTrackerHits()) { for (HelicalTrackStrip hit : ((HelicalTrackCross) hitCross).getStrips()) { int layer = hit.layer(); trackHitDt[trackModule][layer - 1].fill(hit.time() - trackTime); trackHit2D[layer - 1].fill(trackTime, hit.time() - trackTime); trackHitDtChan[layer - 1].fill(hit.umeas(), hit.time() - trackTime); } + } } } @@ -264,42 +230,57 @@ //and assume plotter is split in 3 columns, 4 rows...L0-5 on top 2 rows; L6-11 on bottom 2 private int computePlotterRegion(int layer) { - if (layer == 0) + if (layer == 0) { return 0; - if (layer == 1) + } + if (layer == 1) { return 1; - if (layer == 2) + } + if (layer == 2) { return 4; - if (layer == 3) + } + if (layer == 3) { return 5; - if (layer == 4) + } + if (layer == 4) { return 8; - if (layer == 5) + } + if (layer == 5) { return 9; - - if (layer == 6) + } + + if (layer == 6) { return 2; - if (layer == 7) + } + if (layer == 7) { return 3; - if (layer == 8) + } + if (layer == 8) { return 6; - if (layer == 9) + } + if (layer == 9) { return 7; - if (layer == 10) + } + if (layer == 10) { return 10; - if (layer == 11) + } + if (layer == 11) { return 11; + } return -1; } - - private String getColor(int module){ - String color="Black"; - if(module==1) - color="Green"; - if(module==2) - color="Blue"; - if(module==3) - color="Red"; + + private String getColor(int module) { + String color = "Black"; + if (module == 1) { + color = "Green"; + } + if (module == 2) { + color = "Blue"; + } + if (module == 3) { + color = "Red"; + } return color; } } Modified: java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackingReconPlots.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackingReconPlots.java (original) +++ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/drivers/trackrecon/TrackingReconPlots.java Fri Jun 12 15:27:10 2015 @@ -163,8 +163,8 @@ for (int i = 1; i <= nmodules; i++) { - xvsyTop[i - 1] = aida.histogram2D("Module " + i + " Top", 50, -10, 10, 50, 0, 4); - xvsyBot[i - 1] = aida.histogram2D("Module " + i + " Bottom", 50, -10, 10, 50, 0, 4); + xvsyTop[i - 1] = aida.histogram2D("Module " + i + " Top", 100, -100, 150, 55, 0, 55); + xvsyBot[i - 1] = aida.histogram2D("Module " + i + " Bottom", 100, -100, 150, 55, 0, 55); hthTop[i - 1] = aida.histogram1D("Module " + i + "Top: Track Hits", 25, 0, 25); hthBot[i - 1] = aida.histogram1D("Module " + i + "Bot: Track Hits", 25, 0, 25); plot(plotterHTH, hthTop[i - 1], null, computePlotterRegion(i - 1, true)); @@ -225,10 +225,10 @@ if (hit.getPosition()[1] > 0) { topHits[module - 1]++; - xvsyTop[module - 1].fill(hit.getPosition()[0], hit.getPosition()[0]); + xvsyTop[module - 1].fill(hit.getPosition()[0], hit.getPosition()[1]); } else { botHits[module - 1]++; - xvsyBot[module - 1].fill(hit.getPosition()[0], Math.abs(hit.getPosition()[0])); + xvsyBot[module - 1].fill(hit.getPosition()[0], -1*hit.getPosition()[1]); } } Modified: java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalHitPlots.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalHitPlots.java (original) +++ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalHitPlots.java Fri Jun 12 15:27:10 2015 @@ -189,10 +189,13 @@ if (!triggerList.isEmpty()) { GenericObject triggerData = triggerList.get(0); - if (triggerData instanceof SSPData){ - orTrigTime=((SSPData)triggerData).getOrTrig(); - topTrigTime=((SSPData)triggerData).getTopTrig(); - botTrigTime =((SSPData)triggerData).getBotTrig(); + if (triggerData instanceof SSPData){ + // TODO: TOP, BOTTOM, OR, and AND triggers are test + // run specific parameters and are not supported + // by SSPData. + orTrigTime = 0; //((SSPData)triggerData).getOrTrig(); + topTrigTime = 0; //((SSPData)triggerData).getTopTrig(); + botTrigTime = 0; //((SSPData)triggerData).getBotTrig(); orTrigTimePlot.fill(orTrigTime); Modified: java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalLedSequenceMonitor.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalLedSequenceMonitor.java (original) +++ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalLedSequenceMonitor.java Fri Jun 12 15:27:10 2015 @@ -128,7 +128,7 @@ private IPlotterStyle style ; private int[] fitStatus = new int[NUM_CHANNELS]; - private boolean doEmbedded=true; + private boolean doFullAnalysis=false; private boolean isMonitoringApp=false; private double[] fPars; @@ -188,8 +188,8 @@ this.isMonitoringApp=app; } - public void setDoEmbedded(boolean embedded){ - this.doEmbedded=embedded; + public void setDoFullAnalysis(boolean fullAnalysis){ + this.doFullAnalysis=fullAnalysis; } @Override @@ -241,7 +241,7 @@ factory= aida.analysisFactory().createPlotterFactory("Ecal Led Sequence"); pPlotter= factory.create("Drivers"); pPlotter.createRegions(4,2); - if (doEmbedded){ + if (isMonitoringApp){ pPlotter2=factory.create("Sequence Map"); pPlotter2.createRegions(1,1); pPlotter2.region(0).plot(hMeanCharge2D); @@ -258,8 +258,6 @@ int row = EcalMonitoringUtilities.getRowFromHistoID(ii); int column = EcalMonitoringUtilities.getColumnFromHistoID(ii); iTuple.add(aida.analysisFactory().createTupleFactory(aida.tree()).create("nTuple"+ii,"nTuple"+ii,"int fEvn=0 , double fCharge=0.,double fTime=0.","")); - - } for (int ii=0;ii<nDrivers;ii++){ @@ -268,7 +266,7 @@ } pPlotter.show(); - if (doEmbedded) pPlotter2.show(); + if (isMonitoringApp) pPlotter2.show(); } @@ -297,7 +295,6 @@ fillTime = hit.getTime(); - //find the LED if (row>0){ ledid=LedTopMap.get(chid); @@ -308,6 +305,8 @@ driverid=getDriver(ledid); if (row<0) driverid+=4; + + /*Skip the events under thr*/ if (energy<energyCut) continue; @@ -386,9 +385,10 @@ eMax=-9999; row = EcalMonitoringUtilities.getRowFromHistoID(id); column = EcalMonitoringUtilities.getColumnFromHistoID(id); + System.out.println(""); System.out.println("Doing channel: X= "+column+" Y= "+row); + System.out.println("Number of entries in analysis ntuple: "+iTuple.get(id).rows()); System.out.println("Number of recognized events: "+nEvents[id]); - System.out.println("Number of entries in analysis ntuple: "+iTuple.get(id).rows()); /*Create the profile. Create it for all the channels, to keep sync.*/ nBins=nEvents[id]/100; if (nBins<=0) nBins=1; @@ -408,13 +408,14 @@ fFunction1=fFactory.createFunctionByName("fun1","G"); if (EcalMonitoringUtilities.isInHole(row,column)==true){ + System.out.println("Channel X= "+column+" Y= "+row+" is in hole. Skip"); hCharge.add(aida.histogram1D("charge_"+id,200,0.,1.)); //create here the histogram to keep sync System.out.println("In hole, skip"); continue; } else if (nEvents[id]<nEventsMin) { hCharge.add(aida.histogram1D("charge_"+id,200,0.,1.)); //create here the histogram to keep sync - System.err.println("LedAnalysis:: the channel X= "+column+" Y= "+row+" has not enough"); + System.err.println("LedAnalysis:: the channel X= "+column+" Y= "+row+" has not enough events "+nEvents[id]+" "+nEventsMin); continue; } @@ -438,7 +439,7 @@ } fFitter=aida.analysisFactory().createFitFactory().createFitter("chi2","","v"); - if (!isMonitoringApp){ + if (doFullAnalysis){ //Init function parameters double[] initialPars={eMax-eMin,nEvents[id]/10.,eMin}; if (initialPars[0]<0) initialPars[0]=0; @@ -541,7 +542,7 @@ - if ((pPlotter2!=null)&&(doEmbedded)){ + if ((pPlotter2!=null)&&(isMonitoringApp)){ style = pPlotter2.region(0).style(); style.setParameter("hist2DStyle", "colorMap"); style.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); Modified: java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringPlots.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringPlots.java (original) +++ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringPlots.java Fri Jun 12 15:27:10 2015 @@ -166,10 +166,10 @@ //System.out.println("Event: "+thisEventN+" "+prevEventN); //System.out.println("Time: "+thisEventTime+" "+prevEventTime); // System.out.println("Monitor: "+thisTime+" "+prevTime+" "+NoccupancyFill); - +if (scale>0) { hitCountFillPlot.scale(scale); clusterCountFillPlot.scale(scale); - redraw(); + redraw();} prevTime=thisTime; prevEventN=thisEventN; prevEventTime=thisEventTime; @@ -188,14 +188,14 @@ hitCountDrawPlot.add(hitCountFillPlot); plotter.region(0).clear(); plotter.region(0).plot(hitCountDrawPlot); - plotter.region(0).refresh(); +// plotter.region(0).refresh(); hitCountFillPlot.reset(); clusterCountDrawPlot.reset(); clusterCountDrawPlot.add(clusterCountFillPlot); plotter.region(1).clear(); plotter.region(1).plot(clusterCountDrawPlot); - plotter.region(1).refresh(); +// plotter.region(1).refresh(); clusterCountFillPlot.reset(); occupancyDrawPlot.reset(); @@ -210,7 +210,7 @@ } plotter.region(2).clear(); if (occupancyDrawPlot.sumAllBinHeights()> 0) plotter.region(2).plot(occupancyDrawPlot); - plotter.region(2).refresh(); +// plotter.region(2).refresh(); } private IHistogram2D makeCopy(IHistogram2D hist) { Modified: java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringUtilities.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringUtilities.java (original) +++ java/branches/HPSJAVA-488/monitoring-drivers/src/main/java/org/hps/monitoring/ecal/plots/EcalMonitoringUtilities.java Fri Jun 12 15:27:10 2015 @@ -111,12 +111,16 @@ public static Boolean isInHole(final int row, final int column) { if (row == 1 || row == -1) { - if (column < XHOLESTART + XHOLEWIDTH && column >= XHOLESTART) { + if ((column <= XHOLESTART + XHOLEWIDTH) && (column >= XHOLESTART)) { return true; } - } else if (row == 0) { + } + + if (row == 0) { return true; - } else if (column == 0) { + } + + if (column == 0) { return true; } return false; Modified: java/branches/HPSJAVA-488/monitoring-util/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/monitoring-util/pom.xml (original) +++ java/branches/HPSJAVA-488/monitoring-util/pom.xml Fri Jun 12 15:27:10 2015 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/monitoring-util/</url> Modified: java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/plotting/ExportPdf.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/plotting/ExportPdf.java (original) +++ java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/plotting/ExportPdf.java Fri Jun 12 15:27:10 2015 @@ -9,6 +9,11 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.lcsim.util.log.DefaultLogFormatter; +import org.lcsim.util.log.LogUtil; import com.itextpdf.text.BadElementException; import com.itextpdf.text.Document; @@ -22,35 +27,47 @@ /** * This is a class for exporting plot graphics to PDF. - * + * * @author Jeremy McCormick <[log in to unmask]> - * */ -public class ExportPdf { +public final class ExportPdf { - private ExportPdf() { + /** + * Setup logging. + */ + private static Logger LOGGER = LogUtil.create(ExportPdf.class, new DefaultLogFormatter(), Level.ALL); + + /** + * Do not allow class instantiation. + */ + private ExportPdf() { } - + /** - * Write the graphics from a list of plotters to a PDF, with one plotter per page, - * including a summary page with the run data. - * @param plotters The list of plotters. - * @param fileName The output file name. - * @param runData A list of run data to include on the first page. - * @throws IOException If there is a problem opening or writing to the PDF document. + * Save a set of tabs containing plots to a file. + * + * @param plotTabs the top level tab component (plots are actually in a set + * of tabs without these tabs) + * @param fileName the file name + * @param runData the list of run data to save on the cover page + * @throws IOException if there is a problem with the IO (e.g. writing to + * PDF file) */ - public static void write(List<IPlotter> plotters, String fileName, List<String> runData) throws IOException { - + public static void write(List<IPlotter> plotters, String fileName, List<String> runData) + throws IOException { + + LOGGER.info("writing plots to " + fileName + " ..."); + // Open the document and the writer. - Document document = new Document(PageSize.A4.rotate(), 50, 50, 50, 50); - PdfWriter writer; + Document document = new Document(PageSize.LETTER.rotate(), 50, 50, 50, 50); + PdfWriter writer = null; try { writer = PdfWriter.getInstance(document, new FileOutputStream(fileName)); } catch (DocumentException e) { throw new IOException(e); } document.open(); - + // Create 1st page with run summary data. try { writeRunData(document, runData); @@ -58,67 +75,72 @@ throw new IOException(e); } - // Write out the plots to the PDF, one page per plotter. - for (int i = 0; i < plotters.size(); i++) { - document.newPage(); - IPlotter plotter = plotters.get(i); + // Write the graphics from each plotter on a new page. + for (IPlotter plotter : plotters) { + plotter.refresh(); + document.newPage(); writePage(document, writer, plotter); } - + document.close(); + + LOGGER.info("done writing plots to " + fileName); } - + /** - * Get an image from a Swing component. - * @param component The Swing component. - * @return The image from the component. + * Write a plotter's graphics into a single PDF page. + * + * @param document the output PDF document + * @param writer the PDF writer + * @param image the buffered bitmap image + * @throws IOException if there is a problem writing to the PDF document + */ + static void writePage(Document document, PdfWriter writer, IPlotter plotter) throws IOException { + + Image image = ((Plotter) plotter).getImage(); + String title = plotter.title(); + + // Add header label. + Paragraph p = new Paragraph(title, new Font(FontFamily.HELVETICA, 24)); + p.setAlignment(Element.ALIGN_CENTER); + try { + document.add(p); + } catch (DocumentException e) { + throw new IOException(e); + } + + // Write image into the document. + com.itextpdf.text.Image iTextImage = null; + try { + iTextImage = com.itextpdf.text.Image.getInstance(writer, image, 1f); + } catch (BadElementException e) { + throw new IOException(e); + } + iTextImage.scaleAbsolute(document.getPageSize().getWidth(), (float) 0.75 * document.getPageSize().getHeight()); + iTextImage.setAlignment(Element.ALIGN_CENTER); + try { + document.add(iTextImage); + } catch (DocumentException e) { + throw new IOException(e); + } + } + + /** + * Get a buffered image from a Swing component. + * + * @param component the Swing component + * @return the image from painting the component onto a buffered image */ public static BufferedImage getImage(Component component) { BufferedImage image = new BufferedImage(component.getWidth(), component.getHeight(), BufferedImage.TYPE_INT_RGB); component.paint(image.getGraphics()); return image; } - - /** - * Write plotter graphics into a single PDF page. - * @param document The output PDF document. - * @param writer The PDF writer. - * @param plotter The plotter with the graphics. - * @throws IOException If there is a problem writing to the PDF document. - */ - static void writePage(Document document, PdfWriter writer, IPlotter plotter) throws IOException { - - // Add header label. - Paragraph p = new Paragraph(plotter.title(), new Font(FontFamily.HELVETICA, 24)); - p.setAlignment(Element.ALIGN_CENTER); - try { - document.add(p); - } catch (DocumentException e) { - throw new IOException(e); - } - - // Create image from panel. - Image awtImage = getImage(((Plotter)plotter).panel()); - - // Write image into the document. - com.itextpdf.text.Image iTextImage = null; - try { - iTextImage = com.itextpdf.text.Image.getInstance(writer, awtImage, 1f); - } catch (BadElementException e) { - throw new IOException(e); - } - iTextImage.setAbsolutePosition(50, 50); - iTextImage.scalePercent(60); - try { - document.add(iTextImage); - } catch (DocumentException e) { - throw new IOException(e); - } - } - + /** * Add a page with the run summary data. - * @param runData The list of run summary information. + * + * @param runData the list of run summary information */ static void writeRunData(Document document, List<String> runData) throws DocumentException { for (String line : runData) { Modified: java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/plotting/PlotterRegistry.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/plotting/PlotterRegistry.java (original) +++ java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/plotting/PlotterRegistry.java Fri Jun 12 15:27:10 2015 @@ -10,13 +10,14 @@ import java.util.Map.Entry; /** - * This is a global registry of plotters used by the monitoring plot factory. + * This is a global registry of plotters used by the monitoring plot factory. + * * @author Jeremy McCormick <[log in to unmask]> */ public class PlotterRegistry { - + HashMap<IPlotter, int[]> plotterMap = new HashMap<IPlotter, int[]>(); - + /** * Clear the list of plotters. */ @@ -24,9 +25,10 @@ System.out.println("clearing PlotterRegistry"); plotterMap.clear(); } - + /** * Find a plotter that contains the region object. + * * @param region The plotter region object. * @return The plotter that contains this region or null if none. */ @@ -40,20 +42,31 @@ } return null; } - + + /** + * Get the tab indices of the plotter. + * + * @param plotter the plotter to lookup + * @return the tab indices of the plotter or <code>null</code> if it doesn't exist + */ + public int[] getTabIndices(IPlotter plotter) { + return plotterMap.get(plotter); + } + /** * Register a plotter along with its tab indices. + * * @param plotter The plotter to register. * @param index1 The top tab index. * @param index2 The sub-tab index. */ public void register(IPlotter plotter, int index1, int index2) { - plotterMap.put(plotter, new int[] { index1, index2 }); + plotterMap.put(plotter, new int[] {index1, index2}); } - + /** - * Find a plotter by its tab indices e.g. those that are currently selected - * in an application. + * Find a plotter by its tab indices e.g. those that are currently selected in an application. + * * @param index1 The top tab index. * @param index2 The sub-tab index. * @return The plotter or null if none found. @@ -67,9 +80,10 @@ } return null; } - + /** * Get the current collection of plotters as an unmodifiable collection. + * * @return The current collection of plotters. */ public List<IPlotter> getPlotters() { Modified: java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/subsys/et/EtSystemMonitor.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/subsys/et/EtSystemMonitor.java (original) +++ java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/subsys/et/EtSystemMonitor.java Fri Jun 12 15:27:10 2015 @@ -50,7 +50,7 @@ elapsedMillis = System.currentTimeMillis() - eventReceivedMillis; if (elapsedMillis > warningIntervalMillis) systemStatus.setStatus(StatusCode.WARNING, "No ET events received for " + elapsedMillis + " millis."); - else + else if (systemStatus.getStatusCode()!=StatusCode.OKAY) systemStatus.setStatus(StatusCode.OKAY, "ET events received."); } }; Modified: java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/trigger/AbstractTablePanel.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/trigger/AbstractTablePanel.java (original) +++ java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/trigger/AbstractTablePanel.java Fri Jun 12 15:27:10 2015 @@ -61,7 +61,7 @@ setLayout(null); // Create header labels for the tables. - localHeader = new JLabel("Local Statistics"); + localHeader = new JLabel("Instantaneous Statistics"); localHeader.setHorizontalAlignment(JLabel.CENTER); add(localHeader); Modified: java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/trigger/AbstractTriggerTablePanel.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/trigger/AbstractTriggerTablePanel.java (original) +++ java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/trigger/AbstractTriggerTablePanel.java Fri Jun 12 15:27:10 2015 @@ -109,7 +109,7 @@ for(int i = 0; i < 2; i++) { sspSimTriggers[i] = triggerStats[i][0].getSSPSimulatedTriggers() + triggerStats[i][1].getSSPSimulatedTriggers(); sspBankTriggers[i] = triggerStats[i][0].getReportedTriggers() + triggerStats[i][1].getReportedTriggers(); - sspBankTriggers[i] = triggerStats[i][0].getReconSimulatedTriggers() + triggerStats[i][1].getReconSimulatedTriggers(); + reconSimTriggers[i] = triggerStats[i][0].getReconSimulatedTriggers() + triggerStats[i][1].getReconSimulatedTriggers(); sspMatchedTriggers[i] = triggerStats[i][0].getMatchedSSPSimulatedTriggers() + triggerStats[i][1].getMatchedSSPSimulatedTriggers(); reconMatchedTriggers[i] = triggerStats[i][0].getMatchedReconSimulatedTriggers() + triggerStats[i][1].getMatchedReconSimulatedTriggers(); } Modified: java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/trigger/EfficiencyTablePanel.java ============================================================================= --- java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/trigger/EfficiencyTablePanel.java (original) +++ java/branches/HPSJAVA-488/monitoring-util/src/main/java/org/hps/monitoring/trigger/EfficiencyTablePanel.java Fri Jun 12 15:27:10 2015 @@ -50,7 +50,8 @@ "", "Singles 0", "Singles 1", "Pair 0", "Pair 1", "Count" }; private static final String[] ROW_NAMES = { - "", "Random", "Cosmic", "Singles 0", "Singles 1", "Pair 0", "Pair 1" + "", "Singles 0", "Singles 1", "Pair 0", "Pair 1", "Pulser", "Cosmic" + //"", "Random", "Cosmic", "Singles 0", "Singles 1", "Pair 0", "Pair 1" }; /** @@ -141,7 +142,7 @@ globalText = globalText + " ( N/A %)"; } else { globalText = String.format("%s (%7.3f%%)", globalText, - (100.0 * matched[LOCAL][seenTriggerType][tiTriggerType] / triggers[GLOBAL][seenTriggerType][tiTriggerType])); + (100.0 * matched[GLOBAL][seenTriggerType][tiTriggerType] / triggers[GLOBAL][seenTriggerType][tiTriggerType])); } globalModel.setValueAt(globalText, tiTriggerType + 1, seenTriggerType + 1); } @@ -206,4 +207,4 @@ return new JTable[] { localTable, globalTable }; } -} +} Modified: java/branches/HPSJAVA-488/parent/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/parent/pom.xml (original) +++ java/branches/HPSJAVA-488/parent/pom.xml Fri Jun 12 15:27:10 2015 @@ -6,13 +6,13 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <packaging>pom</packaging> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> <name>parent</name> <description>HPS Java parent POM</description> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <org.lcsim.cacheDir>${user.home}</org.lcsim.cacheDir> - <lcsimVersion>3.1.1-SNAPSHOT</lcsimVersion> + <lcsimVersion>3.1.1</lcsimVersion> <skipSite>false</skipSite> <skipPlugin>false</skipPlugin> </properties> @@ -31,6 +31,11 @@ <id>lcsim-repo-public</id> <name>LCSIM Public Maven Repository</name> <url>http://srs.slac.stanford.edu/nexus/content/groups/lcsim-maven2-public/</url> + </repository> + <repository> + <id>jlab-coda-repo-public</id> + <name>JLAB CODA Maven Repository</name> + <url>https://coda.jlab.org/maven/</url> </repository> <repository> <id>maven-central-repo</id> @@ -80,6 +85,7 @@ <groupId>org.lcsim</groupId> <artifactId>lcsim-distribution</artifactId> <version>${lcsimVersion}</version> + <type>pom</type> <exclusions> <exclusion> <groupId>jdom</groupId> @@ -88,6 +94,39 @@ <exclusion> <groupId>commons-math</groupId> <artifactId>commons-math</artifactId> + </exclusion> + <exclusion> + <groupId>freehep-graphicsio-tests</groupId> + <artifactId>org.freehep</artifactId> + </exclusion> + <exclusion> + <groupId>aida-test</groupId> + <artifactId>hep.aida</artifactId> + </exclusion> + <!-- Exclude some unneeded lcsim jars. --> + <exclusion> + <groupId>org.lcsim</groupId> + <artifactId>lcsim-analysis</artifactId> + </exclusion> + <exclusion> + <groupId>org.lcsim</groupId> + <artifactId>lcsim-cal-calib</artifactId> + </exclusion> + <exclusion> + <groupId>org.lcsim</groupId> + <artifactId>detector-data</artifactId> + </exclusion> + <exclusion> + <groupId>org.lcsim</groupId> + <artifactId>lcsim-mc</artifactId> + </exclusion> + <exclusion> + <groupId>org.lcsim</groupId> + <artifactId>lcsim-steering-files</artifactId> + </exclusion> + <exclusion> + <groupId>org.lcsim</groupId> + <artifactId>lcsim-users</artifactId> </exclusion> </exclusions> </dependency> @@ -98,93 +137,98 @@ <dependency> <groupId>org.hps</groupId> <artifactId>hps-util</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-detector-data</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> + </dependency> + <dependency> + <groupId>org.hps</groupId> + <artifactId>hps-detector-model</artifactId> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-conditions</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-ecal-recon</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-ecal-readout-sim</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-tracking</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-evio</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-recon</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-analysis</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-monitoring-drivers</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-monitoring-app</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-users</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-steering-files</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-distribution</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-ecal-event-display</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-record-util</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <dependency> <groupId>org.hps</groupId> <artifactId>hps-monitoring-util</artifactId> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </dependency> <!-- Next are external dependencies used in multiple modules. --> <dependency> <groupId>org.jlab.coda</groupId> <artifactId>jevio</artifactId> - <version>4.4.5</version> + <version>4.4.6</version> </dependency> <dependency> <groupId>org.jlab.coda</groupId> @@ -192,14 +236,24 @@ <version>14.1</version> </dependency> <dependency> + <groupId>com.google.guava</groupId> + <artifactId>guava</artifactId> + <version>18.0</version> + </dependency> + <dependency> <groupId>org.reflections</groupId> <artifactId>reflections</artifactId> <version>0.9.9-RC1</version> </dependency> <dependency> + <groupId>org.apache.commons</groupId> + <artifactId>commons-math3</artifactId> + <version>3.5</version> + </dependency> + <dependency> <groupId>jfreechart-aida-experimental</groupId> <artifactId>jfreechart-aida-experimental</artifactId> - <version>1.6</version> + <version>1.7</version> <exclusions> <exclusion> <groupId>jdom</groupId> Modified: java/branches/HPSJAVA-488/plugin/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/plugin/pom.xml (original) +++ java/branches/HPSJAVA-488/plugin/pom.xml Fri Jun 12 15:27:10 2015 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/plugin/</url> @@ -51,24 +51,6 @@ <value>http://srs.slac.stanford.edu/nexus/service/local/artifact/maven/redirect?r=lcsim-maven2-public</value> </property> </redirectUrls> - <includes> - <include>org.apache.commons:commons-math3</include> - <include>org.hps:hps-analysis</include> - <include>org.hps:hps-conditions</include> - <include>org.hps:hps-detector-data</include> - <include>org.hps:hps-ecal-readout-sim</include> - <include>org.hps:hps-ecal-recon</include> - <include>org.hps:hps-et</include> - <include>org.hps:hps-evio</include> - <include>org.hps:hps-recon</include> - <include>org.hps:hps-record-util</include> - <include>org.hps:hps-tracking</include> - <include>org.hps:hps-users</include> - <include>org.hps:hps-util</include> - <include>mysql:mysql-connector-java</include> - <include>org.jlab.coda:jevio</include> - <include>org.jlab.coda:et</include> - </includes> </configuration> <executions> <execution> Modified: java/branches/HPSJAVA-488/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/pom.xml (original) +++ java/branches/HPSJAVA-488/pom.xml Fri Jun 12 15:27:10 2015 @@ -10,7 +10,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>svn://svn.freehep.org/hps/java/trunk/</url> @@ -132,6 +132,7 @@ <module>datacat</module> --> <module>detector-data</module> + <module>detector-model</module> <module>distribution</module> <module>ecal-event-display</module> <module>ecal-readout-sim</module> Modified: java/branches/HPSJAVA-488/recon/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/recon/pom.xml (original) +++ java/branches/HPSJAVA-488/recon/pom.xml Fri Jun 12 15:27:10 2015 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/recon/</url> Modified: java/branches/HPSJAVA-488/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java ============================================================================= --- java/branches/HPSJAVA-488/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java (original) +++ java/branches/HPSJAVA-488/recon/src/main/java/org/hps/recon/particle/ReconParticleDriver.java Fri Jun 12 15:27:10 2015 @@ -4,6 +4,7 @@ import hep.physics.vec.BasicHepLorentzVector; import hep.physics.vec.Hep3Vector; import hep.physics.vec.HepLorentzVector; +import hep.physics.vec.VecOp; import java.util.ArrayList; import java.util.List; @@ -297,24 +298,13 @@ if (!unmatchedClusters.isEmpty()) // Iterate over the remaining unmatched clusters. { for (Cluster unmatchedCluster : unmatchedClusters) { - // Create a reconstructed particle to represent the - // unmatched cluster. + // Create a reconstructed particle to represent the unmatched cluster. ReconstructedParticle particle = new BaseReconstructedParticle(); - HepLorentzVector fourVector = new BasicHepLorentzVector(0, 0, 0, 0); - - // Add the cluster to the particle. - particle.addCluster(unmatchedCluster); - - // Set the reconstructed particle properties based on - // the cluster properties. - ((BasicHepLorentzVector) fourVector).setT(unmatchedCluster.getEnergy()); - ((BaseReconstructedParticle) particle).setCharge(0); - ((BaseReconstructedParticle) particle).set4Vector(fourVector); - - // The particle is assumed to be a photon, since it - // did not leave any track. + + // The particle is assumed to be a photon, since it did not leave a track. ((BaseReconstructedParticle) particle).setParticleIdUsed(new SimpleParticleID(22, 0, 0, 0)); + // apply cluster corrections if (unmatchedCluster.getType() == ClusterType.RECON.getType()) { int pid = particle.getParticleIDUsed().getPDG(); // If not electron.... @@ -324,6 +314,18 @@ ClusterUtilities.applyCorrections(unmatchedCluster); } } + //get energy and direction from the cluster + Hep3Vector p = new BasicHep3Vector(unmatchedCluster.getPosition()); + double e = unmatchedCluster.getEnergy(); + // create momentum vector from direction unit vector times the energy (massless photon) + HepLorentzVector fourVector = new BasicHepLorentzVector(e, VecOp.mult(e, VecOp.unit(p))); + + // Add the cluster to the particle. + particle.addCluster(unmatchedCluster); + + // Set the reconstructed particle properties based on the cluster properties. + ((BaseReconstructedParticle) particle).setCharge(0); + ((BaseReconstructedParticle) particle).set4Vector(fourVector); // Add the particle to the reconstructed particle list. particles.add(particle); Modified: java/branches/HPSJAVA-488/record-util/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/record-util/pom.xml (original) +++ java/branches/HPSJAVA-488/record-util/pom.xml Fri Jun 12 15:27:10 2015 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/record-util/</url> Modified: java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/epics/EpicsEtProcessor.java ============================================================================= --- java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/epics/EpicsEtProcessor.java (original) +++ java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/epics/EpicsEtProcessor.java Fri Jun 12 15:27:10 2015 @@ -35,9 +35,9 @@ throw new RuntimeException(e); } this.evioProcessor.process(evio); - if (this.evioProcessor.getEpicsScalarData() != null) { - System.out.println("EpicsEtProcessor created EpicsScalarData ..."); - System.out.println(this.evioProcessor.getEpicsScalarData()); + if (this.evioProcessor.getEpicsData() != null) { + System.out.println("EpicsEtProcessor created EpicsData ..."); + System.out.println(this.evioProcessor.getEpicsData()); } } } Modified: java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/epics/EpicsEvioProcessor.java ============================================================================= --- java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/epics/EpicsEvioProcessor.java (original) +++ java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/epics/EpicsEvioProcessor.java Fri Jun 12 15:27:10 2015 @@ -1,34 +1,40 @@ package org.hps.record.epics; + +import java.util.logging.Level; +import java.util.logging.Logger; import org.hps.record.evio.EvioEventConstants; import org.hps.record.evio.EvioEventProcessor; import org.jlab.coda.jevio.BaseStructure; import org.jlab.coda.jevio.EvioEvent; +import org.lcsim.util.log.DefaultLogFormatter; +import org.lcsim.util.log.LogUtil; /** - * This is an EVIO event processor that will read EPICS events (event tag 31) and turn them into {@link EpicsScalarData} - * objects. + * This is an EVIO event processor that will read EPICS events (event tag 31) and turn them into {@link EpicsData} objects. * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ public final class EpicsEvioProcessor extends EvioEventProcessor { + private static final Logger LOGGER = LogUtil.create(EpicsEvioProcessor.class, new DefaultLogFormatter(), Level.INFO); + /** * The current EPICS data object. */ - private EpicsScalarData data; + private EpicsData data; /** - * Get the current {@link EpicsScalarData} object created from record processing. + * Get the current {@link EpicsData} object created from record processing. * - * @return the {@link EpicsScalarData} object created from record processing + * @return the {@link EpicsData} object created from record processing */ - public EpicsScalarData getEpicsScalarData() { + public EpicsData getEpicsData() { return this.data; } /** - * Process EVIO data and create a {@link EpicsScalarData} if EPICS data bank exists in the event. + * Process EVIO data and create a {@link EpicsData} if EPICS data bank exists in the event. * * @param evio the <code>EvioEvent</code> that possibly has EPICS data */ @@ -40,19 +46,22 @@ return; } + LOGGER.info("processing EPICS event " + evio.getEventNumber()); + // Find the bank with the EPICS information. BaseStructure epicsBank = null; final BaseStructure topBank = evio.getChildrenList().get(0); for (final BaseStructure childBank : topBank.getChildrenList()) { if (childBank.getHeader().getTag() == EvioEventConstants.EPICS_BANK_TAG) { epicsBank = childBank; + LOGGER.fine("found EPICS data bank " + childBank.getHeader().getTag()); break; } } if (epicsBank != null) { final String epicsData = epicsBank.getStringData()[0]; - this.data = new EpicsScalarData(); + this.data = new EpicsData(); this.data.fromString(epicsData); } } Modified: java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/epics/EpicsGenericObject.java ============================================================================= --- java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/epics/EpicsGenericObject.java (original) +++ java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/epics/EpicsGenericObject.java Fri Jun 12 15:27:10 2015 @@ -3,9 +3,8 @@ import org.lcsim.event.GenericObject; /** - * This is an implementation of GenericObject for reading and writing EPICS data. There is no functionality here - * intended for ends users. Instead, the EPICS data should be accessed using - * {@link EpicsScalarData#read(org.lcsim.event.EventHeader)} to create the data object from input event data. + * This is an implementation of GenericObject for reading and writing EPICS data. There is no functionality here intended for ends users. Instead, the + * EPICS data should be accessed using {@link EpicsData#read(org.lcsim.event.EventHeader)} to create the data object from input event data. * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ Modified: java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioEventConstants.java ============================================================================= --- java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioEventConstants.java (original) +++ java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioEventConstants.java Fri Jun 12 15:27:10 2015 @@ -71,14 +71,14 @@ public static final int PRESTART_EVENT_TAG = 17; /** - * Tag of the scalars integer bank, which is a child of the crate bank. + * Tag of the scalers integer bank, which is a child of the crate bank. */ - public static final int SCALARS_BANK_TAG = 57621; + public static final int SCALERS_BANK_TAG = 57621; /** - * Tag of the scalars crate bank, which is a child of the top bank. + * Tag of the scalers crate bank, which is a child of the top bank. */ - public static final int SCALARS_CRATE_TAG = 39; + public static final int SCALERS_CRATE_TAG = 39; /** * CODA SYNC event tag. Modified: java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioEventUtilities.java ============================================================================= --- java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioEventUtilities.java (original) +++ java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioEventUtilities.java Fri Jun 12 15:27:10 2015 @@ -189,6 +189,26 @@ } /** + * Manually set the event number on an <code>EvioEvent</code> from its "EVENT ID" bank. + * + * @param evioEvent the input <code>EvioEvent</code> + */ + public static void setEventNumber(final EvioEvent evioEvent) { + int eventNumber = -1; + if (evioEvent.getChildrenList() != null) { + for (final BaseStructure bank : evioEvent.getChildrenList()) { + if (bank.getHeader().getTag() == EvioEventConstants.EVENTID_BANK_TAG) { + eventNumber = bank.getIntData()[0]; + break; + } + } + } + if (eventNumber != -1) { + evioEvent.setEventNumber(eventNumber); + } + } + + /** * Class should not be instantiated. */ private EvioEventUtilities() { Modified: java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioFileProducer.java ============================================================================= --- java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioFileProducer.java (original) +++ java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioFileProducer.java Fri Jun 12 15:27:10 2015 @@ -1,13 +1,22 @@ package org.hps.record.evio; +import java.io.BufferedReader; import java.io.File; -import java.net.InetAddress; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStreamReader; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.util.ArrayList; import java.util.Arrays; import java.util.List; - +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.commons.cli.CommandLine; +import org.apache.commons.cli.HelpFormatter; +import org.apache.commons.cli.Options; +import org.apache.commons.cli.PosixParser; import org.jlab.coda.et.EtAttachment; import org.jlab.coda.et.EtConstants; import org.jlab.coda.et.EtEvent; @@ -18,91 +27,143 @@ import org.jlab.coda.jevio.EventWriter; import org.jlab.coda.jevio.EvioEvent; import org.jlab.coda.jevio.EvioReader; +import org.lcsim.util.log.DefaultLogFormatter; +import org.lcsim.util.log.LogUtil; /** - * A utility class for streaming an EVIO file to an ET server. + * A command line utility for streaming EVIO files to an ET server. * <p> - * Original version was copied from the CODA group's ET java module. + * The original version was copied from the CODA ET module and modified. * * @author <a href="mailto:[log in to unmask]">Jeremy McCormick</a> */ -// TODO: Add option to set number of events in the put array. public final class EvioFileProducer { /** - * Flag to turn on/off debug print. - */ - private static final boolean debug = false; + * Default event count for printing event sequence number. + */ + private static final int DEFAULT_COUNT = 1000; + + /** + * Default delay time in milliseconds between events. + */ + private static final int DEFAULT_DELAY = 0; + + /** + * The default ET group. + */ + private static final int DEFAULT_ET_GROUP = 1; + + /** + * Default event buffer size (200 KB). + */ + private static final int DEFAULT_EVENT_SIZE = 200000; + + /** + * Default host name. + */ + private static final String DEFAULT_HOST = "localhost"; + + /** + * Default ET system name. + */ + private static final String DEFAULT_NAME = "ETBuffer"; + + /** + * Maximum port number of ET server (maximum value of a TCP/IP port). + */ + private static final int ET_PORT_MAX = 65535; + + /** + * Minimum port number of ET server (lower port numbers not allowed). + */ + private static final int ET_PORT_MIN = 1024; + + /** + * Setup the logger. + */ + private static final Logger LOGGER = LogUtil + .create(EvioFileProducer.class, new DefaultLogFormatter(), Level.CONFIG); + + /** + * The command line options. + */ + private static final Options OPTIONS = new Options(); + + /** + * Define the command line options. + */ + static { + OPTIONS.addOption("h", "help", false, "print help"); + OPTIONS.addOption("c", "count", true, "interval for printing event numbers"); + OPTIONS.addOption("d", "delay", true, "delay in milliseconds between events"); + OPTIONS.addOption("e", "file", true, "add an EVIO file"); + OPTIONS.addOption("f", "name", true, "ET system name which should be a buffer file"); + OPTIONS.addOption("g", "group", true, "group number of the events"); + OPTIONS.addOption("H", "host", true, "server host name"); + OPTIONS.addOption("l", "list", true, "text file with list of EVIO files"); + OPTIONS.addOption("L", "log", true, "log level (INFO, FINE, etc.)"); + OPTIONS.addOption("p", "port", true, "server port"); + OPTIONS.addOption("s", "size", true, "event buffer size in bytes"); + } /** * The externally accessible main method. * - * @param args The command line arguments. + * @param args the command line arguments */ public static void main(final String[] args) { - new EvioFileProducer().doMain(args); // call wrapper method - } - - /** - * Print usage statement. + new EvioFileProducer().run(args); + } + + /** + * Print usage statement and exit. */ private static void usage() { - System.out.println("\nUsage: java Producer -f <et name> -e <evio file> [-p <server port>] [-host <host>]" - + " [-d <delay in millisec>] [-g <group #>]\n\n" + " -f ET system's name\n" - + " -s size in bytes for requested events\n" - + " -p port number for a udp broadcast\n" - + " -g group number of new events to get\n" - + " -host host the ET system resides on (defaults to anywhere)\n\n" - + " This consumer works by making a connection to the\n" - + " ET system's tcp server port.\n"); + final HelpFormatter help = new HelpFormatter(); + help.printHelp("EvioFileProducer", OPTIONS); System.exit(1); } /** - * The byte buffer used to transfer data from EVIO to ET. - */ - private ByteBuffer byteBuffer; + * Event count for printing message. + */ + private int count = DEFAULT_COUNT; /** * A delay in milliseconds between put operations. */ - private int delay = 0; - - /** - * The ET system name which generally maps to a buffer file. - */ - private String etName; - - /** - * The list of input EVIO files. + private int delay = DEFAULT_DELAY; + + /** + * The ET system name which maps to a buffer file. + */ + private String etName = DEFAULT_NAME; + + /** + * The master list of input EVIO files to stream. */ private final List<File> evioFiles = new ArrayList<File>(); /** - * This is used for a "group" value when doing put but not sure what it actually does. - */ - private int group = 1; - - /** - * The server host name. - */ - private String host; - - /** - * The server's network port. + * The ET group (default is 1). + */ + private int group = DEFAULT_ET_GROUP; + + /** + * The server host name (default is localhost). + */ + private String host = DEFAULT_HOST; + + /** + * The server's network port (default is standard ET server port). */ private int port = EtConstants.serverPort; /** - * The EVIO reader used to read the input EVIO events. - */ - private EvioReader reader; - - /** - * The default ET event size. - */ - // FIXME: Should be a lot bigger? - private int size = 10000; // Default event size. + * The default ET event size (default is 200 KB). + */ + private int size = DEFAULT_EVENT_SIZE; /** * Class constructor. @@ -111,174 +172,208 @@ } /** - * Copy byte buffer to an <code>EtEvent</code>. + * Print the command line job configuration to the log. + */ + private void logConfig() { + final StringBuffer sb = new StringBuffer(); + sb.append("count = " + this.count + '\n'); + sb.append("delay = " + this.delay + '\n'); + sb.append("etName = " + this.etName + '\n'); + sb.append("group = " + this.group + '\n'); + sb.append("host = " + this.host + '\n'); + sb.append("port = " + this.port + '\n'); + sb.append("size = " + this.size + '\n'); + sb.append("EVIO files ..." + '\n'); + for (final File evioFile : this.evioFiles) { + sb.append(evioFile.getPath() + '\n'); + } + LOGGER.config(sb.toString()); + } + + /** + * Run the job by streaming all the EVIO files to the ET server using the command line arguments. * - * @param event The target EtEvent. - */ - public void copyToEtEvent(final EtEvent event) { - event.getDataBuffer().put(this.byteBuffer); - } - - /** - * Wrapper method called in main. - * - * @param args The command line arguments. - */ - public void doMain(final String[] args) { + * @param args the command line arguments + */ + public void run(final String[] args) { + + // Command line parser. + final PosixParser parser = new PosixParser(); + try { - for (int i = 0; i < args.length; i++) { - if (args[i].equalsIgnoreCase("-e")) { - // evioFileName = new String(args[++i]); - this.evioFiles.add(new File(args[++i])); - } else if (args[i].equalsIgnoreCase("-f")) { - this.etName = args[++i]; - } else if (args[i].equalsIgnoreCase("-host")) { - this.host = args[++i]; - } else if (args[i].equalsIgnoreCase("-p")) { - try { - this.port = Integer.parseInt(args[++i]); - if (this.port < 1024 || this.port > 65535) { - System.out.println("Port number must be between 1024 and 65535."); - usage(); - return; - } - } catch (final NumberFormatException ex) { - System.out.println("Did not specify a proper port number."); - usage(); - return; - } - } else if (args[i].equalsIgnoreCase("-s")) { - try { - this.size = Integer.parseInt(args[++i]); - if (this.size < 1) { - System.out.println("Size needs to be positive int."); - usage(); - return; - } - } catch (final NumberFormatException ex) { - System.out.println("Did not specify a proper size."); - usage(); - return; - } - } else if (args[i].equalsIgnoreCase("-g")) { - try { - this.group = Integer.parseInt(args[++i]); - if (this.group < 1 || this.group > 10) { - System.out.println("Group number must be between 0 and 10."); - usage(); - return; - } - } catch (final NumberFormatException ex) { - System.out.println("Did not specify a proper group number."); - usage(); - return; - } - } else if (args[i].equalsIgnoreCase("-d")) { - try { - this.delay = Integer.parseInt(args[++i]); - if (this.delay < 1) { - System.out.println("delay must be > 0."); - usage(); - return; - } - } catch (final NumberFormatException ex) { - System.out.println("Did not specify a proper delay."); - usage(); - return; - } - } else { - usage(); - return; - } - } - - if (this.host == null) { - // host = EtConstants.hostAnywhere; - this.host = InetAddress.getLocalHost().getHostName(); - } - - // ET name is required. - if (this.etName == null) { - System.out.println("EVIO file name argument is required"); - usage(); - return; - } - + + // Parse the command line arguments. + final CommandLine cl = parser.parse(OPTIONS, args); + + // Set the log level of this class before doing anything else. + if (cl.hasOption("L")) { + final Level level = Level.parse(cl.getOptionValue("L")); + // Default level is CONFIG so this message will always show. + LOGGER.config("Log level will be set to " + level + "."); + + // Set the new log level. This may suppress subsequent configuration print outs! + LOGGER.setLevel(level); + } + + // Add EVIO files to the job. + if (cl.hasOption("e")) { + for (final String fileName : cl.getOptionValues("e")) { + final File evioFile = new File(fileName); + LOGGER.config("adding EVIO file " + evioFile.getPath()); + this.evioFiles.add(evioFile); + } + } + + // Set ET name which is the buffer file. + if (cl.hasOption("f")) { + this.etName = cl.getOptionValue("f"); + } + + // Add EVIO files from a text file list, assuming one file path per line. + if (cl.hasOption("l")) { + final String filePath = cl.getOptionValue("l"); + final File listFile = new File(filePath); + if (!listFile.exists()) { + throw new IllegalArgumentException("The file " + listFile.getPath() + " does not exist."); + } + BufferedReader br = null; + try { + br = new BufferedReader(new InputStreamReader(new FileInputStream(listFile))); + String line; + while ((line = br.readLine()) != null) { + this.evioFiles.add(new File(line.trim())); + } + } finally { + if (br != null) { + br.close(); + } + } + } + + // Set host name. + if (cl.hasOption("H")) { + this.host = cl.getOptionValue("H"); + } + // if (this.host == null) { + // host = EtConstants.hostAnywhere; + // this.host = InetAddress.getLocalHost().getHostName(); + // } + + // Set the port number. + if (cl.hasOption("p")) { + this.port = Integer.parseInt(cl.getOptionValue("p")); + if (this.port < ET_PORT_MIN || this.port > ET_PORT_MAX) { + throw new IllegalArgumentException("Port number must be between 1024 and 65535."); + } + } + // Set the size of the event buffer in bytes. + if (cl.hasOption("s")) { + this.size = Integer.parseInt(cl.getOptionValue("s")); + if (this.size < 1) { + throw new IllegalArgumentException("Size needs to be positive int."); + } + } + + // Set the group number. + if (cl.hasOption("g")) { + this.group = Integer.parseInt(cl.getOptionValue("g")); + if (this.group < 1 || this.group > 10) { + throw new IllegalArgumentException("Group number must be between 0 and 10."); + } + } + + // Set the delay in milliseconds between putting events. + if (cl.hasOption("d")) { + this.delay = Integer.parseInt(cl.getOptionValue("d")); + if (this.delay < 1) { + throw new IllegalArgumentException("The delay must be > 0."); + } + } + + if (cl.hasOption("c")) { + this.count = Integer.parseInt(cl.getOptionValue("c")); + if (this.count < 1) { + throw new IllegalArgumentException("The count must be > 0."); + } + } + + // At least one EVIO file must be present. if (this.evioFiles.size() == 0) { - System.out.println("At least one input EVIO file is required."); - usage(); - return; + throw new IllegalArgumentException("At least one input EVIO file is required."); } // Check existence of EVIO files. - System.out.println("EVIO input files ..."); + LOGGER.info("Checking EVIO file list ... "); for (final File evioFile : this.evioFiles) { - System.out.println(evioFile.getPath()); if (!evioFile.exists()) { - System.err.println("EVIO file does not exist: " + evioFile.getPath()); - throw new RuntimeException("EVIO input file does not exist."); - } - } - - // Setup ET system with the command line config. + throw new IllegalArgumentException("EVIO input file does not exist: " + evioFile.getPath()); + } + } + LOGGER.info("EVIO file list was checked!"); + + // Print out the configuration for the job to the log. + logConfig(); + + } catch (final Exception e) { /* Catches errors in command line arguments. */ + // If there are errors parsing or validating the command line arguments then print usage and exit. + LOGGER.log(Level.SEVERE, "Error while processing command line options.", e); + usage(); + } + + EtSystem sys = null; + EvioReader reader = null; + + try { + + // Setup ET system from the command line options. final EtSystemOpenConfig config = new EtSystemOpenConfig(this.etName, this.host, this.port); - final EtSystem sys = new EtSystem(config, EtConstants.debugInfo); + sys = new EtSystem(config, EtConstants.debugInfo); sys.open(); final EtStation gc = sys.stationNameToObject("GRAND_CENTRAL"); final EtAttachment att = sys.attach(gc); - // array of events + // Array of ET events. EtEvent[] mevs; // Loop over input EVIO file list. for (final File evioFile : this.evioFiles) { - // Open EVIO reader. - System.out.println("Opening next EVIO file: " + evioFile.getPath()); - this.reader = new EvioReader(evioFile.getPath(), false); - - // Print number of events. - if (debug) { - System.out.println("EVIO file opened with " + this.reader.getEventCount() + " events."); - } - - // Ref to current EVIO event. + // Open a new EVIO reader in sequential read mode so events are immediately streamed to server. + LOGGER.info("Opening next EVIO file " + evioFile.getPath() + " ..."); + reader = new EvioReader(evioFile.getPath(), false, true); + LOGGER.info("Done opening file!"); + + // Reference to the current EVIO event. EvioEvent event; - // Event sequence number; starts with 1. + // Event sequence number. int eventCount = 0; // Loop until event source is exhausted. - while (true) { - - // Get next event. - event = this.reader.nextEvent(); + while ((event = reader.nextEvent()) != null) { + + // Increment event count. ++eventCount; - if (eventCount % 1000 == 0) { - System.out.println("EvioFileProducer - event <" + eventCount + ">"); - } - if (event == null) { - break; - } - - // Try to parse the next event. + + // Print event sequence. + if (eventCount % this.count == 0) { + LOGGER.info("EVIO event " + eventCount); + } + try { - this.reader.parseEvent(event); - if (debug) { - System.out.println("event #" + event.getEventNumber() + " is " + event.getTotalBytes() - + " bytes"); - } - } catch (final Exception e) { + // Parse the next EVIO event. + reader.parseEvent(event); + LOGGER.finest("EVIO event " + event.getEventNumber() + " is " + event.getTotalBytes() + + " bytes."); + } catch (final Exception e) { /* Catches parse errors reading the EVIO events. */ e.printStackTrace(); - System.out.println("Error making EVIO event with sequence number <" + eventCount - + "> in file <" + evioFile.getPath() + ">."); + LOGGER.warning("Error making EVIO event with seq number " + eventCount + " in file " + + evioFile.getPath()); // Attempt to recover from errors by skipping to next event if there are exceptions. continue; } - if (debug) { - System.out.println("new events - size=" + this.size + "; group=" + this.group); - } + LOGGER.finest("new events - size=" + this.size + "; group=" + this.group); final int eventTag = EvioEventUtilities.getEventTag(event); @@ -296,7 +391,7 @@ Arrays.fill(control, eventTag); mevs[0].setControl(control); - // Delay for X millis if applicable. + // Apply delay in milliseconds. if (this.delay > 0) { Thread.sleep(this.delay); } @@ -309,36 +404,44 @@ try { writer.close(); } catch (final Exception e) { - System.out.println("Caught exception while closing writer."); - e.printStackTrace(); + LOGGER.log(Level.WARNING, "Error while closing writer.", e); } mevs[0].setLength(buf.position()); mevs[0].setByteOrder(ByteOrder.nativeOrder()); - if (debug) { - for (final EtEvent mev : mevs) { - System.out.println("event length = " + mev.getLength() + ", remaining bytes: " - + mev.getDataBuffer().remaining()); - } + + for (final EtEvent mev : mevs) { + LOGGER.finest("event length = " + mev.getLength() + ", remaining bytes: " + + mev.getDataBuffer().remaining()); } // Put events onto the ET ring. sys.putEvents(att, mevs); - if (debug) { - System.out.println("Wrote event #" + eventCount + " to ET"); - System.out.println("-------------------------------"); - ++eventCount; - } - } - - this.reader.close(); - } - - // Cleanup. - sys.close(); - - } catch (final Exception e) { - throw new RuntimeException(e); + LOGGER.finest("Sucessfully wrote " + eventCount + " event to ET which was EVIO event number " + + event.getEventNumber() + " from file " + evioFile.getPath() + "."); + } + LOGGER.info(eventCount + " events were read from " + evioFile.getPath()); + reader.close(); + } + + } catch (final Exception e) { /* Catches all event processing errors. */ + // This catches and re-throws all errors from processing the EVIO events and configuring the ET system. + throw new RuntimeException("Error streaming EVIO events to ET system.", e); + } finally { + // Cleanup the EVIO reader if needed. + if (reader != null && !reader.isClosed()) { + try { + reader.close(); + } catch (final IOException e) { + LOGGER.log(Level.WARNING, e.getMessage(), e); + } + } + // Cleanup the ET system. + if (sys != null && sys.alive()) { + sys.close(); + } } + + LOGGER.info("Done!"); } } Modified: java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioFileSource.java ============================================================================= --- java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioFileSource.java (original) +++ java/branches/HPSJAVA-488/record-util/src/main/java/org/hps/record/evio/EvioFileSource.java Fri Jun 12 15:27:10 2015 @@ -151,7 +151,7 @@ private void openReader() { try { System.out.println("Opening reader for file " + this.files.get(this.fileIndex) + " ..."); - this.reader = new EvioReader(this.files.get(this.fileIndex), false); + this.reader = new EvioReader(this.files.get(this.fileIndex), false,true); System.out.println("Done opening file."); } catch (EvioException | IOException e) { throw new RuntimeException(e); Modified: java/branches/HPSJAVA-488/steering-files/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/steering-files/pom.xml (original) +++ java/branches/HPSJAVA-488/steering-files/pom.xml Fri Jun 12 15:27:10 2015 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/steering-files/</url> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/DeadtimeMonitor.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/DeadtimeMonitor.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/DeadtimeMonitor.lcsim Fri Jun 12 15:27:10 2015 @@ -5,7 +5,7 @@ <driver name="CleanupDriver" /> </execute> <drivers> - <driver name="DeadtimeMonitor" type="org.hps.monitoring.drivers.scalars.DeadtimePlots"> + <driver name="DeadtimeMonitor" type="org.hps.monitoring.drivers.scalers.DeadtimePlots"> </driver> <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver" /> </drivers> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/Layers4to6TrackingMonitoring.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/Layers4to6TrackingMonitoring.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/Layers4to6TrackingMonitoring.lcsim Fri Jun 12 15:27:10 2015 @@ -1,80 +1,116 @@ <?xml version="1.0" encoding="UTF-8"?> <lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> -<!-- - Steering file for tracking and v0 reconstruction monitoring - @author Matt Graham <[log in to unmask]> ---> - <execute> -<!-- the 3 drivers below are for reading out 6-sample ADC data --> -<!-- <driver name="RawTrackerHitSensorSetup" /> --> - <driver name="RawTrackerHitFitterDriver" /> - <driver name="TrackerHitDriver" /> - <driver name="HelicalTrackHitDriver" /> - <driver name="TrackerL4to6ReconDriver"/> - <driver name="TrackDataDriver"/> - <driver name="EcalRawConverter" /> - <driver name="EcalClusterer" /> - <driver name="ReconParticle" /> -<!-- Online Monitoring Drivers --> - <driver name="TrackingMonitoring" /> - <driver name="TrackingResiduals"/> - <driver name="TrackTime"/> - <driver name="V0Monitoring"/> - <driver name="CleanupDriver" /> + <!-- + Steering file for tracking and v0 reconstruction monitoring, using L1-3 and L4-6 tracking to check SVT opening angle + @author Matt Graham <[log in to unmask]> + --> + <execute> + <!-- the 3 drivers below are for reading out 6-sample ADC data --> + <!-- <driver name="RawTrackerHitSensorSetup" /> --> + <driver name="RawTrackerHitFitterDriver" /> + <driver name="TrackerHitDriver" /> + <driver name="HelicalTrackHitDriver" /> + <!-- SVT opening angle alignment --> + <driver name="TrackerL1to3ReconDriver"/> + <driver name="TrackerL4to6ReconDriver"/> + <driver name="SVTAlignment"/> + <!-- regular tracking and recon --> + <driver name="FullTrackerReconDriver"/> + <driver name="TrackDataDriver"/> + <driver name="EcalRawConverter" /> + <driver name="EcalClusterer" /> + <driver name="ReconParticle" /> + <!-- Online Monitoring Drivers --> + <driver name="TrackingMonitoring" /> + <driver name="TrackingResiduals"/> + <driver name="TrackTime"/> + <driver name="V0Monitoring"/> + <driver name="CleanupDriver" /> </execute> - <drivers> + <drivers> + <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> + <eventInterval>10</eventInterval> + </driver> <driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup" /> - <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver"> + <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver"> <fitAlgorithm>Pileup</fitAlgorithm> <useTimestamps>false</useTimestamps> - <correctT0Shift>false</correctT0Shift> + <correctTimeOffset>true</correctTimeOffset> + <correctT0Shift>true</correctT0Shift> <useTruthTime>false</useTruthTime> + <subtractTOF>true</subtractTOF> + <subtractTriggerTime>true</subtractTriggerTime> + <correctChanT0>true</correctChanT0> <debug>false</debug> </driver> <driver name="TrackerHitDriver" type="org.hps.recon.tracking.DataTrackerHitDriver"> + <neighborDeltaT>8.0</neighborDeltaT> <debug>false</debug> </driver> <driver name="HelicalTrackHitDriver" type="org.hps.recon.tracking.HelicalTrackHitDriver"> <debug>false</debug> -<!-- <clusterTimeCut>16.0</clusterTimeCut> --> - <maxSeperation>20.0</maxSeperation> - <tolerance>1.0</tolerance> + <clusterTimeCut>12.0</clusterTimeCut> + <clusterAmplitudeCut>400.0</clusterAmplitudeCut> + <maxDt>16.0</maxDt> <saveAxialHits>false</saveAxialHits> </driver> - + <driver name="TrackerL1to3ReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> + <debug>false</debug> + <trackCollectionName>L1to3Tracks</trackCollectionName> + <strategyResource>/org/hps/recon/tracking/strategies/HPS-Full-L1-3.xml</strategyResource> + <rmsTimeCut>8.0</rmsTimeCut> + </driver> <driver name="TrackerL4to6ReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> <debug>false</debug> - <trackCollectionName>L4to6Tracks</trackCollectionName> + <trackCollectionName>L4to6Tracks</trackCollectionName> <strategyResource>/org/hps/recon/tracking/strategies/HPS-Full-L4-6.xml</strategyResource> + <rmsTimeCut>8.0</rmsTimeCut> </driver> - + <driver name="FullTrackerReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> + <debug>false</debug> + <trackCollectionName>MatchedTracks</trackCollectionName> + <strategyResource>/org/hps/recon/tracking/strategies/HPS-Full.xml</strategyResource> + <rmsTimeCut>8.0</rmsTimeCut> + </driver> <driver name="TrackDataDriver" type="org.hps.recon.tracking.TrackDataDriver"> - <trackCollectionName>L4to6Tracks</trackCollectionName> </driver> - <driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverterDriver"> - <ecalCollectionName>EcalCalHits</ecalCollectionName> + <driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverterDriver"> + <ecalCollectionName>EcalCalHits</ecalCollectionName> <use2014Gain>false</use2014Gain> <useTimestamps>false</useTimestamps> - <useTruthTime>false</useTruthTime> - <debug>false</debug> + <useTruthTime>false</useTruthTime> + <useRunningPedestal>false</useRunningPedestal> + <useTimeWalkCorrection>false</useTimeWalkCorrection> + <emulateFirmware>true</emulateFirmware> + <emulateMode7>false</emulateMode7> + <leadingEdgeThreshold>12</leadingEdgeThreshold> + <nsa>100</nsa> + <nsb>20</nsb> + <nPeak>3</nPeak> </driver> - <driver name="EcalClusterer" type="org.hps.recon.ecal.cluster.ReconClusterDriver"> - <useTimeCut>true</useTimeCut> - </driver> + <driver name="EcalClusterer" type="org.hps.recon.ecal.cluster.ReconClusterDriver"> + <logLevel>WARNING</logLevel> + <outputClusterCollectionName>EcalClusters</outputClusterCollectionName> + <hitEnergyThreshold>0.01</hitEnergyThreshold> + <seedEnergyThreshold>0.100</seedEnergyThreshold> + <clusterEnergyThreshold>0.200</clusterEnergyThreshold> + <minTime>0.0</minTime> + <timeWindow>25.0</timeWindow> + <useTimeCut>true</useTimeCut> + <writeRejectedHitCollection>false</writeRejectedHitCollection> + </driver> <driver name="ReconParticle" type="org.hps.recon.particle.HpsReconParticleDriver"> - <trackCollectionName>L4to6Tracks</trackCollectionName> <debug>false</debug> </driver> - <driver name="TrackingMonitoring" type="org.hps.monitoring.drivers.trackrecon.TrackingReconPlots"> - <trackCollectionName>L4to6Tracks</trackCollectionName> + <driver name="TrackingMonitoring" type="org.hps.monitoring.drivers.trackrecon.TrackingReconPlots"> </driver> - <driver name="TrackingResiduals" type="org.hps.monitoring.drivers.trackrecon.TrackResiduals"> + <driver name="TrackingResiduals" type="org.hps.monitoring.drivers.trackrecon.TrackResiduals"> </driver> - <driver name="V0Monitoring" type="org.hps.monitoring.drivers.trackrecon.V0ReconPlots"> + <driver name="V0Monitoring" type="org.hps.monitoring.drivers.trackrecon.V0ReconPlots"> </driver> - - <driver name="TrackTime" type="org.hps.monitoring.drivers.trackrecon.TrackTimePlots"> - <trackCollectionName>L4to6Tracks</trackCollectionName> + <driver name="SVTAlignment" type="org.hps.monitoring.drivers.trackrecon.SVTOpeningAlignment"> + </driver> + <driver name="TrackTime" type="org.hps.monitoring.drivers.trackrecon.TrackTimePlots"> </driver> <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver" /> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/LooseTrackingAndReconMonitoring.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/LooseTrackingAndReconMonitoring.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/LooseTrackingAndReconMonitoring.lcsim Fri Jun 12 15:27:10 2015 @@ -1,68 +1,88 @@ <?xml version="1.0" encoding="UTF-8"?> <lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> -<!-- - Steering file for tracking and v0 reconstruction monitoring - @author Matt Graham <[log in to unmask]> ---> + <!-- + Steering file for tracking and v0 reconstruction monitoring, using an outside-in tracking strategy for more flexibility in opening angle + @author Matt Graham <[log in to unmask]> + --> <execute> -<!-- the 3 drivers below are for reading out 6-sample ADC data --> -<!-- <driver name="RawTrackerHitSensorSetup" /> --> - <driver name="RawTrackerHitFitterDriver" /> - <driver name="TrackerHitDriver" /> - <driver name="HelicalTrackHitDriver" /> -<!-- regular tracking and recon --> - <driver name="FullTrackerReconDriver"/> - <driver name="TrackDataDriver"/> - <driver name="EcalRawConverter" /> - <driver name="EcalClusterer" /> - <driver name="ReconParticle" /> -<!-- Online Monitoring Drivers --> - <driver name="TrackingMonitoring" /> - <driver name="TrackingResiduals"/> - <driver name="TrackTime"/> - <driver name="V0Monitoring"/> - <driver name="CleanupDriver" /> + <!-- the 3 drivers below are for reading out 6-sample ADC data --> + <!-- <driver name="RawTrackerHitSensorSetup" /> --> + <driver name="RawTrackerHitFitterDriver" /> + <driver name="TrackerHitDriver" /> + <driver name="HelicalTrackHitDriver" /> + <!-- regular tracking and recon --> + <driver name="FullTrackerReconDriver"/> + <driver name="TrackDataDriver"/> + <driver name="EcalRawConverter" /> + <driver name="EcalClusterer" /> + <driver name="ReconParticle" /> + <!-- Online Monitoring Drivers --> + <driver name="TrackingMonitoring" /> + <driver name="TrackingResiduals"/> + <driver name="TrackTime"/> + <driver name="V0Monitoring"/> + <driver name="CleanupDriver" /> </execute> <drivers> - <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> + <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> <eventInterval>10</eventInterval> </driver> <driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup" /> - <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver"> + <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver"> <fitAlgorithm>Pileup</fitAlgorithm> <useTimestamps>false</useTimestamps> - <correctT0Shift>false</correctT0Shift> + <correctTimeOffset>true</correctTimeOffset> + <correctT0Shift>true</correctT0Shift> <useTruthTime>false</useTruthTime> + <subtractTOF>true</subtractTOF> + <subtractTriggerTime>true</subtractTriggerTime> + <correctChanT0>true</correctChanT0> <debug>false</debug> </driver> <driver name="TrackerHitDriver" type="org.hps.recon.tracking.DataTrackerHitDriver"> + <neighborDeltaT>8.0</neighborDeltaT> <debug>false</debug> </driver> <driver name="HelicalTrackHitDriver" type="org.hps.recon.tracking.HelicalTrackHitDriver"> <debug>false</debug> -<!-- <clusterTimeCut>16.0</clusterTimeCut> --> - <maxSeperation>20.0</maxSeperation> - <tolerance>1.0</tolerance> + <clusterTimeCut>12.0</clusterTimeCut> + <clusterAmplitudeCut>400.0</clusterAmplitudeCut> + <maxDt>16.0</maxDt> <saveAxialHits>false</saveAxialHits> </driver> <driver name="FullTrackerReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> <debug>false</debug> <trackCollectionName>MatchedTracks</trackCollectionName> - <strategyResource>/org/hps/recon/tracking/strategies/HPS-Full-Loose.xml</strategyResource> + <strategyResource>/org/hps/recon/tracking/strategies/HPS-Full-OutsideIn.xml</strategyResource> + <rmsTimeCut>8.0</rmsTimeCut> </driver> <driver name="TrackDataDriver" type="org.hps.recon.tracking.TrackDataDriver"> </driver> - <driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverterDriver"> - <ecalCollectionName>EcalCalHits</ecalCollectionName> + <driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverterDriver"> + <ecalCollectionName>EcalCalHits</ecalCollectionName> <use2014Gain>false</use2014Gain> <useTimestamps>false</useTimestamps> - <useTruthTime>false</useTruthTime> - <debug>false</debug> + <useTruthTime>false</useTruthTime> + <useRunningPedestal>false</useRunningPedestal> + <useTimeWalkCorrection>false</useTimeWalkCorrection> + <emulateFirmware>true</emulateFirmware> + <emulateMode7>false</emulateMode7> + <leadingEdgeThreshold>12</leadingEdgeThreshold> + <nsa>100</nsa> + <nsb>20</nsb> + <nPeak>3</nPeak> </driver> - <driver name="EcalClusterer" type="org.hps.recon.ecal.cluster.ReconClusterDriver"> - <useTimeCut>true</useTimeCut> - <logLevel>ALL</logLevel> - </driver> + <driver name="EcalClusterer" type="org.hps.recon.ecal.cluster.ReconClusterDriver"> + <logLevel>WARNING</logLevel> + <outputClusterCollectionName>EcalClusters</outputClusterCollectionName> + <hitEnergyThreshold>0.01</hitEnergyThreshold> + <seedEnergyThreshold>0.100</seedEnergyThreshold> + <clusterEnergyThreshold>0.200</clusterEnergyThreshold> + <minTime>0.0</minTime> + <timeWindow>25.0</timeWindow> + <useTimeCut>true</useTimeCut> + <writeRejectedHitCollection>false</writeRejectedHitCollection> + </driver> <driver name="ReconParticle" type="org.hps.recon.particle.HpsReconParticleDriver"> <debug>false</debug> </driver> @@ -70,7 +90,7 @@ </driver> <driver name="TrackingResiduals" type="org.hps.monitoring.drivers.trackrecon.TrackResiduals"> </driver> - <driver name="V0Monitoring" type="org.hps.monitoring.drivers.trackrecon.V0ReconPlots"> + <driver name="V0Monitoring" type="org.hps.monitoring.drivers.trackrecon.V0ReconPlots"> </driver> <driver name="TrackTime" type="org.hps.monitoring.drivers.trackrecon.TrackTimePlots"> </driver> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/TrackingAndReconMonitoring.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/TrackingAndReconMonitoring.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/monitoring/TrackingAndReconMonitoring.lcsim Fri Jun 12 15:27:10 2015 @@ -1,82 +1,87 @@ <?xml version="1.0" encoding="UTF-8"?> <lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> -<!-- - Steering file for tracking and v0 reconstruction monitoring - @author Matt Graham <[log in to unmask]> ---> + <!-- + Steering file for tracking and v0 reconstruction monitoring + @author Matt Graham <[log in to unmask]> + --> <execute> -<!-- the 3 drivers below are for reading out 6-sample ADC data --> -<!-- <driver name="RawTrackerHitSensorSetup" /> --> - <driver name="RawTrackerHitFitterDriver" /> - <driver name="TrackerHitDriver" /> - <driver name="HelicalTrackHitDriver" /> -<!-- SVT opening angle alignment --> - <driver name="TrackerL1to3ReconDriver"/> - <driver name="TrackerL4to6ReconDriver"/> - <driver name="SVTAlignment"/> -<!-- regular tracking and recon --> - <driver name="FullTrackerReconDriver"/> - <driver name="TrackDataDriver"/> - <driver name="EcalRawConverter" /> - <driver name="EcalClusterer" /> - <driver name="ReconParticle" /> -<!-- Online Monitoring Drivers --> - <driver name="TrackingMonitoring" /> - <driver name="TrackingResiduals"/> - <driver name="TrackTime"/> - <driver name="V0Monitoring"/> - <driver name="CleanupDriver" /> + <!-- the 3 drivers below are for reading out 6-sample ADC data --> + <!-- <driver name="RawTrackerHitSensorSetup" /> --> + <driver name="RawTrackerHitFitterDriver" /> + <driver name="TrackerHitDriver" /> + <driver name="HelicalTrackHitDriver" /> + <driver name="TrackerReconDriver"/> + <driver name="TrackDataDriver"/> + <driver name="EcalRawConverter" /> + <driver name="EcalClusterer" /> + <driver name="ReconParticle" /> + <!-- Online Monitoring Drivers --> + <driver name="TrackingMonitoring" /> + <driver name="TrackingResiduals"/> + <driver name="TrackTime"/> + <driver name="V0Monitoring"/> + <driver name="CleanupDriver" /> </execute> <drivers> - <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> + <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> <eventInterval>10</eventInterval> </driver> <driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup" /> <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver"> <fitAlgorithm>Pileup</fitAlgorithm> <useTimestamps>false</useTimestamps> - <correctT0Shift>false</correctT0Shift> + <correctTimeOffset>true</correctTimeOffset> + <correctT0Shift>true</correctT0Shift> <useTruthTime>false</useTruthTime> + <subtractTOF>true</subtractTOF> + <subtractTriggerTime>true</subtractTriggerTime> + <correctChanT0>true</correctChanT0> <debug>false</debug> </driver> <driver name="TrackerHitDriver" type="org.hps.recon.tracking.DataTrackerHitDriver"> + <neighborDeltaT>8.0</neighborDeltaT> <debug>false</debug> </driver> <driver name="HelicalTrackHitDriver" type="org.hps.recon.tracking.HelicalTrackHitDriver"> <debug>false</debug> -<!-- <clusterTimeCut>16.0</clusterTimeCut> --> - <maxSeperation>20.0</maxSeperation> - <tolerance>1.0</tolerance> + <clusterTimeCut>12.0</clusterTimeCut> + <clusterAmplitudeCut>400.0</clusterAmplitudeCut> + <maxDt>16.0</maxDt> <saveAxialHits>false</saveAxialHits> </driver> - <driver name="TrackerL1to3ReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> - <debug>false</debug> - <trackCollectionName>L1to3Tracks</trackCollectionName> - <strategyResource>/org/hps/recon/tracking/strategies/HPS-Full-L1-3.xml</strategyResource> - </driver> - <driver name="TrackerL4to6ReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> - <debug>false</debug> - <trackCollectionName>L4to6Tracks</trackCollectionName> - <strategyResource>/org/hps/recon/tracking/strategies/HPS-Full-L4-6.xml</strategyResource> - </driver> - <driver name="FullTrackerReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> + <driver name="TrackerReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> <debug>false</debug> <trackCollectionName>MatchedTracks</trackCollectionName> <strategyResource>/org/hps/recon/tracking/strategies/HPS-Full.xml</strategyResource> + <rmsTimeCut>8.0</rmsTimeCut> </driver> <driver name="TrackDataDriver" type="org.hps.recon.tracking.TrackDataDriver"> </driver> - <driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverterDriver"> - <ecalCollectionName>EcalCalHits</ecalCollectionName> + <driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverterDriver"> + <ecalCollectionName>EcalCalHits</ecalCollectionName> <use2014Gain>false</use2014Gain> <useTimestamps>false</useTimestamps> - <useTruthTime>false</useTruthTime> - <debug>false</debug> - </driver> - <driver name="EcalClusterer" type="org.hps.recon.ecal.cluster.ReconClusterDriver"> - <useTimeCut>true</useTimeCut> - <logLevel>ALL</logLevel> - </driver> + <useTruthTime>false</useTruthTime> + <useRunningPedestal>false</useRunningPedestal> + <useTimeWalkCorrection>false</useTimeWalkCorrection> + <emulateFirmware>true</emulateFirmware> + <emulateMode7>false</emulateMode7> + <leadingEdgeThreshold>12</leadingEdgeThreshold> + <nsa>100</nsa> + <nsb>20</nsb> + <nPeak>3</nPeak> + </driver> + <driver name="EcalClusterer" type="org.hps.recon.ecal.cluster.ReconClusterDriver"> + <logLevel>WARNING</logLevel> + <outputClusterCollectionName>EcalClusters</outputClusterCollectionName> + <hitEnergyThreshold>0.01</hitEnergyThreshold> + <seedEnergyThreshold>0.100</seedEnergyThreshold> + <clusterEnergyThreshold>0.200</clusterEnergyThreshold> + <minTime>0.0</minTime> + <timeWindow>25.0</timeWindow> + <useTimeCut>true</useTimeCut> + <writeRejectedHitCollection>false</writeRejectedHitCollection> + </driver> <driver name="ReconParticle" type="org.hps.recon.particle.HpsReconParticleDriver"> <debug>false</debug> </driver> @@ -84,10 +89,8 @@ </driver> <driver name="TrackingResiduals" type="org.hps.monitoring.drivers.trackrecon.TrackResiduals"> </driver> - <driver name="V0Monitoring" type="org.hps.monitoring.drivers.trackrecon.V0ReconPlots"> + <driver name="V0Monitoring" type="org.hps.monitoring.drivers.trackrecon.V0ReconPlots"> </driver> - <driver name="SVTAlignment" type="org.hps.monitoring.drivers.trackrecon.SVTOpeningAlignment"> - </driver> <driver name="TrackTime" type="org.hps.monitoring.drivers.trackrecon.TrackTimePlots"> </driver> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/production/DataQualityRecon.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/production/DataQualityRecon.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/production/DataQualityRecon.lcsim Fri Jun 12 15:27:10 2015 @@ -8,21 +8,52 @@ <driver name="EventMarkerDriver"/> <!-- <driver name="DQMDatabaseDriver"/> --> <driver name="RawTrackerHitSensorSetup"/> + <driver name="EcalMonitoring"/> <driver name="SVTMonitoring"/> - <driver name="SVTHitMCEfficiency"/> <driver name="TrackingMonitoring"/> <driver name="TrackingResiduals"/> - <driver name="TrackMCEfficiency"/> <driver name="FinalStateMonitoring"/> <driver name="V0Monitoring"/> <driver name="TridentMonitoring"/> +<!-- Singles0 --> + <driver name="EcalMonitoringSingles0"/> +<!-- <driver name="SVTMonitoringSingles0"/> --> + <driver name="TrackingMonitoringSingles0"/> + <driver name="TrackingResidualsSingles0"/> + <driver name="FinalStateMonitoringSingles0"/> + <driver name="V0MonitoringSingles0"/> + <driver name="TridentMonitoringSingles0"/> +<!-- Singles1 --> + <driver name="EcalMonitoringSingles1"/> + <!-- <driver name="SVTMonitoringSingles1"/> --> + <driver name="TrackingMonitoringSingles1"/> + <driver name="TrackingResidualsSingles1"/> + <driver name="FinalStateMonitoringSingles1"/> + <driver name="V0MonitoringSingles1"/> + <driver name="TridentMonitoringSingles1"/> +<!-- Pairs0 --> + <driver name="EcalMonitoringPairs0"/> + <!-- <driver name="SVTMonitoringPairs0"/> --> + <driver name="TrackingMonitoringPairs0"/> + <driver name="TrackingResidualsPairs0"/> + <driver name="FinalStateMonitoringPairs0"/> + <driver name="V0MonitoringPairs0"/> + <driver name="TridentMonitoringPairs0"/> +<!-- Pairs1 --> + <driver name="EcalMonitoringPairs1"/> + <!-- <driver name="SVTMonitoringPairs1"/> --> + <driver name="TrackingMonitoringPairs1"/> + <driver name="TrackingResidualsPairs1"/> + <driver name="FinalStateMonitoringPairs1"/> + <driver name="V0MonitoringPairs1"/> + <driver name="TridentMonitoringPairs1"/> <driver name="AidaSaveDriver"/> <driver name="CleanupDriver"/> </execute> <drivers> <!-- <driver name="DQMDatabaseDriver" type="org.hps.analysis.dataquality.DQMDatabaseDriver"/> --> <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> - <eventInterval>1</eventInterval> + <eventInterval>1000</eventInterval> </driver> <driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup"> <readoutCollections>SVTRawTrackerHits</readoutCollections> @@ -30,29 +61,127 @@ <driver name="AidaSaveDriver" type="org.lcsim.job.AidaSaveDriver"> <outputFileName>${outputFile}.root</outputFileName> </driver> - <driver name="SVTMonitoring" type="org.hps.analysis.dataquality.SvtMonitoring"> - <overwriteDB>false</overwriteDB> + +<!-- all triggers --> + <driver name="EcalMonitoring" type="org.hps.analysis.dataquality.EcalMonitoring"> + <triggerType>all</triggerType> </driver> + <driver name="SVTMonitoring" type="org.hps.analysis.dataquality.SvtMonitoring"> + <triggerType>all</triggerType> + </driver> <driver name="TrackingMonitoring" type="org.hps.analysis.dataquality.TrackingMonitoring"> <overwriteDB>false</overwriteDB> + <triggerType>all</triggerType> </driver> <driver name="TrackingResiduals" type="org.hps.analysis.dataquality.TrackingResiduals"> - <overwriteDB>false</overwriteDB> + <triggerType>all</triggerType> </driver> <driver name="FinalStateMonitoring" type="org.hps.analysis.dataquality.FinalStateMonitoring"> - <overwriteDB>false</overwriteDB> + <triggerType>all</triggerType> </driver> - <driver name="TrackMCEfficiency" type="org.hps.analysis.dataquality.TrackMCEfficiency"> - <overwriteDB>false</overwriteDB> - </driver> - <driver name="SVTHitMCEfficiency" type="org.hps.analysis.dataquality.SVTHitMCEfficiency"> - <overwriteDB>false</overwriteDB> - </driver> <driver name="V0Monitoring" type="org.hps.analysis.dataquality.V0Monitoring"> - <overwriteDB>false</overwriteDB> + <triggerType>all</triggerType> </driver> <driver name="TridentMonitoring" type="org.hps.analysis.dataquality.TridentMonitoring"> + <triggerType>all</triggerType> + </driver> + +<!-- singles0 triggers --> + <driver name="EcalMonitoringSingles0" type="org.hps.analysis.dataquality.EcalMonitoring"> + <triggerType>singles0</triggerType> + </driver> + <driver name="SVTMonitoringSingles0" type="org.hps.analysis.dataquality.SvtMonitoring"> + <triggerType>singles0</triggerType> + </driver> + <driver name="TrackingMonitoringSingles0" type="org.hps.analysis.dataquality.TrackingMonitoring"> <overwriteDB>false</overwriteDB> + <triggerType>singles0</triggerType> + </driver> + <driver name="TrackingResidualsSingles0" type="org.hps.analysis.dataquality.TrackingResiduals"> + <triggerType>singles0</triggerType> + </driver> + <driver name="FinalStateMonitoringSingles0" type="org.hps.analysis.dataquality.FinalStateMonitoring"> + <triggerType>singles0</triggerType> + </driver> + <driver name="V0MonitoringSingles0" type="org.hps.analysis.dataquality.V0Monitoring"> + <triggerType>singles0</triggerType> + </driver> + <driver name="TridentMonitoringSingles0" type="org.hps.analysis.dataquality.TridentMonitoring"> + <triggerType>singles0</triggerType> + </driver> + +<!-- singles1 triggers --> + <driver name="EcalMonitoringSingles1" type="org.hps.analysis.dataquality.EcalMonitoring"> + <triggerType>singles1</triggerType> + </driver> + <driver name="SVTMonitoringSingles1" type="org.hps.analysis.dataquality.SvtMonitoring"> + <triggerType>singles1</triggerType> + </driver> + <driver name="TrackingMonitoringSingles1" type="org.hps.analysis.dataquality.TrackingMonitoring"> + <overwriteDB>false</overwriteDB> + <triggerType>singles1</triggerType> + </driver> + <driver name="TrackingResidualsSingles1" type="org.hps.analysis.dataquality.TrackingResiduals"> + <triggerType>singles1</triggerType> + </driver> + <driver name="FinalStateMonitoringSingles1" type="org.hps.analysis.dataquality.FinalStateMonitoring"> + <triggerType>singles1</triggerType> + </driver> + <driver name="V0MonitoringSingles1" type="org.hps.analysis.dataquality.V0Monitoring"> + <triggerType>singles1</triggerType> + </driver> + <driver name="TridentMonitoringSingles1" type="org.hps.analysis.dataquality.TridentMonitoring"> + <triggerType>singles1</triggerType> + </driver> + +<!-- pairs0 triggers --> + <driver name="EcalMonitoringPairs0" type="org.hps.analysis.dataquality.EcalMonitoring"> + <triggerType>pairs0</triggerType> + </driver> + <driver name="SVTMonitoringPairs0" type="org.hps.analysis.dataquality.SvtMonitoring"> + <triggerType>pairs0</triggerType> + </driver> + <driver name="TrackingMonitoringPairs0" type="org.hps.analysis.dataquality.TrackingMonitoring"> + <overwriteDB>false</overwriteDB> + <triggerType>pairs0</triggerType> + </driver> + <driver name="TrackingResidualsPairs0" type="org.hps.analysis.dataquality.TrackingResiduals"> + <triggerType>pairs0</triggerType> + </driver> + <driver name="FinalStateMonitoringPairs0" type="org.hps.analysis.dataquality.FinalStateMonitoring"> + <triggerType>pairs0</triggerType> + </driver> + <driver name="V0MonitoringPairs0" type="org.hps.analysis.dataquality.V0Monitoring"> + <triggerType>pairs0</triggerType> + </driver> + <driver name="TridentMonitoringPairs0" type="org.hps.analysis.dataquality.TridentMonitoring"> + <triggerType>pairs0</triggerType> + </driver> + + + +<!-- pairs1 triggers --> + <driver name="EcalMonitoringPairs1" type="org.hps.analysis.dataquality.EcalMonitoring"> + <triggerType>pairs1</triggerType> + </driver> + <driver name="SVTMonitoringPairs1" type="org.hps.analysis.dataquality.SvtMonitoring"> + <triggerType>pairs1</triggerType> + </driver> + <driver name="TrackingMonitoringPairs1" type="org.hps.analysis.dataquality.TrackingMonitoring"> + <overwriteDB>false</overwriteDB> + <triggerType>pairs1</triggerType> + </driver> + <driver name="TrackingResidualsPairs1" type="org.hps.analysis.dataquality.TrackingResiduals"> + <triggerType>pairs1</triggerType> + </driver> + <driver name="FinalStateMonitoringPairs1" type="org.hps.analysis.dataquality.FinalStateMonitoring"> + <triggerType>pairs1</triggerType> + </driver> + <driver name="V0MonitoringPairs1" type="org.hps.analysis.dataquality.V0Monitoring"> + <triggerType>pairs1</triggerType> + </driver> + <driver name="TridentMonitoringPairs1" type="org.hps.analysis.dataquality.TridentMonitoring"> + <triggerType>pairs1</triggerType> </driver> <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver"/> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014ReadoutNoPileup.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014ReadoutNoPileup.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014ReadoutNoPileup.lcsim Fri Jun 12 15:27:10 2015 @@ -21,13 +21,10 @@ <driver name="CleanupDriver"/> </execute> <drivers> - - - - <driver name="ConditionsDriver" type="org.hps.conditions.ConditionsDriver"> - <runNumber>4888</runNumber> - <detectorName>HPS-Proposal2014-v6-2pt2</detectorName> - <freeze>true</freeze> + <driver name="ConditionsDriver" type="org.hps.conditions.ConditionsDriver"> + <detectorName>${detector}</detectorName> + <runNumber>${run}</runNumber> + <freeze>true</freeze> </driver> <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> <eventInterval>1000</eventInterval> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014ReadoutToEvio.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014ReadoutToEvio.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014ReadoutToEvio.lcsim Fri Jun 12 15:27:10 2015 @@ -25,9 +25,9 @@ <eventInterval>1000</eventInterval> </driver> <driver name="ConditionsDriver" type="org.hps.conditions.ConditionsDriver"> - <runNumber>4888</runNumber> - <detectorName>HPS-Proposal2014-v6-2pt2</detectorName> - <freeze>true</freeze> + <detectorName>${detector}</detectorName> + <runNumber>${run}</runNumber> + <freeze>true</freeze> </driver> <driver name="TestRunReconToEvio" type="org.hps.evio.TestRunTriggeredReconToEvio"> <evioOutputFile>${outputFile}.evio</evioOutputFile> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014ReadoutToLcio.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014ReadoutToLcio.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014ReadoutToLcio.lcsim Fri Jun 12 15:27:10 2015 @@ -25,9 +25,9 @@ <eventInterval>1000</eventInterval> </driver> <driver name="ConditionsDriver" type="org.hps.conditions.ConditionsDriver"> - <runNumber>4888</runNumber> - <detectorName>HPS-Proposal2014-v6-2pt2</detectorName> - <freeze>true</freeze> + <detectorName>${detector}</detectorName> + <runNumber>${run}</runNumber> + <freeze>true</freeze> </driver> <driver name="TestRunReconToLcio" type="org.hps.evio.TestRunTriggeredReconToLcio"> <outputFile>${outputFile}.slcio</outputFile> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014TruthReadoutToLcio.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014TruthReadoutToLcio.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/readout/HPS2014TruthReadoutToLcio.lcsim Fri Jun 12 15:27:10 2015 @@ -26,10 +26,10 @@ <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> <eventInterval>1000</eventInterval> </driver> - <driver name="ConditionsDriver" type="org.hps.conditions.ConditionsDriver"> - <runNumber>4888</runNumber> - <detectorName>HPS-Proposal2014-v6-2pt2</detectorName> - <freeze>true</freeze> + <driver name="ConditionsDriver" type="org.hps.conditions.ConditionsDriver"> + <detectorName>${detector}</detectorName> + <runNumber>${run}</runNumber> + <freeze>true</freeze> </driver> <driver name="TestRunReconToLcio" type="org.hps.evio.TestRunTriggeredReconToLcio"> <outputFile>${outputFile}.slcio</outputFile> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullRecon.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullRecon.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/EngineeringRun2015FullRecon.lcsim Fri Jun 12 15:27:10 2015 @@ -1,11 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> <!-- Offline reconstruction for 2015 (engineering run with SVT+ECal) data. @author Sho Uemura <[log in to unmask]> --> -<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="RawTrackerHitSensorSetup"/> <driver name="RawTrackerHitFitterDriver" /> <driver name="TrackerHitDriver"/> <driver name="HelicalTrackHitDriver"/> @@ -14,26 +15,29 @@ <driver name="EcalRawConverter" /> <driver name="ReconClusterer" /> <driver name="GTPOnlineClusterer" /> + <driver name="CopyCluster" /> <driver name="ReconParticle" /> <driver name="TrackDataDriver" /> <!--<driver name="GBLDriver"/>--> <driver name="LCIOWriter"/> - <driver name="CleanupDriver"/> </execute> <drivers> <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> - <eventInterval>100</eventInterval> + <eventInterval>1000</eventInterval> </driver> + <driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup"> + <readoutCollections>SVTRawTrackerHits</readoutCollections> + </driver> <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver"> <fitAlgorithm>Pileup</fitAlgorithm> <useTimestamps>false</useTimestamps> - <correctT0Shift>false</correctT0Shift> + <correctTimeOffset>true</correctTimeOffset> + <correctT0Shift>true</correctT0Shift> <useTruthTime>false</useTruthTime> <subtractTOF>true</subtractTOF> <subtractTriggerTime>true</subtractTriggerTime> <correctChanT0>true</correctChanT0> - <timeOffset>51.0</timeOffset> <debug>false</debug> </driver> <driver name="TrackerHitDriver" type="org.hps.recon.tracking.DataTrackerHitDriver"> @@ -43,11 +47,10 @@ <debug>false</debug> <clusterTimeCut>12.0</clusterTimeCut> <maxDt>16.0</maxDt> - <maxSeperation>20.0</maxSeperation> - <tolerance>1.0</tolerance> + <clusterAmplitudeCut>400.0</clusterAmplitudeCut> </driver> <driver name="TrackerReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> - <strategyResource>HPS-Full-Loose.xml</strategyResource> + <strategyResource>HPS-Full.xml</strategyResource> <debug>false</debug> <rmsTimeCut>8.0</rmsTimeCut> </driver> @@ -58,8 +61,8 @@ </driver> <driver name="EcalRunningPedestal" type="org.hps.recon.ecal.EcalRunningPedestalDriver"> <logLevel>CONFIG</logLevel> - <minLookbackEvents>10</minLookbackEvents> - <maxLookbackEvents>50</maxLookbackEvents> + <minLookbackEvents>5</minLookbackEvents> + <maxLookbackEvents>40</maxLookbackEvents> </driver> <driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverterDriver"> <ecalCollectionName>EcalCalHits</ecalCollectionName> @@ -67,21 +70,22 @@ <useTimestamps>false</useTimestamps> <useTruthTime>false</useTruthTime> <useRunningPedestal>true</useRunningPedestal> - <useTimeWalkCorrection>true</useTimeWalkCorrection> + <useTimeWalkCorrection>false</useTimeWalkCorrection> <emulateFirmware>true</emulateFirmware> - <emulateMode7>false</emulateMode7> + <emulateMode7>true</emulateMode7> <leadingEdgeThreshold>12</leadingEdgeThreshold> <nsa>100</nsa> <nsb>20</nsb> - <windowSamples>50</windowSamples> <nPeak>3</nPeak> + <useFit>true</useFit> + <fixShapeParameter>true</fixShapeParameter> </driver> <driver name="ReconClusterer" type="org.hps.recon.ecal.cluster.ReconClusterDriver"> <logLevel>WARNING</logLevel> <outputClusterCollectionName>EcalClusters</outputClusterCollectionName> - <hitEnergyThreshold>0.01</hitEnergyThreshold> - <seedEnergyThreshold>0.100</seedEnergyThreshold> - <clusterEnergyThreshold>0.200</clusterEnergyThreshold> + <hitEnergyThreshold>0.0075</hitEnergyThreshold> + <seedEnergyThreshold>0.050</seedEnergyThreshold> + <clusterEnergyThreshold>0.100</clusterEnergyThreshold> <minTime>0.0</minTime> <timeWindow>25.0</timeWindow> <useTimeCut>true</useTimeCut> @@ -93,8 +97,14 @@ <outputClusterCollectionName>EcalClustersGTP</outputClusterCollectionName> <!-- seedMinEnergy --> <cuts>0.100</cuts> - </driver> - <driver name="ReconParticle" type="org.hps.recon.particle.HpsReconParticleDriver"> + </driver> + <driver name="CopyCluster" type="org.hps.recon.ecal.cluster.CopyClusterCollectionDriver"> + <inputCollectionName>EcalClusters</inputCollectionName> + <outputCollectionName>EcalClustersCorr</outputCollectionName> + <storeHits>true</storeHits> + </driver> + <driver name="ReconParticle" type="org.hps.recon.particle.HpsReconParticleDriver"> + <ecalClusterCollectionName>EcalClustersCorr</ecalClusterCollectionName> </driver> <driver name="TrackDataDriver" type="org.hps.recon.tracking.TrackDataDriver" /> <driver name="LCIOWriter" type="org.lcsim.util.loop.LCIODriver"> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineNoPileupRecon.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineNoPileupRecon.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineNoPileupRecon.lcsim Fri Jun 12 15:27:10 2015 @@ -8,6 +8,7 @@ <execute> <driver name="EventMarkerDriver"/> <driver name="ConditionsDriver"/> + <driver name="RawTrackerHitSensorSetup"/> <driver name="RawTrackerHitFitterDriver" /> <driver name="TrackerHitDriver"/> <driver name="HelicalTrackHitDriver"/> @@ -31,7 +32,9 @@ <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> <eventInterval>1000</eventInterval> </driver> - <driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup"/> + <driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup"> + <readoutCollections>SVTRawTrackerHits</readoutCollections> + </driver> <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver"> <fitAlgorithm>Analytic</fitAlgorithm> <useTimestamps>false</useTimestamps> @@ -42,8 +45,6 @@ <driver name="HelicalTrackHitDriver" type="org.hps.recon.tracking.HelicalTrackHitDriver"> <debug>false</debug> <!--<clusterTimeCut>16.0</clusterTimeCut>--> - <maxSeperation>20.0</maxSeperation> - <tolerance>1.0</tolerance> </driver> <driver name="TrackerReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> <strategyResource>HPS-Full.xml</strategyResource> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineRecon.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineRecon.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineRecon.lcsim Fri Jun 12 15:27:10 2015 @@ -6,6 +6,7 @@ xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> <execute> <driver name="EventMarkerDriver"/> + <driver name="RawTrackerHitSensorSetup"/> <driver name="RawTrackerHitFitterDriver" /> <driver name="TrackerHitDriver"/> <driver name="HelicalTrackHitDriver"/> @@ -22,6 +23,9 @@ <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> <eventInterval>1000</eventInterval> </driver> + <driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup"> + <readoutCollections>SVTRawTrackerHits</readoutCollections> + </driver> <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver"> <fitAlgorithm>Pileup</fitAlgorithm> <useTimestamps>false</useTimestamps> @@ -37,8 +41,6 @@ <debug>false</debug> <!--<clusterTimeCut>12.0</clusterTimeCut>--> <maxDt>16.0</maxDt> - <maxSeperation>20.0</maxSeperation> - <tolerance>1.0</tolerance> </driver> <driver name="TrackerReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> <strategyResource>HPS-Full.xml</strategyResource> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineTruthRecon.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineTruthRecon.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPS2014OfflineTruthRecon.lcsim Fri Jun 12 15:27:10 2015 @@ -7,7 +7,8 @@ xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> <execute> <driver name="EventMarkerDriver"/> - <driver name="ConditionsDriver"/> + <driver name="RawTrackerHitSensorSetup"/> + <driver name="ConditionsDriver"/> <driver name="RawTrackerHitFitterDriver" /> <driver name="TrackerHitDriver"/> <driver name="HelicalTrackHitDriver"/> @@ -29,7 +30,9 @@ <runNumber>4888</runNumber> <freeze>true</freeze> </driver> - <driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup"/> + <driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup"> + <readoutCollections>SVTRawTrackerHits</readoutCollections> + </driver> <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver"> <fitAlgorithm>Pileup</fitAlgorithm> <useTimestamps>false</useTimestamps> @@ -45,8 +48,6 @@ <debug>false</debug> <!--<clusterTimeCut>12.0</clusterTimeCut>--> <maxDt>16.0</maxDt> - <maxSeperation>20.0</maxSeperation> - <tolerance>1.0</tolerance> </driver> <driver name="TrackerReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> <strategyResource>HPS-Full.xml</strategyResource> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPSTrackingDefaultsRecon.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPSTrackingDefaultsRecon.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/recon/HPSTrackingDefaultsRecon.lcsim Fri Jun 12 15:27:10 2015 @@ -6,7 +6,8 @@ </control> <execute> <driver name="EventMarkerDriver"/> - <driver name="ConditionsDriver"/> + <driver name="RawTrackerHitSensorSetup"/> + <driver name="ConditionsDriver"/> <driver name="RawTrackerHitFitterDriver" /> <driver name="TrackerHitDriver" /> <driver name="HelicalTrackHitDriver" /> @@ -24,7 +25,9 @@ <freeze>true</freeze> </driver> <driver name="SVTBadChannelFilterDriver" type="org.hps.recon.tracking.SVTBadChannelFilterDriver"/> - <driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup"/> + <driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup"> + <readoutCollections>SVTRawTrackerHits</readoutCollections> + </driver> <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver"> <fitAlgorithm>Analytic</fitAlgorithm> <correctT0Shift>true</correctT0Shift> @@ -32,8 +35,6 @@ <driver name="TrackerHitDriver" type="org.hps.recon.tracking.DataTrackerHitDriver" /> <driver name="HelicalTrackHitDriver" type="org.hps.recon.tracking.HelicalTrackHitDriver"> <debug>false</debug> - <maxSeperation>20.0</maxSeperation> - <tolerance>1.0</tolerance> </driver> <driver name="TrackerReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> <debug>false</debug> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/mgraham/TrackingAndReconMonitoring.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/mgraham/TrackingAndReconMonitoring.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/mgraham/TrackingAndReconMonitoring.lcsim Fri Jun 12 15:27:10 2015 @@ -1,73 +1,121 @@ <?xml version="1.0" encoding="UTF-8"?> <lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> -<!-- - Steering file for tracking and v0 reconstruction monitoring - @author Matt Graham <[log in to unmask]> ---> + <!-- + Steering file for tracking and v0 reconstruction monitoring + @author Matt Graham <[log in to unmask]> + --> <execute> - <driver name="EventMarkerDriver" /> -<!-- the 3 drivers below are for reading out 6-sample ADC data --> - <driver name="RawTrackerHitSensorSetup" /> - <driver name="RawTrackerHitFitterDriver" /> - <driver name="TrackerHitDriver" /> - <driver name="HelicalTrackHitDriver" /> -<!-- SVT opening angle alignment --> - <driver name="TrackerL1to3ReconDriver"/> - <driver name="TrackerL4to6ReconDriver"/> - <driver name="SVTAlignment"/> -<!-- regular tracking and recon --> - <driver name="FullTrackerReconDriver"/> - <driver name="TrackDataDriver"/> - <driver name="EcalRawConverter" /> - <driver name="EcalClusterer" /> - <driver name="ReconParticle" /> -<!-- Online Monitoring Drivers --> - <driver name="TrackingMonitoring" /> - <driver name="TrackingResiduals"/> - <driver name="TrackTime"/> - <driver name="V0Monitoring"/> - <driver name="CleanupDriver" /> + <driver name="EventMarkerDriver" /> + <!-- Standard Reconstruction --> + <driver name="RawTrackerHitFitterDriver" /> + <driver name="TrackerHitDriver"/> + <driver name="HelicalTrackHitDriver"/> + <driver name="FullTrackerReconDriver"/><!-- + <driver name="TrackDataDriver" /> + --> + <driver name="EcalRunningPedestal"/> + <driver name="EcalRawConverter" /><!-- +--> + <driver name="ReconClusterer" /><!-- +--> + <driver name="ReconParticle" /> <!-- + <driver name="GTPOnlineClusterer" /> + SVT opening angle alignment --> + <driver name="SplitHitsOnTrack"/> + <driver name="TrackerL1to3ReconDriver"/> + <driver name="TrackerL4to6ReconDriver"/> + <driver name="TrackerL134ReconDriver"/> + <driver name="ReconParticleL1to3" /> + <driver name="ReconParticleL4to6" /> + <driver name="ReconParticleL134" /> + <driver name="SVTAlignment"/> + <driver name="TrackingMonitoringSingles1DQM" /> + <driver name="TrackingMonitoringL1to3Singles1DQM"/> + <driver name="TrackingMonitoringL4to6Singles1DQM"/> + <driver name="TrackingMonitoringL134Singles1DQM"/> + <driver name="FinalStateL1to3DQMSingles1"/> + <driver name="FinalStateL4to6DQMSingles1"/> + <driver name="FinalStateL134DQMSingles1"/> + <!-- Online Monitoring Drivers --> + <!-- <driver name="TrackingMonitoring" /> + <driver name="TrackingResiduals"/> + <driver name="TrackTime"/> + <driver name="V0Monitoring"/> --> + <!-- <driver name="SVTMonitoring"/> + <driver name="TrackingMonitoringDQM" /> + <driver name="TrackingMonitoringSingles1DQM" /> + <driver name="TrackingMonitoringPairs1DQM" /> + <driver name="TrackingResidualsPairs1DQM"/> + <driver name="TrackingResidualsSingles1DQM"/> + <driver name="FinalStateDQM"/> + --> + <driver name="FinalStateDQMSingles1"/><!-- + <driver name="FinalStateDQMPairs1"/> + <driver name="V0DQM"/> + <driver name="V0DQMSingles1"/> + <driver name="V0DQMPairs1"/> + <driver name="TridentMonitoringPairs1"/>--> + <!-- <driver name="PositronDebug"/>--> + <driver name="AidaSaveDriver"/> + <driver name="LCIOWriter"/> + <driver name="CleanupDriver" /> </execute> <drivers> - <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> - <eventInterval>10</eventInterval> + <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> + <eventInterval>1000</eventInterval> </driver> <driver name="RawTrackerHitSensorSetup" type="org.lcsim.recon.tracking.digitization.sisim.config.RawTrackerHitSensorSetup" /> - <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver"> + <!-- <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver"> <fitAlgorithm>Analytic</fitAlgorithm> <useTimestamps>false</useTimestamps> <correctT0Shift>false</correctT0Shift> <useTruthTime>false</useTruthTime> <debug>false</debug> - </driver> - <driver name="TrackerHitDriver" type="org.hps.recon.tracking.DataTrackerHitDriver"> - <debug>false</debug> - </driver> - <driver name="HelicalTrackHitDriver" type="org.hps.recon.tracking.HelicalTrackHitDriver"> - <debug>false</debug> -<!-- <clusterTimeCut>16.0</clusterTimeCut> --> + </driver>--> + <!-- <driver name="TrackerHitDriver" type="org.hps.recon.tracking.DataTrackerHitDriver"> + <debug>false</debug> + </driver>--> + <!-- <driver name="HelicalTrackHitDriver" type="org.hps.recon.tracking.HelicalTrackHitDriver"> + <debug>false</debug> <maxSeperation>20.0</maxSeperation> <tolerance>1.0</tolerance> <saveAxialHits>false</saveAxialHits> + </driver>--> + + <driver name="SplitHitsOnTrack" type="org.hps.users.mgraham.SplitHitsOnTracks"> </driver> <driver name="TrackerL1to3ReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> <debug>false</debug> - <trackCollectionName>L1to3Tracks</trackCollectionName> +<!-- <includeMS>false</includeMS> + <useHPSMaterialManager>false</useHPSMaterialManager>--> + <inputHitCollectionName>OnTrackHits</inputHitCollectionName> + <trackCollectionName>L1to3Tracks</trackCollectionName> <strategyResource>/org/hps/recon/tracking/strategies/HPS-Full-L1-3.xml</strategyResource> </driver> <driver name="TrackerL4to6ReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> <debug>false</debug> - <trackCollectionName>L4to6Tracks</trackCollectionName> +<!-- <includeMS>false</includeMS> + <useHPSMaterialManager>false</useHPSMaterialManager>--> + <trackCollectionName>L4to6Tracks</trackCollectionName> + <inputHitCollectionName>OnTrackHits</inputHitCollectionName> <strategyResource>/org/hps/recon/tracking/strategies/HPS-Full-L4-6.xml</strategyResource> </driver> - <driver name="FullTrackerReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> + <driver name="TrackerL134ReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> + <debug>false</debug> +<!-- <includeMS>false</includeMS> + <useHPSMaterialManager>false</useHPSMaterialManager>--> + <trackCollectionName>L134Tracks</trackCollectionName> + <inputHitCollectionName>OnTrackHits</inputHitCollectionName> + <strategyResource>/org/hps/recon/tracking/strategies/HPS-Full-L134.xml</strategyResource> + </driver> + <!-- <driver name="FullTrackerReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> <debug>false</debug> <trackCollectionName>MatchedTracks</trackCollectionName> <strategyResource>/org/hps/recon/tracking/strategies/HPS-Full.xml</strategyResource> - </driver> + </driver>--> <driver name="TrackDataDriver" type="org.hps.recon.tracking.TrackDataDriver"> </driver> - <driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverterDriver"> + <!-- <driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverterDriver"> <ecalCollectionName>EcalCalHits</ecalCollectionName> <use2014Gain>false</use2014Gain> <useTimestamps>false</useTimestamps> @@ -77,25 +125,259 @@ <driver name="EcalClusterer" type="org.hps.recon.ecal.cluster.ReconClusterDriver"> <useTimeCut>true</useTimeCut> <logLevel>ALL</logLevel> - </driver> + </driver> --> <driver name="ReconParticle" type="org.hps.recon.particle.HpsReconParticleDriver"> <debug>false</debug> - </driver> + <dxCut>50</dxCut> + <dyCut>50</dyCut> + </driver> + + <driver name="ReconParticleL1to3" type="org.hps.recon.particle.HpsReconParticleDriver"> + <trackCollectionName>L1to3Tracks</trackCollectionName> + <targetConV0VerticesColName>TargetConstrainedV0CandidatesL1to3</targetConV0VerticesColName> + <finalStateParticlesColName>FinalStateParticlesL1to3</finalStateParticlesColName> + <unconstrainedV0CandidatesColName>UnconstrainedV0CandidatesL1to3</unconstrainedV0CandidatesColName> + <beamConV0CandidatesColName>BeamspotConstrainedV0CandidatesL1to3</beamConV0CandidatesColName> + <unconstrainedV0VerticesColName>UnconstrainedV0VerticesL1to3</unconstrainedV0VerticesColName> + <beamConV0VerticesColName>BeamspotConstrainedV0VerticesL1to3</beamConV0VerticesColName> + <targetConV0VerticesColName>TargetConstrainedV0VerticesL1to3</targetConV0VerticesColName> + <debug>false</debug> + <dxCut>50</dxCut> + <dyCut>50</dyCut> + </driver> + <driver name="ReconParticleL4to6" type="org.hps.recon.particle.HpsReconParticleDriver"> + <trackCollectionName>L4to6Tracks</trackCollectionName> + <targetConV0VerticesColName>TargetConstrainedV0CandidatesL4to6</targetConV0VerticesColName> + <finalStateParticlesColName>FinalStateParticlesL4to6</finalStateParticlesColName> + <unconstrainedV0CandidatesColName>UnconstrainedV0CandidatesL4to6</unconstrainedV0CandidatesColName> + <beamConV0CandidatesColName>BeamspotConstrainedV0CandidatesL4to6</beamConV0CandidatesColName> + <unconstrainedV0VerticesColName>UnconstrainedV0VerticesL4to6</unconstrainedV0VerticesColName> + <beamConV0VerticesColName>BeamspotConstrainedV0VerticesL4to6</beamConV0VerticesColName> + <targetConV0VerticesColName>TargetConstrainedV0VerticesL4to6</targetConV0VerticesColName> + <debug>false</debug> + <dxCut>50</dxCut> + <dyCut>50</dyCut> + </driver> + + <driver name="ReconParticleL134" type="org.hps.recon.particle.HpsReconParticleDriver"> + <trackCollectionName>L134Tracks</trackCollectionName> + <targetConV0VerticesColName>TargetConstrainedV0CandidatesL134</targetConV0VerticesColName> + <finalStateParticlesColName>FinalStateParticlesL134</finalStateParticlesColName> + <unconstrainedV0CandidatesColName>UnconstrainedV0CandidatesL134</unconstrainedV0CandidatesColName> + <beamConV0CandidatesColName>BeamspotConstrainedV0CandidatesL134</beamConV0CandidatesColName> + <unconstrainedV0VerticesColName>UnconstrainedV0VerticesL134</unconstrainedV0VerticesColName> + <beamConV0VerticesColName>BeamspotConstrainedV0VerticesL134</beamConV0VerticesColName> + <targetConV0VerticesColName>TargetConstrainedV0VerticesL134</targetConV0VerticesColName> + <debug>false</debug> + <dxCut>50</dxCut> + <dyCut>50</dyCut> + </driver> + + <!-- EngineeringRun2015FullRecon from Sho --> + <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver"> + <fitAlgorithm>Pileup</fitAlgorithm> + <useTimestamps>false</useTimestamps> + <correctT0Shift>false</correctT0Shift> + <useTruthTime>false</useTruthTime> + <subtractTOF>true</subtractTOF> + <subtractTriggerTime>true</subtractTriggerTime> + <correctChanT0>true</correctChanT0> + <timeOffset>51.0</timeOffset> + <debug>false</debug> + </driver> + <driver name="TrackerHitDriver" type="org.hps.recon.tracking.DataTrackerHitDriver"> + <neighborDeltaT>8.0</neighborDeltaT> +<!-- <neighborDeltaT>24.0</neighborDeltaT>--> + </driver> + <driver name="HelicalTrackHitDriver" type="org.hps.recon.tracking.HelicalTrackHitDriver"> + <debug>false</debug> +<!-- <clusterTimeCut>10.0</clusterTimeCut> + <maxDt>12.0</maxDt>--> + <clusterTimeCut>12.0</clusterTimeCut> + <maxDt>16.0</maxDt> +<!-- <clusterTimeCut>24.0</clusterTimeCut> + <maxDt>24.0</maxDt>--> + <maxSeperation>20.0</maxSeperation> + <tolerance>1.0</tolerance> + </driver> + <driver name="FullTrackerReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> + <strategyResource>HPS-Full.xml</strategyResource> + <debug>false</debug> + <rmsTimeCut>8.0</rmsTimeCut> +<!-- <rmsTimeCut>24.0</rmsTimeCut>--> + </driver> + <driver name="EcalRunningPedestal" type="org.hps.recon.ecal.EcalRunningPedestalDriver"> + <logLevel>CONFIG</logLevel> + <minLookbackEvents>10</minLookbackEvents> + <maxLookbackEvents>50</maxLookbackEvents> + </driver> + <driver name="EcalRawConverter" type="org.hps.recon.ecal.EcalRawConverterDriver"> + <ecalCollectionName>EcalCalHits</ecalCollectionName> + <use2014Gain>false</use2014Gain> + <useTimestamps>false</useTimestamps> + <useTruthTime>false</useTruthTime> + <useRunningPedestal>true</useRunningPedestal> + <useTimeWalkCorrection>true</useTimeWalkCorrection> + <emulateFirmware>true</emulateFirmware> + <emulateMode7>false</emulateMode7> + <leadingEdgeThreshold>12</leadingEdgeThreshold> + <nsa>100</nsa> + <nsb>20</nsb> + <windowSamples>50</windowSamples> + <nPeak>3</nPeak> + </driver> + <driver name="ReconClusterer" type="org.hps.recon.ecal.cluster.ReconClusterDriver"> + <logLevel>WARNING</logLevel> + <outputClusterCollectionName>EcalClusters</outputClusterCollectionName> + <hitEnergyThreshold>0.01</hitEnergyThreshold> + <seedEnergyThreshold>0.100</seedEnergyThreshold> + <clusterEnergyThreshold>0.200</clusterEnergyThreshold> + <minTime>0.0</minTime> + <timeWindow>25.0</timeWindow> + <useTimeCut>true</useTimeCut> + <writeRejectedHitCollection>false</writeRejectedHitCollection> + </driver> + <!-- End of EngineeringRun2015FullRecon from Sho --> + + <driver name="TrackingMonitoring" type="org.hps.monitoring.drivers.trackrecon.TrackingReconPlots"> - <outputPlots>tracking</outputPlots> </driver> <driver name="TrackingResiduals" type="org.hps.monitoring.drivers.trackrecon.TrackResiduals"> - <outputPlots>track-residuals</outputPlots> - </driver> - <driver name="V0Monitoring" type="org.hps.monitoring.drivers.trackrecon.V0ReconPlots"> - <outputPlots>v0recon</outputPlots> + </driver> + <driver name="V0Monitoring" type="org.hps.monitoring.drivers.trackrecon.V0ReconPlots"> </driver> - <driver name="SVTAlignment" type="org.hps.monitoring.drivers.trackrecon.SVTOpeningAlignment"> - <outputPlots>alignment</outputPlots> - </driver> - <driver name="TrackTime" type="org.hps.monitoring.drivers.trackrecon.TrackTimePlots"> + + <driver name="SVTAlignment" type="org.hps.analysis.dataquality.SVTOpeningStudies"> + </driver> + <driver name="TrackTime" type="org.hps.monitoring.drivers.trackrecon.TrackTimePlots"> + </driver> + <driver name="TrackingMonitoringDQM" type="org.hps.analysis.dataquality.TrackingMonitoring"> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + </driver> + + <driver name="TrackingMonitoringL1to3Singles1DQM" type="org.hps.analysis.dataquality.TrackingMonitoring"> + <trackCollectionName>L1to3Tracks</trackCollectionName> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + </driver> + <driver name="TrackingMonitoringL4to6Singles1DQM" type="org.hps.analysis.dataquality.TrackingMonitoring"> + <trackCollectionName>L4to6Tracks</trackCollectionName> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + </driver> + + <driver name="TrackingMonitoringL134Singles1DQM" type="org.hps.analysis.dataquality.TrackingMonitoring"> + <trackCollectionName>L134Tracks</trackCollectionName> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + </driver> + + + <driver name="TrackingMonitoringSingles1DQM" type="org.hps.analysis.dataquality.TrackingMonitoring"> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + <triggerType>singles1</triggerType> + </driver> + <driver name="TrackingMonitoringPairs1DQM" type="org.hps.analysis.dataquality.TrackingMonitoring"> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + <triggerType>pairs1</triggerType> + </driver> + + <driver name="TrackingResidualsPairs1DQM" type="org.hps.analysis.dataquality.TrackingResiduals"> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + <triggerType>pairs1</triggerType> + </driver> + <driver name="TrackingResidualsSingles1DQM" type="org.hps.analysis.dataquality.TrackingResiduals"> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + <triggerType>singles1</triggerType> + </driver> + <driver name="FinalStateDQM" type="org.hps.analysis.dataquality.FinalStateMonitoring"> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + <triggerType>all</triggerType> + </driver> + + <driver name="FinalStateL1to3DQMSingles1" type="org.hps.analysis.dataquality.FinalStateMonitoring"> + <finalStateParticlesColName>FinalStateParticlesL1to3</finalStateParticlesColName> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + <triggerType>singles1</triggerType> + </driver> + + <driver name="FinalStateL4to6DQMSingles1" type="org.hps.analysis.dataquality.FinalStateMonitoring"> + <finalStateParticlesColName>FinalStateParticlesL4to6</finalStateParticlesColName> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + <triggerType>singles1</triggerType> + </driver> + <driver name="FinalStateL134DQMSingles1" type="org.hps.analysis.dataquality.FinalStateMonitoring"> + <finalStateParticlesColName>FinalStateParticlesL134</finalStateParticlesColName> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + <triggerType>singles1</triggerType> + </driver> + <driver name="FinalStateDQMPairs1" type="org.hps.analysis.dataquality.FinalStateMonitoring"> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + <triggerType>pairs1</triggerType> + </driver> + + + <driver name="FinalStateDQMSingles1" type="org.hps.analysis.dataquality.FinalStateMonitoring"> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + <triggerType>singles1</triggerType> + </driver> + + <driver name="V0DQM" type="org.hps.analysis.dataquality.V0Monitoring"> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + <triggerType>all</triggerType> + </driver> + + <driver name="V0DQMPairs1" type="org.hps.analysis.dataquality.V0Monitoring"> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + <triggerType>pairs1</triggerType> + </driver> + + <driver name="V0DQMSingles1" type="org.hps.analysis.dataquality.V0Monitoring"> + <overwriteDB>false</overwriteDB> + <printDQMStrings>false</printDQMStrings> + <triggerType>singles1</triggerType> + </driver> + + <driver name="SVTMonitoring" type="org.hps.analysis.dataquality.SvtMonitoring"> + <triggerType>all</triggerType> + </driver> + + <driver name="TridentMonitoringPairs1" type="org.hps.analysis.dataquality.TridentMonitoring"> + <triggerType>pairs1</triggerType> + </driver> + + <driver name="PositronDebug" type="org.hps.users.mgraham.PositronDebug"> + </driver> + <driver name="AidaSaveDriver" type="org.lcsim.job.AidaSaveDriver"> + <outputFileName>./${outputFile}.root</outputFileName> + </driver> + <driver name="LCIOWriter" type="org.lcsim.util.loop.LCIODriver"> + <outputFilePath>${outputFile}.slcio</outputFilePath> + </driver> <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver" /> + + <driver name="GTPOnlineClusterer" type="org.hps.recon.ecal.cluster.ClusterDriver"> + <logLevel>WARNING</logLevel> + <clustererName>GTPOnlineClusterer</clustererName> + <outputClusterCollectionName>EcalClustersGTP</outputClusterCollectionName> + <!-- seedMinEnergy --> + <cuts>0.100</cuts> + </driver> + </drivers> </lcsim> Modified: java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/phansson/HPSTrackingDefaults.lcsim ============================================================================= --- java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/phansson/HPSTrackingDefaults.lcsim (original) +++ java/branches/HPSJAVA-488/steering-files/src/main/resources/org/hps/steering/users/phansson/HPSTrackingDefaults.lcsim Fri Jun 12 15:27:10 2015 @@ -1,41 +1,39 @@ -<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> - <inputFiles> - <!-- --> - </inputFiles> +<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd"> <control> - <numberOfEvents>3000</numberOfEvents> - <printInputFiles>true</printInputFiles> - <printDriversDetailed>true</printDriversDetailed> + <printInputFiles>false</printInputFiles> + <printDriversDetailed>false</printDriversDetailed> + <numberOfEvents>1000</numberOfEvents> </control> <execute> - <driver name="EventMarkerDriver" /> - <driver name="BadChannelFilter" /> - <driver name="SimpleSVTReadout" /> - <driver name="RawTrackerHitFitterDriver" /> - <driver name="TrackerHitDriver" /> - <!-- - <driver name="TrackerDigiDriver"/> --> - <driver name="HelicalTrackHitDriver" /> - <driver name="TrackerReconDriver" /> - <driver name="SVTHitReconstructionPlots" /> - <driver name="LCIOWriter" /> +<!-- <driver name="ConditionsDriver"/> --> + <driver name="EventMarkerDriver"/> + <driver name="TrackerDigiDriver"/> + <driver name="HelicalTrackHitDriver"/> + <driver name="TrackerReconDriver"/> + <driver name="GBLOutputDriver"/> + <driver name="GBLDriver"/> +<!-- <driver name="GblTrackingReconstructionPlots"/> --> + <driver name="TrackingReconstructionPlots"/> + <driver name="AidaSaveDriverRoot" /> + <driver name="LCIOWriter"/> + + <driver name="CleanupDriver"/> </execute> <drivers> + + <driver name="ConditionsDriver" type="org.hps.conditions.ConditionsDriver"> + <detectorName>${detector}</detectorName> + <runNumber>${run}</runNumber> + <freeze>true</freeze> + </driver> <driver name="EventMarkerDriver" type="org.lcsim.job.EventMarkerDriver"> - <eventInterval>100</eventInterval> + <eventInterval>1</eventInterval> </driver> - <driver name="BadChannelFilter" type="org.hps.recon.tracking.SVTBadChannelFilterDriver" /> - <driver name="SimpleSVTReadout" type="org.hps.readout.svt.SimpleSvtReadout"> - <noPileup>true</noPileup> - </driver> - <driver name="RawTrackerHitFitterDriver" type="org.hps.recon.tracking.RawTrackerHitFitterDriver"> - <fitAlgorithm>Analytic</fitAlgorithm> - <correctT0Shift>true</correctT0Shift> - </driver> - <driver name="TrackerHitDriver" type="org.hps.recon.tracking.DataTrackerHitDriver" /> <driver name="TrackerDigiDriver" type="org.hps.recon.tracking.SimpleTrackerDigiDriver"> - <debug>true</debug> +<!-- <dropBadChannels>true</dropBadChannels>--> + <debug>false</debug> </driver> <driver name="HelicalTrackHitDriver" type="org.hps.recon.tracking.HelicalTrackHitDriver"> <debug>false</debug> @@ -44,13 +42,39 @@ </driver> <driver name="TrackerReconDriver" type="org.hps.recon.tracking.TrackerReconDriver"> <debug>false</debug> - <strategyResource>/org/hps/recon/tracking/strategies/HPS-Test-All.xml</strategyResource> + <!--<strategyResource>HPS-Full-All.xml</strategyResource>--> + <strategyResource>HPS-Full.xml</strategyResource> </driver> - <driver name="SVTHitReconstructionPlots" type="org.hps.monitoring.drivers.svt.SVTHitReconstructionPlots"> - <outputPlots>SVTHitReconstructionPlots.aida</outputPlots> + <driver name="GBLOutputDriver" type="org.hps.recon.tracking.gbl.GBLOutputDriver"> + <debug>0</debug> + <isMC>true</isMC> + <gblFileName>gbl.out</gblFileName> + </driver> + <driver name="GBLDriver" type="org.hps.recon.tracking.gbl.HpsGblRefitter"> + <debug>false</debug> + <logLevel>WARNING</logLevel> + <milleBinaryFileName>milleTest.bin</milleBinaryFileName> + <writeMilleBinary>true</writeMilleBinary> </driver> <driver name="LCIOWriter" type="org.lcsim.util.loop.LCIODriver"> <outputFilePath>${outputFile}</outputFilePath> </driver> + + <driver name="AidaSaveDriverRoot" type="org.lcsim.job.AidaSaveDriver"> + <outputFileName>outputfile.root</outputFileName> + + </driver> + + <driver name="GblTrackingReconstructionPlots" type="org.hps.monitoring.drivers.svt.GblTrackingReconstructionPlots"> + <outputPlots>TrackingReconstructionPlots.aida</outputPlots> + </driver> + <driver name="TrackingReconstructionPlots" type="org.hps.users.phansson.TrackingReconstructionPlots"> + <showPlots>True</showPlots> + </driver> + + <driver name="CleanupDriver" type="org.lcsim.recon.tracking.digitization.sisim.config.ReadoutCleanupDriver"/> + + + </drivers> </lcsim> Modified: java/branches/HPSJAVA-488/tracking/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/tracking/pom.xml (original) +++ java/branches/HPSJAVA-488/tracking/pom.xml Fri Jun 12 15:27:10 2015 @@ -8,7 +8,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/tracking/</url> @@ -36,7 +36,7 @@ <dependencies> <dependency> <groupId>org.hps</groupId> - <artifactId>hps-conditions</artifactId> + <artifactId>hps-detector-model</artifactId> </dependency> <dependency> <groupId>org.hps</groupId> @@ -45,7 +45,6 @@ <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-math3</artifactId> - <version>3.2</version> </dependency> </dependencies> </project> Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/readout/svt/SimpleSvtReadout.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/readout/svt/SimpleSvtReadout.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/readout/svt/SimpleSvtReadout.java Fri Jun 12 15:27:10 2015 @@ -6,6 +6,8 @@ import java.util.Map; import java.util.PriorityQueue; import java.util.Set; +import org.hps.conditions.database.DatabaseConditionsManager; +import org.hps.conditions.svt.SvtTimingConstants; import org.lcsim.detector.tracker.silicon.ChargeCarrier; import org.lcsim.detector.tracker.silicon.HpsSiSensor; @@ -57,6 +59,8 @@ private boolean noPileup = false; private boolean addNoise = true; + private boolean useTimingConditions = false; + // cut settings private boolean enableThresholdCut = true; private int samplesAboveThreshold = 3; @@ -105,6 +109,10 @@ public void setReadoutLatency(double readoutLatency) { this.readoutLatency = readoutLatency; + } + + public void setUseTimingConditions(boolean useTimingConditions) { + this.useTimingConditions = useTimingConditions; } /** @@ -150,6 +158,12 @@ PriorityQueue<StripHit>[] hitQueues = new PriorityQueue[HPSSVTConstants.TOTAL_STRIPS_PER_SENSOR]; hitMap.put(sensor, hitQueues); } + } + + if (useTimingConditions) { + SvtTimingConstants timingConstants = DatabaseConditionsManager.getInstance().getCachedConditions(SvtTimingConstants.SvtTimingConstantsCollection.class, "svt_timing_constants").getCachedData().get(0); + readoutOffset = 4 * (timingConstants.getOffsetPhase() + 5); + readoutLatency = 240.0 + timingConstants.getOffsetTime(); } } Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/BeamlineConstants.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/BeamlineConstants.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/BeamlineConstants.java Fri Jun 12 15:27:10 2015 @@ -5,6 +5,7 @@ private BeamlineConstants() { } + public static final double ECAL_FACE = 1394.0 ; // mm Email from Takashi Jan 15th, 2015 public static final double ECAL_FACE_TESTRUN = 1524; // mm public static final double DIPOLE_EDGE_TESTRUN = 457.2 + 457.2; // 452.2 + // 462.2; Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/DataTrackerHitDriver.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/DataTrackerHitDriver.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/DataTrackerHitDriver.java Fri Jun 12 15:27:10 2015 @@ -37,8 +37,8 @@ private double clusterSeedThreshold = 4.0; private double clusterNeighborThreshold = 3.0; private double clusterThreshold = 4.0; - private double meanTime = 24.0; - private double timeWindow = 48.0; + private double meanTime = 0.0; + private double timeWindow = 72.0; private double neighborDeltaT = 24.0; private int clusterMaxSize = 10; private int clusterCentralStripAveragingThreshold = 4; Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/HelicalTrackHitDriver.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/HelicalTrackHitDriver.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/HelicalTrackHitDriver.java Fri Jun 12 15:27:10 2015 @@ -14,6 +14,7 @@ import org.lcsim.detector.ITransform3D; import org.lcsim.detector.converter.compact.subdetector.HpsTracker2; import org.lcsim.detector.converter.compact.subdetector.SvtStereoLayer; +import org.lcsim.detector.tracker.silicon.DopedSilicon; import org.lcsim.detector.tracker.silicon.HpsSiSensor; import org.lcsim.detector.tracker.silicon.SiSensor; import org.lcsim.detector.tracker.silicon.SiTrackerModule; @@ -51,6 +52,7 @@ private double _clusterTimeCut = -99; // if negative, don't cut..otherwise, // dt cut time in ns private double maxDt = -99; // max time difference between the two hits in a cross + private double clusterAmplitudeCut = -99; // cluster amplitude cut private String _subdetectorName = "Tracker"; private final Map<String, String> _stereomap = new HashMap<String, String>(); private List<SvtStereoLayer> stereoLayers = null; @@ -70,6 +72,8 @@ * Default Ctor */ public HelicalTrackHitDriver() { + _crosser.setMaxSeparation(20.0); + _crosser.setTolerance(0.1); _colnames.add("StripClusterer_SiTrackerHitStrip1D"); } @@ -93,6 +97,10 @@ public void setMaxDt(double maxDt) { this.maxDt = maxDt; + } + + public void setClusterAmplitudeCut(double clusterAmplitudeCut) { + this.clusterAmplitudeCut = clusterAmplitudeCut; } /** @@ -169,9 +177,11 @@ RelationalTable hittomc = new BaseRelationalTable(RelationalTable.Mode.ONE_TO_MANY, RelationalTable.Weighting.UNWEIGHTED); if (event.hasCollection(LCRelation.class, "SVTTrueHitRelations")) { List<LCRelation> trueHitRelations = event.get(LCRelation.class, "SVTTrueHitRelations"); - for (LCRelation relation : trueHitRelations) - if (relation != null && relation.getFrom() != null && relation.getTo() != null) + for (LCRelation relation : trueHitRelations) { + if (relation != null && relation.getFrom() != null && relation.getTo() != null) { hittomc.add(relation.getFrom(), relation.getTo()); + } + } } List<HelicalTrack2DHit> axialhits = new ArrayList<>(); @@ -180,45 +190,58 @@ // ...for HPS, probably this is just a single one... for (String _colname : this._colnames) { if (!event.hasCollection(SiTrackerHit.class, _colname)) { - if (_debug) + if (_debug) { System.out.println("Event: " + event.getRunNumber() + " does not contain the collection " + _colname); + } continue; } // Get the list of SiTrackerHits for this collection List<SiTrackerHit> hitlist = event.get(SiTrackerHit.class, _colname); - if (_debug) + if (_debug) { System.out.printf("%s: found %d SiTrackerHits\n", this.getClass().getSimpleName(), hitlist.size()); + } Map<HelicalTrackStrip, SiTrackerHitStrip1D> stripmap = new HashMap<HelicalTrackStrip, SiTrackerHitStrip1D>(); - for (SiTrackerHit hit : hitlist) + for (SiTrackerHit hit : hitlist) { if (hit instanceof SiTrackerHitStrip1D) { // Cast the hit as a 1D strip hit and find the // identifier for the detector/layer combo SiTrackerHitStrip1D h = (SiTrackerHitStrip1D) hit; - - if ((_clusterTimeCut > 0 && Math.abs(h.getTime()) < _clusterTimeCut) || _clusterTimeCut < 0) { - // Create a HelicalTrackStrip for this hit - HelicalTrackStrip strip = makeDigiStrip(h); - for (RawTrackerHit rth : h.getRawHits()) - for (Object simHit : hittomc.allFrom(rth)) - strip.addMCParticle(((SimTrackerHit) simHit).getMCParticle()); - - // Map a reference back to the hit needed to create - // the stereo hit LC relations - stripmap.put(strip, h); - if (_debug) - System.out.printf("%s: added strip org %s layer %d\n", this.getClass().getSimpleName(), strip.origin().toString(), strip.layer()); - - if (_saveAxialHits)// - if (((HpsSiSensor) h.getSensor()).isAxial()) { - HelicalTrack2DHit haxial = makeDigiAxialHit(h); - axialhits.add(haxial); - List<RawTrackerHit> rl = haxial.getRawHits(); - for (RawTrackerHit rth : rl) - for (Object simHit : hittomc.allFrom(rth)) - haxial.addMCParticle(((SimTrackerHit) simHit).getMCParticle()); - axialmcrelations.add(new MyLCRelation(haxial, haxial.getMCParticles())); + if (clusterAmplitudeCut > 0 && h.getdEdx()/DopedSilicon.ENERGY_EHPAIR < clusterAmplitudeCut) { + continue; + } + if (_clusterTimeCut > 0 && Math.abs(h.getTime()) > _clusterTimeCut) { + continue; + } + + // Create a HelicalTrackStrip for this hit + HelicalTrackStrip strip = makeDigiStrip(h); + for (RawTrackerHit rth : h.getRawHits()) { + for (Object simHit : hittomc.allFrom(rth)) { + strip.addMCParticle(((SimTrackerHit) simHit).getMCParticle()); + } + } + + // Map a reference back to the hit needed to create + // the stereo hit LC relations + stripmap.put(strip, h); + if (_debug) { + System.out.printf("%s: added strip org %s layer %d\n", this.getClass().getSimpleName(), strip.origin().toString(), strip.layer()); + } + + if (_saveAxialHits)// + { + if (((HpsSiSensor) h.getSensor()).isAxial()) { + HelicalTrack2DHit haxial = makeDigiAxialHit(h); + axialhits.add(haxial); + List<RawTrackerHit> rl = haxial.getRawHits(); + for (RawTrackerHit rth : rl) { + for (Object simHit : hittomc.allFrom(rth)) { + haxial.addMCParticle(((SimTrackerHit) simHit).getMCParticle()); + } } + axialmcrelations.add(new MyLCRelation(haxial, haxial.getMCParticles())); + } } } else { // If not a 1D strip hit, make a pixel hit @@ -227,6 +250,7 @@ helhits.add(hit3d); hitrelations.add(new MyLCRelation(hit3d, hit)); } + } List<HelicalTrackCross> helicalTrackCrosses = new ArrayList<HelicalTrackCross>(); @@ -242,8 +266,9 @@ // This hit should be a on a stereo pair! // With our detector setup, when is this not true? - if (!_stereomap.containsKey(id) && !_stereomap.containsValue(id)) + if (!_stereomap.containsKey(id) && !_stereomap.containsValue(id)) { throw new RuntimeException(this.getClass().getSimpleName() + ": this " + id + " was not among the stereo modules!"); + } // Get the list of strips for this layer - create a new // list if one doesn't already exist @@ -258,8 +283,9 @@ lyrhits.add(strip); } - if (_debug) + if (_debug) { System.out.printf("%s: Create stereo hits from %d strips \n", this.getClass().getSimpleName(), striplistmap.size()); + } // Loop over the stereo layer pairs // TODO: Change this so that it makes use of StereoPairs @@ -267,17 +293,19 @@ // Get the second layer String id2 = _stereomap.get(id1); - if (_debug) + if (_debug) { System.out.printf("%s: Form stereo hits from sensor id %s with %d hits and %s with %d hits\n", this.getClass().getSimpleName(), id1, striplistmap.get(id1) == null ? 0 : striplistmap.get(id1).size(), id2, striplistmap.get(id2) == null ? 0 : striplistmap.get(id2).size()); + } // Form the stereo hits and add them to our hit list helicalTrackCrosses.addAll(_crosser.MakeHits(striplistmap.get(id1), striplistmap.get(id2))); } // End of loop over stereo pairs } else { - if(_debug) + if (_debug) { System.out.printf("%s: Associate %d strips to their sensors before pairing\n", this.getClass().getSimpleName(), stripmap.size()); - + } + Map<SiSensor, List<HelicalTrackStrip>> striplistmap = new HashMap<SiSensor, List<HelicalTrackStrip>>(); for (HelicalTrackStrip strip : stripmap.keySet()) { @@ -293,46 +321,50 @@ // Add the strip to the list of strips on this sensor hitsOnSensor.add(strip); - - if(_debug) + + if (_debug) { System.out.printf("%s: Adding strip hit with origin %s to sensor %s\n", this.getClass().getSimpleName(), strip.origin().toString(), sensor.getName()); - - } - - - if(_debug) { - System.out.printf("%s: Form stereo hits based on %d stereo layers:\n",this.getClass().getSimpleName(), stereoLayers.size()); - System.out.printf("%s: %42s %42s\n",this.getClass().getSimpleName(), "<axial>", "<stereo>"); + } + + } + + if (_debug) { + System.out.printf("%s: Form stereo hits based on %d stereo layers:\n", this.getClass().getSimpleName(), stereoLayers.size()); + System.out.printf("%s: %42s %42s\n", this.getClass().getSimpleName(), "<axial>", "<stereo>"); for (SvtStereoLayer stereoLayer : stereoLayers) { - System.out.printf("%s: %42s %42s\n",this.getClass().getSimpleName(), stereoLayer.getAxialSensor().getName(), stereoLayer.getStereoSensor().getName()); - } - } - - if(_debug) + System.out.printf("%s: %42s %42s\n", this.getClass().getSimpleName(), stereoLayer.getAxialSensor().getName(), stereoLayer.getStereoSensor().getName()); + } + } + + if (_debug) { System.out.printf("%s: Create crosses\n", this.getClass().getSimpleName()); - + } + //===> for (StereoPair stereoPair : SvtUtils.getInstance().getStereoPairs()) { for (SvtStereoLayer stereoLayer : stereoLayers) { - if(_debug) + if (_debug) { System.out.printf("%s: axial %s stereo %s \n", this.getClass().getSimpleName(), stereoLayer.getAxialSensor().getName(), stereoLayer.getStereoSensor().getName()); - - + } + // Form the stereo hits and add them to our hit list List<HelicalTrackCross> newCrosses; //===> if (stereoPair.getDetectorVolume() == detectorVolume.Top) { if (stereoLayer.getAxialSensor().isTopLayer()) { - if(_debug) + if (_debug) { System.out.printf("%s: make hits for top\n", this.getClass().getSimpleName()); - + } + newCrosses = _crosser.MakeHits(striplistmap.get(stereoLayer.getAxialSensor()), striplistmap.get(stereoLayer.getStereoSensor())); //===> } else if (stereoPair.getDetectorVolume() == detectorVolume.Bottom) { } else if (stereoLayer.getAxialSensor().isBottomLayer()) { - if(_debug) + if (_debug) { System.out.printf("%s: make hits for bottom\n", this.getClass().getSimpleName()); + } newCrosses = _crosser.MakeHits(striplistmap.get(stereoLayer.getStereoSensor()), striplistmap.get(stereoLayer.getAxialSensor())); - } else + } else { throw new RuntimeException("stereo pair is neither top nor bottom"); + } helicalTrackCrosses.addAll(newCrosses); } // Loop over stereo pairs @@ -344,25 +376,31 @@ iter.remove(); continue; } - if (cross.getMCParticles() != null) - for (MCParticle mcp : cross.getMCParticles()) + if (cross.getMCParticles() != null) { + for (MCParticle mcp : cross.getMCParticles()) { mcrelations.add(new MyLCRelation((HelicalTrackHit) cross, mcp)); - for (HelicalTrackStrip strip : cross.getStrips()) + } + } + for (HelicalTrackStrip strip : cross.getStrips()) { hitrelations.add(new MyLCRelation(cross, stripmap.get(strip))); - if (_debug) + } + if (_debug) { System.out.printf("%s: cross at %.2f,%.2f,%.2f \n", this.getClass().getSimpleName(), cross.getPosition()[0], cross.getPosition()[1], cross.getPosition()[2]); + } } stereoCrosses.addAll(helicalTrackCrosses); - if (_debug) + if (_debug) { System.out.printf("%s: added %d stereo hits from %s collection \n", this.getClass().getSimpleName(), helicalTrackCrosses.size(), _colname); + } } // End of loop over collection names if (_debug) { System.out.printf("%s: totally added %d stereo hits:\n", this.getClass().getSimpleName(), stereoCrosses.size()); - for (HelicalTrackCross cross : stereoCrosses) + for (HelicalTrackCross cross : stereoCrosses) { System.out.printf("%s: %.2f,%.2f,%.2f \n", this.getClass().getSimpleName(), cross.getPosition()[0], cross.getPosition()[1], cross.getPosition()[2]); + } } // Add things to the event @@ -378,8 +416,9 @@ } if (_doTransformToTracking) { addRotatedHitsToEvent(event, stereoCrosses); - if (_saveAxialHits) + if (_saveAxialHits) { addRotated2DHitsToEvent(event, axialhits); + } } } // Process() @@ -409,30 +448,36 @@ /* * Setup default pairing */ - if (_debug) + if (_debug) { System.out.printf("%s: Setup stereo hit pair modules \n", this.getClass().getSimpleName()); + } List<SiTrackerModule> modules = detector.getSubdetector(this._subdetectorName).getDetectorElement().findDescendants(SiTrackerModule.class); - if (modules.isEmpty()) + if (modules.isEmpty()) { throw new RuntimeException(this.getClass().getName() + ": No SiTrackerModules found in detector."); + } if (LayerGeometryType.Common == this._layerGeometryType) { int nLayersTotal = detector.getSubdetector(_subdetectorName).getLayering().getLayers().getNumberOfLayers(); - if (_debug) + if (_debug) { System.out.printf("%s: %d layers \n", this.getClass().getSimpleName(), nLayersTotal); - if (nLayersTotal % 2 != 0) + } + if (nLayersTotal % 2 != 0) { throw new RuntimeException(this.getClass().getName() + ": Don't know how to do stereo pairing for odd number of modules."); + } for (int i = 1; i <= (nLayersTotal) - 1; i += 2) { - if (_debug) + if (_debug) { System.out.printf("%s: Adding stereo pair: %d,%d\n", this.getClass().getSimpleName(), i, i + 1); + } setStereoPair(_subdetectorName, i, i + 1); } } - if (_debug) + if (_debug) { System.out.printf("%s: %d stereo modules added", this.getClass().getSimpleName(), this._stereomap.size()); + } } @@ -465,11 +510,11 @@ Hep3Vector org = trans.transformed(_orgloc); Hep3Vector u = global.getMeasuredCoordinate(); Hep3Vector v = global.getUnmeasuredCoordinate(); - - if (_debug) + + if (_debug) { System.out.println(this.getClass().getSimpleName() + ": makeDigiStrip: org " + org.toString() + " and u " + u.toString() + " v " + v.toString()); - - + } + double umeas = local.getPosition()[0]; double vmin = VecOp.dot(local.getUnmeasuredCoordinate(), local.getHitSegment().getStartPoint()); double vmax = VecOp.dot(local.getUnmeasuredCoordinate(), local.getHitSegment().getEndPoint()); @@ -486,15 +531,18 @@ HelicalTrackStrip strip = new HelicalTrackStrip(org, u, v, umeas, du, vmin, vmax, dEdx, time, rawhits, det, lyr, be); try { - if (h.getMCParticles() != null) - for (MCParticle p : h.getMCParticles()) + if (h.getMCParticles() != null) { + for (MCParticle p : h.getMCParticles()) { strip.addMCParticle(p); + } + } } catch (RuntimeException e) { // Okay when MC info not present. } - if (_debug) + if (_debug) { System.out.println(this.getClass().getSimpleName() + ": makeDigiStrip: produced HelicalTrackStrip with origin " + strip.origin().toString() + " and u " + strip.u().toString() + " v " + strip.v().toString() + " w " + strip.w().toString()); + } return strip; } @@ -525,19 +573,23 @@ Hep3Vector newu = CoordinateTransformations.transformVectorToTracking(u); Hep3Vector newv = CoordinateTransformations.transformVectorToTracking(v); HelicalTrackStrip newstrip = new HelicalTrackStrip(neworigin, newu, newv, umeas, du, vmin, vmax, dedx, time, rthList, detname, layer, bec); - for (MCParticle p : strip.MCParticles()) + for (MCParticle p : strip.MCParticles()) { newstrip.addMCParticle(p); + } rotatedstriphits.add(newstrip); - if(_debug) - System.out.printf("%s: adding rotated strip with origin %s and u %s v %s w %s \n", getClass().toString(), newstrip.origin().toString(), newstrip.u().toString(),newstrip.v().toString(), newstrip.w().toString()); + if (_debug) { + System.out.printf("%s: adding rotated strip with origin %s and u %s v %s w %s \n", getClass().toString(), newstrip.origin().toString(), newstrip.u().toString(), newstrip.v().toString(), newstrip.w().toString()); + } } HelicalTrackCross newhit = new HelicalTrackCross(rotatedstriphits.get(0), rotatedstriphits.get(1)); - for (MCParticle mcp : cross.getMCParticles()) + for (MCParticle mcp : cross.getMCParticles()) { newhit.addMCParticle(mcp); + } rotatedhits.add(newhit); hthrelations.add(new MyLCRelation(cross, newhit)); - for (MCParticle mcp : newhit.getMCParticles()) + for (MCParticle mcp : newhit.getMCParticles()) { mcrelations.add(new MyLCRelation(newhit, mcp)); + } } event.put("Rotated" + _outname, rotatedhits, HelicalTrackHit.class, 0); @@ -567,11 +619,13 @@ Hep3Vector newaxdir = CoordinateTransformations.transformVectorToTracking(axDir); SymmetricMatrix newcov = CoordinateTransformations.transformCovarianceToTracking(cov); HelicalTrack2DHit newhit = new HelicalTrack2DHit(newpos, newcov, dedx, time, rthList, detname, layer, bec, vmin, vmax, newaxdir); - for (MCParticle mcp : twodhit.getMCParticles()) + for (MCParticle mcp : twodhit.getMCParticles()) { newhit.addMCParticle(mcp); + } rotatedhits.add(newhit); - for (MCParticle mcp : newhit.getMCParticles()) + for (MCParticle mcp : newhit.getMCParticles()) { mcrelations.add(new MyLCRelation(newhit, mcp)); + } } if (_debug) { System.out.println(this.getClass().getSimpleName() + ": " + _axialname + " size = " + rotatedhits.size()); Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/MaterialSupervisor.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/MaterialSupervisor.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/MaterialSupervisor.java Fri Jun 12 15:27:10 2015 @@ -61,25 +61,29 @@ @Override public void buildModel(Detector det) { + boolean local_debug = false; // super.buildModel(det); - if (DEBUG) { + if (DEBUG || local_debug) { System.out.printf("%s: ###########################################################\n", this.getClass().getSimpleName()); System.out.printf("%s: Build detector model\n", this.getClass().getSimpleName()); } List<SiSensor> sensors = det.getSubdetector("Tracker").getDetectorElement().findDescendants(SiSensor.class); // List<SiTrackerModule> modules = // det.getDetectorElement().findDescendants(SiTrackerModule.class); - if (DEBUG) { - System.out.printf("%s: %d sensors\n", this.getClass().getSimpleName(), sensors.size()); - System.out.printf("%s: %5s %32s %22s %15s %10s %10s\n", this.getClass().getSimpleName(), "ID", "Pos (mm)", "size(mm)", "t(mm)", "t(%R.L)", "type"); + if (DEBUG || local_debug) { + System.out.printf("%s: %d SiSensors:\n", this.getClass().getSimpleName(), sensors.size()); + System.out.printf("%s: %45s %35s %35s %35s %35s\n", this.getClass().getSimpleName(), "DE", "Origin", "u", "v", "w"); } for (SiSensor module : sensors) { SiStripPlane plane = new SiStripPlane(module); + if (DEBUG || local_debug) { + System.out.printf("%s: %45s %35s %35s %35s %35s\n", this.getClass().getSimpleName(), plane.getDetectorElement().getName(), plane.getGeometry().getPosition().toString(), plane.getMeasuredCoordinate().toString(), plane.getUnmeasuredCoordinate().toString(),plane.getPsidePlane().getNormal().toString()); + } _detectorVolumes.add(plane); } - if (DEBUG) { + if (DEBUG || local_debug) { System.out.printf("%s: ###########################################################\n", this.getClass().getSimpleName()); } } Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/RawTrackerHitFitterDriver.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/RawTrackerHitFitterDriver.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/RawTrackerHitFitterDriver.java Fri Jun 12 15:27:10 2015 @@ -2,14 +2,14 @@ import java.util.ArrayList; import java.util.List; - -//===> import org.hps.conditions.deprecated.HPSSVTCalibrationConstants.ChannelConstants; +import org.hps.conditions.database.DatabaseConditionsManager; +import org.hps.conditions.svt.SvtTimingConstants; import org.hps.readout.ecal.ReadoutTimestamp; import org.hps.readout.svt.HPSSVTConstants; import org.lcsim.detector.tracker.silicon.HpsSiSensor; -//===> import org.lcsim.detector.tracker.silicon.SiSensor; import org.lcsim.event.EventHeader; import org.lcsim.event.RawTrackerHit; +import org.lcsim.geometry.Detector; import org.lcsim.lcio.LCIOConstants; import org.lcsim.recon.cat.util.Const; import org.lcsim.util.Driver; @@ -27,15 +27,15 @@ private String rawHitCollectionName = "SVTRawTrackerHits"; private String fitCollectionName = "SVTShapeFitParameters"; private String fittedHitCollectionName = "SVTFittedRawTrackerHits"; + private SvtTimingConstants timingConstants; private int genericObjectFlags = 1 << LCIOConstants.GOBIT_FIXED; private int relationFlags = 0; - private double timeOffset = 0.0; + private boolean correctTimeOffset = false; private boolean correctT0Shift = false; private boolean useTimestamps = false; private boolean useTruthTime = false; private boolean subtractTOF = false; private boolean subtractTriggerTime = false; - private int triggerPhaseOffset = 4; private boolean correctChanT0 = true; /** @@ -51,8 +51,8 @@ this.debug = debug; } - public void setTimeOffset(double timeOffset) { - this.timeOffset = timeOffset; + public void setCorrectTimeOffset(boolean correctTimeOffset) { + this.correctTimeOffset = correctTimeOffset; } public void setCorrectT0Shift(boolean correctT0Shift) { @@ -69,10 +69,6 @@ public void setSubtractTriggerTime(boolean subtractTriggerTime) { this.subtractTriggerTime = subtractTriggerTime; - } - - public void setTriggerPhaseOffset(int triggerPhaseOffset) { - this.triggerPhaseOffset = triggerPhaseOffset; } public void setCorrectChanT0(boolean correctChanT0) { @@ -123,6 +119,10 @@ } } + protected void detectorChanged(Detector detector) { + timingConstants = DatabaseConditionsManager.getInstance().getCachedConditions(SvtTimingConstants.SvtTimingConstantsCollection.class, "svt_timing_constants").getCachedData().get(0); + } + @Override public void process(EventHeader event) { if (!event.hasCollection(RawTrackerHit.class, rawHitCollectionName)) { @@ -144,10 +144,11 @@ //===> ChannelConstants constants = HPSSVTCalibrationConstants.getChannelConstants((SiSensor) hit.getDetectorElement(), strip); //for (ShapeFitParameters fit : _shaper.fitShape(hit, constants)) { for (ShapeFitParameters fit : fitter.fitShape(hit, shape)) { - fit.setT0(fit.getT0() - timeOffset); - + if (correctTimeOffset) { + fit.setT0(fit.getT0() - timingConstants.getOffsetTime()); + } if (subtractTriggerTime) { - fit.setT0(fit.getT0() - (((event.getTimeStamp() + 4 * triggerPhaseOffset) % 24) - 12)); + fit.setT0(fit.getT0() - (((event.getTimeStamp() - 4 * timingConstants.getOffsetPhase()) % 24) - 12)); } if (correctChanT0) { fit.setT0(fit.getT0() - sensor.getShapeFitParameters(strip)[HpsSiSensor.T0_INDEX]); Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/ShaperAnalyticFitAlgorithm.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/ShaperAnalyticFitAlgorithm.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/ShaperAnalyticFitAlgorithm.java Fri Jun 12 15:27:10 2015 @@ -26,10 +26,10 @@ @Override public Collection<ShapeFitParameters> fitShape(RawTrackerHit rth, PulseShape shape) { short[] samples = rth.getADCValues(); - HpsSiSensor sensor =(HpsSiSensor) rth.getDetectorElement(); + HpsSiSensor sensor = (HpsSiSensor) rth.getDetectorElement(); int channel = rth.getIdentifierFieldValue("strip"); return this.fitShape(channel, samples, sensor); - //===> return this.fitShape(rth.getADCValues(), constants); + //===> return this.fitShape(rth.getADCValues(), constants); } public Collection<ShapeFitParameters> fitShape(int channel, short[] samples, HpsSiSensor sensor) { @@ -60,11 +60,11 @@ double[] y = new double[length]; double[] t = new double[length]; - double tp = sensor.getShapeFitParameters(channel)[HpsSiSensor.TP_INDEX]; + double tp = 2.5*Math.pow(sensor.getShapeFitParameters(channel)[HpsSiSensor.TP_INDEX], 0.25) * Math.pow(sensor.getShapeFitParameters(channel)[HpsSiSensor.TP_INDEX + 1], 0.75); for (int i = 0; i < length; i++) { //===> y[i] = samples[start + i] - constants.getPedestal(); - y[i] = samples[start + i] - sensor.getPedestal(channel, i); + y[i] = samples[start + i] - sensor.getPedestal(channel, i); t[i] = HPSSVTConstants.SAMPLING_INTERVAL * i; } @@ -74,8 +74,8 @@ //===> p[i] = y[i] / constants.getNoise(); p[i] = y[i] / sensor.getNoise(channel, i); //===> a[i] = Math.exp(1 - t[i] / constants.getTp()) / (constants.getTp() * constants.getNoise()); - - a[i] = Math.exp(1 - t[i] /tp) / (tp * sensor.getNoise(channel, i)); + + a[i] = Math.exp(1 - t[i] / tp) / (tp * sensor.getNoise(channel, i)); } double pa, aatt, pat, aat, aa; Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackDataDriver.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackDataDriver.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackDataDriver.java Fri Jun 12 15:27:10 2015 @@ -13,50 +13,39 @@ import org.lcsim.event.Track; import org.lcsim.event.TrackerHit; import org.lcsim.event.base.BaseLCRelation; +import org.lcsim.event.RelationalTable; +import org.lcsim.event.base.BaseRelationalTable; import org.lcsim.fit.helicaltrack.HelicalTrackCross; import org.lcsim.fit.helicaltrack.HelicalTrackHit; import org.lcsim.fit.helicaltrack.HelicalTrackStrip; -import org.lcsim.geometry.Detector; import org.lcsim.util.Driver; -import org.lcsim.event.RelationalTable; -import org.lcsim.event.base.BaseRelationalTable; /** * * @author Omar Moreno <[log in to unmask]> - * @version $Id$ + * @author Sho Uemura <[log in to unmask]> * */ public class TrackDataDriver extends Driver { // Collection Names String trackCollectionName = "MatchedTracks"; - // TODO: Change this to match whatever track name is decided on - String trackTimeDataCollectionName = "TrackTimeData"; String trackResidualsCollectionName = "TrackResiduals"; String rotatedHthRelationsColName = "RotatedHelicalTrackHitRelations"; String rotatedHthCollectionName = "RotatedHelicalTrackHits"; - String trackTimeDataRelationsColName = "TrackTimeDataRelations"; String trackResidualsRelationsColName = "TrackResidualsRelations"; public TrackDataDriver() { } - public void setTrackCollectionName(String name){ + public void setTrackCollectionName(String name) { this.trackCollectionName=name; } - protected void detectorChanged(Detector detector) { - - // TODO: Add plots of all track data variables - } - protected void process(EventHeader event) { // If the event doesn't contain a collection of tracks, skip it. - if (!event.hasCollection(Track.class, trackCollectionName)) { - return; - } + if (!event.hasCollection(Track.class, trackCollectionName)) return; // Get the collection of tracks from the event List<Track> tracks = event.get(Track.class, trackCollectionName); @@ -69,31 +58,27 @@ List<HelicalTrackHit> rotatedHths = event.get(HelicalTrackHit.class, rotatedHthCollectionName); - // Create a collection to hold the track time and t0 residual data - List<TrackTimeData> timeDataCollection = new ArrayList<TrackTimeData>(); - - // Create a collection of LCRelations between a track and the t0 residual data - List<LCRelation> trackToTrackTimeDataRelations = new ArrayList<LCRelation>(); - + // Create a container that will be used to store all TrackData objects. + List<TrackData> trackDataCollection = new ArrayList<TrackData>(); + + // Create a container that will be used to store all LCRelations between + // a TrackData object and the corresponding Track + List<LCRelation> trackDataRelations = new ArrayList<LCRelation>(); + // Create a collection to hold the track residuals List<TrackResidualsData> trackResidualsCollection = new ArrayList<TrackResidualsData>(); // Create a collection of LCRelations between a track and the track residuals List<LCRelation> trackToTrackResidualsRelations = new ArrayList<LCRelation>(); - // Create a collection to hold the track residuals - List<TrackQualityData> trackQualityCollection = new ArrayList<TrackQualityData>(); - - // Create a collection of LCRelations between a track and the track residuals - List<LCRelation> trackQualityDataToTrackRelations = new ArrayList<LCRelation>(); - - double totalT0 = 0; - double totalHits = 0; - double trackTime = 0; - double t0Residual = 0; double xResidual = 0; double yResidual = 0; - float trackerVolume = -1; + + float totalT0 = 0; + float totalHits = 0; + float trackTime = 0; + + int trackerVolume = -1; boolean isFirstHit = true; @@ -118,10 +103,10 @@ trackResidualsX.clear(); trackResidualsY.clear(); stereoLayers.clear(); + isFirstHit = true; // - // Calculate the track time and track residuals. Also, change the - // position of a HelicalTrackHit to be the corrected one. + // Change the position of a HelicalTrackHit to be the corrected one. // // Loop over all stereo hits comprising a track for (TrackerHit rotatedStereoHit : track.getTrackerHits()) { @@ -154,20 +139,6 @@ totalT0 += cluster.time(); totalHits++; - } - } - - // The track time is the mean t0 of hits on a track - trackTime = totalT0 / totalHits; - - // - // Calculate the t0 residuals - // - isFirstHit = true; - // Loop over all stereo hits comprising a track - for (TrackerHit stereoHit : track.getTrackerHits()) { - // Loop over the clusters comprising the stereo hit - for (HelicalTrackStrip cluster : ((HelicalTrackCross) stereoHit).getStrips()) { if (isFirstHit) { sensor = (HpsSiSensor) ((RawTrackerHit) cluster.rawhits().get(0)).getDetectorElement(); @@ -176,18 +147,13 @@ } else if (sensor.isBottomLayer()) { trackerVolume = 1; } + isFirstHit = false; } - - // Add the layer number associated with this residual to the list of layers - sensorLayers.add(sensor.getLayerNumber()); - - // Find the t0 residual and add it to the list of residuals - t0Residual = trackTime - cluster.time(); - // Apply correction to t0 residual - t0Residual /= Math.sqrt((totalHits - 1) / totalHits); - t0Residuals.add(t0Residual); } } + + // The track time is the mean t0 of hits on a track + trackTime = totalT0 / totalHits; double l1Isolation = 99999999.0; double l2Isolation = 99999999.0; @@ -204,27 +170,20 @@ } } - TrackTimeData timeData = new TrackTimeData(trackerVolume, trackTime, sensorLayers, t0Residuals); - timeDataCollection.add(timeData); - trackToTrackTimeDataRelations.add(new BaseLCRelation(timeData, track)); + double qualityArray[] = {l1Isolation, l2Isolation}; + TrackData trackData = new TrackData(trackerVolume, trackTime, qualityArray); + trackDataCollection.add(trackData); + trackDataRelations.add(new BaseLCRelation(trackData, track)); TrackResidualsData trackResiduals = new TrackResidualsData((int) trackerVolume, stereoLayers, trackResidualsX, trackResidualsY); trackResidualsCollection.add(trackResiduals); trackToTrackResidualsRelations.add(new BaseLCRelation(trackResiduals, track)); - - double qualityArray[] = {l1Isolation, l2Isolation}; - TrackQualityData qualityData = new TrackQualityData(qualityArray); - trackQualityCollection.add(qualityData); - trackQualityDataToTrackRelations.add(new BaseLCRelation(qualityData, track)); } - event.put(trackTimeDataCollectionName, timeDataCollection, TrackTimeData.class, 0); - event.put(trackTimeDataRelationsColName, trackToTrackTimeDataRelations, LCRelation.class, 0); + event.put(TrackData.TRACK_DATA_COLLECTION, trackDataCollection, TrackTimeData.class, 0); + event.put(TrackData.TRACK_DATA_RELATION_COLLECTION, trackDataRelations, LCRelation.class, 0); event.put(trackResidualsCollectionName, trackResidualsCollection, TrackResidualsData.class, 0); event.put(trackResidualsRelationsColName, trackToTrackResidualsRelations, LCRelation.class, 0); - event.put(TrackQualityData.QUALITY_COLLECTION, trackQualityCollection, TrackResidualsData.class, 0); - event.put(TrackQualityData.QUALITY_RELATION_COLLECTION, trackQualityDataToTrackRelations, LCRelation.class, 0); - } private static Double getNearestDistance(HelicalTrackStrip cl, List<HelicalTrackHit> toththits) { Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackTimeData.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackTimeData.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackTimeData.java Fri Jun 12 15:27:10 2015 @@ -8,7 +8,6 @@ /** * * @author Omar Moreno <[log in to unmask]> - * @version $Id$ * */ public class TrackTimeData implements GenericObject { @@ -17,6 +16,9 @@ List<Double> t0Residuals = new ArrayList<Double>(); List<Integer> layers = new ArrayList<Integer>(); + // Constants + private final static int SVT_VOLUME_INDEX = 0; + private final static int TRACK_TIME_INDEX = 1; /** * Default Ctor @@ -40,11 +42,41 @@ * @param t0Residual : * */ - public void addResidual(int layer, double t0Residual){ + private void addResidual(int layer, double t0Residual) { layers.add(layer); t0Residuals.add(t0Residual); } + /** + * + */ + public double getTrackTime() { + return trackTimeData.get(TRACK_TIME_INDEX); + } + + /** + * + * + */ + public double getT0Residual(int layer) { + return this.getDoubleVal(layer); + } + + /** + * + */ + public double getClusterTime(int layer) { + return this.getTrackTime() - this.getT0Residual(layer); + } + + /** + * + * + */ + public boolean isTopSvtVolume() { + return (trackTimeData.get(SVT_VOLUME_INDEX) == 0) ? true : false; + } + /** * */ Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackUtils.java Fri Jun 12 15:27:10 2015 @@ -23,6 +23,7 @@ import org.lcsim.event.MCParticle; import org.lcsim.event.RawTrackerHit; import org.lcsim.event.Track; +import org.lcsim.event.TrackState; import org.lcsim.event.TrackerHit; import org.lcsim.fit.helicaltrack.HelicalTrackFit; import org.lcsim.fit.helicaltrack.HelicalTrackHit; @@ -31,14 +32,17 @@ import org.lcsim.fit.helicaltrack.HelixUtils; import org.lcsim.fit.helicaltrack.HitUtils; import org.lcsim.fit.helicaltrack.MultipleScatter; +import org.lcsim.geometry.subdetector.BarrelEndcapFlag; import org.lcsim.recon.tracking.seedtracker.SeedCandidate; +import org.lcsim.recon.tracking.seedtracker.SeedStrategy; import org.lcsim.recon.tracking.seedtracker.SeedTrack; import org.lcsim.util.swim.Helix; /** - * Assorted helper functions for the track and helix objects in lcsim. Re-use as much of HelixUtils + * Assorted helper functions for the track and helix objects in lcsim. Re-use as + * much of HelixUtils * as possible. - * + * * @author Omar Moreno <[log in to unmask]> */ // TODO: Switch to tracking/LCsim coordinates for the extrapolation output! @@ -52,8 +56,10 @@ } /** - * Extrapolate track to a position along the x-axis. Turn the track into a helix object in + * Extrapolate track to a position along the x-axis. Turn the track into a + * helix object in * order to use HelixUtils. + * * @param track * @param x * @return @@ -64,6 +70,7 @@ /** * Extrapolate helix to a position along the x-axis. Re-use HelixUtils. + * * @param track * @param x * @return @@ -75,7 +82,6 @@ // ========================================================================== // Helper functions for track parameters and commonly used derived variables - public static double getPhi(Track track, Hep3Vector position) { double x = Math.sin(getPhi0(track)) - (1 / getR(track)) * (position.x() - getX0(track)); double y = Math.cos(getPhi0(track)) + (1 / getR(track)) * (position.y() - getY0(track)); @@ -119,10 +125,12 @@ } // ========================================================================== - - /** - * Calculate the point of interception between the helix and a plane in space. Uses an iterative procedure. - * This function makes assumptions on the sign and convecntion of the B-field. Be careful. + /** + * Calculate the point of interception between the helix and a plane in + * space. Uses an iterative procedure. + * This function makes assumptions on the sign and convecntion of the + * B-field. Be careful. + * * @param helfit - helix * @param unit_vec_normal_to_plane - unit vector normal to the plane * @param point_on_plane - point on the plane @@ -144,8 +152,10 @@ } /** - * Calculate the point of interception between the helix and a plane in space. Uses an + * Calculate the point of interception between the helix and a plane in + * space. Uses an * iterative procedure. + * * @param helfit - helix * @param strip - strip cluster that will define the plane * @param bfield - magnetic field value @@ -174,11 +184,11 @@ // y_int = k*x_int + m // R^2 = (y_int-y_c)^2 + (x_int-x_c)^2 // solve for x_int - } /** * Get position of a track extrapolated to the HARP in the HPS test run 2012 + * * @param track * @return position at HARP */ @@ -187,18 +197,22 @@ } /** - * Get position of a track extrapolated to the ECAL face in the HPS test run 2012 + * Get position of a track extrapolated to the ECAL face in the HPS test run + * 2012 + * * @param track * @return position at ECAL */ public static Hep3Vector getTrackPositionAtEcal(Track track) { - return extrapolateTrack(track, BeamlineConstants.ECAL_FACE_TESTRUN); + return extrapolateTrack(track, BeamlineConstants.ECAL_FACE); } /** * Extrapolate track to given position. + * * @param helix - to be extrapolated - * @param track - position along the x-axis of the helix in lcsim coordiantes + * @param track - position along the x-axis of the helix in lcsim + * coordiantes * @return */ public static Hep3Vector extrapolateTrack(Track track, double z) { @@ -234,6 +248,7 @@ /** * Extrapolate helix to given position + * * @param helix - to be extrapolated * @param z - position along the x-axis of the helix in lcsim coordiantes * @return @@ -254,7 +269,8 @@ * @param helix input helix object * @param origin of the plane to intercept * @param normal of the plane to intercept - * @param eps criteria on the distance to the plane before stopping iteration + * @param eps criteria on the distance to the plane before stopping + * iteration * @return position in space at the intercept of the plane */ public static Hep3Vector getHelixPlanePositionIter(HelicalTrackFit helix, Hep3Vector origin, Hep3Vector normal, double eps) { @@ -314,79 +330,67 @@ // System.out.printf("pos %s xc %f phi_at_x %f dphi_at_x %f s_at_x %f\n", // pos.toString(),xc,phi_at_x,dphi_at_x,s_at_x); Hep3Vector posXCheck = TrackUtils.extrapolateHelixToXPlane(helix, x); - if (VecOp.sub(pos, posXCheck).magnitude() > 0.0000001) { + if (VecOp.sub(pos, posXCheck).magnitude() > 0.0000001) throw new RuntimeException(String.format("ERROR the helix propagation equations do not agree? (%f,%f,%f) vs (%f,%f,%f) in HelixUtils", pos.x(), pos.y(), pos.z(), posXCheck.x(), posXCheck.y(), posXCheck.z())); - } return pos; } /** - * - */ + * + */ public static double findTriangleArea(double x0, double y0, double x1, double y1, double x2, double y2) { return .5 * (x1 * y2 - y1 * x2 - x0 * y2 + y0 * x2 + x0 * y1 - y0 * x1); } /** - * - */ + * + */ public static boolean sensorContainsTrack(Hep3Vector trackPosition, SiSensor sensor) { boolean debug = false; ITransform3D localToGlobal = sensor.getGeometry().getLocalToGlobal(); Box sensorSolid = (Box) sensor.getGeometry().getLogicalVolume().getSolid(); Polygon3D sensorFace = sensorSolid.getFacesNormalTo(new BasicHep3Vector(0, 0, 1)).get(0); - if (debug) { + if (debug) System.out.println("sensorContainsTrack: Track Position: " + trackPosition.toString()); - } List<Point3D> vertices = new ArrayList<Point3D>(); - for (int index = 0; index < 4; index++) { + for (int index = 0; index < 4; index++) vertices.add(new Point3D()); - } - for (Point3D vertex : sensorFace.getVertices()) { + for (Point3D vertex : sensorFace.getVertices()) if (vertex.y() < 0 && vertex.x() > 0) { localToGlobal.transform(vertex); // vertices.set(0, new Point3D(vertex.y() + sensorPos.x(), vertex.x() + // sensorPos.y(), vertex.z() + sensorPos.z())); vertices.set(0, new Point3D(vertex.x(), vertex.y(), vertex.z())); - if (debug) { - System.out.println("sensorContainsTrack: Vertex 1 Position: " + vertices.get(0).toString()); - // System.out.println("sensorContainsTrack: Transformed Vertex 1 Position: " + - // localToGlobal.transformed(vertex).toString()); - } + if (debug) + System.out.println("sensorContainsTrack: Vertex 1 Position: " + vertices.get(0).toString()); // System.out.println("sensorContainsTrack: Transformed Vertex 1 Position: " + + // localToGlobal.transformed(vertex).toString()); } else if (vertex.y() > 0 && vertex.x() > 0) { localToGlobal.transform(vertex); // vertices.set(1, new Point3D(vertex.y() + sensorPos.x(), vertex.x() + // sensorPos.y(), vertex.z() + sensorPos.z())); vertices.set(1, new Point3D(vertex.x(), vertex.y(), vertex.z())); - if (debug) { - System.out.println("sensorContainsTrack: Vertex 2 Position: " + vertices.get(1).toString()); - // System.out.println("sensorContainsTrack: Transformed Vertex 2 Position: " + - // localToGlobal.transformed(vertex).toString()); - } + if (debug) + System.out.println("sensorContainsTrack: Vertex 2 Position: " + vertices.get(1).toString()); // System.out.println("sensorContainsTrack: Transformed Vertex 2 Position: " + + // localToGlobal.transformed(vertex).toString()); } else if (vertex.y() > 0 && vertex.x() < 0) { localToGlobal.transform(vertex); // vertices.set(2, new Point3D(vertex.y() + sensorPos.x(), vertex.x() + // sensorPos.y(), vertex.z() + sensorPos.z())); vertices.set(2, new Point3D(vertex.x(), vertex.y(), vertex.z())); - if (debug) { - System.out.println("sensorContainsTrack: Vertex 3 Position: " + vertices.get(2).toString()); - // System.out.println("sensorContainsTrack: Transformed Vertex 3 Position: " + - // localToGlobal.transformed(vertex).toString()); - } + if (debug) + System.out.println("sensorContainsTrack: Vertex 3 Position: " + vertices.get(2).toString()); // System.out.println("sensorContainsTrack: Transformed Vertex 3 Position: " + + // localToGlobal.transformed(vertex).toString()); } else if (vertex.y() < 0 && vertex.x() < 0) { localToGlobal.transform(vertex); // vertices.set(3, new Point3D(vertex.y() + sensorPos.x(), vertex.x() + // sensorPos.y(), vertex.z() + sensorPos.z())); vertices.set(3, new Point3D(vertex.x(), vertex.y(), vertex.z())); - if (debug) { - System.out.println("sensorContainsTrack: Vertex 4 Position: " + vertices.get(3).toString()); - // System.out.println("sensorContainsTrack: Transformed Vertex 4 Position: " + - // localToGlobal.transformed(vertex).toString()); - } + if (debug) + System.out.println("sensorContainsTrack: Vertex 4 Position: " + vertices.get(3).toString()); // System.out.println("sensorContainsTrack: Transformed Vertex 4 Position: " + + // localToGlobal.transformed(vertex).toString()); } - } double area1 = TrackUtils.findTriangleArea(vertices.get(0).x(), vertices.get(0).y(), vertices.get(1).x(), vertices.get(1).y(), trackPosition.y(), trackPosition.z()); double area2 = TrackUtils.findTriangleArea(vertices.get(1).x(), vertices.get(1).y(), vertices.get(2).x(), vertices.get(2).y(), trackPosition.y(), trackPosition.z()); @@ -414,7 +418,6 @@ } // Calculate the residuals that are being used in the track fit - // Start with the bendplane y double drphi_res = hth.drphi(); double wrphi = Math.sqrt(drphi_res * drphi_res + msdrphi * msdrphi); @@ -465,6 +468,11 @@ return residuals; } + public static Map<String, Double> calculateLocalTrackHitResiduals(Track track, HelicalTrackHit hth, HelicalTrackStrip strip, double bFieldInZ) { + HelicalTrackStripGbl stripGbl = new HelicalTrackStripGbl(strip, true); + return calculateLocalTrackHitResiduals(track, hth, stripGbl, bFieldInZ); + } + public static Map<String, Double> calculateLocalTrackHitResiduals(Track track, HelicalTrackHit hth, HelicalTrackStripGbl strip, double bFieldInZ) { SeedTrack st = (SeedTrack) track; @@ -476,21 +484,34 @@ return calculateLocalTrackHitResiduals(_trk, strip, msdrdphi, msdz, bFieldInZ); } + public static Map<String, Double> calculateLocalTrackHitResiduals(HelicalTrackFit _trk, HelicalTrackStrip strip, double bFieldInZ) { + HelicalTrackStripGbl stripGbl = new HelicalTrackStripGbl(strip, true); + return calculateLocalTrackHitResiduals( _trk, stripGbl, 0.0, 0.0, bFieldInZ); + } + + + public static Map<String, Double> calculateLocalTrackHitResiduals(HelicalTrackFit _trk, HelicalTrackStripGbl strip, double msdrdphi, double msdz, double bFieldInZ) { boolean debug = false; boolean includeMS = true; + if (debug) { + System.out.printf("calculateLocalTrackHitResiduals: for strip on sensor %s \n", + ((RawTrackerHit)strip.getStrip().rawhits().get(0)).getDetectorElement().getName()); + } + Hep3Vector u = strip.u(); Hep3Vector corigin = strip.origin(); // Find interception with plane that the strips belongs to - Hep3Vector trkpos = TrackUtils.getHelixPlaneIntercept(_trk, strip, bFieldInZ); + Hep3Vector trkpos = TrackUtils.getHelixPlaneIntercept(_trk, strip, Math.abs(bFieldInZ)); if (debug) { - System.out.printf("calculateLocalTrackHitResiduals: found interception point at %s \n", trkpos.toString()); - } - + System.out.printf("calculateLocalTrackHitResiduals: strip u %s origin %s \n", u.toString(),corigin.toString()); + System.out.printf("calculateLocalTrackHitResiduals: found interception point with sensor at %s \n", trkpos.toString()); + } + if (Double.isNaN(trkpos.x()) || Double.isNaN(trkpos.y()) || Double.isNaN(trkpos.z())) { System.out.printf("calculateLocalTrackHitResiduals: failed to get interception point (%s) \n", trkpos.toString()); System.out.printf("calculateLocalTrackHitResiduals: track params\n%s\n", _trk.toString()); @@ -523,6 +544,12 @@ double wmeas = 0; double wError = 10.0 / Math.sqrt(12); // 0.001; + + if (debug) { + System.out.printf("calculateLocalTrackHitResiduals: vdiffTrk %s vdiff %s umc %f umeas %f du %f\n", + vdiffTrk.toString(),vdiff.toString(),umc, umeas, umeas-umc); + } + Map<String, Double> res = new HashMap<String, Double>(); res.put("ures", umeas - umc); res.put("ureserr", includeMS ? Math.sqrt(uError * uError + msuError * msuError) : uError); @@ -537,17 +564,16 @@ } public static int[] getHitsInTopBottom(Track track) { - int n[] = { 0, 0 }; + int n[] = {0, 0}; List<TrackerHit> hitsOnTrack = track.getTrackerHits(); for (TrackerHit hit : hitsOnTrack) { HelicalTrackHit hth = (HelicalTrackHit) hit; //===> if (SvtUtils.getInstance().isTopLayer((SiSensor) ((RawTrackerHit) hth.getRawHits().get(0)).getDetectorElement())) { HpsSiSensor sensor = ((HpsSiSensor) ((RawTrackerHit) hth.getRawHits().get(0)).getDetectorElement()); - if(sensor.isTopLayer()){ + if (sensor.isTopLayer()) n[0] = n[0] + 1; - } else { + else n[1] = n[1] + 1; - } } return n; } @@ -562,13 +588,12 @@ public static int isTopOrBottomTrack(Track track, int minhits) { int nhits[] = getHitsInTopBottom(track); - if (nhits[0] >= minhits && nhits[1] == 0) { + if (nhits[0] >= minhits && nhits[1] == 0) return 1; - } else if (nhits[1] >= minhits && nhits[0] == 0) { + else if (nhits[1] >= minhits && nhits[0] == 0) return 0; - } else { + else return -1; - } } public static boolean hasTopBotHit(Track track) { @@ -585,10 +610,9 @@ List<TrackerHit> hitsOnTrack = track.getTrackerHits(); for (TrackerHit loop_hit : hitsOnTrack) { HelicalTrackHit loop_hth = (HelicalTrackHit) loop_hit; - if (hth.equals(loop_hth)) { + if (hth.equals(loop_hth)) // System.out.printf("share hit at layer %d at %s (%s) with track w/ chi2=%f\n",hth.Layer(),hth.getCorrectedPosition().toString(),loop_hth.getCorrectedPosition().toString(),track.getChi2()); return true; - } } } return false; @@ -600,20 +624,17 @@ // System.out.printf("look for another track with chi2=%f and px=%f \n",track.getChi2(),track.getTrackStates().get(0).getMomentum()[0]); for (Track t : tracklist) { // System.out.printf("add track with chi2=%f and px=%f ?\n",t.getChi2(),t.getTrackStates().get(0).getMomentum()[0]); - if (t.equals(track)) { + if (t.equals(track)) // System.out.printf("NOPE\n"); continue; - } // System.out.printf("YEPP\n"); tracks.add(t); } List<TrackerHit> hitsOnTrack = track.getTrackerHits(); int n_shared = 0; - for (TrackerHit hit : hitsOnTrack) { - if (isSharedHit(hit, tracks)) { + for (TrackerHit hit : hitsOnTrack) + if (isSharedHit(hit, tracks)) ++n_shared; - } - } return n_shared; } @@ -631,8 +652,8 @@ } public static int passTrackSelections(Track track, List<Track> tracklist, EventQuality.Quality trk_quality) { - int cuts[] = { 0 }; - if(trk_quality.compareTo(Quality.NONE) != 0) { + int cuts[] = {0}; + if (trk_quality.compareTo(Quality.NONE) != 0) { if (track.getTrackStates().get(0).getMomentum()[0] < EventQuality.instance().getCutValue(EventQuality.Cut.PZ, trk_quality)) cut(cuts, EventQuality.Cut.PZ); if (track.getChi2() >= EventQuality.instance().getCutValue(EventQuality.Cut.CHI2, trk_quality)) @@ -656,15 +677,25 @@ } /** - * Transform MCParticle into a Helix object. Note that it produces the helix parameters at + * Transform MCParticle into a Helix object. Note that it produces the helix + * parameters at * nominal x=0 and assumes that there is no field at x<0 - * + * * @param mcp MC particle to be transformed * @return helix object based on the MC particle */ public static HelicalTrackFit getHTF(MCParticle mcp, double Bz) { + boolean debug = true; + if (debug) { + System.out.printf("getHTF\n"); + System.out.printf("mcp org %s mc p %s\n", mcp.getOrigin().toString(), mcp.getMomentum().toString()); + } Hep3Vector org = CoordinateTransformations.transformVectorToTracking(mcp.getOrigin()); Hep3Vector p = CoordinateTransformations.transformVectorToTracking(mcp.getMomentum()); + + if (debug) + System.out.printf("mcp org %s mc p %s (trans)\n", org.toString(), p.toString()); + // Move to x=0 if needed double targetX = BeamlineConstants.DIPOLE_EDGELOW_TESTRUN; if (org.x() < targetX) { @@ -681,7 +712,8 @@ // old.toString(),p.toString(),org.toString()); } - // System.out.printf("outside org %s p %s \n",p.toString(),org.toString()); + if (debug) + System.out.printf("mcp org %s mc p %s (trans2)\n", org.toString(), p.toString()); HelixParamCalculator helixParamCalculator = new HelixParamCalculator(p, org, -1 * ((int) mcp.getCharge()), Bz); double par[] = new double[5]; @@ -691,17 +723,16 @@ par[HelicalTrackFit.curvatureIndex] = 1.0 / helixParamCalculator.getRadius(); par[HelicalTrackFit.z0Index] = helixParamCalculator.getZ0(); HelicalTrackFit htf = getHTF(par); - // System.out.printf("d0 %f z0 %f R %f phi %f lambda %s\n", - // htf.dca(),htf.z0(),htf.R(),htf.phi0(),htf.slope() ); + System.out.printf("d0 %f z0 %f R %f phi %f lambda %s\n", + htf.dca(), htf.z0(), htf.R(), htf.phi0(), htf.slope()); return htf; } public static HelicalTrackFit getHTF(Track track) { - if (track.getClass().isInstance(SeedTrack.class)) { + if (track.getClass().isInstance(SeedTrack.class)) return ((SeedTrack) track).getSeedCandidate().getHelix(); - } else { + else return getHTF(track.getTrackStates().get(0).getParameters()); - } } public static HelicalTrackFit getHTF(double par[]) { @@ -721,9 +752,8 @@ if (useFringe) { // broken because you need ot provide the Field Map to get this... // pos1 = hpstrk1.getPositionAtZMap(100.0, zVal, 5.0)[0]; - } else { + } else pos1 = TrackUtils.extrapolateTrack(trk1, zVal); - } // System.out.printf("%s: Position1 at edge of fringe %s\n",this.getClass().getSimpleName(),pos1.toString()); Helix traj = (Helix) hpstrk1.getTrajectory(); if (traj == null) { @@ -736,4 +766,98 @@ return slt1; } + public static MCParticle getMatchedTruthParticle(Track track) { + boolean debug = false; + + Map<MCParticle, Integer> particlesOnTrack = new HashMap<MCParticle, Integer>(); + + if (debug) + System.out.printf("getMatchedTruthParticle: getmatched mc particle from %d tracker hits on the track \n", track.getTrackerHits().size()); + + for (TrackerHit hit : track.getTrackerHits()) { + List<MCParticle> mcps = ((HelicalTrackHit) hit).getMCParticles(); + if (mcps == null) + System.out.printf("getMatchedTruthParticle: warning, this hit (layer %d pos=%s) has no mc particles.\n", ((HelicalTrackHit) hit).Layer(), ((HelicalTrackHit) hit).getCorrectedPosition().toString()); + else { + if (debug) + System.out.printf("getMatchedTruthParticle: this hit (layer %d pos=%s) has %d mc particles.\n", ((HelicalTrackHit) hit).Layer(), ((HelicalTrackHit) hit).getCorrectedPosition().toString(), mcps.size()); + for (MCParticle mcp : mcps) { + if (!particlesOnTrack.containsKey(mcp)) + particlesOnTrack.put(mcp, 0); + int c = particlesOnTrack.get(mcp); + particlesOnTrack.put(mcp, c + 1); + } + } + } + if (debug) { + System.out.printf("Track p=[ %f, %f, %f] \n", track.getTrackStates().get(0).getMomentum()[0], track.getTrackStates().get(0).getMomentum()[1], track.getTrackStates().get(0).getMomentum()[1]); + System.out.printf("Found %d particles\n", particlesOnTrack.size()); + for (Map.Entry<MCParticle, Integer> entry : particlesOnTrack.entrySet()) + System.out.printf("%d hits assigned to %d p=%s \n", entry.getValue(), entry.getKey().getPDGID(), entry.getKey().getMomentum().toString()); + } + Map.Entry<MCParticle, Integer> maxEntry = null; + for (Map.Entry<MCParticle, Integer> entry : particlesOnTrack.entrySet()) + if (maxEntry == null || entry.getValue().compareTo(maxEntry.getValue()) > 0) + maxEntry = entry; //if ( maxEntry != null ) { + // if(entry.getValue().compareTo(maxEntry.getValue()) < 0) continue; + //} + //maxEntry = entry; + if (debug) + if (maxEntry != null) + System.out.printf("Matched particle with pdgId=%d and mom %s to track with charge %d and momentum [%f %f %f]\n", + maxEntry.getKey().getPDGID(), maxEntry.getKey().getMomentum().toString(), + track.getCharge(), track.getTrackStates().get(0).getMomentum()[0], track.getTrackStates().get(0).getMomentum()[1], track.getTrackStates().get(0).getMomentum()[2]); + else + System.out.printf("No truth particle found on this track\n"); + return maxEntry == null ? null : maxEntry.getKey(); + } + + /* + try to make a seed track from a base track + ...some things are irretrivable (tracking strategy).. + and some things I just don't care much about to dig out (det name) + */ + public static SeedTrack makeSeedTrackFromBaseTrack(Track track) { + + TrackState trkState = track.getTrackStates().get(0); + // first make the HelicalTrackFit Object + double[] covArray = trkState.getCovMatrix(); + SymmetricMatrix cov = new SymmetricMatrix(5, covArray, true); + double[] chisq = {track.getChi2(), 0}; + int[] ndf = {track.getNDF(), 0}; + Map<HelicalTrackHit, Double> smap = new HashMap<>(); // just leave these empty + Map<HelicalTrackHit, MultipleScatter> msmap = new HashMap<>();// just leave these empty + double[] pars = {trkState.getD0(), trkState.getPhi(), trkState.getOmega(), trkState.getZ0(), trkState.getTanLambda()}; + HelicalTrackFit htf = new HelicalTrackFit(pars, cov, chisq, ndf, smap, msmap); + // now get the hits and make them helicaltrackhits + List<TrackerHit> rth = track.getTrackerHits(); + List<HelicalTrackHit> hth = new ArrayList<>(); + for (TrackerHit hit : rth) + hth.add(makeHelicalTrackHitFromTrackerHit(hit)); +// SeedCandidate(List<HelicalTrackHit> , SeedStrategy strategy, HelicalTrackFit helix, double bfield) ; + SeedCandidate scand = new SeedCandidate(hth, null, htf, 0.24); + SeedTrack st = new SeedTrack(); + st.setSeedCandidate(scand); + return st; + } + + /* + cast TrackerHit as HTH...this is pretty dumb; just a rearrangment of information + in TrackerHit. The important information that's in HTH but not + in Tracker hit is the HelicalTrackCrosses (and from there the individual strip clusters) + is lost; some work to get them back. + */ + public static HelicalTrackHit makeHelicalTrackHitFromTrackerHit(TrackerHit hit) { + Hep3Vector pos = new BasicHep3Vector(hit.getPosition()); + SymmetricMatrix hitcov = new SymmetricMatrix(3, hit.getCovMatrix(), true); + double dedx = hit.getdEdx(); + double time = hit.getTime(); + int type = hit.getType(); + List rhits = hit.getRawHits(); + String detname = "Foobar"; + int layer = 666; + BarrelEndcapFlag beflag = BarrelEndcapFlag.BARREL; + return new HelicalTrackHit(pos, hitcov, dedx, time, type, rhits, detname, layer, beflag); + } + } Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackerReconDriver.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackerReconDriver.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/TrackerReconDriver.java Fri Jun 12 15:27:10 2015 @@ -2,11 +2,19 @@ import hep.physics.vec.BasicHep3Vector; import hep.physics.vec.Hep3Vector; - +import hep.physics.vec.VecOp; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; - +import java.util.Map; import org.lcsim.event.EventHeader; +import org.lcsim.event.LCRelation; +import org.lcsim.event.RelationalTable; import org.lcsim.event.Track; +import org.lcsim.event.TrackerHit; +import org.lcsim.event.base.BaseRelationalTable; import org.lcsim.event.base.BaseTrack; import org.lcsim.fit.helicaltrack.HelicalTrackHit; import org.lcsim.geometry.Detector; @@ -49,7 +57,9 @@ // enable the use of sectoring using sector binning in SeedTracker private boolean _applySectorBinning = true; private double rmsTimeCut = -1; - + private boolean rejectUncorrectedHits = true; + private boolean rejectSharedHits = false; + public TrackerReconDriver() { } @@ -109,6 +119,14 @@ */ public void setRmsTimeCut(double rmsTimeCut) { this.rmsTimeCut = rmsTimeCut; + } + + public void setRejectUncorrectedHits(boolean rejectUncorrectedHits) { + this.rejectUncorrectedHits = rejectUncorrectedHits; + } + + public void setRejectSharedHits(boolean rejectSharedHits) { + this.rejectSharedHits = rejectSharedHits; } /** @@ -192,6 +210,79 @@ // Set the type of track to indicate B-field in Y e.g. for swimming in Wired. List<Track> tracks = event.get(Track.class, trackCollectionName); + + if (rejectUncorrectedHits) { + Iterator<Track> iter = tracks.iterator(); + trackLoop: + while (iter.hasNext()) { + Track track = iter.next(); + for (TrackerHit hit : track.getTrackerHits()) { + HelicalTrackHit hth = (HelicalTrackHit) hit; + double correction = VecOp.sub(hth.getCorrectedPosition(), new BasicHep3Vector(hth.getPosition())).magnitude(); + double chisq = hth.chisq(); + if (correction < 1e-6) { + this.getLogger().warning(String.format("Discarding track with bad HelicalTrackHit (correction distance %f, chisq penalty %f)", correction, chisq)); + iter.remove(); + continue trackLoop; + } + } + } + } + + if (rejectSharedHits) { + + RelationalTable hittostrip = new BaseRelationalTable(RelationalTable.Mode.MANY_TO_MANY, RelationalTable.Weighting.UNWEIGHTED); + List<LCRelation> hitrelations = event.get(LCRelation.class, "HelicalTrackHitRelations"); + for (LCRelation relation : hitrelations) { + if (relation != null && relation.getFrom() != null && relation.getTo() != null) { + hittostrip.add(relation.getFrom(), relation.getTo()); + } + } + + RelationalTable hittorotated = new BaseRelationalTable(RelationalTable.Mode.ONE_TO_ONE, RelationalTable.Weighting.UNWEIGHTED); + List<LCRelation> rotaterelations = event.get(LCRelation.class, "RotatedHelicalTrackHitRelations"); + for (LCRelation relation : rotaterelations) { + if (relation != null && relation.getFrom() != null && relation.getTo() != null) { + hittorotated.add(relation.getFrom(), relation.getTo()); + } + } + + Map<TrackerHit, List<Track>> stripsToTracks = new HashMap<TrackerHit, List<Track>>(); + for (Track track : tracks) { + for (TrackerHit hit : track.getTrackerHits()) { + Collection<TrackerHit> htsList = hittostrip.allFrom(hittorotated.from(hit)); + for (TrackerHit strip : htsList) { + List<Track> sharedTracks = stripsToTracks.get(strip); + if (sharedTracks == null) { + sharedTracks = new ArrayList<Track>(); + stripsToTracks.put(strip, sharedTracks); + } + sharedTracks.add(track); + } + } + } + Iterator<Track> iter = tracks.iterator(); + trackLoop: + while (iter.hasNext()) { + Track track = iter.next(); + for (TrackerHit hit : track.getTrackerHits()) { + Collection<TrackerHit> htsList = hittostrip.allFrom(hittorotated.from(hit)); + for (TrackerHit strip : htsList) { + List<Track> sharedTracks = stripsToTracks.get(strip); + if (sharedTracks.size() > 1) { + for (Track otherTrack : sharedTracks) { + if (otherTrack.getChi2() < track.getChi2()) { + this.getLogger().warning(String.format("removing track with shared hits: chisq %f, d0 %f (other track has chisq %f)", track.getChi2(), track.getTrackStates().get(0).getD0(), otherTrack.getChi2())); + iter.remove(); + continue trackLoop; + } + } + } + } + } + } + } + setTrackType(tracks); // Increment number of events. Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLFileIO.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLFileIO.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLFileIO.java Fri Jun 12 15:27:10 2015 @@ -170,9 +170,13 @@ void printStripTrackPos(Hep3Vector pos) { addLine(String.format("Strip track pos %.10f %.10f %.10f",pos.x(),pos.y(),pos.z())); } - - void printStrip(int id, int layer) { - addLine(String.format("New Strip id layer %d %d", id,layer)); + + void printStripTrackPosMeasFrame(Hep3Vector pos) { + addLine(String.format("Strip track pos meas frame %.10f %.10f %.10f",pos.x(),pos.y(),pos.z())); + } + + void printStrip(int id, int layer, String deName) { + addLine(String.format("New Strip id layer %d %d %s", id,layer,deName)); } void printStripPathLen(double s) { Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutput.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutput.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutput.java Fri Jun 12 15:27:10 2015 @@ -59,7 +59,7 @@ private TrackerHitUtils _trackerHitUtils = new TrackerHitUtils(); private MaterialSupervisor _materialmanager; private MultipleScattering _scattering; - private double _beamEnergy = 2.2; //GeV + private double _beamEnergy = 1.1; //GeV private boolean AprimeEvent = false; // do extra checks private boolean hasXPlanes = false; @@ -270,7 +270,7 @@ if(_debug>0) System.out.printf("%s: layer %d millepede %d (DE=\"%s\", origin %s) \n",this.getClass().getSimpleName(),strip.layer(), millepedeId, sensor.getName(), strip.origin().toString()); if(textFile != null) { - textFile.printStrip(istrip,millepedeId); + textFile.printStrip(istrip,millepedeId,de.getName()); } //GBLDATA @@ -404,10 +404,15 @@ if(textFile != null) { textFile.printStripMeas(m_meas.x()); } + + //if(textFile != null) { + // textFile.printStripTrackPosMeasFrame(trkpos_meas); + //} + //GBLDATA stripData.setMeas(strip.umeas()); - stripData.setTrackPos(trkpos_meas); + //stripData.setTrackPos(trkpos_meas); if(_debug>1) { System.out.printf("%s: rotation matrix to meas frame\n%s\n", getClass().getSimpleName(), VecOp.toString(trkToStripRot)); Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/GBLOutputDriver.java Fri Jun 12 15:27:10 2015 @@ -36,7 +36,7 @@ private AIDA aida = AIDA.defaultInstance(); int nevt = 0; - GBLOutput gbl; + GBLOutput gbl = null; TruthResiduals truthRes = null; private String gblFileName = ""; private String outputPlotFileName=""; @@ -166,7 +166,9 @@ @Override public void endOfData() { - gbl.close(); + if(gbl!=null) + gbl.close(); + if (!"".equals(outputPlotFileName)) { try { aida.saveAs(outputPlotFileName); Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/HpsGblRefitter.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/HpsGblRefitter.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/HpsGblRefitter.java Fri Jun 12 15:27:10 2015 @@ -11,6 +11,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.logging.Formatter; import java.util.logging.Level; import java.util.logging.Logger; @@ -40,7 +41,8 @@ */ public class HpsGblRefitter extends Driver { - private static Logger logger = LogUtil.create(HpsGblRefitter.class, new BasicLogFormatter()); + static Formatter f = new BasicLogFormatter(); + private static Logger logger = LogUtil.create(HpsGblRefitter.class.getSimpleName(), f,Level.WARNING); //private static final Logger logger = Logger.getLogger(HpsGblRefitter.class.getName()); private boolean _debug = false; private final String trackCollectionName = "MatchedTracks"; @@ -71,10 +73,15 @@ public HpsGblRefitter() { _makeTracks = new MakeGblTracks(); - logger.setLevel(Level.INFO); - - } - + logger.setLevel(Level.WARNING); + System.out.println("level " + logger.getLevel().toString()); + } + + //@Override + //public void setLogLevel(String logLevel) { + // logger.setLevel(Level.parse(logLevel)); + //} + @Override protected void startOfData() { @@ -423,9 +430,9 @@ for(int i=0; i < milleParameters.size(); ++i) { logders += labGlobal.get(i) + "\t" + addDer.get(0, i) + "\n"; } - logger.fine("\n"+ logders); + logger.info("\n"+ logders); - logger.fine("uRes " + strip.getId() + " uRes " + uRes + " pred (" + strip.getTrackPos().x() + "," + strip.getTrackPos().y() + "," + strip.getTrackPos().z() + ") s(3D) " + strip.getPath3D()); + logger.info("uRes " + strip.getId() + " uRes " + uRes + " pred (" + strip.getTrackPos().x() + "," + strip.getTrackPos().y() + "," + strip.getTrackPos().z() + ") s(3D) " + strip.getPath3D()); //go to next point s += step; Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/MakeGblTracks.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/MakeGblTracks.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/recon/tracking/gbl/MakeGblTracks.java Fri Jun 12 15:27:10 2015 @@ -13,6 +13,7 @@ import org.hps.recon.tracking.gbl.matrix.SymMatrix; import org.hps.recon.tracking.gbl.matrix.Vector; +import org.hps.util.BasicLogFormatter; import org.lcsim.constants.Constants; import org.lcsim.event.EventHeader; import org.lcsim.event.Track; @@ -22,6 +23,7 @@ import org.lcsim.lcio.LCIOConstants; import org.lcsim.recon.tracking.seedtracker.SeedCandidate; import org.lcsim.recon.tracking.seedtracker.SeedTrack; +import org.lcsim.util.log.LogUtil; /** @@ -34,7 +36,7 @@ private String _TrkCollectionName = "GblTracks"; - private static final Logger logger = Logger.getLogger(MakeGblTracks.class.getName()); + private static Logger logger = LogUtil.create(MakeGblTracks.class, new BasicLogFormatter()); /** * Creates a new instance of MakeTracks. @@ -44,7 +46,7 @@ //logger.setUseParentHandlers(false); //Handler handler = new StreamHandler(System.out, new SimpleFormatter()); //logger.addHandler(handler); - logger.setLevel(Level.WARNING); + logger.setLevel(Level.INFO); // try { // logger.addHandler(new FileHandler(MakeGblTracks.class.getSimpleName()+".log")); // } catch (SecurityException | IOException e) { @@ -152,7 +154,8 @@ double phi0 = helix.phi0(); double slope = helix.slope(); double p = helix.p(bfield); - double qOverP = traj.get_seed().getCharge()/p; + double q = traj.get_seed().getCharge(); + double qOverP = q/p; // get corrections from GBL fit Vector locPar = new Vector(5); @@ -164,6 +167,8 @@ double xTPrimeCorr = locPar.get(FittedGblTrajectory.GBLPARIDX.XTPRIME.getValue()); double yTPrimeCorr = locPar.get(FittedGblTrajectory.GBLPARIDX.YTPRIME.getValue()); + logger.info((slope>0?"top: ":"bot ") + "qOverPCorr " + qOverPCorr + " xTCorr " + xTCorr + " yTCorr " + yTCorr + " xtPrimeCorr " + xTPrimeCorr + " yTPrimeCorr " + yTPrimeCorr); + // calculate new d0 and z0 Hep3Matrix perToClPrj = traj.get_track_data().getPrjPerToCl(); Hep3Matrix clToPerPrj = VecOp.inverse(perToClPrj); @@ -177,19 +182,23 @@ double z0_corr = corrPer.z(); double z0_gbl = z0 + z0_corr; + //calculate new phi0 + double phi0_gbl = phi0 + xTPrimeCorr; + + //calculate new slope + double lambda_gbl = Math.atan(slope) + yTPrimeCorr; + double slope_gbl = Math.tan( lambda_gbl ); + // calculate new curvature - // return self.track.qOverP(bfac) + self.curvCorr() + double qOverP_gbl = qOverP + qOverPCorr; - double pt_gbl = 1.0/qOverP_gbl * helix.sth(); + double pt_gbl = Math.abs(1.0/qOverP_gbl) * Math.sin((Math.PI/2.0-lambda_gbl)); double C_gbl = Constants.fieldConversion * bfield / pt_gbl; //make sure sign is not changed C_gbl = Math.signum(helix.curvature())*Math.abs(C_gbl); - //calculate new phi0 - double phi0_gbl = phi0 + xTPrimeCorr; - - //calculate new slope - double slope_gbl = Math.tan( Math.atan(helix.slope()) + yTPrimeCorr); + logger.info("qOverP="+qOverP+" qOverPCorr="+qOverPCorr+" qOverP_gbl="+qOverP_gbl+" ==> pGbl="+1.0/qOverP_gbl); + double parameters_gbl[] = new double[5]; parameters_gbl[HelicalTrackFit.dcaIndex] = d0_gbl; Modified: java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/svt/alignment/BuildMillepedeCompact.java ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/svt/alignment/BuildMillepedeCompact.java (original) +++ java/branches/HPSJAVA-488/tracking/src/main/java/org/hps/svt/alignment/BuildMillepedeCompact.java Fri Jun 12 15:27:10 2015 @@ -176,7 +176,11 @@ if(replaceConstant) { newValue = correction; } else { - newValue = oldValue + correction; + if (p.getType() == MilleParameter.Type.ROTATION.getType()) { + newValue = oldValue - correction; + } else { + newValue = oldValue + correction; + } } System.out.println("Update " + p.getId() + ": " + oldValue + " (corr. " + correction + ") -> " + newValue ); node.setAttribute("value", String.format("%.6f",newValue)); Modified: java/branches/HPSJAVA-488/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L1-3.xml ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L1-3.xml (original) +++ java/branches/HPSJAVA-488/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L1-3.xml Fri Jun 12 15:27:10 2015 @@ -9,8 +9,8 @@ <MinHits>3</MinHits> <MinConfirm>0</MinConfirm> - <MaxDCA>4.0</MaxDCA> - <MaxZ0>4.0</MaxZ0> + <MaxDCA>20.0</MaxDCA> + <MaxZ0>20.0</MaxZ0> <MaxChisq>25.0</MaxChisq> <BadHitChisq>10.0</BadHitChisq> Modified: java/branches/HPSJAVA-488/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L4-6.xml ============================================================================= --- java/branches/HPSJAVA-488/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L4-6.xml (original) +++ java/branches/HPSJAVA-488/tracking/src/main/resources/org/hps/recon/tracking/strategies/HPS-Full-L4-6.xml Fri Jun 12 15:27:10 2015 @@ -9,8 +9,8 @@ <MinHits>3</MinHits> <MinConfirm>0</MinConfirm> - <MaxDCA>10.0</MaxDCA> - <MaxZ0>10.0</MaxZ0> + <MaxDCA>20.0</MaxDCA> + <MaxZ0>20.0</MaxZ0> <MaxChisq>25.0</MaxChisq> <BadHitChisq>10.0</BadHitChisq> Modified: java/branches/HPSJAVA-488/users/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/users/pom.xml (original) +++ java/branches/HPSJAVA-488/users/pom.xml Fri Jun 12 15:27:10 2015 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/users/</url> Modified: java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/celentan/DummyDriverRaw.java ============================================================================= --- java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/celentan/DummyDriverRaw.java (original) +++ java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/celentan/DummyDriverRaw.java Fri Jun 12 15:27:10 2015 @@ -5,58 +5,47 @@ import org.lcsim.event.EventHeader; import org.lcsim.geometry.Detector; import org.lcsim.util.Driver; -import org.lcsim.util.aida.AIDA; -import org.hps.recon.ecal.EcalUtils; import org.hps.recon.ecal.triggerbank.AbstractIntData; import org.hps.recon.ecal.triggerbank.SSPData; -import org.lcsim.event.CalorimeterHit; -import org.lcsim.event.EventHeader; import org.lcsim.event.GenericObject; -public class DummyDriverRaw extends Driver{ - - private Detector detector; - - - -@Override -public void detectorChanged(Detector detector) { - System.out.println("Ecal event display detector changed"); - this.detector = detector; +public class DummyDriverRaw extends Driver { + @Override + public void detectorChanged(Detector detector) { + System.out.println("Ecal event display detector changed"); + } + @Override + public void process(EventHeader event) { + double orTrigTime,topTrigTime,botTrigTime; + System.out.println("1"); + if(event.hasCollection(GenericObject.class, "TriggerBank")) { + System.out.println("2"); + List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank"); + if (!triggerList.isEmpty()) { + System.out.println("3"); + GenericObject triggerData = triggerList.get(0); + if(triggerData instanceof SSPData){ + // TODO: TOP, BOTTOM, OR, and AND triggers were only + // used by the test run data and are not supported by + // SSP data any longer. + System.out.println("4"); + orTrigTime = 0; //((SSPData)triggerData).getOrTrig(); + topTrigTime = 0; //((SSPData)triggerData).getTopTrig(); + botTrigTime = 0; //((SSPData)triggerData).getBotTrig(); + System.out.println(orTrigTime + " " + topTrigTime + " " + botTrigTime); + } + else if (AbstractIntData.getTag(triggerData)==SSPData.BANK_TAG){ + // TODO: TOP, BOTTOM, OR, and AND triggers were only + // used by the test run data and are not supported by + // SSP data any longer. + //SSPData mData=new SSPData(triggerData); + orTrigTime = 0; //(mData).getOrTrig(); + topTrigTime = 0; //(mData).getTopTrig(); + botTrigTime = 0; //(mData).getBotTrig(); + System.out.println(orTrigTime + " " + topTrigTime + " " + botTrigTime); + } + }//end if triggerList isEmpty + } + } } - - - - -@Override -public void process(EventHeader event){ - - double orTrigTime,topTrigTime,botTrigTime; - System.out.println("1"); - if (event.hasCollection(GenericObject.class, "TriggerBank")) { - System.out.println("2"); - List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank"); - if (!triggerList.isEmpty()) { - System.out.println("3"); - GenericObject triggerData = triggerList.get(0); - if (triggerData instanceof SSPData){ - System.out.println("4"); - orTrigTime=((SSPData)triggerData).getOrTrig(); - topTrigTime=((SSPData)triggerData).getTopTrig(); - botTrigTime =((SSPData)triggerData).getBotTrig(); - System.out.println(orTrigTime+" "+topTrigTime+" "+botTrigTime); - } - else if (AbstractIntData.getTag(triggerData)==SSPData.BANK_TAG){ - SSPData mData=new SSPData(triggerData); - orTrigTime=(mData).getOrTrig(); - topTrigTime=(mData).getTopTrig(); - botTrigTime =(mData).getBotTrig(); - System.out.println(orTrigTime+" "+topTrigTime+" "+botTrigTime); - } - }//end if triggerList isEmpty - -} - -} -} Modified: java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/luca/CalibClusterAnalyzerEngRun.java ============================================================================= --- java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/luca/CalibClusterAnalyzerEngRun.java (original) +++ java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/luca/CalibClusterAnalyzerEngRun.java Fri Jun 12 15:27:10 2015 @@ -205,266 +205,5 @@ return dbid; } - /* - public int getCrystal (Cluster cluster){ - int x,y,id=0; - x= cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix"); - y= cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy"); - if(y==5){ - if(x<0) - {id=x+24;} - else id= x+23; - } - - else if(y==4) - {if(x<0){ - id=x+70;} - else id=x+69;} - - else if(y==3) - {if(x<0){ - id=x+116;} - else id=x+115;} - - else if(y==2) - {if(x<0){ - id=x+162;} - else id=x+161;} - - else if(y==1) - {x=-x; - if(x>0){ - id=-x+208;} - else if(x==-1){id=208;} - else if(x<-1) id=-x+198;} - - else if(y==-1) - {x=-x; - if(x>0){ - id=-x+245;} - else if(x==-1 )id=245; - else if(x<-1){id=-x+235;}} - - - else if(y==-2) - {if(x<0){ - id=x+282;} - else id=x+281;} - - else if(y==-3) - {if(x<0){ - id=x+328;} - else id=x+327;} - - else if(y==-4) - {if(x<0){ - id=x+374;} - else id=x+373;} - - else if(y==-5) - {if(x<0){ - id=x+420;} - else id=x+419;} - - return id; - - } - public int getCrystal (CalorimeterHit hit){ - int x,y,id=0; - x= hit.getIdentifierFieldValue("ix"); - y= hit.getIdentifierFieldValue("iy"); - - if(y==5){ - if(x<0) - {id=x+24;} - else id= x+23; - } - - else if(y==4) - {if(x<0){ - id=x+70;} - else id=x+69;} - - else if(y==3) - {if(x<0){ - id=x+116;} - else id=x+115;} - - else if(y==2) - {if(x<0){ - id=x+162;} - else id=x+161;} - - else if(y==1) - {x=-x; - if(x>0){ - id=-x+208;} - else if(x==-1){id=208;} - else if(x<-1) id=-x+198;} - - else if(y==-1) - {x=-x; - if(x>0){ - id=-x+245;} - else if(x==-1 )id=245; - else if(x<-1){id=-x+235;}} - - - else if(y==-2) - {if(x<0){ - id=x+282;} - else id=x+281;} - - else if(y==-3) - {if(x<0){ - id=x+328;} - else id=x+327;} - - else if(y==-4) - {if(x<0){ - id=x+374;} - else id=x+373;} - - else if(y==-5) - {if(x<0){ - id=x+420;} - else id=x+419;} - - return id; - - } */ - - /* - - public int getCrystalFront (Cluster cluster){ - int x,y,id=0; - x= (-1)*cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix"); - y= cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy"); - - if(y==5){ - if(x<0) - {id=x+24;} - else id= x+23; - } - - else if(y==4) - {if(x<0){ - id=x+70;} - else id=x+69;} - - else if(y==3) - {if(x<0){ - id=x+116;} - else id=x+115;} - - else if(y==2) - {if(x<0){ - id=x+162;} - else id=x+161;} - - else if(y==1) - {x=-x; - if(x>0){ - id=-x+208;} - else if(x==-1){id=208;} - else if(x<-1) id=-x+198;} - - else if(y==-1) - {x=-x; - if(x>0){ - id=-x+245;} - else if(x==-1 )id=245; - else if(x<-1){id=-x+235;}} - - - else if(y==-2) - {if(x<0){ - id=x+282;} - else id=x+281;} - - else if(y==-3) - {if(x<0){ - id=x+328;} - else id=x+327;} - - else if(y==-4) - {if(x<0){ - id=x+374;} - else id=x+373;} - - else if(y==-5) - {if(x<0){ - id=x+420;} - else id=x+419;} - - return id; - - } */ - - /* - public int getCrystalFront (CalorimeterHit hit){ - int x,y,id=0; - x= (-1)*hit.getIdentifierFieldValue("ix"); - y= hit.getIdentifierFieldValue("iy"); - - if(y==5){ - if(x<0) - {id=x+24;} - else id= x+23; - } - - else if(y==4) - {if(x<0){ - id=x+70;} - else id=x+69;} - - else if(y==3) - {if(x<0){ - id=x+116;} - else id=x+115;} - - else if(y==2) - {if(x<0){ - id=x+162;} - else id=x+161;} - - else if(y==1) - {x=-x; - if(x>0){ - id=-x+208;} - else if(x==-1){id=208;} - else if(x<-1) id=-x+198;} - - else if(y==-1) - {x=-x; - if(x>0){ - id=-x+245;} - else if(x==-1 )id=245; - else if(x<-1){id=-x+235;}} - - - else if(y==-2) - {if(x<0){ - id=x+282;} - else id=x+281;} - - else if(y==-3) - {if(x<0){ - id=x+328;} - else id=x+327;} - - else if(y==-4) - {if(x<0){ - id=x+374;} - else id=x+373;} - - else if(y==-5) - {if(x<0){ - id=x+420;} - else id=x+419;} - - return id; - - } */ -} +} Modified: java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/luca/rate.java ============================================================================= --- java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/luca/rate.java (original) +++ java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/luca/rate.java Fri Jun 12 15:27:10 2015 @@ -24,10 +24,13 @@ import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection; import org.hps.conditions.ecal.EcalConditions; +import org.hps.recon.ecal.triggerbank.AbstractIntData; +import org.hps.recon.ecal.triggerbank.TIData; import org.lcsim.event.CalorimeterHit; import org.lcsim.event.Cluster; import org.lcsim.event.EventHeader; +import org.lcsim.event.GenericObject; import org.lcsim.geometry.Detector; import org.lcsim.geometry.Subdetector; import org.lcsim.geometry.subdetector.HPSEcal3; @@ -69,11 +72,18 @@ double nevents=0; double[] time=new double[6]; -double E0=1.92; +double E0=1.1; +/* e=1.92 double[] Ymax={45.91,52.95,60.00,67.01,74.04,81.18}; double[] Ymin={38.83,45.81,52.95,60.00,67.01,74.04}; double[] Xmax={-23.59,-23.1,-22.61,-22.11,-21.62,-21.13}; double[] Xmin={-30.1,-30.59,-31.08,-31.58,-32.07,-32.57}; +*/ +double[] Ymax={45.91,53.95,59.98,67.04,74.05,81.18}; +double[] Ymin={38.84, 45.91,53.95,59.98,67.04,74.05}; +double[] Xmax={-13.25,-12.75,-12.26,-11.77,-11.27,-10.78}; +double[] Xmin={-19.75,-20.24,-20.74,-21.23,-21.72,-22.22}; + int[] countertop=new int[6]; int[] counterbot=new int[6]; @@ -99,7 +109,7 @@ */ //e cuts 3430 - +/* double[] ecuttopmin={1.20,1.35,1.50,1.50,1.60,1.60}; double[] ecuttopmax={1.70,1.80,1.90,2.00,2.00,2.00}; @@ -112,7 +122,7 @@ double[] cryecutbotmax={2,2,1.9,1.9,2}; double[] cryecutbotmin= {1.38,1.38,1.5,1.65,1.55}; - +*/ //e cuts 3434 /* double[] ecuttopmin={1.25,1.30,1.40,1.50,1.60,1.60}; @@ -193,6 +203,68 @@ double[] cryecutbotmin= {1.38,1.38,1.5,1.65,1.55}; */ +//e cuts 4904 +/* +double[] ecuttopmin={0.59,0.6,0.6,0.68,0.7,0.7}; +double[] ecuttopmax={1.70,1.80,1.90,2.00,2.00,2.00}; + +double[] ecutbotmin= {0.59,0.6,0.6,0.68,0.7,0.7}; +double[] ecutbotmax={0.85,0.89,0.9,0.93,0.92,0.95}; + + +double[] cryecuttopmin={1.38,1.38,1.52,1.6,1.6}; +double[] cryecuttopmax={1.8,1.8,1.8,2,2}; + +double[] cryecutbotmax={2,2,1.9,1.9,2}; +double[] cryecutbotmin= {1.38,1.38,1.5,1.65,1.55}; +*/ + +//e cuts 5072 + +double[] ecuttopmin={0.45,0.6,0.6,0.7,0.7,0.75}; +double[] ecuttopmax={0.8,0.9,0.9,0.9,1,1}; + +double[] ecutbotmin= {0.45,0.5,0.6,0.7,0.67,0.65}; +double[] ecutbotmax={0.76,0.8,0.8,0.9,1,1}; + + +double[] cryecuttopmin={1.38,1.38,1.52,1.6,1.6}; +double[] cryecuttopmax={1.8,1.8,1.8,2,2}; + +double[] cryecutbotmax={2,2,1.9,1.9,2}; +double[] cryecutbotmin= {1.38,1.38,1.5,1.65,1.55}; + + +// e cut 5181 +/* +double[] ecuttopmin={0.49,0.6,0.6,0.65,0.69,0.7}; +double[] ecuttopmax={0.8,0.8,0.8,0.9,1,1}; + +double[] ecutbotmin= {0.45,0.55,0.6,0.6,0.65,0.65}; +double[] ecutbotmax={0.75,0.85,0.8,0.9,0.9,0.9}; + + +double[] cryecuttopmin={1.38,1.38,1.52,1.6,1.6}; +double[] cryecuttopmax={1.8,1.8,1.8,2,2}; + +double[] cryecutbotmax={2,2,1.9,1.9,2}; +double[] cryecutbotmin= {1.38,1.38,1.5,1.65,1.55}; +*/ +//e cut 5183 +/* +double[] ecuttopmin={0.55,0.6,0.6,0.65,0.7,0.65}; +double[] ecuttopmax={0.8,0.85,0.9,0.9,0.9,0.9}; + +double[] ecutbotmin= {0.5,0.55,0.6,0.7,0.65,0.7}; +double[] ecutbotmax={0.75,0.8,0.8,0.9,0.9,0.9}; + + +double[] cryecuttopmin={1.38,1.38,1.52,1.6,1.6}; +double[] cryecuttopmax={1.8,1.8,1.8,2,2}; + +double[] cryecutbotmax={2,2,1.9,1.9,2}; +double[] cryecutbotmin= {1.38,1.38,1.5,1.65,1.55}; +*/ double vertical; @@ -207,7 +279,7 @@ @Override public void startOfData(){ - System.out.println("mo spacco tutto \n"); + System.out.println("mo spacco tutto davero!!!\n"); //inizializzo il file di uscita try{ //initialize the writers @@ -311,7 +383,7 @@ int menot=-t; writer.append("events in row " + menot + " = " + crycounterbot[t]+ " Rate = " + (crycounterbot[t]/timme) + "\n" ); } -writer.append("\n verticale = " + vertical +"\n"); +writer.append("\n TEMPO = " + timme +"\n"); } @@ -321,7 +393,7 @@ System.err.println("Non ho scritto sul file"); } -System.out.println("vertical = " + vertical + "\n"); +System.out.println("TEMPO = " + timme + "\n"); /*vertical=vertical-6.5; for(int i=0;i<7;i++) {double theta=Math.atan2( (vertical+i*13),1397); @@ -347,6 +419,32 @@ nevents++; + + /* natha's code for trigger + List <AbstractIntData> aids = event.get(AbstractIntData.class, "TriggerBank"); + for (AbstractIntData aid : aids) { + if (aid.getTag() == TIData.BANK_TAG) { + TIData tt=(TIData)aid; + if (!tt.isSingle1Trigger()) return; + break; + } + } + */ //nathans code for trigger end + + + + if (event.hasCollection(GenericObject.class, "TriggerBank")) { + List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank"); + for (GenericObject data : triggerList) + if (AbstractIntData.getTag(data) == TIData.BANK_TAG) { + TIData triggerData = new TIData(data); + if (!triggerData.isSingle1Trigger())//only process singles0 triggers... + + return; + } + } else //if (debug) + System.out.println(this.getClass().getSimpleName() + ": No trigger bank found...running over all trigger types"); + for(int i=0;i<6;i++){ if(countertop[i]==0){timei[i]=timef;}} @@ -369,6 +467,7 @@ //if(cryy==1){verpos[0]=posY;} //da qui righe e colonne + /* if(cryx==-5||cryx==-6){ for(int i=0;i<5;i++){ @@ -390,7 +489,7 @@ } } } - } + } */ ///da qui bin angolari @@ -400,7 +499,7 @@ if(posY>Ymin[i]&&posY<=Ymax[i]){ if(posX<=Xmax[i] &&posX>=Xmin[i]){ TopNoCut.get(i).fill(cluster.getEnergy()); - if(cluster.getEnergy()>ecuttopmin[i]&&cluster.getEnergy()<ecuttopmax[i]){ + if(cluster.getEnergy() > ecuttopmin[i] && cluster.getEnergy() < ecuttopmax[i]){ Top.get(i).fill(cluster.getEnergy()); countertop[i]++; CryId.fill(ID); @@ -413,7 +512,7 @@ else if(posY<= -Ymin[i]&& posY> -Ymax[i]){ if(posX<Xmax[i] && posX>Xmin[i]){ BotNoCut.get(i).fill(cluster.getEnergy()); - if(cluster.getEnergy()>ecutbotmin[i] && cluster.getEnergy()<ecutbotmax[i]){ + if(cluster.getEnergy()> ecutbotmin[i] && cluster.getEnergy()<ecutbotmax[i]){ Bot.get(i).fill(cluster.getEnergy()); counterbot[i]++; BotCry.get(i).fill(cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix"), cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy")); Modified: java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/luca/ratetest.java ============================================================================= --- java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/luca/ratetest.java (original) +++ java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/luca/ratetest.java Fri Jun 12 15:27:10 2015 @@ -24,10 +24,13 @@ import org.hps.conditions.ecal.EcalChannel.EcalChannelCollection; import org.hps.conditions.ecal.EcalConditions; +import org.hps.recon.ecal.triggerbank.AbstractIntData; +import org.hps.recon.ecal.triggerbank.TIData; import org.lcsim.event.CalorimeterHit; import org.lcsim.event.Cluster; import org.lcsim.event.EventHeader; +import org.lcsim.event.GenericObject; import org.lcsim.geometry.Detector; import org.lcsim.geometry.Subdetector; import org.lcsim.geometry.subdetector.HPSEcal3; @@ -46,105 +49,16 @@ private Subdetector ecal; private EcalChannelCollection channels= null; AIDA aida = AIDA.defaultInstance(); - ArrayList<IHistogram1D> Top = new ArrayList<IHistogram1D>(6); - ArrayList<IHistogram1D> Bot = new ArrayList<IHistogram1D>(6); - ArrayList<IHistogram1D> TopNoCut = new ArrayList<IHistogram1D>(6); - ArrayList<IHistogram1D> BotNoCut = new ArrayList<IHistogram1D>(6); - ArrayList<IHistogram2D> TopCry=new ArrayList<IHistogram2D>(6); - ArrayList<IHistogram2D> BotCry=new ArrayList<IHistogram2D>(6); - ArrayList<IHistogram2D> CryTop=new ArrayList<IHistogram2D>(5); - ArrayList<IHistogram2D> CryBot=new ArrayList<IHistogram2D>(5); - ArrayList<IHistogram1D> TopCryEne = new ArrayList<IHistogram1D>(5); - ArrayList<IHistogram1D> BotCryEne = new ArrayList<IHistogram1D>(5); - IHistogram1D clusTot=aida.histogram1D("ALL", 200,0,2.5 ); - IHistogram1D CryId=aida.histogram1D("cry Id",446,1,447); - double[] timei=new double[6]; - double timef=0; - double counterTop=0; - double counterBot=0; - double counterEcut=0; + IHistogram1D c110=aida.histogram1D("110", 200,0,2.5 ); + IHistogram1D c18=aida.histogram1D("18", 200,0,2.5 ); + IHistogram1D c60=aida.histogram1D("60", 200,0,2.5 ); + IHistogram1D c322=aida.histogram1D("322", 200,0,2.5 ); + IHistogram1D c414=aida.histogram1D("414", 200,0,2.5 ); + IHistogram1D c364=aida.histogram1D("364", 200,0,2.5 ); - double nevents=0; -double[] time=new double[6]; -double E0=1.92; -double[] Ymax={45.91,52.95,60.00,67.01,74.04,81.18}; -double[] Ymin={38.83,45.81,52.95,60.00,67.01,74.04}; -double[] Xmax={-23.59,-23.1,-22.61,-22.11,-21.62,-21.13}; -double[] Xmin={-30.1,-30.59,-31.08,-31.58,-32.07,-32.57}; - -int[] countertop=new int[6]; -int[] counterbot=new int[6]; -int[]crycountertop=new int[5]; -int[]crycounterbot=new int[5]; - -double[] vertpos=new double[5]; - -//e cuts 3393 - -double[] ecuttopmin={1.20,1.35,1.50,1.50,1.60,1.60}; -double[] ecuttopmax={1.70,1.90,1.90,2.00,2.00,2.00}; - -double[] ecutbotmin={1.28,1.50,1.50,1.65,1.65,1.50}; -double[] ecutbotmax={1.90,1.90,2.00,2.00,2.00,2.00}; - - -double[] cryecuttopmin={1.38,1.38,1.52,1.6,1.6}; -double[] cryecuttopmax={1.8,1.8,1.8,2,2}; - -double[] cryecutbotmax={2,2,1.9,1.9,2}; -double[] cryecutbotmin= {1.38,1.38,1.5,1.65,1.55}; - - -//e cuts 3430 -/* -double[] ecuttopmin={1.20,1.35,1.50,1.50,1.60,1.60}; -double[] ecuttopmax={1.70,1.80,1.90,2.00,2.00,2.00}; - -double[] ecutbotmin= {1.20,1.50,1.50,1.55,1.60,1.50}; -double[] ecutbotmax={1.80,1.90,1.90,2.00,2.00,2.00}; - - -double[] cryecuttopmin={1.38,1.38,1.52,1.6,1.6}; -double[] cryecuttopmax={1.8,1.8,1.8,2,2}; - -double[] cryecutbotmax={2,2,1.9,1.9,2}; -double[] cryecutbotmin= {1.38,1.38,1.5,1.65,1.55}; -*/ -//e cuts 3434 -/* -double[] ecuttopmin={1.25,1.30,1.40,1.50,1.60,1.60}; -double[] ecuttopmax={1.65,1.80,1.90,1.90,2.00,2.00}; - -double[] ecutbotmin= {1.30,1.40,1.40,1.60,1.60,1.50}; -double[] ecutbotmax={1.70,1.80,1.90,2,2,2}; - - -double[] cryecuttopmin={1.38,1.38,1.52,1.6,1.6}; -double[] cryecuttopmax={1.8,1.8,1.8,2,2}; - -double[] cryecutbotmax={2,2,1.9,1.9,2}; -double[] cryecutbotmin= {1.38,1.38,1.5,1.65,1.55}; -*/ -//e cuts 3435 -/* -double[] ecuttopmin={1.28,1.30,1.40,1.50,1.50,1.60}; -double[] ecuttopmax={1.7,1.7,1.8,1.8,2,2}; - -double[] ecutbotmin= {1.3,1.35,1.40,1.50,1.60,1.50}; -double[] ecutbotmax={1.7,1.8,1.9,2,2,2}; - - -double[] cryecuttopmin={1.38,1.38,1.52,1.6,1.6}; -double[] cryecuttopmax={1.8,1.8,1.8,2,2}; - -double[] cryecutbotmax={2,2,1.9,1.9,2}; -double[] cryecutbotmin= {1.38,1.38,1.5,1.65,1.55}; -*/ - -double vertical; @@ -158,77 +72,7 @@ @Override public void startOfData(){ - System.out.println("mo spacco tutto \n"); - //inizializzo il file di uscita - try{ - //initialize the writers - writer=new FileWriter(outputFileName); - writer.write(""); - } - catch(IOException e ){ - System.err.println("Error initializing output file for event display."); - } - -//inizializzo istogrammi - for(int t=0;t<5;t++){ - String bin=String.valueOf(t+1); - String crytopname="FEE in Crystal " + bin; - String topcryenename="CLu ene in crystal " + bin; - - String bin2=String.valueOf(-(t+1)); - String crybotname="FEE in Crystal " + bin2; - String botcryenename="CLu ene in crystal " + bin2; - IHistogram2D crytophist=aida.histogram2D(crytopname,46,-24,25,10,-5,5 ); - IHistogram2D crybothist=aida.histogram2D(crybotname,46,-24,25,10,-5,5 ); - IHistogram1D Topcryenehist=aida.histogram1D(topcryenename, 250, 0.0,2.5); - IHistogram1D botcryenehist=aida.histogram1D(botcryenename,250,0.0,2.5); - TopCryEne.add(Topcryenehist); - BotCryEne.add(botcryenehist); - CryTop.add(crytophist); - CryBot.add(crybothist); - crycountertop[t]=0; - crycounterbot[t]=0; - } - - - for(int t=0; t<6; t++){ - String bin=String.valueOf(t+1); - String top="(TOP) FEE in Bin in " + bin; - String bot="(BOT) FEE in Bin in "+ bin; - String tope="(TOP) Cluster Energy in Bin " + bin; - String bote="(BOT) Cluster Energy in Bin "+ bin; - String topcryname="(TOP) Crystals in Bin " + bin; - String botcryname="(BOT) Crystals in Bin " + bin; - - - - IHistogram1D Toppe=aida.histogram1D(top, 250, 0.0,2.5); - IHistogram1D Botte=aida.histogram1D(bot, 250, 0.0,2.5); - IHistogram1D TopNoCute=aida.histogram1D(tope, 250, 0.0,2.5); - IHistogram1D BotNoCute=aida.histogram1D(bote, 250, 0.0,2.5); - IHistogram2D topcryhist=aida.histogram2D(topcryname,46,-24,25,11,-5,6 ); - IHistogram2D botcryhist=aida.histogram2D(botcryname,46,-24,25,11,-5,6 ); - - - Top.add(Toppe); - Bot.add(Botte); - TopNoCut.add(TopNoCute); - BotNoCut.add(BotNoCute); - TopCry.add(topcryhist); - BotCry.add(botcryhist); - } - - - -for (int i =0;i<6;i++){ - time[i]=0; - timei[i]=0; - - countertop[i]=0; - counterbot[i]=0; - -} } @@ -236,144 +80,42 @@ @Override public void endOfData(){ -double timme=(timef-timei[0])/1000000000; - -//for(int i=0;i<6;i++){System.out.println(i + " " + time[i] + "\n");} - -try{ -writer.append("Total event in file " + nevents + " Total time = "+ timme +"\n"); -writer.append("TOP \n"); -for(int i=0;i<6;i++){ - int bin=i+1; - time[i]=timef-timei[i]; -writer.append("Bin " + bin + " Total event " + countertop[i] + " Rate = " + (countertop[i]/time[i])*1000000000 + "\n" ); -} -for(int i=0;i<6;i++){ - int bin=i+1; - time[i]=timef-timei[i]; -writer.append("Bin " + bin +" Total event BOT " + counterbot[i] + " Rate = " + (counterbot[i]/time[i])*1000000000 + "\n" ); -} - -writer.append("\n \n \n"); -for(int t=0;t<5;t++){ -writer.append("events in row " + t + " = " + crycountertop[t]+ " Rate = " + (crycountertop[t]/timme) + "\n" ); -int menot=-t; -writer.append("events in row " + menot + " = " + crycounterbot[t]+ " Rate = " + (crycounterbot[t]/timme) + "\n" ); -} -writer.append("\n verticale = " + vertical +"\n"); - -} - - -catch(IOException e) - { - System.err.println("Non ho scritto sul file"); - } - -System.out.println("vertical = " + vertical + "\n"); -/*vertical=vertical-6.5; -for(int i=0;i<7;i++) -{double theta=Math.atan2( (vertical+i*13),1397); -System.out.println("theta = " + theta + "\n"); -} -*/ - - try - { -//close the file writer. - writer.close(); - } - catch(IOException e) - { - System.err.println("Error closing utput file for event display."); - } + } @Override public void process (EventHeader event){ - timef=event.getTimeStamp(); + if (event.hasCollection(GenericObject.class, "TriggerBank")) { + List<GenericObject> triggerList = event.get(GenericObject.class, "TriggerBank"); + for (GenericObject data : triggerList) + if (AbstractIntData.getTag(data) == TIData.BANK_TAG) { + TIData triggerData = new TIData(data); + if (!triggerData.isSingle1Trigger())//only process singles0 triggers... + + return; + } + } else //if (debug) + System.out.println(this.getClass().getSimpleName() + ": No trigger bank found...running over all trigger types"); - nevents++; - - for(int i=0;i<6;i++){ - if(countertop[i]==0){timei[i]=timef;}} - - if(event.hasCollection(Cluster.class,"EcalClusters")){ + + if(event.hasCollection(Cluster.class,"EcalClusters")){ List<Cluster> clusters= event.get(Cluster.class,"EcalClusters"); for(Cluster cluster : clusters){ - + int id=getDBID(cluster); + if(cluster.getEnergy()>0.65 && cluster.getSize()==1){ + if(id==110){c110.fill(cluster.getEnergy());} - int ID=getDBID(cluster); - clusTot.fill(cluster.getEnergy()); - double posY=cluster.getPosition()[1]; - double posX=cluster.getPosition()[0]; - double cryx=cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix"); - double cryy=cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy"); - - //if(cryy==1){verpos[0]=posY;} - //da qui righe e colonne - if(cryx==-5||cryx==-6){ - - for(int i=0;i<5;i++){ - //top - if(cryy==i+1){ - if(cluster.getEnergy()>cryecuttopmin[i]&&cluster.getEnergy()<cryecuttopmax[i]){ - CryTop.get(i).fill(cryx, cryy); - TopCryEne.get(i).fill(cluster.getEnergy()); - crycountertop[i]++; - } - } - - //bottom - if(cryy==-(i+1)){ - if(cluster.getEnergy()>cryecutbotmin[i] && cluster.getEnergy()<cryecutbotmax[i]){ - CryBot.get(i).fill(cryx, cryy); - BotCryEne.get(i).fill(cluster.getEnergy()); - crycounterbot[i]++; - } - } - } - } - - - ///da qui bin angolari - - for(int i=0;i<6;i++){ - //top - if(posY>Ymin[i]&&posY<=Ymax[i]){ - if(posX<=Xmax[i] &&posX>=Xmin[i]){ - TopNoCut.get(i).fill(cluster.getEnergy()); - if(cluster.getEnergy()>ecuttopmin[i]&&cluster.getEnergy()<ecuttopmax[i]){ - Top.get(i).fill(cluster.getEnergy()); - countertop[i]++; - CryId.fill(ID); - TopCry.get(i).fill(cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix"), cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy")); - }//tagli energia - } //if su X - }//if pos y + } - //controllo down - else if(posY<= -Ymin[i]&& posY> -Ymax[i]){ - if(posX<Xmax[i] && posX>Xmin[i]){ - BotNoCut.get(i).fill(cluster.getEnergy()); - if(cluster.getEnergy()>ecutbotmin[i] && cluster.getEnergy()<ecutbotmax[i]){ - Bot.get(i).fill(cluster.getEnergy()); - counterbot[i]++; - BotCry.get(i).fill(cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix"), cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy")); - CryId.fill(ID); - }//e cut bot - } //xpos - }// ypos bot - }//for sui bin - - }//end of for over clusters - } //and of if has colelction + } + }//end of if has collection + }//end pf process Modified: java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/omoreno/SvtClusterAnalysis.java ============================================================================= --- java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/omoreno/SvtClusterAnalysis.java (original) +++ java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/omoreno/SvtClusterAnalysis.java Fri Jun 12 15:27:10 2015 @@ -15,13 +15,17 @@ import hep.aida.ITree; import hep.aida.ref.rootwriter.RootFileStore; -import org.hps.recon.tracking.FittedRawTrackerHit; import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D; import org.lcsim.util.Driver; +import org.lcsim.fit.helicaltrack.HelicalTrackCross; +import org.lcsim.fit.helicaltrack.HelicalTrackStrip; import org.lcsim.geometry.Detector; import org.lcsim.detector.tracker.silicon.HpsSiSensor; import org.lcsim.event.EventHeader; import org.lcsim.event.RawTrackerHit; +import org.lcsim.event.Track; +import org.lcsim.event.TrackerHit; +import org.hps.recon.tracking.FittedRawTrackerHit; /** * @@ -44,17 +48,21 @@ ITree tree; IHistogramFactory histogramFactory; IPlotterFactory plotterFactory = IAnalysisFactory.create().createPlotterFactory(); + protected Map<String, IPlotter> plotters = new HashMap<String, IPlotter>(); - protected Map<String, IPlotter> plotters = new HashMap<String, IPlotter>(); private Map<HpsSiSensor, IHistogram1D> clusterChargePlots = new HashMap<HpsSiSensor, IHistogram1D>(); + private Map<HpsSiSensor, IHistogram1D> singleHitClusterChargePlots = new HashMap<HpsSiSensor, IHistogram1D>(); + private Map<HpsSiSensor, IHistogram1D> multHitClusterChargePlots = new HashMap<HpsSiSensor, IHistogram1D>(); + private Map<HpsSiSensor, IHistogram1D> trackClusterChargePlots = new HashMap<HpsSiSensor, IHistogram1D>(); private Map<HpsSiSensor, IHistogram1D> signalToNoisePlots = new HashMap<HpsSiSensor, IHistogram1D>(); - private Map<HpsSiSensor, IHistogram1D> singleHitClusterChargePlots = new HashMap<HpsSiSensor, IHistogram1D>(); private Map<HpsSiSensor, IHistogram1D> singleHitSignalToNoisePlots = new HashMap<HpsSiSensor, IHistogram1D>(); - private Map<HpsSiSensor, IHistogram1D> multHitClusterChargePlots = new HashMap<HpsSiSensor, IHistogram1D>(); private Map<HpsSiSensor, IHistogram1D> multHitSignalToNoisePlots = new HashMap<HpsSiSensor, IHistogram1D>(); + private Map<HpsSiSensor, IHistogram1D> trackHitSignalToNoisePlots = new HashMap<HpsSiSensor, IHistogram1D>(); + private Map<HpsSiSensor, IHistogram1D> clusterMultiplicityPlots = new HashMap<HpsSiSensor, IHistogram1D>(); private Map<HpsSiSensor, IHistogram1D> clusterTimePlots = new HashMap<HpsSiSensor, IHistogram1D>(); + private Map<HpsSiSensor, IHistogram1D> trackClusterTimePlots = new HashMap<HpsSiSensor, IHistogram1D>(); private Map<HpsSiSensor, IHistogram2D> clusterChargeVsTimePlots = new HashMap<HpsSiSensor, IHistogram2D>(); - + // Detector name private static final String SUBDETECTOR_NAME = "Tracker"; @@ -63,6 +71,7 @@ private String fittedHitsCollectionName = "SVTFittedRawTrackerHits"; private int runNumber = -1; + /** * Default Ctor @@ -117,6 +126,9 @@ plotters.put("Signal to Noise", plotterFactory.create("Signal to Noise")); plotters.get("Signal to Noise").createRegions(6, 6); + plotters.put("Cluster Multiplicity", plotterFactory.create("Cluster Multiplicity")); + plotters.get("Cluster Multiplicity").createRegions(6, 6); + plotters.put("Cluster Time", plotterFactory.create("Cluster Time")); plotters.get("Cluster Time").createRegions(6, 6); @@ -129,7 +141,7 @@ histogramFactory.createHistogram1D(sensor.getName() + " - Cluster Charge", 100, 0, 5000)); plotters.get("Cluster Amplitude").region(this.computePlotterRegion(sensor)) .plot(clusterChargePlots.get(sensor), this.createStyle(1, "Cluster Amplitude [ADC Counts]", "")); - + singleHitClusterChargePlots.put(sensor, histogramFactory.createHistogram1D(sensor.getName() + " - Single Hit Cluster Charge", 100, 0, 5000)); plotters.get("Cluster Amplitude").region(this.computePlotterRegion(sensor)) @@ -139,6 +151,11 @@ histogramFactory.createHistogram1D(sensor.getName() + " - Multiple Hit Cluster Charge", 100, 0, 5000)); plotters.get("Cluster Amplitude").region(this.computePlotterRegion(sensor)) .plot(multHitClusterChargePlots.get(sensor), this.createStyle(2, "Cluster Amplitude [ADC Counts]", "")); + + trackClusterChargePlots.put(sensor, + histogramFactory.createHistogram1D(sensor.getName() + " - Tracker Cluster Charge", 100, 0, 5000)); + plotters.get("Cluster Amplitude").region(this.computePlotterRegion(sensor)) + .plot(trackClusterChargePlots.get(sensor), this.createStyle(3, "Cluster Amplitude [ADC Counts]", "")); signalToNoisePlots.put(sensor, histogramFactory.createHistogram1D(sensor.getName() + " - Signal to Noise", 50, 0, 50)); @@ -154,18 +171,31 @@ histogramFactory.createHistogram1D(sensor.getName() + " - Multiple Hit Signal to Noise", 50, 0, 50)); plotters.get("Signal to Noise").region(this.computePlotterRegion(sensor)) .plot(multHitSignalToNoisePlots.get(sensor), this.createStyle(2, "Signal to Noise", "")); - + + trackHitSignalToNoisePlots.put(sensor, + histogramFactory.createHistogram1D(sensor.getName() + " - Track Signal to Noise", 50, 0, 50)); + plotters.get("Signal to Noise").region(this.computePlotterRegion(sensor)) + .plot(trackHitSignalToNoisePlots.get(sensor), this.createStyle(3, "Signal to Noise", "")); + + clusterMultiplicityPlots.put(sensor, + histogramFactory.createHistogram1D(sensor.getName() + " - Cluster Multiplicity", 10, 0, 10)); + plotters.get("Cluster Multiplicity").region(this.computePlotterRegion(sensor)) + .plot(clusterMultiplicityPlots.get(sensor), this.createStyle(1, "Cluster Multiplicity", "")); clusterTimePlots.put(sensor, histogramFactory.createHistogram1D(sensor.getName() + " - Cluster Time", 100, -100, 100)); plotters.get("Cluster Time").region(this.computePlotterRegion(sensor)) .plot(clusterTimePlots.get(sensor), this.createStyle(1, "Cluster Time [ns]", "")); + + trackClusterTimePlots.put(sensor, + histogramFactory.createHistogram1D(sensor.getName() + " - Track Cluster Time", 100, -100, 100)); + plotters.get("Cluster Time").region(this.computePlotterRegion(sensor)) + .plot(trackClusterTimePlots.get(sensor), this.createStyle(3, "Cluster Time [ns]", "")); clusterChargeVsTimePlots.put(sensor, histogramFactory.createHistogram2D(sensor.getName() + " - Cluster Amplitude vs Time", 100, 0, 5000, 100, -100, 100)); plotters.get("Cluster Amplitude vs Cluster Time").region(this.computePlotterRegion(sensor)) .plot(clusterChargeVsTimePlots.get(sensor)); - } for (IPlotter plotter : plotters.values()) { @@ -191,9 +221,10 @@ // Get the list of clusters in the event List<SiTrackerHitStrip1D> clusters = event.get(SiTrackerHitStrip1D.class, clusterCollectionName); + System.out.println("Number of clusters: " + clusters.size()); for (SiTrackerHitStrip1D cluster : clusters) { - + // Get the sensor associated with this cluster HpsSiSensor sensor = (HpsSiSensor) cluster.getSensor(); @@ -217,7 +248,9 @@ noise += channelNoise * this.getFittedHit(rawHit).getAmp(); } - + + clusterMultiplicityPlots.get(sensor).fill(cluster.getRawHits().size()); + // Calculate the signal weighted noise noise = noise/amplitude; @@ -233,6 +266,52 @@ } else { multHitClusterChargePlots.get(sensor).fill(amplitude); multHitSignalToNoisePlots.get(sensor).fill(amplitude/noise); + } + } + + if (!event.hasCollection(Track.class, "MatchedTracks")) return; + + List<Track> tracks = event.get(Track.class, "MatchedTracks"); + + for (Track track : tracks) { + + for (TrackerHit stereoHit : track.getTrackerHits()) { + + for (HelicalTrackStrip cluster : ((HelicalTrackCross) stereoHit).getStrips()) { + + // Get the raw hits composing this cluster and use them to calculate the amplitude of the hit + double amplitude = 0; + double noise = 0; + HpsSiSensor sensor = null; + for (Object hit : cluster.rawhits()) { + RawTrackerHit rawHit = (RawTrackerHit) hit; + + sensor = (HpsSiSensor) rawHit.getDetectorElement(); + + // Get the channel of the raw hit + int channel = rawHit.getIdentifierFieldValue("strip"); + + // Add the amplitude of that channel to the total amplitude + amplitude += this.getFittedHit(rawHit).getAmp(); + + // Calculate the mean noise for the channel + double channelNoise = 0; + for (int sampleN = 0; sampleN < 6; sampleN++) { + channelNoise += sensor.getNoise(channel, sampleN); + } + channelNoise = channelNoise/6; + + noise += channelNoise * this.getFittedHit(rawHit).getAmp(); + } + + // Calculate the signal weighted noise + noise = noise/amplitude; + + // Fill all plots + trackClusterChargePlots.get(sensor).fill(amplitude); + trackHitSignalToNoisePlots.get(sensor).fill(amplitude/noise); + trackClusterTimePlots.get(sensor).fill(cluster.time()); + } } } } @@ -307,6 +386,10 @@ style.dataStyle().fillStyle().setColor("93, 228, 47, 1"); style.dataStyle().outlineStyle().setColor("93, 228, 47, 1"); style.dataStyle().fillStyle().setOpacity(.70); + } else if (color == 3) { + style.dataStyle().fillStyle().setColor("255, 38, 38, 1"); + style.dataStyle().outlineStyle().setColor("255, 38, 38, 1"); + style.dataStyle().fillStyle().setOpacity(.70); } style.dataStyle().errorBarStyle().setVisible(false); Modified: java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/omoreno/SvtHitEfficiency.java ============================================================================= --- java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/omoreno/SvtHitEfficiency.java (original) +++ java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/omoreno/SvtHitEfficiency.java Fri Jun 12 15:27:10 2015 @@ -1,23 +1,24 @@ package org.hps.users.omoreno; - - -import hep.aida.ICloud2D; -import hep.aida.IHistogram1D; -import hep.aida.IHistogram2D; -import hep.aida.IPlotter; -import hep.aida.IPlotterStyle; -import hep.physics.vec.BasicHep3Vector; -import hep.physics.vec.Hep3Vector; -import hep.physics.vec.VecOp; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.hps.recon.tracking.TrackUtils; -import org.hps.recon.tracking.TrackerHitUtils; +import hep.aida.IAnalysisFactory; +import hep.aida.IHistogramFactory; +import hep.aida.IPlotterFactory; +import hep.aida.IPlotter; +import hep.aida.IHistogram1D; +import hep.aida.ITree; + +import hep.physics.vec.BasicHep3Vector; +import hep.physics.vec.Hep3Vector; +import hep.physics.vec.VecOp; + import org.lcsim.detector.ITransform3D; +import org.lcsim.detector.converter.compact.subdetector.SvtStereoLayer; +import org.lcsim.detector.converter.compact.subdetector.HpsTracker2; import org.lcsim.detector.solids.Box; import org.lcsim.detector.solids.Point3D; import org.lcsim.detector.solids.Polygon3D; @@ -31,7 +32,10 @@ import org.lcsim.fit.helicaltrack.HelicalTrackHit; import org.lcsim.geometry.Detector; import org.lcsim.util.Driver; -import org.lcsim.util.aida.AIDA; + +import org.hps.recon.tracking.TrackUtils; +import org.hps.recon.tracking.TrackerHitUtils; + /** * Analysis driver used to calculate the hit efficiency of the SVT. @@ -41,12 +45,25 @@ */ public class SvtHitEfficiency extends Driver { - private AIDA aida; - private List<IHistogram1D> histos1D = new ArrayList<IHistogram1D>(); - private List<IHistogram2D> histos2D = new ArrayList<IHistogram2D>(); - private List<IPlotter> plotters = new ArrayList<IPlotter>(); - private Map<SiSensor, Map<Integer, Hep3Vector>> stripPositions = new HashMap<SiSensor, Map<Integer, Hep3Vector>>(); + + // Use JFreeChart as the default plotting backend + static { + hep.aida.jfree.AnalysisFactory.register(); + } + + // Plotting + ITree tree; + IHistogramFactory histogramFactory; + IPlotterFactory plotterFactory = IAnalysisFactory.create().createPlotterFactory(); + protected Map<String, IPlotter> plotters = new HashMap<String, IPlotter>(); + + private Map<String, IHistogram1D> trackMomentumPlots = new HashMap<String, IHistogram1D>(); + + //private Map<SiSensor, Map<Integer, Hep3Vector>> stripPositions = new HashMap<SiSensor, Map<Integer, Hep3Vector>>(); private List<HpsSiSensor> sensors = null; + private Map<Integer, SvtStereoLayer> topStereoLayers = new HashMap<Integer, SvtStereoLayer>(); + private Map<Integer, SvtStereoLayer> bottomStereoLayers = new HashMap<Integer, SvtStereoLayer>(); + TrackerHitUtils trackerHitUtils = new TrackerHitUtils(); boolean debug = false; @@ -57,8 +74,6 @@ boolean enableChiSquaredPlots = true; boolean enableTrackPositionPlots = true; boolean maskBadChannels = false; - - int plotterIndex = 0; double numberOfTopTracks = 0; double numberOfBottomTracks = 0; @@ -83,10 +98,22 @@ public static final double SENSOR_WIDTH = 38.3399; // mm private static final String SUBDETECTOR_NAME = "Tracker"; - /** - * Default Ctor + // By default, require that all tracks have 5 hits + int hitsOnTrack = 5; + + /** + * Default Constructor */ public SvtHitEfficiency(){ + } + + /** + * Set the number of stereo hits associated with a track fit. + * + * @param hitsOnTrack : Number of stereo hits associated with a track fit. + */ + public void setHitsOnTrack(int hitsOnTrack) { + this.hitsOnTrack = hitsOnTrack; } /** @@ -100,25 +127,60 @@ * Enable/Disable masking of bad channels */ public void setMaskBadChannels(boolean maskBadChannels){ - this.maskBadChannels = maskBadChannels; + this.maskBadChannels = maskBadChannels; } public void detectorChanged(Detector detector){ - - // Get the list of sensors - sensors = detector.getSubdetector(SUBDETECTOR_NAME).getDetectorElement().findDescendants(HpsSiSensor.class); - - // setup AIDA - aida = AIDA.defaultInstance(); - aida.tree().cd("/"); - + + tree = IAnalysisFactory.create().createTreeFactory().create(); + histogramFactory = IAnalysisFactory.create().createHistogramFactory(tree); + + // Get the HpsSiSensor objects from the tracker detector element + sensors = detector.getSubdetector(SUBDETECTOR_NAME) + .getDetectorElement().findDescendants(HpsSiSensor.class); + + // If the detector element had no sensors associated with it, throw + // an exception + if (sensors.size() == 0) { + throw new RuntimeException("No sensors were found in this detector."); + } + + // Get the stereo layers from the geometry and build the stereo + // layer maps + List<SvtStereoLayer> stereoLayers + = ((HpsTracker2) detector.getSubdetector(SUBDETECTOR_NAME).getDetectorElement()).getStereoPairs(); + for (SvtStereoLayer stereoLayer : stereoLayers) { + if (stereoLayer.getAxialSensor().isTopLayer()) { + topStereoLayers.put(stereoLayer.getLayerNumber(), stereoLayer); + } else { + bottomStereoLayers.put(stereoLayer.getLayerNumber(), stereoLayer); + } + } + + /* String title = null; IHistogram2D histo2D = null; IHistogram1D histo1D = null; ICloud2D cloud2D = null; + */ + + if (enableMomentumPlots) { + + plotters.put("Track Momentum", plotterFactory.create("Track Momentum")); + plotters.get("Track Momentum").createRegions(1, 2); + + trackMomentumPlots.put("Track Momentum", histogramFactory.createHistogram1D("Track Momentum", 50, 0, 5)); + plotters.get("Track Momentum").region(0).plot(trackMomentumPlots.get("Track Momentum")); + + trackMomentumPlots.put("Track Momentum - Tracks Within Acceptance", + histogramFactory.createHistogram1D("Track Momentum - Tracks Within Acceptance", 50, 0, 5)); + plotters.get("Track Momentum").region(0) + .plot(trackMomentumPlots.get("Track Momentum - Tracks Within Acceptance")); + } // Create a Map from sensor to bad channels and from bad channels to // strip position + /* for(ChargeCarrier carrier : ChargeCarrier.values()){ for(SiSensor sensor : sensors){ if(sensor.hasElectrodesOnSide(carrier)){ @@ -137,49 +199,34 @@ } } } - } - - //--- Momentum Plots ---// - //----------------------// - if(enableMomentumPlots){ - plotters.add(PlotUtils.setupPlotter("Track Momentum", 0, 0)); - title = "Track Momentum - All Tracks"; - histo1D = aida.histogram1D(title, 50, 0, 5); - PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 0, "Momentum [GeV]", histo1D); - title = "Track Momentum - Tracks Within Acceptance"; - histo1D = aida.histogram1D(title, 50, 0, 5); - plotters.get(plotterIndex).region(0).plot(histo1D); - title = "Track Momentum - Tracks With All Layers Hit"; - histo1D = aida.histogram1D(title, 50, 0, 5); - plotters.get(plotterIndex).region(0).plot(histo1D); - plotterIndex++; - } + }*/ + //--- Track Fit Chi Squared ---// //-----------------------------// - if(enableChiSquaredPlots){ - plotters.add(PlotUtils.setupPlotter("Track Chi Squared", 0, 0)); - title = "Chi Squared - All Tracks"; - histo1D = aida.histogram1D(title, 50, 0, 50); - PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 0, "Chi Squared", histo1D); - title = "Chi Squared - Tracks Within Acceptance"; - histo1D = aida.histogram1D(title, 50, 0, 50); - plotters.get(plotterIndex).region(0).plot(histo1D); - title = "Chi Squared - Tracks With All Layers Hit"; - histo1D = aida.histogram1D(title, 50, 0, 50); - plotters.get(plotterIndex).region(0).plot(histo1D); + /*if(enableChiSquaredPlots){ + plotters.add(PlotUtils.setupPlotter("Track Chi Squared", 0, 0)); + title = "Chi Squared - All Tracks"; + histo1D = aida.histogram1D(title, 50, 0, 50); + PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 0, "Chi Squared", histo1D); + title = "Chi Squared - Tracks Within Acceptance"; + histo1D = aida.histogram1D(title, 50, 0, 50); + plotters.get(plotterIndex).region(0).plot(histo1D); + title = "Chi Squared - Tracks With All Layers Hit"; + histo1D = aida.histogram1D(title, 50, 0, 50); + plotters.get(plotterIndex).region(0).plot(histo1D); plotterIndex++; - } + }*/ //--- Track Position Plots ---// //----------------------------// - if(enableTrackPositionPlots){ - int layerNumber = 1; - SiSensor sensor = null; - IPlotterStyle style = aida.analysisFactory().createPlotterFactory().createPlotterStyle(); + /*if(enableTrackPositionPlots){ + int layerNumber = 1; + SiSensor sensor = null; + IPlotterStyle style = aida.analysisFactory().createPlotterFactory().createPlotterStyle(); for(int index = 1; index < 6; index++){ plotters.add(PlotUtils.setupPlotter("Track Position - Layer " + index, 2, 3)); - title = "Track Position - Layer " + index + " - Tracks Within Acceptance"; + title = "Track Position - Layer " + index + " - Tracks Within Acceptance"; cloud2D = aida.cloud2D(title); PlotUtils.setup2DRegion(plotters.get(plotterIndex), title, 0, "x [mm]", "y [mm]", cloud2D, style); title = "Track Position - Layer " + index + " - Tracks With All Layers Hit"; @@ -191,6 +238,7 @@ //sensor = SvtUtils.getInstance().getBottomSensor(layerNumber, 0); //title = SvtUtils.getInstance().getDescription(sensor) + " - Occupancy"; histo1D = aida.histogram1D(title, 640, 0, 639); + histos1D.add(histo1D); PlotUtils.setup1DRegion(plotters.get(plotterIndex), title, 2, "Channel #", histo1D); //sensor = SvtUtils.getInstance().getTopSensor(layerNumber, 0); @@ -212,9 +260,9 @@ layerNumber++; plotterIndex++; } - } - - for (IPlotter plotter : plotters) { + }*/ + + for (IPlotter plotter : plotters.values()) { plotter.show(); } } @@ -222,9 +270,9 @@ /** * . */ - private Hep3Vector getStripPosition(SiSensor sensor, int physicalChannel){ + /* private Hep3Vector getStripPosition(SiSensor sensor, int physicalChannel){ return stripPositions.get(sensor).get(physicalChannel); - } + }*/ /** * Print a debug message if they are enabled. @@ -251,140 +299,153 @@ //List<Cluster> ecalClusters = event.get(Cluster.class, ecalClustersCollectionName); for(Track track : tracks){ - - ecalClusterTrackMatch = false; - + + // Check that the track has the required number of hits. The number of hits + // required to make a track is set in the tracking strategy. + if(track.getTrackerHits().size() != this.hitsOnTrack){ + System.out.println("This track doesn't have the required number of hits."); + continue; + } + + // Calculate the momentum of the track + double momentum = (new BasicHep3Vector(track.getTrackStates().get(0).getMomentum())).magnitude(); + + if (enableMomentumPlots) { + trackMomentumPlots.get("Track Momentum").fill(momentum); + } + + // Find which of the layers isn't being used in the track fit + int unusedLayer = this.getUnusedSvtLayer(track.getTrackerHits()); + + // Extrapolate the track to the unused layer and check that it lies + // within the acceptance of that layer. If it doesn't, move on + // to the next event + if(!isWithinAcceptance(track, unusedLayer)) continue; + + if (enableMomentumPlots) { + trackMomentumPlots.get("Track Momentum - Tracks Within Acceptance").fill(momentum); + } + //ecalClusterTrackMatch = false; + // Check if there is an Ecal cluster in the same detector volume as the track - /*for(Cluster ecalCluster : ecalClusters){ - if(ecalCluster.getPosition()[1] > 0 && trkUtil.getZ0() > 0){ - ecalClusterTrackMatch = true; - break; - } - else if(ecalCluster.getPosition()[1] < 0 && trkUtil.getZ0() < 0){ - ecalClusterTrackMatch = true; - break; - } - }*/ - - /* - if(!ecalClusterTrackMatch){ - if(debug) System.out.println(this.getClass().getSimpleName() + ": No matching Ecal cluster found"); - continue; - }*/ - - // Check that the track is associated with four hits only. This should - // be the case since the strategy is only requiring four hits to fit - // a track and is not requiring an extending layer - if(track.getTrackerHits().size() != 4){ - System.out.println(this.getClass().getSimpleName() + ": This track is composed of " + track.getTrackerHits().size() + ". Skipping event..." ); + /*for(Cluster ecalCluster : ecalClusters){ + if(ecalCluster.getPosition()[1] > 0 && trkUtil.getZ0() > 0){ + ecalClusterTrackMatch = true; + break; + } + else if(ecalCluster.getPosition()[1] < 0 && trkUtil.getZ0() < 0){ + ecalClusterTrackMatch = true; + break; + } + }*/ + + /* + if(!ecalClusterTrackMatch){ + if(debug) System.out.println(this.getClass().getSimpleName() + ": No matching Ecal cluster found"); continue; - } - - // Apply a momentum cut? Probably ... - // Calculate the track momentum - double momentum = Math.sqrt(track.getTrackStates().get(0).getMomentum()[0]*track.getTrackStates().get(0).getMomentum()[0] + track.getTrackStates().get(0).getMomentum()[1]*track.getTrackStates().get(0).getMomentum()[1] + track.getTrackStates().get(0).getMomentum()[2]*track.getTrackStates().get(0).getMomentum()[2]); - if(momentum < 0.5 /* GeV */) continue; - if(enableMomentumPlots) - aida.histogram1D("Track Momentum - All Tracks").fill(momentum); - - if(enableChiSquaredPlots) - aida.histogram1D("Chi Squared - All Tracks").fill(track.getChi2()); - - // Find which layer is not being used to fit the track - int layer = this.findMissingFitLayer(track.getTrackerHits()); - int arrayPosition = (layer - 1)/2; - - // Find if the track is within the acceptance of the layer not being used in - // the fit - if(!isWithinAcceptance(track, layer)) continue; - if(TrackUtils.getZ0(track) > 0){ - numberOfTopTracks++; - topTracksPerMissingLayer[arrayPosition]++; - } else { - numberOfBottomTracks++; - bottomTracksPerMissingLayer[arrayPosition]++; - } - - if(enableMomentumPlots) - aida.histogram1D("Track Momentum - Tracks Within Acceptance").fill(momentum); - if(enableChiSquaredPlots) - aida.histogram1D("Chi Squared - Tracks Within Acceptance").fill(track.getChi2()); - + }*/ + + + //int arrayPosition = (layer - 1)/2; + + //if(TrackUtils.getZ0(track) > 0){ + //numberOfTopTracks++; + //topTracksPerMissingLayer[arrayPosition]++; + //} else { + //numberOfBottomTracks++; + //bottomTracksPerMissingLayer[arrayPosition]++; + //} + + //if(enableChiSquaredPlots) + // aida.histogram1D("Chi Squared - Tracks Within Acceptance").fill(track.getChi2()); + // Find if there is a stereo hit within that layer - List<HelicalTrackHit> stereoHits = event.get(HelicalTrackHit.class, stereoHitCollectionName); + /*List<HelicalTrackHit> stereoHits = event.get(HelicalTrackHit.class, stereoHitCollectionName); for(HelicalTrackHit stereoHit : stereoHits){ - if(layer == stereoHit.Layer()){ - if(debug) System.out.println(this.getClass().getSimpleName() + ": Track has five layers hit"); - if(TrackUtils.getZ0(track) > 0){ - numberOfTopTracksWithHitOnMissingLayer++; - topTracksWithHitOnMissingLayer[arrayPosition]++; - } else { - numberOfBottomTracksWithHitOnMissingLayer++; - bottomTracksWithHitOnMissingLayer[arrayPosition]++; - } - if(enableMomentumPlots) - aida.histogram1D("Track Momentum - Tracks With All Layers Hit").fill(momentum); - if(enableChiSquaredPlots) - aida.histogram1D("Chi Squared - Tracks With All Layers Hit").fill(track.getChi2()); - - return; - } - } - - int layerNumber = (layer - 1)/2 + 1; - if(enableTrackPositionPlots){ - String title = "Track Position - Layer " + layerNumber + " - Difference"; - //aida.histogram2D(title).fill(trackPos.y(), trackPos.z()); + if(layer == stereoHit.Layer()){ + if(debug) System.out.println(this.getClass().getSimpleName() + ": Track has five layers hit"); + if(TrackUtils.getZ0(track) > 0){ + numberOfTopTracksWithHitOnMissingLayer++; + topTracksWithHitOnMissingLayer[arrayPosition]++; + } else { + numberOfBottomTracksWithHitOnMissingLayer++; + bottomTracksWithHitOnMissingLayer[arrayPosition]++; + } + if(enableMomentumPlots) + aida.histogram1D("Track Momentum - Tracks With All Layers Hit").fill(momentum); + if(enableChiSquaredPlots) + aida.histogram1D("Chi Squared - Tracks With All Layers Hit").fill(track.getChi2()); + + return; + } + }*/ + + /*int layerNumber = (layer - 1)/2 + 1; + if(enableTrackPositionPlots){ + String title = "Track Position - Layer " + layerNumber + " - Difference"; + //aida.histogram2D(title).fill(trackPos.y(), trackPos.z()); aida.cloud2D(title).fill(frontTrackPos.y(), frontTrackPos.z()); title = "Track Position - Layer " + layerNumber + " - Tracks With All Layers Hit"; //aida.histogram2D(title).fill(trackPos.y(), trackPos.z()); aida.cloud2D(title).fill(frontTrackPos.y(), frontTrackPos.z()); } - - List<SiSensor> sensors = new ArrayList<SiSensor>(); - if(TrackUtils.getZ0(track) > 0){ - //sensors.add(SvtUtils.getInstance().getTopSensor(layer, 0)); - //sensors.add(SvtUtils.getInstance().getTopSensor(layer+1, 0)); - } else { - //sensors.add(SvtUtils.getInstance().getBottomSensor(layer, 0)); - //sensors.add(SvtUtils.getInstance().getBottomSensor(layer+1, 0)); - } - //aida.histogram1D(SvtUtils.getInstance().getDescription(sensors.get(0)) + " - Occupancy").fill(this.findIntersectingChannel(frontTrackPos, sensors.get(0))); + + List<SiSensor> sensors = new ArrayList<SiSensor>(); + if(TrackUtils.getZ0(track) > 0){ + //sensors.add(SvtUtils.getInstance().getTopSensor(layer, 0)); + //sensors.add(SvtUtils.getInstance().getTopSensor(layer+1, 0)); + } else { + //sensors.add(SvtUtils.getInstance().getBottomSensor(layer, 0)); + //sensors.add(SvtUtils.getInstance().getBottomSensor(layer+1, 0)); + } + //aida.histogram1D(SvtUtils.getInstance().getDescription(sensors.get(0)) + " - Occupancy").fill(this.findIntersectingChannel(frontTrackPos, sensors.get(0))); //aida.histogram1D(SvtUtils.getInstance().getDescription(sensors.get(1)) + " - Occupancy").fill(this.findIntersectingChannel(rearTrackPos, sensors.get(1))); - + if(debug) - System.out.println(this.getClass().getSimpleName() + ": Stereo hit was not found."); - } - } - - private int findMissingFitLayer(List<TrackerHit> trkHits){ - int[] layer = new int[5]; - for(TrackerHit trkHit : trkHits){ - HelicalTrackHit stereoHit = (HelicalTrackHit) trkHit; - int arrayPosition = (stereoHit.Layer() - 1)/2; - layer[arrayPosition]++; - } - - for(int index = 0; index < layer.length; index++){ - if(layer[index] == 0) return (2*index + 1); + System.out.println(this.getClass().getSimpleName() + ": Stereo hit was not found.");*/ + } + } + + /** + * Find which of the layers is not being used in the track fit + * + * @param hits : List of stereo hits associated with a track + * @return Layer not used in the track fit + */ + private int getUnusedSvtLayer(List<TrackerHit> hits) { + + int[] svtLayer = new int[6]; + for (TrackerHit hit : hits) { + HelicalTrackHit stereoHit = (HelicalTrackHit) hit; + int layer = (stereoHit.Layer() - 1)/2; + svtLayer[layer]++; + } + + for(int layer = 0; layer < svtLayer.length; layer++){ + if(svtLayer[layer] == 0) return (2*layer + 1); } return -1; } - - private boolean isWithinAcceptance(Track track, int layer){ - - - + + /** + * Check if a track lies within the acceptance of a layer. + * + */ + // TODO: Move this to a utility class + private boolean isWithinAcceptance(Track track, int layer) { + + + List<HpsSiSensor> sensors = new ArrayList<HpsSiSensor>(); - if(TrackUtils.getZ0(track) > 0){ + /*if(TrackUtils.getZ0(track) > 0){ //sensors.add(SvtUtils.getInstance().getTopSensor(layer, 0)); //sensors.add(SvtUtils.getInstance().getTopSensor(layer + 1, 0)); } else { //sensors.add(SvtUtils.getInstance().getBottomSensor(layer, 0)); //sensors.add(SvtUtils.getInstance().getBottomSensor(layer + 1, 0)); - } + }*/ Hep3Vector frontSensorPos = sensors.get(0).getGeometry().getPosition(); Hep3Vector rearSensorPos = sensors.get(1).getGeometry().getPosition(); @@ -393,14 +454,14 @@ this.rearTrackPos = TrackUtils.extrapolateTrack(track,rearSensorPos.z()); if(this.sensorContainsTrack(frontTrackPos, sensors.get(0)) && this.sensorContainsTrack(rearTrackPos, sensors.get(1))){ -// if(this.sensorContainsTrack(trackPos, sensor)) - if(enableTrackPositionPlots){ - int layerNumber = (layer - 1)/2 + 1; - String title = "Track Position - Layer " + layerNumber + " - Tracks Within Acceptance"; - //aida.histogram2D(title).fill(trackPos.y(), trackPos.z()); - aida.cloud2D(title).fill(frontTrackPos.y(), frontTrackPos.z()); - } - return true; +// if(this.sensorContainsTrack(trackPos, sensor)) + if(enableTrackPositionPlots){ + int layerNumber = (layer - 1)/2 + 1; + String title = "Track Position - Layer " + layerNumber + " - Tracks Within Acceptance"; + //aida.histogram2D(title).fill(trackPos.y(), trackPos.z()); + //aida.cloud2D(title).fill(frontTrackPos.y(), frontTrackPos.z()); + } + return true; } @@ -411,35 +472,35 @@ * */ public int findIntersectingChannel(Hep3Vector trackPosition, SiSensor sensor){ - - //--- Check that the track doesn't pass through a region of bad channels ---// - //--------------------------------------------------------------------------// - - //Rotate the track position to the JLab coordinate system - this.printDebug("Track position in tracking frame: " + trackPosition.toString()); - Hep3Vector trackPositionDet = VecOp.mult(VecOp.inverse(this.trackerHitUtils.detToTrackRotationMatrix()), trackPosition); - this.printDebug("Track position in JLab frame " + trackPositionDet.toString()); - // Rotate the track to the sensor coordinates - ITransform3D globalToLocal = sensor.getReadoutElectrodes(ChargeCarrier.HOLE).getGlobalToLocal(); - globalToLocal.transform(trackPositionDet); - this.printDebug("Track position in sensor electrodes frame " + trackPositionDet.toString()); - - // Find the closest channel to the track position - double deltaY = Double.MAX_VALUE; - int intersectingChannel = 0; - for(int physicalChannel= 0; physicalChannel < 639; physicalChannel++){ - /*this.printDebug(SvtUtils.getInstance().getDescription(sensor) + " : Channel " + physicalChannel - + " : Strip Position " + stripPositions.get(sensor).get(physicalChannel)); - this.printDebug(SvtUtils.getInstance().getDescription(sensor) + ": Channel " + physicalChannel - + " : Delta Y: " + Math.abs(trackPositionDet.x() - stripPositions.get(sensor).get(physicalChannel).x()));*/ - if(Math.abs(trackPositionDet.x() - stripPositions.get(sensor).get(physicalChannel).x()) < deltaY ){ - deltaY = Math.abs(trackPositionDet.x() - stripPositions.get(sensor).get(physicalChannel).x()); - intersectingChannel = physicalChannel; - } - } - - - return intersectingChannel; + + //--- Check that the track doesn't pass through a region of bad channels ---// + //--------------------------------------------------------------------------// + + //Rotate the track position to the JLab coordinate system + this.printDebug("Track position in tracking frame: " + trackPosition.toString()); + Hep3Vector trackPositionDet = VecOp.mult(VecOp.inverse(this.trackerHitUtils.detToTrackRotationMatrix()), trackPosition); + this.printDebug("Track position in JLab frame " + trackPositionDet.toString()); + // Rotate the track to the sensor coordinates + ITransform3D globalToLocal = sensor.getReadoutElectrodes(ChargeCarrier.HOLE).getGlobalToLocal(); + globalToLocal.transform(trackPositionDet); + this.printDebug("Track position in sensor electrodes frame " + trackPositionDet.toString()); + + // Find the closest channel to the track position + double deltaY = Double.MAX_VALUE; + int intersectingChannel = 0; + for(int physicalChannel= 0; physicalChannel < 639; physicalChannel++){ + /*this.printDebug(SvtUtils.getInstance().getDescription(sensor) + " : Channel " + physicalChannel + + " : Strip Position " + stripPositions.get(sensor).get(physicalChannel)); + this.printDebug(SvtUtils.getInstance().getDescription(sensor) + ": Channel " + physicalChannel + + " : Delta Y: " + Math.abs(trackPositionDet.x() - stripPositions.get(sensor).get(physicalChannel).x()));*/ + /*if(Math.abs(trackPositionDet.x() - stripPositions.get(sensor).get(physicalChannel).x()) < deltaY ){ + deltaY = Math.abs(trackPositionDet.x() - stripPositions.get(sensor).get(physicalChannel).x()); + intersectingChannel = physicalChannel; + }*/ + } + + + return intersectingChannel; } /** @@ -447,64 +508,64 @@ */ public boolean sensorContainsTrack(Hep3Vector trackPosition, HpsSiSensor sensor){ - - if(maskBadChannels){ - int intersectingChannel = this.findIntersectingChannel(trackPosition, sensor); - if(intersectingChannel == 0 || intersectingChannel == 638) return false; - - if(sensor.isBadChannel(intersectingChannel) - || sensor.isBadChannel(intersectingChannel+1) - || sensor.isBadChannel(intersectingChannel-1)){ - this.printDebug("Track intersects a bad channel!"); - return false; - } - } + + if(maskBadChannels){ + int intersectingChannel = this.findIntersectingChannel(trackPosition, sensor); + if(intersectingChannel == 0 || intersectingChannel == 638) return false; + + if(sensor.isBadChannel(intersectingChannel) + || sensor.isBadChannel(intersectingChannel+1) + || sensor.isBadChannel(intersectingChannel-1)){ + this.printDebug("Track intersects a bad channel!"); + return false; + } + } ITransform3D localToGlobal = sensor.getGeometry().getLocalToGlobal(); - + Hep3Vector sensorPos = sensor.getGeometry().getPosition(); Box sensorSolid = (Box) sensor.getGeometry().getLogicalVolume().getSolid(); Polygon3D sensorFace = sensorSolid.getFacesNormalTo(new BasicHep3Vector(0, 0, 1)).get(0); List<Point3D> vertices = new ArrayList<Point3D>(); for(int index = 0; index < 4; index++){ - vertices.add(new Point3D()); + vertices.add(new Point3D()); } for(Point3D vertex : sensorFace.getVertices()){ if(vertex.y() < 0 && vertex.x() > 0){ - localToGlobal.transform(vertex); + localToGlobal.transform(vertex); //vertices.set(0, new Point3D(vertex.y() + sensorPos.x(), vertex.x() + sensorPos.y(), vertex.z() + sensorPos.z())); - vertices.set(0, new Point3D(vertex.x(), vertex.y(), vertex.z())); + vertices.set(0, new Point3D(vertex.x(), vertex.y(), vertex.z())); if(debug){ - System.out.println(this.getClass().getSimpleName() + ": Vertex 1 Position: " + vertices.get(0).toString()); - //System.out.println(this.getClass().getSimpleName() + ": Transformed Vertex 1 Position: " + localToGlobal.transformed(vertex).toString()); + System.out.println(this.getClass().getSimpleName() + ": Vertex 1 Position: " + vertices.get(0).toString()); + //System.out.println(this.getClass().getSimpleName() + ": Transformed Vertex 1 Position: " + localToGlobal.transformed(vertex).toString()); } } else if(vertex.y() > 0 && vertex.x() > 0){ - localToGlobal.transform(vertex); + localToGlobal.transform(vertex); //vertices.set(1, new Point3D(vertex.y() + sensorPos.x(), vertex.x() + sensorPos.y(), vertex.z() + sensorPos.z())); vertices.set(1, new Point3D(vertex.x(), vertex.y(), vertex.z())); if(debug){ System.out.println(this.getClass().getSimpleName() + ": Vertex 2 Position: " + vertices.get(1).toString()); - //System.out.println(this.getClass().getSimpleName() + ": Transformed Vertex 2 Position: " + localToGlobal.transformed(vertex).toString()); + //System.out.println(this.getClass().getSimpleName() + ": Transformed Vertex 2 Position: " + localToGlobal.transformed(vertex).toString()); } } else if(vertex.y() > 0 && vertex.x() < 0){ - localToGlobal.transform(vertex); + localToGlobal.transform(vertex); //vertices.set(2, new Point3D(vertex.y() + sensorPos.x(), vertex.x() + sensorPos.y(), vertex.z() + sensorPos.z())); vertices.set(2, new Point3D(vertex.x(), vertex.y(), vertex.z())); if(debug){ System.out.println(this.getClass().getSimpleName() + ": Vertex 3 Position: " + vertices.get(2).toString()); - //System.out.println(this.getClass().getSimpleName() + ": Transformed Vertex 3 Position: " + localToGlobal.transformed(vertex).toString()); - } + //System.out.println(this.getClass().getSimpleName() + ": Transformed Vertex 3 Position: " + localToGlobal.transformed(vertex).toString()); + } } else if(vertex.y() < 0 && vertex.x() < 0){ - localToGlobal.transform(vertex); + localToGlobal.transform(vertex); //vertices.set(3, new Point3D(vertex.y() + sensorPos.x(), vertex.x() + sensorPos.y(), vertex.z() + sensorPos.z())); vertices.set(3, new Point3D(vertex.x(), vertex.y(), vertex.z())); if(debug){ System.out.println(this.getClass().getSimpleName() + ": Vertex 4 Position: " + vertices.get(3).toString()); - //System.out.println(this.getClass().getSimpleName() + ": Transformed Vertex 4 Position: " + localToGlobal.transformed(vertex).toString()); + //System.out.println(this.getClass().getSimpleName() + ": Transformed Vertex 4 Position: " + localToGlobal.transformed(vertex).toString()); } } } @@ -531,30 +592,30 @@ System.out.println("%====================== Hit Efficiencies ==========================%"); System.out.println("%===================================================================% \n%"); if(numberOfTopTracks > 0){ - double topEfficiency = numberOfTopTracksWithHitOnMissingLayer/numberOfTopTracks; - System.out.println("% Top Hit Efficiency: " + numberOfTopTracksWithHitOnMissingLayer + "/" + - numberOfTopTracks + " = " + topEfficiency*100 + "%"); - System.out.println("% Top Hit Efficiency Error: sigma poisson = " - + topEfficiency*Math.sqrt((1/numberOfTopTracksWithHitOnMissingLayer) + (1/numberOfTopTracks))*100 + "%"); - System.out.println("% Top Hit Efficiency Error: sigma binomial = " - + (1/numberOfTopTracks)*Math.sqrt(numberOfTopTracksWithHitOnMissingLayer*(1-topEfficiency))*100 + "%"); + double topEfficiency = numberOfTopTracksWithHitOnMissingLayer/numberOfTopTracks; + System.out.println("% Top Hit Efficiency: " + numberOfTopTracksWithHitOnMissingLayer + "/" + + numberOfTopTracks + " = " + topEfficiency*100 + "%"); + System.out.println("% Top Hit Efficiency Error: sigma poisson = " + + topEfficiency*Math.sqrt((1/numberOfTopTracksWithHitOnMissingLayer) + (1/numberOfTopTracks))*100 + "%"); + System.out.println("% Top Hit Efficiency Error: sigma binomial = " + + (1/numberOfTopTracks)*Math.sqrt(numberOfTopTracksWithHitOnMissingLayer*(1-topEfficiency))*100 + "%"); } if(numberOfBottomTracks > 0){ - double bottomEfficiency = numberOfBottomTracksWithHitOnMissingLayer/numberOfBottomTracks; - System.out.println("% Bottom Hit Efficiency: " + numberOfBottomTracksWithHitOnMissingLayer + "/" - + numberOfBottomTracks + " = " + bottomEfficiency*100 + "%"); - System.out.println("% Bottom Hit Efficiency Error: sigma poisson= " - + bottomEfficiency*Math.sqrt((1/numberOfBottomTracksWithHitOnMissingLayer) + (1/numberOfBottomTracks))*100 + "%"); - System.out.println("% Top Hit Efficiency Error: sigma binomial = " - + (1/numberOfBottomTracks)*Math.sqrt(numberOfBottomTracksWithHitOnMissingLayer*(1-bottomEfficiency))*100 + "%"); + double bottomEfficiency = numberOfBottomTracksWithHitOnMissingLayer/numberOfBottomTracks; + System.out.println("% Bottom Hit Efficiency: " + numberOfBottomTracksWithHitOnMissingLayer + "/" + + numberOfBottomTracks + " = " + bottomEfficiency*100 + "%"); + System.out.println("% Bottom Hit Efficiency Error: sigma poisson= " + + bottomEfficiency*Math.sqrt((1/numberOfBottomTracksWithHitOnMissingLayer) + (1/numberOfBottomTracks))*100 + "%"); + System.out.println("% Top Hit Efficiency Error: sigma binomial = " + + (1/numberOfBottomTracks)*Math.sqrt(numberOfBottomTracksWithHitOnMissingLayer*(1-bottomEfficiency))*100 + "%"); } /* for(int index = 0; index < topTracksWithHitOnMissingLayer.length; index++){ - if(topTracksPerMissingLayer[index] > 0) - System.out.println("% Top Layer " + (index+1) + ": " + (topTracksWithHitOnMissingLayer[index]/topTracksPerMissingLayer[index])*100 + "%"); + if(topTracksPerMissingLayer[index] > 0) + System.out.println("% Top Layer " + (index+1) + ": " + (topTracksWithHitOnMissingLayer[index]/topTracksPerMissingLayer[index])*100 + "%"); } for(int index = 0; index < bottomTracksWithHitOnMissingLayer.length; index++){ - if(bottomTracksPerMissingLayer[index] > 0) - System.out.println("% Bottom Layer " + (index+1) + ": " + (bottomTracksWithHitOnMissingLayer[index]/bottomTracksPerMissingLayer[index])*100 + "%"); + if(bottomTracksPerMissingLayer[index] > 0) + System.out.println("% Bottom Layer " + (index+1) + ": " + (bottomTracksWithHitOnMissingLayer[index]/bottomTracksPerMissingLayer[index])*100 + "%"); }*/ System.out.println("% \n%===================================================================%"); } Modified: java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/omoreno/SvtTrackAnalysis.java ============================================================================= --- java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/omoreno/SvtTrackAnalysis.java (original) +++ java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/omoreno/SvtTrackAnalysis.java Fri Jun 12 15:27:10 2015 @@ -1,43 +1,69 @@ package org.hps.users.omoreno; -//--- java ---// -//--- hep ---// -import hep.aida.IPlotter; -import hep.physics.vec.Hep3Vector; - -import java.util.ArrayList; +import java.io.IOException; import java.util.HashMap; import java.util.List; import java.util.Map; - +import java.util.Set; + +import hep.aida.IAnalysisFactory; +import hep.aida.IHistogramFactory; +import hep.aida.IPlotterFactory; +import hep.aida.IPlotter; +import hep.aida.IHistogram1D; +import hep.aida.ITree; +import hep.aida.ref.rootwriter.RootFileStore; + +import org.lcsim.detector.tracker.silicon.HpsSiSensor; +import org.lcsim.event.EventHeader; +import org.lcsim.event.LCRelation; +import org.lcsim.event.RawTrackerHit; +import org.lcsim.event.RelationalTable; +import org.lcsim.event.Track; +import org.lcsim.event.TrackerHit; +import org.lcsim.event.base.BaseRelationalTable; +import org.lcsim.geometry.Detector; +import org.lcsim.util.Driver; + +import org.hps.recon.tracking.FittedRawTrackerHit; import org.hps.recon.tracking.TrackUtils; -import org.lcsim.event.Cluster; -//--- org.lcsim ---// -import org.lcsim.event.EventHeader; -import org.lcsim.event.RawTrackerHit; -import org.lcsim.event.Track; -import org.lcsim.geometry.Detector; -import org.lcsim.recon.tracking.digitization.sisim.SiTrackerHitStrip1D; -import org.lcsim.recon.tracking.seedtracker.SeedTrack; -import org.lcsim.util.Driver; -import org.lcsim.util.aida.AIDA; -//--- hps-java ---// /** * - * @author Omar Moreno - * @version $Id: SvtTrackAnalysis.java,v 1.7 2013/11/06 19:19:55 jeremy Exp $ + * @author Omar Moreno <[log in to unmask]> * */ - public class SvtTrackAnalysis extends Driver { - + + // Use JFreeChart as the default plotting backend + static { + hep.aida.jfree.AnalysisFactory.register(); + } + + // Plotting + ITree tree; + IHistogramFactory histogramFactory; + IPlotterFactory plotterFactory = IAnalysisFactory.create().createPlotterFactory(); + protected Map<String, IPlotter> plotters = new HashMap<String, IPlotter>(); + private Map<String, IHistogram1D> trackPlots = new HashMap<String, IHistogram1D>(); + private Map<String, IHistogram1D> clusterChargePlots = new HashMap<String, IHistogram1D>(); + private Map<String, IHistogram1D> clusterSizePlots = new HashMap<String, IHistogram1D>(); + + private List<HpsSiSensor> sensors; + private Map<RawTrackerHit, LCRelation> fittedRawTrackerHitMap + = new HashMap<RawTrackerHit, LCRelation>(); + + // Detector name + private static final String SUBDETECTOR_NAME = "Tracker"; + + // Collections private String trackCollectionName = "MatchedTracks"; - private String stripHitCollectionName = "StripClusterer_SiTrackerHitStrip1D"; - private AIDA aida; - private List<IPlotter> plotters = new ArrayList<IPlotter>(); + private String stereoHitRelationsColName = "HelicalTrackHitRelations"; + private String fittedHitsCollectionName = "SVTFittedRawTrackerHits"; + private String rotatedHthRelationsColName = "RotatedHelicalTrackHitRelations"; + + private int runNumber = -1; - int npositive = 0; int nnegative = 0; double ntracks = 0; @@ -45,21 +71,133 @@ double ntracksBottom = 0; double nTwoTracks = 0; double nevents = 0; - - + + double d0Cut = -9999; + + // Flags + boolean electronCut = false; + boolean positronCut = false; + + /** + * Default Constructor + */ public SvtTrackAnalysis(){ } - + + public void setEnableElectronCut(boolean electronCut) { + this.electronCut = electronCut; + } + + public void setEnablePositronCut(boolean positronCut) { + this.positronCut = positronCut; + } + + public void setD0Cut(double d0Cut) { + this.d0Cut = d0Cut; + } + + private int computePlotterRegion(HpsSiSensor sensor) { + + if (sensor.getLayerNumber() < 7) { + if (sensor.isTopLayer()) { + return 6*(sensor.getLayerNumber() - 1); + } else { + return 6*(sensor.getLayerNumber() - 1) + 1; + } + } else { + + if (sensor.isTopLayer()) { + if (sensor.getSide() == HpsSiSensor.POSITRON_SIDE) { + return 6*(sensor.getLayerNumber() - 7) + 2; + } else { + return 6*(sensor.getLayerNumber() - 7) + 3; + } + } else if (sensor.isBottomLayer()) { + if (sensor.getSide() == HpsSiSensor.POSITRON_SIDE) { + return 6*(sensor.getLayerNumber() - 7) + 4; + } else { + return 6*(sensor.getLayerNumber() - 7) + 5; + } + } + } + return -1; + } + protected void detectorChanged(Detector detector){ - - aida = AIDA.defaultInstance(); - aida.tree().cd("/"); - - int nPlotters = 0; - + + tree = IAnalysisFactory.create().createTreeFactory().create(); + histogramFactory = IAnalysisFactory.create().createHistogramFactory(tree); + + // Get the HpsSiSensor objects from the tracker detector element + sensors = detector.getSubdetector(SUBDETECTOR_NAME) + .getDetectorElement().findDescendants(HpsSiSensor.class); + + // If the detector element had no sensors associated with it, throw + // an exception + if (sensors.size() == 0) { + throw new RuntimeException("No sensors were found in this detector."); + } + + plotters.put("Event Information", plotterFactory.create("Event information")); + plotters.get("Event Information").createRegions(2, 3); + + trackPlots.put("Number of tracks", histogramFactory.createHistogram1D("Number of tracks", 10, 0, 10)); + plotters.get("Event Information").region(0).plot(trackPlots.get("Number of tracks")); + + trackPlots.put("Track charge", histogramFactory.createHistogram1D("Track charge", 3, -1, 2)); + plotters.get("Event Information").region(1).plot(trackPlots.get("Track charge")); + + trackPlots.put("chi2", histogramFactory.createHistogram1D("chi2", 40, 0, 40)); + plotters.get("Event Information").region(2).plot(trackPlots.get("chi2")); + + plotters.put("Track Parameters", plotterFactory.create("Track Parameters")); + plotters.get("Track Parameters").createRegions(3, 3); + + trackPlots.put("doca", histogramFactory.createHistogram1D("doca", 80, -10, 10)); + plotters.get("Track Parameters").region(0).plot(trackPlots.get("doca")); + + trackPlots.put("z0", histogramFactory.createHistogram1D("z0", 80, -2, 2)); + plotters.get("Track Parameters").region(1).plot(trackPlots.get("z0")); + + trackPlots.put("sin(phi0)", histogramFactory.createHistogram1D("sin(phi0)", 40, -0.2, 0.2)); + plotters.get("Track Parameters").region(2).plot(trackPlots.get("sin(phi0)")); + + trackPlots.put("curvature", histogramFactory.createHistogram1D("curvature", 50, -0.001, 0.001)); + plotters.get("Track Parameters").region(3).plot(trackPlots.get("curvature")); + + trackPlots.put("tan_lambda", histogramFactory.createHistogram1D("tan_lambda", 100, -0.1, 0.1)); + plotters.get("Track Parameters").region(4).plot(trackPlots.get("tan_lambda")); + + trackPlots.put("cos(theta)", histogramFactory.createHistogram1D("cos(theta)", 40, -0.1, 0.1)); + plotters.get("Track Parameters").region(5).plot(trackPlots.get("cos(theta)")); + + trackPlots.put("cluster time dt", histogramFactory.createHistogram1D("cluster time dt", 100, -20, 20)); + plotters.get("Track Parameters").region(6).plot(trackPlots.get("cluster time dt")); + + plotters.put("Cluster Amplitude", plotterFactory.create("Cluster Amplitude")); + plotters.get("Cluster Amplitude").createRegions(6, 6); + + plotters.put("Cluster Size", plotterFactory.create("Cluster Size")); + plotters.get("Cluster Size").createRegions(6, 6); + + + for (HpsSiSensor sensor : sensors) { + + clusterChargePlots.put(sensor.getName(), + histogramFactory.createHistogram1D(sensor.getName() + " - Cluster Charge", 100, 0, 5000)); + plotters.get("Cluster Amplitude").region(this.computePlotterRegion(sensor)) + .plot(clusterChargePlots.get(sensor.getName())); + + clusterSizePlots.put(sensor.getName(), + histogramFactory.createHistogram1D(sensor.getName() + " - Cluster Size", 10, 0, 10)); + plotters.get("Cluster Size").region(this.computePlotterRegion(sensor)) + .plot(clusterSizePlots.get(sensor.getName())); + + } + //--- Track Extrapolation ---// //---------------------------// - plotters.add(aida.analysisFactory().createPlotterFactory().create("Track Position at Ecal")); + /*plotters.add(aida.analysisFactory().createPlotterFactory().create("Track Position at Ecal")); plotters.get(nPlotters).region(0).plot(aida.histogram2D("Track Position at Ecal", 200, -350, 350, 200, -100, 100)); plotters.get(nPlotters).region(0).style().setParameter("hist2DStyle", "colorMap"); plotters.get(nPlotters).region(0).style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); @@ -74,29 +212,29 @@ plotters.get(nPlotters).style().statisticsBoxStyle().setVisible(false); nPlotters++; - plotters.add(aida.analysisFactory().createPlotterFactory().create("Track Position at Ecal: Curvature < 0")); - plotters.get(nPlotters).region(0).plot(aida.histogram2D("Track Position at Ecal: Curvature < 0",200, -350, 350, 200, -100, 100)); - plotters.get(nPlotters).region(0).style().setParameter("hist2DStyle", "colorMap"); - plotters.get(nPlotters).region(0).style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); - plotters.get(nPlotters).style().statisticsBoxStyle().setVisible(false); - nPlotters++; - - plotters.add(aida.analysisFactory().createPlotterFactory().create("Track Position at Harp: Curvature < 0")); - plotters.get(nPlotters).region(0).plot(aida.histogram2D("Track Position at Harp: Curvature < 0", 200, -200, 200, 100, -50, 50)); - plotters.get(nPlotters).region(0).style().setParameter("hist2DStyle", "colorMap"); - plotters.get(nPlotters).region(0).style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); - plotters.get(nPlotters).style().statisticsBoxStyle().setVisible(false); - nPlotters++; - - plotters.add(aida.analysisFactory().createPlotterFactory().create("Track Position at Ecal: Curvature > 0")); - plotters.get(nPlotters).region(0).plot(aida.histogram2D("Track Position at Ecal: Curvature > 0", 200, -350, 350, 200, -100, 100)); - plotters.get(nPlotters).region(0).style().setParameter("hist2DStyle", "colorMap"); - plotters.get(nPlotters).region(0).style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); - plotters.get(nPlotters).style().statisticsBoxStyle().setVisible(false); - nPlotters++; - - plotters.add(aida.analysisFactory().createPlotterFactory().create("Track Position at Harp: Curvature > 0")); - plotters.get(nPlotters).region(0).plot(aida.histogram2D("Track Position at Harp: Curvature > 0", 200, -200, 200, 100, -50, 50)); + plotters.add(aida.analysisFactory().createPlotterFactory().create("Track Position at Ecal: curvature < 0")); + plotters.get(nPlotters).region(0).plot(aida.histogram2D("Track Position at Ecal: curvature < 0",200, -350, 350, 200, -100, 100)); + plotters.get(nPlotters).region(0).style().setParameter("hist2DStyle", "colorMap"); + plotters.get(nPlotters).region(0).style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); + plotters.get(nPlotters).style().statisticsBoxStyle().setVisible(false); + nPlotters++; + + plotters.add(aida.analysisFactory().createPlotterFactory().create("Track Position at Harp: curvature < 0")); + plotters.get(nPlotters).region(0).plot(aida.histogram2D("Track Position at Harp: curvature < 0", 200, -200, 200, 100, -50, 50)); + plotters.get(nPlotters).region(0).style().setParameter("hist2DStyle", "colorMap"); + plotters.get(nPlotters).region(0).style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); + plotters.get(nPlotters).style().statisticsBoxStyle().setVisible(false); + nPlotters++; + + plotters.add(aida.analysisFactory().createPlotterFactory().create("Track Position at Ecal: curvature > 0")); + plotters.get(nPlotters).region(0).plot(aida.histogram2D("Track Position at Ecal: curvature > 0", 200, -350, 350, 200, -100, 100)); + plotters.get(nPlotters).region(0).style().setParameter("hist2DStyle", "colorMap"); + plotters.get(nPlotters).region(0).style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); + plotters.get(nPlotters).style().statisticsBoxStyle().setVisible(false); + nPlotters++; + + plotters.add(aida.analysisFactory().createPlotterFactory().create("Track Position at Harp: curvature > 0")); + plotters.get(nPlotters).region(0).plot(aida.histogram2D("Track Position at Harp: curvature > 0", 200, -200, 200, 100, -50, 50)); plotters.get(nPlotters).region(0).style().setParameter("hist2DStyle", "colorMap"); plotters.get(nPlotters).region(0).style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); plotters.get(nPlotters).style().statisticsBoxStyle().setVisible(false); @@ -118,44 +256,6 @@ nPlotters++; - //--- Track Parameters ---// - //------------------------// - plotters.add(aida.analysisFactory().createPlotterFactory().create("DOCA")); - plotters.get(nPlotters).region(0).plot(aida.histogram1D("DOCA", 120, 0, 120)); - plotters.get(nPlotters).style().statisticsBoxStyle().setVisible(false); - plotters.get(nPlotters).style().dataStyle().errorBarStyle().setVisible(false); - nPlotters++; - - plotters.add(aida.analysisFactory().createPlotterFactory().create("Z0")); - plotters.get(nPlotters).region(0).plot(aida.histogram1D("Z0", 120, 0, 120)); - plotters.get(nPlotters).style().statisticsBoxStyle().setVisible(false); - plotters.get(nPlotters).style().dataStyle().errorBarStyle().setVisible(false); - nPlotters++; - - plotters.add(aida.analysisFactory().createPlotterFactory().create("phi0")); - plotters.get(nPlotters).region(0).plot(aida.histogram1D("phi0", 50, -Math.PI, Math.PI)); - plotters.get(nPlotters).style().statisticsBoxStyle().setVisible(false); - plotters.get(nPlotters).style().dataStyle().errorBarStyle().setVisible(false); - nPlotters++; - - plotters.add(aida.analysisFactory().createPlotterFactory().create("Curvature")); - plotters.get(nPlotters).region(0).plot(aida.histogram1D("R", 200, -10, 10)); - plotters.get(nPlotters).style().statisticsBoxStyle().setVisible(false); - plotters.get(nPlotters).style().dataStyle().errorBarStyle().setVisible(false); - nPlotters++; - - plotters.add(aida.analysisFactory().createPlotterFactory().create("Tan(Lambda)")); - plotters.get(nPlotters).region(0).plot(aida.histogram1D("Tan(Lambda)", 100, 0, 1)); - plotters.get(nPlotters).style().statisticsBoxStyle().setVisible(false); - plotters.get(nPlotters).style().dataStyle().errorBarStyle().setVisible(false); - nPlotters++; - - plotters.add(aida.analysisFactory().createPlotterFactory().create("ChiSquared")); - plotters.get(nPlotters).region(0).plot(aida.histogram1D("ChiSquared", 100, 0, 100)); - plotters.get(nPlotters).style().statisticsBoxStyle().setVisible(false); - plotters.get(nPlotters).style().dataStyle().errorBarStyle().setVisible(false); - nPlotters++; - //--- Momentum ---// //----------------// plotters.add(aida.analysisFactory().createPlotterFactory().create("Px")); @@ -239,36 +339,156 @@ plotters.get(nPlotters).region(0).style().dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); plotters.get(nPlotters).style().statisticsBoxStyle().setVisible(false); nPlotters++; - - for(IPlotter plotter : plotters) plotter.show(); + */ + for (IPlotter plotter : plotters.values()) { + plotter.show(); + } } - public void process(EventHeader event){ + @SuppressWarnings({ "unchecked", "rawtypes" }) + public void process(EventHeader event){ nevents++; - - if(event.hasCollection(SiTrackerHitStrip1D.class, stripHitCollectionName)){ - - System.out.println("Found Strip Hits!"); - List<SiTrackerHitStrip1D> stripHits = event.get(SiTrackerHitStrip1D.class, stripHitCollectionName); - short[] samples = new short[6]; - for(SiTrackerHitStrip1D stripHit : stripHits){ - for(RawTrackerHit rawHit : stripHit.getRawHits()){ - for(int index = 0; index < samples.length; index++){ - samples[index] += rawHit.getADCValues()[index]; - } - } - } - } - + + // Get the run number from the event + if (runNumber == -1) runNumber = event.getRunNumber(); + + // If the event doesn't have any tracks, skip it if(!event.hasCollection(Track.class, trackCollectionName)) return; - List<SeedTrack> tracks = event.get(SeedTrack.class, trackCollectionName); - - Map<Hep3Vector,SeedTrack> trackToEcalPosition = new HashMap<Hep3Vector, SeedTrack>(); - Map<SeedTrack, Cluster> trackToCluster = new HashMap<SeedTrack, Cluster>(); - List<Hep3Vector> ecalPos = new ArrayList<Hep3Vector>(); - - for(SeedTrack track : tracks){ - ntracks++; + + // Get the collection of tracks from the event + List<Track> tracks = event.get(Track.class, trackCollectionName); + + // Get the collection of LCRelations between a stereo hit and the strips making it up + List<LCRelation> stereoHitRelations = event.get(LCRelation.class, stereoHitRelationsColName); + BaseRelationalTable stereoHitToClusters = new BaseRelationalTable(RelationalTable.Mode.MANY_TO_MANY, RelationalTable.Weighting.UNWEIGHTED); + for (LCRelation relation : stereoHitRelations) { + if (relation != null && relation.getFrom() != null && relation.getTo() != null) { + stereoHitToClusters.add(relation.getFrom(), relation.getTo()); + } + } + + // Get the collection of LCRelations relating RotatedHelicalTrackHits to + // HelicalTrackHits + List<LCRelation> rotatedHthToHthRelations = event.get(LCRelation.class, rotatedHthRelationsColName); + BaseRelationalTable hthToRotatedHth = new BaseRelationalTable(RelationalTable.Mode.ONE_TO_ONE, RelationalTable.Weighting.UNWEIGHTED); + for (LCRelation relation : rotatedHthToHthRelations) { + if (relation != null && relation.getFrom() != null && relation.getTo() != null) { + hthToRotatedHth.add(relation.getFrom(), relation.getTo()); + } + } + + // Get the list of fitted hits from the event + List<LCRelation> fittedHits = event.get(LCRelation.class, fittedHitsCollectionName); + + // Map the fitted hits to their corresponding raw hits + this.mapFittedRawHits(fittedHits); + + trackPlots.get("Number of tracks").fill(tracks.size()); + + // Loop over all of the tracks in the event + for(Track track : tracks){ + + if (TrackUtils.getR(track) < 0 && electronCut) continue; + + if (TrackUtils.getR(track) > 0 && positronCut) continue; + + if (d0Cut != -9999 && Math.abs(TrackUtils.getDoca(track)) < d0Cut) continue; + + trackPlots.get("Track charge").fill(TrackUtils.getR(track), 1); + + // Fill the track parameter plots + trackPlots.get("doca").fill(TrackUtils.getDoca(track)); + trackPlots.get("z0").fill(TrackUtils.getZ0(track)); + trackPlots.get("sin(phi0)").fill(TrackUtils.getPhi0(track)); + trackPlots.get("curvature").fill(TrackUtils.getR(track)); + trackPlots.get("tan_lambda").fill(TrackUtils.getTanLambda(track)); + trackPlots.get("cos(theta)").fill(TrackUtils.getCosTheta(track)); + trackPlots.get("chi2").fill(track.getChi2()); + + for (TrackerHit rotatedStereoHit : track.getTrackerHits()) { + + // Get the HelicalTrackHit corresponding to the RotatedHelicalTrackHit + // associated with a track + Set<TrackerHit> clusters = stereoHitToClusters.allFrom(hthToRotatedHth.from(rotatedStereoHit)); + + int clusterIndex = 0; + double clusterTimeDt = 0; + for (TrackerHit cluster : clusters) { + + if (clusterIndex == 0) { + clusterTimeDt += cluster.getTime(); + clusterIndex++; + } else { + clusterTimeDt -= cluster.getTime(); + } + + double amplitude = 0; + HpsSiSensor sensor = null; + for (Object rawHitObject : cluster.getRawHits()) { + RawTrackerHit rawHit = (RawTrackerHit) rawHitObject; + + sensor = (HpsSiSensor) rawHit.getDetectorElement(); + + // Get the channel of the raw hit + //int channel = rawHit.getIdentifierFieldValue("strip"); + + // Add the amplitude of that channel to the total amplitude + amplitude += FittedRawTrackerHit.getAmp(this.getFittedHit(rawHit)); + } + + clusterChargePlots.get(sensor.getName()).fill(amplitude); + clusterSizePlots.get(sensor.getName()).fill(cluster.getRawHits().size()); + } + + trackPlots.get("cluster time dt").fill(clusterTimeDt); + } + } + } + + public void endOfData() { + + String rootFile = "run" + runNumber + "_track_analysis.root"; + RootFileStore store = new RootFileStore(rootFile); + try { + store.open(); + store.add(tree); + store.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + /** + * Method that creates a map between a fitted raw hit and it's corresponding raw fit + * + * @param fittedHits : List of fitted hits to map + */ + private void mapFittedRawHits(List<LCRelation> fittedHits) { + + // Clear the fitted raw hit map of old values + fittedRawTrackerHitMap.clear(); + + // Loop through all fitted hits and map them to their corresponding raw hits + for (LCRelation fittedHit : fittedHits) { + fittedRawTrackerHitMap.put(FittedRawTrackerHit.getRawTrackerHit(fittedHit), fittedHit); + } + } + + /** + * + * @param rawHit + * @return + */ + private LCRelation getFittedHit(RawTrackerHit rawHit) { + return fittedRawTrackerHitMap.get(rawHit); + } +} + + + + + /* + ntracks++; Hep3Vector positionEcal = TrackUtils.getTrackPositionAtEcal(track); System.out.println("Position at Ecal: " + positionEcal); Hep3Vector positionConverter = TrackUtils.extrapolateTrack(track,-700); @@ -278,29 +498,25 @@ if(positionEcal.z() > 0 ) ntracksTop++; else if(positionEcal.z() < 0) ntracksBottom++; - - - aida.histogram1D("DOCA").fill(TrackUtils.getDoca(track)); - aida.histogram1D("Z0").fill(TrackUtils.getZ0(track)); - aida.histogram1D("phi0").fill(TrackUtils.getPhi0(track)); - aida.histogram1D("R").fill((1/TrackUtils.getR(track))*1000); - aida.histogram1D("Tan(Lambda)").fill(TrackUtils.getTanLambda(track)); - + */ + + + /* aida.histogram1D("Px").fill(track.getTrackStates().get(0).getMomentum()[0]); aida.histogram1D("Py").fill(track.getTrackStates().get(0).getMomentum()[1]); aida.histogram1D("Pz").fill(track.getTrackStates().get(0).getMomentum()[2]); aida.histogram1D("ChiSquared").fill(track.getChi2()); if(Math.signum(TrackUtils.getR(track)) < 0){ - aida.histogram2D("Track Position at Ecal: Curvature < 0").fill(positionEcal.y(), positionEcal.z()); - aida.histogram2D("Track Position at Harp: Curvature < 0").fill(positionConverter.y(), positionConverter.z()); + aida.histogram2D("Track Position at Ecal: curvature < 0").fill(positionEcal.y(), positionEcal.z()); + aida.histogram2D("Track Position at Harp: curvature < 0").fill(positionConverter.y(), positionConverter.z()); aida.histogram1D("Px: C < 0").fill(track.getTrackStates().get(0).getMomentum()[0]); aida.histogram1D("Py: C < 0").fill(track.getTrackStates().get(0).getMomentum()[1]); aida.histogram1D("Pz: C < 0").fill(track.getTrackStates().get(0).getMomentum()[2]); nnegative++; } else if(Math.signum(TrackUtils.getR(track)) > 0){ - aida.histogram2D("Track Position at Ecal: Curvature > 0").fill(positionEcal.y(), positionEcal.z()); - aida.histogram2D("Track Position at Harp: Curvature > 0").fill(positionConverter.y(), positionConverter.z()); + aida.histogram2D("Track Position at Ecal: curvature > 0").fill(positionEcal.y(), positionEcal.z()); + aida.histogram2D("Track Position at Harp: curvature > 0").fill(positionConverter.y(), positionConverter.z()); aida.histogram1D("Px: C > 0").fill(track.getTrackStates().get(0).getMomentum()[0]); aida.histogram1D("Px: C > 0").fill(track.getTrackStates().get(0).getMomentum()[1]); aida.histogram1D("Px: C > 0").fill(track.getTrackStates().get(0).getMomentum()[2]); @@ -338,9 +554,9 @@ aida.histogram2D("XY Difference between Ecal Cluster and Track Position").fill(xdiff, ydiff); } - for(Map.Entry<SeedTrack, Cluster> entry : trackToCluster.entrySet()){ + for(Map.Entry<Track, Cluster> entry : trackToCluster.entrySet()){ double Energy = entry.getValue().getEnergy(); - SeedTrack track = entry.getKey(); + Track track = entry.getKey(); double pTotal = Math.sqrt(track.getTrackStates().get(0).getMomentum()[0]*track.getTrackStates().get(0).getMomentum()[0] + track.getTrackStates().get(0).getMomentum()[1]*track.getTrackStates().get(0).getMomentum()[1] + track.getTrackStates().get(0).getMomentum()[2]*track.getTrackStates().get(0).getMomentum()[2]); double ep = Energy/(pTotal*1000); @@ -368,5 +584,6 @@ System.out.println("Number of top tracks per event: " + tracksTopRatio); System.out.println("Number of bottom tracks per event: " + tracksBottomRatio); System.out.println("Number of two track events: " + twoTrackRatio); - } -} + }*/ + + Modified: java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/phansson/TrackingReconstructionPlots.java ============================================================================= --- java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/phansson/TrackingReconstructionPlots.java (original) +++ java/branches/HPSJAVA-488/users/src/main/java/org/hps/users/phansson/TrackingReconstructionPlots.java Fri Jun 12 15:27:10 2015 @@ -7,24 +7,38 @@ import hep.aida.IPlotterStyle; import hep.aida.IProfile; import hep.physics.matrix.SymmetricMatrix; +import hep.physics.vec.BasicHep3Vector; import hep.physics.vec.Hep3Vector; + import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; + +import org.apache.commons.lang3.tuple.Pair; +import org.hps.readout.ecal.FADCEcalReadoutDriver.PulseShape; import org.hps.recon.tracking.BeamlineConstants; import org.hps.recon.tracking.DumbShaperFit; +import org.hps.recon.tracking.FittedRawTrackerHit; import org.hps.recon.tracking.HelixConverter; -import org.hps.recon.tracking.PulseShape; import org.hps.recon.tracking.ShapeFitParameters; import org.hps.recon.tracking.ShaperFitAlgorithm; import org.hps.recon.tracking.StraightLineTrack; import org.hps.recon.tracking.TrackUtils; +import org.hps.recon.tracking.gbl.HelicalTrackStripGbl; +import org.hps.recon.tracking.gbl.HpsGblRefitter; +import org.hps.util.BasicLogFormatter; +import org.lcsim.constants.Constants; +import org.lcsim.detector.IDetectorElement; import org.lcsim.detector.tracker.silicon.HpsSiSensor; import org.lcsim.detector.tracker.silicon.SiSensor; import org.lcsim.event.Cluster; import org.lcsim.event.EventHeader; import org.lcsim.event.LCIOParameters.ParameterName; +import org.lcsim.event.LCRelation; import org.lcsim.event.RawTrackerHit; import org.lcsim.event.Track; import org.lcsim.event.TrackerHit; @@ -41,16 +55,19 @@ import org.lcsim.recon.tracking.seedtracker.SeedTrack; import org.lcsim.util.Driver; import org.lcsim.util.aida.AIDA; +import org.lcsim.util.log.LogUtil; /** * - * @author mgraham + * @author phansson */ public class TrackingReconstructionPlots extends Driver { - //private AIDAFrame plotterFrame; - //private AIDAFrame topFrame; - //private AIDAFrame bottomFrame; + static { + hep.aida.jfree.AnalysisFactory.register(); + } + + private AIDA aida = AIDA.defaultInstance(); private String rawTrackerHitCollectionName = "SVTRawTrackerHits"; private String fittedTrackerHitCollectionName = "SVTFittedRawTrackerHits"; @@ -62,51 +79,64 @@ private String trackerName = "Tracker"; String ecalSubdetectorName = "Ecal"; String ecalCollectionName = "EcalClusters"; - private Detector detector = null; IDDecoder dec; - private int eventCount; - private List<SiSensor> sensors; private String outputPlots = null; IPlotter plotter; IPlotter plotter2; IPlotter plotter22; + IPlotter plotter2221; + IPlotter plotter2222; IPlotter plotter222; + IPlotter plotter22299; + IPlotter plotter22298; + IPlotter plotter2224; + IPlotter plotter2223; IPlotter plotter3; IPlotter plotter3_1; + IPlotter plotter3_11; IPlotter plotter3_2; IPlotter plotter4; IPlotter plotter5; IPlotter plotter5_1; IPlotter plotter55; IPlotter plotter6; + IPlotter plotter66; IPlotter plotter7; + IPlotter plotter8; + IPlotter plotter9; IPlotter top1; IPlotter top2; IPlotter top3; IPlotter top4; + IPlotter top44; IPlotter bot1; IPlotter bot2; IPlotter bot3; IPlotter bot4; - double zEcal = 1500; - double zAtDownStrPairSpec = 914.0; //mm double zAtColl = -1500; IHistogram1D trkPx; IHistogram1D nTracks; + IHistogram1D nTracksTop; + IHistogram1D nTracksBot; ShaperFitAlgorithm _shaper = new DumbShaperFit(); + HelixConverter converter = new HelixConverter(0); + private boolean showPlots = true; + private double _bfield; + private static Logger logger = LogUtil.create(TrackingReconstructionPlots.class, new BasicLogFormatter()); @Override protected void detectorChanged(Detector detector) { - this.detector = detector; aida.tree().cd("/"); - //plotterFrame = new AIDAFrame(); - //plotterFrame.setTitle("HPS Tracking Plots"); - - //topFrame = new AIDAFrame(); - //topFrame.setTitle("Top Tracking Plots"); - //bottomFrame = new AIDAFrame(); - //bottomFrame.setTitle("Bottom Tracking Plots"); - sensors = detector.getSubdetector(trackerName).getDetectorElement().findDescendants(SiSensor.class); + List<HpsSiSensor> sensors = new ArrayList<HpsSiSensor>(); + for(HpsSiSensor s : detector.getDetectorElement().findDescendants(HpsSiSensor.class)) { + if(s.getName().startsWith("module_") && s.getName().endsWith("sensor0")) { + sensors.add(s); + } + } + logger.info("Found " + sensors.size() + " SiSensors."); + + Hep3Vector bfieldvec = detector.getFieldMap().getField(new BasicHep3Vector(0., 0., 1.)); + _bfield = bfieldvec.y(); IAnalysisFactory fac = aida.analysisFactory(); plotter = fac.createPlotterFactory().create("HPS Tracking Plots"); @@ -119,7 +149,7 @@ trkPx = aida.histogram1D("Track Momentum (Px)", 25, -0.25, 0.25); IHistogram1D trkPy = aida.histogram1D("Track Momentum (Py)", 25, -0.5, 0.5); - IHistogram1D trkPz = aida.histogram1D("Track Momentum (Pz)", 25, 0, 3.5); + IHistogram1D trkPz = aida.histogram1D("Track Momentum (Pz)", 25, 0, 1.5); IHistogram1D trkChi2 = aida.histogram1D("Track Chi2", 25, 0, 25.0); plotter.region(0).plot(trkPx); @@ -127,7 +157,7 @@ plotter.region(2).plot(trkPz); plotter.region(3).plot(trkChi2); - plotter.show(); + if(showPlots) plotter.show(); // ****************************************************************** top1 = fac.createPlotterFactory().create("Top Tracking Plots"); @@ -140,7 +170,7 @@ IHistogram1D toptrkPx = aida.histogram1D("Top Track Momentum (Px)", 25, -0.25, 0.25); IHistogram1D toptrkPy = aida.histogram1D("Top Track Momentum (Py)", 25, -0.5, 0.5); - IHistogram1D toptrkPz = aida.histogram1D("Top Track Momentum (Pz)", 25, 0, 3.5); + IHistogram1D toptrkPz = aida.histogram1D("Top Track Momentum (Pz)", 25, 0, 1.5); IHistogram1D toptrkChi2 = aida.histogram1D("Top Track Chi2", 25, 0, 25.0); top1.region(0).plot(toptrkPx); @@ -148,7 +178,7 @@ top1.region(2).plot(toptrkPz); top1.region(3).plot(toptrkChi2); - top1.show(); + if(showPlots) top1.show(); bot1 = fac.createPlotterFactory().create("Bottom Tracking Plots"); bot1.setTitle("Bottom Momentum"); @@ -160,7 +190,7 @@ IHistogram1D bottrkPx = aida.histogram1D("Bottom Track Momentum (Px)", 25, -0.25, 0.25); IHistogram1D bottrkPy = aida.histogram1D("Bottom Track Momentum (Py)", 25, -0.5, 0.5); - IHistogram1D bottrkPz = aida.histogram1D("Bottom Track Momentum (Pz)", 25, 0, 3.5); + IHistogram1D bottrkPz = aida.histogram1D("Bottom Track Momentum (Pz)", 25, 0, 1.5); IHistogram1D bottrkChi2 = aida.histogram1D("Bottom Track Chi2", 25, 0, 25.0); bot1.region(0).plot(bottrkPx); @@ -168,14 +198,14 @@ bot1.region(2).plot(bottrkPz); bot1.region(3).plot(bottrkChi2); - bot1.show(); + if(showPlots) bot1.show(); // ****************************************************************** - IHistogram1D trkd0 = aida.histogram1D("d0 ", 25, -100.0, 100.0); + IHistogram1D trkd0 = aida.histogram1D("d0 ", 25, -10.0, 10.0); IHistogram1D trkphi = aida.histogram1D("sinphi ", 25, -0.2, 0.2); IHistogram1D trkomega = aida.histogram1D("omega ", 25, -0.0025, 0.0025); IHistogram1D trklam = aida.histogram1D("tan(lambda) ", 25, -0.1, 0.1); - IHistogram1D trkz0 = aida.histogram1D("z0 ", 25, -100.0, 100.0); + IHistogram1D trkz0 = aida.histogram1D("z0 ", 25, -6.0, 6.0); plotter22 = fac.createPlotterFactory().create("HPS Track Params"); plotter22.setTitle("Track parameters"); @@ -189,7 +219,63 @@ plotter22.region(2).plot(trkomega); plotter22.region(3).plot(trklam); plotter22.region(4).plot(trkz0); - + + if(showPlots) plotter22.show(); + + // ****************************************************************** + + + trkd0 = aida.histogram1D("d0 Top", 25, -10.0, 10.0); + trkphi = aida.histogram1D("sinphi Top", 25, -0.2, 0.2); + trkomega = aida.histogram1D("omega Top", 25, -0.0025, 0.0025); + trklam = aida.histogram1D("tan(lambda) Top", 25, -0.1, 0.1); + trkz0 = aida.histogram1D("z0 Top", 25, -6.0, 6.0); + + plotter2221 = fac.createPlotterFactory().create("HPS Track Params"); + plotter2221.setTitle("Track parameters"); + //plotterFrame.addPlotter(plotter22); + IPlotterStyle style2221 = plotter2221.style(); + style2221.dataStyle().fillStyle().setColor("yellow"); + style2221.dataStyle().errorBarStyle().setVisible(false); + plotter2221.createRegions(2, 3); + plotter2221.region(0).plot(trkd0); + plotter2221.region(1).plot(trkphi); + plotter2221.region(2).plot(trkomega); + plotter2221.region(3).plot(trklam); + plotter2221.region(4).plot(trkz0); + + if(showPlots) plotter2221.show(); + + + // ****************************************************************** + + + trkd0 = aida.histogram1D("d0 Bottom", 25, -10.0, 10.0); + trkphi = aida.histogram1D("sinphi Bottom", 25, -0.2, 0.2); + trkomega = aida.histogram1D("omega Bottom", 25, -0.0025, 0.0025); + trklam = aida.histogram1D("tan(lambda) Bottom", 25, -0.1, 0.1); + trkz0 = aida.histogram1D("z0 Bottom", 25, -6.0, 6.0); + + plotter2222 = fac.createPlotterFactory().create("HPS Track Params"); + plotter2222.setTitle("Track parameters"); + //plotterFrame.addPlotter(plotter22); + IPlotterStyle style2222 = plotter2222.style(); + style2222.dataStyle().fillStyle().setColor("yellow"); + style2222.dataStyle().errorBarStyle().setVisible(false); + plotter2222.createRegions(2, 3); + plotter2222.region(0).plot(trkd0); + plotter2222.region(1).plot(trkphi); + plotter2222.region(2).plot(trkomega); + plotter2222.region(3).plot(trklam); + plotter2222.region(4).plot(trkz0); + + if(showPlots) plotter2222.show(); + + + + // ****************************************************************** + + plotter2 = fac.createPlotterFactory().create("HPS Tracking Plots"); plotter2.setTitle("Track extrapolation"); //plotterFrame.addPlotter(plotter2); @@ -214,69 +300,204 @@ plotter2.region(6).plot(yAtEcal); plotter2.region(3).plot(xAtEcal2); plotter2.region(7).plot(yAtEcal2); - + + if(showPlots) plotter2.show(); + + // ****************************************************************** + plotter222 = fac.createPlotterFactory().create("HPS Tracking Plots"); - plotter222.setTitle("Other"); + plotter222.setTitle("HPS Tracking Plots"); //plotterFrame.addPlotter(plotter222); IPlotterStyle style222 = plotter222.style(); style222.dataStyle().fillStyle().setColor("yellow"); style222.dataStyle().errorBarStyle().setVisible(false); - plotter222.createRegions(2, 3); - - IHistogram1D nHits = aida.histogram1D("Hits per Track", 2, 4, 6); + plotter222.createRegions(2, 2); + + IHistogram1D nHits = aida.histogram1D("Hits per Track", 4, 3, 7); + nTracks = aida.histogram1D("Tracks per Event", 3, 0, 3); + IHistogram1D nHitsCluster = aida.histogram1D("Hits in Cluster (HitOnTrack)", 4, 0, 4); + + + plotter222.region(0).plot(nHits); + plotter222.region(1).plot(nTracks); + plotter222.region(2).plot(nHitsCluster); + + if(showPlots) plotter222.show(); + + + // ****************************************************************** + + plotter22299 = fac.createPlotterFactory().create("HPS Tracking Plots Top"); + plotter22299.setTitle("HPS Tracking Plots Top"); + //plotterFrame.addPlotter(plotter22299); + IPlotterStyle style22299 = plotter22299.style(); + style22299.dataStyle().fillStyle().setColor("yellow"); + style22299.dataStyle().errorBarStyle().setVisible(false); + plotter22299.createRegions(2, 2); + + IHistogram1D nHitsTop = aida.histogram1D("Hits per Track Top", 4, 3, 7); + nTracksTop = aida.histogram1D("Tracks per Event Top", 3, 0, 3); + IHistogram1D nHitsClusterTop = aida.histogram1D("Hits in Cluster (HitOnTrack) Top", 4, 0, 4); + + + plotter22299.region(0).plot(nHitsTop); + plotter22299.region(1).plot(nTracksTop); + plotter22299.region(2).plot(nHitsClusterTop); + + if(showPlots) plotter22299.show(); + +// ****************************************************************** + + plotter22298 = fac.createPlotterFactory().create("HPS Tracking Plots Bottom"); + plotter22298.setTitle("HPS Tracking Plots Bottom"); + //plotterFrame.addPlotter(plotter22298); + IPlotterStyle style22298 = plotter22298.style(); + style22298.dataStyle().fillStyle().setColor("yellow"); + style22298.dataStyle().errorBarStyle().setVisible(false); + plotter22298.createRegions(2, 2); + + IHistogram1D nHitsBot = aida.histogram1D("Hits per Track Bot", 4, 3, 7); + nTracksBot = aida.histogram1D("Tracks per Event Bot", 3, 0, 3); + IHistogram1D nHitsClusterBot = aida.histogram1D("Hits in Cluster (HitOnTrack) Bot", 4, 0, 4); + + + plotter22298.region(0).plot(nHitsBot); + plotter22298.region(1).plot(nTracksBot); + plotter22298.region(2).plot(nHitsClusterBot); + + if(showPlots) plotter22298.show(); + + + // ****************************************************************** + + + plotter2223 = fac.createPlotterFactory().create("Cluster Amp Plots"); + plotter2223.setTitle("Other"); + //plotterFrame.addPlotter(plotter222); + IPlotterStyle style2223 = plotter2223.style(); + style2223.dataStyle().fillStyle().setColor("yellow"); + style2223.dataStyle().errorBarStyle().setVisible(false); + plotter2223.createRegions(2, 2); + + + IHistogram1D amp = aida.histogram1D("Amp (HitOnTrack)", 50, 0, 5000); - IHistogram1D ampcl = aida.histogram1D("Amp (CluOnTrack)", 50, 0, 5000); - IHistogram1D amp2 = aida.histogram1D("Amp Pz>1000 (HitOnTrack)", 50, 0, 5000); - IHistogram1D ampcl2 = aida.histogram1D("Amp Pz>1000 (CluOnTrack)", 50, 0, 5000); - nTracks = aida.histogram1D("Tracks per Event", 3, 0, 3); - - plotter222.region(0).plot(nHits); - plotter222.region(3).plot(nTracks); - plotter222.region(1).plot(amp); - plotter222.region(4).plot(amp2); - plotter222.region(2).plot(ampcl); - plotter222.region(5).plot(ampcl2); - - plotter3 = fac.createPlotterFactory().create("HPS Residual Plots"); - plotter3.setTitle("Residuals"); + IHistogram1D ampcl = aida.histogram1D("Cluster Amp (HitOnTrack)", 50, 0, 5000); + IHistogram1D amp2 = aida.histogram1D("Amp Pz>0.8 (HitOnTrack)", 50, 0, 5000); + IHistogram1D ampcl2 = aida.histogram1D("Cluster Amp Pz>0.8 (HitOnTrack)", 50, 0, 5000); + + + plotter2223.region(0).plot(amp); + plotter2223.region(1).plot(amp2); + plotter2223.region(2).plot(ampcl); + plotter2223.region(3).plot(ampcl2); + + if(showPlots) plotter2223.show(); + +// ****************************************************************** + + + plotter2224 = fac.createPlotterFactory().create("t0 Plots"); + plotter2224.setTitle("Other"); + IPlotterStyle style2224 = plotter2224.style(); + style2224.dataStyle().fillStyle().setColor("yellow"); + style2224.dataStyle().errorBarStyle().setVisible(false); + plotter2224.createRegions(2, 2); + + IHistogram1D t0 = aida.histogram1D("t0 (HitOnTrack)", 50, -100, 100); + IHistogram1D t0cl = aida.histogram1D("Cluster t0 (HitOnTrack)", 50, -100, 100); + IHistogram1D t02 = aida.histogram1D("t0 Pz>0.8 (HitOnTrack)", 50, -100, 100); + IHistogram1D t0cl2 = aida.histogram1D("Cluster t0 Pz>0.8 (HitOnTrack)", 50, -100, 100); + + plotter2224.region(0).plot(t0); + plotter2224.region(1).plot(t0cl); + plotter2224.region(2).plot(t02); + plotter2224.region(3).plot(t0cl2); + + if(showPlots) plotter2224.show(); + + + // ****************************************************************** + + plotter3 = fac.createPlotterFactory().create("HPS Layer Residual Plots"); + plotter3.setTitle("Layer Residuals"); //plotterFrame.addPlotter(plotter3); IPlotterStyle style3 = plotter3.style(); style3.dataStyle().fillStyle().setColor("yellow"); style3.dataStyle().errorBarStyle().setVisible(false); - plotter3.createRegions(5, 2); - - double minResidY = -1.5; - double maxResidY = 1.5; - - double minResidX = -5; - double maxResidX = 5; - - IHistogram1D mod1ResX = aida.histogram1D("Module 1 Residual X(mm)", 25, minResidX, maxResidX); - IHistogram1D mod1ResY = aida.histogram1D("Module 1 Residual Y(mm)", 25, minResidY, maxResidY); - - IHistogram1D mod2ResX = aida.histogram1D("Module 2 Residual X(mm)", 25, minResidX, maxResidX); - IHistogram1D mod2ResY = aida.histogram1D("Module 2 Residual Y(mm)", 25, minResidY, maxResidY); - - IHistogram1D mod3ResX = aida.histogram1D("Module 3 Residual X(mm)", 25, minResidX, maxResidX); - IHistogram1D mod3ResY = aida.histogram1D("Module 3 Residual Y(mm)", 25, minResidY, maxResidY); - - IHistogram1D mod4ResX = aida.histogram1D("Module 4 Residual X(mm)", 25, minResidX, maxResidX); - IHistogram1D mod4ResY = aida.histogram1D("Module 4 Residual Y(mm)", 25, minResidY, maxResidY); - - IHistogram1D mod5ResX = aida.histogram1D("Module 5 Residual X(mm)", 25, minResidX, maxResidX); - IHistogram1D mod5ResY = aida.histogram1D("Module 5 Residual Y(mm)", 25, minResidY, maxResidY); + plotter3.createRegions(6, 2); + + + + IHistogram1D mod1ResX = aida.histogram1D("Layer 1 Residual X(mm)", 25, -1, 1); + IHistogram1D mod1ResY = aida.histogram1D("Layer 1 Residual Y(mm)", 25, -0.04, 0.04); + + IHistogram1D mod2ResX = aida.histogram1D("Layer 2 Residual X(mm)", 25, -2, 2); + IHistogram1D mod2ResY = aida.histogram1D("Layer 2 Residual Y(mm)", 25, -1, 1); + + IHistogram1D mod3ResX = aida.histogram1D("Layer 3 Residual X(mm)", 25, -2.5, 2.5); + IHistogram1D mod3ResY = aida.histogram1D("Layer 3 Residual Y(mm)", 25, -1.5, 1.5); + + IHistogram1D mod4ResX = aida.histogram1D("Layer 4 Residual X(mm)", 25, -3.0, 3.0); + IHistogram1D mod4ResY = aida.histogram1D("Layer 4 Residual Y(mm)", 25, -2, 2); + + IHistogram1D mod5ResX = aida.histogram1D("Layer 5 Residual X(mm)", 25, -4, 4); + IHistogram1D mod5ResY = aida.histogram1D("Layer 5 Residual Y(mm)", 25, -3, 3); + + IHistogram1D mod6ResX = aida.histogram1D("Layer 6 Residual X(mm)", 25, -5, 5); + IHistogram1D mod6ResY = aida.histogram1D("Layer 6 Residual Y(mm)", 25, -3, 3); plotter3.region(0).plot(mod1ResX); plotter3.region(2).plot(mod2ResX); plotter3.region(4).plot(mod3ResX); plotter3.region(6).plot(mod4ResX); plotter3.region(8).plot(mod5ResX); + plotter3.region(10).plot(mod6ResX); plotter3.region(1).plot(mod1ResY); plotter3.region(3).plot(mod2ResY); plotter3.region(5).plot(mod3ResY); plotter3.region(7).plot(mod4ResY); plotter3.region(9).plot(mod5ResY); + plotter3.region(11).plot(mod6ResY); + + if(showPlots) plotter3.show(); + + + + plotter3_11 = fac.createPlotterFactory().create("HPS Strip Residual Plots"); + plotter3_11.setTitle("Strip Residuals (Top)"); + //plotterFrame.addPlotter(plotter3_11); + IPlotterStyle style3_11 = plotter3_11.style(); + style3_11.dataStyle().fillStyle().setColor("yellow"); + style3_11.dataStyle().errorBarStyle().setVisible(false); + plotter3_11.createRegions(6, 6); + int i=0; + for(HpsSiSensor sensor : sensors) { + double min = 0.0; + double max = 0.0; + if(sensor.getName().contains("L1")) { + min=-0.04; max=0.04; + } else if(sensor.getName().contains("L2")) { + min=-1; max=1; + } else if(sensor.getName().contains("L3")) { + min=-1.5; max=1.5; + } else if(sensor.getName().contains("L4")) { + min=-3; max=3; + } else if(sensor.getName().contains("L5")) { + min=-4; max=4; + } else if(sensor.getName().contains("L6")) { + min=-5; max=5; + } else { + throw new RuntimeException("Invalid sensor name: " + sensor.getName()); + } + IHistogram1D resX = aida.histogram1D(sensor.getName() + " strip residual (mm)", 50, min, max); + plotter3_11.region(i).plot(resX); + i++; + } + + if(showPlots) plotter3_11.show(); + plotter3_1 = fac.createPlotterFactory().create("HPS Residual Plots (Single hit per layer)"); plotter3_1.setTitle("Residuals (Top)"); @@ -284,69 +505,84 @@ IPlotterStyle style3_1 = plotter3_1.style(); style3_1.dataStyle().fillStyle().setColor("yellow"); style3_1.dataStyle().errorBarStyle().setVisible(false); - plotter3_1.createRegions(5, 2); - - IHistogram1D mod1ResX_Top = aida.histogram1D("Module 1 Residual X(mm) Top", 25, minResidX, maxResidX); - IHistogram1D mod1ResY_Top = aida.histogram1D("Module 1 Residual Y(mm) Top", 25, minResidY, maxResidY); - - IHistogram1D mod2ResX_Top = aida.histogram1D("Module 2 Residual X(mm) Top", 25, minResidX, maxResidX); - IHistogram1D mod2ResY_Top = aida.histogram1D("Module 2 Residual Y(mm) Top", 25, minResidY, maxResidY); - - IHistogram1D mod3ResX_Top = aida.histogram1D("Module 3 Residual X(mm) Top", 25, minResidX, maxResidX); - IHistogram1D mod3ResY_Top = aida.histogram1D("Module 3 Residual Y(mm) Top", 25, minResidY, maxResidY); - - IHistogram1D mod4ResX_Top = aida.histogram1D("Module 4 Residual X(mm) Top", 25, minResidX, maxResidX); - IHistogram1D mod4ResY_Top = aida.histogram1D("Module 4 Residual Y(mm) Top", 25, minResidY, maxResidY); - - IHistogram1D mod5ResX_Top = aida.histogram1D("Module 5 Residual X(mm) Top", 25, minResidX, maxResidX); - IHistogram1D mod5ResY_Top = aida.histogram1D("Module 5 Residual Y(mm) Top", 25, minResidY, maxResidY); - + plotter3_1.createRegions(6, 2); + + IHistogram1D mod1ResX_Top = aida.histogram1D("Layer 1 Residual X(mm) Top", 25, -1, 1); + IHistogram1D mod1ResY_Top = aida.histogram1D("Layer 1 Residual Y(mm) Top", 25, -0.04, 0.04); + + IHistogram1D mod2ResX_Top = aida.histogram1D("Layer 2 Residual X(mm) Top", 25, -2, 2); + IHistogram1D mod2ResY_Top = aida.histogram1D("Layer 2 Residual Y(mm) Top", 25, -1, 1); + + IHistogram1D mod3ResX_Top = aida.histogram1D("Layer 3 Residual X(mm) Top", 25, -2.5, 2.5); + IHistogram1D mod3ResY_Top = aida.histogram1D("Layer 3 Residual Y(mm) Top", 25, -1.5, 1.5); + + IHistogram1D mod4ResX_Top = aida.histogram1D("Layer 4 Residual X(mm) Top", 25, -3.0, 3.0); + IHistogram1D mod4ResY_Top = aida.histogram1D("Layer 4 Residual Y(mm) Top", 25, -2, 2); + + IHistogram1D mod5ResX_Top = aida.histogram1D("Layer 5 Residual X(mm) Top", 25, -4, 4); + IHistogram1D mod5ResY_Top = aida.histogram1D("Layer 5 Residual Y(mm) Top", 25, -3, 3); + + IHistogram1D mod6ResX_Top = aida.histogram1D("Layer 6 Residual X(mm) Top", 25, -5, 5); + IHistogram1D mod6ResY_Top = aida.histogram1D("Layer 6 Residual Y(mm) Top", 25, -3, 3); + + plotter3_1.region(0).plot(mod1ResX_Top); plotter3_1.region(2).plot(mod2ResX_Top); plotter3_1.region(4).plot(mod3ResX_Top); plotter3_1.region(6).plot(mod4ResX_Top); plotter3_1.region(8).plot(mod5ResX_Top); + plotter3_1.region(10).plot(mod6ResX_Top); plotter3_1.region(1).plot(mod1ResY_Top); plotter3_1.region(3).plot(mod2ResY_Top); plotter3_1.region(5).plot(mod3ResY_Top); plotter3_1.region(7).plot(mod4ResY_Top); plotter3_1.region(9).plot(mod5ResY_Top); - + plotter3_1.region(11).plot(mod6ResY_Top); + + if(showPlots) plotter3_1.show(); + plotter3_2 = fac.createPlotterFactory().create("HPS Residual Plots (Single strip cluster per layer)"); plotter3_2.setTitle("Residuals (Bottom)"); //plotterFrame.addPlotter(plotter3_2); IPlotterStyle style3_2 = plotter3_2.style(); style3_2.dataStyle().fillStyle().setColor("yellow"); style3_2.dataStyle().errorBarStyle().setVisible(false); - plotter3_2.createRegions(5, 2); - - IHistogram1D mod1ResX_Bottom = aida.histogram1D("Module 1 Residual X(mm) Bottom", 25, minResidX, maxResidX); - IHistogram1D mod1ResY_Bottom = aida.histogram1D("Module 1 Residual Y(mm) Bottom", 25, minResidY, maxResidY); - - IHistogram1D mod2ResX_Bottom = aida.histogram1D("Module 2 Residual X(mm) Bottom", 25, minResidX, maxResidX); - IHistogram1D mod2ResY_Bottom = aida.histogram1D("Module 2 Residual Y(mm) Bottom", 25, minResidY, maxResidY); - - IHistogram1D mod3ResX_Bottom = aida.histogram1D("Module 3 Residual X(mm) Bottom", 25, minResidX, maxResidX); - IHistogram1D mod3ResY_Bottom = aida.histogram1D("Module 3 Residual Y(mm) Bottom", 25, minResidY, maxResidY); - - IHistogram1D mod4ResX_Bottom = aida.histogram1D("Module 4 Residual X(mm) Bottom", 25, minResidX, maxResidX); - IHistogram1D mod4ResY_Bottom = aida.histogram1D("Module 4 Residual Y(mm) Bottom", 25, minResidY, maxResidY); - - IHistogram1D mod5ResX_Bottom = aida.histogram1D("Module 5 Residual X(mm) Bottom", 25, minResidX, maxResidX); - IHistogram1D mod5ResY_Bottom = aida.histogram1D("Module 5 Residual Y(mm) Bottom", 25, minResidY, maxResidY); + plotter3_2.createRegions(6, 2); + + IHistogram1D mod1ResX_Bottom = aida.histogram1D("Layer 1 Residual X(mm) Bottom", 25, -1, 1); + IHistogram1D mod1ResY_Bottom = aida.histogram1D("Layer 1 Residual Y(mm) Bottom", 25, -0.04, 0.04); + + IHistogram1D mod2ResX_Bottom = aida.histogram1D("Layer 2 Residual X(mm) Bottom", 25, -2, 2); + IHistogram1D mod2ResY_Bottom = aida.histogram1D("Layer 2 Residual Y(mm) Bottom", 25, -1, 1); + + IHistogram1D mod3ResX_Bottom = aida.histogram1D("Layer 3 Residual X(mm) Bottom", 25, -2.5, 2.5); + IHistogram1D mod3ResY_Bottom = aida.histogram1D("Layer 3 Residual Y(mm) Bottom", 25, -1.5, 1.5); + + IHistogram1D mod4ResX_Bottom = aida.histogram1D("Layer 4 Residual X(mm) Bottom", 25, -3.0, 3.0); + IHistogram1D mod4ResY_Bottom = aida.histogram1D("Layer 4 Residual Y(mm) Bottom", 25, -2, 2); + + IHistogram1D mod5ResX_Bottom = aida.histogram1D("Layer 5 Residual X(mm) Bottom", 25, -4, 4); + IHistogram1D mod5ResY_Bottom = aida.histogram1D("Layer 5 Residual Y(mm) Bottom", 25, -3, 3); + + IHistogram1D mod6ResX_Bottom = aida.histogram1D("Layer 6 Residual X(mm) Bottom", 25, -5, 5); + IHistogram1D mod6ResY_Bottom = aida.histogram1D("Layer 6 Residual Y(mm) Bottom", 25, -3, 3); plotter3_2.region(0).plot(mod1ResX_Bottom); plotter3_2.region(2).plot(mod2ResX_Bottom); plotter3_2.region(4).plot(mod3ResX_Bottom); plotter3_2.region(6).plot(mod4ResX_Bottom); plotter3_2.region(8).plot(mod5ResX_Bottom); + plotter3_2.region(10).plot(mod6ResX_Bottom); plotter3_2.region(1).plot(mod1ResY_Bottom); plotter3_2.region(3).plot(mod2ResY_Bottom); plotter3_2.region(5).plot(mod3ResY_Bottom); plotter3_2.region(7).plot(mod4ResY_Bottom); plotter3_2.region(9).plot(mod5ResY_Bottom); + plotter3_2.region(11).plot(mod6ResY_Bottom); + + if(showPlots) plotter3_2.show(); plotter4 = fac.createPlotterFactory().create("HPS Track and ECal Plots"); plotter4.setTitle("Track and ECal Correlations"); @@ -358,14 +594,12 @@ style4.dataStyle().errorBarStyle().setVisible(false); plotter4.createRegions(2, 3); - IHistogram2D eVsP = aida.histogram2D("Energy Vs Momentum", 50, 0, 500, 50, 0, 3000); + IHistogram2D eVsP = aida.histogram2D("Energy Vs Momentum", 50, 0, 0.50, 50, 0, 1.5); IHistogram1D eOverP = aida.histogram1D("Energy Over Momentum", 50, 0, 2); - IHistogram1D distX = aida.histogram1D("deltaX", 50, -400, 400); + IHistogram1D distX = aida.histogram1D("deltaX", 50, -100, 100); IHistogram1D distY = aida.histogram1D("deltaY", 50, -40, 40); -// IHistogram1D distX2 = aida.histogram1D("deltaX (Pz>1)", 50, -400, 400); -// IHistogram1D distY2 = aida.histogram1D("deltaY (Pz>1)", 50, -40, 40); IHistogram2D xEcalVsTrk = aida.histogram2D("X ECal Vs Track", 100, -400, 400, 100, -400, 400); IHistogram2D yEcalVsTrk = aida.histogram2D("Y ECal Vs Track", 100, -100, 100, 100, -100, 100); @@ -375,6 +609,8 @@ plotter4.region(4).plot(distY); plotter4.region(2).plot(xEcalVsTrk); plotter4.region(5).plot(yEcalVsTrk); + + if(showPlots) plotter4.show(); // ****************************************************************** top2 = fac.createPlotterFactory().create("Top ECal Plots"); @@ -387,13 +623,13 @@ top2.createRegions(2, 3); //topFrame.addPlotter(top2); - IHistogram2D topeVsP = aida.histogram2D("Top Energy Vs Momentum", 50, 0, 500, 50, 0, 3000); + IHistogram2D topeVsP = aida.histogram2D("Top Energy Vs Momentum", 50, 0, 0.500, 50, 0, 1.5); IHistogram1D topeOverP = aida.histogram1D("Top Energy Over Momentum", 50, 0, 2); - IHistogram1D topdistX = aida.histogram1D("Top deltaX", 50, -400, 400); + IHistogram1D topdistX = aida.histogram1D("Top deltaX", 50, -100, 100); IHistogram1D topdistY = aida.histogram1D("Top deltaY", 50, -40, 40); - IHistogram2D topxEcalVsTrk = aida.histogram2D("Top X ECal Vs Track", 100, -400, 400, 100, -400, 400); + IHistogram2D topxEcalVsTrk = aida.histogram2D("Top X ECal Vs Track", 100, -400, 400, 100, -100, 100); IHistogram2D topyEcalVsTrk = aida.histogram2D("Top Y ECal Vs Track", 100, 0, 100, 100, 0, 100); top2.region(0).plot(topeVsP); @@ -403,6 +639,8 @@ top2.region(2).plot(topxEcalVsTrk); top2.region(5).plot(topyEcalVsTrk); + if(showPlots) top2.show(); + bot2 = fac.createPlotterFactory().create("Bottom ECal Plots"); bot2.setTitle("Bottom ECal Correlations"); IPlotterStyle sbot2 = bot2.style(); @@ -413,10 +651,10 @@ bot2.createRegions(2, 3); //bottomFrame.addPlotter(bot2); - IHistogram2D BottomeVsP = aida.histogram2D("Bottom Energy Vs Momentum", 50, 0, 500, 50, 0, 3000); + IHistogram2D BottomeVsP = aida.histogram2D("Bottom Energy Vs Momentum", 50, 0, 0.500, 50, 0, 1.5); IHistogram1D BottomeOverP = aida.histogram1D("Bottom Energy Over Momentum", 50, 0, 2); - IHistogram1D BottomdistX = aida.histogram1D("Bottom deltaX", 50, -400, 400); + IHistogram1D BottomdistX = aida.histogram1D("Bottom deltaX", 50, -100, 100); IHistogram1D BottomdistY = aida.histogram1D("Bottom deltaY", 50, -40, 40); IHistogram2D BottomxEcalVsTrk = aida.histogram2D("Bottom X ECal Vs Track", 100, -400, 400, 100, -400, 400); @@ -429,7 +667,10 @@ bot2.region(2).plot(BottomxEcalVsTrk); bot2.region(5).plot(BottomyEcalVsTrk); -// ****************************************************************** + if(showPlots) bot2.show(); + + + // ****************************************************************** top3 = fac.createPlotterFactory().create("Top ECal Plots"); top3.setTitle("Top ECal More Correlations"); IPlotterStyle stop3 = top3.style(); @@ -440,12 +681,14 @@ top3.createRegions(1, 2); //topFrame.addPlotter(top3); - IHistogram2D topdistXvsX = aida.histogram2D("Top deltaX vs X", 51, -400, 400, 25, -400, 400); + IHistogram2D topdistXvsX = aida.histogram2D("Top deltaX vs X", 51, -400, 400, 25, -100, 100); IHistogram2D topdistYvsY = aida.histogram2D("Top deltaY vs Y", 51, 0, 100, 25, -40, 40); top3.region(0).plot(topdistXvsX); top3.region(1).plot(topdistYvsY); + if(showPlots) top3.show(); + bot3 = fac.createPlotterFactory().create("Bottom ECal Plots"); bot3.setTitle("Bottom ECal More Correlations"); IPlotterStyle sbot3 = bot3.style(); @@ -456,12 +699,72 @@ bot3.createRegions(1, 2); //bottomFrame.addPlotter(bot3); - IHistogram2D botdistXvsX = aida.histogram2D("Bottom deltaX vs X", 51, -400, 400, 25, -400, 400); + IHistogram2D botdistXvsX = aida.histogram2D("Bottom deltaX vs X", 51, -400, 400, 25, -100, 100); IHistogram2D botdistYvsY = aida.histogram2D("Bottom deltaY vs Y", 51, -100, 0, 25, -40, 40); bot3.region(0).plot(botdistXvsX); bot3.region(1).plot(botdistYvsY); + if(showPlots) bot3.show(); + + // ****************************************************************** + top4 = fac.createPlotterFactory().create("Track Matching Plots"); + top4.setTitle("Track Matching Plots"); + IPlotterStyle stop4 = top4.style(); + stop4.dataStyle().fillStyle().setColor("green"); + stop4.dataStyle().errorBarStyle().setVisible(false); + stop4.setParameter("hist2DStyle", "colorMap"); + stop4.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); + top4.createRegions(2, 3); + //topFrame.addPlotter(top4); + + IHistogram1D trackmatchN = aida.histogram1D("Tracks matched", 3, 0, 3); + IHistogram1D toptrackmatchN = aida.histogram1D("Tracks matched Top", 3, 0, 3); + IHistogram1D bottrackmatchN = aida.histogram1D("Tracks matched Bottom", 3, 0, 3); + IHistogram1D trackmatchN2 = aida.histogram1D("Tracks matched (Pz>0.8)", 3, 0, 3); + IHistogram1D toptrackmatchN2 = aida.histogram1D("Tracks matched Top (Pz>0.8)", 3, 0, 3); + IHistogram1D bottrackmatchN2 = aida.histogram1D("Tracks matched Bottom (Pz>0.8)", 3, 0, 3); + + top4.region(0).plot(trackmatchN); + top4.region(1).plot(toptrackmatchN); + top4.region(2).plot(bottrackmatchN); + top4.region(3).plot(trackmatchN2); + top4.region(4).plot(toptrackmatchN2); + top4.region(5).plot(bottrackmatchN2); + + if(showPlots) top4.show(); + + // ****************************************************************** + top44 = fac.createPlotterFactory().create("e+e- Plots"); + top44.setTitle("e+e- Plots"); + IPlotterStyle stop44 = top44.style(); + stop44.dataStyle().fillStyle().setColor("green"); + stop44.dataStyle().errorBarStyle().setVisible(false); + stop44.setParameter("hist2DStyle", "colorMap"); + stop44.dataStyle().fillStyle().setParameter("colorMapScheme", "rainbow"); + top44.createRegions(2,4); + //topFrame.addPlotter(top44); + + IHistogram2D trackPCorr = aida.histogram2D("p(e-) vs p(e+) max", 25, 0, 1.2, 25, 0, 1.2); + IHistogram1D ne = aida.histogram1D("n(e-)", 3, 0, 3); + IHistogram1D np = aida.histogram1D("n(e+)", 3, 0, 3); + IHistogram1D pem = aida.histogram1D("p(e-) max", 25, 0, 1.5); + IHistogram1D pe = aida.histogram1D("p(e-)", 25, 0, 1.5); + IHistogram1D ppm = aida.histogram1D("p(e+) max", 25, 0, 1.5); + IHistogram1D pp = aida.histogram1D("p(e+)", 25, 0, 1.5); + + top44.region(0).plot(trackPCorr); + top44.region(1).plot(ne); + top44.region(2).plot(np); + top44.region(3).plot(pe); + top44.region(4).plot(pp); + top44.region(5).plot(pem); + top44.region(6).plot(ppm); + + if(showPlots) top44.show(); + + + // ****************************************************************** plotter5 = fac.createPlotterFactory().create("HPS Hit Positions"); plotter5.setTitle("Hit Positions: Top"); @@ -480,7 +783,9 @@ plotter5.region(0).plot(l1Pos); plotter5.region(1).plot(l7Pos); - + + if(showPlots) plotter5.show(); + plotter5_1 = fac.createPlotterFactory().create("HPS Hit Positions"); plotter5_1.setTitle("Hit Positions: Bottom"); //plotterFrame.addPlotter(plotter5_1); @@ -491,10 +796,13 @@ style5_1.dataStyle().errorBarStyle().setVisible(false); plotter5_1.createRegions(1, 2); + IHistogram2D l1PosBot = aida.histogram2D("Layer 1 HTH Position: Bottom", 50, -55, 55, 55, -25, 25); IHistogram2D l7PosBot = aida.histogram2D("Layer 7 HTH Position: Bottom", 50, -55, 55, 55, -25, 25); plotter5_1.region(0).plot(l1PosBot); plotter5_1.region(1).plot(l7PosBot); + + if(showPlots) plotter5_1.show(); plotter55 = fac.createPlotterFactory().create("HPS Hit Positions"); plotter55.setTitle("Helical Track Hits"); @@ -510,6 +818,8 @@ plotter55.region(0).plot(avgLayersTopPlot); plotter55.region(1).plot(avgLayersBottomPlot); + + if(showPlots) plotter55.show(); plotter6 = fac.createPlotterFactory().create("HPS ECAL Hit Positions"); plotter6.setTitle("ECAL Positions"); @@ -525,10 +835,10 @@ IHistogram2D botECal = aida.histogram2D("Bottom ECal Cluster Position", 50, -400, 400, 10, -100, 0); IHistogram2D topECal1 = aida.histogram2D("Top ECal Cluster Position (>0 tracks)", 50, -400, 400, 10, 0, 100); IHistogram2D botECal1 = aida.histogram2D("Bottom ECal Cluster Position (>0 tracks)", 50, -400, 400, 10, -100, 0); - IHistogram2D topECal2 = aida.histogram2D("Top ECal Cluster Position (E>100,>0 tracks)", 50, -400, 400, 10, 0, 100); - IHistogram2D botECal2 = aida.histogram2D("Bottom ECal Cluster Position (E>100,>0 tracks)", 50, -400, 400, 10, -100, 0); - IHistogram2D topECal3 = aida.histogram2D("Top ECal Cluster Position w_E (E>100,>0 tracks)", 50, -400, 400, 10, 0, 100); - IHistogram2D botECal3 = aida.histogram2D("Bottom ECal Cluster Position w_E (E>100,>0 tracks)", 50, -400, 400, 10, -100, 0); + IHistogram2D topECal2 = aida.histogram2D("Top ECal Cluster Position (E>0.1,>0 tracks)", 50, -400, 400, 10, 0, 100); + IHistogram2D botECal2 = aida.histogram2D("Bottom ECal Cluster Position (E>0.1,>0 tracks)", 50, -400, 400, 10, -100, 0); + IHistogram2D topECal3 = aida.histogram2D("Top ECal Cluster Position w_E (E>0.1,>0 tracks)", 50, -400, 400, 10, 0, 100); + IHistogram2D botECal3 = aida.histogram2D("Bottom ECal Cluster Position w_E (E>0.1,>0 tracks)", 50, -400, 400, 10, -100, 0); plotter6.region(0).plot(topECal); plotter6.region(1).plot(botECal); @@ -538,13 +848,31 @@ plotter6.region(5).plot(botECal2); plotter6.region(6).plot(topECal3); plotter6.region(7).plot(botECal3); - - //plotterFrame.pack(); - //plotterFrame.setVisible(true); - //topFrame.pack(); - //topFrame.setVisible(true); - //bottomFrame.pack(); - //bottomFrame.setVisible(true); + + if(showPlots) plotter6.show(); + + + plotter66 = fac.createPlotterFactory().create("HPS ECAL Basic Plots"); + plotter66.setTitle("ECAL Basic Plots"); + //plotterFrame.addPlotter(plotter6); + IPlotterStyle style66 = plotter66.style(); + style66.dataStyle().fillStyle().setColor("yellow"); + style66.dataStyle().errorBarStyle().setVisible(false); + plotter66.createRegions(2, 2); + + IHistogram1D topECalE = aida.histogram1D("Top ECal Cluster Energy", 50, 0, 2); + IHistogram1D botECalE = aida.histogram1D("Bottom ECal Cluster Energy", 50, 0, 2); + IHistogram1D topECalN = aida.histogram1D("Number of Clusters Top", 6, 0, 6); + IHistogram1D botECalN = aida.histogram1D("Number of Clusters Bot", 6, 0, 6); + + plotter66.region(0).plot(topECalE); + plotter66.region(1).plot(botECalE); + plotter66.region(2).plot(botECalN); + plotter66.region(3).plot(topECalN); + + if(showPlots) plotter66.show(); + + plotter7 = fac.createPlotterFactory().create("HPS ECAL Hit Positions"); plotter7.setTitle("Basic Misc Stuff"); //plotterFrame.addPlotter(plotter7); @@ -557,16 +885,59 @@ IHistogram2D quadrants = aida.histogram2D("Charge vs Slope", 2, -1, 1, 2, -1, 1); plotter7.region(0).plot(quadrants); + + if(showPlots) plotter7.show(); + + plotter8 = fac.createPlotterFactory().create("HPS Strip Hit Multiplicity"); + plotter8.setTitle("Strip Hit Multiplicity"); + //plotterFrame.addPlotter(plotter8); + IPlotterStyle style8 = plotter8.style(); + style8.dataStyle().fillStyle().setColor("yellow"); + style8.dataStyle().errorBarStyle().setVisible(false); + plotter8.createRegions(6, 6); + i=0; + for(SiSensor sensor : sensors) { + IHistogram1D resX = aida.histogram1D(sensor.getName() + " strip hits", 10, 0, 10); + plotter8.region(i).plot(resX); + i++; + } + + if(showPlots) plotter8.show(); + + + plotter9 = fac.createPlotterFactory().create("HPS Strip Hit On Track Multiplicity"); + plotter9.setTitle("Strip Hit Multiplicity"); + //plotterFrame.addPlotter(plotter9); + IPlotterStyle style9 = plotter9.style(); + style9.dataStyle().fillStyle().setColor("yellow"); + style9.dataStyle().errorBarStyle().setVisible(false); + plotter9.createRegions(6, 6); + i=0; + for(SiSensor sensor : sensors) { + IHistogram1D resX = aida.histogram1D(sensor.getName() + " strip hits on track", 3, 0, 3); + plotter9.region(i).plot(resX); + i++; + } + + if(showPlots) plotter9.show(); + } public TrackingReconstructionPlots() { + logger.setLevel(Level.WARNING); } public void setOutputPlots(String output) { this.outputPlots = output; } - + + public void setShowPlots(boolean show) { + this.showPlots = show; + } + + + public void setRawTrackerHitCollectionName(String rawTrackerHitCollectionName) { this.rawTrackerHitCollectionName = rawTrackerHitCollectionName; } @@ -594,48 +965,32 @@ // System.out.println(helicalTrackHitCollectionName + " does not exist; skipping event"); return; } - - List<HelicalTrackHit> rotList = event.get(HelicalTrackHit.class, rotatedTrackHitCollectionName); - for (HelicalTrackHit hth : rotList) { - HelicalTrackCross htc = (HelicalTrackCross) hth; -// System.out.println("TrackingReconstructionPlots::original helical track position = "+hth.getPosition()[0]+","+hth.getPosition()[1]+","+hth.getPosition()[2]); -// System.out.println("TrackingReconstructionPlots::corrected helical track position = "+htc.getCorrectedPosition().toString()); - } List<HelicalTrackHit> hthList = event.get(HelicalTrackHit.class, helicalTrackHitCollectionName); - int[] layersTop = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - int[] layersBot = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + int[] layersTop = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + int[] layersBot = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + Map<HpsSiSensor, Integer> stripHits = new HashMap<HpsSiSensor, Integer>(); for (HelicalTrackHit hth : hthList) { HelicalTrackCross htc = (HelicalTrackCross) hth; -// System.out.println("TrackingReconstructionPlots::original helical track position = "+hth.getPosition()[0]+","+hth.getPosition()[1]+","+hth.getPosition()[2]); -// System.out.println("TrackingReconstructionPlots::corrected helical track position = "+htc.getCorrectedPosition().toString()); - //These Helical Track Hits are in the JLAB frame -// htc.resetTrackDirection(); - double x = htc.getPosition()[0]; - double y = htc.getPosition()[1]; HpsSiSensor sensor = ((HpsSiSensor) ((RawTrackerHit) htc.getRawHits().get(0)).getDetectorElement()); + for(HelicalTrackStrip strip : htc.getStrips()) { + HpsSiSensor stripsensor = (HpsSiSensor) ((RawTrackerHit)strip.rawhits().get(0)).getDetectorElement(); + if(stripHits.containsKey(stripsensor)) { + stripHits.put(stripsensor, stripHits.get(stripsensor) + 1); + } else { + stripHits.put(stripsensor, 0); + } + } if(sensor.isTopLayer()){ layersTop[htc.Layer() - 1]++; - Hep3Vector sensorPos = ((SiSensor) ((RawTrackerHit) htc.getRawHits().get(0)).getDetectorElement()).getGeometry().getPosition(); - if (htc.Layer() == 1) { -// System.out.println(sensorPos.toString()); -// System.out.println("Hit X = " + x + "; Hit Y = " + y); -// aida.histogram2D("Layer 1 HTH Position: Top").fill(x - sensorPos.x(), y - sensorPos.y()); - } -// if (htc.Layer() == 7) -// aida.histogram2D("Layer 7 HTH Position: Top").fill(x - sensorPos.x(), y - sensorPos.y()); } else { layersBot[htc.Layer() - 1]++; - Hep3Vector sensorPos = ((SiSensor) ((RawTrackerHit) htc.getRawHits().get(0)).getDetectorElement()).getGeometry().getPosition(); - if (htc.Layer() == 1) { -// System.out.println(sensorPos.toString()); -// System.out.println("Hit X = " + x + "; Hit Y = " + y); -// aida.histogram2D("Layer 1 HTH Position: Bottom").fill(x - sensorPos.x(), y - sensorPos.y()); - } -// if (htc.Layer() == 7) -// aida.histogram2D("Layer 7 HTH Position: Bottom").fill(x - sensorPos.x(), y - sensorPos.y()); - } - } - for (int i = 0; i < 10; i++) { + } + } + for(Map.Entry<HpsSiSensor,Integer> sensor : stripHits.entrySet()) { + aida.histogram1D(sensor.getKey().getName() + " strip hits").fill(sensor.getValue()); + } + + for (int i = 0; i < 12; i++) { aida.profile1D("Number of Stereo Hits per layer in Top Half").fill(i + 1, layersTop[i]); aida.profile1D("Number of Stereo Hits per layer in Bottom Half").fill(i + 1, layersBot[i]); } @@ -647,15 +1002,26 @@ List<Track> tracks = event.get(Track.class, trackCollectionName); nTracks.fill(tracks.size()); + int nBotClusters = 0; + int nTopClusters = 0; if (event.hasCollection(Cluster.class, ecalCollectionName)) { List<Cluster> clusters = event.get(Cluster.class, ecalCollectionName); for (Cluster cluster : clusters) { + // Get the ix and iy indices for the seed. + final int ix = cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("ix"); + final int iy = cluster.getCalorimeterHits().get(0).getIdentifierFieldValue("iy"); + //System.out.println("cluser position = ("+cluster.getPosition()[0]+","+cluster.getPosition()[1]+") with energy = "+cluster.getEnergy()); if (cluster.getPosition()[1] > 0) { + nTopClusters++; + //System.out.println("cl " + cluster.getPosition()[0] + " " + cluster.getPosition()[1] + " ix " + ix + " iy " + iy); aida.histogram2D("Top ECal Cluster Position").fill(cluster.getPosition()[0], cluster.getPosition()[1]); + aida.histogram1D("Top ECal Cluster Energy").fill(cluster.getEnergy()); } if (cluster.getPosition()[1] < 0) { + nBotClusters++; aida.histogram2D("Bottom ECal Cluster Position").fill(cluster.getPosition()[0], cluster.getPosition()[1]); + aida.histogram1D("Bottom ECal Cluster Energy").fill(cluster.getEnergy()); } if (tracks.size() > 0) { @@ -666,30 +1032,43 @@ aida.histogram2D("Bottom ECal Cluster Position (>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1]); } - if (cluster.getEnergy() > 100) { + if (cluster.getEnergy() > 0.1) { if (cluster.getPosition()[1] > 0) { - aida.histogram2D("Top ECal Cluster Position (E>100,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1]); - aida.histogram2D("Top ECal Cluster Position w_E (E>100,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1], cluster.getEnergy()); + aida.histogram2D("Top ECal Cluster Position (E>0.1,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1]); + aida.histogram2D("Top ECal Cluster Position w_E (E>0.1,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1], cluster.getEnergy()); } if (cluster.getPosition()[1] < 0) { - aida.histogram2D("Bottom ECal Cluster Position (E>100,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1]); - aida.histogram2D("Bottom ECal Cluster Position w_E (E>100,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1], cluster.getEnergy()); + aida.histogram2D("Bottom ECal Cluster Position (E>0.1,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1]); + aida.histogram2D("Bottom ECal Cluster Position w_E (E>0.1,>0 tracks)").fill(cluster.getPosition()[0], cluster.getPosition()[1], cluster.getEnergy()); } } } } } - - List<SiTrackerHitStrip1D> stripHits = event.get(SiTrackerHitStrip1D.class, "StripClusterer_SiTrackerHitStrip1D"); - int stripClustersPerLayerTop[] = getStripClustersPerLayer(stripHits, "up"); + + aida.histogram1D("Number of Clusters Top").fill(nTopClusters); + aida.histogram1D("Number of Clusters Bot").fill(nBotClusters); + + + + + + //List<SiTrackerHitStrip1D> stripHits = event.get(SiTrackerHitStrip1D.class, "StripClusterer_SiTrackerHitStrip1D"); + //int stripClustersPerLayerTop[] = getStripClustersPerLayer(stripHits, "up"); //int stripClustersPerLayerBottom[] = getStripClustersPerLayer(stripHits,"down"); - boolean hasSingleStripClusterPerLayer = singleStripClusterPerLayer(stripClustersPerLayerTop); - + //boolean hasSingleStripClusterPerLayer = singleStripClusterPerLayer(stripClustersPerLayerTop); + + Map<Track, Cluster> eCanditates = new HashMap<Track, Cluster>(); + Map<Track, Cluster> pCanditates = new HashMap<Track, Cluster>(); + + int ntracksTop = 0; + int ntracksBot = 0; + for (Track trk : tracks) { - boolean isSingleHitPerLayerTrack = singleTrackHitPerLayer(trk); + //boolean isSingleHitPerLayerTrack = singleTrackHitPerLayer(trk); aida.histogram1D("Track Momentum (Px)").fill(trk.getTrackStates().get(0).getMomentum()[1]); aida.histogram1D("Track Momentum (Py)").fill(trk.getTrackStates().get(0).getMomentum()[2]); @@ -698,24 +1077,17 @@ aida.histogram1D("Hits per Track").fill(trk.getTrackerHits().size()); SeedTrack stEle = (SeedTrack) trk; - SeedCandidate seedEle = stEle.getSeedCandidate(); - HelicalTrackFit ht = seedEle.getHelix(); - HelixConverter converter = new HelixConverter(0); - StraightLineTrack slt = converter.Convert(ht); + SeedCandidate seedCandidate = stEle.getSeedCandidate(); + HelicalTrackFit helicalTrackFit = seedCandidate.getHelix(); + StraightLineTrack slt = converter.Convert(helicalTrackFit); Hep3Vector posAtEcal = TrackUtils.getTrackPositionAtEcal(trk); - + aida.histogram1D("X (mm) @ Z=-60cm").fill(slt.getYZAtX(BeamlineConstants.HARP_POSITION_TESTRUN)[0]); //this is y in the tracker frame aida.histogram1D("Y (mm) @ Z=-60cm").fill(slt.getYZAtX(BeamlineConstants.HARP_POSITION_TESTRUN)[1]); //this is z in the tracker frame - //double sECAL = HelixUtils.PathToXPlane(ht, zEcal, 3000, 1).get(0); aida.histogram1D("X (mm) @ Z=-150cm").fill(slt.getYZAtX(zAtColl)[0]); aida.histogram1D("Y (mm) @ Z=-150cm").fill(slt.getYZAtX(zAtColl)[1]); - //Straight line after field-region??? - //HelixConverter converterEcal = new HelixConverter(zAtDownStrPairSpec); - //StraightLineTrack sltEcal = converterEcal.Convert(ht); -// double sECAL = HelixUtils.PathToXPlane(ht, zEcal, 3000, 1).get(0); -// Hep3Vector posonhelix = HelixUtils.PointOnHelix(ht, sECAL);//position in tracker coordinates! aida.histogram1D("X (mm) @ ECAL").fill(posAtEcal.x()); aida.histogram1D("Y (mm) @ ECAL").fill(posAtEcal.y()); if (trk.getTrackStates().get(0).getMomentum()[0] > 1.0) { @@ -742,39 +1114,84 @@ aida.histogram1D("Top Track Momentum (Py)").fill(trk.getTrackStates().get(0).getMomentum()[2]); aida.histogram1D("Top Track Momentum (Pz)").fill(trk.getTrackStates().get(0).getMomentum()[0]); aida.histogram1D("Top Track Chi2").fill(trk.getChi2()); + + aida.histogram1D("d0 Top").fill(trk.getTrackStates().get(0).getParameter(ParameterName.d0.ordinal())); + aida.histogram1D("sinphi Top").fill(Math.sin(trk.getTrackStates().get(0).getParameter(ParameterName.phi0.ordinal()))); + aida.histogram1D("omega Top").fill(trk.getTrackStates().get(0).getParameter(ParameterName.omega.ordinal())); + aida.histogram1D("tan(lambda) Top").fill(trk.getTrackStates().get(0).getParameter(ParameterName.tanLambda.ordinal())); + aida.histogram1D("z0 Top").fill(trk.getTrackStates().get(0).getParameter(ParameterName.z0.ordinal())); + ntracksTop++; } else { aida.histogram1D("Bottom Track Momentum (Px)").fill(trk.getTrackStates().get(0).getMomentum()[1]); aida.histogram1D("Bottom Track Momentum (Py)").fill(trk.getTrackStates().get(0).getMomentum()[2]); aida.histogram1D("Bottom Track Momentum (Pz)").fill(trk.getTrackStates().get(0).getMomentum()[0]); aida.histogram1D("Bottom Track Chi2").fill(trk.getChi2()); + + aida.histogram1D("d0 Bottom").fill(trk.getTrackStates().get(0).getParameter(ParameterName.d0.ordinal())); + aida.histogram1D("sinphi Bottom").fill(Math.sin(trk.getTrackStates().get(0).getParameter(ParameterName.phi0.ordinal()))); + aida.histogram1D("omega Bottom").fill(trk.getTrackStates().get(0).getParameter(ParameterName.omega.ordinal())); + aida.histogram1D("tan(lambda) Bottom").fill(trk.getTrackStates().get(0).getParameter(ParameterName.tanLambda.ordinal())); + aida.histogram1D("z0 Bottom").fill(trk.getTrackStates().get(0).getParameter(ParameterName.z0.ordinal())); + ntracksBot++; } List<TrackerHit> hitsOnTrack = trk.getTrackerHits(); + Map<HpsSiSensor, Integer> stripHitsOnTrack = new HashMap<HpsSiSensor, Integer>(); + for (TrackerHit hit : hitsOnTrack) { + HelicalTrackHit htc = (HelicalTrackHit) hit; HelicalTrackCross htcross = (HelicalTrackCross) htc; - double sHit = ht.PathMap().get(htc); - Hep3Vector posonhelix = HelixUtils.PointOnHelix(ht, sHit); - + double sHit = helicalTrackFit.PathMap().get(htc); + Hep3Vector posonhelix = HelixUtils.PointOnHelix(helicalTrackFit, sHit); + boolean isTopLayer = false; + + + + //HpsSiSensor sensor = ((HpsSiSensor) ((RawTrackerHit) htc.getRawHits().get(0)).getDetectorElement()); + for(HelicalTrackStrip strip : htcross.getStrips()) { + HpsSiSensor sensor = ((HpsSiSensor) ((RawTrackerHit) strip.rawhits().get(0)).getDetectorElement()); + if(sensor.isTopLayer()) isTopLayer = true; + else isTopLayer=false; + HelicalTrackStripGbl stripGbl = new HelicalTrackStripGbl(strip, true); + Map<String, Double> stripResiduals = TrackUtils.calculateLocalTrackHitResiduals(helicalTrackFit, stripGbl, 0.,0.,_bfield); + logger.info("Sensor " + sensor.getName() + " ures = " + stripResiduals.get("ures")); + aida.histogram1D(sensor.getName() + " strip residual (mm)").fill(stripResiduals.get("ures")); + + + if(stripHitsOnTrack.containsKey(sensor)) { + stripHitsOnTrack.put(sensor, stripHitsOnTrack.get(sensor) + 1); + } else { + stripHitsOnTrack.put(sensor, 1); + } + } + + + + + double yTr = posonhelix.y(); double zTr = posonhelix.z(); int layer = htc.Layer(); - String modNum = "Module X "; + String modNum = "Layer X "; if (layer == 1) { - modNum = "Module 1 "; + modNum = "Layer 1 "; } if (layer == 3) { - modNum = "Module 2 "; + modNum = "Layer 2 "; } if (layer == 5) { - modNum = "Module 3 "; + modNum = "Layer 3 "; } if (layer == 7) { - modNum = "Module 4 "; + modNum = "Layer 4 "; } if (layer == 9) { - modNum = "Module 5 "; - } - SymmetricMatrix cov = htc.getCorrectedCovMatrix(); + modNum = "Layer 5 "; + } + if (layer == 11) { + modNum = "Layer 6 "; + } + //SymmetricMatrix cov = htc.getCorrectedCovMatrix(); aida.histogram1D(modNum + "Residual X(mm)").fill(htcross.getCorrectedPosition().y() - yTr);//these hits should be rotated track hits already aida.histogram1D(modNum + "Residual Y(mm)").fill(htcross.getCorrectedPosition().z() - zTr);//these hits should be rotated track hits already @@ -788,10 +1205,9 @@ aida.histogram1D(modNum + "Residual Y(mm) Bottom").fill(htcross.getCorrectedPosition().z() - zTr);//these hits should be rotated track hits already } - HpsSiSensor sensor = ((HpsSiSensor) ((RawTrackerHit) htc.getRawHits().get(0)).getDetectorElement()); double x = htcross.getCorrectedPosition().y(); double y = htcross.getCorrectedPosition().z(); - if(sensor.isTopLayer()) { + if(isTopLayer) { layersTop[htc.Layer() - 1]++; Hep3Vector sensorPos = ((SiSensor) ((RawTrackerHit) htc.getRawHits().get(0)).getDetectorElement()).getGeometry().getPosition(); if (htc.Layer() == 1) { @@ -814,87 +1230,215 @@ aida.histogram2D("Layer 7 HTH Position: Bottom").fill(x - sensorPos.x(), y - sensorPos.y()); } } - /* - List<RawTrackerHit> rawHits = hit.getRawHits(); - for (RawTrackerHit rawHit : rawHits) { - ChannelConstants constants = HPSSVTCalibrationConstants.getChannelConstants((SiSensor) rawHit.getDetectorElement(), rawHit.getIdentifierFieldValue("strip")); - HPSShapeFitParameters fit = _shaper.fitShape(rawHit, constants); - double amp = fit.getAmp(); - - aida.histogram1D("Amp (HitOnTrack)").fill(amp); - if (trk.getTrackStates().get(0).getMomentum()[0] > 1) - aida.histogram1D("Amp Pz>1000 (HitOnTrack)").fill(amp); - } - */ - boolean doAmplitudePlots = false; + + boolean doAmplitudePlots = true; if(doAmplitudePlots) { for (HelicalTrackStrip hts : htcross.getStrips()) { double clusterSum = 0; + double clusterT0 = 0; + int nHitsCluster = 0; + for (RawTrackerHit rawHit : (List<RawTrackerHit>) hts.rawhits()) { - for (ShapeFitParameters fit : _shaper.fitShape(rawHit,new PulseShape.CRRC())) { - double amp = fit.getAmp(); - clusterSum += amp; - aida.histogram1D("Amp (HitOnTrack)").fill(amp); - if (trk.getTrackStates().get(0).getMomentum()[0] > 1) { - aida.histogram1D("Amp Pz>1000 (HitOnTrack)").fill(amp); + if(event.hasCollection(LCRelation.class, "SVTFittedRawTrackerHits")) { + List<LCRelation> fittedHits = event.get(LCRelation.class, "SVTFittedRawTrackerHits"); + for(LCRelation fittedHit : fittedHits) { + if(rawHit.equals((RawTrackerHit)fittedHit.getFrom())) { + double amp = FittedRawTrackerHit.getAmp(fittedHit); + double t0 = FittedRawTrackerHit.getT0(fittedHit); + //System.out.println("to="+t0 + " amp=" + amp); + aida.histogram1D("Amp (HitOnTrack)").fill(amp); + if (trk.getTrackStates().get(0).getMomentum()[0] > 0.8) { + aida.histogram1D("Amp Pz>0.8 (HitOnTrack)").fill(amp); + } + aida.histogram1D("t0 (HitOnTrack)").fill(t0); + if (trk.getTrackStates().get(0).getMomentum()[0] > 0.8) { + aida.histogram1D("t0 Pz>0.8 (HitOnTrack)").fill(t0); + } + clusterSum += amp; + clusterT0 += t0; + nHitsCluster++; + } + } } + } + + aida.histogram1D("Hits in Cluster (HitOnTrack)").fill(nHitsCluster); + aida.histogram1D("Cluster Amp (HitOnTrack)").fill(clusterSum); + if (trk.getTrackStates().get(0).getMomentum()[0] > 0.8) { + aida.histogram1D("Cluster Amp Pz>0.8 (HitOnTrack)").fill(clusterSum); + } + if(nHitsCluster>0) { + aida.histogram1D("Cluster t0 (HitOnTrack)").fill(clusterT0/nHitsCluster); + if (trk.getTrackStates().get(0).getMomentum()[0] > 0.8) { + aida.histogram1D("Cluster t0 Pz>0.8 (HitOnTrack)").fill(clusterT0/nHitsCluster); } } - aida.histogram1D("Amp (CluOnTrack)").fill(clusterSum); - if (trk.getTrackStates().get(0).getMomentum()[0] > 1) { - aida.histogram1D("Amp Pz>1000 (CluOnTrack)").fill(clusterSum); - } - } - } - } + + } + } + } + + for(Map.Entry<HpsSiSensor,Integer> sensor : stripHitsOnTrack.entrySet()) { + aida.histogram1D(sensor.getKey().getName() + " strip hits on track").fill(sensor.getValue()); + } + + + Cluster clust = null; if(event.hasCollection(Cluster.class,ecalCollectionName)) { List<Cluster> clusters = event.get(Cluster.class, ecalCollectionName); - Cluster clust = findClosestCluster(posAtEcal, clusters); - - // if (clust != null) { - if (clust != null) { - - posAtEcal = TrackUtils.extrapolateTrack(trk, clust.getPosition()[2]);//.positionAtEcal(); - - aida.histogram2D("Energy Vs Momentum").fill(clust.getEnergy(), trk.getTrackStates().get(0).getMomentum()[0] * 1000.0); - aida.histogram1D("Energy Over Momentum").fill(clust.getEnergy() / (trk.getTrackStates().get(0).getMomentum()[0] * 1000.0)); - aida.histogram1D("deltaX").fill(clust.getPosition()[0] - posAtEcal.x()); - aida.histogram1D("deltaY").fill(clust.getPosition()[1] - posAtEcal.y()); - // if (trk.getTrackStates().get(0).getMomentum()[0] > 1.0) { - // aida.histogram1D("deltaX (Pz>1)").fill(clust.getPosition()[0] - posAtEcal.y()); - // aida.histogram1D("deltaY (Pz>1)").fill(clust.getPosition()[1] - posAtEcal.z()); - // } - aida.histogram2D("X ECal Vs Track").fill(clust.getPosition()[0], posAtEcal.x()); - aida.histogram2D("Y ECal Vs Track").fill(clust.getPosition()[1], posAtEcal.y()); - if (isTop == 0) { - aida.histogram2D("Top Energy Vs Momentum").fill(clust.getEnergy(), trk.getTrackStates().get(0).getMomentum()[0] * 1000.0); - // aida.histogram2D("Top Energy Vs Momentum").fill(posAtEcal.y(), trk.getTrackStates().get(0).getMomentum()[0] * 1000.0); - aida.histogram1D("Top Energy Over Momentum").fill(clust.getEnergy() / (trk.getTrackStates().get(0).getMomentum()[0] * 1000.0)); - aida.histogram1D("Top deltaX").fill(clust.getPosition()[0] - posAtEcal.x()); - aida.histogram1D("Top deltaY").fill(clust.getPosition()[1] - posAtEcal.y()); - aida.histogram2D("Top deltaX vs X").fill(clust.getPosition()[0], clust.getPosition()[0] - posAtEcal.x()); - aida.histogram2D("Top deltaY vs Y").fill(clust.getPosition()[1], clust.getPosition()[1] - posAtEcal.y()); - aida.histogram2D("Top X ECal Vs Track").fill(clust.getPosition()[0], posAtEcal.x()); - aida.histogram2D("Top Y ECal Vs Track").fill(clust.getPosition()[1], posAtEcal.y()); - } else { - aida.histogram2D("Bottom Energy Vs Momentum").fill(clust.getEnergy(), trk.getTrackStates().get(0).getMomentum()[0] * 1000.0); - aida.histogram1D("Bottom Energy Over Momentum").fill(clust.getEnergy() / (trk.getTrackStates().get(0).getMomentum()[0] * 1000.0)); - aida.histogram1D("Bottom deltaX").fill(clust.getPosition()[0] - posAtEcal.x()); - aida.histogram1D("Bottom deltaY").fill(clust.getPosition()[1] - posAtEcal.y()); - aida.histogram2D("Bottom deltaX vs X").fill(clust.getPosition()[0], clust.getPosition()[0] - posAtEcal.x()); - aida.histogram2D("Bottom deltaY vs Y").fill(clust.getPosition()[1], clust.getPosition()[1] - posAtEcal.y()); - aida.histogram2D("Bottom X ECal Vs Track").fill(clust.getPosition()[0], posAtEcal.x()); - aida.histogram2D("Bottom Y ECal Vs Track").fill(clust.getPosition()[1], posAtEcal.y()); - } - - } - } - } + Cluster cand_clust = findClosestCluster(posAtEcal, clusters); + + if (cand_clust != null) { + + // track matching requirement + if(Math.abs( posAtEcal.x() - cand_clust.getPosition()[0])<30.0 && + Math.abs( posAtEcal.y() - cand_clust.getPosition()[1])<30.0) + { + clust = cand_clust; + if(trk.getCharge()<0) pCanditates.put(trk, clust); + else eCanditates.put(trk, clust); + + posAtEcal = TrackUtils.extrapolateTrack(trk, clust.getPosition()[2]);//.positionAtEcal(); + + aida.histogram2D("Energy Vs Momentum").fill(clust.getEnergy(), trk.getTrackStates().get(0).getMomentum()[0]); + aida.histogram1D("Energy Over Momentum").fill(clust.getEnergy() / (trk.getTrackStates().get(0).getMomentum()[0] )); + aida.histogram1D("deltaX").fill(clust.getPosition()[0] - posAtEcal.x()); + aida.histogram1D("deltaY").fill(clust.getPosition()[1] - posAtEcal.y()); + aida.histogram2D("X ECal Vs Track").fill(clust.getPosition()[0], posAtEcal.x()); + aida.histogram2D("Y ECal Vs Track").fill(clust.getPosition()[1], posAtEcal.y()); + + if (isTop == 0) { + aida.histogram1D("Tracks matched Top").fill(1); + if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){ + aida.histogram1D("Tracks matched Top (Pz>0.8)").fill(1); + } + + aida.histogram2D("Top Energy Vs Momentum").fill(clust.getEnergy(), trk.getTrackStates().get(0).getMomentum()[0] ); + // aida.histogram2D("Top Energy Vs Momentum").fill(posAtEcal.y(), trk.getTrackStates().get(0).getMomentum()[0]); + aida.histogram1D("Top Energy Over Momentum").fill(clust.getEnergy() / (trk.getTrackStates().get(0).getMomentum()[0])); + aida.histogram1D("Top deltaX").fill(clust.getPosition()[0] - posAtEcal.x()); + aida.histogram1D("Top deltaY").fill(clust.getPosition()[1] - posAtEcal.y()); + aida.histogram2D("Top deltaX vs X").fill(clust.getPosition()[0], clust.getPosition()[0] - posAtEcal.x()); + aida.histogram2D("Top deltaY vs Y").fill(clust.getPosition()[1], clust.getPosition()[1] - posAtEcal.y()); + aida.histogram2D("Top X ECal Vs Track").fill(clust.getPosition()[0], posAtEcal.x()); + aida.histogram2D("Top Y ECal Vs Track").fill(clust.getPosition()[1], posAtEcal.y()); + } else { + aida.histogram1D("Tracks matched Bottom").fill(1); + if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){ + aida.histogram1D("Tracks matched Bottom (Pz>0.8)").fill(1); + } + aida.histogram2D("Bottom Energy Vs Momentum").fill(clust.getEnergy(), trk.getTrackStates().get(0).getMomentum()[0] ); + aida.histogram1D("Bottom Energy Over Momentum").fill(clust.getEnergy() / (trk.getTrackStates().get(0).getMomentum()[0])); + aida.histogram1D("Bottom deltaX").fill(clust.getPosition()[0] - posAtEcal.x()); + aida.histogram1D("Bottom deltaY").fill(clust.getPosition()[1] - posAtEcal.y()); + aida.histogram2D("Bottom deltaX vs X").fill(clust.getPosition()[0], clust.getPosition()[0] - posAtEcal.x()); + aida.histogram2D("Bottom deltaY vs Y").fill(clust.getPosition()[1], clust.getPosition()[1] - posAtEcal.y()); + aida.histogram2D("Bottom X ECal Vs Track").fill(clust.getPosition()[0], posAtEcal.x()); + aida.histogram2D("Bottom Y ECal Vs Track").fill(clust.getPosition()[1], posAtEcal.y()); + } + } + } + } + + if (clust != null) { + aida.histogram1D("Tracks matched").fill(0); + if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){ + aida.histogram1D("Tracks matched (Pz>0.8)").fill(0); + } + if(isTop == 0) { + aida.histogram1D("Tracks matched Top").fill(0); + if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){ + aida.histogram1D("Tracks matched Top (Pz>0.8)").fill(0); + } + } else { + aida.histogram1D("Tracks matched Bottom").fill(0); + if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){ + aida.histogram1D("Tracks matched Bottom (Pz>0.8)").fill(0); + } + } + } else { + aida.histogram1D("Tracks matched").fill(1); + if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){ + aida.histogram1D("Tracks matched (Pz>0.8)").fill(1); + } + + if (isTop == 0) { + aida.histogram1D("Tracks matched Top").fill(1); + if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){ + aida.histogram1D("Tracks matched Top (Pz>0.8)").fill(1); + } + } else { + aida.histogram1D("Tracks matched Bottom").fill(1); + if(trk.getTrackStates().get(0).getMomentum()[0] > 0.8){ + aida.histogram1D("Tracks matched Bottom (Pz>0.8)").fill(1); + } + } + + } + + } + + nTracksBot.fill(ntracksBot); + nTracksTop.fill(ntracksTop); + + // e+/e- + Map.Entry<Track, Cluster> ecand_highestP = null; + double e_pmax = -1; + Map.Entry<Track, Cluster> pcand_highestP = null; + double p_pmax = -1; + for(Map.Entry<Track, Cluster> ecand : eCanditates.entrySet()) { + double p = getMomentum(ecand.getKey()); + aida.histogram1D("p(e-)").fill(p); + if(ecand_highestP == null ) { + ecand_highestP = ecand; + e_pmax = getMomentum(ecand_highestP.getKey()); + } else { + if(p > e_pmax) { + ecand_highestP = ecand; + e_pmax = getMomentum(ecand_highestP.getKey()); + } + } + } + + for(Map.Entry<Track, Cluster> pcand : pCanditates.entrySet()) { + double p = getMomentum(pcand.getKey()); + aida.histogram1D("p(e+)").fill(p); + if(pcand_highestP == null ) { + pcand_highestP = pcand; + p_pmax = getMomentum(pcand_highestP.getKey()); + } else { + if(p > p_pmax) { + pcand_highestP = pcand; + p_pmax = getMomentum(pcand_highestP.getKey()); + } + } + } + + aida.histogram1D("n(e-)").fill(eCanditates.size()); + aida.histogram1D("n(e+)").fill(pCanditates.size()); + if(ecand_highestP!=null) { + aida.histogram1D("p(e-) max").fill(e_pmax); + } + if(pcand_highestP!=null) { + aida.histogram1D("p(e+) max").fill(p_pmax); + } + if(ecand_highestP!=null && pcand_highestP!=null) { + aida.histogram2D("p(e-) vs p(e+) max").fill(e_pmax, p_pmax); + } + + + } + + private double getMomentum(Track trk) { + double p = Math.sqrt(trk.getTrackStates().get(0).getMomentum()[0]*trk.getTrackStates().get(0).getMomentum()[0] + + trk.getTrackStates().get(0).getMomentum()[1]*trk.getTrackStates().get(0).getMomentum()[1] + + trk.getTrackStates().get(0).getMomentum()[2]*trk.getTrackStates().get(0).getMomentum()[2]); + return p; } public int[] getTrackHitsPerLayer(Track trk) { - int n[] = {0, 0, 0, 0, 0}; + int n[] = {0, 0, 0, 0, 0, 0}; List<TrackerHit> hitsOnTrack = trk.getTrackerHits(); int layer; for (TrackerHit hit : hitsOnTrack) { @@ -935,8 +1479,8 @@ String name; int l; int i; - int n[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - boolean ddd = true; + int n[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + boolean ddd = false; if (ddd) { System.out.println("Get # hits per layer on side \"" + side + "\""); @@ -1001,7 +1545,7 @@ System.out.println("sensor name " + name + " --> layer " + l); } - if (l < 1 || l > 10) { + if (l < 1 || l > 12) { System.out.println("This layer doesn't exist?"); throw new RuntimeException("SiSensor name " + name + " is invalid?"); } @@ -1027,6 +1571,8 @@ //bottomFrame.dispose(); } + + private Cluster findClosestCluster(Hep3Vector posonhelix, List<Cluster> clusters) { Cluster closest = null; double minDist = 9999; @@ -1034,16 +1580,13 @@ double[] clPos = cluster.getPosition(); double clEne = cluster.getEnergy(); double dist = Math.sqrt(Math.pow(clPos[0] - posonhelix.x(), 2) + Math.pow(clPos[1] - posonhelix.y(), 2)); //coordinates!!! -// double dist = Math.sqrt(Math.pow(clPos[1] - posonhelix.z(), 2)); //coordinates!!! - if (dist < minDist && clEne > 50) { + double distX = Math.abs(clPos[0] - posonhelix.x()); + double distY = Math.abs(clPos[1] - posonhelix.y()); + if (dist < minDist && clEne > 0.4) { closest = cluster; minDist = dist; } -// if(cluster.getEnergy()/10>500) - } -// System.out.println("Found a cluster..." + minDist); - + } return closest; - } } Modified: java/branches/HPSJAVA-488/util/pom.xml ============================================================================= --- java/branches/HPSJAVA-488/util/pom.xml (original) +++ java/branches/HPSJAVA-488/util/pom.xml Fri Jun 12 15:27:10 2015 @@ -7,7 +7,7 @@ <groupId>org.hps</groupId> <artifactId>hps-parent</artifactId> <relativePath>../parent/pom.xml</relativePath> - <version>3.3.1-SNAPSHOT</version> + <version>3.3.3-SNAPSHOT</version> </parent> <scm> <url>http://java.freehep.org/svn/repos/hps/list/java/trunk/util/</url> @@ -18,7 +18,6 @@ <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-math3</artifactId> - <version>3.2</version> </dependency> </dependencies> </project> Modified: java/branches/HPSJAVA-488/util/src/main/java/org/hps/util/BasicLogFormatter.java ============================================================================= --- java/branches/HPSJAVA-488/util/src/main/java/org/hps/util/BasicLogFormatter.java (original) +++ java/branches/HPSJAVA-488/util/src/main/java/org/hps/util/BasicLogFormatter.java Fri Jun 12 15:27:10 2015 @@ -9,9 +9,10 @@ private static final String LINE_SEPARATOR = System.getProperty("line.separator"); public String format(LogRecord record) { StringBuilder sb = new StringBuilder(); - System.out.printf("%s: format called\n",getClass().getSimpleName()); + //System.out.printf("%s: format called\n",getClass().getSimpleName()); //sb.append(new Date(record.getMillis())) - sb.append("TEST ") + //sb.append(getClass().getSimpleName() + " ") + sb.append(record.getLoggerName() + " ") .append(record.getLevel().getLocalizedName()) .append(": ") .append(formatMessage(record))