Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-27 09:18:08

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /*
0027  * ============================================================================
0028  *
0029  *       Filename:  CexmcEnergyDepositDigitizerMessenger.cc
0030  *
0031  *    Description:  energy deposit digitizer messenger
0032  *
0033  *        Version:  1.0
0034  *        Created:  29.11.2009 19:07:05
0035  *       Revision:  none
0036  *       Compiler:  gcc
0037  *
0038  *         Author:  Alexey Radkov (), 
0039  *        Company:  PNPI
0040  *
0041  * ============================================================================
0042  */
0043 
0044 #include <G4UIcmdWithADouble.hh>
0045 #include <G4UIcmdWithADoubleAndUnit.hh>
0046 #include <G4UIcmdWithAString.hh>
0047 #include <G4UIcmdWithABool.hh>
0048 #include <G4UIcmdWith3Vector.hh>
0049 #include <G4UIcmdWithoutParameter.hh>
0050 #include "CexmcEnergyDepositDigitizer.hh"
0051 #include "CexmcEnergyDepositDigitizerMessenger.hh"
0052 #include "CexmcMessenger.hh"
0053 #include "CexmcCommon.hh"
0054 
0055 
0056 CexmcEnergyDepositDigitizerMessenger::CexmcEnergyDepositDigitizerMessenger(
0057         CexmcEnergyDepositDigitizer *  energyDepositDigitizer_ ) :
0058     energyDepositDigitizer( energyDepositDigitizer_ ),
0059     setMonitorThreshold( NULL ), setVetoCountersThreshold( NULL ),
0060     setLeftVetoCounterThreshold( NULL ), setRightVetoCounterThreshold( NULL ),
0061     setCalorimetersThreshold( NULL ), setLeftCalorimeterThreshold( NULL ),
0062     setRightCalorimeterThreshold( NULL ),
0063     setCalorimeterTriggerAlgorithm( NULL ),
0064     setOuterCrystalsVetoAlgorithm( NULL ), setOuterCrystalsVetoFraction( NULL ),
0065     applyFiniteCrystalResolution( NULL ), addCrystalResolutionRange( NULL ),
0066     clearCrystalResolutionData( NULL )
0067 {
0068     setMonitorThreshold = new G4UIcmdWithADoubleAndUnit(
0069             ( CexmcMessenger::monitorEDDirName + "threshold" ).c_str(), this );
0070     setMonitorThreshold->SetGuidance( "Monitor trigger threshold" );
0071     setMonitorThreshold->SetParameterName( "MonitorThreshold", false );
0072     setMonitorThreshold->SetDefaultValue( 0 );
0073     setMonitorThreshold->SetUnitCandidates( "ev keV MeV GeV" );
0074     setMonitorThreshold->SetDefaultUnit( "MeV" );
0075     setMonitorThreshold->AvailableForStates( G4State_PreInit, G4State_Idle );
0076 
0077     setVetoCountersThreshold = new G4UIcmdWithADoubleAndUnit(
0078             ( CexmcMessenger::vetoCounterEDDirName + "threshold" ).c_str(),
0079             this );
0080     setVetoCountersThreshold->SetGuidance( "Veto counters trigger threshold" );
0081     setVetoCountersThreshold->SetParameterName( "VetoCountersThreshold",
0082                                                 false );
0083     setVetoCountersThreshold->SetDefaultValue( 0 );
0084     setVetoCountersThreshold->SetUnitCandidates( "ev keV MeV GeV" );
0085     setVetoCountersThreshold->SetDefaultUnit( "MeV" );
0086     setVetoCountersThreshold->AvailableForStates( G4State_PreInit,
0087                                                   G4State_Idle );
0088 
0089     setLeftVetoCounterThreshold = new G4UIcmdWithADoubleAndUnit(
0090             ( CexmcMessenger::vetoCounterLeftEDDirName + "threshold" ).c_str(),
0091             this );
0092     setLeftVetoCounterThreshold->SetGuidance(
0093                                     "Left veto counter trigger threshold" );
0094     setLeftVetoCounterThreshold->SetParameterName( "LeftVetoCounterThreshold",
0095                                                    false );
0096     setLeftVetoCounterThreshold->SetDefaultValue( 0 );
0097     setLeftVetoCounterThreshold->SetUnitCandidates( "ev keV MeV GeV" );
0098     setLeftVetoCounterThreshold->SetDefaultUnit( "MeV" );
0099     setLeftVetoCounterThreshold->AvailableForStates( G4State_PreInit,
0100                                                      G4State_Idle );
0101 
0102     setRightVetoCounterThreshold = new G4UIcmdWithADoubleAndUnit(
0103             ( CexmcMessenger::vetoCounterRightEDDirName + "threshold" ).c_str(),
0104             this );
0105     setRightVetoCounterThreshold->SetGuidance(
0106                                     "Right veto counter trigger threshold" );
0107     setRightVetoCounterThreshold->SetParameterName( "RightVetoCounterThreshold",
0108                                                     false );
0109     setRightVetoCounterThreshold->SetDefaultValue( 0 );
0110     setRightVetoCounterThreshold->SetUnitCandidates( "ev keV MeV GeV" );
0111     setRightVetoCounterThreshold->SetDefaultUnit( "MeV" );
0112     setRightVetoCounterThreshold->AvailableForStates( G4State_PreInit,
0113                                                       G4State_Idle );
0114 
0115     setCalorimetersThreshold = new G4UIcmdWithADoubleAndUnit(
0116             ( CexmcMessenger::calorimeterEDDirName + "threshold" ).c_str(),
0117             this );
0118     setCalorimetersThreshold->SetGuidance( "Calorimeters trigger threshold" );
0119     setCalorimetersThreshold->SetParameterName( "CalorimetersThreshold",
0120                                                 false );
0121     setCalorimetersThreshold->SetDefaultValue( 0 );
0122     setCalorimetersThreshold->SetUnitCandidates( "ev keV MeV GeV" );
0123     setCalorimetersThreshold->SetDefaultUnit( "MeV" );
0124     setCalorimetersThreshold->AvailableForStates( G4State_PreInit,
0125                                                   G4State_Idle );
0126 
0127     setLeftCalorimeterThreshold = new G4UIcmdWithADoubleAndUnit(
0128             ( CexmcMessenger::calorimeterLeftEDDirName + "threshold" ).c_str(),
0129             this );
0130     setLeftCalorimeterThreshold->SetGuidance(
0131                                     "Left calorimeter trigger threshold" );
0132     setLeftCalorimeterThreshold->SetParameterName( "LeftCalorimeterThreshold",
0133                                                    false );
0134     setLeftCalorimeterThreshold->SetDefaultValue( 0 );
0135     setLeftCalorimeterThreshold->SetUnitCandidates( "ev keV MeV GeV" );
0136     setLeftCalorimeterThreshold->SetDefaultUnit( "MeV" );
0137     setLeftCalorimeterThreshold->AvailableForStates( G4State_PreInit,
0138                                                      G4State_Idle );
0139 
0140     setRightCalorimeterThreshold = new G4UIcmdWithADoubleAndUnit(
0141             ( CexmcMessenger::calorimeterRightEDDirName + "threshold" ).c_str(),
0142             this );
0143     setRightCalorimeterThreshold->SetGuidance(
0144                                     "Right calorimeter trigger threshold" );
0145     setRightCalorimeterThreshold->SetParameterName( "RightCalorimeterThreshold",
0146                                                     false );
0147     setRightCalorimeterThreshold->SetDefaultValue( 0 );
0148     setRightCalorimeterThreshold->SetUnitCandidates( "ev keV MeV GeV" );
0149     setRightCalorimeterThreshold->SetDefaultUnit( "MeV" );
0150     setRightCalorimeterThreshold->AvailableForStates( G4State_PreInit,
0151                                                       G4State_Idle );
0152 
0153     setCalorimeterTriggerAlgorithm = new G4UIcmdWithAString(
0154             ( CexmcMessenger::detectorDirName +
0155               "calorimeterTriggerAlgorithm" ).c_str(), this );
0156     setCalorimeterTriggerAlgorithm->SetGuidance( "\n"
0157                 "    all - energy deposit in all crystals in a calorimeter\n"
0158                 "          will be checked against calorimeter threshold "
0159                           "value,\n"
0160                 "    inner - energy deposit in only inner crystals\n"
0161                 "            will be checked against calorimeter threshold "
0162                             "value" );
0163     setCalorimeterTriggerAlgorithm->SetParameterName(
0164                                         "CalorimeterTriggerAlgorithm", false );
0165     setCalorimeterTriggerAlgorithm->SetCandidates( "all inner" );
0166     setCalorimeterTriggerAlgorithm->SetDefaultValue( "inner" );
0167     setCalorimeterTriggerAlgorithm->AvailableForStates( G4State_PreInit,
0168                                                         G4State_Idle );
0169 
0170     setOuterCrystalsVetoAlgorithm = new G4UIcmdWithAString(
0171             ( CexmcMessenger::detectorDirName +
0172               "outerCrystalsVetoAlgorithm" ).c_str(), this );
0173     setOuterCrystalsVetoAlgorithm->SetGuidance( "\n"
0174                 "    none - events will not be rejected by any algorithm,\n"
0175                 "    max - reject event trigger if crystal with maximum energy "
0176                     "\n          deposit is one of outer crystals,\n"
0177                 "    fraction - reject event trigger if energy deposit "
0178                     "fraction in\n               outer crystals is more than "
0179                     "value of\n               'outerCrystalsVetoFraction'" );
0180     setOuterCrystalsVetoAlgorithm->SetParameterName(
0181                                         "OuterCrystalsVetoAlgorithm", false );
0182     setOuterCrystalsVetoAlgorithm->SetCandidates( "none max fraction" );
0183     setOuterCrystalsVetoAlgorithm->SetDefaultValue( "none" );
0184     setOuterCrystalsVetoAlgorithm->AvailableForStates( G4State_PreInit,
0185                                                        G4State_Idle );
0186 
0187     setOuterCrystalsVetoFraction = new G4UIcmdWithADouble(
0188             ( CexmcMessenger::detectorDirName +
0189               "outerCrystalsVetoFraction" ).c_str(), this );
0190     setOuterCrystalsVetoFraction->SetGuidance( "\n    Fraction of whole energy "
0191             "deposit in one calorimeter\n    that belongs to outer crystals.\n"
0192             "    If 'outerCrystalsVetoAlgorithm' is 'fraction' and\n"
0193             "    the outer crystals energy deposit fraction exceeds "
0194                 "this\n    value then event won't trigger" );
0195     setOuterCrystalsVetoFraction->SetParameterName(
0196                                         "OuterCrystalsVetoFraction", false );
0197     setOuterCrystalsVetoFraction->SetDefaultValue( 0 );
0198     setOuterCrystalsVetoFraction->AvailableForStates( G4State_PreInit,
0199                                                       G4State_Idle );
0200 
0201     applyFiniteCrystalResolution = new G4UIcmdWithABool(
0202             ( CexmcMessenger::detectorDirName +
0203               "applyFiniteCrystalResolution" ).c_str(), this );
0204     applyFiniteCrystalResolution->SetGuidance( "\n     Specify if finite "
0205             "energy resolution of the crystals\n     will be accounted" );
0206     applyFiniteCrystalResolution->SetParameterName(
0207                                         "ApplyFiniteCrystalResolution", true );
0208     applyFiniteCrystalResolution->SetDefaultValue( true );
0209     applyFiniteCrystalResolution->AvailableForStates( G4State_PreInit,
0210                                                       G4State_Idle );
0211 
0212     addCrystalResolutionRange = new G4UIcmdWith3Vector(
0213             ( CexmcMessenger::detectorDirName +
0214               "addCrystalResolutionRange" ).c_str(), this );
0215     addCrystalResolutionRange->SetGuidance( "\n     Add new energy range "
0216             "(in GeV!) with fwhm percentage\n     value of crystal resolution "
0217             "in this range" );
0218     addCrystalResolutionRange->SetParameterName(
0219             "CrystalResolutionRangeBottom", "CrystalResolutionRangeTop",
0220             "CrystalResolutionRangeValue", false );
0221     addCrystalResolutionRange->SetRange( "CrystalResolutionRangeBottom >= 0. "
0222             "&& CrystalResolutionRangeTop >= 0. && "
0223             "CrystalResolutionRangeValue >= 0." );
0224     addCrystalResolutionRange->AvailableForStates( G4State_PreInit,
0225                                                    G4State_Idle );
0226 
0227     clearCrystalResolutionData = new G4UIcmdWithoutParameter(
0228             ( CexmcMessenger::detectorDirName +
0229               "clearCrystalResolutionData" ).c_str(), this );
0230     clearCrystalResolutionData->SetGuidance( "\n     Clear all crystal "
0231               "resolution ranges.\n     Can be used to redefine crystal "
0232               "resolution data" );
0233     clearCrystalResolutionData->AvailableForStates( G4State_PreInit,
0234                                                     G4State_Idle );
0235 }
0236 
0237 
0238 CexmcEnergyDepositDigitizerMessenger::~CexmcEnergyDepositDigitizerMessenger()
0239 {
0240     delete setMonitorThreshold;
0241     delete setVetoCountersThreshold;
0242     delete setLeftVetoCounterThreshold;
0243     delete setRightVetoCounterThreshold;
0244     delete setCalorimetersThreshold;
0245     delete setLeftCalorimeterThreshold;
0246     delete setRightCalorimeterThreshold;
0247     delete setCalorimeterTriggerAlgorithm;
0248     delete setOuterCrystalsVetoAlgorithm;
0249     delete setOuterCrystalsVetoFraction;
0250     delete applyFiniteCrystalResolution;
0251     delete addCrystalResolutionRange;
0252     delete clearCrystalResolutionData;
0253 }
0254 
0255 
0256 void  CexmcEnergyDepositDigitizerMessenger::SetNewValue( G4UIcommand *  cmd,
0257                                                          G4String  value )
0258 {
0259     do
0260     {
0261         if ( cmd == setMonitorThreshold )
0262         {
0263             energyDepositDigitizer->SetMonitorThreshold(
0264                         G4UIcmdWithADoubleAndUnit::GetNewDoubleValue( value ) );
0265             break;
0266         }
0267         if ( cmd == setVetoCountersThreshold )
0268         {
0269             energyDepositDigitizer->SetVetoCountersThreshold(
0270                         G4UIcmdWithADoubleAndUnit::GetNewDoubleValue( value ) );
0271             break;
0272         }
0273         if ( cmd == setLeftVetoCounterThreshold )
0274         {
0275             energyDepositDigitizer->SetVetoCounterLeftThreshold(
0276                         G4UIcmdWithADoubleAndUnit::GetNewDoubleValue( value ) );
0277             break;
0278         }
0279         if ( cmd == setRightVetoCounterThreshold )
0280         {
0281             energyDepositDigitizer->SetVetoCounterRightThreshold(
0282                         G4UIcmdWithADoubleAndUnit::GetNewDoubleValue( value ) );
0283             break;
0284         }
0285         if ( cmd == setCalorimetersThreshold )
0286         {
0287             energyDepositDigitizer->SetCalorimetersThreshold(
0288                         G4UIcmdWithADoubleAndUnit::GetNewDoubleValue( value ) );
0289             break;
0290         }
0291         if ( cmd == setLeftCalorimeterThreshold )
0292         {
0293             energyDepositDigitizer->SetCalorimeterLeftThreshold(
0294                         G4UIcmdWithADoubleAndUnit::GetNewDoubleValue( value ) );
0295             break;
0296         }
0297         if ( cmd == setRightCalorimeterThreshold )
0298         {
0299             energyDepositDigitizer->SetCalorimeterRightThreshold(
0300                         G4UIcmdWithADoubleAndUnit::GetNewDoubleValue( value ) );
0301             break;
0302         }
0303         if ( cmd == setCalorimeterTriggerAlgorithm )
0304         {
0305             CexmcCalorimeterTriggerAlgorithm  calorimeterTriggerAlgorithm(
0306                                     CexmcAllCrystalsMakeEDTriggerThreshold );
0307             do
0308             {
0309                 if ( value == "inner" )
0310                 {
0311                     calorimeterTriggerAlgorithm =
0312                                     CexmcInnerCrystalsMakeEDTriggerThreshold;
0313                     break;
0314                 }
0315             } while ( false );
0316             energyDepositDigitizer->SetCalorimeterTriggerAlgorithm(
0317                                                 calorimeterTriggerAlgorithm );
0318             break;
0319         }
0320         if ( cmd == setOuterCrystalsVetoAlgorithm )
0321         {
0322             CexmcOuterCrystalsVetoAlgorithm  outerCrystalsVetoAlgorithm(
0323                                                     CexmcNoOuterCrystalsVeto );
0324             do
0325             {
0326                 if ( value == "max" )
0327                 {
0328                     outerCrystalsVetoAlgorithm =
0329                                         CexmcMaximumEDInASingleOuterCrystalVeto;
0330                     break;
0331                 }
0332                 if ( value == "fraction" )
0333                 {
0334                     outerCrystalsVetoAlgorithm =
0335                                         CexmcFractionOfEDInOuterCrystalsVeto;
0336                     break;
0337                 }
0338             } while ( false );
0339             energyDepositDigitizer->SetOuterCrystalsVetoAlgorithm(
0340                                                 outerCrystalsVetoAlgorithm );
0341             break;
0342         }
0343         if ( cmd == setOuterCrystalsVetoFraction )
0344         {
0345             energyDepositDigitizer->SetOuterCrystalsVetoFraction(
0346                         G4UIcmdWithADouble::GetNewDoubleValue( value ) );
0347             break;
0348         }
0349         if ( cmd == applyFiniteCrystalResolution )
0350         {
0351             energyDepositDigitizer->ApplyFiniteCrystalResolution(
0352                         G4UIcmdWithABool::GetNewBoolValue( value ) );
0353             break;
0354         }
0355         if ( cmd == addCrystalResolutionRange )
0356         {
0357             G4ThreeVector  vec( G4UIcmdWith3Vector::GetNew3VectorValue(
0358                                                                     value ) );
0359             G4double       bottom( std::min( vec.x(), vec.y() ) );
0360             G4double       top( std::max( vec.x(), vec.y() ) );
0361             energyDepositDigitizer->AddCrystalResolutionRange( bottom, top,
0362                                                                vec.z() );
0363             break;
0364         }
0365         if ( cmd == clearCrystalResolutionData )
0366         {
0367             energyDepositDigitizer->ClearCrystalResolutionData();
0368             break;
0369         }
0370     } while ( false );
0371 }
0372