File indexing completed on 2025-01-31 09:21:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044 #ifndef CEXMC_HISTO_MANAGER_HH
0045 #define CEXMC_HISTO_MANAGER_HH
0046
0047 #ifdef CEXMC_USE_ROOT
0048
0049 #include <vector>
0050 #include <map>
0051 #include <Rtypes.h>
0052 #include <G4String.hh>
0053 #include "CexmcAngularRange.hh"
0054 #include "CexmcCommon.hh"
0055
0056 class TDirectoryFile;
0057 class TH1;
0058 #ifdef CEXMC_USE_ROOTQT
0059 class TQtWidget;
0060 class TList;
0061 class G4UIsession;
0062 class G4UIQt;
0063 #endif
0064 class CexmcHistoManagerMessenger;
0065
0066
0067 enum CexmcHistoType
0068 {
0069 CexmcMomentumBP_TPT_Histo,
0070 CexmcMomentumBP_RT_Histo,
0071 CexmcMomentumIP_TPT_Histo,
0072 CexmcTPInMonitor_TPT_Histo,
0073 CexmcTPInTarget_TPT_Histo,
0074 CexmcTPInTarget_RT_Histo,
0075 CexmcRecMasses_EDT_Histo,
0076 CexmcRecMasses_RT_Histo,
0077 CexmcAbsorbedEnergy_EDT_Histo,
0078 CexmcAbsorbedEnergy_RT_Histo,
0079 CexmcHistoType_ARReal_START,
0080 CexmcRecMassOP_ARReal_RT_Histo = CexmcHistoType_ARReal_START,
0081 CexmcRecMassNOP_ARReal_RT_Histo,
0082 CexmcOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
0083 CexmcOPDPAtRightCalorimeter_ARReal_EDT_Histo,
0084 CexmcOPDPAtLeftCalorimeter_ARReal_RT_Histo,
0085 CexmcOPDPAtRightCalorimeter_ARReal_RT_Histo,
0086 CexmcRecOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
0087 CexmcRecOPDPAtRightCalorimeter_ARReal_EDT_Histo,
0088 CexmcRecOPDPAtLeftCalorimeter_ARReal_RT_Histo,
0089 CexmcRecOPDPAtRightCalorimeter_ARReal_RT_Histo,
0090 CexmcKinEnAtLeftCalorimeter_ARReal_TPT_Histo,
0091 CexmcKinEnAtRightCalorimeter_ARReal_TPT_Histo,
0092 CexmcKinEnAtLeftCalorimeter_ARReal_RT_Histo,
0093 CexmcKinEnAtRightCalorimeter_ARReal_RT_Histo,
0094 CexmcAbsEnInLeftCalorimeter_ARReal_EDT_Histo,
0095 CexmcAbsEnInRightCalorimeter_ARReal_EDT_Histo,
0096 CexmcAbsEnInLeftCalorimeter_ARReal_RT_Histo,
0097 CexmcAbsEnInRightCalorimeter_ARReal_RT_Histo,
0098 CexmcMissEnFromLeftCalorimeter_ARReal_RT_Histo,
0099 CexmcMissEnFromRightCalorimeter_ARReal_RT_Histo,
0100 CexmcKinEnOP_LAB_ARReal_TPT_Histo,
0101 CexmcKinEnOP_LAB_ARReal_RT_Histo,
0102 CexmcAngleOP_SCM_ARReal_TPT_Histo,
0103 CexmcAngleOP_SCM_ARReal_RT_Histo,
0104 CexmcRecAngleOP_SCM_ARReal_RT_Histo,
0105 CexmcDiffAngleOP_SCM_ARReal_RT_Histo,
0106 CexmcOpenAngle_ARReal_TPT_Histo,
0107 CexmcOpenAngle_ARReal_RT_Histo,
0108 CexmcRecOpenAngle_ARReal_RT_Histo,
0109 CexmcDiffOpenAngle_ARReal_RT_Histo,
0110 CexmcTPInTarget_ARReal_TPT_Histo,
0111 CexmcTPInTarget_ARReal_RT_Histo,
0112 CexmcHistoType_ARReal_END = CexmcTPInTarget_ARReal_RT_Histo,
0113 CexmcHistoType_SIZE
0114 };
0115
0116
0117 class CexmcHistoManager
0118 {
0119 private:
0120 typedef std::vector< TH1 * > CexmcHistoVector;
0121
0122 typedef std::map< CexmcHistoType, CexmcHistoVector > CexmcHistosMap;
0123
0124 typedef CexmcHistosMap::value_type CexmcHistoPair;
0125
0126 struct CexmcHistoAxisData
0127 {
0128 CexmcHistoAxisData() : nBins( 0 ), nBinsMin( 0 ), nBinsMax( 0 )
0129 {}
0130
0131 CexmcHistoAxisData( Int_t nBins_, Double_t nBinsMin_,
0132 Double_t nBinsMax_ ) :
0133 nBins( nBins_ ), nBinsMin( nBinsMin_ ), nBinsMax( nBinsMax_ )
0134 {}
0135
0136 Int_t nBins;
0137
0138 Double_t nBinsMin;
0139
0140 Double_t nBinsMax;
0141 };
0142
0143 typedef std::vector< CexmcHistoAxisData > CexmcHistoAxes;
0144
0145 enum CexmcHistoImpl
0146 {
0147 Cexmc_TH1F,
0148 Cexmc_TH2F,
0149 Cexmc_TH3F
0150 };
0151
0152 struct CexmcHistoData
0153 {
0154 CexmcHistoData() :
0155 type( CexmcHistoType_SIZE ), impl( Cexmc_TH1F ),
0156 isARHisto( false ), isARRec( false ), triggerType( CexmcTPT )
0157 {}
0158
0159 CexmcHistoData( CexmcHistoType type_, CexmcHistoImpl impl_,
0160 bool isARHisto_, bool isARRec_,
0161 CexmcTriggerType triggerType_,
0162 const G4String & name_, const G4String & title_,
0163 const CexmcHistoAxes & axes_ ) :
0164 type( type_ ), impl( impl_ ), isARHisto( isARHisto_ ),
0165 isARRec( isARRec_ ), triggerType( triggerType_ ), name( name_ ),
0166 title( title_ ), axes( axes_ )
0167 {}
0168
0169 CexmcHistoType type;
0170
0171 CexmcHistoImpl impl;
0172
0173 bool isARHisto;
0174
0175 bool isARRec;
0176
0177 CexmcTriggerType triggerType;
0178
0179 G4String name;
0180
0181 G4String title;
0182
0183 CexmcHistoAxes axes;
0184 };
0185
0186 public:
0187 static CexmcHistoManager * Instance( void );
0188
0189 static void Destroy( void );
0190
0191 private:
0192 CexmcHistoManager();
0193
0194 ~CexmcHistoManager();
0195
0196 public:
0197 void Initialize( void );
0198
0199 void SetupARHistos( const CexmcAngularRangeList & aRanges );
0200
0201 void AddARHistos( const CexmcAngularRange & aRange );
0202
0203 void Add( CexmcHistoType histoType, unsigned int index,
0204 G4double x );
0205
0206 void Add( CexmcHistoType histoType, unsigned int index, G4double x,
0207 G4double y );
0208
0209 void Add( CexmcHistoType histoType, unsigned int index, G4double x,
0210 G4double y, G4double z );
0211
0212 void Add( CexmcHistoType histoType, unsigned int index, G4int binX,
0213 G4int binY, G4double value );
0214
0215 void List( void ) const;
0216
0217 void Print( const G4String & value );
0218
0219 #ifdef CEXMC_USE_ROOTQT
0220 void Draw( const G4String & histoName,
0221 const G4String & histoDrawOptions = "" );
0222
0223 void EnableLiveHistograms( G4UIsession * session, G4bool on = true );
0224
0225 void AddHistoMenu( const G4String & handle,
0226 const G4String & label = "Histograms" );
0227
0228 void SetDrawOptions1D( const G4String & value );
0229
0230 void SetDrawOptions2D( const G4String & value );
0231
0232 void SetDrawOptions3D( const G4String & value );
0233 #endif
0234
0235 public:
0236 void SetVerboseLevel( G4int value );
0237
0238 G4int GetVerboseLevel( void ) const;
0239
0240 private:
0241 void AddHisto( const CexmcHistoData & data,
0242 const CexmcAngularRange & aRange = CexmcAngularRange() );
0243
0244 void CreateHisto( CexmcHistoVector & histoVector,
0245 CexmcHistoImpl histoImpl, const G4String & name,
0246 const G4String & title,
0247 const CexmcHistoAxes & axes );
0248
0249 #ifdef CEXMC_USE_ROOTQT
0250 void BuildMenuTree( G4UIQt * session, const G4String & menu,
0251 TList * ls );
0252
0253 void AddSubmenu( G4UIQt * session, const G4String & parent,
0254 const G4String & name, const G4String & label );
0255 #endif
0256
0257 private:
0258 TDirectoryFile * outFile;
0259
0260 private:
0261 CexmcHistosMap histos;
0262
0263 bool isInitialized;
0264
0265 G4String opName;
0266
0267 G4String nopName;
0268
0269 G4double opMass;
0270
0271 G4double nopMass;
0272
0273 G4int verboseLevel;
0274
0275 #ifdef CEXMC_USE_ROOTQT
0276 private:
0277 TQtWidget * rootCanvas;
0278
0279 G4bool areLiveHistogramsEnabled;
0280
0281 G4bool isHistoMenuInitialized;
0282
0283 G4String drawOptions1D;
0284
0285 G4String drawOptions2D;
0286
0287 G4String drawOptions3D;
0288
0289 G4String histoMenuHandle;
0290
0291 G4String histoMenuLabel;
0292 #endif
0293
0294 private:
0295 CexmcHistoManagerMessenger * messenger;
0296
0297 private:
0298 static CexmcHistoManager * instance;
0299 };
0300
0301
0302 inline void CexmcHistoManager::SetVerboseLevel( G4int value )
0303 {
0304 verboseLevel = value;
0305 }
0306
0307
0308 inline G4int CexmcHistoManager::GetVerboseLevel( void ) const
0309 {
0310 return verboseLevel;
0311 }
0312
0313 #ifdef CEXMC_USE_ROOTQT
0314
0315 inline void CexmcHistoManager::AddHistoMenu( const G4String & handle,
0316 const G4String & label )
0317 {
0318 histoMenuHandle = handle;
0319 histoMenuLabel = label;
0320 }
0321
0322
0323 inline void CexmcHistoManager::SetDrawOptions1D( const G4String & value )
0324 {
0325 drawOptions1D = value;
0326 }
0327
0328
0329 inline void CexmcHistoManager::SetDrawOptions2D( const G4String & value )
0330 {
0331 drawOptions2D = value;
0332 }
0333
0334
0335 inline void CexmcHistoManager::SetDrawOptions3D( const G4String & value )
0336 {
0337 drawOptions3D = value;
0338 }
0339 #endif
0340 #endif
0341
0342 #endif
0343