diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/HpdSiEnergyLoss.hh b/LHCbG4Tests/G4RichTbSimHTest/include/HpdSiEnergyLoss.hh
index 7f5676bee6147f5272215b2761f60793c45a6f5f..eea19465997a8575fafea75fbf8abfa586892d40 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/HpdSiEnergyLoss.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/HpdSiEnergyLoss.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_HPDSIENERGYLOSS_HH 
+#ifndef INCLUDE_HPDSIENERGYLOSS_HH
 #define INCLUDE_HPDSIENERGYLOSS_HH 1
 
 // Include files
@@ -13,59 +13,43 @@
 #include "Geant4/G4ParticleDefinition.hh"
 
 /** @class HpdSiEnergyLoss HpdSiEnergyLoss.hh include/HpdSiEnergyLoss.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-12-10
  */
 class HpdSiEnergyLoss : public G4VContinuousDiscreteProcess {
-public: 
+public:
   /// Standard constructor
-  HpdSiEnergyLoss(const G4String& processName); 
+  HpdSiEnergyLoss(const G4String &processName);
 
-  virtual ~HpdSiEnergyLoss( ); ///< Destructor
-  G4bool IsApplicable(const G4ParticleDefinition&);
+  virtual ~HpdSiEnergyLoss(); ///< Destructor
+  G4bool IsApplicable(const G4ParticleDefinition &) override;
   // true for all charged particles
-  G4double GetContinuousStepLimit(const G4Track& track,
-                                G4double previousStepSize,
-                                G4double currentMinimumStep,
-                                G4double& currentSafety);
+  G4double GetContinuousStepLimit(const G4Track &track, G4double previousStepSize, G4double currentMinimumStep,
+                                  G4double &currentSafety) override;
+
+  G4VParticleChange *AlongStepDoIt(const G4Track &aTrack, const G4Step &aStep) override;
+  G4double GetMeanFreePath(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition) override;
+  G4VParticleChange *PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) override;
 
- G4VParticleChange* AlongStepDoIt(const G4Track& aTrack,
-                                     const G4Step& aStep) ;
- G4double GetMeanFreePath(const G4Track& track,
-                          G4double previousStepSize,
-                          G4ForceCondition* condition);
- G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
-                                            const G4Step& aStep);
+  G4String getElossMaterialName() { return ElossMaterialName; }
+  G4String getkillMaterialName() { return EkillMaterialName; }
 
-  G4String getElossMaterialName()  
-  {
-    return ElossMaterialName;
-  }
-  G4String getkillMaterialName()  
-  {
-    return EkillMaterialName;
-  }
-   
 private:
+  // hide  assignment and copy operators
+  HpdSiEnergyLoss(HpdSiEnergyLoss &);
+  HpdSiEnergyLoss &operator=(const HpdSiEnergyLoss &right);
 
-   // hide  assignment and copy operators
-     HpdSiEnergyLoss ( HpdSiEnergyLoss &); 
-     HpdSiEnergyLoss & operator=(const  HpdSiEnergyLoss &right);
- 
- 
 protected:
-
 private:
-  //now the data members
-    G4int fMatIndex;
-    G4int fMatIndexK;
-    G4double MinKineticEnergy ;
-    G4double MipEnergy;
-    G4double finalRangeforStep;   
-    G4String ElossMaterialName;
-    G4String EkillMaterialName;
-
+  // now the data members
+  G4int fMatIndex;
+  G4int fMatIndexK;
+  G4double MinKineticEnergy;
+  G4double MipEnergy;
+  G4double finalRangeforStep;
+  G4String ElossMaterialName;
+  G4String EkillMaterialName;
 };
 #endif // INCLUDE_HPDSIENERGYLOSS_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/PixelHpdPhotoElectricEffect.hh b/LHCbG4Tests/G4RichTbSimHTest/include/PixelHpdPhotoElectricEffect.hh
index 0dd4a84ed47fd7df6babae02b9304d1db0fd4a0f..86eff07551abeb41ae0ac1f4dcc52003b7c47188 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/PixelHpdPhotoElectricEffect.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/PixelHpdPhotoElectricEffect.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_PIXELHPDPHOTOELECTRICEFFECT_HH 
+#ifndef INCLUDE_PIXELHPDPHOTOELECTRICEFFECT_HH
 #define INCLUDE_PIXELHPDPHOTOELECTRICEFFECT_HH 1
 
 // Include files
@@ -18,59 +18,40 @@
 #include "RichTbAnalysisManager.hh"
 
 /** @class PixelHpdPhotoElectricEffect PixelHpdPhotoElectricEffect.hh include/PixelHpdPhotoElectricEffect.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-12-09
  */
-class PixelHpdPhotoElectricEffect:public G4VDiscreteProcess  {
-public: 
+class PixelHpdPhotoElectricEffect : public G4VDiscreteProcess {
+public:
   /// Standard constructor
-  PixelHpdPhotoElectricEffect(const G4String&) ; 
+  PixelHpdPhotoElectricEffect(const G4String &);
 
-  virtual ~PixelHpdPhotoElectricEffect( ); ///< Destructor
-  G4bool IsApplicable(const G4ParticleDefinition&  );
+  virtual ~PixelHpdPhotoElectricEffect(); ///< Destructor
+  G4bool IsApplicable(const G4ParticleDefinition &) override;
   // is applicable for optical photon only
-  G4double GetMeanFreePath(const G4Track& ,
-                                 G4double ,
-                                 G4ForceCondition* condition);
-  //returns infinity (max integer possible) . This means the process does
+  G4double GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *condition) override;
+  // returns infinity (max integer possible) . This means the process does
   // not limit the step, but sets the Forced condition for the DoIt to be
-  // invoked at every step. But only at the boundary between Hpd quartz 
+  // invoked at every step. But only at the boundary between Hpd quartz
   // window and the Hpd photocathode any action be taken.
-  G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
-                                       const G4Step&  aStep);
-  //The method for implementing the HpdPhotoelectric effect.
+  G4VParticleChange *PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) override;
+  // The method for implementing the HpdPhotoelectric effect.
   G4double getHpdQEff(G4int, G4double);
   // To interpolate the QE from QE data.
-  G4double getHpdPhElectronMomentum() 
-  {return HpdPhElectronMomentum; }
-  G4double getPhCathodeToSilDetDist()
-  {return PhCathodeToSilDetDist; }
-  std::vector<G4double> getHpdDemag(G4int hpdnum) 
-   {return DemagnificationFactor[hpdnum]; }
-  G4double getHpdDemagLinearTerm(G4int hpdnum) 
-   {return DemagnificationFactor[hpdnum][1]; }
-  G4int getNumHpdTot() 
-  {
-    return  NumHpdTot;
-  }
-G4double getHpdPhCathodeRInner()
-{return HpdPhCathodeRInner;}
+  G4double getHpdPhElectronMomentum() { return HpdPhElectronMomentum; }
+  G4double getPhCathodeToSilDetDist() { return PhCathodeToSilDetDist; }
+  std::vector<G4double> getHpdDemag(G4int hpdnum) { return DemagnificationFactor[hpdnum]; }
+  G4double getHpdDemagLinearTerm(G4int hpdnum) { return DemagnificationFactor[hpdnum][1]; }
+  G4int getNumHpdTot() { return NumHpdTot; }
+  G4double getHpdPhCathodeRInner() { return HpdPhCathodeRInner; }
 
-G4int getNumDemagParam()
-{
-  return  NumDemagParam;
-}
-G4int getNumQEbins()
-{
-  return NumQEbins;
-}
+  G4int getNumDemagParam() { return NumDemagParam; }
+  G4int getNumQEbins() { return NumQEbins; }
 
 protected:
-
 private:
-
   G4int NumHpdTot;
   G4int NumDemagParam;
   G4int NumQEbins;
@@ -78,11 +59,10 @@ private:
   G4String PostPhotoElectricVolName;
   G4double HpdPhElectronMomentum;
   G4double PhCathodeToSilDetDist;
-  G4double  HpdPhCathodeRInner;
+  G4double HpdPhCathodeRInner;
   G4double PSFsigma;
-  std::vector<std::vector<G4double> >DemagnificationFactor;
-  std::vector<std::vector<G4double> >HpdQE;
-  std::vector<std::vector<G4double> >HpdWabin;
-
+  std::vector<std::vector<G4double>> DemagnificationFactor;
+  std::vector<std::vector<G4double>> HpdQE;
+  std::vector<std::vector<G4double>> HpdWabin;
 };
 #endif // INCLUDE_PIXELHPDPHOTOELECTRICEFFECT_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/PmtAnodeEnergyLoss.hh b/LHCbG4Tests/G4RichTbSimHTest/include/PmtAnodeEnergyLoss.hh
index 40ca6007c3b83cd3666331198fcfddcca403997e..9d382b66d176d1d55b780dd936ab5020ceb7927d 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/PmtAnodeEnergyLoss.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/PmtAnodeEnergyLoss.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_PMTANODEENERGYLOSS_HH 
+#ifndef INCLUDE_PMTANODEENERGYLOSS_HH
 #define INCLUDE_PMTANODEENERGYLOSS_HH 1
 
 // Include files
@@ -13,59 +13,43 @@
 #include "Geant4/G4ParticleDefinition.hh"
 
 /** @class PmtAnodeEnergyLoss PmtAnodeEnergyLoss.hh include/PmtAnodeEnergyLoss.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-12-10
  */
 class PmtAnodeEnergyLoss : public G4VContinuousDiscreteProcess {
-public: 
+public:
   /// Standard constructor
-  PmtAnodeEnergyLoss(const G4String& processName); 
+  PmtAnodeEnergyLoss(const G4String &processName);
 
-  virtual ~PmtAnodeEnergyLoss( ); ///< Destructor
-  G4bool IsApplicable(const G4ParticleDefinition&);
+  virtual ~PmtAnodeEnergyLoss(); ///< Destructor
+  G4bool IsApplicable(const G4ParticleDefinition &) override;
   // true for all charged particles
-  G4double GetContinuousStepLimit(const G4Track& track,
-                                G4double previousStepSize,
-                                G4double currentMinimumStep,
-                                G4double& currentSafety);
+  G4double GetContinuousStepLimit(const G4Track &track, G4double previousStepSize, G4double currentMinimumStep,
+                                  G4double &currentSafety) override;
+
+  G4VParticleChange *AlongStepDoIt(const G4Track &aTrack, const G4Step &aStep) override;
+  G4double GetMeanFreePath(const G4Track &track, G4double previousStepSize, G4ForceCondition *condition) override;
+  G4VParticleChange *PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) override;
 
- G4VParticleChange* AlongStepDoIt(const G4Track& aTrack,
-                                     const G4Step& aStep) ;
- G4double GetMeanFreePath(const G4Track& track,
-                          G4double previousStepSize,
-                          G4ForceCondition* condition);
- G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
-                                            const G4Step& aStep);
+  G4String getElossMaterialName() { return ElossMaterialName; }
+  G4String getkillMaterialName() { return EkillMaterialName; }
 
-  G4String getElossMaterialName()  
-  {
-    return ElossMaterialName;
-  }
-  G4String getkillMaterialName()  
-  {
-    return EkillMaterialName;
-  }
-   
 private:
+  // hide  assignment and copy operators
+  PmtAnodeEnergyLoss(PmtAnodeEnergyLoss &);
+  PmtAnodeEnergyLoss &operator=(const PmtAnodeEnergyLoss &right);
 
-   // hide  assignment and copy operators
-     PmtAnodeEnergyLoss ( PmtAnodeEnergyLoss &); 
-     PmtAnodeEnergyLoss & operator=(const  PmtAnodeEnergyLoss &right);
- 
- 
 protected:
-
 private:
-  //now the data members
-    G4int fMatIndex;
-    G4int fMatIndexK;
-    G4double MinKineticEnergy ;
-    G4double MipEnergy;
-    G4double finalRangeforStep;   
-    G4String ElossMaterialName;
-    G4String EkillMaterialName;
-
+  // now the data members
+  G4int fMatIndex;
+  G4int fMatIndexK;
+  G4double MinKineticEnergy;
+  G4double MipEnergy;
+  G4double finalRangeforStep;
+  G4String ElossMaterialName;
+  G4String EkillMaterialName;
 };
 #endif // INCLUDE_PMTANODEENERGYLOSS_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/PmtPhotoElectricEffect.hh b/LHCbG4Tests/G4RichTbSimHTest/include/PmtPhotoElectricEffect.hh
index 32eabdfdcf21b18b18ae88901ed643ce4d2043f1..a863446934bffb94cad6ff4b1f402ab9719db868 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/PmtPhotoElectricEffect.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/PmtPhotoElectricEffect.hh
@@ -23,47 +23,33 @@
  *  @author Sajan EASO
  *  @date   2003-12-09
  */
-class PmtPhotoElectricEffect:public G4VDiscreteProcess  {
+class PmtPhotoElectricEffect : public G4VDiscreteProcess {
 public:
   /// Standard constructor
-  PmtPhotoElectricEffect(const G4String&) ;
+  PmtPhotoElectricEffect(const G4String &);
 
-  virtual ~PmtPhotoElectricEffect( ); ///< Destructor
-  G4bool IsApplicable(const G4ParticleDefinition&  );
+  virtual ~PmtPhotoElectricEffect(); ///< Destructor
+  G4bool IsApplicable(const G4ParticleDefinition &) override;
   // is applicable for optical photon only
-  G4double GetMeanFreePath(const G4Track& ,
-                                 G4double ,
-                                 G4ForceCondition* condition);
-  //returns infinity (max integer possible) . This means the process does
+  G4double GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *condition) override;
+  // returns infinity (max integer possible) . This means the process does
   // not limit the step, but sets the Forced condition for the DoIt to be
   // invoked at every step. But only at the boundary between Hpd quartz
   // window and the Hpd photocathode any action be taken.
-  G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
-                                       const G4Step&  aStep);
-  //The method for implementing the PmtPhotoelectric effect.
+  G4VParticleChange *PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) override;
+  // The method for implementing the PmtPhotoelectric effect.
   G4double getPmtQEff(G4int, G4double);
   // To interpolate the QE from QE data.
-  G4double getPmtPhElectronMomentum()
-  {return PmtPhElectronMomentum; }
-  G4double getPhCathodeToSilDetDist()
-  {return PhCathodeToSilDetDist; }
+  G4double getPmtPhElectronMomentum() { return PmtPhElectronMomentum; }
+  G4double getPhCathodeToSilDetDist() { return PhCathodeToSilDetDist; }
 
-  G4int getNumPmtTot()
-  {
-    return  NumPmtTot;
-  }
+  G4int getNumPmtTot() { return NumPmtTot; }
 
-
-G4int getNumQEbins()
-{
-  return NumQEbins;
-}
+  G4int getNumQEbins() { return NumQEbins; }
 
 protected:
-
 private:
-
-	G4int NumPmts_; // TESTnumPmts
+  G4int NumPmts_; // TESTnumPmts
 
   G4int NumPmtTot;
 
@@ -73,9 +59,7 @@ private:
   G4double PmtPhElectronMomentum;
   G4double PhCathodeToSilDetDist;
 
-
-  std::vector<std::vector<G4double> >PmtQE;
-  std::vector<std::vector<G4double> >PmtWabin;
-
+  std::vector<std::vector<G4double>> PmtQE;
+  std::vector<std::vector<G4double>> PmtWabin;
 };
 #endif // INCLUDE_PMTPHOTOELECTRICEFFECT_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbAnalysisManager.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbAnalysisManager.hh
index 22350ffbee21692c5d7772267a61e8683320d217..bdbe8f090b027b01d0a1fbfd4d0fd08ff4e15664 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbAnalysisManager.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbAnalysisManager.hh
@@ -1,7 +1,6 @@
 #ifndef RichTbAnalysisManager_h
 #define RichTbAnalysisManager_h 1
 
-
 //#include "Geant4/G4VAnalysisManager.hh"
 #include "Geant4/globals.hh"
 //#include "Geant4/G4std/vector"
@@ -46,27 +45,22 @@ class G4Timer;
 class G4SteppingManager;
 class RichTbRunConfig;
 
-
- class TFile;
- class TTree;
+class TFile;
+class TTree;
 // class TH1D;
 
-  const G4int MaxHisto = 5;
+const G4int MaxHisto = 5;
 
-
-//namespace AIDA {
-  //class IAnalysisFactory;
-//class IHistogramFactory;
-//class ITree;
-//class ITupleFactory;
-//class ITuple;
+// namespace AIDA {
+// class IAnalysisFactory;
+// class IHistogramFactory;
+// class ITree;
+// class ITupleFactory;
+// class ITuple;
 //};
 
-
-
 class RichTbAnalysisManager {
 public:
-
   virtual ~RichTbAnalysisManager();
 
   void InitializeCounters();
@@ -75,248 +69,200 @@ public:
 
   void BeginOfRunAnalysis();
   void EndOfRunAnalysis();
-  void BeginOfEventAnalysis(const G4Event*);
-  void EndOfEventAnalysis(const G4Event*);
-  void StepAnalysis(const G4SteppingManager* );
-  void EndOfEventHisto(const G4Event*);
-  void EndOfEventHistoHpd(const G4Event*);
-
-  void EndOfEventCountersHisto(const G4Event* );
-
-
-
-
-  static  RichTbAnalysisManager* getInstance();
-
-  TH1D * getPhotonXCoord() {return fPhotonXCoord;}
-  TH1D * getPhotonYCoord() {return fPhotonYCoord;}
-  TH1D * getPhotonZCoord() {return fPhotonZCoord;}
-
-  TH2D * getPhotonXYCoord() {return fPhotonXYCoord;}
-
-  TH1D * getPhotonWidthProfile() {return fPhotonWidthProfile;}
-  TProfile * getPhotonXYCoordProfile() {return fPhotonXYCoordProfile;}
-  TProfile * getPhotonXYCoordProfileCut() {return fPhotonXYCoordProfileCut;}
-  TH1D * getSpectrum() {return fSpectrum;}
-  TH1D * getSpectrumPreMirror() {return fSpectrumPreMirror;}
-  TH1D * getSpectrumPostMirror() {return fSpectrumPostMirror;}
-  TH1D * getPhotonZAngle() {return fPhotonZAngle;}
-  TH1D * getCherenkovAngle() {return fCherenkovAngle;}
-  TH1D * getCherenkovAngleCut() {return fCherenkovAngleCut;}
+  void BeginOfEventAnalysis(const G4Event *);
+  void EndOfEventAnalysis(const G4Event *);
+  void StepAnalysis(const G4SteppingManager *);
+  void EndOfEventHisto(const G4Event *);
+  void EndOfEventHistoHpd(const G4Event *);
 
-  TH2D * getRadiusVsWL() {return fRadiusVsWL;}
-  TProfile * getRadiusVsWLProfile() {return fRadiusVsWLProfile;}
-  TH2D * getfGlobalPixelCenterXYCoord() {  return fGlobalPixelCenterXYCoord;}
-  TProfile * getfCkvRadiusVsEmisPtPhoton() {  return  fCkvRadiusVsEmisPtPhoton;}
-  TH1D * getfEmisPtPhoton()  {  return fEmisPtPhoton; }
-  TH1D * getfEmisPtPrimaryTrackPhoton()  {  return fEmisPtPrimaryTrackPhoton; }
+  void EndOfEventCountersHisto(const G4Event *);
 
+  static RichTbAnalysisManager *getInstance();
 
-  TH2D * getfGlobalHitXYCoordPeOrigin()
-  {  return fGlobalHitXYCoordPeOrigin;}
-  TH2D * getfGlobalHitXYCoord()
-  {  return fGlobalHitXYCoord ;}
-  TH1D * getfNumHitInEvent()
-  {  return fNumHitInEvent;  }
+  TH1D *getPhotonXCoord() { return fPhotonXCoord; }
+  TH1D *getPhotonYCoord() { return fPhotonYCoord; }
+  TH1D *getPhotonZCoord() { return fPhotonZCoord; }
 
-  TH1D*  getfNumHitInEventCentralPMT()
-  {  return fNumHitInEventCentralPMT;}
+  TH2D *getPhotonXYCoord() { return fPhotonXYCoord; }
 
-  TH1D*  getfNumHitInEventCentralPMTJura() {return    fNumHitInEventCentralPMTJura ;}
-  TH1D*  getfNumHitInEventCentralPMTSaleve() {return    fNumHitInEventCentralPMTSaleve ;}
+  TH1D *getPhotonWidthProfile() { return fPhotonWidthProfile; }
+  TProfile *getPhotonXYCoordProfile() { return fPhotonXYCoordProfile; }
+  TProfile *getPhotonXYCoordProfileCut() { return fPhotonXYCoordProfileCut; }
+  TH1D *getSpectrum() { return fSpectrum; }
+  TH1D *getSpectrumPreMirror() { return fSpectrumPreMirror; }
+  TH1D *getSpectrumPostMirror() { return fSpectrumPostMirror; }
+  TH1D *getPhotonZAngle() { return fPhotonZAngle; }
+  TH1D *getCherenkovAngle() { return fCherenkovAngle; }
+  TH1D *getCherenkovAngleCut() { return fCherenkovAngleCut; }
 
+  TH2D *getRadiusVsWL() { return fRadiusVsWL; }
+  TProfile *getRadiusVsWLProfile() { return fRadiusVsWLProfile; }
+  TH2D *getfGlobalPixelCenterXYCoord() { return fGlobalPixelCenterXYCoord; }
+  TProfile *getfCkvRadiusVsEmisPtPhoton() { return fCkvRadiusVsEmisPtPhoton; }
+  TH1D *getfEmisPtPhoton() { return fEmisPtPhoton; }
+  TH1D *getfEmisPtPrimaryTrackPhoton() { return fEmisPtPrimaryTrackPhoton; }
 
-  TH1D * getfNumHitInPMT0()
-  {   return fNumHitInPMT0; }
-  TH1D * getfNumHitInPMT1()
-  {   return fNumHitInPMT1; }
-  TH1D * getfNumHitInPMT2()
-  {   return fNumHitInPMT2; }
-  TH1D * getfNumHitInPMT3()
-  {   return fNumHitInPMT3; }
-  TH1D * getfNumHitInPMT4()
-  {   return fNumHitInPMT4; }
-  TH1D * getfNumHitInPMT5()
-  {   return fNumHitInPMT5; }
-  TH1D * getfNumHitInPMT6()
-  {   return fNumHitInPMT6; }
-  TH1D * getfNumHitInPMT7()
-  {   return fNumHitInPMT7; }
-  TH1D * getfNumHitInPMT8()
-  {   return fNumHitInPMT8; }
-  TH1D * getfNumHitInPMT9()
-  {   return fNumHitInPMT9; }
-  TH1D * getfNumHitInPMT10()
-  {   return fNumHitInPMT10; }
-  TH1D * getfNumHitInPMT11()
-  {   return fNumHitInPMT11; }
-  TH1D * getfNumHitInPMT12()
-  {   return fNumHitInPMT12; }
-  TH1D * getfNumHitInPMT13()
-  {   return fNumHitInPMT13; }
-  TH1D * getfNumHitInPMT14()
-  {   return fNumHitInPMT14; }
-  TH1D * getfNumHitInPMT15()
-  {   return fNumHitInPMT15; }
-  TH1D * getfGeneratedCkvPhoton()
-  {  return fGeneratedCkvPhoton;}
+  TH2D *getfGlobalHitXYCoordPeOrigin() { return fGlobalHitXYCoordPeOrigin; }
+  TH2D *getfGlobalHitXYCoord() { return fGlobalHitXYCoord; }
+  TH1D *getfNumHitInEvent() { return fNumHitInEvent; }
 
-  TH2D * getfTIRXYLocationPhoton()
-  {  return fTIRXYLocationPhoton;}
-  TH2D* getfXYRadiatorDnsPhoton()
-  {  return  fXYRadiatorDnsPhoton;}
-  TH2D* getfXYRadiatorTIRDnsPhoton()
-  {  return  fXYRadiatorTIRDnsPhoton;}
+  TH1D *getfNumHitInEventCentralPMT() { return fNumHitInEventCentralPMT; }
 
-  TH2D* getfXYRadiatorRFRDnsPhoton()
-  {  return fXYRadiatorRFRDnsPhoton;}
+  TH1D *getfNumHitInEventCentralPMTJura() { return fNumHitInEventCentralPMTJura; }
+  TH1D *getfNumHitInEventCentralPMTSaleve() { return fNumHitInEventCentralPMTSaleve; }
 
-  TH2D* getfMIRXYLocationPhoton()
-  {  return fMIRXYLocationPhoton;}
+  TH1D *getfNumHitInPMT0() { return fNumHitInPMT0; }
+  TH1D *getfNumHitInPMT1() { return fNumHitInPMT1; }
+  TH1D *getfNumHitInPMT2() { return fNumHitInPMT2; }
+  TH1D *getfNumHitInPMT3() { return fNumHitInPMT3; }
+  TH1D *getfNumHitInPMT4() { return fNumHitInPMT4; }
+  TH1D *getfNumHitInPMT5() { return fNumHitInPMT5; }
+  TH1D *getfNumHitInPMT6() { return fNumHitInPMT6; }
+  TH1D *getfNumHitInPMT7() { return fNumHitInPMT7; }
+  TH1D *getfNumHitInPMT8() { return fNumHitInPMT8; }
+  TH1D *getfNumHitInPMT9() { return fNumHitInPMT9; }
+  TH1D *getfNumHitInPMT10() { return fNumHitInPMT10; }
+  TH1D *getfNumHitInPMT11() { return fNumHitInPMT11; }
+  TH1D *getfNumHitInPMT12() { return fNumHitInPMT12; }
+  TH1D *getfNumHitInPMT13() { return fNumHitInPMT13; }
+  TH1D *getfNumHitInPMT14() { return fNumHitInPMT14; }
+  TH1D *getfNumHitInPMT15() { return fNumHitInPMT15; }
+  TH1D *getfGeneratedCkvPhoton() { return fGeneratedCkvPhoton; }
 
-  TH2D*  getfRFRXYLocationPhoton()
-  {  return fRFRXYLocationPhoton;}
+  TH2D *getfTIRXYLocationPhoton() { return fTIRXYLocationPhoton; }
+  TH2D *getfXYRadiatorDnsPhoton() { return fXYRadiatorDnsPhoton; }
+  TH2D *getfXYRadiatorTIRDnsPhoton() { return fXYRadiatorTIRDnsPhoton; }
 
+  TH2D *getfXYRadiatorRFRDnsPhoton() { return fXYRadiatorRFRDnsPhoton; }
 
-  TH1D* getfNumHitInHPD0()  {  return fNumHitInHPD0; }
+  TH2D *getfMIRXYLocationPhoton() { return fMIRXYLocationPhoton; }
 
-  TH2D* getfRFRXYLocationPhotonHpd() {return   fRFRXYLocationPhotonHpd; }
+  TH2D *getfRFRXYLocationPhoton() { return fRFRXYLocationPhoton; }
 
-  TH2D* getfGlobalHitXYCoordPeOriginHpd() {return   fGlobalHitXYCoordPeOriginHpd; }
+  TH1D *getfNumHitInHPD0() { return fNumHitInHPD0; }
 
-  TH2D* getfGlobalHitXYCoordHpd() {return   fGlobalHitXYCoordHpd; }
+  TH2D *getfRFRXYLocationPhotonHpd() { return fRFRXYLocationPhotonHpd; }
 
-  TH2D* getfGlobalPixelCenterXYCoordHpd() {return   fGlobalPixelCenterXYCoordHpd ;}
-
-  TH2D*  getfGlobalHitXYCoordPeOriginHpdPmt()  {  return fGlobalHitXYCoordPeOriginHpdPmt;}
-
-  TH2D* getfRadiatorRefIndex()  {  return fRadiatorRefIndex;}
-  TProfile * getfRadiatorRefIndexHits()  {  return fRadiatorRefIndexHits;}
-
-  TH2D * getfGlobalHitXYCoordPixPhcathHpd() {return fGlobalHitXYCoordPixPhcathHpd;}
-
-  TH1D* getfNumHitSignalInHPD0() {return fNumHitSignalInHPD0  ;}
+  TH2D *getfGlobalHitXYCoordPeOriginHpd() { return fGlobalHitXYCoordPeOriginHpd; }
 
+  TH2D *getfGlobalHitXYCoordHpd() { return fGlobalHitXYCoordHpd; }
 
+  TH2D *getfGlobalPixelCenterXYCoordHpd() { return fGlobalPixelCenterXYCoordHpd; }
 
-private:
-  //private constructor in order to create a singleton
-
-  RichTbAnalysisManager ();
-
-  static  RichTbAnalysisManager* RichTbAnalysisInstance;
-
-  G4Timer* iTimer;
-
-    TFile*   fRootFile;
-    TH1D*    fHisto[MaxHisto];
-    TTree*   fNtuple1;
-    TH1D *   fPhotonZCoord;
-    TH1D *   fPhotonYCoord;
-    TH1D *   fPhotonXCoord;
-    TH1D *   fSpectrum;
-    TH1D *   fSpectrumPreMirror;
-    TH1D *   fSpectrumPostMirror;
-
-    TH2D * fRadiatorRefIndex;
-    TProfile * fRadiatorRefIndexHits;
-
-    TH2D *   fPhotonXYCoord;
-    TH2D *   fPhotonXYCoord15;
-
-
-    TH2D *   fRadiusVsWL;
-    TProfile * fRadiusVsWLProfile;
-    TH1D *   fPhotonWidthProfile;
-    TProfile *   fPhotonXYCoordProfile;
-    TProfile *   fPhotonXYCoordProfileCut;
-    TH1D *   fPhotonZAngle;
-    TH1D *   fCherenkovAngle;
-    TH1D *   fCherenkovAngleCut;
-
-  TH2D*  fGlobalHitXYCoordPeOrigin;
-  TH2D*  fGlobalHitXYCoord;
-  TH2D*  fGlobalHitXYCoord15;
-  TH2D*  fGlobalPixelCenterXYCoord ;
-  TH1D*  fNumHitInEvent;
-  TH1D*  fNumHitInEventCentralPMT;
-  TH1D*  fNumHitInEventCentralPMTJura ;
-  TH1D*  fNumHitInEventCentralPMTSaleve;
-
-  TH1D*  fNumHitInPMT0;
-  TH1D*  fNumHitInPMT1;
-  TH1D*  fNumHitInPMT2;
-  TH1D*  fNumHitInPMT3;
-  TH1D*  fNumHitInPMT4;
-  TH1D*  fNumHitInPMT5;
-  TH1D*  fNumHitInPMT6;
-  TH1D*  fNumHitInPMT7;
-  TH1D*  fNumHitInPMT8;
-  TH1D*  fNumHitInPMT9;
-  TH1D*  fNumHitInPMT10;
-  TH1D*  fNumHitInPMT11;
-  TH1D*  fNumHitInPMT12;
-  TH1D*  fNumHitInPMT13;
-  TH1D*  fNumHitInPMT14;
-  TH1D*  fNumHitInPMT15;
-
-  TH1D*  radiusInPMT0;
-  TH1D*  radiusInPMT1;
-  TH1D*  radiusInPMT2;
-  TH1D*  radiusInPMT3;
-  TH1D*  radiusInPMT4;
-  TH1D*  radiusInPMT5;
-  TH1D*  radiusInPMT6;
-  TH1D*  radiusInPMT7;
-  TH1D*  radiusInPMT8;
-  TH1D*  radiusInPMT9;
-  TH1D*  radiusInPMT10;
-  TH1D*  radiusInPMT11;
-  TH1D*  radiusInPMT12;
-  TH1D*  radiusInPMT13;
-  TH1D*  radiusInPMT14;
-  TH1D*  radiusInPMT15;
-
-  TProfile * fCkvRadiusVsEmisPtPhoton;
-  TH1D* fEmisPtPhoton;
-  TH1D* fEmisPtPrimaryTrackPhoton;
-
-    G4double fNtupVar1;
-    G4double fNtupVar2;
-
-  TH1D*  fGeneratedCkvPhoton;
-
-  TH2D* fTIRXYLocationPhoton;
-  TH2D* fXYRadiatorDnsPhoton;
-   TH2D* fXYRadiatorTIRDnsPhoton;
-  TH2D* fXYRadiatorRFRDnsPhoton;
-
-  TH2D* fMIRXYLocationPhoton;
-  TH2D* fRFRXYLocationPhoton;
-
-
-
-  TH1D* fNumHitInHPD0;
-  TH1D* fNumHitSignalInHPD0 ;
-
-  TH2D* fRFRXYLocationPhotonHpd;
-  TH2D* fGlobalHitXYCoordPeOriginHpd;
-  TH2D* fGlobalHitXYCoordHpd;
-  TH2D* fGlobalPixelCenterXYCoordHpd ;
-
-  TH2D*  fGlobalHitXYCoordPeOriginHpdPmt;
-
-  TH2D * fGlobalHitXYCoordPixPhcathHpd;
+  TH2D *getfGlobalHitXYCoordPeOriginHpdPmt() { return fGlobalHitXYCoordPeOriginHpdPmt; }
 
+  TH2D *getfRadiatorRefIndex() { return fRadiatorRefIndex; }
+  TProfile *getfRadiatorRefIndexHits() { return fRadiatorRefIndexHits; }
 
+  TH2D *getfGlobalHitXYCoordPixPhcathHpd() { return fGlobalHitXYCoordPixPhcathHpd; }
 
-};
+  TH1D *getfNumHitSignalInHPD0() { return fNumHitSignalInHPD0; }
 
+private:
+  // private constructor in order to create a singleton
+
+  RichTbAnalysisManager();
+
+  static RichTbAnalysisManager *RichTbAnalysisInstance;
+
+  G4Timer *iTimer;
+
+  TFile *fRootFile;
+  TH1D *fHisto[MaxHisto];
+  TTree *fNtuple1;
+  TH1D *fPhotonZCoord;
+  TH1D *fPhotonYCoord;
+  TH1D *fPhotonXCoord;
+  TH1D *fSpectrum;
+  TH1D *fSpectrumPreMirror;
+  TH1D *fSpectrumPostMirror;
+
+  TH2D *fRadiatorRefIndex;
+  TProfile *fRadiatorRefIndexHits;
+
+  TH2D *fPhotonXYCoord;
+  TH2D *fPhotonXYCoord15;
+
+  TH2D *fRadiusVsWL;
+  TProfile *fRadiusVsWLProfile;
+  TH1D *fPhotonWidthProfile;
+  TProfile *fPhotonXYCoordProfile;
+  TProfile *fPhotonXYCoordProfileCut;
+  TH1D *fPhotonZAngle;
+  TH1D *fCherenkovAngle;
+  TH1D *fCherenkovAngleCut;
+
+  TH2D *fGlobalHitXYCoordPeOrigin;
+  TH2D *fGlobalHitXYCoord;
+  TH2D *fGlobalHitXYCoord15;
+  TH2D *fGlobalPixelCenterXYCoord;
+  TH1D *fNumHitInEvent;
+  TH1D *fNumHitInEventCentralPMT;
+  TH1D *fNumHitInEventCentralPMTJura;
+  TH1D *fNumHitInEventCentralPMTSaleve;
+
+  TH1D *fNumHitInPMT0;
+  TH1D *fNumHitInPMT1;
+  TH1D *fNumHitInPMT2;
+  TH1D *fNumHitInPMT3;
+  TH1D *fNumHitInPMT4;
+  TH1D *fNumHitInPMT5;
+  TH1D *fNumHitInPMT6;
+  TH1D *fNumHitInPMT7;
+  TH1D *fNumHitInPMT8;
+  TH1D *fNumHitInPMT9;
+  TH1D *fNumHitInPMT10;
+  TH1D *fNumHitInPMT11;
+  TH1D *fNumHitInPMT12;
+  TH1D *fNumHitInPMT13;
+  TH1D *fNumHitInPMT14;
+  TH1D *fNumHitInPMT15;
+
+  TH1D *radiusInPMT0;
+  TH1D *radiusInPMT1;
+  TH1D *radiusInPMT2;
+  TH1D *radiusInPMT3;
+  TH1D *radiusInPMT4;
+  TH1D *radiusInPMT5;
+  TH1D *radiusInPMT6;
+  TH1D *radiusInPMT7;
+  TH1D *radiusInPMT8;
+  TH1D *radiusInPMT9;
+  TH1D *radiusInPMT10;
+  TH1D *radiusInPMT11;
+  TH1D *radiusInPMT12;
+  TH1D *radiusInPMT13;
+  TH1D *radiusInPMT14;
+  TH1D *radiusInPMT15;
+
+  TProfile *fCkvRadiusVsEmisPtPhoton;
+  TH1D *fEmisPtPhoton;
+  TH1D *fEmisPtPrimaryTrackPhoton;
+
+  G4double fNtupVar1;
+  G4double fNtupVar2;
+
+  TH1D *fGeneratedCkvPhoton;
+
+  TH2D *fTIRXYLocationPhoton;
+  TH2D *fXYRadiatorDnsPhoton;
+  TH2D *fXYRadiatorTIRDnsPhoton;
+  TH2D *fXYRadiatorRFRDnsPhoton;
+
+  TH2D *fMIRXYLocationPhoton;
+  TH2D *fRFRXYLocationPhoton;
+
+  TH1D *fNumHitInHPD0;
+  TH1D *fNumHitSignalInHPD0;
+
+  TH2D *fRFRXYLocationPhotonHpd;
+  TH2D *fGlobalHitXYCoordPeOriginHpd;
+  TH2D *fGlobalHitXYCoordHpd;
+  TH2D *fGlobalPixelCenterXYCoordHpd;
+
+  TH2D *fGlobalHitXYCoordPeOriginHpdPmt;
+
+  TH2D *fGlobalHitXYCoordPixPhcathHpd;
+};
 
 #endif
-
-
-
-
-
-
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbBeamGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbBeamGeometryParameters.hh
index 5e22742769833c73cba13c5d8994c72c3d905681..0c7219eeeff354e7aab7d5f544b646a429b44d9d 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbBeamGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbBeamGeometryParameters.hh
@@ -1,14 +1,13 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBBEAMGEOMETRYPARAMETERS_HH 
+#ifndef INCLUDE_RICHTBBEAMGEOMETRYPARAMETERS_HH
 #define INCLUDE_RICHTBBEAMGEOMETRYPARAMETERS_HH 1
 
 // Include files
-const G4double RichTbNominalBeamXPos=0.0*CLHEP::mm;
-const G4double RichTbNominalBeamYPos=0.0*CLHEP::mm;
-const G4double RichTbNominalBeamZPos=-600.0*CLHEP::mm;
-const G4double RichTbNominalBeamDirCosX=0.0;
-const G4double RichTbNominalBeamDirCosY=0.0;
-const G4double RichTbNominalBeamDirCosZ=1.0;
-
+const G4double RichTbNominalBeamXPos = 0.0 * CLHEP::mm;
+const G4double RichTbNominalBeamYPos = 0.0 * CLHEP::mm;
+const G4double RichTbNominalBeamZPos = -600.0 * CLHEP::mm;
+const G4double RichTbNominalBeamDirCosX = 0.0;
+const G4double RichTbNominalBeamDirCosY = 0.0;
+const G4double RichTbNominalBeamDirCosZ = 1.0;
 
 #endif // INCLUDE_RICHTBBEAMGEOMETRYPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbBeamProperty.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbBeamProperty.hh
index 5dd0cb6c561b49d2c592a36b030381093f3afa59..f1c7f88d6ce9874aefafe4b813c31e48498b8078 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbBeamProperty.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbBeamProperty.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBBEAMPROPERTY_HH 
+#ifndef INCLUDE_RICHTBBEAMPROPERTY_HH
 #define INCLUDE_RICHTBBEAMPROPERTY_HH 1
 
 // Include files
@@ -8,89 +8,69 @@
 #include "Geant4/G4ParticleDefinition.hh"
 
 /** @class RichTbBeamProperty RichTbBeamProperty.hh include/RichTbBeamProperty.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2004-01-22
  */
 class RichTbBeamProperty {
-public: 
-
-  virtual ~RichTbBeamProperty( ); ///< Destructor
-
-  static  RichTbBeamProperty* getRichTbBeamPropertyInstance();
-  
-  G4ThreeVector getBeamPosition() {return mBeamPosition;}
-  G4ThreeVector getBeamDirection()  {    return mBeamDirection;}
-  void setBeamPosition(G4ThreeVector aBeamPosition ) 
-  {mBeamPosition= aBeamPosition;}
-  void setBeamDirection(G4ThreeVector aBeamDirection)
-  {    mBeamDirection=aBeamDirection;}
-
-  G4ThreeVector getNominalBeamPosition() 
-  {    return mNominalBeamPosition;}
-
-  void setNominalBeamPosition(G4ThreeVector aNominalBeamPosition) 
-    {mNominalBeamPosition = aNominalBeamPosition;}
-
-  G4ThreeVector getNominalBeamDirectionCos() 
-  {    return mNominalBeamDirectionCos;}
-  void setNominalBeamDirectionCos(G4ThreeVector aDirCos)
-  {mNominalBeamDirectionCos= aDirCos;}
-
-  void setBeamPartDef(G4ParticleDefinition* aBeamPartDef) 
-  { mBeamPartDef= aBeamPartDef; }
-  
-  G4ParticleDefinition* getBeamPartDef(){    return  mBeamPartDef;}
-
-  G4String BeamPartName()  {    return mBeamPartName;}  
-  void setBeamPartName(G4String aBname ){mBeamPartName=aBname; }
-  
-  G4ThreeVector getBeamPosUpstrAgel() 
-  {    return mBeamPosUpstrAgel;}
-  
-  void setBeamPosUpstrAgel( G4ThreeVector aBPosA ) 
-  {    mBeamPosUpstrAgel=aBPosA;}
-  
-  G4ThreeVector getBeamDirUpstrAgel() 
-  {    return  mBeamDirUpstrAgel;}
-  void setBeamDirUpstrAgel(G4ThreeVector aBDirA) 
-  { mBeamDirUpstrAgel= aBDirA;}
-    
-  G4ThreeVector getAgelNormal() 
-  {    return mAgelNormal;}
-  void setAgelNormal(G4ThreeVector aAgelNormal) 
-  {mAgelNormal= aAgelNormal;}
-  
-    
-  G4ThreeVector getAgelBeamPostionLocal() 
-  {    return  mAgelBeamPostionLocal;}
-  
-  void setAgelBeamPostionLocal(G4ThreeVector aPosLocal) 
-  {    mAgelBeamPostionLocal =  aPosLocal;}
-  
+public:
+  virtual ~RichTbBeamProperty(); ///< Destructor
+
+  static RichTbBeamProperty *getRichTbBeamPropertyInstance();
+
+  G4ThreeVector getBeamPosition() { return mBeamPosition; }
+  G4ThreeVector getBeamDirection() { return mBeamDirection; }
+  void setBeamPosition(G4ThreeVector aBeamPosition) { mBeamPosition = aBeamPosition; }
+  void setBeamDirection(G4ThreeVector aBeamDirection) { mBeamDirection = aBeamDirection; }
+
+  G4ThreeVector getNominalBeamPosition() { return mNominalBeamPosition; }
+
+  void setNominalBeamPosition(G4ThreeVector aNominalBeamPosition) { mNominalBeamPosition = aNominalBeamPosition; }
+
+  G4ThreeVector getNominalBeamDirectionCos() { return mNominalBeamDirectionCos; }
+  void setNominalBeamDirectionCos(G4ThreeVector aDirCos) { mNominalBeamDirectionCos = aDirCos; }
+
+  void setBeamPartDef(G4ParticleDefinition *aBeamPartDef) { mBeamPartDef = aBeamPartDef; }
+
+  G4ParticleDefinition *getBeamPartDef() { return mBeamPartDef; }
+
+  G4String BeamPartName() { return mBeamPartName; }
+  void setBeamPartName(G4String aBname) { mBeamPartName = aBname; }
+
+  G4ThreeVector getBeamPosUpstrAgel() { return mBeamPosUpstrAgel; }
+
+  void setBeamPosUpstrAgel(G4ThreeVector aBPosA) { mBeamPosUpstrAgel = aBPosA; }
+
+  G4ThreeVector getBeamDirUpstrAgel() { return mBeamDirUpstrAgel; }
+  void setBeamDirUpstrAgel(G4ThreeVector aBDirA) { mBeamDirUpstrAgel = aBDirA; }
+
+  G4ThreeVector getAgelNormal() { return mAgelNormal; }
+  void setAgelNormal(G4ThreeVector aAgelNormal) { mAgelNormal = aAgelNormal; }
+
+  G4ThreeVector getAgelBeamPostionLocal() { return mAgelBeamPostionLocal; }
+
+  void setAgelBeamPostionLocal(G4ThreeVector aPosLocal) { mAgelBeamPostionLocal = aPosLocal; }
+
   void ResetBeamProperty();
   void PrintBeamProperty();
-  
-protected:
 
+protected:
 private:
   /// Standard constructor
-  RichTbBeamProperty( ); 
+  RichTbBeamProperty();
+
+  static RichTbBeamProperty *RichTbBeamPropertyInstance;
 
-  static RichTbBeamProperty* RichTbBeamPropertyInstance;
-  
   G4ThreeVector mBeamPosition;
   G4ThreeVector mBeamDirection;
   G4ThreeVector mNominalBeamPosition;
   G4ThreeVector mNominalBeamDirectionCos;
-  G4ParticleDefinition* mBeamPartDef;
+  G4ParticleDefinition *mBeamPartDef;
   G4String mBeamPartName;
   G4ThreeVector mBeamPosUpstrAgel;
   G4ThreeVector mBeamDirUpstrAgel;
   G4ThreeVector mAgelNormal;
   G4ThreeVector mAgelBeamPostionLocal;
-  
-  
 };
 #endif // INCLUDE_RICHTBBEAMPROPERTY_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCounter.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCounter.hh
index b7bdd7b044718c9556947dddf814e43964d9f17a..74a125be80a71f651ec250423cb0146322d69c10 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCounter.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCounter.hh
@@ -13,270 +13,147 @@
  */
 class RichTbCounter {
 public:
-  static RichTbCounter* getRichTbCounterInstance();
-
-  void bumpnumHitTotProd() {
-    numHitTotProd ++;}
-  void bumpnumhitTotEv()
-  {    numhitTotEv++;  }
-  void bumpnumhitTotEvCentralPmt()
-  { numhitTotEvCentralPmt++;}
-  void bumpnumhitTotEvCentralPmtJura()
-  { numhitTotEvCentralPmtJura++;}
-  void bumpnumhitTotEvCentralPmtSaleve()
-  { numhitTotEvCentralPmtSaleve++;}
-
-
-  void bumpnumhitPMT0()
-  {    numhitPMT0++;  }
-  void bumpnumhitPMT1()
-  {    numhitPMT1++;  }
-  void bumpnumhitPMT2()
-  {    numhitPMT2++;  }
-  void bumpnumhitPMT3()
-  {    numhitPMT3++;  }
-  void bumpnumhitPMT4()
-  {    numhitPMT4++;  }
-  void bumpnumhitPMT5()
-  {    numhitPMT5++;  }
-  void bumpnumhitPMT6()
-  {    numhitPMT6++;  }
-  void bumpnumhitPMT7()
-  {    numhitPMT7++;  }
-  void bumpnumhitPMT8()
-  {    numhitPMT8++;  }
-  void bumpnumhitPMT9()
-  {    numhitPMT9++;  }
-  void bumpnumhitPMT10()
-  {    numhitPMT10++;  }
-  void bumpnumhitPMT11()
-  {    numhitPMT11++;  }
-  void bumpnumhitPMT12()
-  {    numhitPMT12++;  }
-  void bumpnumhitPMT13()
-  {    numhitPMT13++;  }
-  void bumpnumhitPMT14()
-  {    numhitPMT14++;  }
-  void bumpnumhitPMT15()
-  {    numhitPMT15++;  }
-
-
-
-  void bumpnumPhEnterMirror()
-  {    numPhEnterMirror++;}
-  void bumpnumPhEnterPhSupFrame()
-  {    numPhEnterPhSupFrame++;}
-  void bumpnumExitGasQuWin() { numExitGasQuWin++;}
-  void bumpnumPhElecPMT0()
-  {    numPhElecPMT0++;}
-  void bumpnumPhElecPMT1()
-  {    numPhElecPMT1++;}
-  void bumpnumPhElecPMT2()
-  {    numPhElecPMT2++;}
-  void bumpnumPhElecPMT3()
-  {    numPhElecPMT3++;}
-  void bumpnumPhElecPMT4()
-  {    numPhElecPMT4++;}
-  void bumpnumPhElecPMT5()
-  {    numPhElecPMT5++;}
-  void bumpnumPhElecPMT6()
-  {    numPhElecPMT6++;}
-  void bumpnumPhElecPMT7()
-  {    numPhElecPMT7++;}
-  void bumpnumPhElecPMT8()
-  {    numPhElecPMT8++;}
-  void bumpnumPhElecPMT9()
-  {    numPhElecPMT9++;}
-  void bumpnumPhElecPMT10()
-  {    numPhElecPMT10++;}
-  void bumpnumPhElecPMT11()
-  {    numPhElecPMT11++;}
-  void bumpnumPhElecPMT12()
-  {    numPhElecPMT12++;}
-  void bumpnumPhElecPMT13()
-  {    numPhElecPMT13++;}
-  void bumpnumPhElecPMT14()
-  {    numPhElecPMT14++;}
-  void bumpnumPhElecPMT15()
-  {    numPhElecPMT15++;}
-  void bumpnumPhEnterPMT0QW()
-  {numPhEnterPMT0QW++;}
-  void bumpnumPhEnterPMT1QW()
-  {numPhEnterPMT1QW++;}
-  void bumpnumPhEnterPMT2QW()
-  {numPhEnterPMT2QW++;}
-  void bumpnumPhEnterPMT3QW()
-  {numPhEnterPMT3QW++;}
-  void bumpnumPhEnterPMT4QW()
-  {numPhEnterPMT4QW++;}
-  void bumpnumPhEnterPMT5QW()
-  {numPhEnterPMT5QW++;}
-  void bumpnumPhEnterPMT6QW()
-  {numPhEnterPMT6QW++;}
-  void bumpnumPhEnterPMT7QW()
-  {numPhEnterPMT7QW++;}
-  void bumpnumPhEnterPMT8QW()
-  {numPhEnterPMT8QW++;}
-  void bumpnumPhEnterPMT9QW()
-  {numPhEnterPMT9QW++;}
-  void bumpnumPhEnterPMT10QW()
-  {numPhEnterPMT10QW++;}
-  void bumpnumPhEnterPMT11QW()
-  {numPhEnterPMT11QW++;}
-  void bumpnumPhEnterPMT12QW()
-  {numPhEnterPMT12QW++;}
-  void bumpnumPhEnterPMT13QW()
-  {numPhEnterPMT13QW++;}
-  void bumpnumPhEnterPMT14QW()
-  {numPhEnterPMT14QW++;}
-  void bumpnumPhEnterPMT15QW()
-  {numPhEnterPMT15QW++;}
-  void bumpnumPhEnterAnPMTQW()
-  {  numPhEnterAnPMTQW++; }
-
-  void bumpnumHitTotHpd0()
-  { numHitTotHpd0++; }
-
-  void bumpnumHitSignalHpd0(){numHitSignalHpd0++;}
-
-
+  static RichTbCounter *getRichTbCounterInstance();
+
+  void bumpnumHitTotProd() { numHitTotProd++; }
+  void bumpnumhitTotEv() { numhitTotEv++; }
+  void bumpnumhitTotEvCentralPmt() { numhitTotEvCentralPmt++; }
+  void bumpnumhitTotEvCentralPmtJura() { numhitTotEvCentralPmtJura++; }
+  void bumpnumhitTotEvCentralPmtSaleve() { numhitTotEvCentralPmtSaleve++; }
+
+  void bumpnumhitPMT0() { numhitPMT0++; }
+  void bumpnumhitPMT1() { numhitPMT1++; }
+  void bumpnumhitPMT2() { numhitPMT2++; }
+  void bumpnumhitPMT3() { numhitPMT3++; }
+  void bumpnumhitPMT4() { numhitPMT4++; }
+  void bumpnumhitPMT5() { numhitPMT5++; }
+  void bumpnumhitPMT6() { numhitPMT6++; }
+  void bumpnumhitPMT7() { numhitPMT7++; }
+  void bumpnumhitPMT8() { numhitPMT8++; }
+  void bumpnumhitPMT9() { numhitPMT9++; }
+  void bumpnumhitPMT10() { numhitPMT10++; }
+  void bumpnumhitPMT11() { numhitPMT11++; }
+  void bumpnumhitPMT12() { numhitPMT12++; }
+  void bumpnumhitPMT13() { numhitPMT13++; }
+  void bumpnumhitPMT14() { numhitPMT14++; }
+  void bumpnumhitPMT15() { numhitPMT15++; }
+
+  void bumpnumPhEnterMirror() { numPhEnterMirror++; }
+  void bumpnumPhEnterPhSupFrame() { numPhEnterPhSupFrame++; }
+  void bumpnumExitGasQuWin() { numExitGasQuWin++; }
+  void bumpnumPhElecPMT0() { numPhElecPMT0++; }
+  void bumpnumPhElecPMT1() { numPhElecPMT1++; }
+  void bumpnumPhElecPMT2() { numPhElecPMT2++; }
+  void bumpnumPhElecPMT3() { numPhElecPMT3++; }
+  void bumpnumPhElecPMT4() { numPhElecPMT4++; }
+  void bumpnumPhElecPMT5() { numPhElecPMT5++; }
+  void bumpnumPhElecPMT6() { numPhElecPMT6++; }
+  void bumpnumPhElecPMT7() { numPhElecPMT7++; }
+  void bumpnumPhElecPMT8() { numPhElecPMT8++; }
+  void bumpnumPhElecPMT9() { numPhElecPMT9++; }
+  void bumpnumPhElecPMT10() { numPhElecPMT10++; }
+  void bumpnumPhElecPMT11() { numPhElecPMT11++; }
+  void bumpnumPhElecPMT12() { numPhElecPMT12++; }
+  void bumpnumPhElecPMT13() { numPhElecPMT13++; }
+  void bumpnumPhElecPMT14() { numPhElecPMT14++; }
+  void bumpnumPhElecPMT15() { numPhElecPMT15++; }
+  void bumpnumPhEnterPMT0QW() { numPhEnterPMT0QW++; }
+  void bumpnumPhEnterPMT1QW() { numPhEnterPMT1QW++; }
+  void bumpnumPhEnterPMT2QW() { numPhEnterPMT2QW++; }
+  void bumpnumPhEnterPMT3QW() { numPhEnterPMT3QW++; }
+  void bumpnumPhEnterPMT4QW() { numPhEnterPMT4QW++; }
+  void bumpnumPhEnterPMT5QW() { numPhEnterPMT5QW++; }
+  void bumpnumPhEnterPMT6QW() { numPhEnterPMT6QW++; }
+  void bumpnumPhEnterPMT7QW() { numPhEnterPMT7QW++; }
+  void bumpnumPhEnterPMT8QW() { numPhEnterPMT8QW++; }
+  void bumpnumPhEnterPMT9QW() { numPhEnterPMT9QW++; }
+  void bumpnumPhEnterPMT10QW() { numPhEnterPMT10QW++; }
+  void bumpnumPhEnterPMT11QW() { numPhEnterPMT11QW++; }
+  void bumpnumPhEnterPMT12QW() { numPhEnterPMT12QW++; }
+  void bumpnumPhEnterPMT13QW() { numPhEnterPMT13QW++; }
+  void bumpnumPhEnterPMT14QW() { numPhEnterPMT14QW++; }
+  void bumpnumPhEnterPMT15QW() { numPhEnterPMT15QW++; }
+  void bumpnumPhEnterAnPMTQW() { numPhEnterAnPMTQW++; }
+
+  void bumpnumHitTotHpd0() { numHitTotHpd0++; }
+
+  void bumpnumHitSignalHpd0() { numHitSignalHpd0++; }
 
   void resetRichTbCounter();
-  G4int getnumHitTotProd() {return numHitTotProd;}
-  G4int getnumhitTotEv()
-  {  return numhitTotEv; }
-
-  G4int getnumhitTotEvCentralPmt()
-  {  return numhitTotEvCentralPmt;}
-
-  G4int getnumhitTotEvCentralPmtJura()
-  {  return numhitTotEvCentralPmtJura;}
-  G4int getnumhitTotEvCentralPmtSaleve()
-  {  return numhitTotEvCentralPmtSaleve;}
-
-  G4int getnumhitPMT0()
-  { return numhitPMT0;}
-  G4int getnumhitPMT1()
-  { return numhitPMT1;}
-  G4int getnumhitPMT2()
-  { return numhitPMT2;}
-  G4int getnumhitPMT3()
-  { return numhitPMT3;}
-  G4int getnumhitPMT4()
-  { return numhitPMT4;}
-  G4int getnumhitPMT5()
-  { return numhitPMT5;}
-  G4int getnumhitPMT6()
-  { return numhitPMT6;}
-  G4int getnumhitPMT7()
-  { return numhitPMT7;}
-  G4int getnumhitPMT8()
-  { return numhitPMT8;}
-  G4int getnumhitPMT9()
-  { return numhitPMT9;}
-  G4int getnumhitPMT10()
-  { return numhitPMT10;}
-  G4int getnumhitPMT11()
-  { return numhitPMT11;}
-  G4int getnumhitPMT12()
-  { return numhitPMT12;}
-  G4int getnumhitPMT13()
-  { return numhitPMT13;}
-  G4int getnumhitPMT14()
-  { return numhitPMT14;}
-  G4int getnumhitPMT15()
-  { return numhitPMT15;}
-  G4int getnumPhEnterMirror()
-  {    return numPhEnterMirror;}
-  G4int getnumPhEnterPhSupFrame()
-  {    return numPhEnterPhSupFrame;}
-  G4int getnumExitGasQuWin() {return numExitGasQuWin;}
-
-  G4int getnumPhElecPMT0()
-  {    return  numPhElecPMT0;}
-  G4int getnumPhElecPMT1()
-  {    return  numPhElecPMT1;}
-  G4int getnumPhElecPMT2()
-  {    return  numPhElecPMT2;}
-  G4int getnumPhElecPMT3()
-  {    return  numPhElecPMT3;}
-  G4int getnumPhElecPMT4()
-  {    return  numPhElecPMT4;}
-  G4int getnumPhElecPMT5()
-  {    return  numPhElecPMT5;}
-  G4int getnumPhElecPMT6()
-  {    return  numPhElecPMT6;}
-  G4int getnumPhElecPMT7()
-  {    return  numPhElecPMT7;}
-  G4int getnumPhElecPMT8()
-  {    return  numPhElecPMT8;}
-  G4int getnumPhElecPMT9()
-  {    return  numPhElecPMT9;}
-  G4int getnumPhElecPMT10()
-  {    return  numPhElecPMT10;}
-  G4int getnumPhElecPMT11()
-  {    return  numPhElecPMT11;}
-  G4int getnumPhElecPMT12()
-  {    return  numPhElecPMT12;}
-  G4int getnumPhElecPMT13()
-  {    return  numPhElecPMT13;}
-  G4int getnumPhElecPMT14()
-  {    return  numPhElecPMT14;}
-  G4int getnumPhElecPMT15()
-  {    return  numPhElecPMT15;}
-
-
-
-  G4int getnumPhEnterPMT0QW()
-  {  return  numPhEnterPMT0QW;}
-  G4int getnumPhEnterPMT1QW()
-  {  return  numPhEnterPMT1QW;}
-  G4int getnumPhEnterPMT2QW()
-  {  return  numPhEnterPMT2QW;}
-  G4int getnumPhEnterPMT3QW()
-  {  return  numPhEnterPMT3QW;}
-  G4int getnumPhEnterPMT4QW()
-  {  return  numPhEnterPMT4QW;}
-  G4int getnumPhEnterPMT5QW()
-  {  return  numPhEnterPMT5QW;}
-  G4int getnumPhEnterPMT6QW()
-  {  return  numPhEnterPMT6QW;}
-  G4int getnumPhEnterPMT7QW()
-  {  return  numPhEnterPMT7QW;}
-  G4int getnumPhEnterPMT8QW()
-  {  return  numPhEnterPMT8QW;}
-  G4int getnumPhEnterPMT9QW()
-  {  return  numPhEnterPMT9QW;}
-  G4int getnumPhEnterPMT10QW()
-  {  return  numPhEnterPMT10QW;}
-  G4int getnumPhEnterPMT11QW()
-  {  return  numPhEnterPMT11QW;}
-  G4int getnumPhEnterPMT12QW()
-  {  return  numPhEnterPMT12QW;}
-  G4int getnumPhEnterPMT13QW()
-  {  return  numPhEnterPMT13QW;}
-  G4int getnumPhEnterPMT14QW()
-  {  return  numPhEnterPMT14QW;}
-  G4int getnumPhEnterPMT15QW()
-  {  return  numPhEnterPMT15QW;}
-
-
-  G4int getnumPhEnterAnPMTQW()
-  {    return numPhEnterAnPMTQW;}
-
-  G4int getnumHitTotHpd0()  {  return numHitTotHpd0;}
-  G4int  getnumHitSignalHpd0() {  return numHitSignalHpd0;}
-
-
-  virtual ~RichTbCounter( ); ///< Destructor
+  G4int getnumHitTotProd() { return numHitTotProd; }
+  G4int getnumhitTotEv() { return numhitTotEv; }
+
+  G4int getnumhitTotEvCentralPmt() { return numhitTotEvCentralPmt; }
+
+  G4int getnumhitTotEvCentralPmtJura() { return numhitTotEvCentralPmtJura; }
+  G4int getnumhitTotEvCentralPmtSaleve() { return numhitTotEvCentralPmtSaleve; }
+
+  G4int getnumhitPMT0() { return numhitPMT0; }
+  G4int getnumhitPMT1() { return numhitPMT1; }
+  G4int getnumhitPMT2() { return numhitPMT2; }
+  G4int getnumhitPMT3() { return numhitPMT3; }
+  G4int getnumhitPMT4() { return numhitPMT4; }
+  G4int getnumhitPMT5() { return numhitPMT5; }
+  G4int getnumhitPMT6() { return numhitPMT6; }
+  G4int getnumhitPMT7() { return numhitPMT7; }
+  G4int getnumhitPMT8() { return numhitPMT8; }
+  G4int getnumhitPMT9() { return numhitPMT9; }
+  G4int getnumhitPMT10() { return numhitPMT10; }
+  G4int getnumhitPMT11() { return numhitPMT11; }
+  G4int getnumhitPMT12() { return numhitPMT12; }
+  G4int getnumhitPMT13() { return numhitPMT13; }
+  G4int getnumhitPMT14() { return numhitPMT14; }
+  G4int getnumhitPMT15() { return numhitPMT15; }
+  G4int getnumPhEnterMirror() { return numPhEnterMirror; }
+  G4int getnumPhEnterPhSupFrame() { return numPhEnterPhSupFrame; }
+  G4int getnumExitGasQuWin() { return numExitGasQuWin; }
+
+  G4int getnumPhElecPMT0() { return numPhElecPMT0; }
+  G4int getnumPhElecPMT1() { return numPhElecPMT1; }
+  G4int getnumPhElecPMT2() { return numPhElecPMT2; }
+  G4int getnumPhElecPMT3() { return numPhElecPMT3; }
+  G4int getnumPhElecPMT4() { return numPhElecPMT4; }
+  G4int getnumPhElecPMT5() { return numPhElecPMT5; }
+  G4int getnumPhElecPMT6() { return numPhElecPMT6; }
+  G4int getnumPhElecPMT7() { return numPhElecPMT7; }
+  G4int getnumPhElecPMT8() { return numPhElecPMT8; }
+  G4int getnumPhElecPMT9() { return numPhElecPMT9; }
+  G4int getnumPhElecPMT10() { return numPhElecPMT10; }
+  G4int getnumPhElecPMT11() { return numPhElecPMT11; }
+  G4int getnumPhElecPMT12() { return numPhElecPMT12; }
+  G4int getnumPhElecPMT13() { return numPhElecPMT13; }
+  G4int getnumPhElecPMT14() { return numPhElecPMT14; }
+  G4int getnumPhElecPMT15() { return numPhElecPMT15; }
+
+  G4int getnumPhEnterPMT0QW() { return numPhEnterPMT0QW; }
+  G4int getnumPhEnterPMT1QW() { return numPhEnterPMT1QW; }
+  G4int getnumPhEnterPMT2QW() { return numPhEnterPMT2QW; }
+  G4int getnumPhEnterPMT3QW() { return numPhEnterPMT3QW; }
+  G4int getnumPhEnterPMT4QW() { return numPhEnterPMT4QW; }
+  G4int getnumPhEnterPMT5QW() { return numPhEnterPMT5QW; }
+  G4int getnumPhEnterPMT6QW() { return numPhEnterPMT6QW; }
+  G4int getnumPhEnterPMT7QW() { return numPhEnterPMT7QW; }
+  G4int getnumPhEnterPMT8QW() { return numPhEnterPMT8QW; }
+  G4int getnumPhEnterPMT9QW() { return numPhEnterPMT9QW; }
+  G4int getnumPhEnterPMT10QW() { return numPhEnterPMT10QW; }
+  G4int getnumPhEnterPMT11QW() { return numPhEnterPMT11QW; }
+  G4int getnumPhEnterPMT12QW() { return numPhEnterPMT12QW; }
+  G4int getnumPhEnterPMT13QW() { return numPhEnterPMT13QW; }
+  G4int getnumPhEnterPMT14QW() { return numPhEnterPMT14QW; }
+  G4int getnumPhEnterPMT15QW() { return numPhEnterPMT15QW; }
+
+  G4int getnumPhEnterAnPMTQW() { return numPhEnterAnPMTQW; }
+
+  G4int getnumHitTotHpd0() { return numHitTotHpd0; }
+  G4int getnumHitSignalHpd0() { return numHitSignalHpd0; }
+
+  virtual ~RichTbCounter(); ///< Destructor
 
 protected:
-
 private:
-
   /// Standard constructor
-  RichTbCounter( );
-  static  RichTbCounter*  RichTbCounterInstance;
+  RichTbCounter();
+  static RichTbCounter *RichTbCounterInstance;
 
   G4int numHitTotProd;
   G4int numhitTotEv;
@@ -284,7 +161,6 @@ private:
   G4int numhitTotEvCentralPmtJura;
   G4int numhitTotEvCentralPmtSaleve;
 
-
   G4int numhitPMT0;
   G4int numhitPMT1;
   G4int numhitPMT2;
@@ -339,10 +215,7 @@ private:
   G4int numPhElecPMT14;
   G4int numPhElecPMT15;
 
-
-
   G4int numHitTotHpd0;
   G4int numHitSignalHpd0;
-
 };
 #endif // INCLUDE_RICHTBCOUNTER_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCrystalCoverGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCrystalCoverGeometryParameters.hh
index d186f6c2720e25ef141fba8642d2a0e9a58e6aa6..49808e297645d637a85875eaf43774d496e920e3 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCrystalCoverGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCrystalCoverGeometryParameters.hh
@@ -1,54 +1,55 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBCRYSTALCOVERGEOMETRYPARAMETERS_HH 
+#ifndef INCLUDE_RICHTBCRYSTALCOVERGEOMETRYPARAMETERS_HH
 #define INCLUDE_RICHTBCRYSTALCOVERGEOMETRYPARAMETERS_HH 1
 
 // Include files
 /** @class RichTbVesselGeometryParameters RichTbVesselGeometryParameters.hh include/RichTbVesselGeometryParameters.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-10-21
  */
 // first for the overall vessel.
-const G4double RichTbCrystalCoverXSize=100.0*CLHEP::mm + 6.0*CLHEP::mm;
-const G4double RichTbCrystalCoverYSize=100.0*CLHEP::mm + 6.0*CLHEP::mm;
-const G4double RichTbCrystalCoverZSize=7.6*CLHEP::mm + 3.0*CLHEP::mm;
+const G4double RichTbCrystalCoverXSize = 100.0 * CLHEP::mm + 6.0 * CLHEP::mm;
+const G4double RichTbCrystalCoverYSize = 100.0 * CLHEP::mm + 6.0 * CLHEP::mm;
+const G4double RichTbCrystalCoverZSize = 7.6 * CLHEP::mm + 3.0 * CLHEP::mm;
 
-const G4double RichTbCrystalCoverOriginShiftFromLeftEdgeX=0.0*CLHEP::mm;
-const G4double RichTbCrystalCoverOriginShiftFromFloorY=0.0*CLHEP::mm;
-const G4double RichTbCrystalCoverOriginShiftFromLeftZ=0.0*CLHEP::mm;
+const G4double RichTbCrystalCoverOriginShiftFromLeftEdgeX = 0.0 * CLHEP::mm;
+const G4double RichTbCrystalCoverOriginShiftFromFloorY = 0.0 * CLHEP::mm;
+const G4double RichTbCrystalCoverOriginShiftFromLeftZ = 0.0 * CLHEP::mm;
 
-const G4double RichTbCrystalCoverSubPartXSize=100.0*CLHEP::mm;
-const G4double RichTbCrystalCoverSubPartYSize=100.0*CLHEP::mm;
-const G4double RichTbCrystalCoverSubPartZSize=100.0*CLHEP::mm;
+const G4double RichTbCrystalCoverSubPartXSize = 100.0 * CLHEP::mm;
+const G4double RichTbCrystalCoverSubPartYSize = 100.0 * CLHEP::mm;
+const G4double RichTbCrystalCoverSubPartZSize = 100.0 * CLHEP::mm;
 
-const G4double RichTbCrystalCoverYLocation = - RichTbCrystalCoverOriginShiftFromFloorY;
+const G4double RichTbCrystalCoverYLocation = -RichTbCrystalCoverOriginShiftFromFloorY;
 const G4double RichTbCrystalCoverXShiftAlongCrystal = RichTbCrystalCoverOriginShiftFromLeftEdgeX;
 const G4double RichTbCrystalCoverZShiftAlongCrystal = -RichTbCrystalCoverOriginShiftFromLeftZ;
 
 const G4double RichTbCrystalCoverXLocation = RichTbCrystalCoverXShiftAlongCrystal;
-const G4double RichTbCrystalCoverZLocation = -1.5*CLHEP::mm;
+const G4double RichTbCrystalCoverZLocation = -1.5 * CLHEP::mm;
 
-const G4double RichTbCrystalCoverSubPartXLocation = 0.0*CLHEP::mm;
-const G4double RichTbCrystalCoverSubPartYLocation = 0.0*CLHEP::mm;
-const G4double RichTbCrystalCoverSubPartZLocation =0.5 * (RichTbCrystalCoverSubPartZSize - RichTbCrystalCoverZSize) + 2.5*CLHEP::mm;
+const G4double RichTbCrystalCoverSubPartXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbCrystalCoverSubPartYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbCrystalCoverSubPartZLocation =
+    0.5 * (RichTbCrystalCoverSubPartZSize - RichTbCrystalCoverZSize) + 2.5 * CLHEP::mm;
 
 // now for variables used after creating the geometry in stepaction.
 
-const G4double RichTbCrystalCoverEnvPlateThickness=0.0*CLHEP::mm;
+const G4double RichTbCrystalCoverEnvPlateThickness = 0.0 * CLHEP::mm;
 // the following are not exact values.
-//const G4double  RichTbCrystalXNegExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX-RichTbCrystalXSize;
-//const G4double  RichTbCrystalXPosExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX;
-//const G4double  RichTbCrystalZUpsExtremeAlongCrystal= -RichTbCrystalUpsExternalPartZSize;
-//const G4double  RichTbCrystalZDnsExtremeAlongCrystal= -RichTbcrystalUpsExternalPartZSize+RichTbCrystalZSize;
-//const G4double  RichTbCrystalXNegExtreme=  RichTbCrystalXNegExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
+// const G4double  RichTbCrystalXNegExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX-RichTbCrystalXSize;
+// const G4double  RichTbCrystalXPosExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX;
+// const G4double  RichTbCrystalZUpsExtremeAlongCrystal= -RichTbCrystalUpsExternalPartZSize;
+// const G4double  RichTbCrystalZDnsExtremeAlongCrystal= -RichTbcrystalUpsExternalPartZSize+RichTbCrystalZSize;
+// const G4double  RichTbCrystalXNegExtreme=  RichTbCrystalXNegExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
 //                                          RichTbCrystalZDnsExtremeAlongCrystal*sin(RichTbCrystalYRotation);
-//const G4double  RichTbCrystalXPosExtreme=  RichTbCrystalXPosExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
+// const G4double  RichTbCrystalXPosExtreme=  RichTbCrystalXPosExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
 //                                          RichTbCrystalZUpsExtremeAlongCrystal*sin(RichTbCrystalYRotation);
 
-//const G4double  RichTbCrystalYNegExtreme= RichTbCrystalYLocation-0.5*RichTbCrystalYSize;
-//const G4double  RichTbCrystalYPosExtreme= RichTbCrystalYLocation+0.5*RichTbCrystalYSize;
-//const G4double  RichTbCrystalZDnsExtreme = -RichTbCrystalXNegExtremeAlongCrystal*sin(RichTbCrystalYRotation)+
+// const G4double  RichTbCrystalYNegExtreme= RichTbCrystalYLocation-0.5*RichTbCrystalYSize;
+// const G4double  RichTbCrystalYPosExtreme= RichTbCrystalYLocation+0.5*RichTbCrystalYSize;
+// const G4double  RichTbCrystalZDnsExtreme = -RichTbCrystalXNegExtremeAlongCrystal*sin(RichTbCrystalYRotation)+
 //                                        RichTbCrystalZDnsExtremeAlongCrystal*cos(RichTbCrystalYRotation);
-//const G4double  RichTbCrystalDnsZEnd = RichTbCrystalZDnsExtreme;
+// const G4double  RichTbCrystalDnsZEnd = RichTbCrystalZDnsExtreme;
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCrystalGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCrystalGeometryParameters.hh
index 24868c44e2e86ca63865c91f279f3575b02bc61a..545baf55003e2e5aec22bf507c1f6616808bba7c 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCrystalGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCrystalGeometryParameters.hh
@@ -1,49 +1,49 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBCRYSTALGEOMETRYPARAMETERS_HH 
+#ifndef INCLUDE_RICHTBCRYSTALGEOMETRYPARAMETERS_HH
 #define INCLUDE_RICHTBCRYSTALGEOMETRYPARAMETERS_HH 1
 
 // Include files
 /** @class RichTbVesselGeometryParameters RichTbVesselGeometryParameters.hh include/RichTbVesselGeometryParameters.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-10-21
  */
 
-const G4double RichTbCrystalXSize=100.0*CLHEP::mm;
-const G4double RichTbCrystalYSize=100.0*CLHEP::mm;
-const G4double RichTbCrystalZSize=10.0*CLHEP::mm;
+const G4double RichTbCrystalXSize = 100.0 * CLHEP::mm;
+const G4double RichTbCrystalYSize = 100.0 * CLHEP::mm;
+const G4double RichTbCrystalZSize = 10.0 * CLHEP::mm;
 
-//const G4double RichTbCrystalOriginShiftFromLeftEdgeX=0.0*CLHEP::mm;  // for now assume middle part. to be verified.
-//const G4double RichTbCrystalOriginShiftFromFloorY=0.0*CLHEP::mm;
-//const G4double RichTbCrystalOriginShiftFromLeftZ=0.0*CLHEP::mm;
-//G4double CrystalXRotation = appoConfig ->getSpecialStudyCrystalRotationX();
-//const G4double RichTbCrystalXRotation=CrystalXRotation*rad;  
-//G4double CrystalYRotation = appoConfig ->getSpecialStudyCrystalRotationY();
-//const G4double RichTbCrystalYRotation=CrystalYRotation*rad;
+// const G4double RichTbCrystalOriginShiftFromLeftEdgeX=0.0*CLHEP::mm;  // for now assume middle part. to be verified.
+// const G4double RichTbCrystalOriginShiftFromFloorY=0.0*CLHEP::mm;
+// const G4double RichTbCrystalOriginShiftFromLeftZ=0.0*CLHEP::mm;
+// G4double CrystalXRotation = appoConfig ->getSpecialStudyCrystalRotationX();
+// const G4double RichTbCrystalXRotation=CrystalXRotation*rad;
+// G4double CrystalYRotation = appoConfig ->getSpecialStudyCrystalRotationY();
+// const G4double RichTbCrystalYRotation=CrystalYRotation*rad;
 const G4double RichTbCrystalYLocation = 0.0;
-//const G4double RichTbCrystalXShiftAlongCrystal = RichTbCrystalOriginShiftFromLeftEdgeX;
-//const G4double RichTbCrystalZShiftAlongCrystal = -RichTbCrystalOriginShiftFromLeftZ;
+// const G4double RichTbCrystalXShiftAlongCrystal = RichTbCrystalOriginShiftFromLeftEdgeX;
+// const G4double RichTbCrystalZShiftAlongCrystal = -RichTbCrystalOriginShiftFromLeftZ;
 
 const G4double RichTbCrystalXLocation = 0.0;
-const G4double RichTbCrystalZLocation = 0.0*CLHEP::mm;
+const G4double RichTbCrystalZLocation = 0.0 * CLHEP::mm;
 
 // now for variables used after creating the geometry in stepaction.
 
-const G4double RichTbCrystalEnvPlateThickness=0.0*CLHEP::mm;
+const G4double RichTbCrystalEnvPlateThickness = 0.0 * CLHEP::mm;
 // the following are not exact values.
-//const G4double  RichTbCrystalXNegExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX-RichTbCrystalXSize;
-//const G4double  RichTbCrystalXPosExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX;
-//const G4double  RichTbCrystalZUpsExtremeAlongCrystal= -RichTbCrystalUpsExternalPartZSize;
-//const G4double  RichTbCrystalZDnsExtremeAlongCrystal= -RichTbcrystalUpsExternalPartZSize+RichTbCrystalZSize;
-//const G4double  RichTbCrystalXNegExtreme=  RichTbCrystalXNegExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
+// const G4double  RichTbCrystalXNegExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX-RichTbCrystalXSize;
+// const G4double  RichTbCrystalXPosExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX;
+// const G4double  RichTbCrystalZUpsExtremeAlongCrystal= -RichTbCrystalUpsExternalPartZSize;
+// const G4double  RichTbCrystalZDnsExtremeAlongCrystal= -RichTbcrystalUpsExternalPartZSize+RichTbCrystalZSize;
+// const G4double  RichTbCrystalXNegExtreme=  RichTbCrystalXNegExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
 //                                          RichTbCrystalZDnsExtremeAlongCrystal*sin(RichTbCrystalYRotation);
-//const G4double  RichTbCrystalXPosExtreme=  RichTbCrystalXPosExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
+// const G4double  RichTbCrystalXPosExtreme=  RichTbCrystalXPosExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
 //                                          RichTbCrystalZUpsExtremeAlongCrystal*sin(RichTbCrystalYRotation);
 
-//const G4double  RichTbCrystalYNegExtreme= RichTbCrystalYLocation-0.5*RichTbCrystalYSize;
-//const G4double  RichTbCrystalYPosExtreme= RichTbCrystalYLocation+0.5*RichTbCrystalYSize;
-//const G4double  RichTbCrystalZDnsExtreme = -RichTbCrystalXNegExtremeAlongCrystal*sin(RichTbCrystalYRotation)+
+// const G4double  RichTbCrystalYNegExtreme= RichTbCrystalYLocation-0.5*RichTbCrystalYSize;
+// const G4double  RichTbCrystalYPosExtreme= RichTbCrystalYLocation+0.5*RichTbCrystalYSize;
+// const G4double  RichTbCrystalZDnsExtreme = -RichTbCrystalXNegExtremeAlongCrystal*sin(RichTbCrystalYRotation)+
 //                                        RichTbCrystalZDnsExtremeAlongCrystal*cos(RichTbCrystalYRotation);
-//const G4double  RichTbCrystalDnsZEnd = RichTbCrystalZDnsExtreme;
+// const G4double  RichTbCrystalDnsZEnd = RichTbCrystalZDnsExtreme;
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCrystalMasterGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCrystalMasterGeometryParameters.hh
index 208acbff00121dac5f3940e4d3667e9f61e1f764..62a78be3b6fb7a81ead4b124a02f4dccde654277 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCrystalMasterGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbCrystalMasterGeometryParameters.hh
@@ -1,54 +1,50 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBCRYSTALMASTERGEOMETRYPARAMETERS_HH 
+#ifndef INCLUDE_RICHTBCRYSTALMASTERGEOMETRYPARAMETERS_HH
 #define INCLUDE_RICHTBCRYSTALMASTERGEOMETRYPARAMETERS_HH 1
 
 // Include files
 /** @class RichTbVesselGeometryParameters RichTbVesselGeometryParameters.hh include/RichTbVesselGeometryParameters.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-10-21
  */
 
-const G4double RichTbCrystalMasterXSize=400.0*CLHEP::mm;
-const G4double RichTbCrystalMasterYSize=600.0*CLHEP::mm;
-const G4double RichTbCrystalMasterZSize=1500.0*CLHEP::mm;
-
-//const G4double RichTbCrystalMasterOriginShiftFromLeftEdgeX=0.0*CLHEP::mm;  // for now assume middle part. to be verified.
-//const G4double RichTbCrystalMasterOriginShiftFromFloorY=0.0*CLHEP::mm;
-//const G4double RichTbCrystalMasterOriginShiftFromLeftZ=300.0*CLHEP::mm;
-//G4double CrystalXRotation = appoConfig ->getSpecialStudyCrystalRotationX();
-//const G4double RichTbCrystalXRotation=CrystalXRotation*rad;  
-//G4double CrystalYRotation = appoConfig ->getSpecialStudyCrystalRotationY();
-//const G4double RichTbCrystalYRotation=CrystalYRotation*rad;
+const G4double RichTbCrystalMasterXSize = 400.0 * CLHEP::mm;
+const G4double RichTbCrystalMasterYSize = 600.0 * CLHEP::mm;
+const G4double RichTbCrystalMasterZSize = 1500.0 * CLHEP::mm;
+
+// const G4double RichTbCrystalMasterOriginShiftFromLeftEdgeX=0.0*CLHEP::mm;  // for now assume middle part. to be
+// verified.  const G4double RichTbCrystalMasterOriginShiftFromFloorY=0.0*CLHEP::mm;  const G4double
+// RichTbCrystalMasterOriginShiftFromLeftZ=300.0*CLHEP::mm;  G4double CrystalXRotation = appoConfig
+// ->getSpecialStudyCrystalRotationX();  const G4double RichTbCrystalXRotation=CrystalXRotation*rad;  G4double
+// CrystalYRotation = appoConfig ->getSpecialStudyCrystalRotationY();  const G4double
+// RichTbCrystalYRotation=CrystalYRotation*rad;
 const G4double RichTbCrystalMasterYLocation = 0.0;
-//const G4double RichTbCrystalMasterXShiftAlongCrystal = RichTbCrystalMasterOriginShiftFromLeftEdgeX;
-//const G4double RichTbCrystalMasterZShiftAlongCrystal = -RichTbCrystalMasterOriginShiftFromLeftZ + 0.5 * RichTbCrystalMasterZSize;
+// const G4double RichTbCrystalMasterXShiftAlongCrystal = RichTbCrystalMasterOriginShiftFromLeftEdgeX;
+// const G4double RichTbCrystalMasterZShiftAlongCrystal = -RichTbCrystalMasterOriginShiftFromLeftZ + 0.5 *
+// RichTbCrystalMasterZSize;
 
 const G4double RichTbCrystalMasterXLocation = 0.0;
-const G4double RichTbCrystalMasterZLocation = -250*CLHEP::mm ;
+const G4double RichTbCrystalMasterZLocation = -250 * CLHEP::mm;
 
 // now for variables used after creating the geometry in stepaction.
 
-const G4double RichTbCrystalMasterEnvPlateThickness=0.0*CLHEP::mm;
-
-
-
-
+const G4double RichTbCrystalMasterEnvPlateThickness = 0.0 * CLHEP::mm;
 
 // the following are not exact values.
-//const G4double  RichTbCrystalXNegExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX-RichTbCrystalXSize;
-//const G4double  RichTbCrystalXPosExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX;
-//const G4double  RichTbCrystalZUpsExtremeAlongCrystal= -RichTbCrystalUpsExternalPartZSize;
-//const G4double  RichTbCrystalZDnsExtremeAlongCrystal= -RichTbcrystalUpsExternalPartZSize+RichTbCrystalZSize;
-//const G4double  RichTbCrystalXNegExtreme=  RichTbCrystalXNegExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
+// const G4double  RichTbCrystalXNegExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX-RichTbCrystalXSize;
+// const G4double  RichTbCrystalXPosExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX;
+// const G4double  RichTbCrystalZUpsExtremeAlongCrystal= -RichTbCrystalUpsExternalPartZSize;
+// const G4double  RichTbCrystalZDnsExtremeAlongCrystal= -RichTbcrystalUpsExternalPartZSize+RichTbCrystalZSize;
+// const G4double  RichTbCrystalXNegExtreme=  RichTbCrystalXNegExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
 //                                          RichTbCrystalZDnsExtremeAlongCrystal*sin(RichTbCrystalYRotation);
-//const G4double  RichTbCrystalXPosExtreme=  RichTbCrystalXPosExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
+// const G4double  RichTbCrystalXPosExtreme=  RichTbCrystalXPosExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
 //                                          RichTbCrystalZUpsExtremeAlongCrystal*sin(RichTbCrystalYRotation);
 
-//const G4double  RichTbCrystalYNegExtreme= RichTbCrystalYLocation-0.5*RichTbCrystalYSize;
-//const G4double  RichTbCrystalYPosExtreme= RichTbCrystalYLocation+0.5*RichTbCrystalYSize;
-//const G4double  RichTbCrystalZDnsExtreme = -RichTbCrystalXNegExtremeAlongCrystal*sin(RichTbCrystalYRotation)+
+// const G4double  RichTbCrystalYNegExtreme= RichTbCrystalYLocation-0.5*RichTbCrystalYSize;
+// const G4double  RichTbCrystalYPosExtreme= RichTbCrystalYLocation+0.5*RichTbCrystalYSize;
+// const G4double  RichTbCrystalZDnsExtreme = -RichTbCrystalXNegExtremeAlongCrystal*sin(RichTbCrystalYRotation)+
 //                                        RichTbCrystalZDnsExtremeAlongCrystal*cos(RichTbCrystalYRotation);
-//const G4double  RichTbCrystalDnsZEnd = RichTbCrystalZDnsExtreme;
+// const G4double  RichTbCrystalDnsZEnd = RichTbCrystalZDnsExtreme;
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbDarkCoverGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbDarkCoverGeometryParameters.hh
index 04a4462c2e984153a00b05d8fc184ac3006200fe..69e9607835f4a6ed71a954ef1148b97af9bacf90 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbDarkCoverGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbDarkCoverGeometryParameters.hh
@@ -10,80 +10,74 @@
  *  @date   2003-10-21
  */
 
-const G4double RichTbUpgradeDarkCoverXSize=17.0*2.0*CLHEP::mm;
-
-//const G4double RichTbUpgradeDarkCoverXSize=(27.0*CLHEP::mm - 10*CLHEP::mm)*2*0.9;
-const G4double RichTbUpgradeDarkCoverYSize=70.0*CLHEP::mm;
-//const G4double RichTbUpgradeDarkCoverZSize=1.0*CLHEP::mm;
-const G4double RichTbUpgradeDarkCoverZSize=2.0*CLHEP::mm;
+const G4double RichTbUpgradeDarkCoverXSize = 17.0 * 2.0 * CLHEP::mm;
 
+// const G4double RichTbUpgradeDarkCoverXSize=(27.0*CLHEP::mm - 10*CLHEP::mm)*2*0.9;
+const G4double RichTbUpgradeDarkCoverYSize = 70.0 * CLHEP::mm;
+// const G4double RichTbUpgradeDarkCoverZSize=1.0*CLHEP::mm;
+const G4double RichTbUpgradeDarkCoverZSize = 2.0 * CLHEP::mm;
 
 const G4double RichTbUpgradeDarkCoverYLocation = 0.0;
 
 const G4double RichTbUpgradeDarkCoverXLocation = 0.0;
-//const G4double RichTbUpgradeDarkCoverZLocation =138.4*CLHEP::mm - 26.5*CLHEP::mm + 1*CLHEP::mm;
-
-//const G4double RichTbUpgradeDarkCoverZLocation =-SphereRadius  + RadiatorLensThickness   + 1*CLHEP::mm;
-
-const G4double RichTbUpgradeDarkCoverZLocation =-SphereRadius  + RadiatorLensThickness   +
-                               0.5* RichTbUpgradeDarkCoverZSize;
+// const G4double RichTbUpgradeDarkCoverZLocation =138.4*CLHEP::mm - 26.5*CLHEP::mm + 1*CLHEP::mm;
 
+// const G4double RichTbUpgradeDarkCoverZLocation =-SphereRadius  + RadiatorLensThickness   + 1*CLHEP::mm;
 
+const G4double RichTbUpgradeDarkCoverZLocation =
+    -SphereRadius + RadiatorLensThickness + 0.5 * RichTbUpgradeDarkCoverZSize;
 
-const G4double RichTbUpgradeDarkCoverEnvPlateThickness=0.0*CLHEP::mm;
-
+const G4double RichTbUpgradeDarkCoverEnvPlateThickness = 0.0 * CLHEP::mm;
 
 // now for the darkcover upstream side
-const G4double RichTbDarkUpsInnerRadius = MirrorOuterRadius + 2.0*CLHEP::mm;
-const G4double RichTbDarkUpsOuterRadius = RichTbDarkUpsInnerRadius + 3.0*CLHEP::mm;
+const G4double RichTbDarkUpsInnerRadius = MirrorOuterRadius + 2.0 * CLHEP::mm;
+const G4double RichTbDarkUpsOuterRadius = RichTbDarkUpsInnerRadius + 3.0 * CLHEP::mm;
 
 // now for the dark cover on the two sides of the radiator
-const G4double RichTbRadiatorC2S= SphereRadius - RadiatorLensThickness;
-const G4double RichTbRadiatorLateralHalfSize = std::sqrt(SphereRadius*SphereRadius - RichTbRadiatorC2S*RichTbRadiatorC2S);
-
-//const G4double RichTbDarkSideZSize = RadiatorLensThickness+6.0*CLHEP::mm;
-const G4double RichTbDarkSideZSize = RadiatorLensThickness+25.0*CLHEP::mm;
-const G4double RichTbDarkSideXSize = 2.0*RichTbRadiatorLateralHalfSize;
-const G4double RichTbDarkSideYSize=3.0*CLHEP::mm;
-
-
-const G4double RichTbDarkSideYTopLocation =  MirrorSubBoxShiftY+2.0*CLHEP::mm;
-const G4double RichTbDarkSideYBotLocation =  -1.0*(MirrorSubBoxShiftY+2.0*CLHEP::mm);
-const G4double RichTbDarkSideZLocation  = 0.5*RichTbDarkSideZSize;
-const G4double RichTbDarkSideXLocation  =0.0*CLHEP::mm;
-
-
-//testbeam 2015 upgrade
-const G4double RichTbUpgradeDarkCoverXSize15 = 17.0*2.0*CLHEP::mm;
+const G4double RichTbRadiatorC2S = SphereRadius - RadiatorLensThickness;
+const G4double RichTbRadiatorLateralHalfSize =
+    std::sqrt(SphereRadius * SphereRadius - RichTbRadiatorC2S * RichTbRadiatorC2S);
+
+// const G4double RichTbDarkSideZSize = RadiatorLensThickness+6.0*CLHEP::mm;
+const G4double RichTbDarkSideZSize = RadiatorLensThickness + 25.0 * CLHEP::mm;
+const G4double RichTbDarkSideXSize = 2.0 * RichTbRadiatorLateralHalfSize;
+const G4double RichTbDarkSideYSize = 3.0 * CLHEP::mm;
+
+const G4double RichTbDarkSideYTopLocation = MirrorSubBoxShiftY + 2.0 * CLHEP::mm;
+const G4double RichTbDarkSideYBotLocation = -1.0 * (MirrorSubBoxShiftY + 2.0 * CLHEP::mm);
+const G4double RichTbDarkSideZLocation = 0.5 * RichTbDarkSideZSize;
+const G4double RichTbDarkSideXLocation = 0.0 * CLHEP::mm;
+
+// testbeam 2015 upgrade
+const G4double RichTbUpgradeDarkCoverXSize15 = 17.0 * 2.0 * CLHEP::mm;
 const G4double RichTbUpgradeDarkCoverYSize15 = RichTbUpgradeDarkCoverXSize15;
-const G4double RichTbUpgradeDarkCoverZSize15 = 2.0*CLHEP::mm;
+const G4double RichTbUpgradeDarkCoverZSize15 = 2.0 * CLHEP::mm;
 
 const G4double RichTbUpgradeDarkCoverYLocation15 = 0.0;
 const G4double RichTbUpgradeDarkCoverXLocation15 = 0.0;
-const G4double RichTbUpgradeDarkCoverZLocation15 =-SphereRadius15 + RadiatorLensThickness15 +
-		0.5*RichTbUpgradeDarkCoverZSize;
+const G4double RichTbUpgradeDarkCoverZLocation15 =
+    -SphereRadius15 + RadiatorLensThickness15 + 0.5 * RichTbUpgradeDarkCoverZSize;
 
-//upstream darkcover
-const G4double RichTbDarkUpsInnerRadius15 = MirrorOuterRadius15 + 2.0*CLHEP::mm;
-const G4double RichTbDarkUpsOuterRadius15 = RichTbDarkUpsInnerRadius15 + 3.0*CLHEP::mm;
+// upstream darkcover
+const G4double RichTbDarkUpsInnerRadius15 = MirrorOuterRadius15 + 2.0 * CLHEP::mm;
+const G4double RichTbDarkUpsOuterRadius15 = RichTbDarkUpsInnerRadius15 + 3.0 * CLHEP::mm;
 
-//side darkcovers
-//const G4double RichTbRadiatorC2S15= SphereRadius15 - RadiatorLensThickness15;
-//const G4double RichTbRadiatorLateralHalfSize15 = std::sqrt(SphereRadius15*SphereRadius15 - RichTbRadiatorC2S*RichTbRadiatorC2S);
+// side darkcovers
+// const G4double RichTbRadiatorC2S15= SphereRadius15 - RadiatorLensThickness15;
+// const G4double RichTbRadiatorLateralHalfSize15 = std::sqrt(SphereRadius15*SphereRadius15 -
+// RichTbRadiatorC2S*RichTbRadiatorC2S);
 const G4double RichTbRadiatorLateralHalfSize15 = cylRmax;
-//const G4double RichTbDarkSideZSize = RadiatorLensThickness+6.0*CLHEP::mm;
-const G4double RichTbDarkSideZSize15 = RadiatorLensThickness15+25.0*CLHEP::mm;
-const G4double RichTbDarkSideXSize15 = 2.0*RichTbRadiatorLateralHalfSize15+60.0*CLHEP::mm;
+// const G4double RichTbDarkSideZSize = RadiatorLensThickness+6.0*CLHEP::mm;
+const G4double RichTbDarkSideZSize15 = RadiatorLensThickness15 + 25.0 * CLHEP::mm;
+const G4double RichTbDarkSideXSize15 = 2.0 * RichTbRadiatorLateralHalfSize15 + 60.0 * CLHEP::mm;
 const G4double RichTbDarkSideYSize15 = RichTbDarkSideXSize15;
-const G4double BoxInnZSize15 = RichTbDarkSideZSize15+30.0*CLHEP::mm;
-const G4double BoxInnXSize15 = RichTbDarkSideXSize15-3.0*CLHEP::mm;
-const G4double BoxInnYSize15 = RichTbDarkSideYSize15-3.0*CLHEP::mm;
-
-
-const G4double RichTbDarkSideYLocation15 =  0.0*CLHEP::mm;//RichTbRadiatorLateralHalfSize15+2.0*CLHEP::mm;
-//const G4double RichTbDarkSideYBotLocation15 =  0.0*CLHEP::mm;//-1.0*(RichTbRadiatorLateralHalfSize15+2.0*CLHEP::mm);
-const G4double RichTbDarkSideZLocation15  = 0.5*RichTbDarkSideZSize15;
-const G4double RichTbDarkSideXLocation15  = 0.0*CLHEP::mm;
-
+const G4double BoxInnZSize15 = RichTbDarkSideZSize15 + 30.0 * CLHEP::mm;
+const G4double BoxInnXSize15 = RichTbDarkSideXSize15 - 3.0 * CLHEP::mm;
+const G4double BoxInnYSize15 = RichTbDarkSideYSize15 - 3.0 * CLHEP::mm;
+
+const G4double RichTbDarkSideYLocation15 = 0.0 * CLHEP::mm; // RichTbRadiatorLateralHalfSize15+2.0*CLHEP::mm;
+// const G4double RichTbDarkSideYBotLocation15 =  0.0*CLHEP::mm;//-1.0*(RichTbRadiatorLateralHalfSize15+2.0*CLHEP::mm);
+const G4double RichTbDarkSideZLocation15 = 0.5 * RichTbDarkSideZSize15;
+const G4double RichTbDarkSideXLocation15 = 0.0 * CLHEP::mm;
 
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbEventAction.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbEventAction.hh
index 9811f10303a869edc92ad5714d366ed7db42d90f..8aec171ef299c31174693311df0a160d31fb1a92 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbEventAction.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbEventAction.hh
@@ -5,25 +5,20 @@
 
 class G4Event;
 
-class RichTbEventAction:public G4UserEventAction {
+class RichTbEventAction : public G4UserEventAction {
 
-  public:
-    RichTbEventAction();
-    virtual ~ RichTbEventAction();
-  public:
-    void BeginOfEventAction(const G4Event *);
-    void EndOfEventAction(const G4Event *);
-    G4int GetRichCollID() {
-        return RichTbCollID;
-    }
-    G4int GetRichCollIDHpd() {
-        return RichTbCollIDHpd;
-    }
+public:
+  RichTbEventAction();
+  virtual ~RichTbEventAction();
 
-  private:
-
-    G4int RichTbCollID;
-    G4int RichTbCollIDHpd;
+public:
+  void BeginOfEventAction(const G4Event *) override;
+  void EndOfEventAction(const G4Event *) override;
+  G4int GetRichCollID() { return RichTbCollID; }
+  G4int GetRichCollIDHpd() { return RichTbCollIDHpd; }
 
+private:
+  G4int RichTbCollID;
+  G4int RichTbCollIDHpd;
 };
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbExtHpdGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbExtHpdGeometryParameters.hh
index 4d608ed9676d4ed3b5dd3d6f33f3657dfc4be218..c8c8d398b38cd4be6cb9da9659935049766f5763 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbExtHpdGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbExtHpdGeometryParameters.hh
@@ -4,65 +4,64 @@
 // Include files
 #include <vector>
 
-const G4int NumHpds= 1;
-
-const G4double RichTbHpdMasterRadius = 43.5*CLHEP::mm;
-const G4double RichTbHpdMasterZSize = 160.0*CLHEP::mm;
-
-const G4double RichTbHpdEnvLargeTubeOutR = 40.3*CLHEP::mm;
-const G4double RichTbHpdEnvLargeTubeThickness = 0.75*CLHEP::mm;
-const G4double RichTbHpdEnvLargeTubInnR=
-      RichTbHpdEnvLargeTubeOutR-RichTbHpdEnvLargeTubeThickness;
-
-//const G4double RichTbHpdEnvLargeTubeZSize = 96.0*CLHEP::mm;
-const G4double RichTbHpdEnvLargeTubeZSize = 106.0*CLHEP::mm;
-const G4double RichTbHpdEnvEndCapZsize = 2.0*CLHEP::mm;
-const G4double RichTbHpdEnvEndCapRadTolerence = 0.1*CLHEP::mm;
-const G4double RichTbHpdQuartzWOuterRad = 62.0*CLHEP::mm;
-
-const G4double RichTbHpdQuartzWThickness = 7.0*CLHEP::mm;
-const G4double RichTbHpdPhCathodeThickness= 0.05*CLHEP::mm;
-const G4double RichTbHpdActiveInputRad=37.5*CLHEP::mm;
-const G4double RichTbHpdQuartzWCylEnvInnerR= RichTbHpdActiveInputRad;
-const G4double RichTbHpdQuartzWCylEnvOuterR = 40.3*CLHEP::mm;
-const G4double RichTbHpdEnvFromEndZ= 40.5*CLHEP::mm;
-
-const G4double RichTbHpdQuartzWindowFromEndZ=20.0*CLHEP::mm;
-const G4double RichTbHpdSiDetDistZFromPhCathode=111.2*CLHEP::mm;
-const G4double RichTbHpdQWCylEnvOuterLargeValue=500.0*CLHEP::mm;
-const G4double RichTbHpdQWCylEnvZLargeValue=1000.0*CLHEP::mm;
+const G4int NumHpds = 1;
+
+const G4double RichTbHpdMasterRadius = 43.5 * CLHEP::mm;
+const G4double RichTbHpdMasterZSize = 160.0 * CLHEP::mm;
+
+const G4double RichTbHpdEnvLargeTubeOutR = 40.3 * CLHEP::mm;
+const G4double RichTbHpdEnvLargeTubeThickness = 0.75 * CLHEP::mm;
+const G4double RichTbHpdEnvLargeTubInnR = RichTbHpdEnvLargeTubeOutR - RichTbHpdEnvLargeTubeThickness;
+
+// const G4double RichTbHpdEnvLargeTubeZSize = 96.0*CLHEP::mm;
+const G4double RichTbHpdEnvLargeTubeZSize = 106.0 * CLHEP::mm;
+const G4double RichTbHpdEnvEndCapZsize = 2.0 * CLHEP::mm;
+const G4double RichTbHpdEnvEndCapRadTolerence = 0.1 * CLHEP::mm;
+const G4double RichTbHpdQuartzWOuterRad = 62.0 * CLHEP::mm;
+
+const G4double RichTbHpdQuartzWThickness = 7.0 * CLHEP::mm;
+const G4double RichTbHpdPhCathodeThickness = 0.05 * CLHEP::mm;
+const G4double RichTbHpdActiveInputRad = 37.5 * CLHEP::mm;
+const G4double RichTbHpdQuartzWCylEnvInnerR = RichTbHpdActiveInputRad;
+const G4double RichTbHpdQuartzWCylEnvOuterR = 40.3 * CLHEP::mm;
+const G4double RichTbHpdEnvFromEndZ = 40.5 * CLHEP::mm;
+
+const G4double RichTbHpdQuartzWindowFromEndZ = 20.0 * CLHEP::mm;
+const G4double RichTbHpdSiDetDistZFromPhCathode = 111.2 * CLHEP::mm;
+const G4double RichTbHpdQWCylEnvOuterLargeValue = 500.0 * CLHEP::mm;
+const G4double RichTbHpdQWCylEnvZLargeValue = 1000.0 * CLHEP::mm;
 
 // create a hexagonal array. The max radius is 22 x 0.5
 
-const G4double RichTbHpdSiDetRadiusSize= 11*CLHEP::mm;
-const G4double RichTbHpdSiDetZSize=0.3*CLHEP::mm;
-const G4double RichTbHpdSiDetHexPixelFlatToFlatSize=1.4*CLHEP::mm;
-const G4double RichTbHpdSiDetHexPixelDiagonalSize = RichTbHpdSiDetHexPixelFlatToFlatSize * 2.0/ sqrt(3.0);
-const G4double RichTbHpdSiDetHexPixelEdgeSize= RichTbHpdSiDetHexPixelFlatToFlatSize/sqrt(3.0);
-const G4double RichTbHpdSiDetHexPixelRadius= RichTbHpdSiDetHexPixelDiagonalSize/2.0;
+const G4double RichTbHpdSiDetRadiusSize = 11 * CLHEP::mm;
+const G4double RichTbHpdSiDetZSize = 0.3 * CLHEP::mm;
+const G4double RichTbHpdSiDetHexPixelFlatToFlatSize = 1.4 * CLHEP::mm;
+const G4double RichTbHpdSiDetHexPixelDiagonalSize = RichTbHpdSiDetHexPixelFlatToFlatSize * 2.0 / sqrt(3.0);
+const G4double RichTbHpdSiDetHexPixelEdgeSize = RichTbHpdSiDetHexPixelFlatToFlatSize / sqrt(3.0);
+const G4double RichTbHpdSiDetHexPixelRadius = RichTbHpdSiDetHexPixelDiagonalSize / 2.0;
 const G4double RichTbHpdSiDetPixelZSize = RichTbHpdSiDetZSize;
-const G4double RichTbHpdSiDetPixelHexPhiStart=0.0*CLHEP::rad;
-const G4double RichTbHpdSiDetPixelHexPhiEnd=2.0*CLHEP::pi* CLHEP::rad;
-const G4int RichTbHpdSiDetPixelHexNumSide=6;
-const G4int RichTbHpdSiDetPixelHexNumZPlanes=2;
-const G4double  RichTbHpdSiDetPixelHexZPlane [] = {-0.5*RichTbHpdSiDetPixelZSize, 0.5*RichTbHpdSiDetPixelZSize};
-const G4double  RichTbHpdSiDetPixelHexRInner [] ={ 0.0*CLHEP::mm, 0.0*CLHEP::mm};
-//const G4double  RichTbHpdSiDetPixelHexROuter [] ={RichTbHpdSiDetHexPixelRadius,RichTbHpdSiDetHexPixelRadius};
-const G4double  RichTbHpdSiDetPixelHexROuter [] ={ 0.5*RichTbHpdSiDetHexPixelFlatToFlatSize,
-                                                   0.5*RichTbHpdSiDetHexPixelFlatToFlatSize  };
-const G4double  RichTbHpdSiDetPixelHexRotZ= (CLHEP::pi/6.0)*CLHEP::rad;
-
-const G4int NumPixelTotInSingleHpd= 163;
-const G4int NumHpdPixelRows=15;
-const std::vector<G4int> NumHpdPixelInRows ={6,9,10,11,12,13,14,13,14,13,12,11,10,9,6  };
-
-const G4double HpdPixelPosTolerence = 0.0*CLHEP::mm ;
-const G4double HpdPixelYCenterStart= -10.5* RichTbHpdSiDetHexPixelEdgeSize;
-const G4double HpdPixelYCenterShift=  0.5*(RichTbHpdSiDetHexPixelDiagonalSize + RichTbHpdSiDetHexPixelEdgeSize);
-const G4double HpdPixelXCenterShift = RichTbHpdSiDetHexPixelFlatToFlatSize+HpdPixelPosTolerence ;
-const G4double RichTbSiDetShiftAlongX  = 0.0*CLHEP::mm;
-const G4double RichTbSiDetShiftAlongY  = 0.0*CLHEP::mm;
-const G4double RichTbSiDetRotZ = (CLHEP::pi/6.0)*CLHEP::rad;
+const G4double RichTbHpdSiDetPixelHexPhiStart = 0.0 * CLHEP::rad;
+const G4double RichTbHpdSiDetPixelHexPhiEnd = 2.0 * CLHEP::pi * CLHEP::rad;
+const G4int RichTbHpdSiDetPixelHexNumSide = 6;
+const G4int RichTbHpdSiDetPixelHexNumZPlanes = 2;
+const G4double RichTbHpdSiDetPixelHexZPlane[] = {-0.5 * RichTbHpdSiDetPixelZSize, 0.5 * RichTbHpdSiDetPixelZSize};
+const G4double RichTbHpdSiDetPixelHexRInner[] = {0.0 * CLHEP::mm, 0.0 * CLHEP::mm};
+// const G4double  RichTbHpdSiDetPixelHexROuter [] ={RichTbHpdSiDetHexPixelRadius,RichTbHpdSiDetHexPixelRadius};
+const G4double RichTbHpdSiDetPixelHexROuter[] = {0.5 * RichTbHpdSiDetHexPixelFlatToFlatSize,
+                                                 0.5 * RichTbHpdSiDetHexPixelFlatToFlatSize};
+const G4double RichTbHpdSiDetPixelHexRotZ = (CLHEP::pi / 6.0) * CLHEP::rad;
+
+const G4int NumPixelTotInSingleHpd = 163;
+const G4int NumHpdPixelRows = 15;
+const std::vector<G4int> NumHpdPixelInRows = {6, 9, 10, 11, 12, 13, 14, 13, 14, 13, 12, 11, 10, 9, 6};
+
+const G4double HpdPixelPosTolerence = 0.0 * CLHEP::mm;
+const G4double HpdPixelYCenterStart = -10.5 * RichTbHpdSiDetHexPixelEdgeSize;
+const G4double HpdPixelYCenterShift = 0.5 * (RichTbHpdSiDetHexPixelDiagonalSize + RichTbHpdSiDetHexPixelEdgeSize);
+const G4double HpdPixelXCenterShift = RichTbHpdSiDetHexPixelFlatToFlatSize + HpdPixelPosTolerence;
+const G4double RichTbSiDetShiftAlongX = 0.0 * CLHEP::mm;
+const G4double RichTbSiDetShiftAlongY = 0.0 * CLHEP::mm;
+const G4double RichTbSiDetRotZ = (CLHEP::pi / 6.0) * CLHEP::rad;
 
 const G4double RichTbHpdSMasterRadius = RichTbHpdMasterRadius;
 const G4double RichTbHpdSMasterZSize = RichTbHpdMasterZSize;
@@ -70,91 +69,84 @@ const G4double RichTbHpdEnvEndCapRad = RichTbHpdEnvLargeTubInnR - RichTbHpdEnvEn
 const G4double RichTbHpdQuartzWInnerRad = RichTbHpdQuartzWOuterRad - RichTbHpdQuartzWThickness;
 const G4double RichTbHpdPhCathodeOuterRad = RichTbHpdQuartzWInnerRad;
 const G4double RichTbHpdPhCathodeInnerRad = RichTbHpdPhCathodeOuterRad - RichTbHpdPhCathodeThickness;
-const G4double RichTbHpdQuartzWDeltaTheta = asin( RichTbHpdActiveInputRad / RichTbHpdQuartzWInnerRad );
-const G4double  RichTbHpdPhCathodeDeltaTheta = RichTbHpdQuartzWDeltaTheta;
+const G4double RichTbHpdQuartzWDeltaTheta = asin(RichTbHpdActiveInputRad / RichTbHpdQuartzWInnerRad);
+const G4double RichTbHpdPhCathodeDeltaTheta = RichTbHpdQuartzWDeltaTheta;
 
 const G4double RichTbEnvLargeTubZLocation =
- -0.5*(RichTbHpdSMasterZSize-RichTbHpdEnvLargeTubeZSize)+ RichTbHpdEnvFromEndZ;
+    -0.5 * (RichTbHpdSMasterZSize - RichTbHpdEnvLargeTubeZSize) + RichTbHpdEnvFromEndZ;
 const G4double RichTbHpdEndCapZLocation =
- -0.5*(RichTbHpdSMasterZSize-RichTbHpdEnvEndCapZsize)+
- RichTbHpdEnvFromEndZ+RichTbHpdEnvLargeTubeZSize;
-const G4double RichTbHpdQuartzWZLocation = -0.5*RichTbHpdSMasterZSize
- +RichTbHpdQuartzWindowFromEndZ+ RichTbHpdQuartzWOuterRad;
-const G4double RichTbHpdPhCathodeZLocation=RichTbHpdQuartzWZLocation;
-const G4double RichTbHpdSiDetZLocation=-0.5*RichTbHpdSMasterZSize + RichTbHpdQuartzWindowFromEndZ
-                              + RichTbHpdQuartzWThickness+RichTbHpdSiDetDistZFromPhCathode
-                              + 0.5*RichTbHpdSiDetZSize;
-
-const G4double RichTbHpdQuartzWRotY=CLHEP::pi* CLHEP::rad;
-const G4double RichTbHpdPhCathodeRotY=RichTbHpdQuartzWRotY;
+    -0.5 * (RichTbHpdSMasterZSize - RichTbHpdEnvEndCapZsize) + RichTbHpdEnvFromEndZ + RichTbHpdEnvLargeTubeZSize;
+const G4double RichTbHpdQuartzWZLocation =
+    -0.5 * RichTbHpdSMasterZSize + RichTbHpdQuartzWindowFromEndZ + RichTbHpdQuartzWOuterRad;
+const G4double RichTbHpdPhCathodeZLocation = RichTbHpdQuartzWZLocation;
+const G4double RichTbHpdSiDetZLocation = -0.5 * RichTbHpdSMasterZSize + RichTbHpdQuartzWindowFromEndZ +
+                                         RichTbHpdQuartzWThickness + RichTbHpdSiDetDistZFromPhCathode +
+                                         0.5 * RichTbHpdSiDetZSize;
 
+const G4double RichTbHpdQuartzWRotY = CLHEP::pi * CLHEP::rad;
+const G4double RichTbHpdPhCathodeRotY = RichTbHpdQuartzWRotY;
 
 // default parameters for Hpd componenets
-const G4double RichTbHpdSMasterXLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdSMasterYLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdSMasterZLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdEnvTubeXLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdEnvTubeYLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdEndCapXLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdEndCapYLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdQuartzWindowXLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdQuartzWindowYLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdPhCathodeXLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdPhCathodeYLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdQWCylXLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdQWCylYLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdQWCylZLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdMasterInnerRad=0.0*CLHEP::mm;
-const G4double  RichTbHpdSMasterInnerRad=0.0*CLHEP::mm;
-const G4double  RichTbHpdMasterStartPhi=0.0*CLHEP::rad;
-const G4double  RichTbHpdMasterEndPhi = (2.0*CLHEP::pi)*CLHEP::rad;
-const G4double  RichTbHpdSMasterStartPhi=0.0*CLHEP::rad;
-const G4double  RichTbHpdSMasterEndPhi = (2.0*CLHEP::pi)*CLHEP::rad;
-const G4double  RichTbHpdEnvelopeTubeStartPhi=0.0*CLHEP::rad;
-const G4double  RichTbHpdEnvelopeTubeEndPhi=(2.0*CLHEP::pi)*CLHEP::rad;
-const G4double  RichTbHpdEnvelopeEndCapStartPhi=0.0*CLHEP::rad;
-const G4double  RichTbHpdEnvelopeEndCapEndPhi=(2.0*CLHEP::pi)*CLHEP::rad;
-const G4double  RichTbHpdEndCapInnerRad=0.0*CLHEP::mm;
-const G4double  RichTbHpdQuartzWStartPhi=0.0*CLHEP::rad;
-const G4double  RichTbHpdQuartzWDeltaPhi=(2.0*CLHEP::pi)*CLHEP::rad;
-const G4double  RichTbHpdQuartzWStartTheta=0.0*CLHEP::rad;
-const G4double  RichTbHpdPhCathodeStartPhi=0.0*CLHEP::rad;
-const G4double  RichTbHpdPhCathodeDeltaPhi=(2.0*CLHEP::pi)*CLHEP::rad;
-const G4double  RichTbHpdPhCathodeStartTheta=0.0*CLHEP::rad;
-const G4double  RichTbSiDetNominalXLocation=0.0*CLHEP::mm;
-const G4double  RichTbSiDetNominalYLocation=0.0*CLHEP::mm;
-const G4double  RichTbHpdQWCylEnvStartPhi=0.0*CLHEP::rad;
-const G4double  RichTbHpdQWCylEnvEndPhi=(2.0*CLHEP::pi)*CLHEP::rad;
-const G4double  RichHpdSiPixelPosZInSiDet=0.0*CLHEP::mm;
-const G4double RichTbHpdSiDetInnerRadiusSize= 0.0*CLHEP::mm;
-const G4double RichTbHpdSiDetStartPhi=0.0*CLHEP::rad;
-const G4double RichTbHpdSiDetEndPhi= (2.0*CLHEP::pi)*CLHEP::rad;
+const G4double RichTbHpdSMasterXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdSMasterYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdSMasterZLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdEnvTubeXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdEnvTubeYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdEndCapXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdEndCapYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdQuartzWindowXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdQuartzWindowYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdPhCathodeXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdPhCathodeYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdQWCylXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdQWCylYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdQWCylZLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdMasterInnerRad = 0.0 * CLHEP::mm;
+const G4double RichTbHpdSMasterInnerRad = 0.0 * CLHEP::mm;
+const G4double RichTbHpdMasterStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdMasterEndPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
+const G4double RichTbHpdSMasterStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdSMasterEndPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
+const G4double RichTbHpdEnvelopeTubeStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdEnvelopeTubeEndPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
+const G4double RichTbHpdEnvelopeEndCapStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdEnvelopeEndCapEndPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
+const G4double RichTbHpdEndCapInnerRad = 0.0 * CLHEP::mm;
+const G4double RichTbHpdQuartzWStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdQuartzWDeltaPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
+const G4double RichTbHpdQuartzWStartTheta = 0.0 * CLHEP::rad;
+const G4double RichTbHpdPhCathodeStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdPhCathodeDeltaPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
+const G4double RichTbHpdPhCathodeStartTheta = 0.0 * CLHEP::rad;
+const G4double RichTbSiDetNominalXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbSiDetNominalYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdQWCylEnvStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdQWCylEnvEndPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
+const G4double RichHpdSiPixelPosZInSiDet = 0.0 * CLHEP::mm;
+const G4double RichTbHpdSiDetInnerRadiusSize = 0.0 * CLHEP::mm;
+const G4double RichTbHpdSiDetStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdSiDetEndPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
 
 // now for the HPD locations
 
-const G4String HpdNamesBox="Hpd0Box";
-const G4String HpdNamesLog= "Hpd0Log";
-const G4String HpdNamesPhys= "Hpd0Phys";
+const G4String HpdNamesBox = "Hpd0Box";
+const G4String HpdNamesLog = "Hpd0Log";
+const G4String HpdNamesPhys = "Hpd0Phys";
 
-const G4String HpdQuartzPhysName="HpdQuartzPhys";
-const G4String HpdPhCathodePhysName="HpdPhCathodePhys";
+const G4String HpdQuartzPhysName = "HpdQuartzPhys";
+const G4String HpdPhCathodePhysName = "HpdPhCathodePhys";
 const G4String HpdSMasterPhysName = "HpdSMasterPhys";
-const G4String  HpdSiDetPhysName = "HpdSiDetPhys";
+const G4String HpdSiDetPhysName = "HpdSiDetPhys";
 
-
-
-const G4double HpdPhCathodeXCenterInPhSup= 0.0*CLHEP::mm;
-const G4double HpdPhCathodeYCenterInPhSup = 0.0*CLHEP::mm;
+const G4double HpdPhCathodeXCenterInPhSup = 0.0 * CLHEP::mm;
+const G4double HpdPhCathodeYCenterInPhSup = 0.0 * CLHEP::mm;
 const G4double RichTbHpdMasterXLocation = HpdPhCathodeXCenterInPhSup;
 const G4double RichTbHpdMasterYLocation = HpdPhCathodeYCenterInPhSup;
 
-
 // the following defined in RichTbHpdSupportFrameGeometryParameters.hh
-//const G4double RichTbHpdMasterZLocation = (-0.5*HpdPhDetSupFrameZSize)  +0.5*RichTbHpdMasterZSize;
-
-
-const G4double RichTbHpdMasterRotationYAxis = 0.0*CLHEP::rad;
-const G4double RichTbHpdMasterRotationZAxis = 0.0*CLHEP::rad;
+// const G4double RichTbHpdMasterZLocation = (-0.5*HpdPhDetSupFrameZSize)  +0.5*RichTbHpdMasterZSize;
 
+const G4double RichTbHpdMasterRotationYAxis = 0.0 * CLHEP::rad;
+const G4double RichTbHpdMasterRotationZAxis = 0.0 * CLHEP::rad;
 
 #endif // INCLUDE_RICHTBEXTHPDGEOMETRYPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbGeometryParameters.hh
index cf54eb7ede0ba8839d18743547668f02ecd20b71..6158219d7186ee2745c4565b5ba9aa99c648532d 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbGeometryParameters.hh
@@ -18,27 +18,22 @@ static const G4double sqroot3 = pow(3.0, 0.5);
 #include "RichTbLensGeometryParameters.hh"
 #include "RichTbMasterGeometryParameters.hh"
 
-
 #include "RichTbCrystalCoverGeometryParameters.hh"
 #include "RichTbMirrorGeometryParamters.hh"
 #include "RichTbDarkCoverGeometryParameters.hh"
 
-
 #include "RichTbPMTGeometryParameters.hh"
 #include "RichTbPMTSupportFrameGeometryParameters.hh"
 
 #include "RichTbHpdGeometryParameters.hh"
 
-
 #include "RichTbExtHpdGeometryParameters.hh"
 #include "RichTbHpdSupportFrameGeometryParameters.hh"
 
-
 #include "RichTbPhDFrameGeometryParameters.hh"
 
 #include "RichTbBeamGeometryParameters.hh"
 
 //
 
-
-#endif                          /*RichTbGeometryParameters_h */
+#endif /*RichTbGeometryParameters_h */
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbGraphics.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbGraphics.hh
index fe4fb9abb0abed48b98d7dcc6a22040c813802c1..c96d81198960ebb815b91c0fdd3735dd9c335d07 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbGraphics.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbGraphics.hh
@@ -8,18 +8,15 @@
 
 class RichTbGraphics {
 
-  public:
+public:
+  RichTbGraphics();
+  RichTbGraphics(RichTbDetectorConstruction *);
+  virtual ~RichTbGraphics();
 
-    RichTbGraphics();
-    RichTbGraphics(RichTbDetectorConstruction* );
-    virtual ~ RichTbGraphics();
+  void setAllGraphicsAttributes();
+  void setRichTbHallGraphicsAttibutes();
 
-   void setAllGraphicsAttributes();
-   void setRichTbHallGraphicsAttibutes();
-  
-  private:
-
-  RichTbDetectorConstruction* curDetector;
-  
+private:
+  RichTbDetectorConstruction *curDetector;
 };
-#endif                          /*RichTbGraphics_h */
+#endif /*RichTbGraphics_h */
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHall.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHall.hh
index 2be6688349b5612dd8222288dd4a78243f474306..486225b548da77f9ba41cbbc2f9704e465fc7e96 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHall.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHall.hh
@@ -12,20 +12,16 @@
 
 class RichTbHall {
 
-  public:
-    RichTbHall();
-    virtual ~ RichTbHall();
+public:
+  RichTbHall();
+  virtual ~RichTbHall();
 
-    G4LogicalVolume *getRichTbHallLogicalVolume() {
-        return RichTbHallLVol;
-    }
-    G4VPhysicalVolume *getRichTbHallPhysicalVolume() {
-        return RichTbHallPVol;
-    }
+  G4LogicalVolume *getRichTbHallLogicalVolume() { return RichTbHallLVol; }
+  G4VPhysicalVolume *getRichTbHallPhysicalVolume() { return RichTbHallPVol; }
 
-  private:
-    G4LogicalVolume*  RichTbHallLVol;
-    G4VPhysicalVolume* RichTbHallPVol;
+private:
+  G4LogicalVolume *RichTbHallLVol;
+  G4VPhysicalVolume *RichTbHallPVol;
 };
 
-#endif                          /*RichTbHall_h */
+#endif /*RichTbHall_h */
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHallGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHallGeometryParameters.hh
index 03cc234328e971e58e333b50d8d726a3f1b0d1ec..7bb1a22d0ea5c69c25eee17cf3160e45e6443ee8 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHallGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHallGeometryParameters.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBHALLGEOMETRYPARAMETERS_HH 
+#ifndef INCLUDE_RICHTBHALLGEOMETRYPARAMETERS_HH
 #define INCLUDE_RICHTBHALLGEOMETRYPARAMETERS_HH 1
 
 #include "CLHEP/Units/SystemOfUnits.h"
@@ -7,22 +7,22 @@
 // Include files
 
 /** @class RichTbHallGeometryParameters RichTbHallGeometryParameters.hh include/RichTbHallGeometryParameters.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-10-21
  */
-//Size of the LHCb Rich Testbeam Hall. 
+// Size of the LHCb Rich Testbeam Hall.
 
- const G4double ExpHallHalfX = 5000.0 * CLHEP::mm;
- const G4double ExpHallHalfY = 5000.0 * CLHEP::mm;
- const G4double ExpHallHalfZ = 10000.0 * CLHEP::mm;
+const G4double ExpHallHalfX = 5000.0 * CLHEP::mm;
+const G4double ExpHallHalfY = 5000.0 * CLHEP::mm;
+const G4double ExpHallHalfZ = 10000.0 * CLHEP::mm;
 
 // The Hall is kept at the orgin of the coord system.
 // The coord system has +z along the beam direction and +y
 // going upwards.
-// The uptream end of the box part of the vessel 
-// is at z=0. The origin is approximately where the 
+// The uptream end of the box part of the vessel
+// is at z=0. The origin is approximately where the
 // beam enters the vessel.
 
 #endif // INCLUDE_RICHTBHALLGEOMETRYPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHit.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHit.hh
index e9376b1364d2990b2b1fbc3c6691164d2dc72757..9c3a2aebdd8404cc65b40c80533fdecb982695ca 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHit.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHit.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBHIT_HH 
+#ifndef INCLUDE_RICHTBHIT_HH
 #define INCLUDE_RICHTBHIT_HH 1
 
 // Include files
@@ -11,179 +11,131 @@
 class RichTbVisManager;
 
 /** @class RichTbHit RichTbHit.hh include/RichTbHit.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-12-12
  */
 class RichTbHit : public G4VHit {
-public: 
+public:
   /// Standard constructor
-  RichTbHit( ); 
+  RichTbHit();
 
-  virtual ~RichTbHit( ); ///< Destructor
+  virtual ~RichTbHit(); ///< Destructor
 
   RichTbHit(const RichTbHit &right);
-  const RichTbHit& operator=(const RichTbHit &right);
+  const RichTbHit &operator=(const RichTbHit &right);
   int operator==(const RichTbHit &right) const;
   inline void *operator new(size_t);
   inline void operator delete(void *aHit);
-  void Draw();
-  void DrawWithVisM(RichTbVisManager* );
-  void Print();
+  void Draw() override;
+  void DrawWithVisM(RichTbVisManager *);
+  void Print() override;
 
 protected:
-
 private:
-  G4double edep;      // energy deposited by PE.
+  G4double edep;     // energy deposited by PE.
   G4ThreeVector pos; //  Global Hit coord on Silicon
-  G4int CurPMTNum;  //   PMT Number
-  G4int CurPixelNum; //  Pixelnumber 
-
-  G4ThreeVector mLocalPos; // local Hit coord on Silicon.
-  G4ThreeVector mPeOrigin; // Global Origin of Photoelectron.  
-  G4ThreeVector mPhotonOrigin;  // Global Emission Point of Photon.
-  G4int mRayleighScatFlag;  // number of times rayleigh scattered. 0 means no scat.
-  G4ThreeVector mPhotonIncidenceOnPMTQW;  // Global Photon incidence coord on hpd QW. 
-  G4int mPhotonMultIncidenceQW;  // number of times the photon hits the PMT QW external surface.
-  G4double mCkvCosThetaProd; // Cos theta of photon for Cherenkov production.
-  G4double mCkvPhiProd;     // Phi for Cherenkov Production.
-  G4double mCkvEnergyProd;  // Energy of Photon at Cherenkov production.
-  G4ThreeVector mPeOriginInPhSupport; // photoelectron origin photodetector
-                                // support frame coord system.
+  G4int CurPMTNum;   //   PMT Number
+  G4int CurPixelNum; //  Pixelnumber
+
+  G4ThreeVector mLocalPos;               // local Hit coord on Silicon.
+  G4ThreeVector mPeOrigin;               // Global Origin of Photoelectron.
+  G4ThreeVector mPhotonOrigin;           // Global Emission Point of Photon.
+  G4int mRayleighScatFlag;               // number of times rayleigh scattered. 0 means no scat.
+  G4ThreeVector mPhotonIncidenceOnPMTQW; // Global Photon incidence coord on hpd QW.
+  G4int mPhotonMultIncidenceQW;          // number of times the photon hits the PMT QW external surface.
+  G4double mCkvCosThetaProd;             // Cos theta of photon for Cherenkov production.
+  G4double mCkvPhiProd;                  // Phi for Cherenkov Production.
+  G4double mCkvEnergyProd;               // Energy of Photon at Cherenkov production.
+  G4ThreeVector mPeOriginInPhSupport;    // photoelectron origin photodetector
+                                         // support frame coord system.
 
   G4ThreeVector mPhEmissionDir; // Global Direction of the photon at its origin.
-  
+
   G4ThreeVector mPixelLocalCenter;
   G4ThreeVector mPixelGlobalCenter;
-  G4ThreeVector mTIRRadiatorCoord;  // Coordinate of Total Internal reflection from the radiator.
-  G4ThreeVector mMIRRadiatorCoord;  // Coordinate of reflection from the mirror
-  G4ThreeVector mRFRRadiatorCoord;  // Coordinate where refraction happened, before exiting the radiator.
-  G4int mMultipleReflFlag;     // Number of times the photon reflected in the radiator. Nominal value=3
-  G4double mChTrackTotMom;     // Total momentum of the charged track which created the photons. 
-  G4ThreeVector mChTrackThreeMom; // Three vector momentum of the charged track which created photons.
-  G4int mHitInPixelGapFlag;  // if 0 the pixel is in the active region of the pixel. If 1, it is in the gap between pixels. 
-  
-
-  public:
-  inline void SetEdep(G4double de)      { edep = de; }
-  inline G4double GetEdep()      { return edep; }
-  inline void SetPos(G4ThreeVector xyz)      { pos = xyz; }
-  inline G4ThreeVector GetPos()      { return pos; }
-  inline void SetCurPMTNum (G4int ihp ) { CurPMTNum = ihp; } ;
-  inline void SetCurHPDNum (G4int ihp ) { CurPMTNum = ihp; } ;
-  inline G4int GetCurPMTNum()           { return CurPMTNum ; }
-  inline G4int GetCurHPDNum()           { return CurPMTNum ; }
-  inline void SetCurPixNum (G4int ipx ) { CurPixelNum = ipx; }
-  inline G4int GetCurPixNum()           { return CurPixelNum; }
-  inline void AddEdep( G4double addenergy ) { edep += addenergy; }  
-  inline void SetLocalPos( G4ThreeVector aLocalPos ) 
-  {    mLocalPos=  aLocalPos;}
-  inline G4ThreeVector GetLocalPos() 
-  {    return  mLocalPos;}
-
-  inline void SetPeOrigin(G4ThreeVector aPeOrigin) 
-  {    mPeOrigin= aPeOrigin;}
-  inline G4ThreeVector GetPeOrigin() 
-  {    return  mPeOrigin;  }
-
-  inline void SetPhotonOrigin(G4ThreeVector aOrigin) 
-  {    mPhotonOrigin= aOrigin;}
-  inline G4ThreeVector GetPhotonOrigin() 
-  {    return  mPhotonOrigin;  }
-  inline void SetRayleighScatFlag( G4int aFlag) 
-  {    mRayleighScatFlag=aFlag;}
-  inline G4int GetRayleighScatFlag() 
-  {    return mRayleighScatFlag;  }
-  inline void SetPhotonIncidenceOnPMTQW(G4ThreeVector aIncidence) 
-  {    mPhotonIncidenceOnPMTQW=aIncidence;}
-  inline G4ThreeVector GetPhotonIncidenceOnPMTQW() 
-  {    return mPhotonIncidenceOnPMTQW;  }
-  inline void SetPhotonMultIncidenceQW(G4int aMultIncFlag) 
-  {    mPhotonMultIncidenceQW=aMultIncFlag;  }
-  inline G4int GetPhotonMultIncidenceQW() 
-  {    return mPhotonMultIncidenceQW;  }
-  inline void SetCkvCosThetaProd(G4double aTheta ) 
-  {    mCkvCosThetaProd=aTheta;  }
-  inline G4double GetCkvCosThetaProd() 
-  {return mCkvCosThetaProd; }
-  inline void SetCkvPhiProd( G4double aPhi) 
-  {mCkvPhiProd=aPhi;}
-  inline G4double GetCkvPhiProd() 
-  {    return mCkvPhiProd;}
-  inline void SetCkvEnergyProd( G4double aEnergy) 
-  {mCkvEnergyProd=aEnergy;}
-  inline G4double GetCkvEnergyProd() 
-  {return mCkvEnergyProd;  }
-  inline void SetPeOriginInPhSupport(G4ThreeVector aPeOriginInPhSupport)
-  { mPeOriginInPhSupport =  aPeOriginInPhSupport;}
-  inline G4ThreeVector GetPeOriginInPhSupport() 
-  {    return  mPeOriginInPhSupport;}
-  
-  inline void SetPhEmissionDir(G4ThreeVector aPhEmissionDir) {
-    mPhEmissionDir= aPhEmissionDir;}
-
-  inline G4ThreeVector GetPhEmissionDir() {return mPhEmissionDir;}
-
-  inline void SetPixelLocalCenter( G4ThreeVector aP ) 
-  {mPixelLocalCenter =aP   ;}
-  inline void SetPixelGlobalCenter( G4ThreeVector aG) 
-  {mPixelGlobalCenter = aG  ;}
-  inline void SetTIRRadiatorCoord(G4ThreeVector aT ) 
-  {  mTIRRadiatorCoord = aT;}
-  inline void SetMIRRadiatorCoord(G4ThreeVector aM ) 
-  {  mMIRRadiatorCoord = aM;}
-  inline void SetRFRRadiatorCoord(G4ThreeVector aF ) 
-  {  mRFRRadiatorCoord = aF;}
-
-  inline void SetMultipleReflFlag (G4int aFlag) 
-  {mMultipleReflFlag = aFlag;}
-  inline void SetChTrackTotMom (G4double aMom) 
-  {mChTrackTotMom = aMom;}
-  inline void SetChTrackThreeMom(G4ThreeVector aThMom)
-  {  mChTrackThreeMom =aThMom;}
-  inline void SetHitInPixelGapFlag(G4int aGapFlag) 
-  { mHitInPixelGapFlag = aGapFlag;}
-  
-
-  inline G4ThreeVector getPixelLocalCenter() 
-  {return mPixelLocalCenter;}
-  inline G4ThreeVector getPixelGlobalCenter() 
-  {return mPixelGlobalCenter;}
-
-  inline G4ThreeVector getTIRRadiatorCoord() 
-  {  return mTIRRadiatorCoord;}
-  inline G4ThreeVector getMIRRadiatorCoord()
-  {  return  mMIRRadiatorCoord;}
-  inline G4ThreeVector getRFRRadiatorCoord()
-  {  return  mRFRRadiatorCoord;}
-  inline  G4int getMultipleReflFlag()
-  {  return mMultipleReflFlag;}
-  inline G4double getChTrackTotMom ()
-  {  return mChTrackTotMom;}
-  inline  G4ThreeVector getChTrackThreeMom ()
-  {  return  mChTrackThreeMom;}
-  inline G4int getHitInPixelGapFlag() 
-  {  return mHitInPixelGapFlag;}
-  
-
-
+  G4ThreeVector mTIRRadiatorCoord; // Coordinate of Total Internal reflection from the radiator.
+  G4ThreeVector mMIRRadiatorCoord; // Coordinate of reflection from the mirror
+  G4ThreeVector mRFRRadiatorCoord; // Coordinate where refraction happened, before exiting the radiator.
+  G4int mMultipleReflFlag;         // Number of times the photon reflected in the radiator. Nominal value=3
+  G4double mChTrackTotMom;         // Total momentum of the charged track which created the photons.
+  G4ThreeVector mChTrackThreeMom;  // Three vector momentum of the charged track which created photons.
+  G4int
+      mHitInPixelGapFlag; // if 0 the pixel is in the active region of the pixel. If 1, it is in the gap between pixels.
+
+public:
+  inline void SetEdep(G4double de) { edep = de; }
+  inline G4double GetEdep() { return edep; }
+  inline void SetPos(G4ThreeVector xyz) { pos = xyz; }
+  inline G4ThreeVector GetPos() { return pos; }
+  inline void SetCurPMTNum(G4int ihp) { CurPMTNum = ihp; };
+  inline void SetCurHPDNum(G4int ihp) { CurPMTNum = ihp; };
+  inline G4int GetCurPMTNum() { return CurPMTNum; }
+  inline G4int GetCurHPDNum() { return CurPMTNum; }
+  inline void SetCurPixNum(G4int ipx) { CurPixelNum = ipx; }
+  inline G4int GetCurPixNum() { return CurPixelNum; }
+  inline void AddEdep(G4double addenergy) { edep += addenergy; }
+  inline void SetLocalPos(G4ThreeVector aLocalPos) { mLocalPos = aLocalPos; }
+  inline G4ThreeVector GetLocalPos() { return mLocalPos; }
+
+  inline void SetPeOrigin(G4ThreeVector aPeOrigin) { mPeOrigin = aPeOrigin; }
+  inline G4ThreeVector GetPeOrigin() { return mPeOrigin; }
+
+  inline void SetPhotonOrigin(G4ThreeVector aOrigin) { mPhotonOrigin = aOrigin; }
+  inline G4ThreeVector GetPhotonOrigin() { return mPhotonOrigin; }
+  inline void SetRayleighScatFlag(G4int aFlag) { mRayleighScatFlag = aFlag; }
+  inline G4int GetRayleighScatFlag() { return mRayleighScatFlag; }
+  inline void SetPhotonIncidenceOnPMTQW(G4ThreeVector aIncidence) { mPhotonIncidenceOnPMTQW = aIncidence; }
+  inline G4ThreeVector GetPhotonIncidenceOnPMTQW() { return mPhotonIncidenceOnPMTQW; }
+  inline void SetPhotonMultIncidenceQW(G4int aMultIncFlag) { mPhotonMultIncidenceQW = aMultIncFlag; }
+  inline G4int GetPhotonMultIncidenceQW() { return mPhotonMultIncidenceQW; }
+  inline void SetCkvCosThetaProd(G4double aTheta) { mCkvCosThetaProd = aTheta; }
+  inline G4double GetCkvCosThetaProd() { return mCkvCosThetaProd; }
+  inline void SetCkvPhiProd(G4double aPhi) { mCkvPhiProd = aPhi; }
+  inline G4double GetCkvPhiProd() { return mCkvPhiProd; }
+  inline void SetCkvEnergyProd(G4double aEnergy) { mCkvEnergyProd = aEnergy; }
+  inline G4double GetCkvEnergyProd() { return mCkvEnergyProd; }
+  inline void SetPeOriginInPhSupport(G4ThreeVector aPeOriginInPhSupport) {
+    mPeOriginInPhSupport = aPeOriginInPhSupport;
+  }
+  inline G4ThreeVector GetPeOriginInPhSupport() { return mPeOriginInPhSupport; }
+
+  inline void SetPhEmissionDir(G4ThreeVector aPhEmissionDir) { mPhEmissionDir = aPhEmissionDir; }
+
+  inline G4ThreeVector GetPhEmissionDir() { return mPhEmissionDir; }
+
+  inline void SetPixelLocalCenter(G4ThreeVector aP) { mPixelLocalCenter = aP; }
+  inline void SetPixelGlobalCenter(G4ThreeVector aG) { mPixelGlobalCenter = aG; }
+  inline void SetTIRRadiatorCoord(G4ThreeVector aT) { mTIRRadiatorCoord = aT; }
+  inline void SetMIRRadiatorCoord(G4ThreeVector aM) { mMIRRadiatorCoord = aM; }
+  inline void SetRFRRadiatorCoord(G4ThreeVector aF) { mRFRRadiatorCoord = aF; }
+
+  inline void SetMultipleReflFlag(G4int aFlag) { mMultipleReflFlag = aFlag; }
+  inline void SetChTrackTotMom(G4double aMom) { mChTrackTotMom = aMom; }
+  inline void SetChTrackThreeMom(G4ThreeVector aThMom) { mChTrackThreeMom = aThMom; }
+  inline void SetHitInPixelGapFlag(G4int aGapFlag) { mHitInPixelGapFlag = aGapFlag; }
+
+  inline G4ThreeVector getPixelLocalCenter() { return mPixelLocalCenter; }
+  inline G4ThreeVector getPixelGlobalCenter() { return mPixelGlobalCenter; }
+
+  inline G4ThreeVector getTIRRadiatorCoord() { return mTIRRadiatorCoord; }
+  inline G4ThreeVector getMIRRadiatorCoord() { return mMIRRadiatorCoord; }
+  inline G4ThreeVector getRFRRadiatorCoord() { return mRFRRadiatorCoord; }
+  inline G4int getMultipleReflFlag() { return mMultipleReflFlag; }
+  inline G4double getChTrackTotMom() { return mChTrackTotMom; }
+  inline G4ThreeVector getChTrackThreeMom() { return mChTrackThreeMom; }
+  inline G4int getHitInPixelGapFlag() { return mHitInPixelGapFlag; }
 };
 typedef G4THitsCollection<RichTbHit> RichTbHitsCollection;
 
 extern G4Allocator<RichTbHit> RichTbHitAllocator;
-inline void* RichTbHit::operator new(size_t)
-{
+inline void *RichTbHit::operator new(size_t) {
   void *aHit;
-  aHit = (void *) RichTbHitAllocator.MallocSingle();
+  aHit = (void *)RichTbHitAllocator.MallocSingle();
   return aHit;
 }
 
-inline void RichTbHit::operator delete(void *aHit)
-{
-  RichTbHitAllocator.FreeSingle((RichTbHit*) aHit);
-}
-
-
+inline void RichTbHit::operator delete(void *aHit) { RichTbHitAllocator.FreeSingle((RichTbHit *)aHit); }
 
 #endif // INCLUDE_RICHTBHIT_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpd.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpd.hh
index 7436b43c900798c667fc7e346dc384aa5a7b3643..74ac5d8bd8c6d4582e01758107fa35f1e2f9390f 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpd.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpd.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBHPD_HH 
+#ifndef INCLUDE_RICHTBHPD_HH
 #define INCLUDE_RICHTBHPD_HH 1
 
 // Include files
@@ -11,143 +11,73 @@
 #include "RichTbUpgradePhDetSupFrame.hh"
 
 /** @class RichTbHpd RichTbHpd.hh include/RichTbHpd.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-11-19
  */
-class  RichTbPhDetSupFrame;
+class RichTbPhDetSupFrame;
 
 class RichTbHpd {
 public:
   /// Standard constructor
-  RichTbHpd(G4int aHpdNum, RichTbUpgradePhDetSupFrame* aSupFrame  ); 
+  RichTbHpd(G4int aHpdNum, RichTbUpgradePhDetSupFrame *aSupFrame);
+
+  virtual ~RichTbHpd(); ///< Destructor
+
+  G4LogicalVolume *getRichTbHpdMasterLVol() { return RichTbHpdMasterLVol; }
+  G4LogicalVolume *getRichTbHpdSMasterLVol() { return RichTbHpdSMasterLVol; }
+  G4LogicalVolume *getRichTbHpdEnvelopeTubeLVol() { return RichTbHpdEnvelopeTubeLVol; }
+  G4LogicalVolume *getRichTbHpdEnvelopeEndCapLVol() { return RichTbHpdEnvelopeEndCapLVol; }
+  G4LogicalVolume *getRichTbHpdQuartzWLVol() { return RichTbHpdQuartzWLVol; }
+  G4LogicalVolume *getRichTbHpdPhCathodeLVol() { return RichTbHpdPhCathodeLVol; }
+  G4LogicalVolume *getRichTbHpdSiDetLVol() { return RichTbHpdSiDetLVol; }
+  G4LogicalVolume *getRichTbSiPixelLVol() { return RichTbSiPixelLVol; }
+  G4VPhysicalVolume *getSingleRichTbSiPixelPVol(G4int PixelNum) { return RichTbSiPixelPVol[PixelNum]; }
+  std::vector<G4VPhysicalVolume *> getRichTbSiPixelPVol() { return RichTbSiPixelPVol; }
 
-  virtual ~RichTbHpd( ); ///< Destructor
+  G4VPhysicalVolume *getRichTbHpdMasterPVol() { return RichTbHpdMasterPVol; }
+  G4VPhysicalVolume *getRichTbHpdSMasterPVol() { return RichTbHpdSMasterPVol; }
+  G4VPhysicalVolume *getRichTbHpdEnvelopeTubePVol() { return RichTbHpdEnvelopeTubePVol; }
+  G4VPhysicalVolume *getRichTbHpdEnvelopeEndCapPVol() { return RichTbHpdEnvelopeEndCapPVol; }
+  G4VPhysicalVolume *getRichTbHpdQuartzWPVol() { return RichTbHpdQuartzWPVol; }
+  G4VPhysicalVolume *getRichTbHpdPhCathodePVol() { return RichTbHpdPhCathodePVol; }
+  G4VPhysicalVolume *getRichTbHpdSiDetPVol() { return RichTbHpdSiDetPVol; }
 
-  G4LogicalVolume* getRichTbHpdMasterLVol() 
-  {
-    return RichTbHpdMasterLVol;
-  }
-  G4LogicalVolume* getRichTbHpdSMasterLVol()
-  {
-    return  RichTbHpdSMasterLVol;
-  }
-  G4LogicalVolume* getRichTbHpdEnvelopeTubeLVol() 
-  {
-    return RichTbHpdEnvelopeTubeLVol;
-  }
-  G4LogicalVolume* getRichTbHpdEnvelopeEndCapLVol() 
-  {
-    return RichTbHpdEnvelopeEndCapLVol;
-  }
-  G4LogicalVolume* getRichTbHpdQuartzWLVol()
-  {
-    return RichTbHpdQuartzWLVol;
-  }
-  G4LogicalVolume* getRichTbHpdPhCathodeLVol()
-  {
-    return RichTbHpdPhCathodeLVol;
-  }
-  G4LogicalVolume* getRichTbHpdSiDetLVol()
-  {
-    return RichTbHpdSiDetLVol;
-  }
-  G4LogicalVolume* getRichTbSiPixelLVol() 
-  {
-    return RichTbSiPixelLVol;
-    
-  }
-  G4VPhysicalVolume* getSingleRichTbSiPixelPVol(G4int PixelNum) 
-  {
-    return RichTbSiPixelPVol[ PixelNum];
-    
-  }
-  std::vector<G4VPhysicalVolume*> getRichTbSiPixelPVol()
-  {
-    return RichTbSiPixelPVol;
-  }
-  
-  G4VPhysicalVolume* getRichTbHpdMasterPVol() 
-  {
-    return RichTbHpdMasterPVol;
-  }
-  G4VPhysicalVolume* getRichTbHpdSMasterPVol()
-  {
-    return RichTbHpdSMasterPVol;
-  }
-  G4VPhysicalVolume* getRichTbHpdEnvelopeTubePVol()
-  {
-    return RichTbHpdEnvelopeTubePVol;
-  }
-  G4VPhysicalVolume* getRichTbHpdEnvelopeEndCapPVol()
-  {
-    return RichTbHpdEnvelopeEndCapPVol;
-  }
-  G4VPhysicalVolume* getRichTbHpdQuartzWPVol()
-  {
-    return RichTbHpdQuartzWPVol; 
-  }
-  G4VPhysicalVolume* getRichTbHpdPhCathodePVol()
-  {
-    return RichTbHpdPhCathodePVol;
-  }
-  G4VPhysicalVolume* getRichTbHpdSiDetPVol()
-  {
-    return  RichTbHpdSiDetPVol;
-  }
-  
-  G4int getCurHpdNum() 
-  {
-    return  CurHpdNum;
-  }
+  G4int getCurHpdNum() { return CurHpdNum; }
+
+  void setTrackingSwitch(bool aV) { m_TrackingSwitch = aV; }
+  bool TrackingSwitch() { return m_TrackingSwitch; }
 
-  void setTrackingSwitch(bool aV ) {
-    m_TrackingSwitch = aV;
-  }
-  bool TrackingSwitch(){
-    return  m_TrackingSwitch;
-  }
-  
   void constructHpdMasterTree();
   void constructHpdComponentsLVol();
   void constructHpdComponentsPVol();
   void constructHpdSiPixel();
   void buildHpdGeometry();
-  
-  
-  
-protected:
 
+protected:
 private:
-
-  RichTbUpgradePhDetSupFrame* MotherOfHpd;
+  RichTbUpgradePhDetSupFrame *MotherOfHpd;
   G4int CurHpdNum;
-  
-  G4LogicalVolume* RichTbHpdMasterLVol;
-  G4LogicalVolume* RichTbHpdSMasterLVol;
-  G4LogicalVolume* RichTbHpdEnvelopeTubeLVol;
-  G4LogicalVolume* RichTbHpdEnvelopeEndCapLVol;
-  G4LogicalVolume* RichTbHpdQuartzWLVol;
-  G4LogicalVolume* RichTbHpdPhCathodeLVol;
-  G4LogicalVolume* RichTbHpdSiDetLVol;
-  G4VPhysicalVolume*  RichTbHpdMasterPVol;
-  G4VPhysicalVolume*  RichTbHpdSMasterPVol;
-  G4VPhysicalVolume* RichTbHpdEnvelopeTubePVol;  
-  G4VPhysicalVolume* RichTbHpdEnvelopeEndCapPVol;  
-  G4VPhysicalVolume* RichTbHpdQuartzWPVol;  
-  G4VPhysicalVolume* RichTbHpdPhCathodePVol;  
-  G4VPhysicalVolume* RichTbHpdSiDetPVol;
 
-    
-  G4LogicalVolume* RichTbSiPixelLVol;
- 
-  std::vector<G4VPhysicalVolume*> RichTbSiPixelPVol;
-  bool m_TrackingSwitch;
-  
-  
-  
- 
+  G4LogicalVolume *RichTbHpdMasterLVol;
+  G4LogicalVolume *RichTbHpdSMasterLVol;
+  G4LogicalVolume *RichTbHpdEnvelopeTubeLVol;
+  G4LogicalVolume *RichTbHpdEnvelopeEndCapLVol;
+  G4LogicalVolume *RichTbHpdQuartzWLVol;
+  G4LogicalVolume *RichTbHpdPhCathodeLVol;
+  G4LogicalVolume *RichTbHpdSiDetLVol;
+  G4VPhysicalVolume *RichTbHpdMasterPVol;
+  G4VPhysicalVolume *RichTbHpdSMasterPVol;
+  G4VPhysicalVolume *RichTbHpdEnvelopeTubePVol;
+  G4VPhysicalVolume *RichTbHpdEnvelopeEndCapPVol;
+  G4VPhysicalVolume *RichTbHpdQuartzWPVol;
+  G4VPhysicalVolume *RichTbHpdPhCathodePVol;
+  G4VPhysicalVolume *RichTbHpdSiDetPVol;
 
+  G4LogicalVolume *RichTbSiPixelLVol;
+
+  std::vector<G4VPhysicalVolume *> RichTbSiPixelPVol;
+  bool m_TrackingSwitch;
 };
 #endif // INCLUDE_RICHTBHPD_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpdGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpdGeometryParameters.hh
index 62539d4ddb1ea7bf040b2995d70c2f39fbd8ff98..8d655484e9d5abdc0208b7f3001fa8cf8985a651 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpdGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpdGeometryParameters.hh
@@ -1,70 +1,66 @@
-#ifndef INCLUDE_RICHTBHPDGEOMETRYPARAMETERS_HH 
+#ifndef INCLUDE_RICHTBHPDGEOMETRYPARAMETERS_HH
 #define INCLUDE_RICHTBHPDGEOMETRYPARAMETERS_HH 1
 
 // Include files
 
-const G4int NumHpds= 1;
+const G4int NumHpds = 1;
 
-const G4double RichTbHpdMasterRadius = 43.5*CLHEP::mm;
-const G4double RichTbHpdMasterZSize = 160.0*CLHEP::mm;
+const G4double RichTbHpdMasterRadius = 43.5 * CLHEP::mm;
+const G4double RichTbHpdMasterZSize = 160.0 * CLHEP::mm;
 
-const G4double RichTbHpdEnvLargeTubeOutR = 40.3*CLHEP::mm;
-const G4double RichTbHpdEnvLargeTubeThickness = 0.75*CLHEP::mm;
+const G4double RichTbHpdEnvLargeTubeOutR = 40.3 * CLHEP::mm;
+const G4double RichTbHpdEnvLargeTubeThickness = 0.75 * CLHEP::mm;
 
-const G4double RichTbHpdEnvLargeTubInnR=
-        RichTbHpdEnvLargeTubeOutR-RichTbHpdEnvLargeTubeThickness;
+const G4double RichTbHpdEnvLargeTubInnR = RichTbHpdEnvLargeTubeOutR - RichTbHpdEnvLargeTubeThickness;
 
-const G4double RichTbHpdEnvLargeTubeZSize = 96.0*CLHEP::mm;
-const G4double RichTbHpdEnvEndCapZsize = 2.0*CLHEP::mm;
-const G4double RichTbHpdEnvEndCapRadTolerence = 0.1*CLHEP::mm;
+const G4double RichTbHpdEnvLargeTubeZSize = 96.0 * CLHEP::mm;
+const G4double RichTbHpdEnvEndCapZsize = 2.0 * CLHEP::mm;
+const G4double RichTbHpdEnvEndCapRadTolerence = 0.1 * CLHEP::mm;
 
-const G4double RichTbHpdQuartzWOuterRad = 62.0*CLHEP::mm;
+const G4double RichTbHpdQuartzWOuterRad = 62.0 * CLHEP::mm;
 
+const G4double RichTbHpdQuartzWThickness = 7.0 * CLHEP::mm;
 
-const G4double RichTbHpdQuartzWThickness = 7.0*CLHEP::mm;
+const G4double RichTbHpdPhCathodeThickness = 0.05 * CLHEP::mm;
+const G4double RichTbHpdActiveInputRad = 37.5 * CLHEP::mm;
+// const G4double RichTbHpdActiveInputRad=36.0*CLHEP::mm;
+const G4double RichTbHpdQuartzWCylEnvInnerR = RichTbHpdActiveInputRad;
+const G4double RichTbHpdQuartzWCylEnvOuterR = 40.3 * CLHEP::mm;
 
-
-
-const G4double RichTbHpdPhCathodeThickness= 0.05*CLHEP::mm;
-const G4double RichTbHpdActiveInputRad=37.5*CLHEP::mm;
-//const G4double RichTbHpdActiveInputRad=36.0*CLHEP::mm;
-const G4double RichTbHpdQuartzWCylEnvInnerR= RichTbHpdActiveInputRad;
-const G4double RichTbHpdQuartzWCylEnvOuterR = 40.3*CLHEP::mm;
-
-const G4double RichTbHpdEnvFromEndZ= 40.5*CLHEP::mm;
-const G4double RichTbHpdQuartzWindowFromEndZ=20.0*CLHEP::mm;
-//const G4double RichTbHpdSiDetDistZFromPhCathode=100.0*CLHEP::mm;
-const G4double RichTbHpdSiDetDistZFromPhCathode=111.2*CLHEP::mm;
-const G4double RichTbHpdQWCylEnvOuterLargeValue=500.0*CLHEP::mm;
-const G4double RichTbHpdQWCylEnvZLargeValue=1000.0*CLHEP::mm;
+const G4double RichTbHpdEnvFromEndZ = 40.5 * CLHEP::mm;
+const G4double RichTbHpdQuartzWindowFromEndZ = 20.0 * CLHEP::mm;
+// const G4double RichTbHpdSiDetDistZFromPhCathode=100.0*CLHEP::mm;
+const G4double RichTbHpdSiDetDistZFromPhCathode = 111.2 * CLHEP::mm;
+const G4double RichTbHpdQWCylEnvOuterLargeValue = 500.0 * CLHEP::mm;
+const G4double RichTbHpdQWCylEnvZLargeValue = 1000.0 * CLHEP::mm;
 
 // create a hexagonal array. The max radius= 22/2=11 CLHEP::mm
 
-const G4double RichTbHpdSiDetRadiusSize= 11*CLHEP::mm;
-const G4double RichTbHpdSiDetZSize=0.3*CLHEP::mm;
+const G4double RichTbHpdSiDetRadiusSize = 11 * CLHEP::mm;
+const G4double RichTbHpdSiDetZSize = 0.3 * CLHEP::mm;
 
-const G4double RichTbHpdSiDetHexPixelFlatToFlatSize=1.4*CLHEP::mm;
-const G4double RichTbHpdSiDetHexPixelDiagonalSize = RichTbHpdSiDetHexPixelFlatToFlatSize * 2.0/ sqrt(3.0);
-const G4double RichTbHpdSiDetHexPixelEdgeSize= RichTbHpdSiDetHexPixelFlatToFlatSize/sqrt(3.0);
-const G4double RichTbHpdSiDetHexPixelRadius= RichTbHpdSiDetHexPixelDiagonalSize/2.0;
+const G4double RichTbHpdSiDetHexPixelFlatToFlatSize = 1.4 * CLHEP::mm;
+const G4double RichTbHpdSiDetHexPixelDiagonalSize = RichTbHpdSiDetHexPixelFlatToFlatSize * 2.0 / sqrt(3.0);
+const G4double RichTbHpdSiDetHexPixelEdgeSize = RichTbHpdSiDetHexPixelFlatToFlatSize / sqrt(3.0);
+const G4double RichTbHpdSiDetHexPixelRadius = RichTbHpdSiDetHexPixelDiagonalSize / 2.0;
 const G4double RichTbHpdSiDetPixelZSize = RichTbHpdSiDetZSize;
 
-const G4double RichTbHpdSiDetPixelHexPhiStart=0.0*CLHEP::rad;
-const G4double RichTbHpdSiDetPixelHexPhiEnd=CLHEP::pi* CLHEP::rad;
-const G4int RichTbHpdSiDetPixelHexNumSide=6;
-const G4int RichTbHpdSiDetPixelHexNumZPlanes=2;
-const G4double  RichTbHpdSiDetPixelHexZPlane []= {-0.5*RichTbHpdSiDetPixelZSize, 0.5*RichTbHpdSiDetPixelZSize};
-const G4double  RichTbHpdSiDetPixelHexRInner [] ={ 0.0*CLHEP::mm, 0.0*CLHEP::mm};
-const G4double  RichTbHpdSiDetPixelHexROuter [] ={RichTbHpdSiDetHexPixelRadius,RichTbHpdSiDetHexPixelRadius};
-const G4int NumPixelTotInSingleHpd= 163;
-const G4int NumHpdPixelRows=15;
-const std::vector<G4int> NumHpdPixelInRows ={6,9,10,11,12,13,14,13,14,13,12,11,10,9,6  };
-
-const G4double HpdPixelYCenterStart= -10.5* RichTbHpdSiDetHexPixelEdgeSize;
-const G4double HpdPixelYCenterShift= 1.5*  RichTbHpdSiDetHexPixelEdgeSize;
-const G4double HpdPixelXCenterShift = 0.5* RichTbHpdSiDetHexPixelFlatToFlatSize;
-const G4double RichTbSiDetShiftAlongX  = 0.0*CLHEP::mm;
-const G4double RichTbSiDetShiftAlongY  = 0.0*CLHEP::mm;
+const G4double RichTbHpdSiDetPixelHexPhiStart = 0.0 * CLHEP::rad;
+const G4double RichTbHpdSiDetPixelHexPhiEnd = CLHEP::pi * CLHEP::rad;
+const G4int RichTbHpdSiDetPixelHexNumSide = 6;
+const G4int RichTbHpdSiDetPixelHexNumZPlanes = 2;
+const G4double RichTbHpdSiDetPixelHexZPlane[] = {-0.5 * RichTbHpdSiDetPixelZSize, 0.5 * RichTbHpdSiDetPixelZSize};
+const G4double RichTbHpdSiDetPixelHexRInner[] = {0.0 * CLHEP::mm, 0.0 * CLHEP::mm};
+const G4double RichTbHpdSiDetPixelHexROuter[] = {RichTbHpdSiDetHexPixelRadius, RichTbHpdSiDetHexPixelRadius};
+const G4int NumPixelTotInSingleHpd = 163;
+const G4int NumHpdPixelRows = 15;
+const std::vector<G4int> NumHpdPixelInRows = {6, 9, 10, 11, 12, 13, 14, 13, 14, 13, 12, 11, 10, 9, 6};
+
+const G4double HpdPixelYCenterStart = -10.5 * RichTbHpdSiDetHexPixelEdgeSize;
+const G4double HpdPixelYCenterShift = 1.5 * RichTbHpdSiDetHexPixelEdgeSize;
+const G4double HpdPixelXCenterShift = 0.5 * RichTbHpdSiDetHexPixelFlatToFlatSize;
+const G4double RichTbSiDetShiftAlongX = 0.0 * CLHEP::mm;
+const G4double RichTbSiDetShiftAlongY = 0.0 * CLHEP::mm;
 
 const G4double RichTbHpdSMasterRadius = RichTbHpdMasterRadius;
 const G4double RichTbHpdSMasterZSize = RichTbHpdMasterZSize;
@@ -73,86 +69,82 @@ const G4double RichTbHpdQuartzWInnerRad = RichTbHpdQuartzWOuterRad - RichTbHpdQu
 const G4double RichTbHpdPhCathodeOuterRad = RichTbHpdQuartzWInnerRad;
 const G4double RichTbHpdPhCathodeInnerRad = RichTbHpdPhCathodeOuterRad - RichTbHpdPhCathodeThickness;
 
-const G4double RichTbHpdQuartzWDeltaTheta = asin( RichTbHpdActiveInputRad / RichTbHpdQuartzWInnerRad );
+const G4double RichTbHpdQuartzWDeltaTheta = asin(RichTbHpdActiveInputRad / RichTbHpdQuartzWInnerRad);
 
-const G4double  RichTbHpdPhCathodeDeltaTheta = RichTbHpdQuartzWDeltaTheta;
+const G4double RichTbHpdPhCathodeDeltaTheta = RichTbHpdQuartzWDeltaTheta;
 
 // now positioning the various parts in an hpd.
 const G4double RichTbEnvLargeTubZLocation =
- -0.5*(RichTbHpdSMasterZSize-RichTbHpdEnvLargeTubeZSize)+ RichTbHpdEnvFromEndZ;
+    -0.5 * (RichTbHpdSMasterZSize - RichTbHpdEnvLargeTubeZSize) + RichTbHpdEnvFromEndZ;
 const G4double RichTbHpdEndCapZLocation =
- -0.5*(RichTbHpdSMasterZSize-RichTbHpdEnvEndCapZsize)+
- RichTbHpdEnvFromEndZ+RichTbHpdEnvLargeTubeZSize;
-const G4double RichTbHpdQuartzWZLocation = -0.5*RichTbHpdSMasterZSize
- +RichTbHpdQuartzWindowFromEndZ+ RichTbHpdQuartzWOuterRad;
-const G4double RichTbHpdPhCathodeZLocation=RichTbHpdQuartzWZLocation;
-const G4double RichTbHpdSiDetZLocation=-0.5*RichTbHpdSMasterZSize + RichTbHpdQuartzWindowFromEndZ
-                              + RichTbHpdQuartzWThickness+RichTbHpdSiDetDistZFromPhCathode
-                              + 0.5*RichTbHpdSiDetZSize;
-
-const G4double RichTbHpdQuartzWRotY=CLHEP::pi* CLHEP::rad;
-const G4double RichTbHpdPhCathodeRotY=RichTbHpdQuartzWRotY;
+    -0.5 * (RichTbHpdSMasterZSize - RichTbHpdEnvEndCapZsize) + RichTbHpdEnvFromEndZ + RichTbHpdEnvLargeTubeZSize;
+const G4double RichTbHpdQuartzWZLocation =
+    -0.5 * RichTbHpdSMasterZSize + RichTbHpdQuartzWindowFromEndZ + RichTbHpdQuartzWOuterRad;
+const G4double RichTbHpdPhCathodeZLocation = RichTbHpdQuartzWZLocation;
+const G4double RichTbHpdSiDetZLocation = -0.5 * RichTbHpdSMasterZSize + RichTbHpdQuartzWindowFromEndZ +
+                                         RichTbHpdQuartzWThickness + RichTbHpdSiDetDistZFromPhCathode +
+                                         0.5 * RichTbHpdSiDetZSize;
+
+const G4double RichTbHpdQuartzWRotY = CLHEP::pi * CLHEP::rad;
+const G4double RichTbHpdPhCathodeRotY = RichTbHpdQuartzWRotY;
 
 // default parameters for Hpd componenets
-const G4double RichTbHpdSMasterXLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdSMasterYLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdSMasterZLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdEnvTubeXLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdEnvTubeYLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdEndCapXLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdEndCapYLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdQuartzWindowXLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdQuartzWindowYLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdPhCathodeXLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdPhCathodeYLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdQWCylXLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdQWCylYLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdQWCylZLocation=0.0*CLHEP::mm;
-const G4double RichTbHpdMasterInnerRad=0.0*CLHEP::mm;
-const G4double  RichTbHpdSMasterInnerRad=0.0*CLHEP::mm;
-const G4double  RichTbHpdMasterStartPhi=0.0*CLHEP::rad;
-const G4double  RichTbHpdMasterEndPhi = (2.0*CLHEP::pi)*CLHEP::rad;
-const G4double  RichTbHpdSMasterStartPhi=0.0*CLHEP::rad;
-const G4double  RichTbHpdSMasterEndPhi = (2.0*CLHEP::pi)*CLHEP::rad;
-const G4double  RichTbHpdEnvelopeTubeStartPhi=0.0*CLHEP::rad;
-const G4double  RichTbHpdEnvelopeTubeEndPhi=(2.0*CLHEP::pi)*CLHEP::rad;
-const G4double  RichTbHpdEnvelopeEndCapStartPhi=0.0*CLHEP::rad;
-const G4double  RichTbHpdEnvelopeEndCapEndPhi=(2.0*CLHEP::pi)*CLHEP::rad;
-const G4double  RichTbHpdEndCapInnerRad=0.0*CLHEP::mm;
-const G4double  RichTbHpdQuartzWStartPhi=0.0*CLHEP::rad;
-const G4double  RichTbHpdQuartzWDeltaPhi=(2.0*CLHEP::pi)*CLHEP::rad;
-const G4double  RichTbHpdQuartzWStartTheta=0.0*CLHEP::rad;
-const G4double  RichTbHpdPhCathodeStartPhi=0.0*CLHEP::rad;
-const G4double  RichTbHpdPhCathodeDeltaPhi=(2.0*CLHEP::pi)*CLHEP::rad;
-const G4double  RichTbHpdPhCathodeStartTheta=0.0*CLHEP::rad;
-const G4double  RichTbSiDetNominalXLocation=0.0*CLHEP::mm;
-const G4double  RichTbSiDetNominalYLocation=0.0*CLHEP::mm;
-const G4double  RichTbHpdQWCylEnvStartPhi=0.0*CLHEP::rad;
-const G4double  RichTbHpdQWCylEnvEndPhi=(2.0*CLHEP::pi)*CLHEP::rad;
-const G4double  RichHpdSiPixelPosZInSiDet=0.0*CLHEP::mm;
-const G4double RichTbHpdSiDetInnerRadiusSize= 0.0*CLHEP::mm;
-const G4double RichTbHpdSiDetStartPhi=0.0*CLHEP::rad;
-const G4double RichTbHpdSiDetEndPhi= (2.0*CLHEP::pi)*CLHEP::rad;
+const G4double RichTbHpdSMasterXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdSMasterYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdSMasterZLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdEnvTubeXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdEnvTubeYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdEndCapXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdEndCapYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdQuartzWindowXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdQuartzWindowYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdPhCathodeXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdPhCathodeYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdQWCylXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdQWCylYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdQWCylZLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdMasterInnerRad = 0.0 * CLHEP::mm;
+const G4double RichTbHpdSMasterInnerRad = 0.0 * CLHEP::mm;
+const G4double RichTbHpdMasterStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdMasterEndPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
+const G4double RichTbHpdSMasterStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdSMasterEndPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
+const G4double RichTbHpdEnvelopeTubeStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdEnvelopeTubeEndPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
+const G4double RichTbHpdEnvelopeEndCapStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdEnvelopeEndCapEndPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
+const G4double RichTbHpdEndCapInnerRad = 0.0 * CLHEP::mm;
+const G4double RichTbHpdQuartzWStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdQuartzWDeltaPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
+const G4double RichTbHpdQuartzWStartTheta = 0.0 * CLHEP::rad;
+const G4double RichTbHpdPhCathodeStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdPhCathodeDeltaPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
+const G4double RichTbHpdPhCathodeStartTheta = 0.0 * CLHEP::rad;
+const G4double RichTbSiDetNominalXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbSiDetNominalYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbHpdQWCylEnvStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdQWCylEnvEndPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
+const G4double RichHpdSiPixelPosZInSiDet = 0.0 * CLHEP::mm;
+const G4double RichTbHpdSiDetInnerRadiusSize = 0.0 * CLHEP::mm;
+const G4double RichTbHpdSiDetStartPhi = 0.0 * CLHEP::rad;
+const G4double RichTbHpdSiDetEndPhi = (2.0 * CLHEP::pi) * CLHEP::rad;
 
 // now for the HPD locations.
-const G4String HpdNamesBox="Hpd0Box";
+const G4String HpdNamesBox = "Hpd0Box";
 
-const G4String HpdNamesLog= "Hpd0Log";
+const G4String HpdNamesLog = "Hpd0Log";
 
-const G4String HpdNamesPhys= "Hpd0Phys";
-const G4double HpdPhCathodeXCenterInPhSup= 0.0*CLHEP::mm;
+const G4String HpdNamesPhys = "Hpd0Phys";
+const G4double HpdPhCathodeXCenterInPhSup = 0.0 * CLHEP::mm;
 
-const G4double HpdPhCathodeYCenterInPhSup = 0.0*CLHEP::mm;
+const G4double HpdPhCathodeYCenterInPhSup = 0.0 * CLHEP::mm;
 
 const G4double RichTbHpdMasterXLocation = HpdPhCathodeXCenterInPhSup;
 const G4double RichTbHpdMasterYLocation = HpdPhCathodeYCenterInPhSup;
 
- const G4double RichTbHpdMasterZLocation = (-0.5*PhDetSupFrameZSize)  +
-  +0.5*RichTbHpdMasterZSize;
-
-const G4double RichTbHpdMasterRotationYAxis = 0.0*CLHEP::rad;
-const G4double RichTbHpdMasterRotationZAxis = 0.0*CLHEP::rad;
-
+const G4double RichTbHpdMasterZLocation = (-0.5 * PhDetSupFrameZSize) + +0.5 * RichTbHpdMasterZSize;
 
+const G4double RichTbHpdMasterRotationYAxis = 0.0 * CLHEP::rad;
+const G4double RichTbHpdMasterRotationZAxis = 0.0 * CLHEP::rad;
 
 #endif // INCLUDE_RICHTBHPDGEOMETRYPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpdRODummySD.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpdRODummySD.hh
index 38e8fe3d0b755ebbf6ea48b7a742e269d2543e0e..8bf387d2440fe4cfdf391daf162b743e445fd0ac 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpdRODummySD.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpdRODummySD.hh
@@ -1,38 +1,33 @@
-#ifndef INCLUDE_RICHTBHPDRODUMMYSD_HH 
+#ifndef INCLUDE_RICHTBHPDRODUMMYSD_HH
 #define INCLUDE_RICHTBHPDRODUMMYSD_HH 1
 
 // Include files
 #include "Geant4/G4VSensitiveDetector.hh"
 /** @class RichTbHpdRODummySD RichTbHpdRODummySD.hh include/RichTbHpdRODummySD.hh
- *  
+ *
  *
  *  @author Sajan Easo
  *  @date   2015-05-06
  */
-class RichTbHpdRODummySD: public G4VSensitiveDetector {
-public: 
+class RichTbHpdRODummySD : public G4VSensitiveDetector {
+public:
   /// Standard constructor
-  RichTbHpdRODummySD(); 
+  RichTbHpdRODummySD();
 
   virtual ~RichTbHpdRODummySD(); ///< Destructor
-  void Initialize(G4HCofThisEvent* /* HCE */) {}
-  G4bool ProcessHits(G4Step* /* aStep */,G4TouchableHistory* /* ROhist */) {return false;}
-  void EndOfEvent(G4HCofThisEvent* /* HCE */) {}
-  void clear() {}
-  void DrawAll() {}
-  void PrintAll() {}
+  void Initialize(G4HCofThisEvent * /* HCE */) override {}
+  G4bool ProcessHits(G4Step * /* aStep */, G4TouchableHistory * /* ROhist */) override { return false; }
+  void EndOfEvent(G4HCofThisEvent * /* HCE */) override {}
+  void clear() override {}
+  void DrawAll() override {}
+  void PrintAll() override {}
 
 protected:
-
 private:
-
-
 };
 
-RichTbHpdRODummySD::RichTbHpdRODummySD(): G4VSensitiveDetector("RichTbHpdROdummySD") {}
-
-RichTbHpdRODummySD::~RichTbHpdRODummySD(){  }
-
+RichTbHpdRODummySD::RichTbHpdRODummySD() : G4VSensitiveDetector("RichTbHpdROdummySD") {}
 
+RichTbHpdRODummySD::~RichTbHpdRODummySD() {}
 
 #endif // INCLUDE_RICHTBHPDRODUMMYSD_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpdSupportFrameGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpdSupportFrameGeometryParameters.hh
index 98f7ab8aeb71c331b2df1324fe76532250d6556f..25bd0800029f251dd894c3359a92d64187394e81 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpdSupportFrameGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbHpdSupportFrameGeometryParameters.hh
@@ -1,42 +1,35 @@
-#ifndef INCLUDE_RICHTBHPDSUPPORTFRAMEGEOMETRYPARAMETERS_HH 
+#ifndef INCLUDE_RICHTBHPDSUPPORTFRAMEGEOMETRYPARAMETERS_HH
 #define INCLUDE_RICHTBHPDSUPPORTFRAMEGEOMETRYPARAMETERS_HH 1
 
+const G4double HpdPhDetSupFrameXSize = 100.0 * CLHEP::mm;
+const G4double HpdPhDetSupFrameYSize = 100.0 * CLHEP::mm;
 
+const G4double HpdPhDetSupFrameZSize = 180.0 * CLHEP::mm;
 
+// const G4double RadiatorHpdGap = 46.40*CLHEP::mm;
 
+const G4double HpdExtraZShiftFromFocalPlane = 26.4 * CLHEP::mm;
 
-const G4double HpdPhDetSupFrameXSize = 100.0*CLHEP::mm;
-const G4double HpdPhDetSupFrameYSize = 100.0*CLHEP::mm;
+// const G4double RadiatorHpdGap = 25.5*CLHEP::mm + 26.4 CLHEP::mm;
 
-const G4double HpdPhDetSupFrameZSize = 180.0*CLHEP::mm;
+const G4double RadiatorHpdGap = PhotonDetPlaneGapWrtRadiatorSurface + HpdExtraZShiftFromFocalPlane;
 
+const G4double HpdPhotonDetectorPlaneZ = RadiatorLensThickness + RadiatorHpdGap + RichTbHpdQuartzWThickness;
 
-//const G4double RadiatorHpdGap = 46.40*CLHEP::mm;
- 
-const G4double HpdExtraZShiftFromFocalPlane= 26.4*CLHEP::mm;
+// const G4double HpdPhotonDetectorPlaneX = -68.1*CLHEP::mm; // from the drawing
 
-//const G4double RadiatorHpdGap = 25.5*CLHEP::mm + 26.4 CLHEP::mm;
+// const G4double HpdPhotonDetectorSupFrameXLocation = HpdPhotonDetectorPlaneX;
+const G4double HpdPhotonDetectorSupFrameXLocation = PhDetSupFrameXLocation[1]; // from later measurements.
+const G4double HpdPhotonDetectorSupFrameYLocation = 0.0 * CLHEP::mm;
+const G4double HpdPhDetFrameZTolerence = 10.0 * CLHEP::mm;
 
-const G4double RadiatorHpdGap =    PhotonDetPlaneGapWrtRadiatorSurface + HpdExtraZShiftFromFocalPlane;
+const G4double HpdPhotonDetPlaneToPhDetSupFrameFrontSurface =
+    -1.0 * (RichTbHpdQuartzWThickness + RichTbHpdQuartzWindowFromEndZ + HpdPhDetFrameZTolerence);
 
-const G4double HpdPhotonDetectorPlaneZ = RadiatorLensThickness +  RadiatorHpdGap + RichTbHpdQuartzWThickness;
-
-//const G4double HpdPhotonDetectorPlaneX = -68.1*CLHEP::mm; // from the drawing
-
-//const G4double HpdPhotonDetectorSupFrameXLocation = HpdPhotonDetectorPlaneX; 
-const G4double HpdPhotonDetectorSupFrameXLocation = PhDetSupFrameXLocation [1]; // from later measurements.
-const G4double HpdPhotonDetectorSupFrameYLocation = 0.0 *CLHEP::mm;
-const G4double HpdPhDetFrameZTolerence = 10.0*CLHEP::mm;
-
-
-const G4double HpdPhotonDetPlaneToPhDetSupFrameFrontSurface = -1.0*(RichTbHpdQuartzWThickness + 
-                                                                    RichTbHpdQuartzWindowFromEndZ + HpdPhDetFrameZTolerence );
-
-const G4double HpdPhDetSupFrameZLocation =   HpdPhotonDetectorPlaneZ 
-         +HpdPhotonDetPlaneToPhDetSupFrameFrontSurface+ 0.5* HpdPhDetSupFrameZSize;
-
-
-const G4double RichTbHpdMasterZLocation = (-0.5*HpdPhDetSupFrameZSize)  +0.5*RichTbHpdMasterZSize + HpdPhDetFrameZTolerence ;
+const G4double HpdPhDetSupFrameZLocation =
+    HpdPhotonDetectorPlaneZ + HpdPhotonDetPlaneToPhDetSupFrameFrontSurface + 0.5 * HpdPhDetSupFrameZSize;
 
+const G4double RichTbHpdMasterZLocation =
+    (-0.5 * HpdPhDetSupFrameZSize) + 0.5 * RichTbHpdMasterZSize + HpdPhDetFrameZTolerence;
 
 #endif // INCLUDE_RICHTBHPDSUPPORTFRAMEGEOMETRYPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbIOData.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbIOData.hh
index 715624fd827c5a2bd6317a6464f7d90f369859ce..a5e8d70727c40d06cf46fa03259eb49629cea582 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbIOData.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbIOData.hh
@@ -7,23 +7,21 @@
 #include "Geant4/G4Event.hh"
 class RichTbIOData {
 
-  public:
-
+public:
   //    RichTbIOData();
 
-    virtual ~ RichTbIOData();
-  static RichTbIOData* getRichTbIODataInstance();
-  
-    void WriteOutEventHeaderData(const G4Event *);
-    void WriteOutHitData(const G4Event *);
-    
-  private:
-    RichTbIOData();
-  static RichTbIOData* RichTbIODataInstance;
-  
-     std::ofstream OutputDataFS;
-    G4String aOutFileString;
-    bool m_IsFirstEvent;
-  
+  virtual ~RichTbIOData();
+  static RichTbIOData *getRichTbIODataInstance();
+
+  void WriteOutEventHeaderData(const G4Event *);
+  void WriteOutHitData(const G4Event *);
+
+private:
+  RichTbIOData();
+  static RichTbIOData *RichTbIODataInstance;
+
+  std::ofstream OutputDataFS;
+  G4String aOutFileString;
+  bool m_IsFirstEvent;
 };
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbLensGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbLensGeometryParameters.hh
index 443b1285166569e392aadb0e4339724bdbca7e11..f96f01f148944c8700420c165103773e98fdf369 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbLensGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbLensGeometryParameters.hh
@@ -1,32 +1,32 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBLENSGEOMETRYPARAMETERS_HH 
+#ifndef INCLUDE_RICHTBLENSGEOMETRYPARAMETERS_HH
 #define INCLUDE_RICHTBLENSGEOMETRYPARAMETERS_HH 1
 
 // Include files
 /** @class RichTbVesselGeometryParameters RichTbVesselGeometryParameters.hh include/RichTbVesselGeometryParameters.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-10-21
  */
 
-const G4double SphRadius1=402.0*CLHEP::mm;
-const G4double SphRadius2=400.0*CLHEP::mm;
-const G4double LensThickness = 10.0*CLHEP::mm;
+const G4double SphRadius1 = 402.0 * CLHEP::mm;
+const G4double SphRadius2 = 400.0 * CLHEP::mm;
+const G4double LensThickness = 10.0 * CLHEP::mm;
 
-const G4double CBoxXSize = 500.0*CLHEP::mm;
-const G4double CBoxYSize = 500.0*CLHEP::mm;
-const G4double CBoxZSize = 500.0*CLHEP::mm;
+const G4double CBoxXSize = 500.0 * CLHEP::mm;
+const G4double CBoxYSize = 500.0 * CLHEP::mm;
+const G4double CBoxZSize = 500.0 * CLHEP::mm;
 
-const G4double DistanceSph= SphRadius1 + SphRadius2 - LensThickness; 
+const G4double DistanceSph = SphRadius1 + SphRadius2 - LensThickness;
 
-const G4double RichTbLensXLocation =0*CLHEP::mm;
+const G4double RichTbLensXLocation = 0 * CLHEP::mm;
 
-const G4double RichTbLensYLocation = 0*CLHEP::mm;
-const G4double RichTbLensZLocation = 500*CLHEP::mm - 2*SphRadius2;
+const G4double RichTbLensYLocation = 0 * CLHEP::mm;
+const G4double RichTbLensZLocation = 500 * CLHEP::mm - 2 * SphRadius2;
 
 // now for variables used after creaxting the geometry in stepaction.
 
-const G4double RichTbLensEnvPlateThickness=0.0*CLHEP::mm;
+const G4double RichTbLensEnvPlateThickness = 0.0 * CLHEP::mm;
 
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMasterGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMasterGeometryParameters.hh
index 6a6ff177262b723f74f932aea0774770cc97b93c..931f0deb2cf2174771516e7590da38707ddc7e4c 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMasterGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMasterGeometryParameters.hh
@@ -1,51 +1,51 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBMASTERGEOMETRYPARAMETERS_HH 
+#ifndef INCLUDE_RICHTBMASTERGEOMETRYPARAMETERS_HH
 #define INCLUDE_RICHTBMASTERGEOMETRYPARAMETERS_HH 1
 
 // Include files
 /** @class RichTbVesselGeometryParameters RichTbVesselGeometryParameters.hh include/RichTbVesselGeometryParameters.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-10-21
  */
 
-const G4double RichTbMasterXSize=27.0*CLHEP::mm;
-const G4double RichTbMasterYSize=27.0*CLHEP::mm;
-const G4double RichTbMasterZSize=22.0*CLHEP::mm;
+const G4double RichTbMasterXSize = 27.0 * CLHEP::mm;
+const G4double RichTbMasterYSize = 27.0 * CLHEP::mm;
+const G4double RichTbMasterZSize = 22.0 * CLHEP::mm;
 
-const G4double RichTbMaster1XLocation = -57.0*CLHEP::mm;
-const G4double RichTbMaster1YLocation = +13.5*CLHEP::mm;
-const G4double RichTbMaster1ZLocation = 0.0*CLHEP::mm;
+const G4double RichTbMaster1XLocation = -57.0 * CLHEP::mm;
+const G4double RichTbMaster1YLocation = +13.5 * CLHEP::mm;
+const G4double RichTbMaster1ZLocation = 0.0 * CLHEP::mm;
 
-const G4double RichTbMaster2XLocation = -57.0*CLHEP::mm;
-const G4double RichTbMaster2YLocation = -13.5*CLHEP::mm;
-const G4double RichTbMaster2ZLocation = 0.0*CLHEP::mm;
+const G4double RichTbMaster2XLocation = -57.0 * CLHEP::mm;
+const G4double RichTbMaster2YLocation = -13.5 * CLHEP::mm;
+const G4double RichTbMaster2ZLocation = 0.0 * CLHEP::mm;
 
-const G4double RichTbMaster3XLocation = 57.0*CLHEP::mm;
-const G4double RichTbMaster3YLocation = 13.5*CLHEP::mm;
-const G4double RichTbMaster3ZLocation = 0.0*CLHEP::mm;
+const G4double RichTbMaster3XLocation = 57.0 * CLHEP::mm;
+const G4double RichTbMaster3YLocation = 13.5 * CLHEP::mm;
+const G4double RichTbMaster3ZLocation = 0.0 * CLHEP::mm;
 
-const G4double RichTbMaster4XLocation = 57.0*CLHEP::mm;
-const G4double RichTbMaster4YLocation = -13.5*CLHEP::mm;
-const G4double RichTbMaster4ZLocation = 0.0*CLHEP::mm;
+const G4double RichTbMaster4XLocation = 57.0 * CLHEP::mm;
+const G4double RichTbMaster4YLocation = -13.5 * CLHEP::mm;
+const G4double RichTbMaster4ZLocation = 0.0 * CLHEP::mm;
 
 // now for variables used after creating the geometry in stepaction.
 
-const G4double RichTbMasterEnvPlateThickness=0.0*CLHEP::mm;
+const G4double RichTbMasterEnvPlateThickness = 0.0 * CLHEP::mm;
 // the following are not exact values.
-//const G4double  RichTbCrystalXNegExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX-RichTbCrystalXSize;
-//const G4double  RichTbCrystalXPosExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX;
-//const G4double  RichTbCrystalZUpsExtremeAlongCrystal= -RichTbCrystalUpsExternalPartZSize;
-//const G4double  RichTbCrystalZDnsExtremeAlongCrystal= -RichTbcrystalUpsExternalPartZSize+RichTbCrystalZSize;
-//const G4double  RichTbCrystalXNegExtreme=  RichTbCrystalXNegExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
+// const G4double  RichTbCrystalXNegExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX-RichTbCrystalXSize;
+// const G4double  RichTbCrystalXPosExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX;
+// const G4double  RichTbCrystalZUpsExtremeAlongCrystal= -RichTbCrystalUpsExternalPartZSize;
+// const G4double  RichTbCrystalZDnsExtremeAlongCrystal= -RichTbcrystalUpsExternalPartZSize+RichTbCrystalZSize;
+// const G4double  RichTbCrystalXNegExtreme=  RichTbCrystalXNegExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
 //                                          RichTbCrystalZDnsExtremeAlongCrystal*sin(RichTbCrystalYRotation);
-//const G4double  RichTbCrystalXPosExtreme=  RichTbCrystalXPosExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
+// const G4double  RichTbCrystalXPosExtreme=  RichTbCrystalXPosExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
 //                                          RichTbCrystalZUpsExtremeAlongCrystal*sin(RichTbCrystalYRotation);
 
-//const G4double  RichTbCrystalYNegExtreme= RichTbCrystalYLocation-0.5*RichTbCrystalYSize;
-//const G4double  RichTbCrystalYPosExtreme= RichTbCrystalYLocation+0.5*RichTbCrystalYSize;
-//const G4double  RichTbCrystalZDnsExtreme = -RichTbCrystalXNegExtremeAlongCrystal*sin(RichTbCrystalYRotation)+
+// const G4double  RichTbCrystalYNegExtreme= RichTbCrystalYLocation-0.5*RichTbCrystalYSize;
+// const G4double  RichTbCrystalYPosExtreme= RichTbCrystalYLocation+0.5*RichTbCrystalYSize;
+// const G4double  RichTbCrystalZDnsExtreme = -RichTbCrystalXNegExtremeAlongCrystal*sin(RichTbCrystalYRotation)+
 //                                        RichTbCrystalZDnsExtremeAlongCrystal*cos(RichTbCrystalYRotation);
-//const G4double  RichTbCrystalDnsZEnd = RichTbCrystalZDnsExtreme;
+// const G4double  RichTbCrystalDnsZEnd = RichTbCrystalZDnsExtreme;
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMaterial.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMaterial.hh
index dc36e7055923b6559fbedd117004d120888b0465..e6c7de4f8377dc0046c9f5a5fd80a1e89671b7f4 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMaterial.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMaterial.hh
@@ -1,5 +1,5 @@
-//This is the declaration of the LHCb RICH Testbeam Material description.
-//Author SE  1-3-2001
+// This is the declaration of the LHCb RICH Testbeam Material description.
+// Author SE  1-3-2001
 //
 #ifndef RichTbMaterial_h
 #define RichTbMaterial_h 1
@@ -13,93 +13,61 @@
 
 class RichTbMaterial {
 
-  public:
+public:
+  virtual ~RichTbMaterial();
+  static RichTbMaterial *getRichTbMaterialInstance();
 
-    virtual ~ RichTbMaterial();
-  static RichTbMaterial* getRichTbMaterialInstance();
-  
-    G4Material *getAir() {
-        return RichTbAmbientAir;
-    }
+  G4Material *getAir() { return RichTbAmbientAir; }
 
-    G4Material *getTAir() {
-        return RichTbTubeAir;
-    }
+  G4Material *getTAir() { return RichTbTubeAir; }
 
-    G4Material *getTAirA() {
-        return RichTbAirA;
-    }
-   G4Material* getNitrogenGas() {return RichTbNitrogenGas;}
-   G4Material* getc4f10Gas() {return RichTbc4f10Gas;}
-   G4Material* getMirrorQuartz() {return RichTbMirrorQuartz;}
-   G4Material* getRichTbVaccum() {return RichTbVaccum;}
-   G4Material* getAluminium() {return RichTbAluminium; }
-   G4Material* getCarbon() {return  RichTbCarbon;}
-  
-  
-  
-  G4Material* getPMTTubeEnvelopeMaterial() 
-  {
-    return PMTTubeEnvelopeMaterial;
-  }
-  G4Material* getPMTAnodeMaterial()
-  {
-    return PMTAnodeMaterial;
-    
-  }
-  G4Material* getPMTPhCathodeMaterial() 
-  {
-    return PMTPhCathodeMaterial;
-    
-  }
-  G4Material* getPMTQuartzWindowMaterial() 
-  {
-    return PMTQuartzWindowMaterial;
-  }
-  
- G4Material* getCrystalMaterial() 
-  {
-    return CrystalMaterial;
-  }
+  G4Material *getTAirA() { return RichTbAirA; }
+  G4Material *getNitrogenGas() { return RichTbNitrogenGas; }
+  G4Material *getc4f10Gas() { return RichTbc4f10Gas; }
+  G4Material *getMirrorQuartz() { return RichTbMirrorQuartz; }
+  G4Material *getRichTbVaccum() { return RichTbVaccum; }
+  G4Material *getAluminium() { return RichTbAluminium; }
+  G4Material *getCarbon() { return RichTbCarbon; }
 
-  G4Material*   getRichTbGasWinQuartz() {return RichTbGasWinQuartz;}   
-  G4Material* getHpdTubeEnvelopeMaterial (){    return HpdTubeEnvelopeMaterial;}
-  G4Material* getHpdQuartzWindowMaterial ()  {  return HPDQuartzWindowMaterial;}
-  G4Material* getHpdPhCathodeMaterial  ()  {  return HPDPhCathodeMaterial;}
-  G4Material* getHpdSiDetMaterial ()  {  return HpdSiDetMaterial;}
-  
-  
-  
-  private:
-    RichTbMaterial();
-  static RichTbMaterial* RichTbMaterialInstance;
-  
-    G4Material * RichTbAmbientAir;
-    G4Material *RichTbTubeAir;
-    G4Material *RichTbAirA;
+  G4Material *getPMTTubeEnvelopeMaterial() { return PMTTubeEnvelopeMaterial; }
+  G4Material *getPMTAnodeMaterial() { return PMTAnodeMaterial; }
+  G4Material *getPMTPhCathodeMaterial() { return PMTPhCathodeMaterial; }
+  G4Material *getPMTQuartzWindowMaterial() { return PMTQuartzWindowMaterial; }
 
-    G4Material* RichTbNitrogenGas;
-    G4Material* RichTbc4f10Gas;
-    G4Material* RichTbMirrorQuartz;
-    G4Material* RichTbVaccum;
-    G4Material* RichTbAluminium;
-    G4Material*  RichTbCarbon;
-    G4Material* PMTTubeEnvelopeMaterial;
-    G4Material* PMTAnodeMaterial;
-    G4Material* PMTQuartzWindowMaterial;
-    G4Material* CrystalMaterial;
-    G4Material* PMTPhCathodeMaterial;
-    G4Material*   RichTbGasWinQuartz;
-    G4Material* HpdTubeEnvelopeMaterial;
-    G4Material* HpdQuartzWindowMaterial;
-    G4Material* HpdPhCathodeMaterial;
-    G4Material* HpdSiDetMaterial;
-    G4Material* HPDQuartzWindowMaterial;
-    G4Material* HPDPhCathodeMaterial;
-  
+  G4Material *getCrystalMaterial() { return CrystalMaterial; }
 
-};
+  G4Material *getRichTbGasWinQuartz() { return RichTbGasWinQuartz; }
+  G4Material *getHpdTubeEnvelopeMaterial() { return HpdTubeEnvelopeMaterial; }
+  G4Material *getHpdQuartzWindowMaterial() { return HPDQuartzWindowMaterial; }
+  G4Material *getHpdPhCathodeMaterial() { return HPDPhCathodeMaterial; }
+  G4Material *getHpdSiDetMaterial() { return HpdSiDetMaterial; }
+
+private:
+  RichTbMaterial();
+  static RichTbMaterial *RichTbMaterialInstance;
 
+  G4Material *RichTbAmbientAir;
+  G4Material *RichTbTubeAir;
+  G4Material *RichTbAirA;
 
+  G4Material *RichTbNitrogenGas;
+  G4Material *RichTbc4f10Gas;
+  G4Material *RichTbMirrorQuartz;
+  G4Material *RichTbVaccum;
+  G4Material *RichTbAluminium;
+  G4Material *RichTbCarbon;
+  G4Material *PMTTubeEnvelopeMaterial;
+  G4Material *PMTAnodeMaterial;
+  G4Material *PMTQuartzWindowMaterial;
+  G4Material *CrystalMaterial;
+  G4Material *PMTPhCathodeMaterial;
+  G4Material *RichTbGasWinQuartz;
+  G4Material *HpdTubeEnvelopeMaterial;
+  G4Material *HpdQuartzWindowMaterial;
+  G4Material *HpdPhCathodeMaterial;
+  G4Material *HpdSiDetMaterial;
+  G4Material *HPDQuartzWindowMaterial;
+  G4Material *HPDPhCathodeMaterial;
+};
 
-#endif                          /*RichTbMaterial_h */
+#endif /*RichTbMaterial_h */
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMaterialParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMaterialParameters.hh
index 9ef4bda7c3d45227d80a13189cadb0085d4fce7b..182b69e31ce05dc71d3bceb45b503684e3085b87 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMaterialParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMaterialParameters.hh
@@ -6,142 +6,135 @@
 #include "RichTbRunConfig.hh"
 #include "RichTbMiscNames.hh"
 
-//k.
+// k.
 #include "Geant4/G4PhysicalConstants.hh"
 
 extern void InitializeRichTbMaterial();
-extern void  HistoRichMaterialProperty();
+extern void HistoRichMaterialProperty();
 extern std::vector<G4double> InitN2RefPhotMom();
 extern std::vector<G4double> Initc4f10RefPhotMom();
-extern G4double  N2RefIndexAtAnEnergy(G4double,G4double,G4double);
+extern G4double N2RefIndexAtAnEnergy(G4double, G4double, G4double);
 extern std::vector<G4double> InitN2RefIndex(G4double, G4double);
 extern std::vector<G4double> Initc4f10RefIndex(G4double, G4double);
-extern G4double  c4f10RefIndexAtAnEnergy(G4double,G4double,G4double);
+extern G4double c4f10RefIndexAtAnEnergy(G4double, G4double, G4double);
 extern std::vector<G4double> InitializePhotonMomentumVector();
-extern std::vector<G4double>  InitializePMTWaveL(G4int);
+extern std::vector<G4double> InitializePMTWaveL(G4int);
 extern std::vector<G4double> InitializePMTQE(G4int);
-extern G4double  FresnelLossAtNormalIncidence(G4double,G4double);
+extern G4double FresnelLossAtNormalIncidence(G4double, G4double);
 
-extern std::vector<G4double>  InitializeHpdWaveL(G4int);
+extern std::vector<G4double> InitializeHpdWaveL(G4int);
 extern std::vector<G4double> InitializeHpdQE(G4int);
 
-
 static const G4double PhotMomWaveConv = 1243.125;
-static const G4double PhotMomToWaveLength =  PhotMomWaveConv*(CLHEP::nanometer*CLHEP::eV);
-static const G4double PhotWaveLengthToMom = PhotMomWaveConv*(CLHEP::eV*CLHEP::nanometer);
+static const G4double PhotMomToWaveLength = PhotMomWaveConv * (CLHEP::nanometer * CLHEP::eV);
+static const G4double PhotWaveLengthToMom = PhotMomWaveConv * (CLHEP::eV * CLHEP::nanometer);
 
 // Limits of Photon Energy  and number of bins for the
 // Photon energy range.
 static const G4double PhotonMinEnergy = 1.3 * CLHEP::eV;
-//static const G4double PhotonMinEnergy = 0.5 * CLHEP::eV;
-//static const G4double PhotonMaxEnergy = 7.5 * CLHEP::eV;
+// static const G4double PhotonMinEnergy = 0.5 * CLHEP::eV;
+// static const G4double PhotonMaxEnergy = 7.5 * CLHEP::eV;
 static const G4double PhotonMaxEnergy = 6.5 * CLHEP::eV;
 static const G4int NumPhotWaveLengthBins = 1000;
-const G4double PhotEnerStep = (PhotonMaxEnergy -PhotonMinEnergy)/
-		(NumPhotWaveLengthBins);
-const G4int PhotEnerBinEdgeForSafety=2;
-//const G4int PhotEnerBinEdgeForSafety=20;
-const G4double PhotonCkvProdMinEnergy =
-		PhotonMinEnergy+ PhotEnerBinEdgeForSafety*PhotEnerStep;
-const G4double PhotonCkvProdMaxEnergy =
-		PhotonMaxEnergy-PhotEnerBinEdgeForSafety*PhotEnerStep;
-const G4int CkvProdNumPhotWaveLengthBins=
-		NumPhotWaveLengthBins -2* PhotEnerBinEdgeForSafety;
+const G4double PhotEnerStep = (PhotonMaxEnergy - PhotonMinEnergy) / (NumPhotWaveLengthBins);
+const G4int PhotEnerBinEdgeForSafety = 2;
+// const G4int PhotEnerBinEdgeForSafety=20;
+const G4double PhotonCkvProdMinEnergy = PhotonMinEnergy + PhotEnerBinEdgeForSafety * PhotEnerStep;
+const G4double PhotonCkvProdMaxEnergy = PhotonMaxEnergy - PhotEnerBinEdgeForSafety * PhotEnerStep;
+const G4int CkvProdNumPhotWaveLengthBins = NumPhotWaveLengthBins - 2 * PhotEnerBinEdgeForSafety;
 
 const G4int NumPhotonRichMirrorReflWaveLengthBins = 26;
 
 // Defintion of STP pressure and temp
 
-//static const G4double Pressure_STP=1.013*bar;
-//static const G4double Temperature_STP=273.*CLHEP::kelvin
+// static const G4double Pressure_STP=1.013*bar;
+// static const G4double Temperature_STP=273.*CLHEP::kelvin
 const G4double GasPressure_STP = CLHEP::STP_Pressure;
 const G4double GasTemperature_STP = CLHEP::STP_Temperature;
 // sellmeir coef  for nitrogen
 // Ref Index of nitrogen using sellmeir parametrization
-const G4double SellN2E1=13.414;
-const G4double SellN2E2=23.215;
-const G4double SellN2F1=921.28;
-const G4double SellN2F2=3569.60;
-const G4double GasMolWeightN2=28.02;      //unit is grams
-const G4double GasRhoN2atSTP=0.00125053;  //unit is gramPercm3
+const G4double SellN2E1 = 13.414;
+const G4double SellN2E2 = 23.215;
+const G4double SellN2F1 = 921.28;
+const G4double SellN2F2 = 3569.60;
+const G4double GasMolWeightN2 = 28.02;     // unit is grams
+const G4double GasRhoN2atSTP = 0.00125053; // unit is gramPercm3
 
 // Ref Index of c4f10 using sellmeir parametrization
-const G4double SellC4F10E1=18.938;
-const G4double SellC4F10E2=50.0;
-const G4double SellC4F10F1=12305.3;
-const G4double SellC4F10F2=0.0;
-const G4double GasMolWeightC4F10=138.0;      //unit is grams
-const G4double GasRhoC4F10atSTP=0.00964;  //unit is gramPercm3
+const G4double SellC4F10E1 = 18.938;
+const G4double SellC4F10E2 = 50.0;
+const G4double SellC4F10F1 = 12305.3;
+const G4double SellC4F10F2 = 0.0;
+const G4double GasMolWeightC4F10 = 138.0;  // unit is grams
+const G4double GasRhoC4F10atSTP = 0.00964; // unit is gramPercm3
 
 // Now for HPD
 
 // CHANGED JDICKENS (25/07/05) FOR TESTING
 
 const G4double PixelPMTPSFSigma = 50.0 * CLHEP::micrometer; // default
-//const G4double PixelPMTPSFSigma = 0.0 * CLHEP::micrometer;
+// const G4double PixelPMTPSFSigma = 0.0 * CLHEP::micrometer;
 
 // END OF CHANGE
 
-//static const G4int NumDemagnificationParam=4;
+// static const G4int NumDemagnificationParam=4;
 // The following change in March 2004.
-//static const G4int NumDemagnificationParam=5;
-//static const G4int NumDemagnificationParam=2;
+// static const G4int NumDemagnificationParam=5;
+// static const G4int NumDemagnificationParam=2;
 
-const G4double PixelPMTDemagConstShift=0.04323*CLHEP::mm;
+const G4double PixelPMTDemagConstShift = 0.04323 * CLHEP::mm;
 
 // The following shifts for constant term  made in March 2004. SE
-const G4double PixelPMTDemagNominalConstShiftX[]={0.0*CLHEP::mm,0.0*CLHEP::mm,0.0*CLHEP::mm,0.0*CLHEP::mm,0.0*CLHEP::mm,0.0*CLHEP::mm};
-const G4double PixelPMTDemagNominalConstShiftY[]={0.0*CLHEP::mm,0.0*CLHEP::mm,0.0*CLHEP::mm,0.0*CLHEP::mm,0.0*CLHEP::mm,0.0*CLHEP::mm};
+const G4double PixelPMTDemagNominalConstShiftX[] = {0.0 * CLHEP::mm, 0.0 * CLHEP::mm, 0.0 * CLHEP::mm,
+                                                    0.0 * CLHEP::mm, 0.0 * CLHEP::mm, 0.0 * CLHEP::mm};
+const G4double PixelPMTDemagNominalConstShiftY[] = {0.0 * CLHEP::mm, 0.0 * CLHEP::mm, 0.0 * CLHEP::mm,
+                                                    0.0 * CLHEP::mm, 0.0 * CLHEP::mm, 0.0 * CLHEP::mm};
 
 // CHANGED JDICKENS 20/06/05
-//const G4double PixelPMTDemagLinearFactor=-0.2018; // *default*
-//const G4double PixelPMTDemagLinearFactor=-0.1994; // Thierry Data
+// const G4double PixelPMTDemagLinearFactor=-0.2018; // *default*
+// const G4double PixelPMTDemagLinearFactor=-0.1994; // Thierry Data
 const G4double PixelPMTDemagLinearFactor = -0.1772; // make rings match
 
-//const G4double PixelPMTDemagQuadraticFactor=0.000741*(1.0/CLHEP::mm); // *default*
-//const G4double PixelPMTDemagQuadraticFactor=0.0007*(1.0/CLHEP::mm); // Thierry Data
-const G4double PixelPMTDemagQuadraticFactor=0.0*(1.0/CLHEP::mm); // make rings match
+// const G4double PixelPMTDemagQuadraticFactor=0.000741*(1.0/CLHEP::mm); // *default*
+// const G4double PixelPMTDemagQuadraticFactor=0.0007*(1.0/CLHEP::mm); // Thierry Data
+const G4double PixelPMTDemagQuadraticFactor = 0.0 * (1.0 / CLHEP::mm); // make rings match
 // END OF CHANGE
 
-const G4double PixelPMTDemagErrorLinearFactor=0.0;
+const G4double PixelPMTDemagErrorLinearFactor = 0.0;
 
-//static const G4int PmtQENumBins= 18; //SILICON TEST
-static const G4int PmtQENumBins= 60;
-//static const G4int PMTQENumBins= 31;
+// static const G4int PmtQENumBins= 18; //SILICON TEST
+static const G4int PmtQENumBins = 60;
+// static const G4int PMTQENumBins= 31;
 
-const G4double PMTQEReductionFactor=1.0;
-const G4double PmtQEWaveLenUnits= 1.0*CLHEP::nanometer;
+const G4double PMTQEReductionFactor = 1.0;
+const G4double PmtQEWaveLenUnits = 1.0 * CLHEP::nanometer;
 // since the quartz window of hpd cuts off at 200 nm.
 // now use the QE values measured in June 2004.  SE Sept 6,2004.
 // PMT labels  L0= 0, L1=1, C0=2, C1=3, R0=4, R1=5
 // nominal values for PMT QE in 2014 testbeam
 
+const G4double PmtQEWaveLen[] = {180, 190, 200, 210, 220, 230, 240, 250, 260, 270, 280, 290, 300, 310, 320,
+                                 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470,
+                                 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620,
+                                 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730, 740, 750, 760, 770};
 
-const G4double PmtQEWaveLen[] =
-{ 180,190,200,210, 220,230,240,250,260,270, 280, 290,
-        300,310, 320,330,340,350,360,370, 380, 390,
-        400,410, 420,430,440,450,460,470, 480, 490,
-        500,510, 520,530,540,550,560,570, 580, 590,
-        600,610, 620,630,640,650,660,670, 680, 690,
-        700,710, 720,730,740,750,760,770 };
-
-//for testing of silicon pmts
-//const G4double PmtQEWaveLen[] =
+// for testing of silicon pmts
+// const G4double PmtQEWaveLen[] =
 //	{200,208,220,243,255,273,293,315,344,373,410,460,500,
 //		555,623,685,760,800,831,860,881,910,931,950,968,990};
-//const G4double PmtQEWaveLen[] =
+// const G4double PmtQEWaveLen[] =
 //    {321,335,352,374,400,421,448,476,510,549,592,625,
 //     673,715,766,821,854,899};
-//const G4double PmtSiliconQEPerCent1[] =
+// const G4double PmtSiliconQEPerCent1[] =
 //	{1.6,10,21,27,34,44,57,65,72,76,79,80.6,81.3,80.3,80,79.2,
 //		78.3,77.5,73,66.3,59,47.5,37,29.5,21.7,13.7
 //};
-//const G4double PmtSiliconQEPerCent2[] =
+// const G4double PmtSiliconQEPerCent2[] =
 //    {4.1,12.6,24.5,34.5,41.8,45.0,47.1,47.5,44.5,39.3,33.4,
 //     28.0,22.7,17.9,13.2,8.0,6.8,5.0
 //};
 
-//const G4double PmtQEPerCent[] =
+// const G4double PmtQEPerCent[] =
 //{0,0,0,0.5,1,1.5,10,13,16.5,20,23.6,27.2,
 // 31,32,33,34,35,35,35,34.5,34,33.5,
 // 33,32.5,32,31.2,30,28,25.9,23.8,21.7,19.6,
@@ -149,226 +142,161 @@ const G4double PmtQEWaveLen[] =
 // 2.29,1.71,1.21,0.77,0.49,0.3,0.18,0.1,0.06,0.03,
 // 0.0181,0.01,0.0056,0.0028,0.0014,0.0007,0,0
 //};
-//BS entrance window
-const G4double Pmt2QEPerCent[] =
-{0,0,0,0,0,0,0,6.3,13.7,19.8,24.3,28.3,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-
-const G4double PmtQEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-//UV entrance window
-const G4double Pmt0QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-const G4double Pmt1QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-
-const G4double Pmt3QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-
-const G4double Pmt4QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-
-
-const G4double Pmt5QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-const G4double Pmt6QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-
-const G4double Pmt7QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-
-const G4double Pmt8QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-const G4double Pmt9QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-
-const G4double Pmt10QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-
-const G4double Pmt11QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-
-const G4double Pmt12QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-
-const G4double Pmt13QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-
-const G4double Pmt14QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-
-const G4double Pmt15QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-
-const G4double Pmt16QEPerCent[] =
-{0,0,11.5,13.2,15.2,17.0,19.3,21.3,23.1,24.7,27.2,29.4,
-		31.2,33.2,34.3,35.0,35.1,35.2,35.0,34.6,34.4,34.4,
-		33.6,32.8,31.8,31.0,29.5,28.2,26.6,24.4,22.6,20.9,
-		19.6,18.3,16.5,13.4,10.4,8.3,7.0,5.9,4.9,4.1,
-		3.3,2.5,1.8,1.3,0.9,0.5,0.3,0.2,0.1,0.1,
-		0.0,0.0,0.0,0.0,0.0,0.0,0,0
-};
-
-//std::vector<G4double> Pmt0QEPerCent= PmtQEPerCent;
-//std::vector<G4double> Pmt1QEPerCent= PmtQEPerCent;
-//std::vector<G4double> Pmt2QEPerCent= PmtQEPerCent;
-//std::vector<G4double> Pmt3QEPerCent= PmtQEPerCent;
-//std::vector<G4double> Pmt4QEPerCent= PmtQEPerCent;
-//std::vector<G4double> Pmt5QEPerCent= PmtQEPerCent;
-//std::vector<G4double> Pmt6QEPerCent= PmtQEPerCent;
-//std::vector<G4double> Pmt7QEPerCent= PmtQEPerCent;
-
-
-
-
-
-//const G4double PMTQEWaveLen[]=
+// BS entrance window
+const G4double Pmt2QEPerCent[] = {0,    0,    0,    0,    0,    0,    0,    6.3,  13.7, 19.8, 24.3, 28.3,
+                                  31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                  31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                  10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                  0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+
+const G4double PmtQEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                 31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                 31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                 10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                 0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+// UV entrance window
+const G4double Pmt0QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                  31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                  31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                  10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                  0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+const G4double Pmt1QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                  31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                  31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                  10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                  0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+
+const G4double Pmt3QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                  31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                  31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                  10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                  0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+
+const G4double Pmt4QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                  31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                  31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                  10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                  0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+
+const G4double Pmt5QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                  31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                  31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                  10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                  0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+const G4double Pmt6QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                  31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                  31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                  10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                  0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+
+const G4double Pmt7QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                  31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                  31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                  10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                  0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+
+const G4double Pmt8QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                  31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                  31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                  10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                  0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+const G4double Pmt9QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                  31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                  31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                  10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                  0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+
+const G4double Pmt10QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                   31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                   31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                   10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                   0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+
+const G4double Pmt11QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                   31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                   31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                   10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                   0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+
+const G4double Pmt12QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                   31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                   31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                   10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                   0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+
+const G4double Pmt13QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                   31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                   31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                   10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                   0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+
+const G4double Pmt14QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                   31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                   31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                   10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                   0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+
+const G4double Pmt15QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                   31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                   31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                   10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                   0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+
+const G4double Pmt16QEPerCent[] = {0,    0,    11.5, 13.2, 15.2, 17.0, 19.3, 21.3, 23.1, 24.7, 27.2, 29.4,
+                                   31.2, 33.2, 34.3, 35.0, 35.1, 35.2, 35.0, 34.6, 34.4, 34.4, 33.6, 32.8,
+                                   31.8, 31.0, 29.5, 28.2, 26.6, 24.4, 22.6, 20.9, 19.6, 18.3, 16.5, 13.4,
+                                   10.4, 8.3,  7.0,  5.9,  4.9,  4.1,  3.3,  2.5,  1.8,  1.3,  0.9,  0.5,
+                                   0.3,  0.2,  0.1,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0,  0.0,  0,    0};
+
+// std::vector<G4double> Pmt0QEPerCent= PmtQEPerCent;
+// std::vector<G4double> Pmt1QEPerCent= PmtQEPerCent;
+// std::vector<G4double> Pmt2QEPerCent= PmtQEPerCent;
+// std::vector<G4double> Pmt3QEPerCent= PmtQEPerCent;
+// std::vector<G4double> Pmt4QEPerCent= PmtQEPerCent;
+// std::vector<G4double> Pmt5QEPerCent= PmtQEPerCent;
+// std::vector<G4double> Pmt6QEPerCent= PmtQEPerCent;
+// std::vector<G4double> Pmt7QEPerCent= PmtQEPerCent;
+
+// const G4double PMTQEWaveLen[]=
 //  {200.0, 240.0, 270.0, 300.0, 320.0, 360.0, 400.0, 440.0, 480.0,
 //   520.0, 560.0, 600.0, 640.0, 700.0, 750.0, 800.0, 830.0,
 //   850.0, 880.0, 900.0
 //  };
 
-
-//const G4double PMT0QEPerCent[]=
+// const G4double PMT0QEPerCent[]=
 //  {10.21, 20.44, 23.04, 19.87, 17.61, 17.31, 19.80, 18.47,
 //   14.89, 12.62, 10.45, 8.38, 6.83, 4.93, 3.11,1.62,0.98,0.68,0.22,0.05
 //  };
-//const G4double PMT1QEPerCent[]=
+// const G4double PMT1QEPerCent[]=
 //  { 8.95, 19.44, 22.38, 19.46, 17.74, 17.24, 18.46, 15.78, 12.11,
 //    9.59, 7.23, 5.10, 3.57, 1.57, 0.37, 0.02, 0.01, 0.0, 0.0, 0.0
 //  };
-//const G4double PMT2QEPerCent[]=
+// const G4double PMT2QEPerCent[]=
 //  {8.70, 24.17, 27.90, 24.63,22.19,21.67,23.29,19.39,15.69,12.37,
 //   9.27,6.25,4.05,1.17,0.12,0.0,0.0,0.0,0.0,0.0
 //  };
 
-//static const G4int PMTQuartzRefIndNumBins=29;
+// static const G4int PMTQuartzRefIndNumBins=29;
 // extra two bins added, one at each edge,
 //  to cover the wavelength
 // range of other materals.
-static const G4int PMTQuartzRefIndNumBins=31;
-//static const G4int CrystalMatRefIndNumBins=51;
-static const G4int CrystalMatRefIndNumBins=52;
-
-const G4double PMTQuartzRefWaveLenUnits= 1.0*CLHEP::nanometer;
-const G4double CrystalMatRefWaveLenUnits= 1.0*CLHEP::nanometer;
-
-const G4double PMTQuartzRefWaveLenValues[]=
-{150.0, 185.41, 193.53, 202.54, 206.20, 214.45, 226.50, 232.94,
-		250.20, 253.70, 257.62, 274.87, 298.06, 328.36, 340.36,346.69,
-		361.17, 398.84, 435.83, 486.13, 546.07, 587.56, 589.00, 589.60,
-		656.27, 670.00, 680.00, 690.00, 700.00, 800.00,1200.0
-};
-const G4double PMTQuartzRefIndexValues[]=
-{1.57464,1.57464, 1.56071, 1.54729, 1.54269, 1.53385, 1.52318,
-		1.51834, 1.50762, 1.50590, 1.50397, 1.49634, 1.48859,
-		1.48183, 1.47877, 1.47766, 1.47520, 1.47028, 1.46679,
-		1.46324, 1.46021, 1.45857, 1.45853, 1.45851, 1.45646,
-		1.456066, 1.455818, 1.455579, 1.455347, 1.453371,1.453371
-};
-
-//const G4double CrystalMatRefWaveLenValues[]=
+static const G4int PMTQuartzRefIndNumBins = 31;
+// static const G4int CrystalMatRefIndNumBins=51;
+static const G4int CrystalMatRefIndNumBins = 52;
+
+const G4double PMTQuartzRefWaveLenUnits = 1.0 * CLHEP::nanometer;
+const G4double CrystalMatRefWaveLenUnits = 1.0 * CLHEP::nanometer;
+
+const G4double PMTQuartzRefWaveLenValues[] = {150.0,  185.41, 193.53, 202.54, 206.20, 214.45, 226.50, 232.94,
+                                              250.20, 253.70, 257.62, 274.87, 298.06, 328.36, 340.36, 346.69,
+                                              361.17, 398.84, 435.83, 486.13, 546.07, 587.56, 589.00, 589.60,
+                                              656.27, 670.00, 680.00, 690.00, 700.00, 800.00, 1200.0};
+const G4double PMTQuartzRefIndexValues[] = {1.57464, 1.57464,  1.56071,  1.54729,  1.54269,  1.53385,  1.52318, 1.51834,
+                                            1.50762, 1.50590,  1.50397,  1.49634,  1.48859,  1.48183,  1.47877, 1.47766,
+                                            1.47520, 1.47028,  1.46679,  1.46324,  1.46021,  1.45857,  1.45853, 1.45851,
+                                            1.45646, 1.456066, 1.455818, 1.455579, 1.455347, 1.453371, 1.453371};
+
+// const G4double CrystalMatRefWaveLenValues[]=
 //  {300,344,388,432,476,520,564,608,652,696,
 //   740,784,828,872,916,960,1004,1048,1092,1136,
 //   1180,1224,1268,1312,1356,1400,1444,1488,1532,1576,
@@ -376,7 +304,7 @@ const G4double PMTQuartzRefIndexValues[]=
 //   2060,2104,2148,2192,2236,2280,2324,2368,2412,2456,
 //   2500
 //  };
-//const G4double CrystalMatRefIndexValues[]=
+// const G4double CrystalMatRefIndexValues[]=
 //  {1.5527702635739,1.5404466868331,1.5325277321700,1.5270784291406,1.5231331738499,
 //   1.5201596882463,1.5178426478869,1.5159846691816,1.5144566604975,1.5131711117948,
 //   1.5120668948646,1.5111002059336,1.5102389559626,1.5094591800239,1.5087426727363,
@@ -391,44 +319,34 @@ const G4double PMTQuartzRefIndexValues[]=
 //
 //  };
 
-const G4double CrystalMatRefWaveLenValues[]=
-{200,300,344,388,432,476,520,564,608,652,696,
-		740,784,828,872,916,960,1004,1048,1092,1136,
-		1180,1224,1268,1312,1356,1400,1444,1488,1532,1576,
-		1620,1664,1708,1752,1796,1840,1884,1928,1972,2016,
-		2060,2104,2148,2192,2236,2280,2324,2368,2412,2456,
-		2500
-};
-const G4double CrystalMatRefIndexValues[]= { 1.5727702635739,
-		1.5527702635739,1.5404466868331,1.5325277321700,1.5270784291406,1.5231331738499,
-		1.5201596882463,1.5178426478869,1.5159846691816,1.5144566604975,1.5131711117948,
-		1.5120668948646,1.5111002059336,1.5102389559626,1.5094591800239,1.5087426727363,
-		1.5080753919142,1.5074463569456,1.5068468735887,1.5062699788386,1.5057100370628,
-		1.5051624419507,1.5046233936610,1.5040897301904,1.5035587983604,1.5030283541053,
-		1.5024964846769,1.5019615474168,1.5014221211688,1.5008769674285,1.5003249990526,
-		1.4997652548858,1.4991968790539,1.4986191039608,1.4980312362468,1.4974326451267,
-		1.4968227526526,1.4962010255422,1.4955669682860,1.4949201173049,1.4942600359742,
-		1.4935863103651,1.4928985455839,1.4921963626087,1.4914793955446,1.4907472892292,
-		1.4899996971337,1.4892362795147,1.4884567017771,1.4876606330169,1.4868477447166,
-		1.4860177095710
+const G4double CrystalMatRefWaveLenValues[] = {
+    200,  300,  344,  388,  432,  476,  520,  564,  608,  652,  696,  740,  784,  828,  872,  916,  960,  1004,
+    1048, 1092, 1136, 1180, 1224, 1268, 1312, 1356, 1400, 1444, 1488, 1532, 1576, 1620, 1664, 1708, 1752, 1796,
+    1840, 1884, 1928, 1972, 2016, 2060, 2104, 2148, 2192, 2236, 2280, 2324, 2368, 2412, 2456, 2500};
+const G4double CrystalMatRefIndexValues[] = {
+    1.5727702635739, 1.5527702635739, 1.5404466868331, 1.5325277321700, 1.5270784291406, 1.5231331738499,
+    1.5201596882463, 1.5178426478869, 1.5159846691816, 1.5144566604975, 1.5131711117948, 1.5120668948646,
+    1.5111002059336, 1.5102389559626, 1.5094591800239, 1.5087426727363, 1.5080753919142, 1.5074463569456,
+    1.5068468735887, 1.5062699788386, 1.5057100370628, 1.5051624419507, 1.5046233936610, 1.5040897301904,
+    1.5035587983604, 1.5030283541053, 1.5024964846769, 1.5019615474168, 1.5014221211688, 1.5008769674285,
+    1.5003249990526, 1.4997652548858, 1.4991968790539, 1.4986191039608, 1.4980312362468, 1.4974326451267,
+    1.4968227526526, 1.4962010255422, 1.4955669682860, 1.4949201173049, 1.4942600359742, 1.4935863103651,
+    1.4928985455839, 1.4921963626087, 1.4914793955446, 1.4907472892292, 1.4899996971337, 1.4892362795147,
+    1.4884567017771, 1.4876606330169, 1.4868477447166, 1.4860177095710
 
 };
 
-//const G4double CrystalMatRefIndexValues[]=
+// const G4double CrystalMatRefIndexValues[]=
 //{
 //};
 
+const G4double CrystalMatAbsorptionValues[] = {
+    0.0,   0.0,   55.0,  282.5, 439.9, 555.3, 644.7, 706.3, 616.9, 558.9, 546.4, 505.9, 447.4,
+    1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32,
+    1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32,
+    1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32, 1.E32};
 
-
-const G4double CrystalMatAbsorptionValues[]=
-{0.0,0.0,55.0,282.5,439.9,555.3,644.7,706.3,616.9,558.9,546.4,
-		505.9,447.4,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,
-		1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,
-		1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,
-		1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,
-		1.E32};
-
-//const G4double CrystalMatAbsorptionValues[]=
+// const G4double CrystalMatAbsorptionValues[]=
 //{0,10,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,
 // 1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,
 // 1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,
@@ -436,99 +354,83 @@ const G4double CrystalMatAbsorptionValues[]=
 // 1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,1.E32,
 // 1.E32};
 
-
-
-
 // now for the ref index of the ph cathode derived from the following
 // value measured by Naoko. The ref index is derived using the fresnel formula
 // and the ref index of PMTquartz. The derivation is done in RichMaterial.cc.
 
-const G4double PMTQwPhReflectionProb=0.02;
-const G4double HPDQwPhReflectionProb=0.02;
+const G4double PMTQwPhReflectionProb = 0.02;
+const G4double HPDQwPhReflectionProb = 0.02;
 // now for the transmission of light through the photocathode.
 // The results of the measurement so far show the transmission in
 // photocathode*reflection at silicon= 0.065 above 550nm and 0.025 below
 // 550 nm. Until this is disentangled, the silicon is set to be 30% reflecting
 // and the transmission in photocathode to be responsible for the rest of the 0.065 and 0.025
 // values measured. In the following the 0.3 is for the Si surface reflectivity assumed so far.
-const G4double PMTSiDetSurfaceReflectivity=0.3;
+const G4double PMTSiDetSurfaceReflectivity = 0.3;
 
-const G4double PMTPhCathodeTransRed=(0.065/PMTSiDetSurfaceReflectivity) ;
-const G4double PMTPhCathodeTransBlue=(0.025/PMTSiDetSurfaceReflectivity);
-const G4double PMTPhCathodeRedBlueBoundary=550.0*CLHEP::nanometer;
+const G4double PMTPhCathodeTransRed = (0.065 / PMTSiDetSurfaceReflectivity);
+const G4double PMTPhCathodeTransBlue = (0.025 / PMTSiDetSurfaceReflectivity);
+const G4double PMTPhCathodeRedBlueBoundary = 550.0 * CLHEP::nanometer;
 
-const G4double HPDPhCathodeTransRed=(0.065/PMTSiDetSurfaceReflectivity) ;
-const G4double HPDPhCathodeTransBlue=(0.025/PMTSiDetSurfaceReflectivity);
-const G4double HPDPhCathodeRedBlueBoundary=550.0*CLHEP::nanometer;
+const G4double HPDPhCathodeTransRed = (0.065 / PMTSiDetSurfaceReflectivity);
+const G4double HPDPhCathodeTransBlue = (0.025 / PMTSiDetSurfaceReflectivity);
+const G4double HPDPhCathodeRedBlueBoundary = 550.0 * CLHEP::nanometer;
 
 const G4double backscaprob = 0.18;
-const G4double bckKillFactor=0.5;
+const G4double bckKillFactor = 0.5;
 // The following parameter can be overridden using
 // the values in the options file. (SE November 2004).
 // hence the following parameter is a default value only.
-//const G4double PMTelectronicsDetAbsEff=0.9;
-const G4double PMTelectronicsDetAbsEff=0.87;
+// const G4double PMTelectronicsDetAbsEff=0.9;
+const G4double PMTelectronicsDetAbsEff = 0.87;
 
 const G4double HpdelectronicsDetAbsEff = 0.85;
 
 // now for the nominal refractive index of Gas Quartz Window
-const G4double GasQuartzWindowNominalRefIndex=1.40;
+const G4double GasQuartzWindowNominalRefIndex = 1.40;
 
 // now for the gas quartzWindow transmission measurements.
 
-const G4int numGasQuTransBins= 38;
-const G4double GasQuTransWlenValues [] =
-{190.0, 200.0, 210.0, 220.0, 230.0, 240.0, 250.0, 260.0, 270.0, 280.0, 290.0, 300.0, 310.0,
-		320.0, 340.0, 360.0, 380.0, 400.0, 420.0, 440.0, 460.0, 480.0, 500.0, 520.0, 540.0, 560.0,
-		580.0, 600.0, 620.0, 640.0, 660.0, 680.0, 700.0, 720.0, 740.0, 760.0, 780.0, 800.0};
-
-const G4double GasQuTransmissionValues [] =
-{0.842326088, 0.846021534, 0.873896705, 0.899239713, 0.904766085, 0.892395354, 0.905442944,
-		0.916895386, 0.924896759, 0.926322055, 0.926729364, 0.92546999, 0.924850007, 0.931886665,
-		0.936234369, 0.939103324, 0.936502177, 0.936451404, 0.933651249, 0.936923238, 0.937613364,
-		0.93764767, 0.937041811, 0.941847013, 0.940911554, 0.942555595, 0.943165589, 0.943507436,
-		0.943549418, 0.94442271, 0.944210076, 0.944153405, 0.946732578, 0.947069746, 0.945611816,
-		0.943229139, 0.947273101, 0.949254646};
-
+const G4int numGasQuTransBins = 38;
+const G4double GasQuTransWlenValues[] = {190.0, 200.0, 210.0, 220.0, 230.0, 240.0, 250.0, 260.0, 270.0, 280.0,
+                                         290.0, 300.0, 310.0, 320.0, 340.0, 360.0, 380.0, 400.0, 420.0, 440.0,
+                                         460.0, 480.0, 500.0, 520.0, 540.0, 560.0, 580.0, 600.0, 620.0, 640.0,
+                                         660.0, 680.0, 700.0, 720.0, 740.0, 760.0, 780.0, 800.0};
 
+const G4double GasQuTransmissionValues[] = {
+    0.842326088, 0.846021534, 0.873896705, 0.899239713, 0.904766085, 0.892395354, 0.905442944, 0.916895386,
+    0.924896759, 0.926322055, 0.926729364, 0.92546999,  0.924850007, 0.931886665, 0.936234369, 0.939103324,
+    0.936502177, 0.936451404, 0.933651249, 0.936923238, 0.937613364, 0.93764767,  0.937041811, 0.941847013,
+    0.940911554, 0.942555595, 0.943165589, 0.943507436, 0.943549418, 0.94442271,  0.944210076, 0.944153405,
+    0.946732578, 0.947069746, 0.945611816, 0.943229139, 0.947273101, 0.949254646};
 
 // now for HPD
 
 const G4double PixelHpdPSFSigma = 50.0 * CLHEP::micrometer; // default
-static const G4int NumDemagnificationParam=2;
-//const G4double PixelHpdDemagLinearFactor = -0.1772; // make rings match
-const G4double PixelHpdDemagLinearFactor = -0.23; // make rings match
-const G4double PixelHpdDemagQuadraticFactor=0.0*(1.0/CLHEP::mm); // make rings match
-static const G4int HpdQENumBins= 20;
-const G4double HpdQEReductionFactor=1.0;
-const G4double HpdQEWaveLenUnits= 1.0*CLHEP::nanometer;
-const G4double HpdQEWaveLen[]=
-{200.0, 240.0, 270.0, 300.0, 320.0, 360.0, 400.0, 440.0, 480.0, 520.0,
-		560.0, 600.0, 640.0, 700.0, 750.0, 800.0, 830.0, 850.0, 880.0, 900.0};
-const G4double Hpd0QEPerCent[]=
-{19.0, 28.02, 31.3, 27.3, 24.7, 24.2, 24.0, 20.8, 17.5, 13.4,
-		10.0, 7.3, 4.6,  1.3,  0.1,  0.0,  0.0,  0.0,  0.0, 0.0  };
-
-static const G4int HPDQuartzRefIndNumBins=31;
-const G4double HPDQuartzRefWaveLenUnits= 1.0*CLHEP::nanometer;
-
-const G4double HPDQuartzRefWaveLenValues[]=
-{150.0, 185.41, 193.53, 202.54, 206.20, 214.45, 226.50, 232.94,
-		250.20, 253.70, 257.62, 274.87, 298.06, 328.36, 340.36,346.69,
-		361.17, 398.84, 435.83, 486.13, 546.07, 587.56, 589.00, 589.60,
-		656.27, 670.00, 680.00, 690.00, 700.00, 800.00,1200.0
-};
-const G4double HPDQuartzRefIndexValues[]=
-{1.57464,1.57464, 1.56071, 1.54729, 1.54269, 1.53385, 1.52318,
-		1.51834, 1.50762, 1.50590, 1.50397, 1.49634, 1.48859,
-		1.48183, 1.47877, 1.47766, 1.47520, 1.47028, 1.46679,
-		1.46324, 1.46021, 1.45857, 1.45853, 1.45851, 1.45646,
-		1.456066, 1.455818, 1.455579, 1.455347, 1.453371,1.453371
-};
-
+static const G4int NumDemagnificationParam = 2;
+// const G4double PixelHpdDemagLinearFactor = -0.1772; // make rings match
+const G4double PixelHpdDemagLinearFactor = -0.23;                      // make rings match
+const G4double PixelHpdDemagQuadraticFactor = 0.0 * (1.0 / CLHEP::mm); // make rings match
+static const G4int HpdQENumBins = 20;
+const G4double HpdQEReductionFactor = 1.0;
+const G4double HpdQEWaveLenUnits = 1.0 * CLHEP::nanometer;
+const G4double HpdQEWaveLen[] = {200.0, 240.0, 270.0, 300.0, 320.0, 360.0, 400.0, 440.0, 480.0, 520.0,
+                                 560.0, 600.0, 640.0, 700.0, 750.0, 800.0, 830.0, 850.0, 880.0, 900.0};
+const G4double Hpd0QEPerCent[] = {19.0, 28.02, 31.3, 27.3, 24.7, 24.2, 24.0, 20.8, 17.5, 13.4,
+                                  10.0, 7.3,   4.6,  1.3,  0.1,  0.0,  0.0,  0.0,  0.0,  0.0};
+
+static const G4int HPDQuartzRefIndNumBins = 31;
+const G4double HPDQuartzRefWaveLenUnits = 1.0 * CLHEP::nanometer;
+
+const G4double HPDQuartzRefWaveLenValues[] = {150.0,  185.41, 193.53, 202.54, 206.20, 214.45, 226.50, 232.94,
+                                              250.20, 253.70, 257.62, 274.87, 298.06, 328.36, 340.36, 346.69,
+                                              361.17, 398.84, 435.83, 486.13, 546.07, 587.56, 589.00, 589.60,
+                                              656.27, 670.00, 680.00, 690.00, 700.00, 800.00, 1200.0};
+const G4double HPDQuartzRefIndexValues[] = {1.57464, 1.57464,  1.56071,  1.54729,  1.54269,  1.53385,  1.52318, 1.51834,
+                                            1.50762, 1.50590,  1.50397,  1.49634,  1.48859,  1.48183,  1.47877, 1.47766,
+                                            1.47520, 1.47028,  1.46679,  1.46324,  1.46021,  1.45857,  1.45853, 1.45851,
+                                            1.45646, 1.456066, 1.455818, 1.455579, 1.455347, 1.453371, 1.453371};
 
 #include "RichTbMiscNames.hh"
 
-
-
-#endif                          /*RichTbMaterialParameters_h */
+#endif /*RichTbMaterialParameters_h */
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMirrorGeometryParamters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMirrorGeometryParamters.hh
index b8189496a5dacf18ab8b165da792d55509871bda..3ceec221d6fd68bf8e8d79901e41132cb188ef8b 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMirrorGeometryParamters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMirrorGeometryParamters.hh
@@ -4,57 +4,52 @@
 
 // Include files
 
-//const G4double MirrorGap = 1.0* CLHEP::mm;
-const G4double MirrorGap = 0.0* CLHEP::mm;
+// const G4double MirrorGap = 1.0* CLHEP::mm;
+const G4double MirrorGap = 0.0 * CLHEP::mm;
 
-const G4double MirrorInnerRadius  = SphereRadius+MirrorGap;
+const G4double MirrorInnerRadius = SphereRadius + MirrorGap;
 
-const G4double MirrorThickness = 5.0*CLHEP::mm;
+const G4double MirrorThickness = 5.0 * CLHEP::mm;
 
-const G4double MirrorOuterRadius  = MirrorInnerRadius+ MirrorThickness;
+const G4double MirrorOuterRadius = MirrorInnerRadius + MirrorThickness;
 
-const G4double MirrorSubBoxLargeXSize=500*CLHEP::mm;
-const G4double MirrorSubBoxLargeYSize=500*CLHEP::mm;
-const G4double MirrorSubBoxLargeZSize=500*CLHEP::mm;
-const G4double MirrorSubBoxShiftY=  0.5*Box2YSize;
+const G4double MirrorSubBoxLargeXSize = 500 * CLHEP::mm;
+const G4double MirrorSubBoxLargeYSize = 500 * CLHEP::mm;
+const G4double MirrorSubBoxLargeZSize = 500 * CLHEP::mm;
+const G4double MirrorSubBoxShiftY = 0.5 * Box2YSize;
 
-const G4double MirrorSubBoxYPosTop = 0.5*MirrorSubBoxLargeYSize+ MirrorSubBoxShiftY;
-const G4double MirrorSubBoxYPosBot = -0.5*MirrorSubBoxLargeYSize - MirrorSubBoxShiftY;
+const G4double MirrorSubBoxYPosTop = 0.5 * MirrorSubBoxLargeYSize + MirrorSubBoxShiftY;
+const G4double MirrorSubBoxYPosBot = -0.5 * MirrorSubBoxLargeYSize - MirrorSubBoxShiftY;
 
+// const G4double MirrorMinExtent=40.0*CLHEP::mm;
+// const G4double MirrorMaxExtent=60.0*CLHEP::mm;
 
-//const G4double MirrorMinExtent=40.0*CLHEP::mm;
-//const G4double MirrorMaxExtent=60.0*CLHEP::mm;
+const G4double MirrorMinExtent = 39.5 * CLHEP::mm;
+const G4double MirrorMaxExtent = 58.2 * CLHEP::mm;
 
-const G4double MirrorMinExtent=39.5*CLHEP::mm;
-const G4double MirrorMaxExtent=58.2*CLHEP::mm;
+const G4double MirrorMinThetaExtent = MirrorMinExtent / MirrorInnerRadius;
+const G4double MirrorMaxThetaExtent = MirrorMaxExtent / MirrorInnerRadius;
 
-const G4double MirrorMinThetaExtent = MirrorMinExtent/MirrorInnerRadius;
-const G4double MirrorMaxThetaExtent = MirrorMaxExtent/MirrorInnerRadius;
+const G4double MirrorPosX = 0.0;
+const G4double MirrorPosZ = SphereRadius;
+const G4double MirrorPosY = 0.0;
 
-
-const G4double  MirrorPosX =0.0;
-const G4double  MirrorPosZ = SphereRadius;
-const G4double  MirrorPosY =0.0;
-
-//testbeam upgrade 2015
-const G4double MirrorGap15 = 0.0* CLHEP::mm;
+// testbeam upgrade 2015
+const G4double MirrorGap15 = 0.0 * CLHEP::mm;
 const G4double MirrorInnerRadius15 = SphereRadius15 + MirrorGap15;
-const G4double MirrorThickness15 = 5.0*CLHEP::mm;
-const G4double MirrorOuterRadius15  = MirrorInnerRadius15+ MirrorThickness15;
-
-const G4double MirrorMinExtent15=33.0*CLHEP::mm;
-const G4double MirrorMaxExtent15=55.0*CLHEP::mm;
-//const G4double MirrorMinThetaExtent15 = MirrorMinExtent/MirrorInnerRadius15;
-//const G4double MirrorMaxThetaExtent15 = MirrorMaxExtent/MirrorInnerRadius15;
-const G4double MirrorMinThetaExtent15 = MirrorMinExtent15/MirrorInnerRadius15;
-const G4double MirrorMaxThetaExtent15 = MirrorMaxExtent15/MirrorInnerRadius15;
-
-const G4double  MirrorPosX15 =0.0;
-const G4double  MirrorPosY15 =0.0;
-const G4double  MirrorPosZ15 = SphereRadius15;
-const G4double  MirrorVolPosZ15 = 0.0;
-
-
-
+const G4double MirrorThickness15 = 5.0 * CLHEP::mm;
+const G4double MirrorOuterRadius15 = MirrorInnerRadius15 + MirrorThickness15;
+
+const G4double MirrorMinExtent15 = 33.0 * CLHEP::mm;
+const G4double MirrorMaxExtent15 = 55.0 * CLHEP::mm;
+// const G4double MirrorMinThetaExtent15 = MirrorMinExtent/MirrorInnerRadius15;
+// const G4double MirrorMaxThetaExtent15 = MirrorMaxExtent/MirrorInnerRadius15;
+const G4double MirrorMinThetaExtent15 = MirrorMinExtent15 / MirrorInnerRadius15;
+const G4double MirrorMaxThetaExtent15 = MirrorMaxExtent15 / MirrorInnerRadius15;
+
+const G4double MirrorPosX15 = 0.0;
+const G4double MirrorPosY15 = 0.0;
+const G4double MirrorPosZ15 = SphereRadius15;
+const G4double MirrorVolPosZ15 = 0.0;
 
 #endif // INCLUDE_RICHTBMIRRORGEOMETRYPARAMTERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMiscNames.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMiscNames.hh
index 6f5a82dabb55cd001b7bd7655cef95fc7f404fa6..cf273c5e2c36ce367fb7f8b2a3d2206254bb0982 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMiscNames.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbMiscNames.hh
@@ -2,22 +2,21 @@
 #ifndef INCLUDE_RICHTBMISCNAMES_HH
 #define INCLUDE_RICHTBMISCNAMES_HH 1
 
-
-const G4String PMTAnodeMaterialName= "PMTAnode";
-
-const G4String PmtQuartzWMaterialName="PmtWindowQuartz";
-const G4String CrystalMaterialName="CrystalMat";
-const G4String PmtPhCathodeMaterialName="S20PhCathode";
-const G4String NitrogenGasMaterialName="NitrogenGas";
-const G4String c4f10GasMaterialName="c4f10Gas";
-const G4String PMTSMasterMaterialName="Galactic";
-const G4String HPDSMasterMaterialName="Galactic";
-const G4String  ROgeometryName= "RichTbROGeom";
-const G4String  ROgeometryNameHpd= "RichTbROGeomHpd";
+const G4String PMTAnodeMaterialName = "PMTAnode";
+
+const G4String PmtQuartzWMaterialName = "PmtWindowQuartz";
+const G4String CrystalMaterialName = "CrystalMat";
+const G4String PmtPhCathodeMaterialName = "S20PhCathode";
+const G4String NitrogenGasMaterialName = "NitrogenGas";
+const G4String c4f10GasMaterialName = "c4f10Gas";
+const G4String PMTSMasterMaterialName = "Galactic";
+const G4String HPDSMasterMaterialName = "Galactic";
+const G4String ROgeometryName = "RichTbROGeom";
+const G4String ROgeometryNameHpd = "RichTbROGeomHpd";
 const G4String PMTSDname = "RichTbPMTSD";
 const G4String HPDSDname = "RichTbHPDSD";
-const G4String RichTbHColname="RichTbHitsCollection";
-const G4String RichTbHColnameHpd="RichTbHpdHitsCollection";
+const G4String RichTbHColname = "RichTbHitsCollection";
+const G4String RichTbHColnameHpd = "RichTbHpdHitsCollection";
 const G4String VesselPhysName = "VesselPhys";
 const G4String LensPhysName = "LensPhys";
 const G4String MasterPhysName = "MasterPhys";
@@ -35,31 +34,26 @@ const G4String PhDetSupName = "PhDetSupPhys";
 
 const G4String PhDetSupPhysNameLeft = "PhDetSupFrameLeftPhys";
 const G4String PhDetSupPhysNameRight = "PhDetSupFrameRightPhys";
-const G4String PhDetSupPhysNameBottomLeft = "PhDetSupFrameBottomLeftPhys"; //2015 upgrade
-const G4String PhDetSupPhysNameBottomRight = "PhDetSupFrameBottomRightPhys"; //2015 upgrade
-
-const G4String PMTSMasterPhysName ="PMTSMasterPhys";
-const G4String PMTSiDetPhysName="PMTSiDetPhys";
-const G4String PMTQuartzPhysName="PMTQuartzPhys";
-const G4String PmtPhotElectProc="PMTPhotElectProc";
-const G4String HpdPhotElectProc="HPDPhotElectProc";
-const G4String PMTEnvelopeMaterialName="Kovar";
-const G4String GasQuWinPhysName ="GasQuWinPhys";
-const G4String RadiatorPhysName ="RadiatorPhys";
-const G4String PMTFrontRingBoxPhysName="PMTFrontRingPhys";
+const G4String PhDetSupPhysNameBottomLeft = "PhDetSupFrameBottomLeftPhys";   // 2015 upgrade
+const G4String PhDetSupPhysNameBottomRight = "PhDetSupFrameBottomRightPhys"; // 2015 upgrade
+
+const G4String PMTSMasterPhysName = "PMTSMasterPhys";
+const G4String PMTSiDetPhysName = "PMTSiDetPhys";
+const G4String PMTQuartzPhysName = "PMTQuartzPhys";
+const G4String PmtPhotElectProc = "PMTPhotElectProc";
+const G4String HpdPhotElectProc = "HPDPhotElectProc";
+const G4String PMTEnvelopeMaterialName = "Kovar";
+const G4String GasQuWinPhysName = "GasQuWinPhys";
+const G4String RadiatorPhysName = "RadiatorPhys";
+const G4String PMTFrontRingBoxPhysName = "PMTFrontRingPhys";
 const G4String PMTQwLogVolName = "PMTQuartzWLog";
-const G4String PMTPhCathLogVolName= "PMTPhCathodeLog";
-const G4String PMTNumberName[]=
-  {"_0","_1","_2","_3","_4","_5","_6","_7","_8","_9","_10","_11","_12","_13","_14","_15"};
-
-const G4String  HpdQuartzWMaterialName ="HpdQuartzPhys";
-const G4String  HpdPhCathodeMaterialName ="HpdPhcathodePhys";
-const G4String  HpdSiDetMaterialName = "HpdAnode";
-const G4String  HpdEnvelopeMaterialName= "Kovar";
-
-
-
-
-
+const G4String PMTPhCathLogVolName = "PMTPhCathodeLog";
+const G4String PMTNumberName[] = {"_0", "_1", "_2",  "_3",  "_4",  "_5",  "_6",  "_7",
+                                  "_8", "_9", "_10", "_11", "_12", "_13", "_14", "_15"};
+
+const G4String HpdQuartzWMaterialName = "HpdQuartzPhys";
+const G4String HpdPhCathodeMaterialName = "HpdPhcathodePhys";
+const G4String HpdSiDetMaterialName = "HpdAnode";
+const G4String HpdEnvelopeMaterialName = "Kovar";
 
 #endif // INCLUDE_RICHTBMISCNAMES_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPEInfo.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPEInfo.hh
index 9d000a7490ca811eef38f442ef8a77a05c11f0ae..342873a45e9f983b92f1a1ec34a5af32c6ce8293 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPEInfo.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPEInfo.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBPEINFO_HH 
+#ifndef INCLUDE_RICHTBPEINFO_HH
 #define INCLUDE_RICHTBPEINFO_HH 1
 
 // Include files
@@ -8,44 +8,36 @@
 #include "RichTbPhotonInfo.hh"
 
 /** @class RichTbPEInfo RichTbPEInfo.hh include/RichTbPEInfo.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2004-01-20
  */
 class RichTbPEInfo {
-public: 
+public:
   /// Standard constructor
-  RichTbPEInfo( ); 
-
-  virtual ~RichTbPEInfo( ); ///< Destructor
-
-  G4ThreeVector  PhOrigin(){return mPhOrigin;}
-  RichTbPhotonInfo* MotherPhotonInfo(){return mMotherPhotonInfo;}
-  G4ThreeVector  PeOriginInHpdSupFrame(){return mPeOriginInHpdSupFrame;}
-  
-
-  void setPhOrigin(G4ThreeVector aPhOrigin){mPhOrigin= aPhOrigin;}
-  
-  void setMotherPhotonInfo(RichTbPhotonInfo* aPhotonInfo ) 
-  {    mMotherPhotonInfo=aPhotonInfo;}
-
-  void setPeOriginInHpdSupFrame( G4ThreeVector aPOrInPhSup ) 
-  {mPeOriginInHpdSupFrame=aPOrInPhSup;}
-  
-  void setPhotEmisDir(G4ThreeVector aEmisDir) 
-  {    mPhotEmisDir=aEmisDir;}
-  G4ThreeVector getPhotEmisDir() {return  mPhotEmisDir;}
-    
-protected:
+  RichTbPEInfo();
 
-private:
+  virtual ~RichTbPEInfo(); ///< Destructor
+
+  G4ThreeVector PhOrigin() { return mPhOrigin; }
+  RichTbPhotonInfo *MotherPhotonInfo() { return mMotherPhotonInfo; }
+  G4ThreeVector PeOriginInHpdSupFrame() { return mPeOriginInHpdSupFrame; }
+
+  void setPhOrigin(G4ThreeVector aPhOrigin) { mPhOrigin = aPhOrigin; }
 
+  void setMotherPhotonInfo(RichTbPhotonInfo *aPhotonInfo) { mMotherPhotonInfo = aPhotonInfo; }
+
+  void setPeOriginInHpdSupFrame(G4ThreeVector aPOrInPhSup) { mPeOriginInHpdSupFrame = aPOrInPhSup; }
+
+  void setPhotEmisDir(G4ThreeVector aEmisDir) { mPhotEmisDir = aEmisDir; }
+  G4ThreeVector getPhotEmisDir() { return mPhotEmisDir; }
+
+protected:
+private:
   G4ThreeVector mPhOrigin;
-  RichTbPhotonInfo* mMotherPhotonInfo;  
+  RichTbPhotonInfo *mMotherPhotonInfo;
   G4ThreeVector mPeOriginInHpdSupFrame;
   G4ThreeVector mPhotEmisDir;
-  
-  
 };
 #endif // INCLUDE_RICHTBPEINFO_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPMT.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPMT.hh
index 316153815a0768db25d7eb45345bb58bebfed3ee..131eaa95011e3e2739eff97cfdda6e6823a6a16e 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPMT.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPMT.hh
@@ -16,35 +16,28 @@
  *  @author Sajan EASO
  *  @date   2003-11-19
  */
-class  RichTbMaster;
+class RichTbMaster;
 
 class RichTbPMT {
 public:
   /// Standard constructor
-  RichTbPMT(RichTbUpgradeEC* aECMaster  );
+  RichTbPMT(RichTbUpgradeEC *aECMaster);
 
-  virtual ~RichTbPMT( ); ///< Destructor
+  virtual ~RichTbPMT(); ///< Destructor
 
-  void setTrackingSwitch(bool aSw)
-  {m_TrackingSwitch = aSw;}
+  void setTrackingSwitch(bool aSw) { m_TrackingSwitch = aSw; }
   void buildPMTGeometry();
   void constructPMTComponentsLVol();
-  void constructPMTComponentsPVol(int CurPMTNum) ;
+  void constructPMTComponentsPVol(int CurPMTNum);
   void constructPMTMasterTree(int CurPMTNum);
 
   void constructPMTAnode();
 
+  std::vector<G4LogicalVolume *> getRichTbPMTMasterLVol() { return RichTbPMTMasterLVol; }
 
-  std::vector<G4LogicalVolume*> getRichTbPMTMasterLVol()
-  {    return RichTbPMTMasterLVol;}
-
-  std::vector<G4LogicalVolume*> getRichTbPMTSMasterLVol()
-  {    return  RichTbPMTSMasterLVol;}
-
-
-  G4LogicalVolume* getRichTbPMTEnvelopeLVol()
-  {    return RichTbPMTEnvelopeLVol;}
+  std::vector<G4LogicalVolume *> getRichTbPMTSMasterLVol() { return RichTbPMTSMasterLVol; }
 
+  G4LogicalVolume *getRichTbPMTEnvelopeLVol() { return RichTbPMTEnvelopeLVol; }
 
   /*
   G4LogicalVolume* getRichTbPMTEnvelopeEndCapLVol()
@@ -52,96 +45,53 @@ public:
     return RichTbPMTEnvelopeEndCapLVol;
   }
   */
-  G4LogicalVolume* getRichTbPMTQuartzWLVol()
-  {
-    return RichTbPMTQuartzWLVol;
-  }
-  G4LogicalVolume* getRichTbPMTPhCathodeLVol()
-  {
-    return RichTbPMTPhCathodeLVol;
-  }
-
-  std::vector<G4LogicalVolume*> getRichTbPMTAnodeLVol()
-  {
-    return RichTbPMTAnodeLVol;
-  }
-
-
-
-  std::vector<G4VPhysicalVolume*> getRichTbPMTQuartzWPVol()
-  {
-    return RichTbPMTQuartzWPVol;
-  }
-  std::vector<G4VPhysicalVolume*> getRichTbPMTPhCathodePVol()
-  {
-    return RichTbPMTPhCathodePVol;
-  }
+  G4LogicalVolume *getRichTbPMTQuartzWLVol() { return RichTbPMTQuartzWLVol; }
+  G4LogicalVolume *getRichTbPMTPhCathodeLVol() { return RichTbPMTPhCathodeLVol; }
 
-  std::vector<G4VPhysicalVolume*> getRichTbPMTAnodePVol()
-  {
-    return RichTbPMTAnodePVol;
-  }
-   G4LogicalVolume* getRichTbPMTFrontRingLVol()
-  {  return   RichTbPMTFrontRingLVol; }
-
-  std::vector<G4VPhysicalVolume*> getRichTbPMTFrontRingPVol ()
-  {
-    return   RichTbPMTFrontRingPVol;
-
-  }
-
-  std::string getPMTQwLogVolName()
-  {
-    return m_PMTQwLogVolName;
-  }
-  std::string getPMTPhCathLogVolName()
-  {
-    return m_PMTPhCathLogVolName;
-  }
-  std::string getPMTAnodeLogVolName()
-  {
-    return m_PMTAnodeLogVolName;
-  }
-
-  G4int getCurNumPmts()
-  {  return CurNumPmts;}
+  std::vector<G4LogicalVolume *> getRichTbPMTAnodeLVol() { return RichTbPMTAnodeLVol; }
 
+  std::vector<G4VPhysicalVolume *> getRichTbPMTQuartzWPVol() { return RichTbPMTQuartzWPVol; }
+  std::vector<G4VPhysicalVolume *> getRichTbPMTPhCathodePVol() { return RichTbPMTPhCathodePVol; }
 
+  std::vector<G4VPhysicalVolume *> getRichTbPMTAnodePVol() { return RichTbPMTAnodePVol; }
+  G4LogicalVolume *getRichTbPMTFrontRingLVol() { return RichTbPMTFrontRingLVol; }
 
+  std::vector<G4VPhysicalVolume *> getRichTbPMTFrontRingPVol() { return RichTbPMTFrontRingPVol; }
 
+  std::string getPMTQwLogVolName() { return m_PMTQwLogVolName; }
+  std::string getPMTPhCathLogVolName() { return m_PMTPhCathLogVolName; }
+  std::string getPMTAnodeLogVolName() { return m_PMTAnodeLogVolName; }
 
+  G4int getCurNumPmts() { return CurNumPmts; }
 
 protected:
-
 private:
-  RichTbUpgradeEC* PmtECFrame;
+  RichTbUpgradeEC *PmtECFrame;
   bool m_TrackingSwitch;
   G4int CurNumPmts;
 
-  G4LogicalVolume* RichTbPMTEnvelopeLVol;
-  G4LogicalVolume* RichTbPMTQuartzWLVol;
-  G4LogicalVolume*  RichTbPMTPhCathodeLVol;
-  G4LogicalVolume* RichTbPMTFrontRingLVol;
+  G4LogicalVolume *RichTbPMTEnvelopeLVol;
+  G4LogicalVolume *RichTbPMTQuartzWLVol;
+  G4LogicalVolume *RichTbPMTPhCathodeLVol;
+  G4LogicalVolume *RichTbPMTFrontRingLVol;
 
-  std::vector<G4VPhysicalVolume*> RichTbPMTEnvelopePVol;
-  std::vector<G4VPhysicalVolume*>  RichTbPMTQuartzWPVol;
-  std::vector<G4VPhysicalVolume*> RichTbPMTPhCathodePVol;
-  std::vector<G4VPhysicalVolume*>  RichTbPMTFrontRingPVol;
+  std::vector<G4VPhysicalVolume *> RichTbPMTEnvelopePVol;
+  std::vector<G4VPhysicalVolume *> RichTbPMTQuartzWPVol;
+  std::vector<G4VPhysicalVolume *> RichTbPMTPhCathodePVol;
+  std::vector<G4VPhysicalVolume *> RichTbPMTFrontRingPVol;
 
-  std::vector<G4LogicalVolume*>  RichTbPMTMasterLVol;
-  std::vector<G4LogicalVolume*> RichTbPMTSMasterLVol;
-  std::vector<G4LogicalVolume*> RichTbPMTAnodeLVol;
-  std::vector<G4VPhysicalVolume*>  RichTbPMTMasterPVol;
-  std::vector<G4VPhysicalVolume*>  RichTbPMTSMasterPVol;
-  std::vector<G4VPhysicalVolume*> RichTbPMTAnodePVol;
+  std::vector<G4LogicalVolume *> RichTbPMTMasterLVol;
+  std::vector<G4LogicalVolume *> RichTbPMTSMasterLVol;
+  std::vector<G4LogicalVolume *> RichTbPMTAnodeLVol;
+  std::vector<G4VPhysicalVolume *> RichTbPMTMasterPVol;
+  std::vector<G4VPhysicalVolume *> RichTbPMTSMasterPVol;
+  std::vector<G4VPhysicalVolume *> RichTbPMTAnodePVol;
 
   std::string m_PMTQwLogVolName;
   std::string m_PMTPhCathLogVolName;
   std::string m_PMTAnodeLogVolName;
 
-  G4LogicalVolume* RichTbAnodePxLVol;
-  std::vector<std::vector<G4VPhysicalVolume*> > RichTbAnodePxPVol;
-
-
+  G4LogicalVolume *RichTbAnodePxLVol;
+  std::vector<std::vector<G4VPhysicalVolume *>> RichTbAnodePxPVol;
 };
 #endif // INCLUDE_RICHTBHPD_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPMTGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPMTGeometryParameters.hh
index 9864579cf2a71ff845b7eda16793fa1fe948b6ba..60ec649cef7cc15471d318f2332349a1fa9b240f 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPMTGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPMTGeometryParameters.hh
@@ -2,207 +2,194 @@
 #ifndef INCLUDE_RICHTBHPDGEOMETRYPARAMETERS_HH
 #define INCLUDE_RICHTBHPDGEOMETRYPARAMETERS_HH 1
 
-
 //#include "RichTbRunConfig.hh"
 
 /*class RichTbPMTGeometryParameters {
 public:
-	void setNumPmts(G4int pmts) {
-		NumPmts = pmts;
-	}
-	void setNumPmtsUpgrade(G4int pmts) {
-		NumPmtsUpgrade15 = pmts;
-	}
-	G4int getNumPmts() {
-		return NumPmts;
-	}
-	G4int getNumPmtsUpgrade() {
-		return NumPmtsUpgrade15;
-	}
+        void setNumPmts(G4int pmts) {
+                NumPmts = pmts;
+        }
+        void setNumPmtsUpgrade(G4int pmts) {
+                NumPmtsUpgrade15 = pmts;
+        }
+        G4int getNumPmts() {
+                return NumPmts;
+        }
+        G4int getNumPmtsUpgrade() {
+                return NumPmtsUpgrade15;
+        }
 private:
-	G4int NumPmts= 8;
-	G4int NumPmtsUpgrade15 = 16;
+        G4int NumPmts= 8;
+        G4int NumPmtsUpgrade15 = 16;
 };*/
 
-//envelope size and position
-
+// envelope size and position
 
-//static G4int NumPmtsUpgrade15 = RichTbPMTGeometryParameters::getNumPmtsUpgrade();
+// static G4int NumPmtsUpgrade15 = RichTbPMTGeometryParameters::getNumPmtsUpgrade();
 static const G4int NumPmtsUpgrade15 = 16;
-//static G4int NumPmts = (RichTbRunConfig::getRunConfigInstance()->getRadiatorConfiguration()==3) ? NumPmtsUpgrade15 : 8;
+// static G4int NumPmts = (RichTbRunConfig::getRunConfigInstance()->getRadiatorConfiguration()==3) ? NumPmtsUpgrade15 :
+// 8;
 static const G4int NumPmts = NumPmtsUpgrade15;
 static const G4int NumPmtsOld = 8;
-//static G4int NumPmts = RichTbPMTGeometryParameters::getNumPmts();
+// static G4int NumPmts = RichTbPMTGeometryParameters::getNumPmts();
 static const G4int NumPmtsWithHpd = 4;
 
-
-static const G4int NumPmtsInAnEC=4;
+static const G4int NumPmtsInAnEC = 4;
 static const G4int MaxPmtNumInEC0 = 3;
 static const G4int MaxPmtNumInEC1 = 7;
 static const G4int MaxPmtNumInEC2 = 11;
 static const G4int MaxPmtNumInEC3 = 15;
 
-
-const G4double PMTMasterBoxXSize = 26.15* CLHEP::mm;
-const G4double PMTMasterBoxYSize = 26.15* CLHEP::mm;
-const G4double PMTMasterBoxZSize = 19.4*CLHEP::mm;
-const G4double PMTLateralTolerence=0.05*CLHEP::mm;
-const G4double PMTZTolerence=0.25*CLHEP::mm;
+const G4double PMTMasterBoxXSize = 26.15 * CLHEP::mm;
+const G4double PMTMasterBoxYSize = 26.15 * CLHEP::mm;
+const G4double PMTMasterBoxZSize = 19.4 * CLHEP::mm;
+const G4double PMTLateralTolerence = 0.05 * CLHEP::mm;
+const G4double PMTZTolerence = 0.25 * CLHEP::mm;
 
 const G4double PMTSMasterBoxXSize = PMTMasterBoxXSize;
 const G4double PMTSMasterBoxYSize = PMTMasterBoxYSize;
 const G4double PMTSMasterBoxZSize = PMTMasterBoxZSize;
-const G4double PMTSMasterBoxXPos=0.0*CLHEP::mm;
-const G4double PMTSMasterBoxYPos=0.0*CLHEP::mm;
-const G4double PMTSMasterBoxZPos=0.0*CLHEP::mm;
-
+const G4double PMTSMasterBoxXPos = 0.0 * CLHEP::mm;
+const G4double PMTSMasterBoxYPos = 0.0 * CLHEP::mm;
+const G4double PMTSMasterBoxZPos = 0.0 * CLHEP::mm;
 
 const G4double PMTEnvelopeBoxXSize = PMTMasterBoxXSize - PMTLateralTolerence;
 const G4double PMTEnvelopeBoxYSize = PMTMasterBoxYSize - PMTLateralTolerence;
-const G4double PMTEnvelopeBoxZSize = 14.0*CLHEP::mm;
-
+const G4double PMTEnvelopeBoxZSize = 14.0 * CLHEP::mm;
 
-const G4double PMTEndToQuartzOuterSurface=2.7*CLHEP::mm;
-const G4double PMTEnvelopeThickness  = 1.0* CLHEP::mm;
-const G4double PMTGapInComponents =0.2*CLHEP::mm;
-const G4double PMTQuartzToAnodeSurfaceDistance = 10.0*CLHEP::mm;
+const G4double PMTEndToQuartzOuterSurface = 2.7 * CLHEP::mm;
+const G4double PMTEnvelopeThickness = 1.0 * CLHEP::mm;
+const G4double PMTGapInComponents = 0.2 * CLHEP::mm;
+const G4double PMTQuartzToAnodeSurfaceDistance = 10.0 * CLHEP::mm;
 
 const G4double PMTEnvelopeSubPartXSize = PMTEnvelopeBoxXSize - 2.0 * PMTEnvelopeThickness;
 const G4double PMTEnvelopeSubPartYSize = PMTEnvelopeBoxYSize - 2.0 * PMTEnvelopeThickness;
-const G4double PMTEnvelopeSubPartZSize = 100.0*CLHEP::mm;
+const G4double PMTEnvelopeSubPartZSize = 100.0 * CLHEP::mm;
 
-const G4double PMTEnvelopeSubPartXLocation = 0.0*CLHEP::mm;
-const G4double PMTEnvelopeSubPartYLocation = 0.0*CLHEP::mm;
-const G4double PMTEnvelopeSubPartZLocation = 0.5 * (PMTEnvelopeBoxXSize - PMTEnvelopeSubPartZSize) - PMTEnvelopeThickness;
+const G4double PMTEnvelopeSubPartXLocation = 0.0 * CLHEP::mm;
+const G4double PMTEnvelopeSubPartYLocation = 0.0 * CLHEP::mm;
+const G4double PMTEnvelopeSubPartZLocation =
+    0.5 * (PMTEnvelopeBoxXSize - PMTEnvelopeSubPartZSize) - PMTEnvelopeThickness;
 
 const G4double RichTbPMTEnvBoxXLocation = 0;
 const G4double RichTbPMTEnvBoxYLocation = 0;
-//const G4double RichTbPMTEnvBoxZLocation = 10.2*CLHEP::mm - 0.5 * PMTEnvelopeBoxZSize - 1.0*CLHEP::mm;
+// const G4double RichTbPMTEnvBoxZLocation = 10.2*CLHEP::mm - 0.5 * PMTEnvelopeBoxZSize - 1.0*CLHEP::mm;
 
-//quartz window size and position
+// quartz window size and position
 
-const G4double PMTQuartzWindowSupXSize = 25.8*CLHEP::mm;
-const G4double PMTQuartzWindowSupYSize = 25.8*CLHEP::mm;
-//const G4double PMTQuartzWindowSupZSize = 6.0*CLHEP::mm;
-const G4double PMTQuartzWindowSupZSize = 0.8*CLHEP::mm;
+const G4double PMTQuartzWindowSupXSize = 25.8 * CLHEP::mm;
+const G4double PMTQuartzWindowSupYSize = 25.8 * CLHEP::mm;
+// const G4double PMTQuartzWindowSupZSize = 6.0*CLHEP::mm;
+const G4double PMTQuartzWindowSupZSize = 0.8 * CLHEP::mm;
 
 const G4double RichTbPMTQuartzWindowXLocation = 0;
 const G4double RichTbPMTQuartzWindowYLocation = 0;
-//const G4double RichTbPMTQuartzWindowZLocation = -4.9*CLHEP::mm - 0.5 * PMTQuartzWindowSupZSize;
+// const G4double RichTbPMTQuartzWindowZLocation = -4.9*CLHEP::mm - 0.5 * PMTQuartzWindowSupZSize;
 
-const G4double RichTbPMTQuartzWindowZLocation = -0.5*PMTMasterBoxZSize +
-		PMTEndToQuartzOuterSurface + 0.5 * PMTQuartzWindowSupZSize;
+const G4double RichTbPMTQuartzWindowZLocation =
+    -0.5 * PMTMasterBoxZSize + PMTEndToQuartzOuterSurface + 0.5 * PMTQuartzWindowSupZSize;
 
+const G4double RichTbPMTEdgeToQuartzInsideEdgeDeltaZ = PMTEndToQuartzOuterSurface + PMTQuartzWindowSupZSize;
 
-const G4double RichTbPMTEdgeToQuartzInsideEdgeDeltaZ= PMTEndToQuartzOuterSurface + PMTQuartzWindowSupZSize;
+const G4double RichTbPMTEnvBoxZLocation =
+    RichTbPMTQuartzWindowZLocation + PMTGapInComponents + 0.5 * (PMTQuartzWindowSupZSize + PMTEnvelopeBoxZSize);
 
+// const G4double RichTbGasQuartzWindowThickness= 6.0*CLHEP::mm; // unused param
 
-const G4double RichTbPMTEnvBoxZLocation = RichTbPMTQuartzWindowZLocation + PMTGapInComponents +
-		0.5 * (PMTQuartzWindowSupZSize + PMTEnvelopeBoxZSize) ;
-
-
-//const G4double RichTbGasQuartzWindowThickness= 6.0*CLHEP::mm; // unused param
-
-//photocathode size and position
+// photocathode size and position
 
 const G4double PMTPhCathodeSupXSize = PMTQuartzWindowSupXSize;
 const G4double PMTPhCathodeSupYSize = PMTQuartzWindowSupYSize;
-const G4double PMTPhCathodeSupZSize = 0.1*CLHEP::mm;
+const G4double PMTPhCathodeSupZSize = 0.1 * CLHEP::mm;
 
 const G4double RichTbPMTPhCathodeXLocation = 0.0;
 const G4double RichTbPMTPhCathodeYLocation = 0.0;
-const G4double RichTbPMTPhCathodeThickness= 0.1*CLHEP::mm;
-//const G4double RichTbPMTPhCathodeZLocation = -4.8*CLHEP::mm - 0.05*CLHEP::mm;
-const G4double RichTbPMTPhCathodeZLocation = RichTbPMTQuartzWindowZLocation +
-		0.5 * (PMTQuartzWindowSupZSize + PMTPhCathodeSupZSize );
+const G4double RichTbPMTPhCathodeThickness = 0.1 * CLHEP::mm;
+// const G4double RichTbPMTPhCathodeZLocation = -4.8*CLHEP::mm - 0.05*CLHEP::mm;
+const G4double RichTbPMTPhCathodeZLocation =
+    RichTbPMTQuartzWindowZLocation + 0.5 * (PMTQuartzWindowSupZSize + PMTPhCathodeSupZSize);
 
+// anode size and position
 
-
-//anode size and position
-
-const G4double PMTAnodeSupXSize = 23.0*CLHEP::mm;
-const G4double PMTAnodeSupYSize = 23.0*CLHEP::mm;
-const G4double PMTAnodeSupZSize = 0.5*CLHEP::mm;
+const G4double PMTAnodeSupXSize = 23.0 * CLHEP::mm;
+const G4double PMTAnodeSupYSize = 23.0 * CLHEP::mm;
+const G4double PMTAnodeSupZSize = 0.5 * CLHEP::mm;
 
 const G4double RichTbPMTAnodeXLocation = 0.0;
 const G4double RichTbPMTAnodeYLocation = 0.0;
-//const G4double RichTbPMTAnodeZLocation = 6.2*CLHEP::mm;
-const G4double RichTbPMTAnodeZLocation = RichTbPMTQuartzWindowZLocation + PMTQuartzToAnodeSurfaceDistance+
-		0.5 * (PMTQuartzWindowSupZSize +PMTAnodeSupZSize );
+// const G4double RichTbPMTAnodeZLocation = 6.2*CLHEP::mm;
+const G4double RichTbPMTAnodeZLocation = RichTbPMTQuartzWindowZLocation + PMTQuartzToAnodeSurfaceDistance +
+                                         0.5 * (PMTQuartzWindowSupZSize + PMTAnodeSupZSize);
 
 // front ring
 
 const G4double RichTbPMTFrontRingLateralXSize = PMTMasterBoxXSize - PMTLateralTolerence;
 const G4double RichTbPMTFrontRingLateralYSize = PMTMasterBoxYSize - PMTLateralTolerence;
-const G4double RichTbPMTFrontRingZSize = 0.5*CLHEP::mm;
-
-const G4double RichTbPMTFrontRingXLocation =0.0*CLHEP::mm;
-const G4double RichTbPMTFrontRingYLocation =0.0*CLHEP::mm;
-const G4double RichTbPMTFrontRingZLocation = RichTbPMTQuartzWindowZLocation -
-		0.5* (PMTQuartzWindowSupZSize + RichTbPMTFrontRingZSize);
-
-
-const G4double RichTbPMTFrontRingSubHoleThickness = 1.4*CLHEP::mm;
-const G4double RichTbPMTFrontRingSubHoleZSize=100*CLHEP::mm;
-const G4double RichTbPMTFrontRingSubHoleXSize = RichTbPMTFrontRingLateralXSize -
-		2.0*RichTbPMTFrontRingSubHoleThickness;
-const G4double RichTbPMTFrontRingSubHoleYSize = RichTbPMTFrontRingLateralYSize -
-		2.0*RichTbPMTFrontRingSubHoleThickness;
-const G4double RichTbPMTFrontRingSubHoleXLocation= 0.0*CLHEP::mm;
-const G4double RichTbPMTFrontRingSubHoleYLocation= 0.0*CLHEP::mm;
-const G4double RichTbPMTFrontRingSubHoleZLocation= 0.0*CLHEP::mm;
+const G4double RichTbPMTFrontRingZSize = 0.5 * CLHEP::mm;
+
+const G4double RichTbPMTFrontRingXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbPMTFrontRingYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbPMTFrontRingZLocation =
+    RichTbPMTQuartzWindowZLocation - 0.5 * (PMTQuartzWindowSupZSize + RichTbPMTFrontRingZSize);
+
+const G4double RichTbPMTFrontRingSubHoleThickness = 1.4 * CLHEP::mm;
+const G4double RichTbPMTFrontRingSubHoleZSize = 100 * CLHEP::mm;
+const G4double RichTbPMTFrontRingSubHoleXSize =
+    RichTbPMTFrontRingLateralXSize - 2.0 * RichTbPMTFrontRingSubHoleThickness;
+const G4double RichTbPMTFrontRingSubHoleYSize =
+    RichTbPMTFrontRingLateralYSize - 2.0 * RichTbPMTFrontRingSubHoleThickness;
+const G4double RichTbPMTFrontRingSubHoleXLocation = 0.0 * CLHEP::mm;
+const G4double RichTbPMTFrontRingSubHoleYLocation = 0.0 * CLHEP::mm;
+const G4double RichTbPMTFrontRingSubHoleZLocation = 0.0 * CLHEP::mm;
 
 // now for PMT Locations
 
-const G4String PMTNamesBox[]=
-{"PMT0Box","PMT1Box","PMT2Box","PMT3Box","PMT4Box","PMT5Box","PMT6Box","PMT7Box",
-		"PMT8Box","PMT9Box","PMT10Box","PMT11Box","PMT12Box","PMT13Box","PMT14Box","PMT15Box"};
-const G4String PMTNamesLog[]=
-{"PMT0Log","PMT1Log","PMT2Log","PMT3Log","PMT4Log","PMT5Log","PMT6Log","PMT7Log",
-		"PMT8Log","PMT9Log","PMT10Log","PMT11Log","PMT12Log","PMT13Log","PMT14Log","PMT15Log"};
-const G4String PMTNamesPhys[]=
-{"PMT0Phys","PMT1Phys","PMT2Phys","PMT3Phys","PMT4Phys","PMT5Phys","PMT6Phys","PMT7Phys",
-		"PMT8Phys","PMT9Phys","PMT10Phys","PMT11Phys","PMT12Phys","PMT13Phys","PMT14Phys","PMT15Phys"};
-
-
-const G4String PMTSMNamesBox[]=
-{"PMTSM0Box","PMTSM1Box","PMTSM2Box","PMTSM3Box","PMTSM4Box","PMTSM5Box","PMTSM6Box","PMTSM7Box",
-		"PMTSM8Box","PMTSM9Box","PMTSM10Box","PMTSM11Box","PMTSM12Box","PMTSM13Box","PMTSM14Box","PMTSM15Box"};
-const G4String PMTSMNamesLog[]=
-{"PMTSM0Log","PMTSM1Log","PMTSM2Log","PMTSM3Log","PMTSM4Log","PMTSM5Log","PMTSM6Log","PMTSM7Log",
-		"PMTSM8Log","PMTSM9Log","PMTSM10Log","PMTSM11Log","PMTSM12Log","PMTSM13Log","PMTSM14Log","PMTSM15Log"};
-const G4String PMTSMNamesPhys[]=
-{"PMTSM0Phys","PMTSM1Phys","PMTSM2Phys","PMTSM3Phys","PMTSM4Phys","PMTSM5Phys","PMTSM6Phys","PMTSM7Phys",
-		"PMTSM8Phys","PMTSM9Phys","PMTSM10Phys","PMTSM11Phys","PMTSM12Phys","PMTSM13Phys","PMTSM14Phys","PMTSM15Phys"};
-
-const G4String PMTANNamesBox[]=
-{"PMTAN0Box","PMTAN1Box","PMTAN2Box","PMTAN3Box","PMTAN4Box","PMTAN5Box","PMTAN6Box","PMTAN7Box",
-		"PMTAN8Box","PMTAN9Box","PMTAN10Box","PMTAN11Box","PMTAN12Box","PMTAN13Box","PMTAN14Box","PMTAN15Box"};
-const G4String PMTANNamesLog[]=
-{"PMTAN0Log","PMTAN1Log","PMTAN2Log","PMTAN3Log","PMTAN4Log","PMTAN5Log","PMTAN6Log","PMTAN7Log",
-		"PMTAN8Log","PMTAN9Log","PMTAN10Log","PMTAN11Log","PMTAN12Log","PMTAN13Log","PMTAN14Log","PMTAN15Log"};
-const G4String PMTANNamesPhys[]=
-{"PMTAN0Phys","PMTAN1Phys","PMTAN2Phys","PMTAN3Phys","PMTAN4Phys","PMTAN5Phys","PMTAN6Phys","PMTAN7Phys",
-		"PMTAN8Phys","PMTAN9Phys","PMTAN10Phys","PMTAN11Phys","PMTAN12Phys","PMTAN13Phys","PMTAN14Phys","PMTAN15Phys"};
-
-
-const G4int NumPixelInPmtRow=8;
-const G4int NumPixelInPmtCol=8;
-const G4int NumPixelTotInPmt = NumPixelInPmtRow*NumPixelInPmtCol;
-
-
-const G4double PmtAnodePixelXSize=PMTAnodeSupXSize/NumPixelInPmtRow;
-const G4double PmtAnodePixelYSize=PMTAnodeSupYSize/NumPixelInPmtCol;
-
-const G4double  RichTbPMTAnodePixelZSize =PMTAnodeSupZSize;
-const G4double  RichTbPMTAnodePixelPosZ=0.0*CLHEP::mm;
-
+const G4String PMTNamesBox[] = {"PMT0Box",  "PMT1Box",  "PMT2Box",  "PMT3Box", "PMT4Box",  "PMT5Box",
+                                "PMT6Box",  "PMT7Box",  "PMT8Box",  "PMT9Box", "PMT10Box", "PMT11Box",
+                                "PMT12Box", "PMT13Box", "PMT14Box", "PMT15Box"};
+const G4String PMTNamesLog[] = {"PMT0Log",  "PMT1Log",  "PMT2Log",  "PMT3Log", "PMT4Log",  "PMT5Log",
+                                "PMT6Log",  "PMT7Log",  "PMT8Log",  "PMT9Log", "PMT10Log", "PMT11Log",
+                                "PMT12Log", "PMT13Log", "PMT14Log", "PMT15Log"};
+const G4String PMTNamesPhys[] = {"PMT0Phys",  "PMT1Phys",  "PMT2Phys",  "PMT3Phys", "PMT4Phys",  "PMT5Phys",
+                                 "PMT6Phys",  "PMT7Phys",  "PMT8Phys",  "PMT9Phys", "PMT10Phys", "PMT11Phys",
+                                 "PMT12Phys", "PMT13Phys", "PMT14Phys", "PMT15Phys"};
+
+const G4String PMTSMNamesBox[] = {"PMTSM0Box",  "PMTSM1Box",  "PMTSM2Box",  "PMTSM3Box", "PMTSM4Box",  "PMTSM5Box",
+                                  "PMTSM6Box",  "PMTSM7Box",  "PMTSM8Box",  "PMTSM9Box", "PMTSM10Box", "PMTSM11Box",
+                                  "PMTSM12Box", "PMTSM13Box", "PMTSM14Box", "PMTSM15Box"};
+const G4String PMTSMNamesLog[] = {"PMTSM0Log",  "PMTSM1Log",  "PMTSM2Log",  "PMTSM3Log", "PMTSM4Log",  "PMTSM5Log",
+                                  "PMTSM6Log",  "PMTSM7Log",  "PMTSM8Log",  "PMTSM9Log", "PMTSM10Log", "PMTSM11Log",
+                                  "PMTSM12Log", "PMTSM13Log", "PMTSM14Log", "PMTSM15Log"};
+const G4String PMTSMNamesPhys[] = {"PMTSM0Phys",  "PMTSM1Phys",  "PMTSM2Phys",  "PMTSM3Phys",
+                                   "PMTSM4Phys",  "PMTSM5Phys",  "PMTSM6Phys",  "PMTSM7Phys",
+                                   "PMTSM8Phys",  "PMTSM9Phys",  "PMTSM10Phys", "PMTSM11Phys",
+                                   "PMTSM12Phys", "PMTSM13Phys", "PMTSM14Phys", "PMTSM15Phys"};
+
+const G4String PMTANNamesBox[] = {"PMTAN0Box",  "PMTAN1Box",  "PMTAN2Box",  "PMTAN3Box", "PMTAN4Box",  "PMTAN5Box",
+                                  "PMTAN6Box",  "PMTAN7Box",  "PMTAN8Box",  "PMTAN9Box", "PMTAN10Box", "PMTAN11Box",
+                                  "PMTAN12Box", "PMTAN13Box", "PMTAN14Box", "PMTAN15Box"};
+const G4String PMTANNamesLog[] = {"PMTAN0Log",  "PMTAN1Log",  "PMTAN2Log",  "PMTAN3Log", "PMTAN4Log",  "PMTAN5Log",
+                                  "PMTAN6Log",  "PMTAN7Log",  "PMTAN8Log",  "PMTAN9Log", "PMTAN10Log", "PMTAN11Log",
+                                  "PMTAN12Log", "PMTAN13Log", "PMTAN14Log", "PMTAN15Log"};
+const G4String PMTANNamesPhys[] = {"PMTAN0Phys",  "PMTAN1Phys",  "PMTAN2Phys",  "PMTAN3Phys",
+                                   "PMTAN4Phys",  "PMTAN5Phys",  "PMTAN6Phys",  "PMTAN7Phys",
+                                   "PMTAN8Phys",  "PMTAN9Phys",  "PMTAN10Phys", "PMTAN11Phys",
+                                   "PMTAN12Phys", "PMTAN13Phys", "PMTAN14Phys", "PMTAN15Phys"};
+
+const G4int NumPixelInPmtRow = 8;
+const G4int NumPixelInPmtCol = 8;
+const G4int NumPixelTotInPmt = NumPixelInPmtRow * NumPixelInPmtCol;
+
+const G4double PmtAnodePixelXSize = PMTAnodeSupXSize / NumPixelInPmtRow;
+const G4double PmtAnodePixelYSize = PMTAnodeSupYSize / NumPixelInPmtCol;
+
+const G4double RichTbPMTAnodePixelZSize = PMTAnodeSupZSize;
+const G4double RichTbPMTAnodePixelPosZ = 0.0 * CLHEP::mm;
 
 // Now for the gap between adjacent pixels.
 // The gaps changed to 0.2 CLHEP::mm following some discussions.
-//const G4double RichTbPmtPixelGap = 0.1*CLHEP::mm;
-
-const G4double RichTbPmtPixelGap = 0.2*CLHEP::mm;
+// const G4double RichTbPmtPixelGap = 0.1*CLHEP::mm;
 
+const G4double RichTbPmtPixelGap = 0.2 * CLHEP::mm;
 
 #endif // INCLUDE_RICHTBHPDGEOMETRYPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPMTSupportFrameGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPMTSupportFrameGeometryParameters.hh
index 2af2409d33a66cf75462b336f5dc3a182361ce60..bff2d57bbee5e82480376f67877df2ff617f27d0 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPMTSupportFrameGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPMTSupportFrameGeometryParameters.hh
@@ -1,7 +1,6 @@
 #ifndef INCLUDE_RICHTBPMTSUPPORTFRAMEGEOMETRYPARAMETERS_HH
 #define INCLUDE_RICHTBPMTSUPPORTFRAMEGEOMETRYPARAMETERS_HH 1
-//size and location of PMTPhDetSupport frames
-
+// size and location of PMTPhDetSupport frames
 
 // Phot det sup frame in Test beam
 // Looking downstream from the origin of the beam towards +Z axis
@@ -77,150 +76,153 @@
 
  */
 
-
 //#include "RichTbRunConfig.hh" //in order to make geometry changes without recompiling
-//const G4double ECXShift = RichTbRunConfig::getRunConfigInstance()->getECXShift()*CLHEP::mm;
+// const G4double ECXShift = RichTbRunConfig::getRunConfigInstance()->getECXShift()*CLHEP::mm;
 const G4double ECXShift = -5.0; // absolute position is 70.6+ECXShift
 
 const G4int NumPhDetSupFrames = 2;
-const G4int NumElementaryCell =2;
+const G4int NumElementaryCell = 2;
 const G4int NumPhDetSupFrames15 = 4;
-const G4int NumElementaryCell15 =4;
+const G4int NumElementaryCell15 = 4;
 const G4int NumPmtsInEC = 4;
 
 const G4int RichTbTotNumPmt = NumElementaryCell * NumPmtsInEC;
 const G4int RichTbTotNumPmt15 = NumElementaryCell15 * NumPmtsInEC;
 
+const G4double PhDetSupFrameXSize = 56.0 * CLHEP::mm;
+const G4double PhDetSupFrameYSize = 60.0 * CLHEP::mm;
 
-const G4double PhDetSupFrameXSize = 56.0*CLHEP::mm;
-const G4double PhDetSupFrameYSize = 60.0*CLHEP::mm;
-
-const G4double PhDetSupFrameZSize = 70.0*CLHEP::mm;
-
-
-
+const G4double PhDetSupFrameZSize = 70.0 * CLHEP::mm;
 
+const G4double ECXSize = 55.4 * CLHEP::mm;
+const G4double ECYSize = 55.4 * CLHEP::mm;
+const G4double ECZSize = 55.4 * CLHEP::mm;
+const G4double ECFrontZSize = 23.55 * CLHEP::mm;
+const G4double ECFrontDistFromPhDetFrameSurface = 5.0 * CLHEP::mm;
 
-const G4double ECXSize = 55.4*CLHEP::mm;
-const G4double ECYSize = 55.4*CLHEP::mm;
-const G4double ECZSize = 55.4*CLHEP::mm;
-const G4double ECFrontZSize = 23.55*CLHEP::mm;
-const G4double ECFrontDistFromPhDetFrameSurface=5.0*CLHEP::mm;
+const G4double ECXLocation = 0.0 * CLHEP::mm;
+const G4double ECYLocation = 0.0 * CLHEP::mm;
+const G4double ECZLocation = (-0.5 * PhDetSupFrameZSize) + ECFrontDistFromPhDetFrameSurface + 0.5 * ECZSize;
 
-
-
-const G4double ECXLocation  = 0.0*CLHEP::mm;
-const G4double ECYLocation  = 0.0*CLHEP::mm;
-const G4double ECZLocation  = (-0.5*PhDetSupFrameZSize) + ECFrontDistFromPhDetFrameSurface + 0.5*ECZSize;
-
-
-const G4double RichTbPMTAdjacentGap= 1.8*CLHEP::mm;
-const G4double RichTbPMTPitch = 28.0*CLHEP::mm;
+const G4double RichTbPMTAdjacentGap = 1.8 * CLHEP::mm;
+const G4double RichTbPMTPitch = 28.0 * CLHEP::mm;
 
 // PMT Rotation values wrt positive Z.
-//The rotations are given to be consistent with Paolo scheme for anodes.
+// The rotations are given to be consistent with Paolo scheme for anodes.
 // The information is available only for the central PMTs  ( 0, 2 , 5, 7). So for now the other pmts are
 // rotations same as the central PMTS as shown in the list above.
 
-const G4double RichTbPmtRotZInEC[]  =  {CLHEP::pi* CLHEP::rad, CLHEP::pi*CLHEP::rad ,0.5*CLHEP::pi* CLHEP::rad, 0.5*CLHEP::pi* CLHEP::rad, -0.5*CLHEP::pi* CLHEP::rad, -0.5*CLHEP::pi* CLHEP::rad, 0.0*CLHEP::rad, 0.0*CLHEP::rad,
-										CLHEP::pi*CLHEP::rad, CLHEP::pi*CLHEP::rad ,0.5*CLHEP::pi* CLHEP::rad, 0.5*CLHEP::pi* CLHEP::rad, -0.5*CLHEP::pi* CLHEP::rad, -0.5*CLHEP::pi* CLHEP::rad, 0.0*CLHEP::rad, 0.0*CLHEP::rad};
-
-
-const G4double RichTbPmtPosXInEC[] = {-0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch, -0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch,
-									-0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch, -0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch,
-									-0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch, -0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch,
-									-0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch, -0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch};
-const G4double RichTbPmtPosYInEC[] = {-0.5*RichTbPMTPitch, -0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch,
-        							-0.5*RichTbPMTPitch, -0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch,
-									-0.5*RichTbPMTPitch, -0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch,
-									-0.5*RichTbPMTPitch, -0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch, 0.5*RichTbPMTPitch};
-
-const G4double PMTFrontDistFromECSurface = 2.0*CLHEP::mm;
-
-
-const G4double RichTbPmtPosZInEC = (-0.5*ECZSize) + PMTFrontDistFromECSurface + ( 0.5* PMTMasterBoxZSize) ;
-
-//const G4double PhotonDetPlaneGapWrtRadiatorSurface=30.0*CLHEP::mm;
-//testing this change on 04-03-2015 following email discussions.
-const G4double PhotonDetPlaneGapWrtRadiatorSurface=25.5*CLHEP::mm;
+const G4double RichTbPmtRotZInEC[] = {CLHEP::pi * CLHEP::rad,
+                                      CLHEP::pi *CLHEP::rad,
+                                      0.5 * CLHEP::pi *CLHEP::rad,
+                                      0.5 * CLHEP::pi *CLHEP::rad,
+                                      -0.5 * CLHEP::pi *CLHEP::rad,
+                                      -0.5 * CLHEP::pi *CLHEP::rad,
+                                      0.0 * CLHEP::rad,
+                                      0.0 * CLHEP::rad,
+                                      CLHEP::pi *CLHEP::rad,
+                                      CLHEP::pi *CLHEP::rad,
+                                      0.5 * CLHEP::pi *CLHEP::rad,
+                                      0.5 * CLHEP::pi *CLHEP::rad,
+                                      -0.5 * CLHEP::pi *CLHEP::rad,
+                                      -0.5 * CLHEP::pi *CLHEP::rad,
+                                      0.0 * CLHEP::rad,
+                                      0.0 * CLHEP::rad};
+
+const G4double RichTbPmtPosXInEC[] = {
+    -0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch, -0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch,
+    -0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch, -0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch,
+    -0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch, -0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch,
+    -0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch, -0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch};
+const G4double RichTbPmtPosYInEC[] = {
+    -0.5 * RichTbPMTPitch, -0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch,
+    -0.5 * RichTbPMTPitch, -0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch,
+    -0.5 * RichTbPMTPitch, -0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch,
+    -0.5 * RichTbPMTPitch, -0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch, 0.5 * RichTbPMTPitch};
+
+const G4double PMTFrontDistFromECSurface = 2.0 * CLHEP::mm;
+
+const G4double RichTbPmtPosZInEC = (-0.5 * ECZSize) + PMTFrontDistFromECSurface + (0.5 * PMTMasterBoxZSize);
+
+// const G4double PhotonDetPlaneGapWrtRadiatorSurface=30.0*CLHEP::mm;
+// testing this change on 04-03-2015 following email discussions.
+const G4double PhotonDetPlaneGapWrtRadiatorSurface = 25.5 * CLHEP::mm;
 
 // The following numbers are in the Crystal master reference frame.
 
-const G4double PhotonDetectorPlaneX=0.0;
-const G4double PhotonDetectorPlaneY=0.0;
-const G4double PhotonDetectorPlaneZ= RadiatorLensThickness + PhotonDetPlaneGapWrtRadiatorSurface;
-const G4double PhotonDetectorPlaneDirCosX=0.0;
-const G4double PhotonDetectorPlaneDirCosY=0.0;
-const G4double PhotonDetectorPlaneDirCosZ=1.0;
-
+const G4double PhotonDetectorPlaneX = 0.0;
+const G4double PhotonDetectorPlaneY = 0.0;
+const G4double PhotonDetectorPlaneZ = RadiatorLensThickness + PhotonDetPlaneGapWrtRadiatorSurface;
+const G4double PhotonDetectorPlaneDirCosX = 0.0;
+const G4double PhotonDetectorPlaneDirCosY = 0.0;
+const G4double PhotonDetectorPlaneDirCosZ = 1.0;
 
 const G4double PhotonDetPlaneToPMTMasterSurfaceZ = -1.0 * RichTbPMTEdgeToQuartzInsideEdgeDeltaZ;
 
-const G4double PhotonDetPlaneToPhDetSupFrameFrontSurface = PhotonDetPlaneToPMTMasterSurfaceZ
-                                                   -PMTFrontDistFromECSurface- ECFrontDistFromPhDetFrameSurface;
-
-const G4double PhDetSupFrameZLocation = PhotonDetectorPlaneZ + PhotonDetPlaneToPhDetSupFrameFrontSurface + 0.5*PhDetSupFrameZSize;
-const G4double PhDetSupFrameNominalXPos= 70.0*CLHEP::mm;
-//const G4double PhDetSupFrameFinalXPos = PhDetSupFrameNominalXPos-(0.5*RichTbPMTPitch)+1.5*CLHEP::mm;
-//const G4double PhDetSupFrameFinalXPos = PhDetSupFrameNominalXPos-(0.5*RichTbPMTPitch)+4.0*CLHEP::mm;
-//Sajan
-//const G4double PhDetSupFrameFinalXPos = PhDetSupFrameNominalXPos-(0.5*RichTbPMTPitch)+8.0*CLHEP::mm;
-//mio
-//const G4double PhDetSupFrameFinalXPos = 70.92;
-//modified May6-2015 for test
-//const G4double ECXShift = (RichTbRunConfig::getRunConfigInstance()->getRadiatorConfiguration()==3) ? ECXShift_ : 0.0;
-const G4double PhDetSupFrameFinalXPos = 70.6*CLHEP::mm;
-const G4double PhDetSupFrameFinalXPos15 = 70.6*CLHEP::mm + ECXShift;
-//const G4double PhDetSupFrameFinalYPos = 0*CLHEP::mm/*1.3*CLHEP::mm*/;
-const G4double PhDetSupFrameYGap = 0.3*CLHEP::mm;
+const G4double PhotonDetPlaneToPhDetSupFrameFrontSurface =
+    PhotonDetPlaneToPMTMasterSurfaceZ - PMTFrontDistFromECSurface - ECFrontDistFromPhDetFrameSurface;
+
+const G4double PhDetSupFrameZLocation =
+    PhotonDetectorPlaneZ + PhotonDetPlaneToPhDetSupFrameFrontSurface + 0.5 * PhDetSupFrameZSize;
+const G4double PhDetSupFrameNominalXPos = 70.0 * CLHEP::mm;
+// const G4double PhDetSupFrameFinalXPos = PhDetSupFrameNominalXPos-(0.5*RichTbPMTPitch)+1.5*CLHEP::mm;
+// const G4double PhDetSupFrameFinalXPos = PhDetSupFrameNominalXPos-(0.5*RichTbPMTPitch)+4.0*CLHEP::mm;
+// Sajan
+// const G4double PhDetSupFrameFinalXPos = PhDetSupFrameNominalXPos-(0.5*RichTbPMTPitch)+8.0*CLHEP::mm;
+// mio
+// const G4double PhDetSupFrameFinalXPos = 70.92;
+// modified May6-2015 for test
+// const G4double ECXShift = (RichTbRunConfig::getRunConfigInstance()->getRadiatorConfiguration()==3) ? ECXShift_ : 0.0;
+const G4double PhDetSupFrameFinalXPos = 70.6 * CLHEP::mm;
+const G4double PhDetSupFrameFinalXPos15 = 70.6 * CLHEP::mm + ECXShift;
+// const G4double PhDetSupFrameFinalYPos = 0*CLHEP::mm/*1.3*CLHEP::mm*/;
+const G4double PhDetSupFrameYGap = 0.3 * CLHEP::mm;
 const G4double PhDetSupFrameFinalYPos = 0.0;
-const G4double PhDetSupFrameFinalYPos15 = 0.5*ECYSize+PhDetSupFrameYGap;
-//Sajan
-//const G4double PhDetSupFrameXLocation[] =  {  PhDetSupFrameFinalXPos  , -1*PhDetSupFrameFinalXPos };
-//const G4double PhDetSupFrameXLocation[] =  {  70.6  , -70.92 };
+const G4double PhDetSupFrameFinalYPos15 = 0.5 * ECYSize + PhDetSupFrameYGap;
+// Sajan
+// const G4double PhDetSupFrameXLocation[] =  {  PhDetSupFrameFinalXPos  , -1*PhDetSupFrameFinalXPos };
+// const G4double PhDetSupFrameXLocation[] =  {  70.6  , -70.92 };
 // Modified May 6-2015 for test
-const G4double PhDetSupFrameXLocation[] = {PhDetSupFrameFinalXPos ,-1*PhDetSupFrameFinalXPos};
-const G4double PhDetSupFrameXLocation15[] = {PhDetSupFrameFinalXPos15 ,-1*PhDetSupFrameFinalXPos15};
+const G4double PhDetSupFrameXLocation[] = {PhDetSupFrameFinalXPos, -1 * PhDetSupFrameFinalXPos};
+const G4double PhDetSupFrameXLocation15[] = {PhDetSupFrameFinalXPos15, -1 * PhDetSupFrameFinalXPos15};
 
-//const G4double PhDetSupFrameYLocation[] =  {    0.0*CLHEP::mm,  0.0*CLHEP::mm};
+// const G4double PhDetSupFrameYLocation[] =  {    0.0*CLHEP::mm,  0.0*CLHEP::mm};
 // Moving EC up for test
-const G4double PhDetSupFrameYLocation[] =  {PhDetSupFrameFinalYPos, PhDetSupFrameFinalYPos};
-const G4double PhDetSupFrameYLocation15[] =  {PhDetSupFrameFinalYPos15, PhDetSupFrameFinalYPos15};
-
-//Upgrade 2015
-//const G4double PhDetSupFrameRadius = sqrt(pow(PhDetSupFrameFinalXPos,2) + pow(PhDetSupFrameFinalYPos,2));
-//const G4double PhDetSupFrameFinalBottomXPos = PhDetSupFrameRadius/3; //for equidistance of EC's in x
-//const G4double PhDetSupFrameFinalBottomYPos = sqrt(pow(PhDetSupFrameRadius,2)-pow(PhDetSupFrameFinalBottomXPos,2)); //for same radius
-//test move up and inwards
-//const G4double PhDetSupFrameBottomXLocation[] = {0.5*PhDetSupFrameFinalXPos-5*CLHEP::mm, -0.5*PhDetSupFrameFinalXPos+5*CLHEP::mm};
-//const G4double PhDetSupFrameBottomYLocation[] = {-1*PhDetSupFrameFinalXPos+5*CLHEP::mm, -1*PhDetSupFrameFinalXPos+5*CLHEP::mm};
-const G4double PhDetSupFrameBottomXLocation[] = {PhDetSupFrameFinalXPos15 ,-1*PhDetSupFrameFinalXPos15};
-const G4double PhDetSupFrameBottomYLocation[] = {-1*PhDetSupFrameFinalYPos15, -1*PhDetSupFrameFinalYPos15};
-
-const G4double ECSupportTolerence = 1.0*CLHEP::mm;
-
-const G4double ECSupportXSize = ECXSize-ECSupportTolerence;
-const G4double ECSupportYSize = ECYSize-ECSupportTolerence;
-const G4double ECSupportZSize = 3.0*CLHEP::mm;
+const G4double PhDetSupFrameYLocation[] = {PhDetSupFrameFinalYPos, PhDetSupFrameFinalYPos};
+const G4double PhDetSupFrameYLocation15[] = {PhDetSupFrameFinalYPos15, PhDetSupFrameFinalYPos15};
+
+// Upgrade 2015
+// const G4double PhDetSupFrameRadius = sqrt(pow(PhDetSupFrameFinalXPos,2) + pow(PhDetSupFrameFinalYPos,2));
+// const G4double PhDetSupFrameFinalBottomXPos = PhDetSupFrameRadius/3; //for equidistance of EC's in x
+// const G4double PhDetSupFrameFinalBottomYPos = sqrt(pow(PhDetSupFrameRadius,2)-pow(PhDetSupFrameFinalBottomXPos,2));
+// //for same radius  test move up and inwards  const G4double PhDetSupFrameBottomXLocation[] =
+// {0.5*PhDetSupFrameFinalXPos-5*CLHEP::mm, -0.5*PhDetSupFrameFinalXPos+5*CLHEP::mm};  const G4double
+// PhDetSupFrameBottomYLocation[] = {-1*PhDetSupFrameFinalXPos+5*CLHEP::mm, -1*PhDetSupFrameFinalXPos+5*CLHEP::mm};
+const G4double PhDetSupFrameBottomXLocation[] = {PhDetSupFrameFinalXPos15, -1 * PhDetSupFrameFinalXPos15};
+const G4double PhDetSupFrameBottomYLocation[] = {-1 * PhDetSupFrameFinalYPos15, -1 * PhDetSupFrameFinalYPos15};
+
+const G4double ECSupportTolerence = 1.0 * CLHEP::mm;
+
+const G4double ECSupportXSize = ECXSize - ECSupportTolerence;
+const G4double ECSupportYSize = ECYSize - ECSupportTolerence;
+const G4double ECSupportZSize = 3.0 * CLHEP::mm;
 const G4double ECSupportXLocation = ECXLocation;
 const G4double ECSupportYLocation = ECYLocation;
-const G4double ECSupportZLocation = ECZLocation+ 0.5*(ECZSize + ECSupportZSize)+2.0*CLHEP::mm;
-
+const G4double ECSupportZLocation = ECZLocation + 0.5 * (ECZSize + ECSupportZSize) + 2.0 * CLHEP::mm;
 
-//testbeam 2015 upgrade
-const G4double ECXLocation15  = 0.0*CLHEP::mm;
-const G4double ECYLocation15  = 0.0*CLHEP::mm;
-const G4double ECZLocation15  = (-0.5*PhDetSupFrameZSize) + ECFrontDistFromPhDetFrameSurface + 0.5*ECZSize;
+// testbeam 2015 upgrade
+const G4double ECXLocation15 = 0.0 * CLHEP::mm;
+const G4double ECYLocation15 = 0.0 * CLHEP::mm;
+const G4double ECZLocation15 = (-0.5 * PhDetSupFrameZSize) + ECFrontDistFromPhDetFrameSurface + 0.5 * ECZSize;
 const G4double ECSupportXLocation15 = ECXLocation15;
 const G4double ECSupportYLocation15 = ECYLocation15;
-const G4double ECSupportZLocation15 = ECZLocation15+ 0.5*(ECZSize + ECSupportZSize)+2.0*CLHEP::mm;
-
-const G4double PhotonDetPlaneGapWrtRadiatorSurface15=21.0*CLHEP::mm;
-const G4double PhotonDetectorPlaneX15=0.0;
-const G4double PhotonDetectorPlaneY15=0.0;
-const G4double PhotonDetectorPlaneZ15= RadiatorLensThickness15 + PhotonDetPlaneGapWrtRadiatorSurface15;
-const G4double PhDetSupFrameZLocation15 = PhotonDetectorPlaneZ15 + PhotonDetPlaneToPhDetSupFrameFrontSurface + 0.5*PhDetSupFrameZSize;
-
-
+const G4double ECSupportZLocation15 = ECZLocation15 + 0.5 * (ECZSize + ECSupportZSize) + 2.0 * CLHEP::mm;
+
+const G4double PhotonDetPlaneGapWrtRadiatorSurface15 = 21.0 * CLHEP::mm;
+const G4double PhotonDetectorPlaneX15 = 0.0;
+const G4double PhotonDetectorPlaneY15 = 0.0;
+const G4double PhotonDetectorPlaneZ15 = RadiatorLensThickness15 + PhotonDetPlaneGapWrtRadiatorSurface15;
+const G4double PhDetSupFrameZLocation15 =
+    PhotonDetectorPlaneZ15 + PhotonDetPlaneToPhDetSupFrameFrontSurface + 0.5 * PhDetSupFrameZSize;
 
 #endif // INCLUDE_RICHTBPMTSUPPORTFRAMEGEOMETRYPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPeUserInfoAttach.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPeUserInfoAttach.hh
index c04f3b88c5285da9dd257a2ad99d44fd51bc46ac..6a5678ed03c01054769f56bb3bd5abf68cd91782 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPeUserInfoAttach.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPeUserInfoAttach.hh
@@ -1,14 +1,13 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBPEUSERINFOATTACH_HH 
+#ifndef INCLUDE_RICHTBPEUSERINFOATTACH_HH
 #define INCLUDE_RICHTBPEUSERINFOATTACH_HH 1
 
 // Include files
 #include "Geant4/G4Track.hh"
 #include "Geant4/G4ThreeVector.hh"
 
-extern G4Track* RichTbPeInfoAttach( const G4Track& aPhotonTk, G4Track* aPETk,
-                                   G4ThreeVector aPeOriginInPhSup);
+extern G4Track *RichTbPeInfoAttach(const G4Track &aPhotonTk, G4Track *aPETk, G4ThreeVector aPeOriginInPhSup);
 
-extern  G4Track* RichTbPeBckAttach( const G4Track& aphotontk, G4Track* aSecPETrack ) ;
+extern G4Track *RichTbPeBckAttach(const G4Track &aphotontk, G4Track *aSecPETrack);
 
 #endif // INCLUDE_RICHTBPEUSERINFOATTACH_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhDFrameGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhDFrameGeometryParameters.hh
index 6e4c751d8c7f2d1ddd7ebe171557f0f026bdb269..6276be044e6864ef04ee0109b6e2eb4fded0bec7 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhDFrameGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhDFrameGeometryParameters.hh
@@ -1,30 +1,31 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBPHDFRAMEGEOMETRYPARAMETERS_HH 
+#ifndef INCLUDE_RICHTBPHDFRAMEGEOMETRYPARAMETERS_HH
 #define INCLUDE_RICHTBPHDFRAMEGEOMETRYPARAMETERS_HH 1
 
 // Include files
 
 /** @class RichTbVesselGeometryParameters RichTbVesselGeometryParameters.hh include/RichTbVesselGeometryParameters.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-10-21
  */
 
 // first for the overall vessel.
-const G4double RichTbPhDFrameXSize=600.0*CLHEP::mm;
-const G4double RichTbPhDFrameYSize=600.0*CLHEP::mm;
-const G4double RichTbPhDFrameZSize=30.0*CLHEP::mm;
-
-const G4double RichTbPhDFrameOriginShiftFromLeftEdgeX=0.0*CLHEP::mm;  // for now assume middle part. to be verified.
-const G4double RichTbPhDFrameOriginShiftFromFloorY=0.0*CLHEP::mm;
-const G4double RichTbPhDFrameOriginShiftFromLeftZ=  30*CLHEP::mm + 15*CLHEP::mm + 22.5*CLHEP::mm;
-
-const G4double RichTbPhDFrameXRotation=0.0*CLHEP::rad;  // for now in the following vessel Xrot is not used in Euler rotations since it is 0.
-//const G4double RichTbVesselYRotation=0.4817*CLHEP::rad;
-const G4double RichTbPhDFrameYRotation=0.0;
+const G4double RichTbPhDFrameXSize = 600.0 * CLHEP::mm;
+const G4double RichTbPhDFrameYSize = 600.0 * CLHEP::mm;
+const G4double RichTbPhDFrameZSize = 30.0 * CLHEP::mm;
+
+const G4double RichTbPhDFrameOriginShiftFromLeftEdgeX = 0.0 * CLHEP::mm; // for now assume middle part. to be verified.
+const G4double RichTbPhDFrameOriginShiftFromFloorY = 0.0 * CLHEP::mm;
+const G4double RichTbPhDFrameOriginShiftFromLeftZ = 30 * CLHEP::mm + 15 * CLHEP::mm + 22.5 * CLHEP::mm;
+
+const G4double RichTbPhDFrameXRotation =
+    0.0 * CLHEP::rad; // for now in the following vessel Xrot is not used in Euler rotations since it is 0.
+// const G4double RichTbVesselYRotation=0.4817*CLHEP::rad;
+const G4double RichTbPhDFrameYRotation = 0.0;
 const G4double RichTbPhDFrameYLocation = -RichTbPhDFrameOriginShiftFromFloorY;
-const G4double RichTbPhDFrameXShiftAlongCrystal =0.0;
+const G4double RichTbPhDFrameXShiftAlongCrystal = 0.0;
 const G4double RichTbPhDFrameZShiftAlongCrystal = +RichTbPhDFrameOriginShiftFromLeftZ;
 
 const G4double RichTbPhDFrameXLocation = RichTbPhDFrameXShiftAlongCrystal;
@@ -32,20 +33,20 @@ const G4double RichTbPhDFrameZLocation = RichTbPhDFrameZShiftAlongCrystal;
 
 // now for variables used after creating the geometry in stepaction.
 
-const G4double RichTbPhDFrameEnvPlateThickness=0.0*CLHEP::mm;
+const G4double RichTbPhDFrameEnvPlateThickness = 0.0 * CLHEP::mm;
 // the following are not exact values.
-//const G4double  RichTbCrystalXNegExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX-RichTbCrystalXSize;
-//const G4double  RichTbCrystalXPosExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX;
-//const G4double  RichTbCrystalZUpsExtremeAlongCrystal= -RichTbCrystalUpsExternalPartZSize;
-//const G4double  RichTbCrystalZDnsExtremeAlongCrystal= -RichTbcrystalUpsExternalPartZSize+RichTbCrystalZSize;
-//const G4double  RichTbCrystalXNegExtreme=  RichTbCrystalXNegExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
+// const G4double  RichTbCrystalXNegExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX-RichTbCrystalXSize;
+// const G4double  RichTbCrystalXPosExtremeAlongCrystal=RichTbCrystalOriginShiftFromLeftEdgeX;
+// const G4double  RichTbCrystalZUpsExtremeAlongCrystal= -RichTbCrystalUpsExternalPartZSize;
+// const G4double  RichTbCrystalZDnsExtremeAlongCrystal= -RichTbcrystalUpsExternalPartZSize+RichTbCrystalZSize;
+// const G4double  RichTbCrystalXNegExtreme=  RichTbCrystalXNegExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
 //                                          RichTbCrystalZDnsExtremeAlongCrystal*sin(RichTbCrystalYRotation);
-//const G4double  RichTbCrystalXPosExtreme=  RichTbCrystalXPosExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
+// const G4double  RichTbCrystalXPosExtreme=  RichTbCrystalXPosExtremeAlongCrystal*cos(RichTbCrystalYRotation)+
 //                                          RichTbCrystalZUpsExtremeAlongCrystal*sin(RichTbCrystalYRotation);
 
-//const G4double  RichTbCrystalYNegExtreme= RichTbCrystalYLocation-0.5*RichTbCrystalYSize;
-//const G4double  RichTbCrystalYPosExtreme= RichTbCrystalYLocation+0.5*RichTbCrystalYSize;
-//const G4double  RichTbCrystalZDnsExtreme = -RichTbCrystalXNegExtremeAlongCrystal*sin(RichTbCrystalYRotation)+
+// const G4double  RichTbCrystalYNegExtreme= RichTbCrystalYLocation-0.5*RichTbCrystalYSize;
+// const G4double  RichTbCrystalYPosExtreme= RichTbCrystalYLocation+0.5*RichTbCrystalYSize;
+// const G4double  RichTbCrystalZDnsExtreme = -RichTbCrystalXNegExtremeAlongCrystal*sin(RichTbCrystalYRotation)+
 //                                        RichTbCrystalZDnsExtremeAlongCrystal*cos(RichTbCrystalYRotation);
-//const G4double  RichTbCrystalDnsZEnd = RichTbCrystalZDnsExtreme;
+// const G4double  RichTbCrystalDnsZEnd = RichTbCrystalZDnsExtreme;
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotoElectron.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotoElectron.hh
index 7671592acad5a2b3bf8a7c84d34b796a5a334d26..7eeecde72e90e38a25c241e651543169aa354b2e 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotoElectron.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotoElectron.hh
@@ -24,7 +24,7 @@
 // $Id: RichTbPhotoElectron.h,v 1.1 2003/04/29 15:04:49 seaso Exp $
 // GEANT4 tag $Name:  $
 //
-// 
+//
 // ------------------------------------------------------------
 //      GEANT 4 class header file
 //
@@ -52,32 +52,18 @@ class G4Positron;
 // ###                         RICHPHOTOELECTRON                      ###
 // ######################################################################
 
-class RichTbPhotoElectron : public G4ParticleDefinition
-{
+class RichTbPhotoElectron : public G4ParticleDefinition {
   // friend class G4Positron;
- private:
-   static RichTbPhotoElectron* theRichTbPhotoElectronInstance;
-
- private: //hide constructor as private
+private:
+  static RichTbPhotoElectron *theRichTbPhotoElectronInstance;
 
- public:
-   virtual ~RichTbPhotoElectron(){}
-
-   static RichTbPhotoElectron* Definition();
-   static RichTbPhotoElectron* PhotoElectronDefinition();
-   static RichTbPhotoElectron* PhotoElectron();
+private: // hide constructor as private
+public:
+  virtual ~RichTbPhotoElectron() {}
 
+  static RichTbPhotoElectron *Definition();
+  static RichTbPhotoElectron *PhotoElectronDefinition();
+  static RichTbPhotoElectron *PhotoElectron();
 };
 
 #endif
-
-
-
-
-
-
-
-
-
-
-
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotonInfo.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotonInfo.hh
index 914ce41776374ca8a2ec153d5a7dcd18265e8f6b..1c3f5995c7d88076bd9adc4dabf8f5f90fc48b5a 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotonInfo.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotonInfo.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBPHOTONINFO_HH 
+#ifndef INCLUDE_RICHTBPHOTONINFO_HH
 #define INCLUDE_RICHTBPHOTONINFO_HH 1
 
 // Include files
@@ -7,87 +7,54 @@
 #include "Geant4/G4ThreeVector.hh"
 
 /** @class RichTbPhotonInfo RichTbPhotonInfo.hh include/RichTbPhotonInfo.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2004-01-20
  */
 class RichTbPhotonInfo {
-public: 
+public:
   /// Standard constructor
-  RichTbPhotonInfo( ); 
+  RichTbPhotonInfo();
 
-  virtual ~RichTbPhotonInfo( ); ///< Destructor
-  G4int NumRayleighScat(){return mNumRayleighScat;}
-  G4ThreeVector PhotonCoordPMTQWExternal() 
-  {    return mPhotonCoordPMTQWExternal;}
-  G4double CkvCosThetaAtProd() 
-  {    return mCkvCosThetaAtProd;}
-  G4double CkvPhiAtProd() 
-  {    return mCkvPhiAtProd;}
-  G4double CkvPhotonEnergyAtProd() 
-  {    return mCkvPhotonEnergyAtProd;}
+  virtual ~RichTbPhotonInfo(); ///< Destructor
+  G4int NumRayleighScat() { return mNumRayleighScat; }
+  G4ThreeVector PhotonCoordPMTQWExternal() { return mPhotonCoordPMTQWExternal; }
+  G4double CkvCosThetaAtProd() { return mCkvCosThetaAtProd; }
+  G4double CkvPhiAtProd() { return mCkvPhiAtProd; }
+  G4double CkvPhotonEnergyAtProd() { return mCkvPhotonEnergyAtProd; }
 
-  G4int   PhotonPMTQWMultipleIncidenceFlag() 
-  {    return mPhotonPMTQWMultipleIncidenceFlag;}
+  G4int PhotonPMTQWMultipleIncidenceFlag() { return mPhotonPMTQWMultipleIncidenceFlag; }
 
-  
-  G4double ParentChTrackMomentum() 
-  {  return mParentChTrackMomentum;}
-  G4ThreeVector ParentChTrackThreeMom() 
-  {  return  mParentChTrackThreeMom;}
-  G4ThreeVector PhotonCrystalDnsTIRCoord() 
-  {  return mPhotonCrystalDnsTIRCoord;}
-  G4ThreeVector PhotonSphMirrReflCoord() 
-  {  return mPhotonSphMirrReflCoord;}
-  G4ThreeVector PhotonCrystalDnsExitCoord()
-  {  return mPhotonCrystalDnsExitCoord;}
+  G4double ParentChTrackMomentum() { return mParentChTrackMomentum; }
+  G4ThreeVector ParentChTrackThreeMom() { return mParentChTrackThreeMom; }
+  G4ThreeVector PhotonCrystalDnsTIRCoord() { return mPhotonCrystalDnsTIRCoord; }
+  G4ThreeVector PhotonSphMirrReflCoord() { return mPhotonSphMirrReflCoord; }
+  G4ThreeVector PhotonCrystalDnsExitCoord() { return mPhotonCrystalDnsExitCoord; }
 
+  G4int PhotonRadiatorMultipleIncidenceFlag() { return mPhotonRadiatorMultipleIncidenceFlag; }
 
-  G4int   PhotonRadiatorMultipleIncidenceFlag() 
-  {    return mPhotonRadiatorMultipleIncidenceFlag;}
+  void BumpNumRaylieghScat() { mNumRayleighScat++; }
+  void setNumRaylieghScat(G4int aNum) { mNumRayleighScat = aNum; }
+  void setPhotonCoordPMTQWExternal(G4ThreeVector aCoorde) { mPhotonCoordPMTQWExternal = aCoorde; }
+  void setCkvCosThetaAtProd(G4double aCosTheta) { mCkvCosThetaAtProd = aCosTheta; }
+  void setCkvPhiAtProd(G4double aPhi) { mCkvPhiAtProd = aPhi; }
+  void setCkvPhotonEnergyAtProd(G4double aEnergy) { mCkvPhotonEnergyAtProd = aEnergy; }
 
- 
+  void BumpPhotonPMTQWMultipleIncidenceFlag() { mPhotonPMTQWMultipleIncidenceFlag++; }
 
+  void setPhotonPMTQWMultipleIncidenceFlag(G4int amFlag) { mPhotonPMTQWMultipleIncidenceFlag = amFlag; }
 
-  void BumpNumRaylieghScat()  {mNumRayleighScat++;}
-  void setNumRaylieghScat(G4int aNum)  {mNumRayleighScat=aNum;}
-  void setPhotonCoordPMTQWExternal(G4ThreeVector aCoorde )
-                    {mPhotonCoordPMTQWExternal=aCoorde;}
-  void setCkvCosThetaAtProd(G4double aCosTheta ) 
-                     {mCkvCosThetaAtProd=aCosTheta;}
-  void setCkvPhiAtProd(G4double aPhi) 
-  {    mCkvPhiAtProd=aPhi;}
-  void setCkvPhotonEnergyAtProd(G4double aEnergy) 
-  {    mCkvPhotonEnergyAtProd=aEnergy;}    
-  
-  void BumpPhotonPMTQWMultipleIncidenceFlag() 
-  {mPhotonPMTQWMultipleIncidenceFlag++;}
-    
-  void setPhotonPMTQWMultipleIncidenceFlag( G4int amFlag ) 
-  {mPhotonPMTQWMultipleIncidenceFlag=amFlag;}
+  void setParentChTrackMomentum(G4double aMom) { mParentChTrackMomentum = aMom; }
+  void setParentChTrackThreeMom(G4ThreeVector aTMom) { mParentChTrackThreeMom = aTMom; }
+  void setPhotonCrystalDnsTIRCoord(G4ThreeVector aTC) { mPhotonCrystalDnsTIRCoord = aTC; }
+  void setPhotonSphMirrReflCoord(G4ThreeVector aMiC) { mPhotonSphMirrReflCoord = aMiC; }
+  void setPhotonCrystalDnsExitCoord(G4ThreeVector aDC) { mPhotonCrystalDnsExitCoord = aDC; }
 
-  void setParentChTrackMomentum( G4double aMom ) 
-  {mParentChTrackMomentum= aMom;}
-  void setParentChTrackThreeMom(G4ThreeVector aTMom) 
-  {  mParentChTrackThreeMom=aTMom;}
-  void setPhotonCrystalDnsTIRCoord(G4ThreeVector aTC) 
-  { mPhotonCrystalDnsTIRCoord= aTC;}
-  void setPhotonSphMirrReflCoord(G4ThreeVector aMiC) 
-  { mPhotonSphMirrReflCoord = aMiC;}
-  void setPhotonCrystalDnsExitCoord(G4ThreeVector aDC) 
-  {mPhotonCrystalDnsExitCoord = aDC;}
-  
- void  BumpPhotonRadiatorMultipleIncidenceFlag()   
-  {    mPhotonRadiatorMultipleIncidenceFlag++;}
-  
-    
-    
+  void BumpPhotonRadiatorMultipleIncidenceFlag() { mPhotonRadiatorMultipleIncidenceFlag++; }
 
 protected:
-
 private:
-
   G4int mNumRayleighScat;
   G4ThreeVector mPhotonCoordPMTQWExternal;
   G4int mPhotonPMTQWMultipleIncidenceFlag;
@@ -100,6 +67,5 @@ private:
   G4ThreeVector mPhotonSphMirrReflCoord;
   G4ThreeVector mPhotonCrystalDnsExitCoord;
   G4int mPhotonRadiatorMultipleIncidenceFlag;
-  
 };
 #endif // INCLUDE_RICHTBPHOTONINFO_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotonProdHisto.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotonProdHisto.hh
index eb80382fbeb191f93e14b9feec507c159254ef6a..0ddaa1c322888f0e3e6198fb65d9267f7dd196ed 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotonProdHisto.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotonProdHisto.hh
@@ -1,15 +1,12 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBPHOTONPRODHISTO_HH 
+#ifndef INCLUDE_RICHTBPHOTONPRODHISTO_HH
 #define INCLUDE_RICHTBPHOTONPRODHISTO_HH 1
 
 // Include files
 #include "Geant4/globals.hh"
 #include "Geant4/G4Track.hh"
 
-extern void RichTbPhotonProductionHisto( const  G4Track& aChTrack,
-                                      const G4Track* aPhotTrack,
-                                        const G4double CkvCosTh, 
-                                        const G4double CkvPhi,
-                                        const G4double  CkvPhEner);
+extern void RichTbPhotonProductionHisto(const G4Track &aChTrack, const G4Track *aPhotTrack, const G4double CkvCosTh,
+                                        const G4double CkvPhi, const G4double CkvPhEner);
 
 #endif // INCLUDE_RICHTBPHOTONPRODHISTO_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotonUserInfoAttach.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotonUserInfoAttach.hh
index 81e246211aeb9390941fea1862157c9b7c00eb01..2aeecd5c6957e104cc09b0769caff809445ec069 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotonUserInfoAttach.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhotonUserInfoAttach.hh
@@ -1,18 +1,13 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBPHOTONUSERINFOATTACH_HH 
+#ifndef INCLUDE_RICHTBPHOTONUSERINFOATTACH_HH
 #define INCLUDE_RICHTBPHOTONUSERINFOATTACH_HH 1
 #include "Geant4/G4Track.hh"
 
-extern void RichTbPMTQWIncidenceInfoAttach(G4Track* aPhTrack, 
-                                       G4ThreeVector aQWPos);
-extern void RichTbRadiatorBoundaryInfoAttach(G4Track* aPhTrack, G4ThreeVector aBoundaryPos, G4int RFROption );
-
-extern void RichTbRayleighInfoAttach( const G4Track& aPhotonTrack);
-extern G4Track* RichTbCkvProdInfoAttach(const G4Track& aChTrack,
-                                    G4Track* aPhotTrack,
-                                    const G4double CkvCosTheta,
-                                    const G4double CkvPhi,
-                                    const G4double CkvPhotEnergy);
+extern void RichTbPMTQWIncidenceInfoAttach(G4Track *aPhTrack, G4ThreeVector aQWPos);
+extern void RichTbRadiatorBoundaryInfoAttach(G4Track *aPhTrack, G4ThreeVector aBoundaryPos, G4int RFROption);
 
+extern void RichTbRayleighInfoAttach(const G4Track &aPhotonTrack);
+extern G4Track *RichTbCkvProdInfoAttach(const G4Track &aChTrack, G4Track *aPhotTrack, const G4double CkvCosTheta,
+                                        const G4double CkvPhi, const G4double CkvPhotEnergy);
 
 #endif // INCLUDE_RICHTBPHOTONUSERINFOATTACH_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhysicsList.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhysicsList.hh
index 9e230134e3ca4a41c6842018d2c97d06af365ee2..8637c0b82ad4dcc2c9bd38d8088d8d10c875c1a4 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhysicsList.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPhysicsList.hh
@@ -5,37 +5,35 @@
 #include "Geant4/G4VUserPhysicsList.hh"
 #include "Geant4/G4ParticleTable.hh"
 
-class RichTbPhysicsList:public G4VUserPhysicsList {
-  public:
-    RichTbPhysicsList();
-    virtual ~ RichTbPhysicsList();
-
-  protected:
-    // Construct particles and processes
-    virtual void ConstructParticle();
-    virtual void ConstructProcess();
-
-    //
-    virtual void SetCuts();
-
-  protected:
-    // these methods Construct particles
-     virtual void ConstructBosons();
-    virtual void ConstructLeptons();
-    virtual void ConstructMesons();
-    virtual void ConstructBaryons();
-
-  protected:
-    // these methods Construct physics processes and register them
-    virtual void ConstructGeneral();
-    virtual void ConstructEM();
-    virtual void ConstructOp();
-
-  private:
-
-    // the particle table has the complete List of existing particle types
-    G4ParticleTable *theParticleTable;
-     G4ParticleTable::G4PTblDicIterator * theParticleIterator;
-
+class RichTbPhysicsList : public G4VUserPhysicsList {
+public:
+  RichTbPhysicsList();
+  virtual ~RichTbPhysicsList();
+
+protected:
+  // Construct particles and processes
+  void ConstructParticle() override;
+  void ConstructProcess() override;
+
+  //
+  void SetCuts() override;
+
+protected:
+  // these methods Construct particles
+  virtual void ConstructBosons();
+  virtual void ConstructLeptons();
+  virtual void ConstructMesons();
+  virtual void ConstructBaryons();
+
+protected:
+  // these methods Construct physics processes and register them
+  virtual void ConstructGeneral();
+  virtual void ConstructEM();
+  virtual void ConstructOp();
+
+private:
+  // the particle table has the complete List of existing particle types
+  G4ParticleTable *theParticleTable;
+  G4ParticleTable::G4PTblDicIterator *theParticleIterator;
 };
-#endif                          /* RichTbPhysicsList_h */
+#endif /* RichTbPhysicsList_h */
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPmtPixelEfficiency.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPmtPixelEfficiency.hh
index 31092bbd607cdb83f2d56368a4acdda70db26744..c8b65e20a5250ef8f613854dad87dd2a3e7ea8c6 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPmtPixelEfficiency.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPmtPixelEfficiency.hh
@@ -7,8 +7,6 @@
 #include <cmath>
 #include <map>
 
-
-
 /** @class RichTbPmtPixelEfficiency RichTbPmtPixelEfficiency.hh include/RichTbPmtPixelEfficiency.hh
  *
  *
@@ -19,31 +17,27 @@ class RichTbPmtPixelEfficiency {
 public:
   /// Standard constructor
   // RichTbPmtPixelEfficiency( );
-  static RichTbPmtPixelEfficiency* getRichTbPmtPixelEfficiencyInstance();
+  static RichTbPmtPixelEfficiency *getRichTbPmtPixelEfficiencyInstance();
 
-  virtual ~RichTbPmtPixelEfficiency( ); ///< Destructor
+  virtual ~RichTbPmtPixelEfficiency(); ///< Destructor
 
   void PmtPixelEffInitialize();
-  G4double getPixelEff(G4int aPmt, G4int aPixel)
-  {  return  mPmtPixelEff [aPmt] [aPixel]; }
-  G4bool PmtPixelEffOK (G4int aPmtNum, G4int aPixelNum);
+  G4double getPixelEff(G4int aPmt, G4int aPixel) { return mPmtPixelEff[aPmt][aPixel]; }
+  G4bool PmtPixelEffOK(G4int aPmtNum, G4int aPixelNum);
   void ReadPixelEfficiency();
-  void ReadAndCopyPixelEffFromFile(G4String aInpFileName  );
+  void ReadAndCopyPixelEffFromFile(G4String aInpFileName);
   void FillPixelEfficiency();
 
-
 protected:
-
 private:
-  RichTbPmtPixelEfficiency( );
-  static RichTbPmtPixelEfficiency* RichTbPmtPixelEfficiencyInstance;
+  RichTbPmtPixelEfficiency();
+  static RichTbPmtPixelEfficiency *RichTbPmtPixelEfficiencyInstance;
 
-  std::vector <std::vector <G4double> >  mPmtPixelEff;
-  std::vector <std::vector <G4String> >  mPmtPixelLabel;
+  std::vector<std::vector<G4double>> mPmtPixelEff;
+  std::vector<std::vector<G4String>> mPmtPixelLabel;
 
-  std::multimap<G4String,G4double> mPmtAnodeEffMap;
+  std::multimap<G4String, G4double> mPmtAnodeEffMap;
 
   G4int RichTbTotNumPmtFinal = 0;
-
 };
 #endif // INCLUDE_RICHTBPMTPIXELEFFICIENCY_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPmtSteppingAction.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPmtSteppingAction.hh
index c4c1b5163a3a20459e235307d6ab32757d85d9bd..02244f2b987d90cce3ac7906c92a9926a68a3a0f 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPmtSteppingAction.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPmtSteppingAction.hh
@@ -6,17 +6,14 @@
 #include "Geant4/G4ParticleChange.hh"
 #include "RichTbMiscNames.hh"
 
-
-class RichTbPmtSteppingAction:public  G4UserSteppingAction {
+class RichTbPmtSteppingAction : public G4UserSteppingAction {
 
 public:
   RichTbPmtSteppingAction();
-  virtual ~ RichTbPmtSteppingAction();
-  void UserSteppingAction(const G4Step * aStep);
+  virtual ~RichTbPmtSteppingAction();
+  void UserSteppingAction(const G4Step *aStep) override;
 
 private:
   G4double mChTrackMinMomFactorForHisto;
-
-
 };
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPrimaryGeneratorAction.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPrimaryGeneratorAction.hh
index cbf51bc495b6ab7c54abce9186cda9e994fa6c18..8fb2933bcedcd754bc51cc4c1088c780b4c3dd4f 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPrimaryGeneratorAction.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbPrimaryGeneratorAction.hh
@@ -9,27 +9,24 @@
 class G4ParticleGun;
 class G4Event;
 
-class RichTbPrimaryGeneratorAction:public G4VUserPrimaryGeneratorAction {
-  public:
-
-    RichTbPrimaryGeneratorAction();
-    virtual ~ RichTbPrimaryGeneratorAction();
-
-  public:
-
-    void GeneratePrimaries(G4Event * anEvent);
-    G4ParticleDefinition*  SetParticleType();  
-    void SetParticleStartPos();
-    void SetParticleKineticEnergy(G4ParticleDefinition * CurPart);
-    void SetParticleDirection();
+class RichTbPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction {
+public:
+  RichTbPrimaryGeneratorAction();
+  virtual ~RichTbPrimaryGeneratorAction();
+
+public:
+  void GeneratePrimaries(G4Event *anEvent) override;
+  G4ParticleDefinition *SetParticleType();
+  void SetParticleStartPos();
+  void SetParticleKineticEnergy(G4ParticleDefinition *CurPart);
+  void SetParticleDirection();
   //    G4double GetCurGenPartEnergy() {
   //      return CurGenPartEnergy;
   //  }
-  private:
-
-     G4ParticleGun * particleGun;
+private:
+  G4ParticleGun *particleGun;
 
   // G4double CurGenPartEnergy;
-    G4ParticleDefinition *CurrentBeamParticle;
+  G4ParticleDefinition *CurrentBeamParticle;
 };
-#endif                          /*RichTbPrimaryGeneratorAction_h */
+#endif /*RichTbPrimaryGeneratorAction_h */
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRODummySD.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRODummySD.hh
index aaf5a3cf0e0c778d19f7d642b70f68b3b37f94f1..1f45bcfd281fd853c01bf30ae6db19c3fc92caec 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRODummySD.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRODummySD.hh
@@ -1,35 +1,32 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBRODUMMYSD_HH 
+#ifndef INCLUDE_RICHTBRODUMMYSD_HH
 #define INCLUDE_RICHTBRODUMMYSD_HH 1
 
 // Include files
 #include "Geant4/G4VSensitiveDetector.hh"
 
 /** @class RichTbRODummySD RichTbRODummySD.hh include/RichTbRODummySD.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-12-12
  */
 class G4Step;
-class RichTbRODummySD: public G4VSensitiveDetector {
-public: 
+class RichTbRODummySD : public G4VSensitiveDetector {
+public:
   /// Standard constructor
-  RichTbRODummySD( ); 
+  RichTbRODummySD();
 
-  virtual ~RichTbRODummySD( ); ///< Destructor
-  void Initialize(G4HCofThisEvent* /* HCE */) {}
-  G4bool ProcessHits(G4Step* /* aStep */,G4TouchableHistory* /* ROhist */) {return false;}
-  void EndOfEvent(G4HCofThisEvent* /* HCE */) {}
-  void clear() {}
-  void DrawAll() {}
-  void PrintAll() {}
+  virtual ~RichTbRODummySD(); ///< Destructor
+  void Initialize(G4HCofThisEvent * /* HCE */) override {}
+  G4bool ProcessHits(G4Step * /* aStep */, G4TouchableHistory * /* ROhist */) override { return false; }
+  void EndOfEvent(G4HCofThisEvent * /* HCE */) override {}
+  void clear() override {}
+  void DrawAll() override {}
+  void PrintAll() override {}
 };
 
+RichTbRODummySD::RichTbRODummySD() : G4VSensitiveDetector("RichTbROdummySD") {}
 
-RichTbRODummySD::RichTbRODummySD()
-  : G4VSensitiveDetector("RichTbROdummySD") {}
-  
-  RichTbRODummySD::~RichTbRODummySD() 
-  {  }
+RichTbRODummySD::~RichTbRODummySD() {}
 #endif // INCLUDE_RICHTBRODUMMYSD_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbROGeometry.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbROGeometry.hh
index 0dcefb975cd1aaa1f7addf1102e5d140ca26d089..f1d625ac409b3ffb497ff5be575afb93cecba26c 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbROGeometry.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbROGeometry.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBROGEOMETRY_HH 
+#ifndef INCLUDE_RICHTBROGEOMETRY_HH
 #define INCLUDE_RICHTBROGEOMETRY_HH 1
 
 // Include files
@@ -8,31 +8,26 @@
 #include "Geant4/G4VPhysicalVolume.hh"
 
 /** @class RichTbROGeometry RichTbROGeometry.hh include/RichTbROGeometry.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-12-11
  */
 class RichTbDetectorConstruction;
 
-class RichTbROGeometry:public G4VReadOutGeometry  {
-public: 
+class RichTbROGeometry : public G4VReadOutGeometry {
+public:
   /// Standard constructor
-  RichTbROGeometry(G4String, RichTbDetectorConstruction* ); 
+  RichTbROGeometry(G4String, RichTbDetectorConstruction *);
 
-  virtual ~RichTbROGeometry( ); ///< Destructor
+  virtual ~RichTbROGeometry(); ///< Destructor
 
-  G4VPhysicalVolume* Build();
+  G4VPhysicalVolume *Build() override;
 
-  RichTbDetectorConstruction* getCurDet() 
-  {
-    return CurDet;
-  }
-  
-protected:
+  RichTbDetectorConstruction *getCurDet() { return CurDet; }
 
+protected:
 private:
-  RichTbDetectorConstruction* CurDet;
-  
+  RichTbDetectorConstruction *CurDet;
 };
 #endif // INCLUDE_RICHTBROGEOMETRY_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbROGeometryHpd.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbROGeometryHpd.hh
index 84ff3ac99c2a9fa721e0169f921c11e65f313e28..0fe7c69c56342a9a7654f786f7a114f9ce5a47ef 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbROGeometryHpd.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbROGeometryHpd.hh
@@ -1,4 +1,4 @@
-#ifndef INCLUDE_RICHTBROGEOMETRYHPD_HH 
+#ifndef INCLUDE_RICHTBROGEOMETRYHPD_HH
 #define INCLUDE_RICHTBROGEOMETRYHPD_HH 1
 
 // Include files
@@ -8,30 +8,24 @@
 
 class RichTbDetectorConstruction;
 
-
 /** @class RichTbROGeometryHpd RichTbROGeometryHpd.hh include/RichTbROGeometryHpd.hh
- *  
+ *
  *
  *  @author Sajan Easo
  *  @date   2015-05-16
  */
-class RichTbROGeometryHpd:public G4VReadOutGeometry  {
-public: 
+class RichTbROGeometryHpd : public G4VReadOutGeometry {
+public:
   /// Standard constructor
-  RichTbROGeometryHpd(G4String, RichTbDetectorConstruction* ); 
+  RichTbROGeometryHpd(G4String, RichTbDetectorConstruction *);
 
-  virtual ~RichTbROGeometryHpd( ); ///< Destructor
-
-  G4VPhysicalVolume* Build();
-  RichTbDetectorConstruction* getCurDet()
-  {
-    return CurDet;
-  }
+  virtual ~RichTbROGeometryHpd(); ///< Destructor
 
+  G4VPhysicalVolume *Build() override;
+  RichTbDetectorConstruction *getCurDet() { return CurDet; }
 
 protected:
-
 private:
-  RichTbDetectorConstruction* CurDet;
+  RichTbDetectorConstruction *CurDet;
 };
 #endif // INCLUDE_RICHTBROGEOMETRYHPD_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRadiatorGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRadiatorGeometryParameters.hh
index 0024a84aa90412e9fdbddb8cf1e0145be244982f..a729096ebaaaff659bfdad6dc4ca495c56363241 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRadiatorGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRadiatorGeometryParameters.hh
@@ -10,28 +10,25 @@
  *  @date   2003-10-21
  */
 
-const G4double Box1XSize=600.0*CLHEP::mm;
-const G4double Box1YSize=600.0*CLHEP::mm;
-const G4double Box1ZSize=600.0*CLHEP::mm;
+const G4double Box1XSize = 600.0 * CLHEP::mm;
+const G4double Box1YSize = 600.0 * CLHEP::mm;
+const G4double Box1ZSize = 600.0 * CLHEP::mm;
 
-const G4double Box2XSize=151.7*CLHEP::mm;
-const G4double Box2YSize=70.0*CLHEP::mm;
-const G4double Box2ZSize=500.0*CLHEP::mm;
-
-//const G4double SphereRadius=138.4*CLHEP::mm;
-//Didier radius
-const G4double SphereRadius=144.6*CLHEP::mm;
-//Laser radius
-//const G4double SphereRadius=141.3*CLHEP::mm;
-const G4double RadiatorLensThickness = 27.0*CLHEP::mm;
+const G4double Box2XSize = 151.7 * CLHEP::mm;
+const G4double Box2YSize = 70.0 * CLHEP::mm;
+const G4double Box2ZSize = 500.0 * CLHEP::mm;
 
+// const G4double SphereRadius=138.4*CLHEP::mm;
+// Didier radius
+const G4double SphereRadius = 144.6 * CLHEP::mm;
+// Laser radius
+// const G4double SphereRadius=141.3*CLHEP::mm;
+const G4double RadiatorLensThickness = 27.0 * CLHEP::mm;
 
 const G4double Box2XLocation = 0.0;
 const G4double Box2YLocation = 0.0;
-//const G4double Box2ZLocation = +0.5* Box2ZSize + SphereRadius - 27.0*CLHEP::mm;
-const G4double Box2ZLocation = -0.5* Box2ZSize - SphereRadius + RadiatorLensThickness ;
-
-
+// const G4double Box2ZLocation = +0.5* Box2ZSize + SphereRadius - 27.0*CLHEP::mm;
+const G4double Box2ZLocation = -0.5 * Box2ZSize - SphereRadius + RadiatorLensThickness;
 
 const G4double BigBoxXLocation = 0.0;
 const G4double BigBoxYLocation = 0.0;
@@ -43,67 +40,66 @@ const G4double RichTbUpgradeRadiatorZLocation = SphereRadius;
 
 // now for variables used after creating the geometry in stepaction analysis.
 // These are not used for geometry construction.
-const G4double RichTbUpgradeRadiatorEnvPlateThickness=0.0*CLHEP::mm;
+const G4double RichTbUpgradeRadiatorEnvPlateThickness = 0.0 * CLHEP::mm;
 
-const G4double RichTbRadiatorLensSizeLateralTolerence=5.0*CLHEP::mm;
-const G4double RichTbRadiatorLensSizeLongitudeTolerence=10.0*CLHEP::mm;
+const G4double RichTbRadiatorLensSizeLateralTolerence = 5.0 * CLHEP::mm;
+const G4double RichTbRadiatorLensSizeLongitudeTolerence = 10.0 * CLHEP::mm;
 
-const G4double  RichTbRadiatorXPosExtreme=  RichTbUpgradeRadiatorXLocation + SphereRadius
-                                            +  RichTbRadiatorLensSizeLateralTolerence;
-const G4double  RichTbRadiatorXNegExtreme=  RichTbUpgradeRadiatorXLocation - SphereRadius
-                                            -  RichTbRadiatorLensSizeLateralTolerence;
+const G4double RichTbRadiatorXPosExtreme =
+    RichTbUpgradeRadiatorXLocation + SphereRadius + RichTbRadiatorLensSizeLateralTolerence;
+const G4double RichTbRadiatorXNegExtreme =
+    RichTbUpgradeRadiatorXLocation - SphereRadius - RichTbRadiatorLensSizeLateralTolerence;
 
-const G4double  RichTbRadiatorYPosExtreme=  RichTbUpgradeRadiatorYLocation + SphereRadius
-                                            +  RichTbRadiatorLensSizeLateralTolerence;
-const G4double  RichTbRadiatorYNegExtreme=  RichTbUpgradeRadiatorYLocation - SphereRadius
-                                            -  RichTbRadiatorLensSizeLateralTolerence;
-const G4double  RichTbRadiatorZNegExtreme =  RichTbCrystalMasterZLocation -  RichTbRadiatorLensSizeLongitudeTolerence;
-const G4double  RichTbRadiatorZPosExtreme =  RichTbCrystalMasterZLocation + RadiatorLensThickness
-                                             + RichTbRadiatorLensSizeLongitudeTolerence;
+const G4double RichTbRadiatorYPosExtreme =
+    RichTbUpgradeRadiatorYLocation + SphereRadius + RichTbRadiatorLensSizeLateralTolerence;
+const G4double RichTbRadiatorYNegExtreme =
+    RichTbUpgradeRadiatorYLocation - SphereRadius - RichTbRadiatorLensSizeLateralTolerence;
+const G4double RichTbRadiatorZNegExtreme = RichTbCrystalMasterZLocation - RichTbRadiatorLensSizeLongitudeTolerence;
+const G4double RichTbRadiatorZPosExtreme =
+    RichTbCrystalMasterZLocation + RadiatorLensThickness + RichTbRadiatorLensSizeLongitudeTolerence;
 
 const G4double RichTbRadiatorDnsZLocation = RichTbCrystalMasterZLocation + RadiatorLensThickness;
-const G4double RichTbRadiatorDnsZLocationTolerence = 2.0*CLHEP::mm;
+const G4double RichTbRadiatorDnsZLocationTolerence = 2.0 * CLHEP::mm;
 
-//testbeam 2015 upgrade parameters
-const G4double SphereRadius15=155.96*CLHEP::mm;
-const G4double RadiatorLensThickness15 = 24.397*CLHEP::mm; //centre thickness of the lens
+// testbeam 2015 upgrade parameters
+const G4double SphereRadius15 = 155.96 * CLHEP::mm;
+const G4double RadiatorLensThickness15 = 24.397 * CLHEP::mm; // centre thickness of the lens
 
-const G4double  RichTbRadiatorXPosExtreme15 =  RichTbUpgradeRadiatorXLocation + SphereRadius15
-                                            +  RichTbRadiatorLensSizeLateralTolerence;
-const G4double  RichTbRadiatorXNegExtreme15 =  RichTbUpgradeRadiatorXLocation - SphereRadius15
-                                            -  RichTbRadiatorLensSizeLateralTolerence;
+const G4double RichTbRadiatorXPosExtreme15 =
+    RichTbUpgradeRadiatorXLocation + SphereRadius15 + RichTbRadiatorLensSizeLateralTolerence;
+const G4double RichTbRadiatorXNegExtreme15 =
+    RichTbUpgradeRadiatorXLocation - SphereRadius15 - RichTbRadiatorLensSizeLateralTolerence;
 
-const G4double  RichTbRadiatorYPosExtreme15 =  RichTbUpgradeRadiatorYLocation + SphereRadius15
-                                            +  RichTbRadiatorLensSizeLateralTolerence;
-const G4double  RichTbRadiatorYNegExtreme15=  RichTbUpgradeRadiatorYLocation - SphereRadius15
-                                            -  RichTbRadiatorLensSizeLateralTolerence;
-const G4double  RichTbRadiatorZNegExtreme15 =  RichTbCrystalMasterZLocation -  RichTbRadiatorLensSizeLongitudeTolerence;
-const G4double  RichTbRadiatorZPosExtreme15 =  RichTbCrystalMasterZLocation + RadiatorLensThickness15
-                                             + RichTbRadiatorLensSizeLongitudeTolerence;
+const G4double RichTbRadiatorYPosExtreme15 =
+    RichTbUpgradeRadiatorYLocation + SphereRadius15 + RichTbRadiatorLensSizeLateralTolerence;
+const G4double RichTbRadiatorYNegExtreme15 =
+    RichTbUpgradeRadiatorYLocation - SphereRadius15 - RichTbRadiatorLensSizeLateralTolerence;
+const G4double RichTbRadiatorZNegExtreme15 = RichTbCrystalMasterZLocation - RichTbRadiatorLensSizeLongitudeTolerence;
+const G4double RichTbRadiatorZPosExtreme15 =
+    RichTbCrystalMasterZLocation + RadiatorLensThickness15 + RichTbRadiatorLensSizeLongitudeTolerence;
 
 const G4double RichTbRadiatorDnsZLocation15 = RichTbCrystalMasterZLocation + RadiatorLensThickness15;
 
-const G4double Box2XSize15=151.7*CLHEP::mm;
-const G4double Box2YSize15=150.0*CLHEP::mm;
-const G4double Box2ZSize15=500.0*CLHEP::mm;
+const G4double Box2XSize15 = 151.7 * CLHEP::mm;
+const G4double Box2YSize15 = 150.0 * CLHEP::mm;
+const G4double Box2ZSize15 = 500.0 * CLHEP::mm;
 
-const G4double cylRmin = 0.0*CLHEP::mm;
-const G4double cylRmax = 149.845/2*CLHEP::mm;
-const G4double cylDarkRmin = 0.0*CLHEP::mm;
-const G4double cylDarkRmax = 11*CLHEP::mm;
-const G4double cylDarkHalfLength = 1.0*CLHEP::mm;
-const G4double cylHalfLength = 250.0*CLHEP::mm;
+const G4double cylRmin = 0.0 * CLHEP::mm;
+const G4double cylRmax = 149.845 / 2 * CLHEP::mm;
+const G4double cylDarkRmin = 0.0 * CLHEP::mm;
+const G4double cylDarkRmax = 11 * CLHEP::mm;
+const G4double cylDarkHalfLength = 1.0 * CLHEP::mm;
+const G4double cylHalfLength = 250.0 * CLHEP::mm;
 const G4double cylSPhi = 0.0;
-const G4double cylDPhi = 2*M_PI;
+const G4double cylDPhi = 2 * M_PI;
 
 const G4double Cyl1XLocation = 0.0;
 const G4double Cyl1YLocation = 0.0;
-//const G4double Box2ZLocation = +0.5* Box2ZSize + SphereRadius - 27.0*CLHEP::mm;
+// const G4double Box2ZLocation = +0.5* Box2ZSize + SphereRadius - 27.0*CLHEP::mm;
 const G4double Cyl1ZLocation = -cylHalfLength - SphereRadius15 + RadiatorLensThickness15;
 
 const G4double RichTbUpgradeRadiatorXLocation15 = 0.0;
 const G4double RichTbUpgradeRadiatorYLocation15 = 0.0;
 const G4double RichTbUpgradeRadiatorZLocation15 = SphereRadius15;
 
-
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRunAction.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRunAction.hh
index 9b2d030671bb9df2d6751e220aa28f43fb7537bb..af9837e0910a3fe02c56a8e94cb82824f865211e 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRunAction.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRunAction.hh
@@ -8,22 +8,18 @@
 class G4Timer;
 class G4Run;
 
-class RichTbRunAction:public G4UserRunAction {
-  public:
+class RichTbRunAction : public G4UserRunAction {
+public:
+  RichTbRunAction();
+  virtual ~RichTbRunAction();
 
-    RichTbRunAction();
-    virtual ~ RichTbRunAction();
+public:
+  void BeginOfRunAction(const G4Run *aRun) override;
+  void EndOfRunAction(const G4Run *aRun) override;
+  RichTbAnalysisManager *getAnalysisMRun() { return ranalysisManager; }
 
-  public:
-
-    virtual void BeginOfRunAction(const G4Run * aRun);
-    virtual void EndOfRunAction(const G4Run * aRun);
-    RichTbAnalysisManager *getAnalysisMRun() {
-        return ranalysisManager;
-    }
-  private:
-
-     G4Timer * timer;
-    RichTbAnalysisManager *ranalysisManager;
+private:
+  G4Timer *timer;
+  RichTbAnalysisManager *ranalysisManager;
 };
-#endif                          /*RichTbRunAction_h */
+#endif /*RichTbRunAction_h */
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRunConfig.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRunConfig.hh
index 2b44d89bf14579fe6632ead000d16ac211393329..d97f34ec0b4b3b21eeb91322ff67b99e50479726 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRunConfig.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbRunConfig.hh
@@ -8,452 +8,274 @@
 #include "Geant4/G4ThreeVector.hh"
 #include "CLHEP/Units/SystemOfUnits.h"
 
-
 class RichTbRunConfig {
-  public:
-    //RichTbRunConfig();
-    virtual ~ RichTbRunConfig();
-
-    static RichTbRunConfig* getRunConfigInstance();
+public:
+  // RichTbRunConfig();
+  virtual ~RichTbRunConfig();
 
-  G4int getRichTbHall_visib()
-  {return  RichTbHall_visib;}
+  static RichTbRunConfig *getRunConfigInstance();
 
-  G4int   getRichTbUpgradeVessel_visib()
-  {    return RichTbUpgradeVessel_visib;  }
+  G4int getRichTbHall_visib() { return RichTbHall_visib; }
 
- G4int   getRichTbCrystal_visib()
-  {    return RichTbCrystal_visib;  }
+  G4int getRichTbUpgradeVessel_visib() { return RichTbUpgradeVessel_visib; }
 
- G4int   getRichTbLens_visib()
-  {    return RichTbLens_visib;  }
+  G4int getRichTbCrystal_visib() { return RichTbCrystal_visib; }
 
-  G4int   getRichTbUpgradeRadiator_visib()
-  {    return RichTbUpgradeRadiator_visib;  }
+  G4int getRichTbLens_visib() { return RichTbLens_visib; }
 
-  G4int   getRichTbUpgradeMirror_visib()
-  {    return RichTbUpgradeMirror_visib;  }
+  G4int getRichTbUpgradeRadiator_visib() { return RichTbUpgradeRadiator_visib; }
 
-  G4int   getRichTbUpgradeDarkCover_visib()
-  {    return RichTbUpgradeDarkCover_visib;  }
+  G4int getRichTbUpgradeMirror_visib() { return RichTbUpgradeMirror_visib; }
 
-  G4int   getRichTbUpgradeUpsDarkCover_visib()
-  {    return RichTbUpgradeUpsDarkCover_visib;  }
-  G4int   getRichTbUpgradeSideDarkCover_visib()
-  {    return RichTbUpgradeSideDarkCover_visib;  }
+  G4int getRichTbUpgradeDarkCover_visib() { return RichTbUpgradeDarkCover_visib; }
 
-  G4int   getRichTbUpgradeDnsDarkCover_visib()
-  {    return RichTbUpgradeDnsDarkCover_visib;  }
+  G4int getRichTbUpgradeUpsDarkCover_visib() { return RichTbUpgradeUpsDarkCover_visib; }
+  G4int getRichTbUpgradeSideDarkCover_visib() { return RichTbUpgradeSideDarkCover_visib; }
 
+  G4int getRichTbUpgradeDnsDarkCover_visib() { return RichTbUpgradeDnsDarkCover_visib; }
 
- G4int   getRichTbCrystalCover_visib()
-  {    return RichTbCrystalCover_visib;  }
+  G4int getRichTbCrystalCover_visib() { return RichTbCrystalCover_visib; }
 
   // G4int   getRichTbMaster_visib()
   // {    return RichTbMaster_visib;  }
 
- G4int   getRichTbPMTEnvelope_visib()
-  {    return RichTbPMTEnvelope_visib;  }
-
- G4int   getRichTbPMTQuartzW_visib()
-  {    return RichTbPMTQuartzW_visib;  }
-
- G4int   getRichTbPMTPhCathode_visib()
-  {    return RichTbPMTPhCathode_visib;  }
+  G4int getRichTbPMTEnvelope_visib() { return RichTbPMTEnvelope_visib; }
 
- G4int   getRichTbPMTAnode_visib()
-  {    return RichTbPMTAnode_visib;  }
+  G4int getRichTbPMTQuartzW_visib() { return RichTbPMTQuartzW_visib; }
 
-  G4int   getRichTbPhDFrame_visib()
-  {    return RichTbPhDFrame_visib;  }
+  G4int getRichTbPMTPhCathode_visib() { return RichTbPMTPhCathode_visib; }
 
+  G4int getRichTbPMTAnode_visib() { return RichTbPMTAnode_visib; }
 
-  G4int getRichTbPhDetSupFrame_visib()
-  {    return RichTbPhDetSupFrame_visib;}
-
-  G4int getRichTbEC_visib()
-  {
-    return RichTbEC_visib;
-  }
+  G4int getRichTbPhDFrame_visib() { return RichTbPhDFrame_visib; }
 
+  G4int getRichTbPhDetSupFrame_visib() { return RichTbPhDetSupFrame_visib; }
 
+  G4int getRichTbEC_visib() { return RichTbEC_visib; }
 
-  G4int getRichTbGasQuWin_visib() {return RichTbGasQuWin_visib;}
+  G4int getRichTbGasQuWin_visib() { return RichTbGasQuWin_visib; }
 
-  G4int getRichTbPMTMaster_visib()
-  { return  RichTbPMTMaster_visib;}
-  G4int getRichTbPMTSMaster_visib()
-  {  return RichTbPMTSMaster_visib;}
+  G4int getRichTbPMTMaster_visib() { return RichTbPMTMaster_visib; }
+  G4int getRichTbPMTSMaster_visib() { return RichTbPMTSMaster_visib; }
   // G4int getRichTbPMTEnvelope_visib()
   // {    return RichTbPMTEnvelope_visib;}
-  G4int getRichTbPMTEndCap_visib()
-  {    return RichTbPMTEndCap_visib;}
+  G4int getRichTbPMTEndCap_visib() { return RichTbPMTEndCap_visib; }
   // G4int getRichTbPMTQuartzW_visib()
   // {    return RichTbPMTQuartzW_visib;  }
   // G4int getRichTbPMTPhCathode_visib()
   // {    return  RichTbPMTPhCathode_visib;}
-  G4int getRichTbPMTFrontRing_visib()
-  {    return RichTbPMTFrontRing_visib; }
+  G4int getRichTbPMTFrontRing_visib() { return RichTbPMTFrontRing_visib; }
 
+  G4int getGasTypeCode() { return GasTypeCode; }
 
+  G4double getNitrogenPressure() { return NitrogenPressure; }
+  G4double getNitrogenTemperature() { return NitrogenTemperature; }
 
+  G4double getNominalNitrogenPressure() { return NominalNitrogenPressure; }
+  G4double getNominalNitrogenTemperature() { return NominalNitrogenTemperature; }
 
-  G4int getGasTypeCode() {return  GasTypeCode;}
+  G4double getc4f10Pressure() { return c4f10Pressure; }
+  G4double getc4f10Temperature() { return c4f10Temperature; }
 
-  G4double getNitrogenPressure()
-  {   return NitrogenPressure;}
-  G4double getNitrogenTemperature()
-  {    return NitrogenTemperature;}
+  G4double getNominalc4f10Pressure() { return Nominalc4f10Pressure; }
+  G4double getNominalc4f10Temperature() { return Nominalc4f10Temperature; }
 
- G4double getNominalNitrogenPressure()
-  {   return NominalNitrogenPressure;}
-  G4double getNominalNitrogenTemperature()
-  {    return NominalNitrogenTemperature;}
+  G4int getMirrorOrientCode() { return MirrorOrientCode; }
 
-  G4double getc4f10Pressure()
-  {   return c4f10Pressure;}
-  G4double getc4f10Temperature()
-  {    return c4f10Temperature;}
+  G4double getMirrorAddTiltX() { return MirrorAddTiltX; }
 
- G4double getNominalc4f10Pressure()
-  {   return Nominalc4f10Pressure;}
-  G4double getNominalc4f10Temperature()
-  {    return Nominalc4f10Temperature;}
+  G4double getMirrorAddTiltY() { return MirrorAddTiltY; }
 
+  G4int getNonOptimalPMTCondition() { return mNonOptimalPMTCondition; }
+  void setNonOptimalPMTCondition(G4int acond) { mNonOptimalPMTCondition = acond; }
+  G4double getNonOptimalPMTAbsEff() { return mNonOptimalPMTAbsEff; }
+  void setNonOptimalPMTAbsEff(G4double ahpdeff) { mNonOptimalPMTAbsEff = ahpdeff; }
 
+  G4double getHpdpeBackScaProb() { return mHpdpeBackScaProb; }
 
-  G4int  getMirrorOrientCode() {
-    return MirrorOrientCode;
-  }
+  G4int getRichTbNumPartEvent() { return RichTbNumPartEvent; }
+  G4int getRichTbParticleTypeCode() { return RichTbParticleTypeCode; }
+  G4int getRichTbParticleStartPosCode() { return RichTbParticleStartPosCode; }
+  G4int getRichTbParticleDirectionCode() { return RichTbParticleDirectionCode; }
+  G4int getRichTbParticleEnergyCode() { return RichTbParticleEnergyCode; }
+  G4double getRichTbParticleMomentum() { return RichTbParticleMomentum; }
+  G4double getPosBeamFraction() { return PosBeamFraction; }
 
-  G4double  getMirrorAddTiltX()
-  {    return  MirrorAddTiltX;}
+  G4double getBeamDirX() { return mBeamDirX; }
+  G4double getBeamDirY() { return mBeamDirY; }
+  G4double getBeamDivergenceX() { return mBeamDivergenceX; }
+  G4double getBeamDivergenceY() { return mBeamDivergenceY; }
 
-  G4double getMirrorAddTiltY()
-  {   return MirrorAddTiltY;}
+  G4double getPMTPEMomInit() { return PMTPEMomInit; }
+  G4double getHpdPEMomInit() { return PMTPEMomInit; }
 
+  G4int getHitCreationOption() { return HitCreationOption; }
 
-  G4int getNonOptimalPMTCondition() {return  mNonOptimalPMTCondition;}
-  void setNonOptimalPMTCondition(G4int acond)
-     {mNonOptimalPMTCondition=acond;}
-  G4double getNonOptimalPMTAbsEff() {return  mNonOptimalPMTAbsEff;}
-  void setNonOptimalPMTAbsEff(G4double ahpdeff)
-     {mNonOptimalPMTAbsEff= ahpdeff;}
+  G4double getECXShift() { return ECXShift; }
 
-  G4double getHpdpeBackScaProb() {return mHpdpeBackScaProb;}
+  G4String getOutputFileName() { return OutputFileName; }
+  G4int DoWriteOutputFile() { return WriteOutputFile; }
 
+  G4String getMirrorReflFileName() { return MirrorReflFileName; }
 
+  G4String getOutputHistoFileName() { return OutputHistoFileName; }
+  G4String getOutputNtupleFileName() { return OutputNtupleFileName; }
 
+  G4int VerboseInfoFlag() { return mVerboseInfoFlag; }
+  void setVerboseInfoFlag(G4int aVerboseFlag) { mVerboseInfoFlag = aVerboseFlag; }
+  G4int VerboseOutputFileFlag() { return mVerboseOutputFileFlag; }
+  void setVerboseOutputFileFlag(G4int aVouf) { mVerboseOutputFileFlag = aVouf; }
 
+  G4int getBatchModeFlag() { return mBatchModeFlag; }
+  void setBatchModeFlag(G4int abatchFlag) { mBatchModeFlag = abatchFlag; }
 
-  G4int getRichTbNumPartEvent()
-  {
-   return  RichTbNumPartEvent;
-  }
-  G4int  getRichTbParticleTypeCode()
-  {
-    return RichTbParticleTypeCode;
-  }
-  G4int  getRichTbParticleStartPosCode()
-  {
-    return RichTbParticleStartPosCode;
-  }
-  G4int  getRichTbParticleDirectionCode()
-  {
-    return RichTbParticleDirectionCode;
-  }
-  G4int  getRichTbParticleEnergyCode()
-  {
-    return RichTbParticleEnergyCode;
-  }
-  G4double  getRichTbParticleMomentum()
-  {
-    return RichTbParticleMomentum;
-  }
-  G4double getPosBeamFraction()
-  {
-    return PosBeamFraction;
+  G4int getNumEventInBatchMode() { return mNumEventInBatchMode; }
+  void setNumEventInBatchMode(G4int aNumEv) { mNumEventInBatchMode = aNumEv; }
 
-  }
+  G4double getBeamXPosShift() { return mBeamXPosShift; }
+  G4double getBeamYPosShift() { return mBeamYPosShift; }
+  void setBeamXPosShift(G4double abeamXs) { mBeamXPosShift = abeamXs; }
+  void setBeamYPosShift(G4double abeamYs) { mBeamYPosShift = abeamYs; }
 
-  G4double getBeamDirX()
-  {    return  mBeamDirX;  }
-  G4double getBeamDirY()
-  {  return mBeamDirY;}
-  G4double getBeamDivergenceX()
-  {    return mBeamDivergenceX;}
-  G4double getBeamDivergenceY()
-  {    return mBeamDivergenceY;}
+  G4double getBeamSpecialXPos() { return mBeamSpecialXPos; }
+  G4double getBeamSpecialYPos() { return mBeamSpecialYPos; }
+  G4double getBeamSpecialZPos() { return mBeamSpecialZPos; }
+  void setBeamSpecialXPos(G4double asPosX) { mBeamSpecialXPos = asPosX; }
+  void setBeamSpecialYPos(G4double asPosY) { mBeamSpecialYPos = asPosY; }
+  void setBeamSpecialZPos(G4double asPosZ) { mBeamSpecialZPos = asPosZ; }
 
+  void setBeamSpecialXRange(G4double aBeamSpecialXRange) { mBeamSpecialXRange = aBeamSpecialXRange; }
 
- G4double getPMTPEMomInit()
-  {
-    return PMTPEMomInit;
-  }
- G4double getHpdPEMomInit ()
-  {
-    return PMTPEMomInit;
-  }
-
+  G4double getBeamSpecialXRange() { return mBeamSpecialXRange; }
 
-  G4int getHitCreationOption()
-  {
-    return HitCreationOption;
+  G4int getActivateBeamShiftNtuple() { return mActivateBeamShiftNtuple; }
+  void setActivateBeamShiftNtuple(G4int aAc) { mActivateBeamShiftNtuple = aAc; }
 
-  }
+  G4double getConstPhotWlenBeam() { return mConstPhotWlenBeam; }
+  G4double getPhotWlenMinBeam() { return mPhotWlenMinBeam; }
+  G4double getPhotWlenMaxBeam() { return mPhotWlenMaxBeam; }
 
-  G4double getECXShift() {
-	  return ECXShift;
-  }
+  void setConstPhotWlenBeam(G4double aPhw) { mConstPhotWlenBeam = aPhw; }
+  void setPhotWlenMinBeam(G4double aPhwMin) { mPhotWlenMinBeam = aPhwMin; }
+  void setPhotWlenMaxBeam(G4double aPhwMax) { mPhotWlenMaxBeam = aPhwMax; }
 
-  G4String getOutputFileName()
-  {
-    return OutputFileName;
+  G4int getSpecialStudyVesselRotation() { return mSpecialStudyVesselRotation; }
 
-  }
-  G4int  DoWriteOutputFile() {return WriteOutputFile; }
-
-  G4String getMirrorReflFileName() {
-    return MirrorReflFileName;
-  }
+  G4int getSpecialStudyCrystalRotation() { return mSpecialStudyCrystalRotation; }
+  G4double getSpecialStudyCrystalRotationX() { return mSpecialStudyCrystalRotationX; }
+  G4double getSpecialStudyCrystalRotationY() { return mSpecialStudyCrystalRotationY; }
 
-  G4String getOutputHistoFileName()
-  {
-    return OutputHistoFileName;
-  }
-  G4String getOutputNtupleFileName()
-  {
-    return OutputNtupleFileName;
-  }
+  G4int getSpecialStudyMasterRotation() { return mSpecialStudyMasterRotation; }
+  G4double getSpecialStudyMasterRotationX() { return mSpecialStudyMasterRotationX; }
+  G4double getSpecialStudyMasterRotationY() { return mSpecialStudyMasterRotationY; }
 
+  std::vector<G4double> getDemagConstShiftAtAnodeX() { return mDemagConstShiftAtAnodeX; }
+  std::vector<G4double> getDemagConstShiftAtAnodeY() { return mDemagConstShiftAtAnodeY; }
+  std::vector<G4double> getPMTAdditionalLocalRotationZ() { return mPMTAdditionalLocalRotationZ; }
 
-  G4int VerboseInfoFlag()
-  {
-    return mVerboseInfoFlag;
-  }
-  void setVerboseInfoFlag(G4int aVerboseFlag)
-  {
-    mVerboseInfoFlag=aVerboseFlag;
-
-  }
-  G4int VerboseOutputFileFlag()
-  { return  mVerboseOutputFileFlag;}
-  void setVerboseOutputFileFlag(G4int aVouf )
-  {mVerboseOutputFileFlag=aVouf ;}
-
-  G4int getBatchModeFlag()  {    return mBatchModeFlag;}
-  void setBatchModeFlag( G4int abatchFlag ){    mBatchModeFlag=abatchFlag;}
-
-  G4int getNumEventInBatchMode(){    return mNumEventInBatchMode;}
-  void setNumEventInBatchMode(G4int aNumEv )
-  {mNumEventInBatchMode=aNumEv;}
-
-  G4double getBeamXPosShift()  {    return mBeamXPosShift;}
-  G4double getBeamYPosShift()  {    return mBeamYPosShift;}
-  void setBeamXPosShift(G4double abeamXs )
-  {mBeamXPosShift= abeamXs;}
-  void setBeamYPosShift(G4double abeamYs )
-  {mBeamYPosShift= abeamYs;}
-
-  G4double getBeamSpecialXPos()
-  {
-    return mBeamSpecialXPos;
-  }
-  G4double getBeamSpecialYPos()
-  {
-    return mBeamSpecialYPos;
-  }
-  G4double getBeamSpecialZPos()
-  {
-    return mBeamSpecialZPos;
-  }
-  void setBeamSpecialXPos (G4double asPosX)
-  {    mBeamSpecialXPos= asPosX;  }
-  void setBeamSpecialYPos (G4double asPosY)
-  {    mBeamSpecialYPos= asPosY;  }
-  void setBeamSpecialZPos (G4double asPosZ)
-  {    mBeamSpecialZPos= asPosZ;  }
-
-  void setBeamSpecialXRange(G4double aBeamSpecialXRange)
-  {mBeamSpecialXRange=aBeamSpecialXRange;}
-
-
-  G4double getBeamSpecialXRange()
-  {return  mBeamSpecialXRange; }
-
-  G4int getActivateBeamShiftNtuple() {return  mActivateBeamShiftNtuple; }
-  void setActivateBeamShiftNtuple(G4int aAc ) {mActivateBeamShiftNtuple=aAc;}
-
-  G4double getConstPhotWlenBeam()
-  {    return  mConstPhotWlenBeam;}
-  G4double getPhotWlenMinBeam()
-  {    return mPhotWlenMinBeam;}
-  G4double getPhotWlenMaxBeam()
-  {    return  mPhotWlenMaxBeam;}
-
-  void setConstPhotWlenBeam( G4double aPhw)
-  { mConstPhotWlenBeam= aPhw;}
-  void setPhotWlenMinBeam(G4double aPhwMin)
-  {mPhotWlenMinBeam=aPhwMin;}
-  void setPhotWlenMaxBeam(G4double aPhwMax)
-  {mPhotWlenMaxBeam=aPhwMax;}
-
-  G4int getSpecialStudyVesselRotation()
-  {return mSpecialStudyVesselRotation ;}
-
-  G4int getSpecialStudyCrystalRotation()
-  {return mSpecialStudyCrystalRotation ;}
-  G4double getSpecialStudyCrystalRotationX()
-  {return mSpecialStudyCrystalRotationX ;}
-  G4double getSpecialStudyCrystalRotationY()
-  {return mSpecialStudyCrystalRotationY ;}
-
-  G4int getSpecialStudyMasterRotation()
-  {return mSpecialStudyMasterRotation ;}
-  G4double getSpecialStudyMasterRotationX()
-  {return mSpecialStudyMasterRotationX ;}
-  G4double getSpecialStudyMasterRotationY()
-  {return mSpecialStudyMasterRotationY ;}
-
-  std::vector<G4double> getDemagConstShiftAtAnodeX()
-  {    return mDemagConstShiftAtAnodeX;}
-  std::vector<G4double> getDemagConstShiftAtAnodeY()
-  {    return mDemagConstShiftAtAnodeY;}
-  std::vector<G4double> getPMTAdditionalLocalRotationZ()
-  {    return mPMTAdditionalLocalRotationZ;}
-
-  G4double getCurrentPMTAdditionalLocalRotationZ (G4int aPMTNum)
-  {
-    G4double aAdRot=0.0;
-    if(aPMTNum < (G4int) mPMTAdditionalLocalRotationZ.size() )
-      aAdRot= mPMTAdditionalLocalRotationZ[aPMTNum];
+  G4double getCurrentPMTAdditionalLocalRotationZ(G4int aPMTNum) {
+    G4double aAdRot = 0.0;
+    if (aPMTNum < (G4int)mPMTAdditionalLocalRotationZ.size())
+      aAdRot = mPMTAdditionalLocalRotationZ[aPMTNum];
 
     return aAdRot;
   }
 
-  std::vector<G4double> getPMTAlignmentLocalShiftX()
-  {    return mPMTAlignmentLocalShiftX;}
+  std::vector<G4double> getPMTAlignmentLocalShiftX() { return mPMTAlignmentLocalShiftX; }
 
-  G4double getCurrentPMTAlignmentLocalShiftX(G4int bPMTNum)
-  {
-    G4double bShiftX=0.0*CLHEP::mm;
-    if(  bPMTNum < (G4int) mPMTAlignmentLocalShiftX.size() )
-         bShiftX= mPMTAlignmentLocalShiftX[bPMTNum];
-         return bShiftX;
+  G4double getCurrentPMTAlignmentLocalShiftX(G4int bPMTNum) {
+    G4double bShiftX = 0.0 * CLHEP::mm;
+    if (bPMTNum < (G4int)mPMTAlignmentLocalShiftX.size())
+      bShiftX = mPMTAlignmentLocalShiftX[bPMTNum];
+    return bShiftX;
   }
 
-  std::vector<G4double> getPMTAlignmentLocalShiftY()
-  {    return mPMTAlignmentLocalShiftY;}
+  std::vector<G4double> getPMTAlignmentLocalShiftY() { return mPMTAlignmentLocalShiftY; }
 
-  G4double getCurrentPMTAlignmentLocalShiftY(G4int cPMTNum)
-  {
-    G4double cShiftY=0.0*CLHEP::mm;
-    if(  cPMTNum < (G4int) mPMTAlignmentLocalShiftY.size() )
-         cShiftY= mPMTAlignmentLocalShiftY[cPMTNum];
-         return cShiftY;
+  G4double getCurrentPMTAlignmentLocalShiftY(G4int cPMTNum) {
+    G4double cShiftY = 0.0 * CLHEP::mm;
+    if (cPMTNum < (G4int)mPMTAlignmentLocalShiftY.size())
+      cShiftY = mPMTAlignmentLocalShiftY[cPMTNum];
+    return cShiftY;
   }
 
-  std::vector<G4double> getPhSupFrameAdditionalShift() {
-    return mPhSupFrameAdditionalShift;}
-  void setPhSupFrameAdditionalShift(std::vector<G4double> aPhSupFrameAdditionalShift){
-    mPhSupFrameAdditionalShift=aPhSupFrameAdditionalShift;}
-  G4double getPhSupFrameAdditionalVertTilt() {
-    return mPhSupFrameAdditionalVertTilt;}
+  std::vector<G4double> getPhSupFrameAdditionalShift() { return mPhSupFrameAdditionalShift; }
+  void setPhSupFrameAdditionalShift(std::vector<G4double> aPhSupFrameAdditionalShift) {
+    mPhSupFrameAdditionalShift = aPhSupFrameAdditionalShift;
+  }
+  G4double getPhSupFrameAdditionalVertTilt() { return mPhSupFrameAdditionalVertTilt; }
   void setPhSupFrameAdditionalVertTilt(G4double aPhSupFrameAdditionalVertTilt) {
-    mPhSupFrameAdditionalVertTilt=aPhSupFrameAdditionalVertTilt;}
-  G4double getPhSupFrameAdditionalZRot(){
-    return mPhSupFrameAdditionalZRot;}
+    mPhSupFrameAdditionalVertTilt = aPhSupFrameAdditionalVertTilt;
+  }
+  G4double getPhSupFrameAdditionalZRot() { return mPhSupFrameAdditionalZRot; }
   void setPhSupFrameAdditionalZRot(G4double aPhSupFrameAdditionalZRot) {
-    mPhSupFrameAdditionalZRot=aPhSupFrameAdditionalZRot;}
+    mPhSupFrameAdditionalZRot = aPhSupFrameAdditionalZRot;
+  }
 
-  G4int getPMTSiReflFlag() {
-    return mPMTSiReflFlag;}
+  G4int getPMTSiReflFlag() { return mPMTSiReflFlag; }
 
-   G4int getRadiatorConfiguration() {
-    return mRadiatorConfiguration;}
+  G4int getRadiatorConfiguration() { return mRadiatorConfiguration; }
 
-   G4double getMapmtDetectionEfficiency()
-   {return mMapmtDetectionEfficiency;}
+  G4double getMapmtDetectionEfficiency() { return mMapmtDetectionEfficiency; }
 
   //   G4double getMapmtPixelGap()
   //  {  return mMapmtPixelGap;}
 
-  G4bool ApplyPixelEff() {
-    return (mMapmtPixelEfficiencyFlag == 0 ) ? false : true;
-  }
-
-  G4int MapmtPixelEfficiencyFlag ()
-  {  return mMapmtPixelEfficiencyFlag;}
-
+  G4bool ApplyPixelEff() { return (mMapmtPixelEfficiencyFlag == 0) ? false : true; }
 
+  G4int MapmtPixelEfficiencyFlag() { return mMapmtPixelEfficiencyFlag; }
 
-  G4String MapmtPixelOptEffFileNameJura()
-  {  return mMapmtPixelOptEffFileNameJura;}
+  G4String MapmtPixelOptEffFileNameJura() { return mMapmtPixelOptEffFileNameJura; }
 
-  G4String MapmtPixelThr7EffFileNameJura()
-  {  return mMapmtPixelThr7EffFileNameJura;}
+  G4String MapmtPixelThr7EffFileNameJura() { return mMapmtPixelThr7EffFileNameJura; }
 
-  G4String MapmtPixelOptEffFileNameSaleve()
-  {  return mMapmtPixelOptEffFileNameSaleve;}
+  G4String MapmtPixelOptEffFileNameSaleve() { return mMapmtPixelOptEffFileNameSaleve; }
 
-  G4String MapmtPixelThr7EffFileNameSaleve()
-  {  return mMapmtPixelThr7EffFileNameSaleve;}
+  G4String MapmtPixelThr7EffFileNameSaleve() { return mMapmtPixelThr7EffFileNameSaleve; }
 
-  //tesbeam 2015 upgrade
-  G4String MapmtPixelOptEffFileNameJuraUpgr()
-  {  return mMapmtPixelOptEffFileNameJuraUpgradeDummy;}
-  G4String MapmtPixelOptEffFileNameSaleveUpgr()
-  {  return mMapmtPixelOptEffFileNameSaleveUpgradeDummy;}
+  // tesbeam 2015 upgrade
+  G4String MapmtPixelOptEffFileNameJuraUpgr() { return mMapmtPixelOptEffFileNameJuraUpgradeDummy; }
+  G4String MapmtPixelOptEffFileNameSaleveUpgr() { return mMapmtPixelOptEffFileNameSaleveUpgradeDummy; }
 
-  G4String MapmtPixelEffFileNameJuraTop100()
-  {  return mMapmtPixelEffFileNameJuraTop100;}
-  G4String MapmtPixelEffFileNameSaleveTop100()
-  {  return mMapmtPixelEffFileNameSaleveTop100;}
-  G4String MapmtPixelEffFileNameJuraBottom100()
-  {  return mMapmtPixelEffFileNameJuraBottom100;}
-  G4String MapmtPixelEffFileNameSaleveBottom100()
-  {  return mMapmtPixelEffFileNameSaleveBottom100;}
+  G4String MapmtPixelEffFileNameJuraTop100() { return mMapmtPixelEffFileNameJuraTop100; }
+  G4String MapmtPixelEffFileNameSaleveTop100() { return mMapmtPixelEffFileNameSaleveTop100; }
+  G4String MapmtPixelEffFileNameJuraBottom100() { return mMapmtPixelEffFileNameJuraBottom100; }
+  G4String MapmtPixelEffFileNameSaleveBottom100() { return mMapmtPixelEffFileNameSaleveBottom100; }
 
-  G4int getRichTbHpdQW_visib() {return  RichTbHpdQW_visib;}
+  G4int getRichTbHpdQW_visib() { return RichTbHpdQW_visib; }
 
+  G4int getRichTbHpdPHC_visib() { return RichTbHpdPHC_visib; }
 
-  G4int  getRichTbHpdPHC_visib() {return RichTbHpdPHC_visib; }
+  G4int getRichTbHpdSID_visib() { return RichTbHpdSID_visib; }
 
-  G4int  getRichTbHpdSID_visib() {return RichTbHpdSID_visib; }
+  G4int getRichTbHpdENV_visib() { return RichTbHpdENV_visib; }
 
-  G4int  getRichTbHpdENV_visib() {return RichTbHpdENV_visib; }
+  G4int getRichTbHpdENVCAP_visib() { return RichTbHpdENVCAP_visib; }
 
-  G4int  getRichTbHpdENVCAP_visib() {return RichTbHpdENVCAP_visib; }
+  G4int getRichTbHpdSM_visib() { return RichTbHpdSM_visib; }
 
-  G4int  getRichTbHpdSM_visib() {return RichTbHpdSM_visib; }
+  G4int getRichTbHpdMas_visib() { return RichTbHpdMas_visib; }
 
-  G4int  getRichTbHpdMas_visib() {return RichTbHpdMas_visib; }
+  G4int getRichTbHpdSiPix_visib() { return RichTbHpdSiPix_visib; }
 
-  G4int  getRichTbHpdSiPix_visib()  {  return RichTbHpdSiPix_visib;}
+  G4long getRandomSeedInput() { return mRandomSeedInput; }
 
+private:
+  RichTbRunConfig();
+  static RichTbRunConfig *RunConfigInstance;
 
-  G4long getRandomSeedInput () {  return mRandomSeedInput;}
+  // Graphics setups
+  // For Following variables 0 means make the volume invisible;
+  //                        1 means make it visible as a solid.
+  //                        2 means make it visible as a wireframe.
 
-
-
-
-  private:
-
-    RichTbRunConfig();
-    static RichTbRunConfig* RunConfigInstance;
-
- //Graphics setups
-    //For Following variables 0 means make the volume invisible;
-    //                        1 means make it visible as a solid.
-    //                        2 means make it visible as a wireframe.
-
-    // for the hpdsipix visib : <5 means it is not activated at all (default)
-    //                          >=5 activated for special interactive session (not for creating hits.
-    //                          10  means make the volume invisible, even though activated
-    //                          11 means make it visible as a solid.
-    //                          12 means make it visible as a wireframe.
-    //
-   G4int RichTbHall_visib;
+  // for the hpdsipix visib : <5 means it is not activated at all (default)
+  //                          >=5 activated for special interactive session (not for creating hits.
+  //                          10  means make the volume invisible, even though activated
+  //                          11 means make it visible as a solid.
+  //                          12 means make it visible as a wireframe.
+  //
+  G4int RichTbHall_visib;
   G4int RichTbUpgradeVessel_visib;
   G4int RichTbCrystal_visib;
   G4int RichTbLens_visib;
@@ -462,7 +284,7 @@ class RichTbRunConfig {
   G4int RichTbUpgradeDarkCover_visib;
   G4int RichTbUpgradeUpsDarkCover_visib;
   G4int RichTbUpgradeSideDarkCover_visib;
-   G4int RichTbUpgradeDnsDarkCover_visib;
+  G4int RichTbUpgradeDnsDarkCover_visib;
 
   G4int RichTbPMTEnvelope_visib;
   G4int RichTbPMTQuartzW_visib;
@@ -471,29 +293,23 @@ class RichTbRunConfig {
   G4int RichTbPhDFrame_visib;
   G4int RichTbUpgradeMirror_visib;
   G4int RichTbPhDetSupFrame_visib;
-  G4int  RichTbEC_visib;
+  G4int RichTbEC_visib;
   G4int RichTbPMTMaster_visib;
   G4int RichTbPMTSMaster_visib;
   G4int RichTbPMTEndCap_visib;
   G4int RichTbPMTFrontRing_visib;
 
-
-   G4int RichTbGasQuWin_visib;
-
-
-
+  G4int RichTbGasQuWin_visib;
 
   G4int RichTbHpdQW_visib;
   G4int RichTbHpdPHC_visib;
   G4int RichTbHpdSID_visib;
   G4int RichTbHpdENV_visib;
-  G4int RichTbHpdENVCAP_visib ;
+  G4int RichTbHpdENVCAP_visib;
   G4int RichTbHpdSM_visib;
   G4int RichTbHpdMas_visib;
   G4int RichTbHpdSiPix_visib;
 
-
-
   G4int GasTypeCode;
 
   G4double NitrogenPressure;
@@ -514,14 +330,12 @@ class RichTbRunConfig {
   G4double mHpdpeBackScaProb;
   G4long mRandomSeedInput;
 
-
-
-  G4int  RichTbNumPartEvent;
-  G4int  RichTbParticleTypeCode;
-  G4int  RichTbParticleStartPosCode;
-  G4int  RichTbParticleDirectionCode;
-  G4int  RichTbParticleEnergyCode;
-  G4double  RichTbParticleMomentum;
+  G4int RichTbNumPartEvent;
+  G4int RichTbParticleTypeCode;
+  G4int RichTbParticleStartPosCode;
+  G4int RichTbParticleDirectionCode;
+  G4int RichTbParticleEnergyCode;
+  G4double RichTbParticleMomentum;
   G4double PosBeamFraction;
   G4double mBeamDirX;
   G4double mBeamDirY;
@@ -551,13 +365,12 @@ class RichTbRunConfig {
   G4String OutputHistoFileName;
   G4String OutputNtupleFileName;
 
-  G4int mVerboseInfoFlag ;
+  G4int mVerboseInfoFlag;
   G4int mBatchModeFlag;
   G4int mNumEventInBatchMode;
   G4int mVerboseOutputFileFlag;
   G4int mPMTSiReflFlag;
 
-
   G4double mConstPhotWlenBeam;
   G4double mPhotWlenMinBeam;
   G4double mPhotWlenMaxBeam;
@@ -580,10 +393,11 @@ class RichTbRunConfig {
   G4double mPhSupFrameAdditionalZRot;
   G4double mPhSupFrameAdditionalVertTilt;
   G4double mMapmtDetectionEfficiency;
-  G4int mMapmtPixelEfficiencyFlag; // 1 means the optimized pixel efficiency applied.The overall detection efficiency not applied.
-                                  //  2 means the threshold7 pixel efficiency applied. The  overall detection efficiency not applied.
-                                 // 0 means the pixel efficiency not applied. The overall detectione efficiency applied.
-
+  G4int mMapmtPixelEfficiencyFlag; // 1 means the optimized pixel efficiency applied.The overall detection efficiency
+                                   // not applied.
+                                   //  2 means the threshold7 pixel efficiency applied. The  overall detection
+                                   //  efficiency not applied.
+  // 0 means the pixel efficiency not applied. The overall detectione efficiency applied.
 
   G4String mMapmtPixelOptEffFileNameJura;
   G4String mMapmtPixelThr7EffFileNameJura;
@@ -595,10 +409,5 @@ class RichTbRunConfig {
   G4String mMapmtPixelEffFileNameJuraBottom100;
   G4String mMapmtPixelEffFileNameSaleveTop100;
   G4String mMapmtPixelEffFileNameSaleveBottom100;
-
-
-
-
-
 };
-#endif                          /*RichTbRunConfig_h */
+#endif /*RichTbRunConfig_h */
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbStackingAction.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbStackingAction.hh
index fd76e3340b4dea7856e372a247f6b039a249f6e4..5e73062c8571a2a1a30b54cda19408d4ea75b3d2 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbStackingAction.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbStackingAction.hh
@@ -2,15 +2,14 @@
 #define RichTbStackingAction_h 1
 
 #include "Geant4/G4UserStackingAction.hh"
-class RichTbStackingAction:public G4UserStackingAction {
+class RichTbStackingAction : public G4UserStackingAction {
 
-  public:
-    RichTbStackingAction();
-    virtual ~ RichTbStackingAction();
-    void NewStage() {;
-    } void PrepareNewEvent() {;
-    }
+public:
+  RichTbStackingAction();
+  virtual ~RichTbStackingAction();
+  void NewStage() override { ; }
+  void PrepareNewEvent() override { ; }
 
-  private:
+private:
 };
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSteppingAction.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSteppingAction.hh
index 8bac7df908de42760c13a892b159c804bed8460b..007b340cec51c653fbfa609375230c5fc9e1a68b 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSteppingAction.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSteppingAction.hh
@@ -7,35 +7,32 @@
 #include "Geant4/G4ParticleChange.hh"
 #include "RichTbMiscNames.hh"
 
-class RichTbSteppingAction:public G4UserSteppingAction {
-
-  public:
-    RichTbSteppingAction();
-    virtual ~ RichTbSteppingAction();
-    void UserSteppingAction(const G4Step * aStep);
-    void RichTbGenericHisto(const G4Step * aStep);
-    void RichTbDebugHisto(const G4Step * aStep);
-    void RichTbPMTIncidenceStep(const G4Step * aStep);
-    void RichTbAgelIncidenceStep(const G4Step * aStep);
-    void RichTbRadiatorLensBoundaryIncidenceStep(const G4Step * aStep);
-
+class RichTbSteppingAction : public G4UserSteppingAction {
+
+public:
+  RichTbSteppingAction();
+  virtual ~RichTbSteppingAction();
+  void UserSteppingAction(const G4Step *aStep) override;
+  void RichTbGenericHisto(const G4Step *aStep);
+  void RichTbDebugHisto(const G4Step *aStep);
+  void RichTbPMTIncidenceStep(const G4Step *aStep);
+  void RichTbAgelIncidenceStep(const G4Step *aStep);
+  void RichTbRadiatorLensBoundaryIncidenceStep(const G4Step *aStep);
 
   //    G4double getPMTPhElectronKE() {
   //      return PMTPhElectronKE;
   //  }
 
-  private:
+private:
   //    G4double PMTPhElectronKE;
   // G4VParticleChange *uParticleChange;
 
-    double RichTbRadiatorXNegExtreme_;
-    double RichTbRadiatorXPosExtreme_;
-    double RichTbRadiatorYNegExtreme_;
-    double RichTbRadiatorYPosExtreme_;
-    double RichTbRadiatorZNegExtreme_;
-    double RichTbRadiatorZPosExtreme_;
-    double RichTbRadiatorDnsZLocation_;
-
-
+  double RichTbRadiatorXNegExtreme_;
+  double RichTbRadiatorXPosExtreme_;
+  double RichTbRadiatorYNegExtreme_;
+  double RichTbRadiatorYPosExtreme_;
+  double RichTbRadiatorZNegExtreme_;
+  double RichTbRadiatorZPosExtreme_;
+  double RichTbRadiatorDnsZLocation_;
 };
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSteppingActionBase.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSteppingActionBase.hh
index be99794541235d2452d4116b7ac7bb3466e65363..b6ffc14a05a6913036c0eadcfb5f05276817369a 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSteppingActionBase.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSteppingActionBase.hh
@@ -1,4 +1,4 @@
-#ifndef INCLUDE_RICHTBSTEPPINGACTIONBASE_HH 
+#ifndef INCLUDE_RICHTBSTEPPINGACTIONBASE_HH
 #define INCLUDE_RICHTBSTEPPINGACTIONBASE_HH 1
 
 // Include files
@@ -12,27 +12,23 @@
 #include "RichTbPmtSteppingAction.hh"
 
 /** @class RichTbSteppingActionBase RichTbSteppingActionBase.hh include/RichTbSteppingActionBase.hh
- *  
+ *
  *
  *  @author Sajan Easo
  *  @date   2015-03-06
  */
-class RichTbSteppingActionBase:public G4UserSteppingAction {
-public: 
+class RichTbSteppingActionBase : public G4UserSteppingAction {
+public:
   /// Standard constructor
-  RichTbSteppingActionBase( ); 
+  RichTbSteppingActionBase();
 
-  virtual ~RichTbSteppingActionBase( ); ///< Destructor
-  void UserSteppingAction(const G4Step * aStep);
+  virtual ~RichTbSteppingActionBase(); ///< Destructor
+  void UserSteppingAction(const G4Step *aStep) override;
   void InitRichTbStepActions();
-  
-protected:
 
+protected:
 private:
-
-  RichTbSteppingAction* mRichTbSteppingAction;
-  RichTbPmtSteppingAction* mRichTbPmtSteppingAction;
-  
-
+  RichTbSteppingAction *mRichTbSteppingAction;
+  RichTbPmtSteppingAction *mRichTbPmtSteppingAction;
 };
 #endif // INCLUDE_RICHTBSTEPPINGACTIONBASE_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSurface.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSurface.hh
index 560ac88f1a1d51d46df94694bced95e36dbad5f8..20655d8287dc37424d9648617b2becb8ca66f7de 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSurface.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSurface.hh
@@ -1,13 +1,12 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBSURFACE_HH 
+#ifndef INCLUDE_RICHTBSURFACE_HH
 #define INCLUDE_RICHTBSURFACE_HH 1
 
 // Include files
 #include "RichTbSurfaceDefinition.hh"
 
-
 /** @class RichTbSurface RichTbSurface.hh include/RichTbSurface.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-11-25
@@ -17,22 +16,16 @@ class RichTbDetectorConstruction;
 class RichTbSurface {
 public:
   /// Standard constructor
-  RichTbSurface(RichTbDetectorConstruction*  ); 
+  RichTbSurface(RichTbDetectorConstruction *);
 
-  virtual ~RichTbSurface( ); ///< Destructor
+  virtual ~RichTbSurface(); ///< Destructor
 
-  RichTbDetectorConstruction* getcurDet()
-  {    return curDet; }
+  RichTbDetectorConstruction *getcurDet() { return curDet; }
 
   void createBorderSurfaces();
-  
-    
-protected:
 
+protected:
 private:
-
-  RichTbDetectorConstruction* curDet;
-  
-
+  RichTbDetectorConstruction *curDet;
 };
 #endif // INCLUDE_RICHTBSURFACE_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSurfaceDefinition.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSurfaceDefinition.hh
index 5364350cdd8d13d05eb9323681f34ff6f532e3bd..16f0789ba4eca31a15a55b5995a4f1248c08c9a0 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSurfaceDefinition.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSurfaceDefinition.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBSURFACEDEFINITION_HH 
+#ifndef INCLUDE_RICHTBSURFACEDEFINITION_HH
 #define INCLUDE_RICHTBSURFACEDEFINITION_HH 1
 
 // Include files
@@ -12,39 +12,23 @@
 #include <vector>
 
 /** @class RichTbSurfaceDefinition RichTbSurfaceDefinition.hh include/RichTbSurfaceDefinition.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-11-24
  */
 class RichTbSurfaceDefinition {
 public:
+  virtual ~RichTbSurfaceDefinition(); ///< Destructor
 
-  virtual ~RichTbSurfaceDefinition( ); ///< Destructor
-
-  static RichTbSurfaceDefinition* getRichTbSurfaceDefinitionInstance();
-  
+  static RichTbSurfaceDefinition *getRichTbSurfaceDefinitionInstance();
 
-  G4OpticalSurface* getRichTbSphMirrorSurface() 
-  {
-    return  RichTbSphMirrorSurface;
-  }
-  G4OpticalSurface* getRichTbVesselSurface()
-  {
-    return RichTbVesselSurface;
-  }
-  G4OpticalSurface* getRichTbPMTMasterQuartzWSurface()
-  {
-    return RichTbPMTMasterQuartzWSurface;
-  }
-  G4OpticalSurface* getRichTbPMTQuartzWPhCathodeSurface()
-  {
-    return RichTbPMTQuartzWPhCathodeSurface;
-  }
-  G4OpticalSurface* getRichTbKovarSurface() {
-    return RichTbKovarSurface;}
-  G4OpticalSurface* getRichTbSiDetSurface() {
-    return RichTbSiDetSurface;}
+  G4OpticalSurface *getRichTbSphMirrorSurface() { return RichTbSphMirrorSurface; }
+  G4OpticalSurface *getRichTbVesselSurface() { return RichTbVesselSurface; }
+  G4OpticalSurface *getRichTbPMTMasterQuartzWSurface() { return RichTbPMTMasterQuartzWSurface; }
+  G4OpticalSurface *getRichTbPMTQuartzWPhCathodeSurface() { return RichTbPMTQuartzWPhCathodeSurface; }
+  G4OpticalSurface *getRichTbKovarSurface() { return RichTbKovarSurface; }
+  G4OpticalSurface *getRichTbSiDetSurface() { return RichTbSiDetSurface; }
 
   void createMirrorOpticalSurface();
   void createVesselSurface();
@@ -53,24 +37,21 @@ public:
   void ReadMirrorReflectivity();
   void createRichTbKovarSurface();
   void createtRichTbSiDetSurface();
-  
-protected:
 
+protected:
 private:
-
   /// Standard constructor
-  RichTbSurfaceDefinition( ); 
+  RichTbSurfaceDefinition();
+
+  static RichTbSurfaceDefinition *RichTbSurfaceDefinitionInstance;
 
-  static  RichTbSurfaceDefinition*  RichTbSurfaceDefinitionInstance;
-  
-  G4OpticalSurface* RichTbSphMirrorSurface;
-  G4OpticalSurface* RichTbVesselSurface;
-  G4OpticalSurface* RichTbPMTMasterQuartzWSurface;
-  G4OpticalSurface* RichTbPMTQuartzWPhCathodeSurface;
-  G4OpticalSurface* RichTbKovarSurface;
-  G4OpticalSurface* RichTbSiDetSurface;  
+  G4OpticalSurface *RichTbSphMirrorSurface;
+  G4OpticalSurface *RichTbVesselSurface;
+  G4OpticalSurface *RichTbPMTMasterQuartzWSurface;
+  G4OpticalSurface *RichTbPMTQuartzWPhCathodeSurface;
+  G4OpticalSurface *RichTbKovarSurface;
+  G4OpticalSurface *RichTbSiDetSurface;
   std::vector<G4double> MirrorSurfWlen;
   std::vector<G4double> MirrorSurfReflect;
-
 };
 #endif // INCLUDE_RICHTBSURFACEDEFINITION_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSurfaceParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSurfaceParameters.hh
index 49c3ca5f0aadbdc9c8a7083cb8ebbe0fc3371739..b75e56916e3d0cae5d417469e9da86d303568e77 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSurfaceParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbSurfaceParameters.hh
@@ -1,22 +1,19 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBSURFACEPARAMETERS_HH 
+#ifndef INCLUDE_RICHTBSURFACEPARAMETERS_HH
 #define INCLUDE_RICHTBSURFACEPARAMETERS_HH 1
 
 // Include files
 
-
-
-static G4int NumPhotMirrorReflectBins=403;
+static G4int NumPhotMirrorReflectBins = 403;
 
 // in the above 401 is from the file and 2 bins added at the ends.
 // depending upon the wavelength range of measurements.
-// this is redefined while reading the file. 
-
+// this is redefined while reading the file.
 
-const G4double PhotonMirrReflWavelengthUnits= 1.0*CLHEP::nanometer;
+const G4double PhotonMirrReflWavelengthUnits = 1.0 * CLHEP::nanometer;
 // for testbem in 2004 a file is read with mirror reflectivity values.
 
-//const G4double  PhotonWavelengthMirrRefl[] =
+// const G4double  PhotonWavelengthMirrRefl[] =
 //
 //
 //  {140.0,145.0,150.0,155.0,160.0,165.0,170.0,
@@ -28,7 +25,7 @@ const G4double PhotonMirrReflWavelengthUnits= 1.0*CLHEP::nanometer;
 //   350.0,355.0,360.0,400.0,900.0,1000.0,1200.0
 //  };
 //
-//const G4double MirrorReflectivity[]=
+// const G4double MirrorReflectivity[]=
 //  {51.34108,53.09734,50.90585,49.3188,66.75388,
 //   68.24143,70.30895,72.34739,73.85167,75.23763,
 //   77.33105,79.52776,81.00301,82.8635,84.10011,
@@ -41,7 +38,4 @@ const G4double PhotonMirrReflWavelengthUnits= 1.0*CLHEP::nanometer;
 //   86.36691,86.36691,86.36691,86.36691
 //  };
 
-
-
-   
 #endif // INCLUDE_RICHTBSURFACEPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbTrackingAction.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbTrackingAction.hh
index 80778a94298fc9753ff96df60f4ff109102de089..978f4bbf2e2c9d5f67350e1f3985df1c3f1fe8e9 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbTrackingAction.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbTrackingAction.hh
@@ -4,16 +4,15 @@
 #include "Geant4/G4UserTrackingAction.hh"
 #include "Geant4/G4Track.hh"
 
-class RichTbTrackingAction:public G4UserTrackingAction {
+class RichTbTrackingAction : public G4UserTrackingAction {
 
-  public:
-    RichTbTrackingAction();
-    virtual ~ RichTbTrackingAction();
-  void PreUserTrackingAction(const G4Track * aTrack);
-  
-  void PostUserTrackingAction(const G4Track * aTrack);
-  
+public:
+  RichTbTrackingAction();
+  virtual ~RichTbTrackingAction();
+  void PreUserTrackingAction(const G4Track *aTrack) override;
 
-  private:
+  void PostUserTrackingAction(const G4Track *aTrack) override;
+
+private:
 };
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeCrystal.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeCrystal.hh
index cde071d709e9807e756ea0df495a56b08f0f8818..ce22f732d5c1938008a4ca03ee00998a3bfe2f64 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeCrystal.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeCrystal.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBUPGRADECRYSTAL_HH 
+#ifndef INCLUDE_RICHTBUPGRADECRYSTAL_HH
 #define INCLUDE_RICHTBUPGRADECRYSTAL_HH 1
 
 // Include files
@@ -12,7 +12,7 @@
 #include "RichTbUpgradeCrystalMaster.hh"
 
 /** @class RichTbVessel RichTbVessel.hh include/RichTbVessel.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-11-05
@@ -20,49 +20,28 @@
 class RichTbCrystal {
 public:
   /// Standard constructor
-  RichTbCrystal(RichTbUpgradeCrystalMaster* rTbCrystalMaster ); 
+  RichTbCrystal(RichTbUpgradeCrystalMaster *rTbCrystalMaster);
 
-  virtual ~RichTbCrystal( ); ///< Destructor
+  virtual ~RichTbCrystal(); ///< Destructor
 
-  void  constructRichTbCrystal();
-  void  constructRichTbCrystalEnvelope();
-  
-  G4LogicalVolume* getRichTbCrystalLVol() 
-  {
-    return RichTbCrystalLVol;
-  }
-  G4LogicalVolume* getRichTbCrystalEnvelopeBottomLVol()
-  {
-    return RichTbCrystalEnvelopeBottomLVol;
-    
-  }
+  void constructRichTbCrystal();
+  void constructRichTbCrystalEnvelope();
 
-  G4VPhysicalVolume* getRichTbCrystalPVol() 
-  {
-    return RichTbCrystalPVol;
-  }
-  G4VPhysicalVolume* getRichTbCrystalEnvelopeBottomPVol()
-  {
-    return RichTbCrystalEnvelopeBottomPVol;
-  }
-  RichTbUpgradeCrystalMaster* getaRTbCrystalMaster() 
-  { 
-    return aRTbCrystalMaster;
-  
-  }
-  
-protected:
+  G4LogicalVolume *getRichTbCrystalLVol() { return RichTbCrystalLVol; }
+  G4LogicalVolume *getRichTbCrystalEnvelopeBottomLVol() { return RichTbCrystalEnvelopeBottomLVol; }
 
+  G4VPhysicalVolume *getRichTbCrystalPVol() { return RichTbCrystalPVol; }
+  G4VPhysicalVolume *getRichTbCrystalEnvelopeBottomPVol() { return RichTbCrystalEnvelopeBottomPVol; }
+  RichTbUpgradeCrystalMaster *getaRTbCrystalMaster() { return aRTbCrystalMaster; }
+
+protected:
 private:
-  RichTbUpgradeCrystalMaster* aRTbCrystalMaster;
-  
-  G4LogicalVolume* RichTbCrystalLVol;
-  G4LogicalVolume*  RichTbCrystalEnvelopeBottomLVol;
-  
+  RichTbUpgradeCrystalMaster *aRTbCrystalMaster;
 
-  G4VPhysicalVolume* RichTbCrystalPVol;
-  G4VPhysicalVolume* RichTbCrystalEnvelopeBottomPVol; 
+  G4LogicalVolume *RichTbCrystalLVol;
+  G4LogicalVolume *RichTbCrystalEnvelopeBottomLVol;
 
- 
+  G4VPhysicalVolume *RichTbCrystalPVol;
+  G4VPhysicalVolume *RichTbCrystalEnvelopeBottomPVol;
 };
-#endif 
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeCrystalCover.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeCrystalCover.hh
index 790d386d5d7e58c419ec8f24b63ebdeae9040929..48210ac301ab552116b10f4d348c9606a98f3229 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeCrystalCover.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeCrystalCover.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBUPGRADECRYSTALCOVER_HH 
+#ifndef INCLUDE_RICHTBUPGRADECRYSTALCOVER_HH
 #define INCLUDE_RICHTBUPGRADECRYSTALCOVER_HH 1
 
 // Include files
@@ -10,9 +10,9 @@
 #include "RichTbHall.hh"
 #include "RichTbUpgradeCrystalMaster.hh"
 
-/** @class (RichTbCrystalMaster (RichTbCrystalMaster.hh include/RichTbCrystalMaster.hh 
+/** @class (RichTbCrystalMaster (RichTbCrystalMaster.hh include/RichTbCrystalMaster.hh
 
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-11-05
@@ -20,52 +20,38 @@
 class RichTbCrystalCover {
 public:
   /// Standard constructor
-  RichTbCrystalCover(RichTbUpgradeCrystalMaster* rTbCrystalMaster ); 
+  RichTbCrystalCover(RichTbUpgradeCrystalMaster *rTbCrystalMaster);
 
-  virtual ~RichTbCrystalCover( ); ///< Destructor
+  virtual ~RichTbCrystalCover(); ///< Destructor
 
-  void  constructRichTbCrystalCover();
-  void  constructRichTbCrystalCoverEnvelope();
-  
-  G4LogicalVolume* getRichTbCrystalCoverLVol() 
-  {
-    return RichTbCrystalCoverLVol;
-  }
+  void constructRichTbCrystalCover();
+  void constructRichTbCrystalCoverEnvelope();
+
+  G4LogicalVolume *getRichTbCrystalCoverLVol() { return RichTbCrystalCoverLVol; }
   /*
  G4LogicalVolume* getRichTbCrystalCoverEnvelopeBottomLVol()
   {
     return RichTbCrystalCoverEnvelopeBottomLVol;
-    
+
   }
   */
-  G4VPhysicalVolume* getRichTbCrystalCoverPVol() 
-  {
-    return RichTbCrystalCoverPVol;
-  }
+  G4VPhysicalVolume *getRichTbCrystalCoverPVol() { return RichTbCrystalCoverPVol; }
   /*
   G4VPhysicalVolume* getRichTbCrystalCoverEnvelopeBottomPVol()
   {
     return RichTbVesselEnvelopeBottomPVol;
   }
   */
-  RichTbUpgradeCrystalMaster* getaRTbCrystalMaster() 
-  { 
-    return aRTbCrystalMaster;
-  
-  }
-  
-protected:
+  RichTbUpgradeCrystalMaster *getaRTbCrystalMaster() { return aRTbCrystalMaster; }
 
+protected:
 private:
-  RichTbUpgradeCrystalMaster* aRTbCrystalMaster;
-  
-  G4LogicalVolume* RichTbCrystalCoverLVol;
-  // G4LogicalVolume*  RichTbVesselEnvelopeBottomLVol;
-  
+  RichTbUpgradeCrystalMaster *aRTbCrystalMaster;
 
-  G4VPhysicalVolume* RichTbCrystalCoverPVol;
-  // G4VPhysicalVolume* RichTbVesselEnvelopeBottomPVol; 
+  G4LogicalVolume *RichTbCrystalCoverLVol;
+  // G4LogicalVolume*  RichTbVesselEnvelopeBottomLVol;
 
- 
+  G4VPhysicalVolume *RichTbCrystalCoverPVol;
+  // G4VPhysicalVolume* RichTbVesselEnvelopeBottomPVol;
 };
-#endif 
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeCrystalMaster.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeCrystalMaster.hh
index 7f7a4c6396191a43938a5fccf00c937d9ec47d39..2bf93f0d049dcc23f5ec36374a8a363065ab2f7f 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeCrystalMaster.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeCrystalMaster.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBUPGRADECRYSTALMASTER_HH 
+#ifndef INCLUDE_RICHTBUPGRADECRYSTALMASTER_HH
 #define INCLUDE_RICHTBUPGRADECRYSTALMASTER_HH 1
 
 // Include files
@@ -11,7 +11,7 @@
 #include "RichTbUpgradeVessel.hh"
 
 /** @class RichTbUpgradeVessel RichTbUpgradeVessel.hh include/RichTbUpgradeVessel.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-11-05
@@ -19,49 +19,32 @@
 class RichTbUpgradeCrystalMaster {
 public:
   /// Standard constructor
-  RichTbUpgradeCrystalMaster(RichTbUpgradeVessel* rTbVessel ); 
+  RichTbUpgradeCrystalMaster(RichTbUpgradeVessel *rTbVessel);
 
-  virtual ~RichTbUpgradeCrystalMaster( ); ///< Destructor
+  virtual ~RichTbUpgradeCrystalMaster(); ///< Destructor
 
-  void  constructRichTbUpgradeCrystalMaster();
-  void  constructRichTbUpgradeCrystalMasterEnvelope();
-  
-  G4LogicalVolume* getRichTbUpgradeCrystalMasterLVol() 
-  {
-    return RichTbUpgradeCrystalMasterLVol;
-  }
-  G4LogicalVolume* getRichTbUpgradeCrystalMasterEnvelopeBottomLVol()
-  {
+  void constructRichTbUpgradeCrystalMaster();
+  void constructRichTbUpgradeCrystalMasterEnvelope();
+
+  G4LogicalVolume *getRichTbUpgradeCrystalMasterLVol() { return RichTbUpgradeCrystalMasterLVol; }
+  G4LogicalVolume *getRichTbUpgradeCrystalMasterEnvelopeBottomLVol() {
     return RichTbUpgradeCrystalMasterEnvelopeBottomLVol;
-    
   }
 
-  G4VPhysicalVolume* getRichTbUpgradeCrystalMasterPVol() 
-  {
-    return RichTbUpgradeCrystalMasterPVol;
-  }
-  G4VPhysicalVolume* getRichTbUpgradeCrystalMasterEnvelopeBottomPVol()
-  {
+  G4VPhysicalVolume *getRichTbUpgradeCrystalMasterPVol() { return RichTbUpgradeCrystalMasterPVol; }
+  G4VPhysicalVolume *getRichTbUpgradeCrystalMasterEnvelopeBottomPVol() {
     return RichTbUpgradeCrystalMasterEnvelopeBottomPVol;
   }
-  RichTbUpgradeVessel* getaRTbVessel() 
-  { 
-    return aRTbVessel;
-  
-  }
-  
-protected:
+  RichTbUpgradeVessel *getaRTbVessel() { return aRTbVessel; }
 
+protected:
 private:
-  RichTbUpgradeVessel * aRTbVessel;
-  
-  G4LogicalVolume* RichTbUpgradeCrystalMasterLVol;
-  G4LogicalVolume*  RichTbUpgradeCrystalMasterEnvelopeBottomLVol;
-  
+  RichTbUpgradeVessel *aRTbVessel;
 
-  G4VPhysicalVolume* RichTbUpgradeCrystalMasterPVol;
-  G4VPhysicalVolume* RichTbUpgradeCrystalMasterEnvelopeBottomPVol; 
+  G4LogicalVolume *RichTbUpgradeCrystalMasterLVol;
+  G4LogicalVolume *RichTbUpgradeCrystalMasterEnvelopeBottomLVol;
 
- 
+  G4VPhysicalVolume *RichTbUpgradeCrystalMasterPVol;
+  G4VPhysicalVolume *RichTbUpgradeCrystalMasterEnvelopeBottomPVol;
 };
-#endif 
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeDarkCover.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeDarkCover.hh
index 31df7c33e3024c0d965da5752652f8ad5e7b55bf..3ccba7d8a9e38a34ea251fe109b58c06dad0513d 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeDarkCover.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeDarkCover.hh
@@ -20,67 +20,43 @@
 class RichTbUpgradeDarkCover {
 public:
   /// Standard constructor
-  RichTbUpgradeDarkCover(RichTbUpgradeRadiator* rTbRadiator );
+  RichTbUpgradeDarkCover(RichTbUpgradeRadiator *rTbRadiator);
 
-  virtual ~RichTbUpgradeDarkCover( ); ///< Destructor
+  virtual ~RichTbUpgradeDarkCover(); ///< Destructor
 
-  void  constructRichTbUpgradeDarkCover();
-  void  constructRichTbUpgradeUpsDarkCoverEnvelope(RichTbUpgradeCrystalMaster* aMaster);
-  void  constructRichTbUpgradeSideDarkCoverEnvelope(RichTbUpgradeCrystalMaster* aMasterC);
+  void constructRichTbUpgradeDarkCover();
+  void constructRichTbUpgradeUpsDarkCoverEnvelope(RichTbUpgradeCrystalMaster *aMaster);
+  void constructRichTbUpgradeSideDarkCoverEnvelope(RichTbUpgradeCrystalMaster *aMasterC);
 
-  //testbeam 2015 upgrade
-  void  constructRichTbUpgradeDarkCover15();
-  void  constructRichTbUpgradeUpsDarkCoverEnvelope15(RichTbUpgradeCrystalMaster* aMaster);
-  void  constructRichTbUpgradeSideDarkCoverEnvelope15(RichTbUpgradeCrystalMaster* aMasterC);
+  // testbeam 2015 upgrade
+  void constructRichTbUpgradeDarkCover15();
+  void constructRichTbUpgradeUpsDarkCoverEnvelope15(RichTbUpgradeCrystalMaster *aMaster);
+  void constructRichTbUpgradeSideDarkCoverEnvelope15(RichTbUpgradeCrystalMaster *aMasterC);
 
-  G4LogicalVolume* getRichTbUpgradeDarkCoverLVol()
-  {
-    return RichTbUpgradeDarkCoverLVol;
-  }
-  G4LogicalVolume* getRichTbUpgradeDarkCoverEnvelopeBottomLVol()
-  {
-    return RichTbUpgradeDarkCoverEnvelopeBottomLVol;
+  G4LogicalVolume *getRichTbUpgradeDarkCoverLVol() { return RichTbUpgradeDarkCoverLVol; }
+  G4LogicalVolume *getRichTbUpgradeDarkCoverEnvelopeBottomLVol() { return RichTbUpgradeDarkCoverEnvelopeBottomLVol; }
 
-  }
-
-  G4VPhysicalVolume* getRichTbUpgradeDarkCoverPVol()
-  {
-    return RichTbUpgradeDarkCoverPVol;
-  }
-  G4VPhysicalVolume* getRichTbUpgradeDarkCoverEnvelopeBottomPVol()
-  {
-    return RichTbUpgradeDarkCoverEnvelopeBottomPVol;
-  }
-  RichTbUpgradeRadiator* getaRTbUpgradeRadiator()
-  {
-    return aRTbUpgradeRadiator;
-  }
-
-  G4LogicalVolume* getRichTbUpgradeUpsDarkCoverLVol()
-  {  return RichTbUpgradeUpsDarkCoverLVol; }
-
-  G4LogicalVolume* getRichTbUpgradeSideDarkCoverLVol()
-  {   return RichTbUpgradeSideDarkCoverLVol ;}
+  G4VPhysicalVolume *getRichTbUpgradeDarkCoverPVol() { return RichTbUpgradeDarkCoverPVol; }
+  G4VPhysicalVolume *getRichTbUpgradeDarkCoverEnvelopeBottomPVol() { return RichTbUpgradeDarkCoverEnvelopeBottomPVol; }
+  RichTbUpgradeRadiator *getaRTbUpgradeRadiator() { return aRTbUpgradeRadiator; }
 
+  G4LogicalVolume *getRichTbUpgradeUpsDarkCoverLVol() { return RichTbUpgradeUpsDarkCoverLVol; }
 
+  G4LogicalVolume *getRichTbUpgradeSideDarkCoverLVol() { return RichTbUpgradeSideDarkCoverLVol; }
 
 protected:
-
 private:
-  RichTbUpgradeRadiator* aRTbUpgradeRadiator;
-
-  G4LogicalVolume* RichTbUpgradeDarkCoverLVol;
-  G4LogicalVolume*  RichTbUpgradeUpsDarkCoverLVol;
-  G4LogicalVolume* RichTbUpgradeDarkCoverEnvelopeBottomLVol;
-  G4LogicalVolume*  RichTbUpgradeSideDarkCoverLVol;
-
-
-  G4VPhysicalVolume* RichTbUpgradeDarkCoverPVol;
-  G4VPhysicalVolume* RichTbUpgradeUpsDarkCoverPVol;
-  G4VPhysicalVolume* RichTbUpgradeDarkCoverEnvelopeBottomPVol;
-  G4VPhysicalVolume* RichTbUpgradeSideTopDarkCoverPVol;
-  G4VPhysicalVolume* RichTbUpgradeSideBotDarkCoverPVol;
-
-
+  RichTbUpgradeRadiator *aRTbUpgradeRadiator;
+
+  G4LogicalVolume *RichTbUpgradeDarkCoverLVol;
+  G4LogicalVolume *RichTbUpgradeUpsDarkCoverLVol;
+  G4LogicalVolume *RichTbUpgradeDarkCoverEnvelopeBottomLVol;
+  G4LogicalVolume *RichTbUpgradeSideDarkCoverLVol;
+
+  G4VPhysicalVolume *RichTbUpgradeDarkCoverPVol;
+  G4VPhysicalVolume *RichTbUpgradeUpsDarkCoverPVol;
+  G4VPhysicalVolume *RichTbUpgradeDarkCoverEnvelopeBottomPVol;
+  G4VPhysicalVolume *RichTbUpgradeSideTopDarkCoverPVol;
+  G4VPhysicalVolume *RichTbUpgradeSideBotDarkCoverPVol;
 };
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeDetectorConstruction.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeDetectorConstruction.hh
index 4acbd1d3d50e9f3e88b6f2ca23d2e79addd41efe..03b534521972af38f958142c35a8dab0236977aa 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeDetectorConstruction.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeDetectorConstruction.hh
@@ -1,5 +1,5 @@
-//This is the definition of the LHCb RICH Testbeam Detector Construction
-//Author SE  1-3-2001
+// This is the definition of the LHCb RICH Testbeam Detector Construction
+// Author SE  1-3-2001
 //
 #ifndef RichTbUpgradeDetectorConstruction_h
 #define RichTbUpgradeDetectorConstruction_h 1
@@ -35,122 +35,76 @@
 
 #include "RichTbGraphics.hh"
 
-class RichTbDetectorConstruction:public G4VUserDetectorConstruction {
+class RichTbDetectorConstruction : public G4VUserDetectorConstruction {
 
-  public:
-    RichTbDetectorConstruction();
-    virtual ~ RichTbDetectorConstruction();
-    G4VPhysicalVolume *Construct();
+public:
+  RichTbDetectorConstruction();
+  virtual ~RichTbDetectorConstruction();
+  G4VPhysicalVolume *Construct() override;
 
-    RichTbHall *getRichTbHall() {
-        return rTbHall;
-    }
-  RichTbUpgradeVessel* getRichTbUpgradeVessel() 
-  {
-    return  rTbVessel;
-  }
+  RichTbHall *getRichTbHall() { return rTbHall; }
+  RichTbUpgradeVessel *getRichTbUpgradeVessel() { return rTbVessel; }
 
   /*
-  RichTbMaster* getRichTbMaster1() 
+  RichTbMaster* getRichTbMaster1()
   {
     return  rTbMaster1;
   }
-  RichTbMaster* getRichTbMaster2() 
+  RichTbMaster* getRichTbMaster2()
   {
     return  rTbMaster2;
   }
-  RichTbMaster* getRichTbMaster3() 
+  RichTbMaster* getRichTbMaster3()
   {
     return  rTbMaster3;
   }
-  RichTbMaster* getRichTbMaster4() 
+  RichTbMaster* getRichTbMaster4()
   {
     return  rTbMaster4;
   }
 
   */
 
+  RichTbLens *getRichTbLens() { return rTbLens; }
+  RichTbCrystal *getRichTbCrystal() { return rTbCrystal; }
+  RichTbUpgradeRadiator *getRichTbUpgradeRadiator() { return rTbUpgradeRadiator; }
 
-  RichTbLens* getRichTbLens() 
-  {
-    return  rTbLens;
-  }
-  RichTbCrystal* getRichTbCrystal() 
-  {
-    return  rTbCrystal;
-  }
- RichTbUpgradeRadiator* getRichTbUpgradeRadiator() 
-  {
-    return  rTbUpgradeRadiator;
-  }
+  RichTbUpgradeCrystalMaster *getRichTbUpgradeCrystalMaster() { return rTbCrystalMaster; }
+  RichTbCrystalCover *getRichTbCrystalCover() { return rTbCrystalCover; }
 
- RichTbUpgradeCrystalMaster* getRichTbUpgradeCrystalMaster() 
-  {
-    return  rTbCrystalMaster;
-  }
-  RichTbCrystalCover* getRichTbCrystalCover() 
-  {
-    return  rTbCrystalCover;
-  }
+  RichTbUpgradeDarkCover *getRichTbUpgradeDarkCover() { return rTbUpgradeDarkCover; }
 
- RichTbUpgradeDarkCover* getRichTbUpgradeDarkCover() 
-  {
-    return  rTbUpgradeDarkCover;
-  }
+  RichTbPhDFrame *getRichTbPhDFrame() { return rTbPhDFrame; }
 
-  RichTbPhDFrame* getRichTbPhDFrame() 
-  {
-    return  rTbPhDFrame;
-  }
+  RichTbPMT *getRichTbPMT() { return rTbPMT; }
 
- RichTbPMT* getRichTbPMT() 
-  {
-    return  rTbPMT;
-  }
+  RichTbUpgradeMirror *getRichTbUpgradeMirror() { return rTbUpgradeMirror; }
 
+  RichTbUpgradePhDetSupFrame *getRichTbUpgradePhDetSupFrame() { return rTbUpgradePhotSupFrame; }
 
-  RichTbUpgradeMirror* getRichTbUpgradeMirror() 
-  {
-    return rTbUpgradeMirror;
-    
-  }
- 
-  RichTbUpgradePhDetSupFrame* getRichTbUpgradePhDetSupFrame() 
-  {  return   rTbUpgradePhotSupFrame;  }
-  
-  RichTbUpgradeEC* getRichTbEC() 
-  {
-    return rTbEC;
-  }
-  
+  RichTbUpgradeEC *getRichTbEC() { return rTbEC; }
 
-  /*  
-  RichTbPhDetSupFrame* getRichTbPhDetSupFrame() 
+  /*
+  RichTbPhDetSupFrame* getRichTbPhDetSupFrame()
   {
     return  rTbPhotSupFrame;
   }
   */
-  RichTbSurface* getRichTbSurface() 
-  {
-    return rTbSurface;
-  }
-  
-   RichTbROGeometry *getROGeometry() { return rTbROGeom;}
-  RichTbROGeometryHpd *getROGeometryHpd( ){return rTbROGeomHpd;}
-  
-       
-   /* RichTbSD* getRichTbSD()
-  { return  PMTSD;
-  }
-  */
+  RichTbSurface *getRichTbSurface() { return rTbSurface; }
+
+  RichTbROGeometry *getROGeometry() { return rTbROGeom; }
+  RichTbROGeometryHpd *getROGeometryHpd() { return rTbROGeomHpd; }
+
+  /* RichTbSD* getRichTbSD()
+ { return  PMTSD;
+ }
+ */
 
-  RichTbHpd* getRichTbHpd() {return  rTbHpd; }
-  
- 
-  private:
+  RichTbHpd *getRichTbHpd() { return rTbHpd; }
 
+private:
   RichTbHall *rTbHall;
-  RichTbUpgradeVessel* rTbVessel;
+  RichTbUpgradeVessel *rTbVessel;
   /*
   RichTbMaster* rTbMaster1;
   RichTbMaster* rTbMaster2;
@@ -158,34 +112,30 @@ class RichTbDetectorConstruction:public G4VUserDetectorConstruction {
   RichTbMaster* rTbMaster4;
   */
 
-  RichTbCrystal* rTbCrystal;
-  RichTbUpgradeRadiator* rTbUpgradeRadiator;
-  RichTbUpgradeCrystalMaster* rTbCrystalMaster;
-  RichTbCrystalCover* rTbCrystalCover;
-  RichTbUpgradeDarkCover* rTbUpgradeDarkCover;
-  RichTbPhDFrame* rTbPhDFrame;
-  RichTbPMT* rTbPMT;
-  RichTbUpgradeMirror* rTbUpgradeMirror;
-  RichTbLens* rTbLens;
- 
+  RichTbCrystal *rTbCrystal;
+  RichTbUpgradeRadiator *rTbUpgradeRadiator;
+  RichTbUpgradeCrystalMaster *rTbCrystalMaster;
+  RichTbCrystalCover *rTbCrystalCover;
+  RichTbUpgradeDarkCover *rTbUpgradeDarkCover;
+  RichTbPhDFrame *rTbPhDFrame;
+  RichTbPMT *rTbPMT;
+  RichTbUpgradeMirror *rTbUpgradeMirror;
+  RichTbLens *rTbLens;
 
   // RichTbGraphics* rTbGraphics ;
-  
-  // RichTbPhDetSupFrame* rTbPhotSupFrame;
 
-  RichTbUpgradePhDetSupFrame* rTbUpgradePhotSupFrame;
-  RichTbUpgradeEC* rTbEC;
-  RichTbHpd* rTbHpd;
-  
+  // RichTbPhDetSupFrame* rTbPhotSupFrame;
 
+  RichTbUpgradePhDetSupFrame *rTbUpgradePhotSupFrame;
+  RichTbUpgradeEC *rTbEC;
+  RichTbHpd *rTbHpd;
 
-  RichTbSurface* rTbSurface;
+  RichTbSurface *rTbSurface;
 
   // RichTbSD* PMTSD;
-  
+
   RichTbROGeometry *rTbROGeom;
   RichTbROGeometryHpd *rTbROGeomHpd;
-
 };
 
-#endif                          /*RichTbDetectorConstruction_h */
+#endif /*RichTbDetectorConstruction_h */
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeEC.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeEC.hh
index 1e41ca400e694164f8b236064cf2ab66d14f323d..eee1ffccbed8bb161d4249cfdd6e69eb236f34aa 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeEC.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeEC.hh
@@ -8,7 +8,6 @@
 #include "Geant4/G4LogicalVolume.hh"
 #include "RichTbUpgradePhDetSupFrame.hh"
 
-
 /** @class RichTbUpgradeEC RichTbUpgradeEC.hh include/RichTbUpgradeEC.hh
  *
  *
@@ -18,66 +17,50 @@
 class RichTbUpgradeEC {
 public:
   /// Standard constructor
-  RichTbUpgradeEC( RichTbUpgradePhDetSupFrame * rTbPhotSupFrame  );
+  RichTbUpgradeEC(RichTbUpgradePhDetSupFrame *rTbPhotSupFrame);
 
-  virtual ~RichTbUpgradeEC( ); ///< Destructor
+  virtual ~RichTbUpgradeEC(); ///< Destructor
   void constructRichTbUpgradeEC();
-  void constructRichTbUpgradeECSupport ();
-  void constructRichTbUpgradeSingleEC ();
-  void constructRichTbUpgradeSingleECSupport ();
+  void constructRichTbUpgradeECSupport();
+  void constructRichTbUpgradeSingleEC();
+  void constructRichTbUpgradeSingleECSupport();
   void constructRichTbUpgradeEC15();
   void constructRichTbUpgradeECSupport15();
 
+  G4LogicalVolume *getRichTbECLeftLVol() { return RichTbECLeftLVol; }
+  G4LogicalVolume *getRichTbECRightLVol() { return RichTbECRightLVol; }
+  G4VPhysicalVolume *getRichTbECLeftPVol() { return RichTbECLeftPVol; }
+  G4VPhysicalVolume *getRichTbECRightPVol() { return RichTbECRightPVol; }
 
+  // Upgrade 2015
+  G4LogicalVolume *getRichTbECBottomLeftLVol() { return RichTbECBottomLeftLVol; }
+  G4LogicalVolume *getRichTbECBottomRightLVol() { return RichTbECBottomRightLVol; }
+  G4VPhysicalVolume *getRichTbECBottomLeftPVol() { return RichTbECBottomLeftPVol; }
+  G4VPhysicalVolume *getRichTbECBottomRightPVol() { return RichTbECBottomRightPVol; }
 
-  G4LogicalVolume* getRichTbECLeftLVol()
-  {  return RichTbECLeftLVol; }
-  G4LogicalVolume* getRichTbECRightLVol()
-  {  return  RichTbECRightLVol;}
-  G4VPhysicalVolume* getRichTbECLeftPVol()
-  {  return RichTbECLeftPVol;}
-  G4VPhysicalVolume* getRichTbECRightPVol()
-  {  return RichTbECRightPVol;}
-
-  //Upgrade 2015
-  G4LogicalVolume* getRichTbECBottomLeftLVol()
-  {  return RichTbECBottomLeftLVol; }
-  G4LogicalVolume* getRichTbECBottomRightLVol()
-  {  return  RichTbECBottomRightLVol;}
-  G4VPhysicalVolume* getRichTbECBottomLeftPVol()
-  {  return RichTbECBottomLeftPVol;}
-  G4VPhysicalVolume* getRichTbECBottomRightPVol()
-  {  return RichTbECBottomRightPVol;}
-
-  RichTbUpgradePhDetSupFrame * getRTbPhotSupFrame()
-  {  return aRTbPhotSupFrame;}
+  RichTbUpgradePhDetSupFrame *getRTbPhotSupFrame() { return aRTbPhotSupFrame; }
 
-  G4LogicalVolume*  getRichTbECSupLVol()
-  {    return  RichTbECSupLVol;}
+  G4LogicalVolume *getRichTbECSupLVol() { return RichTbECSupLVol; }
 
 protected:
-
 private:
-
-  G4LogicalVolume*    RichTbECLeftLVol;
-  G4LogicalVolume*    RichTbECRightLVol;
-  G4VPhysicalVolume*  RichTbECLeftPVol;
-  G4VPhysicalVolume*  RichTbECRightPVol;
-
-  //Upgrade 2015
-  G4LogicalVolume*    RichTbECBottomLeftLVol;
-  G4LogicalVolume*    RichTbECBottomRightLVol;
-  G4VPhysicalVolume*  RichTbECBottomLeftPVol;
-  G4VPhysicalVolume*  RichTbECBottomRightPVol;
-
-  RichTbUpgradePhDetSupFrame* aRTbPhotSupFrame;
-  G4LogicalVolume* RichTbECSupLVol;
-
-  G4VPhysicalVolume* RichTbECSupLeftPVol ;
-  G4VPhysicalVolume* RichTbECSupRightPVol ;
-  G4VPhysicalVolume* RichTbECSupBottomLeftPVol ;
-  G4VPhysicalVolume* RichTbECSupBottomRightPVol ;
-
-
+  G4LogicalVolume *RichTbECLeftLVol;
+  G4LogicalVolume *RichTbECRightLVol;
+  G4VPhysicalVolume *RichTbECLeftPVol;
+  G4VPhysicalVolume *RichTbECRightPVol;
+
+  // Upgrade 2015
+  G4LogicalVolume *RichTbECBottomLeftLVol;
+  G4LogicalVolume *RichTbECBottomRightLVol;
+  G4VPhysicalVolume *RichTbECBottomLeftPVol;
+  G4VPhysicalVolume *RichTbECBottomRightPVol;
+
+  RichTbUpgradePhDetSupFrame *aRTbPhotSupFrame;
+  G4LogicalVolume *RichTbECSupLVol;
+
+  G4VPhysicalVolume *RichTbECSupLeftPVol;
+  G4VPhysicalVolume *RichTbECSupRightPVol;
+  G4VPhysicalVolume *RichTbECSupBottomLeftPVol;
+  G4VPhysicalVolume *RichTbECSupBottomRightPVol;
 };
 #endif // INCLUDE_RICHTBUPGRADEEC_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeHpdSD.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeHpdSD.hh
index 43d59a0e867de88525ca34c7ca8a6e728b2feeae..955451a948e9a37a016d57def6a3b544c05ce6b4 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeHpdSD.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeHpdSD.hh
@@ -1,4 +1,4 @@
-#ifndef INCLUDE_RICHTBUPGRADEHPDSD_HH 
+#ifndef INCLUDE_RICHTBUPGRADEHPDSD_HH
 #define INCLUDE_RICHTBUPGRADEHPDSD_HH 1
 
 // Include files
@@ -11,37 +11,33 @@ class G4Step;
 class G4HCofThisEvent;
 
 /** @class RichTbUpgradeHpdSD RichTbUpgradeHpdSD.hh include/RichTbUpgradeHpdSD.hh
- *  
+ *
  *
  *  @author Sajan Easo
  *  @date   2015-05-15
  */
-class RichTbUpgradeHpdSD:public G4VSensitiveDetector {
-public: 
+class RichTbUpgradeHpdSD : public G4VSensitiveDetector {
+public:
   /// Standard constructor
-  RichTbUpgradeHpdSD(G4String ); 
+  RichTbUpgradeHpdSD(G4String);
 
-  virtual ~RichTbUpgradeHpdSD( ); ///< Destructor
-      void Initialize(G4HCofThisEvent*HCE);
+  virtual ~RichTbUpgradeHpdSD(); ///< Destructor
+  void Initialize(G4HCofThisEvent *HCE) override;
 
-      G4bool ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist);
-      void EndOfEvent(G4HCofThisEvent*HCE);
-      void clear();
-      void DrawAll();
-      void PrintAll();
-      G4int getCurrentHitCreationOption(){
-        return  CurrentHitCreationOption;
-      }
+  G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist) override;
+  void EndOfEvent(G4HCofThisEvent *HCE) override;
+  void clear() override;
+  void DrawAll() override;
+  void PrintAll() override;
+  G4int getCurrentHitCreationOption() { return CurrentHitCreationOption; }
 
 protected:
-
 private:
-      RichTbHitsCollection * RichTbHitCollectionHpd;
-      std::vector<G4int> HpdSDID;
-      G4int HCID;
-  G4int  CurrentHitCreationOption;
+  RichTbHitsCollection *RichTbHitCollectionHpd;
+  std::vector<G4int> HpdSDID;
+  G4int HCID;
+  G4int CurrentHitCreationOption;
   G4int RichTbHitCollIndex;
   G4String RichTbSDHpdName;
-  
 };
 #endif // INCLUDE_RICHTBUPGRADEHPDSD_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeLens.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeLens.hh
index d0abefc8ffba2e45965a31b17af56ccdb7a11947..e35ac02ed85578ea42a8572c467558b05e818372 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeLens.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeLens.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBUPGRADELENS_HH 
+#ifndef INCLUDE_RICHTBUPGRADELENS_HH
 #define INCLUDE_RICHTBUPGRADELENS_HH 1
 
 // Include files
@@ -12,7 +12,7 @@
 #include "RichTbUpgradeCrystalMaster.hh"
 
 /** @class RichTbVessel RichTbVessel.hh include/RichTbVessel.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-11-05
@@ -20,37 +20,25 @@
 class RichTbLens {
 public:
   /// Standard constructor
-  RichTbLens(RichTbUpgradeCrystalMaster* rTbCrystalMaster ); 
-
-  virtual ~RichTbLens( ); ///< Destructor
-
-  void  constructRichTbLens();
-  void  constructRichTbLensEnvelope();
-  
-  G4LogicalVolume* getRichTbLensLVol() 
-  {
-    return RichTbLensLVol;
-  }
-
-  G4VPhysicalVolume* getRichTbLensPVol() 
-  {
-    return RichTbLensPVol;
-  }
- 
-  RichTbUpgradeCrystalMaster* getaRTbCrystalMaster() 
-  { 
-    return aRTbCrystalMaster;
-  
-  }
-  
-protected:
+  RichTbLens(RichTbUpgradeCrystalMaster *rTbCrystalMaster);
+
+  virtual ~RichTbLens(); ///< Destructor
+
+  void constructRichTbLens();
+  void constructRichTbLensEnvelope();
+
+  G4LogicalVolume *getRichTbLensLVol() { return RichTbLensLVol; }
 
+  G4VPhysicalVolume *getRichTbLensPVol() { return RichTbLensPVol; }
+
+  RichTbUpgradeCrystalMaster *getaRTbCrystalMaster() { return aRTbCrystalMaster; }
+
+protected:
 private:
-  RichTbUpgradeCrystalMaster* aRTbCrystalMaster;
-  
-  G4LogicalVolume* RichTbLensLVol;
- 
-  G4VPhysicalVolume* RichTbLensPVol;
- 
+  RichTbUpgradeCrystalMaster *aRTbCrystalMaster;
+
+  G4LogicalVolume *RichTbLensLVol;
+
+  G4VPhysicalVolume *RichTbLensPVol;
 };
-#endif 
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeMaster.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeMaster.hh
index 61f7fb2b7f2620ed00855148d136906a2662d5bb..ae21cefa8b6b2d8ec8445d546e8e1b6d8267b810 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeMaster.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeMaster.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBUPGRADEMASTER_HH 
+#ifndef INCLUDE_RICHTBUPGRADEMASTER_HH
 #define INCLUDE_RICHTBUPGRADEMASTER_HH 1
 
 // Include files
@@ -12,7 +12,7 @@
 #include "RichTbUpgradePhDFrame.hh"
 
 /** @class RichTbVessel RichTbVessel.hh include/RichTbVessel.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-11-05
@@ -20,63 +20,40 @@
 class RichTbMaster {
 public:
   /// Standard constructor
-  RichTbMaster(RichTbPhDFrame* rTbPhDFrame, int MasterNum ); 
+  RichTbMaster(RichTbPhDFrame *rTbPhDFrame, int MasterNum);
 
-  virtual ~RichTbMaster( ); ///< Destructor
+  virtual ~RichTbMaster(); ///< Destructor
 
-  void  constructRichTbMaster1();
-  void  constructRichTbMasterEnvelope1();
-  
-  void  constructRichTbMaster2();
-  void  constructRichTbMasterEnvelope2();
+  void constructRichTbMaster1();
+  void constructRichTbMasterEnvelope1();
 
-  void  constructRichTbMaster3();
-  void  constructRichTbMasterEnvelope3();
+  void constructRichTbMaster2();
+  void constructRichTbMasterEnvelope2();
 
-  void  constructRichTbMaster4();
-  void  constructRichTbMasterEnvelope4();
+  void constructRichTbMaster3();
+  void constructRichTbMasterEnvelope3();
 
-  G4LogicalVolume* getRichTbMasterLVol() 
-  {
-    return RichTbMasterLVol;
-  }
-  G4LogicalVolume* getRichTbMasterEnvelopeBottomLVol()
-  {
-    return RichTbMasterEnvelopeBottomLVol;
-  }
+  void constructRichTbMaster4();
+  void constructRichTbMasterEnvelope4();
 
-  G4VPhysicalVolume* getRichTbMasterPVol() 
-  {
-    return RichTbMasterPVol;
-  }
-  G4VPhysicalVolume* getRichTbMasterEnvelopeBottomPVol()
-  {
-    return RichTbMasterEnvelopeBottomPVol;
-  }
+  G4LogicalVolume *getRichTbMasterLVol() { return RichTbMasterLVol; }
+  G4LogicalVolume *getRichTbMasterEnvelopeBottomLVol() { return RichTbMasterEnvelopeBottomLVol; }
 
-  RichTbPhDFrame* getaRTbPhDFrame() 
-  { 
-    return aRTbPhDFrame;
-  
-  }
-  int getaMasterNum() 
-  { 
-    return aMasterNum;
-  
-  }
-protected:
+  G4VPhysicalVolume *getRichTbMasterPVol() { return RichTbMasterPVol; }
+  G4VPhysicalVolume *getRichTbMasterEnvelopeBottomPVol() { return RichTbMasterEnvelopeBottomPVol; }
 
+  RichTbPhDFrame *getaRTbPhDFrame() { return aRTbPhDFrame; }
+  int getaMasterNum() { return aMasterNum; }
+
+protected:
 private:
-  RichTbPhDFrame* aRTbPhDFrame;
+  RichTbPhDFrame *aRTbPhDFrame;
   int aMasterNum;
-  
-  G4LogicalVolume* RichTbMasterLVol;
-  G4LogicalVolume*  RichTbMasterEnvelopeBottomLVol;
-  
 
-  G4VPhysicalVolume* RichTbMasterPVol;
-  G4VPhysicalVolume* RichTbMasterEnvelopeBottomPVol; 
+  G4LogicalVolume *RichTbMasterLVol;
+  G4LogicalVolume *RichTbMasterEnvelopeBottomLVol;
 
- 
+  G4VPhysicalVolume *RichTbMasterPVol;
+  G4VPhysicalVolume *RichTbMasterEnvelopeBottomPVol;
 };
-#endif 
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeMirror.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeMirror.hh
index 88bd9370cc7e40f06428dfb29d96d01b247fd43e..9e586a8e362f69c605f503810d72a863c26415aa 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeMirror.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeMirror.hh
@@ -17,48 +17,31 @@
 class RichTbUpgradeMirror {
 public:
   /// Standard constructor
-  RichTbUpgradeMirror( RichTbUpgradeCrystalMaster* aMaster, RichTbUpgradeRadiator* aRadiator);
+  RichTbUpgradeMirror(RichTbUpgradeCrystalMaster *aMaster, RichTbUpgradeRadiator *aRadiator);
 
-  virtual ~RichTbUpgradeMirror( ); ///< Destructor
+  virtual ~RichTbUpgradeMirror(); ///< Destructor
 
-
-  G4LogicalVolume* getRichTbUpgradeMirrorLVol()
-  {
-   return RichTbUpgradeMirrorLVol;
-
-  }
-  G4VPhysicalVolume* getRichTbUpgradeMirrorPVol()
-  {
-    return RichTbUpgradeMirrorPVol;
-  }
+  G4LogicalVolume *getRichTbUpgradeMirrorLVol() { return RichTbUpgradeMirrorLVol; }
+  G4VPhysicalVolume *getRichTbUpgradeMirrorPVol() { return RichTbUpgradeMirrorPVol; }
 
   void constructRichTbUpgradeMirror();
-  void constructRichTbUpgradeMirror15(); //testbeam 2015 upgrade
+  void constructRichTbUpgradeMirror15(); // testbeam 2015 upgrade
 
-  RichTbUpgradeRadiator* getaRTbUpgradeRadiator()
-  {
-    return aRTbUpgradeRadiator;
-  }
+  RichTbUpgradeRadiator *getaRTbUpgradeRadiator() { return aRTbUpgradeRadiator; }
 
 protected:
-
 private:
-
   /// Standard constructor
-  //RichTbUpgradeMirror( RichTbCrystalMaster* aMaster );
+  // RichTbUpgradeMirror( RichTbCrystalMaster* aMaster );
 
-
-  //static RichTbUpgradeMirror* RichTbUpgradeMirrorInstance;
+  // static RichTbUpgradeMirror* RichTbUpgradeMirrorInstance;
   G4ThreeVector MirrorCoC;
 
+  RichTbUpgradeCrystalMaster *motherMaster;
 
+  RichTbUpgradeRadiator *aRTbUpgradeRadiator;
 
-  RichTbUpgradeCrystalMaster* motherMaster;
-
-  RichTbUpgradeRadiator* aRTbUpgradeRadiator;
-
-  G4LogicalVolume* RichTbUpgradeMirrorLVol;
-  G4VPhysicalVolume* RichTbUpgradeMirrorPVol;
-
+  G4LogicalVolume *RichTbUpgradeMirrorLVol;
+  G4VPhysicalVolume *RichTbUpgradeMirrorPVol;
 };
 #endif // INCLUDE_RICHTBUPGRADEMIRROR_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradePhDFrame.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradePhDFrame.hh
index 539e8e95f6ddf2e4bc50dc5dc752b4009b251135..ec1d39e693aea3707991946c214b81b8d750efb8 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradePhDFrame.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradePhDFrame.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBUPGRADEPHDFRAME_HH 
+#ifndef INCLUDE_RICHTBUPGRADEPHDFRAME_HH
 #define INCLUDE_RICHTBUPGRADEPHDFRAME_HH 1
 
 // Include files
@@ -11,7 +11,7 @@
 #include "RichTbUpgradeCrystalMaster.hh"
 
 /** @class RichTbVessel RichTbVessel.hh include/RichTbVessel.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-11-05
@@ -19,49 +19,28 @@
 class RichTbPhDFrame {
 public:
   /// Standard constructor
-  RichTbPhDFrame(RichTbUpgradeCrystalMaster* rTbCrystalMaster ); 
+  RichTbPhDFrame(RichTbUpgradeCrystalMaster *rTbCrystalMaster);
 
-  virtual ~RichTbPhDFrame( ); ///< Destructor
+  virtual ~RichTbPhDFrame(); ///< Destructor
 
-  void  constructRichTbPhDFrame();
-  void  constructRichTbPhDFrameEnvelope();
-  
-  G4LogicalVolume* getRichTbPhDFrameLVol() 
-  {
-    return RichTbPhDFrameLVol;
-  }
-  G4LogicalVolume* getRichTbPhDFrameEnvelopeBottomLVol()
-  {
-    return RichTbPhDFrameEnvelopeBottomLVol;
-    
-  }
+  void constructRichTbPhDFrame();
+  void constructRichTbPhDFrameEnvelope();
 
-  G4VPhysicalVolume* getRichTbPhDFramePVol() 
-  {
-    return RichTbPhDFramePVol;
-  }
-  G4VPhysicalVolume* getRichTbPhDFrameEnvelopeBottomPVol()
-  {
-    return RichTbPhDFrameEnvelopeBottomPVol;
-  }
-  RichTbUpgradeCrystalMaster* getRTbCrystalMaster() 
-  { 
-    return aRTbCrystalMaster;
-  
-  }
-  
-protected:
+  G4LogicalVolume *getRichTbPhDFrameLVol() { return RichTbPhDFrameLVol; }
+  G4LogicalVolume *getRichTbPhDFrameEnvelopeBottomLVol() { return RichTbPhDFrameEnvelopeBottomLVol; }
 
+  G4VPhysicalVolume *getRichTbPhDFramePVol() { return RichTbPhDFramePVol; }
+  G4VPhysicalVolume *getRichTbPhDFrameEnvelopeBottomPVol() { return RichTbPhDFrameEnvelopeBottomPVol; }
+  RichTbUpgradeCrystalMaster *getRTbCrystalMaster() { return aRTbCrystalMaster; }
+
+protected:
 private:
-  RichTbUpgradeCrystalMaster* aRTbCrystalMaster;
-  
-  G4LogicalVolume* RichTbPhDFrameLVol;
-  G4LogicalVolume*  RichTbPhDFrameEnvelopeBottomLVol;
-  
+  RichTbUpgradeCrystalMaster *aRTbCrystalMaster;
 
-  G4VPhysicalVolume* RichTbPhDFramePVol;
-  G4VPhysicalVolume* RichTbPhDFrameEnvelopeBottomPVol; 
+  G4LogicalVolume *RichTbPhDFrameLVol;
+  G4LogicalVolume *RichTbPhDFrameEnvelopeBottomLVol;
 
- 
+  G4VPhysicalVolume *RichTbPhDFramePVol;
+  G4VPhysicalVolume *RichTbPhDFrameEnvelopeBottomPVol;
 };
-#endif 
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradePhDetSupFrame.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradePhDetSupFrame.hh
index eb299995ddba230f3529f04a4adb6c259e294099..0ef53309bdbaf59c202e2873e7dc4f03c474e0db 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradePhDetSupFrame.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradePhDetSupFrame.hh
@@ -17,54 +17,36 @@
 class RichTbUpgradePhDetSupFrame {
 public:
   /// Standard constructor
-  RichTbUpgradePhDetSupFrame(RichTbUpgradeCrystalMaster*  rTbCrystalMaster );
+  RichTbUpgradePhDetSupFrame(RichTbUpgradeCrystalMaster *rTbCrystalMaster);
 
-  virtual ~RichTbUpgradePhDetSupFrame( ); ///< Destructor
+  virtual ~RichTbUpgradePhDetSupFrame(); ///< Destructor
 
-  void constructRichTbPhotoDetectorSupFrame() ;
+  void constructRichTbPhotoDetectorSupFrame();
   void constructRichTbPhotoDetectorSupFrameWithHpd();
   void constructRichTbPhotoDetectorSupFrame15();
 
+  G4LogicalVolume *getRichTbPhDetSupFrameLeftLVol() { return RichTbPhDetSupFrameLeftLVol; }
+  G4LogicalVolume *getRichTbPhDetSupFrameRightLVol() { return RichTbPhDetSupFrameRightLVol; }
+  G4VPhysicalVolume *getRichTbPhDetSupFrameLeftPVol() { return RichTbPhDetSupFrameLeftPVol; }
+  G4VPhysicalVolume *getRichTbPhDetSupFrameRightPVol() { return RichTbPhDetSupFrameRightPVol; }
 
-  G4LogicalVolume* getRichTbPhDetSupFrameLeftLVol()
-  {return RichTbPhDetSupFrameLeftLVol;}
-  G4LogicalVolume* getRichTbPhDetSupFrameRightLVol()
-  {  return  RichTbPhDetSupFrameRightLVol;}
-  G4VPhysicalVolume* getRichTbPhDetSupFrameLeftPVol()
-  {  return RichTbPhDetSupFrameLeftPVol ;}
-  G4VPhysicalVolume* getRichTbPhDetSupFrameRightPVol()
-  {  return RichTbPhDetSupFrameRightPVol ;}
-
-  G4LogicalVolume* getRichTbPhDetSupFrameBottomLeftLVol()
-  {return RichTbPhDetSupFrameBottomLeftLVol;}
-  G4LogicalVolume* getRichTbPhDetSupFrameBottomRightLVol()
-  {  return  RichTbPhDetSupFrameBottomRightLVol;}
-  G4VPhysicalVolume* getRichTbPhDetSupFrameBottomLeftPVol()
-  {  return RichTbPhDetSupFrameBottomLeftPVol ;}
-  G4VPhysicalVolume* getRichTbPhDetSupFrameBottomRightPVol()
-  {  return RichTbPhDetSupFrameBottomRightPVol ;}
-
-  RichTbUpgradeCrystalMaster* getCrystalMaster()
-  {return aRTbCrystalMaster;  }
-
-
+  G4LogicalVolume *getRichTbPhDetSupFrameBottomLeftLVol() { return RichTbPhDetSupFrameBottomLeftLVol; }
+  G4LogicalVolume *getRichTbPhDetSupFrameBottomRightLVol() { return RichTbPhDetSupFrameBottomRightLVol; }
+  G4VPhysicalVolume *getRichTbPhDetSupFrameBottomLeftPVol() { return RichTbPhDetSupFrameBottomLeftPVol; }
+  G4VPhysicalVolume *getRichTbPhDetSupFrameBottomRightPVol() { return RichTbPhDetSupFrameBottomRightPVol; }
 
+  RichTbUpgradeCrystalMaster *getCrystalMaster() { return aRTbCrystalMaster; }
 
 protected:
-
 private:
-
-
-  G4LogicalVolume*   RichTbPhDetSupFrameLeftLVol;
-  G4LogicalVolume*   RichTbPhDetSupFrameRightLVol;
-  G4VPhysicalVolume* RichTbPhDetSupFrameLeftPVol ;
-  G4VPhysicalVolume* RichTbPhDetSupFrameRightPVol ;
-  G4LogicalVolume*   RichTbPhDetSupFrameBottomLeftLVol;
-  G4LogicalVolume*   RichTbPhDetSupFrameBottomRightLVol;
-  G4VPhysicalVolume* RichTbPhDetSupFrameBottomLeftPVol;
-  G4VPhysicalVolume* RichTbPhDetSupFrameBottomRightPVol;
-  RichTbUpgradeCrystalMaster* aRTbCrystalMaster;
-
-
+  G4LogicalVolume *RichTbPhDetSupFrameLeftLVol;
+  G4LogicalVolume *RichTbPhDetSupFrameRightLVol;
+  G4VPhysicalVolume *RichTbPhDetSupFrameLeftPVol;
+  G4VPhysicalVolume *RichTbPhDetSupFrameRightPVol;
+  G4LogicalVolume *RichTbPhDetSupFrameBottomLeftLVol;
+  G4LogicalVolume *RichTbPhDetSupFrameBottomRightLVol;
+  G4VPhysicalVolume *RichTbPhDetSupFrameBottomLeftPVol;
+  G4VPhysicalVolume *RichTbPhDetSupFrameBottomRightPVol;
+  RichTbUpgradeCrystalMaster *aRTbCrystalMaster;
 };
 #endif // INCLUDE_RICHTBUPGRADEPHDETSUPFRAME_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeRadiator.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeRadiator.hh
index 0bc8359ccf009831a2d09dc7690ed985453b75f1..8a891a25af132c9a4eace7ae552d95491b699b30 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeRadiator.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeRadiator.hh
@@ -17,63 +17,37 @@
  *  @author Sajan EASO
  *  @date   2003-11-05
  */
-class RichTbUpgradeRadiator{
+class RichTbUpgradeRadiator {
 public:
   /// Standard constructor
-  RichTbUpgradeRadiator(RichTbUpgradeCrystalMaster* rTbCrystalMaster );
+  RichTbUpgradeRadiator(RichTbUpgradeCrystalMaster *rTbCrystalMaster);
 
-  virtual ~RichTbUpgradeRadiator( ); ///< Destructor
+  virtual ~RichTbUpgradeRadiator(); ///< Destructor
 
-  void  constructRichTbUpgradeRadiator();
-  void  constructRichTbUpgradeRadiator15();
-  void  constructRichTbUpgradeRadiatorEnvelope();
+  void constructRichTbUpgradeRadiator();
+  void constructRichTbUpgradeRadiator15();
+  void constructRichTbUpgradeRadiatorEnvelope();
 
-  G4LogicalVolume* getRichTbUpgradeRadiatorLVol()
-  {
-    return RichTbUpgradeRadiatorLVol;
-  }
-  G4LogicalVolume* getRichTbUpgradeRadiatorEnvelopeBottomLVol()
-  {
-    return RichTbUpgradeRadiatorEnvelopeBottomLVol;
+  G4LogicalVolume *getRichTbUpgradeRadiatorLVol() { return RichTbUpgradeRadiatorLVol; }
+  G4LogicalVolume *getRichTbUpgradeRadiatorEnvelopeBottomLVol() { return RichTbUpgradeRadiatorEnvelopeBottomLVol; }
 
-  }
-
-  G4VPhysicalVolume* getRichTbUpgradeRadiatorPVol()
-  {
-    return RichTbUpgradeRadiatorPVol;
-  }
-  G4VPhysicalVolume* getRichTbUpgradeRadiatorEnvelopeBottomPVol()
-  {
-    return RichTbUpgradeRadiatorEnvelopeBottomPVol;
-  }
-  RichTbUpgradeCrystalMaster* getaRTbCrystalMaster()
-  {
-    return aRTbCrystalMaster;
-
-  }
-  G4LogicalVolume* getTestLvol()
-  {
-    return testLvol;
-  }
-  G4VPhysicalVolume* getTestPvol()
-  {
-    return testPvol;
-  }
+  G4VPhysicalVolume *getRichTbUpgradeRadiatorPVol() { return RichTbUpgradeRadiatorPVol; }
+  G4VPhysicalVolume *getRichTbUpgradeRadiatorEnvelopeBottomPVol() { return RichTbUpgradeRadiatorEnvelopeBottomPVol; }
+  RichTbUpgradeCrystalMaster *getaRTbCrystalMaster() { return aRTbCrystalMaster; }
+  G4LogicalVolume *getTestLvol() { return testLvol; }
+  G4VPhysicalVolume *getTestPvol() { return testPvol; }
 
 protected:
-
 private:
-  RichTbUpgradeCrystalMaster* aRTbCrystalMaster;
-
-  G4LogicalVolume* RichTbUpgradeRadiatorLVol;
-  G4LogicalVolume*  RichTbUpgradeRadiatorEnvelopeBottomLVol;
-
+  RichTbUpgradeCrystalMaster *aRTbCrystalMaster;
 
-  G4VPhysicalVolume* RichTbUpgradeRadiatorPVol;
-  G4VPhysicalVolume* RichTbUpgradeRadiatorEnvelopeBottomPVol;
+  G4LogicalVolume *RichTbUpgradeRadiatorLVol;
+  G4LogicalVolume *RichTbUpgradeRadiatorEnvelopeBottomLVol;
 
-  G4LogicalVolume * testLvol;
-  G4VPhysicalVolume * testPvol;
+  G4VPhysicalVolume *RichTbUpgradeRadiatorPVol;
+  G4VPhysicalVolume *RichTbUpgradeRadiatorEnvelopeBottomPVol;
 
+  G4LogicalVolume *testLvol;
+  G4VPhysicalVolume *testPvol;
 };
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeSD.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeSD.hh
index 6be735506afbaccb161649b549e01a73f7abce81..99a437147ac33130111c1afcbf65f26e35823470 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeSD.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeSD.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBUPGRADESD_HH 
+#ifndef INCLUDE_RICHTBUPGRADESD_HH
 #define INCLUDE_RICHTBUPGRADESD_HH 1
 
 // Include files
@@ -11,46 +11,38 @@
 class G4Step;
 class G4HCofThisEvent;
 
-
 /** @class RichTbUpgradeSD RichTbUpgradeSD.hh include/RichTbUpgradeSD.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-12-12
  *  Modif: Claudia Merlassino, Sajan Easo
- *  date  : 2014-08-21 
+ *  date  : 2014-08-21
  */
-class RichTbUpgradeSD:public G4VSensitiveDetector {
-public: 
+class RichTbUpgradeSD : public G4VSensitiveDetector {
+public:
   /// Standard constructor
-  RichTbUpgradeSD(G4String ); 
+  RichTbUpgradeSD(G4String);
 
-  virtual ~RichTbUpgradeSD( ); ///< Destructor
-      void Initialize(G4HCofThisEvent*HCE);
+  virtual ~RichTbUpgradeSD(); ///< Destructor
+  void Initialize(G4HCofThisEvent *HCE) override;
 
-      G4bool ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist);
-      void EndOfEvent(G4HCofThisEvent*HCE);
-      void clear();
-      void DrawAll();
-      void PrintAll();
+  G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist) override;
+  void EndOfEvent(G4HCofThisEvent *HCE) override;
+  void clear() override;
+  void DrawAll() override;
+  void PrintAll() override;
 
-  G4int getCurrentHitCreationOption()
-  {
-    return  CurrentHitCreationOption;
-  }
-  
-    
-protected:
+  G4int getCurrentHitCreationOption() { return CurrentHitCreationOption; }
 
+protected:
 private:
-      RichTbHitsCollection * RichTbHitCollection;
-      std::vector<G4int> PmtSDID;
-      G4int HCID;
-  G4int  CurrentHitCreationOption;
+  RichTbHitsCollection *RichTbHitCollection;
+  std::vector<G4int> PmtSDID;
+  G4int HCID;
+  G4int CurrentHitCreationOption;
   G4double CurrentPmtPixelGap;
   G4int RichTbHitCollIndex;
-  G4String  RichTbSensDetName;
-  
-
+  G4String RichTbSensDetName;
 };
 #endif // INCLUDE_RICHTBUPGRADESD_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeVessel.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeVessel.hh
index 5f23a0fb8e06198a0d1d38928b491766c1a48e08..20cf09cb64b4b08fd1460d570b78510fd5bb0b3a 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeVessel.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUpgradeVessel.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBUPGRADEVESSEL_HH 
+#ifndef INCLUDE_RICHTBUPGRADEVESSEL_HH
 #define INCLUDE_RICHTBUPGRADEVESSEL_HH 1
 
 // Include files
@@ -10,7 +10,7 @@
 #include "RichTbHall.hh"
 
 /** @class RichTbUpgradeVessel RichTbUpgradeVessel.hh include/RichTbUpgradeVessel.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-11-05
@@ -18,49 +18,28 @@
 class RichTbUpgradeVessel {
 public:
   /// Standard constructor
-  RichTbUpgradeVessel(RichTbHall* rTbHall ); 
+  RichTbUpgradeVessel(RichTbHall *rTbHall);
 
-  virtual ~RichTbUpgradeVessel( ); ///< Destructor
+  virtual ~RichTbUpgradeVessel(); ///< Destructor
 
-  void  constructRichTbGasVessel();
-  void  constructRichTbUpgradeVesselEnvelope();
-  
-  G4LogicalVolume* getRichTbGasVesselLVol() 
-  {
-    return RichTbGasVesselLVol;
-  }
-  G4LogicalVolume* getRichTbUpgradeVesselEnvelopeBottomLVol()
-  {
-    return RichTbUpgradeVesselEnvelopeBottomLVol;
-    
-  }
+  void constructRichTbGasVessel();
+  void constructRichTbUpgradeVesselEnvelope();
 
-  G4VPhysicalVolume* getRichTbGasVesselPVol() 
-  {
-    return RichTbGasVesselPVol;
-  }
-  G4VPhysicalVolume* getRichTbUpgradeVesselEnvelopeBottomPVol()
-  {
-    return RichTbUpgradeVesselEnvelopeBottomPVol;
-  }
-  RichTbHall* getaRTbHall() 
-  { 
-    return aRTbHall;
-  
-  }
-  
-protected:
+  G4LogicalVolume *getRichTbGasVesselLVol() { return RichTbGasVesselLVol; }
+  G4LogicalVolume *getRichTbUpgradeVesselEnvelopeBottomLVol() { return RichTbUpgradeVesselEnvelopeBottomLVol; }
 
+  G4VPhysicalVolume *getRichTbGasVesselPVol() { return RichTbGasVesselPVol; }
+  G4VPhysicalVolume *getRichTbUpgradeVesselEnvelopeBottomPVol() { return RichTbUpgradeVesselEnvelopeBottomPVol; }
+  RichTbHall *getaRTbHall() { return aRTbHall; }
+
+protected:
 private:
-  RichTbHall* aRTbHall;
-  
-  G4LogicalVolume* RichTbGasVesselLVol;
-  G4LogicalVolume*  RichTbUpgradeVesselEnvelopeBottomLVol;
-  
+  RichTbHall *aRTbHall;
 
-  G4VPhysicalVolume* RichTbGasVesselPVol;
-  G4VPhysicalVolume* RichTbUpgradeVesselEnvelopeBottomPVol; 
+  G4LogicalVolume *RichTbGasVesselLVol;
+  G4LogicalVolume *RichTbUpgradeVesselEnvelopeBottomLVol;
 
- 
+  G4VPhysicalVolume *RichTbGasVesselPVol;
+  G4VPhysicalVolume *RichTbUpgradeVesselEnvelopeBottomPVol;
 };
 #endif // INCLUDE_RICHTBUPGRADEVESSEL_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUserTrackInfo.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUserTrackInfo.hh
index 872da0c6e6a4aa0c43ad21f587bea10c8c1f007b..fdd8ea3d21db6b80ff9eb50c7a3e4c2623cd0e6e 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUserTrackInfo.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbUserTrackInfo.hh
@@ -1,5 +1,5 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBUSERTRACKINFO_HH 
+#ifndef INCLUDE_RICHTBUSERTRACKINFO_HH
 #define INCLUDE_RICHTBUSERTRACKINFO_HH 1
 
 // Include files
@@ -8,48 +8,40 @@
 #include "RichTbPhotonInfo.hh"
 
 /** @class RichTbUserTrackInfo RichTbUserTrackInfo.hh include/RichTbUserTrackInfo.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2004-01-20
  */
-class RichTbUserTrackInfo:public G4VUserTrackInformation {
-public: 
+class RichTbUserTrackInfo : public G4VUserTrackInformation {
+public:
   /// Standard constructor
-  RichTbUserTrackInfo( ); 
-  RichTbUserTrackInfo(RichTbPhotonInfo* );
-  RichTbUserTrackInfo(RichTbPEInfo* );
-  
-
-  virtual ~RichTbUserTrackInfo( ); ///< Destructor
-
-  RichTbPhotonInfo* getRichTbPhotonInfo(){    return mRichTbPhotonInfo; }
-  void setRichTbPhotonInfo(RichTbPhotonInfo* aRichTbPhotonInfo)
-  {mRichTbPhotonInfo=aRichTbPhotonInfo;}
-
-  RichTbPEInfo* getRichTbPEInfo(){    return mRichTbPEInfo;}
-  void setRichTbPEInfo(RichTbPEInfo* aRichTbPEInfo)
-  {mRichTbPEInfo=aRichTbPEInfo;   }
-  
-  bool HasUserPhotonInfo(){return  mHasUserPhotonInfo;}
-  void setUserPhotonInfo(bool abPhValue)  {mHasUserPhotonInfo=abPhValue;}  
-    
-  bool HasUserPEInfo(){return mHasUserPEInfo;}
-  void setUserPEInfo(bool abPeValue )  {mHasUserPEInfo = abPeValue;}
-
-  virtual void Print () const {}
-  
-  
-    
-protected:
+  RichTbUserTrackInfo();
+  RichTbUserTrackInfo(RichTbPhotonInfo *);
+  RichTbUserTrackInfo(RichTbPEInfo *);
+
+  virtual ~RichTbUserTrackInfo(); ///< Destructor
+
+  RichTbPhotonInfo *getRichTbPhotonInfo() { return mRichTbPhotonInfo; }
+  void setRichTbPhotonInfo(RichTbPhotonInfo *aRichTbPhotonInfo) { mRichTbPhotonInfo = aRichTbPhotonInfo; }
+
+  RichTbPEInfo *getRichTbPEInfo() { return mRichTbPEInfo; }
+  void setRichTbPEInfo(RichTbPEInfo *aRichTbPEInfo) { mRichTbPEInfo = aRichTbPEInfo; }
 
+  bool HasUserPhotonInfo() { return mHasUserPhotonInfo; }
+  void setUserPhotonInfo(bool abPhValue) { mHasUserPhotonInfo = abPhValue; }
+
+  bool HasUserPEInfo() { return mHasUserPEInfo; }
+  void setUserPEInfo(bool abPeValue) { mHasUserPEInfo = abPeValue; }
+
+  virtual void Print() const override {}
+
+protected:
 private:
-  RichTbPhotonInfo* mRichTbPhotonInfo;
-  RichTbPEInfo* mRichTbPEInfo;
-  
+  RichTbPhotonInfo *mRichTbPhotonInfo;
+  RichTbPEInfo *mRichTbPEInfo;
+
   bool mHasUserPhotonInfo;
   bool mHasUserPEInfo;
-  
- 
 };
 #endif // INCLUDE_RICHTBUSERTRACKINFO_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbVesselGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbVesselGeometryParameters.hh
index a0b9036a8b4bd9e6dfe1b43179efa3cc0d4807a5..e4feb3a7e87e281433513ba706926a1f097875d8 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbVesselGeometryParameters.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbVesselGeometryParameters.hh
@@ -1,27 +1,27 @@
 // $Id: $
-#ifndef INCLUDE_RICHTBVESSELGEOMETRYPARAMETERS_HH 
+#ifndef INCLUDE_RICHTBVESSELGEOMETRYPARAMETERS_HH
 #define INCLUDE_RICHTBVESSELGEOMETRYPARAMETERS_HH 1
 
 // Include files
 
 /** @class RichTbVesselGeometryParameters RichTbVesselGeometryParameters.hh include/RichTbVesselGeometryParameters.hh
- *  
+ *
  *
  *  @author Sajan EASO
  *  @date   2003-10-21
  */
 
 // first for the overall vessel.
-const G4double RichTbVesselXSize=1000.0*CLHEP::mm;
-const G4double RichTbVesselYSize=600.0*CLHEP::mm;
-const G4double RichTbVesselZSize=2000.0*CLHEP::mm;
+const G4double RichTbVesselXSize = 1000.0 * CLHEP::mm;
+const G4double RichTbVesselYSize = 600.0 * CLHEP::mm;
+const G4double RichTbVesselZSize = 2000.0 * CLHEP::mm;
 
 // now for the boolean subtraction.
 /*
-const G4double RichTbVesselUpsExternalPartXSize=500.0*CLHEP::mm;  // for now assume it to be half way point. to be verified.
-const G4double RichTbVesselUpsExternalPartZSize=1000.0*CLHEP::mm;
-const G4double RichTbVesselUpsExternalPartYLargeSize=20000.0*CLHEP::mm;
-const G4double RichTbVesselUpsExternalPartZLargeSize=20000.0*CLHEP::mm;
+const G4double RichTbVesselUpsExternalPartXSize=500.0*CLHEP::mm;  // for now assume it to be half way point. to be
+verified. const G4double RichTbVesselUpsExternalPartZSize=1000.0*CLHEP::mm; const G4double
+RichTbVesselUpsExternalPartYLargeSize=20000.0*CLHEP::mm; const G4double
+RichTbVesselUpsExternalPartZLargeSize=20000.0*CLHEP::mm;
 
 const G4double RichTbVesselUpsExternalPartXShift=0.5*(RichTbVesselXSize-RichTbVesselUpsExternalPartXSize);
 const G4double RichTbVesselUpsExternalPartYShift=0.0*CLHEP::mm;
@@ -30,40 +30,41 @@ const G4double RichTbVesselUpsExternalPartZShift=-0.5*RichTbVesselZSize+
 */
 // now for the location and rotation of the vessel
 
-//const G4double RichTbVesselOriginShiftFromLeftEdgeX=250.0*CLHEP::mm;  // for now assume middle part. to be verified.
-//const G4double RichTbVesselOriginShiftFromFloorY=1300.0*CLHEP::mm;
-const G4double RichTbVesselXRotation=0.0*CLHEP::rad;  // for now in the following vessel Xrot is not used in Euler rotations since it is 0.
-//const G4double RichTbVesselYRotation=0.4817*CLHEP::rad;
-const G4double RichTbVesselYRotation=0.0*CLHEP::rad;
+// const G4double RichTbVesselOriginShiftFromLeftEdgeX=250.0*CLHEP::mm;  // for now assume middle part. to be verified.
+// const G4double RichTbVesselOriginShiftFromFloorY=1300.0*CLHEP::mm;
+const G4double RichTbVesselXRotation =
+    0.0 * CLHEP::rad; // for now in the following vessel Xrot is not used in Euler rotations since it is 0.
+// const G4double RichTbVesselYRotation=0.4817*CLHEP::rad;
+const G4double RichTbVesselYRotation = 0.0 * CLHEP::rad;
 const G4double RichTbVesselYLocation = 0;
-//const G4double RichTbVesselXShiftAlongVessel = RichTbVesselOriginShiftFromLeftEdgeX - 0.5 * RichTbVesselXSize;
-//const G4double RichTbVesselZShiftAlongVessel = -RichTbVesselUpsExternalPartZSize + 0.5 * RichTbVesselZSize;
+// const G4double RichTbVesselXShiftAlongVessel = RichTbVesselOriginShiftFromLeftEdgeX - 0.5 * RichTbVesselXSize;
+// const G4double RichTbVesselZShiftAlongVessel = -RichTbVesselUpsExternalPartZSize + 0.5 * RichTbVesselZSize;
 // X and Y location shifts in the global frame using Euler rotation wrt the Y axis.
-//const G4double RichTbVesselXLocation= RichTbVesselXShiftAlongVessel*cos(RichTbVesselYRotation)+ 
+// const G4double RichTbVesselXLocation= RichTbVesselXShiftAlongVessel*cos(RichTbVesselYRotation)+
 //                                      RichTbVesselZShiftAlongVessel*sin(RichTbVesselYRotation);
-//const G4double RichTbVesselZLocation=-RichTbVesselXShiftAlongVessel*sin(RichTbVesselYRotation)+ 
+// const G4double RichTbVesselZLocation=-RichTbVesselXShiftAlongVessel*sin(RichTbVesselYRotation)+
 //                                      RichTbVesselZShiftAlongVessel*cos(RichTbVesselYRotation);
 const G4double RichTbVesselXLocation = 0;
 const G4double RichTbVesselZLocation = 0;
 
 // now for variables used after creating the geometry in stepaction.
 
-const G4double RichTbVesselEnvPlateThickness=0.0*CLHEP::mm;
+const G4double RichTbVesselEnvPlateThickness = 0.0 * CLHEP::mm;
 // the following are not exact values.
 
-const G4double  RichTbVesselXNegExtremeAlongVessel=- 0.5 * RichTbVesselXSize;
-const G4double  RichTbVesselXPosExtremeAlongVessel= +0.5 * RichTbVesselXSize;
-const G4double  RichTbVesselZUpsExtremeAlongVessel= - 0.5 * RichTbVesselZSize;
-const G4double  RichTbVesselZDnsExtremeAlongVessel= +0.5 * RichTbVesselZSize;
-const G4double  RichTbVesselXNegExtreme=  RichTbVesselXNegExtremeAlongVessel*cos(RichTbVesselYRotation)+
-                                          RichTbVesselZDnsExtremeAlongVessel*sin(RichTbVesselYRotation);
-const G4double  RichTbVesselXPosExtreme=  RichTbVesselXPosExtremeAlongVessel*cos(RichTbVesselYRotation)+
-                                          RichTbVesselZUpsExtremeAlongVessel*sin(RichTbVesselYRotation);
+const G4double RichTbVesselXNegExtremeAlongVessel = -0.5 * RichTbVesselXSize;
+const G4double RichTbVesselXPosExtremeAlongVessel = +0.5 * RichTbVesselXSize;
+const G4double RichTbVesselZUpsExtremeAlongVessel = -0.5 * RichTbVesselZSize;
+const G4double RichTbVesselZDnsExtremeAlongVessel = +0.5 * RichTbVesselZSize;
+const G4double RichTbVesselXNegExtreme = RichTbVesselXNegExtremeAlongVessel * cos(RichTbVesselYRotation) +
+                                         RichTbVesselZDnsExtremeAlongVessel * sin(RichTbVesselYRotation);
+const G4double RichTbVesselXPosExtreme = RichTbVesselXPosExtremeAlongVessel * cos(RichTbVesselYRotation) +
+                                         RichTbVesselZUpsExtremeAlongVessel * sin(RichTbVesselYRotation);
 
-const G4double  RichTbVesselYNegExtreme= RichTbVesselYLocation-0.5*RichTbVesselYSize;
-const G4double  RichTbVesselYPosExtreme= RichTbVesselYLocation+0.5*RichTbVesselYSize;
-const G4double  RichTbVesselZDnsExtreme = -RichTbVesselXNegExtremeAlongVessel*sin(RichTbVesselYRotation)+
-                                        RichTbVesselZDnsExtremeAlongVessel*cos(RichTbVesselYRotation);
-const G4double  RichTbVesselDnsZEnd = RichTbVesselZDnsExtreme;
+const G4double RichTbVesselYNegExtreme = RichTbVesselYLocation - 0.5 * RichTbVesselYSize;
+const G4double RichTbVesselYPosExtreme = RichTbVesselYLocation + 0.5 * RichTbVesselYSize;
+const G4double RichTbVesselZDnsExtreme = -RichTbVesselXNegExtremeAlongVessel * sin(RichTbVesselYRotation) +
+                                         RichTbVesselZDnsExtremeAlongVessel * cos(RichTbVesselYRotation);
+const G4double RichTbVesselDnsZEnd = RichTbVesselZDnsExtreme;
 
 #endif // INCLUDE_RICHTBVESSELGEOMETRYPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbVisManager.hh b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbVisManager.hh
index 565cd214f56f967919254e7c4fd915e075713d2e..b1c6725ceb5de0f685035ef9961f095feb84d5e6 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/include/RichTbVisManager.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/include/RichTbVisManager.hh
@@ -21,21 +21,18 @@
 
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 
-class RichTbVisManager:public G4VisManager {
-
-  public:
+class RichTbVisManager : public G4VisManager {
 
+public:
   //    RichTbVisManager();
-    virtual ~ RichTbVisManager();
-  static  RichTbVisManager*  getRichTbVisManagerInstance();
-  
-  private:
+  virtual ~RichTbVisManager();
+  static RichTbVisManager *getRichTbVisManagerInstance();
 
-     RichTbVisManager();
-   void RegisterGraphicsSystems();
+private:
+  RichTbVisManager();
+  void RegisterGraphicsSystems() override;
 
-  static RichTbVisManager* RichTbVisManagerInstance;
-  
+  static RichTbVisManager *RichTbVisManagerInstance;
 };
 
 #endif
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4Cerenkov.hh b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4Cerenkov.hh
index 2ff7adb838fd5cf69a70bd003e0880dd77e2fae6..e9acc05e944e77eb7478b7929fe34c0524aab15a 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4Cerenkov.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4Cerenkov.hh
@@ -24,12 +24,12 @@
 // $Id: RichTbG4Cerenkov.hh,v 1.5 2001/07/11 10:03:41 gunter Exp $
 // GEANT4 tag $Name: geant4-07-00 $
 //
-// 
+//
 ////////////////////////////////////////////////////////////////////////
-// Cerenkov Radiation Class Definition 
+// Cerenkov Radiation Class Definition
 ////////////////////////////////////////////////////////////////////////
 //
-// File:        RichTbG4Cerenkov.hh  
+// File:        RichTbG4Cerenkov.hh
 // Description:	Continuous Process -- Generation of Cerenkov Photons
 // Version:     2.0
 // Created:     1996-02-21
@@ -72,135 +72,107 @@
 // Class Definition
 /////////////////////
 
-class RichTbG4Cerenkov : public G4VContinuousProcess  
-{
+class RichTbG4Cerenkov : public G4VContinuousProcess {
 
 private:
+  //////////////
+  // Operators
+  //////////////
 
-        //////////////
-        // Operators
-        //////////////
-
-	// RichTbG4Cerenkov& operator=(const RichTbG4Cerenkov &right);
+  // RichTbG4Cerenkov& operator=(const RichTbG4Cerenkov &right);
 
 public: // Without description
+  ////////////////////////////////
+  // Constructors and Destructor
+  ////////////////////////////////
 
-	////////////////////////////////
-	// Constructors and Destructor
-	////////////////////////////////
+  RichTbG4Cerenkov(const G4String &processName = "Cerenkov");
 
-	RichTbG4Cerenkov(const G4String& processName = "Cerenkov");
+  // RichTbG4Cerenkov(const RichTbG4Cerenkov &right);
 
-	// RichTbG4Cerenkov(const RichTbG4Cerenkov &right);
+  ~RichTbG4Cerenkov();
 
-	~RichTbG4Cerenkov();	
-
-        ////////////
-        // Methods
-        ////////////
+  ////////////
+  // Methods
+  ////////////
 
 public: // With description
+  G4bool IsApplicable(const G4ParticleDefinition &aParticleType) override;
+  // Returns true -> 'is applicable', for all charged particles.
 
-        G4bool IsApplicable(const G4ParticleDefinition& aParticleType);
-        // Returns true -> 'is applicable', for all charged particles.
-
-	G4double GetContinuousStepLimit(const G4Track& aTrack,
-					G4double  ,
-					G4double  ,
-                                        G4double& );
-        // Returns the continuous step limit defined by the Cerenkov
-        // process.
-
-	G4VParticleChange* AlongStepDoIt(const G4Track& aTrack, 
-					const G4Step&  aStep);
-        // This is the method implementing the Cerenkov process.
-
-	void SetTrackSecondariesFirst(const G4bool state);
-        // If set, the primary particle tracking is interrupted and any 
-        // produced Cerenkov photons are tracked next. When all have 
-        // been tracked, the tracking of the primary resumes. 
-	
-	void SetMaxNumPhotonsPerStep(const G4int NumPhotons);
-        // Set the maximum number of Cerenkov photons allowed to be 
-        // generated during a tracking step. This is an average ONLY; 
-        // the actual number will vary around this average. If invoked, 
-        // the maximum photon stack will roughly be of the size set.
-        // If not called, the step is not limited by the number of 
-        // photons generated.
-
-        G4PhysicsTable* GetPhysicsTable() const;
-        // Returns the address of the physics table.
-
-        void DumpPhysicsTable() const;
-        // Prints the physics table.
+  G4double GetContinuousStepLimit(const G4Track &aTrack, G4double, G4double, G4double &) override;
+  // Returns the continuous step limit defined by the Cerenkov
+  // process.
 
-private:
+  G4VParticleChange *AlongStepDoIt(const G4Track &aTrack, const G4Step &aStep) override;
+  // This is the method implementing the Cerenkov process.
 
-        void BuildThePhysicsTable();
+  void SetTrackSecondariesFirst(const G4bool state);
+  // If set, the primary particle tracking is interrupted and any
+  // produced Cerenkov photons are tracked next. When all have
+  // been tracked, the tracking of the primary resumes.
 
-	/////////////////////
-	// Helper Functions
-	/////////////////////
+  void SetMaxNumPhotonsPerStep(const G4int NumPhotons);
+  // Set the maximum number of Cerenkov photons allowed to be
+  // generated during a tracking step. This is an average ONLY;
+  // the actual number will vary around this average. If invoked,
+  // the maximum photon stack will roughly be of the size set.
+  // If not called, the step is not limited by the number of
+  // photons generated.
 
-	G4double GetAverageNumberOfPhotons(const G4DynamicParticle *aParticle,
-		    		const G4Material *aMaterial,
-				    G4MaterialPropertyVector* Rindex) const;
+  G4PhysicsTable *GetPhysicsTable() const;
+  // Returns the address of the physics table.
 
-        ///////////////////////
-        // Class Data Members
-        ///////////////////////
+  void DumpPhysicsTable() const;
+  // Prints the physics table.
 
-protected:
+private:
+  void BuildThePhysicsTable();
 
-        G4PhysicsTable* thePhysicsTable;
-        //  A Physics Table can be either a cross-sections table or
-        //  an energy table (or can be used for other specific
-        //  purposes).
+  /////////////////////
+  // Helper Functions
+  /////////////////////
 
-private:
+  G4double GetAverageNumberOfPhotons(const G4DynamicParticle *aParticle, const G4Material *aMaterial,
+                                     G4MaterialPropertyVector *Rindex) const;
+
+  ///////////////////////
+  // Class Data Members
+  ///////////////////////
 
-	G4bool fTrackSecondariesFirst;
-	G4int  fMaxPhotons;
+protected:
+  G4PhysicsTable *thePhysicsTable;
+  //  A Physics Table can be either a cross-sections table or
+  //  an energy table (or can be used for other specific
+  //  purposes).
+
+private:
+  G4bool fTrackSecondariesFirst;
+  G4int fMaxPhotons;
 };
 
 ////////////////////
 // Inline methods
 ////////////////////
 
-inline 
-G4bool RichTbG4Cerenkov::IsApplicable(const G4ParticleDefinition& aParticleType)
-{
-   return (aParticleType.GetPDGCharge() != 0);
+inline G4bool RichTbG4Cerenkov::IsApplicable(const G4ParticleDefinition &aParticleType) {
+  return (aParticleType.GetPDGCharge() != 0);
 }
 
-inline 
-void RichTbG4Cerenkov::SetTrackSecondariesFirst(const G4bool state) 
-{ 
-	fTrackSecondariesFirst = state;
-}
+inline void RichTbG4Cerenkov::SetTrackSecondariesFirst(const G4bool state) { fTrackSecondariesFirst = state; }
 
-inline
-void RichTbG4Cerenkov::SetMaxNumPhotonsPerStep(const G4int NumPhotons) 
-{ 
-	fMaxPhotons = NumPhotons;
-}
+inline void RichTbG4Cerenkov::SetMaxNumPhotonsPerStep(const G4int NumPhotons) { fMaxPhotons = NumPhotons; }
 
-inline
-void RichTbG4Cerenkov::DumpPhysicsTable() const
-{
-        G4int PhysicsTableSize = thePhysicsTable->entries();
-        G4PhysicsOrderedFreeVector *v;
-
-        for (G4int i = 0 ; i < PhysicsTableSize ; i++ )
-        {
-        	v = (G4PhysicsOrderedFreeVector*)(*thePhysicsTable)[i];
-        	v->DumpValues();
-        }
-}
+inline void RichTbG4Cerenkov::DumpPhysicsTable() const {
+  G4int PhysicsTableSize = thePhysicsTable->entries();
+  G4PhysicsOrderedFreeVector *v;
 
-inline G4PhysicsTable* RichTbG4Cerenkov::GetPhysicsTable() const
-{
-  return thePhysicsTable;
+  for (G4int i = 0; i < PhysicsTableSize; i++) {
+    v = (G4PhysicsOrderedFreeVector *)(*thePhysicsTable)[i];
+    v->DumpValues();
+  }
 }
 
+inline G4PhysicsTable *RichTbG4Cerenkov::GetPhysicsTable() const { return thePhysicsTable; }
+
 #endif /* RichTbG4Cerenkov_h */
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4OpAbsorption.hh b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4OpAbsorption.hh
index 8b9173d371840f8f2f2f9734e7a47d476a115122..757db8e2880e4b411584a549a9be30c4176365ca 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4OpAbsorption.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4OpAbsorption.hh
@@ -68,59 +68,49 @@
 // Class Definition
 /////////////////////
 
-class RichTbG4OpAbsorption : public G4VDiscreteProcess 
-{
+class RichTbG4OpAbsorption : public G4VDiscreteProcess {
 
 private:
+  //////////////
+  // Operators
+  //////////////
 
-        //////////////
-        // Operators
-        //////////////
-
-        // RichTbG4OpAbsorption& operator=(const RichTbG4OpAbsorption &right);
+  // RichTbG4OpAbsorption& operator=(const RichTbG4OpAbsorption &right);
 
 public: // Without description
+  ////////////////////////////////
+  // Constructors and Destructor
+  ////////////////////////////////
 
-        ////////////////////////////////
-        // Constructors and Destructor
-        ////////////////////////////////
-
-        RichTbG4OpAbsorption(const G4String& processName = "OpAbsorption");
+  RichTbG4OpAbsorption(const G4String &processName = "OpAbsorption");
 
-        // RichTbG4OpAbsorption(const RichTbG4OpAbsorption &right);
+  // RichTbG4OpAbsorption(const RichTbG4OpAbsorption &right);
 
-	~RichTbG4OpAbsorption();
+  ~RichTbG4OpAbsorption();
 
-	////////////
-	// Methods
-        ////////////
+  ////////////
+  // Methods
+  ////////////
 
 public: // With description
+  G4bool IsApplicable(const G4ParticleDefinition &aParticleType) override;
+  // Returns true -> 'is applicable' only for an optical photon.
 
-        G4bool IsApplicable(const G4ParticleDefinition& aParticleType);
-        // Returns true -> 'is applicable' only for an optical photon.
-
-	G4double GetMeanFreePath(const G4Track& aTrack,
-				 G4double ,
-				 G4ForceCondition* );
-        // Returns the absorption length for bulk absorption of optical
-        // photons in media with a specified attenuation length. 
-
-	G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
- 				        const G4Step&  aStep);
-        // This is the method implementing bulk absorption of optical 
-        // photons.
+  G4double GetMeanFreePath(const G4Track &aTrack, G4double, G4ForceCondition *) override;
+  // Returns the absorption length for bulk absorption of optical
+  // photons in media with a specified attenuation length.
 
+  G4VParticleChange *PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) override;
+  // This is the method implementing bulk absorption of optical
+  // photons.
 };
 
 ////////////////////
 // Inline methods
 ////////////////////
 
-inline
-G4bool RichTbG4OpAbsorption::IsApplicable(const G4ParticleDefinition& aParticleType)
-{
-   return ( &aParticleType == G4OpticalPhoton::OpticalPhoton() );
+inline G4bool RichTbG4OpAbsorption::IsApplicable(const G4ParticleDefinition &aParticleType) {
+  return (&aParticleType == G4OpticalPhoton::OpticalPhoton());
 }
 
 #endif /* RichTbG4OpAbsorption_h */
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4OpBoundaryProcess.hh b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4OpBoundaryProcess.hh
index a5b43bb9f53fe9204f2cb37d58a8d41638d883e4..b1956a78dd12fc979c30d681bfcf0c17ce90d611 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4OpBoundaryProcess.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4OpBoundaryProcess.hh
@@ -24,7 +24,7 @@
 // $Id: RichTbG4OpBoundaryProcess.hh,v 1.12 2004/12/02 23:10:36 gum Exp $
 // GEANT4 tag $Name: geant4-07-00 $
 //
-// 
+//
 ////////////////////////////////////////////////////////////////////////
 // Optical Photon Boundary Process Class Definition
 ////////////////////////////////////////////////////////////////////////
@@ -35,9 +35,9 @@
 // Version:     1.1
 // Created:     1997-06-18
 // Modified:    1999-10-29 add method and class descriptors
-//              1999-10-10 - Fill NewMomentum/NewPolarization in 
+//              1999-10-10 - Fill NewMomentum/NewPolarization in
 //                           DoAbsorption. These members need to be
-//                           filled since DoIt calls 
+//                           filled since DoIt calls
 //                           aParticleChange.SetMomentumChange etc.
 //                           upon return (thanks to: Clark McGrew)
 //
@@ -45,7 +45,7 @@
 //              adopted from work by Werner Keil - April 2/96
 // mail:        gum@triumf.ca
 // modified and renamed to adapt to the RICH testbeam. SE 1-3-2005.
-// CVS version tag: 
+// CVS version tag:
 ////////////////////////////////////////////////////////////////////////
 
 #ifndef RichTbG4OpBoundaryProcess_h
@@ -71,147 +71,144 @@
 
 // Class Description:
 // Discrete Process -- reflection/refraction at optical interfaces.
-// Class inherits publicly from G4VDiscreteProcess.                  
-// Class Description - End:             
+// Class inherits publicly from G4VDiscreteProcess.
+// Class Description - End:
 
 /////////////////////
 // Class Definition
 /////////////////////
 
-enum RichTbG4OpBoundaryProcessStatus {  Undefined,
-                                  FresnelRefraction, FresnelReflection,
-                                  TotalInternalReflection,
-                                  LambertianReflection, LobeReflection,
-                                  SpikeReflection, BackScattering,
-                                  Absorption, Detection, NotAtBoundary,
-                                  SameMaterial, StepTooSmall, NoRINDEX };
+enum RichTbG4OpBoundaryProcessStatus {
+  Undefined,
+  FresnelRefraction,
+  FresnelReflection,
+  TotalInternalReflection,
+  LambertianReflection,
+  LobeReflection,
+  SpikeReflection,
+  BackScattering,
+  Absorption,
+  Detection,
+  NotAtBoundary,
+  SameMaterial,
+  StepTooSmall,
+  NoRINDEX
+};
 
-class RichTbG4OpBoundaryProcess : public G4VDiscreteProcess 
-{
+class RichTbG4OpBoundaryProcess : public G4VDiscreteProcess {
 
 private:
+  //////////////
+  // Operators
+  //////////////
 
-        //////////////
-        // Operators
-        //////////////
-
-        // RichTbG4OpBoundaryProcess& operator=(const RichTbG4OpBoundaryProcess &right);
+  // RichTbG4OpBoundaryProcess& operator=(const RichTbG4OpBoundaryProcess &right);
 
-        // RichTbG4OpBoundaryProcess(const RichTbG4OpBoundaryProcess &right);
+  // RichTbG4OpBoundaryProcess(const RichTbG4OpBoundaryProcess &right);
 
 public: // Without description
+  ////////////////////////////////
+  // Constructors and Destructor
+  ////////////////////////////////
 
-        ////////////////////////////////
-        // Constructors and Destructor
-        ////////////////////////////////
+  RichTbG4OpBoundaryProcess(const G4String &processName = "OpBoundary");
 
-        RichTbG4OpBoundaryProcess(const G4String& processName = "OpBoundary");
+  ~RichTbG4OpBoundaryProcess();
 
-	~RichTbG4OpBoundaryProcess();
-
-	////////////
-	// Methods
-        ////////////
+  ////////////
+  // Methods
+  ////////////
 
 public: // With description
+  G4bool IsApplicable(const G4ParticleDefinition &aParticleType) override;
+  // Returns true -> 'is applicable' only for an optical photon.
 
-        G4bool IsApplicable(const G4ParticleDefinition& aParticleType);
-        // Returns true -> 'is applicable' only for an optical photon.
-
-	G4double GetMeanFreePath(const G4Track& ,
-				 G4double ,
-				 G4ForceCondition* condition);
-        // Returns infinity; i. e. the process does not limit the step,
-        // but sets the 'Forced' condition for the DoIt to be invoked at
-        // every step. However, only at a boundary will any action be
-        // taken. 
+  G4double GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *condition) override;
+  // Returns infinity; i. e. the process does not limit the step,
+  // but sets the 'Forced' condition for the DoIt to be invoked at
+  // every step. However, only at a boundary will any action be
+  // taken.
 
-	G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
-				       const G4Step&  aStep);
-        // This is the method implementing boundary processes.
+  G4VParticleChange *PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) override;
+  // This is the method implementing boundary processes.
 
-	G4OpticalSurfaceModel GetModel() const;
-        // Returns the optical surface mode.
+  G4OpticalSurfaceModel GetModel() const;
+  // Returns the optical surface mode.
 
-        RichTbG4OpBoundaryProcessStatus GetStatus() const;
-        // Returns the current status.
+  RichTbG4OpBoundaryProcessStatus GetStatus() const;
+  // Returns the current status.
 
-	void           SetModel(G4OpticalSurfaceModel model);
-	// Set the optical surface model to be followed 
-        // (glisur || unified). 
+  void SetModel(G4OpticalSurfaceModel model);
+  // Set the optical surface model to be followed
+  // (glisur || unified).
 
 private:
+  void G4Swap(G4double *a, G4double *b) const;
 
-	void G4Swap(G4double* a, G4double* b) const;
+  void G4Swap(G4Material *a, G4Material *b) const;
 
-	void G4Swap(G4Material* a, G4Material* b) const;
+  void G4VectorSwap(G4ThreeVector *vec1, G4ThreeVector *vec2) const;
 
-	void G4VectorSwap(G4ThreeVector* vec1, G4ThreeVector* vec2) const;
+  G4bool G4BooleanRand(const G4double prob) const;
 
-	G4bool G4BooleanRand(const G4double prob) const;
+  G4ThreeVector G4IsotropicRand() const;
 
-	G4ThreeVector G4IsotropicRand() const;
+  G4ThreeVector G4LambertianRand(const G4ThreeVector &normal);
 
-	G4ThreeVector G4LambertianRand(const G4ThreeVector& normal);
+  G4ThreeVector G4PlaneVectorRand(const G4ThreeVector &normal) const;
 
-	G4ThreeVector G4PlaneVectorRand(const G4ThreeVector& normal) const; 
+  G4ThreeVector GetFacetNormal(const G4ThreeVector &Momentum, const G4ThreeVector &Normal) const;
 
-	G4ThreeVector GetFacetNormal(const G4ThreeVector& Momentum,
-				     const G4ThreeVector&  Normal) const;
+  void DielectricMetal();
+  void DielectricDielectric();
 
-	void DielectricMetal();
-	void DielectricDielectric();
-
-	void ChooseReflection();
-	void DoAbsorption();
-	void DoReflection();
+  void ChooseReflection();
+  void DoAbsorption();
+  void DoReflection();
 
 private:
+  G4double thePhotonMomentum;
 
-	G4double thePhotonMomentum;
-
-	G4ThreeVector OldMomentum;
-	G4ThreeVector OldPolarization;
+  G4ThreeVector OldMomentum;
+  G4ThreeVector OldPolarization;
 
-	G4ThreeVector NewMomentum;
-	G4ThreeVector NewPolarization;
+  G4ThreeVector NewMomentum;
+  G4ThreeVector NewPolarization;
 
-	G4ThreeVector theGlobalNormal;
-	G4ThreeVector theFacetNormal;
+  G4ThreeVector theGlobalNormal;
+  G4ThreeVector theFacetNormal;
 
-	G4Material* Material1;
-	G4Material* Material2;
+  G4Material *Material1;
+  G4Material *Material2;
 
-	G4OpticalSurface* OpticalSurface;
+  G4OpticalSurface *OpticalSurface;
 
-	G4double Rindex1;
-	G4double Rindex2;
+  G4double Rindex1;
+  G4double Rindex2;
 
-	G4double cost1, cost2, sint1, sint2;
+  G4double cost1, cost2, sint1, sint2;
 
-	RichTbG4OpBoundaryProcessStatus theStatus;
+  RichTbG4OpBoundaryProcessStatus theStatus;
 
-	G4OpticalSurfaceModel theModel;
+  G4OpticalSurfaceModel theModel;
 
-	G4OpticalSurfaceFinish theFinish;
+  G4OpticalSurfaceFinish theFinish;
 
-	G4double theReflectivity;
-	G4double theEfficiency;
-	G4double prob_sl, prob_ss, prob_bs;
+  G4double theReflectivity;
+  G4double theEfficiency;
+  G4double prob_sl, prob_ss, prob_bs;
 
-       G4int CurStepNum;
-       G4int theMaxPhotStepNumInBoundaryProc;
+  G4int CurStepNum;
+  G4int theMaxPhotStepNumInBoundaryProc;
 };
 
 ////////////////////
 // Inline methods
 ////////////////////
 
-inline
-void RichTbG4OpBoundaryProcess::G4Swap(G4double* a, G4double* b) const
-{
-	// swaps the contents of the objects pointed 
-	// to by 'a' and 'b'!
+inline void RichTbG4OpBoundaryProcess::G4Swap(G4double *a, G4double *b) const {
+  // swaps the contents of the objects pointed
+  // to by 'a' and 'b'!
 
   G4double temp;
 
@@ -220,24 +217,19 @@ void RichTbG4OpBoundaryProcess::G4Swap(G4double* a, G4double* b) const
   *b = temp;
 }
 
-inline
-void RichTbG4OpBoundaryProcess::G4Swap(G4Material* a, G4Material* b) const
-{
-	// ONLY swaps the pointers; i.e. what used to be pointed
-	// to by 'a' is now pointed to by 'b' and vice versa!
+inline void RichTbG4OpBoundaryProcess::G4Swap(G4Material *a, G4Material *b) const {
+  // ONLY swaps the pointers; i.e. what used to be pointed
+  // to by 'a' is now pointed to by 'b' and vice versa!
 
-   G4Material* temp = a;
+  G4Material *temp = a;
 
-   a = b;
-   b = temp;
+  a = b;
+  b = temp;
 }
 
-inline
-void RichTbG4OpBoundaryProcess::G4VectorSwap(G4ThreeVector* vec1,
-				       G4ThreeVector* vec2) const
-{
-        // swaps the contents of the objects pointed
-        // to by 'vec1' and 'vec2'!
+inline void RichTbG4OpBoundaryProcess::G4VectorSwap(G4ThreeVector *vec1, G4ThreeVector *vec2) const {
+  // swaps the contents of the objects pointed
+  // to by 'vec1' and 'vec2'!
 
   G4ThreeVector temp;
 
@@ -246,17 +238,13 @@ void RichTbG4OpBoundaryProcess::G4VectorSwap(G4ThreeVector* vec1,
   *vec2 = temp;
 }
 
-inline
-G4bool RichTbG4OpBoundaryProcess::G4BooleanRand(const G4double prob) const
-{
+inline G4bool RichTbG4OpBoundaryProcess::G4BooleanRand(const G4double prob) const {
   /* Returns a random boolean variable with the specified probability */
 
   return (G4UniformRand() < prob);
 }
 
-inline
-G4ThreeVector RichTbG4OpBoundaryProcess::G4IsotropicRand() const
-{
+inline G4ThreeVector RichTbG4OpBoundaryProcess::G4IsotropicRand() const {
   /* Returns a random isotropic unit vector. */
 
   G4ThreeVector vect;
@@ -275,10 +263,7 @@ G4ThreeVector RichTbG4OpBoundaryProcess::G4IsotropicRand() const
   return vect.unit();
 }
 
-inline
-G4ThreeVector RichTbG4OpBoundaryProcess::
-	      G4LambertianRand(const G4ThreeVector& normal)
-{
+inline G4ThreeVector RichTbG4OpBoundaryProcess::G4LambertianRand(const G4ThreeVector &normal) {
   /* Returns a random lambertian unit vector. */
 
   G4ThreeVector vect;
@@ -298,119 +283,87 @@ G4ThreeVector RichTbG4OpBoundaryProcess::
   return vect;
 }
 
-inline
-G4ThreeVector RichTbG4OpBoundaryProcess::
-	      G4PlaneVectorRand(const G4ThreeVector& normal) const
+inline G4ThreeVector RichTbG4OpBoundaryProcess::G4PlaneVectorRand(const G4ThreeVector &normal) const
 
-  /* This function chooses a random vector within a plane given
-     by the unit normal */
+/* This function chooses a random vector within a plane given
+   by the unit normal */
 {
   G4ThreeVector vec1 = normal.orthogonal();
 
   G4ThreeVector vec2 = vec1.cross(normal);
 
-  G4double phi = CLHEP::twopi*G4UniformRand();
+  G4double phi = CLHEP::twopi * G4UniformRand();
   G4double cosphi = std::cos(phi);
   G4double sinphi = std::sin(phi);
 
   return cosphi * vec1 + sinphi * vec2;
 }
 
-inline
-G4bool RichTbG4OpBoundaryProcess::IsApplicable(const G4ParticleDefinition& 
-					               aParticleType)
-{
-   return ( &aParticleType == G4OpticalPhoton::OpticalPhoton() );
+inline G4bool RichTbG4OpBoundaryProcess::IsApplicable(const G4ParticleDefinition &aParticleType) {
+  return (&aParticleType == G4OpticalPhoton::OpticalPhoton());
 }
 
-inline
-G4OpticalSurfaceModel RichTbG4OpBoundaryProcess::GetModel() const
-{
-   return theModel;
-}
+inline G4OpticalSurfaceModel RichTbG4OpBoundaryProcess::GetModel() const { return theModel; }
 
-inline
-RichTbG4OpBoundaryProcessStatus RichTbG4OpBoundaryProcess::GetStatus() const
-{
-   return theStatus;
-}
+inline RichTbG4OpBoundaryProcessStatus RichTbG4OpBoundaryProcess::GetStatus() const { return theStatus; }
 
-inline
-void RichTbG4OpBoundaryProcess::SetModel(G4OpticalSurfaceModel model)
-{
-   theModel = model;
-}
+inline void RichTbG4OpBoundaryProcess::SetModel(G4OpticalSurfaceModel model) { theModel = model; }
 
-inline
-void RichTbG4OpBoundaryProcess::ChooseReflection()
-{
-                 G4double rand = G4UniformRand();
-                 if ( rand >= 0.0 && rand < prob_ss ) {
-                    theStatus = SpikeReflection;
-                    theFacetNormal = theGlobalNormal;
-                 }
-                 else if ( rand >= prob_ss &&
-                           rand <= prob_ss+prob_sl) {
-                    theStatus = LobeReflection;
-                 }
-                 else if ( rand > prob_ss+prob_sl &&
-                           rand < prob_ss+prob_sl+prob_bs ) {
-                    theStatus = BackScattering;
-                 }
-                 else {
-                    theStatus = LambertianReflection;
-                 }
+inline void RichTbG4OpBoundaryProcess::ChooseReflection() {
+  G4double rand = G4UniformRand();
+  if (rand >= 0.0 && rand < prob_ss) {
+    theStatus = SpikeReflection;
+    theFacetNormal = theGlobalNormal;
+  } else if (rand >= prob_ss && rand <= prob_ss + prob_sl) {
+    theStatus = LobeReflection;
+  } else if (rand > prob_ss + prob_sl && rand < prob_ss + prob_sl + prob_bs) {
+    theStatus = BackScattering;
+  } else {
+    theStatus = LambertianReflection;
+  }
 }
 
-inline
-void RichTbG4OpBoundaryProcess::DoAbsorption()
-{
-              theStatus = Absorption;
-
-              if ( G4BooleanRand(theEfficiency) ) {
-		
-                 // EnergyDeposited =/= 0 means: photon has been detected
-                 theStatus = Detection;
-                 aParticleChange.ProposeLocalEnergyDeposit(thePhotonMomentum);
-              }
-              else {
-                 aParticleChange.ProposeLocalEnergyDeposit(0.0);
-              }
-
-              NewMomentum = OldMomentum;
-              NewPolarization = OldPolarization;
-
-	      // aParticleChange.ProposeEnergy(0.0);
-              aParticleChange.ProposeTrackStatus(fStopAndKill);
-}
+inline void RichTbG4OpBoundaryProcess::DoAbsorption() {
+  theStatus = Absorption;
 
-inline
-void RichTbG4OpBoundaryProcess::DoReflection()
-{
-        if ( theStatus == LambertianReflection ) {
+  if (G4BooleanRand(theEfficiency)) {
+
+    // EnergyDeposited =/= 0 means: photon has been detected
+    theStatus = Detection;
+    aParticleChange.ProposeLocalEnergyDeposit(thePhotonMomentum);
+  } else {
+    aParticleChange.ProposeLocalEnergyDeposit(0.0);
+  }
+
+  NewMomentum = OldMomentum;
+  NewPolarization = OldPolarization;
+
+  // aParticleChange.ProposeEnergy(0.0);
+  aParticleChange.ProposeTrackStatus(fStopAndKill);
+}
 
-          NewMomentum = G4LambertianRand(theGlobalNormal);
-          theFacetNormal = (NewMomentum - OldMomentum).unit();
+inline void RichTbG4OpBoundaryProcess::DoReflection() {
+  if (theStatus == LambertianReflection) {
 
-        }
-        else if ( theFinish == ground ) {
+    NewMomentum = G4LambertianRand(theGlobalNormal);
+    theFacetNormal = (NewMomentum - OldMomentum).unit();
 
-	  theStatus = LobeReflection;
-          theFacetNormal = GetFacetNormal(OldMomentum,theGlobalNormal);
-          G4double PdotN = OldMomentum * theFacetNormal;
-          NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
+  } else if (theFinish == ground) {
 
-        }
-        else {
+    theStatus = LobeReflection;
+    theFacetNormal = GetFacetNormal(OldMomentum, theGlobalNormal);
+    G4double PdotN = OldMomentum * theFacetNormal;
+    NewMomentum = OldMomentum - (2. * PdotN) * theFacetNormal;
 
-          theStatus = SpikeReflection;
-          theFacetNormal = theGlobalNormal;
-          G4double PdotN = OldMomentum * theFacetNormal;
-          NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
+  } else {
 
-        }
-        G4double EdotN = OldPolarization * theFacetNormal;
-        NewPolarization = -OldPolarization + (2.*EdotN)*theFacetNormal;
+    theStatus = SpikeReflection;
+    theFacetNormal = theGlobalNormal;
+    G4double PdotN = OldMomentum * theFacetNormal;
+    NewMomentum = OldMomentum - (2. * PdotN) * theFacetNormal;
+  }
+  G4double EdotN = OldPolarization * theFacetNormal;
+  NewPolarization = -OldPolarization + (2. * EdotN) * theFacetNormal;
 }
 
 #endif /* RichTbG4OpBoundaryProcess_h */
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4OpRayleigh.hh b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4OpRayleigh.hh
index 8843630ecc62293d381bb7bb549c89ff60e779ec..ca6b3dea48c911955bec6c7527bdcbaea4510709 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4OpRayleigh.hh
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/includeG4/RichTbG4OpRayleigh.hh
@@ -24,13 +24,13 @@
 // $Id: RichTbG4OpRayleigh.hh,v 1.7 2004/04/27 00:26:34 gum Exp $
 // GEANT4 tag $Name: geant4-07-00 $
 //
-// 
+//
 ////////////////////////////////////////////////////////////////////////
 // Optical Photon Rayleigh Scattering Class Definition
 ////////////////////////////////////////////////////////////////////////
 //
 // File:        RichTbG4OpRayleigh.hh
-// Description: Discrete Process -- Rayleigh scattering of optical photons 
+// Description: Discrete Process -- Rayleigh scattering of optical photons
 // Version:     1.0
 // Created:     1996-05-31
 // Author:      Juliet Armstrong
@@ -70,110 +70,90 @@
 // Class Definition
 /////////////////////
 
-class RichTbG4OpRayleigh : public G4VDiscreteProcess 
-{
+class RichTbG4OpRayleigh : public G4VDiscreteProcess {
 
 private:
- 
-        //////////////
-        // Operators
-        //////////////
+  //////////////
+  // Operators
+  //////////////
 
-        // RichTbG4OpRayleigh& operator=(const RichTbG4OpRayleigh &right);
+  // RichTbG4OpRayleigh& operator=(const RichTbG4OpRayleigh &right);
 
 public: // Without description
+  ////////////////////////////////
+  // Constructors and Destructor
+  ////////////////////////////////
 
-        ////////////////////////////////
-        // Constructors and Destructor
-        ////////////////////////////////
- 
-        RichTbG4OpRayleigh(const G4String& processName = "OpRayleigh");
+  RichTbG4OpRayleigh(const G4String &processName = "OpRayleigh");
 
-        // RichTbG4OpRayleigh(const RichTbG4OpRayleigh &right);
+  // RichTbG4OpRayleigh(const RichTbG4OpRayleigh &right);
 
-	~RichTbG4OpRayleigh();
+  ~RichTbG4OpRayleigh();
 
-        ////////////
-        // Methods
-        ////////////
+  ////////////
+  // Methods
+  ////////////
 
 public: // With description
+  G4bool IsApplicable(const G4ParticleDefinition &aParticleType) override;
+  // Returns true -> 'is applicable' only for an optical photon.
 
-        G4bool IsApplicable(const G4ParticleDefinition& aParticleType);
-        // Returns true -> 'is applicable' only for an optical photon.
-
-        G4double GetMeanFreePath(const G4Track& aTrack,
-				 G4double ,
-                                 G4ForceCondition* );
-        // Returns the mean free path for Rayleigh scattering in water.
-        // --- Not yet implemented for other materials! ---
+  G4double GetMeanFreePath(const G4Track &aTrack, G4double, G4ForceCondition *) override;
+  // Returns the mean free path for Rayleigh scattering in water.
+  // --- Not yet implemented for other materials! ---
 
-        G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
-                                       const G4Step&  aStep);
-        // This is the method implementing Rayleigh scattering.
+  G4VParticleChange *PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) override;
+  // This is the method implementing Rayleigh scattering.
 
-        G4PhysicsTable* GetPhysicsTable() const;
-        // Returns the address of the physics table.
+  G4PhysicsTable *GetPhysicsTable() const;
+  // Returns the address of the physics table.
 
-        void DumpPhysicsTable() const;
-        // Prints the physics table.
+  void DumpPhysicsTable() const;
+  // Prints the physics table.
 
 private:
+  void BuildThePhysicsTable();
 
-        void BuildThePhysicsTable();
+  /////////////////////
+  // Helper Functions
+  /////////////////////
 
-        /////////////////////
-        // Helper Functions
-        /////////////////////
+  G4PhysicsOrderedFreeVector *RayleighAttenuationLengthGenerator(G4MaterialPropertiesTable *aMPT);
 
-	G4PhysicsOrderedFreeVector* RayleighAttenuationLengthGenerator(
-					G4MaterialPropertiesTable *aMPT);
-
-        ///////////////////////
-        // Class Data Members
-        ///////////////////////
+  ///////////////////////
+  // Class Data Members
+  ///////////////////////
 
 protected:
-
-        G4PhysicsTable* thePhysicsTable;
-        //  A Physics Table can be either a cross-sections table or
-        //  an energy table (or can be used for other specific
-        //  purposes).
+  G4PhysicsTable *thePhysicsTable;
+  //  A Physics Table can be either a cross-sections table or
+  //  an energy table (or can be used for other specific
+  //  purposes).
 
 private:
-
-        G4bool DefaultWater;
-
+  G4bool DefaultWater;
 };
 
 ////////////////////
 // Inline methods
 ////////////////////
 
-inline
-G4bool RichTbG4OpRayleigh::IsApplicable(const G4ParticleDefinition& aParticleType)
-{
-  return ( &aParticleType == G4OpticalPhoton::OpticalPhoton() );
+inline G4bool RichTbG4OpRayleigh::IsApplicable(const G4ParticleDefinition &aParticleType) {
+  return (&aParticleType == G4OpticalPhoton::OpticalPhoton());
 }
 
-inline
-void RichTbG4OpRayleigh::DumpPhysicsTable() const
+inline void RichTbG4OpRayleigh::DumpPhysicsTable() const
 
 {
-        G4int PhysicsTableSize = thePhysicsTable->entries();
-        G4PhysicsOrderedFreeVector *v;
-
-        for (G4int i = 0 ; i < PhysicsTableSize ; i++ )
-        {
-                v = (G4PhysicsOrderedFreeVector*)(*thePhysicsTable)[i];
-                v->DumpValues();
-        }
-}
+  G4int PhysicsTableSize = thePhysicsTable->entries();
+  G4PhysicsOrderedFreeVector *v;
 
-inline G4PhysicsTable* RichTbG4OpRayleigh::GetPhysicsTable() const
-{
-  return thePhysicsTable;
+  for (G4int i = 0; i < PhysicsTableSize; i++) {
+    v = (G4PhysicsOrderedFreeVector *)(*thePhysicsTable)[i];
+    v->DumpValues();
+  }
 }
 
+inline G4PhysicsTable *RichTbG4OpRayleigh::GetPhysicsTable() const { return thePhysicsTable; }
 
 #endif /* RichTbG4OpRayleigh_h */
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4Cerenkov.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4Cerenkov.cc
index f0494642524086592261f3d6444e131443c43974..6493d7c0603c7f74931248b75603e6b5eb5ec2ce 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4Cerenkov.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4Cerenkov.cc
@@ -28,15 +28,15 @@
 // Cerenkov Radiation Class Implementation
 ////////////////////////////////////////////////////////////////////////
 //
-// File:        RichTbG4Cerenkov.cc 
+// File:        RichTbG4Cerenkov.cc
 // Description: Continuous Process -- Generation of Cerenkov Photons
 // Version:     2.1
-// Created:     1996-02-21  
+// Created:     1996-02-21
 // Author:      Juliet Armstrong
-// Updated:     2001-09-17, migration of Materials to pure STL (mma) 
+// Updated:     2001-09-17, migration of Materials to pure STL (mma)
 //              2000-11-12 by Peter Gumplinger
 //              > add check on CerenkovAngleIntegrals->IsFilledVectorExist()
-//              in method GetAverageNumberOfPhotons 
+//              in method GetAverageNumberOfPhotons
 //              > and a test for MeanNumPhotons <= 0.0 in DoIt
 //              2000-09-18 by Peter Gumplinger
 //              > change: aSecondaryPosition=x0+rand*aStep.GetDeltaPosition();
@@ -52,541 +52,499 @@
 //        renamed the class.
 ////////////////////////////////////////////////////////////////////////
 
-#include "Geant4/G4ios.hh"
-#include "Geant4/G4Poisson.hh"
 #include "RichTbG4Cerenkov.hh"
-#include "RichTbPhotonUserInfoAttach.hh"
+#include "Geant4/G4Poisson.hh"
+#include "Geant4/G4ios.hh"
 #include "RichTbPhotonProdHisto.hh"
+#include "RichTbPhotonUserInfoAttach.hh"
 
 using namespace std;
 
 /////////////////////////
-// Class Implementation  
+// Class Implementation
 /////////////////////////
 
-        //////////////
-        // Operators
-        //////////////
+//////////////
+// Operators
+//////////////
 
 // RichTbG4Cerenkov::operator=(const RichTbG4Cerenkov &right)
 // {
 // }
 
-        /////////////////
-        // Constructors
-        /////////////////
+/////////////////
+// Constructors
+/////////////////
 
-RichTbG4Cerenkov::RichTbG4Cerenkov(const G4String& processName)
-           : G4VContinuousProcess(processName)
-{
-	fTrackSecondariesFirst = false;
-	fMaxPhotons = 0;
+RichTbG4Cerenkov::RichTbG4Cerenkov(const G4String &processName) : G4VContinuousProcess(processName) {
+  fTrackSecondariesFirst = false;
+  fMaxPhotons = 0;
 
-        thePhysicsTable = NULL;
+  thePhysicsTable = NULL;
 
-	if (verboseLevel>0) {
-           G4cout << GetProcessName() << " is created " << G4endl;
-	}
+  if (verboseLevel > 0) {
+    G4cout << GetProcessName() << " is created " << G4endl;
+  }
 
-	BuildThePhysicsTable();
+  BuildThePhysicsTable();
 }
 
 // RichTbG4Cerenkov::RichTbG4Cerenkov(const RichTbG4Cerenkov &right)
 // {
 // }
 
-        ////////////////
-        // Destructors
-        ////////////////
+////////////////
+// Destructors
+////////////////
 
-RichTbG4Cerenkov::~RichTbG4Cerenkov() 
-{
-	if (thePhysicsTable != NULL) {
-	   thePhysicsTable->clearAndDestroy();
-           delete thePhysicsTable;
-	}
+RichTbG4Cerenkov::~RichTbG4Cerenkov() {
+  if (thePhysicsTable != NULL) {
+    thePhysicsTable->clearAndDestroy();
+    delete thePhysicsTable;
+  }
 }
 
-        ////////////
-        // Methods
-        ////////////
+////////////
+// Methods
+////////////
 
 // AlongStepDoIt
 // -------------
 //
-G4VParticleChange*
-RichTbG4Cerenkov::AlongStepDoIt(const G4Track& aTrack, const G4Step& aStep)
+G4VParticleChange *RichTbG4Cerenkov::AlongStepDoIt(const G4Track &aTrack, const G4Step &aStep)
 
 // This routine is called for each tracking Step of a charged particle
 // in a radiator. A Poisson-distributed number of photons is generated
 // according to the Cerenkov formula, distributed evenly along the track
-// segment and uniformly azimuth w.r.t. the particle direction. The 
-// parameters are then transformed into the Master Reference System, and 
-// they are added to the particle change. 
+// segment and uniformly azimuth w.r.t. the particle direction. The
+// parameters are then transformed into the Master Reference System, and
+// they are added to the particle change.
 
 {
-	//////////////////////////////////////////////////////
-	// Should we ensure that the material is dispersive?
-	//////////////////////////////////////////////////////
+  //////////////////////////////////////////////////////
+  // Should we ensure that the material is dispersive?
+  //////////////////////////////////////////////////////
 
-        aParticleChange.Initialize(aTrack);
+  aParticleChange.Initialize(aTrack);
 
-	//        G4cout<<" G4Cerenkov ch trackid stepnum "<<aTrack.GetTrackID()<<"  "<<aTrack.GetCurrentStepNumber() <<G4endl;
-        const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
-        const G4Material* aMaterial = aTrack.GetMaterial();
+  //        G4cout<<" G4Cerenkov ch trackid stepnum "<<aTrack.GetTrackID()<<"  "<<aTrack.GetCurrentStepNumber()
+  //        <<G4endl;
+  const G4DynamicParticle *aParticle = aTrack.GetDynamicParticle();
+  const G4Material *aMaterial = aTrack.GetMaterial();
 
-	G4StepPoint* pPreStepPoint  = aStep.GetPreStepPoint();
-	G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
+  G4StepPoint *pPreStepPoint = aStep.GetPreStepPoint();
+  G4StepPoint *pPostStepPoint = aStep.GetPostStepPoint();
 
-	G4ThreeVector x0 = pPreStepPoint->GetPosition();
-        G4ThreeVector p0 = aStep.GetDeltaPosition().unit();
-	G4double t0 = pPreStepPoint->GetGlobalTime();
+  G4ThreeVector x0 = pPreStepPoint->GetPosition();
+  G4ThreeVector p0 = aStep.GetDeltaPosition().unit();
+  G4double t0 = pPreStepPoint->GetGlobalTime();
 
-        G4MaterialPropertiesTable* aMaterialPropertiesTable =
-                               aMaterial->GetMaterialPropertiesTable();
-        if (!aMaterialPropertiesTable)
-           return G4VContinuousProcess::AlongStepDoIt(aTrack, aStep);
+  G4MaterialPropertiesTable *aMaterialPropertiesTable = aMaterial->GetMaterialPropertiesTable();
+  if (!aMaterialPropertiesTable)
+    return G4VContinuousProcess::AlongStepDoIt(aTrack, aStep);
 
-	       G4MaterialPropertyVector* Rindex = 
-                aMaterialPropertiesTable->GetProperty("CKVRNDX"); 
-        if (!Rindex) 
-	   return G4VContinuousProcess::AlongStepDoIt(aTrack, aStep);
+  G4MaterialPropertyVector *Rindex = aMaterialPropertiesTable->GetProperty("CKVRNDX");
+  if (!Rindex)
+    return G4VContinuousProcess::AlongStepDoIt(aTrack, aStep);
 
-	G4double MeanNumPhotons = 
-                 GetAverageNumberOfPhotons(aParticle,aMaterial,Rindex);
+  G4double MeanNumPhotons = GetAverageNumberOfPhotons(aParticle, aMaterial, Rindex);
 
-        if (MeanNumPhotons <= 0.0) {
+  if (MeanNumPhotons <= 0.0) {
 
-                // return unchanged particle and no secondaries
+    // return unchanged particle and no secondaries
 
-                aParticleChange.SetNumberOfSecondaries(0);
- 
-                return G4VContinuousProcess::AlongStepDoIt(aTrack, aStep);
+    aParticleChange.SetNumberOfSecondaries(0);
 
-        }
+    return G4VContinuousProcess::AlongStepDoIt(aTrack, aStep);
+  }
 
-        G4double step_length;
-        step_length = aStep.GetStepLength();
-	//	G4cout<<"G4Cerenkov MeanNumPhot steplen zpre zpost "<< MeanNumPhotons<<"  "<<step_length<<"   "
-        //      << (pPreStepPoint->GetPosition()).z()<<"   "<<(pPostStepPoint->GetPosition()).z()<< G4endl;
+  G4double step_length;
+  step_length = aStep.GetStepLength();
+  //	G4cout<<"G4Cerenkov MeanNumPhot steplen zpre zpost "<< MeanNumPhotons<<"  "<<step_length<<"   "
+  //      << (pPreStepPoint->GetPosition()).z()<<"   "<<(pPostStepPoint->GetPosition()).z()<< G4endl;
 
-	MeanNumPhotons = MeanNumPhotons * step_length;
+  MeanNumPhotons = MeanNumPhotons * step_length;
 
+  G4int NumPhotons = (G4int)G4Poisson(MeanNumPhotons);
 
-	G4int NumPhotons = (G4int) G4Poisson(MeanNumPhotons);
+  if (NumPhotons <= 0) {
 
-	if (NumPhotons <= 0) {
+    // return unchanged particle and no secondaries
 
-		// return unchanged particle and no secondaries  
+    aParticleChange.SetNumberOfSecondaries(0);
 
-		aParticleChange.SetNumberOfSecondaries(0);
-		
-                return G4VContinuousProcess::AlongStepDoIt(aTrack, aStep);
-	}
+    return G4VContinuousProcess::AlongStepDoIt(aTrack, aStep);
+  }
 
-	////////////////////////////////////////////////////////////////
+  ////////////////////////////////////////////////////////////////
 
-	aParticleChange.SetNumberOfSecondaries(NumPhotons);
+  aParticleChange.SetNumberOfSecondaries(NumPhotons);
 
-        if (fTrackSecondariesFirst) {
-           if (aTrack.GetTrackStatus() == fAlive )
-                   aParticleChange.ProposeTrackStatus(fSuspend);
-        }
-	
-	////////////////////////////////////////////////////////////////
+  if (fTrackSecondariesFirst) {
+    if (aTrack.GetTrackStatus() == fAlive)
+      aParticleChange.ProposeTrackStatus(fSuspend);
+  }
 
-        //	G4double Pmin = Rindex->GetMinPhotonMomentum();
-        //	G4double Pmax = Rindex->GetMaxPhotonMomentum();
+  ////////////////////////////////////////////////////////////////
 
-  G4double Pmin = Rindex->GetMinLowEdgeEnergy(); // for G4.95 onwards
-  G4double Pmax = Rindex->GetMaxLowEdgeEnergy();  //for G4.95.onwards
+  //	G4double Pmin = Rindex->GetMinPhotonMomentum();
+  //	G4double Pmax = Rindex->GetMaxPhotonMomentum();
 
+  G4double Pmin = Rindex->GetMinLowEdgeEnergy(); // for G4.95 onwards
+  G4double Pmax = Rindex->GetMaxLowEdgeEnergy(); // for G4.95.onwards
 
-	G4double dp = Pmax - Pmin;
+  G4double dp = Pmax - Pmin;
 
   //	G4double nMax = Rindex->GetMaxProperty();
-  //	G4double nMin = Rindex->GetMinValue();	
-	G4double nMax = Rindex->GetMaxValue();
+  //	G4double nMin = Rindex->GetMinValue();
+  G4double nMax = Rindex->GetMaxValue();
 
-        G4double BetaInverse = aParticle->GetTotalEnergy() /
-	   	 	       aParticle->GetTotalMomentum();
+  G4double BetaInverse = aParticle->GetTotalEnergy() / aParticle->GetTotalMomentum();
 
-        // G4cout<<" RichG4Cerenkov energy mom betainverse max refindex "<<
-        //      aParticle->GetTotalEnergy()<<"  "<<aParticle->GetTotalMomentum()
-        //      <<"   "<< BetaInverse<<"   "<< nMax << G4endl;
-	G4double maxCos = BetaInverse / nMax; 
-	G4double maxSin2 = (1.0 - maxCos) * (1.0 + maxCos);
+  // G4cout<<" RichG4Cerenkov energy mom betainverse max refindex "<<
+  //      aParticle->GetTotalEnergy()<<"  "<<aParticle->GetTotalMomentum()
+  //      <<"   "<< BetaInverse<<"   "<< nMax << G4endl;
+  G4double maxCos = BetaInverse / nMax;
+  G4double maxSin2 = (1.0 - maxCos) * (1.0 + maxCos);
 
-	for (G4int i = 0; i < NumPhotons; i++) {
+  for (G4int i = 0; i < NumPhotons; i++) {
 
-		// Determine photon momentum
+    // Determine photon momentum
 
-		G4double rand;
-    //	G4double sampledMomentum, sampledRI; 
+    G4double rand;
+    //	G4double sampledMomentum, sampledRI;
 
-    G4double sampledEnergy, sampledRI; 
+    G4double sampledEnergy, sampledRI;
 
-		G4double cosTheta, sin2Theta;
-		
-		// sample a momentum 
+    G4double cosTheta, sin2Theta;
 
-		do {
-			rand = G4UniformRand();	
-      //			sampledMomentum = Pmin + rand * dp; 
+    // sample a momentum
+
+    do {
+      rand = G4UniformRand();
+      //			sampledMomentum = Pmin + rand * dp;
       //	sampledRI = Rindex->GetProperty(sampledMomentum);
-			sampledEnergy = Pmin + rand * dp; 
-			sampledRI = Rindex->Value(sampledEnergy);
-			cosTheta = BetaInverse / sampledRI;  
+      sampledEnergy = Pmin + rand * dp;
+      sampledRI = Rindex->Value(sampledEnergy);
+      cosTheta = BetaInverse / sampledRI;
       //	G4cout<<"RichG4cerenkov SampledMom sampledRI costh th "
       //                      <<sampledMomentum<<"  "<<	sampledRI<<"   "
       //                      <<cosTheta<< "   "<<acos(cosTheta)<<G4endl;
 
-			sin2Theta = (1.0 - cosTheta)*(1.0 + cosTheta);
-			rand = G4UniformRand();	
+      sin2Theta = (1.0 - cosTheta) * (1.0 + cosTheta);
+      rand = G4UniformRand();
+
+    } while (rand * maxSin2 > sin2Theta);
 
-		} while (rand*maxSin2 > sin2Theta);
+    // Generate random position of photon on cone surface
+    // defined by Theta
 
-		// Generate random position of photon on cone surface 
-		// defined by Theta 
+    rand = G4UniformRand();
 
-		rand = G4UniformRand();
+    G4double phi = CLHEP::twopi * rand;
+    G4double sinPhi = sin(phi);
+    G4double cosPhi = cos(phi);
 
-		G4double phi = CLHEP::twopi*rand;
-		G4double sinPhi = sin(phi);
-		G4double cosPhi = cos(phi);
+    // calculate x,y, and z components of photon momentum
+    // (in coord system with primary particle direction
+    //  aligned with the z axis)
 
-		// calculate x,y, and z components of photon momentum 
-		// (in coord system with primary particle direction 
-		//  aligned with the z axis)
+    G4double sinTheta = sqrt(sin2Theta);
+    G4double px = sinTheta * cosPhi;
+    G4double py = sinTheta * sinPhi;
+    G4double pz = cosTheta;
 
-		G4double sinTheta = sqrt(sin2Theta); 
-		G4double px = sinTheta*cosPhi;
-		G4double py = sinTheta*sinPhi;
-		G4double pz = cosTheta;
+    // Create photon momentum direction vector
+    // The momentum direction is still with respect
+    // to the coordinate system where the primary
+    // particle direction is aligned with the z axis
 
-		// Create photon momentum direction vector 
-		// The momentum direction is still with respect
-	 	// to the coordinate system where the primary
-		// particle direction is aligned with the z axis  
+    G4ParticleMomentum photonMomentum(px, py, pz);
 
-		G4ParticleMomentum photonMomentum(px, py, pz);
+    // Rotate momentum direction back to global reference
+    // system
 
-		// Rotate momentum direction back to global reference
-		// system 
+    photonMomentum.rotateUz(p0);
 
-                photonMomentum.rotateUz(p0);
+    // Determine polarization of new photon
 
-		// Determine polarization of new photon 
+    G4double sx = cosTheta * cosPhi;
+    G4double sy = cosTheta * sinPhi;
+    G4double sz = -sinTheta;
 
-		G4double sx = cosTheta*cosPhi;
-		G4double sy = cosTheta*sinPhi; 
-		G4double sz = -sinTheta;
+    G4ThreeVector photonPolarization(sx, sy, sz);
 
-		G4ThreeVector photonPolarization(sx, sy, sz);
+    // Rotate back to original coord system
 
-		// Rotate back to original coord system 
+    photonPolarization.rotateUz(p0);
 
-                photonPolarization.rotateUz(p0);
-		
-                // Generate a new photon:
+    // Generate a new photon:
 
-                G4DynamicParticle* aCerenkovPhoton =
-                  new G4DynamicParticle(G4OpticalPhoton::OpticalPhoton(), 
-  					                 photonMomentum);
-		aCerenkovPhoton->SetPolarization
-				     (photonPolarization.x(),
-				      photonPolarization.y(),
-				      photonPolarization.z());
+    G4DynamicParticle *aCerenkovPhoton = new G4DynamicParticle(G4OpticalPhoton::OpticalPhoton(), photonMomentum);
+    aCerenkovPhoton->SetPolarization(photonPolarization.x(), photonPolarization.y(), photonPolarization.z());
 
     //	aCerenkovPhoton->SetKineticEnergy(sampledMomentum);
-		aCerenkovPhoton->SetKineticEnergy(sampledEnergy);
+    aCerenkovPhoton->SetKineticEnergy(sampledEnergy);
 
-                // Generate new G4Track object:
+    // Generate new G4Track object:
 
-		rand = G4UniformRand();
+    rand = G4UniformRand();
 
-                G4double delta = rand * aStep.GetStepLength();
-		G4double deltaTime = delta /
-                       ((pPreStepPoint->GetVelocity()+
-                         pPostStepPoint->GetVelocity())/2.);
+    G4double delta = rand * aStep.GetStepLength();
+    G4double deltaTime = delta / ((pPreStepPoint->GetVelocity() + pPostStepPoint->GetVelocity()) / 2.);
 
-                G4double aSecondaryTime = t0 + deltaTime;
+    G4double aSecondaryTime = t0 + deltaTime;
 
-                G4ThreeVector aSecondaryPosition =
-                                    x0 + rand * aStep.GetDeltaPosition();
+    G4ThreeVector aSecondaryPosition = x0 + rand * aStep.GetDeltaPosition();
 
-		G4Track* aSecondaryTrack = 
-		new G4Track(aCerenkovPhoton,aSecondaryTime,aSecondaryPosition);
+    G4Track *aSecondaryTrack = new G4Track(aCerenkovPhoton, aSecondaryTime, aSecondaryPosition);
 
-                aSecondaryTrack->SetTouchableHandle((G4VTouchable*)0);
+    aSecondaryTrack->SetTouchableHandle((G4VTouchable *)0);
 
-                aSecondaryTrack->SetParentID(aTrack.GetTrackID());
-     //Additions and modif made by SE to Tag the info regarding photon
-     //production. SE 1-3-2005
-               G4Track* aTaggedSecondaryTrack
-                   = RichTbCkvProdInfoAttach(aTrack,aSecondaryTrack,
-                     cosTheta,phi,sampledEnergy);
+    aSecondaryTrack->SetParentID(aTrack.GetTrackID());
+    // Additions and modif made by SE to Tag the info regarding photon
+    // production. SE 1-3-2005
+    G4Track *aTaggedSecondaryTrack = RichTbCkvProdInfoAttach(aTrack, aSecondaryTrack, cosTheta, phi, sampledEnergy);
     //		aParticleChange.AddSecondary(aSecondaryTrack);
 
-		aParticleChange.AddSecondary(aTaggedSecondaryTrack);
-		// now for histograms
-		RichTbPhotonProductionHisto(aTrack, aTaggedSecondaryTrack,
-    				    cosTheta,phi,sampledEnergy);
-    //end of modif by SE
-
-	}
+    aParticleChange.AddSecondary(aTaggedSecondaryTrack);
+    // now for histograms
+    RichTbPhotonProductionHisto(aTrack, aTaggedSecondaryTrack, cosTheta, phi, sampledEnergy);
+    // end of modif by SE
+  }
 
-	if (verboseLevel>0) {
-	G4cout << "\n Exiting from RichTbG4Cerenkov::DoIt -- NumberOfSecondaries = " 
-	     << aParticleChange.GetNumberOfSecondaries() << G4endl;
-	}
+  if (verboseLevel > 0) {
+    G4cout << "\n Exiting from RichTbG4Cerenkov::DoIt -- NumberOfSecondaries = "
+           << aParticleChange.GetNumberOfSecondaries() << G4endl;
+  }
 
-	return G4VContinuousProcess::AlongStepDoIt(aTrack, aStep);
+  return G4VContinuousProcess::AlongStepDoIt(aTrack, aStep);
 }
 
 // BuildThePhysicsTable for the Cerenkov process
 // ---------------------------------------------
 //
 
-void RichTbG4Cerenkov::BuildThePhysicsTable()
-{
-	if (thePhysicsTable) return;
+void RichTbG4Cerenkov::BuildThePhysicsTable() {
+  if (thePhysicsTable)
+    return;
+
+  const G4MaterialTable *theMaterialTable = G4Material::GetMaterialTable();
+  G4int numOfMaterials = G4Material::GetNumberOfMaterials();
 
-	const G4MaterialTable* theMaterialTable=
-	 		       G4Material::GetMaterialTable();
-	G4int numOfMaterials = G4Material::GetNumberOfMaterials();
+  // create new physics table
 
-	// create new physics table
-	
-	thePhysicsTable = new G4PhysicsTable(numOfMaterials);
+  thePhysicsTable = new G4PhysicsTable(numOfMaterials);
 
-	// loop for materials
+  // loop for materials
 
-	for (G4int i=0 ; i < numOfMaterials; i++)
-	{
-		G4PhysicsOrderedFreeVector* aPhysicsOrderedFreeVector =
-					new G4PhysicsOrderedFreeVector();
+  for (G4int i = 0; i < numOfMaterials; i++) {
+    G4PhysicsOrderedFreeVector *aPhysicsOrderedFreeVector = new G4PhysicsOrderedFreeVector();
 
-		// Retrieve vector of refraction indices for the material
-		// from the material's optical properties table 
+    // Retrieve vector of refraction indices for the material
+    // from the material's optical properties table
 
-		G4Material* aMaterial = (*theMaterialTable)[i];
+    G4Material *aMaterial = (*theMaterialTable)[i];
 
-		G4MaterialPropertiesTable* aMaterialPropertiesTable =
-				aMaterial->GetMaterialPropertiesTable();
+    G4MaterialPropertiesTable *aMaterialPropertiesTable = aMaterial->GetMaterialPropertiesTable();
 
-		if (aMaterialPropertiesTable) {
+    if (aMaterialPropertiesTable) {
 
-		   G4MaterialPropertyVector* theRefractionIndexVector = 
-		    	   aMaterialPropertiesTable->GetProperty("CKVRNDX");
+      G4MaterialPropertyVector *theRefractionIndexVector = aMaterialPropertiesTable->GetProperty("CKVRNDX");
 
-		   if (theRefractionIndexVector) {
-		
-		      // Retrieve the first refraction index in vector
-		      // of (photon momentum, refraction index) pairs 
+      if (theRefractionIndexVector) {
 
-		     // theRefractionIndexVector->ResetIterator();
-		     // ++(*theRefractionIndexVector);	// advance to 1st entry
+        // Retrieve the first refraction index in vector
+        // of (photon momentum, refraction index) pairs
 
-          G4double currentRI = (*theRefractionIndexVector)[0];
-		      //G4double currentRI = theRefractionIndexVector->
-          //		   GetProperty();
+        // theRefractionIndexVector->ResetIterator();
+        // ++(*theRefractionIndexVector);	// advance to 1st entry
 
-		      if (currentRI > 1.0) {
+        G4double currentRI = (*theRefractionIndexVector)[0];
+        // G4double currentRI = theRefractionIndexVector->
+        //		   GetProperty();
 
-			 // Create first (photon momentum, Cerenkov Integral)
-			 // pair  
+        if (currentRI > 1.0) {
 
-            // G4double currentPM = theRefractionIndexVector->
-            //	 GetPhotonMomentum();
-            //G4double currentPM = theRefractionIndexVector->
-			 			// GetPhotonMomentum();
+          // Create first (photon momentum, Cerenkov Integral)
+          // pair
 
-       G4double currentPM = theRefractionIndexVector->Energy(0);
-			 G4double currentCAI = 0.0;
+          // G4double currentPM = theRefractionIndexVector->
+          //	 GetPhotonMomentum();
+          // G4double currentPM = theRefractionIndexVector->
+          // GetPhotonMomentum();
 
-			 aPhysicsOrderedFreeVector->
-			 	 InsertValues(currentPM , currentCAI);
+          G4double currentPM = theRefractionIndexVector->Energy(0);
+          G4double currentCAI = 0.0;
 
-			 // Set previous values to current ones prior to loop
+          aPhysicsOrderedFreeVector->InsertValues(currentPM, currentCAI);
 
-			 G4double prevPM  = currentPM;
-			 G4double prevCAI = currentCAI;
-                	 G4double prevRI  = currentRI;
+          // Set previous values to current ones prior to loop
 
-			 // loop over all (photon momentum, refraction index)
-			 // pairs stored for this material
+          G4double prevPM = currentPM;
+          G4double prevCAI = currentCAI;
+          G4double prevRI = currentRI;
 
-       for (size_t i = 1;i < theRefractionIndexVector->GetVectorLength(); i++)
-                           //			 while(++(*theRefractionIndexVector))
-			 {
+          // loop over all (photon momentum, refraction index)
+          // pairs stored for this material
+
+          for (size_t i = 1; i < theRefractionIndexVector->GetVectorLength(); i++)
+          //			 while(++(*theRefractionIndexVector))
+          {
 
             currentRI = (*theRefractionIndexVector)[i];
             currentPM = theRefractionIndexVector->Energy(i);
-            //	currentRI=theRefractionIndexVector->	
+            //	currentRI=theRefractionIndexVector->
             //	GetProperty();
 
             //	currentPM = theRefractionIndexVector->
             //		GetPhotonMomentum();
 
-				currentCAI = 0.5*(1.0/(prevRI*prevRI) +
-					          1.0/(currentRI*currentRI));
-
-				currentCAI = prevCAI + 
-					     (currentPM - prevPM) * currentCAI;
+            currentCAI = 0.5 * (1.0 / (prevRI * prevRI) + 1.0 / (currentRI * currentRI));
 
-				aPhysicsOrderedFreeVector->
-				    InsertValues(currentPM, currentCAI);
+            currentCAI = prevCAI + (currentPM - prevPM) * currentCAI;
 
-				prevPM  = currentPM;
-				prevCAI = currentCAI;
-				prevRI  = currentRI;
-			 }
+            aPhysicsOrderedFreeVector->InsertValues(currentPM, currentCAI);
 
-		      }
-		   }
-		}
-
-	// The Cerenkov integral for a given material
-	// will be inserted in thePhysicsTable
-	// according to the position of the material in
-	// the material table. 
+            prevPM = currentPM;
+            prevCAI = currentCAI;
+            prevRI = currentRI;
+          }
+        }
+      }
+    }
 
-	thePhysicsTable->insertAt(i,aPhysicsOrderedFreeVector); 
+    // The Cerenkov integral for a given material
+    // will be inserted in thePhysicsTable
+    // according to the position of the material in
+    // the material table.
 
-	}
+    thePhysicsTable->insertAt(i, aPhysicsOrderedFreeVector);
+  }
 }
 
 // GetContinuousStepLimit
 // ----------------------
 //
 
-G4double 
-RichTbG4Cerenkov::GetContinuousStepLimit(const G4Track& aTrack,
-				   G4double  ,
-				   G4double  ,
-                                   G4double& )
-{
-	// If user has defined an average maximum number of photons to
-	// be generated in a Step, then return the Step length for that 
-	// number of photons. 
- 
-	if (fMaxPhotons <= 0) return DBL_MAX;
+G4double RichTbG4Cerenkov::GetContinuousStepLimit(const G4Track &aTrack, G4double, G4double, G4double &) {
+  // If user has defined an average maximum number of photons to
+  // be generated in a Step, then return the Step length for that
+  // number of photons.
+
+  if (fMaxPhotons <= 0)
+    return DBL_MAX;
 
-        const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
-        const G4Material* aMaterial = aTrack.GetMaterial();
+  const G4DynamicParticle *aParticle = aTrack.GetDynamicParticle();
+  const G4Material *aMaterial = aTrack.GetMaterial();
 
-        G4MaterialPropertiesTable* aMaterialPropertiesTable =
-                               aMaterial->GetMaterialPropertiesTable();
-        if (!aMaterialPropertiesTable) return DBL_MAX;
+  G4MaterialPropertiesTable *aMaterialPropertiesTable = aMaterial->GetMaterialPropertiesTable();
+  if (!aMaterialPropertiesTable)
+    return DBL_MAX;
 
-         G4MaterialPropertyVector* Rindex =
-                aMaterialPropertiesTable->GetProperty("CKVRNDX");
-        if (!Rindex) return DBL_MAX;
+  G4MaterialPropertyVector *Rindex = aMaterialPropertiesTable->GetProperty("CKVRNDX");
+  if (!Rindex)
+    return DBL_MAX;
 
-	G4double MeanNumPhotons = 
-                 GetAverageNumberOfPhotons(aParticle,aMaterial,Rindex);
+  G4double MeanNumPhotons = GetAverageNumberOfPhotons(aParticle, aMaterial, Rindex);
 
-        if(MeanNumPhotons <= 0.0) return DBL_MAX;
+  if (MeanNumPhotons <= 0.0)
+    return DBL_MAX;
 
-	G4double StepLimit = fMaxPhotons / MeanNumPhotons;
+  G4double StepLimit = fMaxPhotons / MeanNumPhotons;
 
-	return StepLimit;
+  return StepLimit;
 }
 
 // GetAverageNumberOfPhotons
 // -------------------------
 // This routine computes the number of Cerenkov photons produced per
-// GEANT-unit (millimeter) in the current medium. 
+// GEANT-unit (millimeter) in the current medium.
 //             ^^^^^^^^^^
 
-G4double 
-RichTbG4Cerenkov::GetAverageNumberOfPhotons(const G4DynamicParticle* aParticle, 
-			      const G4Material* aMaterial,
-			       G4MaterialPropertyVector* Rindex) const
-{
-	const G4double Rfact = 369.81/(CLHEP::eV * CLHEP::cm);
+G4double RichTbG4Cerenkov::GetAverageNumberOfPhotons(const G4DynamicParticle *aParticle, const G4Material *aMaterial,
+                                                     G4MaterialPropertyVector *Rindex) const {
+  const G4double Rfact = 369.81 / (CLHEP::eV * CLHEP::cm);
+
+  if (aParticle->GetTotalMomentum() <= 0.0)
+    return 0.0;
 
-        if(aParticle->GetTotalMomentum() <= 0.0)return 0.0;
+  G4double BetaInverse = aParticle->GetTotalEnergy() / aParticle->GetTotalMomentum();
 
-	G4double BetaInverse = aParticle->GetTotalEnergy() /
-			       aParticle->GetTotalMomentum();
+  // Vectors used in computation of Cerenkov Angle Integral:
+  // 	- Refraction Indices for the current material
+  //	- new G4PhysicsOrderedFreeVector allocated to hold CAI's
 
-	// Vectors used in computation of Cerenkov Angle Integral:
-	// 	- Refraction Indices for the current material
-	//	- new G4PhysicsOrderedFreeVector allocated to hold CAI's
- 
-	G4int materialIndex = aMaterial->GetIndex();
+  G4int materialIndex = aMaterial->GetIndex();
 
-	// Retrieve the Cerenkov Angle Integrals for this material  
+  // Retrieve the Cerenkov Angle Integrals for this material
 
-	G4PhysicsOrderedFreeVector* CerenkovAngleIntegrals =
-	(G4PhysicsOrderedFreeVector*)((*thePhysicsTable)(materialIndex));
+  G4PhysicsOrderedFreeVector *CerenkovAngleIntegrals =
+      (G4PhysicsOrderedFreeVector *)((*thePhysicsTable)(materialIndex));
 
-        if(!(CerenkovAngleIntegrals->IsFilledVectorExist()))return 0.0;
+  if (!(CerenkovAngleIntegrals->IsFilledVectorExist()))
+    return 0.0;
 
-	// Min and Max photon momenta  
-        //	G4double Pmin = Rindex->GetMinPhotonMomentum();
-        //	G4double Pmax = Rindex->GetMaxPhotonMomentum();
-  G4double Pmin = Rindex->GetMinLowEdgeEnergy(); //G4.95 onwards
-  G4double Pmax = Rindex->GetMaxLowEdgeEnergy(); //G4.95 onwards
+  // Min and Max photon momenta
+  //	G4double Pmin = Rindex->GetMinPhotonMomentum();
+  //	G4double Pmax = Rindex->GetMaxPhotonMomentum();
+  G4double Pmin = Rindex->GetMinLowEdgeEnergy(); // G4.95 onwards
+  G4double Pmax = Rindex->GetMaxLowEdgeEnergy(); // G4.95 onwards
 
-	// Min and Max Refraction Indices 
-  //	G4double nMin = Rindex->GetMinProperty();	
+  // Min and Max Refraction Indices
+  //	G4double nMin = Rindex->GetMinProperty();
   //	G4double nMax = Rindex->GetMaxProperty();
 
-	G4double nMin = Rindex->GetMinValue();	
-	G4double nMax = Rindex->GetMaxValue();
+  G4double nMin = Rindex->GetMinValue();
+  G4double nMax = Rindex->GetMaxValue();
 
-	// Max Cerenkov Angle Integral 
-	G4double CAImax = CerenkovAngleIntegrals->GetMaxValue();
+  // Max Cerenkov Angle Integral
+  G4double CAImax = CerenkovAngleIntegrals->GetMaxValue();
 
-	G4double dp, ge;
+  G4double dp, ge;
 
-	// If n(Pmax) < 1/Beta -- no photons generated 
+  // If n(Pmax) < 1/Beta -- no photons generated
 
-	if (nMax < BetaInverse) {
-		dp = 0;
-		ge = 0;
-	} 
+  if (nMax < BetaInverse) {
+    dp = 0;
+    ge = 0;
+  }
 
-	// otherwise if n(Pmin) >= 1/Beta -- photons generated  
+  // otherwise if n(Pmin) >= 1/Beta -- photons generated
 
-	else if (nMin > BetaInverse) {
-		dp = Pmax - Pmin;	
-		ge = CAImax; 
-	} 
+  else if (nMin > BetaInverse) {
+    dp = Pmax - Pmin;
+    ge = CAImax;
+  }
 
-	// If n(Pmin) < 1/Beta, and n(Pmax) >= 1/Beta, then
-	// we need to find a P such that the value of n(P) == 1/Beta.
-	// Interpolation is performed by the GetPhotonMomentum() and
-	// GetProperty() methods of the G4MaterialPropertiesTable and
-	// the GetValue() method of G4PhysicsVector.  
+  // If n(Pmin) < 1/Beta, and n(Pmax) >= 1/Beta, then
+  // we need to find a P such that the value of n(P) == 1/Beta.
+  // Interpolation is performed by the GetPhotonMomentum() and
+  // GetProperty() methods of the G4MaterialPropertiesTable and
+  // the GetValue() method of G4PhysicsVector.
 
-	else {
+  else {
     //		Pmin = Rindex->GetPhotonMomentum(BetaInverse);
-		Pmin = Rindex->GetEnergy(BetaInverse);
-		dp = Pmax - Pmin;
-
-		// need boolean for current implementation of G4PhysicsVector
-		// ==> being phased out
-		G4bool isOutRange;
-		G4double CAImin = CerenkovAngleIntegrals->
-                                  GetValue(Pmin, isOutRange);
-		ge = CAImax - CAImin;
-
-		if (verboseLevel>0) {
-			G4cout << "CAImin = " << CAImin << G4endl;
-			G4cout << "ge = " << ge << G4endl;
-		}
-	}
-	
-	// particle charge 
-	G4double charge = aParticle->GetDefinition()->GetPDGCharge();
-
-	// Calculate number of photons 
-	G4double NumPhotons = Rfact * charge/CLHEP::eplus * charge/CLHEP::eplus *
-                                 (dp - ge * BetaInverse*BetaInverse);
-
-	return NumPhotons;		
+    Pmin = Rindex->GetEnergy(BetaInverse);
+    dp = Pmax - Pmin;
+
+    // need boolean for current implementation of G4PhysicsVector
+    // ==> being phased out
+    G4bool isOutRange;
+    G4double CAImin = CerenkovAngleIntegrals->GetValue(Pmin, isOutRange);
+    ge = CAImax - CAImin;
+
+    if (verboseLevel > 0) {
+      G4cout << "CAImin = " << CAImin << G4endl;
+      G4cout << "ge = " << ge << G4endl;
+    }
+  }
+
+  // particle charge
+  G4double charge = aParticle->GetDefinition()->GetPDGCharge();
+
+  // Calculate number of photons
+  G4double NumPhotons = Rfact * charge / CLHEP::eplus * charge / CLHEP::eplus * (dp - ge * BetaInverse * BetaInverse);
+
+  return NumPhotons;
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4OpAbsorption.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4OpAbsorption.cc
index 3df85d898be5684539ba29eb763c96869865649f..1a24e492700b6cb85f924ef8fe7ec09a07a6d955 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4OpAbsorption.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4OpAbsorption.cc
@@ -29,12 +29,12 @@
 ////////////////////////////////////////////////////////////////////////
 //
 // File:        RichTbG4OpAbsorption.cc
-// Description: Discrete Process -- Absorption of Optical Photons  
+// Description: Discrete Process -- Absorption of Optical Photons
 // Version:     1.0
 // Created:     1996-05-21
 // Author:      Juliet Armstrong
 // Updated:     2000-09-18 by Peter Gumplinger
-//              > comment out warning - "No Absorption length specified" 
+//              > comment out warning - "No Absorption length specified"
 //              1997-04-09 by Peter Gumplinger
 //              > new physics/tracking scheme
 //              1998-08-25 by Stefano Magni
@@ -46,100 +46,88 @@
 //
 ////////////////////////////////////////////////////////////////////////
 
-#include "Geant4/G4ios.hh"
 #include "RichTbG4OpAbsorption.hh"
+#include "Geant4/G4ios.hh"
 
 /////////////////////////
 // Class Implementation
 /////////////////////////
 
-        //////////////
-        // Operators
-        //////////////
+//////////////
+// Operators
+//////////////
 
 // RichTbG4OpAbsorption::operator=(const RichTbG4OpAbsorption &right)
 // {
 // }
 
-        /////////////////
-        // Constructors
-        /////////////////
+/////////////////
+// Constructors
+/////////////////
 
-RichTbG4OpAbsorption::RichTbG4OpAbsorption(const G4String& processName)
-              : G4VDiscreteProcess(processName)
-{
-        if (verboseLevel>0) {
-           G4cout << GetProcessName() << " is created " << G4endl;
-        }
+RichTbG4OpAbsorption::RichTbG4OpAbsorption(const G4String &processName) : G4VDiscreteProcess(processName) {
+  if (verboseLevel > 0) {
+    G4cout << GetProcessName() << " is created " << G4endl;
+  }
 }
 
 // RichTbG4OpAbsorption::RichTbG4OpAbsorption(const G4OpAbsorpton &right)
 // {
 // }
 
-        ////////////////
-        // Destructors
-        ////////////////
+////////////////
+// Destructors
+////////////////
 
-RichTbG4OpAbsorption::~RichTbG4OpAbsorption(){}
+RichTbG4OpAbsorption::~RichTbG4OpAbsorption() {}
 
-        ////////////
-        // Methods
-        ////////////
+////////////
+// Methods
+////////////
 
 // PostStepDoIt
 // -------------
 //
-G4VParticleChange*
-RichTbG4OpAbsorption::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
-{
-        aParticleChange.Initialize(aTrack);
-
-        aParticleChange.ProposeTrackStatus(fStopAndKill);
-        aStep.GetTrack()->SetTrackStatus(fStopAndKill);
-        if (verboseLevel>0) {
-	   G4cout << "\n** Photon absorbed! **" << G4endl;
-        }
-        return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+G4VParticleChange *RichTbG4OpAbsorption::PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) {
+  aParticleChange.Initialize(aTrack);
+
+  aParticleChange.ProposeTrackStatus(fStopAndKill);
+  aStep.GetTrack()->SetTrackStatus(fStopAndKill);
+  if (verboseLevel > 0) {
+    G4cout << "\n** Photon absorbed! **" << G4endl;
+  }
+  return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
 }
 
-
 // GetMeanFreePath
 // ---------------
 //
-G4double RichTbG4OpAbsorption::GetMeanFreePath(const G4Track& aTrack,
- 				         G4double ,
-				         G4ForceCondition* )
-{
-	const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
-        const G4Material* aMaterial = aTrack.GetMaterial();
-
-        //	G4double thePhotonMomentum = aParticle->GetTotalMomentum();
-        G4double thePhotonEnergy = aParticle->GetTotalEnergy();
-
-	G4MaterialPropertiesTable* aMaterialPropertyTable;
-	G4MaterialPropertyVector* AttenuationLengthVector;
-	
-        G4double AttenuationLength = DBL_MAX;
-
-	aMaterialPropertyTable = aMaterial->GetMaterialPropertiesTable();
-
-	if ( aMaterialPropertyTable ) {
-	   AttenuationLengthVector = aMaterialPropertyTable->
-                                                GetProperty("ABSLENGTH");
-           if ( AttenuationLengthVector ){
-             // AttenuationLength = AttenuationLengthVector->
-             //                         GetProperty (thePhotonMomentum);
-             AttenuationLength = AttenuationLengthVector->
-                                         Value (thePhotonEnergy);
-           }
-           else {
-//             G4cout << "No Absorption length specified" << G4endl;
-           }
-        } 
-        else {
-//           G4cout << "No Absorption length specified" << G4endl;
-        }
-
-        return AttenuationLength;
+G4double RichTbG4OpAbsorption::GetMeanFreePath(const G4Track &aTrack, G4double, G4ForceCondition *) {
+  const G4DynamicParticle *aParticle = aTrack.GetDynamicParticle();
+  const G4Material *aMaterial = aTrack.GetMaterial();
+
+  //	G4double thePhotonMomentum = aParticle->GetTotalMomentum();
+  G4double thePhotonEnergy = aParticle->GetTotalEnergy();
+
+  G4MaterialPropertiesTable *aMaterialPropertyTable;
+  G4MaterialPropertyVector *AttenuationLengthVector;
+
+  G4double AttenuationLength = DBL_MAX;
+
+  aMaterialPropertyTable = aMaterial->GetMaterialPropertiesTable();
+
+  if (aMaterialPropertyTable) {
+    AttenuationLengthVector = aMaterialPropertyTable->GetProperty("ABSLENGTH");
+    if (AttenuationLengthVector) {
+      // AttenuationLength = AttenuationLengthVector->
+      //                         GetProperty (thePhotonMomentum);
+      AttenuationLength = AttenuationLengthVector->Value(thePhotonEnergy);
+    } else {
+      //             G4cout << "No Absorption length specified" << G4endl;
+    }
+  } else {
+    //           G4cout << "No Absorption length specified" << G4endl;
+  }
+
+  return AttenuationLength;
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4OpBoundaryProcess.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4OpBoundaryProcess.cc
index 50eefb81d627fa74b7fb29310e52d350c047b291..d95baf02aabe1a069ed930a10f55f5d45f722ade 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4OpBoundaryProcess.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4OpBoundaryProcess.cc
@@ -35,7 +35,7 @@
 //                           (thanks to: Stefano Magni)
 //              1998-06-11 - delete *sint1 in oblique reflection
 //                           (thanks to: Giovanni Pieri)
-//              1998-06-19 - move from GetLocalExitNormal() to the new 
+//              1998-06-19 - move from GetLocalExitNormal() to the new
 //                           method: GetLocalExitNormal(&valid) to get
 //                           the surface normal in all cases
 //              1998-11-07 - NULL OpticalSurface pointer before use
@@ -54,910 +54,818 @@
 // Author:      Peter Gumplinger
 // 		adopted from work by Werner Keil - April 2/96
 // mail:        gum@triumf.ca
-// modified and renamed to adapt to the RICH testbeam. SE 1-3-2005. 
+// modified and renamed to adapt to the RICH testbeam. SE 1-3-2005.
 ////////////////////////////////////////////////////////////////////////
 
-#include "Geant4/G4ios.hh"
 #include "RichTbG4OpBoundaryProcess.hh"
-#include "RichTbMiscNames.hh"
 #include "Geant4/G4GeometryTolerance.hh"
+#include "Geant4/G4ios.hh"
+#include "RichTbMiscNames.hh"
 
 /////////////////////////
 // Class Implementation
 /////////////////////////
 
-        //////////////
-        // Operators
-        //////////////
+//////////////
+// Operators
+//////////////
 
 // RichTbG4OpBoundaryProcess::operator=(const RichTbG4OpBoundaryProcess &right)
 // {
 // }
 
-        /////////////////
-        // Constructors
-        /////////////////
-
-RichTbG4OpBoundaryProcess::RichTbG4OpBoundaryProcess(const G4String& processName)
-             : G4VDiscreteProcess(processName)
-{
-        if ( verboseLevel > 0) {
-           G4cout << GetProcessName() << " is created " << G4endl;
-        }
-
-	theStatus = Undefined;
-	theModel = glisur;
-	theFinish = polished;
-        theReflectivity = 1.;
-        theEfficiency   = 0.;
-                                                                                
-        prob_sl = 0.;
-        prob_ss = 0.;
-        prob_bs = 0.;
-        CurStepNum=0;
-        theMaxPhotStepNumInBoundaryProc=3;
+/////////////////
+// Constructors
+/////////////////
 
+RichTbG4OpBoundaryProcess::RichTbG4OpBoundaryProcess(const G4String &processName) : G4VDiscreteProcess(processName) {
+  if (verboseLevel > 0) {
+    G4cout << GetProcessName() << " is created " << G4endl;
+  }
 
+  theStatus = Undefined;
+  theModel = glisur;
+  theFinish = polished;
+  theReflectivity = 1.;
+  theEfficiency = 0.;
+
+  prob_sl = 0.;
+  prob_ss = 0.;
+  prob_bs = 0.;
+  CurStepNum = 0;
+  theMaxPhotStepNumInBoundaryProc = 3;
 }
 
 // RichTbG4OpBoundaryProcess::RichTbG4OpBoundaryProcess(const RichTbG4OpBoundaryProcess &right)
 // {
 // }
 
-        ////////////////
-        // Destructors
-        ////////////////
+////////////////
+// Destructors
+////////////////
 
-RichTbG4OpBoundaryProcess::~RichTbG4OpBoundaryProcess(){}
+RichTbG4OpBoundaryProcess::~RichTbG4OpBoundaryProcess() {}
 
-        ////////////
-        // Methods
-        ////////////
+////////////
+// Methods
+////////////
 
 // PostStepDoIt
 // ------------
 //
-G4VParticleChange*
-RichTbG4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
-{
-        theStatus = Undefined;
+G4VParticleChange *RichTbG4OpBoundaryProcess::PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) {
+  theStatus = Undefined;
 
-        aParticleChange.Initialize(aTrack);
+  aParticleChange.Initialize(aTrack);
 
-        G4StepPoint* pPreStepPoint  = aStep.GetPreStepPoint();
-        G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
+  G4StepPoint *pPreStepPoint = aStep.GetPreStepPoint();
+  G4StepPoint *pPostStepPoint = aStep.GetPostStepPoint();
 
-        if (pPostStepPoint->GetStepStatus() != fGeomBoundary){
-	        theStatus = NotAtBoundary;
-	        return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-	}
+  if (pPostStepPoint->GetStepStatus() != fGeomBoundary) {
+    theStatus = NotAtBoundary;
+    return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+  }
   G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
 
-	if (aTrack.GetStepLength()<=kCarTolerance/2){
-	        theStatus = StepTooSmall;
-	        return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-	}
+  if (aTrack.GetStepLength() <= kCarTolerance / 2) {
+    theStatus = StepTooSmall;
+    return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+  }
 
-	Material1 = pPreStepPoint  -> GetMaterial();
-	Material2 = pPostStepPoint -> GetMaterial();
-  //  debug printout by SE 
-  G4String 	Material1Name = 	Material1->GetName();
-  G4String 	Material2Name = 	Material2->GetName();
+  Material1 = pPreStepPoint->GetMaterial();
+  Material2 = pPostStepPoint->GetMaterial();
+  //  debug printout by SE
+  G4String Material1Name = Material1->GetName();
+  G4String Material2Name = Material2->GetName();
 
   //     G4cout<<"RichTbBoundaryProc Materal1 Materal2  "
   //       <<	Material1Name<<"   "<<	Material2Name<<G4endl;
   //     G4cout<<"RichTbBoundaryProc track status  "
-  //      <<aTrack.GetTrackStatus()<<G4endl;    
+  //      <<aTrack.GetTrackStatus()<<G4endl;
   // end of printout by SE
 
-
   G4int CurrentStepNumber = aTrack.GetCurrentStepNumber();
   CurStepNum = CurrentStepNumber;
-  if(CurrentStepNumber > 10000){
-    G4cout<<"killing photon at step # "<< CurrentStepNumber << G4endl;
+  if (CurrentStepNumber > 10000) {
+    G4cout << "killing photon at step # " << CurrentStepNumber << G4endl;
     theStatus = Absorption;
     aParticleChange.ProposeTrackStatus(fStopAndKill);
     aStep.GetTrack()->SetTrackStatus(fStopAndKill);
     return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
   }
 
+  const G4DynamicParticle *aParticle = aTrack.GetDynamicParticle();
 
-        const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
-
-	thePhotonMomentum = aParticle->GetTotalMomentum();
-	G4double aPhotonKE = aParticle->GetKineticEnergy();
-	if(	thePhotonMomentum == 0.0 ||  aPhotonKE == 0.0 ) {
-	  G4cout<< "Boundary proc photon energy  "<< thePhotonMomentum 
-		<<"  "<< aPhotonKE<<G4endl;
-        }
-	G4double Lambda = 1243.125*(CLHEP::nanometer*CLHEP::eV)/aPhotonKE*1000000;
+  thePhotonMomentum = aParticle->GetTotalMomentum();
+  G4double aPhotonKE = aParticle->GetKineticEnergy();
+  if (thePhotonMomentum == 0.0 || aPhotonKE == 0.0) {
+    G4cout << "Boundary proc photon energy  " << thePhotonMomentum << "  " << aPhotonKE << G4endl;
+  }
+  // G4double Lambda = 1243.125 * (CLHEP::nanometer * CLHEP::eV) / aPhotonKE * 1000000;
   //	G4cout <<"energy momentum and lambda " <<aPhotonKE << " "<< thePhotonMomentum<< " " << Lambda << G4endl;
-  // modif made by SE 
+  // modif made by SE
   //   if the photon momentum is zero kill it anyway.
   // this is to avoid the photons killed by other process in the same step.
 
-	// if(thePhotonMomentum = 0.0 || aPhotonKE == 0.0  ) {
-	//		aParticleChange.ProposeTrackStatus(fStopAndKill);
-		//    aParticleChange.ProposeEnergy(0.0);
-	//		return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-	// }
-   // end of modif by SE.   
-
-        OldMomentum       = aParticle->GetMomentumDirection();
-	OldPolarization   = aParticle->GetPolarization();
-
-	G4MaterialPropertiesTable* aMaterialPropertiesTable;
-        G4MaterialPropertyVector* Rindex;
-
-	aMaterialPropertiesTable = Material1->GetMaterialPropertiesTable();
-        if (aMaterialPropertiesTable) {
-		Rindex = aMaterialPropertiesTable->GetProperty("RINDEX");
-	}
-	else {
-	        theStatus = NoRINDEX;
-		aParticleChange.ProposeTrackStatus(fStopAndKill);
-                aStep.GetTrack()->SetTrackStatus(fStopAndKill);
-		//  aParticleChange.ProposeEnergy(0.0);
-		return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-	}
+  // if(thePhotonMomentum = 0.0 || aPhotonKE == 0.0  ) {
+  //		aParticleChange.ProposeTrackStatus(fStopAndKill);
+  //    aParticleChange.ProposeEnergy(0.0);
+  //		return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+  // }
+  // end of modif by SE.
+
+  OldMomentum = aParticle->GetMomentumDirection();
+  OldPolarization = aParticle->GetPolarization();
+
+  G4MaterialPropertiesTable *aMaterialPropertiesTable;
+  G4MaterialPropertyVector *Rindex;
+
+  aMaterialPropertiesTable = Material1->GetMaterialPropertiesTable();
+  if (aMaterialPropertiesTable) {
+    Rindex = aMaterialPropertiesTable->GetProperty("RINDEX");
+  } else {
+    theStatus = NoRINDEX;
+    aParticleChange.ProposeTrackStatus(fStopAndKill);
+    aStep.GetTrack()->SetTrackStatus(fStopAndKill);
+    //  aParticleChange.ProposeEnergy(0.0);
+    return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+  }
+
+  if (Rindex) {
+    //	Rindex1 = Rindex->GetProperty(thePhotonMomentum);
+    Rindex1 = Rindex->Value(thePhotonMomentum);
+
+  } else {
+    theStatus = NoRINDEX;
+    aParticleChange.ProposeTrackStatus(fStopAndKill);
+    aStep.GetTrack()->SetTrackStatus(fStopAndKill);
+    // aParticleChange.ProposeEnergy(0.0);
+    return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+  }
+
+  theModel = glisur;
+  theFinish = polished;
+
+  G4SurfaceType type = dielectric_dielectric;
+
+  Rindex = NULL;
+  OpticalSurface = NULL;
+
+  G4LogicalSurface *Surface =
+      G4LogicalBorderSurface::GetSurface(pPreStepPoint->GetPhysicalVolume(), pPostStepPoint->GetPhysicalVolume());
+
+  if (Surface == NULL) {
+    G4bool enteredDaughter = (pPostStepPoint->GetPhysicalVolume()->GetMotherLogical() ==
+                              pPreStepPoint->GetPhysicalVolume()->GetLogicalVolume());
+    if (enteredDaughter) {
+      Surface = G4LogicalSkinSurface::GetSurface(pPostStepPoint->GetPhysicalVolume()->GetLogicalVolume());
+      if (Surface == NULL)
+        Surface = G4LogicalSkinSurface::GetSurface(pPreStepPoint->GetPhysicalVolume()->GetLogicalVolume());
+    } else {
+      Surface = G4LogicalSkinSurface::GetSurface(pPreStepPoint->GetPhysicalVolume()->GetLogicalVolume());
+      if (Surface == NULL)
+        Surface = G4LogicalSkinSurface::GetSurface(pPostStepPoint->GetPhysicalVolume()->GetLogicalVolume());
+    }
+  }
+
+  //	if (Surface) OpticalSurface = dynamic_cast <G4OpticalSurface*> (Surface->GetSurfaceProperty());
+  if (Surface)
+    OpticalSurface = (G4OpticalSurface *)Surface->GetSurfaceProperty();
+
+  if (OpticalSurface) {
+
+    type = OpticalSurface->GetType();
+    theModel = OpticalSurface->GetModel();
+    theFinish = OpticalSurface->GetFinish();
+
+    aMaterialPropertiesTable = OpticalSurface->GetMaterialPropertiesTable();
 
+    if (aMaterialPropertiesTable) {
+
+      if (theFinish == polishedbackpainted || theFinish == groundbackpainted) {
+        Rindex = aMaterialPropertiesTable->GetProperty("RINDEX");
         if (Rindex) {
-          //	Rindex1 = Rindex->GetProperty(thePhotonMomentum);
-          		Rindex1 = Rindex->Value(thePhotonMomentum);
-
-	}
-	else {
-	        theStatus = NoRINDEX;
-		aParticleChange.ProposeTrackStatus(fStopAndKill);
-                aStep.GetTrack()->SetTrackStatus(fStopAndKill);
-		// aParticleChange.ProposeEnergy(0.0);    
-		return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-	}
-
-        theModel = glisur;
-        theFinish = polished;
-
-        G4SurfaceType type = dielectric_dielectric;
-
-        Rindex = NULL;
-        OpticalSurface = NULL;
-
-        G4LogicalSurface* Surface = G4LogicalBorderSurface::GetSurface
-				    (pPreStepPoint ->GetPhysicalVolume(),
-				     pPostStepPoint->GetPhysicalVolume());
-
-        if (Surface == NULL){
-	  G4bool enteredDaughter=(pPostStepPoint->GetPhysicalVolume()
-				  ->GetMotherLogical() == 
-				  pPreStepPoint->GetPhysicalVolume()
-				  ->GetLogicalVolume());
-	  if(enteredDaughter){
-	    Surface = G4LogicalSkinSurface::GetSurface
-	      (pPostStepPoint->GetPhysicalVolume()->
-	       GetLogicalVolume());
-	    if(Surface == NULL)
-	      Surface = G4LogicalSkinSurface::GetSurface
-	      (pPreStepPoint->GetPhysicalVolume()->
-	       GetLogicalVolume());
-	  }
-	  else{
-	    Surface = G4LogicalSkinSurface::GetSurface
-	      (pPreStepPoint->GetPhysicalVolume()->
-	       GetLogicalVolume());
-	    if(Surface == NULL)
-	      Surface = G4LogicalSkinSurface::GetSurface
-	      (pPostStepPoint->GetPhysicalVolume()->
-	       GetLogicalVolume());
-	  }
-	}
-
-	//	if (Surface) OpticalSurface = dynamic_cast <G4OpticalSurface*> (Surface->GetSurfaceProperty());
-	if (Surface) OpticalSurface = (G4OpticalSurface*) Surface->GetSurfaceProperty();
-
-	if (OpticalSurface) {
-
-           type      = OpticalSurface->GetType();
-	   theModel  = OpticalSurface->GetModel();
-	   theFinish = OpticalSurface->GetFinish();
-
-	   aMaterialPropertiesTable = OpticalSurface->
-					GetMaterialPropertiesTable();
-
-           if (aMaterialPropertiesTable) {
-
-              if (theFinish == polishedbackpainted ||
-                  theFinish == groundbackpainted ) {
-                  Rindex = aMaterialPropertiesTable->GetProperty("RINDEX");
-	          if (Rindex) {
-              // Rindex2 = Rindex->GetProperty(thePhotonMomentum);
-                     Rindex2 = Rindex->Value(thePhotonMomentum);
-
-                  }
-                  else {
-		     theStatus = NoRINDEX;
-                     aParticleChange.ProposeTrackStatus(fStopAndKill);
-                     aStep.GetTrack()->SetTrackStatus(fStopAndKill);
-
-		     // aParticleChange.ProposeEnergy(0.0);
-
-                     return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-                  }
-              }
-
-              G4MaterialPropertyVector* PropertyPointer;
-
-	      PropertyPointer = 
-	      aMaterialPropertiesTable->GetProperty("REFLECTIVITY");
-	      if (PropertyPointer) { 
-                        // PropertyPointer->GetProperty(thePhotonMomentum);
-                      theReflectivity =
-               		      PropertyPointer->Value(thePhotonMomentum);
-              } else {
-                      theReflectivity = 1.0;
-              }
-
-	      PropertyPointer = 
-	      aMaterialPropertiesTable->GetProperty("EFFICIENCY");
-	      if (PropertyPointer) {
-                        // PropertyPointer->GetProperty(thePhotonMomentum);
-                      theEfficiency =
-                		      PropertyPointer->Value(thePhotonMomentum);
-              } else {
-                      theEfficiency = 0.0;
-              }
-
-	      if ( theModel == unified ) {
-	        PropertyPointer = 
-		aMaterialPropertiesTable->GetProperty("SPECULARLOBECONSTANT");
-	        if (PropertyPointer) {
-                           // PropertyPointer->GetProperty(thePhotonMomentum);
-                         prob_sl =
-                  			 PropertyPointer->Value(thePhotonMomentum);
-                } else {
-                         prob_sl = 0.0;
-                }
-
-	        PropertyPointer = 
-		aMaterialPropertiesTable->GetProperty("SPECULARSPIKECONSTANT");
-	        if (PropertyPointer) {
-                            // PropertyPointer->GetProperty(thePhotonMomentum);
-                        prob_ss =
-                   			 PropertyPointer->Value(thePhotonMomentum);
-                } else {
-                         prob_ss = 0.0;
-                }
-
-	        PropertyPointer = 
-		aMaterialPropertiesTable->GetProperty("BACKSCATTERCONSTANT");
-	        if (PropertyPointer) {
-            // 			 PropertyPointer->GetProperty(thePhotonMomentum);
-                        prob_bs =
-			                     PropertyPointer->Value(thePhotonMomentum);
-                } else {
-                         prob_bs = 0.0;
-                }
-	      }
-	   }
-           else if (theFinish == polishedbackpainted ||
-                    theFinish == groundbackpainted ) {
-                      aParticleChange.ProposeTrackStatus(fStopAndKill);
-		      aStep.GetTrack()->SetTrackStatus(fStopAndKill);
-
-		      // aParticleChange.ProposeEnergy(0.0);
-
-                      return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-           }
+          // Rindex2 = Rindex->GetProperty(thePhotonMomentum);
+          Rindex2 = Rindex->Value(thePhotonMomentum);
+
+        } else {
+          theStatus = NoRINDEX;
+          aParticleChange.ProposeTrackStatus(fStopAndKill);
+          aStep.GetTrack()->SetTrackStatus(fStopAndKill);
+
+          // aParticleChange.ProposeEnergy(0.0);
+
+          return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+        }
+      }
+
+      G4MaterialPropertyVector *PropertyPointer;
+
+      PropertyPointer = aMaterialPropertiesTable->GetProperty("REFLECTIVITY");
+      if (PropertyPointer) {
+        // PropertyPointer->GetProperty(thePhotonMomentum);
+        theReflectivity = PropertyPointer->Value(thePhotonMomentum);
+      } else {
+        theReflectivity = 1.0;
+      }
+
+      PropertyPointer = aMaterialPropertiesTable->GetProperty("EFFICIENCY");
+      if (PropertyPointer) {
+        // PropertyPointer->GetProperty(thePhotonMomentum);
+        theEfficiency = PropertyPointer->Value(thePhotonMomentum);
+      } else {
+        theEfficiency = 0.0;
+      }
+
+      if (theModel == unified) {
+        PropertyPointer = aMaterialPropertiesTable->GetProperty("SPECULARLOBECONSTANT");
+        if (PropertyPointer) {
+          // PropertyPointer->GetProperty(thePhotonMomentum);
+          prob_sl = PropertyPointer->Value(thePhotonMomentum);
+        } else {
+          prob_sl = 0.0;
         }
 
-        if (type == dielectric_dielectric ) {
-           if (theFinish == polished || theFinish == ground ) {
-
-	      if (Material1 == Material2){
-		 theStatus = SameMaterial;
-		 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-	      }
-              aMaterialPropertiesTable = 
-                     Material2->GetMaterialPropertiesTable();
-              if (aMaterialPropertiesTable)
-                 Rindex = aMaterialPropertiesTable->GetProperty("RINDEX");
-              if (Rindex) {
-                // Rindex2 = Rindex->GetProperty(thePhotonMomentum);
-                 Rindex2 = Rindex->Value(thePhotonMomentum);
-              }
-              else {
-		 theStatus = NoRINDEX;
-                 aParticleChange.ProposeTrackStatus(fStopAndKill);
-		 aStep.GetTrack()->SetTrackStatus(fStopAndKill);
-
-		 // aParticleChange.ProposeEnergy(0.0);
-
-                 return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-	      }
-           }
+        PropertyPointer = aMaterialPropertiesTable->GetProperty("SPECULARSPIKECONSTANT");
+        if (PropertyPointer) {
+          // PropertyPointer->GetProperty(thePhotonMomentum);
+          prob_ss = PropertyPointer->Value(thePhotonMomentum);
+        } else {
+          prob_ss = 0.0;
         }
 
-        if ( verboseLevel > 0 ) {
-                G4cout << " Photon at Boundary! " << G4endl;
-                G4cout << " Old Momentum Direction: " << OldMomentum     << G4endl;
-                G4cout << " Old Polarization:       " << OldPolarization << G4endl;
+        PropertyPointer = aMaterialPropertiesTable->GetProperty("BACKSCATTERCONSTANT");
+        if (PropertyPointer) {
+          // 			 PropertyPointer->GetProperty(thePhotonMomentum);
+          prob_bs = PropertyPointer->Value(thePhotonMomentum);
+        } else {
+          prob_bs = 0.0;
         }
+      }
+    } else if (theFinish == polishedbackpainted || theFinish == groundbackpainted) {
+      aParticleChange.ProposeTrackStatus(fStopAndKill);
+      aStep.GetTrack()->SetTrackStatus(fStopAndKill);
+
+      // aParticleChange.ProposeEnergy(0.0);
+
+      return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+    }
+  }
+
+  if (type == dielectric_dielectric) {
+    if (theFinish == polished || theFinish == ground) {
+
+      if (Material1 == Material2) {
+        theStatus = SameMaterial;
+        return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+      }
+      aMaterialPropertiesTable = Material2->GetMaterialPropertiesTable();
+      if (aMaterialPropertiesTable)
+        Rindex = aMaterialPropertiesTable->GetProperty("RINDEX");
+      if (Rindex) {
+        // Rindex2 = Rindex->GetProperty(thePhotonMomentum);
+        Rindex2 = Rindex->Value(thePhotonMomentum);
+      } else {
+        theStatus = NoRINDEX;
+        aParticleChange.ProposeTrackStatus(fStopAndKill);
+        aStep.GetTrack()->SetTrackStatus(fStopAndKill);
+
+        // aParticleChange.ProposeEnergy(0.0);
+
+        return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+      }
+    }
+  }
 
-	G4ThreeVector theGlobalPoint = pPostStepPoint->GetPosition();
+  if (verboseLevel > 0) {
+    G4cout << " Photon at Boundary! " << G4endl;
+    G4cout << " Old Momentum Direction: " << OldMomentum << G4endl;
+    G4cout << " Old Polarization:       " << OldPolarization << G4endl;
+  }
+
+  G4ThreeVector theGlobalPoint = pPostStepPoint->GetPosition();
 
-        G4Navigator* theNavigator =
-                     G4TransportationManager::GetTransportationManager()->
-                                              GetNavigatorForTracking();
+  G4Navigator *theNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
 
-	G4ThreeVector theLocalPoint = theNavigator->
-        			      GetGlobalToLocalTransform().
-				      TransformPoint(theGlobalPoint);
+  G4ThreeVector theLocalPoint = theNavigator->GetGlobalToLocalTransform().TransformPoint(theGlobalPoint);
 
-	G4ThreeVector theLocalNormal;	// Normal points back into volume
+  G4ThreeVector theLocalNormal; // Normal points back into volume
 
-	G4bool valid;
-	theLocalNormal = theNavigator->GetLocalExitNormal(&valid);
+  G4bool valid;
+  theLocalNormal = theNavigator->GetLocalExitNormal(&valid);
 
-	if (valid) {
-	  theLocalNormal = -theLocalNormal;
-	}
-	else {
-	  G4cerr << " RichTbG4OpBoundaryProcess/PostStepDoIt(): "
-	       << " The Navigator reports that it returned an invalid normal" 
-	       << G4endl;
-	}
+  if (valid) {
+    theLocalNormal = -theLocalNormal;
+  } else {
+    G4cerr << " RichTbG4OpBoundaryProcess/PostStepDoIt(): "
+           << " The Navigator reports that it returned an invalid normal" << G4endl;
+  }
 
-	theGlobalNormal = theNavigator->GetLocalToGlobalTransform().
-	                                TransformAxis(theLocalNormal);
-        if (OldMomentum * theGlobalNormal > 0.0) {
+  theGlobalNormal = theNavigator->GetLocalToGlobalTransform().TransformAxis(theLocalNormal);
+  if (OldMomentum * theGlobalNormal > 0.0) {
 #ifdef G4DEBUG_OPTICAL
-           G4cerr << " RichTbG4OpBoundaryProcess/PostStepDoIt(): "
-                  << " theGlobalNormal points the wrong direction "
-                  << G4endl;
+    G4cerr << " RichTbG4OpBoundaryProcess/PostStepDoIt(): "
+           << " theGlobalNormal points the wrong direction " << G4endl;
 #endif
-           theGlobalNormal = -theGlobalNormal;
-        }
-	if (type == dielectric_metal) {
-
-	  DielectricMetal();
-
-	}
-	else if (type == dielectric_dielectric) {
-
-	  if ( theFinish == polishedfrontpainted ||
-	       theFinish == groundfrontpainted ) {
-	          if( !G4BooleanRand(theReflectivity) ) {
-		    DoAbsorption();
-		  }
-	          else {
-		    if ( theFinish == groundfrontpainted )
-					theStatus = LambertianReflection;
-		    DoReflection();
-		  }
-	  }
-	  else {
-		  DielectricDielectric();
-	  }
-	}
-	else {
-
-	  G4cerr << " Error: G4BoundaryProcess: illegal boundary type " << G4endl;
-	  return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-
-	}
-
-        NewMomentum = NewMomentum.unit();
-        NewPolarization = NewPolarization.unit();
-
-        if ( verboseLevel > 0) {
-		G4cout << " New Momentum Direction: " << NewMomentum     << G4endl;
-		G4cout << " New Polarization:       " << NewPolarization << G4endl;
-		if ( theStatus == Undefined )
-			G4cout << " *** Undefined *** " << G4endl;
-		if ( theStatus == FresnelRefraction )
-			G4cout << " *** FresnelRefraction *** " << G4endl;
-		if ( theStatus == FresnelReflection )
-			G4cout << " *** FresnelReflection *** " << G4endl;
-		if ( theStatus == TotalInternalReflection )
-			G4cout << " *** TotalInternalReflection *** " << G4endl;
-		if ( theStatus == LambertianReflection )
-			G4cout << " *** LambertianReflection *** " << G4endl;
-		if ( theStatus == LobeReflection ) 
-			G4cout << " *** LobeReflection *** " << G4endl;
-		if ( theStatus == SpikeReflection )
-			G4cout << " *** SpikeReflection *** " << G4endl;
-		if ( theStatus == BackScattering )
-			G4cout << " *** BackScattering *** " << G4endl;
-		if ( theStatus == Absorption )
-			G4cout << " *** Absorption *** " << G4endl;
-		if ( theStatus == Detection )
-			G4cout << " *** Detection *** " << G4endl;
-                if ( theStatus == NotAtBoundary )
-                        G4cout << " *** NotAtBoundary *** " << G4endl;
-                if ( theStatus == SameMaterial )
-                        G4cout << " *** SameMaterial *** " << G4endl;
-                if ( theStatus == StepTooSmall )
-                        G4cout << " *** StepTooSmall *** " << G4endl;
-                if ( theStatus == NoRINDEX )
-                        G4cout << " *** NoRINDEX *** " << G4endl;
-        }
+    theGlobalNormal = -theGlobalNormal;
+  }
+  if (type == dielectric_metal) {
+
+    DielectricMetal();
+
+  } else if (type == dielectric_dielectric) {
+
+    if (theFinish == polishedfrontpainted || theFinish == groundfrontpainted) {
+      if (!G4BooleanRand(theReflectivity)) {
+        DoAbsorption();
+      } else {
+        if (theFinish == groundfrontpainted)
+          theStatus = LambertianReflection;
+        DoReflection();
+      }
+    } else {
+      DielectricDielectric();
+    }
+  } else {
+
+    G4cerr << " Error: G4BoundaryProcess: illegal boundary type " << G4endl;
+    return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+  }
 
-	// addtional fix by SE to really kill the photon if it is proposed to be killed.
-        //  SE March 7, 2005.
-        const G4TrackStatus curTrackStatus = aParticleChange.GetTrackStatus(); 
-	  if( curTrackStatus == fStopAndKill ) {
-	    aStep.GetTrack()->SetTrackStatus(fStopAndKill);
-          }
-        // end of fix by SE
-	aParticleChange.ProposeMomentumDirection(NewMomentum);
-	aParticleChange.ProposePolarization(NewPolarization);
+  NewMomentum = NewMomentum.unit();
+  NewPolarization = NewPolarization.unit();
+
+  if (verboseLevel > 0) {
+    G4cout << " New Momentum Direction: " << NewMomentum << G4endl;
+    G4cout << " New Polarization:       " << NewPolarization << G4endl;
+    if (theStatus == Undefined)
+      G4cout << " *** Undefined *** " << G4endl;
+    if (theStatus == FresnelRefraction)
+      G4cout << " *** FresnelRefraction *** " << G4endl;
+    if (theStatus == FresnelReflection)
+      G4cout << " *** FresnelReflection *** " << G4endl;
+    if (theStatus == TotalInternalReflection)
+      G4cout << " *** TotalInternalReflection *** " << G4endl;
+    if (theStatus == LambertianReflection)
+      G4cout << " *** LambertianReflection *** " << G4endl;
+    if (theStatus == LobeReflection)
+      G4cout << " *** LobeReflection *** " << G4endl;
+    if (theStatus == SpikeReflection)
+      G4cout << " *** SpikeReflection *** " << G4endl;
+    if (theStatus == BackScattering)
+      G4cout << " *** BackScattering *** " << G4endl;
+    if (theStatus == Absorption)
+      G4cout << " *** Absorption *** " << G4endl;
+    if (theStatus == Detection)
+      G4cout << " *** Detection *** " << G4endl;
+    if (theStatus == NotAtBoundary)
+      G4cout << " *** NotAtBoundary *** " << G4endl;
+    if (theStatus == SameMaterial)
+      G4cout << " *** SameMaterial *** " << G4endl;
+    if (theStatus == StepTooSmall)
+      G4cout << " *** StepTooSmall *** " << G4endl;
+    if (theStatus == NoRINDEX)
+      G4cout << " *** NoRINDEX *** " << G4endl;
+  }
 
-        return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-}
+  // addtional fix by SE to really kill the photon if it is proposed to be killed.
+  //  SE March 7, 2005.
+  const G4TrackStatus curTrackStatus = aParticleChange.GetTrackStatus();
+  if (curTrackStatus == fStopAndKill) {
+    aStep.GetTrack()->SetTrackStatus(fStopAndKill);
+  }
+  // end of fix by SE
+  aParticleChange.ProposeMomentumDirection(NewMomentum);
+  aParticleChange.ProposePolarization(NewPolarization);
 
-G4ThreeVector 
-RichTbG4OpBoundaryProcess::GetFacetNormal(const G4ThreeVector& Momentum,
-			            const G4ThreeVector&  Normal ) const
-{
-        G4ThreeVector FacetNormal;
-
-	if (theModel == unified) {
-
-	/* This function code alpha to a random value taken from the
-           distribution p(alpha) = g(alpha; 0, sigma_alpha)*std::sin(alpha), 
-           for alpha > 0 and alpha < 90, where g(alpha; 0, sigma_alpha) 
-           is a gaussian distribution with mean 0 and standard deviation 
-           sigma_alpha.  */
-
-	   G4double alpha;
-
-	   G4double sigma_alpha = 0.0;
-	   if (OpticalSurface) sigma_alpha = OpticalSurface->GetSigmaAlpha();
-
-	   G4double f_max = std::min(1.0,4.*sigma_alpha);
-
-	   do {
-	      do {
-	         alpha = G4RandGauss::shoot(0.0,sigma_alpha);
-	      } while (G4UniformRand()*f_max > std::sin(alpha) || alpha >= CLHEP::halfpi );
-
-	      G4double phi = G4UniformRand()*CLHEP::twopi;
-
-	      G4double SinAlpha = std::sin(alpha);
-	      G4double CosAlpha = std::cos(alpha);
-              G4double SinPhi = std::sin(phi);
-              G4double CosPhi = std::cos(phi);
-
-              G4double unit_x = SinAlpha * CosPhi;
-              G4double unit_y = SinAlpha * SinPhi;
-              G4double unit_z = CosAlpha;
-
-	      FacetNormal.setX(unit_x);
-	      FacetNormal.setY(unit_y);
-	      FacetNormal.setZ(unit_z);
-
-	      G4ThreeVector tmpNormal = Normal;
-
-	      FacetNormal.rotateUz(tmpNormal);
-	   } while (Momentum * FacetNormal >= 0.0);
-	}
-	else {
-
-	   G4double  polish = 1.0;
-	   if (OpticalSurface) polish = OpticalSurface->GetPolish();
-
-           if (polish < 1.0) {
-              do {
-                 G4ThreeVector smear;
-                 do {
-                    smear.setX(2.*G4UniformRand()-1.0);
-                    smear.setY(2.*G4UniformRand()-1.0);
-                    smear.setZ(2.*G4UniformRand()-1.0);
-                 } while (smear.mag()>1.0);
-                 smear = (1.-polish) * smear;
-                 FacetNormal = Normal + smear;
-              } while (Momentum * FacetNormal >= 0.0);
-              FacetNormal = FacetNormal.unit();
-	   }
-           else {
-              FacetNormal = Normal;
-           }
-	}
-	return FacetNormal;
+  return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
 }
 
-void RichTbG4OpBoundaryProcess::DielectricMetal()
-{
-        G4int n = 0;
+G4ThreeVector RichTbG4OpBoundaryProcess::GetFacetNormal(const G4ThreeVector &Momentum,
+                                                        const G4ThreeVector &Normal) const {
+  G4ThreeVector FacetNormal;
+
+  if (theModel == unified) {
+
+    /* This function code alpha to a random value taken from the
+       distribution p(alpha) = g(alpha; 0, sigma_alpha)*std::sin(alpha),
+       for alpha > 0 and alpha < 90, where g(alpha; 0, sigma_alpha)
+       is a gaussian distribution with mean 0 and standard deviation
+       sigma_alpha.  */
+
+    G4double alpha;
+
+    G4double sigma_alpha = 0.0;
+    if (OpticalSurface)
+      sigma_alpha = OpticalSurface->GetSigmaAlpha();
+
+    G4double f_max = std::min(1.0, 4. * sigma_alpha);
+
+    do {
+      do {
+        alpha = G4RandGauss::shoot(0.0, sigma_alpha);
+      } while (G4UniformRand() * f_max > std::sin(alpha) || alpha >= CLHEP::halfpi);
+
+      G4double phi = G4UniformRand() * CLHEP::twopi;
+
+      G4double SinAlpha = std::sin(alpha);
+      G4double CosAlpha = std::cos(alpha);
+      G4double SinPhi = std::sin(phi);
+      G4double CosPhi = std::cos(phi);
+
+      G4double unit_x = SinAlpha * CosPhi;
+      G4double unit_y = SinAlpha * SinPhi;
+      G4double unit_z = CosAlpha;
+
+      FacetNormal.setX(unit_x);
+      FacetNormal.setY(unit_y);
+      FacetNormal.setZ(unit_z);
+
+      G4ThreeVector tmpNormal = Normal;
+
+      FacetNormal.rotateUz(tmpNormal);
+    } while (Momentum * FacetNormal >= 0.0);
+  } else {
+
+    G4double polish = 1.0;
+    if (OpticalSurface)
+      polish = OpticalSurface->GetPolish();
+
+    if (polish < 1.0) {
+      do {
+        G4ThreeVector smear;
+        do {
+          smear.setX(2. * G4UniformRand() - 1.0);
+          smear.setY(2. * G4UniformRand() - 1.0);
+          smear.setZ(2. * G4UniformRand() - 1.0);
+        } while (smear.mag() > 1.0);
+        smear = (1. - polish) * smear;
+        FacetNormal = Normal + smear;
+      } while (Momentum * FacetNormal >= 0.0);
+      FacetNormal = FacetNormal.unit();
+    } else {
+      FacetNormal = Normal;
+    }
+  }
+  return FacetNormal;
+}
 
-	do {
+void RichTbG4OpBoundaryProcess::DielectricMetal() {
+  G4int n = 0;
 
-           n++;
+  do {
 
-           if( !G4BooleanRand(theReflectivity) && n == 1 ) {
+    n++;
 
-             DoAbsorption();
-             break;
+    if (!G4BooleanRand(theReflectivity) && n == 1) {
 
-           }
-           else {
+      DoAbsorption();
+      break;
 
-             if ( theModel == glisur || theFinish == polished || 
-                                        prob_ss+prob_sl+prob_bs == 0.0 ) {
-               // G4cout << "reflection" << G4endl;
-                DoReflection();
+    } else {
 
-             } else {
+      if (theModel == glisur || theFinish == polished || prob_ss + prob_sl + prob_bs == 0.0) {
+        // G4cout << "reflection" << G4endl;
+        DoReflection();
 
-                if ( n == 1 ) ChooseReflection();
-                                                                                
-                if ( theStatus == LambertianReflection ) {
-                   DoReflection();
-                }
-                else if ( theStatus == BackScattering ) {
-                   NewMomentum = -OldMomentum;
-                   NewPolarization = -OldPolarization;
-                }
-                else {
+      } else {
 
-                   if(theStatus==LobeReflection)theFacetNormal = 
-                             GetFacetNormal(OldMomentum,theGlobalNormal);
+        if (n == 1)
+          ChooseReflection();
 
-                   G4double PdotN = OldMomentum * theFacetNormal;
-                   NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
-                   G4double EdotN = OldPolarization * theFacetNormal;
-                   NewPolarization = -OldPolarization + (2.*EdotN)*theFacetNormal;                                                                                
-                }
+        if (theStatus == LambertianReflection) {
+          DoReflection();
+        } else if (theStatus == BackScattering) {
+          NewMomentum = -OldMomentum;
+          NewPolarization = -OldPolarization;
+        } else {
 
-             }
+          if (theStatus == LobeReflection)
+            theFacetNormal = GetFacetNormal(OldMomentum, theGlobalNormal);
 
-             OldMomentum = NewMomentum;
-             OldPolarization = NewPolarization;
+          G4double PdotN = OldMomentum * theFacetNormal;
+          NewMomentum = OldMomentum - (2. * PdotN) * theFacetNormal;
+          G4double EdotN = OldPolarization * theFacetNormal;
+          NewPolarization = -OldPolarization + (2. * EdotN) * theFacetNormal;
+        }
+      }
 
-	   }
+      OldMomentum = NewMomentum;
+      OldPolarization = NewPolarization;
+    }
 
-	} while (NewMomentum * theGlobalNormal < 0.0);
+  } while (NewMomentum * theGlobalNormal < 0.0);
 }
 
-void RichTbG4OpBoundaryProcess::DielectricDielectric()
-{
-	G4bool Inside = false;
-	G4bool Swap = false;
-
-	leap:
-
-        G4bool Through = false;
-	G4bool Done = false;
-
-	do {
-
-	   if (Through) {
-	      Swap = !Swap;
-	      Through = false;
-	      theGlobalNormal = -theGlobalNormal;
-	      G4Swap(Material1,Material2);
-	      G4Swap(&Rindex1,&Rindex2);
-	   }
-
-	   if ( theFinish == ground || theFinish == groundbackpainted ) {
-		theFacetNormal = 
-			     GetFacetNormal(OldMomentum,theGlobalNormal);
-	   }
-	   else {
-		theFacetNormal = theGlobalNormal;
-	   }
-
-	   G4double PdotN = OldMomentum * theFacetNormal;
-	   G4double EdotN = OldPolarization * theFacetNormal;
-
-	   cost1 = - PdotN;
-     G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
-
-	   if (std::abs(cost1) < 1.0-kCarTolerance){
-	      sint1 = std::sqrt(1.-cost1*cost1);
-	      sint2 = sint1*Rindex1/Rindex2;     // *** Snell's Law ***
-	   }
-	   else {
-	      sint1 = 0.0;
-	      sint2 = 0.0;
-	   }
-
-	   if (sint2 >= 1.0) {
-
-	      // Simulate total internal reflection
-
-	      if (Swap) Swap = !Swap;
-
-              theStatus = TotalInternalReflection;
-
-	      if ( theModel == unified && theFinish != polished )
-						     ChooseReflection();
-
-	      if ( theStatus == LambertianReflection ) {
-		 DoReflection();
-	      }
-	      else if ( theStatus == BackScattering ) {
-		 NewMomentum = -OldMomentum;
-		 NewPolarization = -OldPolarization;
-	      }
-	      else {
-
-                 
-		//PdotN = OldMomentum * theFacetNormal;
-		// NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
-		// EdotN = OldPolarization * theFacetNormal;
-		// NewPolarization = -OldPolarization + (2.*EdotN)*theFacetNormal;
-
-		 // begin test for total internal reflection
-		 // G4cout<< "test of total internal reflection "<<G4endl;
-                 // For test Kill photons whoch do total internal reflection in Crystal
-                  G4String aMaterial1Name= Material1->GetName();
-		  // G4cout<< "test Material1 name "<< aMaterial1Name <<G4endl;
-		   G4String aMaterial2Name= Material2->GetName();
-		   // G4cout<< "test Material2 name "<< aMaterial2Name <<G4endl;
-		   //  G4cout << "step " << CurStepNum <<" " << NewMomentum <<G4endl;
-
-                  if(Material1->GetName() == CrystalMaterialName ) {
-
-		     if( CurStepNum > theMaxPhotStepNumInBoundaryProc ) {
-		       // G4cout << "step " << CurStepNum << G4endl;
-		      DoAbsorption();
-		      //  G4cout << "killed!" << G4endl;
-		       
-		       
-		     }
-		  }
-
-                 PdotN = OldMomentum * theFacetNormal;
-		 NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
-		 EdotN = OldPolarization * theFacetNormal;
-		 NewPolarization = -OldPolarization + (2.*EdotN)*theFacetNormal;
-		  
-		  //end of test for killing total internal reflecton
-
-
-	      }
-	   }
-	   else if (sint2 < 1.0) {
-
-	      // Calculate amplitude for transmission (Q = P x N)
-
-	      if (cost1 > 0.0) {
-	         cost2 =  std::sqrt(1.-sint2*sint2);
-	      }
-	      else {
-	         cost2 = -std::sqrt(1.-sint2*sint2);
-	      }
-
-	      G4ThreeVector A_trans, A_paral, E1pp, E1pl;
-	      G4double E1_perp, E1_parl;
-
-	      if (sint1 > 0.0) {
-	         A_trans = OldMomentum.cross(theFacetNormal);
-                 A_trans = A_trans.unit();
-	         E1_perp = OldPolarization * A_trans;
-                 E1pp    = E1_perp * A_trans;
-                 E1pl    = OldPolarization - E1pp;
-                 E1_parl = E1pl.mag();
-              }
-	      else {
-	         A_trans  = OldPolarization;
-	         // Here we Follow Jackson's conventions and we set the
-	         // parallel component = 1 in case of a ray perpendicular
-	         // to the surface
-	         E1_perp  = 0.0;
-	         E1_parl  = 1.0;
-	      }
-
-              G4double s1 = Rindex1*cost1;
-              G4double E2_perp = 2.*s1*E1_perp/(Rindex1*cost1+Rindex2*cost2);
-              G4double E2_parl = 2.*s1*E1_parl/(Rindex2*cost1+Rindex1*cost2);
-              G4double E2_total = E2_perp*E2_perp + E2_parl*E2_parl;
-              G4double s2 = Rindex2*cost2*E2_total;
-
-              G4double TransCoeff;
-
-	      if (cost1 != 0.0) {
-	         TransCoeff = s2/s1;
-	      }
-	      else {
-	         TransCoeff = 0.0;
-	      }
-
-// modif done by SE to avoid reflections
-        G4String Material1Name= Material1->GetName();
-        G4String Material2Name= Material2->GetName();
-// The QE values already contains the loss at the following two
-// boundaries.
-        if( (Material1Name== PmtQuartzWMaterialName) || 
-            (Material2Name == PmtQuartzWMaterialName) ) TransCoeff=1.0;
-        if( (Material1Name== PmtPhCathodeMaterialName) || 
-            (Material2Name == PmtPhCathodeMaterialName) ) TransCoeff=1.0;
-        // now for avoiding loss at software created (artificial) boundaries.
-        if( (Material1Name== NitrogenGasMaterialName) && 
-            (Material2Name== PMTSMasterMaterialName ) )  TransCoeff=1.0;
-        if( (Material1Name==  PMTSMasterMaterialName) &&
-            (Material2Name == NitrogenGasMaterialName))   TransCoeff=1.0;
-
-        if( (Material1Name== HpdQuartzWMaterialName) || 
-            (Material2Name == HpdQuartzWMaterialName ) ) TransCoeff=1.0;
-        if( (Material1Name== HpdPhCathodeMaterialName) || 
-            (Material2Name == HpdPhCathodeMaterialName) ) TransCoeff=1.0;
-
-        if( (Material1Name== NitrogenGasMaterialName) && 
-            (Material2Name== HPDSMasterMaterialName ) )  TransCoeff=1.0;
-        if( (Material1Name==  HPDSMasterMaterialName) &&
-            (Material2Name == NitrogenGasMaterialName))   TransCoeff=1.0;
-
- // end of modif by SE
-
-
-
-	      G4double E2_abs, C_parl, C_perp;
-
-	      if ( !G4BooleanRand(TransCoeff) ) {
-
-	         // Simulate reflection
-
-                 if (Swap) Swap = !Swap;
-
-		 theStatus = FresnelReflection;
-
-		 if ( theModel == unified && theFinish != polished )
-						     ChooseReflection();
-
-		 if ( theStatus == LambertianReflection ) {
-		    DoReflection();
-		 }
-		 else if ( theStatus == BackScattering ) {
-		    NewMomentum = -OldMomentum;
-		    NewPolarization = -OldPolarization;
-		 }
-		 else {
-
-                    PdotN = OldMomentum * theFacetNormal;
-	            NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
-
-	            if (sint1 > 0.0) {   // incident ray oblique
-
-		       E2_parl   = Rindex2*E2_parl/Rindex1 - E1_parl;
-		       E2_perp   = E2_perp - E1_perp;
-		       E2_total  = E2_perp*E2_perp + E2_parl*E2_parl;
-                       A_paral   = NewMomentum.cross(A_trans);
-                       A_paral   = A_paral.unit();
-		       E2_abs    = std::sqrt(E2_total);
-		       C_parl    = E2_parl/E2_abs;
-		       C_perp    = E2_perp/E2_abs;
-
-                       NewPolarization = C_parl*A_paral + C_perp*A_trans;
-
-	            }
-
-	            else {               // incident ray perpendicular
-
-	               if (Rindex2 > Rindex1) {
-		          NewPolarization = - OldPolarization;
-	               }
-	               else {
-	                  NewPolarization =   OldPolarization;
-	               }
-
-	            }
-	         }
-
-     //  fix made by SE to avoid reflection at the exit of aerogel when the
-     // polarisation values are unphysical.
-     //  At this dielec-dielec boundary the polarisation sometimes gets unphysical
-     // values depending upon the angle of incidence. These values eventually
-     // get tramsmitted to the photon direction. Hence in these cases the 
-     // photon is killed by absorption.
-     G4bool PolarisOk = true;
-     //              G4cout<<"dielc dielec newpolariation at refl " 
-     //         << NewPolarization<<G4endl;
-                     G4String Material1NameA= Material1->GetName();
-                     G4String Material2NameA= Material2->GetName();
-
-              if(  NewPolarization.x() <= 1.0 &&  NewPolarization.x() >= -1.0 &&
-                   NewPolarization.y() <= 1.0 &&  NewPolarization.y() >= -1.0 && 
-                   NewPolarization.z() <= 1.0 && NewPolarization.z() >=  -1.0 )
-              { PolarisOk=true;} else { PolarisOk=false;}
-
-           if(  ! PolarisOk) {
-              G4cout<<" Unphysical polarization at dielec dielec boundary for refl  "
-                    <<" Material1 Material2 newPolarisation newMomentum " 
-                    << Material1NameA<<"    "<< Material2NameA
-                    <<"     " <<NewPolarization<<"    "
-                    << NewMomentum<<G4endl;
-               DoAbsorption() ;
-              
+void RichTbG4OpBoundaryProcess::DielectricDielectric() {
+  G4bool Inside = false;
+  G4bool Swap = false;
+
+leap:
+
+  G4bool Through = false;
+  G4bool Done = false;
+
+  do {
+
+    if (Through) {
+      Swap = !Swap;
+      Through = false;
+      theGlobalNormal = -theGlobalNormal;
+      G4Swap(Material1, Material2);
+      G4Swap(&Rindex1, &Rindex2);
+    }
+
+    if (theFinish == ground || theFinish == groundbackpainted) {
+      theFacetNormal = GetFacetNormal(OldMomentum, theGlobalNormal);
+    } else {
+      theFacetNormal = theGlobalNormal;
+    }
+
+    G4double PdotN = OldMomentum * theFacetNormal;
+    G4double EdotN = OldPolarization * theFacetNormal;
+
+    cost1 = -PdotN;
+    G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
+
+    if (std::abs(cost1) < 1.0 - kCarTolerance) {
+      sint1 = std::sqrt(1. - cost1 * cost1);
+      sint2 = sint1 * Rindex1 / Rindex2; // *** Snell's Law ***
+    } else {
+      sint1 = 0.0;
+      sint2 = 0.0;
+    }
+
+    if (sint2 >= 1.0) {
+
+      // Simulate total internal reflection
+
+      if (Swap)
+        Swap = !Swap;
+
+      theStatus = TotalInternalReflection;
+
+      if (theModel == unified && theFinish != polished)
+        ChooseReflection();
+
+      if (theStatus == LambertianReflection) {
+        DoReflection();
+      } else if (theStatus == BackScattering) {
+        NewMomentum = -OldMomentum;
+        NewPolarization = -OldPolarization;
+      } else {
+
+        // PdotN = OldMomentum * theFacetNormal;
+        // NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
+        // EdotN = OldPolarization * theFacetNormal;
+        // NewPolarization = -OldPolarization + (2.*EdotN)*theFacetNormal;
+
+        // begin test for total internal reflection
+        // G4cout<< "test of total internal reflection "<<G4endl;
+        // For test Kill photons whoch do total internal reflection in Crystal
+        G4String aMaterial1Name = Material1->GetName();
+        // G4cout<< "test Material1 name "<< aMaterial1Name <<G4endl;
+        G4String aMaterial2Name = Material2->GetName();
+        // G4cout<< "test Material2 name "<< aMaterial2Name <<G4endl;
+        //  G4cout << "step " << CurStepNum <<" " << NewMomentum <<G4endl;
+
+        if (Material1->GetName() == CrystalMaterialName) {
+
+          if (CurStepNum > theMaxPhotStepNumInBoundaryProc) {
+            // G4cout << "step " << CurStepNum << G4endl;
+            DoAbsorption();
+            //  G4cout << "killed!" << G4endl;
+          }
+        }
+
+        PdotN = OldMomentum * theFacetNormal;
+        NewMomentum = OldMomentum - (2. * PdotN) * theFacetNormal;
+        EdotN = OldPolarization * theFacetNormal;
+        NewPolarization = -OldPolarization + (2. * EdotN) * theFacetNormal;
+
+        // end of test for killing total internal reflecton
+      }
+    } else if (sint2 < 1.0) {
+
+      // Calculate amplitude for transmission (Q = P x N)
+
+      if (cost1 > 0.0) {
+        cost2 = std::sqrt(1. - sint2 * sint2);
+      } else {
+        cost2 = -std::sqrt(1. - sint2 * sint2);
+      }
+
+      G4ThreeVector A_trans, A_paral, E1pp, E1pl;
+      G4double E1_perp, E1_parl;
+
+      if (sint1 > 0.0) {
+        A_trans = OldMomentum.cross(theFacetNormal);
+        A_trans = A_trans.unit();
+        E1_perp = OldPolarization * A_trans;
+        E1pp = E1_perp * A_trans;
+        E1pl = OldPolarization - E1pp;
+        E1_parl = E1pl.mag();
+      } else {
+        A_trans = OldPolarization;
+        // Here we Follow Jackson's conventions and we set the
+        // parallel component = 1 in case of a ray perpendicular
+        // to the surface
+        E1_perp = 0.0;
+        E1_parl = 1.0;
+      }
+
+      G4double s1 = Rindex1 * cost1;
+      G4double E2_perp = 2. * s1 * E1_perp / (Rindex1 * cost1 + Rindex2 * cost2);
+      G4double E2_parl = 2. * s1 * E1_parl / (Rindex2 * cost1 + Rindex1 * cost2);
+      G4double E2_total = E2_perp * E2_perp + E2_parl * E2_parl;
+      G4double s2 = Rindex2 * cost2 * E2_total;
+
+      G4double TransCoeff;
+
+      if (cost1 != 0.0) {
+        TransCoeff = s2 / s1;
+      } else {
+        TransCoeff = 0.0;
+      }
+
+      // modif done by SE to avoid reflections
+      G4String Material1Name = Material1->GetName();
+      G4String Material2Name = Material2->GetName();
+      // The QE values already contains the loss at the following two
+      // boundaries.
+      if ((Material1Name == PmtQuartzWMaterialName) || (Material2Name == PmtQuartzWMaterialName))
+        TransCoeff = 1.0;
+      if ((Material1Name == PmtPhCathodeMaterialName) || (Material2Name == PmtPhCathodeMaterialName))
+        TransCoeff = 1.0;
+      // now for avoiding loss at software created (artificial) boundaries.
+      if ((Material1Name == NitrogenGasMaterialName) && (Material2Name == PMTSMasterMaterialName))
+        TransCoeff = 1.0;
+      if ((Material1Name == PMTSMasterMaterialName) && (Material2Name == NitrogenGasMaterialName))
+        TransCoeff = 1.0;
+
+      if ((Material1Name == HpdQuartzWMaterialName) || (Material2Name == HpdQuartzWMaterialName))
+        TransCoeff = 1.0;
+      if ((Material1Name == HpdPhCathodeMaterialName) || (Material2Name == HpdPhCathodeMaterialName))
+        TransCoeff = 1.0;
+
+      if ((Material1Name == NitrogenGasMaterialName) && (Material2Name == HPDSMasterMaterialName))
+        TransCoeff = 1.0;
+      if ((Material1Name == HPDSMasterMaterialName) && (Material2Name == NitrogenGasMaterialName))
+        TransCoeff = 1.0;
+
+      // end of modif by SE
+
+      G4double E2_abs, C_parl, C_perp;
+
+      if (!G4BooleanRand(TransCoeff)) {
+
+        // Simulate reflection
+
+        if (Swap)
+          Swap = !Swap;
+
+        theStatus = FresnelReflection;
+
+        if (theModel == unified && theFinish != polished)
+          ChooseReflection();
+
+        if (theStatus == LambertianReflection) {
+          DoReflection();
+        } else if (theStatus == BackScattering) {
+          NewMomentum = -OldMomentum;
+          NewPolarization = -OldPolarization;
+        } else {
+
+          PdotN = OldMomentum * theFacetNormal;
+          NewMomentum = OldMomentum - (2. * PdotN) * theFacetNormal;
+
+          if (sint1 > 0.0) { // incident ray oblique
+
+            E2_parl = Rindex2 * E2_parl / Rindex1 - E1_parl;
+            E2_perp = E2_perp - E1_perp;
+            E2_total = E2_perp * E2_perp + E2_parl * E2_parl;
+            A_paral = NewMomentum.cross(A_trans);
+            A_paral = A_paral.unit();
+            E2_abs = std::sqrt(E2_total);
+            C_parl = E2_parl / E2_abs;
+            C_perp = E2_perp / E2_abs;
+
+            NewPolarization = C_parl * A_paral + C_perp * A_trans;
+
+          }
+
+          else { // incident ray perpendicular
+
+            if (Rindex2 > Rindex1) {
+              NewPolarization = -OldPolarization;
+            } else {
+              NewPolarization = OldPolarization;
             }
+          }
+        }
+
+        //  fix made by SE to avoid reflection at the exit of aerogel when the
+        // polarisation values are unphysical.
+        //  At this dielec-dielec boundary the polarisation sometimes gets unphysical
+        // values depending upon the angle of incidence. These values eventually
+        // get tramsmitted to the photon direction. Hence in these cases the
+        // photon is killed by absorption.
+        G4bool PolarisOk = true;
+        //              G4cout<<"dielc dielec newpolariation at refl "
+        //         << NewPolarization<<G4endl;
+        G4String Material1NameA = Material1->GetName();
+        G4String Material2NameA = Material2->GetName();
+
+        if (NewPolarization.x() <= 1.0 && NewPolarization.x() >= -1.0 && NewPolarization.y() <= 1.0 &&
+            NewPolarization.y() >= -1.0 && NewPolarization.z() <= 1.0 && NewPolarization.z() >= -1.0) {
+          PolarisOk = true;
+        } else {
+          PolarisOk = false;
+        }
+
+        if (!PolarisOk) {
+          G4cout << " Unphysical polarization at dielec dielec boundary for refl  "
+                 << " Material1 Material2 newPolarisation newMomentum " << Material1NameA << "    " << Material2NameA
+                 << "     " << NewPolarization << "    " << NewMomentum << G4endl;
+          DoAbsorption();
+        }
+
+        // end of fix by SE on 12-1-2004 and copied to this version on 1-3-2005.
 
-             // end of fix by SE on 12-1-2004 and copied to this version on 1-3-2005.
-
-	      }
-	      else { // photon gets transmitted
-
-	         // Simulate transmission/refraction
-
-		 Inside = !Inside;
-		 Through = true;
-		 theStatus = FresnelRefraction;
-
-	         if (sint1 > 0.0) {      // incident ray oblique
-
-		    G4double alpha = cost1 - cost2*(Rindex2/Rindex1);
-		    NewMomentum = OldMomentum + alpha*theFacetNormal;
-		    NewMomentum = NewMomentum.unit();
-		    PdotN = -cost2;
-                    A_paral = NewMomentum.cross(A_trans);
-                    A_paral = A_paral.unit();
-		    E2_abs     = std::sqrt(E2_total);
-		    C_parl     = E2_parl/E2_abs;
-		    C_perp     = E2_perp/E2_abs;
-
-                    NewPolarization = C_parl*A_paral + C_perp*A_trans;
-
-	         }
-	         else {                  // incident ray perpendicular
-
-		    NewMomentum = OldMomentum;
-		    NewPolarization = OldPolarization;
-
-	         }
-	      }
-	   }
-
-	   OldMomentum = NewMomentum.unit();
-	   OldPolarization = NewPolarization.unit();
-
-     //  G4cout << "newMom and global normal " << NewMomentum << " " << theGlobalNormal << G4endl;
-
-	   if (theStatus == FresnelRefraction) {
-	      Done = (NewMomentum * theGlobalNormal <= 0.0);
-	   } 
-	   else {
-	      Done = (NewMomentum * theGlobalNormal >= 0.0);
-	   }
-
-	} while (!Done);
-
-	if (Inside && !Swap) {
-          if( theFinish == polishedbackpainted ||
-              theFinish == groundbackpainted ) {
-	      if( !G4BooleanRand(theReflectivity) ) {
-		DoAbsorption();
-              }
-	      else {
-		if (theStatus != FresnelRefraction ) {
-		   theGlobalNormal = -theGlobalNormal;
-	        }
-	        else {
-		   Swap = !Swap;
-		   G4Swap(Material1,Material2);
-		   G4Swap(&Rindex1,&Rindex2);
-	        }
-		if ( theFinish == groundbackpainted )
-					theStatus = LambertianReflection;
-
-	        DoReflection();
-
-	        theGlobalNormal = -theGlobalNormal;
-		OldMomentum = NewMomentum;
-
-	        goto leap;
-	      }
-	  }
-	}
+      } else { // photon gets transmitted
+
+        // Simulate transmission/refraction
+
+        Inside = !Inside;
+        Through = true;
+        theStatus = FresnelRefraction;
+
+        if (sint1 > 0.0) { // incident ray oblique
+
+          G4double alpha = cost1 - cost2 * (Rindex2 / Rindex1);
+          NewMomentum = OldMomentum + alpha * theFacetNormal;
+          NewMomentum = NewMomentum.unit();
+          PdotN = -cost2;
+          A_paral = NewMomentum.cross(A_trans);
+          A_paral = A_paral.unit();
+          E2_abs = std::sqrt(E2_total);
+          C_parl = E2_parl / E2_abs;
+          C_perp = E2_perp / E2_abs;
+
+          NewPolarization = C_parl * A_paral + C_perp * A_trans;
+
+        } else { // incident ray perpendicular
+
+          NewMomentum = OldMomentum;
+          NewPolarization = OldPolarization;
+        }
+      }
+    }
+
+    OldMomentum = NewMomentum.unit();
+    OldPolarization = NewPolarization.unit();
+
+    //  G4cout << "newMom and global normal " << NewMomentum << " " << theGlobalNormal << G4endl;
+
+    if (theStatus == FresnelRefraction) {
+      Done = (NewMomentum * theGlobalNormal <= 0.0);
+    } else {
+      Done = (NewMomentum * theGlobalNormal >= 0.0);
+    }
+
+  } while (!Done);
+
+  if (Inside && !Swap) {
+    if (theFinish == polishedbackpainted || theFinish == groundbackpainted) {
+      if (!G4BooleanRand(theReflectivity)) {
+        DoAbsorption();
+      } else {
+        if (theStatus != FresnelRefraction) {
+          theGlobalNormal = -theGlobalNormal;
+        } else {
+          Swap = !Swap;
+          G4Swap(Material1, Material2);
+          G4Swap(&Rindex1, &Rindex2);
+        }
+        if (theFinish == groundbackpainted)
+          theStatus = LambertianReflection;
+
+        DoReflection();
+
+        theGlobalNormal = -theGlobalNormal;
+        OldMomentum = NewMomentum;
+
+        goto leap;
+      }
+    }
+  }
 }
 
 // GetMeanFreePath
 // ---------------
 //
-G4double RichTbG4OpBoundaryProcess::GetMeanFreePath(const G4Track& ,
-                                              G4double ,
-                                              G4ForceCondition* condition)
-{
-	*condition = Forced;
+G4double RichTbG4OpBoundaryProcess::GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *condition) {
+  *condition = Forced;
 
-	return DBL_MAX;
+  return DBL_MAX;
 }
-
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4OpRayleigh.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4OpRayleigh.cc
index 8699f8ec65ffa82a78f2a5a3e97476dea82b48db..4ce3533177833a93b25d9a2eb5cfbff1570695c4 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4OpRayleigh.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcG4/proc/RichTbG4OpRayleigh.cc
@@ -24,16 +24,16 @@
 // $Id: RichTbG4OpRayleigh.cc,v 1.12 2004/12/02 23:10:57 gum Exp $
 // GEANT4 tag $Name: geant4-07-00 $
 //
-// 
+//
 ////////////////////////////////////////////////////////////////////////
 // Optical Photon Rayleigh Scattering Class Implementation
 ////////////////////////////////////////////////////////////////////////
 //
-// File:        RichTbG4OpRayleigh.cc 
-// Description: Discrete Process -- Rayleigh scattering of optical 
-//		photons  
+// File:        RichTbG4OpRayleigh.cc
+// Description: Discrete Process -- Rayleigh scattering of optical
+//		photons
 // Version:     1.0
-// Created:     1996-05-31  
+// Created:     1996-05-31
 // Author:      Juliet Armstrong
 // Updated:     2001-10-18 by Peter Gumplinger
 //              eliminate unused variable warning on Linux (gcc-2.95.2)
@@ -51,344 +51,304 @@
 // modif and renamed for extracting info SE 1-3-2005.
 ////////////////////////////////////////////////////////////////////////
 
-#include "Geant4/G4ios.hh"
 #include "RichTbG4OpRayleigh.hh"
+#include "Geant4/G4ios.hh"
 #include "RichTbPhotonUserInfoAttach.hh"
 
 /////////////////////////
 // Class Implementation
 /////////////////////////
 
-        //////////////
-        // Operators
-        //////////////
+//////////////
+// Operators
+//////////////
 
 // RichTbG4OpRayleigh::operator=(const RichTbG4OpRayleigh &right)
 // {
 // }
 
-        /////////////////
-        // Constructors
-        /////////////////
+/////////////////
+// Constructors
+/////////////////
 
-RichTbG4OpRayleigh::RichTbG4OpRayleigh(const G4String& processName)
-           : G4VDiscreteProcess(processName)
-{
+RichTbG4OpRayleigh::RichTbG4OpRayleigh(const G4String &processName) : G4VDiscreteProcess(processName) {
 
-        thePhysicsTable = 0;
+  thePhysicsTable = 0;
 
-        DefaultWater = false;
+  DefaultWater = false;
 
-        if (verboseLevel>0) {
-           G4cout << GetProcessName() << " is created " << G4endl;
-        }
+  if (verboseLevel > 0) {
+    G4cout << GetProcessName() << " is created " << G4endl;
+  }
 
-        BuildThePhysicsTable();
+  BuildThePhysicsTable();
 }
 
 // RichTbG4OpRayleigh::RichTbG4OpRayleigh(const RichTbG4OpRayleigh &right)
 // {
 // }
 
-        ////////////////
-        // Destructors
-        ////////////////
+////////////////
+// Destructors
+////////////////
 
-RichTbG4OpRayleigh::~RichTbG4OpRayleigh()
-{
-        if (thePhysicsTable!= 0) {
-           thePhysicsTable->clearAndDestroy();
-           delete thePhysicsTable;
-        }
+RichTbG4OpRayleigh::~RichTbG4OpRayleigh() {
+  if (thePhysicsTable != 0) {
+    thePhysicsTable->clearAndDestroy();
+    delete thePhysicsTable;
+  }
 }
 
-        ////////////
-        // Methods
-        ////////////
+////////////
+// Methods
+////////////
 
 // PostStepDoIt
 // -------------
 //
-G4VParticleChange* 
-RichTbG4OpRayleigh::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
-{
-        aParticleChange.Initialize(aTrack);
-
-        const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
-
-        if (verboseLevel>0) {
-		G4cout << "Scattering Photon!" << G4endl;
-		G4cout << "Old Momentum Direction: "
-	     	     << aParticle->GetMomentumDirection() << G4endl;
-		G4cout << "Old Polarization: "
-		     << aParticle->GetPolarization() << G4endl;
-	}
-
-	// find polar angle w.r.t. old polarization vector
-
-	G4double rand = G4UniformRand();
-
-	G4double CosTheta = std::pow(rand, 1./3.);
-	G4double SinTheta = std::sqrt(1.-CosTheta*CosTheta);
-
-        if(G4UniformRand() < 0.5)CosTheta = -CosTheta;
-
-
-// Addtions made by SE to save cpu time.
-// Kill the photon when
-// the stepnumber is very large just to avoid any photon
-// going through an in infinite loop through the aerogel
-// or any similar material.
-          G4double totEn = aParticle->GetTotalEnergy();
-          const G4double CurStepLen=  aStep.GetStepLength();
-          const G4int CurStepNum=  aTrack.GetCurrentStepNumber() ;
-          G4bool KillPhotInRayleigh = false;
-          if( CurStepNum > 1000 &&  CurStepLen < 0.00000001*CLHEP::mm ) {
-            KillPhotInRayleigh = true;
-            G4cout<<" Optical Photon killed in Rayleigh after 1000 steps "
-                  << "current energy step size =  "
-                  <<  totEn<<"      "<< CurStepLen <<G4endl;   
-          }
-
-          if(CurStepNum > 5000   ) {
-            KillPhotInRayleigh = true;
-            G4cout<<" Optical Photon killed in Rayleigh after 5000 steps" 
-                  <<G4endl;            
-          }
- 
-          if(KillPhotInRayleigh) {
-            //          aParticleChange.SetStatusChange(fStopAndKill);
-           aParticleChange.ProposeTrackStatus(fStopAndKill);
-           aStep.GetTrack()->SetTrackStatus(fStopAndKill);
-           //           aParticleChange.ProposeEnergy(0.0);    
-          return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-         }
-
-
-// now tag the photon as having rayliegh scattered.
-
-          RichTbRayleighInfoAttach(aTrack);
-// end of additions by SE
-
-
-	// find azimuthal angle w.r.t old polarization vector 
-
-	rand = G4UniformRand();
-
-	G4double Phi = CLHEP::twopi*rand;
-	G4double SinPhi = std::sin(Phi); 
-	G4double CosPhi = std::cos(Phi); 
-	
-	G4double unit_x = SinTheta * CosPhi; 
-	G4double unit_y = SinTheta * SinPhi;  
-	G4double unit_z = CosTheta; 
-	
-        G4ThreeVector NewPolarization (unit_x,unit_y,unit_z);
-
-        // Rotate new polarization direction into global reference system 
-
-	G4ThreeVector OldPolarization = aParticle->GetPolarization();
-        OldPolarization = OldPolarization.unit();
-
-	NewPolarization.rotateUz(OldPolarization);
-        NewPolarization = NewPolarization.unit();
-	
-        // -- new momentum direction is normal to the new
-        // polarization vector and in the same plane as the
-        // old and new polarization vectors --
-
-        G4ThreeVector NewMomentumDirection = 
-                              OldPolarization - NewPolarization * CosTheta;
-
-        if(G4UniformRand() < 0.5)NewMomentumDirection = -NewMomentumDirection;
-        NewMomentumDirection = NewMomentumDirection.unit();
-
-	aParticleChange.ProposePolarization(NewPolarization);
-
-	aParticleChange.ProposeMomentumDirection(NewMomentumDirection);
-
-        if (verboseLevel>0) {
-		G4cout << "New Polarization: " 
-		     << NewPolarization << G4endl;
-		G4cout << "Polarization Change: "
-		     << *(aParticleChange.GetPolarization()) << G4endl;  
-		G4cout << "New Momentum Direction: " 
-		     << NewMomentumDirection << G4endl;
-		G4cout << "Momentum Change: "
-		     << *(aParticleChange.GetMomentumDirection()) << G4endl; 
-	}
-
-        return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+G4VParticleChange *RichTbG4OpRayleigh::PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) {
+  aParticleChange.Initialize(aTrack);
+
+  const G4DynamicParticle *aParticle = aTrack.GetDynamicParticle();
+
+  if (verboseLevel > 0) {
+    G4cout << "Scattering Photon!" << G4endl;
+    G4cout << "Old Momentum Direction: " << aParticle->GetMomentumDirection() << G4endl;
+    G4cout << "Old Polarization: " << aParticle->GetPolarization() << G4endl;
+  }
+
+  // find polar angle w.r.t. old polarization vector
+
+  G4double rand = G4UniformRand();
+
+  G4double CosTheta = std::pow(rand, 1. / 3.);
+  G4double SinTheta = std::sqrt(1. - CosTheta * CosTheta);
+
+  if (G4UniformRand() < 0.5)
+    CosTheta = -CosTheta;
+
+  // Addtions made by SE to save cpu time.
+  // Kill the photon when
+  // the stepnumber is very large just to avoid any photon
+  // going through an in infinite loop through the aerogel
+  // or any similar material.
+  G4double totEn = aParticle->GetTotalEnergy();
+  const G4double CurStepLen = aStep.GetStepLength();
+  const G4int CurStepNum = aTrack.GetCurrentStepNumber();
+  G4bool KillPhotInRayleigh = false;
+  if (CurStepNum > 1000 && CurStepLen < 0.00000001 * CLHEP::mm) {
+    KillPhotInRayleigh = true;
+    G4cout << " Optical Photon killed in Rayleigh after 1000 steps "
+           << "current energy step size =  " << totEn << "      " << CurStepLen << G4endl;
+  }
+
+  if (CurStepNum > 5000) {
+    KillPhotInRayleigh = true;
+    G4cout << " Optical Photon killed in Rayleigh after 5000 steps" << G4endl;
+  }
+
+  if (KillPhotInRayleigh) {
+    //          aParticleChange.SetStatusChange(fStopAndKill);
+    aParticleChange.ProposeTrackStatus(fStopAndKill);
+    aStep.GetTrack()->SetTrackStatus(fStopAndKill);
+    //           aParticleChange.ProposeEnergy(0.0);
+    return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+  }
+
+  // now tag the photon as having rayliegh scattered.
+
+  RichTbRayleighInfoAttach(aTrack);
+  // end of additions by SE
+
+  // find azimuthal angle w.r.t old polarization vector
+
+  rand = G4UniformRand();
+
+  G4double Phi = CLHEP::twopi * rand;
+  G4double SinPhi = std::sin(Phi);
+  G4double CosPhi = std::cos(Phi);
+
+  G4double unit_x = SinTheta * CosPhi;
+  G4double unit_y = SinTheta * SinPhi;
+  G4double unit_z = CosTheta;
+
+  G4ThreeVector NewPolarization(unit_x, unit_y, unit_z);
+
+  // Rotate new polarization direction into global reference system
+
+  G4ThreeVector OldPolarization = aParticle->GetPolarization();
+  OldPolarization = OldPolarization.unit();
+
+  NewPolarization.rotateUz(OldPolarization);
+  NewPolarization = NewPolarization.unit();
+
+  // -- new momentum direction is normal to the new
+  // polarization vector and in the same plane as the
+  // old and new polarization vectors --
+
+  G4ThreeVector NewMomentumDirection = OldPolarization - NewPolarization * CosTheta;
+
+  if (G4UniformRand() < 0.5)
+    NewMomentumDirection = -NewMomentumDirection;
+  NewMomentumDirection = NewMomentumDirection.unit();
+
+  aParticleChange.ProposePolarization(NewPolarization);
+
+  aParticleChange.ProposeMomentumDirection(NewMomentumDirection);
+
+  if (verboseLevel > 0) {
+    G4cout << "New Polarization: " << NewPolarization << G4endl;
+    G4cout << "Polarization Change: " << *(aParticleChange.GetPolarization()) << G4endl;
+    G4cout << "New Momentum Direction: " << NewMomentumDirection << G4endl;
+    G4cout << "Momentum Change: " << *(aParticleChange.GetMomentumDirection()) << G4endl;
+  }
+
+  return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
 }
 
 // BuildThePhysicsTable for the Rayleigh Scattering process
 // --------------------------------------------------------
 //
-void RichTbG4OpRayleigh::BuildThePhysicsTable()
-{
-//      Builds a table of scattering lengths for each material
+void RichTbG4OpRayleigh::BuildThePhysicsTable() {
+  //      Builds a table of scattering lengths for each material
+
+  if (thePhysicsTable)
+    return;
 
-        if (thePhysicsTable) return;
+  const G4MaterialTable *theMaterialTable = G4Material::GetMaterialTable();
+  G4int numOfMaterials = G4Material::GetNumberOfMaterials();
 
-        const G4MaterialTable* theMaterialTable=
-                               G4Material::GetMaterialTable();
-        G4int numOfMaterials = G4Material::GetNumberOfMaterials();
+  // create a new physics table
 
-        // create a new physics table
+  thePhysicsTable = new G4PhysicsTable(numOfMaterials);
 
-        thePhysicsTable = new G4PhysicsTable(numOfMaterials);
+  // loop for materials
 
-        // loop for materials
+  for (G4int i = 0; i < numOfMaterials; i++) {
+    G4PhysicsOrderedFreeVector *ScatteringLengths = new G4PhysicsOrderedFreeVector();
 
-        for (G4int i=0 ; i < numOfMaterials; i++)
-        {
-            G4PhysicsOrderedFreeVector* ScatteringLengths =
-                                new G4PhysicsOrderedFreeVector();
+    G4MaterialPropertiesTable *aMaterialPropertiesTable = (*theMaterialTable)[i]->GetMaterialPropertiesTable();
 
-            G4MaterialPropertiesTable *aMaterialPropertiesTable =
-                         (*theMaterialTable)[i]->GetMaterialPropertiesTable();
-                                                                                
-            if(aMaterialPropertiesTable){
+    if (aMaterialPropertiesTable) {
 
-              G4MaterialPropertyVector* AttenuationLengthVector =
-                            aMaterialPropertiesTable->GetProperty("RAYLEIGH");
+      G4MaterialPropertyVector *AttenuationLengthVector = aMaterialPropertiesTable->GetProperty("RAYLEIGH");
 
-              if(!AttenuationLengthVector){
+      if (!AttenuationLengthVector) {
 
-                if ((*theMaterialTable)[i]->GetName() == "Water")
-                {
-		   // Call utility routine to Generate
-		   // Rayleigh Scattering Lengths
+        if ((*theMaterialTable)[i]->GetName() == "Water") {
+          // Call utility routine to Generate
+          // Rayleigh Scattering Lengths
 
-                   DefaultWater = true;
+          DefaultWater = true;
 
-		   ScatteringLengths =
-		   RayleighAttenuationLengthGenerator(aMaterialPropertiesTable);
-                }
-              }
-	    }
+          ScatteringLengths = RayleighAttenuationLengthGenerator(aMaterialPropertiesTable);
+        }
+      }
+    }
 
-	    thePhysicsTable->insertAt(i,ScatteringLengths);
-        } 
+    thePhysicsTable->insertAt(i, ScatteringLengths);
+  }
 }
 
 // GetMeanFreePath()
 // -----------------
 //
-G4double RichTbG4OpRayleigh::GetMeanFreePath(const G4Track& aTrack,
-                                     G4double ,
-                                     G4ForceCondition* )
-{
-        const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
-        const G4Material* aMaterial = aTrack.GetMaterial();
+G4double RichTbG4OpRayleigh::GetMeanFreePath(const G4Track &aTrack, G4double, G4ForceCondition *) {
+  const G4DynamicParticle *aParticle = aTrack.GetDynamicParticle();
+  const G4Material *aMaterial = aTrack.GetMaterial();
 
-        // G4double thePhotonMomentum = aParticle->GetTotalMomentum();
-        G4double thePhotonEnergy = aParticle->GetTotalEnergy();
+  // G4double thePhotonMomentum = aParticle->GetTotalMomentum();
+  G4double thePhotonEnergy = aParticle->GetTotalEnergy();
 
-        G4double AttenuationLength = DBL_MAX;
+  G4double AttenuationLength = DBL_MAX;
 
-        if (aMaterial->GetName() == "Water" && DefaultWater){
+  if (aMaterial->GetName() == "Water" && DefaultWater) {
 
-           G4bool isOutRange;
+    G4bool isOutRange;
 
-           AttenuationLength =
-                (*thePhysicsTable)(aMaterial->GetIndex())->
-                           GetValue(thePhotonEnergy, isOutRange);
-        }
-        else {
-
-           G4MaterialPropertiesTable* aMaterialPropertyTable =
-                           aMaterial->GetMaterialPropertiesTable();
-
-           if(aMaterialPropertyTable){
-             G4MaterialPropertyVector* AttenuationLengthVector =
-                   aMaterialPropertyTable->GetProperty("RAYLEIGH");
-             if(AttenuationLengthVector){
-               //AttenuationLength = AttenuationLengthVector ->
-               //                     GetProperty(thePhotonMomentum);
-               AttenuationLength = AttenuationLengthVector ->
-                                    Value(thePhotonEnergy);
-             }
-             else{
-//               G4cout << "No Rayleigh scattering length specified" << G4endl;
-             }
-           }
-           else{
-//             G4cout << "No Rayleigh scattering length specified" << G4endl; 
-           }
-        }
+    AttenuationLength = (*thePhysicsTable)(aMaterial->GetIndex())->GetValue(thePhotonEnergy, isOutRange);
+  } else {
 
-        return AttenuationLength;
+    G4MaterialPropertiesTable *aMaterialPropertyTable = aMaterial->GetMaterialPropertiesTable();
+
+    if (aMaterialPropertyTable) {
+      G4MaterialPropertyVector *AttenuationLengthVector = aMaterialPropertyTable->GetProperty("RAYLEIGH");
+      if (AttenuationLengthVector) {
+        // AttenuationLength = AttenuationLengthVector ->
+        //                     GetProperty(thePhotonMomentum);
+        AttenuationLength = AttenuationLengthVector->Value(thePhotonEnergy);
+      } else {
+        //               G4cout << "No Rayleigh scattering length specified" << G4endl;
+      }
+    } else {
+      //             G4cout << "No Rayleigh scattering length specified" << G4endl;
+    }
+  }
+
+  return AttenuationLength;
 }
 
 // RayleighAttenuationLengthGenerator()
 // ------------------------------------
 // Private method to compute Rayleigh Scattering Lengths (for water)
 //
-G4PhysicsOrderedFreeVector* 
-RichTbG4OpRayleigh::RayleighAttenuationLengthGenerator(G4MaterialPropertiesTable *aMPT) 
-{
-        // Physical Constants
-
-        // isothermal compressibility of water
-        G4double betat = 7.658e-23*CLHEP::m3/CLHEP::MeV;
+G4PhysicsOrderedFreeVector *RichTbG4OpRayleigh::RayleighAttenuationLengthGenerator(G4MaterialPropertiesTable *aMPT) {
+  // Physical Constants
 
-        // K Boltzman
-        G4double kboltz = 8.61739e-11*CLHEP::MeV/CLHEP::kelvin;
+  // isothermal compressibility of water
+  G4double betat = 7.658e-23 * CLHEP::m3 / CLHEP::MeV;
 
-        // Temperature of water is 10 degrees celsius
-        // conversion to CLHEP::kelvin:
-        // TCelsius = TKelvin - 273.15 => 273.15 + 10 = 283.15
-        G4double temp = 283.15*CLHEP::kelvin;
+  // K Boltzman
+  G4double kboltz = 8.61739e-11 * CLHEP::MeV / CLHEP::kelvin;
 
-        // Retrieve vectors for refraction index
-        // and photon momentum from the material properties table
+  // Temperature of water is 10 degrees celsius
+  // conversion to CLHEP::kelvin:
+  // TCelsius = TKelvin - 273.15 => 273.15 + 10 = 283.15
+  G4double temp = 283.15 * CLHEP::kelvin;
 
-        G4MaterialPropertyVector* Rindex = aMPT->GetProperty("RINDEX");
+  // Retrieve vectors for refraction index
+  // and photon momentum from the material properties table
 
-        G4double refsq;
-        G4double e;
-        G4double xlambda;
-        G4double c1, c2, c3, c4;
-        G4double Dist;
-        G4double refraction_index;
+  G4MaterialPropertyVector *Rindex = aMPT->GetProperty("RINDEX");
 
-        G4PhysicsOrderedFreeVector *RayleighScatteringLengths = 
-				new G4PhysicsOrderedFreeVector();
+  G4double refsq;
+  G4double e;
+  G4double xlambda;
+  G4double c1, c2, c3, c4;
+  G4double Dist;
+  G4double refraction_index;
 
-        if (Rindex ) {
+  G4PhysicsOrderedFreeVector *RayleighScatteringLengths = new G4PhysicsOrderedFreeVector();
 
-           for (size_t i = 0; i < Rindex->GetVectorLength(); i++) {
+  if (Rindex) {
 
-                e = Rindex->Energy(i);
+    for (size_t i = 0; i < Rindex->GetVectorLength(); i++) {
 
-                refraction_index = (*Rindex)[i];
+      e = Rindex->Energy(i);
 
-                refsq = refraction_index*refraction_index;
-                xlambda = CLHEP::h_Planck*CLHEP::c_light/e;
+      refraction_index = (*Rindex)[i];
 
-	        if (verboseLevel>0) {
-        	        G4cout << Rindex->Energy(i) << " CLHEP::MeV\t";
-                	G4cout << xlambda << " mm\t";
-		}
+      refsq = refraction_index * refraction_index;
+      xlambda = CLHEP::h_Planck * CLHEP::c_light / e;
 
-                c1 = 1 / (6.0 * CLHEP::pi);
-                c2 = std::pow((2.0 * CLHEP::pi / xlambda), 4);
-                c3 = std::pow( ( (refsq - 1.0) * (refsq + 2.0) / 3.0 ), 2);
-                c4 = betat * temp * kboltz;
+      if (verboseLevel > 0) {
+        G4cout << Rindex->Energy(i) << " CLHEP::MeV\t";
+        G4cout << xlambda << " mm\t";
+      }
 
-                Dist = 1.0 / (c1*c2*c3*c4);
+      c1 = 1 / (6.0 * CLHEP::pi);
+      c2 = std::pow((2.0 * CLHEP::pi / xlambda), 4);
+      c3 = std::pow(((refsq - 1.0) * (refsq + 2.0) / 3.0), 2);
+      c4 = betat * temp * kboltz;
 
-	        if (verboseLevel>0) {
-	                G4cout << Dist << " mm" << G4endl;
-		}
-                RayleighScatteringLengths->
-			InsertValues(Rindex->Energy(i), Dist);
-           }
-
-        }
-        
+      Dist = 1.0 / (c1 * c2 * c3 * c4);
 
+      if (verboseLevel > 0) {
+        G4cout << Dist << " mm" << G4endl;
+      }
+      RayleighScatteringLengths->InsertValues(Rindex->Energy(i), Dist);
+    }
+  }
 
-	return RayleighScatteringLengths;
+  return RayleighScatteringLengths;
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbAnalysisManager.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbAnalysisManager.cc
index 8cc098ea7ac465f37ca1470604c8d7c974f6f8f9..eb8b7df451b05519f1550a066077beaf4f1030c2 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbAnalysisManager.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbAnalysisManager.cc
@@ -1,762 +1,736 @@
-#include "Geant4/G4Timer.hh"
 #include "RichTbAnalysisManager.hh"
-#include "Geant4/globals.hh"
-#include  <fstream>
-#include  <memory>
-#include <ctype.h>
-#include <cstdlib>
-#include "Geant4/G4ios.hh"
-#include "Geant4/G4Run.hh"
+#include "CLHEP/Units/SystemOfUnits.h"
 #include "Geant4/G4Event.hh"
+#include "Geant4/G4HCofThisEvent.hh"
+#include "Geant4/G4Run.hh"
+#include "Geant4/G4SDManager.hh"
+#include "Geant4/G4SteppingManager.hh"
+#include "Geant4/G4Timer.hh"
 #include "Geant4/G4Track.hh"
-#include "Geant4/G4VVisManager.hh"
-#include "Geant4/G4TrajectoryContainer.hh"
 #include "Geant4/G4Trajectory.hh"
-#include "Geant4/G4SteppingManager.hh"
-#include "Geant4/G4SDManager.hh"
-#include "Geant4/G4HCofThisEvent.hh"
-#include "RichTbRunConfig.hh"
+#include "Geant4/G4TrajectoryContainer.hh"
 #include "Geant4/G4VHitsCollection.hh"
-#include "RichTbHit.hh"
+#include "Geant4/G4VVisManager.hh"
+#include "Geant4/G4ios.hh"
+#include "Geant4/globals.hh"
 #include "RichTbCounter.hh"
-#include "RichTbMiscNames.hh"
 #include "RichTbGeometryParameters.hh"
-#include <TH1D.h>
+#include "RichTbHit.hh"
+#include "RichTbMaterialParameters.hh"
+#include "RichTbMiscNames.hh"
+#include "RichTbRunConfig.hh"
+#include <CLHEP/Units/SystemOfUnits.h>
 #include <TFile.h>
+#include <TH1D.h>
 #include <TTree.h>
-#include <CLHEP/Units/SystemOfUnits.h>
+#include <cstdlib>
+#include <ctype.h>
+#include <fstream>
 #include <math.h>
-#include "RichTbMaterialParameters.hh"
-#include "CLHEP/Units/SystemOfUnits.h"
-
+#include <memory>
 
 RichTbAnalysisManager *RichTbAnalysisManager::RichTbAnalysisInstance = 0;
 
-RichTbAnalysisManager::RichTbAnalysisManager()
-{
-	//  : analysisFactory(0), tree(0),treeNt(0), hfactory(0),nfactory(0)
-
-	fRootFile=0;
-	for (G4int k=0; k<MaxHisto; k++) fHisto[k] = 0;
-	fNtuple1=0;
-	fPhotonXCoord=0;
-	fPhotonYCoord=0;
-	fPhotonZCoord=0;
-	fPhotonXYCoord=0;
-	fPhotonXYCoord15=0;
-	fPhotonWidthProfile=0;
-	fPhotonXYCoordProfile=0;
-	fPhotonXYCoordProfileCut=0;
-	fPhotonZCoord=0;
-	fPhotonZAngle=0;
-	fCherenkovAngle=0;
-	fCherenkovAngleCut=0;
-	fRadiusVsWLProfile=0;
-	fRadiusVsWL=0;
-	fSpectrum=0;
-	fSpectrumPostMirror=0;
-	fSpectrumPreMirror=0;
-
-	//  RichTbRunConfig* rConfig = RichTbRunConfig::getRunConfigInstance();
-
-	//  G4String outputFileName= "testHistoFile";
-
-	//    G4String dirName = rConfig->getOutputHistoDirName();
-	// G4String aHistoFileName = "histofile";
-
-	//G4String outputHistoFileName= aHistoFileName;
-
-	//G4String outputHistoFileName = aHistoFileName;
-	// G4String outputHistoFileName = dirName + aHistoFileName;
-
-	// analysisFactory =  AIDA_createAnalysisFactory();
-
-	//std::auto_ptr<AIDA::IAnalysisFactory> af( AIDA_createAnalysisFactory() );
-
-	//  analysisFactory = af;
-
-	// if (analysisFactory) {
-	//   AIDA::ITreeFactory * treeFactory = analysisFactory->createTreeFactory();
-	//  if (treeFactory) {
-	//    tree = treeFactory->
-	//create(outputHistoFileName, "hbook", false, true);
-	//            tree = treeFactory->create(outputHistoFileName,"hbook",
-	//          false,true,"");
-
-	//     treeNt = treeFactory->
-	//create(OutputNtFileName,"hbook",false,true);
-
-	//  delete treeFactory; // Will not delete the ITree.
-	//     hfactory = analysisFactory->createHistogramFactory(*tree);
-	//  nfactory =analysisFactory->createTupleFactory(*treeNt);
-
-	//    }
-	//  }
-}
-
-
-
-
-RichTbAnalysisManager *RichTbAnalysisManager::getInstance()
-{
-	if (RichTbAnalysisInstance == 0) {
-		RichTbAnalysisInstance = new RichTbAnalysisManager();
-	}
-	return RichTbAnalysisInstance;
-
+RichTbAnalysisManager::RichTbAnalysisManager() {
+  //  : analysisFactory(0), tree(0),treeNt(0), hfactory(0),nfactory(0)
+
+  fRootFile = 0;
+  for (G4int k = 0; k < MaxHisto; k++)
+    fHisto[k] = 0;
+  fNtuple1 = 0;
+  fPhotonXCoord = 0;
+  fPhotonYCoord = 0;
+  fPhotonZCoord = 0;
+  fPhotonXYCoord = 0;
+  fPhotonXYCoord15 = 0;
+  fPhotonWidthProfile = 0;
+  fPhotonXYCoordProfile = 0;
+  fPhotonXYCoordProfileCut = 0;
+  fPhotonZCoord = 0;
+  fPhotonZAngle = 0;
+  fCherenkovAngle = 0;
+  fCherenkovAngleCut = 0;
+  fRadiusVsWLProfile = 0;
+  fRadiusVsWL = 0;
+  fSpectrum = 0;
+  fSpectrumPostMirror = 0;
+  fSpectrumPreMirror = 0;
+
+  //  RichTbRunConfig* rConfig = RichTbRunConfig::getRunConfigInstance();
+
+  //  G4String outputFileName= "testHistoFile";
+
+  //    G4String dirName = rConfig->getOutputHistoDirName();
+  // G4String aHistoFileName = "histofile";
+
+  // G4String outputHistoFileName= aHistoFileName;
+
+  // G4String outputHistoFileName = aHistoFileName;
+  // G4String outputHistoFileName = dirName + aHistoFileName;
+
+  // analysisFactory =  AIDA_createAnalysisFactory();
+
+  // std::auto_ptr<AIDA::IAnalysisFactory> af( AIDA_createAnalysisFactory() );
+
+  //  analysisFactory = af;
+
+  // if (analysisFactory) {
+  //   AIDA::ITreeFactory * treeFactory = analysisFactory->createTreeFactory();
+  //  if (treeFactory) {
+  //    tree = treeFactory->
+  // create(outputHistoFileName, "hbook", false, true);
+  //            tree = treeFactory->create(outputHistoFileName,"hbook",
+  //          false,true,"");
+
+  //     treeNt = treeFactory->
+  // create(OutputNtFileName,"hbook",false,true);
+
+  //  delete treeFactory; // Will not delete the ITree.
+  //     hfactory = analysisFactory->createHistogramFactory(*tree);
+  //  nfactory =analysisFactory->createTupleFactory(*treeNt);
+
+  //    }
+  //  }
 }
 
-
-void RichTbAnalysisManager::InitializeCounters()
-{
-	iTimer = new G4Timer;
-
+RichTbAnalysisManager *RichTbAnalysisManager::getInstance() {
+  if (RichTbAnalysisInstance == 0) {
+    RichTbAnalysisInstance = new RichTbAnalysisManager();
+  }
+  return RichTbAnalysisInstance;
 }
 
-
-void RichTbAnalysisManager::BookHisto()
-{
-	RichTbRunConfig* rConfig = RichTbRunConfig::getRunConfigInstance();
-
-	G4String outputHistoFileName =
-			rConfig->getOutputHistoFileName();
-	// G4String    OutputNtFileName=  rConfig->getOutputNtupleFileName();
-	fRootFile = new TFile(outputHistoFileName,"RECREATE");
-	if(!fRootFile) {
-		G4cout << " RichTBAnalysis Manager::book :"
-				<< " problem creating the ROOT TFile "<< outputHistoFileName
-				<< G4endl;
-	}
-
-	fHisto[0] = new TH1D("1", "Example random number histo ", 100, 0., 100.0);
-	if (!fHisto[0]) G4cout << "\n can't create histo 1" << G4endl;
-
-
-	//const double p = 2.78;
-
-	fRadiatorRefIndex = new TH2D("RadiatorRefIndex", "RefIndex - 1 vs Wavelength ", 80, 200, 800.0, 120, 0.3, 0.9);
-	fRadiatorRefIndex->SetXTitle("#lambda [nm]");
-	fRadiatorRefIndex->SetYTitle("n-1");
-	fRadiatorRefIndex->SetMarkerStyle(8);
-	fRadiatorRefIndex->SetMarkerColor(kBlue);
-
-
-
-	fRadiatorRefIndexHits = new TProfile("RadiatorRefIndexHits", "RefIndex -1 vs Wavelength for photons creating hits",
-			80, 200, 800.0, 0.3, 0.9);
-
-	fPhotonXCoord =  new TH1D("100", "Photon X location on frame " , 100,-350.0, 350.0);
-	fPhotonYCoord =  new TH1D("101", "Photon Y location on frame " , 100,-350.0, +350.0);
-	fPhotonZCoord =  new TH1D("102", "Photon Z location on frame " , 100, -400.0, -50.0);
-
-	//  fPhotonXYCoord =  new TH2D("103", "Photon location on frame " , 150, -208.5, 208.5, 150, -208.5, 208.5);
-	fPhotonXYCoord =  new TH2D("103", "Photon location on frame " , 200, -70.0, 70.0, 200, -70.0, 70.0);
-
-
-	fPhotonWidthProfile = new TH1D("104", "Cherenkov ring radius", 100, 45., 63.5);
-	fPhotonXYCoordProfile = new TProfile("105", "Profile Photon location on frame", 100, -60.0, 60.0, -60.0, -20.0);
-	fPhotonXYCoordProfileCut = new TProfile("106", "Profile Photon location on frame - cut", 100, -30.0, 30.0, -60.0, -20.0);
-
-	fPhotonZAngle =  new TH1D("200", "Photon Z angle on Photon frame " , 100, -2, 2);
-	fCherenkovAngle =  new TH1D("201", "Cherenkov Angle " , 100, 0.75, 0.93);
-	fCherenkovAngleCut =  new TH1D("202", "Cherenkov Angle - cut " , 100, 0.80, 0.90);
-
-	fRadiusVsWL =  new TH2D("300", "WaveLenght vs Radius " , 400, 200., 3000., 100, 56., 59.);
-	fRadiusVsWLProfile = new TProfile("301", "WaveLenght Profile vs Radius", 200, 200., 3000., 56.0, 59.0);
-	fSpectrum =  new TH1D("302", "Photons spectrum on PMTs frame " , 200, 300.0, 3000.0);
-	fSpectrumPostMirror =  new TH1D("303", "Photons spectrum post Mirror " , 200, 300.0, 3000.0);
-	fSpectrumPreMirror =  new TH1D("304", "Photons spectrum pre Mirror " , 200, 300.0, 3000.0);
-
-	fCkvRadiusVsEmisPtPhoton = new TProfile ("310","CherenkovRadius vs Emission Point for photons", 80, -260.0,-220.0,50.0, 70.0);
-	fEmisPtPhoton = new  TH1D("312","Emission point for  photons", 80,-260.0,-220.0);
-	fEmisPtPhoton->SetXTitle("z [mm]");
-	fEmisPtPrimaryTrackPhoton = new  TH1D("314","Emission point for  photons from PrimaryTrack ", 80,-260.0,-220.0);
-	fEmisPtPrimaryTrackPhoton->SetXTitle("z [mm]");
-
-	fGeneratedCkvPhoton = new TH1D("320", "Generated Cherenkov angle for Photons", 60, 0.75, 0.95);
-
-	fTIRXYLocationPhoton = new TH2D("TIRXYLocationPhoton","TIR Location for Photons which reached pmt plane",
-			80,-80.0,80.0,40,-40.0,40.0);
-
-	fXYRadiatorDnsPhoton = new TH2D("fXYRadiatorDnsPhoton", "Dns XY location for photons",
-			80, -80.0, 80.0,40, -40.0,40.0);
-
-	fXYRadiatorTIRDnsPhoton = new TH2D("fXYRadiatorTIRDnsPhoton", "TIR Dns XY location for photons",
-			80, -80.0, 80.0,40, -40.0,40.0);
-	fXYRadiatorRFRDnsPhoton = new TH2D("fXYRadiatorRFRDnsPhoton", "RFR Dns XY location for photons",
-			80, -80.0, 80.0,40, -40.0,40.0);
-	fMIRXYLocationPhoton = new TH2D("fMIRXYLocationPhoton", "Mirror  XY location for photons which reached pmt plane",
-			80, -80.0, 80.0,40, -40.0,40.0);
-
-	fRFRXYLocationPhoton = new TH2D("fRFRXYLocationPhoton","Exit plane location for photons which reached pmt plane",
-			80, -80.0, 80.0,40, -40.0,40.0);
-
-	fGlobalHitXYCoordPeOrigin =  new TH2D("500", "GlobalHitPeOriginXYCoord", 220 , -110.0,110.0,80,-40.0,40.0);
-	fGlobalHitXYCoord =  new TH2D("510", "GlobalHitXYCoord", 220 , -110.0,110.0, 80,-40.0,40.0);
-
-	fGlobalPixelCenterXYCoord =  new TH2D("515", "GlobalPixelCenterXYCoord", 220 , -110.0,110.0,80,-40.0,40.0);
-
-
-	fNumHitInEvent  = new TH1D ("600"," Number of Hits per event ", 40, 0.0, 40.0);
-
-	fNumHitInEventCentralPMT  = new TH1D ("602",
-			"Number of Hits per event (in the 8 PMTs near the beamline)", 90, 0.0, 90.0);
-	fNumHitInEventCentralPMT->SetXTitle("Hits per Event");
-
-	fNumHitInEventCentralPMTJura  = new TH1D ("604",
-				" Number of Hits per event (in the 2 PMTs near the beamline on Jura side)", 60, 0.0, 60.0);
-	fNumHitInEventCentralPMTSaleve  = new TH1D ("606",
-				" Number of Hits per event (in the 2 PMTs near the beamline on Saleve side)", 60, 0.0, 60.0);
-
-
-	fNumHitInPMT0   = new TH1D ("650","Number of Hits per event in PMT0" , 20, 0.0,20.0);
-	fNumHitInPMT1   = new TH1D ("651","Number of Hits per event in PMT1" , 20, 0.0,20.0);
-	fNumHitInPMT2   = new TH1D ("652","Number of Hits per event in PMT2" , 20, 0.0,20.0);
-	fNumHitInPMT3   = new TH1D ("653","Number of Hits per event in PMT3" , 20, 0.0,20.0);
-	fNumHitInPMT4   = new TH1D ("654","Number of Hits per event in PMT4" , 20, 0.0,20.0);
-	fNumHitInPMT5   = new TH1D ("655","Number of Hits per event in PMT5" , 20, 0.0,20.0);
-	fNumHitInPMT6   = new TH1D ("656","Number of Hits per event in PMT6" , 20, 0.0,20.0);
-	fNumHitInPMT7   = new TH1D ("657","Number of Hits per event in PMT7" , 20, 0.0,20.0);
-	fNumHitInPMT8   = new TH1D ("658","Number of Hits per event in PMT8" , 20, 0.0,20.0);
-	fNumHitInPMT9   = new TH1D ("659","Number of Hits per event in PMT9" , 20, 0.0,20.0);
-	fNumHitInPMT10   = new TH1D ("6510","Number of Hits per event in PMT10" , 20, 0.0,20.0);
-	fNumHitInPMT11   = new TH1D ("6511","Number of Hits per event in PMT11" , 20, 0.0,20.0);
-	fNumHitInPMT12   = new TH1D ("6512","Number of Hits per event in PMT12" , 20, 0.0,20.0);
-	fNumHitInPMT13   = new TH1D ("6513","Number of Hits per event in PMT13" , 20, 0.0,20.0);
-	fNumHitInPMT14   = new TH1D ("6514","Number of Hits per event in PMT14" , 20, 0.0,20.0);
-	fNumHitInPMT15   = new TH1D ("6515","Number of Hits per event in PMT15" , 20, 0.0,20.0);
-
-	G4double radMax = 70.0;
-	G4double radMin = 50.0;
-	G4double radNBins = 150;
-	radiusInPMT0   = new TH1D ("rIn0","Hit Coordinate Radius on PMT Plane (PMT0)" , radNBins, radMin,radMax);
-	radiusInPMT1   = new TH1D ("rIn1","Hit Coordinate Radius on PMT Plane (PMT1)" , radNBins, radMin,radMax);
-	radiusInPMT2   = new TH1D ("rIn2","Hit Coordinate Radius on PMT Plane (PMT2)" , radNBins, radMin,radMax);
-	radiusInPMT3   = new TH1D ("rIn3","Hit Coordinate Radius on PMT Plane (PMT3)" , radNBins, radMin,radMax);
-	radiusInPMT4   = new TH1D ("rIn4","Hit Coordinate Radius on PMT Plane (PMT4)" , radNBins, radMin,radMax);
-	radiusInPMT5   = new TH1D ("rIn5","Hit Coordinate Radius on PMT Plane (PMT5)" , radNBins, radMin,radMax);
-	radiusInPMT6   = new TH1D ("rIn6","Hit Coordinate Radius on PMT Plane (PMT6)" , radNBins, radMin,radMax);
-	radiusInPMT7   = new TH1D ("rIn7","Hit Coordinate Radius on PMT Plane (PMT7)" , radNBins, radMin,radMax);
-	radiusInPMT8   = new TH1D ("rIn8","Hit Coordinate Radius on PMT Plane (PMT8)" , radNBins, radMin,radMax);
-	radiusInPMT9   = new TH1D ("rIn9","Hit Coordinate Radius on PMT Plane (PMT9)" , radNBins, radMin,radMax);
-	radiusInPMT10   = new TH1D ("rIn10","Hit Coordinate Radius on PMT Plane (PMT10)" , radNBins, radMin,radMax);
-	radiusInPMT11   = new TH1D ("rIn11","Hit Coordinate Radius on PMT Plane (PMT11)" , radNBins, radMin,radMax);
-	radiusInPMT12   = new TH1D ("rIn12","Hit Coordinate Radius on PMT Plane (PMT12)" , radNBins, radMin,radMax);
-	radiusInPMT13   = new TH1D ("rIn13","Hit Coordinate Radius on PMT Plane (PMT13)" , radNBins, radMin,radMax);
-	radiusInPMT14   = new TH1D ("rIn14","Hit Coordinate Radius on PMT Plane (PMT14)" , radNBins, radMin,radMax);
-	radiusInPMT15   = new TH1D ("rIn15","Hit Coordinate Radius on PMT Plane (PMT15)" , radNBins, radMin,radMax);
-	radiusInPMT0->SetXTitle("r [mm]");
-	radiusInPMT1->SetXTitle("r [mm]");
-	radiusInPMT2->SetXTitle("r [mm]");
-	radiusInPMT3->SetXTitle("r [mm]");
-	radiusInPMT4->SetXTitle("r [mm]");
-	radiusInPMT5->SetXTitle("r [mm]");
-	radiusInPMT6->SetXTitle("r [mm]");
-	radiusInPMT7->SetXTitle("r [mm]");
-	radiusInPMT8->SetXTitle("r [mm]");
-	radiusInPMT9->SetXTitle("r [mm]");
-	radiusInPMT10->SetXTitle("r [mm]");
-	radiusInPMT11->SetXTitle("r [mm]");
-	radiusInPMT12->SetXTitle("r [mm]");
-	radiusInPMT13->SetXTitle("r [mm]");
-	radiusInPMT14->SetXTitle("r [mm]");
-	radiusInPMT15->SetXTitle("r [mm]");
-
-	fGlobalHitXYCoord15 =  new TH2D("GlobalHitXYCoord", "Global Hit XY-Coordinate", 220 , -110.0,110.0, 220,-110.0,110.0);
-	fGlobalHitXYCoord15->SetXTitle("x [mm]");
-	fGlobalHitXYCoord15->SetYTitle("y [mm]");
-
-
-	fNtuple1 = new TTree("10", "RichTbNtup");
-	fNtuple1->Branch("NtupVar1", &fNtupVar1, "NtupVar1/D");
-	fNtuple1->Branch("NtupVar2", &fNtupVar2, "NtupVar2/D");
-
-
-	BookHistoHpd();
-
-	G4cout<<" Histogram file created "<<G4endl;
-
+void RichTbAnalysisManager::InitializeCounters() { iTimer = new G4Timer; }
+
+void RichTbAnalysisManager::BookHisto() {
+  RichTbRunConfig *rConfig = RichTbRunConfig::getRunConfigInstance();
+
+  G4String outputHistoFileName = rConfig->getOutputHistoFileName();
+  // G4String    OutputNtFileName=  rConfig->getOutputNtupleFileName();
+  fRootFile = new TFile(outputHistoFileName, "RECREATE");
+  if (!fRootFile) {
+    G4cout << " RichTBAnalysis Manager::book :"
+           << " problem creating the ROOT TFile " << outputHistoFileName << G4endl;
+  }
+
+  fHisto[0] = new TH1D("1", "Example random number histo ", 100, 0., 100.0);
+  if (!fHisto[0])
+    G4cout << "\n can't create histo 1" << G4endl;
+
+  // const double p = 2.78;
+
+  fRadiatorRefIndex = new TH2D("RadiatorRefIndex", "RefIndex - 1 vs Wavelength ", 80, 200, 800.0, 120, 0.3, 0.9);
+  fRadiatorRefIndex->SetXTitle("#lambda [nm]");
+  fRadiatorRefIndex->SetYTitle("n-1");
+  fRadiatorRefIndex->SetMarkerStyle(8);
+  fRadiatorRefIndex->SetMarkerColor(kBlue);
+
+  fRadiatorRefIndexHits = new TProfile("RadiatorRefIndexHits", "RefIndex -1 vs Wavelength for photons creating hits",
+                                       80, 200, 800.0, 0.3, 0.9);
+
+  fPhotonXCoord = new TH1D("100", "Photon X location on frame ", 100, -350.0, 350.0);
+  fPhotonYCoord = new TH1D("101", "Photon Y location on frame ", 100, -350.0, +350.0);
+  fPhotonZCoord = new TH1D("102", "Photon Z location on frame ", 100, -400.0, -50.0);
+
+  //  fPhotonXYCoord =  new TH2D("103", "Photon location on frame " , 150, -208.5, 208.5, 150, -208.5, 208.5);
+  fPhotonXYCoord = new TH2D("103", "Photon location on frame ", 200, -70.0, 70.0, 200, -70.0, 70.0);
+
+  fPhotonWidthProfile = new TH1D("104", "Cherenkov ring radius", 100, 45., 63.5);
+  fPhotonXYCoordProfile = new TProfile("105", "Profile Photon location on frame", 100, -60.0, 60.0, -60.0, -20.0);
+  fPhotonXYCoordProfileCut =
+      new TProfile("106", "Profile Photon location on frame - cut", 100, -30.0, 30.0, -60.0, -20.0);
+
+  fPhotonZAngle = new TH1D("200", "Photon Z angle on Photon frame ", 100, -2, 2);
+  fCherenkovAngle = new TH1D("201", "Cherenkov Angle ", 100, 0.75, 0.93);
+  fCherenkovAngleCut = new TH1D("202", "Cherenkov Angle - cut ", 100, 0.80, 0.90);
+
+  fRadiusVsWL = new TH2D("300", "WaveLenght vs Radius ", 400, 200., 3000., 100, 56., 59.);
+  fRadiusVsWLProfile = new TProfile("301", "WaveLenght Profile vs Radius", 200, 200., 3000., 56.0, 59.0);
+  fSpectrum = new TH1D("302", "Photons spectrum on PMTs frame ", 200, 300.0, 3000.0);
+  fSpectrumPostMirror = new TH1D("303", "Photons spectrum post Mirror ", 200, 300.0, 3000.0);
+  fSpectrumPreMirror = new TH1D("304", "Photons spectrum pre Mirror ", 200, 300.0, 3000.0);
+
+  fCkvRadiusVsEmisPtPhoton =
+      new TProfile("310", "CherenkovRadius vs Emission Point for photons", 80, -260.0, -220.0, 50.0, 70.0);
+  fEmisPtPhoton = new TH1D("312", "Emission point for  photons", 80, -260.0, -220.0);
+  fEmisPtPhoton->SetXTitle("z [mm]");
+  fEmisPtPrimaryTrackPhoton = new TH1D("314", "Emission point for  photons from PrimaryTrack ", 80, -260.0, -220.0);
+  fEmisPtPrimaryTrackPhoton->SetXTitle("z [mm]");
+
+  fGeneratedCkvPhoton = new TH1D("320", "Generated Cherenkov angle for Photons", 60, 0.75, 0.95);
+
+  fTIRXYLocationPhoton = new TH2D("TIRXYLocationPhoton", "TIR Location for Photons which reached pmt plane", 80, -80.0,
+                                  80.0, 40, -40.0, 40.0);
+
+  fXYRadiatorDnsPhoton =
+      new TH2D("fXYRadiatorDnsPhoton", "Dns XY location for photons", 80, -80.0, 80.0, 40, -40.0, 40.0);
+
+  fXYRadiatorTIRDnsPhoton =
+      new TH2D("fXYRadiatorTIRDnsPhoton", "TIR Dns XY location for photons", 80, -80.0, 80.0, 40, -40.0, 40.0);
+  fXYRadiatorRFRDnsPhoton =
+      new TH2D("fXYRadiatorRFRDnsPhoton", "RFR Dns XY location for photons", 80, -80.0, 80.0, 40, -40.0, 40.0);
+  fMIRXYLocationPhoton = new TH2D("fMIRXYLocationPhoton", "Mirror  XY location for photons which reached pmt plane", 80,
+                                  -80.0, 80.0, 40, -40.0, 40.0);
+
+  fRFRXYLocationPhoton = new TH2D("fRFRXYLocationPhoton", "Exit plane location for photons which reached pmt plane", 80,
+                                  -80.0, 80.0, 40, -40.0, 40.0);
+
+  fGlobalHitXYCoordPeOrigin = new TH2D("500", "GlobalHitPeOriginXYCoord", 220, -110.0, 110.0, 80, -40.0, 40.0);
+  fGlobalHitXYCoord = new TH2D("510", "GlobalHitXYCoord", 220, -110.0, 110.0, 80, -40.0, 40.0);
+
+  fGlobalPixelCenterXYCoord = new TH2D("515", "GlobalPixelCenterXYCoord", 220, -110.0, 110.0, 80, -40.0, 40.0);
+
+  fNumHitInEvent = new TH1D("600", " Number of Hits per event ", 40, 0.0, 40.0);
+
+  fNumHitInEventCentralPMT =
+      new TH1D("602", "Number of Hits per event (in the 8 PMTs near the beamline)", 90, 0.0, 90.0);
+  fNumHitInEventCentralPMT->SetXTitle("Hits per Event");
+
+  fNumHitInEventCentralPMTJura =
+      new TH1D("604", " Number of Hits per event (in the 2 PMTs near the beamline on Jura side)", 60, 0.0, 60.0);
+  fNumHitInEventCentralPMTSaleve =
+      new TH1D("606", " Number of Hits per event (in the 2 PMTs near the beamline on Saleve side)", 60, 0.0, 60.0);
+
+  fNumHitInPMT0 = new TH1D("650", "Number of Hits per event in PMT0", 20, 0.0, 20.0);
+  fNumHitInPMT1 = new TH1D("651", "Number of Hits per event in PMT1", 20, 0.0, 20.0);
+  fNumHitInPMT2 = new TH1D("652", "Number of Hits per event in PMT2", 20, 0.0, 20.0);
+  fNumHitInPMT3 = new TH1D("653", "Number of Hits per event in PMT3", 20, 0.0, 20.0);
+  fNumHitInPMT4 = new TH1D("654", "Number of Hits per event in PMT4", 20, 0.0, 20.0);
+  fNumHitInPMT5 = new TH1D("655", "Number of Hits per event in PMT5", 20, 0.0, 20.0);
+  fNumHitInPMT6 = new TH1D("656", "Number of Hits per event in PMT6", 20, 0.0, 20.0);
+  fNumHitInPMT7 = new TH1D("657", "Number of Hits per event in PMT7", 20, 0.0, 20.0);
+  fNumHitInPMT8 = new TH1D("658", "Number of Hits per event in PMT8", 20, 0.0, 20.0);
+  fNumHitInPMT9 = new TH1D("659", "Number of Hits per event in PMT9", 20, 0.0, 20.0);
+  fNumHitInPMT10 = new TH1D("6510", "Number of Hits per event in PMT10", 20, 0.0, 20.0);
+  fNumHitInPMT11 = new TH1D("6511", "Number of Hits per event in PMT11", 20, 0.0, 20.0);
+  fNumHitInPMT12 = new TH1D("6512", "Number of Hits per event in PMT12", 20, 0.0, 20.0);
+  fNumHitInPMT13 = new TH1D("6513", "Number of Hits per event in PMT13", 20, 0.0, 20.0);
+  fNumHitInPMT14 = new TH1D("6514", "Number of Hits per event in PMT14", 20, 0.0, 20.0);
+  fNumHitInPMT15 = new TH1D("6515", "Number of Hits per event in PMT15", 20, 0.0, 20.0);
+
+  G4double radMax = 70.0;
+  G4double radMin = 50.0;
+  G4double radNBins = 150;
+  radiusInPMT0 = new TH1D("rIn0", "Hit Coordinate Radius on PMT Plane (PMT0)", radNBins, radMin, radMax);
+  radiusInPMT1 = new TH1D("rIn1", "Hit Coordinate Radius on PMT Plane (PMT1)", radNBins, radMin, radMax);
+  radiusInPMT2 = new TH1D("rIn2", "Hit Coordinate Radius on PMT Plane (PMT2)", radNBins, radMin, radMax);
+  radiusInPMT3 = new TH1D("rIn3", "Hit Coordinate Radius on PMT Plane (PMT3)", radNBins, radMin, radMax);
+  radiusInPMT4 = new TH1D("rIn4", "Hit Coordinate Radius on PMT Plane (PMT4)", radNBins, radMin, radMax);
+  radiusInPMT5 = new TH1D("rIn5", "Hit Coordinate Radius on PMT Plane (PMT5)", radNBins, radMin, radMax);
+  radiusInPMT6 = new TH1D("rIn6", "Hit Coordinate Radius on PMT Plane (PMT6)", radNBins, radMin, radMax);
+  radiusInPMT7 = new TH1D("rIn7", "Hit Coordinate Radius on PMT Plane (PMT7)", radNBins, radMin, radMax);
+  radiusInPMT8 = new TH1D("rIn8", "Hit Coordinate Radius on PMT Plane (PMT8)", radNBins, radMin, radMax);
+  radiusInPMT9 = new TH1D("rIn9", "Hit Coordinate Radius on PMT Plane (PMT9)", radNBins, radMin, radMax);
+  radiusInPMT10 = new TH1D("rIn10", "Hit Coordinate Radius on PMT Plane (PMT10)", radNBins, radMin, radMax);
+  radiusInPMT11 = new TH1D("rIn11", "Hit Coordinate Radius on PMT Plane (PMT11)", radNBins, radMin, radMax);
+  radiusInPMT12 = new TH1D("rIn12", "Hit Coordinate Radius on PMT Plane (PMT12)", radNBins, radMin, radMax);
+  radiusInPMT13 = new TH1D("rIn13", "Hit Coordinate Radius on PMT Plane (PMT13)", radNBins, radMin, radMax);
+  radiusInPMT14 = new TH1D("rIn14", "Hit Coordinate Radius on PMT Plane (PMT14)", radNBins, radMin, radMax);
+  radiusInPMT15 = new TH1D("rIn15", "Hit Coordinate Radius on PMT Plane (PMT15)", radNBins, radMin, radMax);
+  radiusInPMT0->SetXTitle("r [mm]");
+  radiusInPMT1->SetXTitle("r [mm]");
+  radiusInPMT2->SetXTitle("r [mm]");
+  radiusInPMT3->SetXTitle("r [mm]");
+  radiusInPMT4->SetXTitle("r [mm]");
+  radiusInPMT5->SetXTitle("r [mm]");
+  radiusInPMT6->SetXTitle("r [mm]");
+  radiusInPMT7->SetXTitle("r [mm]");
+  radiusInPMT8->SetXTitle("r [mm]");
+  radiusInPMT9->SetXTitle("r [mm]");
+  radiusInPMT10->SetXTitle("r [mm]");
+  radiusInPMT11->SetXTitle("r [mm]");
+  radiusInPMT12->SetXTitle("r [mm]");
+  radiusInPMT13->SetXTitle("r [mm]");
+  radiusInPMT14->SetXTitle("r [mm]");
+  radiusInPMT15->SetXTitle("r [mm]");
+
+  fGlobalHitXYCoord15 =
+      new TH2D("GlobalHitXYCoord", "Global Hit XY-Coordinate", 220, -110.0, 110.0, 220, -110.0, 110.0);
+  fGlobalHitXYCoord15->SetXTitle("x [mm]");
+  fGlobalHitXYCoord15->SetYTitle("y [mm]");
+
+  fNtuple1 = new TTree("10", "RichTbNtup");
+  fNtuple1->Branch("NtupVar1", &fNtupVar1, "NtupVar1/D");
+  fNtuple1->Branch("NtupVar2", &fNtupVar2, "NtupVar2/D");
+
+  BookHistoHpd();
+
+  G4cout << " Histogram file created " << G4endl;
 }
 
 void RichTbAnalysisManager::BookHistoHpd() {
 
+  fNumHitInHPD0 = new TH1D("2650", "Number of Hits per event in HPD0", 80, 0.0, 20.0);
+  fNumHitSignalInHPD0 = new TH1D("2652", "Number of Hits per event in signal region in HPD0", 80, 0.0, 20.0);
 
+  fRFRXYLocationPhotonHpd =
+      new TH2D("fRFRXYLocationPhotonHpd", "Exit plane location for photons which reached Hpd plane", 80, -80.0, 80.0,
+               40, -40.0, 40.0);
 
+  fGlobalHitXYCoordPeOriginHpd = new TH2D("2500", "GlobalHitPeOriginXYCoordHpd", 320, -160.0, 0.0, 80, -40.0, 40.0);
+  fGlobalHitXYCoordHpd = new TH2D("2510", "GlobalHitXYCoordHpd", 320, -160.0, 0.0, 80, -40.0, 40.0);
 
-	fNumHitInHPD0   = new TH1D ("2650","Number of Hits per event in HPD0" , 80, 0.0,20.0);
-	fNumHitSignalInHPD0   = new TH1D ("2652","Number of Hits per event in signal region in HPD0" , 80, 0.0,20.0);
-
-	fRFRXYLocationPhotonHpd = new TH2D("fRFRXYLocationPhotonHpd","Exit plane location for photons which reached Hpd plane",
-			80, -80.0, 80.0,40, -40.0,40.0);
-
-	fGlobalHitXYCoordPeOriginHpd =  new TH2D("2500", "GlobalHitPeOriginXYCoordHpd", 320 , -160.0,0.0,80,-40.0,40.0);
-	fGlobalHitXYCoordHpd =  new TH2D("2510", "GlobalHitXYCoordHpd", 320 , -160.0,0.0, 80,-40.0,40.0);
-
-	fGlobalPixelCenterXYCoordHpd =  new TH2D("2515", "GlobalPixelCenterXYCoordHpd", 320 , -160.0,0.0,80,-40.0,40.0);
-
-
-	fGlobalHitXYCoordPeOriginHpdPmt = new TH2D("2520", "GlobalHitPeOriginXYCoordHpdPmt", 320 , -160.0,160.0,80,-40.0,40.0);
-	fGlobalHitXYCoordPixPhcathHpd =  new TH2D("2525", "GlobalHitXYCoordHpdPhCathode", 320 , -160.0,0.0,80,-40.0,40.0);
+  fGlobalPixelCenterXYCoordHpd = new TH2D("2515", "GlobalPixelCenterXYCoordHpd", 320, -160.0, 0.0, 80, -40.0, 40.0);
 
+  fGlobalHitXYCoordPeOriginHpdPmt =
+      new TH2D("2520", "GlobalHitPeOriginXYCoordHpdPmt", 320, -160.0, 160.0, 80, -40.0, 40.0);
+  fGlobalHitXYCoordPixPhcathHpd = new TH2D("2525", "GlobalHitXYCoordHpdPhCathode", 320, -160.0, 0.0, 80, -40.0, 40.0);
 }
 
+RichTbAnalysisManager::~RichTbAnalysisManager() {
 
-RichTbAnalysisManager::~RichTbAnalysisManager()
-{
+  //    delete hfactory;
+  //    hfactory = 0;
 
-	//    delete hfactory;
-	//    hfactory = 0;
+  //  delete analysisFactory;
+  //   analysisFactory = 0;
 
-	//  delete analysisFactory;
-	//   analysisFactory = 0;
+  // delete tree;
+  // if(fRootFile) delete fRootFile;
 
-	// delete tree;
-	//if(fRootFile) delete fRootFile;
-
-	if(RichTbAnalysisInstance !=0 ) delete  RichTbAnalysisInstance;
-
-
-	G4cout << "RichTbAnalysisManager Deleted" << G4endl;
+  if (RichTbAnalysisInstance != 0)
+    delete RichTbAnalysisInstance;
 
+  G4cout << "RichTbAnalysisManager Deleted" << G4endl;
 }
 
-
-void RichTbAnalysisManager::BeginOfRunAnalysis()
-{
-	// G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
-	InitializeCounters();
-	BookHisto();
-
+void RichTbAnalysisManager::BeginOfRunAnalysis() {
+  // G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
+  InitializeCounters();
+  BookHisto();
 }
 
-
-void RichTbAnalysisManager::EndOfRunAnalysis()
-{
-
-	//  if (tree) {
-	//    G4cout<<" Now writing histos out "<<G4endl;
-
-	//      tree->commit();         // Write histos and tuple in file.
-	//      tree->close();
-	//  }
-	//  if(treeNt) {
-	//    G4cout<<" Now writing ntuples out "<<G4endl;
-	//      treeNt->commit();         // Write  tuple in file.
-	//      treeNt->close();
-	//
-	//  }
-
-	if (fRootFile) {
-		fRootFile->Write();       // Writing the histograms to the file
-		fRootFile->Close();        // and closing the tree (and the file)
-		G4cout << "\n----> Histogram Tree is saved \n" << G4endl;
-
-	}
-
+void RichTbAnalysisManager::EndOfRunAnalysis() {
+
+  //  if (tree) {
+  //    G4cout<<" Now writing histos out "<<G4endl;
+
+  //      tree->commit();         // Write histos and tuple in file.
+  //      tree->close();
+  //  }
+  //  if(treeNt) {
+  //    G4cout<<" Now writing ntuples out "<<G4endl;
+  //      treeNt->commit();         // Write  tuple in file.
+  //      treeNt->close();
+  //
+  //  }
+
+  if (fRootFile) {
+    fRootFile->Write(); // Writing the histograms to the file
+    fRootFile->Close(); // and closing the tree (and the file)
+    G4cout << "\n----> Histogram Tree is saved \n" << G4endl;
+  }
 }
 
+void RichTbAnalysisManager::BeginOfEventAnalysis(const G4Event * /* evt */) {
 
-
-void RichTbAnalysisManager::BeginOfEventAnalysis(const G4Event * /* evt */)
-{
-
-	//RichCollId is already defined in LHCbRichSimEventAction.cc
-	// Hence its extraction is not repeated here.
-	iTimer->Start();
-
+  // RichCollId is already defined in LHCbRichSimEventAction.cc
+  // Hence its extraction is not repeated here.
+  iTimer->Start();
 }
 
+void RichTbAnalysisManager::EndOfEventAnalysis(const G4Event * /* evt */) { iTimer->Stop(); }
 
-void RichTbAnalysisManager::EndOfEventAnalysis(const G4Event * /* evt */)
-{
-	iTimer->Stop();
-
-
+void RichTbAnalysisManager::StepAnalysis(const G4SteppingManager * /* aSteppingManager */) {
 
+  // if(!aSteppingManager) return;
+  //  G4Track* track = aSteppingManager->GetTrack();
+  // G4ThreeVector pos = track->GetPosition();
 }
-
-
-void RichTbAnalysisManager::StepAnalysis
-(const G4SteppingManager * /* aSteppingManager */)
-{
-
-	// if(!aSteppingManager) return;
-	//  G4Track* track = aSteppingManager->GetTrack();
-	// G4ThreeVector pos = track->GetPosition();
-
+void RichTbAnalysisManager::EndOfEventCountersHisto(const G4Event * /* evt */) {
+  // RichTbCounter* aRichCounter= RichTbCounter::getRichTbCounterInstance();
+
+  //  G4cout<<" Filling histo of counters "<<G4endl;
+
+  // G4int NRadiatorProduced= aRichCounter->getnumHitTotProd();
+  // G4int NEnterMirror= aRichCounter->getnumPhEnterMirror();
+  // G4int NEnterPhFrame = aRichCounter->getnumPhEnterPhSupFrame();
+  // G4int NExitGasQuWin = aRichCounter->getnumExitGasQuWin();
+  // G4int NEnterPMT0QW =  aRichCounter->getnumPhEnterPMT0QW();
+  //  G4int NEnterPMT1QW =  aRichCounter->getnumPhEnterPMT1QW();
+  // G4int NEnterPMT2QW =  aRichCounter->getnumPhEnterPMT2QW();
+  // G4int NEnterPMT3QW =  aRichCounter->getnumPhEnterPMT3QW();
+  //  G4int NEnterPMT4QW =  aRichCounter->getnumPhEnterPMT4QW();
+  // G4int NEnterPMT5QW =  aRichCounter->getnumPhEnterPMT5QW();
+  //  G4int NEnterAnPMTQW = aRichCounter->getnumPhEnterAnPMTQW();
+
+  //  if( fhistoNProduced) fhistoNProduced->fill(1.0* NRadiatorProduced);
+  //  if( fhistoNEnterMirror) fhistoNEnterMirror->fill(1.0* NEnterMirror);
+  // if(fhistoNEnterPhSupframe) fhistoNEnterPhSupframe->fill(1.0* NEnterPhFrame);
+  // if(fhistoNExitGasQuWin) fhistoNExitGasQuWin->fill(1.0*  NExitGasQuWin);
+  // if(  fhistoNEnterPMT0QW)  fhistoNEnterPMT0QW->fill(1.0* NEnterPMT0QW);
+  // if(  fhistoNEnterPMT1QW)  fhistoNEnterPMT1QW->fill(1.0* NEnterPMT1QW);
+  // if(  fhistoNEnterPMT2QW)  fhistoNEnterPMT2QW->fill(1.0* NEnterPMT2QW);
+  // if(  fhistoNEnterPMT3QW)  fhistoNEnterPMT3QW->fill(1.0* NEnterPMT3QW);
+  // if(  fhistoNEnterPMT4QW)  fhistoNEnterPMT4QW->fill(1.0* NEnterPMT4QW);
+  // if(  fhistoNEnterPMT5QW)  fhistoNEnterPMT5QW->fill(1.0* NEnterPMT5QW);
+  // if( fhistoNEnterAnPMTQW) fhistoNEnterAnPMTQW->fill(1.0*  NEnterAnPMTQW);
+  //  G4cout<<"end of  Filling histo of counters "<<G4endl;
 }
-void RichTbAnalysisManager::EndOfEventCountersHisto(const G4Event * /* evt */)
-{
-	// RichTbCounter* aRichCounter= RichTbCounter::getRichTbCounterInstance();
-
-	//  G4cout<<" Filling histo of counters "<<G4endl;
-
-	// G4int NRadiatorProduced= aRichCounter->getnumHitTotProd();
-	// G4int NEnterMirror= aRichCounter->getnumPhEnterMirror();
-	// G4int NEnterPhFrame = aRichCounter->getnumPhEnterPhSupFrame();
-	// G4int NExitGasQuWin = aRichCounter->getnumExitGasQuWin();
-	// G4int NEnterPMT0QW =  aRichCounter->getnumPhEnterPMT0QW();
-	//  G4int NEnterPMT1QW =  aRichCounter->getnumPhEnterPMT1QW();
-	// G4int NEnterPMT2QW =  aRichCounter->getnumPhEnterPMT2QW();
-	// G4int NEnterPMT3QW =  aRichCounter->getnumPhEnterPMT3QW();
-	//  G4int NEnterPMT4QW =  aRichCounter->getnumPhEnterPMT4QW();
-	// G4int NEnterPMT5QW =  aRichCounter->getnumPhEnterPMT5QW();
-	//  G4int NEnterAnPMTQW = aRichCounter->getnumPhEnterAnPMTQW();
-
-
-	//  if( fhistoNProduced) fhistoNProduced->fill(1.0* NRadiatorProduced);
-	//  if( fhistoNEnterMirror) fhistoNEnterMirror->fill(1.0* NEnterMirror);
-	// if(fhistoNEnterPhSupframe) fhistoNEnterPhSupframe->fill(1.0* NEnterPhFrame);
-	// if(fhistoNExitGasQuWin) fhistoNExitGasQuWin->fill(1.0*  NExitGasQuWin);
-	// if(  fhistoNEnterPMT0QW)  fhistoNEnterPMT0QW->fill(1.0* NEnterPMT0QW);
-	// if(  fhistoNEnterPMT1QW)  fhistoNEnterPMT1QW->fill(1.0* NEnterPMT1QW);
-	// if(  fhistoNEnterPMT2QW)  fhistoNEnterPMT2QW->fill(1.0* NEnterPMT2QW);
-	// if(  fhistoNEnterPMT3QW)  fhistoNEnterPMT3QW->fill(1.0* NEnterPMT3QW);
-	// if(  fhistoNEnterPMT4QW)  fhistoNEnterPMT4QW->fill(1.0* NEnterPMT4QW);
-	// if(  fhistoNEnterPMT5QW)  fhistoNEnterPMT5QW->fill(1.0* NEnterPMT5QW);
-	// if( fhistoNEnterAnPMTQW) fhistoNEnterAnPMTQW->fill(1.0*  NEnterAnPMTQW);
-	//  G4cout<<"end of  Filling histo of counters "<<G4endl;
 
+void RichTbAnalysisManager::EndOfEventHisto(const G4Event *evt) {
+
+  RichTbRunConfig *rConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int aRadiatorConfiguration = rConfig->getRadiatorConfiguration();
+
+  RichTbCounter *aRichCounter = RichTbCounter::getRichTbCounterInstance();
+
+  G4SDManager *SDman = G4SDManager::GetSDMpointer();
+  G4String colNam = RichTbHColname;
+  G4int RichTbCollID = SDman->GetCollectionID(colNam);
+  G4int aVerboseFlag = rConfig->VerboseInfoFlag();
+
+  G4HCofThisEvent *HCE = evt->GetHCofThisEvent();
+  RichTbHitsCollection *RHC = NULL;
+  if (HCE) {
+    RHC = (RichTbHitsCollection *)(HCE->GetHC(RichTbCollID));
+  }
+
+  if (RHC) {
+    G4int n_hit = RHC->entries();
+
+    for (G4int ih = 0; ih < n_hit; ih++) {
+      RichTbHit *aHit = (*RHC)[ih];
+
+      // Now for printing
+      if (aVerboseFlag >= 5) {
+        aHit->Print();
+      }
+
+      G4int curPMTNum = aHit->GetCurPMTNum();
+      G4ThreeVector curHitCoord = aHit->GetPos();
+      G4int curHitInGapFlag = aHit->getHitInPixelGapFlag();
+
+      //      G4cout<<"Hit PMT Number: "<<curPMTNum<<", coordinate: "<<curHitCoord<<G4endl;
+
+      // G4cout<<" Gap flag :  "<<curHitInGapFlag<<G4endl;
+
+      if (curHitInGapFlag == 0) {
+
+        aRichCounter->bumpnumhitTotEv();
+        if (curPMTNum == 0)
+          aRichCounter->bumpnumhitPMT0();
+        if (curPMTNum == 1)
+          aRichCounter->bumpnumhitPMT1();
+        if (curPMTNum == 2)
+          aRichCounter->bumpnumhitPMT2();
+        if (curPMTNum == 3)
+          aRichCounter->bumpnumhitPMT3();
+        if (curPMTNum == 4)
+          aRichCounter->bumpnumhitPMT4();
+        if (curPMTNum == 5)
+          aRichCounter->bumpnumhitPMT5();
+        if (curPMTNum == 6)
+          aRichCounter->bumpnumhitPMT6();
+        if (curPMTNum == 7)
+          aRichCounter->bumpnumhitPMT7();
+        if (curPMTNum == 8)
+          aRichCounter->bumpnumhitPMT8();
+        if (curPMTNum == 9)
+          aRichCounter->bumpnumhitPMT9();
+        if (curPMTNum == 10)
+          aRichCounter->bumpnumhitPMT10();
+        if (curPMTNum == 11)
+          aRichCounter->bumpnumhitPMT11();
+        if (curPMTNum == 12)
+          aRichCounter->bumpnumhitPMT12();
+        if (curPMTNum == 13)
+          aRichCounter->bumpnumhitPMT13();
+        if (curPMTNum == 14)
+          aRichCounter->bumpnumhitPMT14();
+        if (curPMTNum == 15)
+          aRichCounter->bumpnumhitPMT15();
+        if ((curPMTNum == 0) || (curPMTNum == 2) || (curPMTNum == 5) || (curPMTNum == 7) || (curPMTNum == 8) ||
+            (curPMTNum == 10) || (curPMTNum == 13) || (curPMTNum == 15))
+          aRichCounter->bumpnumhitTotEvCentralPmt();
+
+        if ((curPMTNum == 0) || (curPMTNum == 2) || (curPMTNum == 8) || (curPMTNum == 10))
+          aRichCounter->bumpnumhitTotEvCentralPmtJura();
+
+        if ((curPMTNum == 5) || (curPMTNum == 7) || (curPMTNum == 13) || (curPMTNum == 15))
+          aRichCounter->bumpnumhitTotEvCentralPmtSaleve();
+
+        // if(  fHistoCkvTruePhiHits)
+        //  fHistoCkvTruePhiHits->fill( aHit->GetCkvPhiProd());
+
+        // now fill the pixel  col row in a histogram.
+
+        //  G4int aPixelNum = aHit-> GetCurPixNum();
+        // G4int aPixelRow = aPixelNum/RichTbPMTSiDetNumPixelAlongX;
+        // G4int aPixelCol = aPixelNum- aPixelRow*RichTbPMTSiDetNumPixelAlongX;
+
+        // if(   (curPMTNum == 0)  && (fHistoPixelColRowPMT0) )
+        //  fHistoPixelColRowPMT0->fill(1.0*aPixelCol,1.0* aPixelRow);
+        //  if(   (curPMTNum == 1)  && (fHistoPixelColRowPMT1) )
+        //  fHistoPixelColRowPMT1->fill(1.0*aPixelCol,1.0* aPixelRow);
+        // if(   (curPMTNum == 2)  && (fHistoPixelColRowPMT2) )
+        //  fHistoPixelColRowPMT2->fill(1.0*aPixelCol,1.0*aPixelRow);
+        // if(   (curPMTNum == 3)  && (fHistoPixelColRowPMT3) )
+        //  fHistoPixelColRowPMT3->fill(1.0*aPixelCol,1.0*aPixelRow);
+        // if(   (curPMTNum == 4)  && (fHistoPixelColRowPMT4) )
+        //  fHistoPixelColRowPMT4->fill(1.0*aPixelCol,1.0*aPixelRow);
+        //  if(   (curPMTNum == 5)  && (fHistoPixelColRowPMT5) )
+        //  fHistoPixelColRowPMT5->fill(1.0*aPixelCol,1.0*aPixelRow);
+
+        G4ThreeVector aPeOrigin = aHit->GetPeOrigin();
+        G4ThreeVector aGlobalXYHitC = aHit->GetPos();
+        G4ThreeVector aPixelCenterC = aHit->getPixelGlobalCenter();
+
+        if (fGlobalHitXYCoord15)
+          fGlobalHitXYCoord15->Fill(aGlobalXYHitC.x(), aGlobalXYHitC.y());
+
+        G4double pmtRad = sqrt(pow(aGlobalXYHitC.x(), 2) + pow(aGlobalXYHitC.y(), 2));
+        if (curPMTNum == 0)
+          radiusInPMT0->Fill(pmtRad);
+        if (curPMTNum == 1)
+          radiusInPMT1->Fill(pmtRad);
+        if (curPMTNum == 2)
+          radiusInPMT2->Fill(pmtRad);
+        if (curPMTNum == 3)
+          radiusInPMT3->Fill(pmtRad);
+        if (curPMTNum == 4)
+          radiusInPMT4->Fill(pmtRad);
+        if (curPMTNum == 5)
+          radiusInPMT5->Fill(pmtRad);
+        if (curPMTNum == 6)
+          radiusInPMT6->Fill(pmtRad);
+        if (curPMTNum == 7)
+          radiusInPMT7->Fill(pmtRad);
+        if (curPMTNum == 8)
+          radiusInPMT8->Fill(pmtRad);
+        if (curPMTNum == 9)
+          radiusInPMT9->Fill(pmtRad);
+        if (curPMTNum == 10)
+          radiusInPMT10->Fill(pmtRad);
+        if (curPMTNum == 11)
+          radiusInPMT11->Fill(pmtRad);
+        if (curPMTNum == 12)
+          radiusInPMT12->Fill(pmtRad);
+        if (curPMTNum == 13)
+          radiusInPMT13->Fill(pmtRad);
+        if (curPMTNum == 14)
+          radiusInPMT14->Fill(pmtRad);
+        if (curPMTNum == 15)
+          radiusInPMT15->Fill(pmtRad);
+
+        //				G4cout<<pmtRad<<G4endl;
+
+        if (fGlobalHitXYCoordPeOrigin)
+          fGlobalHitXYCoordPeOrigin->Fill(aPeOrigin.x(), aPeOrigin.y());
+        if (fGlobalHitXYCoord)
+          fGlobalHitXYCoord->Fill(aGlobalXYHitC.x(), aGlobalXYHitC.y());
+        if (fGlobalPixelCenterXYCoord)
+          fGlobalPixelCenterXYCoord->Fill(aPixelCenterC.x(), aPixelCenterC.y());
+        if (curPMTNum == 0 || curPMTNum == 2) {
+          if (fGlobalHitXYCoordPeOriginHpdPmt)
+            fGlobalHitXYCoordPeOriginHpdPmt->Fill(aPeOrigin.x(), aPeOrigin.y());
+        }
+      }
+    }
+
+    G4int numTotHitInEv = aRichCounter->getnumhitTotEv();
+    G4int numTotHitInEvCentralPmt = aRichCounter->getnumhitTotEvCentralPmt();
+    G4int numTotHitInEvCentralPmtJura = aRichCounter->getnumhitTotEvCentralPmtJura();
+    G4int numTotHitInEvCentralPmtSaleve = aRichCounter->getnumhitTotEvCentralPmtSaleve();
+
+    G4int numTotHitInPMT0 = aRichCounter->getnumhitPMT0();
+    G4int numTotHitInPMT1 = aRichCounter->getnumhitPMT1();
+    G4int numTotHitInPMT2 = aRichCounter->getnumhitPMT2();
+    G4int numTotHitInPMT3 = aRichCounter->getnumhitPMT3();
+    G4int numTotHitInPMT4 = aRichCounter->getnumhitPMT4();
+    G4int numTotHitInPMT5 = aRichCounter->getnumhitPMT5();
+    G4int numTotHitInPMT6 = aRichCounter->getnumhitPMT6();
+    G4int numTotHitInPMT7 = aRichCounter->getnumhitPMT7();
+    G4int numTotHitInPMT8 = aRichCounter->getnumhitPMT8();
+    G4int numTotHitInPMT9 = aRichCounter->getnumhitPMT9();
+    G4int numTotHitInPMT10 = aRichCounter->getnumhitPMT10();
+    G4int numTotHitInPMT11 = aRichCounter->getnumhitPMT11();
+    G4int numTotHitInPMT12 = aRichCounter->getnumhitPMT12();
+    G4int numTotHitInPMT13 = aRichCounter->getnumhitPMT13();
+    G4int numTotHitInPMT14 = aRichCounter->getnumhitPMT14();
+    G4int numTotHitInPMT15 = aRichCounter->getnumhitPMT15();
+
+    //  G4cout<<" Number of hits in this event "<<n_hit<<G4endl;
+
+    /*
+G4cout<<"NumHits Tot pmt01234567 "<<
+numTotHitInEv <<"  "<<(numTotHitInEvCentralPmt<<"  "<< numTotHitInPMT0<<"  "
+<<  numTotHitInPMT1<<"   "<< numTotHitInPMT2<<"   "
+<< numTotHitInPMT3<<"   "<< numTotHitInPMT4<<"   "
+<<  numTotHitInPMT5<<"   "<< numTotHitInPMT6<<"  "<<  numTotHitInPMT7<<  G4endl;
+
+     */
+
+    if (fNumHitInEvent)
+      fNumHitInEvent->Fill(numTotHitInEv * 1.0);
+    if (fNumHitInEventCentralPMT)
+      fNumHitInEventCentralPMT->Fill(numTotHitInEvCentralPmt * 1.0);
+
+    if (fNumHitInPMT0)
+      fNumHitInPMT0->Fill(numTotHitInPMT0 * 1.0);
+    if (fNumHitInPMT1)
+      fNumHitInPMT1->Fill(numTotHitInPMT1 * 1.0);
+    if (fNumHitInPMT2)
+      fNumHitInPMT2->Fill(numTotHitInPMT2 * 1.0);
+    if (fNumHitInPMT3)
+      fNumHitInPMT3->Fill(numTotHitInPMT3 * 1.0);
+    if (fNumHitInPMT4)
+      fNumHitInPMT4->Fill(numTotHitInPMT4 * 1.0);
+    if (fNumHitInPMT5)
+      fNumHitInPMT5->Fill(numTotHitInPMT5 * 1.0);
+    if (fNumHitInPMT6)
+      fNumHitInPMT6->Fill(numTotHitInPMT6 * 1.0);
+    if (fNumHitInPMT7)
+      fNumHitInPMT7->Fill(numTotHitInPMT7 * 1.0);
+    if (fNumHitInPMT8)
+      fNumHitInPMT8->Fill(numTotHitInPMT8 * 1.0);
+    if (fNumHitInPMT9)
+      fNumHitInPMT9->Fill(numTotHitInPMT9 * 1.0);
+    if (fNumHitInPMT10)
+      fNumHitInPMT10->Fill(numTotHitInPMT10 * 1.0);
+    if (fNumHitInPMT11)
+      fNumHitInPMT11->Fill(numTotHitInPMT11 * 1.0);
+    if (fNumHitInPMT12)
+      fNumHitInPMT12->Fill(numTotHitInPMT12 * 1.0);
+    if (fNumHitInPMT13)
+      fNumHitInPMT13->Fill(numTotHitInPMT13 * 1.0);
+    if (fNumHitInPMT14)
+      fNumHitInPMT14->Fill(numTotHitInPMT14 * 1.0);
+    if (fNumHitInPMT15)
+      fNumHitInPMT15->Fill(numTotHitInPMT15 * 1.0);
+
+    if (fNumHitInEventCentralPMTJura)
+      fNumHitInEventCentralPMTJura->Fill(numTotHitInEvCentralPmtJura);
+    if (fNumHitInEventCentralPMTSaleve)
+      fNumHitInEventCentralPMTSaleve->Fill(numTotHitInEvCentralPmtSaleve);
+
+    //    if(fhistoNrPhotAll) {
+    //      G4cout<<"Now filling histoNrPhotAll"<<G4endl;
+
+    //   fhistoNrPhotAll->fill(1.0*numTotHitInEv);
+
+    // G4cout<<"Test print histo mean rms  "<<
+    //  fhistoNrPhotAll->mean()<<"  "<<fhistoNrPhotAll->rms()<<G4endl;
+
+    //  }else {
+    //  G4cout<<" histoNrPhotAll Not available for filling"<<G4endl;
+
+    //  }
+
+    //  if(fhistoNrPhotPMT0) {
+    //  fhistoNrPhotPMT0->fill(1.0*numTotHitInPMT0);
+    //  }else {
+
+    //  G4cout<<" histoNrPhotPMT0 Not available for filling"<<G4endl;
+    //  }
+
+    // if(fhistoNrPhotPMT1) fhistoNrPhotPMT1->fill(1.0*numTotHitInPMT1);
+    // if(fhistoNrPhotPMT2) fhistoNrPhotPMT2->fill(1.0*numTotHitInPMT2);
+    // if(fhistoNrPhotPMT3) fhistoNrPhotPMT3->fill(1.0*numTotHitInPMT3);
+    // if(fhistoNrPhotPMT4) fhistoNrPhotPMT4->fill(1.0*numTotHitInPMT4);
+    // if(fhistoNrPhotPMT5) fhistoNrPhotPMT5->fill(1.0*numTotHitInPMT5);
+  }
+
+  // test histo and ntuple
+
+  G4double aRNum1 = G4RandGauss::shoot(50.0, 10.0);
+
+  G4double aRNum2 = G4RandGauss::shoot(1.0, 0.2);
+
+  G4double aRNum3 = G4UniformRand();
+  if (fHisto[0])
+    fHisto[0]->Fill(aRNum1);
+
+  fNtupVar1 = aRNum2;
+  fNtupVar2 = aRNum3;
+  if (fNtuple1)
+    fNtuple1->Fill();
+
+  // end test histo and ntuple
+
+  // now for the hpd
+
+  if (aRadiatorConfiguration == 2) {
+    EndOfEventHistoHpd(evt);
+  }
 }
 
-
-void RichTbAnalysisManager::EndOfEventHisto(const G4Event * evt)
-{
-
-	RichTbRunConfig* rConfig = RichTbRunConfig::getRunConfigInstance();
-	G4int aRadiatorConfiguration = rConfig ->getRadiatorConfiguration();
-
-
-	RichTbCounter* aRichCounter= RichTbCounter::getRichTbCounterInstance();
-
-	G4SDManager * SDman = G4SDManager::GetSDMpointer();
-	G4String colNam= RichTbHColname;
-	G4int RichTbCollID = SDman->GetCollectionID(colNam);
-	G4int aVerboseFlag =  rConfig-> VerboseInfoFlag() ;
-
-
-	G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
-	RichTbHitsCollection* RHC = NULL;
-	if(HCE)
-	{
-		RHC = (RichTbHitsCollection*)(HCE->GetHC(RichTbCollID));
-	}
-
-	if(RHC)
-	{
-		G4int n_hit = RHC->entries();
-
-
-		for(G4int ih=0; ih<n_hit; ih++) {
-			RichTbHit* aHit = (*RHC)[ih];
-
-			// Now for printing
-			if( aVerboseFlag >=5 ) {
-				aHit->Print();
-			}
-
-			G4int curPMTNum =  aHit->GetCurPMTNum() ;
-			G4ThreeVector curHitCoord=  aHit-> GetPos();
-			G4int curHitInGapFlag = aHit-> getHitInPixelGapFlag() ;
-
-			//      G4cout<<"Hit PMT Number: "<<curPMTNum<<", coordinate: "<<curHitCoord<<G4endl;
-
-			// G4cout<<" Gap flag :  "<<curHitInGapFlag<<G4endl;
-
-			if(curHitInGapFlag == 0 ) {
-
-				aRichCounter->bumpnumhitTotEv();
-				if( curPMTNum == 0 ) aRichCounter->bumpnumhitPMT0();
-				if( curPMTNum == 1 ) aRichCounter->bumpnumhitPMT1();
-				if( curPMTNum == 2 ) aRichCounter->bumpnumhitPMT2();
-				if( curPMTNum == 3 ) aRichCounter->bumpnumhitPMT3();
-				if( curPMTNum == 4 ) aRichCounter->bumpnumhitPMT4();
-				if( curPMTNum == 5 ) aRichCounter->bumpnumhitPMT5();
-				if( curPMTNum == 6 ) aRichCounter->bumpnumhitPMT6();
-				if( curPMTNum == 7 ) aRichCounter->bumpnumhitPMT7();
-				if( curPMTNum == 8 ) aRichCounter->bumpnumhitPMT8();
-				if( curPMTNum == 9 ) aRichCounter->bumpnumhitPMT9();
-				if( curPMTNum == 10 ) aRichCounter->bumpnumhitPMT10();
-				if( curPMTNum == 11 ) aRichCounter->bumpnumhitPMT11();
-				if( curPMTNum == 12 ) aRichCounter->bumpnumhitPMT12();
-				if( curPMTNum == 13 ) aRichCounter->bumpnumhitPMT13();
-				if( curPMTNum == 14 ) aRichCounter->bumpnumhitPMT14();
-				if( curPMTNum == 15 ) aRichCounter->bumpnumhitPMT15();
-				if(  ( curPMTNum == 0 ) || ( curPMTNum == 2 ) ||
-						( curPMTNum == 5 ) || ( curPMTNum == 7 ) ||
-						( curPMTNum == 8 ) || ( curPMTNum == 10 ) ||
-						( curPMTNum == 13 ) || ( curPMTNum == 15 )) aRichCounter->bumpnumhitTotEvCentralPmt();
-
-				if(  ( curPMTNum == 0 ) || ( curPMTNum == 2 ) ||
-						(curPMTNum == 8) || ( curPMTNum == 10 )) aRichCounter->bumpnumhitTotEvCentralPmtJura();
-
-				if(  ( curPMTNum == 5 ) || ( curPMTNum == 7 ) ||
-						(curPMTNum == 13) || ( curPMTNum == 15 )) aRichCounter->bumpnumhitTotEvCentralPmtSaleve();
-
-
-				// if(  fHistoCkvTruePhiHits)
-					//  fHistoCkvTruePhiHits->fill( aHit->GetCkvPhiProd());
-
-				// now fill the pixel  col row in a histogram.
-
-				//  G4int aPixelNum = aHit-> GetCurPixNum();
-				// G4int aPixelRow = aPixelNum/RichTbPMTSiDetNumPixelAlongX;
-				// G4int aPixelCol = aPixelNum- aPixelRow*RichTbPMTSiDetNumPixelAlongX;
-
-				// if(   (curPMTNum == 0)  && (fHistoPixelColRowPMT0) )
-				//  fHistoPixelColRowPMT0->fill(1.0*aPixelCol,1.0* aPixelRow);
-				//  if(   (curPMTNum == 1)  && (fHistoPixelColRowPMT1) )
-				//  fHistoPixelColRowPMT1->fill(1.0*aPixelCol,1.0* aPixelRow);
-				// if(   (curPMTNum == 2)  && (fHistoPixelColRowPMT2) )
-				//  fHistoPixelColRowPMT2->fill(1.0*aPixelCol,1.0*aPixelRow);
-				// if(   (curPMTNum == 3)  && (fHistoPixelColRowPMT3) )
-				//  fHistoPixelColRowPMT3->fill(1.0*aPixelCol,1.0*aPixelRow);
-				// if(   (curPMTNum == 4)  && (fHistoPixelColRowPMT4) )
-				//  fHistoPixelColRowPMT4->fill(1.0*aPixelCol,1.0*aPixelRow);
-				//  if(   (curPMTNum == 5)  && (fHistoPixelColRowPMT5) )
-				//  fHistoPixelColRowPMT5->fill(1.0*aPixelCol,1.0*aPixelRow);
-
-				G4ThreeVector aPeOrigin = aHit->GetPeOrigin();
-				G4ThreeVector aGlobalXYHitC = aHit->GetPos();
-				G4ThreeVector aPixelCenterC =  aHit->getPixelGlobalCenter() ;
-
-
-				if(fGlobalHitXYCoord15) fGlobalHitXYCoord15->Fill(aGlobalXYHitC.x(),aGlobalXYHitC.y());
-
-
-				G4double pmtRad = sqrt(pow(aGlobalXYHitC.x(),2) + pow(aGlobalXYHitC.y(),2));
-				if(curPMTNum == 0) radiusInPMT0->Fill(pmtRad);
-				if(curPMTNum == 1) radiusInPMT1->Fill(pmtRad);
-				if(curPMTNum == 2) radiusInPMT2->Fill(pmtRad);
-				if(curPMTNum == 3) radiusInPMT3->Fill(pmtRad);
-				if(curPMTNum == 4) radiusInPMT4->Fill(pmtRad);
-				if(curPMTNum == 5) radiusInPMT5->Fill(pmtRad);
-				if(curPMTNum == 6) radiusInPMT6->Fill(pmtRad);
-				if(curPMTNum == 7) radiusInPMT7->Fill(pmtRad);
-				if(curPMTNum == 8) radiusInPMT8->Fill(pmtRad);
-				if(curPMTNum == 9) radiusInPMT9->Fill(pmtRad);
-				if(curPMTNum == 10) radiusInPMT10->Fill(pmtRad);
-				if(curPMTNum == 11) radiusInPMT11->Fill(pmtRad);
-				if(curPMTNum == 12) radiusInPMT12->Fill(pmtRad);
-				if(curPMTNum == 13) radiusInPMT13->Fill(pmtRad);
-				if(curPMTNum == 14) radiusInPMT14->Fill(pmtRad);
-				if(curPMTNum == 15) radiusInPMT15->Fill(pmtRad);
-
-//				G4cout<<pmtRad<<G4endl;
-
-				if( fGlobalHitXYCoordPeOrigin) fGlobalHitXYCoordPeOrigin->Fill( aPeOrigin.x(),aPeOrigin.y());
-				if(fGlobalHitXYCoord) fGlobalHitXYCoord->Fill(aGlobalXYHitC.x(),aGlobalXYHitC.y());
-				if(fGlobalPixelCenterXYCoord)fGlobalPixelCenterXYCoord ->Fill(aPixelCenterC.x(), aPixelCenterC.y());
-				if(curPMTNum == 0 || curPMTNum == 2 ) {
-					if(fGlobalHitXYCoordPeOriginHpdPmt)  fGlobalHitXYCoordPeOriginHpdPmt->Fill(aPeOrigin.x(),aPeOrigin.y() );
-				}
-			}
-		}
-
-
-		G4int numTotHitInEv =  aRichCounter->getnumhitTotEv();
-		G4int numTotHitInEvCentralPmt = aRichCounter->getnumhitTotEvCentralPmt();
-		G4int numTotHitInEvCentralPmtJura = aRichCounter->getnumhitTotEvCentralPmtJura();
-		G4int numTotHitInEvCentralPmtSaleve = aRichCounter->getnumhitTotEvCentralPmtSaleve();
-
-		G4int numTotHitInPMT0=   aRichCounter->getnumhitPMT0();
-		G4int numTotHitInPMT1=   aRichCounter->getnumhitPMT1();
-		G4int numTotHitInPMT2=   aRichCounter->getnumhitPMT2();
-		G4int numTotHitInPMT3=   aRichCounter->getnumhitPMT3();
-		G4int numTotHitInPMT4=   aRichCounter->getnumhitPMT4();
-		G4int numTotHitInPMT5=   aRichCounter->getnumhitPMT5();
-		G4int numTotHitInPMT6=   aRichCounter->getnumhitPMT6();
-		G4int numTotHitInPMT7=   aRichCounter->getnumhitPMT7();
-		G4int numTotHitInPMT8=   aRichCounter->getnumhitPMT8();
-		G4int numTotHitInPMT9=   aRichCounter->getnumhitPMT9();
-		G4int numTotHitInPMT10=   aRichCounter->getnumhitPMT10();
-		G4int numTotHitInPMT11=   aRichCounter->getnumhitPMT11();
-		G4int numTotHitInPMT12=   aRichCounter->getnumhitPMT12();
-		G4int numTotHitInPMT13=   aRichCounter->getnumhitPMT13();
-		G4int numTotHitInPMT14=   aRichCounter->getnumhitPMT14();
-		G4int numTotHitInPMT15=   aRichCounter->getnumhitPMT15();
-
-		//  G4cout<<" Number of hits in this event "<<n_hit<<G4endl;
-
-		/*
-      G4cout<<"NumHits Tot pmt01234567 "<<
-      numTotHitInEv <<"  "<<(numTotHitInEvCentralPmt<<"  "<< numTotHitInPMT0<<"  "
-          <<  numTotHitInPMT1<<"   "<< numTotHitInPMT2<<"   "
-          << numTotHitInPMT3<<"   "<< numTotHitInPMT4<<"   "
-          <<  numTotHitInPMT5<<"   "<< numTotHitInPMT6<<"  "<<  numTotHitInPMT7<<  G4endl;
-
-		 */
-
-		if(fNumHitInEvent) fNumHitInEvent ->Fill( numTotHitInEv*1.0);
-		if(fNumHitInEventCentralPMT) fNumHitInEventCentralPMT->Fill(numTotHitInEvCentralPmt*1.0);
-
-		if(fNumHitInPMT0)fNumHitInPMT0->Fill(numTotHitInPMT0*1.0);
-		if(fNumHitInPMT1)fNumHitInPMT1->Fill(numTotHitInPMT1*1.0);
-		if(fNumHitInPMT2)fNumHitInPMT2->Fill(numTotHitInPMT2*1.0);
-		if(fNumHitInPMT3)fNumHitInPMT3->Fill(numTotHitInPMT3*1.0);
-		if(fNumHitInPMT4)fNumHitInPMT4->Fill(numTotHitInPMT4*1.0);
-		if(fNumHitInPMT5)fNumHitInPMT5->Fill(numTotHitInPMT5*1.0);
-		if(fNumHitInPMT6)fNumHitInPMT6->Fill(numTotHitInPMT6*1.0);
-		if(fNumHitInPMT7)fNumHitInPMT7->Fill(numTotHitInPMT7*1.0);
-		if(fNumHitInPMT8)fNumHitInPMT8->Fill(numTotHitInPMT8*1.0);
-		if(fNumHitInPMT9)fNumHitInPMT9->Fill(numTotHitInPMT9*1.0);
-		if(fNumHitInPMT10)fNumHitInPMT10->Fill(numTotHitInPMT10*1.0);
-		if(fNumHitInPMT11)fNumHitInPMT11->Fill(numTotHitInPMT11*1.0);
-		if(fNumHitInPMT12)fNumHitInPMT12->Fill(numTotHitInPMT12*1.0);
-		if(fNumHitInPMT13)fNumHitInPMT13->Fill(numTotHitInPMT13*1.0);
-		if(fNumHitInPMT14)fNumHitInPMT14->Fill(numTotHitInPMT14*1.0);
-		if(fNumHitInPMT15)fNumHitInPMT15->Fill(numTotHitInPMT15*1.0);
-
-
-		if(fNumHitInEventCentralPMTJura) fNumHitInEventCentralPMTJura->Fill ( numTotHitInEvCentralPmtJura );
-		if(fNumHitInEventCentralPMTSaleve) fNumHitInEventCentralPMTSaleve->Fill ( numTotHitInEvCentralPmtSaleve );
-
-
-
-		//    if(fhistoNrPhotAll) {
-			//      G4cout<<"Now filling histoNrPhotAll"<<G4endl;
-
-		//   fhistoNrPhotAll->fill(1.0*numTotHitInEv);
-
-		// G4cout<<"Test print histo mean rms  "<<
-		//  fhistoNrPhotAll->mean()<<"  "<<fhistoNrPhotAll->rms()<<G4endl;
-
-		//  }else {
-		//  G4cout<<" histoNrPhotAll Not available for filling"<<G4endl;
-
-		//  }
-
-
-		//  if(fhistoNrPhotPMT0) {
-		//  fhistoNrPhotPMT0->fill(1.0*numTotHitInPMT0);
-		//  }else {
-
-		//  G4cout<<" histoNrPhotPMT0 Not available for filling"<<G4endl;
-		//  }
-
-
-		// if(fhistoNrPhotPMT1) fhistoNrPhotPMT1->fill(1.0*numTotHitInPMT1);
-		// if(fhistoNrPhotPMT2) fhistoNrPhotPMT2->fill(1.0*numTotHitInPMT2);
-		// if(fhistoNrPhotPMT3) fhistoNrPhotPMT3->fill(1.0*numTotHitInPMT3);
-		// if(fhistoNrPhotPMT4) fhistoNrPhotPMT4->fill(1.0*numTotHitInPMT4);
-		// if(fhistoNrPhotPMT5) fhistoNrPhotPMT5->fill(1.0*numTotHitInPMT5);
-
-
-
-
-	}
-
-	// test histo and ntuple
-
-	G4double aRNum1=  G4RandGauss::shoot(50.0,10.0);
-
-	G4double aRNum2 = G4RandGauss::shoot(1.0,0.2);
-
-	G4double aRNum3  =  G4UniformRand() ;
-	if(fHisto[0] )fHisto[0] ->Fill( aRNum1 );
-
-	fNtupVar1 = aRNum2;
-	fNtupVar2 = aRNum3;
-	if (fNtuple1) fNtuple1->Fill();
-
-	// end test histo and ntuple
-
-	// now for the hpd
-
-	if( aRadiatorConfiguration == 2 ) {
-		EndOfEventHistoHpd(evt);
-	}
-
-
-
+void RichTbAnalysisManager::EndOfEventHistoHpd(const G4Event *evt) {
+  // RichTbRunConfig *rConfig = RichTbRunConfig::getRunConfigInstance();
+  // G4int aRadiatorConfiguration = rConfig->getRadiatorConfiguration();
+  RichTbCounter *aRichCounter = RichTbCounter::getRichTbCounterInstance();
+
+  G4SDManager *SDman = G4SDManager::GetSDMpointer();
+  G4String colNam = RichTbHColnameHpd;
+  G4int RichTbCollID = SDman->GetCollectionID(colNam);
+  // G4int aVerboseFlag = rConfig->VerboseInfoFlag();
+
+  G4HCofThisEvent *HCE = evt->GetHCofThisEvent();
+  RichTbHitsCollection *RHC = NULL;
+  if (HCE) {
+    RHC = (RichTbHitsCollection *)(HCE->GetHC(RichTbCollID));
+  }
+
+  if (RHC) {
+    G4int n_hit = RHC->entries();
+
+    for (G4int ih = 0; ih < n_hit; ih++) {
+      RichTbHit *aHit = (*RHC)[ih];
+
+      // G4int curHPDNum = aHit->GetCurHPDNum();
+      G4ThreeVector curHitCoord = aHit->GetPos();
+
+      G4ThreeVector aPeOrigin = aHit->GetPeOrigin();
+      G4ThreeVector aPixelCenterC = aHit->getPixelGlobalCenter();
+      G4double aRefIndexHit = (aHit->GetCkvCosThetaProd()) != 0.0 ? 1.0 / (aHit->GetCkvCosThetaProd()) : 1.0;
+      G4double aWavelenHit =
+          (aHit->GetCkvEnergyProd()) != 0.0 ? 1243.125 / ((aHit->GetCkvEnergyProd()) * 1000000) : 0.0;
+      G4ThreeVector aLocalPixelCenterC = aHit->getPixelLocalCenter();
+      G4double ax = aLocalPixelCenterC.x();
+      G4double ay = aLocalPixelCenterC.y();
+      G4double aDX = ax * ((1.0 / PixelPMTDemagLinearFactor) - 1.0);
+      G4double aDY = ay * ((1.0 / PixelPMTDemagLinearFactor) - 1.0);
+      G4double rdsq = -sqrt(ax * ax + ay * ay) / PixelPMTDemagLinearFactor;
+      G4double rPh = RichTbHpdPhCathodeInnerRad;
+
+      G4double aDZ = -RichTbHpdSiDetDistZFromPhCathode + rPh * (1 - sqrt(1 - (rdsq) / (rPh * rPh)));
+      G4ThreeVector aGlobalPixelCenterPhcath = aPixelCenterC + G4ThreeVector(aDX, aDY, aDZ);
+
+      // G4cout <<" hpd hits  ih  refindex energy wavelen "<< ih
+      //       <<"  "<<aRefIndexHit <<"   "<< aHit->GetCkvEnergyProd()<<"  "<<aWavelenHit<<G4endl;
+
+      aRichCounter->bumpnumHitTotHpd0();
+      //  G4cout<<" a Peorigin X Y "<<ih <<"  "<<aPeOrigin.x() << "  "<< aPeOrigin.y()<<G4endl;
+      if (aPeOrigin.x() < -0.1) { // avoid unphysical ccord.
+
+        if (aPeOrigin.x() > -80.0 && aPeOrigin.x() < -55.0) {
+
+          aRichCounter->bumpnumHitSignalHpd0();
+        }
+
+        if (fGlobalHitXYCoordPeOriginHpd)
+          fGlobalHitXYCoordPeOriginHpd->Fill(aPeOrigin.x(), aPeOrigin.y());
+        if (fGlobalHitXYCoordHpd)
+          fGlobalHitXYCoordHpd->Fill(curHitCoord.x(), curHitCoord.y());
+        if (fGlobalPixelCenterXYCoordHpd)
+          fGlobalPixelCenterXYCoordHpd->Fill(aPixelCenterC.x(), aPixelCenterC.y());
+        if (fGlobalHitXYCoordPeOriginHpdPmt)
+          fGlobalHitXYCoordPeOriginHpdPmt->Fill(aPeOrigin.x(), aPeOrigin.y());
+        if (fRadiatorRefIndexHits)
+          fRadiatorRefIndexHits->Fill(aWavelenHit, (aRefIndexHit - 1));
+        if (fGlobalHitXYCoordPixPhcathHpd)
+          fGlobalHitXYCoordPixPhcathHpd->Fill(aGlobalPixelCenterPhcath.x(), aGlobalPixelCenterPhcath.y());
+      }
+    }
+  }
+
+  G4int numTotHitInHpd0 = aRichCounter->getnumHitTotHpd0();
+
+  G4int numTotSignalInHpd0 = aRichCounter->getnumHitSignalHpd0();
+  // G4cout <<" Num hit signal hpd0 "<< numTotHitInHpd0<<"   "<<numTotSignalInHpd0<<G4endl;
+
+  if (fNumHitInHPD0)
+    fNumHitInHPD0->Fill(numTotHitInHpd0 * 1.0);
+  if (fNumHitSignalInHPD0)
+    fNumHitSignalInHPD0->Fill(numTotSignalInHpd0 * 1.0);
 }
-
-void RichTbAnalysisManager::EndOfEventHistoHpd(const G4Event * evt) {
-	RichTbRunConfig* rConfig = RichTbRunConfig::getRunConfigInstance();
-	G4int aRadiatorConfiguration = rConfig ->getRadiatorConfiguration();
-	RichTbCounter* aRichCounter= RichTbCounter::getRichTbCounterInstance();
-
-	G4SDManager * SDman = G4SDManager::GetSDMpointer();
-	G4String colNam=RichTbHColnameHpd;
-	G4int RichTbCollID = SDman->GetCollectionID(colNam);
-	G4int aVerboseFlag =  rConfig-> VerboseInfoFlag() ;
-
-
-	G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
-	RichTbHitsCollection* RHC = NULL;
-	if(HCE)
-	{
-		RHC = (RichTbHitsCollection*)(HCE->GetHC(RichTbCollID));
-	}
-
-	if(RHC)
-	{
-		G4int n_hit = RHC->entries();
-
-
-		for(G4int ih=0; ih<n_hit; ih++) {
-			RichTbHit* aHit = (*RHC)[ih];
-
-			G4int curHPDNum =  aHit->GetCurHPDNum() ;
-			G4ThreeVector curHitCoord=  aHit-> GetPos();
-
-			G4ThreeVector aPeOrigin = aHit-> GetPeOrigin();
-			G4ThreeVector aPixelCenterC =  aHit->getPixelGlobalCenter() ;
-			G4double aRefIndexHit = (aHit-> GetCkvCosThetaProd()) != 0.0 ? 1.0/(aHit-> GetCkvCosThetaProd()) : 1.0;
-			G4double aWavelenHit =  ( aHit->GetCkvEnergyProd()) != 0.0 ?
-					1243.125 /((aHit->GetCkvEnergyProd())*1000000) : 0.0;
-			G4ThreeVector aLocalPixelCenterC = aHit->getPixelLocalCenter();
-			G4double ax=aLocalPixelCenterC.x();
-			G4double ay=aLocalPixelCenterC.y();
-			G4double aDX = ax*( (1.0 /PixelPMTDemagLinearFactor)  -1.0);
-			G4double aDY = ay*( (1.0 /PixelPMTDemagLinearFactor)   - 1.0);
-			G4double rdsq = -sqrt(ax*ax + ay*ay )/PixelPMTDemagLinearFactor;
-			G4double rPh = RichTbHpdPhCathodeInnerRad;
-
-			G4double aDZ = -RichTbHpdSiDetDistZFromPhCathode + rPh * (1- sqrt(1-(rdsq)/(rPh*rPh)));
-			G4ThreeVector aGlobalPixelCenterPhcath = aPixelCenterC + G4ThreeVector(aDX,aDY,aDZ) ;
-
-
-			// G4cout <<" hpd hits  ih  refindex energy wavelen "<< ih
-					//       <<"  "<<aRefIndexHit <<"   "<< aHit->GetCkvEnergyProd()<<"  "<<aWavelenHit<<G4endl;
-
-
-
-			aRichCounter->bumpnumHitTotHpd0();
-			//  G4cout<<" a Peorigin X Y "<<ih <<"  "<<aPeOrigin.x() << "  "<< aPeOrigin.y()<<G4endl;
-			if( aPeOrigin.x() < -0.1 ) {  // avoid unphysical ccord.
-
-				if(aPeOrigin.x() > -80.0 &&  aPeOrigin.x() < -55.0) {
-
-					aRichCounter->bumpnumHitSignalHpd0();
-
-				}
-
-				if(fGlobalHitXYCoordPeOriginHpd)fGlobalHitXYCoordPeOriginHpd ->Fill(aPeOrigin.x(),aPeOrigin.y());
-				if(fGlobalHitXYCoordHpd) fGlobalHitXYCoordHpd ->Fill(curHitCoord.x(), curHitCoord.y());
-				if(fGlobalPixelCenterXYCoordHpd) fGlobalPixelCenterXYCoordHpd -> Fill(aPixelCenterC.x(), aPixelCenterC.y());
-				if(fGlobalHitXYCoordPeOriginHpdPmt)  fGlobalHitXYCoordPeOriginHpdPmt->Fill(aPeOrigin.x(),aPeOrigin.y());
-				if(fRadiatorRefIndexHits) fRadiatorRefIndexHits ->Fill(aWavelenHit, (aRefIndexHit-1) );
-				if( fGlobalHitXYCoordPixPhcathHpd)
-					fGlobalHitXYCoordPixPhcathHpd->Fill(aGlobalPixelCenterPhcath.x(),aGlobalPixelCenterPhcath.y());
-
-			}
-
-		}
-	}
-
-	G4int numTotHitInHpd0 =  aRichCounter->getnumHitTotHpd0();
-
-	G4int  numTotSignalInHpd0 =  aRichCounter->getnumHitSignalHpd0();
-	// G4cout <<" Num hit signal hpd0 "<< numTotHitInHpd0<<"   "<<numTotSignalInHpd0<<G4endl;
-
-	if(fNumHitInHPD0) fNumHitInHPD0 ->Fill( numTotHitInHpd0 * 1.0);
-	if(fNumHitSignalInHPD0) fNumHitSignalInHPD0 ->Fill( numTotSignalInHpd0 * 1.0);
-
-
-}
-
-
-
-
-
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbCounter.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbCounter.cc
index 54513ea9eb44647fc4158c924d7e1e26369bf3c8..145ee802cf53d5a90c110ee371cf3c850171dcfc 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbCounter.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbCounter.cc
@@ -1,8 +1,6 @@
 // $Id: $
 // Include files
 
-
-
 // local
 #include "RichTbCounter.hh"
 
@@ -15,71 +13,62 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbCounter* RichTbCounter::RichTbCounterInstance = 0;
-
-RichTbCounter::RichTbCounter(  ) {
-  resetRichTbCounter();
+RichTbCounter *RichTbCounter::RichTbCounterInstance = 0;
 
-}
+RichTbCounter::RichTbCounter() { resetRichTbCounter(); }
 //=============================================================================
 // Destructor
 //=============================================================================
 RichTbCounter::~RichTbCounter() {}
 
 //=============================================================================
-RichTbCounter* RichTbCounter::getRichTbCounterInstance()
-{
-  if( RichTbCounterInstance == 0 ) {
-    RichTbCounterInstance = new RichTbCounter(  );
-
+RichTbCounter *RichTbCounter::getRichTbCounterInstance() {
+  if (RichTbCounterInstance == 0) {
+    RichTbCounterInstance = new RichTbCounter();
   }
-  return  RichTbCounterInstance;
+  return RichTbCounterInstance;
 }
 
-void RichTbCounter::resetRichTbCounter()
-{
-  numHitTotProd=0;
-  numhitTotEv=0;
-  numhitTotEvCentralPmt=0;
-  numhitTotEvCentralPmtJura=0;
-  numhitTotEvCentralPmtSaleve=0;
-
-  numhitPMT0=0;
-  numhitPMT1=0;
-  numhitPMT2=0;
-  numhitPMT3=0;
-  numhitPMT4=0;
-  numhitPMT5=0;
-  numhitPMT6=0;
-  numhitPMT7=0;
-  numhitPMT9=0;
-  numhitPMT8=0;
-  numhitPMT10=0;
-  numhitPMT11=0;
-  numhitPMT12=0;
-  numhitPMT13=0;
-  numhitPMT14=0;
-  numhitPMT15=0;
-
-
-  numPhEnterMirror=0;
-  numPhEnterPhSupFrame=0;
-  numPhEnterPMT0QW=0;
-  numPhEnterPMT1QW=0;
-  numPhEnterPMT2QW=0;
-  numPhEnterPMT3QW=0;
-  numPhEnterPMT4QW=0;
-  numPhEnterPMT5QW=0;
-  numPhEnterAnPMTQW=0;
-  numPhElecPMT0=0;
-  numPhElecPMT1=0;
-  numPhElecPMT2=0;
-  numPhElecPMT3=0;
-  numPhElecPMT4=0;
-  numPhElecPMT5=0;
-
-  numHitTotHpd0=0;
-  numHitSignalHpd0=0;
-
-
+void RichTbCounter::resetRichTbCounter() {
+  numHitTotProd = 0;
+  numhitTotEv = 0;
+  numhitTotEvCentralPmt = 0;
+  numhitTotEvCentralPmtJura = 0;
+  numhitTotEvCentralPmtSaleve = 0;
+
+  numhitPMT0 = 0;
+  numhitPMT1 = 0;
+  numhitPMT2 = 0;
+  numhitPMT3 = 0;
+  numhitPMT4 = 0;
+  numhitPMT5 = 0;
+  numhitPMT6 = 0;
+  numhitPMT7 = 0;
+  numhitPMT9 = 0;
+  numhitPMT8 = 0;
+  numhitPMT10 = 0;
+  numhitPMT11 = 0;
+  numhitPMT12 = 0;
+  numhitPMT13 = 0;
+  numhitPMT14 = 0;
+  numhitPMT15 = 0;
+
+  numPhEnterMirror = 0;
+  numPhEnterPhSupFrame = 0;
+  numPhEnterPMT0QW = 0;
+  numPhEnterPMT1QW = 0;
+  numPhEnterPMT2QW = 0;
+  numPhEnterPMT3QW = 0;
+  numPhEnterPMT4QW = 0;
+  numPhEnterPMT5QW = 0;
+  numPhEnterAnPMTQW = 0;
+  numPhElecPMT0 = 0;
+  numPhElecPMT1 = 0;
+  numPhElecPMT2 = 0;
+  numPhElecPMT3 = 0;
+  numPhElecPMT4 = 0;
+  numPhElecPMT5 = 0;
+
+  numHitTotHpd0 = 0;
+  numHitSignalHpd0 = 0;
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbEventAction.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbEventAction.cc
index bbdf70654711f3a563d4ad046d3f62591be24a24..8b73b29940fdc05a237a3e3129beaa7d7187cac8 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbEventAction.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbEventAction.cc
@@ -1,128 +1,99 @@
 #include "RichTbEventAction.hh"
 #include "Geant4/G4Event.hh"
 #include "Geant4/G4EventManager.hh"
-#include "Geant4/G4TrajectoryContainer.hh"
-#include "Geant4/G4Trajectory.hh"
 #include "Geant4/G4HCofThisEvent.hh"
-#include "Geant4/G4VHitsCollection.hh"
 #include "Geant4/G4SDManager.hh"
-#include "Geant4/G4VVisManager.hh"
-#include "RichTbVisManager.hh"
+#include "Geant4/G4Trajectory.hh"
+#include "Geant4/G4TrajectoryContainer.hh"
 #include "Geant4/G4UImanager.hh"
+#include "Geant4/G4VHitsCollection.hh"
+#include "Geant4/G4VVisManager.hh"
 #include "Geant4/G4ios.hh"
+#include "RichTbVisManager.hh"
 //#include "RichTbSD.hh"
-#include "RichTbHit.hh"
-#include "RichTbRunConfig.hh"
 #include "RichTbAnalysisManager.hh"
+#include "RichTbCounter.hh"
+#include "RichTbHit.hh"
 #include "RichTbIOData.hh"
 #include "RichTbMiscNames.hh"
-#include "RichTbCounter.hh"
-
-
-RichTbEventAction::RichTbEventAction( )
-{
-    RichTbCollID = -1;
-    RichTbCollIDHpd = -1;
- 
-}
-
-
-RichTbEventAction::~RichTbEventAction()
-{
+#include "RichTbRunConfig.hh"
 
+RichTbEventAction::RichTbEventAction() {
+  RichTbCollID = -1;
+  RichTbCollIDHpd = -1;
 }
 
+RichTbEventAction::~RichTbEventAction() {}
 
-void RichTbEventAction::BeginOfEventAction(const G4Event * /*  evt */)
-{
+void RichTbEventAction::BeginOfEventAction(const G4Event * /*  evt */) {
 
-   // reset the counters.
+  // reset the counters.
 
-  RichTbCounter* aRichCounter =  
-           RichTbCounter::getRichTbCounterInstance();
-  aRichCounter-> resetRichTbCounter();
+  RichTbCounter *aRichCounter = RichTbCounter::getRichTbCounterInstance();
+  aRichCounter->resetRichTbCounter();
 
- G4SDManager * SDman = G4SDManager::GetSDMpointer();
-  if(RichTbCollID<0){
+  G4SDManager *SDman = G4SDManager::GetSDMpointer();
+  if (RichTbCollID < 0) {
     G4String colNam;
-    RichTbCollID = SDman->GetCollectionID(colNam= RichTbHColname);
-
+    RichTbCollID = SDman->GetCollectionID(colNam = RichTbHColname);
+  }
+  RichTbRunConfig *RConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int aRadiatorConfiguration = RConfig->getRadiatorConfiguration();
 
-}
-   RichTbRunConfig* RConfig =  RichTbRunConfig::getRunConfigInstance();
-   G4int aRadiatorConfiguration = RConfig ->getRadiatorConfiguration();
-
-   if(aRadiatorConfiguration == 2 ){
-     
-       if(RichTbCollIDHpd<0){
-         G4String colNamh;
-         RichTbCollIDHpd = SDman->GetCollectionID(colNamh= RichTbHColnameHpd);
-
-       }
-       
-   }
-   
-   
-
-  
-}
+  if (aRadiatorConfiguration == 2) {
 
-void RichTbEventAction::EndOfEventAction(const G4Event * evt)
-{
-   RichTbRunConfig* RConfig =  RichTbRunConfig::getRunConfigInstance();
-  if(RichTbCollID<0) return;
- // first get the trajectories
-  G4TrajectoryContainer* trajectoryContainer=evt->GetTrajectoryContainer();
-  G4int n_trajectories=0;
-  if(trajectoryContainer){n_trajectories=trajectoryContainer->entries();
-    G4cout << "     " << n_trajectories
-         << " Tracks are stored in Trajectorycontainer." << G4endl;
-  }
-   // Now get the hits
-  
-  G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
-  RichTbHitsCollection* RHC = NULL;
-  if(HCE)
-  {
-    RHC = (RichTbHitsCollection*)(HCE->GetHC(RichTbCollID));
+    if (RichTbCollIDHpd < 0) {
+      G4String colNamh;
+      RichTbCollIDHpd = SDman->GetCollectionID(colNamh = RichTbHColnameHpd);
+    }
   }
+}
 
-  if(RHC)
-  {
-    G4int n_hit = RHC->entries();
-    //  G4cout << "     " << n_hit
-    //  << " hits are stored in RichTbHitsCollection." << G4endl;
+void RichTbEventAction::EndOfEventAction(const G4Event *evt) {
+  RichTbRunConfig *RConfig = RichTbRunConfig::getRunConfigInstance();
+  if (RichTbCollID < 0)
+    return;
+  // first get the trajectories
+  G4TrajectoryContainer *trajectoryContainer = evt->GetTrajectoryContainer();
+  G4int n_trajectories = 0;
+  if (trajectoryContainer) {
+    n_trajectories = trajectoryContainer->entries();
+    G4cout << "     " << n_trajectories << " Tracks are stored in Trajectorycontainer." << G4endl;
   }
+  // Now get the hits
+
+//  G4HCofThisEvent *HCE = evt->GetHCofThisEvent();
+//  RichTbHitsCollection *RHC = NULL;
+//  if (HCE) {
+//    RHC = (RichTbHitsCollection *)(HCE->GetHC(RichTbCollID));
+//  }
+
+//  if (RHC) {
+//    G4int n_hit = RHC->entries();
+    // G4cout << "     " << n_hit << " hits are stored in RichTbHitsCollection." << G4endl;
+//  }
   // Now for analysis of hits related information.
 
-  RichTbAnalysisManager* aAnalysisManager= 
-    RichTbAnalysisManager::getInstance();
+  RichTbAnalysisManager *aAnalysisManager = RichTbAnalysisManager::getInstance();
   // aAnalysisManager->EndOfEventCountersHisto(evt);
-   aAnalysisManager->EndOfEventHisto(evt);
-  
-
+  aAnalysisManager->EndOfEventHisto(evt);
 
-   // Now to write out the data
+  // Now to write out the data
 
-   if(RConfig -> DoWriteOutputFile() ) {
+  if (RConfig->DoWriteOutputFile()) {
 
-    RichTbIOData* rTbIOData= RichTbIOData::getRichTbIODataInstance();
-     
-   rTbIOData -> WriteOutEventHeaderData(evt);
-   rTbIOData -> WriteOutHitData(evt);
-   //  G4cout << ">>> End of Event  Number  " << evt->GetEventID() << G4endl;
+    RichTbIOData *rTbIOData = RichTbIOData::getRichTbIODataInstance();
 
-   }
-   G4int totNumev = RConfig ->getNumEventInBatchMode();
-   if( totNumev > 100 ) {
-     if(  (evt->GetEventID())  % (totNumev/100)  == 0 ) {
-       G4cout << ">>> End of Event  Number  " << evt->GetEventID() << G4endl;
-
-     }
-   } else {
+    rTbIOData->WriteOutEventHeaderData(evt);
+    rTbIOData->WriteOutHitData(evt);
+    //  G4cout << ">>> End of Event  Number  " << evt->GetEventID() << G4endl;
+  }
+  G4int totNumev = RConfig->getNumEventInBatchMode();
+  if (totNumev > 100) {
+    if ((evt->GetEventID()) % (totNumev / 100) == 0) {
       G4cout << ">>> End of Event  Number  " << evt->GetEventID() << G4endl;
-   }   
-  
+    }
+  } else {
+    G4cout << ">>> End of Event  Number  " << evt->GetEventID() << G4endl;
+  }
 }
-
- 
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPEInfo.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPEInfo.cc
index b461d365eba4359752d7fd32726751414807b2c6..7ae25f70e1f8dc8aba607a5ffff18c3f60355c1f 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPEInfo.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPEInfo.cc
@@ -1,7 +1,5 @@
 // $Id: $
-// Include files 
-
-
+// Include files
 
 // local
 #include "RichTbPEInfo.hh"
@@ -15,10 +13,7 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbPEInfo::RichTbPEInfo(  ): mPhOrigin(0), mMotherPhotonInfo(0),
-       mPeOriginInHpdSupFrame(0){
-
-}
+RichTbPEInfo::RichTbPEInfo() : mPhOrigin(0), mMotherPhotonInfo(0), mPeOriginInHpdSupFrame(0) {}
 //=============================================================================
 // Destructor
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPeUserInfoAttach.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPeUserInfoAttach.cc
index f1c91ac6ca28c8974b47e1628366e94a7764b9aa..7eb82a7a90a8c61f3e943ac851b4a0c4e64dccf6 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPeUserInfoAttach.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPeUserInfoAttach.cc
@@ -1,68 +1,52 @@
 // $Id: $
-// Include files 
-
-
+// Include files
 
 // local
-#include "RichTbUserTrackInfo.hh"
 #include "RichTbPeUserInfoAttach.hh"
-G4Track*  RichTbPeInfoAttach( const G4Track& aPhotonTk, G4Track* aPETk,
-   G4ThreeVector aPeOriginInPhSup) 
-{
-   G4VUserTrackInformation* aTkInfo=aPhotonTk.GetUserInformation();
-   RichTbUserTrackInfo* curPhotTrackUserInfo=
-                  (RichTbUserTrackInfo*)  aTkInfo;
-
-   G4ThreeVector CurPhotonOrigin = aPhotonTk.GetVertexPosition();
-   G4ThreeVector CurPhotonEmisDir = aPhotonTk.GetVertexMomentumDirection();
-   RichTbPEInfo* aRichTbPEInfo =new RichTbPEInfo();
-   
-   if(curPhotTrackUserInfo && curPhotTrackUserInfo->HasUserPhotonInfo() ) {
-       RichTbPhotonInfo* aRichTbPhotonInfo = 
-         curPhotTrackUserInfo->getRichTbPhotonInfo();
-   aRichTbPEInfo-> setPhOrigin(CurPhotonOrigin);
-   aRichTbPEInfo-> setPhotEmisDir(CurPhotonEmisDir);
-   aRichTbPEInfo->setMotherPhotonInfo(aRichTbPhotonInfo);
-   aRichTbPEInfo->setPeOriginInHpdSupFrame(aPeOriginInPhSup);
-   
+#include "RichTbUserTrackInfo.hh"
+G4Track *RichTbPeInfoAttach(const G4Track &aPhotonTk, G4Track *aPETk, G4ThreeVector aPeOriginInPhSup) {
+  G4VUserTrackInformation *aTkInfo = aPhotonTk.GetUserInformation();
+  RichTbUserTrackInfo *curPhotTrackUserInfo = (RichTbUserTrackInfo *)aTkInfo;
+
+  G4ThreeVector CurPhotonOrigin = aPhotonTk.GetVertexPosition();
+  G4ThreeVector CurPhotonEmisDir = aPhotonTk.GetVertexMomentumDirection();
+  RichTbPEInfo *aRichTbPEInfo = new RichTbPEInfo();
+
+  if (curPhotTrackUserInfo && curPhotTrackUserInfo->HasUserPhotonInfo()) {
+    RichTbPhotonInfo *aRichTbPhotonInfo = curPhotTrackUserInfo->getRichTbPhotonInfo();
+    aRichTbPEInfo->setPhOrigin(CurPhotonOrigin);
+    aRichTbPEInfo->setPhotEmisDir(CurPhotonEmisDir);
+    aRichTbPEInfo->setMotherPhotonInfo(aRichTbPhotonInfo);
+    aRichTbPEInfo->setPeOriginInHpdSupFrame(aPeOriginInPhSup);
   }
 
-   RichTbUserTrackInfo* curPeTrackUserInfo=
-     new  RichTbUserTrackInfo( aRichTbPEInfo);
-   
-   aPETk->SetUserInformation(curPeTrackUserInfo);
-   
-   return  aPETk;
-   
+  RichTbUserTrackInfo *curPeTrackUserInfo = new RichTbUserTrackInfo(aRichTbPEInfo);
+
+  aPETk->SetUserInformation(curPeTrackUserInfo);
+
+  return aPETk;
 }
 
-G4Track* RichTbPeBckAttach( const G4Track& aPhotonTk, G4Track* aSecPETrack ) {
-  
-   G4VUserTrackInformation* aTkInfo=aPhotonTk.GetUserInformation();
-   RichTbUserTrackInfo* curPhotTrackUserInfo=
-                  (RichTbUserTrackInfo*)  aTkInfo;
+G4Track *RichTbPeBckAttach(const G4Track &aPhotonTk, G4Track *aSecPETrack) {
 
-   G4ThreeVector CurPhotonOrigin = aPhotonTk.GetVertexPosition();
-   G4ThreeVector CurPhotonEmisDir = aPhotonTk.GetVertexMomentumDirection();
-   RichTbPEInfo* aRichTbPEInfo =new RichTbPEInfo();
-   
-   if(curPhotTrackUserInfo && curPhotTrackUserInfo->HasUserPhotonInfo() ) {
-       RichTbPhotonInfo* aRichTbPhotonInfo = 
-         curPhotTrackUserInfo->getRichTbPhotonInfo();
-   aRichTbPEInfo-> setPhOrigin(CurPhotonOrigin);
-   aRichTbPEInfo-> setPhotEmisDir(CurPhotonEmisDir);
-   aRichTbPEInfo->setMotherPhotonInfo(aRichTbPhotonInfo);
-   //aRichTbPEInfo->setPeOriginInHpdSupFrame(aPeOriginInPhSup);
-   
-  }
+  G4VUserTrackInformation *aTkInfo = aPhotonTk.GetUserInformation();
+  RichTbUserTrackInfo *curPhotTrackUserInfo = (RichTbUserTrackInfo *)aTkInfo;
 
-   RichTbUserTrackInfo* curPeTrackUserInfo=
-     new  RichTbUserTrackInfo( aRichTbPEInfo);
-   
-   aSecPETrack ->SetUserInformation(curPeTrackUserInfo);
-   
-   return  aSecPETrack ;
+  G4ThreeVector CurPhotonOrigin = aPhotonTk.GetVertexPosition();
+  G4ThreeVector CurPhotonEmisDir = aPhotonTk.GetVertexMomentumDirection();
+  RichTbPEInfo *aRichTbPEInfo = new RichTbPEInfo();
+
+  if (curPhotTrackUserInfo && curPhotTrackUserInfo->HasUserPhotonInfo()) {
+    RichTbPhotonInfo *aRichTbPhotonInfo = curPhotTrackUserInfo->getRichTbPhotonInfo();
+    aRichTbPEInfo->setPhOrigin(CurPhotonOrigin);
+    aRichTbPEInfo->setPhotEmisDir(CurPhotonEmisDir);
+    aRichTbPEInfo->setMotherPhotonInfo(aRichTbPhotonInfo);
+    // aRichTbPEInfo->setPeOriginInHpdSupFrame(aPeOriginInPhSup);
+  }
 
+  RichTbUserTrackInfo *curPeTrackUserInfo = new RichTbUserTrackInfo(aRichTbPEInfo);
 
+  aSecPETrack->SetUserInformation(curPeTrackUserInfo);
 
+  return aSecPETrack;
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPhotonInfo.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPhotonInfo.cc
index 90e78a8be6c1b11790f8b668dc11211efe64745a..1f1fae81e894bef5898c22d49189db1124238e9a 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPhotonInfo.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPhotonInfo.cc
@@ -1,7 +1,5 @@
 // $Id: $
-// Include files 
-
-
+// Include files
 
 // local
 #include "RichTbPhotonInfo.hh"
@@ -15,19 +13,11 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbPhotonInfo::RichTbPhotonInfo(  ): mNumRayleighScat(0),
-                                        mPhotonCoordPMTQWExternal(0),
-                                        mPhotonPMTQWMultipleIncidenceFlag(0),
-                                        mCkvCosThetaAtProd(0.0),
-                                        mCkvPhiAtProd(-10.0),
-                                        mCkvPhotonEnergyAtProd(-1.0),
-                                        mParentChTrackMomentum(0.0),
-                                        mParentChTrackThreeMom(0),
-                                        mPhotonCrystalDnsTIRCoord(0),
-                                        mPhotonSphMirrReflCoord(0),
-                                        mPhotonCrystalDnsExitCoord(0),
-                                        mPhotonRadiatorMultipleIncidenceFlag(0)  
- {}
+RichTbPhotonInfo::RichTbPhotonInfo()
+    : mNumRayleighScat(0), mPhotonCoordPMTQWExternal(0), mPhotonPMTQWMultipleIncidenceFlag(0), mCkvCosThetaAtProd(0.0),
+      mCkvPhiAtProd(-10.0), mCkvPhotonEnergyAtProd(-1.0), mParentChTrackMomentum(0.0), mParentChTrackThreeMom(0),
+      mPhotonCrystalDnsTIRCoord(0), mPhotonSphMirrReflCoord(0), mPhotonCrystalDnsExitCoord(0),
+      mPhotonRadiatorMultipleIncidenceFlag(0) {}
 //=============================================================================
 // Destructor
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPhotonProdHisto.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPhotonProdHisto.cc
index 7a89f7f8540c385f55f3dc0bfe90dcb0140c256e..bed52c5c31a0cebf554ce3f6a62a6a6a64a81908 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPhotonProdHisto.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPhotonProdHisto.cc
@@ -1,69 +1,57 @@
-#include "RichTbAnalysisManager.hh"
-#include "RichTbMaterialParameters.hh"
 #include "RichTbPhotonProdHisto.hh"
-#include "RichTbGeometryParameters.hh"
+#include "RichTbAnalysisManager.hh"
 #include "RichTbCounter.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMaterialParameters.hh"
 
-
-void  RichTbPhotonProductionHisto (const  G4Track& /* aChTrack */,
-                                    const G4Track* aPhotTrack,
-                                   const G4double /* CkvCosTh */, 
-                                   const G4double /* CkvPhi */,
-                                        const G4double  CkvPhEner) {
-
+void RichTbPhotonProductionHisto(const G4Track & /* aChTrack */, const G4Track *aPhotTrack,
+                                 const G4double /* CkvCosTh */, const G4double /* CkvPhi */, const G4double CkvPhEner) {
 
   //  G4cout<<"begin RichTbPhotonProductionHisto "<<G4endl;
-  
-  //RichTbAnalysisManager* rAnalysisPhy=RichTbAnalysisManager::getInstance();
+
+  // RichTbAnalysisManager* rAnalysisPhy=RichTbAnalysisManager::getInstance();
   //  RichTbCounter* rCounter = RichTbCounter::getRichTbCounterInstance();
 
   // G4double PhotWLength=0.0;
   //  G4double PhotWLengthNano=0.0;
-  
-  if(  CkvPhEner != 0.0 ) {
-    
+
+  if (CkvPhEner != 0.0) {
+
     // PhotWLength=PhotMomToWaveLength/ CkvPhEner ;
-  // PhotWLengthNano =   PhotWLength/(CLHEP::nanometer);
+    // PhotWLengthNano =   PhotWLength/(CLHEP::nanometer);
   }
   // G4double CkvTh = acos( CkvCosTh);
 
- // G4cout<<" RichTbPhotonProductionHisto Photwlen Phener ckvth ckv phi "
- //     <<  PhotWLengthNano<<"  "<< CkvTh<<"  "<<CkvPhi
- //     <<G4endl;
- 
+  // G4cout<<" RichTbPhotonProductionHisto Photwlen Phener ckvth ckv phi "
+  //     <<  PhotWLengthNano<<"  "<< CkvTh<<"  "<<CkvPhi
+  //     <<G4endl;
+
+  // G4String curVolName= aChTrack.GetVolume()->GetName();
+  // G4String curMatName= aChTrack.GetMaterial()->GetName();
+  // G4String curVolFirstPart =
+  //           (curVolName.length() >= 7) ? curVolName(0,7):curVolName;
 
- // G4String curVolName= aChTrack.GetVolume()->GetName();
- // G4String curMatName= aChTrack.GetMaterial()->GetName();
- //G4String curVolFirstPart =
- //           (curVolName.length() >= 7) ? curVolName(0,7):curVolName;
+  //  G4cout<<" RichTbPhotonProductionHisto Cur Vol "
+  //       <<  curVolName <<"  "<<  curVolFirstPart <<G4endl;
 
- //  G4cout<<" RichTbPhotonProductionHisto Cur Vol "
- //       <<  curVolName <<"  "<<  curVolFirstPart <<G4endl;
-  
- G4ThreeVector avPos= aPhotTrack->GetVertexPosition() ;
- // if( avPos.z() >= 0.0  && avPos.z() <= MirrrorNominalPivotZLocationInGlobal ) {
- // rCounter->bumpnumHitTotProd();
-   
- // }
- 
+  G4ThreeVector avPos = aPhotTrack->GetVertexPosition();
+  // if( avPos.z() >= 0.0  && avPos.z() <= MirrrorNominalPivotZLocationInGlobal ) {
+  // rCounter->bumpnumHitTotProd();
 
- //  if( rAnalysisPhy->getfhistoWProduced() ) {
- //    rAnalysisPhy->getfhistoWProduced()->fill( PhotWLengthNano);
- //  }
+  // }
 
+  //  if( rAnalysisPhy->getfhistoWProduced() ) {
+  //    rAnalysisPhy->getfhistoWProduced()->fill( PhotWLengthNano);
+  //  }
 
- //  if( rAnalysisPhy-> getfhistoCkvProdTheta()) {
-    
- //   rAnalysisPhy-> getfhistoCkvProdTheta()->fill( CkvTh );
- //  }
+  //  if( rAnalysisPhy-> getfhistoCkvProdTheta()) {
 
-      
- //  if(rAnalysisPhy-> getfhistoCkvProdPhi () ){//
- //	rAnalysisPhy-> getfhistoCkvProdPhi ()->fill(CkvPhi);
- // }
+  //   rAnalysisPhy-> getfhistoCkvProdTheta()->fill( CkvTh );
+  //  }
 
- 
+  //  if(rAnalysisPhy-> getfhistoCkvProdPhi () ){//
+  //	rAnalysisPhy-> getfhistoCkvProdPhi ()->fill(CkvPhi);
+  // }
 
   //  G4cout<<"end RichTbPhotonProductionHisto "<<G4endl;
-     
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPhotonUserInfoAttach.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPhotonUserInfoAttach.cc
index bf072112502a41de7f47fb466763ec854437a6fa..acc29064f78384d5d5677e541a350757b9d2554f 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPhotonUserInfoAttach.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPhotonUserInfoAttach.cc
@@ -1,131 +1,100 @@
 
-#include "RichTbPhotonInfo.hh"
+#include "RichTbPhotonUserInfoAttach.hh"
 #include "Geant4/globals.hh"
+#include "RichTbPhotonInfo.hh"
 #include "RichTbUserTrackInfo.hh"
-#include "RichTbPhotonUserInfoAttach.hh"
 
-void RichTbPMTQWIncidenceInfoAttach(G4Track* aPhTrack, G4ThreeVector aQWPos) 
-{
-  G4VUserTrackInformation* aUserTrackInfo = aPhTrack->GetUserInformation();
-  
-  RichTbUserTrackInfo* aRichTbUserTrackInfoPhoton =
-    (RichTbUserTrackInfo * ) aUserTrackInfo;
-
-  // G4cout << "in RichTbPMTQW...\t" << aUserTrackInfo 
-// 	 << "\t" << aRichTbUserTrackInfoPhoton<< G4endl;
- 
-  if(aRichTbUserTrackInfoPhoton) 
-    {
-      if(aRichTbUserTrackInfoPhoton->HasUserPhotonInfo() ) 
-	{
-	  RichTbPhotonInfo* aRichTbPhotonInfo = 
-	    aRichTbUserTrackInfoPhoton->getRichTbPhotonInfo();
-	  
-	  if( aRichTbPhotonInfo ) 
-	    {
-	      
-	      aRichTbPhotonInfo->setPhotonCoordPMTQWExternal(aQWPos);
-	      //G4cout << "Setting HPDQuartz ipmact vector" << G4endl;
-	      aRichTbPhotonInfo->BumpPhotonPMTQWMultipleIncidenceFlag();
-	      
-	    }
-	}
-    }   
+void RichTbPMTQWIncidenceInfoAttach(G4Track *aPhTrack, G4ThreeVector aQWPos) {
+  G4VUserTrackInformation *aUserTrackInfo = aPhTrack->GetUserInformation();
+
+  RichTbUserTrackInfo *aRichTbUserTrackInfoPhoton = (RichTbUserTrackInfo *)aUserTrackInfo;
+
+  // G4cout << "in RichTbPMTQW...\t" << aUserTrackInfo
+  // 	 << "\t" << aRichTbUserTrackInfoPhoton<< G4endl;
+
+  if (aRichTbUserTrackInfoPhoton) {
+    if (aRichTbUserTrackInfoPhoton->HasUserPhotonInfo()) {
+      RichTbPhotonInfo *aRichTbPhotonInfo = aRichTbUserTrackInfoPhoton->getRichTbPhotonInfo();
+
+      if (aRichTbPhotonInfo) {
+
+        aRichTbPhotonInfo->setPhotonCoordPMTQWExternal(aQWPos);
+        // G4cout << "Setting HPDQuartz ipmact vector" << G4endl;
+        aRichTbPhotonInfo->BumpPhotonPMTQWMultipleIncidenceFlag();
+      }
+    }
+  }
 }
 
-void RichTbRadiatorBoundaryInfoAttach(G4Track* aPhTrack, G4ThreeVector aBoundaryPos, G4int RFROption ){
-  
+void RichTbRadiatorBoundaryInfoAttach(G4Track *aPhTrack, G4ThreeVector aBoundaryPos, G4int RFROption) {
+
   //  RFROption = 0 means total internal reflection happened at this boundary
   //   RFROption = 1 means normal refraction happened at this boundary.
   //    RFROption = 2 means normal reflection happend at this boundary  (mirror reflection)
 
   //   For nominal signal photons the MultipleIncidenceFlag is bumped three times so that its value=3
 
+  G4VUserTrackInformation *aUserTrackInfo = aPhTrack->GetUserInformation();
 
-  G4VUserTrackInformation* aUserTrackInfo = aPhTrack->GetUserInformation();
-  
-  RichTbUserTrackInfo* aRichTbUserTrackInfoPhoton =
-    (RichTbUserTrackInfo * ) aUserTrackInfo;
-
-  // G4cout << "in RichTbTIR...\t" << aUserTrackInfo 
-// 	 << "\t" << aRichTbUserTrackInfoPhoton<< G4endl;
- 
-  if(aRichTbUserTrackInfoPhoton) 
-    {
-      if(aRichTbUserTrackInfoPhoton->HasUserPhotonInfo() ){
-	  RichTbPhotonInfo* aRichTbPhotonInfo = 
-	    aRichTbUserTrackInfoPhoton->getRichTbPhotonInfo();
-	  
-	  if( aRichTbPhotonInfo ){
-      if( RFROption == 0 ){
-	      aRichTbPhotonInfo->setPhotonCrystalDnsTIRCoord(aBoundaryPos);
-      }else if (RFROption == 1 ) {
-	      aRichTbPhotonInfo-> setPhotonCrystalDnsExitCoord (aBoundaryPos);
-      } else if ( RFROption == 2 ) {
-        aRichTbPhotonInfo-> setPhotonSphMirrReflCoord(aBoundaryPos);
-      }
-      
-	      aRichTbPhotonInfo->BumpPhotonRadiatorMultipleIncidenceFlag();      
-        //G4cout<<" RichTbPhotinfo attach RFR option  flag "<< RFROption <<"  "
-        //      <<aRichTbPhotonInfo->PhotonRadiatorMultipleIncidenceFlag()<<G4endl;
-        
-	    }
-    
-      } 
-      
-    } 
+  RichTbUserTrackInfo *aRichTbUserTrackInfoPhoton = (RichTbUserTrackInfo *)aUserTrackInfo;
+
+  // G4cout << "in RichTbTIR...\t" << aUserTrackInfo
+  // 	 << "\t" << aRichTbUserTrackInfoPhoton<< G4endl;
+
+  if (aRichTbUserTrackInfoPhoton) {
+    if (aRichTbUserTrackInfoPhoton->HasUserPhotonInfo()) {
+      RichTbPhotonInfo *aRichTbPhotonInfo = aRichTbUserTrackInfoPhoton->getRichTbPhotonInfo();
+
+      if (aRichTbPhotonInfo) {
+        if (RFROption == 0) {
+          aRichTbPhotonInfo->setPhotonCrystalDnsTIRCoord(aBoundaryPos);
+        } else if (RFROption == 1) {
+          aRichTbPhotonInfo->setPhotonCrystalDnsExitCoord(aBoundaryPos);
+        } else if (RFROption == 2) {
+          aRichTbPhotonInfo->setPhotonSphMirrReflCoord(aBoundaryPos);
+        }
 
+        aRichTbPhotonInfo->BumpPhotonRadiatorMultipleIncidenceFlag();
+        // G4cout<<" RichTbPhotinfo attach RFR option  flag "<< RFROption <<"  "
+        //      <<aRichTbPhotonInfo->PhotonRadiatorMultipleIncidenceFlag()<<G4endl;
+      }
+    }
+  }
 }
 
+void RichTbRayleighInfoAttach(const G4Track &aPhotonTrack) {
+
+  G4VUserTrackInformation *aUserTrackInfo = aPhotonTrack.GetUserInformation();
+  RichTbUserTrackInfo *aRichTbUserTrackInfoPhoton = (RichTbUserTrackInfo *)aUserTrackInfo;
 
+  if (aRichTbUserTrackInfoPhoton) {
 
-void RichTbRayleighInfoAttach (const G4Track& aPhotonTrack) 
-{
-
-   G4VUserTrackInformation* aUserTrackInfo=aPhotonTrack.GetUserInformation();
-   RichTbUserTrackInfo* aRichTbUserTrackInfoPhoton =
-     (RichTbUserTrackInfo * ) aUserTrackInfo;
-   
-   if(aRichTbUserTrackInfoPhoton) {
-
-     if(aRichTbUserTrackInfoPhoton->HasUserPhotonInfo() ) {
-       RichTbPhotonInfo* aRichTbPhotonInfo = 
-         aRichTbUserTrackInfoPhoton->getRichTbPhotonInfo();
-       
-       if( aRichTbPhotonInfo ) {
-         aRichTbPhotonInfo-> BumpNumRaylieghScat();
-         
-       }       
-       
-     }
-     
-     
-   }   
-   
+    if (aRichTbUserTrackInfoPhoton->HasUserPhotonInfo()) {
+      RichTbPhotonInfo *aRichTbPhotonInfo = aRichTbUserTrackInfoPhoton->getRichTbPhotonInfo();
+
+      if (aRichTbPhotonInfo) {
+        aRichTbPhotonInfo->BumpNumRaylieghScat();
+      }
+    }
+  }
 }
 
-G4Track* RichTbCkvProdInfoAttach(const G4Track& aChTrack,
-                                    G4Track* aPhotTrack,
-                                    const G4double CkvCosTheta,
-                                    const G4double CkvPhi,
-                             const G4double CkvPhotEnergy)
-{
-  //const G4DynamicParticle* aChTrackParticle 
-  //             = aChTrack.GetDynamicParticle(); 
-  
-  RichTbPhotonInfo* aRichTbPhotonInfo = new RichTbPhotonInfo();
-  aRichTbPhotonInfo-> setCkvCosThetaAtProd(CkvCosTheta);
-  aRichTbPhotonInfo->  setCkvPhiAtProd( CkvPhi);
-  aRichTbPhotonInfo->   setCkvPhotonEnergyAtProd(CkvPhotEnergy);
-  aRichTbPhotonInfo-> setParentChTrackMomentum(aChTrack.GetDynamicParticle()-> GetTotalMomentum());
-  aRichTbPhotonInfo-> setParentChTrackThreeMom(aChTrack.GetMomentum());
-  RichTbUserTrackInfo* aRichTbUserTrackInfo =
-     new RichTbUserTrackInfo(aRichTbPhotonInfo );
-   aPhotTrack->SetUserInformation( aRichTbUserTrackInfo);
-
-   
-   //  G4double Lambda = 1243.125*(CLHEP::nanometer*CLHEP::eV)/CkvPhotEnergy*1000000;
-   //   G4cout<<" CkvprodInfoAttach Lambda Photonenergy "
-   //     <<Lambda<<"   "<<CkvPhotEnergy<<G4endl;
-   return  aPhotTrack;
+G4Track *RichTbCkvProdInfoAttach(const G4Track &aChTrack, G4Track *aPhotTrack, const G4double CkvCosTheta,
+                                 const G4double CkvPhi, const G4double CkvPhotEnergy) {
+  // const G4DynamicParticle* aChTrackParticle
+  //             = aChTrack.GetDynamicParticle();
+
+  RichTbPhotonInfo *aRichTbPhotonInfo = new RichTbPhotonInfo();
+  aRichTbPhotonInfo->setCkvCosThetaAtProd(CkvCosTheta);
+  aRichTbPhotonInfo->setCkvPhiAtProd(CkvPhi);
+  aRichTbPhotonInfo->setCkvPhotonEnergyAtProd(CkvPhotEnergy);
+  aRichTbPhotonInfo->setParentChTrackMomentum(aChTrack.GetDynamicParticle()->GetTotalMomentum());
+  aRichTbPhotonInfo->setParentChTrackThreeMom(aChTrack.GetMomentum());
+  RichTbUserTrackInfo *aRichTbUserTrackInfo = new RichTbUserTrackInfo(aRichTbPhotonInfo);
+  aPhotTrack->SetUserInformation(aRichTbUserTrackInfo);
+
+  //  G4double Lambda = 1243.125*(CLHEP::nanometer*CLHEP::eV)/CkvPhotEnergy*1000000;
+  //   G4cout<<" CkvprodInfoAttach Lambda Photonenergy "
+  //     <<Lambda<<"   "<<CkvPhotEnergy<<G4endl;
+  return aPhotTrack;
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPmtSteppingAction.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPmtSteppingAction.cc
index 081886d29a9123835b3b654e0d21e1478c50e858..6df6462a5ad418bf86a165d7b1d98a277dc03767 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPmtSteppingAction.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbPmtSteppingAction.cc
@@ -1,319 +1,274 @@
-#include "Geant4/globals.hh"
-#include <cmath>
 #include "RichTbPmtSteppingAction.hh"
-#include "RichTbAnalysisManager.hh"
-#include "RichTbMaterial.hh"
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMaterialParameters.hh"
-#include "RichTbRunConfig.hh"
-#include "RichTbPrimaryGeneratorAction.hh"
-#include "Geant4/G4ParticleDefinition.hh"
 #include "Geant4/G4DynamicParticle.hh"
-#include "Geant4/G4Material.hh"
-#include "Geant4/G4Step.hh"
-#include "Geant4/G4Track.hh"
 #include "Geant4/G4Electron.hh"
-#include "Geant4/G4ThreeVector.hh"
+#include "Geant4/G4Material.hh"
+#include "Geant4/G4Navigator.hh"
 #include "Geant4/G4OpticalPhoton.hh"
+#include "Geant4/G4ParticleDefinition.hh"
 #include "Geant4/G4PionMinus.hh"
-#include "RichTbCounter.hh"
-#include "RichTbPhotonUserInfoAttach.hh"
+#include "Geant4/G4Step.hh"
+#include "Geant4/G4ThreeVector.hh"
+#include "Geant4/G4Track.hh"
+#include "Geant4/G4TransportationManager.hh"
+#include "Geant4/globals.hh"
+#include "RichTbAnalysisManager.hh"
 #include "RichTbBeamProperty.hh"
+#include "RichTbCounter.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMaterialParameters.hh"
 #include "RichTbPhotoElectron.hh"
-#include "Geant4/G4Navigator.hh"
-#include "Geant4/G4TransportationManager.hh"
+#include "RichTbPhotonUserInfoAttach.hh"
+#include "RichTbPrimaryGeneratorAction.hh"
+#include "RichTbRunConfig.hh"
 #include "RichTbUserTrackInfo.hh"
-#include "Geant4/G4ThreeVector.hh"
-
-
-RichTbPmtSteppingAction::RichTbPmtSteppingAction():mChTrackMinMomFactorForHisto(0.95)
-{ }
-RichTbPmtSteppingAction::~RichTbPmtSteppingAction()
-{
-    ;
-}
-
-void RichTbPmtSteppingAction::UserSteppingAction(const G4Step * aStep) {
+#include <cmath>
 
+RichTbPmtSteppingAction::RichTbPmtSteppingAction() : mChTrackMinMomFactorForHisto(0.95) {}
+RichTbPmtSteppingAction::~RichTbPmtSteppingAction() { ; }
 
+void RichTbPmtSteppingAction::UserSteppingAction(const G4Step *aStep) {
 
   // RichTbAnalysisManager* aRAnalysisManager = RichTbAnalysisManager::getInstance();
-  RichTbRunConfig* aRunConfig =   RichTbRunConfig::getRunConfigInstance();
-  G4StepPoint* pPreStepPoint  = aStep ->GetPreStepPoint();
-  G4StepPoint* pPostStepPoint = aStep ->GetPostStepPoint();
-  const G4ThreeVector prePos= pPreStepPoint->GetPosition();
-  const G4ThreeVector postPos= pPostStepPoint->GetPosition();
-    RichTbAnalysisManager * myanalysisManager =
-           RichTbAnalysisManager::getInstance();
-
-
-    // G4Track* aTrack = aStep -> GetTrack();
-    // const G4DynamicParticle* aParticle = aTrack->GetDynamicParticle();
-    // const G4double aTrackEnergy = aParticle->GetKineticEnergy();
-
-    /*
-   //check for phelectron
-    if( aParticle->GetDefinition() == RichTbPhotoElectron::PhotoElectron()) {
-      // G4cout<<" electron! " <<G4endl;
-   if( aTrackEnergy > 0.0 )
-	    {
-
-	 // check prestep and post are valid physical volume
-	      if( pPreStepPoint -> GetPhysicalVolume() &&
-		  pPostStepPoint -> GetPhysicalVolume() ) {
-
-		  G4String tpreVol = pPreStepPoint -> GetPhysicalVolume()->GetName();
-		  G4String tpostVol = pPostStepPoint -> GetPhysicalVolume()->GetName();
-
-		    G4cout<<" pre post stepvol names "<< tpreVol << "    "<<
-		      tpostVol <<G4endl;
-	      }
-	    }
-    }
-
-    */
+  RichTbRunConfig *aRunConfig = RichTbRunConfig::getRunConfigInstance();
+  G4StepPoint *pPreStepPoint = aStep->GetPreStepPoint();
+  G4StepPoint *pPostStepPoint = aStep->GetPostStepPoint();
+  const G4ThreeVector prePos = pPreStepPoint->GetPosition();
+  const G4ThreeVector postPos = pPostStepPoint->GetPosition();
+  RichTbAnalysisManager *myanalysisManager = RichTbAnalysisManager::getInstance();
+
+  // G4Track* aTrack = aStep -> GetTrack();
+  // const G4DynamicParticle* aParticle = aTrack->GetDynamicParticle();
+  // const G4double aTrackEnergy = aParticle->GetKineticEnergy();
+
+  /*
+ //check for phelectron
+  if( aParticle->GetDefinition() == RichTbPhotoElectron::PhotoElectron()) {
+    // G4cout<<" electron! " <<G4endl;
+ if( aTrackEnergy > 0.0 )
+          {
+
+       // check prestep and post are valid physical volume
+            if( pPreStepPoint -> GetPhysicalVolume() &&
+                pPostStepPoint -> GetPhysicalVolume() ) {
+
+                G4String tpreVol = pPreStepPoint -> GetPhysicalVolume()->GetName();
+                G4String tpostVol = pPostStepPoint -> GetPhysicalVolume()->GetName();
+
+                  G4cout<<" pre post stepvol names "<< tpreVol << "    "<<
+                    tpostVol <<G4endl;
+            }
+          }
+  }
 
+  */
 
   // check photon presetp inside the vessel
-   if( (prePos.z()< RichTbVesselDnsZEnd ) &&
-      (prePos.x()< RichTbVesselXPosExtreme &&
-       prePos.x() > RichTbVesselXNegExtreme ) &&
-      (prePos.y() <  RichTbVesselYPosExtreme &&
-       prePos.y() >  RichTbVesselYNegExtreme) )
-
-     {
-       // check photon at a geometrical boundary
-       if (pPostStepPoint->GetStepStatus() == fGeomBoundary) {
-
-	  G4Track* aTrack = aStep -> GetTrack();
-	  const G4DynamicParticle* aParticle = aTrack->GetDynamicParticle();
-	  const G4double aTrackEnergy = aParticle->GetKineticEnergy();
-
-	  // test for photons which are not already killed.
-
-	  if( (aParticle->GetDefinition() == G4OpticalPhoton::OpticalPhoton()) &&
-	      (  aTrackEnergy > 0.0 ))
-	    {
-
-	 // check prestep and post are valid physical volume
-	      if( pPreStepPoint -> GetPhysicalVolume() &&
-		  pPostStepPoint -> GetPhysicalVolume() ) {
-
-		  G4String tpreVol = pPreStepPoint -> GetPhysicalVolume()->GetName();
-		  G4String tpostVol = pPostStepPoint -> GetPhysicalVolume()->GetName();
+  if ((prePos.z() < RichTbVesselDnsZEnd) &&
+      (prePos.x() < RichTbVesselXPosExtreme && prePos.x() > RichTbVesselXNegExtreme) &&
+      (prePos.y() < RichTbVesselYPosExtreme && prePos.y() > RichTbVesselYNegExtreme))
 
-      //  G4cout<<" pre post stepvol names "<< tpreVol << "    "<<
-		  //    tpostVol <<G4endl;
+  {
+    // check photon at a geometrical boundary
+    if (pPostStepPoint->GetStepStatus() == fGeomBoundary) {
 
-		  if((tpreVol == CrystalMasterPhysName) &&
-         ((tpostVol == PhDetSupPhysNameLeft) || (tpostVol == PhDetSupPhysNameRight)
-        		 || (tpostVol == PhDetSupPhysNameBottomLeft)) || (tpostVol == PhDetSupPhysNameBottomRight)) {
+      G4Track *aTrack = aStep->GetTrack();
+      const G4DynamicParticle *aParticle = aTrack->GetDynamicParticle();
+      const G4double aTrackEnergy = aParticle->GetKineticEnergy();
 
-		    //print photon coordinate at the current step.
-		    // G4cout<<" do something " <<G4endl;
-        //		     G4cout<<"Photon incidence on Photonframe  "<< prePos << "  "<<postPos<<G4endl;
-		    if( myanalysisManager -> getPhotonXCoord()) {
-          // G4cout<<"x coordinate  "<< postPos.x() <<G4endl;
-		      myanalysisManager -> getPhotonXCoord()->Fill( postPos.x());
-		      // G4cout<<"x coordinate  "<< postPos.x() <<G4endl;
-		    }
-		    if( myanalysisManager -> getPhotonYCoord()) {
-		      myanalysisManager -> getPhotonYCoord()->Fill( postPos.y());
-          // G4cout<<"Y coordinate  "<< postPos.y() <<G4endl;
-		    }
+      // test for photons which are not already killed.
 
-		    if( myanalysisManager -> getPhotonZCoord()) {
-		      myanalysisManager -> getPhotonZCoord()->Fill( postPos.z());
-          //  G4cout<<"z coordinate  "<< postPos.z() <<G4endl;
-		    }
+      if ((aParticle->GetDefinition() == G4OpticalPhoton::OpticalPhoton()) && (aTrackEnergy > 0.0)) {
 
-		    if( myanalysisManager -> getPhotonXYCoord()) {
-		      myanalysisManager -> getPhotonXYCoord()->Fill(postPos.x(), postPos.y());
-		      //G4cout<<"z coordinate  "<< postPos.z() <<G4endl;
-		    }
-		    if( myanalysisManager -> getPhotonXYCoordProfile()) {
-		      myanalysisManager -> getPhotonXYCoordProfile()->Fill(postPos.y(), postPos.x());
-		    }
+        // check prestep and post are valid physical volume
+        if (pPreStepPoint->GetPhysicalVolume() && pPostStepPoint->GetPhysicalVolume()) {
 
+          G4String tpreVol = pPreStepPoint->GetPhysicalVolume()->GetName();
+          G4String tpostVol = pPostStepPoint->GetPhysicalVolume()->GetName();
 
+          //  G4cout<<" pre post stepvol names "<< tpreVol << "    "<<
+          //    tpostVol <<G4endl;
 
+          if (((tpreVol == CrystalMasterPhysName) &&
+                  ((tpostVol == PhDetSupPhysNameLeft) || (tpostVol == PhDetSupPhysNameRight) ||
+                   (tpostVol == PhDetSupPhysNameBottomLeft))) ||
+              (tpostVol == PhDetSupPhysNameBottomRight)) {
 
+            // print photon coordinate at the current step.
+            // G4cout<<" do something " <<G4endl;
+            //		     G4cout<<"Photon incidence on Photonframe  "<< prePos << "  "<<postPos<<G4endl;
+            if (myanalysisManager->getPhotonXCoord()) {
+              // G4cout<<"x coordinate  "<< postPos.x() <<G4endl;
+              myanalysisManager->getPhotonXCoord()->Fill(postPos.x());
+              // G4cout<<"x coordinate  "<< postPos.x() <<G4endl;
+            }
+            if (myanalysisManager->getPhotonYCoord()) {
+              myanalysisManager->getPhotonYCoord()->Fill(postPos.y());
+              // G4cout<<"Y coordinate  "<< postPos.y() <<G4endl;
+            }
 
-		      if(postPos.y()>-30.0 && postPos.y()< +30.0){
-		       	if((postPos.x()>-60.0 && postPos.x()< -20.0) || (postPos.x()<60.0 && postPos.x()> 20.0)){
-		         	double y = postPos.y() - 0.0;
-	        		double x = postPos.x() + 0.0;
-		        	double radius = sqrt(y*y + x*x);
-              double emisptZ= aTrack->GetVertexPosition().z();
-
-		         	myanalysisManager -> getPhotonWidthProfile()->Fill(radius);
-             	if(myanalysisManager -> getfCkvRadiusVsEmisPtPhoton())
-                 myanalysisManager -> getfCkvRadiusVsEmisPtPhoton()->Fill( emisptZ, radius);
-              if(myanalysisManager ->getfEmisPtPhoton())
-                myanalysisManager ->getfEmisPtPhoton()->Fill(emisptZ);
-
-               G4VUserTrackInformation* aTkInfo=aTrack->GetUserInformation();
-               RichTbUserTrackInfo* curPhotTrackUserInfo= (RichTbUserTrackInfo*)  aTkInfo;
-               if(curPhotTrackUserInfo && curPhotTrackUserInfo->HasUserPhotonInfo() ) {
-                RichTbPhotonInfo* aRichTbPhotonInfo =
-                  curPhotTrackUserInfo->getRichTbPhotonInfo();
-                if(aRichTbPhotonInfo) {
-                 G4double aChTrackTotMom = aRichTbPhotonInfo->ParentChTrackMomentum();
-                 G4ThreeVector aPhotTIR =aRichTbPhotonInfo-> PhotonCrystalDnsTIRCoord();
-                 G4ThreeVector aPhotMIR =aRichTbPhotonInfo-> PhotonSphMirrReflCoord();
-                 G4ThreeVector aPhotRFR =aRichTbPhotonInfo-> PhotonCrystalDnsExitCoord();
-
-                 // G4cout<<" aPhotTIR "<<aPhotTIR <<G4endl;
-
-                 if( aChTrackTotMom > ( mChTrackMinMomFactorForHisto* (aRunConfig-> getRichTbParticleMomentum()))) {
-
-                   if(myanalysisManager ->getfEmisPtPrimaryTrackPhoton())
-                      myanalysisManager ->getfEmisPtPrimaryTrackPhoton()->Fill(emisptZ);
-                   G4double aCkvAtProd = acos(aRichTbPhotonInfo->CkvCosThetaAtProd());
-
-                   if(myanalysisManager ->getfGeneratedCkvPhoton() )
-                     myanalysisManager ->getfGeneratedCkvPhoton() ->Fill(aCkvAtProd);
-                   // G4cout<<" aPhotTIR Fill "<<aPhotTIR <<G4endl;
-
-                   if(myanalysisManager ->getfTIRXYLocationPhoton() )
-                     myanalysisManager ->getfTIRXYLocationPhoton()->Fill (aPhotTIR.x(), aPhotTIR.y() );
-
-                   if(myanalysisManager ->getfMIRXYLocationPhoton() )
-                     myanalysisManager ->getfMIRXYLocationPhoton()->Fill (aPhotMIR.x(), aPhotMIR.y() );
-
-                   if(myanalysisManager ->getfRFRXYLocationPhoton() )
-                     myanalysisManager ->getfRFRXYLocationPhoton()->Fill (aPhotRFR.x(), aPhotRFR.y() );
-
-
+            if (myanalysisManager->getPhotonZCoord()) {
+              myanalysisManager->getPhotonZCoord()->Fill(postPos.z());
+              //  G4cout<<"z coordinate  "<< postPos.z() <<G4endl;
+            }
 
-                 }
+            if (myanalysisManager->getPhotonXYCoord()) {
+              myanalysisManager->getPhotonXYCoord()->Fill(postPos.x(), postPos.y());
+              // G4cout<<"z coordinate  "<< postPos.z() <<G4endl;
+            }
+            if (myanalysisManager->getPhotonXYCoordProfile()) {
+              myanalysisManager->getPhotonXYCoordProfile()->Fill(postPos.y(), postPos.x());
+            }
 
+            if (postPos.y() > -30.0 && postPos.y() < +30.0) {
+              if ((postPos.x() > -60.0 && postPos.x() < -20.0) || (postPos.x() < 60.0 && postPos.x() > 20.0)) {
+                double y = postPos.y() - 0.0;
+                double x = postPos.x() + 0.0;
+                double radius = sqrt(y * y + x * x);
+                double emisptZ = aTrack->GetVertexPosition().z();
+
+                myanalysisManager->getPhotonWidthProfile()->Fill(radius);
+                if (myanalysisManager->getfCkvRadiusVsEmisPtPhoton())
+                  myanalysisManager->getfCkvRadiusVsEmisPtPhoton()->Fill(emisptZ, radius);
+                if (myanalysisManager->getfEmisPtPhoton())
+                  myanalysisManager->getfEmisPtPhoton()->Fill(emisptZ);
+
+                G4VUserTrackInformation *aTkInfo = aTrack->GetUserInformation();
+                RichTbUserTrackInfo *curPhotTrackUserInfo = (RichTbUserTrackInfo *)aTkInfo;
+                if (curPhotTrackUserInfo && curPhotTrackUserInfo->HasUserPhotonInfo()) {
+                  RichTbPhotonInfo *aRichTbPhotonInfo = curPhotTrackUserInfo->getRichTbPhotonInfo();
+                  if (aRichTbPhotonInfo) {
+                    G4double aChTrackTotMom = aRichTbPhotonInfo->ParentChTrackMomentum();
+                    G4ThreeVector aPhotTIR = aRichTbPhotonInfo->PhotonCrystalDnsTIRCoord();
+                    G4ThreeVector aPhotMIR = aRichTbPhotonInfo->PhotonSphMirrReflCoord();
+                    G4ThreeVector aPhotRFR = aRichTbPhotonInfo->PhotonCrystalDnsExitCoord();
+
+                    // G4cout<<" aPhotTIR "<<aPhotTIR <<G4endl;
+
+                    if (aChTrackTotMom > (mChTrackMinMomFactorForHisto * (aRunConfig->getRichTbParticleMomentum()))) {
+
+                      if (myanalysisManager->getfEmisPtPrimaryTrackPhoton())
+                        myanalysisManager->getfEmisPtPrimaryTrackPhoton()->Fill(emisptZ);
+                      G4double aCkvAtProd = acos(aRichTbPhotonInfo->CkvCosThetaAtProd());
+
+                      if (myanalysisManager->getfGeneratedCkvPhoton())
+                        myanalysisManager->getfGeneratedCkvPhoton()->Fill(aCkvAtProd);
+                      // G4cout<<" aPhotTIR Fill "<<aPhotTIR <<G4endl;
+
+                      if (myanalysisManager->getfTIRXYLocationPhoton())
+                        myanalysisManager->getfTIRXYLocationPhoton()->Fill(aPhotTIR.x(), aPhotTIR.y());
+
+                      if (myanalysisManager->getfMIRXYLocationPhoton())
+                        myanalysisManager->getfMIRXYLocationPhoton()->Fill(aPhotMIR.x(), aPhotMIR.y());
+
+                      if (myanalysisManager->getfRFRXYLocationPhoton())
+                        myanalysisManager->getfRFRXYLocationPhoton()->Fill(aPhotRFR.x(), aPhotRFR.y());
+                    }
+                  }
                 }
-
-
-               }
-
-
+              }
             }
-
-
-		      }
-
-		    }
-
-
+          }
         }
       }
-       }
-     }
-
-
-
-
-
-
-
-        /*
-		    //angle on frame
-		    const G4ThreeVector CurPhotDir = aTrack ->GetMomentumDirection() ;
-		    G4cout<<" Photon direction "<< CurPhotDir <<G4endl;
-		    G4double IncidenceAngle = asin(-CurPhotDir.x()/sqrt( CurPhotDir.x()*CurPhotDir.x() +
-						       CurPhotDir.z()*CurPhotDir.z()));
-		    if( myanalysisManager -> getPhotonZAngle()) {
-		      myanalysisManager -> getPhotonZAngle()->Fill( IncidenceAngle);
-		    }
-		    G4double TiltAngle = - aRunConfig->getSpecialStudyCrystalRotationY();
-		    G4double CherenkovAngle = asin( sin( IncidenceAngle - TiltAngle )/1.5) + TiltAngle;
-		    G4cout<<"Cherenkov angle  "<<CherenkovAngle <<G4endl;
-		    if( myanalysisManager -> getCherenkovAngle()) {
-		      myanalysisManager -> getCherenkovAngle()->Fill(CherenkovAngle);
-		    }
-
-		    //radius as a function of lambda
-		    const G4ThreeVector CurPhotMom = aTrack ->GetMomentum() ;
-
-		    G4double Energy = sqrt( CurPhotMom.x()*CurPhotMom.x() + CurPhotMom.y()*CurPhotMom.y() +
-						       CurPhotMom.z()*CurPhotMom.z());
-		    G4double Lambda = 1243.125*(CLHEP::nanometer*CLHEP::eV)/Energy*1000000;
-		    G4cout<<"Energy  "<< Energy <<G4endl;
-		    G4cout<<"Lambda  "<< Lambda <<G4endl;
-		    if( myanalysisManager -> getSpectrum()) {
-		      myanalysisManager -> getSpectrum()->Fill(Lambda);
-		    }
-		    if( myanalysisManager -> getRadiusVsWL()) {
-		      if(postPos.y()>-30.0 && postPos.y()< +30.0){
-			if(postPos.x()>-60.0 && postPos.x()< -20.0){
-			double y = postPos.y() - 0.0;
-			double x = postPos.x() + 0.0;
-			double radius = sqrt(y*y + x*x);
-			myanalysisManager -> getRadiusVsWL()->Fill(Lambda,radius);
-			if( myanalysisManager -> getRadiusVsWLProfile()) {
-			  myanalysisManager -> getRadiusVsWLProfile()->Fill(Lambda,radius);
-			}
-			}
-		      }
-		    }
-
-
-
-		    //I just keep central hits
-		    if(postPos.y()>-50.0 && postPos.y()< +50.0){
-
-		      if( myanalysisManager -> getPhotonXYCoordProfileCut()) {
-			 myanalysisManager -> getPhotonXYCoordProfileCut()->Fill(postPos.y(), postPos.x());
-		       }
-		      if( myanalysisManager -> getCherenkovAngleCut()) {
-			myanalysisManager -> getCherenkovAngleCut()->Fill(CherenkovAngle);
-		      }
-		    }
-		  }
-		    // check post mirror
-		    if(tpreVol == MirrorPhysName &&
-		       tpostVol == CrystalMasterPhysName ) {
+    }
+  }
+
+  /*
+              //angle on frame
+              const G4ThreeVector CurPhotDir = aTrack ->GetMomentumDirection() ;
+              G4cout<<" Photon direction "<< CurPhotDir <<G4endl;
+              G4double IncidenceAngle = asin(-CurPhotDir.x()/sqrt( CurPhotDir.x()*CurPhotDir.x() +
+                                                 CurPhotDir.z()*CurPhotDir.z()));
+              if( myanalysisManager -> getPhotonZAngle()) {
+                myanalysisManager -> getPhotonZAngle()->Fill( IncidenceAngle);
+              }
+              G4double TiltAngle = - aRunConfig->getSpecialStudyCrystalRotationY();
+              G4double CherenkovAngle = asin( sin( IncidenceAngle - TiltAngle )/1.5) + TiltAngle;
+              G4cout<<"Cherenkov angle  "<<CherenkovAngle <<G4endl;
+              if( myanalysisManager -> getCherenkovAngle()) {
+                myanalysisManager -> getCherenkovAngle()->Fill(CherenkovAngle);
+              }
+
+              //radius as a function of lambda
+              const G4ThreeVector CurPhotMom = aTrack ->GetMomentum() ;
+
+              G4double Energy = sqrt( CurPhotMom.x()*CurPhotMom.x() + CurPhotMom.y()*CurPhotMom.y() +
+                                                 CurPhotMom.z()*CurPhotMom.z());
+              G4double Lambda = 1243.125*(CLHEP::nanometer*CLHEP::eV)/Energy*1000000;
+              G4cout<<"Energy  "<< Energy <<G4endl;
+              G4cout<<"Lambda  "<< Lambda <<G4endl;
+              if( myanalysisManager -> getSpectrum()) {
+                myanalysisManager -> getSpectrum()->Fill(Lambda);
+              }
+              if( myanalysisManager -> getRadiusVsWL()) {
+                if(postPos.y()>-30.0 && postPos.y()< +30.0){
+                  if(postPos.x()>-60.0 && postPos.x()< -20.0){
+                  double y = postPos.y() - 0.0;
+                  double x = postPos.x() + 0.0;
+                  double radius = sqrt(y*y + x*x);
+                  myanalysisManager -> getRadiusVsWL()->Fill(Lambda,radius);
+                  if( myanalysisManager -> getRadiusVsWLProfile()) {
+                    myanalysisManager -> getRadiusVsWLProfile()->Fill(Lambda,radius);
+                  }
+                  }
+                }
+              }
 
 
 
-		      //radius as a function of lambda
-		      const G4ThreeVector CurPhotMom = aTrack ->GetMomentum() ;
+              //I just keep central hits
+              if(postPos.y()>-50.0 && postPos.y()< +50.0){
 
-		      G4double Energy = sqrt( CurPhotMom.x()*CurPhotMom.x() + CurPhotMom.y()*CurPhotMom.y() +
-						       CurPhotMom.z()*CurPhotMom.z());
-		      G4double Lambda = 1243.125*(CLHEP::nanometer*CLHEP::eV)/Energy*1000000;
-		      G4cout<<"Energy post mirror "<< Energy <<G4endl;
-		      G4cout<<"Lambda post mirror "<< Lambda <<G4endl;
-		      if( myanalysisManager -> getSpectrumPostMirror()) {
-			myanalysisManager -> getSpectrumPostMirror()->Fill(Lambda);
-		      }
-		    }
+                if( myanalysisManager -> getPhotonXYCoordProfileCut()) {
+                   myanalysisManager -> getPhotonXYCoordProfileCut()->Fill(postPos.y(), postPos.x());
+                 }
+                if( myanalysisManager -> getCherenkovAngleCut()) {
+                  myanalysisManager -> getCherenkovAngleCut()->Fill(CherenkovAngle);
+                }
+              }
+            }
+              // check post mirror
+              if(tpreVol == MirrorPhysName &&
+                 tpostVol == CrystalMasterPhysName ) {
 
-		   // check pre mirror
-		    if(tpreVol == CrystalMasterPhysName &&
-		       tpostVol == MirrorPhysName ) {
 
 
+                //radius as a function of lambda
+                const G4ThreeVector CurPhotMom = aTrack ->GetMomentum() ;
 
-		      //radius as a function of lambda
-		      const G4ThreeVector CurPhotMom = aTrack ->GetMomentum() ;
+                G4double Energy = sqrt( CurPhotMom.x()*CurPhotMom.x() + CurPhotMom.y()*CurPhotMom.y() +
+                                                 CurPhotMom.z()*CurPhotMom.z());
+                G4double Lambda = 1243.125*(CLHEP::nanometer*CLHEP::eV)/Energy*1000000;
+                G4cout<<"Energy post mirror "<< Energy <<G4endl;
+                G4cout<<"Lambda post mirror "<< Lambda <<G4endl;
+                if( myanalysisManager -> getSpectrumPostMirror()) {
+                  myanalysisManager -> getSpectrumPostMirror()->Fill(Lambda);
+                }
+              }
 
-		      G4double Energy = sqrt( CurPhotMom.x()*CurPhotMom.x() + CurPhotMom.y()*CurPhotMom.y() +
-						       CurPhotMom.z()*CurPhotMom.z());
-		      G4double Lambda = 1243.125*(CLHEP::nanometer*CLHEP::eV)/Energy*1000000;
-		      G4cout<<"Energy pre mirror "<< Energy <<G4endl;
-		      G4cout<<"Lambda pre mirror "<< Lambda <<G4endl;
-		      if( myanalysisManager -> getSpectrumPreMirror()) {
-			myanalysisManager -> getSpectrumPreMirror()->Fill(Lambda);
-		      }
-		    }
+             // check pre mirror
+              if(tpreVol == CrystalMasterPhysName &&
+                 tpostVol == MirrorPhysName ) {
 
 
-		  }
 
-	      }
-        */
+                //radius as a function of lambda
+                const G4ThreeVector CurPhotMom = aTrack ->GetMomentum() ;
 
+                G4double Energy = sqrt( CurPhotMom.x()*CurPhotMom.x() + CurPhotMom.y()*CurPhotMom.y() +
+                                                 CurPhotMom.z()*CurPhotMom.z());
+                G4double Lambda = 1243.125*(CLHEP::nanometer*CLHEP::eV)/Energy*1000000;
+                G4cout<<"Energy pre mirror "<< Energy <<G4endl;
+                G4cout<<"Lambda pre mirror "<< Lambda <<G4endl;
+                if( myanalysisManager -> getSpectrumPreMirror()) {
+                  myanalysisManager -> getSpectrumPreMirror()->Fill(Lambda);
+                }
+              }
 
 
+            }
 
+        }
+  */
 }
-
-
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbStackingAction.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbStackingAction.cc
index f48826c5048f8dba1495962dea30790991b78ba9..e2c8c42f351503ba6ef1feab8a02d71e2047093b 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbStackingAction.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbStackingAction.cc
@@ -1,12 +1,5 @@
 #include "RichTbStackingAction.hh"
 
-RichTbStackingAction::RichTbStackingAction()
-{
-    ;
-}
+RichTbStackingAction::RichTbStackingAction() { ; }
 
-
-RichTbStackingAction::~RichTbStackingAction()
-{
-    ;
-}
+RichTbStackingAction::~RichTbStackingAction() { ; }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbSteppingAction.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbSteppingAction.cc
index 1f6a451c092c2d30014ce8ec3d50fe454b594fb6..fd5d06f242c2ceb38c8af4a8f999ca9f962ced69 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbSteppingAction.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbSteppingAction.cc
@@ -1,485 +1,390 @@
-#include "Geant4/globals.hh"
 #include "RichTbSteppingAction.hh"
-#include "Geant4/G4SteppingManager.hh"
-#include "RichTbAnalysisManager.hh"
-#include "RichTbMaterial.hh"
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMaterialParameters.hh"
-#include "RichTbRunConfig.hh"
-#include "RichTbPrimaryGeneratorAction.hh"
-#include "Geant4/G4ParticleDefinition.hh"
 #include "Geant4/G4DynamicParticle.hh"
-#include "Geant4/G4Material.hh"
-#include "Geant4/G4Step.hh"
-#include "Geant4/G4Track.hh"
 #include "Geant4/G4Electron.hh"
-#include "Geant4/G4ThreeVector.hh"
+#include "Geant4/G4Material.hh"
+#include "Geant4/G4Navigator.hh"
 #include "Geant4/G4OpticalPhoton.hh"
+#include "Geant4/G4ParticleDefinition.hh"
 #include "Geant4/G4PionMinus.hh"
+#include "Geant4/G4Step.hh"
+#include "Geant4/G4SteppingManager.hh"
+#include "Geant4/G4ThreeVector.hh"
+#include "Geant4/G4Track.hh"
+#include "Geant4/G4TransportationManager.hh"
+#include "Geant4/globals.hh"
+#include "RichTbAnalysisManager.hh"
+#include "RichTbBeamProperty.hh"
 #include "RichTbCounter.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMaterialParameters.hh"
 #include "RichTbPhotonUserInfoAttach.hh"
-#include "RichTbBeamProperty.hh"
-#include "Geant4/G4Navigator.hh"
-#include "Geant4/G4TransportationManager.hh"
-
-
-RichTbSteppingAction::RichTbSteppingAction()
-{
-	G4cout<<" Created user RichTbSteppingAction "<<G4endl;
-
-
-	//    ranalysisManager = RichTbAnalysisManager::getInstance();
-	//   richtbRunConfig = RichTbRunConfig::getRunConfigInstance();
-	//  rPrimGenAction = RPrimGenAction;
-	//  PMTPhElectronKE = richtbRunConfig->getPMTPhElectronEnergy();
-	//  uParticleChange = new G4VParticleChange();
-}
+#include "RichTbPrimaryGeneratorAction.hh"
+#include "RichTbRunConfig.hh"
 
+RichTbSteppingAction::RichTbSteppingAction() {
+  G4cout << " Created user RichTbSteppingAction " << G4endl;
 
-RichTbSteppingAction::~RichTbSteppingAction()
-{
-	;
+  //    ranalysisManager = RichTbAnalysisManager::getInstance();
+  //   richtbRunConfig = RichTbRunConfig::getRunConfigInstance();
+  //  rPrimGenAction = RPrimGenAction;
+  //  PMTPhElectronKE = richtbRunConfig->getPMTPhElectronEnergy();
+  //  uParticleChange = new G4VParticleChange();
 }
 
+RichTbSteppingAction::~RichTbSteppingAction() { ; }
 
-void RichTbSteppingAction::UserSteppingAction(const G4Step * aStep)
-{
-
-
-
-	RichTbRadiatorLensBoundaryIncidenceStep(aStep);
-
-	RichTbPMTIncidenceStep(aStep);
-
-	//    RichTbGenericHisto(aStep);
-	// RichTbDebugHisto(aStep);
-
-	RichTbCounter* aRCounter = RichTbCounter::getRichTbCounterInstance();
-	//  RichTbAnalysisManager* aRAnalysisManager = RichTbAnalysisManager::getInstance();
-	// RichTbRunConfig* aRunConfig =   RichTbRunConfig::getRunConfigInstance();
-
-	G4StepPoint* pPreStepPoint  = aStep ->GetPreStepPoint();
-	G4StepPoint* pPostStepPoint = aStep ->GetPostStepPoint();
-	const G4ThreeVector prePos= pPreStepPoint->GetPosition();
-	const G4ThreeVector postPos= pPostStepPoint->GetPosition();
-	// now test if the prestep is inside the vessel.
+void RichTbSteppingAction::UserSteppingAction(const G4Step *aStep) {
 
-	if( (prePos.z()< RichTbVesselDnsZEnd && prePos.z() >= 0.0*CLHEP::mm) &&
-			(prePos.x()< RichTbVesselXPosExtreme &&
-					prePos.x() > RichTbVesselXNegExtreme ) &&
-					(prePos.y() <  RichTbVesselYPosExtreme &&
-							prePos.y() >  RichTbVesselYNegExtreme) )
-	{
+  RichTbRadiatorLensBoundaryIncidenceStep(aStep);
 
-		// check to see if if we are a boundary.
+  RichTbPMTIncidenceStep(aStep);
 
-		if (pPostStepPoint->GetStepStatus() == fGeomBoundary)
-		{
+  //    RichTbGenericHisto(aStep);
+  // RichTbDebugHisto(aStep);
 
-			G4Track* aTrack = aStep -> GetTrack();
-			const G4DynamicParticle* aParticle = aTrack->GetDynamicParticle();
-			const G4double aTrackEnergy = aParticle->GetKineticEnergy();
+  RichTbCounter *aRCounter = RichTbCounter::getRichTbCounterInstance();
+  //  RichTbAnalysisManager* aRAnalysisManager = RichTbAnalysisManager::getInstance();
+  // RichTbRunConfig* aRunConfig =   RichTbRunConfig::getRunConfigInstance();
 
-			// test for photons which are not already killed.
+  G4StepPoint *pPreStepPoint = aStep->GetPreStepPoint();
+  G4StepPoint *pPostStepPoint = aStep->GetPostStepPoint();
+  const G4ThreeVector prePos = pPreStepPoint->GetPosition();
+  const G4ThreeVector postPos = pPostStepPoint->GetPosition();
+  // now test if the prestep is inside the vessel.
 
-			if( (aParticle->GetDefinition() == G4OpticalPhoton::OpticalPhoton()) &&
-					(  aTrackEnergy > 0.0 ))
-			{
+  if ((prePos.z() < RichTbVesselDnsZEnd && prePos.z() >= 0.0 * CLHEP::mm) &&
+      (prePos.x() < RichTbVesselXPosExtreme && prePos.x() > RichTbVesselXNegExtreme) &&
+      (prePos.y() < RichTbVesselYPosExtreme && prePos.y() > RichTbVesselYNegExtreme)) {
 
-				// G4double curPhotWavLenNano=PhotMomToWaveLength/(aTrackEnergy*CLHEP::nanometer);
+    // check to see if if we are a boundary.
 
-				// check that valid phys vol exist to avoid particles exiting to universe.
+    if (pPostStepPoint->GetStepStatus() == fGeomBoundary) {
 
-				if( pPreStepPoint -> GetPhysicalVolume() &&
-						pPostStepPoint -> GetPhysicalVolume() )
-				{
+      G4Track *aTrack = aStep->GetTrack();
+      const G4DynamicParticle *aParticle = aTrack->GetDynamicParticle();
+      const G4double aTrackEnergy = aParticle->GetKineticEnergy();
 
-					G4String tpreVol = pPreStepPoint -> GetPhysicalVolume()->GetName();
-					G4String tpostVol = pPostStepPoint -> GetPhysicalVolume()->GetName();
+      // test for photons which are not already killed.
 
-					//          G4String tpreVolFirstPart=
-					//  (tpreVol.length() >=7 ) ? tpreVol(0,7) : tpreVol;
-					//  G4String tpostVolFirstPart =
-					//  (tpostVol.length() >= 7) ? tpostVol(0,7):tpostVol;
+      if ((aParticle->GetDefinition() == G4OpticalPhoton::OpticalPhoton()) && (aTrackEnergy > 0.0)) {
 
+        // G4double curPhotWavLenNano=PhotMomToWaveLength/(aTrackEnergy*CLHEP::nanometer);
 
-					//   G4cout <<"RichTbstep pre post vol "<<tpreVol
-					// <<"  "<<tpostVol<<G4endl;
+        // check that valid phys vol exist to avoid particles exiting to universe.
 
+        if (pPreStepPoint->GetPhysicalVolume() && pPostStepPoint->GetPhysicalVolume()) {
 
+          G4String tpreVol = pPreStepPoint->GetPhysicalVolume()->GetName();
+          G4String tpostVol = pPostStepPoint->GetPhysicalVolume()->GetName();
 
+          //          G4String tpreVolFirstPart=
+          //  (tpreVol.length() >=7 ) ? tpreVol(0,7) : tpreVol;
+          //  G4String tpostVolFirstPart =
+          //  (tpostVol.length() >= 7) ? tpostVol(0,7):tpostVol;
 
-					// now for photons entering the mirror
-					if(tpreVol == VesselPhysName &&
-							tpostVol ==  MirrorPhysName )
-					{
-						//  G4cout<<"StepAction: Entering mirror "<<G4endl;
+          //   G4cout <<"RichTbstep pre post vol "<<tpreVol
+          // <<"  "<<tpostVol<<G4endl;
 
-						aRCounter->    bumpnumPhEnterMirror();
-						// if( aRAnalysisManager->getfhistoWEnterMirror() )
-						//			aRAnalysisManager->getfhistoWEnterMirror()
-						// ->fill(curPhotWavLenNano);
+          // now for photons entering the mirror
+          if (tpreVol == VesselPhysName && tpostVol == MirrorPhysName) {
+            //  G4cout<<"StepAction: Entering mirror "<<G4endl;
 
-					}
-					// now for photons exiting the mirror
-					if(tpreVol == MirrorPhysName &&
-							tpostVol ==  VesselPhysName )
-					{
-						//  G4cout<<"StepAction: Entering mirror "<<G4endl;
+            aRCounter->bumpnumPhEnterMirror();
+            // if( aRAnalysisManager->getfhistoWEnterMirror() )
+            //			aRAnalysisManager->getfhistoWEnterMirror()
+            // ->fill(curPhotWavLenNano);
+          }
+          // now for photons exiting the mirror
+          if (tpreVol == MirrorPhysName && tpostVol == VesselPhysName) {
+            //  G4cout<<"StepAction: Entering mirror "<<G4endl;
 
-						//   if( aRAnalysisManager->getfhistoWExitMirror() )
-						//		aRAnalysisManager->getfhistoWExitMirror()
-						// ->fill( curPhotWavLenNano);
+            //   if( aRAnalysisManager->getfhistoWExitMirror() )
+            //		aRAnalysisManager->getfhistoWExitMirror()
+            // ->fill( curPhotWavLenNano);
+          }
+          // now for photons entering the ph det sup frame.
+          if (tpreVol == VesselPhysName && tpostVol == GasQuWinPhysName) {
 
-					}
-					// now for photons entering the ph det sup frame.
-					if(tpreVol == VesselPhysName &&
-							tpostVol ==  GasQuWinPhysName  )
-					{
+            // G4cout<<"StepAction: Entering  GasQuWin "<<G4endl;
 
-						// G4cout<<"StepAction: Entering  GasQuWin "<<G4endl;
+            aRCounter->bumpnumPhEnterPhSupFrame();
+            //     if( aRAnalysisManager->getfhistoWEnterPhSupFrame())
+            //		aRAnalysisManager->getfhistoWEnterPhSupFrame()
+            //  ->fill( curPhotWavLenNano);
+          }
+          if (tpreVol == GasQuWinPhysName && tpostVol == PhDetSupName) {
+            // now exiting Gas qu Win
 
-						aRCounter->bumpnumPhEnterPhSupFrame();
-						//     if( aRAnalysisManager->getfhistoWEnterPhSupFrame())
-						//		aRAnalysisManager->getfhistoWEnterPhSupFrame()
-						//  ->fill( curPhotWavLenNano);
+            aRCounter->bumpnumExitGasQuWin();
 
-					}
-					if(tpreVol == GasQuWinPhysName &&
-							tpostVol == PhDetSupName )
-					{
-						// now exiting Gas qu Win
+            //  if( aRAnalysisManager->getfhistoWExitGasQuWin())
+            //	aRAnalysisManager->getfhistoWExitGasQuWin()
+            //  ->fill( curPhotWavLenNano);
+          }
 
-						aRCounter->bumpnumExitGasQuWin();
+          // now for photons enetering the PMT QW
 
-						//  if( aRAnalysisManager->getfhistoWExitGasQuWin())
-						//	aRAnalysisManager->getfhistoWExitGasQuWin()
-						//  ->fill( curPhotWavLenNano);
+          if (tpreVol == PMTSMasterPhysName && tpostVol == PMTQuartzPhysName) {
+            //  G4cout<<"StepAction: Entering PMT QW "<<G4endl;
 
+            aRCounter->bumpnumPhEnterAnPMTQW();
 
-					}
-
-					// now for photons enetering the PMT QW
-
-					if(tpreVol ==  PMTSMasterPhysName &&
-							tpostVol ==  PMTQuartzPhysName)
-					{
-						//  G4cout<<"StepAction: Entering PMT QW "<<G4endl;
-
-						aRCounter->bumpnumPhEnterAnPMTQW();
-
-						G4TouchableHistory* CurTTB =
-								(G4TouchableHistory*)(pPreStepPoint->GetTouchable());
-						CurTTB -> MoveUpHistory(1);
-						G4int curPMTNum =   CurTTB -> GetVolume() -> GetCopyNo();
-						if( curPMTNum == 0 )
-						{
-							//   G4cout<<"StepAction: Entering PMT0  QW "<<G4endl;
-
-							// if( aRAnalysisManager->getfhistoWEnterPMT0QW() )
-							//   aRAnalysisManager->getfhistoWEnterPMT0QW()
-							//     ->fill(curPhotWavLenNano);
-							aRCounter->bumpnumPhEnterPMT0QW();
-
-						}
-						else if( curPMTNum == 1 )
-						{
-							//  G4cout<<"StepAction: Entering PMT1  QW "<<G4endl;
-
-							//  if( aRAnalysisManager->getfhistoWEnterPMT1QW() )
-							//   aRAnalysisManager->getfhistoWEnterPMT1QW()
-							//    ->fill(curPhotWavLenNano);
-							aRCounter->bumpnumPhEnterPMT1QW();
-						}
-						else if( curPMTNum == 2 )
-						{
-							//  G4cout<<"StepAction: Entering PMT2  QW "<<G4endl;
-
-							//		  if( aRAnalysisManager->getfhistoWEnterPMT2QW() )
-							//   {
-							//  G4cout<<"StepAction: Entering PMT2  QW fil histo  "
-							// << G4endl;
-
-							//     aRAnalysisManager->getfhistoWEnterPMT2QW()
-							//		->fill(curPhotWavLenNano);
-							//   }
-
-							// G4cout<<"StepAction: Entering PMT2  QW bump counter "
-							// <<G4endl;
-
-							aRCounter->bumpnumPhEnterPMT2QW();
-							//  G4cout<<"StepAction: Entering PMT2  QW counter bumped up"
-							// <<G4endl;
-						}
-						else if( curPMTNum == 3 )
-						{
-							//  G4cout<<"StepAction: Entering PMT3  QW "<<G4endl;
-
-							//	  if( aRAnalysisManager->getfhistoWEnterPMT3QW() )
-							//  {
-							//  G4cout<<"StepAction: Entering PMT3  QW fil histo  "
-							// <<G4endl;
-
-							//      aRAnalysisManager->getfhistoWEnterPMT3QW()
-							//		->fill(curPhotWavLenNano);
-							//  }
-
-							// G4cout<<"StepAction: Entering PMT2  QW bump counter "
-							// <<G4endl;
-
-							aRCounter->bumpnumPhEnterPMT3QW();
-							//  G4cout<<"StepAction: Entering PMT2  QW counter bumped up"
-							// <<G4endl;
-
-
-						}
-						else if( curPMTNum == 4 )
-						{
-							//  G4cout<<"StepAction: Entering PMT4  QW "<<G4endl;
-
-							//	  if( aRAnalysisManager->getfhistoWEnterPMT4QW() )
-							//  {
-							//  G4cout<<"StepAction: Entering PMT4  QW fil histo  "
-							// <<G4endl;
-
-							//     aRAnalysisManager->getfhistoWEnterPMT4QW()
-							//		->fill(curPhotWavLenNano);
-							//   }
-
-							// G4cout<<"StepAction: Entering PMT4  QW bump counter "
-							// <<G4endl;
-
-							aRCounter->bumpnumPhEnterPMT4QW();
-							//  G4cout<<"StepAction: Entering PMT4  QW counter bumped up"
-							// <<G4endl;
-						}
-						else if( curPMTNum == 5 )
-						{
-							//  G4cout<<"StepAction: Entering PMT5  QW "<<G4endl;
-
-							//	  if( aRAnalysisManager->getfhistoWEnterPMT5QW() )
-							//  {
-							//  G4cout<<"StepAction: Entering PMT5  QW fil histo  "
-							// <<G4endl;
-
-							//    aRAnalysisManager->getfhistoWEnterPMT5QW()
-							//		->fill(curPhotWavLenNano);
-							//   }
-
-							// G4cout<<"StepAction: Entering PMT5  QW bump counter "
-							// <<G4endl;
-
-							aRCounter->bumpnumPhEnterPMT5QW();
-							//  G4cout<<"StepAction: Entering PMT5  QW counter bumped up"
-							// <<G4endl;
-						}
-						else if( curPMTNum == 6 ) aRCounter->bumpnumPhEnterPMT6QW();
-						else if( curPMTNum == 7 ) aRCounter->bumpnumPhEnterPMT7QW();
-						else if( curPMTNum == 8 ) aRCounter->bumpnumPhEnterPMT8QW();
-						else if( curPMTNum == 9 ) aRCounter->bumpnumPhEnterPMT9QW();
-						else if( curPMTNum == 10 ) aRCounter->bumpnumPhEnterPMT10QW();
-						else if( curPMTNum == 11 ) aRCounter->bumpnumPhEnterPMT11QW();
-						else if( curPMTNum == 12 ) aRCounter->bumpnumPhEnterPMT12QW();
-						else if( curPMTNum == 13 ) aRCounter->bumpnumPhEnterPMT13QW();
-						else if( curPMTNum == 14 ) aRCounter->bumpnumPhEnterPMT14QW();
-						else if( curPMTNum == 15 ) aRCounter->bumpnumPhEnterPMT15QW();
-					}
-				}
-			}
-		}
-	}
-	//             G4cout<<"StepAction: End of Step action "<<G4endl;
+            G4TouchableHistory *CurTTB = (G4TouchableHistory *)(pPreStepPoint->GetTouchable());
+            CurTTB->MoveUpHistory(1);
+            G4int curPMTNum = CurTTB->GetVolume()->GetCopyNo();
+            if (curPMTNum == 0) {
+              //   G4cout<<"StepAction: Entering PMT0  QW "<<G4endl;
+
+              // if( aRAnalysisManager->getfhistoWEnterPMT0QW() )
+              //   aRAnalysisManager->getfhistoWEnterPMT0QW()
+              //     ->fill(curPhotWavLenNano);
+              aRCounter->bumpnumPhEnterPMT0QW();
+
+            } else if (curPMTNum == 1) {
+              //  G4cout<<"StepAction: Entering PMT1  QW "<<G4endl;
+
+              //  if( aRAnalysisManager->getfhistoWEnterPMT1QW() )
+              //   aRAnalysisManager->getfhistoWEnterPMT1QW()
+              //    ->fill(curPhotWavLenNano);
+              aRCounter->bumpnumPhEnterPMT1QW();
+            } else if (curPMTNum == 2) {
+              //  G4cout<<"StepAction: Entering PMT2  QW "<<G4endl;
+
+              //		  if( aRAnalysisManager->getfhistoWEnterPMT2QW() )
+              //   {
+              //  G4cout<<"StepAction: Entering PMT2  QW fil histo  "
+              // << G4endl;
+
+              //     aRAnalysisManager->getfhistoWEnterPMT2QW()
+              //		->fill(curPhotWavLenNano);
+              //   }
+
+              // G4cout<<"StepAction: Entering PMT2  QW bump counter "
+              // <<G4endl;
+
+              aRCounter->bumpnumPhEnterPMT2QW();
+              //  G4cout<<"StepAction: Entering PMT2  QW counter bumped up"
+              // <<G4endl;
+            } else if (curPMTNum == 3) {
+              //  G4cout<<"StepAction: Entering PMT3  QW "<<G4endl;
+
+              //	  if( aRAnalysisManager->getfhistoWEnterPMT3QW() )
+              //  {
+              //  G4cout<<"StepAction: Entering PMT3  QW fil histo  "
+              // <<G4endl;
+
+              //      aRAnalysisManager->getfhistoWEnterPMT3QW()
+              //		->fill(curPhotWavLenNano);
+              //  }
+
+              // G4cout<<"StepAction: Entering PMT2  QW bump counter "
+              // <<G4endl;
+
+              aRCounter->bumpnumPhEnterPMT3QW();
+              //  G4cout<<"StepAction: Entering PMT2  QW counter bumped up"
+              // <<G4endl;
+
+            } else if (curPMTNum == 4) {
+              //  G4cout<<"StepAction: Entering PMT4  QW "<<G4endl;
+
+              //	  if( aRAnalysisManager->getfhistoWEnterPMT4QW() )
+              //  {
+              //  G4cout<<"StepAction: Entering PMT4  QW fil histo  "
+              // <<G4endl;
+
+              //     aRAnalysisManager->getfhistoWEnterPMT4QW()
+              //		->fill(curPhotWavLenNano);
+              //   }
+
+              // G4cout<<"StepAction: Entering PMT4  QW bump counter "
+              // <<G4endl;
+
+              aRCounter->bumpnumPhEnterPMT4QW();
+              //  G4cout<<"StepAction: Entering PMT4  QW counter bumped up"
+              // <<G4endl;
+            } else if (curPMTNum == 5) {
+              //  G4cout<<"StepAction: Entering PMT5  QW "<<G4endl;
+
+              //	  if( aRAnalysisManager->getfhistoWEnterPMT5QW() )
+              //  {
+              //  G4cout<<"StepAction: Entering PMT5  QW fil histo  "
+              // <<G4endl;
+
+              //    aRAnalysisManager->getfhistoWEnterPMT5QW()
+              //		->fill(curPhotWavLenNano);
+              //   }
+
+              // G4cout<<"StepAction: Entering PMT5  QW bump counter "
+              // <<G4endl;
+
+              aRCounter->bumpnumPhEnterPMT5QW();
+              //  G4cout<<"StepAction: Entering PMT5  QW counter bumped up"
+              // <<G4endl;
+            } else if (curPMTNum == 6)
+              aRCounter->bumpnumPhEnterPMT6QW();
+            else if (curPMTNum == 7)
+              aRCounter->bumpnumPhEnterPMT7QW();
+            else if (curPMTNum == 8)
+              aRCounter->bumpnumPhEnterPMT8QW();
+            else if (curPMTNum == 9)
+              aRCounter->bumpnumPhEnterPMT9QW();
+            else if (curPMTNum == 10)
+              aRCounter->bumpnumPhEnterPMT10QW();
+            else if (curPMTNum == 11)
+              aRCounter->bumpnumPhEnterPMT11QW();
+            else if (curPMTNum == 12)
+              aRCounter->bumpnumPhEnterPMT12QW();
+            else if (curPMTNum == 13)
+              aRCounter->bumpnumPhEnterPMT13QW();
+            else if (curPMTNum == 14)
+              aRCounter->bumpnumPhEnterPMT14QW();
+            else if (curPMTNum == 15)
+              aRCounter->bumpnumPhEnterPMT15QW();
+          }
+        }
+      }
+    }
+  }
+  //             G4cout<<"StepAction: End of Step action "<<G4endl;
 }
 
-
-
-void RichTbSteppingAction::RichTbDebugHisto(const G4Step * /* aStep */)
-{
-
-}
-
-
-void RichTbSteppingAction::RichTbGenericHisto(const G4Step * /*  aStep */)
-{
-
-
-
+void RichTbSteppingAction::RichTbDebugHisto(const G4Step * /* aStep */) {}
+
+void RichTbSteppingAction::RichTbGenericHisto(const G4Step * /*  aStep */) {}
+void RichTbSteppingAction::RichTbRadiatorLensBoundaryIncidenceStep(const G4Step *aStep) {
+
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+  int aRadiatorConfiguration = aConfig->getRadiatorConfiguration();
+  if (/*false*/ aRadiatorConfiguration == 3) {
+    RichTbRadiatorXNegExtreme_ = RichTbRadiatorXNegExtreme15;
+    RichTbRadiatorXPosExtreme_ = RichTbRadiatorXPosExtreme15;
+    RichTbRadiatorYNegExtreme_ = RichTbRadiatorYNegExtreme15;
+    RichTbRadiatorYPosExtreme_ = RichTbRadiatorYPosExtreme15;
+    RichTbRadiatorZNegExtreme_ = RichTbRadiatorZNegExtreme15;
+    RichTbRadiatorZPosExtreme_ = RichTbRadiatorZPosExtreme15;
+    RichTbRadiatorDnsZLocation_ = RichTbRadiatorDnsZLocation15;
+  } else {
+    RichTbRadiatorXNegExtreme_ = RichTbRadiatorXNegExtreme;
+    RichTbRadiatorXPosExtreme_ = RichTbRadiatorXPosExtreme;
+    RichTbRadiatorYNegExtreme_ = RichTbRadiatorYNegExtreme;
+    RichTbRadiatorYPosExtreme_ = RichTbRadiatorYPosExtreme;
+    RichTbRadiatorZNegExtreme_ = RichTbRadiatorZNegExtreme;
+    RichTbRadiatorZPosExtreme_ = RichTbRadiatorZPosExtreme;
+    RichTbRadiatorDnsZLocation_ = RichTbRadiatorDnsZLocation;
+  }
+
+  G4StepPoint *pPreStepPoint = aStep->GetPreStepPoint();
+  G4StepPoint *pPostStepPoint = aStep->GetPostStepPoint();
+  const G4ThreeVector prePos = pPreStepPoint->GetPosition();
+  const G4ThreeVector postPos = pPostStepPoint->GetPosition();
+  RichTbAnalysisManager *myanalysisManager = RichTbAnalysisManager::getInstance();
+
+  // G4cout<<" Now in radiator boundary step "<< prePos <<"   "<<postPos<<  G4endl;
+  if ((prePos.z() < RichTbVesselDnsZEnd) &&
+      (prePos.x() < RichTbVesselXPosExtreme && prePos.x() > RichTbVesselXNegExtreme) &&
+      (prePos.y() < RichTbVesselYPosExtreme && prePos.y() > RichTbVesselYNegExtreme)) {
+
+    if (pPostStepPoint->GetStepStatus() == fGeomBoundary) {
+
+      G4Track *aTrack = aStep->GetTrack();
+
+      const G4DynamicParticle *aParticle = aTrack->GetDynamicParticle();
+      const G4double aTrackEnergy = aParticle->GetKineticEnergy();
+
+      //     G4cout<<" Particle definition direction"<< aParticle->GetDefinition()->GetParticleName()
+      //      << aTrack->GetMomentum()   <<G4endl;
+
+      if ((aParticle->GetDefinition() == G4OpticalPhoton::OpticalPhoton()) && (aTrackEnergy > 0.0)) {
+
+        if ((prePos.z() < RichTbRadiatorZPosExtreme_) && (prePos.z() > RichTbRadiatorZNegExtreme_) &&
+            (prePos.x() < RichTbRadiatorXPosExtreme_) && (prePos.x() > RichTbRadiatorXNegExtreme_) &&
+            (prePos.y() < RichTbRadiatorYPosExtreme_) && (prePos.y() > RichTbRadiatorYNegExtreme_)) {
+          if (pPreStepPoint->GetPhysicalVolume() && pPostStepPoint->GetPhysicalVolume()) {
+            G4String tpreVol = pPreStepPoint->GetPhysicalVolume()->GetName();
+            G4String tpostVol = pPostStepPoint->GetPhysicalVolume()->GetName();
+            G4ThreeVector pPostStepMom = pPostStepPoint->GetMomentum();
+            G4ThreeVector pPreStepMom = pPreStepPoint->GetMomentum();
+            G4int PostStepMomZSign = ((pPostStepMom.z()) > 0.0) ? 1 : -1;
+            G4int PreStepMomZSign = ((pPreStepMom.z()) > 0.0) ? 1 : -1;
+            // G4cout<<" Step action pre post vol" <<tpreVol<<"  "<<tpostVol<<"  "<<prePos<<"   "
+            //     <<postPos<<G4endl;
+
+            if ((tpreVol == RadiatorPhysName) && (tpostVol == CrystalMasterPhysName) &&
+                (postPos.z() > (RichTbRadiatorDnsZLocation_ - RichTbRadiatorDnsZLocationTolerence)) &&
+                (postPos.z() < (RichTbRadiatorDnsZLocation_ + RichTbRadiatorDnsZLocationTolerence))) {
+
+              if (myanalysisManager->getfXYRadiatorDnsPhoton())
+                myanalysisManager->getfXYRadiatorDnsPhoton()->Fill(postPos.x(), postPos.y());
+
+              if ((PreStepMomZSign == 1) && (PostStepMomZSign == -1)) {
+                //    G4cout<<" TIR step "<<postPos<<G4endl;
+
+                if (myanalysisManager->getfXYRadiatorTIRDnsPhoton())
+                  myanalysisManager->getfXYRadiatorTIRDnsPhoton()->Fill(postPos.x(), postPos.y());
+
+                RichTbRadiatorBoundaryInfoAttach(aTrack, postPos, 0);
+              } else if ((PreStepMomZSign == 1) && (PostStepMomZSign == 1)) {
+                //                        G4cout<<" Refr step "<<postPos<<G4endl;
+
+                if (myanalysisManager->getfXYRadiatorRFRDnsPhoton())
+                  myanalysisManager->getfXYRadiatorRFRDnsPhoton()->Fill(postPos.x(), postPos.y());
+
+                RichTbRadiatorBoundaryInfoAttach(aTrack, postPos, 1);
+              }
+
+            } else if ((tpreVol == RadiatorPhysName) && (tpostVol == MirrorPhysName)) {
+              if ((PreStepMomZSign == -1) && (PostStepMomZSign == 1)) {
+                RichTbRadiatorBoundaryInfoAttach(aTrack, postPos, 2);
+                // G4cout<<" Mirror step "<<postPos<<G4endl;
+              }
+            }
+          }
+        }
+      }
+    }
+  }
 }
-void RichTbSteppingAction::RichTbRadiatorLensBoundaryIncidenceStep(const G4Step * aStep ) {
-
-	RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-	int aRadiatorConfiguration = aConfig ->getRadiatorConfiguration();
-	if(/*false*/aRadiatorConfiguration==3) {
-	    RichTbRadiatorXNegExtreme_ = RichTbRadiatorXNegExtreme15;
-	    RichTbRadiatorXPosExtreme_ = RichTbRadiatorXPosExtreme15;
-	    RichTbRadiatorYNegExtreme_ = RichTbRadiatorYNegExtreme15;
-	    RichTbRadiatorYPosExtreme_ = RichTbRadiatorYPosExtreme15;
-	    RichTbRadiatorZNegExtreme_ = RichTbRadiatorZNegExtreme15;
-	    RichTbRadiatorZPosExtreme_ = RichTbRadiatorZPosExtreme15;
-		RichTbRadiatorDnsZLocation_ = RichTbRadiatorDnsZLocation15;
-	} else {
-	    RichTbRadiatorXNegExtreme_ = RichTbRadiatorXNegExtreme;
-	    RichTbRadiatorXPosExtreme_ = RichTbRadiatorXPosExtreme;
-	    RichTbRadiatorYNegExtreme_ = RichTbRadiatorYNegExtreme;
-	    RichTbRadiatorYPosExtreme_ = RichTbRadiatorYPosExtreme;
-	    RichTbRadiatorZNegExtreme_ = RichTbRadiatorZNegExtreme;
-	    RichTbRadiatorZPosExtreme_ = RichTbRadiatorZPosExtreme;
-		RichTbRadiatorDnsZLocation_ = RichTbRadiatorDnsZLocation;
-	}
-
-	G4StepPoint* pPreStepPoint  = aStep ->GetPreStepPoint();
-	G4StepPoint* pPostStepPoint = aStep ->GetPostStepPoint();
-	const G4ThreeVector prePos= pPreStepPoint->GetPosition();
-	const G4ThreeVector postPos= pPostStepPoint->GetPosition();
-	RichTbAnalysisManager * myanalysisManager = RichTbAnalysisManager::getInstance();
-
-
-	// G4cout<<" Now in radiator boundary step "<< prePos <<"   "<<postPos<<  G4endl;
-	if( (prePos.z()< RichTbVesselDnsZEnd ) &&
-			(prePos.x()< RichTbVesselXPosExtreme &&
-					prePos.x() > RichTbVesselXNegExtreme ) &&
-					(prePos.y() <  RichTbVesselYPosExtreme &&
-							prePos.y() >  RichTbVesselYNegExtreme) ){
-
-		if (pPostStepPoint->GetStepStatus() == fGeomBoundary){
-
-			G4Track* aTrack = aStep -> GetTrack();
-
-			const G4DynamicParticle* aParticle = aTrack->GetDynamicParticle();
-			const G4double aTrackEnergy = aParticle->GetKineticEnergy();
-
-			//     G4cout<<" Particle definition direction"<< aParticle->GetDefinition()->GetParticleName()
-			//      << aTrack->GetMomentum()   <<G4endl;
-
-			if( (aParticle->GetDefinition() == G4OpticalPhoton::OpticalPhoton()) &&
-					(  aTrackEnergy > 0.0 )) {
 
-				if( (prePos.z() < RichTbRadiatorZPosExtreme_ ) &&
-						(prePos.z() > RichTbRadiatorZNegExtreme_ ) &&
-						(prePos.x() < RichTbRadiatorXPosExtreme_ ) &&
-						(prePos.x() > RichTbRadiatorXNegExtreme_ ) &&
-						(prePos.y() < RichTbRadiatorYPosExtreme_ ) &&
-						(prePos.y() > RichTbRadiatorYNegExtreme_ ) ){
-					if( pPreStepPoint -> GetPhysicalVolume() &&
-							pPostStepPoint -> GetPhysicalVolume() ){
-						G4String tpreVol = pPreStepPoint->GetPhysicalVolume()->GetName();
-						G4String tpostVol = pPostStepPoint->GetPhysicalVolume()->GetName();
-						G4ThreeVector pPostStepMom =  pPostStepPoint->GetMomentum();
-						G4ThreeVector pPreStepMom =  pPreStepPoint->GetMomentum();
-						G4int PostStepMomZSign= ((pPostStepMom.z()) > 0.0) ? 1 : -1 ;
-						G4int PreStepMomZSign = ((pPreStepMom.z())> 0.0)   ? 1 : -1 ;
-						// G4cout<<" Step action pre post vol" <<tpreVol<<"  "<<tpostVol<<"  "<<prePos<<"   "
-								//     <<postPos<<G4endl;
+void RichTbSteppingAction::RichTbPMTIncidenceStep(const G4Step *aStep) {
+  G4StepPoint *pPreStepPoint = aStep->GetPreStepPoint();
+  G4StepPoint *pPostStepPoint = aStep->GetPostStepPoint();
+  const G4ThreeVector prePos = pPreStepPoint->GetPosition();
+  const G4ThreeVector postPos = pPostStepPoint->GetPosition();
+  // now test if the prestep is inside the vessel.
 
-						if(( tpreVol ==  RadiatorPhysName) &&
-								(tpostVol ==  CrystalMasterPhysName) &&
-								( postPos.z() > (RichTbRadiatorDnsZLocation_-RichTbRadiatorDnsZLocationTolerence)) &&
-								( postPos.z() < (RichTbRadiatorDnsZLocation_+RichTbRadiatorDnsZLocationTolerence)) ){
+  if ((prePos.z() < RichTbVesselDnsZEnd && prePos.z() >= 0.0 * CLHEP::mm) &&
+      (prePos.x() < RichTbVesselXPosExtreme && prePos.x() > RichTbVesselXNegExtreme) &&
+      (prePos.y() < RichTbVesselYPosExtreme && prePos.y() > RichTbVesselYNegExtreme)) {
 
-							if(myanalysisManager->getfXYRadiatorDnsPhoton())
-								myanalysisManager->getfXYRadiatorDnsPhoton()-> Fill(postPos.x(), postPos.y());
+    // check to see if if we are a boundary.
 
+    if (pPostStepPoint->GetStepStatus() == fGeomBoundary) {
 
-							if ( (PreStepMomZSign ==1) && (PostStepMomZSign == -1)) {
-								//    G4cout<<" TIR step "<<postPos<<G4endl;
+      G4Track *aTrack = aStep->GetTrack();
 
-								if(myanalysisManager->getfXYRadiatorTIRDnsPhoton())
-									myanalysisManager->getfXYRadiatorTIRDnsPhoton()-> Fill(postPos.x(), postPos.y());
+      const G4DynamicParticle *aParticle = aTrack->GetDynamicParticle();
+      const G4double aTrackEnergy = aParticle->GetKineticEnergy();
 
-								RichTbRadiatorBoundaryInfoAttach( aTrack, postPos, 0);
-							}else if (  (PreStepMomZSign ==1) && (PostStepMomZSign == 1) ){
-								//                        G4cout<<" Refr step "<<postPos<<G4endl;
+      // test for photons which are not already killed.
 
-								if(myanalysisManager->getfXYRadiatorRFRDnsPhoton())
-									myanalysisManager->getfXYRadiatorRFRDnsPhoton()-> Fill(postPos.x(), postPos.y());
+      if ((aParticle->GetDefinition() == G4OpticalPhoton::OpticalPhoton()) && (aTrackEnergy > 0.0)) {
 
-								RichTbRadiatorBoundaryInfoAttach( aTrack, postPos,1);
-							}
-
-						} else if ( ( tpreVol ==   RadiatorPhysName ) &&
-								(tpostVol ==  MirrorPhysName ) ){
-							if ( (PreStepMomZSign == -1) && (PostStepMomZSign == 1)      ) {
-								RichTbRadiatorBoundaryInfoAttach( aTrack, postPos,2);
-								// G4cout<<" Mirror step "<<postPos<<G4endl;
-
-							}
-
-						}
-
-					}
-
-
-
-				}
-
-
-
-			}
-
-		}
-
-	}
+        if (pPreStepPoint->GetPhysicalVolume() && pPostStepPoint->GetPhysicalVolume()) {
+          G4String tpreVol = pPreStepPoint->GetPhysicalVolume()->GetName();
+          G4String tpostVol = pPostStepPoint->GetPhysicalVolume()->GetName();
+          // now for the entry at the wuartz window of hpd.
 
+          if (tpreVol == PMTSMasterPhysName && tpostVol == PMTQuartzPhysName) {
+            //   G4cout<<" PMT Incidence Pre post pos xyz "
+            //      << prePos.x()<<"  "<<prePos.y()<<"  "<<prePos.z()<<"  "
+            //      <<postPos.x() <<"  "<<postPos.y()<<"  "
+            //      << postPos.z()<<G4endl;
 
+            RichTbPMTQWIncidenceInfoAttach(aTrack, postPos);
+          }
+        }
+      }
+    }
+  }
 }
-
-
-void RichTbSteppingAction::RichTbPMTIncidenceStep(const G4Step * aStep)
-{
-	G4StepPoint* pPreStepPoint  = aStep ->GetPreStepPoint();
-	G4StepPoint* pPostStepPoint = aStep ->GetPostStepPoint();
-	const G4ThreeVector prePos= pPreStepPoint->GetPosition();
-	const G4ThreeVector postPos= pPostStepPoint->GetPosition();
-	// now test if the prestep is inside the vessel.
-
-	if( (prePos.z()< RichTbVesselDnsZEnd && prePos.z() >= 0.0*CLHEP::mm) &&
-			(prePos.x()< RichTbVesselXPosExtreme &&
-					prePos.x() > RichTbVesselXNegExtreme ) &&
-					(prePos.y() <  RichTbVesselYPosExtreme &&
-							prePos.y() >  RichTbVesselYNegExtreme) )
-	{
-
-		// check to see if if we are a boundary.
-
-		if (pPostStepPoint->GetStepStatus() == fGeomBoundary)
-		{
-
-			G4Track* aTrack = aStep -> GetTrack();
-
-			const G4DynamicParticle* aParticle = aTrack->GetDynamicParticle();
-			const G4double aTrackEnergy = aParticle->GetKineticEnergy();
-
-			// test for photons which are not already killed.
-
-			if( (aParticle->GetDefinition() == G4OpticalPhoton::OpticalPhoton()) &&
-					(  aTrackEnergy > 0.0 ))
-			{
-
-				if( pPreStepPoint -> GetPhysicalVolume() &&
-						pPostStepPoint -> GetPhysicalVolume() )
-				{
-					G4String tpreVol = pPreStepPoint->GetPhysicalVolume()->GetName();
-					G4String tpostVol = pPostStepPoint->GetPhysicalVolume()->GetName();
-					// now for the entry at the wuartz window of hpd.
-
-					if(tpreVol ==  PMTSMasterPhysName &&
-							tpostVol ==  PMTQuartzPhysName)
-					{
-						//   G4cout<<" PMT Incidence Pre post pos xyz "
-						//      << prePos.x()<<"  "<<prePos.y()<<"  "<<prePos.z()<<"  "
-						//      <<postPos.x() <<"  "<<postPos.y()<<"  "
-						//      << postPos.z()<<G4endl;
-
-						RichTbPMTQWIncidenceInfoAttach( aTrack, postPos );
-					}
-				}
-			}
-		}
-	}
-}
-
-
-
-
-
-
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbSteppingActionBase.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbSteppingActionBase.cc
index 63198f21ab4ea9a055e478dceb38821d5cb63ad7..cc57ddb692f94490286a011e50cfdc5c3883edbf 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbSteppingActionBase.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbSteppingActionBase.cc
@@ -1,54 +1,40 @@
-// Include files 
-
-
+// Include files
 
 // local
 
-
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbSteppingActionBase
 //
 // 2015-03-06 : Sajan Easo
 //-----------------------------------------------------------------------------
-#include "Geant4/globals.hh"
 #include "RichTbSteppingActionBase.hh"
 #include "Geant4/G4SteppingManager.hh"
+#include "Geant4/globals.hh"
 
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbSteppingActionBase::RichTbSteppingActionBase(  ) {
-
-  InitRichTbStepActions();
-  
- 
-
-}
+RichTbSteppingActionBase::RichTbSteppingActionBase() { InitRichTbStepActions(); }
 //=============================================================================
 // Destructor
 //=============================================================================
 RichTbSteppingActionBase::~RichTbSteppingActionBase() {
 
-  if(mRichTbSteppingAction) delete mRichTbSteppingAction;
-  if(mRichTbPmtSteppingAction) delete mRichTbPmtSteppingAction;
-
-} 
+  if (mRichTbSteppingAction)
+    delete mRichTbSteppingAction;
+  if (mRichTbPmtSteppingAction)
+    delete mRichTbPmtSteppingAction;
+}
 
 //=============================================================================
-void RichTbSteppingActionBase::UserSteppingAction(const G4Step * aStep){
+void RichTbSteppingActionBase::UserSteppingAction(const G4Step *aStep) {
 
   mRichTbSteppingAction->UserSteppingAction(aStep);
   mRichTbPmtSteppingAction->UserSteppingAction(aStep);
-
-
-
 }
 
-void  RichTbSteppingActionBase::InitRichTbStepActions(){
+void RichTbSteppingActionBase::InitRichTbStepActions() {
 
-  mRichTbSteppingAction=new RichTbSteppingAction();
+  mRichTbSteppingAction = new RichTbSteppingAction();
   mRichTbPmtSteppingAction = new RichTbPmtSteppingAction();
-  
-  
-
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbTrackingAction.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbTrackingAction.cc
index 9b3d57d7cb3314907bcd1b807d8708f8e5f49fad..c8e92ba095287e2fbf1adb81eec3a04dfc21b5f9 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbTrackingAction.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbTrackingAction.cc
@@ -1,90 +1,66 @@
 #include "RichTbTrackingAction.hh"
 #include "Geant4/G4DynamicParticle.hh"
+#include "Geant4/G4OpticalPhoton.hh"
 #include "Geant4/G4ParticleDefinition.hh"
 #include "Geant4/G4ThreeVector.hh"
-#include "Geant4/G4OpticalPhoton.hh"
 #include "Geant4/globals.hh"
-#include "RichTbUserTrackInfo.hh"
-#include "RichTbPhotoElectron.hh"
-#include "RichTbBeamProperty.hh"
 #include "RichTbAnalysisManager.hh"
+#include "RichTbBeamProperty.hh"
+#include "RichTbPhotoElectron.hh"
 #include "RichTbRunConfig.hh"
+#include "RichTbUserTrackInfo.hh"
+
+RichTbTrackingAction::RichTbTrackingAction() { ; }
+RichTbTrackingAction::~RichTbTrackingAction() { ; }
+void RichTbTrackingAction::PreUserTrackingAction(const G4Track * /* aTrack */) { ; }
+void RichTbTrackingAction::PostUserTrackingAction(const G4Track *aTrack) {
+  if (aTrack != 0) {
+
+    const G4DynamicParticle *aParticle = aTrack->GetDynamicParticle();
+    if (aParticle->GetDefinition() == G4OpticalPhoton::OpticalPhoton()) {
+
+      // delete the photon user info at the end of
+      // tracking the photon. This is so that it does not
+      // accumulate over the events and fill up the memory.
+      // This removes dangling reference to the trackuserinformation class.
+      // no deletion for now. SE 20-1-2004.
+
+      //  G4double cPhotTrueCkv = 0.0;
 
-RichTbTrackingAction::RichTbTrackingAction()
-{;}
-RichTbTrackingAction::~RichTbTrackingAction()
-{  ;}
-void RichTbTrackingAction::PreUserTrackingAction(const G4Track * /* aTrack */) 
-{;}
-void RichTbTrackingAction:: PostUserTrackingAction(const G4Track * aTrack)
-{
-  if( aTrack != 0 ) {
-  
-   const G4DynamicParticle * aParticle = aTrack->GetDynamicParticle();
-   if( aParticle->GetDefinition() == G4OpticalPhoton::OpticalPhoton() ){
+      G4VUserTrackInformation *aTkInfo = aTrack->GetUserInformation();
 
-   // delete the photon user info at the end of
-     // tracking the photon. This is so that it does not
-     // accumulate over the events and fill up the memory.
-     // This removes dangling reference to the trackuserinformation class.
-     // no deletion for now. SE 20-1-2004.
+      if (aTkInfo) {
+        RichTbUserTrackInfo *curPhotTrackUserInfo = (RichTbUserTrackInfo *)aTkInfo;
 
-     //  G4double cPhotTrueCkv = 0.0;
-     
-     G4VUserTrackInformation* aTkInfo = aTrack->GetUserInformation();
-     
-     if( aTkInfo) {
-       RichTbUserTrackInfo*  curPhotTrackUserInfo =
-                 (RichTbUserTrackInfo*)  aTkInfo;
+        if (curPhotTrackUserInfo && curPhotTrackUserInfo->HasUserPhotonInfo()) {
+          RichTbPhotonInfo *aRichTbPhotonInfo = curPhotTrackUserInfo->getRichTbPhotonInfo();
+          if (aRichTbPhotonInfo) {
 
-       if(curPhotTrackUserInfo && curPhotTrackUserInfo->HasUserPhotonInfo() ){
-           RichTbPhotonInfo* aRichTbPhotonInfo = 
-              curPhotTrackUserInfo->getRichTbPhotonInfo();
-           if( aRichTbPhotonInfo ) {
+            // cPhotTrueCkv=aRichTbPhotonInfo->CkvCosThetaAtProd();
 
-             // cPhotTrueCkv=aRichTbPhotonInfo->CkvCosThetaAtProd();
-             
-             //  delete   aRichTbPhotonInfo;
-             
-           }
-           
+            //  delete   aRichTbPhotonInfo;
+          }
+        }
+      }
 
-       }
-       
-     }
-     
-     
-   } else if (aParticle->GetDefinition() ==  
-              RichTbPhotoElectron::PhotoElectron()) {
-     // delete the photoelectron user info at the end of tracking the
-     // photoelectron. This is so that they  do not accumulate 
-     // over the events and fill up the memory.
-     // This removes dangling reference to the trackuserinformation class.
-     // no deletion for now. SE 20-1-2004.
-     G4VUserTrackInformation* aTkInfoP = aTrack->GetUserInformation();
-     if( aTkInfoP) {
+    } else if (aParticle->GetDefinition() == RichTbPhotoElectron::PhotoElectron()) {
+      // delete the photoelectron user info at the end of tracking the
+      // photoelectron. This is so that they  do not accumulate
+      // over the events and fill up the memory.
+      // This removes dangling reference to the trackuserinformation class.
+      // no deletion for now. SE 20-1-2004.
+      G4VUserTrackInformation *aTkInfoP = aTrack->GetUserInformation();
+      if (aTkInfoP) {
 
-       RichTbUserTrackInfo*  curPeTrackUserInfo =
-                 (RichTbUserTrackInfo*)  aTkInfoP;
-    
-       if( curPeTrackUserInfo && curPeTrackUserInfo-> HasUserPEInfo()) {
-           RichTbPEInfo* aRichTbPEInfo =
-             curPeTrackUserInfo->getRichTbPEInfo();
-           if(aRichTbPEInfo ) {
-             //  delete   aRichTbPEInfo;
-             
-           }
-           
+        RichTbUserTrackInfo *curPeTrackUserInfo = (RichTbUserTrackInfo *)aTkInfoP;
 
-       }
-       
-       
-     }
-     
-   }   
-      
-    
+        if (curPeTrackUserInfo && curPeTrackUserInfo->HasUserPEInfo()) {
+          RichTbPEInfo *aRichTbPEInfo = curPeTrackUserInfo->getRichTbPEInfo();
+          if (aRichTbPEInfo) {
+            //  delete   aRichTbPEInfo;
+          }
+        }
+      }
+    }
   }
-  
-  
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbUserTrackInfo.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbUserTrackInfo.cc
index 5c21508f4127b70e36131f4a4e379f9b0731821c..3904fcd077a38acac9aeaa5e7640edd9637b05d3 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbUserTrackInfo.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcev/RichTbUserTrackInfo.cc
@@ -1,7 +1,5 @@
 // $Id: $
-// Include files 
-
-
+// Include files
 
 // local
 #include "RichTbUserTrackInfo.hh"
@@ -15,23 +13,18 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbUserTrackInfo::RichTbUserTrackInfo(  ):  mRichTbPhotonInfo(0),
- mRichTbPEInfo(0),mHasUserPhotonInfo(false),mHasUserPEInfo(false) {
-
+RichTbUserTrackInfo::RichTbUserTrackInfo()
+    : mRichTbPhotonInfo(0), mRichTbPEInfo(0), mHasUserPhotonInfo(false), mHasUserPEInfo(false) {}
+RichTbUserTrackInfo::RichTbUserTrackInfo(RichTbPhotonInfo *aRichTbPhotonInfo)
+    : mRichTbPEInfo(0), mHasUserPEInfo(false) {
+  mRichTbPhotonInfo = aRichTbPhotonInfo;
+  mHasUserPhotonInfo = true;
 }
-RichTbUserTrackInfo::RichTbUserTrackInfo(RichTbPhotonInfo* aRichTbPhotonInfo): 
- mRichTbPEInfo(0),mHasUserPEInfo(false){ 
-  mRichTbPhotonInfo= aRichTbPhotonInfo;
-  mHasUserPhotonInfo=true;
-  
+RichTbUserTrackInfo::RichTbUserTrackInfo(RichTbPEInfo *aRichTbPEInfo)
+    : mRichTbPhotonInfo(0), mHasUserPhotonInfo(false) {
+  mRichTbPEInfo = aRichTbPEInfo;
+  mHasUserPEInfo = true;
 }
-RichTbUserTrackInfo::RichTbUserTrackInfo(RichTbPEInfo* aRichTbPEInfo): 
-mRichTbPhotonInfo(0), mHasUserPhotonInfo(false){
-  mRichTbPEInfo=aRichTbPEInfo;
-  mHasUserPEInfo=true;
-  
-}
-
 
 //=============================================================================
 // Destructor
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgr/RichTbGraphics.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgr/RichTbGraphics.cc
index 836154663850fc8c30926fd90a9a00212e02b5af..e438b663e5c774a2d17da1880d9e9fa87473691c 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgr/RichTbGraphics.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgr/RichTbGraphics.cc
@@ -1,1955 +1,1748 @@
-#include <iostream>
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMaterial.hh"
 #include "RichTbGraphics.hh"
+#include "Geant4/G4Colour.hh"
 #include "Geant4/G4LogicalVolume.hh"
 #include "Geant4/G4VisAttributes.hh"
-#include "Geant4/G4Colour.hh"
-#include "RichTbRunConfig.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMaterial.hh"
 #include "RichTbPMT.hh"
-RichTbGraphics::RichTbGraphics()
-{
-	;
-}
-
+#include "RichTbRunConfig.hh"
+#include <iostream>
+RichTbGraphics::RichTbGraphics() { ; }
 
-RichTbGraphics::RichTbGraphics(RichTbDetectorConstruction* aDetector )
+RichTbGraphics::RichTbGraphics(RichTbDetectorConstruction *aDetector)
 
 {
 
+  curDetector = aDetector;
 
-
-	curDetector = aDetector;
-
-	setAllGraphicsAttributes();
-
+  setAllGraphicsAttributes();
 }
 
-RichTbGraphics::~RichTbGraphics()
-{
-	;
-}
-
-void RichTbGraphics::setAllGraphicsAttributes()
-{
-
-	//now for the RichTbHall.
+RichTbGraphics::~RichTbGraphics() { ; }
 
-	setRichTbHallGraphicsAttibutes();
+void RichTbGraphics::setAllGraphicsAttributes() {
 
+  // now for the RichTbHall.
 
+  setRichTbHallGraphicsAttibutes();
 }
 
-void RichTbGraphics::setRichTbHallGraphicsAttibutes()
-{
-
-	// For Following variables on visibility
-	//  0 means make the volume invisible;
-	//                        1 means make it visible as a solid.
-	//                        2 means make it visible as a wireframe.
-
-	RichTbRunConfig* aRunConfig=  RichTbRunConfig::getRunConfigInstance();
-	G4int aRadiatorConfiguration =  aRunConfig ->getRadiatorConfiguration();
-
-
-	G4int RichTbHall_vis = aRunConfig->getRichTbHall_visib();
-
-	if(  (curDetector != 0)  && (curDetector->getRichTbHall() != 0) ) {
-
-		G4LogicalVolume *RichTbHall_LV =curDetector->getRichTbHall()
-                    				 ->getRichTbHallLogicalVolume();
+void RichTbGraphics::setRichTbHallGraphicsAttibutes() {
 
-		if( RichTbHall_LV != 0 ) {
+  // For Following variables on visibility
+  //  0 means make the volume invisible;
+  //                        1 means make it visible as a solid.
+  //                        2 means make it visible as a wireframe.
 
-			if (RichTbHall_vis == 0) {
-				RichTbHall_LV->SetVisAttributes(G4VisAttributes::Invisible);
-			} else {
-				G4VisAttributes *RichTbHall_LogVisAtt =
-						new G4VisAttributes(G4Colour(0., 1., 1.));
-				if (RichTbHall_vis == 2) {
-					RichTbHall_LogVisAtt->SetForceSolid(false);
-					RichTbHall_LogVisAtt->SetForceWireframe(true);
-				}
-				if (RichTbHall_vis == 1) {
-					RichTbHall_LogVisAtt->SetForceSolid(true);
-				}
-				RichTbHall_LogVisAtt->SetVisibility(true);
-				RichTbHall_LV->SetVisAttributes(RichTbHall_LogVisAtt);
-				//
-			}
-		}
-
-	}
-
-	// now for the vessel
-
-	G4int RichTbUpgradeVessel_vis = aRunConfig->getRichTbUpgradeVessel_visib();
-	// G4cout<<"vessel visib flag  "<<RichTbUpgradeVessel_vis<<G4endl;
-
-	if(  (curDetector != 0)  && (curDetector-> getRichTbUpgradeVessel() != 0))
-	{
-		//    G4cout<<"now setting vessel visb options  "<<RichTbUpgradeVessel_vis<<G4endl;
-
-		G4LogicalVolume * RichTbUpgradeVessel_LV =curDetector->
-				getRichTbUpgradeVessel()-> getRichTbGasVesselLVol();
-		if(RichTbUpgradeVessel_LV != 0 ) {
-			if(RichTbUpgradeVessel_vis == 0 ) {
-				RichTbUpgradeVessel_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-			} else {
-				G4VisAttributes * RichTbUpgradeVessel_LogVisAtt =
-						new G4VisAttributes(G4Colour(0.5,0.5,0.0));
-				if(RichTbUpgradeVessel_vis == 2 ) {
-					RichTbUpgradeVessel_LogVisAtt ->SetForceSolid(false);
-					RichTbUpgradeVessel_LogVisAtt ->SetForceWireframe(true);
-				}
-				if(RichTbUpgradeVessel_vis == 1 ) {
-					RichTbUpgradeVessel_LogVisAtt ->SetForceSolid(true);
-				}
-				RichTbUpgradeVessel_LogVisAtt->SetVisibility(true);
-				RichTbUpgradeVessel_LV -> SetVisAttributes(RichTbUpgradeVessel_LogVisAtt);
-
-			}
-
-		}
-
-	}
-
-	//G4int aRadiatorConfiguration =
-	//  aRunConfig ->getRadiatorConfiguration();
-
-	if(aRadiatorConfiguration == 0){
-
-
-		// now for the crystal
-
-		G4int RichTbCrystal_vis = aRunConfig->getRichTbCrystal_visib();
-		G4cout<<"Crystal visib flag  "<<RichTbCrystal_vis<<G4endl;
-
-		if(  (curDetector != 0)  && (curDetector-> getRichTbCrystal() != 0))
-		{
-			G4cout<<"now setting crystal visib options  "<<RichTbCrystal_vis<<G4endl;
-
-			G4LogicalVolume * RichTbCrystal_LV =curDetector->
-					getRichTbCrystal()-> getRichTbCrystalLVol();
-			if(RichTbCrystal_LV != 0 ) {
-				if(RichTbCrystal_vis == 0 ) {
-					RichTbCrystal_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
-					G4VisAttributes * RichTbCrystal_LogVisAtt =
-							new G4VisAttributes(G4Colour(1.,0.0,0.0));
-					if(RichTbCrystal_vis == 2 ) {
-						RichTbCrystal_LogVisAtt ->SetForceSolid(false);
-						RichTbCrystal_LogVisAtt ->SetForceWireframe(true);
-						G4cout<<"test crystal vis "<<RichTbCrystal_vis<<G4endl;
-					}
-					if(RichTbCrystal_vis == 1 ) {
-						RichTbCrystal_LogVisAtt ->SetForceSolid(true);
-					}
-					RichTbCrystal_LogVisAtt->SetVisibility(true);
-					RichTbCrystal_LV -> SetVisAttributes(RichTbCrystal_LogVisAtt);
-
-				}
-
-			}
-
-		}
-
-		// now for the crystal cover
-
-		G4int RichTbCrystalCover_vis = aRunConfig->getRichTbCrystalCover_visib();
-		G4cout<<"Crystal cover visib flag  "<<RichTbCrystalCover_vis<<G4endl;
-
-		if(  (curDetector != 0)  && (curDetector-> getRichTbCrystalCover() != 0))
-		{
-			G4cout<<"now setting crystal visb options  "<<RichTbCrystalCover_vis<<G4endl;
-
-			G4LogicalVolume * RichTbCrystalCover_LV =curDetector->
-					getRichTbCrystalCover()-> getRichTbCrystalCoverLVol();
-			if(RichTbCrystalCover_LV != 0 ) {
-				if(RichTbCrystalCover_vis == 0 ) {
-					RichTbCrystalCover_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
-					G4VisAttributes * RichTbCrystalCover_LogVisAtt =
-							new G4VisAttributes(G4Colour(0.0,0.0,1.0));
-					if(RichTbCrystalCover_vis == 2 ) {
-						RichTbCrystalCover_LogVisAtt ->SetForceSolid(false);
-						RichTbCrystalCover_LogVisAtt ->SetForceWireframe(true);
-						G4cout<<"test crystal cover vis "<<RichTbCrystalCover_vis<<G4endl;
-					}
-					if(RichTbCrystalCover_vis == 1 ) {
-						RichTbCrystalCover_LogVisAtt ->SetForceSolid(true);
-					}
-					RichTbCrystalCover_LogVisAtt->SetVisibility(true);
-					RichTbCrystalCover_LV -> SetVisAttributes(RichTbCrystalCover_LogVisAtt);
-
-				}
-
-			}
-
-		}
-
-		// now for the lens
-
-		G4int RichTbLens_vis = aRunConfig->getRichTbLens_visib();
-		G4cout<<"Lens visib flag  "<<RichTbLens_vis<<G4endl;
-
-		if(  (curDetector != 0)  && (curDetector-> getRichTbLens() != 0))
-		{
-			G4cout<<"now setting lens visb options  "<<RichTbLens_vis<<G4endl;
-
-			G4LogicalVolume * RichTbLens_LV =curDetector->
-					getRichTbLens()-> getRichTbLensLVol();
-			if(RichTbLens_LV != 0 ) {
-				if(RichTbLens_vis == 0 ) {
-					RichTbLens_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
-					G4VisAttributes * RichTbLens_LogVisAtt =
-							new G4VisAttributes(G4Colour(1.,0.0,0.0));
-					if(RichTbLens_vis == 2 ) {
-						RichTbLens_LogVisAtt ->SetForceSolid(false);
-						RichTbLens_LogVisAtt ->SetForceWireframe(true);
-						G4cout<<"test lens vis "<<RichTbLens_vis<<G4endl;
-					}
-					if(RichTbLens_vis == 1 ) {
-						RichTbLens_LogVisAtt ->SetForceSolid(true);
-					}
-					RichTbLens_LogVisAtt->SetVisibility(true);
-					RichTbLens_LV -> SetVisAttributes(RichTbLens_LogVisAtt);
-
-				}
-
-			}
-
-		}
-
-	}
-	else{
-
-		// now for the radiator
-
-		G4int RichTbUpgradeRadiator_vis = aRunConfig->getRichTbUpgradeRadiator_visib();
-		G4cout<<"Radiator visib flag  "<<RichTbUpgradeRadiator_vis<<G4endl;
-
-		if(  (curDetector != 0)  && (curDetector-> getRichTbUpgradeRadiator() != 0))
-		{
-			G4cout<<"now setting radiator visb options  "<<RichTbUpgradeRadiator_vis<<G4endl;
-
-			G4LogicalVolume * RichTbUpgradeRadiator_LV =curDetector->
-					getRichTbUpgradeRadiator()-> getRichTbUpgradeRadiatorLVol();
-			if(RichTbUpgradeRadiator_LV != 0 ) {
-				if(RichTbUpgradeRadiator_vis == 0 ) {
-					RichTbUpgradeRadiator_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
-					G4VisAttributes * RichTbUpgradeRadiator_LogVisAtt =
-							new G4VisAttributes(G4Colour(0.7,0.1,0.4));
-					if(RichTbUpgradeRadiator_vis == 2 ) {
-						RichTbUpgradeRadiator_LogVisAtt ->SetForceSolid(false);
-						RichTbUpgradeRadiator_LogVisAtt ->SetForceWireframe(true);
-						G4cout<<"test radiator vis "<<RichTbUpgradeRadiator_vis<<G4endl;
-					}
-					if(RichTbUpgradeRadiator_vis == 1 ) {
-						RichTbUpgradeRadiator_LogVisAtt ->SetForceSolid(true);
-					}
-					RichTbUpgradeRadiator_LogVisAtt->SetVisibility(true);
-					RichTbUpgradeRadiator_LV -> SetVisAttributes(RichTbUpgradeRadiator_LogVisAtt);
-
-				}
-
-			}
-
-		}
-
-		// now for the dark cover
-
-		G4int RichTbUpgradeDarkCover_vis = aRunConfig->getRichTbUpgradeDarkCover_visib();
-		G4cout<<"Dark cover visib flag  "<<RichTbUpgradeDarkCover_vis<<G4endl;
-
-		if(  (curDetector != 0)  && (curDetector-> getRichTbUpgradeDarkCover() != 0))
-		{
-			G4cout<<"now setting dark cover visib options  "<<RichTbUpgradeDarkCover_vis<<G4endl;
-
-			G4LogicalVolume * RichTbUpgradeDarkCover_LV =curDetector->
-					getRichTbUpgradeDarkCover()-> getRichTbUpgradeDarkCoverLVol();
-			if(RichTbUpgradeDarkCover_LV != 0 ) {
-				if(RichTbUpgradeDarkCover_vis == 0 ) {
-					RichTbUpgradeDarkCover_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
-					G4VisAttributes * RichTbUpgradeDarkCover_LogVisAtt =
-							new G4VisAttributes(G4Colour(0.0,0.1,0.05));
-					if(RichTbUpgradeDarkCover_vis == 2 ) {
-						RichTbUpgradeDarkCover_LogVisAtt ->SetForceSolid(false);
-						RichTbUpgradeDarkCover_LogVisAtt ->SetForceWireframe(true);
-						G4cout<<"test dark cover vis "<<RichTbUpgradeDarkCover_vis<<G4endl;
-					}
-					if(RichTbUpgradeDarkCover_vis == 1 ) {
-						RichTbUpgradeDarkCover_LogVisAtt ->SetForceSolid(true);
-					}
-					RichTbUpgradeDarkCover_LogVisAtt->SetVisibility(true);
-					RichTbUpgradeDarkCover_LV -> SetVisAttributes(RichTbUpgradeDarkCover_LogVisAtt);
-
-				}
-
-			}
-
-		}
-
-
-		G4int RichTbUpgradeUpsDarkCover_vis = aRunConfig->getRichTbUpgradeUpsDarkCover_visib();
-		G4cout<<"Ups Dark cover visib flag  "<<RichTbUpgradeUpsDarkCover_vis<<G4endl;
-
-		if(  (curDetector != 0)  && (curDetector-> getRichTbUpgradeDarkCover() != 0))
-		{
-			G4cout<<"now setting ups dark cover visib options  "<<RichTbUpgradeUpsDarkCover_vis<<G4endl;
-
-			G4LogicalVolume * RichTbUpgradeUpsDarkCover_LV =curDetector->
-					getRichTbUpgradeDarkCover()-> getRichTbUpgradeUpsDarkCoverLVol() ;
-			if(RichTbUpgradeUpsDarkCover_LV != 0 ) {
-				if(RichTbUpgradeUpsDarkCover_vis == 0 ) {
-					RichTbUpgradeUpsDarkCover_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
-					G4VisAttributes * RichTbUpgradeUpsDarkCover_LogVisAtt =
-							new G4VisAttributes(G4Colour(0.0,0.1,0.05));
-					if(RichTbUpgradeUpsDarkCover_vis == 2 ) {
-						RichTbUpgradeUpsDarkCover_LogVisAtt ->SetForceSolid(false);
-						RichTbUpgradeUpsDarkCover_LogVisAtt ->SetForceWireframe(true);
-						G4cout<<"test dark cover vis "<<RichTbUpgradeUpsDarkCover_vis<<G4endl;
-					}
-					if(RichTbUpgradeUpsDarkCover_vis == 1 ) {
-						RichTbUpgradeUpsDarkCover_LogVisAtt ->SetForceSolid(true);
-					}
-					RichTbUpgradeUpsDarkCover_LogVisAtt->SetVisibility(true);
-					RichTbUpgradeUpsDarkCover_LV -> SetVisAttributes(RichTbUpgradeUpsDarkCover_LogVisAtt);
-
-				}
-
-			}
-
-		}
-
-
-		G4int RichTbUpgradeSideDarkCover_vis = aRunConfig->getRichTbUpgradeSideDarkCover_visib();
-		G4cout<<"Ups Dark cover visib flag  "<<RichTbUpgradeSideDarkCover_vis<<G4endl;
-
-		if(  (curDetector != 0)  && (curDetector-> getRichTbUpgradeDarkCover() != 0))
-		{
-			G4cout<<"now setting ups dark cover visib options  "<<RichTbUpgradeSideDarkCover_vis<<G4endl;
-
-			G4LogicalVolume * RichTbUpgradeSideDarkCover_LV =curDetector->
-					getRichTbUpgradeDarkCover()-> getRichTbUpgradeSideDarkCoverLVol() ;
-			if(RichTbUpgradeSideDarkCover_LV != 0 ) {
-				if(RichTbUpgradeSideDarkCover_vis == 0 ) {
-					RichTbUpgradeSideDarkCover_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
-					G4VisAttributes * RichTbUpgradeSideDarkCover_LogVisAtt =
-							new G4VisAttributes(G4Colour(0.4,0.4,0.05));
-					if(RichTbUpgradeSideDarkCover_vis == 2 ) {
-						RichTbUpgradeSideDarkCover_LogVisAtt ->SetForceSolid(false);
-						RichTbUpgradeSideDarkCover_LogVisAtt ->SetForceWireframe(true);
-						G4cout<<"test dark cover vis "<<RichTbUpgradeSideDarkCover_vis<<G4endl;
-					}
-					if(RichTbUpgradeSideDarkCover_vis == 1 ) {
-						RichTbUpgradeSideDarkCover_LogVisAtt ->SetForceSolid(true);
-					}
-					RichTbUpgradeSideDarkCover_LogVisAtt->SetVisibility(true);
-					RichTbUpgradeSideDarkCover_LV -> SetVisAttributes(RichTbUpgradeSideDarkCover_LogVisAtt);
+  RichTbRunConfig *aRunConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int aRadiatorConfiguration = aRunConfig->getRadiatorConfiguration();
 
-				}
+  G4int RichTbHall_vis = aRunConfig->getRichTbHall_visib();
 
-			}
+  if ((curDetector != 0) && (curDetector->getRichTbHall() != 0)) {
 
-		}
+    G4LogicalVolume *RichTbHall_LV = curDetector->getRichTbHall()->getRichTbHallLogicalVolume();
 
-		G4int RichTbUpgradeDnsDarkCover_vis = aRunConfig->getRichTbUpgradeDnsDarkCover_visib();
-		G4cout<<"Dns Dark cover visib flag  "<<RichTbUpgradeDnsDarkCover_vis<<G4endl;
+    if (RichTbHall_LV != 0) {
 
-		if(  (curDetector != 0)  && (curDetector-> getRichTbEC()  != 0))
-		{
-			G4cout<<"now setting dns dark cover visib options  "<<RichTbUpgradeDnsDarkCover_vis<<G4endl;
+      if (RichTbHall_vis == 0) {
+        RichTbHall_LV->SetVisAttributes(G4VisAttributes::Invisible);
+      } else {
+        G4VisAttributes *RichTbHall_LogVisAtt = new G4VisAttributes(G4Colour(0., 1., 1.));
+        if (RichTbHall_vis == 2) {
+          RichTbHall_LogVisAtt->SetForceSolid(false);
+          RichTbHall_LogVisAtt->SetForceWireframe(true);
+        }
+        if (RichTbHall_vis == 1) {
+          RichTbHall_LogVisAtt->SetForceSolid(true);
+        }
+        RichTbHall_LogVisAtt->SetVisibility(true);
+        RichTbHall_LV->SetVisAttributes(RichTbHall_LogVisAtt);
+        //
+      }
+    }
+  }
 
-			G4LogicalVolume * RichTbUpgradeDnsDarkCover_LV =curDetector->
-					getRichTbEC()->getRichTbECSupLVol () ;
-			if(RichTbUpgradeDnsDarkCover_LV != 0 ) {
-				if(RichTbUpgradeDnsDarkCover_vis == 0 ) {
-					RichTbUpgradeDnsDarkCover_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
-					G4VisAttributes * RichTbUpgradeDnsDarkCover_LogVisAtt =
-							new G4VisAttributes(G4Colour(0.5,0.6,0.05));
-					if(RichTbUpgradeDnsDarkCover_vis == 2 ) {
-						RichTbUpgradeDnsDarkCover_LogVisAtt ->SetForceSolid(false);
-						RichTbUpgradeDnsDarkCover_LogVisAtt ->SetForceWireframe(true);
-						G4cout<<"test dark cover vis "<<RichTbUpgradeDnsDarkCover_vis<<G4endl;
-					}
-					if(RichTbUpgradeDnsDarkCover_vis == 1 ) {
-						RichTbUpgradeDnsDarkCover_LogVisAtt ->SetForceSolid(true);
-					}
-					RichTbUpgradeDnsDarkCover_LogVisAtt->SetVisibility(true);
-					RichTbUpgradeDnsDarkCover_LV -> SetVisAttributes(RichTbUpgradeDnsDarkCover_LogVisAtt);
+  // now for the vessel
 
-				}
+  G4int RichTbUpgradeVessel_vis = aRunConfig->getRichTbUpgradeVessel_visib();
+  // G4cout<<"vessel visib flag  "<<RichTbUpgradeVessel_vis<<G4endl;
 
-			}
+  if ((curDetector != 0) && (curDetector->getRichTbUpgradeVessel() != 0)) {
+    //    G4cout<<"now setting vessel visb options  "<<RichTbUpgradeVessel_vis<<G4endl;
 
-		}
+    G4LogicalVolume *RichTbUpgradeVessel_LV = curDetector->getRichTbUpgradeVessel()->getRichTbGasVesselLVol();
+    if (RichTbUpgradeVessel_LV != 0) {
+      if (RichTbUpgradeVessel_vis == 0) {
+        RichTbUpgradeVessel_LV->SetVisAttributes(G4VisAttributes::Invisible);
+      } else {
+        G4VisAttributes *RichTbUpgradeVessel_LogVisAtt = new G4VisAttributes(G4Colour(0.5, 0.5, 0.0));
+        if (RichTbUpgradeVessel_vis == 2) {
+          RichTbUpgradeVessel_LogVisAtt->SetForceSolid(false);
+          RichTbUpgradeVessel_LogVisAtt->SetForceWireframe(true);
+        }
+        if (RichTbUpgradeVessel_vis == 1) {
+          RichTbUpgradeVessel_LogVisAtt->SetForceSolid(true);
+        }
+        RichTbUpgradeVessel_LogVisAtt->SetVisibility(true);
+        RichTbUpgradeVessel_LV->SetVisAttributes(RichTbUpgradeVessel_LogVisAtt);
+      }
+    }
+  }
 
+  // G4int aRadiatorConfiguration =
+  //  aRunConfig ->getRadiatorConfiguration();
 
+  if (aRadiatorConfiguration == 0) {
 
+    // now for the crystal
 
-		// now for the mirror
+    G4int RichTbCrystal_vis = aRunConfig->getRichTbCrystal_visib();
+    G4cout << "Crystal visib flag  " << RichTbCrystal_vis << G4endl;
 
-		G4int RichTbUpgradeMirror_vis =   aRunConfig->getRichTbUpgradeMirror_visib();
-		if(  (curDetector != 0)  && (curDetector-> getRichTbUpgradeMirror() != 0)){
-			G4cout<<"now setting mirror visb options  "<<RichTbUpgradeMirror_vis<<G4endl;
-			G4LogicalVolume * RichTbUpgradeMirror_LV =   curDetector->
-					getRichTbUpgradeMirror()->getRichTbUpgradeMirrorLVol();
+    if ((curDetector != 0) && (curDetector->getRichTbCrystal() != 0)) {
+      G4cout << "now setting crystal visib options  " << RichTbCrystal_vis << G4endl;
 
-			if(  RichTbUpgradeMirror_LV != 0 ) {
-				// G4cout<<" mirror log vol "<<RichTbUpgradeMirror_LV<<G4endl;
+      G4LogicalVolume *RichTbCrystal_LV = curDetector->getRichTbCrystal()->getRichTbCrystalLVol();
+      if (RichTbCrystal_LV != 0) {
+        if (RichTbCrystal_vis == 0) {
+          RichTbCrystal_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
+          G4VisAttributes *RichTbCrystal_LogVisAtt = new G4VisAttributes(G4Colour(1., 0.0, 0.0));
+          if (RichTbCrystal_vis == 2) {
+            RichTbCrystal_LogVisAtt->SetForceSolid(false);
+            RichTbCrystal_LogVisAtt->SetForceWireframe(true);
+            G4cout << "test crystal vis " << RichTbCrystal_vis << G4endl;
+          }
+          if (RichTbCrystal_vis == 1) {
+            RichTbCrystal_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbCrystal_LogVisAtt->SetVisibility(true);
+          RichTbCrystal_LV->SetVisAttributes(RichTbCrystal_LogVisAtt);
+        }
+      }
+    }
 
-				if(RichTbUpgradeMirror_vis == 0) {
-					RichTbUpgradeMirror_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
+    // now for the crystal cover
 
-					G4VisAttributes *  RichTbUpgradeMirror_LogVisAtt =
-							new G4VisAttributes(G4Colour(0.1,0.8,0.8));
+    G4int RichTbCrystalCover_vis = aRunConfig->getRichTbCrystalCover_visib();
+    G4cout << "Crystal cover visib flag  " << RichTbCrystalCover_vis << G4endl;
 
-					if( RichTbUpgradeMirror_vis == 2 ) {
-						RichTbUpgradeMirror_LogVisAtt ->SetForceSolid(false);
-						RichTbUpgradeMirror_LogVisAtt ->SetForceWireframe(true);
-						G4cout<<"test mirror vis "<<RichTbUpgradeMirror_vis<<G4endl;
-					}
-					if( RichTbUpgradeMirror_vis == 1 ) {
-						RichTbUpgradeMirror_LogVisAtt ->SetForceSolid(true);
-					}
+    if ((curDetector != 0) && (curDetector->getRichTbCrystalCover() != 0)) {
+      G4cout << "now setting crystal visb options  " << RichTbCrystalCover_vis << G4endl;
 
-					RichTbUpgradeMirror_LogVisAtt ->SetVisibility(true);
-					RichTbUpgradeMirror_LV -> SetVisAttributes( RichTbUpgradeMirror_LogVisAtt);
-				}
-
-			}
-
-
-		}
-
-	}
-
-
-	// now for the crystal master
-
-	G4int RichTbCrystal_vis = aRunConfig->getRichTbCrystal_visib();
-	//  G4cout<<"Crystal visib flag  "<<RichTbCrystal_vis<<G4endl;
-
-	if(  (curDetector != 0)  && (curDetector-> getRichTbUpgradeCrystalMaster() != 0))
-	{
-		G4cout<<"now setting crystal master visb options  "<<G4endl;
-
-		G4LogicalVolume * RichTbUpgradeCrystalMaster_LV =curDetector->
-				getRichTbUpgradeCrystalMaster()-> getRichTbUpgradeCrystalMasterLVol();
-		if(RichTbUpgradeCrystalMaster_LV != 0 ) {
-
-			if(RichTbCrystal_vis == 0 )
-			{
-
-				RichTbUpgradeCrystalMaster_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-			}else{
-
-
-
-
-				G4VisAttributes * RichTbUpgradeCrystalMaster_LogVisAtt =
-						new G4VisAttributes(G4Colour(0.2,0.3,0.0));
-
-				//              RichTbUpgradeCrystalMaster_LogVisAtt ->SetForceSolid(false);
-				//     RichTbUpgradeCrystalMaster_LogVisAtt ->SetForceWireframe(true);
-
-
-				/*
-	else {
-				 */
-				//G4VisAttributes * RichTbCrystal_LogVisAtt =
-				//                 new G4VisAttributes(G4Colour(1.,0.0,0.0));
-				if(RichTbCrystal_vis == 2 ) {
-					RichTbUpgradeCrystalMaster_LogVisAtt ->SetForceSolid(false);
-					RichTbUpgradeCrystalMaster_LogVisAtt ->SetForceWireframe(true);
-					// G4cout<<"test crystal vis "<<RichTbCrystal_vis<<G4endl;
-				}
-				if(RichTbCrystal_vis == 1 ) {
-					RichTbUpgradeCrystalMaster_LogVisAtt ->SetForceSolid(true);
-				}
-				RichTbUpgradeCrystalMaster_LogVisAtt->SetVisibility(true);
-				RichTbUpgradeCrystalMaster_LV -> SetVisAttributes(RichTbUpgradeCrystalMaster_LogVisAtt);
-
-			}
-
-
-		}
-
-
-	}
-
-	// now for the upgrade phdet frame
-	G4int RichTbPhdet_vis = aRunConfig->getRichTbPhDetSupFrame_visib();
-	if( (curDetector != 0)  && (curDetector-> getRichTbUpgradePhDetSupFrame() != 0))
-	{
-		G4cout<<" Now setting PhDetFrame visib options " <<G4endl;
-		G4LogicalVolume * RichTbPhDetLeft_LV =curDetector->
-				getRichTbUpgradePhDetSupFrame() -> getRichTbPhDetSupFrameLeftLVol();
-		G4LogicalVolume * RichTbPhDetRight_LV =curDetector->
-				getRichTbUpgradePhDetSupFrame() -> getRichTbPhDetSupFrameRightLVol();
-		G4LogicalVolume * RichTbPhDetBottomLeft_LV;
-		G4LogicalVolume * RichTbPhDetBottomRight_LV;
-		if(aRadiatorConfiguration == 3) {
-			RichTbPhDetBottomLeft_LV =curDetector->
-					getRichTbUpgradePhDetSupFrame()->getRichTbPhDetSupFrameBottomLeftLVol();
-			RichTbPhDetBottomRight_LV =curDetector->
-					getRichTbUpgradePhDetSupFrame()->getRichTbPhDetSupFrameBottomRightLVol();
-		}
-		if((RichTbPhDetLeft_LV !=0)  && (RichTbPhDetRight_LV != 0)) {
-			if(RichTbPhdet_vis == 0){
-				RichTbPhDetLeft_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-				RichTbPhDetRight_LV  ->SetVisAttributes(G4VisAttributes::Invisible);
-				if((aRadiatorConfiguration == 3) && (RichTbPhDetBottomLeft_LV !=0) && (RichTbPhDetBottomRight_LV != 0)) {
-					RichTbPhDetBottomLeft_LV->SetVisAttributes(G4VisAttributes::Invisible);
-					RichTbPhDetBottomRight_LV->SetVisAttributes(G4VisAttributes::Invisible);
-				}
-			}else {
-				G4VisAttributes * RichTbPhDetSupFrame_LogVisAtt =
-						new G4VisAttributes(G4Colour(0.3,0.3,0.7));
-
-				if(RichTbPhdet_vis == 2)
-				{
-					RichTbPhDetSupFrame_LogVisAtt->SetForceSolid(false);
-					RichTbPhDetSupFrame_LogVisAtt->SetForceWireframe(true);
-				}
-				if(RichTbPhdet_vis == 1)
-				{
-					RichTbPhDetSupFrame_LogVisAtt->SetForceSolid(true);
-				}
-				RichTbPhDetSupFrame_LogVisAtt->SetVisibility(true);
-				RichTbPhDetLeft_LV->SetVisAttributes(RichTbPhDetSupFrame_LogVisAtt);
-				RichTbPhDetRight_LV->SetVisAttributes(RichTbPhDetSupFrame_LogVisAtt);
-				if((aRadiatorConfiguration == 3) && (RichTbPhDetBottomLeft_LV !=0) && (RichTbPhDetBottomRight_LV != 0)) {
-					RichTbPhDetBottomLeft_LV->SetVisAttributes(RichTbPhDetSupFrame_LogVisAtt);
-					RichTbPhDetBottomRight_LV->SetVisAttributes(RichTbPhDetSupFrame_LogVisAtt);
-				}
-			}
-		}
-	}
-
-	// now for the upgrade EC
-	G4int RichTbEC_vis = aRunConfig->getRichTbEC_visib();
-	if( (curDetector != 0)  && (curDetector-> getRichTbEC() != 0))
-	{
-		G4cout<<" Now setting EC visib options " <<G4endl;
-		G4LogicalVolume * RichTbECLeft_LV =curDetector->
-				getRichTbEC()-> getRichTbECLeftLVol();
-		G4LogicalVolume * RichTbECRight_LV =
-				(aRadiatorConfiguration == 2) ? 0 : curDetector-> getRichTbEC()-> getRichTbECRightLVol();
-		G4LogicalVolume * RichTbECBottomLeft_LV;
-		G4LogicalVolume * RichTbECBottomRight_LV;
-		if(aRadiatorConfiguration == 3) {
-			RichTbECBottomLeft_LV = curDetector->getRichTbEC()->getRichTbECBottomLeftLVol();
-			RichTbECBottomRight_LV = curDetector->getRichTbEC()->getRichTbECBottomRightLVol();
-		}
-		G4VisAttributes * RichTbEC_LogVisAtt = new G4VisAttributes(G4Colour(0.7,0.3,0.7));
-		if(RichTbECLeft_LV !=0 ) {
-			if(  RichTbEC_vis == 0 ){
-				RichTbECLeft_LV->SetVisAttributes(G4VisAttributes::Invisible);
-				if((aRadiatorConfiguration == 3) && (RichTbECBottomLeft_LV!=0) && (RichTbECBottomRight_LV!=0)){
-					RichTbECBottomLeft_LV->SetVisAttributes(G4VisAttributes::Invisible);
-					RichTbECBottomRight_LV->SetVisAttributes(G4VisAttributes::Invisible);
-				}
-			}else {
-
-				if(RichTbEC_vis == 2 ) {
-					RichTbEC_LogVisAtt->SetForceSolid(false);
-					RichTbEC_LogVisAtt->SetForceWireframe(true);
-				}
-				if(RichTbEC_vis == 1 ) RichTbEC_LogVisAtt->SetForceSolid(true);
-				RichTbEC_LogVisAtt->SetVisibility(true);
-				RichTbECLeft_LV-> SetVisAttributes(RichTbEC_LogVisAtt);
-				if((aRadiatorConfiguration == 3) && (RichTbECBottomLeft_LV!=0) && (RichTbECBottomRight_LV!=0)){
-					RichTbECBottomLeft_LV->SetVisAttributes(RichTbEC_LogVisAtt);
-					RichTbECBottomRight_LV->SetVisAttributes(RichTbEC_LogVisAtt);
-				}
-			}
-		}
-		if(RichTbECRight_LV != 0) {
-			if(RichTbEC_vis == 0) RichTbECRight_LV->SetVisAttributes(G4VisAttributes::Invisible);
-			else RichTbECRight_LV->SetVisAttributes(RichTbEC_LogVisAtt);
-		}
-	}
-
-
-	// now for the upgrade PMTmaster
-	// TESTnumPmts
-	G4int CurNumPmts = NumPmtsOld;
-//	G4int CurNumPmts = RichTbPMTGeometryParameters::getNumPmts();
-	if (aRadiatorConfiguration == 2) CurNumPmts = NumPmtsWithHpd;
-	else if (aRadiatorConfiguration == 3) CurNumPmts = NumPmtsUpgrade15;
-//	else if (aRadiatorConfiguration == 3) CurNumPmts = RichTbPMTGeometryParameters::getNumPmtsUpgrade();
-	// CurNumPmts = (aRadiatorConfiguration==3) ? NumPmtsUpgrade15 : NumPmts;
-
-	G4int RichTbPMTMaster_vis = aRunConfig->getRichTbPMTMaster_visib();
-	G4cout<<"RichTb PMT Master visib flag  "<<RichTbPMTMaster_vis<<G4endl;
-
-	if(  (curDetector != 0)  && (curDetector-> getRichTbPMT() != 0)){
-		G4cout<<"now setting PMT master visb options  "<<RichTbPMTMaster_vis<<G4endl;
-
-		std::vector<G4LogicalVolume *> RichTbPMTMaster_LV =curDetector->
-				getRichTbPMT()-> getRichTbPMTMasterLVol() ;
-
-		if((int) RichTbPMTMaster_LV.size() != 0 ) {
-			if(RichTbPMTMaster_vis == 0 ) {
-				for (int i=0; i<CurNumPmts; i++){
-					RichTbPMTMaster_LV[i] ->SetVisAttributes(G4VisAttributes::Invisible);
-				}
-			} else {
-				G4VisAttributes * RichTbPMTMaster_LogVisAtt =
-						new G4VisAttributes(G4Colour(0.0,0.2,0.5));
-				if(RichTbPMTMaster_vis == 2 ) {
-					RichTbPMTMaster_LogVisAtt ->SetForceSolid(false);
-					RichTbPMTMaster_LogVisAtt ->SetForceWireframe(true);
-				}
-				if(RichTbPMTMaster_vis == 1 ) {
-					RichTbPMTMaster_LogVisAtt ->SetForceSolid(true);
-				}
-				RichTbPMTMaster_LogVisAtt->SetVisibility(true);
-
-				for (int i=0; i<CurNumPmts; i++){
-					RichTbPMTMaster_LV [i] -> SetVisAttributes(RichTbPMTMaster_LogVisAtt);
-				}
-			}
-		}
-	}
-
-
-	G4int RichTbPMTSMaster_vis = aRunConfig->getRichTbPMTSMaster_visib();
-	G4cout<<"RichTb PMT SMaster visib flag  "<<RichTbPMTSMaster_vis<<G4endl;
-
-	if((curDetector != 0) && (curDetector-> getRichTbPMT() != 0)){
-		G4cout<<"now setting PMT SMaster visib options  "<<RichTbPMTSMaster_vis<<G4endl;
-
-		std::vector<G4LogicalVolume *>  RichTbPMTSMaster_LV = curDetector->
-				getRichTbPMT()-> getRichTbPMTSMasterLVol() ;
-
-		if((int) RichTbPMTSMaster_LV.size() != 0 ) {
-			if(RichTbPMTSMaster_vis == 0 ) {
-				for (int i=0; i<CurNumPmts; i++){
-					RichTbPMTSMaster_LV[i]->SetVisAttributes(G4VisAttributes::Invisible);
-				}
-			} else {
-				G4VisAttributes * RichTbPMTSMaster_LogVisAtt =
-						new G4VisAttributes(G4Colour(0.0,0.2,0.5));
-				if(RichTbPMTSMaster_vis == 2 ) {
-					RichTbPMTSMaster_LogVisAtt->SetForceSolid(false);
-					RichTbPMTSMaster_LogVisAtt->SetForceWireframe(true);
-				}
-				if(RichTbPMTSMaster_vis == 1 ) {
-					RichTbPMTSMaster_LogVisAtt->SetForceSolid(true);
-				}
-				RichTbPMTSMaster_LogVisAtt->SetVisibility(true);
-				for (int i=0; i<CurNumPmts; i++){
-					RichTbPMTSMaster_LV [i] -> SetVisAttributes(RichTbPMTSMaster_LogVisAtt);
-				}
-			}
-		}
-	}
-
-
-
-	G4int RichTbPMTAnode_vis = aRunConfig->getRichTbPMTAnode_visib();
-	G4cout<<"RichTb PMT Anode visib flag  "<<RichTbPMTAnode_vis<<G4endl;
-
-	if(  (curDetector != 0)  && (curDetector-> getRichTbPMT() != 0)){
-		G4cout<<"now setting PMT Anode visib options  "<<RichTbPMTAnode_vis<<G4endl;
-
-		std::vector<G4LogicalVolume *>  RichTbPMTAnode_LV =curDetector->
-				getRichTbPMT()-> getRichTbPMTAnodeLVol() ;
-
-		if((int) RichTbPMTAnode_LV.size() != 0 ) {
-			if(RichTbPMTAnode_vis == 0 ) {
-				for (int i=0; i<CurNumPmts; i++){
-					RichTbPMTAnode_LV[i] ->SetVisAttributes(G4VisAttributes::Invisible);
-				}
-
-			} else {
-				G4VisAttributes * RichTbPMTAnode_LogVisAtt =
-						new G4VisAttributes(G4Colour(0.0,0.2,0.5));
-				if(RichTbPMTAnode_vis == 2 ) {
-					RichTbPMTAnode_LogVisAtt ->SetForceSolid(false);
-					RichTbPMTAnode_LogVisAtt ->SetForceWireframe(true);
-
-				}
-				if(RichTbPMTAnode_vis == 1 ) {
-					RichTbPMTAnode_LogVisAtt ->SetForceSolid(true);
-				}
-				RichTbPMTAnode_LogVisAtt->SetVisibility(true);
-				for (int i=0; i<CurNumPmts; i++){
-					RichTbPMTAnode_LV [i] -> SetVisAttributes(RichTbPMTAnode_LogVisAtt);
-				}
-
-			}
-
-
-		}
-	}
-
-
-
-
-	G4int RichTbPMTEnvelope_vis = aRunConfig->getRichTbPMTEnvelope_visib();
-	G4cout<<"PMT Envelope visib flag  "<<RichTbPMTEnvelope_vis<<G4endl;
-
-	if(  (curDetector != 0)  && (curDetector-> getRichTbPMT() != 0))
-	{
-		G4cout<<"now setting pmt envelope visb options  "<<RichTbPMTEnvelope_vis<<G4endl;
+      G4LogicalVolume *RichTbCrystalCover_LV = curDetector->getRichTbCrystalCover()->getRichTbCrystalCoverLVol();
+      if (RichTbCrystalCover_LV != 0) {
+        if (RichTbCrystalCover_vis == 0) {
+          RichTbCrystalCover_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
+          G4VisAttributes *RichTbCrystalCover_LogVisAtt = new G4VisAttributes(G4Colour(0.0, 0.0, 1.0));
+          if (RichTbCrystalCover_vis == 2) {
+            RichTbCrystalCover_LogVisAtt->SetForceSolid(false);
+            RichTbCrystalCover_LogVisAtt->SetForceWireframe(true);
+            G4cout << "test crystal cover vis " << RichTbCrystalCover_vis << G4endl;
+          }
+          if (RichTbCrystalCover_vis == 1) {
+            RichTbCrystalCover_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbCrystalCover_LogVisAtt->SetVisibility(true);
+          RichTbCrystalCover_LV->SetVisAttributes(RichTbCrystalCover_LogVisAtt);
+        }
+      }
+    }
 
-		G4LogicalVolume * RichTbPMTEnvelope_LV =curDetector->
-				getRichTbPMT()-> getRichTbPMTEnvelopeLVol();
-		G4cout<<"test PMT Envelope LV "<<RichTbPMTEnvelope_LV<<G4endl;
-		if(RichTbPMTEnvelope_LV != 0 ) {
-			if(RichTbPMTEnvelope_vis == 0 ) {
-				RichTbPMTEnvelope_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-			} else {
-				G4VisAttributes * RichTbPMTEnvelope_LogVisAtt =
-						new G4VisAttributes(G4Colour(0.0,0.8,0.2));
-				if(RichTbPMTEnvelope_vis == 2 ) {
-					RichTbPMTEnvelope_LogVisAtt ->SetForceSolid(false);
-					RichTbPMTEnvelope_LogVisAtt ->SetForceWireframe(true);
-				}
-				if(RichTbPMTEnvelope_vis == 1 ) {
-					RichTbPMTEnvelope_LogVisAtt ->SetForceSolid(true);
-				}
-				RichTbPMTEnvelope_LogVisAtt->SetVisibility(true);
-				RichTbPMTEnvelope_LV -> SetVisAttributes(RichTbPMTEnvelope_LogVisAtt);
+    // now for the lens
 
-			}
+    G4int RichTbLens_vis = aRunConfig->getRichTbLens_visib();
+    G4cout << "Lens visib flag  " << RichTbLens_vis << G4endl;
 
-		}
+    if ((curDetector != 0) && (curDetector->getRichTbLens() != 0)) {
+      G4cout << "now setting lens visb options  " << RichTbLens_vis << G4endl;
 
-	}
+      G4LogicalVolume *RichTbLens_LV = curDetector->getRichTbLens()->getRichTbLensLVol();
+      if (RichTbLens_LV != 0) {
+        if (RichTbLens_vis == 0) {
+          RichTbLens_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
+          G4VisAttributes *RichTbLens_LogVisAtt = new G4VisAttributes(G4Colour(1., 0.0, 0.0));
+          if (RichTbLens_vis == 2) {
+            RichTbLens_LogVisAtt->SetForceSolid(false);
+            RichTbLens_LogVisAtt->SetForceWireframe(true);
+            G4cout << "test lens vis " << RichTbLens_vis << G4endl;
+          }
+          if (RichTbLens_vis == 1) {
+            RichTbLens_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbLens_LogVisAtt->SetVisibility(true);
+          RichTbLens_LV->SetVisAttributes(RichTbLens_LogVisAtt);
+        }
+      }
+    }
 
+  } else {
 
+    // now for the radiator
 
-	G4int RichTbPMTQuartzW_vis = aRunConfig->getRichTbPMTQuartzW_visib();
-	G4cout<<"PMT QW window visib flag  "<<RichTbPMTQuartzW_vis<<G4endl;
+    G4int RichTbUpgradeRadiator_vis = aRunConfig->getRichTbUpgradeRadiator_visib();
+    G4cout << "Radiator visib flag  " << RichTbUpgradeRadiator_vis << G4endl;
 
-	if(  (curDetector != 0)  && (curDetector-> getRichTbPMT() != 0))
-	{
-		G4cout<<"now setting qw window  visb options  "<<RichTbPMTQuartzW_vis<<G4endl;
+    if ((curDetector != 0) && (curDetector->getRichTbUpgradeRadiator() != 0)) {
+      G4cout << "now setting radiator visb options  " << RichTbUpgradeRadiator_vis << G4endl;
 
-		G4LogicalVolume * RichTbPMTQuartzW_LV =curDetector->getRichTbPMT()-> getRichTbPMTQuartzWLVol();
+      G4LogicalVolume *RichTbUpgradeRadiator_LV =
+          curDetector->getRichTbUpgradeRadiator()->getRichTbUpgradeRadiatorLVol();
+      if (RichTbUpgradeRadiator_LV != 0) {
+        if (RichTbUpgradeRadiator_vis == 0) {
+          RichTbUpgradeRadiator_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
+          G4VisAttributes *RichTbUpgradeRadiator_LogVisAtt = new G4VisAttributes(G4Colour(0.7, 0.1, 0.4));
+          if (RichTbUpgradeRadiator_vis == 2) {
+            RichTbUpgradeRadiator_LogVisAtt->SetForceSolid(false);
+            RichTbUpgradeRadiator_LogVisAtt->SetForceWireframe(true);
+            G4cout << "test radiator vis " << RichTbUpgradeRadiator_vis << G4endl;
+          }
+          if (RichTbUpgradeRadiator_vis == 1) {
+            RichTbUpgradeRadiator_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbUpgradeRadiator_LogVisAtt->SetVisibility(true);
+          RichTbUpgradeRadiator_LV->SetVisAttributes(RichTbUpgradeRadiator_LogVisAtt);
+        }
+      }
+    }
 
+    // now for the dark cover
 
-		if(RichTbPMTQuartzW_LV != 0 ) {
-			if(RichTbPMTQuartzW_vis == 0 ) {
-				RichTbPMTQuartzW_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-			} else {
-				G4VisAttributes * RichTbPMTQuartzW_LogVisAtt =
-						new G4VisAttributes(G4Colour(0.2,0.0,0.8));
-				if(RichTbPMTQuartzW_vis == 2 ) {
-					RichTbPMTQuartzW_LogVisAtt ->SetForceSolid(false);
-					RichTbPMTQuartzW_LogVisAtt ->SetForceWireframe(true);
-				}
-				if(RichTbPMTQuartzW_vis == 1 ) {
-					RichTbPMTQuartzW_LogVisAtt ->SetForceSolid(true);
-				}
-				RichTbPMTQuartzW_LogVisAtt->SetVisibility(true);
-				RichTbPMTQuartzW_LV -> SetVisAttributes(RichTbPMTQuartzW_LogVisAtt);
+    G4int RichTbUpgradeDarkCover_vis = aRunConfig->getRichTbUpgradeDarkCover_visib();
+    G4cout << "Dark cover visib flag  " << RichTbUpgradeDarkCover_vis << G4endl;
 
-			}
+    if ((curDetector != 0) && (curDetector->getRichTbUpgradeDarkCover() != 0)) {
+      G4cout << "now setting dark cover visib options  " << RichTbUpgradeDarkCover_vis << G4endl;
 
-		}
+      G4LogicalVolume *RichTbUpgradeDarkCover_LV =
+          curDetector->getRichTbUpgradeDarkCover()->getRichTbUpgradeDarkCoverLVol();
+      if (RichTbUpgradeDarkCover_LV != 0) {
+        if (RichTbUpgradeDarkCover_vis == 0) {
+          RichTbUpgradeDarkCover_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
+          G4VisAttributes *RichTbUpgradeDarkCover_LogVisAtt = new G4VisAttributes(G4Colour(0.0, 0.1, 0.05));
+          if (RichTbUpgradeDarkCover_vis == 2) {
+            RichTbUpgradeDarkCover_LogVisAtt->SetForceSolid(false);
+            RichTbUpgradeDarkCover_LogVisAtt->SetForceWireframe(true);
+            G4cout << "test dark cover vis " << RichTbUpgradeDarkCover_vis << G4endl;
+          }
+          if (RichTbUpgradeDarkCover_vis == 1) {
+            RichTbUpgradeDarkCover_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbUpgradeDarkCover_LogVisAtt->SetVisibility(true);
+          RichTbUpgradeDarkCover_LV->SetVisAttributes(RichTbUpgradeDarkCover_LogVisAtt);
+        }
+      }
+    }
 
-	}
+    G4int RichTbUpgradeUpsDarkCover_vis = aRunConfig->getRichTbUpgradeUpsDarkCover_visib();
+    G4cout << "Ups Dark cover visib flag  " << RichTbUpgradeUpsDarkCover_vis << G4endl;
 
+    if ((curDetector != 0) && (curDetector->getRichTbUpgradeDarkCover() != 0)) {
+      G4cout << "now setting ups dark cover visib options  " << RichTbUpgradeUpsDarkCover_vis << G4endl;
 
+      G4LogicalVolume *RichTbUpgradeUpsDarkCover_LV =
+          curDetector->getRichTbUpgradeDarkCover()->getRichTbUpgradeUpsDarkCoverLVol();
+      if (RichTbUpgradeUpsDarkCover_LV != 0) {
+        if (RichTbUpgradeUpsDarkCover_vis == 0) {
+          RichTbUpgradeUpsDarkCover_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
+          G4VisAttributes *RichTbUpgradeUpsDarkCover_LogVisAtt = new G4VisAttributes(G4Colour(0.0, 0.1, 0.05));
+          if (RichTbUpgradeUpsDarkCover_vis == 2) {
+            RichTbUpgradeUpsDarkCover_LogVisAtt->SetForceSolid(false);
+            RichTbUpgradeUpsDarkCover_LogVisAtt->SetForceWireframe(true);
+            G4cout << "test dark cover vis " << RichTbUpgradeUpsDarkCover_vis << G4endl;
+          }
+          if (RichTbUpgradeUpsDarkCover_vis == 1) {
+            RichTbUpgradeUpsDarkCover_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbUpgradeUpsDarkCover_LogVisAtt->SetVisibility(true);
+          RichTbUpgradeUpsDarkCover_LV->SetVisAttributes(RichTbUpgradeUpsDarkCover_LogVisAtt);
+        }
+      }
+    }
 
-	G4int RichTbPMTCathode_vis = aRunConfig->getRichTbPMTPhCathode_visib();
-	G4cout<<"PMT cathod visib flag  "<<RichTbPMTCathode_vis<<G4endl;
+    G4int RichTbUpgradeSideDarkCover_vis = aRunConfig->getRichTbUpgradeSideDarkCover_visib();
+    G4cout << "Ups Dark cover visib flag  " << RichTbUpgradeSideDarkCover_vis << G4endl;
 
-	if(  (curDetector != 0)  && (curDetector-> getRichTbPMT() != 0))
-	{
-		G4cout<<"now setting cathode visib options  "<<RichTbPMTCathode_vis<<G4endl;
+    if ((curDetector != 0) && (curDetector->getRichTbUpgradeDarkCover() != 0)) {
+      G4cout << "now setting ups dark cover visib options  " << RichTbUpgradeSideDarkCover_vis << G4endl;
 
-		G4LogicalVolume * RichTbPMTCathode_LV =curDetector->
-				getRichTbPMT()-> getRichTbPMTPhCathodeLVol();
-		if(RichTbPMTCathode_LV != 0 ) {
-			if(RichTbPMTCathode_vis == 0 ) {
-				RichTbPMTCathode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-			} else {
-				G4VisAttributes * RichTbPMTCathode_LogVisAtt =
-						new G4VisAttributes(G4Colour(1.0,0.0,0.0));
-				if(RichTbPMTCathode_vis == 2 ) {
-					RichTbPMTCathode_LogVisAtt ->SetForceSolid(false);
-					RichTbPMTCathode_LogVisAtt ->SetForceWireframe(true);
-				}
-				if(RichTbPMTCathode_vis == 1 ) {
-					RichTbPMTCathode_LogVisAtt ->SetForceSolid(true);
-				}
-				RichTbPMTCathode_LogVisAtt->SetVisibility(true);
-				RichTbPMTCathode_LV -> SetVisAttributes(RichTbPMTCathode_LogVisAtt);
+      G4LogicalVolume *RichTbUpgradeSideDarkCover_LV =
+          curDetector->getRichTbUpgradeDarkCover()->getRichTbUpgradeSideDarkCoverLVol();
+      if (RichTbUpgradeSideDarkCover_LV != 0) {
+        if (RichTbUpgradeSideDarkCover_vis == 0) {
+          RichTbUpgradeSideDarkCover_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
+          G4VisAttributes *RichTbUpgradeSideDarkCover_LogVisAtt = new G4VisAttributes(G4Colour(0.4, 0.4, 0.05));
+          if (RichTbUpgradeSideDarkCover_vis == 2) {
+            RichTbUpgradeSideDarkCover_LogVisAtt->SetForceSolid(false);
+            RichTbUpgradeSideDarkCover_LogVisAtt->SetForceWireframe(true);
+            G4cout << "test dark cover vis " << RichTbUpgradeSideDarkCover_vis << G4endl;
+          }
+          if (RichTbUpgradeSideDarkCover_vis == 1) {
+            RichTbUpgradeSideDarkCover_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbUpgradeSideDarkCover_LogVisAtt->SetVisibility(true);
+          RichTbUpgradeSideDarkCover_LV->SetVisAttributes(RichTbUpgradeSideDarkCover_LogVisAtt);
+        }
+      }
+    }
 
+    G4int RichTbUpgradeDnsDarkCover_vis = aRunConfig->getRichTbUpgradeDnsDarkCover_visib();
+    G4cout << "Dns Dark cover visib flag  " << RichTbUpgradeDnsDarkCover_vis << G4endl;
 
-			}
+    if ((curDetector != 0) && (curDetector->getRichTbEC() != 0)) {
+      G4cout << "now setting dns dark cover visib options  " << RichTbUpgradeDnsDarkCover_vis << G4endl;
 
-		}
+      G4LogicalVolume *RichTbUpgradeDnsDarkCover_LV = curDetector->getRichTbEC()->getRichTbECSupLVol();
+      if (RichTbUpgradeDnsDarkCover_LV != 0) {
+        if (RichTbUpgradeDnsDarkCover_vis == 0) {
+          RichTbUpgradeDnsDarkCover_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
+          G4VisAttributes *RichTbUpgradeDnsDarkCover_LogVisAtt = new G4VisAttributes(G4Colour(0.5, 0.6, 0.05));
+          if (RichTbUpgradeDnsDarkCover_vis == 2) {
+            RichTbUpgradeDnsDarkCover_LogVisAtt->SetForceSolid(false);
+            RichTbUpgradeDnsDarkCover_LogVisAtt->SetForceWireframe(true);
+            G4cout << "test dark cover vis " << RichTbUpgradeDnsDarkCover_vis << G4endl;
+          }
+          if (RichTbUpgradeDnsDarkCover_vis == 1) {
+            RichTbUpgradeDnsDarkCover_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbUpgradeDnsDarkCover_LogVisAtt->SetVisibility(true);
+          RichTbUpgradeDnsDarkCover_LV->SetVisAttributes(RichTbUpgradeDnsDarkCover_LogVisAtt);
+        }
+      }
+    }
 
-	}
+    // now for the mirror
 
+    G4int RichTbUpgradeMirror_vis = aRunConfig->getRichTbUpgradeMirror_visib();
+    if ((curDetector != 0) && (curDetector->getRichTbUpgradeMirror() != 0)) {
+      G4cout << "now setting mirror visb options  " << RichTbUpgradeMirror_vis << G4endl;
+      G4LogicalVolume *RichTbUpgradeMirror_LV = curDetector->getRichTbUpgradeMirror()->getRichTbUpgradeMirrorLVol();
 
+      if (RichTbUpgradeMirror_LV != 0) {
+        // G4cout<<" mirror log vol "<<RichTbUpgradeMirror_LV<<G4endl;
 
+        if (RichTbUpgradeMirror_vis == 0) {
+          RichTbUpgradeMirror_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
 
-	G4int RichTbPMTFrontRing_vis = aRunConfig->getRichTbPMTFrontRing_visib();
-	G4cout<<"PMT front ring visib flag  "<<RichTbPMTFrontRing_vis<<G4endl;
+          G4VisAttributes *RichTbUpgradeMirror_LogVisAtt = new G4VisAttributes(G4Colour(0.1, 0.8, 0.8));
 
-	if(  (curDetector != 0)  && (curDetector-> getRichTbPMT() != 0)){
+          if (RichTbUpgradeMirror_vis == 2) {
+            RichTbUpgradeMirror_LogVisAtt->SetForceSolid(false);
+            RichTbUpgradeMirror_LogVisAtt->SetForceWireframe(true);
+            G4cout << "test mirror vis " << RichTbUpgradeMirror_vis << G4endl;
+          }
+          if (RichTbUpgradeMirror_vis == 1) {
+            RichTbUpgradeMirror_LogVisAtt->SetForceSolid(true);
+          }
 
-		G4cout<<"now setting front ring visib options  "<<RichTbPMTFrontRing_vis<<G4endl;
+          RichTbUpgradeMirror_LogVisAtt->SetVisibility(true);
+          RichTbUpgradeMirror_LV->SetVisAttributes(RichTbUpgradeMirror_LogVisAtt);
+        }
+      }
+    }
+  }
 
-		G4LogicalVolume * RichTbPMTFrontRing_LV =curDetector->
-				getRichTbPMT()-> getRichTbPMTFrontRingLVol();
-		if(RichTbPMTFrontRing_LV != 0 ) {
-			if(RichTbPMTFrontRing_vis == 0 ) {
-				RichTbPMTFrontRing_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-			} else {
-				G4VisAttributes * RichTbPMTFrontRing_LogVisAtt =
-						new G4VisAttributes(G4Colour(1.0,0.0,0.0));
-				if(RichTbPMTFrontRing_vis == 2 ) {
-					RichTbPMTFrontRing_LogVisAtt ->SetForceSolid(false);
-					RichTbPMTFrontRing_LogVisAtt ->SetForceWireframe(true);
-				}
-				if(RichTbPMTFrontRing_vis == 1 ) {
-					RichTbPMTFrontRing_LogVisAtt ->SetForceSolid(true);
-				}
-				RichTbPMTFrontRing_LogVisAtt->SetVisibility(true);
-				RichTbPMTFrontRing_LV -> SetVisAttributes(RichTbPMTFrontRing_LogVisAtt);
+  // now for the crystal master
 
+  G4int RichTbCrystal_vis = aRunConfig->getRichTbCrystal_visib();
+  //  G4cout<<"Crystal visib flag  "<<RichTbCrystal_vis<<G4endl;
 
-			}
+  if ((curDetector != 0) && (curDetector->getRichTbUpgradeCrystalMaster() != 0)) {
+    G4cout << "now setting crystal master visb options  " << G4endl;
 
-		}
+    G4LogicalVolume *RichTbUpgradeCrystalMaster_LV =
+        curDetector->getRichTbUpgradeCrystalMaster()->getRichTbUpgradeCrystalMasterLVol();
+    if (RichTbUpgradeCrystalMaster_LV != 0) {
 
-	}
+      if (RichTbCrystal_vis == 0) {
 
+        RichTbUpgradeCrystalMaster_LV->SetVisAttributes(G4VisAttributes::Invisible);
+      } else {
 
-	if( aRadiatorConfiguration == 2 ) {
+        G4VisAttributes *RichTbUpgradeCrystalMaster_LogVisAtt = new G4VisAttributes(G4Colour(0.2, 0.3, 0.0));
 
-		G4int  RichTbHpdQW_vis =  aRunConfig->getRichTbHpdQW_visib();
-		if( (curDetector != 0) &&  (curDetector-> getRichTbHpd() != 0  ) ) {
+        //              RichTbUpgradeCrystalMaster_LogVisAtt ->SetForceSolid(false);
+        //     RichTbUpgradeCrystalMaster_LogVisAtt ->SetForceWireframe(true);
 
-			G4cout<<"now setting HPD QW visib options  "<< RichTbHpdQW_vis <<G4endl;
+        /*
+else {
+         */
+        // G4VisAttributes * RichTbCrystal_LogVisAtt =
+        //                 new G4VisAttributes(G4Colour(1.,0.0,0.0));
+        if (RichTbCrystal_vis == 2) {
+          RichTbUpgradeCrystalMaster_LogVisAtt->SetForceSolid(false);
+          RichTbUpgradeCrystalMaster_LogVisAtt->SetForceWireframe(true);
+          // G4cout<<"test crystal vis "<<RichTbCrystal_vis<<G4endl;
+        }
+        if (RichTbCrystal_vis == 1) {
+          RichTbUpgradeCrystalMaster_LogVisAtt->SetForceSolid(true);
+        }
+        RichTbUpgradeCrystalMaster_LogVisAtt->SetVisibility(true);
+        RichTbUpgradeCrystalMaster_LV->SetVisAttributes(RichTbUpgradeCrystalMaster_LogVisAtt);
+      }
+    }
+  }
+
+  // now for the upgrade phdet frame
+  G4int RichTbPhdet_vis = aRunConfig->getRichTbPhDetSupFrame_visib();
+  if ((curDetector != 0) && (curDetector->getRichTbUpgradePhDetSupFrame() != 0)) {
+    G4cout << " Now setting PhDetFrame visib options " << G4endl;
+    G4LogicalVolume *RichTbPhDetLeft_LV =
+        curDetector->getRichTbUpgradePhDetSupFrame()->getRichTbPhDetSupFrameLeftLVol();
+    G4LogicalVolume *RichTbPhDetRight_LV =
+        curDetector->getRichTbUpgradePhDetSupFrame()->getRichTbPhDetSupFrameRightLVol();
+    G4LogicalVolume *RichTbPhDetBottomLeft_LV;
+    G4LogicalVolume *RichTbPhDetBottomRight_LV;
+    if (aRadiatorConfiguration == 3) {
+      RichTbPhDetBottomLeft_LV = curDetector->getRichTbUpgradePhDetSupFrame()->getRichTbPhDetSupFrameBottomLeftLVol();
+      RichTbPhDetBottomRight_LV = curDetector->getRichTbUpgradePhDetSupFrame()->getRichTbPhDetSupFrameBottomRightLVol();
+    }
+    if ((RichTbPhDetLeft_LV != 0) && (RichTbPhDetRight_LV != 0)) {
+      if (RichTbPhdet_vis == 0) {
+        RichTbPhDetLeft_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        RichTbPhDetRight_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        if ((aRadiatorConfiguration == 3) && (RichTbPhDetBottomLeft_LV != 0) && (RichTbPhDetBottomRight_LV != 0)) {
+          RichTbPhDetBottomLeft_LV->SetVisAttributes(G4VisAttributes::Invisible);
+          RichTbPhDetBottomRight_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        }
+      } else {
+        G4VisAttributes *RichTbPhDetSupFrame_LogVisAtt = new G4VisAttributes(G4Colour(0.3, 0.3, 0.7));
 
-			G4LogicalVolume * RichTbHpdQW_LV =curDetector->getRichTbHpd()-> getRichTbHpdQuartzWLVol();
-			if( RichTbHpdQW_LV != 0 ) {
+        if (RichTbPhdet_vis == 2) {
+          RichTbPhDetSupFrame_LogVisAtt->SetForceSolid(false);
+          RichTbPhDetSupFrame_LogVisAtt->SetForceWireframe(true);
+        }
+        if (RichTbPhdet_vis == 1) {
+          RichTbPhDetSupFrame_LogVisAtt->SetForceSolid(true);
+        }
+        RichTbPhDetSupFrame_LogVisAtt->SetVisibility(true);
+        RichTbPhDetLeft_LV->SetVisAttributes(RichTbPhDetSupFrame_LogVisAtt);
+        RichTbPhDetRight_LV->SetVisAttributes(RichTbPhDetSupFrame_LogVisAtt);
+        if ((aRadiatorConfiguration == 3) && (RichTbPhDetBottomLeft_LV != 0) && (RichTbPhDetBottomRight_LV != 0)) {
+          RichTbPhDetBottomLeft_LV->SetVisAttributes(RichTbPhDetSupFrame_LogVisAtt);
+          RichTbPhDetBottomRight_LV->SetVisAttributes(RichTbPhDetSupFrame_LogVisAtt);
+        }
+      }
+    }
+  }
+
+  // now for the upgrade EC
+  G4int RichTbEC_vis = aRunConfig->getRichTbEC_visib();
+  if ((curDetector != 0) && (curDetector->getRichTbEC() != 0)) {
+    G4cout << " Now setting EC visib options " << G4endl;
+    G4LogicalVolume *RichTbECLeft_LV = curDetector->getRichTbEC()->getRichTbECLeftLVol();
+    G4LogicalVolume *RichTbECRight_LV =
+        (aRadiatorConfiguration == 2) ? 0 : curDetector->getRichTbEC()->getRichTbECRightLVol();
+    G4LogicalVolume *RichTbECBottomLeft_LV;
+    G4LogicalVolume *RichTbECBottomRight_LV;
+    if (aRadiatorConfiguration == 3) {
+      RichTbECBottomLeft_LV = curDetector->getRichTbEC()->getRichTbECBottomLeftLVol();
+      RichTbECBottomRight_LV = curDetector->getRichTbEC()->getRichTbECBottomRightLVol();
+    }
+    G4VisAttributes *RichTbEC_LogVisAtt = new G4VisAttributes(G4Colour(0.7, 0.3, 0.7));
+    if (RichTbECLeft_LV != 0) {
+      if (RichTbEC_vis == 0) {
+        RichTbECLeft_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        if ((aRadiatorConfiguration == 3) && (RichTbECBottomLeft_LV != 0) && (RichTbECBottomRight_LV != 0)) {
+          RichTbECBottomLeft_LV->SetVisAttributes(G4VisAttributes::Invisible);
+          RichTbECBottomRight_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        }
+      } else {
 
-				if( RichTbHpdQW_vis == 0 ){
-					RichTbHpdQW_LV -> SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
+        if (RichTbEC_vis == 2) {
+          RichTbEC_LogVisAtt->SetForceSolid(false);
+          RichTbEC_LogVisAtt->SetForceWireframe(true);
+        }
+        if (RichTbEC_vis == 1)
+          RichTbEC_LogVisAtt->SetForceSolid(true);
+        RichTbEC_LogVisAtt->SetVisibility(true);
+        RichTbECLeft_LV->SetVisAttributes(RichTbEC_LogVisAtt);
+        if ((aRadiatorConfiguration == 3) && (RichTbECBottomLeft_LV != 0) && (RichTbECBottomRight_LV != 0)) {
+          RichTbECBottomLeft_LV->SetVisAttributes(RichTbEC_LogVisAtt);
+          RichTbECBottomRight_LV->SetVisAttributes(RichTbEC_LogVisAtt);
+        }
+      }
+    }
+    if (RichTbECRight_LV != 0) {
+      if (RichTbEC_vis == 0)
+        RichTbECRight_LV->SetVisAttributes(G4VisAttributes::Invisible);
+      else
+        RichTbECRight_LV->SetVisAttributes(RichTbEC_LogVisAtt);
+    }
+  }
+
+  // now for the upgrade PMTmaster
+  // TESTnumPmts
+  G4int CurNumPmts = NumPmtsOld;
+  //	G4int CurNumPmts = RichTbPMTGeometryParameters::getNumPmts();
+  if (aRadiatorConfiguration == 2)
+    CurNumPmts = NumPmtsWithHpd;
+  else if (aRadiatorConfiguration == 3)
+    CurNumPmts = NumPmtsUpgrade15;
+  //	else if (aRadiatorConfiguration == 3) CurNumPmts = RichTbPMTGeometryParameters::getNumPmtsUpgrade();
+  // CurNumPmts = (aRadiatorConfiguration==3) ? NumPmtsUpgrade15 : NumPmts;
+
+  G4int RichTbPMTMaster_vis = aRunConfig->getRichTbPMTMaster_visib();
+  G4cout << "RichTb PMT Master visib flag  " << RichTbPMTMaster_vis << G4endl;
+
+  if ((curDetector != 0) && (curDetector->getRichTbPMT() != 0)) {
+    G4cout << "now setting PMT master visb options  " << RichTbPMTMaster_vis << G4endl;
+
+    std::vector<G4LogicalVolume *> RichTbPMTMaster_LV = curDetector->getRichTbPMT()->getRichTbPMTMasterLVol();
+
+    if ((int)RichTbPMTMaster_LV.size() != 0) {
+      if (RichTbPMTMaster_vis == 0) {
+        for (int i = 0; i < CurNumPmts; i++) {
+          RichTbPMTMaster_LV[i]->SetVisAttributes(G4VisAttributes::Invisible);
+        }
+      } else {
+        G4VisAttributes *RichTbPMTMaster_LogVisAtt = new G4VisAttributes(G4Colour(0.0, 0.2, 0.5));
+        if (RichTbPMTMaster_vis == 2) {
+          RichTbPMTMaster_LogVisAtt->SetForceSolid(false);
+          RichTbPMTMaster_LogVisAtt->SetForceWireframe(true);
+        }
+        if (RichTbPMTMaster_vis == 1) {
+          RichTbPMTMaster_LogVisAtt->SetForceSolid(true);
+        }
+        RichTbPMTMaster_LogVisAtt->SetVisibility(true);
 
-					G4VisAttributes * RichTbHpdQW_LogVisAtt =
-							new G4VisAttributes(G4Colour(1.0,0.6,0.0));
-					if(  RichTbHpdQW_vis == 2 ) {
-						RichTbHpdQW_LogVisAtt -> SetForceSolid(false);
-						RichTbHpdQW_LogVisAtt -> SetForceWireframe(true);
-					}
-					if(  RichTbHpdQW_vis == 1 ) {
-						RichTbHpdQW_LogVisAtt -> SetForceSolid(true);
-					}
-					RichTbHpdQW_LogVisAtt ->SetVisibility(true);
-					RichTbHpdQW_LV ->  SetVisAttributes(RichTbHpdQW_LogVisAtt);
+        for (int i = 0; i < CurNumPmts; i++) {
+          RichTbPMTMaster_LV[i]->SetVisAttributes(RichTbPMTMaster_LogVisAtt);
+        }
+      }
+    }
+  }
 
+  G4int RichTbPMTSMaster_vis = aRunConfig->getRichTbPMTSMaster_visib();
+  G4cout << "RichTb PMT SMaster visib flag  " << RichTbPMTSMaster_vis << G4endl;
 
-				}
+  if ((curDetector != 0) && (curDetector->getRichTbPMT() != 0)) {
+    G4cout << "now setting PMT SMaster visib options  " << RichTbPMTSMaster_vis << G4endl;
 
-			}
+    std::vector<G4LogicalVolume *> RichTbPMTSMaster_LV = curDetector->getRichTbPMT()->getRichTbPMTSMasterLVol();
 
-		}
+    if ((int)RichTbPMTSMaster_LV.size() != 0) {
+      if (RichTbPMTSMaster_vis == 0) {
+        for (int i = 0; i < CurNumPmts; i++) {
+          RichTbPMTSMaster_LV[i]->SetVisAttributes(G4VisAttributes::Invisible);
+        }
+      } else {
+        G4VisAttributes *RichTbPMTSMaster_LogVisAtt = new G4VisAttributes(G4Colour(0.0, 0.2, 0.5));
+        if (RichTbPMTSMaster_vis == 2) {
+          RichTbPMTSMaster_LogVisAtt->SetForceSolid(false);
+          RichTbPMTSMaster_LogVisAtt->SetForceWireframe(true);
+        }
+        if (RichTbPMTSMaster_vis == 1) {
+          RichTbPMTSMaster_LogVisAtt->SetForceSolid(true);
+        }
+        RichTbPMTSMaster_LogVisAtt->SetVisibility(true);
+        for (int i = 0; i < CurNumPmts; i++) {
+          RichTbPMTSMaster_LV[i]->SetVisAttributes(RichTbPMTSMaster_LogVisAtt);
+        }
+      }
+    }
+  }
 
-		G4int  RichTbHpdPHC_vis =  aRunConfig->getRichTbHpdPHC_visib();
-		if( (curDetector != 0) &&  (curDetector-> getRichTbHpd() != 0  ) ) {
+  G4int RichTbPMTAnode_vis = aRunConfig->getRichTbPMTAnode_visib();
+  G4cout << "RichTb PMT Anode visib flag  " << RichTbPMTAnode_vis << G4endl;
 
-			G4cout<<"now setting HPD PHC visib options  "<< RichTbHpdPHC_vis <<G4endl;
+  if ((curDetector != 0) && (curDetector->getRichTbPMT() != 0)) {
+    G4cout << "now setting PMT Anode visib options  " << RichTbPMTAnode_vis << G4endl;
 
-			G4LogicalVolume * RichTbHpdPHC_LV =curDetector->getRichTbHpd()->  getRichTbHpdPhCathodeLVol();
-			if( RichTbHpdPHC_LV != 0 ) {
+    std::vector<G4LogicalVolume *> RichTbPMTAnode_LV = curDetector->getRichTbPMT()->getRichTbPMTAnodeLVol();
 
-				if( RichTbHpdPHC_vis == 0 ){
-					RichTbHpdPHC_LV -> SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
+    if ((int)RichTbPMTAnode_LV.size() != 0) {
+      if (RichTbPMTAnode_vis == 0) {
+        for (int i = 0; i < CurNumPmts; i++) {
+          RichTbPMTAnode_LV[i]->SetVisAttributes(G4VisAttributes::Invisible);
+        }
 
-					G4VisAttributes * RichTbHpdPHC_LogVisAtt =
-							new G4VisAttributes(G4Colour(0.3,0.6,0.8));
-					if(  RichTbHpdPHC_vis == 2 ) {
-						RichTbHpdPHC_LogVisAtt -> SetForceSolid(false);
-						RichTbHpdPHC_LogVisAtt -> SetForceWireframe(true);
-					}
-					if(  RichTbHpdPHC_vis == 1 ) {
-						RichTbHpdPHC_LogVisAtt -> SetForceSolid(true);
-					}
-					RichTbHpdPHC_LogVisAtt ->SetVisibility(true);
-					RichTbHpdPHC_LV ->  SetVisAttributes(RichTbHpdPHC_LogVisAtt);
+      } else {
+        G4VisAttributes *RichTbPMTAnode_LogVisAtt = new G4VisAttributes(G4Colour(0.0, 0.2, 0.5));
+        if (RichTbPMTAnode_vis == 2) {
+          RichTbPMTAnode_LogVisAtt->SetForceSolid(false);
+          RichTbPMTAnode_LogVisAtt->SetForceWireframe(true);
+        }
+        if (RichTbPMTAnode_vis == 1) {
+          RichTbPMTAnode_LogVisAtt->SetForceSolid(true);
+        }
+        RichTbPMTAnode_LogVisAtt->SetVisibility(true);
+        for (int i = 0; i < CurNumPmts; i++) {
+          RichTbPMTAnode_LV[i]->SetVisAttributes(RichTbPMTAnode_LogVisAtt);
+        }
+      }
+    }
+  }
+
+  G4int RichTbPMTEnvelope_vis = aRunConfig->getRichTbPMTEnvelope_visib();
+  G4cout << "PMT Envelope visib flag  " << RichTbPMTEnvelope_vis << G4endl;
+
+  if ((curDetector != 0) && (curDetector->getRichTbPMT() != 0)) {
+    G4cout << "now setting pmt envelope visb options  " << RichTbPMTEnvelope_vis << G4endl;
+
+    G4LogicalVolume *RichTbPMTEnvelope_LV = curDetector->getRichTbPMT()->getRichTbPMTEnvelopeLVol();
+    G4cout << "test PMT Envelope LV " << RichTbPMTEnvelope_LV << G4endl;
+    if (RichTbPMTEnvelope_LV != 0) {
+      if (RichTbPMTEnvelope_vis == 0) {
+        RichTbPMTEnvelope_LV->SetVisAttributes(G4VisAttributes::Invisible);
+      } else {
+        G4VisAttributes *RichTbPMTEnvelope_LogVisAtt = new G4VisAttributes(G4Colour(0.0, 0.8, 0.2));
+        if (RichTbPMTEnvelope_vis == 2) {
+          RichTbPMTEnvelope_LogVisAtt->SetForceSolid(false);
+          RichTbPMTEnvelope_LogVisAtt->SetForceWireframe(true);
+        }
+        if (RichTbPMTEnvelope_vis == 1) {
+          RichTbPMTEnvelope_LogVisAtt->SetForceSolid(true);
+        }
+        RichTbPMTEnvelope_LogVisAtt->SetVisibility(true);
+        RichTbPMTEnvelope_LV->SetVisAttributes(RichTbPMTEnvelope_LogVisAtt);
+      }
+    }
+  }
 
+  G4int RichTbPMTQuartzW_vis = aRunConfig->getRichTbPMTQuartzW_visib();
+  G4cout << "PMT QW window visib flag  " << RichTbPMTQuartzW_vis << G4endl;
 
-				}
+  if ((curDetector != 0) && (curDetector->getRichTbPMT() != 0)) {
+    G4cout << "now setting qw window  visb options  " << RichTbPMTQuartzW_vis << G4endl;
 
-			}
+    G4LogicalVolume *RichTbPMTQuartzW_LV = curDetector->getRichTbPMT()->getRichTbPMTQuartzWLVol();
 
-		}
+    if (RichTbPMTQuartzW_LV != 0) {
+      if (RichTbPMTQuartzW_vis == 0) {
+        RichTbPMTQuartzW_LV->SetVisAttributes(G4VisAttributes::Invisible);
+      } else {
+        G4VisAttributes *RichTbPMTQuartzW_LogVisAtt = new G4VisAttributes(G4Colour(0.2, 0.0, 0.8));
+        if (RichTbPMTQuartzW_vis == 2) {
+          RichTbPMTQuartzW_LogVisAtt->SetForceSolid(false);
+          RichTbPMTQuartzW_LogVisAtt->SetForceWireframe(true);
+        }
+        if (RichTbPMTQuartzW_vis == 1) {
+          RichTbPMTQuartzW_LogVisAtt->SetForceSolid(true);
+        }
+        RichTbPMTQuartzW_LogVisAtt->SetVisibility(true);
+        RichTbPMTQuartzW_LV->SetVisAttributes(RichTbPMTQuartzW_LogVisAtt);
+      }
+    }
+  }
+
+  G4int RichTbPMTCathode_vis = aRunConfig->getRichTbPMTPhCathode_visib();
+  G4cout << "PMT cathod visib flag  " << RichTbPMTCathode_vis << G4endl;
+
+  if ((curDetector != 0) && (curDetector->getRichTbPMT() != 0)) {
+    G4cout << "now setting cathode visib options  " << RichTbPMTCathode_vis << G4endl;
+
+    G4LogicalVolume *RichTbPMTCathode_LV = curDetector->getRichTbPMT()->getRichTbPMTPhCathodeLVol();
+    if (RichTbPMTCathode_LV != 0) {
+      if (RichTbPMTCathode_vis == 0) {
+        RichTbPMTCathode_LV->SetVisAttributes(G4VisAttributes::Invisible);
+      } else {
+        G4VisAttributes *RichTbPMTCathode_LogVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
+        if (RichTbPMTCathode_vis == 2) {
+          RichTbPMTCathode_LogVisAtt->SetForceSolid(false);
+          RichTbPMTCathode_LogVisAtt->SetForceWireframe(true);
+        }
+        if (RichTbPMTCathode_vis == 1) {
+          RichTbPMTCathode_LogVisAtt->SetForceSolid(true);
+        }
+        RichTbPMTCathode_LogVisAtt->SetVisibility(true);
+        RichTbPMTCathode_LV->SetVisAttributes(RichTbPMTCathode_LogVisAtt);
+      }
+    }
+  }
 
-		G4int  RichTbHpdSID_vis =  aRunConfig->getRichTbHpdSID_visib();
-		if( (curDetector != 0) &&  (curDetector-> getRichTbHpd() != 0  ) ) {
+  G4int RichTbPMTFrontRing_vis = aRunConfig->getRichTbPMTFrontRing_visib();
+  G4cout << "PMT front ring visib flag  " << RichTbPMTFrontRing_vis << G4endl;
 
-			G4cout<<"now setting HPD SiDet visib options  "<< RichTbHpdSID_vis <<G4endl;
+  if ((curDetector != 0) && (curDetector->getRichTbPMT() != 0)) {
 
-			G4LogicalVolume * RichTbHpdSID_LV =curDetector->getRichTbHpd()->  getRichTbHpdSiDetLVol ();
-			if( RichTbHpdSID_LV != 0 ) {
+    G4cout << "now setting front ring visib options  " << RichTbPMTFrontRing_vis << G4endl;
 
-				if( RichTbHpdSID_vis == 0 ){
-					RichTbHpdSID_LV -> SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
+    G4LogicalVolume *RichTbPMTFrontRing_LV = curDetector->getRichTbPMT()->getRichTbPMTFrontRingLVol();
+    if (RichTbPMTFrontRing_LV != 0) {
+      if (RichTbPMTFrontRing_vis == 0) {
+        RichTbPMTFrontRing_LV->SetVisAttributes(G4VisAttributes::Invisible);
+      } else {
+        G4VisAttributes *RichTbPMTFrontRing_LogVisAtt = new G4VisAttributes(G4Colour(1.0, 0.0, 0.0));
+        if (RichTbPMTFrontRing_vis == 2) {
+          RichTbPMTFrontRing_LogVisAtt->SetForceSolid(false);
+          RichTbPMTFrontRing_LogVisAtt->SetForceWireframe(true);
+        }
+        if (RichTbPMTFrontRing_vis == 1) {
+          RichTbPMTFrontRing_LogVisAtt->SetForceSolid(true);
+        }
+        RichTbPMTFrontRing_LogVisAtt->SetVisibility(true);
+        RichTbPMTFrontRing_LV->SetVisAttributes(RichTbPMTFrontRing_LogVisAtt);
+      }
+    }
+  }
 
-					G4VisAttributes * RichTbHpdSID_LogVisAtt =
-							new G4VisAttributes(G4Colour(0.3,0.6,0.8));
-					if(  RichTbHpdSID_vis == 2 ) {
-						RichTbHpdSID_LogVisAtt -> SetForceSolid(false);
-						RichTbHpdSID_LogVisAtt -> SetForceWireframe(true);
-					}
-					if(  RichTbHpdSID_vis == 1 ) {
-						RichTbHpdSID_LogVisAtt -> SetForceSolid(true);
-					}
-					RichTbHpdSID_LogVisAtt ->SetVisibility(true);
-					RichTbHpdSID_LV ->  SetVisAttributes(RichTbHpdSID_LogVisAtt);
+  if (aRadiatorConfiguration == 2) {
 
+    G4int RichTbHpdQW_vis = aRunConfig->getRichTbHpdQW_visib();
+    if ((curDetector != 0) && (curDetector->getRichTbHpd() != 0)) {
 
-				}
+      G4cout << "now setting HPD QW visib options  " << RichTbHpdQW_vis << G4endl;
 
-			}
+      G4LogicalVolume *RichTbHpdQW_LV = curDetector->getRichTbHpd()->getRichTbHpdQuartzWLVol();
+      if (RichTbHpdQW_LV != 0) {
 
-		}
+        if (RichTbHpdQW_vis == 0) {
+          RichTbHpdQW_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
 
+          G4VisAttributes *RichTbHpdQW_LogVisAtt = new G4VisAttributes(G4Colour(1.0, 0.6, 0.0));
+          if (RichTbHpdQW_vis == 2) {
+            RichTbHpdQW_LogVisAtt->SetForceSolid(false);
+            RichTbHpdQW_LogVisAtt->SetForceWireframe(true);
+          }
+          if (RichTbHpdQW_vis == 1) {
+            RichTbHpdQW_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbHpdQW_LogVisAtt->SetVisibility(true);
+          RichTbHpdQW_LV->SetVisAttributes(RichTbHpdQW_LogVisAtt);
+        }
+      }
+    }
 
-		G4int  RichTbHpdENV_vis =  aRunConfig->getRichTbHpdENV_visib();
-		if( (curDetector != 0) &&  (curDetector-> getRichTbHpd() != 0  ) ) {
+    G4int RichTbHpdPHC_vis = aRunConfig->getRichTbHpdPHC_visib();
+    if ((curDetector != 0) && (curDetector->getRichTbHpd() != 0)) {
 
-			G4cout<<"now setting HPD Envelope tube  visib options  "<< RichTbHpdENV_vis <<G4endl;
+      G4cout << "now setting HPD PHC visib options  " << RichTbHpdPHC_vis << G4endl;
 
-			G4LogicalVolume * RichTbHpdENV_LV =curDetector->getRichTbHpd()->  getRichTbHpdEnvelopeTubeLVol  ();
+      G4LogicalVolume *RichTbHpdPHC_LV = curDetector->getRichTbHpd()->getRichTbHpdPhCathodeLVol();
+      if (RichTbHpdPHC_LV != 0) {
 
-			if( RichTbHpdENV_LV != 0 ) {
+        if (RichTbHpdPHC_vis == 0) {
+          RichTbHpdPHC_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
 
-				if( RichTbHpdENV_vis == 0 ){
-					RichTbHpdENV_LV -> SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
+          G4VisAttributes *RichTbHpdPHC_LogVisAtt = new G4VisAttributes(G4Colour(0.3, 0.6, 0.8));
+          if (RichTbHpdPHC_vis == 2) {
+            RichTbHpdPHC_LogVisAtt->SetForceSolid(false);
+            RichTbHpdPHC_LogVisAtt->SetForceWireframe(true);
+          }
+          if (RichTbHpdPHC_vis == 1) {
+            RichTbHpdPHC_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbHpdPHC_LogVisAtt->SetVisibility(true);
+          RichTbHpdPHC_LV->SetVisAttributes(RichTbHpdPHC_LogVisAtt);
+        }
+      }
+    }
 
-					G4VisAttributes * RichTbHpdENV_LogVisAtt =
-							new G4VisAttributes(G4Colour(0.2,0.2,0.5));
-					if(  RichTbHpdENV_vis == 2 ) {
-						RichTbHpdENV_LogVisAtt -> SetForceSolid(false);
-						RichTbHpdENV_LogVisAtt -> SetForceWireframe(true);
-					}
-					if(  RichTbHpdENV_vis == 1 ) {
-						RichTbHpdENV_LogVisAtt -> SetForceSolid(true);
-					}
-					RichTbHpdENV_LogVisAtt ->SetVisibility(true);
-					RichTbHpdENV_LV ->  SetVisAttributes(RichTbHpdENV_LogVisAtt);
+    G4int RichTbHpdSID_vis = aRunConfig->getRichTbHpdSID_visib();
+    if ((curDetector != 0) && (curDetector->getRichTbHpd() != 0)) {
 
+      G4cout << "now setting HPD SiDet visib options  " << RichTbHpdSID_vis << G4endl;
 
-				}
+      G4LogicalVolume *RichTbHpdSID_LV = curDetector->getRichTbHpd()->getRichTbHpdSiDetLVol();
+      if (RichTbHpdSID_LV != 0) {
 
-			}
+        if (RichTbHpdSID_vis == 0) {
+          RichTbHpdSID_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
 
-		}
+          G4VisAttributes *RichTbHpdSID_LogVisAtt = new G4VisAttributes(G4Colour(0.3, 0.6, 0.8));
+          if (RichTbHpdSID_vis == 2) {
+            RichTbHpdSID_LogVisAtt->SetForceSolid(false);
+            RichTbHpdSID_LogVisAtt->SetForceWireframe(true);
+          }
+          if (RichTbHpdSID_vis == 1) {
+            RichTbHpdSID_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbHpdSID_LogVisAtt->SetVisibility(true);
+          RichTbHpdSID_LV->SetVisAttributes(RichTbHpdSID_LogVisAtt);
+        }
+      }
+    }
 
-		G4int  RichTbHpdENVCAP_vis =  aRunConfig->getRichTbHpdENVCAP_visib();
-		if( (curDetector != 0) &&  (curDetector-> getRichTbHpd() != 0  ) ) {
+    G4int RichTbHpdENV_vis = aRunConfig->getRichTbHpdENV_visib();
+    if ((curDetector != 0) && (curDetector->getRichTbHpd() != 0)) {
 
-			G4cout<<"now setting HPD Envelope endcap visib options  "<< RichTbHpdENVCAP_vis <<G4endl;
+      G4cout << "now setting HPD Envelope tube  visib options  " << RichTbHpdENV_vis << G4endl;
 
-			G4LogicalVolume * RichTbHpdENVCAP_LV =curDetector->getRichTbHpd()->  getRichTbHpdEnvelopeEndCapLVol();
+      G4LogicalVolume *RichTbHpdENV_LV = curDetector->getRichTbHpd()->getRichTbHpdEnvelopeTubeLVol();
 
-			if( RichTbHpdENVCAP_LV != 0 ) {
+      if (RichTbHpdENV_LV != 0) {
 
-				if( RichTbHpdENVCAP_vis == 0 ){
-					RichTbHpdENVCAP_LV -> SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
+        if (RichTbHpdENV_vis == 0) {
+          RichTbHpdENV_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
 
-					G4VisAttributes * RichTbHpdENVCAP_LogVisAtt =
-							new G4VisAttributes(G4Colour(0.2,0.2,0.5));
-					if(  RichTbHpdENVCAP_vis == 2 ) {
-						RichTbHpdENVCAP_LogVisAtt -> SetForceSolid(false);
-						RichTbHpdENVCAP_LogVisAtt -> SetForceWireframe(true);
-					}
-					if(  RichTbHpdENVCAP_vis == 1 ) {
-						RichTbHpdENVCAP_LogVisAtt -> SetForceSolid(true);
-					}
-					RichTbHpdENVCAP_LogVisAtt ->SetVisibility(true);
-					RichTbHpdENVCAP_LV ->  SetVisAttributes(RichTbHpdENVCAP_LogVisAtt);
+          G4VisAttributes *RichTbHpdENV_LogVisAtt = new G4VisAttributes(G4Colour(0.2, 0.2, 0.5));
+          if (RichTbHpdENV_vis == 2) {
+            RichTbHpdENV_LogVisAtt->SetForceSolid(false);
+            RichTbHpdENV_LogVisAtt->SetForceWireframe(true);
+          }
+          if (RichTbHpdENV_vis == 1) {
+            RichTbHpdENV_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbHpdENV_LogVisAtt->SetVisibility(true);
+          RichTbHpdENV_LV->SetVisAttributes(RichTbHpdENV_LogVisAtt);
+        }
+      }
+    }
 
+    G4int RichTbHpdENVCAP_vis = aRunConfig->getRichTbHpdENVCAP_visib();
+    if ((curDetector != 0) && (curDetector->getRichTbHpd() != 0)) {
 
-				}
+      G4cout << "now setting HPD Envelope endcap visib options  " << RichTbHpdENVCAP_vis << G4endl;
 
-			}
+      G4LogicalVolume *RichTbHpdENVCAP_LV = curDetector->getRichTbHpd()->getRichTbHpdEnvelopeEndCapLVol();
 
-		}
+      if (RichTbHpdENVCAP_LV != 0) {
 
+        if (RichTbHpdENVCAP_vis == 0) {
+          RichTbHpdENVCAP_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
 
-		G4int  RichTbHpdSM_vis =  aRunConfig->getRichTbHpdSM_visib();
-		if( (curDetector != 0) &&  (curDetector-> getRichTbHpd() != 0  ) ) {
+          G4VisAttributes *RichTbHpdENVCAP_LogVisAtt = new G4VisAttributes(G4Colour(0.2, 0.2, 0.5));
+          if (RichTbHpdENVCAP_vis == 2) {
+            RichTbHpdENVCAP_LogVisAtt->SetForceSolid(false);
+            RichTbHpdENVCAP_LogVisAtt->SetForceWireframe(true);
+          }
+          if (RichTbHpdENVCAP_vis == 1) {
+            RichTbHpdENVCAP_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbHpdENVCAP_LogVisAtt->SetVisibility(true);
+          RichTbHpdENVCAP_LV->SetVisAttributes(RichTbHpdENVCAP_LogVisAtt);
+        }
+      }
+    }
 
-			G4cout<<"now setting HPD Smaster visib options  "<< RichTbHpdSM_vis <<G4endl;
+    G4int RichTbHpdSM_vis = aRunConfig->getRichTbHpdSM_visib();
+    if ((curDetector != 0) && (curDetector->getRichTbHpd() != 0)) {
 
-			G4LogicalVolume * RichTbHpdSM_LV =curDetector->getRichTbHpd()-> getRichTbHpdSMasterLVol ();
+      G4cout << "now setting HPD Smaster visib options  " << RichTbHpdSM_vis << G4endl;
 
-			if( RichTbHpdSM_LV != 0 ) {
+      G4LogicalVolume *RichTbHpdSM_LV = curDetector->getRichTbHpd()->getRichTbHpdSMasterLVol();
 
-				if( RichTbHpdSM_vis == 0 ){
-					RichTbHpdSM_LV -> SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
+      if (RichTbHpdSM_LV != 0) {
 
-					G4VisAttributes * RichTbHpdSM_LogVisAtt =
-							new G4VisAttributes(G4Colour(0.7,0.4,0.1));
-					if(  RichTbHpdSM_vis == 2 ) {
-						RichTbHpdSM_LogVisAtt -> SetForceSolid(false);
-						RichTbHpdSM_LogVisAtt -> SetForceWireframe(true);
-					}
-					if(  RichTbHpdSM_vis == 1 ) {
-						RichTbHpdSM_LogVisAtt -> SetForceSolid(true);
-					}
-					RichTbHpdSM_LogVisAtt ->SetVisibility(true);
-					RichTbHpdSM_LV ->  SetVisAttributes(RichTbHpdSM_LogVisAtt);
+        if (RichTbHpdSM_vis == 0) {
+          RichTbHpdSM_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
 
+          G4VisAttributes *RichTbHpdSM_LogVisAtt = new G4VisAttributes(G4Colour(0.7, 0.4, 0.1));
+          if (RichTbHpdSM_vis == 2) {
+            RichTbHpdSM_LogVisAtt->SetForceSolid(false);
+            RichTbHpdSM_LogVisAtt->SetForceWireframe(true);
+          }
+          if (RichTbHpdSM_vis == 1) {
+            RichTbHpdSM_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbHpdSM_LogVisAtt->SetVisibility(true);
+          RichTbHpdSM_LV->SetVisAttributes(RichTbHpdSM_LogVisAtt);
+        }
+      }
+    }
 
-				}
+    G4int RichTbHpdMas_vis = aRunConfig->getRichTbHpdMas_visib();
+    if ((curDetector != 0) && (curDetector->getRichTbHpd() != 0)) {
 
-			}
+      G4cout << "now setting HPD master visib options  " << RichTbHpdMas_vis << G4endl;
 
-		}
+      G4LogicalVolume *RichTbHpdMas_LV = curDetector->getRichTbHpd()->getRichTbHpdMasterLVol();
 
-		G4int  RichTbHpdMas_vis =  aRunConfig->getRichTbHpdMas_visib();
-		if( (curDetector != 0) &&  (curDetector-> getRichTbHpd() != 0  ) ) {
+      if (RichTbHpdMas_LV != 0) {
 
-			G4cout<<"now setting HPD master visib options  "<< RichTbHpdMas_vis <<G4endl;
+        if (RichTbHpdMas_vis == 0) {
+          RichTbHpdMas_LV->SetVisAttributes(G4VisAttributes::Invisible);
+        } else {
 
-			G4LogicalVolume * RichTbHpdMas_LV =curDetector->getRichTbHpd()-> getRichTbHpdMasterLVol ();
+          G4VisAttributes *RichTbHpdMas_LogVisAtt = new G4VisAttributes(G4Colour(0.3, 0.7, 0.5));
+          if (RichTbHpdMas_vis == 2) {
+            RichTbHpdMas_LogVisAtt->SetForceSolid(false);
+            RichTbHpdMas_LogVisAtt->SetForceWireframe(true);
+          }
+          if (RichTbHpdMas_vis == 1) {
+            RichTbHpdMas_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbHpdMas_LogVisAtt->SetVisibility(true);
+          RichTbHpdMas_LV->SetVisAttributes(RichTbHpdMas_LogVisAtt);
+        }
+      }
+    }
 
-			if( RichTbHpdMas_LV != 0 ) {
+    G4int RichTbHpdPix_vis = aRunConfig->getRichTbHpdSiPix_visib();
+    if (RichTbHpdPix_vis > 5) {
 
-				if( RichTbHpdMas_vis == 0 ){
-					RichTbHpdMas_LV -> SetVisAttributes(G4VisAttributes::Invisible);
-				} else {
+      if ((curDetector != 0) && (curDetector->getRichTbHpd() != 0)) {
 
-					G4VisAttributes * RichTbHpdMas_LogVisAtt =
-							new G4VisAttributes(G4Colour(0.3,0.7,0.5));
-					if(  RichTbHpdMas_vis == 2 ) {
-						RichTbHpdMas_LogVisAtt -> SetForceSolid(false);
-						RichTbHpdMas_LogVisAtt -> SetForceWireframe(true);
-					}
-					if(  RichTbHpdMas_vis == 1 ) {
-						RichTbHpdMas_LogVisAtt -> SetForceSolid(true);
-					}
-					RichTbHpdMas_LogVisAtt ->SetVisibility(true);
-					RichTbHpdMas_LV ->  SetVisAttributes(RichTbHpdMas_LogVisAtt);
+        G4cout << "now setting HPD si pixel  visib options  " << RichTbHpdPix_vis << G4endl;
 
+        G4LogicalVolume *RichTbHpdPix_LV = curDetector->getRichTbHpd()->getRichTbSiPixelLVol();
+        if (RichTbHpdPix_vis == 10) {
 
-				}
+          RichTbHpdPix_LV->SetVisAttributes(G4VisAttributes::Invisible);
 
-			}
+        } else {
 
-		}
+          G4VisAttributes *RichTbHpdPix_LogVisAtt = new G4VisAttributes(G4Colour(0.2, 0.4, 0.7));
 
+          if (RichTbHpdPix_vis == 12) {
+            RichTbHpdPix_LogVisAtt->SetForceSolid(false);
+            RichTbHpdPix_LogVisAtt->SetForceWireframe(true);
+          }
+          if (RichTbHpdPix_vis == 11) {
+            RichTbHpdPix_LogVisAtt->SetForceSolid(true);
+          }
+          RichTbHpdPix_LogVisAtt->SetVisibility(true);
+          RichTbHpdPix_LV->SetVisAttributes(RichTbHpdPix_LogVisAtt);
+        }
+      }
+    }
+  }
 
+  // now the PMT1 !
 
-		G4int  RichTbHpdPix_vis =  aRunConfig->getRichTbHpdSiPix_visib();
-		if( RichTbHpdPix_vis > 5 ) {
+  // now for the PMTEnvelope
 
-			if( (curDetector != 0) &&  (curDetector-> getRichTbHpd() != 0  ) ) {
+  /*
+G4int RichTbPMT1Envelope_vis = aRunConfig->getRichTbPMTEnvelope_visib();
+G4cout<<"PMT Envelope visib flag  "<<RichTbPMT1Envelope_vis<<G4endl;
 
-				G4cout<<"now setting HPD si pixel  visib options  "<< RichTbHpdPix_vis <<G4endl;
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT1() != 0))
+{
+  G4cout<<"now setting pmt envelope visb options  "<<RichTbPMT1Envelope_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTEnvelope_LV =curDetector->
+  getRichTbPMT1()-> getRichTbPMTEnvelopeBoxLVol();
+G4cout<<"test PMT Envelope LV "<<RichTbPMTEnvelope_LV<<G4endl;
+if(RichTbPMTEnvelope_LV != 0 ) {
+  if(RichTbPMT1Envelope_vis == 0 ) {
+    RichTbPMTEnvelope_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT1Envelope_LogVisAtt =
+                       new G4VisAttributes(G4Colour(0.0,0.8,0.2));
+    if(RichTbPMT1Envelope_vis == 2 ) {
+        RichTbPMT1Envelope_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT1Envelope_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test Hped Envelope vis "<<RichTbPMT1Envelope_vis<<G4endl;
+    }
+    if(RichTbPMT1Envelope_vis == 1 ) {
+        RichTbPMT1Envelope_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPMT1Envelope_LogVisAtt->SetVisibility(true);
+    RichTbPMTEnvelope_LV -> SetVisAttributes(RichTbPMT1Envelope_LogVisAtt);
 
-				G4LogicalVolume * RichTbHpdPix_LV =curDetector->getRichTbHpd()-> getRichTbSiPixelLVol() ;
-				if(  RichTbHpdPix_vis  == 10 ) {
+  }
 
-					RichTbHpdPix_LV  -> SetVisAttributes(G4VisAttributes::Invisible);
+}
 
-				}else {
+}
 
-					G4VisAttributes * RichTbHpdPix_LogVisAtt =
-							new G4VisAttributes(G4Colour(0.2,0.4,0.7));
+// now for the PMT window
 
-					if(  RichTbHpdPix_vis == 12 ) {
-						RichTbHpdPix_LogVisAtt -> SetForceSolid(false);
-						RichTbHpdPix_LogVisAtt -> SetForceWireframe(true);
-					}
-					if(  RichTbHpdPix_vis == 11 ) {
-						RichTbHpdPix_LogVisAtt -> SetForceSolid(true);
-					}
-					RichTbHpdPix_LogVisAtt  ->SetVisibility(true);
-					RichTbHpdPix_LV ->  SetVisAttributes( RichTbHpdPix_LogVisAtt );
+G4int RichTbPMT1QuartzW_vis = aRunConfig->getRichTbPMTQuartzW_visib();
+G4cout<<"PMT window visib flag  "<<RichTbPMT1QuartzW_vis<<G4endl;
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT1() != 0))
+{
+  G4cout<<"now setting window  visb options  "<<RichTbPMT1QuartzW_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTQuartzW_LV =curDetector->
+  getRichTbPMT1()-> getRichTbPMTQuartzWLVol();
+// G4cout<<"test PMT window LV "<<RichTbPMTQuartzW_LV<<G4endl;
+if(RichTbPMTQuartzW_LV != 0 ) {
+  if(RichTbPMT1QuartzW_vis == 0 ) {
+    RichTbPMTQuartzW_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT1QuartzW_LogVisAtt =
+                       new G4VisAttributes(G4Colour(0.2,0.0,0.8));
+    if(RichTbPMT1QuartzW_vis == 2 ) {
+        RichTbPMT1QuartzW_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT1QuartzW_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test PMT window vis "<<RichTbPMT1QuartzW_vis<<G4endl;
+    }
+    if(RichTbPMT1QuartzW_vis == 1 ) {
+        RichTbPMT1QuartzW_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPMT1QuartzW_LogVisAtt->SetVisibility(true);
+    RichTbPMTQuartzW_LV -> SetVisAttributes(RichTbPMT1QuartzW_LogVisAtt);
 
-				}
-			}
-		}
-	}
+  }
 
+}
 
+}
 
+// now for the PMT photocathode
 
+G4int RichTbPMT1Cathode_vis = aRunConfig->getRichTbPMTPhCathode_visib();
+G4cout<<"PMT cathod visib flag  "<<RichTbPMT1Cathode_vis<<G4endl;
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT1() != 0))
+{
+  G4cout<<"now setting cathode visb options  "<<RichTbPMT1Cathode_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTCathode_LV =curDetector->
+  getRichTbPMT1()-> getRichTbPMTPhCathodeLVol();
+if(RichTbPMTCathode_LV != 0 ) {
+  if(RichTbPMT1Cathode_vis == 0 ) {
+    RichTbPMTCathode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT1Cathode_LogVisAtt =
+                       new G4VisAttributes(G4Colour(1.0,0.0,0.0));
+    if(RichTbPMT1Cathode_vis == 2 ) {
+        RichTbPMT1Cathode_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT1Cathode_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test PMT photocathode vis "<<RichTbPMT1Cathode_vis<<G4endl;
+    }
+    if(RichTbPMT1Cathode_vis == 1 ) {
+        RichTbPMT1Cathode_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPMT1Cathode_LogVisAtt->SetVisibility(true);
+    RichTbPMTCathode_LV -> SetVisAttributes(RichTbPMT1Cathode_LogVisAtt);
+    G4cout<<"prova prova "<<G4endl;
 
+  }
 
+}
 
+}
 
+// now for the PMT anode
 
+G4int RichTbPMT1Anode_vis = aRunConfig->getRichTbPMTAnode_visib();
+G4cout<<"PMT anod visib flag  "<<RichTbPMT1Anode_vis<<G4endl;
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT1() != 0))
+{
+  G4cout<<"now setting cathode visb options  "<<RichTbPMT1Anode_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTAnode_LV =curDetector->
+  getRichTbPMT1()-> getRichTbPMTAnodeLVol();
+if(RichTbPMTAnode_LV != 0 ) {
+  if(RichTbPMT1Anode_vis == 0 ) {
+    RichTbPMTAnode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT1Anode_LogVisAtt =
+                       new G4VisAttributes(G4Colour(0.5,0.0,0.2));
+    if(RichTbPMT1Anode_vis == 2 ) {
+        RichTbPMT1Anode_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT1Anode_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test PMT anode vis "<<RichTbPMT1Anode_vis<<G4endl;
+    }
+    if(RichTbPMT1Anode_vis == 1 ) {
+        RichTbPMT1Anode_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPMT1Anode_LogVisAtt->SetVisibility(true);
+    RichTbPMTAnode_LV -> SetVisAttributes(RichTbPMT1Anode_LogVisAtt);
 
-	//now the PMT1 !
 
-	// now for the PMTEnvelope
+  }
 
-	/*
-    G4int RichTbPMT1Envelope_vis = aRunConfig->getRichTbPMTEnvelope_visib();
-     G4cout<<"PMT Envelope visib flag  "<<RichTbPMT1Envelope_vis<<G4endl;
+}
 
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT1() != 0))
-    {
-        G4cout<<"now setting pmt envelope visb options  "<<RichTbPMT1Envelope_vis<<G4endl;
+}
 
-      G4LogicalVolume * RichTbPMTEnvelope_LV =curDetector->
-        getRichTbPMT1()-> getRichTbPMTEnvelopeBoxLVol();
-      G4cout<<"test PMT Envelope LV "<<RichTbPMTEnvelope_LV<<G4endl;
-      if(RichTbPMTEnvelope_LV != 0 ) {
-        if(RichTbPMT1Envelope_vis == 0 ) {
-          RichTbPMTEnvelope_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT1Envelope_LogVisAtt =
-                             new G4VisAttributes(G4Colour(0.0,0.8,0.2));
-          if(RichTbPMT1Envelope_vis == 2 ) {
-              RichTbPMT1Envelope_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT1Envelope_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test Hped Envelope vis "<<RichTbPMT1Envelope_vis<<G4endl;
-          }
-          if(RichTbPMT1Envelope_vis == 1 ) {
-              RichTbPMT1Envelope_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT1Envelope_LogVisAtt->SetVisibility(true);
-          RichTbPMTEnvelope_LV -> SetVisAttributes(RichTbPMT1Envelope_LogVisAtt);
+//now the PMT2 !
 
-        }
+// now for the PMTEnvelope
 
-      }
+G4int RichTbPMT2Envelope_vis = aRunConfig->getRichTbPMTEnvelope_visib();
+G4cout<<"PMT Envelope visib flag  "<<RichTbPMT2Envelope_vis<<G4endl;
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT2() != 0))
+{
+  G4cout<<"now setting hpd envelope visb options  "<<RichTbPMT2Envelope_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTEnvelope_LV =curDetector->
+  getRichTbPMT2()-> getRichTbPMTEnvelopeBoxLVol();
+G4cout<<"test PMT Envelope LV "<<RichTbPMTEnvelope_LV<<G4endl;
+if(RichTbPMTEnvelope_LV != 0 ) {
+  if(RichTbPMT2Envelope_vis == 0 ) {
+    RichTbPMTEnvelope_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT2Envelope_LogVisAtt =
+                       new G4VisAttributes(G4Colour(0.0,0.8,0.2));
+    if(RichTbPMT2Envelope_vis == 2 ) {
+        RichTbPMT2Envelope_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT2Envelope_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test Hped Envelope vis "<<RichTbPMT2Envelope_vis<<G4endl;
     }
+    if(RichTbPMT2Envelope_vis == 1 ) {
+        RichTbPMT2Envelope_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPMT2Envelope_LogVisAtt->SetVisibility(true);
+    RichTbPMTEnvelope_LV -> SetVisAttributes(RichTbPMT2Envelope_LogVisAtt);
 
-// now for the PMT window
-
-    G4int RichTbPMT1QuartzW_vis = aRunConfig->getRichTbPMTQuartzW_visib();
-     G4cout<<"PMT window visib flag  "<<RichTbPMT1QuartzW_vis<<G4endl;
+  }
 
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT1() != 0))
-    {
-        G4cout<<"now setting window  visb options  "<<RichTbPMT1QuartzW_vis<<G4endl;
+}
 
-      G4LogicalVolume * RichTbPMTQuartzW_LV =curDetector->
-	getRichTbPMT1()-> getRichTbPMTQuartzWLVol();
-      // G4cout<<"test PMT window LV "<<RichTbPMTQuartzW_LV<<G4endl;
-      if(RichTbPMTQuartzW_LV != 0 ) {
-        if(RichTbPMT1QuartzW_vis == 0 ) {
-          RichTbPMTQuartzW_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT1QuartzW_LogVisAtt =
-                             new G4VisAttributes(G4Colour(0.2,0.0,0.8));
-          if(RichTbPMT1QuartzW_vis == 2 ) {
-              RichTbPMT1QuartzW_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT1QuartzW_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test PMT window vis "<<RichTbPMT1QuartzW_vis<<G4endl;
-          }
-          if(RichTbPMT1QuartzW_vis == 1 ) {
-              RichTbPMT1QuartzW_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT1QuartzW_LogVisAtt->SetVisibility(true);
-          RichTbPMTQuartzW_LV -> SetVisAttributes(RichTbPMT1QuartzW_LogVisAtt);
+}
 
-        }
+// now for the PMT window
 
-      }
+G4int RichTbPMT2QuartzW_vis = aRunConfig->getRichTbPMTQuartzW_visib();
+G4cout<<"PMT window visib flag  "<<RichTbPMT2QuartzW_vis<<G4endl;
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT2() != 0))
+{
+  G4cout<<"now setting window  visb options  "<<RichTbPMT2QuartzW_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTQuartzW_LV =curDetector->
+  getRichTbPMT2()-> getRichTbPMTQuartzWLVol();
+G4cout<<"test PMT window LV "<<RichTbPMTQuartzW_LV<<G4endl;
+if(RichTbPMTQuartzW_LV != 0 ) {
+  if(RichTbPMT2QuartzW_vis == 0 ) {
+    RichTbPMTQuartzW_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT2QuartzW_LogVisAtt =
+                       new G4VisAttributes(G4Colour(0.2,0.0,0.8));
+    if(RichTbPMT2QuartzW_vis == 2 ) {
+        RichTbPMT2QuartzW_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT2QuartzW_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test PMT window vis "<<RichTbPMT2QuartzW_vis<<G4endl;
     }
+    if(RichTbPMT2QuartzW_vis == 1 ) {
+        RichTbPMT2QuartzW_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPMT2QuartzW_LogVisAtt->SetVisibility(true);
+    RichTbPMTQuartzW_LV -> SetVisAttributes(RichTbPMT2QuartzW_LogVisAtt);
 
-// now for the PMT photocathode
-
-    G4int RichTbPMT1Cathode_vis = aRunConfig->getRichTbPMTPhCathode_visib();
-     G4cout<<"PMT cathod visib flag  "<<RichTbPMT1Cathode_vis<<G4endl;
+  }
 
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT1() != 0))
-    {
-        G4cout<<"now setting cathode visb options  "<<RichTbPMT1Cathode_vis<<G4endl;
+}
 
-      G4LogicalVolume * RichTbPMTCathode_LV =curDetector->
-        getRichTbPMT1()-> getRichTbPMTPhCathodeLVol();
-      if(RichTbPMTCathode_LV != 0 ) {
-        if(RichTbPMT1Cathode_vis == 0 ) {
-          RichTbPMTCathode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT1Cathode_LogVisAtt =
-                             new G4VisAttributes(G4Colour(1.0,0.0,0.0));
-          if(RichTbPMT1Cathode_vis == 2 ) {
-              RichTbPMT1Cathode_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT1Cathode_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test PMT photocathode vis "<<RichTbPMT1Cathode_vis<<G4endl;
-          }
-          if(RichTbPMT1Cathode_vis == 1 ) {
-              RichTbPMT1Cathode_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT1Cathode_LogVisAtt->SetVisibility(true);
-          RichTbPMTCathode_LV -> SetVisAttributes(RichTbPMT1Cathode_LogVisAtt);
-	  G4cout<<"prova prova "<<G4endl;
+}
 
-        }
+// now for the PMT photocathode
 
-      }
+G4int RichTbPMT2Cathode_vis = aRunConfig->getRichTbPMTPhCathode_visib();
+G4cout<<"PMT cathod visib flag  "<<RichTbPMT2Cathode_vis<<G4endl;
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT2() != 0))
+{
+  G4cout<<"now setting cathode visb options  "<<RichTbPMT2Cathode_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTCathode_LV =curDetector->
+  getRichTbPMT2()-> getRichTbPMTPhCathodeLVol();
+if(RichTbPMTCathode_LV != 0 ) {
+  if(RichTbPMT2Cathode_vis == 0 ) {
+    RichTbPMTCathode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT2Cathode_LogVisAtt =
+                       new G4VisAttributes(G4Colour(1.0,0.0,0.0));
+    if(RichTbPMT2Cathode_vis == 2 ) {
+        RichTbPMT2Cathode_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT2Cathode_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test PMT photocathode vis "<<RichTbPMT2Cathode_vis<<G4endl;
     }
+    if(RichTbPMT2Cathode_vis == 1 ) {
+        RichTbPMT2Cathode_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPMT2Cathode_LogVisAtt->SetVisibility(true);
+    RichTbPMTCathode_LV -> SetVisAttributes(RichTbPMT2Cathode_LogVisAtt);
+    G4cout<<"prova prova "<<G4endl;
 
-// now for the PMT anode
-
-    G4int RichTbPMT1Anode_vis = aRunConfig->getRichTbPMTAnode_visib();
-     G4cout<<"PMT anod visib flag  "<<RichTbPMT1Anode_vis<<G4endl;
-
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT1() != 0))
-    {
-        G4cout<<"now setting cathode visb options  "<<RichTbPMT1Anode_vis<<G4endl;
+  }
 
-      G4LogicalVolume * RichTbPMTAnode_LV =curDetector->
-        getRichTbPMT1()-> getRichTbPMTAnodeLVol();
-      if(RichTbPMTAnode_LV != 0 ) {
-        if(RichTbPMT1Anode_vis == 0 ) {
-          RichTbPMTAnode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT1Anode_LogVisAtt =
-                             new G4VisAttributes(G4Colour(0.5,0.0,0.2));
-          if(RichTbPMT1Anode_vis == 2 ) {
-              RichTbPMT1Anode_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT1Anode_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test PMT anode vis "<<RichTbPMT1Anode_vis<<G4endl;
-          }
-          if(RichTbPMT1Anode_vis == 1 ) {
-              RichTbPMT1Anode_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT1Anode_LogVisAtt->SetVisibility(true);
-          RichTbPMTAnode_LV -> SetVisAttributes(RichTbPMT1Anode_LogVisAtt);
+}
 
+}
 
-        }
+// now for the PMT anode
 
-      }
+G4int RichTbPMT2Anode_vis = aRunConfig->getRichTbPMTAnode_visib();
+G4cout<<"PMT anod visib flag  "<<RichTbPMT2Anode_vis<<G4endl;
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT2() != 0))
+{
+  G4cout<<"now setting cathode visb options  "<<RichTbPMT2Anode_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTAnode_LV =curDetector->
+  getRichTbPMT2()-> getRichTbPMTAnodeLVol();
+if(RichTbPMTAnode_LV != 0 ) {
+  if(RichTbPMT2Anode_vis == 0 ) {
+    RichTbPMTAnode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT2Anode_LogVisAtt =
+                       new G4VisAttributes(G4Colour(0.5,0.0,0.2));
+    if(RichTbPMT2Anode_vis == 2 ) {
+        RichTbPMT2Anode_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT2Anode_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test PMT anode vis "<<RichTbPMT2Anode_vis<<G4endl;
     }
+    if(RichTbPMT2Anode_vis == 1 ) {
+        RichTbPMT2Anode_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPMT2Anode_LogVisAtt->SetVisibility(true);
+    RichTbPMTAnode_LV -> SetVisAttributes(RichTbPMT2Anode_LogVisAtt);
+    G4cout<<"prova prova "<<G4endl;
 
- //now the PMT2 !
-
- // now for the PMTEnvelope
+  }
 
-    G4int RichTbPMT2Envelope_vis = aRunConfig->getRichTbPMTEnvelope_visib();
-     G4cout<<"PMT Envelope visib flag  "<<RichTbPMT2Envelope_vis<<G4endl;
+}
 
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT2() != 0))
-    {
-        G4cout<<"now setting hpd envelope visb options  "<<RichTbPMT2Envelope_vis<<G4endl;
+}
 
-      G4LogicalVolume * RichTbPMTEnvelope_LV =curDetector->
-        getRichTbPMT2()-> getRichTbPMTEnvelopeBoxLVol();
-      G4cout<<"test PMT Envelope LV "<<RichTbPMTEnvelope_LV<<G4endl;
-      if(RichTbPMTEnvelope_LV != 0 ) {
-        if(RichTbPMT2Envelope_vis == 0 ) {
-          RichTbPMTEnvelope_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT2Envelope_LogVisAtt =
-                             new G4VisAttributes(G4Colour(0.0,0.8,0.2));
-          if(RichTbPMT2Envelope_vis == 2 ) {
-              RichTbPMT2Envelope_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT2Envelope_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test Hped Envelope vis "<<RichTbPMT2Envelope_vis<<G4endl;
-          }
-          if(RichTbPMT2Envelope_vis == 1 ) {
-              RichTbPMT2Envelope_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT2Envelope_LogVisAtt->SetVisibility(true);
-          RichTbPMTEnvelope_LV -> SetVisAttributes(RichTbPMT2Envelope_LogVisAtt);
+//now the PMT 3 !
 
-        }
+// now for the PMTEnvelope
 
-      }
+G4int RichTbPMT3Envelope_vis = aRunConfig->getRichTbPMTEnvelope_visib();
+G4cout<<"PMT Envelope visib flag  "<<RichTbPMT3Envelope_vis<<G4endl;
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT3() != 0))
+{
+  G4cout<<"now setting hpd envelope visb options  "<<RichTbPMT3Envelope_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTEnvelope_LV =curDetector->
+  getRichTbPMT3()-> getRichTbPMTEnvelopeBoxLVol();
+G4cout<<"test PMT Envelope LV "<<RichTbPMTEnvelope_LV<<G4endl;
+if(RichTbPMTEnvelope_LV != 0 ) {
+  if(RichTbPMT3Envelope_vis == 0 ) {
+    RichTbPMTEnvelope_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT3Envelope_LogVisAtt =
+                       new G4VisAttributes(G4Colour(0.0,0.8,0.2));
+    if(RichTbPMT3Envelope_vis == 2 ) {
+        RichTbPMT3Envelope_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT3Envelope_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test Hped Envelope vis "<<RichTbPMT3Envelope_vis<<G4endl;
     }
+    if(RichTbPMT3Envelope_vis == 1 ) {
+        RichTbPMT3Envelope_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPMT3Envelope_LogVisAtt->SetVisibility(true);
+    RichTbPMTEnvelope_LV -> SetVisAttributes(RichTbPMT3Envelope_LogVisAtt);
 
-// now for the PMT window
-
-    G4int RichTbPMT2QuartzW_vis = aRunConfig->getRichTbPMTQuartzW_visib();
-     G4cout<<"PMT window visib flag  "<<RichTbPMT2QuartzW_vis<<G4endl;
+  }
 
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT2() != 0))
-    {
-        G4cout<<"now setting window  visb options  "<<RichTbPMT2QuartzW_vis<<G4endl;
+}
 
-      G4LogicalVolume * RichTbPMTQuartzW_LV =curDetector->
-	getRichTbPMT2()-> getRichTbPMTQuartzWLVol();
-      G4cout<<"test PMT window LV "<<RichTbPMTQuartzW_LV<<G4endl;
-      if(RichTbPMTQuartzW_LV != 0 ) {
-        if(RichTbPMT2QuartzW_vis == 0 ) {
-          RichTbPMTQuartzW_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT2QuartzW_LogVisAtt =
-                             new G4VisAttributes(G4Colour(0.2,0.0,0.8));
-          if(RichTbPMT2QuartzW_vis == 2 ) {
-              RichTbPMT2QuartzW_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT2QuartzW_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test PMT window vis "<<RichTbPMT2QuartzW_vis<<G4endl;
-          }
-          if(RichTbPMT2QuartzW_vis == 1 ) {
-              RichTbPMT2QuartzW_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT2QuartzW_LogVisAtt->SetVisibility(true);
-          RichTbPMTQuartzW_LV -> SetVisAttributes(RichTbPMT2QuartzW_LogVisAtt);
+}
 
-        }
+// now for the PMT window
 
-      }
+G4int RichTbPMT3QuartzW_vis = aRunConfig->getRichTbPMTQuartzW_visib();
+G4cout<<"PMT window visib flag  "<<RichTbPMT3QuartzW_vis<<G4endl;
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT3() != 0))
+{
+  G4cout<<"now setting window  visb options  "<<RichTbPMT3QuartzW_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTQuartzW_LV =curDetector->
+  getRichTbPMT3()-> getRichTbPMTQuartzWLVol();
+// G4cout<<"test PMT window LV "<<RichTbPMTQuartzW_LV<<G4endl;
+if(RichTbPMTQuartzW_LV != 0 ) {
+  if(RichTbPMT3QuartzW_vis == 0 ) {
+    RichTbPMTQuartzW_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT3QuartzW_LogVisAtt =
+                       new G4VisAttributes(G4Colour(0.2,0.0,0.8));
+    if(RichTbPMT3QuartzW_vis == 2 ) {
+        RichTbPMT3QuartzW_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT3QuartzW_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test PMT window vis "<<RichTbPMT3QuartzW_vis<<G4endl;
     }
+    if(RichTbPMT3QuartzW_vis == 1 ) {
+        RichTbPMT3QuartzW_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPMT3QuartzW_LogVisAtt->SetVisibility(true);
+    RichTbPMTQuartzW_LV -> SetVisAttributes(RichTbPMT3QuartzW_LogVisAtt);
 
-// now for the PMT photocathode
-
-    G4int RichTbPMT2Cathode_vis = aRunConfig->getRichTbPMTPhCathode_visib();
-     G4cout<<"PMT cathod visib flag  "<<RichTbPMT2Cathode_vis<<G4endl;
+  }
 
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT2() != 0))
-    {
-        G4cout<<"now setting cathode visb options  "<<RichTbPMT2Cathode_vis<<G4endl;
+}
 
-      G4LogicalVolume * RichTbPMTCathode_LV =curDetector->
-        getRichTbPMT2()-> getRichTbPMTPhCathodeLVol();
-      if(RichTbPMTCathode_LV != 0 ) {
-        if(RichTbPMT2Cathode_vis == 0 ) {
-          RichTbPMTCathode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT2Cathode_LogVisAtt =
-                             new G4VisAttributes(G4Colour(1.0,0.0,0.0));
-          if(RichTbPMT2Cathode_vis == 2 ) {
-              RichTbPMT2Cathode_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT2Cathode_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test PMT photocathode vis "<<RichTbPMT2Cathode_vis<<G4endl;
-          }
-          if(RichTbPMT2Cathode_vis == 1 ) {
-              RichTbPMT2Cathode_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT2Cathode_LogVisAtt->SetVisibility(true);
-          RichTbPMTCathode_LV -> SetVisAttributes(RichTbPMT2Cathode_LogVisAtt);
-	  G4cout<<"prova prova "<<G4endl;
+}
 
-        }
+// now for the PMT photocathode
 
-      }
+G4int RichTbPMT3Cathode_vis = aRunConfig->getRichTbPMTPhCathode_visib();
+G4cout<<"PMT cathod visib flag  "<<RichTbPMT3Cathode_vis<<G4endl;
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT3() != 0))
+{
+  G4cout<<"now setting cathode visb options  "<<RichTbPMT3Cathode_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTCathode_LV =curDetector->
+  getRichTbPMT3()-> getRichTbPMTPhCathodeLVol();
+if(RichTbPMTCathode_LV != 0 ) {
+  if(RichTbPMT3Cathode_vis == 0 ) {
+    RichTbPMTCathode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT3Cathode_LogVisAtt =
+                       new G4VisAttributes(G4Colour(1.0,0.0,0.0));
+    if(RichTbPMT3Cathode_vis == 2 ) {
+        RichTbPMT3Cathode_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT3Cathode_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test PMT photocathode vis "<<RichTbPMT3Cathode_vis<<G4endl;
     }
+    if(RichTbPMT3Cathode_vis == 1 ) {
+        RichTbPMT3Cathode_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPMT3Cathode_LogVisAtt->SetVisibility(true);
+    RichTbPMTCathode_LV -> SetVisAttributes(RichTbPMT3Cathode_LogVisAtt);
 
-// now for the PMT anode
 
-    G4int RichTbPMT2Anode_vis = aRunConfig->getRichTbPMTAnode_visib();
-     G4cout<<"PMT anod visib flag  "<<RichTbPMT2Anode_vis<<G4endl;
+  }
 
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT2() != 0))
-    {
-        G4cout<<"now setting cathode visb options  "<<RichTbPMT2Anode_vis<<G4endl;
+}
 
-      G4LogicalVolume * RichTbPMTAnode_LV =curDetector->
-        getRichTbPMT2()-> getRichTbPMTAnodeLVol();
-      if(RichTbPMTAnode_LV != 0 ) {
-        if(RichTbPMT2Anode_vis == 0 ) {
-          RichTbPMTAnode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT2Anode_LogVisAtt =
-                             new G4VisAttributes(G4Colour(0.5,0.0,0.2));
-          if(RichTbPMT2Anode_vis == 2 ) {
-              RichTbPMT2Anode_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT2Anode_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test PMT anode vis "<<RichTbPMT2Anode_vis<<G4endl;
-          }
-          if(RichTbPMT2Anode_vis == 1 ) {
-              RichTbPMT2Anode_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT2Anode_LogVisAtt->SetVisibility(true);
-          RichTbPMTAnode_LV -> SetVisAttributes(RichTbPMT2Anode_LogVisAtt);
-	  G4cout<<"prova prova "<<G4endl;
+}
 
-        }
+// now for the PMT anode
 
-      }
+G4int RichTbPMT3Anode_vis = aRunConfig->getRichTbPMTAnode_visib();
+G4cout<<"PMT anod visib flag  "<<RichTbPMT3Anode_vis<<G4endl;
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT3() != 0))
+{
+  G4cout<<"now setting cathode visb options  "<<RichTbPMT3Anode_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTAnode_LV =curDetector->
+  getRichTbPMT3()-> getRichTbPMTAnodeLVol();
+if(RichTbPMTAnode_LV != 0 ) {
+  if(RichTbPMT3Anode_vis == 0 ) {
+    RichTbPMTAnode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT3Anode_LogVisAtt =
+                       new G4VisAttributes(G4Colour(0.5,0.0,0.2));
+    if(RichTbPMT3Anode_vis == 2 ) {
+        RichTbPMT3Anode_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT3Anode_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test PMT anode vis "<<RichTbPMT3Anode_vis<<G4endl;
     }
+    if(RichTbPMT3Anode_vis == 1 ) {
+        RichTbPMT3Anode_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPMT3Anode_LogVisAtt->SetVisibility(true);
+    RichTbPMTAnode_LV -> SetVisAttributes(RichTbPMT3Anode_LogVisAtt);
 
- //now the PMT 3 !
+  }
 
- // now for the PMTEnvelope
+}
 
-    G4int RichTbPMT3Envelope_vis = aRunConfig->getRichTbPMTEnvelope_visib();
-     G4cout<<"PMT Envelope visib flag  "<<RichTbPMT3Envelope_vis<<G4endl;
+}
 
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT3() != 0))
-    {
-        G4cout<<"now setting hpd envelope visb options  "<<RichTbPMT3Envelope_vis<<G4endl;
+//now the PMT4 !
 
-      G4LogicalVolume * RichTbPMTEnvelope_LV =curDetector->
-        getRichTbPMT3()-> getRichTbPMTEnvelopeBoxLVol();
-      G4cout<<"test PMT Envelope LV "<<RichTbPMTEnvelope_LV<<G4endl;
-      if(RichTbPMTEnvelope_LV != 0 ) {
-        if(RichTbPMT3Envelope_vis == 0 ) {
-          RichTbPMTEnvelope_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT3Envelope_LogVisAtt =
-                             new G4VisAttributes(G4Colour(0.0,0.8,0.2));
-          if(RichTbPMT3Envelope_vis == 2 ) {
-              RichTbPMT3Envelope_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT3Envelope_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test Hped Envelope vis "<<RichTbPMT3Envelope_vis<<G4endl;
-          }
-          if(RichTbPMT3Envelope_vis == 1 ) {
-              RichTbPMT3Envelope_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT3Envelope_LogVisAtt->SetVisibility(true);
-          RichTbPMTEnvelope_LV -> SetVisAttributes(RichTbPMT3Envelope_LogVisAtt);
-
-        }
+// now for the PMTEnvelope
 
-      }
+G4int RichTbPMT4Envelope_vis = aRunConfig->getRichTbPMTEnvelope_visib();
+G4cout<<"PMT Envelope visib flag  "<<RichTbPMT4Envelope_vis<<G4endl;
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT4() != 0))
+{
+  G4cout<<"now setting hpd envelope visb options  "<<RichTbPMT4Envelope_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTEnvelope_LV =curDetector->
+  getRichTbPMT4()-> getRichTbPMTEnvelopeBoxLVol();
+G4cout<<"test PMT Envelope LV "<<RichTbPMTEnvelope_LV<<G4endl;
+if(RichTbPMTEnvelope_LV != 0 ) {
+  if(RichTbPMT4Envelope_vis == 0 ) {
+    RichTbPMTEnvelope_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT4Envelope_LogVisAtt =
+                       new G4VisAttributes(G4Colour(0.0,0.8,0.2));
+    if(RichTbPMT4Envelope_vis == 2 ) {
+        RichTbPMT4Envelope_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT4Envelope_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test Hped Envelope vis "<<RichTbPMT4Envelope_vis<<G4endl;
     }
+    if(RichTbPMT4Envelope_vis == 1 ) {
+        RichTbPMT4Envelope_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPMT4Envelope_LogVisAtt->SetVisibility(true);
+    RichTbPMTEnvelope_LV -> SetVisAttributes(RichTbPMT4Envelope_LogVisAtt);
 
-// now for the PMT window
-
-    G4int RichTbPMT3QuartzW_vis = aRunConfig->getRichTbPMTQuartzW_visib();
-     G4cout<<"PMT window visib flag  "<<RichTbPMT3QuartzW_vis<<G4endl;
+  }
 
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT3() != 0))
-    {
-        G4cout<<"now setting window  visb options  "<<RichTbPMT3QuartzW_vis<<G4endl;
+}
 
-      G4LogicalVolume * RichTbPMTQuartzW_LV =curDetector->
-	getRichTbPMT3()-> getRichTbPMTQuartzWLVol();
-      // G4cout<<"test PMT window LV "<<RichTbPMTQuartzW_LV<<G4endl;
-      if(RichTbPMTQuartzW_LV != 0 ) {
-        if(RichTbPMT3QuartzW_vis == 0 ) {
-          RichTbPMTQuartzW_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT3QuartzW_LogVisAtt =
-                             new G4VisAttributes(G4Colour(0.2,0.0,0.8));
-          if(RichTbPMT3QuartzW_vis == 2 ) {
-              RichTbPMT3QuartzW_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT3QuartzW_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test PMT window vis "<<RichTbPMT3QuartzW_vis<<G4endl;
-          }
-          if(RichTbPMT3QuartzW_vis == 1 ) {
-              RichTbPMT3QuartzW_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT3QuartzW_LogVisAtt->SetVisibility(true);
-          RichTbPMTQuartzW_LV -> SetVisAttributes(RichTbPMT3QuartzW_LogVisAtt);
+}
 
-        }
+// now for the PMT window
 
-      }
+G4int RichTbPMT4QuartzW_vis = aRunConfig->getRichTbPMTQuartzW_visib();
+G4cout<<"PMT window visib flag  "<<RichTbPMT4QuartzW_vis<<G4endl;
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT4() != 0))
+{
+  G4cout<<"now setting window  visb options  "<<RichTbPMT4QuartzW_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTQuartzW_LV =curDetector->
+  getRichTbPMT4()-> getRichTbPMTQuartzWLVol();
+G4cout<<"test PMT window LV "<<RichTbPMTQuartzW_LV<<G4endl;
+if(RichTbPMTQuartzW_LV != 0 ) {
+  if(RichTbPMT4QuartzW_vis == 0 ) {
+    RichTbPMTQuartzW_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT4QuartzW_LogVisAtt =
+                       new G4VisAttributes(G4Colour(0.2,0.0,0.8));
+    if(RichTbPMT4QuartzW_vis == 2 ) {
+        RichTbPMT4QuartzW_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT4QuartzW_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test PMT window vis "<<RichTbPMT4QuartzW_vis<<G4endl;
     }
+    if(RichTbPMT4QuartzW_vis == 1 ) {
+        RichTbPMT4QuartzW_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPMT4QuartzW_LogVisAtt->SetVisibility(true);
+    RichTbPMTQuartzW_LV -> SetVisAttributes(RichTbPMT4QuartzW_LogVisAtt);
 
-// now for the PMT photocathode
-
-    G4int RichTbPMT3Cathode_vis = aRunConfig->getRichTbPMTPhCathode_visib();
-     G4cout<<"PMT cathod visib flag  "<<RichTbPMT3Cathode_vis<<G4endl;
-
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT3() != 0))
-    {
-        G4cout<<"now setting cathode visb options  "<<RichTbPMT3Cathode_vis<<G4endl;
+  }
 
-      G4LogicalVolume * RichTbPMTCathode_LV =curDetector->
-        getRichTbPMT3()-> getRichTbPMTPhCathodeLVol();
-      if(RichTbPMTCathode_LV != 0 ) {
-        if(RichTbPMT3Cathode_vis == 0 ) {
-          RichTbPMTCathode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT3Cathode_LogVisAtt =
-                             new G4VisAttributes(G4Colour(1.0,0.0,0.0));
-          if(RichTbPMT3Cathode_vis == 2 ) {
-              RichTbPMT3Cathode_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT3Cathode_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test PMT photocathode vis "<<RichTbPMT3Cathode_vis<<G4endl;
-          }
-          if(RichTbPMT3Cathode_vis == 1 ) {
-              RichTbPMT3Cathode_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT3Cathode_LogVisAtt->SetVisibility(true);
-          RichTbPMTCathode_LV -> SetVisAttributes(RichTbPMT3Cathode_LogVisAtt);
+}
 
+}
 
-        }
+// now for the PMT photocathode
 
-      }
+G4int RichTbPMT4Cathode_vis = aRunConfig->getRichTbPMTPhCathode_visib();
+G4cout<<"PMT cathod visib flag  "<<RichTbPMT4Cathode_vis<<G4endl;
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT4() != 0))
+{
+  G4cout<<"now setting cathode visb options  "<<RichTbPMT4Cathode_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTCathode_LV =curDetector->
+  getRichTbPMT4()-> getRichTbPMTPhCathodeLVol();
+if(RichTbPMTCathode_LV != 0 ) {
+  if(RichTbPMT4Cathode_vis == 0 ) {
+    RichTbPMTCathode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT4Cathode_LogVisAtt =
+                       new G4VisAttributes(G4Colour(1.0,0.0,0.0));
+    if(RichTbPMT4Cathode_vis == 2 ) {
+        RichTbPMT4Cathode_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT4Cathode_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test PMT photocathode vis "<<RichTbPMT4Cathode_vis<<G4endl;
     }
+    if(RichTbPMT4Cathode_vis == 1 ) {
+        RichTbPMT4Cathode_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPMT4Cathode_LogVisAtt->SetVisibility(true);
+    RichTbPMTCathode_LV -> SetVisAttributes(RichTbPMT4Cathode_LogVisAtt);
+    G4cout<<"prova prova "<<G4endl;
 
-// now for the PMT anode
-
-    G4int RichTbPMT3Anode_vis = aRunConfig->getRichTbPMTAnode_visib();
-     G4cout<<"PMT anod visib flag  "<<RichTbPMT3Anode_vis<<G4endl;
+  }
 
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT3() != 0))
-    {
-        G4cout<<"now setting cathode visb options  "<<RichTbPMT3Anode_vis<<G4endl;
+}
 
-      G4LogicalVolume * RichTbPMTAnode_LV =curDetector->
-        getRichTbPMT3()-> getRichTbPMTAnodeLVol();
-      if(RichTbPMTAnode_LV != 0 ) {
-        if(RichTbPMT3Anode_vis == 0 ) {
-          RichTbPMTAnode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT3Anode_LogVisAtt =
-                             new G4VisAttributes(G4Colour(0.5,0.0,0.2));
-          if(RichTbPMT3Anode_vis == 2 ) {
-              RichTbPMT3Anode_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT3Anode_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test PMT anode vis "<<RichTbPMT3Anode_vis<<G4endl;
-          }
-          if(RichTbPMT3Anode_vis == 1 ) {
-              RichTbPMT3Anode_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT3Anode_LogVisAtt->SetVisibility(true);
-          RichTbPMTAnode_LV -> SetVisAttributes(RichTbPMT3Anode_LogVisAtt);
+}
 
-        }
+// now for the PMT anode
 
-      }
+G4int RichTbPMT4Anode_vis = aRunConfig->getRichTbPMTAnode_visib();
+G4cout<<"PMT anod visib flag  "<<RichTbPMT4Anode_vis<<G4endl;
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPMT4() != 0))
+{
+  G4cout<<"now setting cathode visb options  "<<RichTbPMT4Anode_vis<<G4endl;
+
+G4LogicalVolume * RichTbPMTAnode_LV =curDetector->
+  getRichTbPMT4()-> getRichTbPMTAnodeLVol();
+if(RichTbPMTAnode_LV != 0 ) {
+  if(RichTbPMT4Anode_vis == 0 ) {
+    RichTbPMTAnode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPMT4Anode_LogVisAtt =
+                       new G4VisAttributes(G4Colour(0.5,0.0,0.2));
+    if(RichTbPMT4Anode_vis == 2 ) {
+        RichTbPMT4Anode_LogVisAtt ->SetForceSolid(false);
+        RichTbPMT4Anode_LogVisAtt ->SetForceWireframe(true);
+        G4cout<<"test PMT anode vis "<<RichTbPMT4Anode_vis<<G4endl;
+    }
+    if(RichTbPMT4Anode_vis == 1 ) {
+        RichTbPMT4Anode_LogVisAtt ->SetForceSolid(true);
     }
+    RichTbPMT4Anode_LogVisAtt->SetVisibility(true);
+    RichTbPMTAnode_LV -> SetVisAttributes(RichTbPMT4Anode_LogVisAtt);
 
- //now the PMT4 !
+  }
 
- // now for the PMTEnvelope
+}
 
-    G4int RichTbPMT4Envelope_vis = aRunConfig->getRichTbPMTEnvelope_visib();
-     G4cout<<"PMT Envelope visib flag  "<<RichTbPMT4Envelope_vis<<G4endl;
+}
 
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT4() != 0))
-    {
-        G4cout<<"now setting hpd envelope visb options  "<<RichTbPMT4Envelope_vis<<G4endl;
+   */
 
-      G4LogicalVolume * RichTbPMTEnvelope_LV =curDetector->
-        getRichTbPMT4()-> getRichTbPMTEnvelopeBoxLVol();
-      G4cout<<"test PMT Envelope LV "<<RichTbPMTEnvelope_LV<<G4endl;
-      if(RichTbPMTEnvelope_LV != 0 ) {
-        if(RichTbPMT4Envelope_vis == 0 ) {
-          RichTbPMTEnvelope_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT4Envelope_LogVisAtt =
-                             new G4VisAttributes(G4Colour(0.0,0.8,0.2));
-          if(RichTbPMT4Envelope_vis == 2 ) {
-              RichTbPMT4Envelope_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT4Envelope_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test Hped Envelope vis "<<RichTbPMT4Envelope_vis<<G4endl;
-          }
-          if(RichTbPMT4Envelope_vis == 1 ) {
-              RichTbPMT4Envelope_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT4Envelope_LogVisAtt->SetVisibility(true);
-          RichTbPMTEnvelope_LV -> SetVisAttributes(RichTbPMT4Envelope_LogVisAtt);
+  // now for the PhDFrame
+  /*
 
-        }
-
-      }
+G4int RichTbPhDFrame_vis = aRunConfig->getRichTbPhDFrame_visib();
 
+if(  (curDetector != 0)  && (curDetector-> getRichTbPhDFrame() != 0))
+{
+  G4cout<<"now setting PhDFrame visb options  "<<RichTbPhDFrame_vis<<G4endl;
+
+G4LogicalVolume * RichTbPhDFrame_LV =curDetector->
+  getRichTbPhDFrame()-> getRichTbPhDFrameLVol();
+if(RichTbPhDFrame_LV != 0 ) {
+  if(RichTbPhDFrame_vis == 0 ) {
+    RichTbPhDFrame_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+  } else {
+    G4VisAttributes * RichTbPhDFrame_LogVisAtt =
+                       new G4VisAttributes(G4Colour(0.5,0.0,0.5));
+    if(RichTbPhDFrame_vis == 2 ) {
+        RichTbPhDFrame_LogVisAtt ->SetForceSolid(false);
+        RichTbPhDFrame_LogVisAtt ->SetForceWireframe(true);
+        // G4cout<<"test crystal vis "<<RichTbCrystal_vis<<G4endl;
     }
+    if(RichTbPhDFrame_vis == 1 ) {
+        RichTbPhDFrame_LogVisAtt ->SetForceSolid(true);
+    }
+    RichTbPhDFrame_LogVisAtt->SetVisibility(true);
+    RichTbPhDFrame_LV -> SetVisAttributes(RichTbPhDFrame_LogVisAtt);
 
-// now for the PMT window
-
-    G4int RichTbPMT4QuartzW_vis = aRunConfig->getRichTbPMTQuartzW_visib();
-     G4cout<<"PMT window visib flag  "<<RichTbPMT4QuartzW_vis<<G4endl;
-
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT4() != 0))
-    {
-        G4cout<<"now setting window  visb options  "<<RichTbPMT4QuartzW_vis<<G4endl;
-
-      G4LogicalVolume * RichTbPMTQuartzW_LV =curDetector->
-	getRichTbPMT4()-> getRichTbPMTQuartzWLVol();
-      G4cout<<"test PMT window LV "<<RichTbPMTQuartzW_LV<<G4endl;
-      if(RichTbPMTQuartzW_LV != 0 ) {
-        if(RichTbPMT4QuartzW_vis == 0 ) {
-          RichTbPMTQuartzW_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT4QuartzW_LogVisAtt =
-                             new G4VisAttributes(G4Colour(0.2,0.0,0.8));
-          if(RichTbPMT4QuartzW_vis == 2 ) {
-              RichTbPMT4QuartzW_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT4QuartzW_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test PMT window vis "<<RichTbPMT4QuartzW_vis<<G4endl;
-          }
-          if(RichTbPMT4QuartzW_vis == 1 ) {
-              RichTbPMT4QuartzW_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT4QuartzW_LogVisAtt->SetVisibility(true);
-          RichTbPMTQuartzW_LV -> SetVisAttributes(RichTbPMT4QuartzW_LogVisAtt);
+  }
 
-        }
+}
 
-      }
+}
 
-    }
 
-// now for the PMT photocathode
 
-    G4int RichTbPMT4Cathode_vis = aRunConfig->getRichTbPMTPhCathode_visib();
-     G4cout<<"PMT cathod visib flag  "<<RichTbPMT4Cathode_vis<<G4endl;
 
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT4() != 0))
-    {
-        G4cout<<"now setting cathode visb options  "<<RichTbPMT4Cathode_vis<<G4endl;
+   */
+  /*
+// Now for the Photdet sup frame and the HPDs
+
+G4int RichTbPhDet_vis=aRunConfig-> getRichTbPhDetSupFrame_visib();
+// G4int RichTbGasQuWin_vis=aRunConfig-> getRichTbGasQuWin_visib();
+//G4int RichTbPMTMaster_vis=aRunConfig-> getRichTbPMTMaster_visib();
+//G4int RichTbPMTSMaster_vis=aRunConfig-> getRichTbPMTSMaster_visib();
+//G4int RichTbPMTEnvelope_vis=aRunConfig-> getRichTbPMTEnvelope_visib();
+//G4int RichTbPMTEndCap_vis= aRunConfig->getRichTbPMTEndCap_visib();
+//G4int RichTbPMTQuartzW_vis= aRunConfig->getRichTbPMTQuartzW_visib();
+//G4int RichTbPMTPhCathode_vis=aRunConfig->getRichTbPMTPhCathode_visib();
+//G4int RichTbPMTSiDet_vis= aRunConfig-> getRichTbPMTSiDet_visib();
+if(  (curDetector != 0)  && (curDetector-> getRichTbPhDetSupFrame() != 0 )){
+RichTbPhDetSupFrame*   aPhSupFrame =
+          curDetector-> getRichTbPhDetSupFrame();
+G4LogicalVolume * RichTbPhSubFrame_LV =
+          aPhSupFrame->   getRichTbPhDetSupFrameLVol() ;
+if(RichTbPhSubFrame_LV != 0 ) {
+
+ if( RichTbPhDet_vis == 0) {
+   RichTbPhSubFrame_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+
+ }else {
+   G4VisAttributes *  RichTbPhSubFrame_LogVisAtt =
+     new  G4VisAttributes(G4Colour(0.5,0.6,0.5));
+   if(RichTbPhDet_vis == 2 ) {
+     RichTbPhSubFrame_LogVisAtt->SetForceSolid(false);
+     RichTbPhSubFrame_LogVisAtt->SetForceWireframe(true);
+   }
+   if(RichTbPhDet_vis == 1 ) {
+     RichTbPhSubFrame_LogVisAtt->SetForceSolid(true);
+   }
+     RichTbPhSubFrame_LogVisAtt->  SetVisibility(true);
+     RichTbPhSubFrame_LV ->SetVisAttributes(RichTbPhSubFrame_LogVisAtt);
+ }
 
-      G4LogicalVolume * RichTbPMTCathode_LV =curDetector->
-        getRichTbPMT4()-> getRichTbPMTPhCathodeLVol();
-      if(RichTbPMTCathode_LV != 0 ) {
-        if(RichTbPMT4Cathode_vis == 0 ) {
-          RichTbPMTCathode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT4Cathode_LogVisAtt =
-                             new G4VisAttributes(G4Colour(1.0,0.0,0.0));
-          if(RichTbPMT4Cathode_vis == 2 ) {
-              RichTbPMT4Cathode_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT4Cathode_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test PMT photocathode vis "<<RichTbPMT4Cathode_vis<<G4endl;
-          }
-          if(RichTbPMT4Cathode_vis == 1 ) {
-              RichTbPMT4Cathode_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT4Cathode_LogVisAtt->SetVisibility(true);
-          RichTbPMTCathode_LV -> SetVisAttributes(RichTbPMT4Cathode_LogVisAtt);
-	  G4cout<<"prova prova "<<G4endl;
+}
 
-        }
+G4LogicalVolume * RichTbGasQuWin_LV= aPhSupFrame->getRichTbGasQuWinLVol();
+if( RichTbGasQuWin_LV !=0 ) {
+ if(  RichTbGasQuWin_vis ==0 ) {
+    RichTbGasQuWin_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+ }else {
+   G4VisAttributes *  RichTbGasQuWin_LogVisAtt =
+     new  G4VisAttributes(G4Colour(0.5,0.4,0.2));
+   if( RichTbGasQuWin_vis  == 2 ) {
+     RichTbGasQuWin_LogVisAtt->SetForceSolid(false);
+     RichTbGasQuWin_LogVisAtt->SetForceWireframe(true);
+   }
+   if( RichTbGasQuWin_vis  == 1 ) {
+     RichTbGasQuWin_LogVisAtt->SetForceSolid(true);
+   }
+    RichTbGasQuWin_LogVisAtt->SetVisibility(true);
+    RichTbGasQuWin_LV ->SetVisAttributes(RichTbGasQuWin_LogVisAtt);
+ }
+}
 
+for (G4int ih=0; ih< (aPhSupFrame-> getNumPMTVol()) ; ih++){
+ //       G4cout<<" Now setting display options for HPD "<<ih<<G4endl;
+
+ RichTbPMT* curPMT = aPhSupFrame->getSinglePMTVolume(ih);
+
+ if(curPMT !=0 ) {
+   G4LogicalVolume* RichTbPMTMaster_LV= curPMT->getRichTbPMTMasterLVol();
+   if(RichTbPMTMaster_LV != 0 ) {
+     if( RichTbPMTMaster_vis == 0 ) {
+       RichTbPMTMaster_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+     }else {
+      G4VisAttributes * RichTbPMTMaster_LogVisAtt =
+        new  G4VisAttributes (G4Colour(0.8,0.4,0.7));
+      if(RichTbPMTMaster_vis == 2 ) {
+         RichTbPMTMaster_LogVisAtt->SetForceSolid(false);
+       RichTbPMTMaster_LogVisAtt->SetForceWireframe(true);
       }
+      if(RichTbPMTMaster_vis == 1 ) {
+        RichTbPMTMaster_LogVisAtt->SetForceSolid(true);
+      }
+      RichTbPMTMaster_LogVisAtt ->SetVisibility(true);
+      RichTbPMTMaster_LV->SetVisAttributes(RichTbPMTMaster_LogVisAtt);
 
-    }
-
-// now for the PMT anode
-
-    G4int RichTbPMT4Anode_vis = aRunConfig->getRichTbPMTAnode_visib();
-     G4cout<<"PMT anod visib flag  "<<RichTbPMT4Anode_vis<<G4endl;
-
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPMT4() != 0))
-    {
-        G4cout<<"now setting cathode visb options  "<<RichTbPMT4Anode_vis<<G4endl;
+     }
+   }
 
-      G4LogicalVolume * RichTbPMTAnode_LV =curDetector->
-        getRichTbPMT4()-> getRichTbPMTAnodeLVol();
-      if(RichTbPMTAnode_LV != 0 ) {
-        if(RichTbPMT4Anode_vis == 0 ) {
-          RichTbPMTAnode_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPMT4Anode_LogVisAtt =
-                             new G4VisAttributes(G4Colour(0.5,0.0,0.2));
-          if(RichTbPMT4Anode_vis == 2 ) {
-              RichTbPMT4Anode_LogVisAtt ->SetForceSolid(false);
-              RichTbPMT4Anode_LogVisAtt ->SetForceWireframe(true);
-	      G4cout<<"test PMT anode vis "<<RichTbPMT4Anode_vis<<G4endl;
-          }
-          if(RichTbPMT4Anode_vis == 1 ) {
-              RichTbPMT4Anode_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPMT4Anode_LogVisAtt->SetVisibility(true);
-          RichTbPMTAnode_LV -> SetVisAttributes(RichTbPMT4Anode_LogVisAtt);
+   G4LogicalVolume* RichTbPMTSMaster_LV=
+                curPMT->getRichTbPMTSMasterLVol();
+   if(RichTbPMTSMaster_LV != 0 ) {
+     if( RichTbPMTSMaster_vis == 0 ) {
+       RichTbPMTSMaster_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+     }else {
+      G4VisAttributes * RichTbPMTSMaster_LogVisAtt =
+        new  G4VisAttributes (G4Colour(0.3,0.4,0.7));
+      if(RichTbPMTSMaster_vis == 2 ) {
+        RichTbPMTSMaster_LogVisAtt->SetForceSolid(false);
+        RichTbPMTSMaster_LogVisAtt->SetForceWireframe(true);
+      }
+      if(RichTbPMTSMaster_vis == 1 ) {
+        RichTbPMTSMaster_LogVisAtt->SetForceSolid(true);
+      }
+      RichTbPMTSMaster_LogVisAtt ->SetVisibility(true);
+      RichTbPMTSMaster_LV->SetVisAttributes(RichTbPMTSMaster_LogVisAtt);
 
-        }
+     }
+   }
 
+   G4LogicalVolume*  RichTbPMTEnvelopeTube_LV =
+       curPMT->getRichTbPMTEnvelopeTubeLVol();
+   if(RichTbPMTEnvelopeTube_LV != 0 ) {
+     if(RichTbPMTEnvelope_vis == 0) {
+        RichTbPMTEnvelopeTube_LV->
+            SetVisAttributes(G4VisAttributes::Invisible);
+     }else {
+      G4VisAttributes *  RichTbPMTEnvelopeTube_LogVisAtt =
+        new  G4VisAttributes(G4Colour(0.4,0.2,0.8));
+      if(RichTbPMTEnvelope_vis == 2){
+        RichTbPMTEnvelopeTube_LogVisAtt->SetForceSolid(false);
+        RichTbPMTEnvelopeTube_LogVisAtt->SetForceWireframe(true);
+      }
+      if(RichTbPMTEnvelope_vis == 1){
+        RichTbPMTEnvelopeTube_LogVisAtt->SetForceSolid(true);
       }
+      RichTbPMTEnvelopeTube_LogVisAtt->SetVisibility(true);
+      RichTbPMTEnvelopeTube_LV->
+         SetVisAttributes(RichTbPMTEnvelopeTube_LogVisAtt);
 
-    }
+     }
 
-	 */
+   }
 
+   G4LogicalVolume*  RichTbPMTEndCap_LV =
+       curPMT->getRichTbPMTEnvelopeEndCapLVol();
+   if(RichTbPMTEndCap_LV != 0 ) {
+     if(RichTbPMTEndCap_vis == 0) {
+        RichTbPMTEndCap_LV->
+            SetVisAttributes(G4VisAttributes::Invisible);
+     }else {
+      G4VisAttributes *  RichTbPMTEndCap_LogVisAtt =
+        new  G4VisAttributes(G4Colour(0.3,0.2,0.8));
+      if(RichTbPMTEndCap_vis == 2){
+        RichTbPMTEndCap_LogVisAtt->SetForceSolid(false);
+        RichTbPMTEndCap_LogVisAtt->SetForceWireframe(true);
+      }
+      if(RichTbPMTEndCap_vis == 1){
+        RichTbPMTEndCap_LogVisAtt->SetForceSolid(true);
+      }
+      RichTbPMTEndCap_LogVisAtt->SetVisibility(true);
+      RichTbPMTEndCap_LV->
+         SetVisAttributes(RichTbPMTEndCap_LogVisAtt);
 
-	// now for the PhDFrame
-	/*
+     }
 
-    G4int RichTbPhDFrame_vis = aRunConfig->getRichTbPhDFrame_visib();
 
-    if(  (curDetector != 0)  && (curDetector-> getRichTbPhDFrame() != 0))
-    {
-        G4cout<<"now setting PhDFrame visb options  "<<RichTbPhDFrame_vis<<G4endl;
+   }
 
-      G4LogicalVolume * RichTbPhDFrame_LV =curDetector->
-        getRichTbPhDFrame()-> getRichTbPhDFrameLVol();
-      if(RichTbPhDFrame_LV != 0 ) {
-        if(RichTbPhDFrame_vis == 0 ) {
-          RichTbPhDFrame_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-        } else {
-          G4VisAttributes * RichTbPhDFrame_LogVisAtt =
-                             new G4VisAttributes(G4Colour(0.5,0.0,0.5));
-          if(RichTbPhDFrame_vis == 2 ) {
-              RichTbPhDFrame_LogVisAtt ->SetForceSolid(false);
-              RichTbPhDFrame_LogVisAtt ->SetForceWireframe(true);
-	      // G4cout<<"test crystal vis "<<RichTbCrystal_vis<<G4endl;
-          }
-          if(RichTbPhDFrame_vis == 1 ) {
-              RichTbPhDFrame_LogVisAtt ->SetForceSolid(true);
-          }
-          RichTbPhDFrame_LogVisAtt->SetVisibility(true);
-          RichTbPhDFrame_LV -> SetVisAttributes(RichTbPhDFrame_LogVisAtt);
 
-        }
+   G4LogicalVolume*  RichTbPMTQuartzW_LV =
+     curPMT -> getRichTbPMTQuartzWLVol();
 
+   if( RichTbPMTQuartzW_LV != 0 ) {
+     if( RichTbPMTQuartzW_vis == 0 ) {
+        RichTbPMTQuartzW_LV ->
+            SetVisAttributes(G4VisAttributes::Invisible);
+     }else {
+      G4VisAttributes *  RichTbPMTQuartzW_LogVisAtt =
+        new  G4VisAttributes(G4Colour(0.9,0.9,0.8));
+      if(RichTbPMTQuartzW_vis == 2){
+       RichTbPMTQuartzW_LogVisAtt->SetForceSolid(false);
+        RichTbPMTQuartzW_LogVisAtt->SetForceWireframe(true);
+      }
+      if(RichTbPMTQuartzW_vis == 1){
+        RichTbPMTQuartzW_LogVisAtt->SetForceSolid(true);
       }
 
-    }
-
-
-
-
-	 */
-	/*
-   // Now for the Photdet sup frame and the HPDs
-
-   G4int RichTbPhDet_vis=aRunConfig-> getRichTbPhDetSupFrame_visib();
-   // G4int RichTbGasQuWin_vis=aRunConfig-> getRichTbGasQuWin_visib();
-   //G4int RichTbPMTMaster_vis=aRunConfig-> getRichTbPMTMaster_visib();
-   //G4int RichTbPMTSMaster_vis=aRunConfig-> getRichTbPMTSMaster_visib();
-   //G4int RichTbPMTEnvelope_vis=aRunConfig-> getRichTbPMTEnvelope_visib();
-   //G4int RichTbPMTEndCap_vis= aRunConfig->getRichTbPMTEndCap_visib();
-   //G4int RichTbPMTQuartzW_vis= aRunConfig->getRichTbPMTQuartzW_visib();
-   //G4int RichTbPMTPhCathode_vis=aRunConfig->getRichTbPMTPhCathode_visib();
-   //G4int RichTbPMTSiDet_vis= aRunConfig-> getRichTbPMTSiDet_visib();
-   if(  (curDetector != 0)  && (curDetector-> getRichTbPhDetSupFrame() != 0 )){
-     RichTbPhDetSupFrame*   aPhSupFrame =
-                curDetector-> getRichTbPhDetSupFrame();
-     G4LogicalVolume * RichTbPhSubFrame_LV =
-                aPhSupFrame->   getRichTbPhDetSupFrameLVol() ;
-     if(RichTbPhSubFrame_LV != 0 ) {
+      RichTbPMTQuartzW_LogVisAtt->SetVisibility(true);
+     RichTbPMTQuartzW_LV  ->
+         SetVisAttributes(RichTbPMTQuartzW_LogVisAtt);
 
-       if( RichTbPhDet_vis == 0) {
-         RichTbPhSubFrame_LV ->SetVisAttributes(G4VisAttributes::Invisible);
+     }
 
-       }else {
-         G4VisAttributes *  RichTbPhSubFrame_LogVisAtt =
-           new  G4VisAttributes(G4Colour(0.5,0.6,0.5));
-         if(RichTbPhDet_vis == 2 ) {
-           RichTbPhSubFrame_LogVisAtt->SetForceSolid(false);
-           RichTbPhSubFrame_LogVisAtt->SetForceWireframe(true);
-         }
-         if(RichTbPhDet_vis == 1 ) {
-           RichTbPhSubFrame_LogVisAtt->SetForceSolid(true);
-         }
-           RichTbPhSubFrame_LogVisAtt->  SetVisibility(true);
-           RichTbPhSubFrame_LV ->SetVisAttributes(RichTbPhSubFrame_LogVisAtt);
-       }
+   }
 
-     }
+    G4LogicalVolume*  RichTbPMTPhCathode_LV =
+      curPMT->getRichTbPMTPhCathodeLVol();
+
+   if(RichTbPMTPhCathode_LV != 0 ) {
+     if( RichTbPMTPhCathode_vis == 0 ) {
+        RichTbPMTPhCathode_LV->
+            SetVisAttributes(G4VisAttributes::Invisible);
+     }else {
+      G4VisAttributes *  RichTbPMTPhCathode_LogVisAtt =
+        new  G4VisAttributes(G4Colour(0.3,0.2,0.2));
+      if(RichTbPMTPhCathode_vis == 2){
+        RichTbPMTPhCathode_LogVisAtt->SetForceSolid(false);
+        RichTbPMTPhCathode_LogVisAtt->SetForceWireframe(true);
+      }
+      if(RichTbPMTPhCathode_vis == 1){
+        RichTbPMTPhCathode_LogVisAtt->SetForceSolid(true);
+      }
+      RichTbPMTPhCathode_LogVisAtt->SetVisibility(true);
+      RichTbPMTPhCathode_LV->
+         SetVisAttributes(RichTbPMTPhCathode_LogVisAtt);
 
-     G4LogicalVolume * RichTbGasQuWin_LV= aPhSupFrame->getRichTbGasQuWinLVol();
-     if( RichTbGasQuWin_LV !=0 ) {
-       if(  RichTbGasQuWin_vis ==0 ) {
-          RichTbGasQuWin_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-       }else {
-         G4VisAttributes *  RichTbGasQuWin_LogVisAtt =
-           new  G4VisAttributes(G4Colour(0.5,0.4,0.2));
-         if( RichTbGasQuWin_vis  == 2 ) {
-           RichTbGasQuWin_LogVisAtt->SetForceSolid(false);
-           RichTbGasQuWin_LogVisAtt->SetForceWireframe(true);
-         }
-         if( RichTbGasQuWin_vis  == 1 ) {
-           RichTbGasQuWin_LogVisAtt->SetForceSolid(true);
-         }
-          RichTbGasQuWin_LogVisAtt->SetVisibility(true);
-	  RichTbGasQuWin_LV ->SetVisAttributes(RichTbGasQuWin_LogVisAtt);
-       }
      }
 
-     for (G4int ih=0; ih< (aPhSupFrame-> getNumPMTVol()) ; ih++){
-       //       G4cout<<" Now setting display options for HPD "<<ih<<G4endl;
-
-       RichTbPMT* curPMT = aPhSupFrame->getSinglePMTVolume(ih);
-
-       if(curPMT !=0 ) {
-         G4LogicalVolume* RichTbPMTMaster_LV= curPMT->getRichTbPMTMasterLVol();
-         if(RichTbPMTMaster_LV != 0 ) {
-           if( RichTbPMTMaster_vis == 0 ) {
-             RichTbPMTMaster_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-           }else {
-            G4VisAttributes * RichTbPMTMaster_LogVisAtt =
-              new  G4VisAttributes (G4Colour(0.8,0.4,0.7));
-            if(RichTbPMTMaster_vis == 2 ) {
-               RichTbPMTMaster_LogVisAtt->SetForceSolid(false);
-             RichTbPMTMaster_LogVisAtt->SetForceWireframe(true);
-            }
-            if(RichTbPMTMaster_vis == 1 ) {
-              RichTbPMTMaster_LogVisAtt->SetForceSolid(true);
-            }
-            RichTbPMTMaster_LogVisAtt ->SetVisibility(true);
-            RichTbPMTMaster_LV->SetVisAttributes(RichTbPMTMaster_LogVisAtt);
-
-           }
-         }
-
-         G4LogicalVolume* RichTbPMTSMaster_LV=
-                      curPMT->getRichTbPMTSMasterLVol();
-         if(RichTbPMTSMaster_LV != 0 ) {
-           if( RichTbPMTSMaster_vis == 0 ) {
-             RichTbPMTSMaster_LV ->SetVisAttributes(G4VisAttributes::Invisible);
-           }else {
-            G4VisAttributes * RichTbPMTSMaster_LogVisAtt =
-              new  G4VisAttributes (G4Colour(0.3,0.4,0.7));
-            if(RichTbPMTSMaster_vis == 2 ) {
-              RichTbPMTSMaster_LogVisAtt->SetForceSolid(false);
-              RichTbPMTSMaster_LogVisAtt->SetForceWireframe(true);
-            }
-            if(RichTbPMTSMaster_vis == 1 ) {
-              RichTbPMTSMaster_LogVisAtt->SetForceSolid(true);
-            }
-            RichTbPMTSMaster_LogVisAtt ->SetVisibility(true);
-            RichTbPMTSMaster_LV->SetVisAttributes(RichTbPMTSMaster_LogVisAtt);
-
-           }
-         }
-
-         G4LogicalVolume*  RichTbPMTEnvelopeTube_LV =
-             curPMT->getRichTbPMTEnvelopeTubeLVol();
-         if(RichTbPMTEnvelopeTube_LV != 0 ) {
-           if(RichTbPMTEnvelope_vis == 0) {
-              RichTbPMTEnvelopeTube_LV->
-                  SetVisAttributes(G4VisAttributes::Invisible);
-           }else {
-            G4VisAttributes *  RichTbPMTEnvelopeTube_LogVisAtt =
-              new  G4VisAttributes(G4Colour(0.4,0.2,0.8));
-            if(RichTbPMTEnvelope_vis == 2){
-              RichTbPMTEnvelopeTube_LogVisAtt->SetForceSolid(false);
-              RichTbPMTEnvelopeTube_LogVisAtt->SetForceWireframe(true);
-            }
-            if(RichTbPMTEnvelope_vis == 1){
-              RichTbPMTEnvelopeTube_LogVisAtt->SetForceSolid(true);
-            }
-            RichTbPMTEnvelopeTube_LogVisAtt->SetVisibility(true);
-            RichTbPMTEnvelopeTube_LV->
-               SetVisAttributes(RichTbPMTEnvelopeTube_LogVisAtt);
-
-           }
-
-         }
-
-         G4LogicalVolume*  RichTbPMTEndCap_LV =
-             curPMT->getRichTbPMTEnvelopeEndCapLVol();
-         if(RichTbPMTEndCap_LV != 0 ) {
-           if(RichTbPMTEndCap_vis == 0) {
-              RichTbPMTEndCap_LV->
-                  SetVisAttributes(G4VisAttributes::Invisible);
-           }else {
-            G4VisAttributes *  RichTbPMTEndCap_LogVisAtt =
-              new  G4VisAttributes(G4Colour(0.3,0.2,0.8));
-            if(RichTbPMTEndCap_vis == 2){
-              RichTbPMTEndCap_LogVisAtt->SetForceSolid(false);
-              RichTbPMTEndCap_LogVisAtt->SetForceWireframe(true);
-            }
-            if(RichTbPMTEndCap_vis == 1){
-              RichTbPMTEndCap_LogVisAtt->SetForceSolid(true);
-            }
-            RichTbPMTEndCap_LogVisAtt->SetVisibility(true);
-            RichTbPMTEndCap_LV->
-               SetVisAttributes(RichTbPMTEndCap_LogVisAtt);
-
-           }
-
-
-         }
-
-
-         G4LogicalVolume*  RichTbPMTQuartzW_LV =
-           curPMT -> getRichTbPMTQuartzWLVol();
-
-         if( RichTbPMTQuartzW_LV != 0 ) {
-           if( RichTbPMTQuartzW_vis == 0 ) {
-              RichTbPMTQuartzW_LV ->
-                  SetVisAttributes(G4VisAttributes::Invisible);
-           }else {
-            G4VisAttributes *  RichTbPMTQuartzW_LogVisAtt =
-              new  G4VisAttributes(G4Colour(0.9,0.9,0.8));
-            if(RichTbPMTQuartzW_vis == 2){
-             RichTbPMTQuartzW_LogVisAtt->SetForceSolid(false);
-              RichTbPMTQuartzW_LogVisAtt->SetForceWireframe(true);
-            }
-            if(RichTbPMTQuartzW_vis == 1){
-              RichTbPMTQuartzW_LogVisAtt->SetForceSolid(true);
-            }
-
-            RichTbPMTQuartzW_LogVisAtt->SetVisibility(true);
-           RichTbPMTQuartzW_LV  ->
-               SetVisAttributes(RichTbPMTQuartzW_LogVisAtt);
-
-           }
-
-         }
-
-          G4LogicalVolume*  RichTbPMTPhCathode_LV =
-            curPMT->getRichTbPMTPhCathodeLVol();
-
-         if(RichTbPMTPhCathode_LV != 0 ) {
-           if( RichTbPMTPhCathode_vis == 0 ) {
-              RichTbPMTPhCathode_LV->
-                  SetVisAttributes(G4VisAttributes::Invisible);
-           }else {
-            G4VisAttributes *  RichTbPMTPhCathode_LogVisAtt =
-              new  G4VisAttributes(G4Colour(0.3,0.2,0.2));
-            if(RichTbPMTPhCathode_vis == 2){
-              RichTbPMTPhCathode_LogVisAtt->SetForceSolid(false);
-              RichTbPMTPhCathode_LogVisAtt->SetForceWireframe(true);
-            }
-            if(RichTbPMTPhCathode_vis == 1){
-              RichTbPMTPhCathode_LogVisAtt->SetForceSolid(true);
-            }
-            RichTbPMTPhCathode_LogVisAtt->SetVisibility(true);
-            RichTbPMTPhCathode_LV->
-               SetVisAttributes(RichTbPMTPhCathode_LogVisAtt);
-
-           }
-
-         }
-
-
-          G4LogicalVolume*  RichTbPMTSiDet_LV =
-            curPMT->getRichTbPMTSiDetLVol();
-
-         if(RichTbPMTSiDet_LV != 0 ) {
-           if( RichTbPMTSiDet_vis == 0 ) {
-              RichTbPMTSiDet_LV->
-                  SetVisAttributes(G4VisAttributes::Invisible);
-           }else {
-            G4VisAttributes *  RichTbPMTSiDet_LogVisAtt =
-              new  G4VisAttributes(G4Colour(0.7,0.7,0.3));
-            if(RichTbPMTSiDet_vis == 2){
-              RichTbPMTSiDet_LogVisAtt->SetForceSolid(false);
-              RichTbPMTSiDet_LogVisAtt->SetForceWireframe(true);
-            }
-            if(RichTbPMTSiDet_vis == 1){
-              RichTbPMTSiDet_LogVisAtt->SetForceSolid(true);
-            }
-            RichTbPMTSiDet_LogVisAtt->SetVisibility(true);
-            RichTbPMTSiDet_LV->
-               SetVisAttributes(RichTbPMTSiDet_LogVisAtt);
-
-           }
-         }
-       }
-     }
    }
 
-	 */
-
-
 
+    G4LogicalVolume*  RichTbPMTSiDet_LV =
+      curPMT->getRichTbPMTSiDetLVol();
 
+   if(RichTbPMTSiDet_LV != 0 ) {
+     if( RichTbPMTSiDet_vis == 0 ) {
+        RichTbPMTSiDet_LV->
+            SetVisAttributes(G4VisAttributes::Invisible);
+     }else {
+      G4VisAttributes *  RichTbPMTSiDet_LogVisAtt =
+        new  G4VisAttributes(G4Colour(0.7,0.7,0.3));
+      if(RichTbPMTSiDet_vis == 2){
+        RichTbPMTSiDet_LogVisAtt->SetForceSolid(false);
+        RichTbPMTSiDet_LogVisAtt->SetForceWireframe(true);
+      }
+      if(RichTbPMTSiDet_vis == 1){
+        RichTbPMTSiDet_LogVisAtt->SetForceSolid(true);
+      }
+      RichTbPMTSiDet_LogVisAtt->SetVisibility(true);
+      RichTbPMTSiDet_LV->
+         SetVisAttributes(RichTbPMTSiDet_LogVisAtt);
 
+     }
+   }
+ }
+}
 }
 
+   */
+}
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgr/RichTbVisManager.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgr/RichTbVisManager.cc
index d2cbe0b847ed56d17085edb50ad7af72f06387e9..7d0fb31d4f136dfe8ae8d22d1a81f082e63bf518 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgr/RichTbVisManager.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgr/RichTbVisManager.cc
@@ -46,126 +46,108 @@
 #include "Geant4/G4OpenGLStoredXm.hh"
 //#endif
 
- //#ifdef G4VIS_USE_OIX
+//#ifdef G4VIS_USE_OIX
 // #include "Geant4/G4OpenInventorX.hh"
- //#endif
+//#endif
 
 //#ifdef G4VIS_USE_OIWIN32
 //#include "Geant4/G4OpenInventorWin32.hh"
 //#endif
 
-//ifdef G4VIS_USE_VRML
+// ifdef G4VIS_USE_VRML
 //#include "Geant4/G4VRML1.hh"
 //#include "Geant4/G4VRML2.hh"
-//endif
+// endif
 
-//ifdef G4VIS_USE_VRMLFILE
+// ifdef G4VIS_USE_VRMLFILE
 //#include "Geant4/G4VRML1File.hh"
 //#include "Geant4/G4VRML2File.hh"
-//endif
+// endif
 
-//ifdef G4VIS_USE_RAYTRACER
+// ifdef G4VIS_USE_RAYTRACER
 //#include "Geant4/G4RayTracer.hh"
-//endif
+// endif
 //#ifdef G4VIS_USE
 //#include "Geant4/G4VisExecutive.hh"
 //#endif
 
-
-
-
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 
-RichTbVisManager* RichTbVisManager::RichTbVisManagerInstance=0;
+RichTbVisManager *RichTbVisManager::RichTbVisManagerInstance = 0;
+
+RichTbVisManager::RichTbVisManager() {
 
-RichTbVisManager::RichTbVisManager()
-{
+  // RegisterGraphicsSystems();
 
-  //RegisterGraphicsSystems();
-  
   // visualization manager
   // G4VisManager* visManagerE = new G4VisExecutive;
   //  visManagerE->Initialize();
-
-    
 }
 
-
-RichTbVisManager::~RichTbVisManager()
-{
-    ;
-}
-RichTbVisManager* RichTbVisManager::getRichTbVisManagerInstance()
-{
-  if(RichTbVisManagerInstance == 0 ) {
+RichTbVisManager::~RichTbVisManager() { ; }
+RichTbVisManager *RichTbVisManager::getRichTbVisManagerInstance() {
+  if (RichTbVisManagerInstance == 0) {
     RichTbVisManagerInstance = new RichTbVisManager();
-    
   }
   return RichTbVisManagerInstance;
-  
-  
 }
 
-
 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
 
-void RichTbVisManager::RegisterGraphicsSystems()
-{
+void RichTbVisManager::RegisterGraphicsSystems() {
 
   //#ifdef G4VIS_USE_DAWN
   //  RegisterGraphicsSystem(new G4FukuiRenderer);
-    //#endif
+  //#endif
 
-    //#ifdef G4VIS_USE_DAWNFILE
+  //#ifdef G4VIS_USE_DAWNFILE
   //  RegisterGraphicsSystem(new G4DAWNFILE);
-    //#endif
+  //#endif
 
   //#ifdef G4VIS_USE_OPACS
   //      RegisterGraphicsSystem(new G4Wo);
   //  RegisterGraphicsSystem(new G4Xo);
   //#endif
 
-    //#ifdef G4VIS_USE_OPENGLX
-   RegisterGraphicsSystem(new G4OpenGLImmediateX);
-   RegisterGraphicsSystem(new G4OpenGLStoredX);
-    //#endif
+  //#ifdef G4VIS_USE_OPENGLX
+  RegisterGraphicsSystem(new G4OpenGLImmediateX);
+  RegisterGraphicsSystem(new G4OpenGLStoredX);
+  //#endif
 
   //#ifdef G4VIS_USE_OPENGLWIN32
   //  RegisterGraphicsSystem(new G4OpenGLImmediateWin32);
   //  RegisterGraphicsSystem(new G4OpenGLStoredWin32);
   //#endif
 
-    //#ifdef G4VIS_USE_OPENGLXM
-    RegisterGraphicsSystem(new G4OpenGLImmediateXm);
-    RegisterGraphicsSystem(new G4OpenGLStoredXm);
-    //#endif
+  //#ifdef G4VIS_USE_OPENGLXM
+  RegisterGraphicsSystem(new G4OpenGLImmediateXm);
+  RegisterGraphicsSystem(new G4OpenGLStoredXm);
+  //#endif
 
   //#ifdef G4VIS_USE_OIX
-    //  RegisterGraphicsSystem (new G4OpenInventorX);
+  //  RegisterGraphicsSystem (new G4OpenInventorX);
   //#endif
 
   //#ifdef G4VIS_USE_OIWIN32
   //  RegisterGraphicsSystem(new G4OpenInventorWin32);
   //#endif
 
-    //#ifdef G4VIS_USE_VRML
+  //#ifdef G4VIS_USE_VRML
   // RegisterGraphicsSystem(new G4VRML1);
   //  RegisterGraphicsSystem(new G4VRML2);
-    //#endif
+  //#endif
 
-    //#ifdef G4VIS_USE_VRMLFILE
+  //#ifdef G4VIS_USE_VRMLFILE
   // RegisterGraphicsSystem(new G4VRML1File);
   //  RegisterGraphicsSystem(new G4VRML2File);
-    //#endif
+  //#endif
 
-    //#ifdef G4VIS_USE_RAYTRACER
+  //#ifdef G4VIS_USE_RAYTRACER
   // RegisterGraphicsSystem(new G4RayTracer);
-    //#endif
-
-    //#ifdef G4VIS_USE
-    //#endif
-
+  //#endif
 
+  //#ifdef G4VIS_USE
+  //#endif
 
   //    if (fVerbose > 0) {
   //      G4cout << "\nYou have successfully chosen to use the following graphics systems." << G4endl;
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbGeometryParameters.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbGeometryParameters.cc
index 839f14f70c85d1bc3d1f69a120307c1adcc963e5..0adb486cd823c2faa2814b7c992364d0b72b0727 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbGeometryParameters.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbGeometryParameters.cc
@@ -1,6 +1,4 @@
-#include "Geant4/globals.hh"
 #include "RichTbGeometryParameters.hh"
+#include "Geant4/globals.hh"
 
-void InitializeRichTbGeometry()
-{
-}
+void InitializeRichTbGeometry() {}
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbHall.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbHall.cc
index 6608141111924ae5fd066267dc99760a7bb1d531..c06640d8e8a84b20dd8b83d19e827e7f78d7b781 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbHall.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbHall.cc
@@ -1,36 +1,26 @@
 #include "Geant4/G4Box.hh"
-#include "Geant4/G4ThreeVector.hh"
 #include "Geant4/G4LogicalVolume.hh"
-#include "Geant4/G4VPhysicalVolume.hh"
 #include "Geant4/G4PVPlacement.hh"
+#include "Geant4/G4ThreeVector.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
 
 #include <iostream>
 
-#include "RichTbUpgradeDetectorConstruction.hh"
+#include "RichTbGeometryParameters.hh"
 #include "RichTbHall.hh"
 #include "RichTbMaterial.hh"
-#include "RichTbGeometryParameters.hh"
-
-RichTbHall::RichTbHall()
-{
+#include "RichTbUpgradeDetectorConstruction.hh"
 
+RichTbHall::RichTbHall() {
 
-  RichTbMaterial * RMaterial = RichTbMaterial::getRichTbMaterialInstance();
-  
-  G4Box * RichTbHallBox
-    = new G4Box("World",ExpHallHalfX,ExpHallHalfY,ExpHallHalfZ);
-  G4LogicalVolume * RichTbHallLog
-    = new G4LogicalVolume(RichTbHallBox,RMaterial->getRichTbVaccum(),"World",0,0,0);
-  G4VPhysicalVolume * RichTbHallPhys
-    = new G4PVPlacement(0,G4ThreeVector(),"World",RichTbHallLog,0,false,0);
+  RichTbMaterial *RMaterial = RichTbMaterial::getRichTbMaterialInstance();
 
-  RichTbHallLVol  = RichTbHallLog;
-  RichTbHallPVol  = RichTbHallPhys;
+  G4Box *RichTbHallBox = new G4Box("World", ExpHallHalfX, ExpHallHalfY, ExpHallHalfZ);
+  G4LogicalVolume *RichTbHallLog = new G4LogicalVolume(RichTbHallBox, RMaterial->getRichTbVaccum(), "World", 0, 0, 0);
+  G4VPhysicalVolume *RichTbHallPhys = new G4PVPlacement(0, G4ThreeVector(), "World", RichTbHallLog, 0, false, 0);
 
+  RichTbHallLVol = RichTbHallLog;
+  RichTbHallPVol = RichTbHallPhys;
 }
 
-
-RichTbHall::~RichTbHall()
-{
-    ;
-}
+RichTbHall::~RichTbHall() { ; }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbHpd.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbHpd.cc
index c4a514a6448367d15c2675aace64fc34b9a906f0..2f5c61660a1af13ae84a8ffad0b50b7cbc44c7aa 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbHpd.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbHpd.cc
@@ -1,30 +1,29 @@
 // $Id: $
-// Include files 
+// Include files
 
-
-#include "Geant4/globals.hh"
-#include "Geant4/G4Tubs.hh"
 #include "Geant4/G4Box.hh"
-#include "Geant4/G4Sphere.hh"
 #include "Geant4/G4Polyhedra.hh"
+#include "Geant4/G4Sphere.hh"
+#include "Geant4/G4Tubs.hh"
+#include "Geant4/globals.hh"
 
 // local
-#include "RichTbMaterial.hh"
-#include "RichTbHpd.hh"
-#include "RichTbUpgradePhDetSupFrame.hh"
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMaterialParameters.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4PVPlacement.hh"
 #include "Geant4/G4RotationMatrix.hh"
+#include "Geant4/G4SDManager.hh"
+#include "Geant4/G4SubtractionSolid.hh"
 #include "Geant4/G4ThreeVector.hh"
 #include "Geant4/G4Transform3D.hh"
-#include "Geant4/G4LogicalVolume.hh"
 #include "Geant4/G4VPhysicalVolume.hh"
-#include "Geant4/G4PVPlacement.hh"
-#include "Geant4/G4SubtractionSolid.hh"
-#include "Geant4/G4SDManager.hh"
-#include "RichTbUpgradeSD.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbHpd.hh"
 #include "RichTbHpdRODummySD.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMaterialParameters.hh"
 #include "RichTbMiscNames.hh"
+#include "RichTbUpgradePhDetSupFrame.hh"
+#include "RichTbUpgradeSD.hh"
 
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbHpd
@@ -35,407 +34,287 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbHpd::RichTbHpd(G4int aHpdNum , RichTbUpgradePhDetSupFrame* aSupFrame  )
-{  MotherOfHpd = aSupFrame;
+RichTbHpd::RichTbHpd(G4int aHpdNum, RichTbUpgradePhDetSupFrame *aSupFrame) {
+  MotherOfHpd = aSupFrame;
   CurHpdNum = aHpdNum;
-  m_TrackingSwitch=true;
-  
+  m_TrackingSwitch = true;
 }
 
-RichTbHpd::~RichTbHpd(  ) {
-}
+RichTbHpd::~RichTbHpd() {}
 
 void RichTbHpd::buildHpdGeometry() {
 
-
   constructHpdMasterTree();
-  RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-  G4int agraphics=   aConfig ->getRichTbHpdSiPix_visib() ;
-  
-  
-  if(m_TrackingSwitch) { 
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int agraphics = aConfig->getRichTbHpdSiPix_visib();
+
+  if (m_TrackingSwitch) {
     constructHpdComponentsLVol();
     constructHpdComponentsPVol();
-    if( agraphics > 5 ) {
+    if (agraphics > 5) {
       // special config to just visualize the pixel geometry. Not for simulating data.
       constructHpdSiPixel();
-
     }
-    
-
 
-  }else {
+  } else {
     constructHpdSiPixel();
   }
-  
-  
-
 }
 
-void RichTbHpd::constructHpdComponentsLVol() 
-{
-  RichTbMaterial* aMaterial =  RichTbMaterial::getRichTbMaterialInstance();
-
-   G4Tubs*  HpdEnvelopeTube = 
-     new G4Tubs("HpdEnvelopeTube", RichTbHpdEnvLargeTubInnR,  
-                RichTbHpdEnvLargeTubeOutR,
-                0.5*RichTbHpdEnvLargeTubeZSize,
-                 RichTbHpdEnvelopeTubeStartPhi, RichTbHpdEnvelopeTubeEndPhi);
-   
-   G4Tubs* HpdEndCapTube=
-     new G4Tubs("HpdEndCap",    RichTbHpdEndCapInnerRad,RichTbHpdEnvEndCapRad,
-                0.5*RichTbHpdEnvEndCapZsize,  RichTbHpdEnvelopeEndCapStartPhi,
-                 RichTbHpdEnvelopeEndCapEndPhi);
-   G4Sphere* HpdQuartzWindowOverallSphe=
-     new G4Sphere("HpdQuartzWSphe",  RichTbHpdQuartzWInnerRad,
-                  RichTbHpdQuartzWOuterRad, RichTbHpdQuartzWStartPhi,
-                   RichTbHpdQuartzWDeltaPhi, RichTbHpdQuartzWStartTheta,
-                  RichTbHpdQuartzWDeltaTheta);
-   
-    G4Tubs* HpdQWCylEnvTube=
-      new G4Tubs("HpdQWCylEnvTube", RichTbHpdQuartzWCylEnvInnerR,
-                 RichTbHpdQWCylEnvOuterLargeValue,
-                 0.5*RichTbHpdQWCylEnvZLargeValue,
-                 RichTbHpdQWCylEnvStartPhi,RichTbHpdQWCylEnvEndPhi);
-    
-   G4Sphere* HpdPhCathodeSphe=
-     new G4Sphere("HpdPhCathodeSphe", RichTbHpdPhCathodeInnerRad,
-                  RichTbHpdPhCathodeOuterRad, RichTbHpdPhCathodeStartPhi,
-                  RichTbHpdPhCathodeDeltaPhi,    RichTbHpdPhCathodeStartTheta,
-                  RichTbHpdPhCathodeDeltaTheta);
-   
-    G4RotationMatrix  RichTbHpdQWCylRot;
-
-    G4ThreeVector RichTbHpdQWCylPos(RichTbHpdQWCylXLocation,
-                                   RichTbHpdQWCylYLocation,
-                                   RichTbHpdQWCylZLocation);
-   
-   G4Transform3D   RichTbHpdQWCylTransform(   RichTbHpdQWCylRot,
-                                              RichTbHpdQWCylPos);
-   
-   G4SubtractionSolid* HpdQuartzWSub =
-     new    G4SubtractionSolid("HpdQWSubtr",HpdQuartzWindowOverallSphe,
-                               HpdQWCylEnvTube, RichTbHpdQWCylTransform);
-   
- 
-
-   G4LogicalVolume*  HpdEnvelopeLog =
-     new G4LogicalVolume( HpdEnvelopeTube ,
-                          aMaterial->getHpdTubeEnvelopeMaterial(),
-                          "HpdEnvelopeLog",0,0,0);
-   G4LogicalVolume* HpdEndCapLog =
-     new G4LogicalVolume( HpdEndCapTube,
-                    aMaterial->getHpdTubeEnvelopeMaterial(),
-                          "HpdEndCapLog",0,0,0);
-   G4LogicalVolume* HpdQuartzWLog= 
-      new  G4LogicalVolume( HpdQuartzWSub,
-                            aMaterial->getHpdQuartzWindowMaterial(),
-                            "HpdQuartzWLog",0,0,0);
-   G4LogicalVolume* HpdPhCathodeLog =
-     new G4LogicalVolume( HpdPhCathodeSphe,
-                          aMaterial->getHpdPhCathodeMaterial() ,
-                          "HpdPhCathodeLog",0,0,0);
-
-   RichTbHpdEnvelopeTubeLVol=HpdEnvelopeLog;
-   RichTbHpdEnvelopeEndCapLVol=HpdEndCapLog;
-   RichTbHpdQuartzWLVol= HpdQuartzWLog;
-   RichTbHpdPhCathodeLVol=HpdPhCathodeLog;
-   
-
-
-   
+void RichTbHpd::constructHpdComponentsLVol() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+
+  G4Tubs *HpdEnvelopeTube =
+      new G4Tubs("HpdEnvelopeTube", RichTbHpdEnvLargeTubInnR, RichTbHpdEnvLargeTubeOutR,
+                 0.5 * RichTbHpdEnvLargeTubeZSize, RichTbHpdEnvelopeTubeStartPhi, RichTbHpdEnvelopeTubeEndPhi);
+
+  G4Tubs *HpdEndCapTube =
+      new G4Tubs("HpdEndCap", RichTbHpdEndCapInnerRad, RichTbHpdEnvEndCapRad, 0.5 * RichTbHpdEnvEndCapZsize,
+                 RichTbHpdEnvelopeEndCapStartPhi, RichTbHpdEnvelopeEndCapEndPhi);
+  G4Sphere *HpdQuartzWindowOverallSphe =
+      new G4Sphere("HpdQuartzWSphe", RichTbHpdQuartzWInnerRad, RichTbHpdQuartzWOuterRad, RichTbHpdQuartzWStartPhi,
+                   RichTbHpdQuartzWDeltaPhi, RichTbHpdQuartzWStartTheta, RichTbHpdQuartzWDeltaTheta);
+
+  G4Tubs *HpdQWCylEnvTube =
+      new G4Tubs("HpdQWCylEnvTube", RichTbHpdQuartzWCylEnvInnerR, RichTbHpdQWCylEnvOuterLargeValue,
+                 0.5 * RichTbHpdQWCylEnvZLargeValue, RichTbHpdQWCylEnvStartPhi, RichTbHpdQWCylEnvEndPhi);
+
+  G4Sphere *HpdPhCathodeSphe = new G4Sphere("HpdPhCathodeSphe", RichTbHpdPhCathodeInnerRad, RichTbHpdPhCathodeOuterRad,
+                                            RichTbHpdPhCathodeStartPhi, RichTbHpdPhCathodeDeltaPhi,
+                                            RichTbHpdPhCathodeStartTheta, RichTbHpdPhCathodeDeltaTheta);
+
+  G4RotationMatrix RichTbHpdQWCylRot;
+
+  G4ThreeVector RichTbHpdQWCylPos(RichTbHpdQWCylXLocation, RichTbHpdQWCylYLocation, RichTbHpdQWCylZLocation);
+
+  G4Transform3D RichTbHpdQWCylTransform(RichTbHpdQWCylRot, RichTbHpdQWCylPos);
+
+  G4SubtractionSolid *HpdQuartzWSub =
+      new G4SubtractionSolid("HpdQWSubtr", HpdQuartzWindowOverallSphe, HpdQWCylEnvTube, RichTbHpdQWCylTransform);
+
+  G4LogicalVolume *HpdEnvelopeLog =
+      new G4LogicalVolume(HpdEnvelopeTube, aMaterial->getHpdTubeEnvelopeMaterial(), "HpdEnvelopeLog", 0, 0, 0);
+  G4LogicalVolume *HpdEndCapLog =
+      new G4LogicalVolume(HpdEndCapTube, aMaterial->getHpdTubeEnvelopeMaterial(), "HpdEndCapLog", 0, 0, 0);
+  G4LogicalVolume *HpdQuartzWLog =
+      new G4LogicalVolume(HpdQuartzWSub, aMaterial->getHpdQuartzWindowMaterial(), "HpdQuartzWLog", 0, 0, 0);
+  G4LogicalVolume *HpdPhCathodeLog =
+      new G4LogicalVolume(HpdPhCathodeSphe, aMaterial->getHpdPhCathodeMaterial(), "HpdPhCathodeLog", 0, 0, 0);
+
+  RichTbHpdEnvelopeTubeLVol = HpdEnvelopeLog;
+  RichTbHpdEnvelopeEndCapLVol = HpdEndCapLog;
+  RichTbHpdQuartzWLVol = HpdQuartzWLog;
+  RichTbHpdPhCathodeLVol = HpdPhCathodeLog;
 }
-void RichTbHpd::constructHpdComponentsPVol() 
-{
-
-   G4RotationMatrix  HpdEnvelopeTubeRot;
-   G4RotationMatrix  HpdEndCapTubeRot,  HpdQuartzWindowRot, HpdPhCathodeRot;
-
-    G4ThreeVector HpdEnvelopeTubePos( RichTbHpdEnvTubeXLocation,
-                                     RichTbHpdEnvTubeYLocation,
-                                     RichTbEnvLargeTubZLocation);
-   
-   G4Transform3D   HpdEnvelopeTubeTransform( HpdEnvelopeTubeRot,
-                                             HpdEnvelopeTubePos);
-   
-   G4ThreeVector HpdEndCapPos(RichTbHpdEndCapXLocation, 
-                              RichTbHpdEndCapYLocation,
-                              RichTbHpdEndCapZLocation);
-   
-   G4Transform3D HpdEndCapTransform( HpdEndCapTubeRot, HpdEndCapPos);
-
-
-   HpdQuartzWindowRot.rotateY(RichTbHpdQuartzWRotY);
-   HpdPhCathodeRot.rotateY( RichTbHpdPhCathodeRotY);
-
-   
-   G4ThreeVector HpdQuartzWindowPos(  RichTbHpdQuartzWindowXLocation,
-                                      RichTbHpdQuartzWindowYLocation,
-                                      RichTbHpdQuartzWZLocation);
-
-
-   G4Transform3D  HpdQuartzWindowTransform(  HpdQuartzWindowRot, 
-                                            HpdQuartzWindowPos);
-   
-   G4ThreeVector   HpdPhCathodePos(RichTbHpdPhCathodeXLocation,
-                                   RichTbHpdPhCathodeYLocation,
-                                   RichTbHpdPhCathodeZLocation);
-   
-   G4Transform3D HpdPhCathodeTransform( HpdPhCathodeRot, HpdPhCathodePos);
-   
-    
-     
-   G4VPhysicalVolume*   HpdEnvelopePhys =
-     new G4PVPlacement(  HpdEnvelopeTubeTransform,"HpdEnvelopeTubePhys",
-                       RichTbHpdEnvelopeTubeLVol  , RichTbHpdSMasterPVol,
-                        false,0);
-   
-   G4VPhysicalVolume*  HpdEndCapPhys =
-     new G4PVPlacement(  HpdEndCapTransform,"HpdEndCapPhys",
-                         RichTbHpdEnvelopeEndCapLVol,
-                        RichTbHpdSMasterPVol,false,0);
-
-   G4VPhysicalVolume*   HpdQuartzWPhys=
-     new G4PVPlacement(  HpdQuartzWindowTransform,HpdQuartzPhysName  ,
-                        RichTbHpdQuartzWLVol ,
-                       RichTbHpdSMasterPVol,false,0);
-
-   G4VPhysicalVolume*   HpdPhCathodePhys=
-     new G4PVPlacement(  HpdPhCathodeTransform, HpdPhCathodePhysName ,
-                          RichTbHpdPhCathodeLVol, 
-                         RichTbHpdSMasterPVol,false,0);
-
-   RichTbHpdEnvelopeTubePVol= HpdEnvelopePhys;   
-   RichTbHpdEnvelopeEndCapPVol=  HpdEndCapPhys;  
-   RichTbHpdQuartzWPVol= HpdQuartzWPhys;   
-   RichTbHpdPhCathodePVol= HpdPhCathodePhys;   
-
-   
+void RichTbHpd::constructHpdComponentsPVol() {
+
+  G4RotationMatrix HpdEnvelopeTubeRot;
+  G4RotationMatrix HpdEndCapTubeRot, HpdQuartzWindowRot, HpdPhCathodeRot;
+
+  G4ThreeVector HpdEnvelopeTubePos(RichTbHpdEnvTubeXLocation, RichTbHpdEnvTubeYLocation, RichTbEnvLargeTubZLocation);
+
+  G4Transform3D HpdEnvelopeTubeTransform(HpdEnvelopeTubeRot, HpdEnvelopeTubePos);
+
+  G4ThreeVector HpdEndCapPos(RichTbHpdEndCapXLocation, RichTbHpdEndCapYLocation, RichTbHpdEndCapZLocation);
+
+  G4Transform3D HpdEndCapTransform(HpdEndCapTubeRot, HpdEndCapPos);
 
+  HpdQuartzWindowRot.rotateY(RichTbHpdQuartzWRotY);
+  HpdPhCathodeRot.rotateY(RichTbHpdPhCathodeRotY);
 
+  G4ThreeVector HpdQuartzWindowPos(RichTbHpdQuartzWindowXLocation, RichTbHpdQuartzWindowYLocation,
+                                   RichTbHpdQuartzWZLocation);
+
+  G4Transform3D HpdQuartzWindowTransform(HpdQuartzWindowRot, HpdQuartzWindowPos);
+
+  G4ThreeVector HpdPhCathodePos(RichTbHpdPhCathodeXLocation, RichTbHpdPhCathodeYLocation, RichTbHpdPhCathodeZLocation);
+
+  G4Transform3D HpdPhCathodeTransform(HpdPhCathodeRot, HpdPhCathodePos);
+
+  G4VPhysicalVolume *HpdEnvelopePhys = new G4PVPlacement(HpdEnvelopeTubeTransform, "HpdEnvelopeTubePhys",
+                                                         RichTbHpdEnvelopeTubeLVol, RichTbHpdSMasterPVol, false, 0);
+
+  G4VPhysicalVolume *HpdEndCapPhys = new G4PVPlacement(HpdEndCapTransform, "HpdEndCapPhys", RichTbHpdEnvelopeEndCapLVol,
+                                                       RichTbHpdSMasterPVol, false, 0);
+
+  G4VPhysicalVolume *HpdQuartzWPhys = new G4PVPlacement(HpdQuartzWindowTransform, HpdQuartzPhysName,
+                                                        RichTbHpdQuartzWLVol, RichTbHpdSMasterPVol, false, 0);
+
+  G4VPhysicalVolume *HpdPhCathodePhys = new G4PVPlacement(HpdPhCathodeTransform, HpdPhCathodePhysName,
+                                                          RichTbHpdPhCathodeLVol, RichTbHpdSMasterPVol, false, 0);
+
+  RichTbHpdEnvelopeTubePVol = HpdEnvelopePhys;
+  RichTbHpdEnvelopeEndCapPVol = HpdEndCapPhys;
+  RichTbHpdQuartzWPVol = HpdQuartzWPhys;
+  RichTbHpdPhCathodePVol = HpdPhCathodePhys;
 }
 
-void RichTbHpd::constructHpdMasterTree(){
+void RichTbHpd::constructHpdMasterTree() {
 
-  RichTbMaterial* aMaterial =  RichTbMaterial::getRichTbMaterialInstance();
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
   //  RichTbRunConfig* aRunConfig= RichTbRunConfig::getRunConfigInstance();
-  
+
   //  G4String HpdMasterBoxName = HpdNamesBox[ CurHpdNum ];
   // G4String HpdMasterLogVolName= HpdNamesLog[CurHpdNum ];
   //  G4String HpdMasterPhysVolName = HpdNamesPhys[ CurHpdNum ];
 
   G4String HpdMasterBoxName = HpdNamesBox;
-  G4String HpdMasterLogVolName= HpdNamesLog;
+  G4String HpdMasterLogVolName = HpdNamesLog;
   G4String HpdMasterPhysVolName = HpdNamesPhys;
 
+  G4Tubs *HpdMasterTube = new G4Tubs(HpdMasterBoxName, RichTbHpdMasterInnerRad, RichTbHpdMasterRadius,
+                                     0.5 * RichTbHpdMasterZSize, RichTbHpdMasterStartPhi, RichTbHpdMasterEndPhi);
+  G4Tubs *HpdSMasterTube = new G4Tubs("HPDSMaster", RichTbHpdSMasterInnerRad, RichTbHpdSMasterRadius,
+                                      0.5 * RichTbHpdSMasterZSize, RichTbHpdSMasterStartPhi, RichTbHpdSMasterEndPhi);
+
+  //   G4double SiDetXSize= RichTbHpdSiDetXSize[CurHpdNum];
+  // G4double SiDetYSize= RichTbHpdSiDetYSize[CurHpdNum];
+  // G4double SiDetZSize= RichTbHpdSiDetZSize;
+  //   G4Box* HpdSiDetBox =
+  //  new G4Box("HpdSiDetBox", 0.5*SiDetXSize,
+  //            0.5*SiDetYSize,
+  //            0.5*SiDetZSize);
+
+  G4Tubs *HpdSiDetTube = new G4Tubs("HpdSiDetTube", RichTbHpdSiDetInnerRadiusSize, RichTbHpdSiDetRadiusSize,
+                                    0.5 * RichTbHpdSiDetZSize, RichTbHpdSiDetStartPhi, RichTbHpdSiDetEndPhi);
+
+  G4RotationMatrix HpdMasterRotZ, HpdMasterRotY;
+  G4RotationMatrix HpdSMasterRot;
+  G4RotationMatrix HpdSiDetRot;
+
+  //   G4double CurHpdAdditionalRotZ=
+  //   aRunConfig->getCurrentHpdAdditionalLocalRotationZ;
+  // G4double CurHpdTotalRotZ= RichTbHpdMasterRotationZAxis+
+  //  CurHpdAdditionalRotZ;
+
+  G4double CurHpdTotalRotZ = RichTbHpdMasterRotationZAxis;
+
+  //   G4double CurHpdAdditionalShiftX=
+  //  aRunConfig->getCurrentHpdAlignmentLocalShiftX;
+
+  //   G4double CurHpdAdditionalShiftY=
+  //  aRunConfig->getCurrentHpdAlignmentLocalShiftY;
+
+  //  G4cout<<" Hpd Master hpdNUm RotZ Orig Additional "
+  //      <<CurHpdNum<<"  "<<RichTbHpdMasterRotationZAxis
+  //      <<"   "<< CurHpdAdditionalRotZ<<G4endl;
+
+  //  G4cout<<" Hpd MasterInphdetframe  hpdNum OrginalX ShiftX OriginalY ShiftY "
+  //      << CurHpdNum<<"   "<< RichTbHpdMasterXLocation
+  //      <<"    "<<CurHpdAdditionalShiftX<<"    "
+  //      << RichTbHpdMasterYLocation<<"    "
+  //      << CurHpdAdditionalShiftY<<G4endl;
+
+  // G4double RichTbHpdMasterXPosFinal= RichTbHpdMasterXLocation+
+  //  CurHpdAdditionalShiftX;
+  //  G4double  RichTbHpdMasterYPosFinal= RichTbHpdMasterYLocation+
+  //  CurHpdAdditionalShiftY;
+
+  G4double RichTbHpdMasterXPosFinal = RichTbHpdMasterXLocation;
+  G4double RichTbHpdMasterYPosFinal = RichTbHpdMasterYLocation;
+
+  HpdMasterRotZ.rotateZ(CurHpdTotalRotZ);
+  HpdMasterRotY.rotateY(RichTbHpdMasterRotationYAxis);
+  HpdSiDetRot.rotateZ(RichTbSiDetRotZ);
+
+  G4ThreeVector HpdMasterPos(RichTbHpdMasterXPosFinal, RichTbHpdMasterYPosFinal, RichTbHpdMasterZLocation);
+
+  G4Transform3D HpdMasterTransform(HpdMasterRotY * HpdMasterRotZ, HpdMasterPos);
+
+  G4ThreeVector HpdSMasterPos(RichTbHpdSMasterXLocation, RichTbHpdSMasterYLocation, RichTbHpdSMasterZLocation);
 
-   G4Tubs* HpdMasterTube= 
-     new G4Tubs( HpdMasterBoxName, RichTbHpdMasterInnerRad,
-                 RichTbHpdMasterRadius,
-                0.5* RichTbHpdMasterZSize, RichTbHpdMasterStartPhi,  
-                RichTbHpdMasterEndPhi);
-   G4Tubs* HpdSMasterTube= 
-     new G4Tubs("HPDSMaster", RichTbHpdSMasterInnerRad,RichTbHpdSMasterRadius,
-                0.5* RichTbHpdSMasterZSize, RichTbHpdSMasterStartPhi, 
-                 RichTbHpdSMasterEndPhi);
-
-
-   //   G4double SiDetXSize= RichTbHpdSiDetXSize[CurHpdNum];
-   // G4double SiDetYSize= RichTbHpdSiDetYSize[CurHpdNum];
-   // G4double SiDetZSize= RichTbHpdSiDetZSize;
-   //   G4Box* HpdSiDetBox =
-   //  new G4Box("HpdSiDetBox", 0.5*SiDetXSize,
-   //            0.5*SiDetYSize,
-   //            0.5*SiDetZSize);
-
-    G4Tubs* HpdSiDetTube =
-      new G4Tubs("HpdSiDetTube",  RichTbHpdSiDetInnerRadiusSize, RichTbHpdSiDetRadiusSize,
-                 0.5*RichTbHpdSiDetZSize, RichTbHpdSiDetStartPhi,  RichTbHpdSiDetEndPhi);
-    
-
-
-  
-   G4RotationMatrix HpdMasterRotZ, HpdMasterRotY;
-   G4RotationMatrix HpdSMasterRot;
-   G4RotationMatrix  HpdSiDetRot;
-   
-   //   G4double CurHpdAdditionalRotZ=
-   //   aRunConfig->getCurrentHpdAdditionalLocalRotationZ;  
-   //G4double CurHpdTotalRotZ= RichTbHpdMasterRotationZAxis+
-   //  CurHpdAdditionalRotZ;
-
-   G4double CurHpdTotalRotZ= RichTbHpdMasterRotationZAxis;
-   
-
-   //   G4double CurHpdAdditionalShiftX=  
-   //  aRunConfig->getCurrentHpdAlignmentLocalShiftX;
-
-   //   G4double CurHpdAdditionalShiftY=  
-   //  aRunConfig->getCurrentHpdAlignmentLocalShiftY;
-   
-   //  G4cout<<" Hpd Master hpdNUm RotZ Orig Additional "
-   //      <<CurHpdNum<<"  "<<RichTbHpdMasterRotationZAxis
-   //      <<"   "<< CurHpdAdditionalRotZ<<G4endl;
-   
-   //  G4cout<<" Hpd MasterInphdetframe  hpdNum OrginalX ShiftX OriginalY ShiftY "
-   //      << CurHpdNum<<"   "<< RichTbHpdMasterXLocation
-   //      <<"    "<<CurHpdAdditionalShiftX<<"    "
-   //      << RichTbHpdMasterYLocation<<"    "
-   //      << CurHpdAdditionalShiftY<<G4endl;
-
-   // G4double RichTbHpdMasterXPosFinal= RichTbHpdMasterXLocation+
-   //  CurHpdAdditionalShiftX;
-   //  G4double  RichTbHpdMasterYPosFinal= RichTbHpdMasterYLocation+
-   //  CurHpdAdditionalShiftY;
-
-   G4double RichTbHpdMasterXPosFinal= RichTbHpdMasterXLocation;
-   G4double RichTbHpdMasterYPosFinal= RichTbHpdMasterYLocation;
-   
-   
-   
-
-   HpdMasterRotZ.rotateZ(CurHpdTotalRotZ);
-   HpdMasterRotY.rotateY(RichTbHpdMasterRotationYAxis);
-   HpdSiDetRot.rotateZ( RichTbSiDetRotZ) ;
-   
-     
-
-  G4ThreeVector HpdMasterPos(RichTbHpdMasterXPosFinal,
-                             RichTbHpdMasterYPosFinal,
-                             RichTbHpdMasterZLocation);
- 
-   G4Transform3D HpdMasterTransform(HpdMasterRotY*HpdMasterRotZ, 
-                         HpdMasterPos);
-
-   
-   G4ThreeVector HpdSMasterPos(RichTbHpdSMasterXLocation,
-                               RichTbHpdSMasterYLocation,
-                               RichTbHpdSMasterZLocation);
-   
-   G4Transform3D HpdSMasterTransform( HpdSMasterRot,HpdSMasterPos);
-
-    
-   G4ThreeVector   HpdSiDetPos(
-     RichTbSiDetNominalXLocation+ RichTbSiDetShiftAlongX,
-     RichTbSiDetNominalYLocation+ RichTbSiDetShiftAlongY,
-     RichTbHpdSiDetZLocation);
-   
-   G4Transform3D  HpdSiDetTransform( HpdSiDetRot, HpdSiDetPos);
-   
-      
-   G4LogicalVolume* HpdMasterLog=
-     new G4LogicalVolume(HpdMasterTube,aMaterial-> getRichTbVaccum(),
-                         HpdMasterLogVolName ,0,0,0);
-   G4LogicalVolume* HpdSMasterLog=
-     new G4LogicalVolume(HpdSMasterTube,aMaterial-> getRichTbVaccum(),
-                         "HpdSMasterLog",0,0,0);
-   G4LogicalVolume* HpdSiDetLog =
-     new G4LogicalVolume( HpdSiDetTube,
-                          aMaterial->getHpdSiDetMaterial(),
-                          "HpdSiDetLog",0,0,0);
-   
-        
-   
-   G4VPhysicalVolume* HpdMasterPhys =
-     new G4PVPlacement(HpdMasterTransform,HpdMasterPhysVolName,
-                       HpdMasterLog,  
-                       MotherOfHpd-> getRichTbPhDetSupFrameRightPVol(),
-                       false, CurHpdNum);
-
-   G4VPhysicalVolume* HpdSMasterPhys=
-     new G4PVPlacement(HpdSMasterTransform,HpdSMasterPhysName,
-                       HpdSMasterLog,HpdMasterPhys,false,0);
-
-
-   G4VPhysicalVolume*  HpdSiDetPhys=
-      new G4PVPlacement(  HpdSiDetTransform, HpdSiDetPhysName ,
-                          HpdSiDetLog , HpdSMasterPhys,false,0);
-
-   RichTbHpdMasterLVol=HpdMasterLog;
-   RichTbHpdSMasterLVol=HpdSMasterLog;
-   RichTbHpdSiDetLVol= HpdSiDetLog;
-   RichTbHpdMasterPVol=HpdMasterPhys;   
-   RichTbHpdSMasterPVol=HpdSMasterPhys;   
-   RichTbHpdSiDetPVol= HpdSiDetPhys;
-   
-   
+  G4Transform3D HpdSMasterTransform(HpdSMasterRot, HpdSMasterPos);
+
+  G4ThreeVector HpdSiDetPos(RichTbSiDetNominalXLocation + RichTbSiDetShiftAlongX,
+                            RichTbSiDetNominalYLocation + RichTbSiDetShiftAlongY, RichTbHpdSiDetZLocation);
+
+  G4Transform3D HpdSiDetTransform(HpdSiDetRot, HpdSiDetPos);
+
+  G4LogicalVolume *HpdMasterLog =
+      new G4LogicalVolume(HpdMasterTube, aMaterial->getRichTbVaccum(), HpdMasterLogVolName, 0, 0, 0);
+  G4LogicalVolume *HpdSMasterLog =
+      new G4LogicalVolume(HpdSMasterTube, aMaterial->getRichTbVaccum(), "HpdSMasterLog", 0, 0, 0);
+  G4LogicalVolume *HpdSiDetLog =
+      new G4LogicalVolume(HpdSiDetTube, aMaterial->getHpdSiDetMaterial(), "HpdSiDetLog", 0, 0, 0);
+
+  G4VPhysicalVolume *HpdMasterPhys =
+      new G4PVPlacement(HpdMasterTransform, HpdMasterPhysVolName, HpdMasterLog,
+                        MotherOfHpd->getRichTbPhDetSupFrameRightPVol(), false, CurHpdNum);
+
+  G4VPhysicalVolume *HpdSMasterPhys =
+      new G4PVPlacement(HpdSMasterTransform, HpdSMasterPhysName, HpdSMasterLog, HpdMasterPhys, false, 0);
+
+  G4VPhysicalVolume *HpdSiDetPhys =
+      new G4PVPlacement(HpdSiDetTransform, HpdSiDetPhysName, HpdSiDetLog, HpdSMasterPhys, false, 0);
+
+  RichTbHpdMasterLVol = HpdMasterLog;
+  RichTbHpdSMasterLVol = HpdSMasterLog;
+  RichTbHpdSiDetLVol = HpdSiDetLog;
+  RichTbHpdMasterPVol = HpdMasterPhys;
+  RichTbHpdSMasterPVol = HpdSMasterPhys;
+  RichTbHpdSiDetPVol = HpdSiDetPhys;
 }
 
-void  RichTbHpd::constructHpdSiPixel()
-{
+void RichTbHpd::constructHpdSiPixel() {
 
   RichTbSiPixelPVol.clear();
   RichTbSiPixelPVol.reserve(NumPixelTotInSingleHpd);
-  
- 
-  RichTbMaterial* aMaterial =  RichTbMaterial::getRichTbMaterialInstance();
 
-  //G4double aPixelXSize= RichTbHpdSiDetHexPixelFlatToFlatSize;
-  
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+
+  // G4double aPixelXSize= RichTbHpdSiDetHexPixelFlatToFlatSize;
+
   // G4double aPixelYSize= RichTbHpdSiDetHexPixelFlatToFlatSize;
-  
-  G4Polyhedra* HpdSiPxHex= new G4Polyhedra("HpdSiPxHex",RichTbHpdSiDetPixelHexPhiStart,
-                                           RichTbHpdSiDetPixelHexPhiEnd, RichTbHpdSiDetPixelHexNumSide,
-                                           RichTbHpdSiDetPixelHexNumZPlanes,RichTbHpdSiDetPixelHexZPlane,
-                                           RichTbHpdSiDetPixelHexRInner, RichTbHpdSiDetPixelHexROuter);
-   G4LogicalVolume* HpdSiPxLog =
-     new G4LogicalVolume( HpdSiPxHex,
-                          aMaterial->getHpdSiDetMaterial(),
-                          "HpdSiPxLog",0,0,0);
-
-     //Now for the readout dummy sensitive detector
-      // This just flags the pixel as active.
-   // for now all pixels are set active. To deactivate 
-   // specific pixels, the log vol must be created for each 
-   // given pixel and the set to be active as done below. This means
-   // a separate log vol must be created for every pixel. 
-
-       G4bool      thisPixelisAlive=true;         
-       if(thisPixelisAlive){
-        RichTbHpdRODummySD * DummyHpdSensi = new  RichTbHpdRODummySD;
-        HpdSiPxLog->SetSensitiveDetector(DummyHpdSensi);
-       }
- 
-   
-   // now positioning the pixels in the Silicon Det.
-
-   G4RotationMatrix  HpdSiPixelRot;
-   HpdSiPixelRot.rotateZ(RichTbHpdSiDetPixelHexRotZ);
-   
-
-   G4int PixelNumAcc = 0;
-   
-   for(G4int iPixelRowY = 0; iPixelRowY < NumHpdPixelRows ; iPixelRowY++) {
-
-     G4double aPixelColStartX = -0.5*(NumHpdPixelInRows[iPixelRowY] - 1 ) *  HpdPixelXCenterShift;
-     G4double curPixelPosY = HpdPixelYCenterStart + HpdPixelYCenterShift *iPixelRowY ;
-       
-	  for (G4int iPixelColX = 0; iPixelColX < NumHpdPixelInRows[iPixelRowY] ; iPixelColX++)
-	    {
-        G4double curPixelPosX = aPixelColStartX + iPixelColX *  HpdPixelXCenterShift;
-        
-	      G4int PixelCopyNumber = iPixelColX + PixelNumAcc ;
-       
-
-	      G4ThreeVector HpdSiPixelPos(curPixelPosX, curPixelPosY, RichHpdSiPixelPosZInSiDet);
-	      G4Transform3D HpdSiPixelTransform(HpdSiPixelRot, HpdSiPixelPos);
-       
-	      G4VPhysicalVolume*  HpdSiPxPhys =
-     		new G4PVPlacement(  HpdSiPixelTransform,"HpdSiPxPhys",
-				    HpdSiPxLog, RichTbHpdSiDetPVol, false, PixelCopyNumber);  
-	      
-	      RichTbSiPixelPVol.push_back(HpdSiPxPhys);
-	      
-	    }
-      PixelNumAcc += NumHpdPixelInRows[iPixelRowY ];
-    
-    
-   }
-   
-      
-  
-      RichTbSiPixelLVol=HpdSiPxLog;
-      
+
+  G4Polyhedra *HpdSiPxHex =
+      new G4Polyhedra("HpdSiPxHex", RichTbHpdSiDetPixelHexPhiStart, RichTbHpdSiDetPixelHexPhiEnd,
+                      RichTbHpdSiDetPixelHexNumSide, RichTbHpdSiDetPixelHexNumZPlanes, RichTbHpdSiDetPixelHexZPlane,
+                      RichTbHpdSiDetPixelHexRInner, RichTbHpdSiDetPixelHexROuter);
+  G4LogicalVolume *HpdSiPxLog =
+      new G4LogicalVolume(HpdSiPxHex, aMaterial->getHpdSiDetMaterial(), "HpdSiPxLog", 0, 0, 0);
+
+  // Now for the readout dummy sensitive detector
+  // This just flags the pixel as active.
+  // for now all pixels are set active. To deactivate
+  // specific pixels, the log vol must be created for each
+  // given pixel and the set to be active as done below. This means
+  // a separate log vol must be created for every pixel.
+
+  G4bool thisPixelisAlive = true;
+  if (thisPixelisAlive) {
+    RichTbHpdRODummySD *DummyHpdSensi = new RichTbHpdRODummySD;
+    HpdSiPxLog->SetSensitiveDetector(DummyHpdSensi);
+  }
+
+  // now positioning the pixels in the Silicon Det.
+
+  G4RotationMatrix HpdSiPixelRot;
+  HpdSiPixelRot.rotateZ(RichTbHpdSiDetPixelHexRotZ);
+
+  G4int PixelNumAcc = 0;
+
+  for (G4int iPixelRowY = 0; iPixelRowY < NumHpdPixelRows; iPixelRowY++) {
+
+    G4double aPixelColStartX = -0.5 * (NumHpdPixelInRows[iPixelRowY] - 1) * HpdPixelXCenterShift;
+    G4double curPixelPosY = HpdPixelYCenterStart + HpdPixelYCenterShift * iPixelRowY;
+
+    for (G4int iPixelColX = 0; iPixelColX < NumHpdPixelInRows[iPixelRowY]; iPixelColX++) {
+      G4double curPixelPosX = aPixelColStartX + iPixelColX * HpdPixelXCenterShift;
+
+      G4int PixelCopyNumber = iPixelColX + PixelNumAcc;
+
+      G4ThreeVector HpdSiPixelPos(curPixelPosX, curPixelPosY, RichHpdSiPixelPosZInSiDet);
+      G4Transform3D HpdSiPixelTransform(HpdSiPixelRot, HpdSiPixelPos);
+
+      G4VPhysicalVolume *HpdSiPxPhys =
+          new G4PVPlacement(HpdSiPixelTransform, "HpdSiPxPhys", HpdSiPxLog, RichTbHpdSiDetPVol, false, PixelCopyNumber);
+
+      RichTbSiPixelPVol.push_back(HpdSiPxPhys);
+    }
+    PixelNumAcc += NumHpdPixelInRows[iPixelRowY];
+  }
+
+  RichTbSiPixelLVol = HpdSiPxLog;
 }
 
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbMaterial.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbMaterial.cc
index cf90e7a9a6ebf32c277d253a89c16d0908074c87..995f4e5b5692e3f6d3811fa0bd5cab50b2b02fc2 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbMaterial.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbMaterial.cc
@@ -3,17 +3,17 @@
 #include "CLHEP/Units/PhysicalConstants.h"
 
 // Geant 4
-#include "Geant4/globals.hh"
-#include "Geant4/G4Isotope.hh"
 #include "Geant4/G4Element.hh"
 #include "Geant4/G4ElementTable.hh"
-#include "Geant4/G4Material.hh"
-#include "Geant4/G4MaterialTable.hh"
-#include "Geant4/G4UnitsTable.hh"
-#include "Geant4/G4OpticalSurface.hh"
+#include "Geant4/G4Isotope.hh"
 #include "Geant4/G4LogicalBorderSurface.hh"
 #include "Geant4/G4LogicalSkinSurface.hh"
+#include "Geant4/G4Material.hh"
+#include "Geant4/G4MaterialTable.hh"
 #include "Geant4/G4OpBoundaryProcess.hh"
+#include "Geant4/G4OpticalSurface.hh"
+#include "Geant4/G4UnitsTable.hh"
+#include "Geant4/globals.hh"
 
 // STL etc
 #include <iostream>
@@ -25,841 +25,696 @@
 //#include "RichTbGasQuWinProperty.hh"
 #include "RichTbAnalysisManager.hh"
 
+RichTbMaterial *RichTbMaterial::RichTbMaterialInstance = 0;
 
-RichTbMaterial* RichTbMaterial::RichTbMaterialInstance =0;
-
-RichTbMaterial::RichTbMaterial( ){
+RichTbMaterial::RichTbMaterial() {
 
   InitializeRichTbMaterial();
-  
-  RichTbRunConfig* aRunConfig= RichTbRunConfig::getRunConfigInstance();
-  
+
+  RichTbRunConfig *aRunConfig = RichTbRunConfig::getRunConfigInstance();
+
   //  RichTbGasQuWinProperty* aRichTbGasQuWinProperty= RichTbGasQuWinProperty::getRichTbGasQuWinPropertyInstance();
 
   HistoRichMaterialProperty();
 
-    G4double a, z, density;     //a=mass of a CLHEP::mole;
-    // z=mean number of protons;
-    G4String name, symbol;
-    //  G4int isz, isn;             //isz= number of protons in an isotope;
-    //isn= number of nucleons in an isotope;
-
-    G4int numel, natoms;        //numel=Number of elements constituting a material.
-    //   G4double abundance;
-    G4double fractionmass;
-    G4double temperature, pressure;
-    G4State aStateGas =  kStateGas;
-    // G4double FactorOne = 1.0;
-    G4UnitDefinition::BuildUnitsTable();
-
-    //PhotonEnergy
-
-        G4double PhotonEnergyStep = 
-       (PhotonMaxEnergy - PhotonMinEnergy) / NumPhotWaveLengthBins;
-       G4double *PhotonMomentum = new G4double[NumPhotWaveLengthBins];
-       for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
-        PhotonMomentum[ibin] = PhotonMinEnergy + PhotonEnergyStep * ibin;
-     }
-     G4int IbMinForCkv= PhotEnerBinEdgeForSafety;
-     G4int IbMaxForCkv= NumPhotWaveLengthBins-PhotEnerBinEdgeForSafety;
-     //     G4double PhotEneryStepForCkvProd=
-     //  ( PhotonCkvProdMaxEnergy- PhotonCkvProdMinEnergy)/
-     //  CkvProdNumPhotWaveLengthBins;     
-
-       G4double* PhotonMomentumCkvProd = 
-           new G4double[CkvProdNumPhotWaveLengthBins];
-       for(G4int ibinc=IbMinForCkv;  ibinc<IbMaxForCkv; ibinc++){
-         G4int ibp= ibinc- PhotEnerBinEdgeForSafety;
-         PhotonMomentumCkvProd[ibp]=PhotonMomentum[ibinc];         
-       }
-       
-       
-
-    G4cout << "\nNow Define Elements ..\n" << G4endl;
-
-    // Nitrogen
-
-    a = 14.01 * CLHEP::g / CLHEP::mole;
-    G4Element *elN = new G4Element(name = "Nitrogen",
-                                   symbol = "N", z = 7., a);
-
-    //Oxygen
-
-    a = 16.00 * CLHEP::g / CLHEP::mole;
-    G4Element *elO = new G4Element(name = "Oxygen",
-                                   symbol = "O", z = 8., a);
-
-    //Hydrogen
-
-    a = 1.01 * CLHEP::g / CLHEP::mole;
-    G4Element *elH = new G4Element(name = "Hydrogen",
-                                   symbol = "H", z = 1., a);
-
-    //Carbon
-
-    a = 12.01 * CLHEP::g / CLHEP::mole;
-    G4Element *elC = new G4Element(name = "Carbon",
-                                   symbol = "C", z = 6., a);
-
-    //Silicon
-
-    a = 28.09 * CLHEP::g / CLHEP::mole;
-    G4Element *elSi = new G4Element(name = "Silicon",
-                                    symbol = "Si", z = 14., a);
-    //Fluorine
-    a = 18.998 * CLHEP::g / CLHEP::mole;
-    G4Element *elF = new G4Element(name = "Fluorine",
-                                   symbol = "F", z = 9., a);
-    //Aluminum
-    a = 26.98 * CLHEP::g / CLHEP::mole;
-    G4Element *elAL = new G4Element(name = "Aluminium",
-                                    symbol = "Al", z = 13., a);
-
-    //Sodium
-    a = 22.99 * CLHEP::g / CLHEP::mole;
-    G4Element *elNa = new G4Element(name = "Sodium",
-                                    symbol = "Na", z = 11., a);
-
-    //Potassium
-    a = 39.10 * CLHEP::g / CLHEP::mole;
-    G4Element *elK = new G4Element(name = "Potassium",
-                                   symbol = "K", z = 19., a);
-
-    //Cesium
-
-    a = 132.91 * CLHEP::g / CLHEP::mole;
-    G4Element *elCs = new G4Element(name = "Cesium",
-                                    symbol = "Cs", z = 55., a);
-
-    //Antimony
-
-    a = 121.76 * CLHEP::g / CLHEP::mole;
-    G4Element *elSb = new G4Element(name = "Antimony",
-                                    symbol = "Sb", z = 51., a);
-
-    //Define Materials
-    G4cout << "\nNow Define Materials ..\n" << G4endl;
-    //
-
-    //Air at 20 degree C and 1 atm for the ambiet air.
-    // Also Air as  a radiator material for inside the tubes.
-    //--
-    density = 1.205e-03 * CLHEP::g / CLHEP::cm3;
-    pressure = 1. * CLHEP::atmosphere;
-    temperature = 293. * CLHEP::kelvin;
-    G4Material *Air = new G4Material(name = "Air ", density, numel = 2,
-                                     aStateGas, temperature, pressure);
-    Air->AddElement(elN, fractionmass = 0.7);
-    Air->AddElement(elO, fractionmass = 0.3);
-
-
-    RichTbAmbientAir = Air;
-
-    density = 1.205e-03 * CLHEP::g / CLHEP::cm3;
-    pressure = 1. * CLHEP::atmosphere;
-    temperature = 293. * CLHEP::kelvin;
-    G4Material *TAir = new G4Material(name = "TAir ", density, numel = 2,
-                                      aStateGas, temperature, pressure);
-    TAir->AddElement(elN, fractionmass = 0.7);
-    TAir->AddElement(elO, fractionmass = 0.3);
-
-    G4double *TAirAbsorpLength = new G4double[NumPhotWaveLengthBins];
-    G4double *TAirRindex = new G4double[NumPhotWaveLengthBins];
-
-    for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
-        TAirAbsorpLength[ibin] = 1.E32 * CLHEP::mm;
-        TAirRindex[ibin] = 1.000273;
-    }
-    G4MaterialPropertiesTable *TAirMPT = new G4MaterialPropertiesTable();
+  G4double a, z, density; // a=mass of a CLHEP::mole;
+  // z=mean number of protons;
+  G4String name, symbol;
+  //  G4int isz, isn;             //isz= number of protons in an isotope;
+  // isn= number of nucleons in an isotope;
+
+  G4int numel, natoms; // numel=Number of elements constituting a material.
+  //   G4double abundance;
+  G4double fractionmass;
+  G4double temperature, pressure;
+  G4State aStateGas = kStateGas;
+  // G4double FactorOne = 1.0;
+  G4UnitDefinition::BuildUnitsTable();
+
+  // PhotonEnergy
+
+  G4double PhotonEnergyStep = (PhotonMaxEnergy - PhotonMinEnergy) / NumPhotWaveLengthBins;
+  G4double *PhotonMomentum = new G4double[NumPhotWaveLengthBins];
+  for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
+    PhotonMomentum[ibin] = PhotonMinEnergy + PhotonEnergyStep * ibin;
+  }
+  G4int IbMinForCkv = PhotEnerBinEdgeForSafety;
+  G4int IbMaxForCkv = NumPhotWaveLengthBins - PhotEnerBinEdgeForSafety;
+  //     G4double PhotEneryStepForCkvProd=
+  //  ( PhotonCkvProdMaxEnergy- PhotonCkvProdMinEnergy)/
+  //  CkvProdNumPhotWaveLengthBins;
+
+  G4double *PhotonMomentumCkvProd = new G4double[CkvProdNumPhotWaveLengthBins];
+  for (G4int ibinc = IbMinForCkv; ibinc < IbMaxForCkv; ibinc++) {
+    G4int ibp = ibinc - PhotEnerBinEdgeForSafety;
+    PhotonMomentumCkvProd[ibp] = PhotonMomentum[ibinc];
+  }
 
-    TAirMPT->AddProperty("ABSLENGTH", PhotonMomentum, 
-                  TAirAbsorpLength, NumPhotWaveLengthBins);
+  G4cout << "\nNow Define Elements ..\n" << G4endl;
 
-    TAirMPT->AddProperty("RINDEX", PhotonMomentum, TAirRindex, 
-                        NumPhotWaveLengthBins);
+  // Nitrogen
 
-    TAir->SetMaterialPropertiesTable(TAirMPT);
-    RichTbTubeAir = TAir;
+  a = 14.01 * CLHEP::g / CLHEP::mole;
+  G4Element *elN = new G4Element(name = "Nitrogen", symbol = "N", z = 7., a);
 
-    //
-    //
+  // Oxygen
 
-    density = 1.205e-03 * CLHEP::g / CLHEP::cm3;
-    pressure = 1. * CLHEP::atmosphere;
-    temperature = 293. * CLHEP::kelvin;
-    G4Material *TAirA = new G4Material(name = "TAirA ", density, numel = 2,
-                                       aStateGas, temperature, pressure);
-    TAirA->AddElement(elN, fractionmass = 0.7);
-    TAirA->AddElement(elO, fractionmass = 0.3);
+  a = 16.00 * CLHEP::g / CLHEP::mole;
+  G4Element *elO = new G4Element(name = "Oxygen", symbol = "O", z = 8., a);
 
-    G4double *TAirAAbsorpLength = new G4double[NumPhotWaveLengthBins];
-    // G4double *TAirARindex = new G4double[NumPhotWaveLengthBins];
+  // Hydrogen
 
-    for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
-        TAirAAbsorpLength[ibin] = 1.E32 * CLHEP::mm;
-        //    TAirARindex[ibin]=1.0;
-        //    TAirARindex[ibin]=1.000273;
-    }
-    G4MaterialPropertiesTable *TAirAMPT = new G4MaterialPropertiesTable();
+  a = 1.01 * CLHEP::g / CLHEP::mole;
+  G4Element *elH = new G4Element(name = "Hydrogen", symbol = "H", z = 1., a);
 
-    TAirAMPT->AddProperty("ABSLENGTH", PhotonMomentum, 
-                              TAirAAbsorpLength, NumPhotWaveLengthBins);
+  // Carbon
 
-    //    TAirAMPT->AddProperty("RINDEX", PhotonMomentum,
-    //               TAirARindex,NumPhotWaveLengthBins);
+  a = 12.01 * CLHEP::g / CLHEP::mole;
+  G4Element *elC = new G4Element(name = "Carbon", symbol = "C", z = 6., a);
 
-    TAirA->SetMaterialPropertiesTable(TAirAMPT);
-    RichTbAirA = TAirA;
+  // Silicon
 
-    //    HistoRichTbMaterialProperties(rAnalysis, rConfig);
+  a = 28.09 * CLHEP::g / CLHEP::mole;
+  G4Element *elSi = new G4Element(name = "Silicon", symbol = "Si", z = 14., a);
+  // Fluorine
+  a = 18.998 * CLHEP::g / CLHEP::mole;
+  G4Element *elF = new G4Element(name = "Fluorine", symbol = "F", z = 9., a);
+  // Aluminum
+  a = 26.98 * CLHEP::g / CLHEP::mole;
+  G4Element *elAL = new G4Element(name = "Aluminium", symbol = "Al", z = 13., a);
+
+  // Sodium
+  a = 22.99 * CLHEP::g / CLHEP::mole;
+  G4Element *elNa = new G4Element(name = "Sodium", symbol = "Na", z = 11., a);
+
+  // Potassium
+  a = 39.10 * CLHEP::g / CLHEP::mole;
+  G4Element *elK = new G4Element(name = "Potassium", symbol = "K", z = 19., a);
+
+  // Cesium
+
+  a = 132.91 * CLHEP::g / CLHEP::mole;
+  G4Element *elCs = new G4Element(name = "Cesium", symbol = "Cs", z = 55., a);
+
+  // Antimony
+
+  a = 121.76 * CLHEP::g / CLHEP::mole;
+  G4Element *elSb = new G4Element(name = "Antimony", symbol = "Sb", z = 51., a);
+
+  // Define Materials
+  G4cout << "\nNow Define Materials ..\n" << G4endl;
+  //
+
+  // Air at 20 degree C and 1 atm for the ambiet air.
+  // Also Air as  a radiator material for inside the tubes.
+  //--
+  density = 1.205e-03 * CLHEP::g / CLHEP::cm3;
+  pressure = 1. * CLHEP::atmosphere;
+  temperature = 293. * CLHEP::kelvin;
+  G4Material *Air = new G4Material(name = "Air ", density, numel = 2, aStateGas, temperature, pressure);
+  Air->AddElement(elN, fractionmass = 0.7);
+  Air->AddElement(elO, fractionmass = 0.3);
+
+  RichTbAmbientAir = Air;
+
+  density = 1.205e-03 * CLHEP::g / CLHEP::cm3;
+  pressure = 1. * CLHEP::atmosphere;
+  temperature = 293. * CLHEP::kelvin;
+  G4Material *TAir = new G4Material(name = "TAir ", density, numel = 2, aStateGas, temperature, pressure);
+  TAir->AddElement(elN, fractionmass = 0.7);
+  TAir->AddElement(elO, fractionmass = 0.3);
+
+  G4double *TAirAbsorpLength = new G4double[NumPhotWaveLengthBins];
+  G4double *TAirRindex = new G4double[NumPhotWaveLengthBins];
+
+  for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
+    TAirAbsorpLength[ibin] = 1.E32 * CLHEP::mm;
+    TAirRindex[ibin] = 1.000273;
+  }
+  G4MaterialPropertiesTable *TAirMPT = new G4MaterialPropertiesTable();
 
-    //Water
-    
- density=1.000*CLHEP::g/CLHEP::cm3;
- G4Material* H2O = new G4Material(name="Water",density,numel=2);
- H2O->AddElement(elH,natoms=2);
- H2O->AddElement(elO,natoms=1);
-    G4double *H20AbsorpLength = new G4double[NumPhotWaveLengthBins];
-    G4double *H20Rindex = new G4double[NumPhotWaveLengthBins];
+  TAirMPT->AddProperty("ABSLENGTH", PhotonMomentum, TAirAbsorpLength, NumPhotWaveLengthBins);
 
-    G4MaterialPropertiesTable *H20AMPT = new G4MaterialPropertiesTable();
-    for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
-      H20AbsorpLength[ibin]=100000.0*CLHEP::mm  ;
-         H20Rindex[ibin]=1.33;
-       
-    }
-    H20AMPT->AddProperty("ABSLENGTH",PhotonMomentum,
-                         H20AbsorpLength, NumPhotWaveLengthBins);
+  TAirMPT->AddProperty("RINDEX", PhotonMomentum, TAirRindex, NumPhotWaveLengthBins);
 
-    H20AMPT->AddProperty("RINDEX", PhotonMomentum,
-                         H20Rindex,NumPhotWaveLengthBins);
+  TAir->SetMaterialPropertiesTable(TAirMPT);
+  RichTbTubeAir = TAir;
 
-    H2O->SetMaterialPropertiesTable(H20AMPT);
-    
+  //
+  //
 
+  density = 1.205e-03 * CLHEP::g / CLHEP::cm3;
+  pressure = 1. * CLHEP::atmosphere;
+  temperature = 293. * CLHEP::kelvin;
+  G4Material *TAirA = new G4Material(name = "TAirA ", density, numel = 2, aStateGas, temperature, pressure);
+  TAirA->AddElement(elN, fractionmass = 0.7);
+  TAirA->AddElement(elO, fractionmass = 0.3);
+
+  G4double *TAirAAbsorpLength = new G4double[NumPhotWaveLengthBins];
+  // G4double *TAirARindex = new G4double[NumPhotWaveLengthBins];
+
+  for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
+    TAirAAbsorpLength[ibin] = 1.E32 * CLHEP::mm;
+    //    TAirARindex[ibin]=1.0;
+    //    TAirARindex[ibin]=1.000273;
+  }
+  G4MaterialPropertiesTable *TAirAMPT = new G4MaterialPropertiesTable();
 
+  TAirAMPT->AddProperty("ABSLENGTH", PhotonMomentum, TAirAAbsorpLength, NumPhotWaveLengthBins);
 
-  //Nitrogen gas.
+  //    TAirAMPT->AddProperty("RINDEX", PhotonMomentum,
+  //               TAirARindex,NumPhotWaveLengthBins);
 
-  density = 0.8073e-03*CLHEP::g/CLHEP::cm3;
+  TAirA->SetMaterialPropertiesTable(TAirAMPT);
+  RichTbAirA = TAirA;
+
+  //    HistoRichTbMaterialProperties(rAnalysis, rConfig);
+
+  // Water
+
+  density = 1.000 * CLHEP::g / CLHEP::cm3;
+  G4Material *H2O = new G4Material(name = "Water", density, numel = 2);
+  H2O->AddElement(elH, natoms = 2);
+  H2O->AddElement(elO, natoms = 1);
+  G4double *H20AbsorpLength = new G4double[NumPhotWaveLengthBins];
+  G4double *H20Rindex = new G4double[NumPhotWaveLengthBins];
+
+  G4MaterialPropertiesTable *H20AMPT = new G4MaterialPropertiesTable();
+  for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
+    H20AbsorpLength[ibin] = 100000.0 * CLHEP::mm;
+    H20Rindex[ibin] = 1.33;
+  }
+  H20AMPT->AddProperty("ABSLENGTH", PhotonMomentum, H20AbsorpLength, NumPhotWaveLengthBins);
+
+  H20AMPT->AddProperty("RINDEX", PhotonMomentum, H20Rindex, NumPhotWaveLengthBins);
+
+  H2O->SetMaterialPropertiesTable(H20AMPT);
+
+  // Nitrogen gas.
+
+  density = 0.8073e-03 * CLHEP::g / CLHEP::cm3;
   //  pressure=1.*CLHEP::atmosphere;
   // temperature=293.*CLHEP::kelvin;
-  pressure = aRunConfig -> getNitrogenPressure();
-  
-  temperature = aRunConfig ->getNitrogenTemperature();
-  
+  pressure = aRunConfig->getNitrogenPressure();
 
-  G4Material* NitrogenGas = new G4Material(name=NitrogenGasMaterialName, 
-                                 density, numel=1,
-                                 kStateGas,temperature,pressure);
-  NitrogenGas->AddElement(elN, natoms=2);
+  temperature = aRunConfig->getNitrogenTemperature();
 
-  G4double* NitrogenGasAbsorpLength=new G4double[NumPhotWaveLengthBins];
-  G4double* NitrogenGasRindex=new G4double[NumPhotWaveLengthBins];
-  G4double* NitrogenGasPhotMom=new G4double[NumPhotWaveLengthBins];
+  G4Material *NitrogenGas =
+      new G4Material(name = NitrogenGasMaterialName, density, numel = 1, kStateGas, temperature, pressure);
+  NitrogenGas->AddElement(elN, natoms = 2);
 
-  G4double* NitrogenGasCkvProdRindex=
-          new G4double[CkvProdNumPhotWaveLengthBins];
-  G4double* NitrogenGasPhotMomCkvProd=
-          new G4double[CkvProdNumPhotWaveLengthBins];
-  
+  G4double *NitrogenGasAbsorpLength = new G4double[NumPhotWaveLengthBins];
+  G4double *NitrogenGasRindex = new G4double[NumPhotWaveLengthBins];
+  G4double *NitrogenGasPhotMom = new G4double[NumPhotWaveLengthBins];
 
-  std::vector<G4double>N2RefInd= InitN2RefIndex(pressure,temperature);
-  std::vector<G4double>N2RefPhotMom=InitN2RefPhotMom();
+  G4double *NitrogenGasCkvProdRindex = new G4double[CkvProdNumPhotWaveLengthBins];
+  G4double *NitrogenGasPhotMomCkvProd = new G4double[CkvProdNumPhotWaveLengthBins];
 
+  std::vector<G4double> N2RefInd = InitN2RefIndex(pressure, temperature);
+  std::vector<G4double> N2RefPhotMom = InitN2RefPhotMom();
 
-  for (G4int ibin=0; ibin<NumPhotWaveLengthBins; ibin++){
-    NitrogenGasAbsorpLength[ibin]=1.E32*CLHEP::mm;
-
-    NitrogenGasRindex[ibin]=N2RefInd[ibin];
-    NitrogenGasPhotMom[ibin]=N2RefPhotMom[ibin];
-    // G4cout<<" N2 ref index in RichMaterial "<<ibin<<"  "<< NitrogenGasPhotMom[ibin]	  <<"  "<<NitrogenGasRindex[ibin]<<G4endl;
+  for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
+    NitrogenGasAbsorpLength[ibin] = 1.E32 * CLHEP::mm;
 
+    NitrogenGasRindex[ibin] = N2RefInd[ibin];
+    NitrogenGasPhotMom[ibin] = N2RefPhotMom[ibin];
+    // G4cout<<" N2 ref index in RichMaterial "<<ibin<<"  "<< NitrogenGasPhotMom[ibin]	  <<"
+    // "<<NitrogenGasRindex[ibin]<<G4endl;
   }
-  
-  for (G4int ibina=IbMinForCkv; ibina <IbMaxForCkv ; ibina++){
-    G4int ibinp=  ibina-PhotEnerBinEdgeForSafety;
-    
-    NitrogenGasCkvProdRindex[ibinp]= NitrogenGasRindex[ibina];
-    NitrogenGasPhotMomCkvProd[ibinp]=  NitrogenGasPhotMom[ibina];
-    
+
+  for (G4int ibina = IbMinForCkv; ibina < IbMaxForCkv; ibina++) {
+    G4int ibinp = ibina - PhotEnerBinEdgeForSafety;
+
+    NitrogenGasCkvProdRindex[ibinp] = NitrogenGasRindex[ibina];
+    NitrogenGasPhotMomCkvProd[ibinp] = NitrogenGasPhotMom[ibina];
   }
-  
-  G4MaterialPropertiesTable* NitrogenGasMPT = 
-                            new G4MaterialPropertiesTable();
 
-    NitrogenGasMPT->AddProperty("ABSLENGTH",NitrogenGasPhotMom,
-                        NitrogenGasAbsorpLength,NumPhotWaveLengthBins);
+  G4MaterialPropertiesTable *NitrogenGasMPT = new G4MaterialPropertiesTable();
 
-    NitrogenGasMPT->AddProperty("RINDEX", NitrogenGasPhotMom, 
-                      NitrogenGasRindex,NumPhotWaveLengthBins);
+  NitrogenGasMPT->AddProperty("ABSLENGTH", NitrogenGasPhotMom, NitrogenGasAbsorpLength, NumPhotWaveLengthBins);
 
-    NitrogenGasMPT->AddProperty("CKVRNDX", NitrogenGasPhotMomCkvProd , 
-                      NitrogenGasCkvProdRindex,CkvProdNumPhotWaveLengthBins);
+  NitrogenGasMPT->AddProperty("RINDEX", NitrogenGasPhotMom, NitrogenGasRindex, NumPhotWaveLengthBins);
 
-    NitrogenGas->SetMaterialPropertiesTable(NitrogenGasMPT);
-    RichTbNitrogenGas = NitrogenGas;
+  NitrogenGasMPT->AddProperty("CKVRNDX", NitrogenGasPhotMomCkvProd, NitrogenGasCkvProdRindex,
+                              CkvProdNumPhotWaveLengthBins);
 
-    // test printout
+  NitrogenGas->SetMaterialPropertiesTable(NitrogenGasMPT);
+  RichTbNitrogenGas = NitrogenGas;
 
-    // G4MaterialPropertyVector* theRefractionIndexVector = 
-    //		    	  NitrogenGasMPT ->GetProperty("CKVRNDX");
+  // test printout
 
-    //  G4int itb=0;
-    //  theRefractionIndexVector->ResetIterator();
-    //  while(++(*theRefractionIndexVector))
+  // G4MaterialPropertyVector* theRefractionIndexVector =
+  //		    	  NitrogenGasMPT ->GetProperty("CKVRNDX");
 
-    //  {
-    // itb++;
-                               
-    //  G4double currentPM = theRefractionIndexVector->GetPhotonMomentum();
-    //  G4double currentRI=theRefractionIndexVector->GetProperty();
+  //  G4int itb=0;
+  //  theRefractionIndexVector->ResetIterator();
+  //  while(++(*theRefractionIndexVector))
 
+  //  {
+  // itb++;
 
-    // G4cout<<" Richtbmaterial N2refindVect  "<< itb<<"  "<< currentPM<<"  "<<currentRI
-    //      <<G4endl;
+  //  G4double currentPM = theRefractionIndexVector->GetPhotonMomentum();
+  //  G4double currentRI=theRefractionIndexVector->GetProperty();
 
-    //  }  
+  // G4cout<<" Richtbmaterial N2refindVect  "<< itb<<"  "<< currentPM<<"  "<<currentRI
+  //      <<G4endl;
+
+  //  }
 
   // end testprintout
-  //c4f10 gas.
+  // c4f10 gas.
 
-  density = 0.01195*CLHEP::g/CLHEP::cm3;
+  density = 0.01195 * CLHEP::g / CLHEP::cm3;
   //  pressure=1.*CLHEP::atmosphere;
   // temperature=293.*CLHEP::kelvin;
-  pressure = aRunConfig -> getc4f10Pressure();
-  
-  temperature = aRunConfig ->getc4f10Temperature();
-  
-
-  G4Material* c4f10Gas = new G4Material(name=c4f10GasMaterialName, 
-                                 density, numel=2,
-                                 kStateGas,temperature,pressure);
-  c4f10Gas->AddElement(elC, natoms=4);
-  c4f10Gas->AddElement(elF, natoms=10);
+  pressure = aRunConfig->getc4f10Pressure();
 
-  G4double* c4f10GasAbsorpLength=new G4double[NumPhotWaveLengthBins];
-  G4double* c4f10GasRindex=new G4double[NumPhotWaveLengthBins];
-  G4double* c4f10GasPhotMom=new G4double[NumPhotWaveLengthBins];
+  temperature = aRunConfig->getc4f10Temperature();
 
-  G4double* c4f10GasCkvProdRindex=
-          new G4double[CkvProdNumPhotWaveLengthBins];
-  G4double* c4f10GasPhotMomCkvProd=
-          new G4double[CkvProdNumPhotWaveLengthBins];
-  
+  G4Material *c4f10Gas =
+      new G4Material(name = c4f10GasMaterialName, density, numel = 2, kStateGas, temperature, pressure);
+  c4f10Gas->AddElement(elC, natoms = 4);
+  c4f10Gas->AddElement(elF, natoms = 10);
 
-  std::vector<G4double>c4f10RefInd= Initc4f10RefIndex(pressure,temperature);
-  std::vector<G4double>c4f10RefPhotMom=Initc4f10RefPhotMom();
+  G4double *c4f10GasAbsorpLength = new G4double[NumPhotWaveLengthBins];
+  G4double *c4f10GasRindex = new G4double[NumPhotWaveLengthBins];
+  G4double *c4f10GasPhotMom = new G4double[NumPhotWaveLengthBins];
 
+  G4double *c4f10GasCkvProdRindex = new G4double[CkvProdNumPhotWaveLengthBins];
+  G4double *c4f10GasPhotMomCkvProd = new G4double[CkvProdNumPhotWaveLengthBins];
 
-  for (G4int ibin=0; ibin<NumPhotWaveLengthBins; ibin++){
-    c4f10GasAbsorpLength[ibin]=1.E32*CLHEP::mm;
+  std::vector<G4double> c4f10RefInd = Initc4f10RefIndex(pressure, temperature);
+  std::vector<G4double> c4f10RefPhotMom = Initc4f10RefPhotMom();
 
-    c4f10GasRindex[ibin]=c4f10RefInd[ibin];
-    c4f10GasPhotMom[ibin]=c4f10RefPhotMom[ibin];
+  for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
+    c4f10GasAbsorpLength[ibin] = 1.E32 * CLHEP::mm;
 
+    c4f10GasRindex[ibin] = c4f10RefInd[ibin];
+    c4f10GasPhotMom[ibin] = c4f10RefPhotMom[ibin];
   }
-  
-  for (G4int ibina=IbMinForCkv; ibina <IbMaxForCkv ; ibina++){
-    G4int ibinp=  ibina-PhotEnerBinEdgeForSafety;
-    
-    c4f10GasCkvProdRindex[ibinp]= c4f10GasRindex[ibina];
-    c4f10GasPhotMomCkvProd[ibinp]=  c4f10GasPhotMom[ibina];
-    
-  }
-  
-  G4MaterialPropertiesTable* c4f10GasMPT = 
-                            new G4MaterialPropertiesTable();
-
-     c4f10GasMPT->AddProperty("ABSLENGTH",c4f10GasPhotMom,
-                        c4f10GasAbsorpLength,NumPhotWaveLengthBins);
-
-     c4f10GasMPT->AddProperty("RINDEX", c4f10GasPhotMom, 
-                      c4f10GasRindex,NumPhotWaveLengthBins);
-
-     c4f10GasMPT->AddProperty("CKVRNDX", c4f10GasPhotMomCkvProd , 
-                      c4f10GasCkvProdRindex,CkvProdNumPhotWaveLengthBins);
-
-    c4f10Gas->SetMaterialPropertiesTable(c4f10GasMPT);
-    RichTbc4f10Gas = c4f10Gas;
-
-
- // MirrorQuartz.
-//Sio2 
-//There is a quartz for the mirror and
- //another quartz which is used in aerogel and
- // yet another quartz used for the quartz window.
- //Mirrorquartz
-
- density=2.200*CLHEP::g/CLHEP::cm3;
- G4Material* SiO2MirrorQuartz = new G4Material(name="MirrorQuartz",
-                                              density,numel=2);
- SiO2MirrorQuartz->AddElement(elSi,natoms=1);
- SiO2MirrorQuartz->AddElement(elO,natoms=2);
- 
- //  G4double* MirrorQuartzRindex=new G4double[NumPhotWaveLengthBins];
-  G4double* MirrorQuartzAbsorpLength=new G4double[NumPhotWaveLengthBins];
- for (G4int ibin=0; ibin<NumPhotWaveLengthBins; ibin++){
-    MirrorQuartzAbsorpLength[ibin]=0.01*CLHEP::mm;
-    //   MirrorQuartzRindex[ibin]=1.40;
+
+  for (G4int ibina = IbMinForCkv; ibina < IbMaxForCkv; ibina++) {
+    G4int ibinp = ibina - PhotEnerBinEdgeForSafety;
+
+    c4f10GasCkvProdRindex[ibinp] = c4f10GasRindex[ibina];
+    c4f10GasPhotMomCkvProd[ibinp] = c4f10GasPhotMom[ibina];
   }
-  G4MaterialPropertiesTable* MirrorQuartzMPT = 
-                            new G4MaterialPropertiesTable();
 
+  G4MaterialPropertiesTable *c4f10GasMPT = new G4MaterialPropertiesTable();
 
-  MirrorQuartzMPT->AddProperty("ABSLENGTH",PhotonMomentum,
-                MirrorQuartzAbsorpLength,NumPhotWaveLengthBins);
+  c4f10GasMPT->AddProperty("ABSLENGTH", c4f10GasPhotMom, c4f10GasAbsorpLength, NumPhotWaveLengthBins);
 
+  c4f10GasMPT->AddProperty("RINDEX", c4f10GasPhotMom, c4f10GasRindex, NumPhotWaveLengthBins);
 
-  //  MirrorQuartzMPT->AddProperty("RINDEX", PhotonMomentum, 
-  //                   MirrorQuartzRindex,NumPhotWaveLengthBins);
+  c4f10GasMPT->AddProperty("CKVRNDX", c4f10GasPhotMomCkvProd, c4f10GasCkvProdRindex, CkvProdNumPhotWaveLengthBins);
 
-  SiO2MirrorQuartz->SetMaterialPropertiesTable(MirrorQuartzMPT);
-  RichTbMirrorQuartz=SiO2MirrorQuartz;
- //
- // GasQuWindowQuartz.
-//Sio2 
-
- density=2.200*CLHEP::g/CLHEP::cm3;
- G4Material* SiO2GasWinQuartz = new G4Material(name="GasWinQuartz",
-                                              density,numel=2);
- SiO2GasWinQuartz->AddElement(elSi,natoms=1);
- SiO2GasWinQuartz->AddElement(elO,natoms=2);
- 
- // G4int CurGasQuWinAbsorpNumBins=aRichTbGasQuWinProperty->getGasQuWinAbsorpNumBins();
- //  G4double* GasWinQuartzAbsorpLength=new G4double[CurGasQuWinAbsorpNumBins];
- //  G4double* GasWinQuAbsorpPhotonMomentum= new G4double[ CurGasQuWinAbsorpNumBins];
- //  std::vector<G4double> GasQuWinAbsorpLengthVect= aRichTbGasQuWinProperty-> getGasQuWinAbsorpLength();
- //  std::vector<G4double> GasWinQuAbsorpPhotonMomentumVect=aRichTbGasQuWinProperty->  getGasQuWinAbsorpPhMom();  
- //  for(G4int ibina=0; ibina<CurGasQuWinAbsorpNumBins; ibina++) {
-   
-    //    GasWinQuartzAbsorpLength[ibina]=1.E32*CLHEP::mm;
- //   GasWinQuartzAbsorpLength[ibina]=GasQuWinAbsorpLengthVect[ibina];
- //   GasWinQuAbsorpPhotonMomentum[ibina]= GasWinQuAbsorpPhotonMomentumVect[ibina];
- //  }
+  c4f10Gas->SetMaterialPropertiesTable(c4f10GasMPT);
+  RichTbc4f10Gas = c4f10Gas;
 
-  // now for the refractive index of GasQuWindow.
- //  G4double* GasWinQuartzRindex=new G4double[NumPhotWaveLengthBins];
- // for (G4int ibin=0; ibin<NumPhotWaveLengthBins; ibin++){
-    //    GasWinQuartzRindex[ibin]=1.40;
- //  GasWinQuartzRindex[ibin]=GasQuartzWindowNominalRefIndex;
- //  }
-
-
- //4MaterialPropertiesTable* GasWinQuartzMPT = 
- //                            new G4MaterialPropertiesTable();
-
-
- // GasWinQuartzMPT->AddProperty("ABSLENGTH",GasWinQuAbsorpPhotonMomentum,
- //               GasWinQuartzAbsorpLength,CurGasQuWinAbsorpNumBins);
-
-
- // GasWinQuartzMPT->AddProperty("RINDEX", PhotonMomentum, 
- //                    GasWinQuartzRindex,NumPhotWaveLengthBins);
-
- //  SiO2GasWinQuartz->SetMaterialPropertiesTable(GasWinQuartzMPT);
- // RichTbGasWinQuartz=SiO2GasWinQuartz;
-
-//Vaccum
-//
- density=CLHEP::universe_mean_density;    //from PhysicalConstants.h
- a=1.01*CLHEP::g/CLHEP::mole;
- pressure=1.e-19*CLHEP::pascal;
- temperature=0.1*CLHEP::kelvin;
-// G4Material* vaccum = new G4Material(name="Galactic",z=1.,a,density,
- G4Material* vaccum = new G4Material(name="Galactic",density,numel=1,
-                              kStateGas,temperature,pressure);
- vaccum->AddMaterial(Air, fractionmass=1.);
- G4double *vacAbsorpLength = new G4double[NumPhotWaveLengthBins];
- G4double *vacRindex = new G4double[NumPhotWaveLengthBins];
-    for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
-        vacAbsorpLength[ibin] = 1.E32 * CLHEP::mm;
-        vacRindex[ibin] = 1.000273;
-    }
-    G4MaterialPropertiesTable *vacMPT = new G4MaterialPropertiesTable();
+  // MirrorQuartz.
+  // Sio2
+  // There is a quartz for the mirror and
+  // another quartz which is used in aerogel and
+  // yet another quartz used for the quartz window.
+  // Mirrorquartz
 
-    vacMPT->AddProperty("ABSLENGTH", PhotonMomentum, 
-                  vacAbsorpLength, NumPhotWaveLengthBins);
+  density = 2.200 * CLHEP::g / CLHEP::cm3;
+  G4Material *SiO2MirrorQuartz = new G4Material(name = "MirrorQuartz", density, numel = 2);
+  SiO2MirrorQuartz->AddElement(elSi, natoms = 1);
+  SiO2MirrorQuartz->AddElement(elO, natoms = 2);
 
-    vacMPT->AddProperty("RINDEX", PhotonMomentum, vacRindex, 
-                        NumPhotWaveLengthBins);
+  //  G4double* MirrorQuartzRindex=new G4double[NumPhotWaveLengthBins];
+  G4double *MirrorQuartzAbsorpLength = new G4double[NumPhotWaveLengthBins];
+  for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
+    MirrorQuartzAbsorpLength[ibin] = 0.01 * CLHEP::mm;
+    //   MirrorQuartzRindex[ibin]=1.40;
+  }
+  G4MaterialPropertiesTable *MirrorQuartzMPT = new G4MaterialPropertiesTable();
 
-     vaccum->SetMaterialPropertiesTable(vacMPT);
- 
- RichTbVaccum=vaccum;
+  MirrorQuartzMPT->AddProperty("ABSLENGTH", PhotonMomentum, MirrorQuartzAbsorpLength, NumPhotWaveLengthBins);
 
- // G4cout<<"Now define Aluminium "<<G4endl;
- 
-//Aluminium
-  density=2.7*CLHEP::g/CLHEP::cm3;
-  G4Material* Aluminium =new G4Material(name="Aluminium",density,numel=1);
-  Aluminium->AddElement(elAL,natoms=1);
- 
+  //  MirrorQuartzMPT->AddProperty("RINDEX", PhotonMomentum,
+  //                   MirrorQuartzRindex,NumPhotWaveLengthBins);
 
-  G4double* AluminiumAbsorpLength= new G4double[NumPhotWaveLengthBins];
+  SiO2MirrorQuartz->SetMaterialPropertiesTable(MirrorQuartzMPT);
+  RichTbMirrorQuartz = SiO2MirrorQuartz;
+  //
+  // GasQuWindowQuartz.
+  // Sio2
+
+  density = 2.200 * CLHEP::g / CLHEP::cm3;
+  G4Material *SiO2GasWinQuartz = new G4Material(name = "GasWinQuartz", density, numel = 2);
+  SiO2GasWinQuartz->AddElement(elSi, natoms = 1);
+  SiO2GasWinQuartz->AddElement(elO, natoms = 2);
+
+  // G4int CurGasQuWinAbsorpNumBins=aRichTbGasQuWinProperty->getGasQuWinAbsorpNumBins();
+  //  G4double* GasWinQuartzAbsorpLength=new G4double[CurGasQuWinAbsorpNumBins];
+  //  G4double* GasWinQuAbsorpPhotonMomentum= new G4double[ CurGasQuWinAbsorpNumBins];
+  //  std::vector<G4double> GasQuWinAbsorpLengthVect= aRichTbGasQuWinProperty-> getGasQuWinAbsorpLength();
+  //  std::vector<G4double> GasWinQuAbsorpPhotonMomentumVect=aRichTbGasQuWinProperty->  getGasQuWinAbsorpPhMom();
+  //  for(G4int ibina=0; ibina<CurGasQuWinAbsorpNumBins; ibina++) {
+
+  //    GasWinQuartzAbsorpLength[ibina]=1.E32*CLHEP::mm;
+  //   GasWinQuartzAbsorpLength[ibina]=GasQuWinAbsorpLengthVect[ibina];
+  //   GasWinQuAbsorpPhotonMomentum[ibina]= GasWinQuAbsorpPhotonMomentumVect[ibina];
+  //  }
 
-  for (G4int ibin=0; ibin<NumPhotWaveLengthBins; ibin++){
-    AluminiumAbsorpLength[ibin]=0.0*CLHEP::mm;
+  // now for the refractive index of GasQuWindow.
+  //  G4double* GasWinQuartzRindex=new G4double[NumPhotWaveLengthBins];
+  // for (G4int ibin=0; ibin<NumPhotWaveLengthBins; ibin++){
+  //    GasWinQuartzRindex[ibin]=1.40;
+  //  GasWinQuartzRindex[ibin]=GasQuartzWindowNominalRefIndex;
+  //  }
+
+  // 4MaterialPropertiesTable* GasWinQuartzMPT =
+  //                            new G4MaterialPropertiesTable();
+
+  // GasWinQuartzMPT->AddProperty("ABSLENGTH",GasWinQuAbsorpPhotonMomentum,
+  //               GasWinQuartzAbsorpLength,CurGasQuWinAbsorpNumBins);
+
+  // GasWinQuartzMPT->AddProperty("RINDEX", PhotonMomentum,
+  //                    GasWinQuartzRindex,NumPhotWaveLengthBins);
+
+  //  SiO2GasWinQuartz->SetMaterialPropertiesTable(GasWinQuartzMPT);
+  // RichTbGasWinQuartz=SiO2GasWinQuartz;
+
+  // Vaccum
+  //
+  density = CLHEP::universe_mean_density; // from PhysicalConstants.h
+  a = 1.01 * CLHEP::g / CLHEP::mole;
+  pressure = 1.e-19 * CLHEP::pascal;
+  temperature = 0.1 * CLHEP::kelvin;
+  // G4Material* vaccum = new G4Material(name="Galactic",z=1.,a,density,
+  G4Material *vaccum = new G4Material(name = "Galactic", density, numel = 1, kStateGas, temperature, pressure);
+  vaccum->AddMaterial(Air, fractionmass = 1.);
+  G4double *vacAbsorpLength = new G4double[NumPhotWaveLengthBins];
+  G4double *vacRindex = new G4double[NumPhotWaveLengthBins];
+  for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
+    vacAbsorpLength[ibin] = 1.E32 * CLHEP::mm;
+    vacRindex[ibin] = 1.000273;
   }
+  G4MaterialPropertiesTable *vacMPT = new G4MaterialPropertiesTable();
+
+  vacMPT->AddProperty("ABSLENGTH", PhotonMomentum, vacAbsorpLength, NumPhotWaveLengthBins);
+
+  vacMPT->AddProperty("RINDEX", PhotonMomentum, vacRindex, NumPhotWaveLengthBins);
+
+  vaccum->SetMaterialPropertiesTable(vacMPT);
 
+  RichTbVaccum = vaccum;
 
-  G4MaterialPropertiesTable* AluminiumMPT = 
-                            new G4MaterialPropertiesTable();
+  // G4cout<<"Now define Aluminium "<<G4endl;
 
+  // Aluminium
+  density = 2.7 * CLHEP::g / CLHEP::cm3;
+  G4Material *Aluminium = new G4Material(name = "Aluminium", density, numel = 1);
+  Aluminium->AddElement(elAL, natoms = 1);
 
-  AluminiumMPT->AddProperty("ABSLENGTH",PhotonMomentum,
-                AluminiumAbsorpLength,NumPhotWaveLengthBins);
+  G4double *AluminiumAbsorpLength = new G4double[NumPhotWaveLengthBins];
 
+  for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
+    AluminiumAbsorpLength[ibin] = 0.0 * CLHEP::mm;
+  }
+
+  G4MaterialPropertiesTable *AluminiumMPT = new G4MaterialPropertiesTable();
 
+  AluminiumMPT->AddProperty("ABSLENGTH", PhotonMomentum, AluminiumAbsorpLength, NumPhotWaveLengthBins);
 
   Aluminium->SetMaterialPropertiesTable(AluminiumMPT);
 
-  RichTbAluminium=Aluminium;
+  RichTbAluminium = Aluminium;
 
   // generic carbon
-  density= 2.0*CLHEP::g/CLHEP::cm3;
-  G4Material* CarbonMaterial = 
-    new G4Material (name="CarbonMaterial",
-                    density,numel=1 );
-   CarbonMaterial->AddElement(elC, natoms=1);  
-   RichTbCarbon= CarbonMaterial;
-   
- 
-  
-// Kovar
-  density=2.7*CLHEP::g/CLHEP::cm3;
-  G4Material* Kovar =new G4Material(PMTEnvelopeMaterialName,density,numel=1);
-  Kovar->AddElement(elAL,natoms=1);
-   
-  PMTTubeEnvelopeMaterial=Kovar;
-  HpdTubeEnvelopeMaterial=Kovar;
-  
+  density = 2.0 * CLHEP::g / CLHEP::cm3;
+  G4Material *CarbonMaterial = new G4Material(name = "CarbonMaterial", density, numel = 1);
+  CarbonMaterial->AddElement(elC, natoms = 1);
+  RichTbCarbon = CarbonMaterial;
+
+  // Kovar
+  density = 2.7 * CLHEP::g / CLHEP::cm3;
+  G4Material *Kovar = new G4Material(PMTEnvelopeMaterialName, density, numel = 1);
+  Kovar->AddElement(elAL, natoms = 1);
+
+  PMTTubeEnvelopeMaterial = Kovar;
+  HpdTubeEnvelopeMaterial = Kovar;
+
   // Silicon
-  
-   density=2.33*CLHEP::g/CLHEP::cm3;
-   //"PMTSilicon"
-  G4Material* Silicon =new G4Material(name= PMTAnodeMaterialName,
-             density,numel=1);
-  Silicon->AddElement(elSi,natoms=1);
 
-  PMTAnodeMaterial=Silicon;
+  density = 2.33 * CLHEP::g / CLHEP::cm3;
+  //"PMTSilicon"
+  G4Material *Silicon = new G4Material(name = PMTAnodeMaterialName, density, numel = 1);
+  Silicon->AddElement(elSi, natoms = 1);
 
+  PMTAnodeMaterial = Silicon;
 
-  G4Material* HpdSilicon =new G4Material(name= HpdSiDetMaterialName,density,numel=1);
-  HpdSilicon->AddElement(elSi,natoms=1);
+  G4Material *HpdSilicon = new G4Material(name = HpdSiDetMaterialName, density, numel = 1);
+  HpdSilicon->AddElement(elSi, natoms = 1);
   HpdSiDetMaterial = HpdSilicon;
 
- 
   // hpd quartz window
 
- density=2.200*CLHEP::g/CLHEP::cm3;
- //"PMTWindowQuartz"
- G4Material* PMTWindowQuartz = new G4Material(name=PmtQuartzWMaterialName,
-                                              density,numel=2);
- PMTWindowQuartz->AddElement(elSi,natoms=1);
- PMTWindowQuartz->AddElement(elO,natoms=2);
- 
- G4double* PMTWindowQuartzRindex=new G4double[PMTQuartzRefIndNumBins]; //31 bin
- G4double* PMTWindowQuartzPhMom = new G4double[PMTQuartzRefIndNumBins];
- G4double* PMTWindowQuartzAbsorpLength=new G4double[NumPhotWaveLengthBins];
-  for (G4int ibin=0; ibin<NumPhotWaveLengthBins; ibin++){
-   PMTWindowQuartzAbsorpLength[ibin]=1.E32*CLHEP::mm;
-   //    PMTWindowQuartzRindex[ibin]=1.40;
+  density = 2.200 * CLHEP::g / CLHEP::cm3;
+  //"PMTWindowQuartz"
+  G4Material *PMTWindowQuartz = new G4Material(name = PmtQuartzWMaterialName, density, numel = 2);
+  PMTWindowQuartz->AddElement(elSi, natoms = 1);
+  PMTWindowQuartz->AddElement(elO, natoms = 2);
+
+  G4double *PMTWindowQuartzRindex = new G4double[PMTQuartzRefIndNumBins]; // 31 bin
+  G4double *PMTWindowQuartzPhMom = new G4double[PMTQuartzRefIndNumBins];
+  G4double *PMTWindowQuartzAbsorpLength = new G4double[NumPhotWaveLengthBins];
+  for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
+    PMTWindowQuartzAbsorpLength[ibin] = 1.E32 * CLHEP::mm;
+    //    PMTWindowQuartzRindex[ibin]=1.40;
   }
-  for(G4int ibina=0; ibina <PMTQuartzRefIndNumBins; ibina++ ) {
-     PMTWindowQuartzPhMom[ibina]=
-       PhotWaveLengthToMom/
-       (PMTQuartzRefWaveLenValues[ibina]*PMTQuartzRefWaveLenUnits);     
-      PMTWindowQuartzRindex[ibina] = PMTQuartzRefIndexValues[ibina];
-    
+  for (G4int ibina = 0; ibina < PMTQuartzRefIndNumBins; ibina++) {
+    PMTWindowQuartzPhMom[ibina] = PhotWaveLengthToMom / (PMTQuartzRefWaveLenValues[ibina] * PMTQuartzRefWaveLenUnits);
+    PMTWindowQuartzRindex[ibina] = PMTQuartzRefIndexValues[ibina];
   }
-  
-  G4MaterialPropertiesTable* PMTWindowQuartzMPT = 
-                            new G4MaterialPropertiesTable();
 
-  PMTWindowQuartzMPT->AddProperty("ABSLENGTH",PhotonMomentum,
-                PMTWindowQuartzAbsorpLength,NumPhotWaveLengthBins);
+  G4MaterialPropertiesTable *PMTWindowQuartzMPT = new G4MaterialPropertiesTable();
+
+  PMTWindowQuartzMPT->AddProperty("ABSLENGTH", PhotonMomentum, PMTWindowQuartzAbsorpLength, NumPhotWaveLengthBins);
 
-  PMTWindowQuartzMPT->AddProperty("RINDEX",PMTWindowQuartzPhMom , 
-                        PMTWindowQuartzRindex,PMTQuartzRefIndNumBins);
+  PMTWindowQuartzMPT->AddProperty("RINDEX", PMTWindowQuartzPhMom, PMTWindowQuartzRindex, PMTQuartzRefIndNumBins);
 
   PMTWindowQuartz->SetMaterialPropertiesTable(PMTWindowQuartzMPT);
 
-  PMTQuartzWindowMaterial=PMTWindowQuartz;
+  PMTQuartzWindowMaterial = PMTWindowQuartz;
 
-  
- //"HPDWindowQuartz"
+  //"HPDWindowQuartz"
 
- G4Material* HPDWindowQuartz = new G4Material(name= HpdQuartzWMaterialName,density,numel=2);
- HPDWindowQuartz->AddElement(elSi,natoms=1);
- HPDWindowQuartz->AddElement(elO,natoms=2);
- 
- G4double* HPDWindowQuartzRindex=new G4double[HPDQuartzRefIndNumBins]; //31 bin
- G4double* HPDWindowQuartzPhMom = new G4double[HPDQuartzRefIndNumBins];
+  G4Material *HPDWindowQuartz = new G4Material(name = HpdQuartzWMaterialName, density, numel = 2);
+  HPDWindowQuartz->AddElement(elSi, natoms = 1);
+  HPDWindowQuartz->AddElement(elO, natoms = 2);
 
- G4double* HPDWindowQuartzAbsorpLength=new G4double[NumPhotWaveLengthBins];
+  G4double *HPDWindowQuartzRindex = new G4double[HPDQuartzRefIndNumBins]; // 31 bin
+  G4double *HPDWindowQuartzPhMom = new G4double[HPDQuartzRefIndNumBins];
 
-  for (G4int ibin=0; ibin<NumPhotWaveLengthBins; ibin++){
-   HPDWindowQuartzAbsorpLength[ibin]=1.E32*CLHEP::mm;
-   //    PMTWindowQuartzRindex[ibin]=1.40;
+  G4double *HPDWindowQuartzAbsorpLength = new G4double[NumPhotWaveLengthBins];
+
+  for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
+    HPDWindowQuartzAbsorpLength[ibin] = 1.E32 * CLHEP::mm;
+    //    PMTWindowQuartzRindex[ibin]=1.40;
   }
-  for(G4int ibina=0; ibina <HPDQuartzRefIndNumBins; ibina++ ) {
-     HPDWindowQuartzPhMom[ibina]=
-       PhotWaveLengthToMom/
-       (HPDQuartzRefWaveLenValues[ibina]*HPDQuartzRefWaveLenUnits);     
-        HPDWindowQuartzRindex[ibina] = HPDQuartzRefIndexValues[ibina];
-    
+  for (G4int ibina = 0; ibina < HPDQuartzRefIndNumBins; ibina++) {
+    HPDWindowQuartzPhMom[ibina] = PhotWaveLengthToMom / (HPDQuartzRefWaveLenValues[ibina] * HPDQuartzRefWaveLenUnits);
+    HPDWindowQuartzRindex[ibina] = HPDQuartzRefIndexValues[ibina];
   }
-  
-  
-  G4MaterialPropertiesTable* HPDWindowQuartzMPT = 
-                            new G4MaterialPropertiesTable();
 
-  HPDWindowQuartzMPT->AddProperty("ABSLENGTH",PhotonMomentum,
-                HPDWindowQuartzAbsorpLength,NumPhotWaveLengthBins);
+  G4MaterialPropertiesTable *HPDWindowQuartzMPT = new G4MaterialPropertiesTable();
 
-  HPDWindowQuartzMPT->AddProperty("RINDEX",HPDWindowQuartzPhMom , 
-                        HPDWindowQuartzRindex,HPDQuartzRefIndNumBins);
+  HPDWindowQuartzMPT->AddProperty("ABSLENGTH", PhotonMomentum, HPDWindowQuartzAbsorpLength, NumPhotWaveLengthBins);
 
-  HPDWindowQuartz->SetMaterialPropertiesTable(HPDWindowQuartzMPT);
+  HPDWindowQuartzMPT->AddProperty("RINDEX", HPDWindowQuartzPhMom, HPDWindowQuartzRindex, HPDQuartzRefIndNumBins);
 
-  HPDQuartzWindowMaterial=HPDWindowQuartz;
+  HPDWindowQuartz->SetMaterialPropertiesTable(HPDWindowQuartzMPT);
 
+  HPDQuartzWindowMaterial = HPDWindowQuartz;
 
+  // crystal material
 
-// crystal material
+  density = 2.200 * CLHEP::g / CLHEP::cm3; // non e' quella giusta
 
-  density=2.200*CLHEP::g/CLHEP::cm3; //non e' quella giusta
+  G4Material *CrystalMat = new G4Material(name = CrystalMaterialName, density, numel = 2);
+  CrystalMat->AddElement(elSi, natoms = 1); // anche questi sono sbagliati
+  CrystalMat->AddElement(elO, natoms = 2);
 
- G4Material* CrystalMat = new G4Material(name=CrystalMaterialName,
-                                              density,numel=2);
- CrystalMat->AddElement(elSi,natoms=1); // anche questi sono sbagliati
- CrystalMat->AddElement(elO,natoms=2);
- 
-  G4double* CrystalMatRindex=new G4double[CrystalMatRefIndNumBins]; //31 
-  //std::vector<G4double> CrystalMatRefPhMom=Initc4f10RefPhotMom();
-  G4double* CrystalMatPhMom = new G4double[CrystalMatRefIndNumBins];
-  G4double* CrystalMatAbsorpLength= new G4double[CrystalMatRefIndNumBins];
-  G4double* CrystalMatCkvProdRindex= new G4double[CrystalMatRefIndNumBins];
+  G4double *CrystalMatRindex = new G4double[CrystalMatRefIndNumBins]; // 31
+  // std::vector<G4double> CrystalMatRefPhMom=Initc4f10RefPhotMom();
+  G4double *CrystalMatPhMom = new G4double[CrystalMatRefIndNumBins];
+  G4double *CrystalMatAbsorpLength = new G4double[CrystalMatRefIndNumBins];
+  G4double *CrystalMatCkvProdRindex = new G4double[CrystalMatRefIndNumBins];
   G4cout << "n bin " << CkvProdNumPhotWaveLengthBins << G4endl;
-  G4double* CrystalMatPhotMomCkvProd=
-          new G4double[CrystalMatRefIndNumBins];
+  G4double *CrystalMatPhotMomCkvProd = new G4double[CrystalMatRefIndNumBins];
   //  test study for reconstruction
   //  G4bool m_activateRefIndexStudy = false;
 
-   G4bool m_activateRefIndexStudy = true;
-  
+  G4bool m_activateRefIndexStudy = true;
+
   //  G4double  CrysMatRefractiveIndexShift = m_activateRefIndexStudy ? 0.1 : 0.0 ;
-  G4double  CrysMatRefractiveIndexShift = m_activateRefIndexStudy ? 0.03 : 0.0 ;
-  
+  G4double CrysMatRefractiveIndexShift = m_activateRefIndexStudy ? 0.03 : 0.0;
+
   // end test study for reconstruction
- 
-  
-  RichTbAnalysisManager* aRichTbAnalysisManager = RichTbAnalysisManager::getInstance();
-  
- 
-  for(G4int ibina=0; ibina <CrystalMatRefIndNumBins; ibina++ ) {
-     CrystalMatPhMom[ibina]=
-     PhotWaveLengthToMom/
-    	(CrystalMatRefWaveLenValues[ibina]*CrystalMatRefWaveLenUnits);   
-      CrystalMatRindex[ibina] = CrystalMatRefIndexValues[ibina] + CrysMatRefractiveIndexShift;
+
+  RichTbAnalysisManager *aRichTbAnalysisManager = RichTbAnalysisManager::getInstance();
+
+  for (G4int ibina = 0; ibina < CrystalMatRefIndNumBins; ibina++) {
+    CrystalMatPhMom[ibina] = PhotWaveLengthToMom / (CrystalMatRefWaveLenValues[ibina] * CrystalMatRefWaveLenUnits);
+    CrystalMatRindex[ibina] = CrystalMatRefIndexValues[ibina] + CrysMatRefractiveIndexShift;
     //  G4cout<<"Crystal RI " << CrystalMatRindex[ibina] <<G4endl;
-      //G4cout<<"momentum " << CrystalMatPhMom[ibina] <<G4endl;
-
-      if(aRichTbAnalysisManager->getfRadiatorRefIndex()) 
-        aRichTbAnalysisManager->getfRadiatorRefIndex()->Fill(CrystalMatRefWaveLenValues[ibina],
-                                                             (CrystalMatRindex[ibina]-1.0) );
-      
-      //  CrystalMatAbsorpLength[ibina]=1.E32*CLHEP::mm;
-       CrystalMatAbsorpLength[ibina] = CrystalMatAbsorptionValues[ibina]*CLHEP::mm;
-       //  CrystalMatRindex[ibina]=1.5;
-    // G4cout<<"Crystal RI " << CrystalMatRindex[ibin] <<G4endl;  
-       //   G4cout<<"Crystal momentum and  Abs Length " <<CrystalMatPhMom[ibina]<< " "<<CrystalMatAbsorpLength[ibina] <<G4endl;
-   
-     G4int ibinp = ibina;
-     CrystalMatCkvProdRindex[ibinp]= CrystalMatRindex[ibina];
+    // G4cout<<"momentum " << CrystalMatPhMom[ibina] <<G4endl;
+
+    if (aRichTbAnalysisManager->getfRadiatorRefIndex())
+      aRichTbAnalysisManager->getfRadiatorRefIndex()->Fill(CrystalMatRefWaveLenValues[ibina],
+                                                           (CrystalMatRindex[ibina] - 1.0));
+
+    //  CrystalMatAbsorpLength[ibina]=1.E32*CLHEP::mm;
+    CrystalMatAbsorpLength[ibina] = CrystalMatAbsorptionValues[ibina] * CLHEP::mm;
+    //  CrystalMatRindex[ibina]=1.5;
+    // G4cout<<"Crystal RI " << CrystalMatRindex[ibin] <<G4endl;
+    //   G4cout<<"Crystal momentum and  Abs Length " <<CrystalMatPhMom[ibina]<< " "<<CrystalMatAbsorpLength[ibina]
+    //   <<G4endl;
+
+    G4int ibinp = ibina;
+    CrystalMatCkvProdRindex[ibinp] = CrystalMatRindex[ibina];
     // G4cout << "Ckv crystal RI " << ibinp<< " " << CrystalMatCkvProdRindex[ibinp] << G4endl;
-    CrystalMatPhotMomCkvProd[ibinp]=  CrystalMatPhMom[ibina];
+    CrystalMatPhotMomCkvProd[ibinp] = CrystalMatPhMom[ibina];
     // G4cout << "Ckv momentum " << ibinp<< " " << CrystalMatPhotMomCkvProd[ibinp] << G4endl;
   }
-  
 
-  
-  G4MaterialPropertiesTable* CrystalMPT = 
-                            new G4MaterialPropertiesTable();
+  G4MaterialPropertiesTable *CrystalMPT = new G4MaterialPropertiesTable();
 
-  CrystalMPT->AddProperty("ABSLENGTH",CrystalMatPhMom,
-			  CrystalMatAbsorpLength,CrystalMatRefIndNumBins);
+  CrystalMPT->AddProperty("ABSLENGTH", CrystalMatPhMom, CrystalMatAbsorpLength, CrystalMatRefIndNumBins);
 
-  CrystalMPT->AddProperty("RINDEX",CrystalMatPhMom , 
-                        CrystalMatRindex,CrystalMatRefIndNumBins);
+  CrystalMPT->AddProperty("RINDEX", CrystalMatPhMom, CrystalMatRindex, CrystalMatRefIndNumBins);
 
-  CrystalMPT->AddProperty("CKVRNDX", CrystalMatPhotMomCkvProd , 
-                      CrystalMatCkvProdRindex,CrystalMatRefIndNumBins);
+  CrystalMPT->AddProperty("CKVRNDX", CrystalMatPhotMomCkvProd, CrystalMatCkvProdRindex, CrystalMatRefIndNumBins);
 
   CrystalMat->SetMaterialPropertiesTable(CrystalMPT);
 
-  CrystalMaterial=CrystalMat;
-
+  CrystalMaterial = CrystalMat;
 
   // PMT Ph Cathode
 
- //the following numbers on the property of the S20 may not be accurate.
- //Some number is is jut put in for initial program test purposes.
- //The real composition is 60 nm of Na2KSb followed by 20 nm of Cs3Sb
- //from the outside to inside of the HPD. 
-  density=0.100*CLHEP::g/CLHEP::cm3;
+  // the following numbers on the property of the S20 may not be accurate.
+  // Some number is is jut put in for initial program test purposes.
+  // The real composition is 60 nm of Na2KSb followed by 20 nm of Cs3Sb
+  // from the outside to inside of the HPD.
+  density = 0.100 * CLHEP::g / CLHEP::cm3;
   //"S20PhCathode"
 
-
- G4Material* S20PhCathode = new G4Material(name=PmtPhCathodeMaterialName, 
-                                 density, numel=4);
- S20PhCathode->AddElement(elNa, fractionmass=37.5*CLHEP::perCent);
- S20PhCathode->AddElement(elK, fractionmass=18.75*CLHEP::perCent);
- S20PhCathode->AddElement(elCs, fractionmass=18.75*CLHEP::perCent);
- S20PhCathode->AddElement(elSb, fractionmass=25.0*CLHEP::perCent);
-
- // G4double* S20PhCathodeRindex=new G4double[NumPhotWaveLengthBins];
-  G4int  S20PhCathodeRefIndNumBins=PMTQuartzRefIndNumBins;
-  G4double* S20PhCathodeRindex=new G4double[S20PhCathodeRefIndNumBins];
-  G4double* S20PhCathodeRefIndPhMom = new G4double[S20PhCathodeRefIndNumBins];
- // the ref index of phcathode is derived from that of the hpd quartz window.
- // using the formula (na*na-nb*nb)/(na*na+nb*nb) = fraction of refelcted photons. 
- G4double refindphFactor=1.04;
- if (PMTQwPhReflectionProb < 1.0) 
-  refindphFactor =  pow(((1+PMTQwPhReflectionProb)/(1-PMTQwPhReflectionProb)),0.5);
-  for(G4int ibins=0; ibins <S20PhCathodeRefIndNumBins; ibins++ ) {
-  //    S20PhCathodeRindex[ibin]=1.6;
-
-    S20PhCathodeRefIndPhMom[ibins] =  PMTWindowQuartzPhMom[ibins];
-
-    S20PhCathodeRindex[ibins] =   refindphFactor* PMTWindowQuartzRindex[ibins];
+  G4Material *S20PhCathode = new G4Material(name = PmtPhCathodeMaterialName, density, numel = 4);
+  S20PhCathode->AddElement(elNa, fractionmass = 37.5 * CLHEP::perCent);
+  S20PhCathode->AddElement(elK, fractionmass = 18.75 * CLHEP::perCent);
+  S20PhCathode->AddElement(elCs, fractionmass = 18.75 * CLHEP::perCent);
+  S20PhCathode->AddElement(elSb, fractionmass = 25.0 * CLHEP::perCent);
+
+  // G4double* S20PhCathodeRindex=new G4double[NumPhotWaveLengthBins];
+  G4int S20PhCathodeRefIndNumBins = PMTQuartzRefIndNumBins;
+  G4double *S20PhCathodeRindex = new G4double[S20PhCathodeRefIndNumBins];
+  G4double *S20PhCathodeRefIndPhMom = new G4double[S20PhCathodeRefIndNumBins];
+  // the ref index of phcathode is derived from that of the hpd quartz window.
+  // using the formula (na*na-nb*nb)/(na*na+nb*nb) = fraction of refelcted photons.
+  G4double refindphFactor = 1.04;
+  if (PMTQwPhReflectionProb < 1.0)
+    refindphFactor = pow(((1 + PMTQwPhReflectionProb) / (1 - PMTQwPhReflectionProb)), 0.5);
+  for (G4int ibins = 0; ibins < S20PhCathodeRefIndNumBins; ibins++) {
+    //    S20PhCathodeRindex[ibin]=1.6;
+
+    S20PhCathodeRefIndPhMom[ibins] = PMTWindowQuartzPhMom[ibins];
+
+    S20PhCathodeRindex[ibins] = refindphFactor * PMTWindowQuartzRindex[ibins];
   }
   // now for the absorption length.
- G4double* S20PhCathodeAbsorpLength=new G4double[NumPhotWaveLengthBins];
- G4double MomBoundaryRedBlue=PhotWaveLengthToMom/PMTPhCathodeRedBlueBoundary;
- G4double ablengblue = -1.0*RichTbPMTPhCathodeThickness/log(PMTPhCathodeTransBlue);
- G4double ablengred=  -1.0*RichTbPMTPhCathodeThickness/log(PMTPhCathodeTransRed);
-
-  for (G4int iabin=0; iabin < NumPhotWaveLengthBins; iabin++ ) {
-   if(PhotonMomentum[iabin] < MomBoundaryRedBlue ) {
-     S20PhCathodeAbsorpLength[iabin]=ablengred;     
-   }else {
-     S20PhCathodeAbsorpLength[iabin]= ablengblue;
-   }
-   
-
+  G4double *S20PhCathodeAbsorpLength = new G4double[NumPhotWaveLengthBins];
+  G4double MomBoundaryRedBlue = PhotWaveLengthToMom / PMTPhCathodeRedBlueBoundary;
+  G4double ablengblue = -1.0 * RichTbPMTPhCathodeThickness / log(PMTPhCathodeTransBlue);
+  G4double ablengred = -1.0 * RichTbPMTPhCathodeThickness / log(PMTPhCathodeTransRed);
+
+  for (G4int iabin = 0; iabin < NumPhotWaveLengthBins; iabin++) {
+    if (PhotonMomentum[iabin] < MomBoundaryRedBlue) {
+      S20PhCathodeAbsorpLength[iabin] = ablengred;
+    } else {
+      S20PhCathodeAbsorpLength[iabin] = ablengblue;
+    }
   }
 
+  G4MaterialPropertiesTable *S20PhCathodeMPT = new G4MaterialPropertiesTable();
+  S20PhCathodeMPT->AddProperty("ABSLENGTH", PhotonMomentum, S20PhCathodeAbsorpLength, NumPhotWaveLengthBins);
 
- G4MaterialPropertiesTable* S20PhCathodeMPT = 
-                            new G4MaterialPropertiesTable();
-  S20PhCathodeMPT->AddProperty("ABSLENGTH",PhotonMomentum,
-                S20PhCathodeAbsorpLength,NumPhotWaveLengthBins);
-
-  //  S20PhCathodeMPT->AddProperty("RINDEX", PhotonMomentum, 
+  //  S20PhCathodeMPT->AddProperty("RINDEX", PhotonMomentum,
   //                      S20PhCathodeRindex,NumPhotWaveLengthBins);
-  S20PhCathodeMPT->AddProperty("RINDEX",S20PhCathodeRefIndPhMom , 
-                        S20PhCathodeRindex,S20PhCathodeRefIndNumBins);
-
-
+  S20PhCathodeMPT->AddProperty("RINDEX", S20PhCathodeRefIndPhMom, S20PhCathodeRindex, S20PhCathodeRefIndNumBins);
 
   S20PhCathode->SetMaterialPropertiesTable(S20PhCathodeMPT);
-  PMTPhCathodeMaterial=S20PhCathode;
-
-
-
+  PMTPhCathodeMaterial = S20PhCathode;
 
   //"HPDS20PhCathode"
 
- G4Material* HPDS20PhCathode = new G4Material(name=HpdPhCathodeMaterialName, 
-                                 density, numel=4);
- HPDS20PhCathode->AddElement(elNa, fractionmass=37.5*CLHEP::perCent);
- HPDS20PhCathode->AddElement(elK, fractionmass=18.75*CLHEP::perCent);
- HPDS20PhCathode->AddElement(elCs, fractionmass=18.75*CLHEP::perCent);
- HPDS20PhCathode->AddElement(elSb, fractionmass=25.0*CLHEP::perCent);
-
- // G4double* S20PhCathodeRindex=new G4double[NumPhotWaveLengthBins];
+  G4Material *HPDS20PhCathode = new G4Material(name = HpdPhCathodeMaterialName, density, numel = 4);
+  HPDS20PhCathode->AddElement(elNa, fractionmass = 37.5 * CLHEP::perCent);
+  HPDS20PhCathode->AddElement(elK, fractionmass = 18.75 * CLHEP::perCent);
+  HPDS20PhCathode->AddElement(elCs, fractionmass = 18.75 * CLHEP::perCent);
+  HPDS20PhCathode->AddElement(elSb, fractionmass = 25.0 * CLHEP::perCent);
 
-  G4int  HPDS20PhCathodeRefIndNumBins=HPDQuartzRefIndNumBins;
+  // G4double* S20PhCathodeRindex=new G4double[NumPhotWaveLengthBins];
 
-  G4double* HPDS20PhCathodeRindex=new G4double[HPDS20PhCathodeRefIndNumBins];
-  G4double* HPDS20PhCathodeRefIndPhMom = new G4double[HPDS20PhCathodeRefIndNumBins];
- // the ref index of phcathode is derived from that of the hpd quartz window.
- // using the formula (na*na-nb*nb)/(na*na+nb*nb) = fraction of refelcted photons. 
+  G4int HPDS20PhCathodeRefIndNumBins = HPDQuartzRefIndNumBins;
 
- G4double hpdrefindphFactor=1.04;
+  G4double *HPDS20PhCathodeRindex = new G4double[HPDS20PhCathodeRefIndNumBins];
+  G4double *HPDS20PhCathodeRefIndPhMom = new G4double[HPDS20PhCathodeRefIndNumBins];
+  // the ref index of phcathode is derived from that of the hpd quartz window.
+  // using the formula (na*na-nb*nb)/(na*na+nb*nb) = fraction of refelcted photons.
 
+  G4double hpdrefindphFactor = 1.04;
 
- if (HPDQwPhReflectionProb < 1.0) 
-   hpdrefindphFactor =  pow(((1+HPDQwPhReflectionProb)/(1-HPDQwPhReflectionProb)),0.5);
+  if (HPDQwPhReflectionProb < 1.0)
+    hpdrefindphFactor = pow(((1 + HPDQwPhReflectionProb) / (1 - HPDQwPhReflectionProb)), 0.5);
 
-  for(G4int ibins=0; ibins <HPDS20PhCathodeRefIndNumBins; ibins++ ) {
-  //    HPDS20PhCathodeRindex[ibin]=1.6;
+  for (G4int ibins = 0; ibins < HPDS20PhCathodeRefIndNumBins; ibins++) {
+    //    HPDS20PhCathodeRindex[ibin]=1.6;
 
-    HPDS20PhCathodeRefIndPhMom[ibins] =  HPDWindowQuartzPhMom[ibins];
+    HPDS20PhCathodeRefIndPhMom[ibins] = HPDWindowQuartzPhMom[ibins];
 
-    HPDS20PhCathodeRindex[ibins] =   hpdrefindphFactor* HPDWindowQuartzRindex[ibins];
+    HPDS20PhCathodeRindex[ibins] = hpdrefindphFactor * HPDWindowQuartzRindex[ibins];
   }
-  
 
   // now for the absorption length.
- G4double* HPDS20PhCathodeAbsorpLength=new G4double[NumPhotWaveLengthBins];
-
- G4double HpdMomBoundaryRedBlue=PhotWaveLengthToMom/HPDPhCathodeRedBlueBoundary;
- G4double hablengblue = -1.0*RichTbHpdPhCathodeThickness/log(HPDPhCathodeTransBlue);
- G4double hablengred=  -1.0*RichTbHpdPhCathodeThickness/log(HPDPhCathodeTransRed);
-
- for (G4int ibin=0; ibin<NumPhotWaveLengthBins; ibin++){
-   //   S20PhCathodeAbsorpLength[ibin]=1.E32*CLHEP::mm;
-   if(PhotonMomentum[ibin] < MomBoundaryRedBlue ) {
-     // we are in the red region.
-     HPDS20PhCathodeAbsorpLength[ibin]=hablengred;     
-   }else {
-     HPDS20PhCathodeAbsorpLength[ibin]= hablengblue;  
-     
-   } 
-
- }
- 
-
- 
+  G4double *HPDS20PhCathodeAbsorpLength = new G4double[NumPhotWaveLengthBins];
+
+//  G4double HpdMomBoundaryRedBlue = PhotWaveLengthToMom / HPDPhCathodeRedBlueBoundary;
+  G4double hablengblue = -1.0 * RichTbHpdPhCathodeThickness / log(HPDPhCathodeTransBlue);
+  G4double hablengred = -1.0 * RichTbHpdPhCathodeThickness / log(HPDPhCathodeTransRed);
+
+  for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
+    //   S20PhCathodeAbsorpLength[ibin]=1.E32*CLHEP::mm;
+    if (PhotonMomentum[ibin] < MomBoundaryRedBlue) {
+      // we are in the red region.
+      HPDS20PhCathodeAbsorpLength[ibin] = hablengred;
+    } else {
+      HPDS20PhCathodeAbsorpLength[ibin] = hablengblue;
+    }
+  }
 
-  G4MaterialPropertiesTable* HPDS20PhCathodeMPT = 
-                            new G4MaterialPropertiesTable();
-  HPDS20PhCathodeMPT->AddProperty("ABSLENGTH",PhotonMomentum,
-                                  HPDS20PhCathodeAbsorpLength,NumPhotWaveLengthBins);
+  G4MaterialPropertiesTable *HPDS20PhCathodeMPT = new G4MaterialPropertiesTable();
+  HPDS20PhCathodeMPT->AddProperty("ABSLENGTH", PhotonMomentum, HPDS20PhCathodeAbsorpLength, NumPhotWaveLengthBins);
 
-  //  S20PhCathodeMPT->AddProperty("RINDEX", PhotonMomentum, 
+  //  S20PhCathodeMPT->AddProperty("RINDEX", PhotonMomentum,
   //                      S20PhCathodeRindex,NumPhotWaveLengthBins);
 
-  HPDS20PhCathodeMPT->AddProperty("RINDEX",HPDS20PhCathodeRefIndPhMom , 
-                                  HPDS20PhCathodeRindex,HPDS20PhCathodeRefIndNumBins);
+  HPDS20PhCathodeMPT->AddProperty("RINDEX", HPDS20PhCathodeRefIndPhMom, HPDS20PhCathodeRindex,
+                                  HPDS20PhCathodeRefIndNumBins);
 
   HPDS20PhCathode->SetMaterialPropertiesTable(HPDS20PhCathodeMPT);
-  HPDPhCathodeMaterial=HPDS20PhCathode;
-
-
-
+  HPDPhCathodeMaterial = HPDS20PhCathode;
 }
 
-
-
-
-
-RichTbMaterial* RichTbMaterial::getRichTbMaterialInstance() 
-{
-  if( RichTbMaterialInstance== 0 ) {
-    RichTbMaterialInstance= new RichTbMaterial();
-    
+RichTbMaterial *RichTbMaterial::getRichTbMaterialInstance() {
+  if (RichTbMaterialInstance == 0) {
+    RichTbMaterialInstance = new RichTbMaterial();
   }
 
   return RichTbMaterialInstance;
-  
 }
 
-
-RichTbMaterial::~RichTbMaterial()
-{
-    ;
-}
+RichTbMaterial::~RichTbMaterial() { ; }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbMaterialParameters.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbMaterialParameters.cc
index 8c9e5482187c1d813e9c84c5f460e77788249b94..e23fc35db91e72ddeeed165c6ee2908f10a0bdca 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbMaterialParameters.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbMaterialParameters.cc
@@ -2,343 +2,288 @@
 #include "Geant4/globals.hh"
 
 // STL etc
+#include <cmath>
 #include <iostream>
 #include <vector>
-#include <cmath>
 
 // local
-#include "RichTbMaterialParameters.hh"
-#include "RichTbGeometryParameters.hh"
 #include "RichTbAnalysisManager.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMaterialParameters.hh"
 
-
-void InitializeRichTbMaterial()
-{
-	//Setup a switch between the various parametrizations of the
-	// ref index.
+void InitializeRichTbMaterial() {
+  // Setup a switch between the various parametrizations of the
+  // ref index.
 }
 void HistoRichMaterialProperty() {
-	//histogram the material properties.
-
-	//  G4cout<<" Now in histo material Property "<<G4endl;
-
-	// RichTbAnalysisManager* rAnalysis=
-	//  RichTbAnalysisManager::getInstance();
+  // histogram the material properties.
 
+  //  G4cout<<" Now in histo material Property "<<G4endl;
 
+  // RichTbAnalysisManager* rAnalysis=
+  //  RichTbAnalysisManager::getInstance();
 }
 
-
 std::vector<G4double> InitializePhotonMomentumVector() {
 
-	G4double PhotonEnergyStep=(PhotonMaxEnergy-PhotonMinEnergy)/
-			NumPhotWaveLengthBins;
-	std::vector<G4double>PhotMomVect(NumPhotWaveLengthBins);
-	for (G4int ibin=0; ibin<NumPhotWaveLengthBins; ibin++){
-		PhotMomVect[ibin]=PhotonMinEnergy+PhotonEnergyStep*ibin;
-	}
-	return PhotMomVect;
+  G4double PhotonEnergyStep = (PhotonMaxEnergy - PhotonMinEnergy) / NumPhotWaveLengthBins;
+  std::vector<G4double> PhotMomVect(NumPhotWaveLengthBins);
+  for (G4int ibin = 0; ibin < NumPhotWaveLengthBins; ibin++) {
+    PhotMomVect[ibin] = PhotonMinEnergy + PhotonEnergyStep * ibin;
+  }
+  return PhotMomVect;
 }
 
-G4double FresnelLossAtNormalIncidence(G4double RIndex1, G4double RIndex2 )
-{
-	G4double ALoss=0.0;
-
-	if(RIndex1 >= 1.0 && RIndex2 >= 1.0) {
-
-		ALoss= pow(((RIndex2- RIndex1)/( RIndex2+ RIndex1)),2.0);
+G4double FresnelLossAtNormalIncidence(G4double RIndex1, G4double RIndex2) {
+  G4double ALoss = 0.0;
 
-	}
-	return ALoss;
+  if (RIndex1 >= 1.0 && RIndex2 >= 1.0) {
 
+    ALoss = pow(((RIndex2 - RIndex1) / (RIndex2 + RIndex1)), 2.0);
+  }
+  return ALoss;
 }
 
-std::vector<G4double> InitN2RefIndex(G4double pressure, G4double temperature){
+std::vector<G4double> InitN2RefIndex(G4double pressure, G4double temperature) {
 
-	G4int NumWLenBins=NumPhotWaveLengthBins;
-	std::vector<G4double> PmV = InitN2RefPhotMom();
-	std::vector<G4double> RefN2( NumPhotWaveLengthBins);
+  G4int NumWLenBins = NumPhotWaveLengthBins;
+  std::vector<G4double> PmV = InitN2RefPhotMom();
+  std::vector<G4double> RefN2(NumPhotWaveLengthBins);
 
-	// G4cout<<" RichTbmaterial Parameters Nitrogen GasPressure stppressure temp stptemp "
-	//      << pressure <<"  "<<GasPressure_STP<<"   "
-	//      << temperature<<"   "<<GasTemperature_STP<<G4endl;
+  // G4cout<<" RichTbmaterial Parameters Nitrogen GasPressure stppressure temp stptemp "
+  //      << pressure <<"  "<<GasPressure_STP<<"   "
+  //      << temperature<<"   "<<GasTemperature_STP<<G4endl;
 
+  G4double GasRhoN2Cur = GasRhoN2atSTP * (GasTemperature_STP / temperature) * (pressure / GasPressure_STP);
 
-	G4double GasRhoN2Cur=GasRhoN2atSTP*(GasTemperature_STP/temperature)*
-			(pressure/ GasPressure_STP);
+  //  G4cout<<" RichTbmaterial Parameters N2densitySTP N2Curdensity " <<GasRhoN2atSTP
+  //	<<  "   "<<  GasRhoN2Cur<<G4endl;
 
-	//  G4cout<<" RichTbmaterial Parameters N2densitySTP N2Curdensity " <<GasRhoN2atSTP
-	//	<<  "   "<<  GasRhoN2Cur<<G4endl;
+  G4double epho, pfe, cpfe;
+  for (G4int ibinwn = 0; ibinwn < NumWLenBins; ibinwn++) {
 
+    epho = PmV[ibinwn] / CLHEP::eV;
+    pfe = SellN2F1 / (SellN2E1 * SellN2E1 - epho * epho) + SellN2F2 / (SellN2E2 * SellN2E2 - epho * epho);
+    cpfe = 0.3738 * (GasRhoN2Cur / GasMolWeightN2) * pfe;
+    RefN2[ibinwn] = pow((1.0 + 2 * cpfe) / (1.0 - cpfe), 0.5);
+    //   G4cout<<" N2 ref index "<< ibinwn<<"  "<<epho<<"   "<<PhotMomWaveConv/ epho
+    //      <<"     "<<RefN2[ibinwn]<<G4endl;
+  }
 
-	G4double epho,pfe,cpfe;
-	for(G4int ibinwn =0; ibinwn<NumWLenBins ; ibinwn++ ){
-
-		epho = PmV[ibinwn]/CLHEP::eV;
-		pfe  = SellN2F1/(SellN2E1*SellN2E1 - epho*epho )  +
-				SellN2F2/(SellN2E2*SellN2E2 - epho*epho );
-		cpfe=0.3738*(GasRhoN2Cur/GasMolWeightN2)*pfe;
-		RefN2[ibinwn]=pow((1.0+2*cpfe)/(1.0-cpfe),0.5);
-		//   G4cout<<" N2 ref index "<< ibinwn<<"  "<<epho<<"   "<<PhotMomWaveConv/ epho
-		//      <<"     "<<RefN2[ibinwn]<<G4endl;
-
-	}
-
-	return RefN2;
+  return RefN2;
 }
 
-G4double N2RefIndexAtAnEnergy( G4double pressure, G4double temperature,
-		G4double PhotonEnergy)
-{
-	G4double curRefIndex=1.0;
+G4double N2RefIndexAtAnEnergy(G4double pressure, G4double temperature, G4double PhotonEnergy) {
+  G4double curRefIndex = 1.0;
 
-	G4double GasRhoN2Cur=GasRhoN2atSTP*(GasTemperature_STP/temperature)*
-			(pressure/ GasPressure_STP);
-	G4double epho=0.0;
-	G4double pfe=0.0;
-	G4double cpfe=0.0;
+  G4double GasRhoN2Cur = GasRhoN2atSTP * (GasTemperature_STP / temperature) * (pressure / GasPressure_STP);
+  G4double epho = 0.0;
+  G4double pfe = 0.0;
+  G4double cpfe = 0.0;
 
+  epho = PhotonEnergy / CLHEP::eV;
+  pfe = SellN2F1 / (SellN2E1 * SellN2E1 - epho * epho) + SellN2F2 / (SellN2E2 * SellN2E2 - epho * epho);
+  cpfe = 0.3738 * (GasRhoN2Cur / GasMolWeightN2) * pfe;
 
-	epho = PhotonEnergy/CLHEP::eV;
-	pfe  = SellN2F1/(SellN2E1*SellN2E1 - epho*epho )  +
-			SellN2F2/(SellN2E2*SellN2E2 - epho*epho );
-	cpfe=0.3738*(GasRhoN2Cur/GasMolWeightN2)*pfe;
-
-	curRefIndex=pow((1.0+2*cpfe)/(1.0-cpfe),0.5);
-
-	return curRefIndex;
+  curRefIndex = pow((1.0 + 2 * cpfe) / (1.0 - cpfe), 0.5);
 
+  return curRefIndex;
 }
 
+std::vector<G4double> InitN2RefPhotMom() { return InitializePhotonMomentumVector(); }
+std::vector<G4double> Initc4f10RefPhotMom() { return InitializePhotonMomentumVector(); }
 
-std::vector<G4double> InitN2RefPhotMom() {
-	return InitializePhotonMomentumVector() ;
-}
-std::vector<G4double> Initc4f10RefPhotMom() {
-	return InitializePhotonMomentumVector() ;
-}
-
-std::vector<G4double> CrystalRefPhotMom() {
-	return InitializePhotonMomentumVector() ;
-}
+std::vector<G4double> CrystalRefPhotMom() { return InitializePhotonMomentumVector(); }
 
-std::vector<G4double> Initc4f10RefIndex(G4double pressure, G4double temperature){
+std::vector<G4double> Initc4f10RefIndex(G4double pressure, G4double temperature) {
 
-	G4int NumWLenBins=NumPhotWaveLengthBins;
-	std::vector<G4double> PmV = Initc4f10RefPhotMom();
-	std::vector<G4double> RefC4F10( NumPhotWaveLengthBins);
+  G4int NumWLenBins = NumPhotWaveLengthBins;
+  std::vector<G4double> PmV = Initc4f10RefPhotMom();
+  std::vector<G4double> RefC4F10(NumPhotWaveLengthBins);
 
-	//  G4cout<<" RichTbmaterial Parameters c4f10GasPressure stppressure temp stptemp "
-	//      << pressure <<"  "<<GasPressure_STP<<"   "
-	//      << temperature<<"   "<<GasTemperature_STP<<G4endl;
+  //  G4cout<<" RichTbmaterial Parameters c4f10GasPressure stppressure temp stptemp "
+  //      << pressure <<"  "<<GasPressure_STP<<"   "
+  //      << temperature<<"   "<<GasTemperature_STP<<G4endl;
 
+  G4double GasRhoC4F10Cur = GasRhoC4F10atSTP * (GasTemperature_STP / temperature) * (pressure / GasPressure_STP);
 
-	G4double GasRhoC4F10Cur=GasRhoC4F10atSTP*(GasTemperature_STP/temperature)*
-			(pressure/ GasPressure_STP);
+  G4double epho = 0.0;
+  G4double pfe = 0.0;
+  G4double cpfe = 0.0;
 
-	G4double epho=0.0;
-	G4double pfe=0.0;
-	G4double cpfe=0.0;
+  for (G4int ibinwn = 0; ibinwn < NumWLenBins; ibinwn++) {
 
-	for(G4int ibinwn =0; ibinwn<NumWLenBins ; ibinwn++ ){
-
-		epho = PmV[ibinwn]/CLHEP::eV;
-		pfe  = SellC4F10F1/(SellC4F10E1*SellC4F10E1 - epho*epho )  +
-				SellC4F10F2/(SellC4F10E2*SellC4F10E2 - epho*epho );
-		cpfe=0.3738*(GasRhoC4F10Cur/GasMolWeightC4F10)*pfe;
-		RefC4F10[ibinwn]  = pow((1.0+2*cpfe)/(1.0-cpfe),0.5);
-	}
-	return RefC4F10;
+    epho = PmV[ibinwn] / CLHEP::eV;
+    pfe = SellC4F10F1 / (SellC4F10E1 * SellC4F10E1 - epho * epho) +
+          SellC4F10F2 / (SellC4F10E2 * SellC4F10E2 - epho * epho);
+    cpfe = 0.3738 * (GasRhoC4F10Cur / GasMolWeightC4F10) * pfe;
+    RefC4F10[ibinwn] = pow((1.0 + 2 * cpfe) / (1.0 - cpfe), 0.5);
+  }
+  return RefC4F10;
 }
 
-G4double c4f10RefIndexAtAnEnergy(G4double pressure, G4double temperature ,
-		G4double PhotonEnergy){
-
-	G4double curRefIndex=1.0;
+G4double c4f10RefIndexAtAnEnergy(G4double pressure, G4double temperature, G4double PhotonEnergy) {
 
-	G4cout<<" RichTbmaterial Parameters c4f10GasPressure stppressure temp stptemp "
-			<< pressure <<"  "<<GasPressure_STP<<"   "
-			<< temperature<<"   "<<GasTemperature_STP<<G4endl;
+  G4double curRefIndex = 1.0;
 
+  G4cout << " RichTbmaterial Parameters c4f10GasPressure stppressure temp stptemp " << pressure << "  "
+         << GasPressure_STP << "   " << temperature << "   " << GasTemperature_STP << G4endl;
 
-	G4double GasRhoC4F10Cur=GasRhoC4F10atSTP*(GasTemperature_STP/temperature)*
-			(pressure/ GasPressure_STP);
+  G4double GasRhoC4F10Cur = GasRhoC4F10atSTP * (GasTemperature_STP / temperature) * (pressure / GasPressure_STP);
 
-	G4double epho=0.0;
-	G4double pfe=0.0;
-	G4double cpfe=0.0;
+  G4double epho = 0.0;
+  G4double pfe = 0.0;
+  G4double cpfe = 0.0;
 
-	epho = PhotonEnergy/CLHEP::eV;
+  epho = PhotonEnergy / CLHEP::eV;
 
-	pfe  = SellC4F10F1/(SellC4F10E1*SellC4F10E1 - epho*epho )  +
-			SellC4F10F2/(SellC4F10E2*SellC4F10E2 - epho*epho );
-	cpfe=0.3738*(GasRhoC4F10Cur/GasMolWeightC4F10)*pfe;
-	curRefIndex = pow((1.0+2*cpfe)/(1.0-cpfe),0.5);
+  pfe =
+      SellC4F10F1 / (SellC4F10E1 * SellC4F10E1 - epho * epho) + SellC4F10F2 / (SellC4F10E2 * SellC4F10E2 - epho * epho);
+  cpfe = 0.3738 * (GasRhoC4F10Cur / GasMolWeightC4F10) * pfe;
+  curRefIndex = pow((1.0 + 2 * cpfe) / (1.0 - cpfe), 0.5);
 
-	return curRefIndex ;
+  return curRefIndex;
 }
-std::vector<G4double>  InitializePMTWaveL(G4int /* ipmtnum */)
-						{
-	// for now it is the same wavlength bins for all pmts.
-
-	std::vector<G4double>PmtQEW(PmtQENumBins);
-	for (G4int iqb=0; iqb<PmtQENumBins; iqb++){
-		PmtQEW[iqb]= PmtQEWaveLen [iqb]*PmtQEWaveLenUnits;
-	}
-	return PmtQEW;
-
-						}
-std::vector<G4double>  InitializePMTQE(G4int ipmtqe) {
-
-	G4double PmtQEReductionFactor =1.;
-	//  if(ihpdqe >= 2 ) {
-	//   G4cout<<"Wrong HPD Number for QE " <<ihpdqe<<"  vs "
-	//      <<NumPMTs <<G4endl;
-	// }
-	std::vector<G4double>qeCurPerCent( PmtQENumBins);
-	if(ipmtqe == 0 ){
-		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt0QEPerCent[iqb]* PmtQEReductionFactor;
-		}
-
-
-	}else if( ipmtqe == 1 ){
-		for(G4int  iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt1QEPerCent[iqb]* PmtQEReductionFactor;
-		}
-
-	}else if( ipmtqe == 2 ){
-
-		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt2QEPerCent[iqb]* PmtQEReductionFactor;
-		}
-
-	} else if ( ipmtqe == 3 ){
-
-		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt3QEPerCent[iqb]* PmtQEReductionFactor;
-		}
-
-
-	} else if ( ipmtqe == 4 ){
-
-		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt4QEPerCent[iqb]* PmtQEReductionFactor;
-		}
-
-	}else if ( ipmtqe == 5 ){
-
-		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt5QEPerCent[iqb]* PmtQEReductionFactor;
-		}
+std::vector<G4double> InitializePMTWaveL(G4int /* ipmtnum */) {
+  // for now it is the same wavlength bins for all pmts.
+
+  std::vector<G4double> PmtQEW(PmtQENumBins);
+  for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+    PmtQEW[iqb] = PmtQEWaveLen[iqb] * PmtQEWaveLenUnits;
+  }
+  return PmtQEW;
+}
+std::vector<G4double> InitializePMTQE(G4int ipmtqe) {
 
+  G4double PmtQEReductionFactor = 1.;
+  //  if(ihpdqe >= 2 ) {
+  //   G4cout<<"Wrong HPD Number for QE " <<ihpdqe<<"  vs "
+  //      <<NumPMTs <<G4endl;
+  // }
+  std::vector<G4double> qeCurPerCent(PmtQENumBins);
+  if (ipmtqe == 0) {
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt0QEPerCent[iqb] * PmtQEReductionFactor;
+    }
 
-	}else if ( ipmtqe == 6 ){
+  } else if (ipmtqe == 1) {
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt1QEPerCent[iqb] * PmtQEReductionFactor;
+    }
 
-		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt6QEPerCent[iqb]* PmtQEReductionFactor;
-		}
+  } else if (ipmtqe == 2) {
 
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt2QEPerCent[iqb] * PmtQEReductionFactor;
+    }
 
-	}else if ( ipmtqe == 7 ){
+  } else if (ipmtqe == 3) {
 
-		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt7QEPerCent[iqb]* PmtQEReductionFactor;
-		}
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt3QEPerCent[iqb] * PmtQEReductionFactor;
+    }
 
-	}else if( ipmtqe == 8 ){
-		for(G4int  iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt8QEPerCent[iqb]* PmtQEReductionFactor;
-		}
+  } else if (ipmtqe == 4) {
 
-	}else if( ipmtqe == 9 ){
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt4QEPerCent[iqb] * PmtQEReductionFactor;
+    }
 
-		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt9QEPerCent[iqb]* PmtQEReductionFactor;
-		}
+  } else if (ipmtqe == 5) {
 
-	} else if ( ipmtqe == 10 ){
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt5QEPerCent[iqb] * PmtQEReductionFactor;
+    }
 
-		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt1QEPerCent[iqb]* PmtQEReductionFactor;
-		}
+  } else if (ipmtqe == 6) {
 
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt6QEPerCent[iqb] * PmtQEReductionFactor;
+    }
 
-	} else if ( ipmtqe == 11 ){
+  } else if (ipmtqe == 7) {
 
-		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt11QEPerCent[iqb]* PmtQEReductionFactor;
-		}
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt7QEPerCent[iqb] * PmtQEReductionFactor;
+    }
 
-	}else if ( ipmtqe == 12 ){
+  } else if (ipmtqe == 8) {
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt8QEPerCent[iqb] * PmtQEReductionFactor;
+    }
 
-		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt12QEPerCent[iqb]* PmtQEReductionFactor;
-		}
+  } else if (ipmtqe == 9) {
 
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt9QEPerCent[iqb] * PmtQEReductionFactor;
+    }
 
-	}else if ( ipmtqe == 13 ){
+  } else if (ipmtqe == 10) {
 
-		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt13QEPerCent[iqb]* PmtQEReductionFactor;
-		}
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt1QEPerCent[iqb] * PmtQEReductionFactor;
+    }
 
+  } else if (ipmtqe == 11) {
 
-	}else if ( ipmtqe == 14 ){
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt11QEPerCent[iqb] * PmtQEReductionFactor;
+    }
 
-		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt14QEPerCent[iqb]* PmtQEReductionFactor;
-		}
+  } else if (ipmtqe == 12) {
 
-	}else if ( ipmtqe == 15 ){
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt12QEPerCent[iqb] * PmtQEReductionFactor;
+    }
 
-		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
-            qeCurPerCent[iqb] =  Pmt15QEPerCent[iqb]* PmtQEReductionFactor;
-		}
+  } else if (ipmtqe == 13) {
 
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt13QEPerCent[iqb] * PmtQEReductionFactor;
+    }
 
-	}
-//	else if ( ipmtqe == 16 ){
-//
-//		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
-//			qeCurPerCent[iqb] =  Pmt16QEPerCent[iqb]* PmtQEReductionFactor;
-//		}
-//
-//	}
+  } else if (ipmtqe == 14) {
 
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt14QEPerCent[iqb] * PmtQEReductionFactor;
+    }
 
+  } else if (ipmtqe == 15) {
 
-	return  qeCurPerCent;
+    for (G4int iqb = 0; iqb < PmtQENumBins; iqb++) {
+      qeCurPerCent[iqb] = Pmt15QEPerCent[iqb] * PmtQEReductionFactor;
+    }
+  }
+  //	else if ( ipmtqe == 16 ){
+  //
+  //		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
+  //			qeCurPerCent[iqb] =  Pmt16QEPerCent[iqb]* PmtQEReductionFactor;
+  //		}
+  //
+  //	}
 
+  return qeCurPerCent;
 }
 
-std::vector<G4double>  InitializeHpdQE(G4int ihpdqe) {
-
-	G4double HpdQEReductionFactor =1.;
-	std::vector<G4double>qeCurPerCent( HpdQENumBins);
-	if(ihpdqe == 0 ){
-		for(G4int iqa=0; iqa< HpdQENumBins ; iqa++){
-			qeCurPerCent[iqa] =  Hpd0QEPerCent[iqa]* HpdQEReductionFactor;
-		}
-
-	}
-
-
-	return  qeCurPerCent;
+std::vector<G4double> InitializeHpdQE(G4int ihpdqe) {
 
+  G4double HpdQEReductionFactor = 1.;
+  std::vector<G4double> qeCurPerCent(HpdQENumBins);
+  if (ihpdqe == 0) {
+    for (G4int iqa = 0; iqa < HpdQENumBins; iqa++) {
+      qeCurPerCent[iqa] = Hpd0QEPerCent[iqa] * HpdQEReductionFactor;
+    }
+  }
 
+  return qeCurPerCent;
 }
 
-std::vector<G4double>  InitializeHpdWaveL(G4int /* ipmtnum */)
-						{
-	// for now it is the same wavlength bins for all pmts.
-
-	std::vector<G4double>HpdQEW(HpdQENumBins);
-	for (G4int iqb=0; iqb<HpdQENumBins; iqb++){
-		HpdQEW[iqb]= HpdQEWaveLen [iqb]*HpdQEWaveLenUnits;
-	}
-	return HpdQEW;
-
-						}
-
+std::vector<G4double> InitializeHpdWaveL(G4int /* ipmtnum */) {
+  // for now it is the same wavlength bins for all pmts.
 
+  std::vector<G4double> HpdQEW(HpdQENumBins);
+  for (G4int iqb = 0; iqb < HpdQENumBins; iqb++) {
+    HpdQEW[iqb] = HpdQEWaveLen[iqb] * HpdQEWaveLenUnits;
+  }
+  return HpdQEW;
+}
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbPMT.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbPMT.cc
index 3bd4f33bec24258ac297d2e6566666d46a80bf9f..c3b9f63e71e62e444cb63b75c4443d675c61080d 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbPMT.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbPMT.cc
@@ -1,32 +1,30 @@
 // $Id: $
 // Include files
 
-
-#include "Geant4/globals.hh"
-#include "Geant4/G4Tubs.hh"
 #include "Geant4/G4Box.hh"
 #include "Geant4/G4Sphere.hh"
+#include "Geant4/G4Tubs.hh"
+#include "Geant4/globals.hh"
 // local
-#include "RichTbMaterial.hh"
-#include "RichTbPMT.hh"
-#include "RichTbUpgradeMaster.hh"
-#include "RichTbUpgradePhDFrame.hh"
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMaterialParameters.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4PVPlacement.hh"
 #include "Geant4/G4RotationMatrix.hh"
+#include "Geant4/G4SDManager.hh"
+#include "Geant4/G4SubtractionSolid.hh"
 #include "Geant4/G4ThreeVector.hh"
 #include "Geant4/G4Transform3D.hh"
-#include "Geant4/G4LogicalVolume.hh"
 #include "Geant4/G4VPhysicalVolume.hh"
-#include "Geant4/G4PVPlacement.hh"
-#include "Geant4/G4SubtractionSolid.hh"
-#include "Geant4/G4SDManager.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMaterialParameters.hh"
+#include "RichTbPMT.hh"
+#include "RichTbUpgradeMaster.hh"
+#include "RichTbUpgradePhDFrame.hh"
 //#include "RichTbSD.hh"
-#include "RichTbRODummySD.hh"
 #include "RichTbMiscNames.hh"
+#include "RichTbRODummySD.hh"
 #include "RichTbRunConfig.hh"
 
-
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbPMT
 //
@@ -37,453 +35,314 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbPMT::RichTbPMT( RichTbUpgradeEC* aECMaster )
-{  PmtECFrame = aECMaster;
-m_TrackingSwitch=true;
-m_PMTQwLogVolName=PMTQwLogVolName;
-m_PMTPhCathLogVolName= PMTPhCathLogVolName ;
-m_PMTAnodeLogVolName=PMTANNamesLog[0];
-RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-G4int aRadiatorConfiguration = aConfig ->getRadiatorConfiguration();
-CurNumPmts = NumPmtsOld;
-//CurNumPmts = RichTbPMTGeometryParameters::getNumPmts(); // TESTnumPmts
-if (aRadiatorConfiguration == 2) CurNumPmts = NumPmtsWithHpd;
-else if (aRadiatorConfiguration == 3) CurNumPmts = NumPmtsUpgrade15;
-//else if (aRadiatorConfiguration == 3) CurNumPmts = RichTbPMTGeometryParameters::getNumPmtsUpgrade();// TESTnumPmts
-}
-
-RichTbPMT::~RichTbPMT(  ) {
+RichTbPMT::RichTbPMT(RichTbUpgradeEC *aECMaster) {
+  PmtECFrame = aECMaster;
+  m_TrackingSwitch = true;
+  m_PMTQwLogVolName = PMTQwLogVolName;
+  m_PMTPhCathLogVolName = PMTPhCathLogVolName;
+  m_PMTAnodeLogVolName = PMTANNamesLog[0];
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int aRadiatorConfiguration = aConfig->getRadiatorConfiguration();
+  CurNumPmts = NumPmtsOld;
+  // CurNumPmts = RichTbPMTGeometryParameters::getNumPmts(); // TESTnumPmts
+  if (aRadiatorConfiguration == 2)
+    CurNumPmts = NumPmtsWithHpd;
+  else if (aRadiatorConfiguration == 3)
+    CurNumPmts = NumPmtsUpgrade15;
+  // else if (aRadiatorConfiguration == 3) CurNumPmts = RichTbPMTGeometryParameters::getNumPmtsUpgrade();// TESTnumPmts
 }
 
-void  RichTbPMT::buildPMTGeometry()
-{
-
-	RichTbPMTMasterLVol.resize(CurNumPmts);
-	RichTbPMTSMasterLVol.resize(CurNumPmts);
-	RichTbPMTAnodeLVol.resize(CurNumPmts);
-	RichTbPMTMasterPVol.resize(CurNumPmts);
-	RichTbPMTSMasterPVol.resize(CurNumPmts);
-	RichTbPMTAnodePVol.resize(CurNumPmts);
-
-	for (int ipmt=0; ipmt <CurNumPmts; ++ipmt ){
-		constructPMTMasterTree(ipmt);
-	}
-
-	if(m_TrackingSwitch) {
-		constructPMTComponentsLVol();
-		RichTbPMTEnvelopePVol.resize(CurNumPmts);
-		RichTbPMTQuartzWPVol.resize(CurNumPmts);
-		RichTbPMTPhCathodePVol.resize(CurNumPmts);
-		RichTbPMTFrontRingPVol.resize(CurNumPmts);
-
-		for (int jpmt=0; jpmt <CurNumPmts; ++jpmt )
-
-			constructPMTComponentsPVol(jpmt) ;
-
-	}else {
-		constructPMTAnode();
-	}
+RichTbPMT::~RichTbPMT() {}
 
+void RichTbPMT::buildPMTGeometry() {
 
+  RichTbPMTMasterLVol.resize(CurNumPmts);
+  RichTbPMTSMasterLVol.resize(CurNumPmts);
+  RichTbPMTAnodeLVol.resize(CurNumPmts);
+  RichTbPMTMasterPVol.resize(CurNumPmts);
+  RichTbPMTSMasterPVol.resize(CurNumPmts);
+  RichTbPMTAnodePVol.resize(CurNumPmts);
 
+  for (int ipmt = 0; ipmt < CurNumPmts; ++ipmt) {
+    constructPMTMasterTree(ipmt);
+  }
 
+  if (m_TrackingSwitch) {
+    constructPMTComponentsLVol();
+    RichTbPMTEnvelopePVol.resize(CurNumPmts);
+    RichTbPMTQuartzWPVol.resize(CurNumPmts);
+    RichTbPMTPhCathodePVol.resize(CurNumPmts);
+    RichTbPMTFrontRingPVol.resize(CurNumPmts);
 
+    for (int jpmt = 0; jpmt < CurNumPmts; ++jpmt)
 
+      constructPMTComponentsPVol(jpmt);
 
+  } else {
+    constructPMTAnode();
+  }
 }
 
-void RichTbPMT::constructPMTComponentsLVol()
-{
-	RichTbMaterial* aMaterial =  RichTbMaterial::getRichTbMaterialInstance();
-
-
-
-	// evelope = substraction of boxes
+void RichTbPMT::constructPMTComponentsLVol() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
 
+  // evelope = substraction of boxes
 
-	G4Box* PMTEnvelopeBox
-	= new G4Box( "PMTEnvelopeBox",
-			0.5 * PMTEnvelopeBoxXSize,
-			0.5 * PMTEnvelopeBoxYSize,
-			0.5 * PMTEnvelopeBoxZSize );
+  G4Box *PMTEnvelopeBox =
+      new G4Box("PMTEnvelopeBox", 0.5 * PMTEnvelopeBoxXSize, 0.5 * PMTEnvelopeBoxYSize, 0.5 * PMTEnvelopeBoxZSize);
 
-	// G4cout<<"test Envelope size "<<PMTEnvelopeBoxXSize <<G4endl;
+  // G4cout<<"test Envelope size "<<PMTEnvelopeBoxXSize <<G4endl;
 
-	G4Box* PMTEnvelopeSubBox
-	= new G4Box("PMTEnvelopeSubBox",
-			0.5*PMTEnvelopeSubPartXSize,
-			0.5*PMTEnvelopeSubPartYSize,
-			0.5*PMTEnvelopeSubPartZSize);
+  G4Box *PMTEnvelopeSubBox = new G4Box("PMTEnvelopeSubBox", 0.5 * PMTEnvelopeSubPartXSize,
+                                       0.5 * PMTEnvelopeSubPartYSize, 0.5 * PMTEnvelopeSubPartZSize);
 
-	G4ThreeVector PMTEnvelopeSubPos( PMTEnvelopeSubPartXLocation,
-			PMTEnvelopeSubPartYLocation,
-			PMTEnvelopeSubPartZLocation );
+  G4ThreeVector PMTEnvelopeSubPos(PMTEnvelopeSubPartXLocation, PMTEnvelopeSubPartYLocation,
+                                  PMTEnvelopeSubPartZLocation);
 
-	G4RotationMatrix  PMTEnvelopeSubRotX, PMTEnvelopeSubRotY;
+  G4RotationMatrix PMTEnvelopeSubRotX, PMTEnvelopeSubRotY;
 
-	G4Transform3D PMTEnvelopeSubTransform(PMTEnvelopeSubRotX * PMTEnvelopeSubRotY,
-			PMTEnvelopeSubPos);
+  G4Transform3D PMTEnvelopeSubTransform(PMTEnvelopeSubRotX * PMTEnvelopeSubRotY, PMTEnvelopeSubPos);
 
-	G4SubtractionSolid* PMTEnvelope = new G4SubtractionSolid("PMTEnvelope",
-			PMTEnvelopeBox,
-			PMTEnvelopeSubBox,
-			PMTEnvelopeSubTransform);
+  G4SubtractionSolid *PMTEnvelope =
+      new G4SubtractionSolid("PMTEnvelope", PMTEnvelopeBox, PMTEnvelopeSubBox, PMTEnvelopeSubTransform);
 
+  // quartz window
+  G4Box *PMTQuartzWindow = new G4Box("PMTQuartzWindow", 0.5 * PMTQuartzWindowSupXSize, 0.5 * PMTQuartzWindowSupYSize,
+                                     0.5 * PMTQuartzWindowSupZSize);
 
+  // cathode
+  G4Box *PMTPhCathode =
+      new G4Box("PMTPhCathode", 0.5 * PMTPhCathodeSupXSize, 0.5 * PMTPhCathodeSupYSize, 0.5 * PMTPhCathodeSupZSize);
 
-	//quartz window
-	G4Box* PMTQuartzWindow
-	= new G4Box( "PMTQuartzWindow",
-			0.5 * PMTQuartzWindowSupXSize,
-			0.5 * PMTQuartzWindowSupYSize,
-			0.5 * PMTQuartzWindowSupZSize );
+  // front ring
+  G4Box *PMTFrontRingOuterBox = new G4Box("PMTFrontRingOuterBox", 0.5 * RichTbPMTFrontRingLateralXSize,
+                                          0.5 * RichTbPMTFrontRingLateralYSize, 0.5 * RichTbPMTFrontRingZSize);
 
-	//cathode
-	G4Box* PMTPhCathode=
-			new G4Box("PMTPhCathode",
-					0.5 * PMTPhCathodeSupXSize,
-					0.5 * PMTPhCathodeSupYSize,
-					0.5 * PMTPhCathodeSupZSize );
+  G4Box *PMTFrontRingInnerSubBox =
+      new G4Box("PMTFrontRingInnerSubBox", 0.5 * RichTbPMTFrontRingSubHoleXSize, 0.5 * RichTbPMTFrontRingSubHoleYSize,
+                0.5 * RichTbPMTFrontRingSubHoleZSize);
 
+  G4ThreeVector PMTFrontRingSubPos(RichTbPMTFrontRingSubHoleXLocation, RichTbPMTFrontRingSubHoleYLocation,
+                                   RichTbPMTFrontRingSubHoleZLocation);
 
-	//front ring
-	G4Box* PMTFrontRingOuterBox =
-			new G4Box("PMTFrontRingOuterBox" ,
-					0.5*RichTbPMTFrontRingLateralXSize,
-					0.5*RichTbPMTFrontRingLateralYSize,
-					0.5*  RichTbPMTFrontRingZSize);
+  G4RotationMatrix PMTFrontRingSubRotX, PMTFrontRingSubRotY;
 
-	G4Box* PMTFrontRingInnerSubBox =
-			new G4Box("PMTFrontRingInnerSubBox" ,
-					0.5*RichTbPMTFrontRingSubHoleXSize,
-					0.5*RichTbPMTFrontRingSubHoleYSize,
-					0.5*RichTbPMTFrontRingSubHoleZSize);
+  G4Transform3D PMTFrontRingSubTransform(PMTFrontRingSubRotX * PMTFrontRingSubRotY, PMTFrontRingSubPos);
 
+  G4SubtractionSolid *PMTFrontRing =
+      new G4SubtractionSolid("PMTFrontRing", PMTFrontRingOuterBox, PMTFrontRingInnerSubBox, PMTFrontRingSubTransform);
 
-	G4ThreeVector PMTFrontRingSubPos( RichTbPMTFrontRingSubHoleXLocation ,
-			RichTbPMTFrontRingSubHoleYLocation,
-			RichTbPMTFrontRingSubHoleZLocation );
+  // logical voulmes
 
-	G4RotationMatrix  PMTFrontRingSubRotX, PMTFrontRingSubRotY;
-
-	G4Transform3D PMTFrontRingSubTransform(PMTFrontRingSubRotX * PMTFrontRingSubRotY,
-			PMTFrontRingSubPos);
-
-	G4SubtractionSolid* PMTFrontRing = new G4SubtractionSolid("PMTFrontRing",
-			PMTFrontRingOuterBox,
-			PMTFrontRingInnerSubBox,
-			PMTFrontRingSubTransform);
-
-	//logical voulmes
-
-
-
-	G4LogicalVolume*  PMTEnvelopeLog =
-			new G4LogicalVolume( PMTEnvelope,
-					aMaterial->getPMTTubeEnvelopeMaterial(),
-					"PMTEnvelopeLog",0,0,0);
-
-	G4LogicalVolume* PMTQuartzWLog=
-			new  G4LogicalVolume( PMTQuartzWindow,
-					aMaterial->getPMTQuartzWindowMaterial(),
-					m_PMTQwLogVolName ,0,0,0);
-	G4LogicalVolume* PMTPhCathodeLog =
-			new G4LogicalVolume( PMTPhCathode,
-					aMaterial->getPMTPhCathodeMaterial() ,
-					m_PMTPhCathLogVolName ,0,0,0);
-
-
-	G4LogicalVolume*  PMTFrontRingLog =
-			new G4LogicalVolume( PMTFrontRing,
-					aMaterial->getPMTTubeEnvelopeMaterial(),
-					"PMTFrontRingLog",0,0,0);
-
-	RichTbPMTEnvelopeLVol=PMTEnvelopeLog;
-	RichTbPMTQuartzWLVol= PMTQuartzWLog;
-	RichTbPMTPhCathodeLVol=PMTPhCathodeLog;
-	RichTbPMTFrontRingLVol = PMTFrontRingLog;
+  G4LogicalVolume *PMTEnvelopeLog =
+      new G4LogicalVolume(PMTEnvelope, aMaterial->getPMTTubeEnvelopeMaterial(), "PMTEnvelopeLog", 0, 0, 0);
 
+  G4LogicalVolume *PMTQuartzWLog =
+      new G4LogicalVolume(PMTQuartzWindow, aMaterial->getPMTQuartzWindowMaterial(), m_PMTQwLogVolName, 0, 0, 0);
+  G4LogicalVolume *PMTPhCathodeLog =
+      new G4LogicalVolume(PMTPhCathode, aMaterial->getPMTPhCathodeMaterial(), m_PMTPhCathLogVolName, 0, 0, 0);
 
+  G4LogicalVolume *PMTFrontRingLog =
+      new G4LogicalVolume(PMTFrontRing, aMaterial->getPMTTubeEnvelopeMaterial(), "PMTFrontRingLog", 0, 0, 0);
 
+  RichTbPMTEnvelopeLVol = PMTEnvelopeLog;
+  RichTbPMTQuartzWLVol = PMTQuartzWLog;
+  RichTbPMTPhCathodeLVol = PMTPhCathodeLog;
+  RichTbPMTFrontRingLVol = PMTFrontRingLog;
 }
 
-void RichTbPMT::constructPMTComponentsPVol(int CurPMTNum)
-{
-
-	G4RotationMatrix  PMTEnvelopeBoxRot, PMTFrontRingBoxRot;
-
-	G4RotationMatrix PMTQuartzWindowRot, PMTPhCathodeRot;
-
-
-
-	G4ThreeVector PMTEnvelopeBoxPos( RichTbPMTEnvBoxXLocation,
-			RichTbPMTEnvBoxYLocation,
-			RichTbPMTEnvBoxZLocation);
-
-	G4Transform3D   PMTEnvelopeBoxTransform( PMTEnvelopeBoxRot,
-			PMTEnvelopeBoxPos);
-
-	G4ThreeVector PMTFrontRingBoxPos( RichTbPMTFrontRingXLocation,
-			RichTbPMTFrontRingYLocation,
-			RichTbPMTFrontRingZLocation);
-
-	G4Transform3D   PMTFrontRingBoxTransform( PMTFrontRingBoxRot,
-			PMTFrontRingBoxPos);
-
-	G4ThreeVector PMTQuartzWindowPos(  RichTbPMTQuartzWindowXLocation,
-			RichTbPMTQuartzWindowYLocation,
-			RichTbPMTQuartzWindowZLocation);
+void RichTbPMT::constructPMTComponentsPVol(int CurPMTNum) {
 
-	G4Transform3D  PMTQuartzWindowTransform( PMTQuartzWindowRot,
-			PMTQuartzWindowPos);
+  G4RotationMatrix PMTEnvelopeBoxRot, PMTFrontRingBoxRot;
 
-	G4ThreeVector   PMTPhCathodePos(RichTbPMTPhCathodeXLocation,
-			RichTbPMTPhCathodeYLocation,
-			RichTbPMTPhCathodeZLocation);
+  G4RotationMatrix PMTQuartzWindowRot, PMTPhCathodeRot;
 
-	G4Transform3D PMTPhCathodeTransform( PMTPhCathodeRot, PMTPhCathodePos);
+  G4ThreeVector PMTEnvelopeBoxPos(RichTbPMTEnvBoxXLocation, RichTbPMTEnvBoxYLocation, RichTbPMTEnvBoxZLocation);
 
+  G4Transform3D PMTEnvelopeBoxTransform(PMTEnvelopeBoxRot, PMTEnvelopeBoxPos);
 
+  G4ThreeVector PMTFrontRingBoxPos(RichTbPMTFrontRingXLocation, RichTbPMTFrontRingYLocation,
+                                   RichTbPMTFrontRingZLocation);
 
-	G4VPhysicalVolume*  CurMPhys =
-			RichTbPMTSMasterPVol[CurPMTNum];
+  G4Transform3D PMTFrontRingBoxTransform(PMTFrontRingBoxRot, PMTFrontRingBoxPos);
 
+  G4ThreeVector PMTQuartzWindowPos(RichTbPMTQuartzWindowXLocation, RichTbPMTQuartzWindowYLocation,
+                                   RichTbPMTQuartzWindowZLocation);
 
-	G4VPhysicalVolume*   PMTEnvelopePhys =
-			new G4PVPlacement(  PMTEnvelopeBoxTransform, PMTEnvelopeBoxPhysName+PMTNumberName[CurPMTNum],
-					RichTbPMTEnvelopeLVol  , CurMPhys,
-					false,0);
+  G4Transform3D PMTQuartzWindowTransform(PMTQuartzWindowRot, PMTQuartzWindowPos);
 
-	G4VPhysicalVolume*   PMTFrontRingPhys =
-			new G4PVPlacement(  PMTFrontRingBoxTransform, PMTFrontRingBoxPhysName+PMTNumberName[CurPMTNum],
-					RichTbPMTFrontRingLVol  , CurMPhys,
-					false,0);
+  G4ThreeVector PMTPhCathodePos(RichTbPMTPhCathodeXLocation, RichTbPMTPhCathodeYLocation, RichTbPMTPhCathodeZLocation);
 
-	G4VPhysicalVolume*   PMTQuartzWPhys=
-			new G4PVPlacement(  PMTQuartzWindowTransform, PMTQuartzWPhysName+PMTNumberName[CurPMTNum],
-					RichTbPMTQuartzWLVol ,
-					CurMPhys , false,0);
+  G4Transform3D PMTPhCathodeTransform(PMTPhCathodeRot, PMTPhCathodePos);
 
-	G4VPhysicalVolume*   PMTPhCathodePhys=
-			new G4PVPlacement(  PMTPhCathodeTransform, PMTPhCathodePhysName +PMTNumberName[CurPMTNum],
-					RichTbPMTPhCathodeLVol,
-					CurMPhys,false,0);
+  G4VPhysicalVolume *CurMPhys = RichTbPMTSMasterPVol[CurPMTNum];
 
+  G4VPhysicalVolume *PMTEnvelopePhys =
+      new G4PVPlacement(PMTEnvelopeBoxTransform, PMTEnvelopeBoxPhysName + PMTNumberName[CurPMTNum],
+                        RichTbPMTEnvelopeLVol, CurMPhys, false, 0);
 
+  G4VPhysicalVolume *PMTFrontRingPhys =
+      new G4PVPlacement(PMTFrontRingBoxTransform, PMTFrontRingBoxPhysName + PMTNumberName[CurPMTNum],
+                        RichTbPMTFrontRingLVol, CurMPhys, false, 0);
 
-	RichTbPMTEnvelopePVol[CurPMTNum] = PMTEnvelopePhys;
-	RichTbPMTQuartzWPVol[CurPMTNum]= PMTQuartzWPhys;
-	RichTbPMTPhCathodePVol[CurPMTNum]= PMTPhCathodePhys;
-	RichTbPMTFrontRingPVol[CurPMTNum] =  PMTFrontRingPhys;
+  G4VPhysicalVolume *PMTQuartzWPhys =
+      new G4PVPlacement(PMTQuartzWindowTransform, PMTQuartzWPhysName + PMTNumberName[CurPMTNum], RichTbPMTQuartzWLVol,
+                        CurMPhys, false, 0);
 
+  G4VPhysicalVolume *PMTPhCathodePhys =
+      new G4PVPlacement(PMTPhCathodeTransform, PMTPhCathodePhysName + PMTNumberName[CurPMTNum], RichTbPMTPhCathodeLVol,
+                        CurMPhys, false, 0);
 
+  RichTbPMTEnvelopePVol[CurPMTNum] = PMTEnvelopePhys;
+  RichTbPMTQuartzWPVol[CurPMTNum] = PMTQuartzWPhys;
+  RichTbPMTPhCathodePVol[CurPMTNum] = PMTPhCathodePhys;
+  RichTbPMTFrontRingPVol[CurPMTNum] = PMTFrontRingPhys;
 }
 
-
-
-void RichTbPMT::constructPMTMasterTree(int CurPMTNum)
-{
-
-	RichTbMaterial* aMaterial =  RichTbMaterial::getRichTbMaterialInstance();
-	//   RichTbRunConfig* aRunConfig= RichTbRunConfig::getRunConfigInstance();
-	RichTbRunConfig* aConfig = RichTbRunConfig::getRunConfigInstance();
-	G4int aRadiatorConfiguration = aConfig->getRadiatorConfiguration();
-
-
-
-	G4RotationMatrix  PMTSMasterRot, PMTAnodeRot;
-	G4ThreeVector PMTSMasterPos(PMTSMasterBoxXPos,PMTSMasterBoxYPos,PMTSMasterBoxZPos);
-	G4Transform3D PMTSMasterTransform( PMTSMasterRot,PMTSMasterPos);
-
-
-	G4ThreeVector PMTAnodePos(RichTbPMTAnodeXLocation,
-			RichTbPMTAnodeYLocation,
-			RichTbPMTAnodeZLocation);
-
-	G4Transform3D PMTAnodeTransform( PMTAnodeRot, PMTAnodePos);
-
-
-	G4String PMTMasterBoxName = PMTNamesBox[ CurPMTNum ];
-	G4String PMTMasterLogVolName= PMTNamesLog[CurPMTNum ];
-	G4String PMTMasterPhysVolName = PMTNamesPhys[ CurPMTNum ];
-
-
-	G4Box* PMTMasterBox
-	= new G4Box( PMTMasterBoxName,
-			0.5 * PMTMasterBoxXSize,
-			0.5 * PMTMasterBoxYSize,
-			0.5 * PMTMasterBoxZSize );
-	G4Box* PMTSMasterBox
-	= new G4Box( PMTSMNamesBox[CurPMTNum],
-			0.5 * PMTMasterBoxXSize,
-			0.5 * PMTMasterBoxYSize,
-			0.5 * PMTMasterBoxZSize );
-	//anode
-	G4Box* PMTAnode=
-			new G4Box(PMTANNamesBox[CurPMTNum],
-					0.5 * PMTAnodeSupXSize,
-					0.5 * PMTAnodeSupYSize,
-					0.5 * PMTAnodeSupZSize );
-
-	G4double RichTbPMTMasterXPosFinal=  RichTbPmtPosXInEC[CurPMTNum] ;
-	G4double  RichTbPMTMasterYPosFinal= RichTbPmtPosYInEC[CurPMTNum];
-	G4double  RichTbPMTMasterZPosFinal = RichTbPmtPosZInEC ;
-	G4ThreeVector PMTMasterPos(RichTbPMTMasterXPosFinal,
-			RichTbPMTMasterYPosFinal,
-			RichTbPMTMasterZPosFinal);
-
-	//  G4RotationMatrix  PMTMasterRotY;
-	//G4Transform3D PMTMasterTransform(PMTMasterRotY*PMTMasterRotZ,
-	//                      PMTMasterPos);
-
-	G4RotationMatrix PMTMasterRotZ;
-	PMTMasterRotZ.rotateZ(RichTbPmtRotZInEC[CurPMTNum]);
-
-
-
-	G4Transform3D PMTMasterTransform(PMTMasterRotZ,PMTMasterPos);
-
-	G4LogicalVolume* PMTMasterLog=
-			new G4LogicalVolume(PMTMasterBox,aMaterial-> getRichTbVaccum(),
-					PMTMasterLogVolName ,0,0,0);
-
-	G4VPhysicalVolume* PMTMasterPhys;
-	if(aRadiatorConfiguration==3){
-		if(CurPMTNum<=MaxPmtNumInEC0) {
-			PMTMasterPhys = new G4PVPlacement(PMTMasterTransform,PMTMasterPhysVolName,
-					PMTMasterLog,
-					PmtECFrame->getRichTbECLeftPVol(),
-					false, CurPMTNum);
-		}else if(CurPMTNum<=MaxPmtNumInEC1) {
-			PMTMasterPhys = new G4PVPlacement(PMTMasterTransform,PMTMasterPhysVolName,
-					PMTMasterLog,
-					PmtECFrame->getRichTbECRightPVol(),
-					false, CurPMTNum);
-		}else if(CurPMTNum<=MaxPmtNumInEC2) {
-			PMTMasterPhys = new G4PVPlacement(PMTMasterTransform,PMTMasterPhysVolName,
-					PMTMasterLog,
-					PmtECFrame->getRichTbECBottomLeftPVol(),
-					false, CurPMTNum);
-		}else if(CurPMTNum<=MaxPmtNumInEC3) {
-			PMTMasterPhys = new G4PVPlacement(PMTMasterTransform,PMTMasterPhysVolName,
-					PMTMasterLog,
-					PmtECFrame->getRichTbECBottomRightPVol(),
-					false, CurPMTNum);
-		}
-	}else{
-		PMTMasterPhys = (CurPMTNum <= MaxPmtNumInEC0) ?
-				( new G4PVPlacement(PMTMasterTransform,PMTMasterPhysVolName,
-						PMTMasterLog,
-						PmtECFrame->getRichTbECLeftPVol(),
-						false, CurPMTNum)) :
-						( new G4PVPlacement(PMTMasterTransform,PMTMasterPhysVolName,
-								PMTMasterLog,
-								PmtECFrame->getRichTbECRightPVol(),
-								false, CurPMTNum)) ;
-	}
-
-	G4LogicalVolume* PMTSMasterLog=
-			new G4LogicalVolume(PMTSMasterBox,aMaterial-> getRichTbVaccum(),
-					PMTSMNamesLog[CurPMTNum] ,0,0,0);
-
-	G4LogicalVolume* PMTAnodeLog =
-			new G4LogicalVolume(PMTAnode ,aMaterial->getPMTAnodeMaterial() ,
-					PMTANNamesLog[CurPMTNum] ,0,0,0);
-
-	G4VPhysicalVolume* PMTSMasterPhys =
-			new G4PVPlacement(PMTSMasterTransform, PMTSMNamesPhys [CurPMTNum],
-					PMTSMasterLog,PMTMasterPhys,false, 0);
-
-	G4VPhysicalVolume* PMTAnodePhys =
-			new G4PVPlacement(PMTAnodeTransform,PMTANNamesPhys [CurPMTNum],
-					PMTAnodeLog, PMTSMasterPhys,false, 0);
-
-	RichTbPMTMasterLVol[CurPMTNum]=PMTMasterLog;
-	RichTbPMTMasterPVol[CurPMTNum]=PMTMasterPhys;
-	RichTbPMTSMasterLVol[CurPMTNum]=PMTSMasterLog;
-	RichTbPMTSMasterPVol[CurPMTNum]=PMTSMasterPhys;
-	RichTbPMTAnodeLVol[CurPMTNum]=PMTAnodeLog;
-	RichTbPMTAnodePVol[CurPMTNum]=PMTAnodePhys;
-
-
-
-
+void RichTbPMT::constructPMTMasterTree(int CurPMTNum) {
+
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  //   RichTbRunConfig* aRunConfig= RichTbRunConfig::getRunConfigInstance();
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int aRadiatorConfiguration = aConfig->getRadiatorConfiguration();
+
+  G4RotationMatrix PMTSMasterRot, PMTAnodeRot;
+  G4ThreeVector PMTSMasterPos(PMTSMasterBoxXPos, PMTSMasterBoxYPos, PMTSMasterBoxZPos);
+  G4Transform3D PMTSMasterTransform(PMTSMasterRot, PMTSMasterPos);
+
+  G4ThreeVector PMTAnodePos(RichTbPMTAnodeXLocation, RichTbPMTAnodeYLocation, RichTbPMTAnodeZLocation);
+
+  G4Transform3D PMTAnodeTransform(PMTAnodeRot, PMTAnodePos);
+
+  G4String PMTMasterBoxName = PMTNamesBox[CurPMTNum];
+  G4String PMTMasterLogVolName = PMTNamesLog[CurPMTNum];
+  G4String PMTMasterPhysVolName = PMTNamesPhys[CurPMTNum];
+
+  G4Box *PMTMasterBox =
+      new G4Box(PMTMasterBoxName, 0.5 * PMTMasterBoxXSize, 0.5 * PMTMasterBoxYSize, 0.5 * PMTMasterBoxZSize);
+  G4Box *PMTSMasterBox =
+      new G4Box(PMTSMNamesBox[CurPMTNum], 0.5 * PMTMasterBoxXSize, 0.5 * PMTMasterBoxYSize, 0.5 * PMTMasterBoxZSize);
+  // anode
+  G4Box *PMTAnode =
+      new G4Box(PMTANNamesBox[CurPMTNum], 0.5 * PMTAnodeSupXSize, 0.5 * PMTAnodeSupYSize, 0.5 * PMTAnodeSupZSize);
+
+  G4double RichTbPMTMasterXPosFinal = RichTbPmtPosXInEC[CurPMTNum];
+  G4double RichTbPMTMasterYPosFinal = RichTbPmtPosYInEC[CurPMTNum];
+  G4double RichTbPMTMasterZPosFinal = RichTbPmtPosZInEC;
+  G4ThreeVector PMTMasterPos(RichTbPMTMasterXPosFinal, RichTbPMTMasterYPosFinal, RichTbPMTMasterZPosFinal);
+
+  //  G4RotationMatrix  PMTMasterRotY;
+  // G4Transform3D PMTMasterTransform(PMTMasterRotY*PMTMasterRotZ,
+  //                      PMTMasterPos);
+
+  G4RotationMatrix PMTMasterRotZ;
+  PMTMasterRotZ.rotateZ(RichTbPmtRotZInEC[CurPMTNum]);
+
+  G4Transform3D PMTMasterTransform(PMTMasterRotZ, PMTMasterPos);
+
+  G4LogicalVolume *PMTMasterLog =
+      new G4LogicalVolume(PMTMasterBox, aMaterial->getRichTbVaccum(), PMTMasterLogVolName, 0, 0, 0);
+
+  G4VPhysicalVolume *PMTMasterPhys;
+  if (aRadiatorConfiguration == 3) {
+    if (CurPMTNum <= MaxPmtNumInEC0) {
+      PMTMasterPhys = new G4PVPlacement(PMTMasterTransform, PMTMasterPhysVolName, PMTMasterLog,
+                                        PmtECFrame->getRichTbECLeftPVol(), false, CurPMTNum);
+    } else if (CurPMTNum <= MaxPmtNumInEC1) {
+      PMTMasterPhys = new G4PVPlacement(PMTMasterTransform, PMTMasterPhysVolName, PMTMasterLog,
+                                        PmtECFrame->getRichTbECRightPVol(), false, CurPMTNum);
+    } else if (CurPMTNum <= MaxPmtNumInEC2) {
+      PMTMasterPhys = new G4PVPlacement(PMTMasterTransform, PMTMasterPhysVolName, PMTMasterLog,
+                                        PmtECFrame->getRichTbECBottomLeftPVol(), false, CurPMTNum);
+    } else if (CurPMTNum <= MaxPmtNumInEC3) {
+      PMTMasterPhys = new G4PVPlacement(PMTMasterTransform, PMTMasterPhysVolName, PMTMasterLog,
+                                        PmtECFrame->getRichTbECBottomRightPVol(), false, CurPMTNum);
+    }
+  } else {
+    PMTMasterPhys = (CurPMTNum <= MaxPmtNumInEC0)
+                        ? (new G4PVPlacement(PMTMasterTransform, PMTMasterPhysVolName, PMTMasterLog,
+                                             PmtECFrame->getRichTbECLeftPVol(), false, CurPMTNum))
+                        : (new G4PVPlacement(PMTMasterTransform, PMTMasterPhysVolName, PMTMasterLog,
+                                             PmtECFrame->getRichTbECRightPVol(), false, CurPMTNum));
+  }
+
+  G4LogicalVolume *PMTSMasterLog =
+      new G4LogicalVolume(PMTSMasterBox, aMaterial->getRichTbVaccum(), PMTSMNamesLog[CurPMTNum], 0, 0, 0);
+
+  G4LogicalVolume *PMTAnodeLog =
+      new G4LogicalVolume(PMTAnode, aMaterial->getPMTAnodeMaterial(), PMTANNamesLog[CurPMTNum], 0, 0, 0);
+
+  G4VPhysicalVolume *PMTSMasterPhys =
+      new G4PVPlacement(PMTSMasterTransform, PMTSMNamesPhys[CurPMTNum], PMTSMasterLog, PMTMasterPhys, false, 0);
+
+  G4VPhysicalVolume *PMTAnodePhys =
+      new G4PVPlacement(PMTAnodeTransform, PMTANNamesPhys[CurPMTNum], PMTAnodeLog, PMTSMasterPhys, false, 0);
+
+  RichTbPMTMasterLVol[CurPMTNum] = PMTMasterLog;
+  RichTbPMTMasterPVol[CurPMTNum] = PMTMasterPhys;
+  RichTbPMTSMasterLVol[CurPMTNum] = PMTSMasterLog;
+  RichTbPMTSMasterPVol[CurPMTNum] = PMTSMasterPhys;
+  RichTbPMTAnodeLVol[CurPMTNum] = PMTAnodeLog;
+  RichTbPMTAnodePVol[CurPMTNum] = PMTAnodePhys;
 }
-void  RichTbPMT::constructPMTAnode()
-{
-
-	RichTbAnodePxPVol.resize( CurNumPmts);
-	for (G4int jpmt =0; jpmt < CurNumPmts ; jpmt++ ){
-		RichTbAnodePxPVol[jpmt].reserve( NumPixelInPmtCol*NumPixelInPmtRow);
-	}
-
-	RichTbMaterial* aMaterial =  RichTbMaterial::getRichTbMaterialInstance();
-
-
-	G4Box* PMTSiPxBox =
-			new G4Box("PMTAnodePxBox",0.5*PmtAnodePixelXSize,0.5*PmtAnodePixelYSize,
-					0.5* RichTbPMTAnodePixelZSize);
+void RichTbPMT::constructPMTAnode() {
 
-	G4LogicalVolume* PMTAnodePxLog =
-			new G4LogicalVolume( PMTSiPxBox,
-					aMaterial->getPMTAnodeMaterial(),
-					"PMTAnodePxLog",0,0,0);
+  RichTbAnodePxPVol.resize(CurNumPmts);
+  for (G4int jpmt = 0; jpmt < CurNumPmts; jpmt++) {
+    RichTbAnodePxPVol[jpmt].reserve(NumPixelInPmtCol * NumPixelInPmtRow);
+  }
 
-	//Now for the readout dummy sensitive detector
-	// This just flags the pixel as active.
-	// for now all pixels are set active. To deactivate
-	// specific pixels, the log vol must be created for each
-	// given pixel and the set to be active as done below. This means
-	// a separate log vol must be created for every pixel.
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
 
-	G4bool thisPixelisAlive=true;
-	if(thisPixelisAlive){
-		RichTbRODummySD * DummySensi = new RichTbRODummySD;
-		PMTAnodePxLog->SetSensitiveDetector(DummySensi);
-	}
+  G4Box *PMTSiPxBox =
+      new G4Box("PMTAnodePxBox", 0.5 * PmtAnodePixelXSize, 0.5 * PmtAnodePixelYSize, 0.5 * RichTbPMTAnodePixelZSize);
 
+  G4LogicalVolume *PMTAnodePxLog =
+      new G4LogicalVolume(PMTSiPxBox, aMaterial->getPMTAnodeMaterial(), "PMTAnodePxLog", 0, 0, 0);
 
-	// now positioning the pixels in the Silicon Det.
+  // Now for the readout dummy sensitive detector
+  // This just flags the pixel as active.
+  // for now all pixels are set active. To deactivate
+  // specific pixels, the log vol must be created for each
+  // given pixel and the set to be active as done below. This means
+  // a separate log vol must be created for every pixel.
 
-	G4RotationMatrix  PMTAnodeRot;
+  G4bool thisPixelisAlive = true;
+  if (thisPixelisAlive) {
+    RichTbRODummySD *DummySensi = new RichTbRODummySD;
+    PMTAnodePxLog->SetSensitiveDetector(DummySensi);
+  }
 
+  // now positioning the pixels in the Silicon Det.
 
+  G4RotationMatrix PMTAnodeRot;
 
-	G4double aPixelColStartX = -0.5*(NumPixelInPmtRow-1)*PmtAnodePixelXSize;
-	G4double aPixelColStartY = -0.5*(NumPixelInPmtCol-1)*PmtAnodePixelYSize;
+  G4double aPixelColStartX = -0.5 * (NumPixelInPmtRow - 1) * PmtAnodePixelXSize;
+  G4double aPixelColStartY = -0.5 * (NumPixelInPmtCol - 1) * PmtAnodePixelYSize;
 
+  for (G4int iPixelRowY = 0; iPixelRowY < NumPixelInPmtCol; iPixelRowY++) {
+    for (G4int iPixelColX = 0; iPixelColX < NumPixelInPmtRow; iPixelColX++) {
 
-	for(G4int iPixelRowY = 0; iPixelRowY < NumPixelInPmtCol ; iPixelRowY++){
-		for (G4int iPixelColX = 0; iPixelColX < NumPixelInPmtRow ; iPixelColX++){
+      G4int PixelCopyNumber = iPixelColX + iPixelRowY * NumPixelInPmtRow;
 
-			G4int PixelCopyNumber = iPixelColX + iPixelRowY*NumPixelInPmtRow;
+      G4double curPixelPosX = aPixelColStartX + iPixelColX * PmtAnodePixelXSize;
 
-			G4double curPixelPosX =   aPixelColStartX +  iPixelColX*PmtAnodePixelXSize ;
+      G4double curPixelPosY = aPixelColStartY + iPixelRowY * PmtAnodePixelYSize;
 
-			G4double curPixelPosY =   aPixelColStartY +  iPixelRowY*PmtAnodePixelYSize;
+      G4ThreeVector PMTAnodePxPos(curPixelPosX, curPixelPosY, RichTbPMTAnodePixelPosZ);
+      G4Transform3D PMTAnodeTransform(PMTAnodeRot, PMTAnodePxPos);
 
-			G4ThreeVector PMTAnodePxPos(curPixelPosX, curPixelPosY, RichTbPMTAnodePixelPosZ);
-			G4Transform3D PMTAnodeTransform(PMTAnodeRot, PMTAnodePxPos);
+      for (G4int ipmt = 0; ipmt < CurNumPmts; ipmt++) {
 
-			for (G4int ipmt =0; ipmt < CurNumPmts ; ipmt++ ){
-
-				G4VPhysicalVolume*  PMTAnodePxPhys =
-						new G4PVPlacement(  PMTAnodeTransform,"PMTAnodePxPhys"+PMTNumberName[ipmt],
-								PMTAnodePxLog, RichTbPMTAnodePVol[ipmt], false, PixelCopyNumber);
-				RichTbAnodePxPVol[ipmt].push_back(PMTAnodePxPhys);
-			}
-
-
-		}
-
-
-
-	}
-
-	RichTbAnodePxLVol=PMTAnodePxLog;
+        G4VPhysicalVolume *PMTAnodePxPhys =
+            new G4PVPlacement(PMTAnodeTransform, "PMTAnodePxPhys" + PMTNumberName[ipmt], PMTAnodePxLog,
+                              RichTbPMTAnodePVol[ipmt], false, PixelCopyNumber);
+        RichTbAnodePxPVol[ipmt].push_back(PMTAnodePxPhys);
+      }
+    }
+  }
 
+  RichTbAnodePxLVol = PMTAnodePxLog;
 }
 
-
-
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbROGeometry.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbROGeometry.cc
index 717b926102235ed0de4afe7474ac790ce0a66b2d..50ef9f137d72d1f0d2ba5d0082720a4756cebead 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbROGeometry.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbROGeometry.cc
@@ -1,18 +1,16 @@
 // $Id: $
 // Include files
 
-
-
 // local
 #include "RichTbROGeometry.hh"
-#include "RichTbUpgradeDetectorConstruction.hh"
-#include "RichTbRunConfig.hh"
 #include "RichTbGeometryParameters.hh"
 #include "RichTbHall.hh"
-#include "RichTbUpgradeVessel.hh"
+#include "RichTbRunConfig.hh"
 #include "RichTbUpgradeCrystalMaster.hh"
-#include "RichTbUpgradePhDetSupFrame.hh"
+#include "RichTbUpgradeDetectorConstruction.hh"
 #include "RichTbUpgradeEC.hh"
+#include "RichTbUpgradePhDetSupFrame.hh"
+#include "RichTbUpgradeVessel.hh"
 
 #include "RichTbPMT.hh"
 //-----------------------------------------------------------------------------
@@ -24,71 +22,61 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbROGeometry::RichTbROGeometry(G4String RoNameString,
-		RichTbDetectorConstruction* aDet  )
-: G4VReadOutGeometry(RoNameString){
-
-	CurDet = aDet;
+RichTbROGeometry::RichTbROGeometry(G4String RoNameString, RichTbDetectorConstruction *aDet)
+    : G4VReadOutGeometry(RoNameString) {
 
+  CurDet = aDet;
 }
-G4VPhysicalVolume* RichTbROGeometry::Build()
-{
-	RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-	// now construct the readout geometry.
-	RichTbHall* rTbHallRO = new RichTbHall();
-	RichTbUpgradeVessel*  rTbVesselRO = new RichTbUpgradeVessel(rTbHallRO );
-	RichTbUpgradeCrystalMaster*  rTbCrystalMasterRO = new RichTbUpgradeCrystalMaster(rTbVesselRO );
-
-	G4int aRadiatorConfiguration = aConfig->getRadiatorConfiguration();
-	if(aRadiatorConfiguration == 0){
-
-		//  RichTbCrystal*  rTbCrystalRO = new RichTbCrystal(rTbCrystalMasterRO );
-		//  RichTbLens*  rTbLensRO = new RichTbLens(rTbCrystalMasterRO );
-		// RichTbCrystalCover*  rTbCrystalCoverRO = new RichTbCrystalCover(rTbCrystalMasterRO );
-
-	}else{
-
-		// RichTbUpgradeRadiator*  rTbUpgradeRadiatorRO = new RichTbUpgradeRadiator(rTbCrystalMasterRO );
-		//   RichTbUpgradeMirror*  rTbMirrorRO = new RichTbUpgradeMirror(rTbCrystalMasterRO );
-		// RichTbUpgradeDarkCover*  rTbDarkCoverRO = new RichTbUpgradeDarkCover(rTbRadiatorRO );
-
-		RichTbUpgradePhDetSupFrame* rTbUpgradePhotSupFrameRO = new RichTbUpgradePhDetSupFrame(rTbCrystalMasterRO);
-		if( aRadiatorConfiguration == 1){
-			rTbUpgradePhotSupFrameRO ->constructRichTbPhotoDetectorSupFrame();
-		}else if (aRadiatorConfiguration == 2) {
-			rTbUpgradePhotSupFrameRO ->constructRichTbPhotoDetectorSupFrameWithHpd();
-		}else if(aRadiatorConfiguration == 3) {
-			rTbUpgradePhotSupFrameRO->constructRichTbPhotoDetectorSupFrame15();
-		}
-
-
-
-		RichTbUpgradeEC *  rTbECRO =  new RichTbUpgradeEC(rTbUpgradePhotSupFrameRO);
-		if( aRadiatorConfiguration == 1){
-			rTbECRO ->  constructRichTbUpgradeEC ();
-			rTbECRO ->  constructRichTbUpgradeECSupport ();
-		}else if( aRadiatorConfiguration == 2) {
-			rTbECRO ->  constructRichTbUpgradeSingleEC ();
-			rTbECRO ->  constructRichTbUpgradeSingleECSupport ();
-		}else if(aRadiatorConfiguration == 3) {
-			rTbECRO->constructRichTbUpgradeEC15();
-			rTbECRO->constructRichTbUpgradeECSupport15();
-		}
-
-
-
-		RichTbPMT * rTbPMTRO =  new RichTbPMT( rTbECRO );
-		rTbPMTRO ->setTrackingSwitch(false);
-		rTbPMTRO ->buildPMTGeometry() ;
-		G4cout<<"created pmt ro geometry "<<G4endl;
-
-	}
-
-	return  rTbHallRO->getRichTbHallPhysicalVolume();
-
+G4VPhysicalVolume *RichTbROGeometry::Build() {
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+  // now construct the readout geometry.
+  RichTbHall *rTbHallRO = new RichTbHall();
+  RichTbUpgradeVessel *rTbVesselRO = new RichTbUpgradeVessel(rTbHallRO);
+  RichTbUpgradeCrystalMaster *rTbCrystalMasterRO = new RichTbUpgradeCrystalMaster(rTbVesselRO);
+
+  G4int aRadiatorConfiguration = aConfig->getRadiatorConfiguration();
+  if (aRadiatorConfiguration == 0) {
+
+    //  RichTbCrystal*  rTbCrystalRO = new RichTbCrystal(rTbCrystalMasterRO );
+    //  RichTbLens*  rTbLensRO = new RichTbLens(rTbCrystalMasterRO );
+    // RichTbCrystalCover*  rTbCrystalCoverRO = new RichTbCrystalCover(rTbCrystalMasterRO );
+
+  } else {
+
+    // RichTbUpgradeRadiator*  rTbUpgradeRadiatorRO = new RichTbUpgradeRadiator(rTbCrystalMasterRO );
+    //   RichTbUpgradeMirror*  rTbMirrorRO = new RichTbUpgradeMirror(rTbCrystalMasterRO );
+    // RichTbUpgradeDarkCover*  rTbDarkCoverRO = new RichTbUpgradeDarkCover(rTbRadiatorRO );
+
+    RichTbUpgradePhDetSupFrame *rTbUpgradePhotSupFrameRO = new RichTbUpgradePhDetSupFrame(rTbCrystalMasterRO);
+    if (aRadiatorConfiguration == 1) {
+      rTbUpgradePhotSupFrameRO->constructRichTbPhotoDetectorSupFrame();
+    } else if (aRadiatorConfiguration == 2) {
+      rTbUpgradePhotSupFrameRO->constructRichTbPhotoDetectorSupFrameWithHpd();
+    } else if (aRadiatorConfiguration == 3) {
+      rTbUpgradePhotSupFrameRO->constructRichTbPhotoDetectorSupFrame15();
+    }
+
+    RichTbUpgradeEC *rTbECRO = new RichTbUpgradeEC(rTbUpgradePhotSupFrameRO);
+    if (aRadiatorConfiguration == 1) {
+      rTbECRO->constructRichTbUpgradeEC();
+      rTbECRO->constructRichTbUpgradeECSupport();
+    } else if (aRadiatorConfiguration == 2) {
+      rTbECRO->constructRichTbUpgradeSingleEC();
+      rTbECRO->constructRichTbUpgradeSingleECSupport();
+    } else if (aRadiatorConfiguration == 3) {
+      rTbECRO->constructRichTbUpgradeEC15();
+      rTbECRO->constructRichTbUpgradeECSupport15();
+    }
+
+    RichTbPMT *rTbPMTRO = new RichTbPMT(rTbECRO);
+    rTbPMTRO->setTrackingSwitch(false);
+    rTbPMTRO->buildPMTGeometry();
+    G4cout << "created pmt ro geometry " << G4endl;
+  }
+
+  return rTbHallRO->getRichTbHallPhysicalVolume();
 }
 
-
 //=============================================================================
 // Destructor
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbROGeometryHpd.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbROGeometryHpd.cc
index 594b636205117633d4c1858788a26b05fb18c119..483f1d4775174bd41c0eb705053eb4f940835b31 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbROGeometryHpd.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbROGeometryHpd.cc
@@ -1,17 +1,15 @@
 // Include files
 
-
-
 // local
 #include "RichTbROGeometryHpd.hh"
-#include "RichTbUpgradeDetectorConstruction.hh"
-#include "RichTbRunConfig.hh"
 #include "RichTbGeometryParameters.hh"
 #include "RichTbHall.hh"
-#include "RichTbUpgradeVessel.hh"
+#include "RichTbRunConfig.hh"
 #include "RichTbUpgradeCrystalMaster.hh"
-#include "RichTbUpgradePhDetSupFrame.hh"
+#include "RichTbUpgradeDetectorConstruction.hh"
 #include "RichTbUpgradeEC.hh"
+#include "RichTbUpgradePhDetSupFrame.hh"
+#include "RichTbUpgradeVessel.hh"
 
 #include "RichTbHpd.hh"
 
@@ -24,40 +22,33 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbROGeometryHpd::RichTbROGeometryHpd(G4String RoNameString,
-            RichTbDetectorConstruction* aDet  )
-: G4VReadOutGeometry(RoNameString){
+RichTbROGeometryHpd::RichTbROGeometryHpd(G4String RoNameString, RichTbDetectorConstruction *aDet)
+    : G4VReadOutGeometry(RoNameString) {
 
   CurDet = aDet;
-
 }
-G4VPhysicalVolume* RichTbROGeometryHpd::Build() {
+G4VPhysicalVolume *RichTbROGeometryHpd::Build() {
 
-  RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
   // now construct the readout geometry.
-  RichTbHall* rTbHallRO = new RichTbHall();
-  RichTbUpgradeVessel*  rTbVesselRO = new RichTbUpgradeVessel(rTbHallRO );
-  RichTbUpgradeCrystalMaster*  rTbCrystalMasterRO = new RichTbUpgradeCrystalMaster(rTbVesselRO );
-
-  G4int aRadiatorConfiguration =aConfig ->getRadiatorConfiguration();
+  RichTbHall *rTbHallRO = new RichTbHall();
+  RichTbUpgradeVessel *rTbVesselRO = new RichTbUpgradeVessel(rTbHallRO);
+  RichTbUpgradeCrystalMaster *rTbCrystalMasterRO = new RichTbUpgradeCrystalMaster(rTbVesselRO);
 
-  if(aRadiatorConfiguration == 2){
+  G4int aRadiatorConfiguration = aConfig->getRadiatorConfiguration();
 
-	RichTbUpgradePhDetSupFrame* rTbUpgradePhotSupFrameRO = new RichTbUpgradePhDetSupFrame(rTbCrystalMasterRO);
-	rTbUpgradePhotSupFrameRO ->constructRichTbPhotoDetectorSupFrameWithHpd();
-
-	RichTbHpd*  rTbHpdRO = new RichTbHpd(0, rTbUpgradePhotSupFrameRO);
-	rTbHpdRO -> setTrackingSwitch(false);
-	rTbHpdRO  -> buildHpdGeometry();
-	G4cout<<"created hpd ro geometry "<<G4endl;
+  if (aRadiatorConfiguration == 2) {
 
+    RichTbUpgradePhDetSupFrame *rTbUpgradePhotSupFrameRO = new RichTbUpgradePhDetSupFrame(rTbCrystalMasterRO);
+    rTbUpgradePhotSupFrameRO->constructRichTbPhotoDetectorSupFrameWithHpd();
 
+    RichTbHpd *rTbHpdRO = new RichTbHpd(0, rTbUpgradePhotSupFrameRO);
+    rTbHpdRO->setTrackingSwitch(false);
+    rTbHpdRO->buildHpdGeometry();
+    G4cout << "created hpd ro geometry " << G4endl;
   }
 
-
-  return  rTbHallRO->getRichTbHallPhysicalVolume();
-
-
+  return rTbHallRO->getRichTbHallPhysicalVolume();
 }
 
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbSurface.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbSurface.cc
index e63dc16f132651530b9d6639e3c23134fe041b57..5fcd48239e81ae51657b321f12a11fe266e7282f 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbSurface.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbSurface.cc
@@ -1,15 +1,12 @@
 // $Id: $
-// Include files 
-
-
+// Include files
 
 // local
 #include "RichTbSurface.hh"
 #include "Geant4/G4LogicalBorderSurface.hh"
+#include "RichTbPMT.hh"
 #include "RichTbSurfaceDefinition.hh"
 #include "RichTbUpgradeDetectorConstruction.hh"
-#include "RichTbPMT.hh"
-
 
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbSurface
@@ -20,109 +17,95 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbSurface::RichTbSurface(
-  RichTbDetectorConstruction* aDet  ) {
+RichTbSurface::RichTbSurface(RichTbDetectorConstruction *aDet) {
 
-  curDet= aDet;
+  curDet = aDet;
   createBorderSurfaces();
-  
 }
 
-RichTbSurface::~RichTbSurface(  ) {}
-
-void RichTbSurface::createBorderSurfaces() 
-{
-
-  RichTbSurfaceDefinition* aSurfaceDef=
-     RichTbSurfaceDefinition::getRichTbSurfaceDefinitionInstance();
- 
-
-  G4cout << "creating mirror surface" << G4endl; 
-  G4LogicalBorderSurface* MirrorBorderSurface =
-    new G4LogicalBorderSurface("RichTbMirrorSurface",
-      curDet->getRichTbUpgradeRadiator()->getRichTbUpgradeRadiatorPVol(), 
-      curDet-> getRichTbUpgradeMirror()-> getRichTbUpgradeMirrorPVol(),
-      aSurfaceDef->getRichTbSphMirrorSurface());
-
-
-  //      curDet->getRichTbUpgradeCrystalMaster()->getRichTbUpgradeCrystalMasterPVol(), 
-
-
-   G4LogicalBorderSurface* VesselOuterSurface=
-     new  G4LogicalBorderSurface("VesselOuterSurface",
-     curDet-> getRichTbHall()-> getRichTbHallPhysicalVolume(),
-      curDet->getRichTbUpgradeVessel()->getRichTbGasVesselPVol(), 
-      aSurfaceDef-> getRichTbVesselSurface());
-
-   G4LogicalBorderSurface* VesselOuterBackSurface =
-     new  G4LogicalBorderSurface     ("VesselOuterBackSurface",
-      curDet->getRichTbUpgradeVessel()->getRichTbGasVesselPVol(), 
-      curDet-> getRichTbHall()-> getRichTbHallPhysicalVolume(),
-      aSurfaceDef-> getRichTbVesselSurface());
-
-   /*   for(G4int ih=0; ih<curDet->getRichTbPhDetSupFrame()-> getNumPMTVol();ih++){
-     
-
-   G4LogicalBorderSurface* PMTMasterToQuartzWSurface =
-     new  G4LogicalBorderSurface("PMTMasterToQuartzWSurface",
-      curDet->getRichTbPhDetSupFrame()-> 
-       getSinglePMTVolume(ih)-> getRichTbPMTSMasterPVol(),
-      curDet->getRichTbPhDetSupFrame()-> 
-      getSinglePMTVolume(ih)-> getRichTbPMTQuartzWPVol(),
-      aSurfaceDef->getRichTbPMTMasterQuartzWSurface());
-
-   G4LogicalBorderSurface* PMTQuartzWToMasterSurface =
-     new  G4LogicalBorderSurface("PMTQuartzWToMasterSurface",
-      curDet->getRichTbPhDetSupFrame()-> 
-      getSinglePMTVolume(ih)-> getRichTbPMTQuartzWPVol(),
-      curDet->getRichTbPhDetSupFrame()-> 
-       getSinglePMTVolume(ih)-> getRichTbPMTSMasterPVol(),
-      aSurfaceDef->getRichTbPMTMasterQuartzWSurface());
-
-   G4LogicalBorderSurface* PMTQuartzWToPhCathodeSurface =
-     new     G4LogicalBorderSurface("PMTQuartzWToPhCathodeSurface",
-      curDet->getRichTbPhDetSupFrame()-> 
-      getSinglePMTVolume(ih)-> getRichTbPMTQuartzWPVol(),
-      curDet->getRichTbPhDetSupFrame()->
-      getSinglePMTVolume(ih)-> getRichTbPMTPhCathodePVol(),
-      aSurfaceDef-> getRichTbPMTQuartzWPhCathodeSurface());
-   
-   G4LogicalBorderSurface* PMTPhCathodeToQuartzSurface =
-     new     G4LogicalBorderSurface("PMTPhCathodeToQuartzSurface",
-      curDet->getRichTbPhDetSupFrame()->
-      getSinglePMTVolume(ih)-> getRichTbPMTPhCathodePVol(),
-      curDet->getRichTbPhDetSupFrame()-> 
-      getSinglePMTVolume(ih)-> getRichTbPMTQuartzWPVol(),
-      aSurfaceDef-> getRichTbPMTQuartzWPhCathodeSurface());   
-
-    G4LogicalBorderSurface* PMTKovarEnvelopeTubeSurface =
-      new     G4LogicalBorderSurface("PMTKovarEnvelopeTubeSurface",
-      curDet->getRichTbPhDetSupFrame()->
-      getSinglePMTVolume(ih)-> getRichTbPMTSMasterPVol(),   
-      curDet->getRichTbPhDetSupFrame()->
-      getSinglePMTVolume(ih)->  getRichTbPMTEnvelopeTubePVol(),
-      aSurfaceDef-> getRichTbKovarSurface());
-
-    G4LogicalBorderSurface* PMTKovarEnvelopeEndCapSurface =
-      new     G4LogicalBorderSurface("PMTKovarEnvelopeEndCapSurface",
-      curDet->getRichTbPhDetSupFrame()->
-      getSinglePMTVolume(ih)-> getRichTbPMTSMasterPVol(),   
-      curDet->getRichTbPhDetSupFrame()->
-      getSinglePMTVolume(ih)-> getRichTbPMTEnvelopeEndCapPVol(),
-      aSurfaceDef-> getRichTbKovarSurface());
-
-    G4LogicalBorderSurface* PMTSiDetSurface =
-      new   G4LogicalBorderSurface("PMTSiDetSurface",
-      curDet->getRichTbPhDetSupFrame()->
-      getSinglePMTVolume(ih)-> getRichTbPMTSMasterPVol(),   
-      curDet->getRichTbPhDetSupFrame()->
-      getSinglePMTVolume(ih)-> getRichTbPMTSiDetPVol(),
-      aSurfaceDef-> getRichTbSiDetSurface());
-
-  
-   }
-   */   
-      
+RichTbSurface::~RichTbSurface() {}
+
+void RichTbSurface::createBorderSurfaces() {
+
+  // RichTbSurfaceDefinition *aSurfaceDef = RichTbSurfaceDefinition::getRichTbSurfaceDefinitionInstance();
+
+  G4cout << "creating mirror surface" << G4endl;
+/*  G4LogicalBorderSurface *MirrorBorderSurface = new G4LogicalBorderSurface(
+      "RichTbMirrorSurface", curDet->getRichTbUpgradeRadiator()->getRichTbUpgradeRadiatorPVol(),
+      curDet->getRichTbUpgradeMirror()->getRichTbUpgradeMirrorPVol(), aSurfaceDef->getRichTbSphMirrorSurface()); */
+
+  //      curDet->getRichTbUpgradeCrystalMaster()->getRichTbUpgradeCrystalMasterPVol(),
+
+/*  G4LogicalBorderSurface *VesselOuterSurface = new G4LogicalBorderSurface(
+      "VesselOuterSurface", curDet->getRichTbHall()->getRichTbHallPhysicalVolume(),
+      curDet->getRichTbUpgradeVessel()->getRichTbGasVesselPVol(), aSurfaceDef->getRichTbVesselSurface()); */
+
+/*  G4LogicalBorderSurface *VesselOuterBackSurface = new G4LogicalBorderSurface(
+      "VesselOuterBackSurface", curDet->getRichTbUpgradeVessel()->getRichTbGasVesselPVol(),
+      curDet->getRichTbHall()->getRichTbHallPhysicalVolume(), aSurfaceDef->getRichTbVesselSurface()); */
+
+  /*   for(G4int ih=0; ih<curDet->getRichTbPhDetSupFrame()-> getNumPMTVol();ih++){
+
+
+  G4LogicalBorderSurface* PMTMasterToQuartzWSurface =
+    new  G4LogicalBorderSurface("PMTMasterToQuartzWSurface",
+     curDet->getRichTbPhDetSupFrame()->
+      getSinglePMTVolume(ih)-> getRichTbPMTSMasterPVol(),
+     curDet->getRichTbPhDetSupFrame()->
+     getSinglePMTVolume(ih)-> getRichTbPMTQuartzWPVol(),
+     aSurfaceDef->getRichTbPMTMasterQuartzWSurface());
+
+  G4LogicalBorderSurface* PMTQuartzWToMasterSurface =
+    new  G4LogicalBorderSurface("PMTQuartzWToMasterSurface",
+     curDet->getRichTbPhDetSupFrame()->
+     getSinglePMTVolume(ih)-> getRichTbPMTQuartzWPVol(),
+     curDet->getRichTbPhDetSupFrame()->
+      getSinglePMTVolume(ih)-> getRichTbPMTSMasterPVol(),
+     aSurfaceDef->getRichTbPMTMasterQuartzWSurface());
+
+  G4LogicalBorderSurface* PMTQuartzWToPhCathodeSurface =
+    new     G4LogicalBorderSurface("PMTQuartzWToPhCathodeSurface",
+     curDet->getRichTbPhDetSupFrame()->
+     getSinglePMTVolume(ih)-> getRichTbPMTQuartzWPVol(),
+     curDet->getRichTbPhDetSupFrame()->
+     getSinglePMTVolume(ih)-> getRichTbPMTPhCathodePVol(),
+     aSurfaceDef-> getRichTbPMTQuartzWPhCathodeSurface());
+
+  G4LogicalBorderSurface* PMTPhCathodeToQuartzSurface =
+    new     G4LogicalBorderSurface("PMTPhCathodeToQuartzSurface",
+     curDet->getRichTbPhDetSupFrame()->
+     getSinglePMTVolume(ih)-> getRichTbPMTPhCathodePVol(),
+     curDet->getRichTbPhDetSupFrame()->
+     getSinglePMTVolume(ih)-> getRichTbPMTQuartzWPVol(),
+     aSurfaceDef-> getRichTbPMTQuartzWPhCathodeSurface());
+
+   G4LogicalBorderSurface* PMTKovarEnvelopeTubeSurface =
+     new     G4LogicalBorderSurface("PMTKovarEnvelopeTubeSurface",
+     curDet->getRichTbPhDetSupFrame()->
+     getSinglePMTVolume(ih)-> getRichTbPMTSMasterPVol(),
+     curDet->getRichTbPhDetSupFrame()->
+     getSinglePMTVolume(ih)->  getRichTbPMTEnvelopeTubePVol(),
+     aSurfaceDef-> getRichTbKovarSurface());
+
+   G4LogicalBorderSurface* PMTKovarEnvelopeEndCapSurface =
+     new     G4LogicalBorderSurface("PMTKovarEnvelopeEndCapSurface",
+     curDet->getRichTbPhDetSupFrame()->
+     getSinglePMTVolume(ih)-> getRichTbPMTSMasterPVol(),
+     curDet->getRichTbPhDetSupFrame()->
+     getSinglePMTVolume(ih)-> getRichTbPMTEnvelopeEndCapPVol(),
+     aSurfaceDef-> getRichTbKovarSurface());
+
+   G4LogicalBorderSurface* PMTSiDetSurface =
+     new   G4LogicalBorderSurface("PMTSiDetSurface",
+     curDet->getRichTbPhDetSupFrame()->
+     getSinglePMTVolume(ih)-> getRichTbPMTSMasterPVol(),
+     curDet->getRichTbPhDetSupFrame()->
+     getSinglePMTVolume(ih)-> getRichTbPMTSiDetPVol(),
+     aSurfaceDef-> getRichTbSiDetSurface());
+
+
+  }
+  */
 }
 
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbSurfaceDefinition.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbSurfaceDefinition.cc
index 539e06a88092f51226ac9ca9d191da7e58e24695..1472572eb670e56ae5e3853614fff8c1b430de18 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbSurfaceDefinition.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbSurfaceDefinition.cc
@@ -1,18 +1,17 @@
 // $Id: $
 // Include files
 
-#include "Geant4/G4Material.hh"
-#include "Geant4/G4MaterialTable.hh"
 #include "Geant4/G4Element.hh"
 #include "Geant4/G4ElementTable.hh"
+#include "Geant4/G4Material.hh"
+#include "Geant4/G4MaterialTable.hh"
 #include "Geant4/G4OpticalSurface.hh"
-#include "RichTbRunConfig.hh"
 #include "RichTbMaterialParameters.hh"
+#include "RichTbRunConfig.hh"
 #include "RichTbSurfaceParameters.hh"
+#include <cstdlib>
 #include <fstream>
 #include <vector>
-#include <cstdlib>
-
 
 // local
 #include "RichTbSurfaceDefinition.hh"
@@ -26,421 +25,312 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbSurfaceDefinition* RichTbSurfaceDefinition::RichTbSurfaceDefinitionInstance=0;
+RichTbSurfaceDefinition *RichTbSurfaceDefinition::RichTbSurfaceDefinitionInstance = 0;
 
-RichTbSurfaceDefinition::RichTbSurfaceDefinition(  )
-:  MirrorSurfWlen(std::vector<G4double>(10)),
-   MirrorSurfReflect(std::vector<G4double>(10)) {
+RichTbSurfaceDefinition::RichTbSurfaceDefinition()
+    : MirrorSurfWlen(std::vector<G4double>(10)), MirrorSurfReflect(std::vector<G4double>(10)) {
 
   // in the above 10 is a dummy value.
 
-
   createMirrorOpticalSurface();
   createVesselSurface();
   createPMTQuartzWSurface();
   createPMTQuartzWPhCathodeSurface();
   createRichTbKovarSurface();
   createtRichTbSiDetSurface();
-
-
 }
 
-RichTbSurfaceDefinition::~RichTbSurfaceDefinition(  ) {
-
-}
+RichTbSurfaceDefinition::~RichTbSurfaceDefinition() {}
 
-RichTbSurfaceDefinition* RichTbSurfaceDefinition::getRichTbSurfaceDefinitionInstance()
-{
-  if(RichTbSurfaceDefinitionInstance == 0) {
-    RichTbSurfaceDefinitionInstance= new RichTbSurfaceDefinition(  );
+RichTbSurfaceDefinition *RichTbSurfaceDefinition::getRichTbSurfaceDefinitionInstance() {
+  if (RichTbSurfaceDefinitionInstance == 0) {
+    RichTbSurfaceDefinitionInstance = new RichTbSurfaceDefinition();
   }
   return RichTbSurfaceDefinitionInstance;
-
 }
 
-
-void RichTbSurfaceDefinition::createMirrorOpticalSurface()
-{
+void RichTbSurfaceDefinition::createMirrorOpticalSurface() {
 
   ReadMirrorReflectivity();
 
   // Now for the Spherical mirror surface
- G4double* MirrReflPhotonMomentum
-    =new G4double[NumPhotMirrorReflectBins];
- G4double* MirrReflect
-    = new G4double[NumPhotMirrorReflectBins];
- G4double* MirrEff
-   = new G4double[NumPhotMirrorReflectBins];
- G4double* MirrReflRefIndex
-   = new G4double[NumPhotMirrorReflectBins];
-
- for(G4int ibin=0; ibin<NumPhotMirrorReflectBins;ibin++) {
-  MirrReflPhotonMomentum[ibin]=
-    PhotWaveLengthToMom/
-    ( MirrorSurfWlen[ibin]*PhotonMirrReflWavelengthUnits);
-  // in the following the 100 is to convert from percent
-  // to absolute fraction.
-   MirrReflect[ibin]=  MirrorSurfReflect[ibin]/100.0;
-   MirrEff[ibin]=0.0;
-   MirrReflRefIndex[ibin]=1.40;
-
-   //  G4cout<<" Mirror reflectivity bin Wlen refl  "<<
-   //  ibin<<"   "<< MirrorSurfWlen[ibin] <<" " << MirrReflPhotonMomentum[ibin]
-   //    <<"   "<< MirrReflect[ibin]<<G4endl;
-
- }
-
- G4OpticalSurface* OpRichTbMirrorSurface =
-     new G4OpticalSurface("RichTbMirrorSurface");
-
-   OpRichTbMirrorSurface->SetType(dielectric_metal);
-   OpRichTbMirrorSurface->SetFinish(polished);
-   OpRichTbMirrorSurface->SetModel(glisur);
-   G4MaterialPropertiesTable* OpRichTbMirrorSurfaceMPT =
-                            new G4MaterialPropertiesTable();
-
-   OpRichTbMirrorSurfaceMPT->AddProperty("REFLECTIVITY",
-                                         MirrReflPhotonMomentum,
-                                         MirrReflect,
-                                         NumPhotMirrorReflectBins);
-
-   OpRichTbMirrorSurfaceMPT->AddProperty("EFFICIENCY",
-                                            MirrReflPhotonMomentum,
-                                            MirrEff,
-                                            NumPhotMirrorReflectBins);
-   OpRichTbMirrorSurfaceMPT->AddProperty("RINDEX",
-                                             MirrReflPhotonMomentum,
-                                             MirrReflRefIndex,
-                                             NumPhotMirrorReflectBins);
-   OpRichTbMirrorSurface->SetMaterialPropertiesTable(OpRichTbMirrorSurfaceMPT);
-
-   RichTbSphMirrorSurface=  OpRichTbMirrorSurface;
-
-}
+  G4double *MirrReflPhotonMomentum = new G4double[NumPhotMirrorReflectBins];
+  G4double *MirrReflect = new G4double[NumPhotMirrorReflectBins];
+  G4double *MirrEff = new G4double[NumPhotMirrorReflectBins];
+  G4double *MirrReflRefIndex = new G4double[NumPhotMirrorReflectBins];
+
+  for (G4int ibin = 0; ibin < NumPhotMirrorReflectBins; ibin++) {
+    MirrReflPhotonMomentum[ibin] = PhotWaveLengthToMom / (MirrorSurfWlen[ibin] * PhotonMirrReflWavelengthUnits);
+    // in the following the 100 is to convert from percent
+    // to absolute fraction.
+    MirrReflect[ibin] = MirrorSurfReflect[ibin] / 100.0;
+    MirrEff[ibin] = 0.0;
+    MirrReflRefIndex[ibin] = 1.40;
+
+    //  G4cout<<" Mirror reflectivity bin Wlen refl  "<<
+    //  ibin<<"   "<< MirrorSurfWlen[ibin] <<" " << MirrReflPhotonMomentum[ibin]
+    //    <<"   "<< MirrReflect[ibin]<<G4endl;
+  }
 
+  G4OpticalSurface *OpRichTbMirrorSurface = new G4OpticalSurface("RichTbMirrorSurface");
 
+  OpRichTbMirrorSurface->SetType(dielectric_metal);
+  OpRichTbMirrorSurface->SetFinish(polished);
+  OpRichTbMirrorSurface->SetModel(glisur);
+  G4MaterialPropertiesTable *OpRichTbMirrorSurfaceMPT = new G4MaterialPropertiesTable();
 
+  OpRichTbMirrorSurfaceMPT->AddProperty("REFLECTIVITY", MirrReflPhotonMomentum, MirrReflect, NumPhotMirrorReflectBins);
 
-void RichTbSurfaceDefinition::createVesselSurface()
-{
-  G4int NumPhotVesselSurfaceBins=10;
+  OpRichTbMirrorSurfaceMPT->AddProperty("EFFICIENCY", MirrReflPhotonMomentum, MirrEff, NumPhotMirrorReflectBins);
+  OpRichTbMirrorSurfaceMPT->AddProperty("RINDEX", MirrReflPhotonMomentum, MirrReflRefIndex, NumPhotMirrorReflectBins);
+  OpRichTbMirrorSurface->SetMaterialPropertiesTable(OpRichTbMirrorSurfaceMPT);
 
-  G4double VesselSurfacePhotMom[]=
-   {1.0*CLHEP::eV,2.0*CLHEP::eV, 3.0*CLHEP::eV,4.0*CLHEP::eV,5.0*CLHEP::eV,6.0*CLHEP::eV,7.0*CLHEP::eV,8.0*CLHEP::eV,
-    9.0*CLHEP::eV,10.0*CLHEP::eV};
+  RichTbSphMirrorSurface = OpRichTbMirrorSurface;
+}
 
-   G4double VesselSurfaceReflectivity[]=
-   {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
-   G4double VesselSurfaceEfficiency[]=
-   {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
+void RichTbSurfaceDefinition::createVesselSurface() {
+  G4int NumPhotVesselSurfaceBins = 10;
 
- G4OpticalSurface* OpVesselSurface=
-   new G4OpticalSurface("VesselOpticalSurface");
- OpVesselSurface->SetType(dielectric_metal);
- OpVesselSurface->SetFinish(polished);
- OpVesselSurface->SetModel(glisur);
+  G4double VesselSurfacePhotMom[] = {1.0 * CLHEP::eV, 2.0 * CLHEP::eV, 3.0 * CLHEP::eV, 4.0 * CLHEP::eV,
+                                     5.0 * CLHEP::eV, 6.0 * CLHEP::eV, 7.0 * CLHEP::eV, 8.0 * CLHEP::eV,
+                                     9.0 * CLHEP::eV, 10.0 * CLHEP::eV};
 
- G4MaterialPropertiesTable* OpVesselSurfaceMPT =
-          new G4MaterialPropertiesTable();
+  G4double VesselSurfaceReflectivity[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
+  G4double VesselSurfaceEfficiency[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
 
- OpVesselSurfaceMPT->AddProperty("REFLECTIVITY",
-                                 VesselSurfacePhotMom,
-                                 VesselSurfaceReflectivity,
-                                 NumPhotVesselSurfaceBins);
+  G4OpticalSurface *OpVesselSurface = new G4OpticalSurface("VesselOpticalSurface");
+  OpVesselSurface->SetType(dielectric_metal);
+  OpVesselSurface->SetFinish(polished);
+  OpVesselSurface->SetModel(glisur);
 
+  G4MaterialPropertiesTable *OpVesselSurfaceMPT = new G4MaterialPropertiesTable();
 
- OpVesselSurfaceMPT->AddProperty(" EFFICIENCY",
-                                 VesselSurfacePhotMom,
-                                 VesselSurfaceEfficiency,
-                                 NumPhotVesselSurfaceBins);
- OpVesselSurface->SetMaterialPropertiesTable( OpVesselSurfaceMPT);
+  OpVesselSurfaceMPT->AddProperty("REFLECTIVITY", VesselSurfacePhotMom, VesselSurfaceReflectivity,
+                                  NumPhotVesselSurfaceBins);
 
- RichTbVesselSurface=  OpVesselSurface;
+  OpVesselSurfaceMPT->AddProperty(" EFFICIENCY", VesselSurfacePhotMom, VesselSurfaceEfficiency,
+                                  NumPhotVesselSurfaceBins);
+  OpVesselSurface->SetMaterialPropertiesTable(OpVesselSurfaceMPT);
 
+  RichTbVesselSurface = OpVesselSurface;
 }
 
-void RichTbSurfaceDefinition::createPMTQuartzWSurface()
-{
-  G4int NumPhotPMTQuartzWMasterSurfaceWavelengthBins=10;
-  G4double PMTQuartzWMasterSurfacePhotMom []=
-   {1.0*CLHEP::eV,2.0*CLHEP::eV, 3.0*CLHEP::eV,4.0*CLHEP::eV,5.0*CLHEP::eV,6.0*CLHEP::eV,7.0*CLHEP::eV,8.0*CLHEP::eV,
-    9.0*CLHEP::eV,10.0*CLHEP::eV};
-  G4double PMTQuartzWMasterSurfaceReflectivity[]=
-    {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
-
-  G4double PMTQuartzWMasterSurfaceEff[]=
-    {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
-   G4OpticalSurface* OpPMTQuartzWMasterSurface=
-     new  G4OpticalSurface("PMTQuartzWMasterSurface");
+void RichTbSurfaceDefinition::createPMTQuartzWSurface() {
+  G4int NumPhotPMTQuartzWMasterSurfaceWavelengthBins = 10;
+  G4double PMTQuartzWMasterSurfacePhotMom[] = {1.0 * CLHEP::eV, 2.0 * CLHEP::eV, 3.0 * CLHEP::eV, 4.0 * CLHEP::eV,
+                                               5.0 * CLHEP::eV, 6.0 * CLHEP::eV, 7.0 * CLHEP::eV, 8.0 * CLHEP::eV,
+                                               9.0 * CLHEP::eV, 10.0 * CLHEP::eV};
+  G4double PMTQuartzWMasterSurfaceReflectivity[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
 
-   OpPMTQuartzWMasterSurface->SetType(dielectric_dielectric);
-   OpPMTQuartzWMasterSurface->SetFinish(polished);
-   OpPMTQuartzWMasterSurface->SetModel(glisur);
-   //   OpPMTQuartzWMasterSurface->SetModel(unified);
+  G4double PMTQuartzWMasterSurfaceEff[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
+  G4OpticalSurface *OpPMTQuartzWMasterSurface = new G4OpticalSurface("PMTQuartzWMasterSurface");
 
-   G4MaterialPropertiesTable*  OpPMTQuartzWMasterSurfaceMPT =
-           new G4MaterialPropertiesTable();
+  OpPMTQuartzWMasterSurface->SetType(dielectric_dielectric);
+  OpPMTQuartzWMasterSurface->SetFinish(polished);
+  OpPMTQuartzWMasterSurface->SetModel(glisur);
+  //   OpPMTQuartzWMasterSurface->SetModel(unified);
 
-   OpPMTQuartzWMasterSurfaceMPT ->AddProperty("REFLECTIVITY",
-                  PMTQuartzWMasterSurfacePhotMom,
-                  PMTQuartzWMasterSurfaceReflectivity,
-                  NumPhotPMTQuartzWMasterSurfaceWavelengthBins);
+  G4MaterialPropertiesTable *OpPMTQuartzWMasterSurfaceMPT = new G4MaterialPropertiesTable();
 
-   OpPMTQuartzWMasterSurfaceMPT ->AddProperty( "EFFICIENCY",
-                  PMTQuartzWMasterSurfacePhotMom,
-                  PMTQuartzWMasterSurfaceEff,
-                  NumPhotPMTQuartzWMasterSurfaceWavelengthBins);
+  OpPMTQuartzWMasterSurfaceMPT->AddProperty("REFLECTIVITY", PMTQuartzWMasterSurfacePhotMom,
+                                            PMTQuartzWMasterSurfaceReflectivity,
+                                            NumPhotPMTQuartzWMasterSurfaceWavelengthBins);
 
-    OpPMTQuartzWMasterSurface->
-      SetMaterialPropertiesTable(OpPMTQuartzWMasterSurfaceMPT);
+  OpPMTQuartzWMasterSurfaceMPT->AddProperty("EFFICIENCY", PMTQuartzWMasterSurfacePhotMom, PMTQuartzWMasterSurfaceEff,
+                                            NumPhotPMTQuartzWMasterSurfaceWavelengthBins);
 
-    RichTbPMTMasterQuartzWSurface=OpPMTQuartzWMasterSurface;
+  OpPMTQuartzWMasterSurface->SetMaterialPropertiesTable(OpPMTQuartzWMasterSurfaceMPT);
 
+  RichTbPMTMasterQuartzWSurface = OpPMTQuartzWMasterSurface;
 }
 
-void RichTbSurfaceDefinition::createPMTQuartzWPhCathodeSurface()
-{
+void RichTbSurfaceDefinition::createPMTQuartzWPhCathodeSurface() {
 
-  G4int  NumPhotQuartzWPhCathodeSurfaceWavelengthBins=10;
-  G4double PMTQuartzWPhCathodeSurfaceReflectivity[]=
-    {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
-  G4double PMTQuartzWPhCathodeSurfaceEff[]=
-    {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
-  G4double PMTQuartzWPhCathodeSurfacePhotMom[]=
-  {1.0*CLHEP::eV,2.0*CLHEP::eV, 3.0*CLHEP::eV,4.0*CLHEP::eV,5.0*CLHEP::eV,6.0*CLHEP::eV,7.0*CLHEP::eV,8.0*CLHEP::eV,
-    9.0*CLHEP::eV,10.0*CLHEP::eV};
+  G4int NumPhotQuartzWPhCathodeSurfaceWavelengthBins = 10;
+  G4double PMTQuartzWPhCathodeSurfaceReflectivity[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
+  G4double PMTQuartzWPhCathodeSurfaceEff[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
+  G4double PMTQuartzWPhCathodeSurfacePhotMom[] = {1.0 * CLHEP::eV, 2.0 * CLHEP::eV, 3.0 * CLHEP::eV, 4.0 * CLHEP::eV,
+                                                  5.0 * CLHEP::eV, 6.0 * CLHEP::eV, 7.0 * CLHEP::eV, 8.0 * CLHEP::eV,
+                                                  9.0 * CLHEP::eV, 10.0 * CLHEP::eV};
 
-  G4OpticalSurface * OpPMTQuartzWPhCathodeSurface=
-            new  G4OpticalSurface("PMTQuartzWPhCathodeSurface");
+  G4OpticalSurface *OpPMTQuartzWPhCathodeSurface = new G4OpticalSurface("PMTQuartzWPhCathodeSurface");
   OpPMTQuartzWPhCathodeSurface->SetType(dielectric_dielectric);
   OpPMTQuartzWPhCathodeSurface->SetFinish(polished);
   OpPMTQuartzWPhCathodeSurface->SetModel(glisur);
 
-  G4MaterialPropertiesTable* OpPMTQuartzWPhCathodeSurfaceMPT=
-           new G4MaterialPropertiesTable();
+  G4MaterialPropertiesTable *OpPMTQuartzWPhCathodeSurfaceMPT = new G4MaterialPropertiesTable();
 
-  OpPMTQuartzWPhCathodeSurfaceMPT->AddProperty("REFLECTIVITY",
-            PMTQuartzWPhCathodeSurfacePhotMom,
-            PMTQuartzWPhCathodeSurfaceReflectivity,
-            NumPhotQuartzWPhCathodeSurfaceWavelengthBins);
+  OpPMTQuartzWPhCathodeSurfaceMPT->AddProperty("REFLECTIVITY", PMTQuartzWPhCathodeSurfacePhotMom,
+                                               PMTQuartzWPhCathodeSurfaceReflectivity,
+                                               NumPhotQuartzWPhCathodeSurfaceWavelengthBins);
 
-  OpPMTQuartzWPhCathodeSurfaceMPT->AddProperty("EFFICIENCY",
-            PMTQuartzWPhCathodeSurfacePhotMom,
-            PMTQuartzWPhCathodeSurfaceEff,
-            NumPhotQuartzWPhCathodeSurfaceWavelengthBins);
+  OpPMTQuartzWPhCathodeSurfaceMPT->AddProperty("EFFICIENCY", PMTQuartzWPhCathodeSurfacePhotMom,
+                                               PMTQuartzWPhCathodeSurfaceEff,
+                                               NumPhotQuartzWPhCathodeSurfaceWavelengthBins);
 
-  OpPMTQuartzWPhCathodeSurface->
-   SetMaterialPropertiesTable(OpPMTQuartzWPhCathodeSurfaceMPT);
-
-  RichTbPMTQuartzWPhCathodeSurface= OpPMTQuartzWPhCathodeSurface;
+  OpPMTQuartzWPhCathodeSurface->SetMaterialPropertiesTable(OpPMTQuartzWPhCathodeSurfaceMPT);
 
+  RichTbPMTQuartzWPhCathodeSurface = OpPMTQuartzWPhCathodeSurface;
 }
 
 void RichTbSurfaceDefinition::ReadMirrorReflectivity() {
 
-
-  RichTbRunConfig* aRunConfig= RichTbRunConfig::getRunConfigInstance();
-  G4String MirrorFname= aRunConfig->getMirrorReflFileName();
-  G4cout<<" MirrorReflectivity being read from   "<<MirrorFname<<G4endl;
+  RichTbRunConfig *aRunConfig = RichTbRunConfig::getRunConfigInstance();
+  G4String MirrorFname = aRunConfig->getMirrorReflFileName();
+  G4cout << " MirrorReflectivity being read from   " << MirrorFname << G4endl;
   MirrorSurfWlen.clear();
   MirrorSurfReflect.clear();
-  G4int numbinrefl=0;
+  G4int numbinrefl = 0;
   // the -1 above is to take care of the addtional 1 which
   // happens when closing the while loop.
-  const char* MirrorDataFileNameChar= MirrorFname.c_str();
-  std::ifstream finpfa(MirrorDataFileNameChar );
-  if(!finpfa) {
-    G4cout<<"Mirror Reflectivity data file  cannot be opened " <<
-           "  Please check the file names and paths "<<G4endl;
+  const char *MirrorDataFileNameChar = MirrorFname.c_str();
+  std::ifstream finpfa(MirrorDataFileNameChar);
+  if (!finpfa) {
+    G4cout << "Mirror Reflectivity data file  cannot be opened "
+           << "  Please check the file names and paths " << G4endl;
   } else {
-      G4double wa=0.0;
-      G4double rf=0.0;
-      while(!finpfa.eof()) {
-       finpfa>>wa;
-       finpfa>>rf;
-       numbinrefl++;
-
-       MirrorSurfWlen.push_back(wa);
-       MirrorSurfReflect.push_back(rf);
-
-      }
-
-      // remove the last bin since it is a repeat of the previous bin.
-
-      G4int aSize= G4int (MirrorSurfWlen.size());
-      if(MirrorSurfWlen[aSize-1] ==MirrorSurfWlen[aSize-2] ) {
-        MirrorSurfWlen.pop_back();
-	MirrorSurfReflect.pop_back();
-        numbinrefl--;
-
-      }
-
-      //      G4cout<<"Numbins in Mirr file "<<numbinrefl
-      //	    <<"  "<<G4int( MirrorSurfWlen.size()) <<G4endl;
+    G4double wa = 0.0;
+    G4double rf = 0.0;
+    while (!finpfa.eof()) {
+      finpfa >> wa;
+      finpfa >> rf;
+      numbinrefl++;
+
+      MirrorSurfWlen.push_back(wa);
+      MirrorSurfReflect.push_back(rf);
+    }
 
-      //  G4cout<<"Now adding the bins in Mirror Refl "<<G4endl;
-      // it assumes that in the data file,  the order
-      // is set with highest wavelength to lower wavelengths.
+    // remove the last bin since it is a repeat of the previous bin.
 
-      if(MirrorSurfWlen.front() >  0.0 ) {
-        G4double MirrFirstMom=PhotWaveLengthToMom/
-            ((MirrorSurfWlen.front())* PhotonMirrReflWavelengthUnits) ;
-	  if(MirrFirstMom >   PhotonMinEnergy ){
-            numbinrefl++;
-	    G4double PhotonMaxWlen=
-             PhotMomToWaveLength/(PhotonMinEnergy*CLHEP::nanometer);
+    G4int aSize = G4int(MirrorSurfWlen.size());
+    if (MirrorSurfWlen[aSize - 1] == MirrorSurfWlen[aSize - 2]) {
+      MirrorSurfWlen.pop_back();
+      MirrorSurfReflect.pop_back();
+      numbinrefl--;
+    }
 
-	    MirrorSurfWlen.insert( MirrorSurfWlen.begin(), PhotonMaxWlen);
-	MirrorSurfReflect.insert(MirrorSurfReflect.begin(),
-				 MirrorSurfReflect.front());
+    //      G4cout<<"Numbins in Mirr file "<<numbinrefl
+    //	    <<"  "<<G4int( MirrorSurfWlen.size()) <<G4endl;
 
-	  }
+    //  G4cout<<"Now adding the bins in Mirror Refl "<<G4endl;
+    // it assumes that in the data file,  the order
+    // is set with highest wavelength to lower wavelengths.
 
+    if (MirrorSurfWlen.front() > 0.0) {
+      G4double MirrFirstMom = PhotWaveLengthToMom / ((MirrorSurfWlen.front()) * PhotonMirrReflWavelengthUnits);
+      if (MirrFirstMom > PhotonMinEnergy) {
+        numbinrefl++;
+        G4double PhotonMaxWlen = PhotMomToWaveLength / (PhotonMinEnergy * CLHEP::nanometer);
 
+        MirrorSurfWlen.insert(MirrorSurfWlen.begin(), PhotonMaxWlen);
+        MirrorSurfReflect.insert(MirrorSurfReflect.begin(), MirrorSurfReflect.front());
       }
+    }
 
-      if( MirrorSurfWlen.back()  > 0.0 ) {
-        G4double MirrLastMom=PhotWaveLengthToMom/
-	  ((MirrorSurfWlen.back())* PhotonMirrReflWavelengthUnits);
-        if(MirrLastMom <  PhotonMaxEnergy ) {
-            numbinrefl++;
-            G4double PhotonMinWlen=
-	      PhotMomToWaveLength/( PhotonMaxEnergy*CLHEP::nanometer);
-	    MirrorSurfWlen.push_back(PhotonMinWlen);
-            MirrorSurfReflect.push_back( MirrorSurfReflect.back());
-	      }
-
+    if (MirrorSurfWlen.back() > 0.0) {
+      G4double MirrLastMom = PhotWaveLengthToMom / ((MirrorSurfWlen.back()) * PhotonMirrReflWavelengthUnits);
+      if (MirrLastMom < PhotonMaxEnergy) {
+        numbinrefl++;
+        G4double PhotonMinWlen = PhotMomToWaveLength / (PhotonMaxEnergy * CLHEP::nanometer);
+        MirrorSurfWlen.push_back(PhotonMinWlen);
+        MirrorSurfReflect.push_back(MirrorSurfReflect.back());
       }
+    }
 
-      NumPhotMirrorReflectBins= numbinrefl;
-      reverse(MirrorSurfWlen.begin(),MirrorSurfWlen.end());
-      reverse(MirrorSurfReflect.begin(),MirrorSurfReflect.end());
-
-
-      // test print
-      /*
-      G4cout<<"Numbins for Mirror refl "<<NumPhotMirrorReflectBins<<G4endl;
+    NumPhotMirrorReflectBins = numbinrefl;
+    reverse(MirrorSurfWlen.begin(), MirrorSurfWlen.end());
+    reverse(MirrorSurfReflect.begin(), MirrorSurfReflect.end());
 
-        for(G4int ii=0; ii<NumPhotMirrorReflectBins; ii++ ) {
-        G4cout<<"Mirr "<<MirrorSurfWlen[ii]<<"   "
-          <<MirrorSurfReflect[ii]
-              <<G4endl;
-        }
+    // test print
+    /*
+    G4cout<<"Numbins for Mirror refl "<<NumPhotMirrorReflectBins<<G4endl;
 
-      */
+      for(G4int ii=0; ii<NumPhotMirrorReflectBins; ii++ ) {
+      G4cout<<"Mirr "<<MirrorSurfWlen[ii]<<"   "
+        <<MirrorSurfReflect[ii]
+            <<G4endl;
+      }
 
-      //end of test print.
+    */
 
+    // end of test print.
 
-    G4cout<<"End of reading Mirror reflectivity"<<G4endl;
+    G4cout << "End of reading Mirror reflectivity" << G4endl;
   }
-
 }
 
 void RichTbSurfaceDefinition::createRichTbKovarSurface() {
 
-   G4int NumPhotKovarSurfaceBins=12;
+  G4int NumPhotKovarSurfaceBins = 12;
 
-  G4double KovarSurfacePhotMom[]=
-   {0.01*CLHEP::eV, 1.0*CLHEP::eV,2.0*CLHEP::eV, 3.0*CLHEP::eV,4.0*CLHEP::eV,5.0*CLHEP::eV,6.0*CLHEP::eV,7.0*CLHEP::eV,8.0*CLHEP::eV,
-    9.0*CLHEP::eV,10.0*CLHEP::eV,11*CLHEP::eV};
+  G4double KovarSurfacePhotMom[] = {0.01 * CLHEP::eV, 1.0 * CLHEP::eV, 2.0 * CLHEP::eV,  3.0 * CLHEP::eV,
+                                    4.0 * CLHEP::eV,  5.0 * CLHEP::eV, 6.0 * CLHEP::eV,  7.0 * CLHEP::eV,
+                                    8.0 * CLHEP::eV,  9.0 * CLHEP::eV, 10.0 * CLHEP::eV, 11 * CLHEP::eV};
 
-   G4double KovarSurfaceReflectivity[]=
-   {0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05,0.05};
-   G4double KovarSurfaceEfficiency[]=
-   {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
+  G4double KovarSurfaceReflectivity[] = {0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05, 0.05};
+  G4double KovarSurfaceEfficiency[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
 
- G4OpticalSurface* OpKovarSurface=
-   new G4OpticalSurface("KovarOpticalSurface");
- OpKovarSurface->SetType(dielectric_dielectric);
- OpKovarSurface->SetFinish(groundfrontpainted);
- OpKovarSurface->SetModel(glisur);
+  G4OpticalSurface *OpKovarSurface = new G4OpticalSurface("KovarOpticalSurface");
+  OpKovarSurface->SetType(dielectric_dielectric);
+  OpKovarSurface->SetFinish(groundfrontpainted);
+  OpKovarSurface->SetModel(glisur);
 
- G4MaterialPropertiesTable* OpKovarSurfaceMPT =
-          new G4MaterialPropertiesTable();
+  G4MaterialPropertiesTable *OpKovarSurfaceMPT = new G4MaterialPropertiesTable();
 
- OpKovarSurfaceMPT->AddProperty("REFLECTIVITY",
-                                 KovarSurfacePhotMom,
-                                 KovarSurfaceReflectivity,
+  OpKovarSurfaceMPT->AddProperty("REFLECTIVITY", KovarSurfacePhotMom, KovarSurfaceReflectivity,
                                  NumPhotKovarSurfaceBins);
 
+  OpKovarSurfaceMPT->AddProperty(" EFFICIENCY", KovarSurfacePhotMom, KovarSurfaceEfficiency, NumPhotKovarSurfaceBins);
+  OpKovarSurface->SetMaterialPropertiesTable(OpKovarSurfaceMPT);
 
- OpKovarSurfaceMPT->AddProperty(" EFFICIENCY",
-                                 KovarSurfacePhotMom,
-                                 KovarSurfaceEfficiency,
-                                 NumPhotKovarSurfaceBins);
- OpKovarSurface->SetMaterialPropertiesTable(OpKovarSurfaceMPT);
-
- RichTbKovarSurface =  OpKovarSurface;
-
+  RichTbKovarSurface = OpKovarSurface;
 }
 
-void   RichTbSurfaceDefinition::createtRichTbSiDetSurface(){
-
-  RichTbRunConfig* aRunConfig= RichTbRunConfig::getRunConfigInstance();
-  G4int aSiReflFlag= aRunConfig-> getPMTSiReflFlag();
-
-   G4int NumPhotSiDetSurfaceBins=13;
+void RichTbSurfaceDefinition::createtRichTbSiDetSurface() {
 
+  RichTbRunConfig *aRunConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int aSiReflFlag = aRunConfig->getPMTSiReflFlag();
 
-  G4double SiDetSurfacePhotMom[]=
-   {0.01*CLHEP::eV, 1.0*CLHEP::eV,2.0*CLHEP::eV, 2.5*CLHEP::eV, 3.0*CLHEP::eV,4.0*CLHEP::eV,5.0*CLHEP::eV,6.0*CLHEP::eV,7.0*CLHEP::eV,8.0*CLHEP::eV,
-    9.0*CLHEP::eV,10.0*CLHEP::eV,11*CLHEP::eV};
-  G4double SiDetSurfaceReflectivity[]=
-   {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
-
+  G4int NumPhotSiDetSurfaceBins = 13;
 
+  G4double SiDetSurfacePhotMom[] = {0.01 * CLHEP::eV, 1.0 * CLHEP::eV, 2.0 * CLHEP::eV, 2.5 * CLHEP::eV,
+                                    3.0 * CLHEP::eV,  4.0 * CLHEP::eV, 5.0 * CLHEP::eV, 6.0 * CLHEP::eV,
+                                    7.0 * CLHEP::eV,  8.0 * CLHEP::eV, 9.0 * CLHEP::eV, 10.0 * CLHEP::eV,
+                                    11 * CLHEP::eV};
+  G4double SiDetSurfaceReflectivity[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
 
   // For now using 30% reflectivity. The use of this may be refined in the
   // future using more bins of the QE and disentagling the transmission
   // in photocathode vs reflection in Si etc.
-  if(aSiReflFlag >0 ) {
-    for(G4int ib=0; ib< NumPhotSiDetSurfaceBins;ib++) {
-      SiDetSurfaceReflectivity[ib]=PMTSiDetSurfaceReflectivity;
-
+  if (aSiReflFlag > 0) {
+    for (G4int ib = 0; ib < NumPhotSiDetSurfaceBins; ib++) {
+      SiDetSurfaceReflectivity[ib] = PMTSiDetSurfaceReflectivity;
     }
-
   }
 
+  G4double SiDetSurfaceEfficiency[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
 
-   G4double SiDetSurfaceEfficiency[]=
-   {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
+  G4double *SiDetReflRefIndex = new G4double[NumPhotSiDetSurfaceBins];
 
-   G4double* SiDetReflRefIndex
-   = new G4double[NumPhotSiDetSurfaceBins];
-
- for(G4int ibind=0; ibind<NumPhotSiDetSurfaceBins;ibind++) {
-   SiDetReflRefIndex[ibind]=1.40;
- }
- G4OpticalSurface* OpSiDetSurface=
-   new G4OpticalSurface("SiDetOpticalSurface");
- OpSiDetSurface->SetType(dielectric_metal);
- OpSiDetSurface->SetFinish(polished);
- OpSiDetSurface->SetModel(glisur);
-
- G4MaterialPropertiesTable* OpSiDetSurfaceMPT =
-          new G4MaterialPropertiesTable();
-
- OpSiDetSurfaceMPT->AddProperty("REFLECTIVITY",
-                                 SiDetSurfacePhotMom,
-                                 SiDetSurfaceReflectivity,
-                                 NumPhotSiDetSurfaceBins);
+  for (G4int ibind = 0; ibind < NumPhotSiDetSurfaceBins; ibind++) {
+    SiDetReflRefIndex[ibind] = 1.40;
+  }
+  G4OpticalSurface *OpSiDetSurface = new G4OpticalSurface("SiDetOpticalSurface");
+  OpSiDetSurface->SetType(dielectric_metal);
+  OpSiDetSurface->SetFinish(polished);
+  OpSiDetSurface->SetModel(glisur);
 
+  G4MaterialPropertiesTable *OpSiDetSurfaceMPT = new G4MaterialPropertiesTable();
 
- OpSiDetSurfaceMPT->AddProperty(" EFFICIENCY",
-                                 SiDetSurfacePhotMom,
-                                 SiDetSurfaceEfficiency,
+  OpSiDetSurfaceMPT->AddProperty("REFLECTIVITY", SiDetSurfacePhotMom, SiDetSurfaceReflectivity,
                                  NumPhotSiDetSurfaceBins);
 
- OpSiDetSurfaceMPT->AddProperty("RINDEX",
-                                 SiDetSurfacePhotMom,
-				 SiDetReflRefIndex,
-                                 NumPhotSiDetSurfaceBins );
-
+  OpSiDetSurfaceMPT->AddProperty(" EFFICIENCY", SiDetSurfacePhotMom, SiDetSurfaceEfficiency, NumPhotSiDetSurfaceBins);
 
- OpSiDetSurface->SetMaterialPropertiesTable(OpSiDetSurfaceMPT);
+  OpSiDetSurfaceMPT->AddProperty("RINDEX", SiDetSurfacePhotMom, SiDetReflRefIndex, NumPhotSiDetSurfaceBins);
 
- RichTbSiDetSurface =  OpSiDetSurface;
+  OpSiDetSurface->SetMaterialPropertiesTable(OpSiDetSurfaceMPT);
 
+  RichTbSiDetSurface = OpSiDetSurface;
 }
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeCrystal.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeCrystal.cc
index 8e91f931553d9657df2db4fb42a0df27a5e89980..9853a37d8c87c01c9d504367bd03bd07da5a7161 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeCrystal.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeCrystal.cc
@@ -1,25 +1,23 @@
 // $Id: $
-// Include files 
-
-
+// Include files
 
 // local
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMiscNames.hh"
-#include "RichTbMaterial.hh"
-#include "RichTbUpgradeVessel.hh"
 #include "RichTbUpgradeCrystal.hh"
-#include "RichTbUpgradeCrystalMaster.hh"
-#include "RichTbHall.hh"
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4PVPlacement.hh"
 #include "Geant4/G4RotationMatrix.hh"
+#include "Geant4/G4SubtractionSolid.hh"
 #include "Geant4/G4ThreeVector.hh"
 #include "Geant4/G4Transform3D.hh"
-#include "Geant4/G4SubtractionSolid.hh"
-#include "Geant4/G4Box.hh"
-#include "Geant4/G4LogicalVolume.hh"
 #include "Geant4/G4VPhysicalVolume.hh"
-#include "Geant4/G4PVPlacement.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbHall.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMiscNames.hh"
 #include "RichTbRunConfig.hh"
+#include "RichTbUpgradeCrystalMaster.hh"
+#include "RichTbUpgradeVessel.hh"
 
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbVessel
@@ -31,77 +29,59 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbCrystal::RichTbCrystal(RichTbUpgradeCrystalMaster* rTbCrystalMaster ) {
+RichTbCrystal::RichTbCrystal(RichTbUpgradeCrystalMaster *rTbCrystalMaster) {
 
   aRTbCrystalMaster = rTbCrystalMaster;
-  
+
   constructRichTbCrystal();
-  
 }
-RichTbCrystal::~RichTbCrystal(  )
-{
-}
-void RichTbCrystal::constructRichTbCrystal()
-{
-  RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+RichTbCrystal::~RichTbCrystal() {}
+void RichTbCrystal::constructRichTbCrystal() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
   // RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-  
-  G4Box * RichTbCrystalBox 
-    = new G4Box("RichTbCrystalBox", 0.5*RichTbCrystalXSize,
-                0.5*RichTbCrystalYSize, 0.5*RichTbCrystalZSize);
-
-  G4ThreeVector CrystalPos(RichTbCrystalXLocation,
-                          RichTbCrystalYLocation,
-                          RichTbCrystalZLocation);
- 
-  G4RotationMatrix CrystalRotX,CrystalRotY;
+
+  G4Box *RichTbCrystalBox =
+      new G4Box("RichTbCrystalBox", 0.5 * RichTbCrystalXSize, 0.5 * RichTbCrystalYSize, 0.5 * RichTbCrystalZSize);
+
+  G4ThreeVector CrystalPos(RichTbCrystalXLocation, RichTbCrystalYLocation, RichTbCrystalZLocation);
+
+  G4RotationMatrix CrystalRotX, CrystalRotY;
   /*
-   G4int aSpecialStudyCrystalRotFlag =  
+   G4int aSpecialStudyCrystalRotFlag =
       aConfig ->getSpecialStudyCrystalRotation();
 
   if( aSpecialStudyCrystalRotFlag != 1 ) {
-    
+
     CrystalRotX.rotateX(aConfig ->getSpecialStudyCrystalRotationX());
     CrystalRotY.rotateY(aConfig ->getSpecialStudyCrystalRotationY());
 
   }
   */
-  
+
   //
   // G4cout<<" Vessel XRot Yrot "<<RichTbVesselXRotation<<"   "
   //      <<RichTbVesselYRotation<<G4endl;
-  
-  //G4Transform3D VesselUpsSubTransform(VesselUpsSubRot,VesselUpsSubPos);
-  G4Transform3D CrystalTransform(  CrystalRotX * CrystalRotY, CrystalPos);
-  
-  /* G4SubtractionSolid* VesselUpsSub = 
+
+  // G4Transform3D VesselUpsSubTransform(VesselUpsSubRot,VesselUpsSubPos);
+  G4Transform3D CrystalTransform(CrystalRotX * CrystalRotY, CrystalPos);
+
+  /* G4SubtractionSolid* VesselUpsSub =
       new G4SubtractionSolid("VesselUpsSub",  RichTbVesselBoxOverall ,
                              RichTbVesselUpsSubBox,VesselUpsSubTransform);
-  
+
   */
-    G4LogicalVolume* CrystalLog;
-    
-     
-    //crystal material
-     CrystalLog = 
-       new G4LogicalVolume(RichTbCrystalBox,
-                           aMaterial->getCrystalMaterial(), "CrystalLog",0,0,0);
-
-     //crystal location  
-     G4VPhysicalVolume* CrystalPhys =
-       new G4PVPlacement(CrystalTransform, CrystalPhysName, CrystalLog ,
-                         aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(),
-                         false,0);
-     
-     RichTbCrystalLVol =  CrystalLog;
-     RichTbCrystalPVol =  CrystalPhys;
-     
-
-} 
-void RichTbCrystal::constructRichTbCrystalEnvelope()
-{
-  
-}
+  G4LogicalVolume *CrystalLog;
+
+  // crystal material
+  CrystalLog = new G4LogicalVolume(RichTbCrystalBox, aMaterial->getCrystalMaterial(), "CrystalLog", 0, 0, 0);
 
+  // crystal location
+  G4VPhysicalVolume *CrystalPhys = new G4PVPlacement(CrystalTransform, CrystalPhysName, CrystalLog,
+                                                     aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(), false, 0);
+
+  RichTbCrystalLVol = CrystalLog;
+  RichTbCrystalPVol = CrystalPhys;
+}
+void RichTbCrystal::constructRichTbCrystalEnvelope() {}
 
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeCrystalCover.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeCrystalCover.cc
index 9a61e9d7778f075e41bef641c1e3afed1815dc2f..3edf6a27bf0bd5d3d392e4c47b82c2d194fd5524 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeCrystalCover.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeCrystalCover.cc
@@ -1,25 +1,23 @@
 // $Id: $
-// Include files 
-
-
+// Include files
 
 // local
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMiscNames.hh"
-#include "RichTbMaterial.hh"
-#include "RichTbUpgradeVessel.hh"
 #include "RichTbUpgradeCrystalCover.hh"
-#include "RichTbUpgradeCrystalMaster.hh"
-#include "RichTbHall.hh"
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4PVPlacement.hh"
 #include "Geant4/G4RotationMatrix.hh"
+#include "Geant4/G4SubtractionSolid.hh"
 #include "Geant4/G4ThreeVector.hh"
 #include "Geant4/G4Transform3D.hh"
-#include "Geant4/G4SubtractionSolid.hh"
-#include "Geant4/G4Box.hh"
-#include "Geant4/G4LogicalVolume.hh"
 #include "Geant4/G4VPhysicalVolume.hh"
-#include "Geant4/G4PVPlacement.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbHall.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMiscNames.hh"
 #include "RichTbRunConfig.hh"
+#include "RichTbUpgradeCrystalMaster.hh"
+#include "RichTbUpgradeVessel.hh"
 
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbVessel
@@ -31,46 +29,34 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbCrystalCover::RichTbCrystalCover(RichTbUpgradeCrystalMaster* rTbCrystalMaster) {
+RichTbCrystalCover::RichTbCrystalCover(RichTbUpgradeCrystalMaster *rTbCrystalMaster) {
 
   aRTbCrystalMaster = rTbCrystalMaster;
-  
+
   constructRichTbCrystalCover();
-  
 }
-RichTbCrystalCover::~RichTbCrystalCover(  )
-{
-}
-void RichTbCrystalCover::constructRichTbCrystalCover()
-{
-  RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-  RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-  
-  G4Box * RichTbCrystalCoverBox 
-    = new G4Box("RichTbCrystalCoverBox", 0.5*RichTbCrystalCoverXSize,
-                0.5*RichTbCrystalCoverYSize, 0.5*RichTbCrystalCoverZSize);
- 
-  //volume substraction
-  
-  G4Box* RichTbCrystalCoverSubBox 
-   = new G4Box("RichTbCrystalCoverSubBox", 
-              0.5*RichTbCrystalCoverSubPartXSize,
-              0.5*RichTbCrystalCoverSubPartYSize,
-              0.5*RichTbCrystalCoverSubPartZSize);
-  
-
-  G4ThreeVector CrystalCoverSubPos(RichTbCrystalCoverSubPartXLocation , //!posizioni relative!
-				   RichTbCrystalCoverSubPartYLocation,
-				   RichTbCrystalCoverSubPartZLocation );
-
-  G4ThreeVector CrystalCoverPos(RichTbCrystalCoverXLocation,
-				RichTbCrystalCoverYLocation,
-				RichTbCrystalCoverZLocation);
- 
+RichTbCrystalCover::~RichTbCrystalCover() {}
+void RichTbCrystalCover::constructRichTbCrystalCover() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  // RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+
+  G4Box *RichTbCrystalCoverBox = new G4Box("RichTbCrystalCoverBox", 0.5 * RichTbCrystalCoverXSize,
+                                           0.5 * RichTbCrystalCoverYSize, 0.5 * RichTbCrystalCoverZSize);
+
+  // volume substraction
+
+  G4Box *RichTbCrystalCoverSubBox =
+      new G4Box("RichTbCrystalCoverSubBox", 0.5 * RichTbCrystalCoverSubPartXSize, 0.5 * RichTbCrystalCoverSubPartYSize,
+                0.5 * RichTbCrystalCoverSubPartZSize);
+
+  G4ThreeVector CrystalCoverSubPos(RichTbCrystalCoverSubPartXLocation, //! posizioni relative!
+                                   RichTbCrystalCoverSubPartYLocation, RichTbCrystalCoverSubPartZLocation);
+
+  G4ThreeVector CrystalCoverPos(RichTbCrystalCoverXLocation, RichTbCrystalCoverYLocation, RichTbCrystalCoverZLocation);
+
   G4RotationMatrix CrystalCoverSubRotX, CrystalCoverSubRotY, CrystalCoverRotX, CrystalCoverRotY;
   /*
-  G4int aSpecialStudyCrystalCoverRotFlag =  
-      aConfig ->getSpecialStudyCrystalRotation();
+  G4int aSpecialStudyCrystalCoverRotFlag = aConfig ->getSpecialStudyCrystalRotation();
 
   if( aSpecialStudyCrystalCoverRotFlag != 1 ) {
 
@@ -79,36 +65,36 @@ void RichTbCrystalCover::constructRichTbCrystalCover()
 
     //now rotating the cover
 
-    G4double CrystalCoverRadius = 0.5 * (RichTbCrystalCoverZSize 
-					 - RichTbCrystalZSize);
-    
-    G4ThreeVector CrystalCoverPos(RichTbCrystalCoverXLocation 
-				  - CrystalCoverRadius*sin(CrystalRotY),
-				  RichTbCrystalCoverYLocation
-				  + CrystalCoverRadius*sin(CrystalRotX) ,
-				  RichTbCrystalCoverZLocation
-				  + CrystalCoverRadius*(2+cos(CrystalRotY)+cos(CrystalRotX)));
-    
+    G4double CrystalCoverRadius = 0.5 * (RichTbCrystalCoverZSize
+                                         - RichTbCrystalZSize);
+
+    G4ThreeVector CrystalCoverPos(RichTbCrystalCoverXLocation
+                                  - CrystalCoverRadius*sin(CrystalRotY),
+                                  RichTbCrystalCoverYLocation
+                                  + CrystalCoverRadius*sin(CrystalRotX) ,
+                                  RichTbCrystalCoverZLocation
+                                  + CrystalCoverRadius*(2+cos(CrystalRotY)+cos(CrystalRotX)));
+
     CrystalCoverRotX.rotateX(CrystalRotX);
     CrystalCoverRotY.rotateY(CrystalRotY);
-  
-    
+
+
     //now rotating the inner volume
-    
-     G4double CrystalCoverInnerRadius = 0.5 * (RichTbCrystalCoverSubPartZSize 
-					 - RichTbCrystalZSize);
-
-     G4ThreeVector CrystalCoverSubPos(RichTbCrystalCoverSubPartXLocation 
-				  + CrystalCoverInnerRadius*sin(CrystalRotY),
-				  RichTbCrystalCoverSubPartYLocation
-				  - CrystalCoverInnerRadius*sin(CrystalRotX) ,
-				  RichTbCrystalCoverSubPartZLocation
-				  + CrystalCoverInnerRadius*(2+cos(CrystalRotY)+cos(CrystalRotX)));
-    
+
+     G4double CrystalCoverInnerRadius = 0.5 * (RichTbCrystalCoverSubPartZSize
+                                         - RichTbCrystalZSize);
+
+     G4ThreeVector CrystalCoverSubPos(RichTbCrystalCoverSubPartXLocation
+                                  + CrystalCoverInnerRadius*sin(CrystalRotY),
+                                  RichTbCrystalCoverSubPartYLocation
+                                  - CrystalCoverInnerRadius*sin(CrystalRotX) ,
+                                  RichTbCrystalCoverSubPartZLocation
+                                  + CrystalCoverInnerRadius*(2+cos(CrystalRotY)+cos(CrystalRotX)));
+
      CrystalCoverSubRotX.rotateX(CrystalRotX);
      CrystalCoverSubRotY.rotateY(CrystalRotY);
-    
-     
+
+
 
   }
   */
@@ -116,40 +102,26 @@ void RichTbCrystalCover::constructRichTbCrystalCover()
   // G4cout<<" Vessel XRot Yrot "<<RichTbVesselXRotation<<"   "
   //      <<RichTbVesselYRotation<<G4endl;
 
-  G4Transform3D CrystalCoverTransform(CrystalCoverRotX * CrystalCoverRotY,
-					 CrystalCoverPos);
-
-  G4Transform3D CrystalCoverSubTransform(CrystalCoverSubRotX * CrystalCoverSubRotY,
-					 CrystalCoverSubPos);
-  
-   G4SubtractionSolid* CrystalCover = 
-      new G4SubtractionSolid("CrystalCover",  RichTbCrystalCoverBox,
-                             RichTbCrystalCoverSubBox, CrystalCoverSubTransform);
-  
-  
-    G4LogicalVolume* CrystalCoverLog;
-    
-     
-    //air in the cover
-     CrystalCoverLog = 
-       new G4LogicalVolume(CrystalCover,
-                           aMaterial->getCarbon(), "CrystalCoverLog",0,0,0);
-
-     //location of the cover  
-     G4VPhysicalVolume* CrystalCoverPhys =
-       new G4PVPlacement(CrystalCoverTransform, CrystalCoverPhysName, CrystalCoverLog ,
-                         aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(),
-                         false,0);
-     
-     RichTbCrystalCoverLVol =  CrystalCoverLog;
-     RichTbCrystalCoverPVol =  CrystalCoverPhys;
-     
-
-} 
-void RichTbCrystalCover::constructRichTbCrystalCoverEnvelope()
-{
-  
-}
+  G4Transform3D CrystalCoverTransform(CrystalCoverRotX * CrystalCoverRotY, CrystalCoverPos);
+
+  G4Transform3D CrystalCoverSubTransform(CrystalCoverSubRotX * CrystalCoverSubRotY, CrystalCoverSubPos);
 
+  G4SubtractionSolid *CrystalCover =
+      new G4SubtractionSolid("CrystalCover", RichTbCrystalCoverBox, RichTbCrystalCoverSubBox, CrystalCoverSubTransform);
+
+  G4LogicalVolume *CrystalCoverLog;
+
+  // air in the cover
+  CrystalCoverLog = new G4LogicalVolume(CrystalCover, aMaterial->getCarbon(), "CrystalCoverLog", 0, 0, 0);
+
+  // location of the cover
+  G4VPhysicalVolume *CrystalCoverPhys =
+      new G4PVPlacement(CrystalCoverTransform, CrystalCoverPhysName, CrystalCoverLog,
+                        aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(), false, 0);
+
+  RichTbCrystalCoverLVol = CrystalCoverLog;
+  RichTbCrystalCoverPVol = CrystalCoverPhys;
+}
+void RichTbCrystalCover::constructRichTbCrystalCoverEnvelope() {}
 
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeCrystalMaster.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeCrystalMaster.cc
index 5b1a9f1548f8b16448a5e19789cad5967c9bae52..c24e48634f9e40b7f31e1b1b6f7b049892598119 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeCrystalMaster.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeCrystalMaster.cc
@@ -1,24 +1,22 @@
 // $Id: $
 // Include files
 
-
-
 // local
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMiscNames.hh"
-#include "RichTbMaterial.hh"
-#include "RichTbUpgradeVessel.hh"
 #include "RichTbUpgradeCrystalMaster.hh"
-#include "RichTbHall.hh"
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4PVPlacement.hh"
 #include "Geant4/G4RotationMatrix.hh"
+#include "Geant4/G4SubtractionSolid.hh"
 #include "Geant4/G4ThreeVector.hh"
 #include "Geant4/G4Transform3D.hh"
-#include "Geant4/G4SubtractionSolid.hh"
-#include "Geant4/G4Box.hh"
-#include "Geant4/G4LogicalVolume.hh"
 #include "Geant4/G4VPhysicalVolume.hh"
-#include "Geant4/G4PVPlacement.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbHall.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMiscNames.hh"
 #include "RichTbRunConfig.hh"
+#include "RichTbUpgradeVessel.hh"
 
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbVessel
@@ -30,77 +28,58 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbUpgradeCrystalMaster::RichTbUpgradeCrystalMaster(RichTbUpgradeVessel* rTbVessel ) {
+RichTbUpgradeCrystalMaster::RichTbUpgradeCrystalMaster(RichTbUpgradeVessel *rTbVessel) {
 
   aRTbVessel = rTbVessel;
 
   constructRichTbUpgradeCrystalMaster();
-
 }
-RichTbUpgradeCrystalMaster::~RichTbUpgradeCrystalMaster(  )
-{
-}
-void RichTbUpgradeCrystalMaster::constructRichTbUpgradeCrystalMaster()
-{
-  RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-  RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-
-  G4Box * RichTbCrystalMasterBox
-    = new G4Box("RichTbCrystalMasterBox", 0.5*RichTbCrystalMasterXSize,
-                0.5*RichTbCrystalMasterYSize, 0.5*RichTbCrystalMasterZSize);
+RichTbUpgradeCrystalMaster::~RichTbUpgradeCrystalMaster() {}
+void RichTbUpgradeCrystalMaster::constructRichTbUpgradeCrystalMaster() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
 
-  G4ThreeVector CrystalMasterPos(RichTbCrystalMasterXLocation,
-                          RichTbCrystalMasterYLocation,
-                          RichTbCrystalMasterZLocation);
+  G4Box *RichTbCrystalMasterBox = new G4Box("RichTbCrystalMasterBox", 0.5 * RichTbCrystalMasterXSize,
+                                            0.5 * RichTbCrystalMasterYSize, 0.5 * RichTbCrystalMasterZSize);
 
-  G4RotationMatrix CrystalMasterRotX,CrystalMasterRotY;
+  G4ThreeVector CrystalMasterPos(RichTbCrystalMasterXLocation, RichTbCrystalMasterYLocation,
+                                 RichTbCrystalMasterZLocation);
 
-   G4int aSpecialStudyCrystalRotFlag =
-      aConfig ->getSpecialStudyCrystalRotation();
+  G4RotationMatrix CrystalMasterRotX, CrystalMasterRotY;
 
-  if( aSpecialStudyCrystalRotFlag != 1 ) {
-    //G4cout << "rotation " << -aConfig ->getSpecialStudyCrystalRotationY() << G4endl;
-    CrystalMasterRotX.rotateX(aConfig ->getSpecialStudyCrystalRotationX());
-    CrystalMasterRotY.rotateY(aConfig ->getSpecialStudyCrystalRotationY());
+  G4int aSpecialStudyCrystalRotFlag = aConfig->getSpecialStudyCrystalRotation();
 
+  if (aSpecialStudyCrystalRotFlag != 1) {
+    // G4cout << "rotation " << -aConfig ->getSpecialStudyCrystalRotationY() << G4endl;
+    CrystalMasterRotX.rotateX(aConfig->getSpecialStudyCrystalRotationX());
+    CrystalMasterRotY.rotateY(aConfig->getSpecialStudyCrystalRotationY());
   }
 
-
   //
   // G4cout<<" Vessel XRot Yrot "<<RichTbVesselXRotation<<"   "
   //      <<RichTbVesselYRotation<<G4endl;
 
-  //G4Transform3D VesselUpsSubTransform(VesselUpsSubRot,VesselUpsSubPos);
-  G4Transform3D CrystalMasterTransform(  CrystalMasterRotX * CrystalMasterRotY, CrystalMasterPos);
+  // G4Transform3D VesselUpsSubTransform(VesselUpsSubRot,VesselUpsSubPos);
+  G4Transform3D CrystalMasterTransform(CrystalMasterRotX * CrystalMasterRotY, CrystalMasterPos);
 
   /* G4SubtractionSolid* VesselUpsSub =
       new G4SubtractionSolid("VesselUpsSub",  RichTbVesselBoxOverall ,
                              RichTbVesselUpsSubBox,VesselUpsSubTransform);
 
   */
-    G4LogicalVolume* CrystalMasterLog;
-
-
-    //crystal material
-     CrystalMasterLog =
-       new G4LogicalVolume(RichTbCrystalMasterBox,
-                           aMaterial->getNitrogenGas(), "CrystalMasterLog",0,0,0);
-
-     //crystal location
-     G4VPhysicalVolume* CrystalMasterPhys =
-       new G4PVPlacement(CrystalMasterTransform, CrystalMasterPhysName, CrystalMasterLog ,
-                         aRTbVessel->getRichTbGasVesselPVol(),
-                         false,0);
+  G4LogicalVolume *CrystalMasterLog;
 
-     RichTbUpgradeCrystalMasterLVol =  CrystalMasterLog;
-     RichTbUpgradeCrystalMasterPVol =  CrystalMasterPhys;
+  // crystal material
+  CrystalMasterLog =
+      new G4LogicalVolume(RichTbCrystalMasterBox, aMaterial->getNitrogenGas(), "CrystalMasterLog", 0, 0, 0);
 
+  // crystal location
+  G4VPhysicalVolume *CrystalMasterPhys = new G4PVPlacement(
+      CrystalMasterTransform, CrystalMasterPhysName, CrystalMasterLog, aRTbVessel->getRichTbGasVesselPVol(), false, 0);
 
+  RichTbUpgradeCrystalMasterLVol = CrystalMasterLog;
+  RichTbUpgradeCrystalMasterPVol = CrystalMasterPhys;
 }
-void RichTbUpgradeCrystalMaster::constructRichTbUpgradeCrystalMasterEnvelope()
-{
-
-}
-
+void RichTbUpgradeCrystalMaster::constructRichTbUpgradeCrystalMasterEnvelope() {}
 
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeDarkCover.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeDarkCover.cc
index bbac8a21f653e09025210e1ca77c987d34d38eb4..a009bbf19c5a7ef6709bed47073d2eec125e9c33 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeDarkCover.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeDarkCover.cc
@@ -1,27 +1,25 @@
 // $Id: $
 // Include files
 
-
-
 // local
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMiscNames.hh"
-#include "RichTbMaterial.hh"
-#include "RichTbUpgradeVessel.hh"
 #include "RichTbUpgradeDarkCover.hh"
-#include "RichTbUpgradeCrystalMaster.hh"
-#include "RichTbHall.hh"
-#include "Geant4/G4RotationMatrix.hh"
-#include "Geant4/G4ThreeVector.hh"
-#include "Geant4/G4Transform3D.hh"
-#include "Geant4/G4SubtractionSolid.hh"
 #include "Geant4/G4Box.hh"
 #include "Geant4/G4LogicalVolume.hh"
-#include "Geant4/G4VPhysicalVolume.hh"
 #include "Geant4/G4PVPlacement.hh"
-#include "RichTbRunConfig.hh"
+#include "Geant4/G4RotationMatrix.hh"
 #include "Geant4/G4Sphere.hh"
+#include "Geant4/G4SubtractionSolid.hh"
+#include "Geant4/G4ThreeVector.hh"
+#include "Geant4/G4Transform3D.hh"
 #include "Geant4/G4Tubs.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbHall.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMiscNames.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbUpgradeCrystalMaster.hh"
+#include "RichTbUpgradeVessel.hh"
 
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbVessel
@@ -33,276 +31,216 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbUpgradeDarkCover::RichTbUpgradeDarkCover(RichTbUpgradeRadiator* arTbRadiator ) {
-
-	aRTbUpgradeRadiator = arTbRadiator;
+RichTbUpgradeDarkCover::RichTbUpgradeDarkCover(RichTbUpgradeRadiator *arTbRadiator) {
 
-	RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-	G4int aRadiatorConfiguration = aConfig ->getRadiatorConfiguration();
+  aRTbUpgradeRadiator = arTbRadiator;
 
-	if(aRadiatorConfiguration == 3) constructRichTbUpgradeDarkCover15();
-	else constructRichTbUpgradeDarkCover();
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int aRadiatorConfiguration = aConfig->getRadiatorConfiguration();
 
+  if (aRadiatorConfiguration == 3)
+    constructRichTbUpgradeDarkCover15();
+  else
+    constructRichTbUpgradeDarkCover();
 }
-RichTbUpgradeDarkCover::~RichTbUpgradeDarkCover(  )
-{
-}
-
-void RichTbUpgradeDarkCover::constructRichTbUpgradeDarkCover()
-{
-	RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-	//RichTbRunConfig* aConfig = RichTbRunConfig::getRunConfigInstance();
-
-	G4Box * RichTbUpgradeDarkCoverBox
-	= new G4Box("RichTbUpgradeDarkCoverBox", 0.5*RichTbUpgradeDarkCoverXSize,
-			0.5*RichTbUpgradeDarkCoverYSize, 0.5*RichTbUpgradeDarkCoverZSize);
-
-	G4ThreeVector DarkCoverPos(RichTbUpgradeDarkCoverXLocation,
-			RichTbUpgradeDarkCoverYLocation,
-			RichTbUpgradeDarkCoverZLocation);
-
-	G4RotationMatrix DarkCoverRotX, DarkCoverRotY;
-
-	G4Transform3D DarkCoverTransform(  DarkCoverRotX * DarkCoverRotY, DarkCoverPos);
+RichTbUpgradeDarkCover::~RichTbUpgradeDarkCover() {}
 
-	/* G4SubtractionSolid* VesselUpsSub =
-      new G4SubtractionSolid("VesselUpsSub",  RichTbVesselBoxOverall ,
-                             RichTbVesselUpsSubBox,VesselUpsSubTransform);
+void RichTbUpgradeDarkCover::constructRichTbUpgradeDarkCover() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  // RichTbRunConfig* aConfig = RichTbRunConfig::getRunConfigInstance();
 
-	 */
-	G4LogicalVolume* DarkCoverLog;
+  G4Box *RichTbUpgradeDarkCoverBox = new G4Box("RichTbUpgradeDarkCoverBox", 0.5 * RichTbUpgradeDarkCoverXSize,
+                                               0.5 * RichTbUpgradeDarkCoverYSize, 0.5 * RichTbUpgradeDarkCoverZSize);
 
+  G4ThreeVector DarkCoverPos(RichTbUpgradeDarkCoverXLocation, RichTbUpgradeDarkCoverYLocation,
+                             RichTbUpgradeDarkCoverZLocation);
 
+  G4RotationMatrix DarkCoverRotX, DarkCoverRotY;
 
-	DarkCoverLog =
-			new G4LogicalVolume(RichTbUpgradeDarkCoverBox,
-					aMaterial->getCarbon(), "DarkCoverLog",0,0,0);
+  G4Transform3D DarkCoverTransform(DarkCoverRotX * DarkCoverRotY, DarkCoverPos);
 
+  /* G4SubtractionSolid* VesselUpsSub =
+new G4SubtractionSolid("VesselUpsSub",  RichTbVesselBoxOverall ,
+                       RichTbVesselUpsSubBox,VesselUpsSubTransform);
 
-	G4VPhysicalVolume* DarkCoverPhys =
-			new G4PVPlacement(DarkCoverTransform, DarkCoverPhysName, DarkCoverLog ,
-					aRTbUpgradeRadiator->getRichTbUpgradeRadiatorPVol(),
-					false,0);
-
-	RichTbUpgradeDarkCoverLVol =  DarkCoverLog;
-	RichTbUpgradeDarkCoverPVol =  DarkCoverPhys;
+   */
+  G4LogicalVolume *DarkCoverLog;
 
+  DarkCoverLog = new G4LogicalVolume(RichTbUpgradeDarkCoverBox, aMaterial->getCarbon(), "DarkCoverLog", 0, 0, 0);
 
+  G4VPhysicalVolume *DarkCoverPhys = new G4PVPlacement(DarkCoverTransform, DarkCoverPhysName, DarkCoverLog,
+                                                       aRTbUpgradeRadiator->getRichTbUpgradeRadiatorPVol(), false, 0);
 
+  RichTbUpgradeDarkCoverLVol = DarkCoverLog;
+  RichTbUpgradeDarkCoverPVol = DarkCoverPhys;
 }
-void RichTbUpgradeDarkCover::constructRichTbUpgradeUpsDarkCoverEnvelope(RichTbUpgradeCrystalMaster* aMaster  )
-{
-	RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+void RichTbUpgradeDarkCover::constructRichTbUpgradeUpsDarkCoverEnvelope(RichTbUpgradeCrystalMaster *aMaster) {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
 
-	G4double DarkPhiStart = 0.0*CLHEP::rad;
-	G4double DarkPhiSize=2*CLHEP::pi* CLHEP::rad;
-	G4double DarkThetaStart = 0.0*CLHEP::rad;
-	G4double DarkThetaSize= CLHEP::pi/5*CLHEP::rad;
+  G4double DarkPhiStart = 0.0 * CLHEP::rad;
+  G4double DarkPhiSize = 2 * CLHEP::pi * CLHEP::rad;
+  G4double DarkThetaStart = 0.0 * CLHEP::rad;
+  G4double DarkThetaSize = CLHEP::pi / 5 * CLHEP::rad;
 
-	G4Sphere* UpsDarkFull =  new G4Sphere("MirrorFull", RichTbDarkUpsInnerRadius,
-			RichTbDarkUpsOuterRadius,DarkPhiStart ,
-			DarkPhiSize , DarkThetaStart,
-			DarkThetaSize);
+  G4Sphere *UpsDarkFull = new G4Sphere("MirrorFull", RichTbDarkUpsInnerRadius, RichTbDarkUpsOuterRadius, DarkPhiStart,
+                                       DarkPhiSize, DarkThetaStart, DarkThetaSize);
 
-	G4Box * BoxU
-	= new G4Box("DarkBoxSub", 0.5* MirrorSubBoxLargeXSize,
-			0.5* MirrorSubBoxLargeYSize , 0.5*MirrorSubBoxLargeZSize );
+  G4Box *BoxU =
+      new G4Box("DarkBoxSub", 0.5 * MirrorSubBoxLargeXSize, 0.5 * MirrorSubBoxLargeYSize, 0.5 * MirrorSubBoxLargeZSize);
 
-	G4RotationMatrix BoxTopRot, BoxBotRot;
-	G4ThreeVector Box2PosTop (0.0, MirrorSubBoxYPosTop,0.0);
-	G4ThreeVector Box2PosBot (0.0, MirrorSubBoxYPosBot,0.0);
-	G4Transform3D BoxTopTransform(BoxTopRot, Box2PosTop );
-	G4Transform3D BoxBotTransform(BoxBotRot, Box2PosBot );
+  G4RotationMatrix BoxTopRot, BoxBotRot;
+  G4ThreeVector Box2PosTop(0.0, MirrorSubBoxYPosTop, 0.0);
+  G4ThreeVector Box2PosBot(0.0, MirrorSubBoxYPosBot, 0.0);
+  G4Transform3D BoxTopTransform(BoxTopRot, Box2PosTop);
+  G4Transform3D BoxBotTransform(BoxBotRot, Box2PosBot);
 
+  G4SubtractionSolid *DarkHA = new G4SubtractionSolid("DarkHA", UpsDarkFull, BoxU, BoxTopTransform);
 
-	G4SubtractionSolid* DarkHA =
-			new G4SubtractionSolid("DarkHA",UpsDarkFull  ,
-					BoxU , BoxTopTransform );
+  G4SubtractionSolid *UpsDarkSphe = new G4SubtractionSolid("UpsDarkSphe", DarkHA, BoxU, BoxBotTransform);
 
-	G4SubtractionSolid* UpsDarkSphe =
-			new G4SubtractionSolid("UpsDarkSphe",DarkHA  ,
-					BoxU , BoxBotTransform );
+  G4RotationMatrix UpsDarkRotationX, UpsDarkRotationY;
+  UpsDarkRotationY.rotateY(180 * CLHEP::degree);
+  G4ThreeVector UpsDarkPos(MirrorPosX, MirrorPosY, MirrorPosZ);
 
-	G4RotationMatrix UpsDarkRotationX, UpsDarkRotationY;
-	UpsDarkRotationY.rotateY(180*CLHEP::degree);
-	G4ThreeVector UpsDarkPos ( MirrorPosX , MirrorPosY, MirrorPosZ);
+  G4Transform3D UpsDarkTransform(UpsDarkRotationX * UpsDarkRotationY, UpsDarkPos);
 
+  G4LogicalVolume *UpsDarkLog = new G4LogicalVolume(UpsDarkSphe, aMaterial->getCarbon(), "UpsDarkSpheLog", 0, 0, 0);
 
-	G4Transform3D UpsDarkTransform(  UpsDarkRotationX * UpsDarkRotationY, UpsDarkPos);
+  G4VPhysicalVolume *UpsDarkPhys = new G4PVPlacement(UpsDarkTransform, "UpsDarkSphePhys", UpsDarkLog,
+                                                     aMaster->getRichTbUpgradeCrystalMasterPVol(), false, 0);
 
-	G4LogicalVolume* UpsDarkLog =
-			new G4LogicalVolume( UpsDarkSphe,aMaterial->getCarbon(),
-					"UpsDarkSpheLog",0,0,0);
+  RichTbUpgradeUpsDarkCoverLVol = UpsDarkLog;
+  RichTbUpgradeUpsDarkCoverPVol = UpsDarkPhys;
+}
+void RichTbUpgradeDarkCover::constructRichTbUpgradeSideDarkCoverEnvelope(RichTbUpgradeCrystalMaster *aMasterC) {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+
+  G4Box *BoxT =
+      new G4Box("DarkBoxSide", 0.5 * RichTbDarkSideXSize, 0.5 * RichTbDarkSideYSize, 0.5 * RichTbDarkSideZSize);
+  G4RotationMatrix BoxTopRot, BoxBotRot;
+  G4ThreeVector BoxTPosTop(RichTbDarkSideXLocation, RichTbDarkSideYTopLocation, RichTbDarkSideZLocation);
+  G4ThreeVector BoxTPosBot(RichTbDarkSideXLocation, RichTbDarkSideYBotLocation, RichTbDarkSideZLocation);
+  G4Transform3D BoxTTopTransform(BoxTopRot, BoxTPosTop);
+  G4Transform3D BoxTBotTransform(BoxBotRot, BoxTPosBot);
+  G4LogicalVolume *SideDarkLog = new G4LogicalVolume(BoxT, aMaterial->getCarbon(), "SideDarkLog", 0, 0, 0);
+  G4VPhysicalVolume *SideDarkTopPhys = new G4PVPlacement(BoxTTopTransform, "SideDarkTopPhys", SideDarkLog,
+                                                         aMasterC->getRichTbUpgradeCrystalMasterPVol(), false, 0);
+  G4VPhysicalVolume *SideDarkBotPhys = new G4PVPlacement(BoxTBotTransform, "SideDarkBotPhys", SideDarkLog,
+                                                         aMasterC->getRichTbUpgradeCrystalMasterPVol(), false, 0);
+
+  RichTbUpgradeSideDarkCoverLVol = SideDarkLog;
+  RichTbUpgradeSideTopDarkCoverPVol = SideDarkTopPhys;
+  RichTbUpgradeSideBotDarkCoverPVol = SideDarkBotPhys;
+}
 
-	G4VPhysicalVolume* UpsDarkPhys=
-			new  G4PVPlacement( UpsDarkTransform, "UpsDarkSphePhys",
-					UpsDarkLog,aMaster->getRichTbUpgradeCrystalMasterPVol(),false,0);
+void RichTbUpgradeDarkCover::constructRichTbUpgradeDarkCover15() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  // RichTbRunConfig* aConfig = RichTbRunConfig::getRunConfigInstance();
 
+  //	G4Box * RichTbUpgradeDarkCoverBox = new G4Box("RichTbUpgradeDarkCoverBox",
+  //			0.5*RichTbUpgradeDarkCoverXSize15,
+  //			0.5*RichTbUpgradeDarkCoverYSize15,
+  //			0.5*RichTbUpgradeDarkCoverZSize15);
 
-	RichTbUpgradeUpsDarkCoverLVol =  UpsDarkLog;
-	RichTbUpgradeUpsDarkCoverPVol =  UpsDarkPhys;
+  G4Tubs *RichTbUpgradeDarkCoverSubTubs =
+      new G4Tubs("RichTbUpgradeDarkCoverCyl", cylDarkRmin, cylDarkRmax, cylDarkHalfLength, cylSPhi, cylDPhi);
 
+  G4ThreeVector DarkCoverPos(RichTbUpgradeDarkCoverXLocation15, RichTbUpgradeDarkCoverYLocation15,
+                             RichTbUpgradeDarkCoverZLocation15);
 
+  G4RotationMatrix DarkCoverRotX, DarkCoverRotY;
+  G4Transform3D DarkCoverTransform(DarkCoverRotX * DarkCoverRotY, DarkCoverPos);
 
+  /* G4SubtractionSolid* VesselUpsSub =
+new G4SubtractionSolid("VesselUpsSub",  RichTbVesselBoxOverall ,
+                       RichTbVesselUpsSubBox,VesselUpsSubTransform);
+   */
 
+  G4LogicalVolume *DarkCoverLog;
+  DarkCoverLog = new G4LogicalVolume(RichTbUpgradeDarkCoverSubTubs, aMaterial->getCarbon(), "DarkCoverLog", 0, 0, 0);
 
+  G4VPhysicalVolume *DarkCoverPhys = new G4PVPlacement(DarkCoverTransform, DarkCoverPhysName, DarkCoverLog,
+                                                       aRTbUpgradeRadiator->getRichTbUpgradeRadiatorPVol(), false, 0);
 
+  RichTbUpgradeDarkCoverLVol = DarkCoverLog;
+  RichTbUpgradeDarkCoverPVol = DarkCoverPhys;
 }
-void RichTbUpgradeDarkCover::constructRichTbUpgradeSideDarkCoverEnvelope(RichTbUpgradeCrystalMaster* aMasterC  )
-{
-	RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-
-	G4Box * BoxT
-	= new G4Box("DarkBoxSide", 0.5* RichTbDarkSideXSize ,
-			0.5* RichTbDarkSideYSize  , 0.5*RichTbDarkSideZSize  );
-	G4RotationMatrix BoxTopRot, BoxBotRot;
-	G4ThreeVector BoxTPosTop ( RichTbDarkSideXLocation,RichTbDarkSideYTopLocation ,RichTbDarkSideZLocation );
-	G4ThreeVector BoxTPosBot ( RichTbDarkSideXLocation,RichTbDarkSideYBotLocation ,RichTbDarkSideZLocation);
-	G4Transform3D BoxTTopTransform(BoxTopRot, BoxTPosTop );
-	G4Transform3D BoxTBotTransform(BoxBotRot, BoxTPosBot );
-	G4LogicalVolume* SideDarkLog =
-			new G4LogicalVolume( BoxT,aMaterial->getCarbon(),
-					"SideDarkLog",0,0,0);
-	G4VPhysicalVolume* SideDarkTopPhys=
-			new  G4PVPlacement( BoxTTopTransform, "SideDarkTopPhys",
-					SideDarkLog,aMasterC->getRichTbUpgradeCrystalMasterPVol(),false,0);
-	G4VPhysicalVolume* SideDarkBotPhys=
-			new  G4PVPlacement( BoxTBotTransform, "SideDarkBotPhys",
-					SideDarkLog,aMasterC->getRichTbUpgradeCrystalMasterPVol(),false,0);
-
-	RichTbUpgradeSideDarkCoverLVol =  SideDarkLog;
-	RichTbUpgradeSideTopDarkCoverPVol = SideDarkTopPhys;
-	RichTbUpgradeSideBotDarkCoverPVol = SideDarkBotPhys;
 
+void RichTbUpgradeDarkCover::constructRichTbUpgradeUpsDarkCoverEnvelope15(RichTbUpgradeCrystalMaster *aMaster) {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+
+  G4double DarkPhiStart = 0.0 * CLHEP::rad;
+  G4double DarkPhiSize = 2 * CLHEP::pi * CLHEP::rad;
+  G4double DarkThetaStart = 0.0 * CLHEP::rad;
+  G4double DarkThetaSize = CLHEP::pi / 5 * CLHEP::rad;
+
+  G4Sphere *UpsDarkFull = new G4Sphere("MirrorFull", RichTbDarkUpsInnerRadius15, RichTbDarkUpsOuterRadius15,
+                                       DarkPhiStart, DarkPhiSize, DarkThetaStart, DarkThetaSize);
+  //
+  //	G4Box * BoxU = new G4Box("DarkBoxSub", 0.5*MirrorSubBoxLargeXSize,
+  //			0.5*MirrorSubBoxLargeYSize, 0.5*MirrorSubBoxLargeZSize);
+  //
+  //	G4RotationMatrix BoxTopRot, BoxBotRot;
+  //	G4ThreeVector Box2PosTop (0.0, MirrorSubBoxYPosTop,0.0);
+  //	G4ThreeVector Box2PosBot (0.0, MirrorSubBoxYPosBot,0.0);
+  //	G4Transform3D BoxTopTransform(BoxTopRot, Box2PosTop);
+  //	G4Transform3D BoxBotTransform(BoxBotRot, Box2PosBot);
+  //
+  //	G4SubtractionSolid* DarkHA = new G4SubtractionSolid("DarkHA",UpsDarkFull,
+  //			BoxU, BoxTopTransform);
+  //
+  //	G4SubtractionSolid* UpsDarkSphe = new G4SubtractionSolid("UpsDarkSphe",DarkHA,
+  //			BoxU, BoxBotTransform);
+
+  G4RotationMatrix UpsDarkRotationX, UpsDarkRotationY;
+  UpsDarkRotationY.rotateY(180 * CLHEP::degree);
+  G4ThreeVector UpsDarkPos(MirrorPosX15, MirrorPosY15, MirrorPosZ15);
+
+  G4Transform3D UpsDarkTransform(UpsDarkRotationX * UpsDarkRotationY, UpsDarkPos);
+
+  //	G4LogicalVolume* UpsDarkLog = new G4LogicalVolume(UpsDarkSphe,aMaterial->getCarbon(),
+  //					"UpsDarkSpheLog",0,0,0);
+  G4LogicalVolume *UpsDarkLog = new G4LogicalVolume(UpsDarkFull, aMaterial->getCarbon(), "UpsDarkSpheLog", 0, 0, 0);
+
+  G4VPhysicalVolume *UpsDarkPhys = new G4PVPlacement(UpsDarkTransform, "UpsDarkSphePhys", UpsDarkLog,
+                                                     aMaster->getRichTbUpgradeCrystalMasterPVol(), false, 0);
+
+  RichTbUpgradeUpsDarkCoverLVol = UpsDarkLog;
+  RichTbUpgradeUpsDarkCoverPVol = UpsDarkPhys;
 }
 
-void RichTbUpgradeDarkCover::constructRichTbUpgradeDarkCover15()
-{
-	RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-	//RichTbRunConfig* aConfig = RichTbRunConfig::getRunConfigInstance();
-
-//	G4Box * RichTbUpgradeDarkCoverBox = new G4Box("RichTbUpgradeDarkCoverBox",
-//			0.5*RichTbUpgradeDarkCoverXSize15,
-//			0.5*RichTbUpgradeDarkCoverYSize15,
-//			0.5*RichTbUpgradeDarkCoverZSize15);
-
-	G4Tubs * RichTbUpgradeDarkCoverSubTubs = new G4Tubs("RichTbUpgradeDarkCoverCyl", cylDarkRmin, cylDarkRmax, cylDarkHalfLength, cylSPhi, cylDPhi);
+void RichTbUpgradeDarkCover::constructRichTbUpgradeSideDarkCoverEnvelope15(RichTbUpgradeCrystalMaster *aMasterC) {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
 
+  G4Box *BoxOut =
+      new G4Box("BoxOut", 0.5 * RichTbDarkSideXSize15, 0.5 * RichTbDarkSideYSize15, 0.5 * RichTbDarkSideZSize15);
 
-	G4ThreeVector DarkCoverPos(RichTbUpgradeDarkCoverXLocation15,
-			RichTbUpgradeDarkCoverYLocation15,
-			RichTbUpgradeDarkCoverZLocation15);
+  G4Box *BoxInn = new G4Box("BoxInn", 0.5 * BoxInnXSize15, 0.5 * BoxInnYSize15, 0.5 * BoxInnZSize15);
 
-	G4RotationMatrix DarkCoverRotX,DarkCoverRotY;
-	G4Transform3D DarkCoverTransform(DarkCoverRotX * DarkCoverRotY, DarkCoverPos);
+  G4RotationMatrix BoxOutRot, BoxInnRot;
+  G4ThreeVector BoxTPosOut(RichTbDarkSideXLocation15, RichTbDarkSideYLocation15, RichTbDarkSideZLocation15);
+  //	G4ThreeVector BoxTPosInn(RichTbDarkSideXLocation15,RichTbDarkSideYLocation15,RichTbDarkSideZLocation15);
+  G4Transform3D BoxTOutTransform(BoxOutRot, BoxTPosOut);
+  //	G4Transform3D BoxTInnTransform(BoxInnRot, BoxTPosInn);
 
-	/* G4SubtractionSolid* VesselUpsSub =
-      new G4SubtractionSolid("VesselUpsSub",  RichTbVesselBoxOverall ,
-                             RichTbVesselUpsSubBox,VesselUpsSubTransform);
-	 */
+  G4SubtractionSolid *DarkBox = new G4SubtractionSolid("DarkBox", BoxOut, BoxInn);
 
-	G4LogicalVolume* DarkCoverLog;
-	DarkCoverLog = new G4LogicalVolume(RichTbUpgradeDarkCoverSubTubs,
-			aMaterial->getCarbon(), "DarkCoverLog",0,0,0);
+  G4LogicalVolume *SideDarkLog = new G4LogicalVolume(DarkBox, aMaterial->getCarbon(), "SideDarkLog", 0, 0, 0);
 
+  G4VPhysicalVolume *SideDarkPhys = new G4PVPlacement(BoxTOutTransform, "SideDarkTopPhys", SideDarkLog,
+                                                      aMasterC->getRichTbUpgradeCrystalMasterPVol(), false, 0);
 
-	G4VPhysicalVolume* DarkCoverPhys = new G4PVPlacement(DarkCoverTransform,
-			DarkCoverPhysName, DarkCoverLog ,
-			aRTbUpgradeRadiator->getRichTbUpgradeRadiatorPVol(),
-			false,0);
+  //	G4LogicalVolume* SideDarkLog = new G4LogicalVolume(BoxT,aMaterial->getCarbon(),
+  //			"SideDarkLog",0,0,0);
+  //	G4VPhysicalVolume* SideDarkTopPhys = new G4PVPlacement(BoxTTopTransform,"SideDarkTopPhys",
+  //			SideDarkLog,aMasterC->getRichTbUpgradeCrystalMasterPVol(),false,0);
+  //	G4VPhysicalVolume* SideDarkBotPhys=	new G4PVPlacement(BoxTBotTransform, "SideDarkBotPhys",
+  //			SideDarkLog,aMasterC->getRichTbUpgradeCrystalMasterPVol(),false,0);
 
-	RichTbUpgradeDarkCoverLVol =  DarkCoverLog;
-	RichTbUpgradeDarkCoverPVol =  DarkCoverPhys;
+  RichTbUpgradeSideDarkCoverLVol = SideDarkLog;
+  RichTbUpgradeSideTopDarkCoverPVol = SideDarkPhys;
+  //	RichTbUpgradeSideTopDarkCoverPVol = SideDarkTopPhys;
+  //	RichTbUpgradeSideBotDarkCoverPVol = SideDarkBotPhys;
 }
 
-void RichTbUpgradeDarkCover::constructRichTbUpgradeUpsDarkCoverEnvelope15(RichTbUpgradeCrystalMaster* aMaster)
-{
-	RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-
-	G4double DarkPhiStart = 0.0*CLHEP::rad;
-	G4double DarkPhiSize=2*CLHEP::pi* CLHEP::rad;
-	G4double DarkThetaStart = 0.0*CLHEP::rad;
-	G4double DarkThetaSize= CLHEP::pi/5*CLHEP::rad;
-
-	G4Sphere* UpsDarkFull =  new G4Sphere("MirrorFull", RichTbDarkUpsInnerRadius15,
-			RichTbDarkUpsOuterRadius15,DarkPhiStart,
-			DarkPhiSize, DarkThetaStart,
-			DarkThetaSize);
-	//
-	//	G4Box * BoxU = new G4Box("DarkBoxSub", 0.5*MirrorSubBoxLargeXSize,
-	//			0.5*MirrorSubBoxLargeYSize, 0.5*MirrorSubBoxLargeZSize);
-	//
-	//	G4RotationMatrix BoxTopRot, BoxBotRot;
-	//	G4ThreeVector Box2PosTop (0.0, MirrorSubBoxYPosTop,0.0);
-	//	G4ThreeVector Box2PosBot (0.0, MirrorSubBoxYPosBot,0.0);
-	//	G4Transform3D BoxTopTransform(BoxTopRot, Box2PosTop);
-	//	G4Transform3D BoxBotTransform(BoxBotRot, Box2PosBot);
-	//
-	//	G4SubtractionSolid* DarkHA = new G4SubtractionSolid("DarkHA",UpsDarkFull,
-	//			BoxU, BoxTopTransform);
-	//
-	//	G4SubtractionSolid* UpsDarkSphe = new G4SubtractionSolid("UpsDarkSphe",DarkHA,
-	//			BoxU, BoxBotTransform);
-
-	G4RotationMatrix UpsDarkRotationX, UpsDarkRotationY;
-	UpsDarkRotationY.rotateY(180*CLHEP::degree);
-	G4ThreeVector UpsDarkPos(MirrorPosX15, MirrorPosY15, MirrorPosZ15);
-
-	G4Transform3D UpsDarkTransform(UpsDarkRotationX * UpsDarkRotationY, UpsDarkPos);
-
-	//	G4LogicalVolume* UpsDarkLog = new G4LogicalVolume(UpsDarkSphe,aMaterial->getCarbon(),
-	//					"UpsDarkSpheLog",0,0,0);
-	G4LogicalVolume* UpsDarkLog = new G4LogicalVolume(UpsDarkFull,aMaterial->getCarbon(),
-			"UpsDarkSpheLog",0,0,0);
-
-	G4VPhysicalVolume* UpsDarkPhys= new  G4PVPlacement(UpsDarkTransform, "UpsDarkSphePhys",
-			UpsDarkLog,aMaster->getRichTbUpgradeCrystalMasterPVol(),false,0);
-
-
-	RichTbUpgradeUpsDarkCoverLVol =  UpsDarkLog;
-	RichTbUpgradeUpsDarkCoverPVol =  UpsDarkPhys;
-}
-
-void RichTbUpgradeDarkCover::constructRichTbUpgradeSideDarkCoverEnvelope15(RichTbUpgradeCrystalMaster* aMasterC)
-{
-	RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-
-	G4Box * BoxOut = new G4Box("BoxOut",
-			0.5 * RichTbDarkSideXSize15,
-			0.5 * RichTbDarkSideYSize15,
-			0.5 * RichTbDarkSideZSize15);
-
-	G4Box * BoxInn = new G4Box("BoxInn",
-			0.5 * BoxInnXSize15,
-			0.5 * BoxInnYSize15,
-			0.5 * BoxInnZSize15);
-
-	G4RotationMatrix BoxOutRot, BoxInnRot;
-	G4ThreeVector BoxTPosOut(RichTbDarkSideXLocation15,RichTbDarkSideYLocation15,RichTbDarkSideZLocation15);
-	//	G4ThreeVector BoxTPosInn(RichTbDarkSideXLocation15,RichTbDarkSideYLocation15,RichTbDarkSideZLocation15);
-	G4Transform3D BoxTOutTransform(BoxOutRot, BoxTPosOut);
-	//	G4Transform3D BoxTInnTransform(BoxInnRot, BoxTPosInn);
-
-	G4SubtractionSolid * DarkBox = new G4SubtractionSolid("DarkBox", BoxOut, BoxInn);
-
-	G4LogicalVolume* SideDarkLog = new G4LogicalVolume(DarkBox,aMaterial->getCarbon(),
-			"SideDarkLog",0,0,0);
-
-	G4VPhysicalVolume* SideDarkPhys = new G4PVPlacement(BoxTOutTransform,"SideDarkTopPhys",
-			SideDarkLog,aMasterC->getRichTbUpgradeCrystalMasterPVol(),false,0);
-
-//	G4LogicalVolume* SideDarkLog = new G4LogicalVolume(BoxT,aMaterial->getCarbon(),
-//			"SideDarkLog",0,0,0);
-//	G4VPhysicalVolume* SideDarkTopPhys = new G4PVPlacement(BoxTTopTransform,"SideDarkTopPhys",
-//			SideDarkLog,aMasterC->getRichTbUpgradeCrystalMasterPVol(),false,0);
-//	G4VPhysicalVolume* SideDarkBotPhys=	new G4PVPlacement(BoxTBotTransform, "SideDarkBotPhys",
-//			SideDarkLog,aMasterC->getRichTbUpgradeCrystalMasterPVol(),false,0);
-
-	RichTbUpgradeSideDarkCoverLVol =  SideDarkLog;
-	RichTbUpgradeSideTopDarkCoverPVol = SideDarkPhys;
-//	RichTbUpgradeSideTopDarkCoverPVol = SideDarkTopPhys;
-//	RichTbUpgradeSideBotDarkCoverPVol = SideDarkBotPhys;
-}
-
-
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeDetectorConstruction.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeDetectorConstruction.cc
index 2fa3e97a3f6e6904e5dcbf28121a60f380bcaa59..b9e978f5075a5095002b82e707084d977eda6ab7 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeDetectorConstruction.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeDetectorConstruction.cc
@@ -1,204 +1,185 @@
 // Geant4 headers
 #include "Geant4/G4Box.hh"
-#include "Geant4/G4ThreeVector.hh"
 #include "Geant4/G4LogicalVolume.hh"
-#include "Geant4/G4VPhysicalVolume.hh"
 #include "Geant4/G4PVPlacement.hh"
 #include "Geant4/G4SDManager.hh"
+#include "Geant4/G4ThreeVector.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
 
 // STL etc
 #include <iostream>
 
 // local headers
-#include "RichTbMiscNames.hh"
 #include "RichTbGeometryParameters.hh"
-#include "RichTbUpgradeDetectorConstruction.hh"
 #include "RichTbHall.hh"
+#include "RichTbMiscNames.hh"
+#include "RichTbUpgradeDetectorConstruction.hh"
 
-#include "RichTbSurfaceDefinition.hh"
 #include "RichTbSurface.hh"
+#include "RichTbSurfaceDefinition.hh"
 
-#include "RichTbUpgradeSD.hh"
 #include "RichTbUpgradeHpdSD.hh"
+#include "RichTbUpgradeSD.hh"
 
-RichTbDetectorConstruction::RichTbDetectorConstruction()
-{;
-}
-
-RichTbDetectorConstruction::~RichTbDetectorConstruction()
-{;
-}
-
-G4VPhysicalVolume *RichTbDetectorConstruction::Construct()
-{
-
-	// now create all the materials and surface properties.
-	// RichTbMaterial* rMaterial = RichTbMaterial::getRichTbMaterialInstance();
-	RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-	G4int aRadiatorConfiguration = aConfig ->getRadiatorConfiguration();
-
-	G4int CurNumPmts = NumPmtsOld;
-//	G4int CurNumPmts = RichTbPMTGeometryParameters::getNumPmts(); //TESTnumPmts
-	if (aRadiatorConfiguration == 2) CurNumPmts = NumPmtsWithHpd;
-	else if(aRadiatorConfiguration == 3) CurNumPmts = NumPmtsUpgrade15;
-//	else if(aRadiatorConfiguration == 3) CurNumPmts = RichTbPMTGeometryParameters::getNumPmtsUpgrade();//TESTnumPmts
-
-
-	RichTbSurfaceDefinition* rSurfaceDef=
-			RichTbSurfaceDefinition::getRichTbSurfaceDefinitionInstance();
-	if(rSurfaceDef) G4cout<<" RichTb Surface definitions created "<<G4endl;
-
-	InitializeRichTbGeometry();
-
-
-	rTbHall = new RichTbHall();
-
-	rTbVessel = new RichTbUpgradeVessel(rTbHall );
-
-	rTbCrystalMaster = new RichTbUpgradeCrystalMaster(rTbVessel );
-
-
-	if(aRadiatorConfiguration == 0){
-
-		rTbCrystal = new RichTbCrystal(rTbCrystalMaster );
-
-		rTbLens = new RichTbLens(rTbCrystalMaster );
-
-		rTbCrystalCover = new RichTbCrystalCover(rTbCrystalMaster );
-
-	} else{
-		//Radiator + Mirror + Cover
-		rTbUpgradeRadiator = new RichTbUpgradeRadiator(rTbCrystalMaster);
-		rTbUpgradeMirror = new RichTbUpgradeMirror(rTbCrystalMaster, rTbUpgradeRadiator);
-		// rTbMirror = RichTbUpgradeMirror::getRichTbUpgradeMirrorInstance( rTbVessel );
-		rTbUpgradeDarkCover = new RichTbUpgradeDarkCover(rTbUpgradeRadiator );
-
-		if(aRadiatorConfiguration == 3){
-			rTbUpgradeDarkCover->constructRichTbUpgradeUpsDarkCoverEnvelope15(rTbCrystalMaster);
-			rTbUpgradeDarkCover->constructRichTbUpgradeSideDarkCoverEnvelope15(rTbCrystalMaster);
-		} else {
-			rTbUpgradeDarkCover->constructRichTbUpgradeUpsDarkCoverEnvelope(rTbCrystalMaster);
-			rTbUpgradeDarkCover->constructRichTbUpgradeSideDarkCoverEnvelope(rTbCrystalMaster);
-		}
-
-		//Elementary Cells, PMT's and Support
-		rTbUpgradePhotSupFrame = new RichTbUpgradePhDetSupFrame(rTbCrystalMaster);
-		if(aRadiatorConfiguration == 1){
-			rTbUpgradePhotSupFrame->constructRichTbPhotoDetectorSupFrame();
-		}else if (aRadiatorConfiguration == 2) {
-			rTbUpgradePhotSupFrame->constructRichTbPhotoDetectorSupFrameWithHpd();
-		}else if(aRadiatorConfiguration == 3) {
-			rTbUpgradePhotSupFrame->constructRichTbPhotoDetectorSupFrame15();
-		}
-
-		rTbEC  = new RichTbUpgradeEC(rTbUpgradePhotSupFrame);
-
-		if(aRadiatorConfiguration == 1){
-			rTbEC->constructRichTbUpgradeEC();
-			rTbEC->constructRichTbUpgradeECSupport();
-		}else if(aRadiatorConfiguration == 2) {
-			rTbEC->constructRichTbUpgradeSingleEC();
-			rTbEC->constructRichTbUpgradeSingleECSupport ();
-		}else if(aRadiatorConfiguration == 3) {
-			rTbEC->constructRichTbUpgradeEC15();
-			rTbEC->constructRichTbUpgradeECSupport15();
-		}
-
-
-		rTbPMT = new RichTbPMT( rTbEC );
-		rTbPMT ->buildPMTGeometry();
-		if( aRadiatorConfiguration == 2 ) {
-			rTbHpd = new RichTbHpd(0, rTbUpgradePhotSupFrame);
-			rTbHpd -> buildHpdGeometry();
-		}
-	}
-
-	//now for the surfaces
+RichTbDetectorConstruction::RichTbDetectorConstruction() { ; }
 
-	rTbSurface = new  RichTbSurface(this);
+RichTbDetectorConstruction::~RichTbDetectorConstruction() { ; }
 
-	//sensitive detector creation for PMT
+G4VPhysicalVolume *RichTbDetectorConstruction::Construct() {
 
-	G4SDManager* SDman = G4SDManager::GetSDMpointer();
+  // now create all the materials and surface properties.
+  // RichTbMaterial* rMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int aRadiatorConfiguration = aConfig->getRadiatorConfiguration();
 
+  G4int CurNumPmts = NumPmtsOld;
+  //	G4int CurNumPmts = RichTbPMTGeometryParameters::getNumPmts(); //TESTnumPmts
+  if (aRadiatorConfiguration == 2)
+    CurNumPmts = NumPmtsWithHpd;
+  else if (aRadiatorConfiguration == 3)
+    CurNumPmts = NumPmtsUpgrade15;
+  //	else if(aRadiatorConfiguration == 3) CurNumPmts = RichTbPMTGeometryParameters::getNumPmtsUpgrade();//TESTnumPmts
 
-	RichTbUpgradeSD* PMTSD = new RichTbUpgradeSD( PMTSDname );
+  RichTbSurfaceDefinition *rSurfaceDef = RichTbSurfaceDefinition::getRichTbSurfaceDefinitionInstance();
+  if (rSurfaceDef)
+    G4cout << " RichTb Surface definitions created " << G4endl;
 
+  InitializeRichTbGeometry();
 
-	//sensitive detector creation for HPD
-	RichTbUpgradeHpdSD* HPDSD = (aRadiatorConfiguration == 2) ? new RichTbUpgradeHpdSD(HPDSDname):0;
+  rTbHall = new RichTbHall();
 
+  rTbVessel = new RichTbUpgradeVessel(rTbHall);
 
+  rTbCrystalMaster = new RichTbUpgradeCrystalMaster(rTbVessel);
 
-	// now for the readout Geometry.
+  if (aRadiatorConfiguration == 0) {
 
-	G4cout<< " Now for readout geometry in Pmt "<<G4endl;
+    rTbCrystal = new RichTbCrystal(rTbCrystalMaster);
 
-	rTbROGeom = new  RichTbROGeometry( ROgeometryName, this);
+    rTbLens = new RichTbLens(rTbCrystalMaster);
 
-	rTbROGeom -> BuildROGeometry();
-	PMTSD->SetROgeometry(rTbROGeom);
-	SDman->AddNewDetector( PMTSD );
-	G4cout<< " Now associate sensdet to  readout geometry in Pmt "<<G4endl;
-	//begin test
-	G4int HCID = G4SDManager::GetSDMpointer()->GetCollectionID (RichTbHColname);
-	G4cout<< " Now associate sensdet to  readout geometry in Pmt "<< HCID <<  G4endl;
-	// end test
-	//  Associate the anode of each pmt to the sensitive detector.
-	for(G4int ipmt=0; ipmt< CurNumPmts; ipmt++) {
+    rTbCrystalCover = new RichTbCrystalCover(rTbCrystalMaster);
 
-		G4LogicalVolume* RichTbPmtAnode_LV = rTbPMT->getRichTbPMTAnodeLVol()  [ipmt];
-		RichTbPmtAnode_LV ->SetSensitiveDetector( PMTSD );
-		G4cout<<"associate pmtsd to sensdet "<<RichTbPmtAnode_LV->GetName()<<"  "<<  ipmt<<G4endl;
+  } else {
+    // Radiator + Mirror + Cover
+    rTbUpgradeRadiator = new RichTbUpgradeRadiator(rTbCrystalMaster);
+    rTbUpgradeMirror = new RichTbUpgradeMirror(rTbCrystalMaster, rTbUpgradeRadiator);
+    // rTbMirror = RichTbUpgradeMirror::getRichTbUpgradeMirrorInstance( rTbVessel );
+    rTbUpgradeDarkCover = new RichTbUpgradeDarkCover(rTbUpgradeRadiator);
 
-	}
+    if (aRadiatorConfiguration == 3) {
+      rTbUpgradeDarkCover->constructRichTbUpgradeUpsDarkCoverEnvelope15(rTbCrystalMaster);
+      rTbUpgradeDarkCover->constructRichTbUpgradeSideDarkCoverEnvelope15(rTbCrystalMaster);
+    } else {
+      rTbUpgradeDarkCover->constructRichTbUpgradeUpsDarkCoverEnvelope(rTbCrystalMaster);
+      rTbUpgradeDarkCover->constructRichTbUpgradeSideDarkCoverEnvelope(rTbCrystalMaster);
+    }
 
-	// Now for the HPD sensitive detector
-	if( aRadiatorConfiguration == 2 ) {
-		if( HPDSD ) {
-			G4cout<< " Now for readout geometry in hpd "<<G4endl;
+    // Elementary Cells, PMT's and Support
+    rTbUpgradePhotSupFrame = new RichTbUpgradePhDetSupFrame(rTbCrystalMaster);
+    if (aRadiatorConfiguration == 1) {
+      rTbUpgradePhotSupFrame->constructRichTbPhotoDetectorSupFrame();
+    } else if (aRadiatorConfiguration == 2) {
+      rTbUpgradePhotSupFrame->constructRichTbPhotoDetectorSupFrameWithHpd();
+    } else if (aRadiatorConfiguration == 3) {
+      rTbUpgradePhotSupFrame->constructRichTbPhotoDetectorSupFrame15();
+    }
 
-			// now for the hpd readout
-			rTbROGeomHpd = new  RichTbROGeometryHpd( ROgeometryNameHpd, this);
-			rTbROGeomHpd -> BuildROGeometry();
+    rTbEC = new RichTbUpgradeEC(rTbUpgradePhotSupFrame);
 
-			HPDSD ->SetROgeometry( rTbROGeomHpd);
-			SDman->AddNewDetector( HPDSD );
+    if (aRadiatorConfiguration == 1) {
+      rTbEC->constructRichTbUpgradeEC();
+      rTbEC->constructRichTbUpgradeECSupport();
+    } else if (aRadiatorConfiguration == 2) {
+      rTbEC->constructRichTbUpgradeSingleEC();
+      rTbEC->constructRichTbUpgradeSingleECSupport();
+    } else if (aRadiatorConfiguration == 3) {
+      rTbEC->constructRichTbUpgradeEC15();
+      rTbEC->constructRichTbUpgradeECSupport15();
+    }
 
-			G4cout<<"associate hpdsd to sensdet " << G4endl;
-			//begin test
-			G4int numberOfCollections = HPDSD->GetNumberOfCollections();
-			G4cout<<"hpdsd test   "<< numberOfCollections<<"  "
-					<< HPDSD ->GetName() <<"  "<< HPDSD->GetCollectionName(0) <<G4endl;
+    rTbPMT = new RichTbPMT(rTbEC);
+    rTbPMT->buildPMTGeometry();
+    if (aRadiatorConfiguration == 2) {
+      rTbHpd = new RichTbHpd(0, rTbUpgradePhotSupFrame);
+      rTbHpd->buildHpdGeometry();
+    }
+  }
 
+  // now for the surfaces
 
+  rTbSurface = new RichTbSurface(this);
 
-			G4int HCIDHA = G4SDManager::GetSDMpointer()->GetCollectionID (RichTbHColnameHpd);
+  // sensitive detector creation for PMT
 
-			G4cout<< "associated hpdsd to sensdet A  "<< HCIDHA <<  G4endl;
-			// end test
+  G4SDManager *SDman = G4SDManager::GetSDMpointer();
 
-			G4LogicalVolume*  RichTbHpdAnode_LV =  rTbHpd ->getRichTbHpdSiDetLVol();
-			RichTbHpdAnode_LV -> SetSensitiveDetector( HPDSD );
-			G4cout<<"associated hpdsd to sensdet "<<RichTbHpdAnode_LV->GetName()<<"  "<<G4endl;
+  RichTbUpgradeSD *PMTSD = new RichTbUpgradeSD(PMTSDname);
 
-			//begin test
-			G4int HCIDH = G4SDManager::GetSDMpointer()->GetCollectionID (RichTbHColnameHpd);
+  // sensitive detector creation for HPD
+  RichTbUpgradeHpdSD *HPDSD = (aRadiatorConfiguration == 2) ? new RichTbUpgradeHpdSD(HPDSDname) : 0;
 
-			G4cout<< "associated hpdsd to sensdet  "<< HCIDH <<  G4endl;
-			// end test
+  // now for the readout Geometry.
 
+  G4cout << " Now for readout geometry in Pmt " << G4endl;
 
-		}
+  rTbROGeom = new RichTbROGeometry(ROgeometryName, this);
 
+  rTbROGeom->BuildROGeometry();
+  PMTSD->SetROgeometry(rTbROGeom);
+  SDman->AddNewDetector(PMTSD);
+  G4cout << " Now associate sensdet to  readout geometry in Pmt " << G4endl;
+  // begin test
+  G4int HCID = G4SDManager::GetSDMpointer()->GetCollectionID(RichTbHColname);
+  G4cout << " Now associate sensdet to  readout geometry in Pmt " << HCID << G4endl;
+  // end test
+  //  Associate the anode of each pmt to the sensitive detector.
+  for (G4int ipmt = 0; ipmt < CurNumPmts; ipmt++) {
 
-	}
+    G4LogicalVolume *RichTbPmtAnode_LV = rTbPMT->getRichTbPMTAnodeLVol()[ipmt];
+    RichTbPmtAnode_LV->SetSensitiveDetector(PMTSD);
+    G4cout << "associate pmtsd to sensdet " << RichTbPmtAnode_LV->GetName() << "  " << ipmt << G4endl;
+  }
 
+  // Now for the HPD sensitive detector
+  if (aRadiatorConfiguration == 2) {
+    if (HPDSD) {
+      G4cout << " Now for readout geometry in hpd " << G4endl;
 
-	// Now for the graphics setups.
-	RichTbGraphics* rTbGraphics = new RichTbGraphics(this);
-	if( rTbGraphics) G4cout<<" Graphics definitions created "<<G4endl;
+      // now for the hpd readout
+      rTbROGeomHpd = new RichTbROGeometryHpd(ROgeometryNameHpd, this);
+      rTbROGeomHpd->BuildROGeometry();
 
+      HPDSD->SetROgeometry(rTbROGeomHpd);
+      SDman->AddNewDetector(HPDSD);
+
+      G4cout << "associate hpdsd to sensdet " << G4endl;
+      // begin test
+      G4int numberOfCollections = HPDSD->GetNumberOfCollections();
+      G4cout << "hpdsd test   " << numberOfCollections << "  " << HPDSD->GetName() << "  "
+             << HPDSD->GetCollectionName(0) << G4endl;
+
+      G4int HCIDHA = G4SDManager::GetSDMpointer()->GetCollectionID(RichTbHColnameHpd);
+
+      G4cout << "associated hpdsd to sensdet A  " << HCIDHA << G4endl;
+      // end test
+
+      G4LogicalVolume *RichTbHpdAnode_LV = rTbHpd->getRichTbHpdSiDetLVol();
+      RichTbHpdAnode_LV->SetSensitiveDetector(HPDSD);
+      G4cout << "associated hpdsd to sensdet " << RichTbHpdAnode_LV->GetName() << "  " << G4endl;
+
+      // begin test
+      G4int HCIDH = G4SDManager::GetSDMpointer()->GetCollectionID(RichTbHColnameHpd);
+
+      G4cout << "associated hpdsd to sensdet  " << HCIDH << G4endl;
+      // end test
+    }
+  }
+
+  // Now for the graphics setups.
+  RichTbGraphics *rTbGraphics = new RichTbGraphics(this);
+  if (rTbGraphics)
+    G4cout << " Graphics definitions created " << G4endl;
 
-	return rTbHall->getRichTbHallPhysicalVolume();
+  return rTbHall->getRichTbHallPhysicalVolume();
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeEC.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeEC.cc
index e24645e437568055b5387b865623db378fb3d726..7ec4de7b9be37a12e0dced7c1f2bbd4a3518b517 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeEC.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeEC.cc
@@ -1,18 +1,16 @@
 // Include files
 
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMiscNames.hh"
-#include "RichTbMaterial.hh"
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4PVPlacement.hh"
 #include "Geant4/G4RotationMatrix.hh"
+#include "Geant4/G4SubtractionSolid.hh"
 #include "Geant4/G4ThreeVector.hh"
 #include "Geant4/G4Transform3D.hh"
-#include "Geant4/G4SubtractionSolid.hh"
-#include "Geant4/G4Box.hh"
-#include "Geant4/G4PVPlacement.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMiscNames.hh"
 #include "RichTbRunConfig.hh"
 
-
-
 // local
 #include "RichTbUpgradeEC.hh"
 
@@ -26,13 +24,11 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbUpgradeEC::RichTbUpgradeEC(RichTbUpgradePhDetSupFrame * rTbPhotSupFrame   ) {
-
-   aRTbPhotSupFrame = rTbPhotSupFrame ;
-   // constructRichTbUpgradeEC ();
-   // constructRichTbUpgradeECSupport ();
-
+RichTbUpgradeEC::RichTbUpgradeEC(RichTbUpgradePhDetSupFrame *rTbPhotSupFrame) {
 
+  aRTbPhotSupFrame = rTbPhotSupFrame;
+  // constructRichTbUpgradeEC ();
+  // constructRichTbUpgradeECSupport ();
 }
 //=============================================================================
 // Destructor
@@ -40,166 +36,149 @@ RichTbUpgradeEC::RichTbUpgradeEC(RichTbUpgradePhDetSupFrame * rTbPhotSupFrame
 RichTbUpgradeEC::~RichTbUpgradeEC() {}
 
 //=============================================================================
-void RichTbUpgradeEC::constructRichTbUpgradeEC () {
-   RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-   G4Box * ECBox = new G4Box("ECBox", 0.5*ECXSize,0.5*ECYSize, 0.5*ECZSize);
-   G4RotationMatrix ECBoxRotX, ECBoxRotY;
-   G4ThreeVector ECPosLeft(ECXLocation ,ECYLocation ,ECZLocation);
-   G4ThreeVector ECPosRight(ECXLocation ,ECYLocation ,ECZLocation);
-   G4Transform3D ECTransformLeft( ECBoxRotX*ECBoxRotY, ECPosLeft);
-   G4Transform3D ECTransformRight( ECBoxRotX*ECBoxRotY, ECPosRight);
-
-   G4LogicalVolume*  ECLogLeft = new G4LogicalVolume( ECBox, aMaterial->getNitrogenGas(),
-                                                      "ECLeftLog", 0,0,0);
-   G4LogicalVolume*  ECLogRight = new G4LogicalVolume( ECBox, aMaterial->getNitrogenGas(),
-                                                      "ECRightLog", 0,0,0);
-   G4VPhysicalVolume* ECPhysLeft = new G4PVPlacement(ECTransformLeft, "ECLeftPhys",
-                                                     ECLogLeft, aRTbPhotSupFrame->getRichTbPhDetSupFrameLeftPVol(),false,0);
-
-   G4VPhysicalVolume* ECPhysRight = new G4PVPlacement(ECTransformRight, "ECRightPhys",
-                                                     ECLogRight, aRTbPhotSupFrame->getRichTbPhDetSupFrameRightPVol(),false,1);
-
-
-   RichTbECLeftLVol  =   ECLogLeft;
-   RichTbECRightLVol =   ECLogRight;
-   RichTbECLeftPVol  =   ECPhysLeft;
-   RichTbECRightPVol =  ECPhysRight;
-
+void RichTbUpgradeEC::constructRichTbUpgradeEC() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  G4Box *ECBox = new G4Box("ECBox", 0.5 * ECXSize, 0.5 * ECYSize, 0.5 * ECZSize);
+  G4RotationMatrix ECBoxRotX, ECBoxRotY;
+  G4ThreeVector ECPosLeft(ECXLocation, ECYLocation, ECZLocation);
+  G4ThreeVector ECPosRight(ECXLocation, ECYLocation, ECZLocation);
+  G4Transform3D ECTransformLeft(ECBoxRotX * ECBoxRotY, ECPosLeft);
+  G4Transform3D ECTransformRight(ECBoxRotX * ECBoxRotY, ECPosRight);
+
+  G4LogicalVolume *ECLogLeft = new G4LogicalVolume(ECBox, aMaterial->getNitrogenGas(), "ECLeftLog", 0, 0, 0);
+  G4LogicalVolume *ECLogRight = new G4LogicalVolume(ECBox, aMaterial->getNitrogenGas(), "ECRightLog", 0, 0, 0);
+  G4VPhysicalVolume *ECPhysLeft = new G4PVPlacement(ECTransformLeft, "ECLeftPhys", ECLogLeft,
+                                                    aRTbPhotSupFrame->getRichTbPhDetSupFrameLeftPVol(), false, 0);
+
+  G4VPhysicalVolume *ECPhysRight = new G4PVPlacement(ECTransformRight, "ECRightPhys", ECLogRight,
+                                                     aRTbPhotSupFrame->getRichTbPhDetSupFrameRightPVol(), false, 1);
+
+  RichTbECLeftLVol = ECLogLeft;
+  RichTbECRightLVol = ECLogRight;
+  RichTbECLeftPVol = ECPhysLeft;
+  RichTbECRightPVol = ECPhysRight;
 }
-void RichTbUpgradeEC::constructRichTbUpgradeECSupport () {
-
-   RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-   G4Box * ECSupBox = new G4Box("ECBox", 0.5*ECSupportXSize,0.5*ECSupportYSize, 0.5*ECSupportZSize);
-
-   G4ThreeVector ECSupPos(ECXLocation ,ECYLocation , ECSupportZLocation);
+void RichTbUpgradeEC::constructRichTbUpgradeECSupport() {
 
-   G4RotationMatrix ECSupportBoxRot;
-   G4Transform3D ECSupTransform( ECSupportBoxRot, ECSupPos);
-   G4LogicalVolume*  ECSupLog  = new G4LogicalVolume( ECSupBox, aMaterial->getCarbon(),
-                                                      "ECSupLog", 0,0,0);
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  G4Box *ECSupBox = new G4Box("ECBox", 0.5 * ECSupportXSize, 0.5 * ECSupportYSize, 0.5 * ECSupportZSize);
 
-   G4VPhysicalVolume* ECSupPhysLeft = new G4PVPlacement(ECSupTransform, "ECSupLeftPhys",
-                                                     ECSupLog, aRTbPhotSupFrame->getRichTbPhDetSupFrameLeftPVol(),false,0);
+  G4ThreeVector ECSupPos(ECXLocation, ECYLocation, ECSupportZLocation);
 
-   G4VPhysicalVolume* ECSupPhysRight = new G4PVPlacement(ECSupTransform, "ECSupRightPhys",
-                                                     ECSupLog, aRTbPhotSupFrame->getRichTbPhDetSupFrameRightPVol(),false,0);
+  G4RotationMatrix ECSupportBoxRot;
+  G4Transform3D ECSupTransform(ECSupportBoxRot, ECSupPos);
+  G4LogicalVolume *ECSupLog = new G4LogicalVolume(ECSupBox, aMaterial->getCarbon(), "ECSupLog", 0, 0, 0);
 
-   RichTbECSupLVol      =  ECSupLog ;
-   RichTbECSupLeftPVol  =  ECSupPhysLeft;
-   RichTbECSupRightPVol =  ECSupPhysRight;
+  G4VPhysicalVolume *ECSupPhysLeft = new G4PVPlacement(ECSupTransform, "ECSupLeftPhys", ECSupLog,
+                                                       aRTbPhotSupFrame->getRichTbPhDetSupFrameLeftPVol(), false, 0);
 
+  G4VPhysicalVolume *ECSupPhysRight = new G4PVPlacement(ECSupTransform, "ECSupRightPhys", ECSupLog,
+                                                        aRTbPhotSupFrame->getRichTbPhDetSupFrameRightPVol(), false, 0);
 
+  RichTbECSupLVol = ECSupLog;
+  RichTbECSupLeftPVol = ECSupPhysLeft;
+  RichTbECSupRightPVol = ECSupPhysRight;
 }
-void RichTbUpgradeEC::constructRichTbUpgradeSingleEC () {
-   RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-   G4Box * ECBox = new G4Box("ECBox", 0.5*ECXSize,0.5*ECYSize, 0.5*ECZSize);
-   G4RotationMatrix ECBoxRotX, ECBoxRotY;
-   G4ThreeVector ECPosLeft(ECXLocation ,ECYLocation ,ECZLocation);
-   G4Transform3D ECTransformLeft( ECBoxRotX*ECBoxRotY, ECPosLeft);
-
-   G4LogicalVolume*  ECLogLeft = new G4LogicalVolume( ECBox, aMaterial->getNitrogenGas(),
-                                                      "ECLeftLog", 0,0,0);
-   G4VPhysicalVolume* ECPhysLeft = new G4PVPlacement(ECTransformLeft, "ECLeftPhys",
-                                                     ECLogLeft, aRTbPhotSupFrame->getRichTbPhDetSupFrameLeftPVol(),false,0);
-
-
-
-   RichTbECLeftLVol  =   ECLogLeft;
-   RichTbECLeftPVol  =   ECPhysLeft;
-
+void RichTbUpgradeEC::constructRichTbUpgradeSingleEC() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  G4Box *ECBox = new G4Box("ECBox", 0.5 * ECXSize, 0.5 * ECYSize, 0.5 * ECZSize);
+  G4RotationMatrix ECBoxRotX, ECBoxRotY;
+  G4ThreeVector ECPosLeft(ECXLocation, ECYLocation, ECZLocation);
+  G4Transform3D ECTransformLeft(ECBoxRotX * ECBoxRotY, ECPosLeft);
+
+  G4LogicalVolume *ECLogLeft = new G4LogicalVolume(ECBox, aMaterial->getNitrogenGas(), "ECLeftLog", 0, 0, 0);
+  G4VPhysicalVolume *ECPhysLeft = new G4PVPlacement(ECTransformLeft, "ECLeftPhys", ECLogLeft,
+                                                    aRTbPhotSupFrame->getRichTbPhDetSupFrameLeftPVol(), false, 0);
+
+  RichTbECLeftLVol = ECLogLeft;
+  RichTbECLeftPVol = ECPhysLeft;
 }
-void RichTbUpgradeEC::constructRichTbUpgradeSingleECSupport () {
-
-   RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-   G4Box * ECSupBox = new G4Box("ECBox", 0.5*ECSupportXSize,0.5*ECSupportYSize, 0.5*ECSupportZSize);
-
-   G4ThreeVector ECSupPos(ECXLocation ,ECYLocation , ECSupportZLocation);
+void RichTbUpgradeEC::constructRichTbUpgradeSingleECSupport() {
 
-   G4RotationMatrix ECSupportBoxRot;
-   G4Transform3D ECSupTransform( ECSupportBoxRot, ECSupPos);
-   G4LogicalVolume*  ECSupLog  = new G4LogicalVolume( ECSupBox, aMaterial->getCarbon(),
-                                                      "ECSupLog", 0,0,0);
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  G4Box *ECSupBox = new G4Box("ECBox", 0.5 * ECSupportXSize, 0.5 * ECSupportYSize, 0.5 * ECSupportZSize);
 
-   G4VPhysicalVolume* ECSupPhysLeft = new G4PVPlacement(ECSupTransform, "ECSupLeftPhys",
-                                                     ECSupLog, aRTbPhotSupFrame->getRichTbPhDetSupFrameLeftPVol(),false,0);
-
-
-   RichTbECSupLVol      =  ECSupLog ;
-   RichTbECSupLeftPVol  =  ECSupPhysLeft;
+  G4ThreeVector ECSupPos(ECXLocation, ECYLocation, ECSupportZLocation);
 
+  G4RotationMatrix ECSupportBoxRot;
+  G4Transform3D ECSupTransform(ECSupportBoxRot, ECSupPos);
+  G4LogicalVolume *ECSupLog = new G4LogicalVolume(ECSupBox, aMaterial->getCarbon(), "ECSupLog", 0, 0, 0);
 
+  G4VPhysicalVolume *ECSupPhysLeft = new G4PVPlacement(ECSupTransform, "ECSupLeftPhys", ECSupLog,
+                                                       aRTbPhotSupFrame->getRichTbPhDetSupFrameLeftPVol(), false, 0);
 
+  RichTbECSupLVol = ECSupLog;
+  RichTbECSupLeftPVol = ECSupPhysLeft;
 }
 void RichTbUpgradeEC::constructRichTbUpgradeEC15() {
-   RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-   G4Box * ECBox = new G4Box("ECBox", 0.5*ECXSize,0.5*ECYSize, 0.5*ECZSize);
-   G4RotationMatrix ECBoxRotX, ECBoxRotY;
-   G4ThreeVector ECPosLeft(ECXLocation15,ECYLocation15,ECZLocation15);
-   G4ThreeVector ECPosRight(ECXLocation15,ECYLocation15,ECZLocation15);
-   G4ThreeVector ECPosBottomLeft(ECXLocation15,ECYLocation15,ECZLocation15);
-   G4ThreeVector ECPosBottomRight(ECXLocation15,ECYLocation15,ECZLocation15);
-   G4Transform3D ECTransformLeft(ECBoxRotX*ECBoxRotY,ECPosLeft);
-   G4Transform3D ECTransformRight(ECBoxRotX*ECBoxRotY,ECPosRight);
-   G4Transform3D ECTransformBottomLeft(ECBoxRotX*ECBoxRotY,ECPosBottomLeft);
-   G4Transform3D ECTransformBottomRight(ECBoxRotX*ECBoxRotY,ECPosBottomRight);
-
-   G4LogicalVolume*  ECLogLeft = new G4LogicalVolume( ECBox, aMaterial->getNitrogenGas(),
-                                                      "ECLeftLog", 0,0,0);
-   G4LogicalVolume*  ECLogRight = new G4LogicalVolume( ECBox, aMaterial->getNitrogenGas(),
-                                                      "ECRightLog", 0,0,0);
-   G4LogicalVolume*  ECLogBottomLeft = new G4LogicalVolume(ECBox, aMaterial->getNitrogenGas(),
-                                                      "ECBottomLeftLog", 0,0,0);
-   G4LogicalVolume*  ECLogBottomRight = new G4LogicalVolume(ECBox, aMaterial->getNitrogenGas(),
-                                                      "ECBottomRightLog", 0,0,0);
-
-   G4VPhysicalVolume* ECPhysLeft = new G4PVPlacement(ECTransformLeft, "ECLeftPhys",
-                                                     ECLogLeft, aRTbPhotSupFrame->getRichTbPhDetSupFrameLeftPVol(),false,0);
-   G4VPhysicalVolume* ECPhysRight = new G4PVPlacement(ECTransformRight, "ECRightPhys",
-                                                     ECLogRight, aRTbPhotSupFrame->getRichTbPhDetSupFrameRightPVol(),false,1);
-   G4VPhysicalVolume* ECPhysBottomLeft = new G4PVPlacement(ECTransformBottomLeft, "ECBottomLeftPhys",
-                                                     ECLogBottomLeft, aRTbPhotSupFrame->getRichTbPhDetSupFrameBottomLeftPVol(),false,2);
-   G4VPhysicalVolume* ECPhysBottomRight = new G4PVPlacement(ECTransformBottomRight, "ECRBottomightPhys",
-                                                     ECLogBottomRight, aRTbPhotSupFrame->getRichTbPhDetSupFrameBottomRightPVol(),false,3);
-
-
-   RichTbECLeftLVol  = ECLogLeft;
-   RichTbECRightLVol = ECLogRight;
-   RichTbECBottomLeftLVol  = ECLogBottomLeft;
-   RichTbECBottomRightLVol = ECLogBottomRight;
-
-   RichTbECLeftPVol  = ECPhysLeft;
-   RichTbECRightPVol = ECPhysRight;
-   RichTbECBottomLeftPVol  = ECPhysBottomLeft;
-   RichTbECBottomRightPVol = ECPhysBottomRight;
-
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  G4Box *ECBox = new G4Box("ECBox", 0.5 * ECXSize, 0.5 * ECYSize, 0.5 * ECZSize);
+  G4RotationMatrix ECBoxRotX, ECBoxRotY;
+  G4ThreeVector ECPosLeft(ECXLocation15, ECYLocation15, ECZLocation15);
+  G4ThreeVector ECPosRight(ECXLocation15, ECYLocation15, ECZLocation15);
+  G4ThreeVector ECPosBottomLeft(ECXLocation15, ECYLocation15, ECZLocation15);
+  G4ThreeVector ECPosBottomRight(ECXLocation15, ECYLocation15, ECZLocation15);
+  G4Transform3D ECTransformLeft(ECBoxRotX * ECBoxRotY, ECPosLeft);
+  G4Transform3D ECTransformRight(ECBoxRotX * ECBoxRotY, ECPosRight);
+  G4Transform3D ECTransformBottomLeft(ECBoxRotX * ECBoxRotY, ECPosBottomLeft);
+  G4Transform3D ECTransformBottomRight(ECBoxRotX * ECBoxRotY, ECPosBottomRight);
+
+  G4LogicalVolume *ECLogLeft = new G4LogicalVolume(ECBox, aMaterial->getNitrogenGas(), "ECLeftLog", 0, 0, 0);
+  G4LogicalVolume *ECLogRight = new G4LogicalVolume(ECBox, aMaterial->getNitrogenGas(), "ECRightLog", 0, 0, 0);
+  G4LogicalVolume *ECLogBottomLeft =
+      new G4LogicalVolume(ECBox, aMaterial->getNitrogenGas(), "ECBottomLeftLog", 0, 0, 0);
+  G4LogicalVolume *ECLogBottomRight =
+      new G4LogicalVolume(ECBox, aMaterial->getNitrogenGas(), "ECBottomRightLog", 0, 0, 0);
+
+  G4VPhysicalVolume *ECPhysLeft = new G4PVPlacement(ECTransformLeft, "ECLeftPhys", ECLogLeft,
+                                                    aRTbPhotSupFrame->getRichTbPhDetSupFrameLeftPVol(), false, 0);
+  G4VPhysicalVolume *ECPhysRight = new G4PVPlacement(ECTransformRight, "ECRightPhys", ECLogRight,
+                                                     aRTbPhotSupFrame->getRichTbPhDetSupFrameRightPVol(), false, 1);
+  G4VPhysicalVolume *ECPhysBottomLeft =
+      new G4PVPlacement(ECTransformBottomLeft, "ECBottomLeftPhys", ECLogBottomLeft,
+                        aRTbPhotSupFrame->getRichTbPhDetSupFrameBottomLeftPVol(), false, 2);
+  G4VPhysicalVolume *ECPhysBottomRight =
+      new G4PVPlacement(ECTransformBottomRight, "ECRBottomightPhys", ECLogBottomRight,
+                        aRTbPhotSupFrame->getRichTbPhDetSupFrameBottomRightPVol(), false, 3);
+
+  RichTbECLeftLVol = ECLogLeft;
+  RichTbECRightLVol = ECLogRight;
+  RichTbECBottomLeftLVol = ECLogBottomLeft;
+  RichTbECBottomRightLVol = ECLogBottomRight;
+
+  RichTbECLeftPVol = ECPhysLeft;
+  RichTbECRightPVol = ECPhysRight;
+  RichTbECBottomLeftPVol = ECPhysBottomLeft;
+  RichTbECBottomRightPVol = ECPhysBottomRight;
 }
 void RichTbUpgradeEC::constructRichTbUpgradeECSupport15() {
 
-   RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-   G4Box * ECSupBox = new G4Box("ECBox", 0.5*ECSupportXSize,0.5*ECSupportYSize, 0.5*ECSupportZSize);
-
-   G4ThreeVector ECSupPos(ECSupportXLocation15 ,ECSupportYLocation15 , ECSupportZLocation15);
-   G4ThreeVector ECSupPosBottom(ECSupportXLocation15 ,ECSupportYLocation15 , ECSupportZLocation15);
-
-   G4RotationMatrix ECSupportBoxRot;
-   G4Transform3D ECSupTransform( ECSupportBoxRot, ECSupPos);
-   G4Transform3D ECSupTransformBottom( ECSupportBoxRot, ECSupPos);
-   G4LogicalVolume*  ECSupLog  = new G4LogicalVolume( ECSupBox, aMaterial->getCarbon(),
-                                                      "ECSupLog", 0,0,0);
-
-   G4VPhysicalVolume* ECSupPhysLeft = new G4PVPlacement(ECSupTransform, "ECSupLeftPhys",
-                                                     ECSupLog, aRTbPhotSupFrame->getRichTbPhDetSupFrameLeftPVol(),false,0);
-   G4VPhysicalVolume* ECSupPhysRight = new G4PVPlacement(ECSupTransform, "ECSupRightPhys",
-                                                     ECSupLog, aRTbPhotSupFrame->getRichTbPhDetSupFrameRightPVol(),false,1);
-
-   G4VPhysicalVolume* ECSupPhysBottomLeft = new G4PVPlacement(ECSupTransformBottom, "ECSupBottomLeftPhys",
-                                                     ECSupLog, aRTbPhotSupFrame->getRichTbPhDetSupFrameBottomLeftPVol(),false,2);
-   G4VPhysicalVolume* ECSupPhysBottomRight = new G4PVPlacement(ECSupTransformBottom, "ECSupBottomRightPhys",
-                                                     ECSupLog, aRTbPhotSupFrame->getRichTbPhDetSupFrameBottomRightPVol(),false,3);
-
-   RichTbECSupLVol      =  ECSupLog ;
-   RichTbECSupLeftPVol  =  ECSupPhysLeft;
-   RichTbECSupRightPVol =  ECSupPhysRight;
-   RichTbECSupBottomLeftPVol  =  ECSupPhysBottomLeft;
-   RichTbECSupBottomRightPVol =  ECSupPhysBottomRight;
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  G4Box *ECSupBox = new G4Box("ECBox", 0.5 * ECSupportXSize, 0.5 * ECSupportYSize, 0.5 * ECSupportZSize);
+
+  G4ThreeVector ECSupPos(ECSupportXLocation15, ECSupportYLocation15, ECSupportZLocation15);
+  G4ThreeVector ECSupPosBottom(ECSupportXLocation15, ECSupportYLocation15, ECSupportZLocation15);
+
+  G4RotationMatrix ECSupportBoxRot;
+  G4Transform3D ECSupTransform(ECSupportBoxRot, ECSupPos);
+  G4Transform3D ECSupTransformBottom(ECSupportBoxRot, ECSupPos);
+  G4LogicalVolume *ECSupLog = new G4LogicalVolume(ECSupBox, aMaterial->getCarbon(), "ECSupLog", 0, 0, 0);
+
+  G4VPhysicalVolume *ECSupPhysLeft = new G4PVPlacement(ECSupTransform, "ECSupLeftPhys", ECSupLog,
+                                                       aRTbPhotSupFrame->getRichTbPhDetSupFrameLeftPVol(), false, 0);
+  G4VPhysicalVolume *ECSupPhysRight = new G4PVPlacement(ECSupTransform, "ECSupRightPhys", ECSupLog,
+                                                        aRTbPhotSupFrame->getRichTbPhDetSupFrameRightPVol(), false, 1);
+
+  G4VPhysicalVolume *ECSupPhysBottomLeft =
+      new G4PVPlacement(ECSupTransformBottom, "ECSupBottomLeftPhys", ECSupLog,
+                        aRTbPhotSupFrame->getRichTbPhDetSupFrameBottomLeftPVol(), false, 2);
+  G4VPhysicalVolume *ECSupPhysBottomRight =
+      new G4PVPlacement(ECSupTransformBottom, "ECSupBottomRightPhys", ECSupLog,
+                        aRTbPhotSupFrame->getRichTbPhDetSupFrameBottomRightPVol(), false, 3);
+
+  RichTbECSupLVol = ECSupLog;
+  RichTbECSupLeftPVol = ECSupPhysLeft;
+  RichTbECSupRightPVol = ECSupPhysRight;
+  RichTbECSupBottomLeftPVol = ECSupPhysBottomLeft;
+  RichTbECSupBottomRightPVol = ECSupPhysBottomRight;
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeLens.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeLens.cc
index dede1b25f69b80f621b73bab7ae2f629fef75465..631a38decf161f3df0cb496407ac280a0bb9d4a1 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeLens.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeLens.cc
@@ -1,25 +1,23 @@
 // $Id: $
 // Include files
 
-
-
 // local
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMiscNames.hh"
-#include "RichTbMaterial.hh"
-#include "RichTbUpgradeVessel.hh"
 #include "RichTbUpgradeLens.hh"
-#include "RichTbHall.hh"
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4Orb.hh"
+#include "Geant4/G4PVPlacement.hh"
 #include "Geant4/G4RotationMatrix.hh"
+#include "Geant4/G4SubtractionSolid.hh"
 #include "Geant4/G4ThreeVector.hh"
 #include "Geant4/G4Transform3D.hh"
-#include "Geant4/G4SubtractionSolid.hh"
-#include "Geant4/G4Box.hh"
-#include "Geant4/G4Orb.hh"
-#include "Geant4/G4LogicalVolume.hh"
 #include "Geant4/G4VPhysicalVolume.hh"
-#include "Geant4/G4PVPlacement.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbHall.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMiscNames.hh"
 #include "RichTbRunConfig.hh"
+#include "RichTbUpgradeVessel.hh"
 
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbVessel
@@ -31,63 +29,46 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbLens::RichTbLens(RichTbUpgradeCrystalMaster* rTbCrystalMaster ) {
+RichTbLens::RichTbLens(RichTbUpgradeCrystalMaster *rTbCrystalMaster) {
 
   aRTbCrystalMaster = rTbCrystalMaster;
 
   constructRichTbLens();
-
 }
-RichTbLens::~RichTbLens(  )
-{
-}
-void RichTbLens::constructRichTbLens()
-{
-  RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+RichTbLens::~RichTbLens() {}
+void RichTbLens::constructRichTbLens() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
   // RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
 
+  G4Orb *Sph1 = new G4Orb("Sph1", SphRadius1);
 
-  G4Orb * Sph1 = new G4Orb("Sph1", SphRadius1);
-
-  G4Orb * Sph2 = new G4Orb("Sph2", SphRadius2);
+  G4Orb *Sph2 = new G4Orb("Sph2", SphRadius2);
 
   //   G4int aSpecialStudyCrystalRotFlag =
   //    aConfig ->getSpecialStudyCrystalRotation();
 
-
-
-
-
   G4double RichTbSph2XLocation, RichTbSph2YLocation, RichTbSph2ZLocation;
 
-  RichTbSph2XLocation = 0.0*CLHEP::mm;
-  RichTbSph2YLocation = 0.0*CLHEP::mm;
+  RichTbSph2XLocation = 0.0 * CLHEP::mm;
+  RichTbSph2YLocation = 0.0 * CLHEP::mm;
   RichTbSph2ZLocation = DistanceSph;
-  G4cout << "distance " << RichTbSph2ZLocation  << G4endl;
+  G4cout << "distance " << RichTbSph2ZLocation << G4endl;
 
-  G4ThreeVector Sph2Pos(RichTbSph2XLocation,
-                        RichTbSph2YLocation,
-                        RichTbSph2ZLocation);
+  G4ThreeVector Sph2Pos(RichTbSph2XLocation, RichTbSph2YLocation, RichTbSph2ZLocation);
 
   G4RotationMatrix Sph2RotX, Sph2RotY;
 
+  G4Transform3D Sph2Transform(Sph2RotX * Sph2RotY, Sph2Pos);
 
+  G4SubtractionSolid *A = new G4SubtractionSolid("A", Sph1, Sph2, Sph2Transform);
 
-  G4Transform3D Sph2Transform(Sph2RotX * Sph2RotY,Sph2Pos);
-
-  G4SubtractionSolid* A =
-      new G4SubtractionSolid("A", Sph1, Sph2, Sph2Transform);
-
-  G4ThreeVector APos( 0.0*CLHEP::mm,
-                      0.0*CLHEP::mm,
-                      0.0*CLHEP::mm);
+  G4ThreeVector APos(0.0 * CLHEP::mm, 0.0 * CLHEP::mm, 0.0 * CLHEP::mm);
 
   G4RotationMatrix ARotX, ARotY;
 
   G4Transform3D ATransform(ARotX * ARotY, APos);
 
-  G4SubtractionSolid* Lens =
-      new G4SubtractionSolid("Lens", Sph2, A, ATransform);
+  G4SubtractionSolid *Lens = new G4SubtractionSolid("Lens", Sph2, A, ATransform);
   /*
   G4Box* C = new G4Box("CBox", 0.5*CBoxXSize,
                 0.5*CBoxYSize, 0.5*CBoxZSize);
@@ -102,9 +83,7 @@ void RichTbLens::constructRichTbLens()
       new G4SubtractionSolid("Lens", B, C, ATransform);
   */
 
-  G4ThreeVector LensPos(RichTbLensXLocation,
-                          RichTbLensYLocation,
-                          RichTbLensZLocation);
+  G4ThreeVector LensPos(RichTbLensXLocation, RichTbLensYLocation, RichTbLensZLocation);
 
   G4RotationMatrix LensRotX, LensRotY;
   /*
@@ -117,32 +96,20 @@ void RichTbLens::constructRichTbLens()
 
   */
 
-  G4Transform3D LensTransform(  LensRotX * LensRotY, LensPos);
-
-
-  G4LogicalVolume* LensLog;
+  G4Transform3D LensTransform(LensRotX * LensRotY, LensPos);
 
+  G4LogicalVolume *LensLog;
 
-    //lens logical volume
-     LensLog =
-       new G4LogicalVolume(Lens,
-                           aMaterial->getPMTQuartzWindowMaterial(), "LensLog",0,0,0);
-
-     //lens physical volume
-     G4VPhysicalVolume* LensPhys =
-       new G4PVPlacement(LensTransform, LensPhysName, LensLog ,
-                         aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(),
-                         false,0);
-
-     RichTbLensLVol =  LensLog;
-     RichTbLensPVol =  LensPhys;
+  // lens logical volume
+  LensLog = new G4LogicalVolume(Lens, aMaterial->getPMTQuartzWindowMaterial(), "LensLog", 0, 0, 0);
 
+  // lens physical volume
+  G4VPhysicalVolume *LensPhys = new G4PVPlacement(LensTransform, LensPhysName, LensLog,
+                                                  aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(), false, 0);
 
+  RichTbLensLVol = LensLog;
+  RichTbLensPVol = LensPhys;
 }
-void RichTbLens::constructRichTbLensEnvelope()
-{
-
-}
-
+void RichTbLens::constructRichTbLensEnvelope() {}
 
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeMaster.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeMaster.cc
index ccb93ad3fc7cb1abe0c5267a11a3c3b7fcfde7f3..a7cd31b1aed66f5fa954679086617f67b8f0ef8a 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeMaster.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeMaster.cc
@@ -1,25 +1,23 @@
 // $Id: $
-// Include files 
-
-
+// Include files
 
 // local
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMiscNames.hh"
-#include "RichTbMaterial.hh"
-#include "RichTbUpgradeVessel.hh"
-#include "RichTbUpgradePhDFrame.hh"
 #include "RichTbUpgradeMaster.hh"
-#include "RichTbHall.hh"
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4PVPlacement.hh"
 #include "Geant4/G4RotationMatrix.hh"
+#include "Geant4/G4SubtractionSolid.hh"
 #include "Geant4/G4ThreeVector.hh"
 #include "Geant4/G4Transform3D.hh"
-#include "Geant4/G4SubtractionSolid.hh"
-#include "Geant4/G4Box.hh"
-#include "Geant4/G4LogicalVolume.hh"
 #include "Geant4/G4VPhysicalVolume.hh"
-#include "Geant4/G4PVPlacement.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbHall.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMiscNames.hh"
 #include "RichTbRunConfig.hh"
+#include "RichTbUpgradePhDFrame.hh"
+#include "RichTbUpgradeVessel.hh"
 
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbVessel
@@ -31,231 +29,160 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbMaster::RichTbMaster(RichTbPhDFrame* rTbPhDFrame, int MasterNum ) {
+RichTbMaster::RichTbMaster(RichTbPhDFrame *rTbPhDFrame, int MasterNum) {
 
   aMasterNum = MasterNum;
   aRTbPhDFrame = rTbPhDFrame;
 
-  if(aMasterNum == 1)
+  if (aMasterNum == 1)
     constructRichTbMaster1();
-  if(aMasterNum == 2)
+  if (aMasterNum == 2)
     constructRichTbMaster2();
-  if(aMasterNum == 3)
+  if (aMasterNum == 3)
     constructRichTbMaster3();
-  if(aMasterNum == 4)
+  if (aMasterNum == 4)
     constructRichTbMaster4();
 }
-RichTbMaster::~RichTbMaster(  )
-{
-}
-void RichTbMaster::constructRichTbMaster1()
-{
-  RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-  RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-  
-  G4Box * RichTbMasterBox 
-    = new G4Box("RichTbMasterBox", 0.5*RichTbMasterXSize,
-                0.5*RichTbMasterYSize, 0.5*RichTbMasterZSize);
-
-  G4ThreeVector MasterPos(RichTbMaster1XLocation,
-                          RichTbMaster1YLocation,
-                          RichTbMaster1ZLocation);
- 
-  G4RotationMatrix MasterRotX,MasterRotY;
-  
-
-   G4int aSpecialStudyMasterRotFlag =  
-      aConfig ->getSpecialStudyMasterRotation();
-
-  if( aSpecialStudyMasterRotFlag != 1 ) {
-    
-    MasterRotX.rotateX(aConfig ->getSpecialStudyMasterRotationX());
-    MasterRotY.rotateY(aConfig ->getSpecialStudyMasterRotationY());
+RichTbMaster::~RichTbMaster() {}
+void RichTbMaster::constructRichTbMaster1() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+
+  G4Box *RichTbMasterBox =
+      new G4Box("RichTbMasterBox", 0.5 * RichTbMasterXSize, 0.5 * RichTbMasterYSize, 0.5 * RichTbMasterZSize);
+
+  G4ThreeVector MasterPos(RichTbMaster1XLocation, RichTbMaster1YLocation, RichTbMaster1ZLocation);
+
+  G4RotationMatrix MasterRotX, MasterRotY;
+
+  G4int aSpecialStudyMasterRotFlag = aConfig->getSpecialStudyMasterRotation();
+
+  if (aSpecialStudyMasterRotFlag != 1) {
 
+    MasterRotX.rotateX(aConfig->getSpecialStudyMasterRotationX());
+    MasterRotY.rotateY(aConfig->getSpecialStudyMasterRotationY());
   }
 
-  
- 
-  G4Transform3D MasterTransform(  MasterRotX * MasterRotY, MasterPos);
-  
- 
-    G4LogicalVolume* MasterLog;
-    
-     
-    //master material
-     MasterLog = 
-       new G4LogicalVolume(RichTbMasterBox,
-                           aMaterial->getRichTbVaccum(), "MasterLog",0,0,0);
-
-     //master location  
-     G4VPhysicalVolume* MasterPhys =
-       new G4PVPlacement(MasterTransform, MasterPhysName, MasterLog ,
-                         aRTbPhDFrame->getRichTbPhDFramePVol(),
-                         false,0);
-     
-     RichTbMasterLVol = MasterLog;
-     RichTbMasterPVol = MasterPhys;
-     
+  G4Transform3D MasterTransform(MasterRotX * MasterRotY, MasterPos);
 
+  G4LogicalVolume *MasterLog;
+
+  // master material
+  MasterLog = new G4LogicalVolume(RichTbMasterBox, aMaterial->getRichTbVaccum(), "MasterLog", 0, 0, 0);
+
+  // master location
+  G4VPhysicalVolume *MasterPhys =
+      new G4PVPlacement(MasterTransform, MasterPhysName, MasterLog, aRTbPhDFrame->getRichTbPhDFramePVol(), false, 0);
+
+  RichTbMasterLVol = MasterLog;
+  RichTbMasterPVol = MasterPhys;
 }
 
-void RichTbMaster::constructRichTbMaster2()
-{
-  RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-  RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-  
-  G4Box * RichTbMasterBox 
-    = new G4Box("RichTbMasterBox", 0.5*RichTbMasterXSize,
-                0.5*RichTbMasterYSize, 0.5*RichTbMasterZSize);
-
-  G4ThreeVector MasterPos(RichTbMaster2XLocation,
-                          RichTbMaster2YLocation,
-                          RichTbMaster2ZLocation);
- 
-  G4RotationMatrix MasterRotX,MasterRotY;
-
-   G4int aSpecialStudyMasterRotFlag =  
-      aConfig ->getSpecialStudyMasterRotation();
-
-  if( aSpecialStudyMasterRotFlag != 1 ) {
-    
-    MasterRotX.rotateX(aConfig ->getSpecialStudyMasterRotationX());
-    MasterRotY.rotateY(aConfig ->getSpecialStudyMasterRotationY());
+void RichTbMaster::constructRichTbMaster2() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+
+  G4Box *RichTbMasterBox =
+      new G4Box("RichTbMasterBox", 0.5 * RichTbMasterXSize, 0.5 * RichTbMasterYSize, 0.5 * RichTbMasterZSize);
+
+  G4ThreeVector MasterPos(RichTbMaster2XLocation, RichTbMaster2YLocation, RichTbMaster2ZLocation);
+
+  G4RotationMatrix MasterRotX, MasterRotY;
+
+  G4int aSpecialStudyMasterRotFlag = aConfig->getSpecialStudyMasterRotation();
 
+  if (aSpecialStudyMasterRotFlag != 1) {
+
+    MasterRotX.rotateX(aConfig->getSpecialStudyMasterRotationX());
+    MasterRotY.rotateY(aConfig->getSpecialStudyMasterRotationY());
   }
 
-  
- 
-  G4Transform3D MasterTransform(  MasterRotX * MasterRotY, MasterPos);
-  
- 
-    G4LogicalVolume* MasterLog;
-    
-     
-    //master material
-     MasterLog = 
-       new G4LogicalVolume(RichTbMasterBox,
-                           aMaterial->getAir(), "MasterLog",0,0,0);
-
-     //master location  
-     G4VPhysicalVolume* MasterPhys =
-       new G4PVPlacement(MasterTransform, MasterPhysName, MasterLog ,
-                         aRTbPhDFrame->getRichTbPhDFramePVol(),
-                         false,0);
-     
-     RichTbMasterLVol = MasterLog;
-     RichTbMasterPVol = MasterPhys;
-     
+  G4Transform3D MasterTransform(MasterRotX * MasterRotY, MasterPos);
+
+  G4LogicalVolume *MasterLog;
+
+  // master material
+  MasterLog = new G4LogicalVolume(RichTbMasterBox, aMaterial->getAir(), "MasterLog", 0, 0, 0);
+
+  // master location
+  G4VPhysicalVolume *MasterPhys =
+      new G4PVPlacement(MasterTransform, MasterPhysName, MasterLog, aRTbPhDFrame->getRichTbPhDFramePVol(), false, 0);
 
+  RichTbMasterLVol = MasterLog;
+  RichTbMasterPVol = MasterPhys;
 }
 
-void RichTbMaster::constructRichTbMaster3()
-{
-  RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-  RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-  
-  G4Box * RichTbMasterBox 
-    = new G4Box("RichTbMasterBox", 0.5*RichTbMasterXSize,
-                0.5*RichTbMasterYSize, 0.5*RichTbMasterZSize);
-
-  G4ThreeVector MasterPos(RichTbMaster3XLocation,
-                          RichTbMaster3YLocation,
-                          RichTbMaster3ZLocation);
- 
-  G4RotationMatrix MasterRotX,MasterRotY;
- 
-   G4int aSpecialStudyMasterRotFlag =  
-      aConfig ->getSpecialStudyMasterRotation();
-
-  if( aSpecialStudyMasterRotFlag != 1 ) {
-    
-    MasterRotX.rotateX(aConfig ->getSpecialStudyMasterRotationX());
-    MasterRotY.rotateY(aConfig ->getSpecialStudyMasterRotationY());
+void RichTbMaster::constructRichTbMaster3() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+
+  G4Box *RichTbMasterBox =
+      new G4Box("RichTbMasterBox", 0.5 * RichTbMasterXSize, 0.5 * RichTbMasterYSize, 0.5 * RichTbMasterZSize);
+
+  G4ThreeVector MasterPos(RichTbMaster3XLocation, RichTbMaster3YLocation, RichTbMaster3ZLocation);
+
+  G4RotationMatrix MasterRotX, MasterRotY;
 
+  G4int aSpecialStudyMasterRotFlag = aConfig->getSpecialStudyMasterRotation();
+
+  if (aSpecialStudyMasterRotFlag != 1) {
+
+    MasterRotX.rotateX(aConfig->getSpecialStudyMasterRotationX());
+    MasterRotY.rotateY(aConfig->getSpecialStudyMasterRotationY());
   }
 
-  
- 
-  G4Transform3D MasterTransform(  MasterRotX * MasterRotY, MasterPos);
-  
- 
-    G4LogicalVolume* MasterLog;
-    
-     
-    //master material
-     MasterLog = 
-       new G4LogicalVolume(RichTbMasterBox,
-                           aMaterial->getAir(), "MasterLog",0,0,0);
-
-     //master location  
-     G4VPhysicalVolume* MasterPhys =
-       new G4PVPlacement(MasterTransform, MasterPhysName, MasterLog ,
-                         aRTbPhDFrame->getRichTbPhDFramePVol(),
-                         false,0);
-     
-     RichTbMasterLVol = MasterLog;
-     RichTbMasterPVol = MasterPhys;
-     
+  G4Transform3D MasterTransform(MasterRotX * MasterRotY, MasterPos);
+
+  G4LogicalVolume *MasterLog;
+
+  // master material
+  MasterLog = new G4LogicalVolume(RichTbMasterBox, aMaterial->getAir(), "MasterLog", 0, 0, 0);
 
+  // master location
+  G4VPhysicalVolume *MasterPhys =
+      new G4PVPlacement(MasterTransform, MasterPhysName, MasterLog, aRTbPhDFrame->getRichTbPhDFramePVol(), false, 0);
+
+  RichTbMasterLVol = MasterLog;
+  RichTbMasterPVol = MasterPhys;
 }
 
-void RichTbMaster::constructRichTbMaster4()
-{
-  RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-  RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-  
-  G4Box * RichTbMasterBox 
-    = new G4Box("RichTbMasterBox", 0.5*RichTbMasterXSize,
-                0.5*RichTbMasterYSize, 0.5*RichTbMasterZSize);
-
-  G4ThreeVector MasterPos(RichTbMaster4XLocation,
-                          RichTbMaster4YLocation,
-                          RichTbMaster4ZLocation);
- 
-  G4RotationMatrix MasterRotX,MasterRotY;
-
-   G4int aSpecialStudyMasterRotFlag =  
-      aConfig ->getSpecialStudyMasterRotation();
-
-  if( aSpecialStudyMasterRotFlag != 1 ) {
-    
-    MasterRotX.rotateX(aConfig ->getSpecialStudyMasterRotationX());
-    MasterRotY.rotateY(aConfig ->getSpecialStudyMasterRotationY());
+void RichTbMaster::constructRichTbMaster4() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+
+  G4Box *RichTbMasterBox =
+      new G4Box("RichTbMasterBox", 0.5 * RichTbMasterXSize, 0.5 * RichTbMasterYSize, 0.5 * RichTbMasterZSize);
+
+  G4ThreeVector MasterPos(RichTbMaster4XLocation, RichTbMaster4YLocation, RichTbMaster4ZLocation);
 
+  G4RotationMatrix MasterRotX, MasterRotY;
+
+  G4int aSpecialStudyMasterRotFlag = aConfig->getSpecialStudyMasterRotation();
+
+  if (aSpecialStudyMasterRotFlag != 1) {
+
+    MasterRotX.rotateX(aConfig->getSpecialStudyMasterRotationX());
+    MasterRotY.rotateY(aConfig->getSpecialStudyMasterRotationY());
   }
 
-  
- 
-  G4Transform3D MasterTransform(  MasterRotX * MasterRotY, MasterPos);
-  
- 
-    G4LogicalVolume* MasterLog;
-    
-     
-    //master material
-     MasterLog = 
-       new G4LogicalVolume(RichTbMasterBox,
-                           aMaterial->getAir(), "MasterLog",0,0,0);
-
-     //master location  
-     G4VPhysicalVolume* MasterPhys =
-       new G4PVPlacement(MasterTransform, MasterPhysName, MasterLog ,
-                         aRTbPhDFrame->getRichTbPhDFramePVol(),
-                         false,0);
-     
-     RichTbMasterLVol = MasterLog;
-     RichTbMasterPVol = MasterPhys;
-     
+  G4Transform3D MasterTransform(MasterRotX * MasterRotY, MasterPos);
 
-}
+  G4LogicalVolume *MasterLog;
 
+  // master material
+  MasterLog = new G4LogicalVolume(RichTbMasterBox, aMaterial->getAir(), "MasterLog", 0, 0, 0);
 
+  // master location
+  G4VPhysicalVolume *MasterPhys =
+      new G4PVPlacement(MasterTransform, MasterPhysName, MasterLog, aRTbPhDFrame->getRichTbPhDFramePVol(), false, 0);
 
+  RichTbMasterLVol = MasterLog;
+  RichTbMasterPVol = MasterPhys;
+}
 
-//void RichTbMaster::constructRichTbMasterEnvelope()
+// void RichTbMaster::constructRichTbMasterEnvelope()
 //{
-  
-//}
 
+//}
 
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeMirror.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeMirror.cc
index 1c7075572a116b485e0d56875d2f7071c587d471..4fc577ec24893e82206d77d221a80c1880087d98 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeMirror.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeMirror.cc
@@ -1,23 +1,23 @@
 // $Id: $
 // Include files
 
-#include "RichTbGeometryParameters.hh"
-#include "Geant4/globals.hh"
-#include "RichTbRunConfig.hh"
-#include "Geant4/G4Sphere.hh"
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4PVPlacement.hh"
 #include "Geant4/G4RotationMatrix.hh"
+#include "Geant4/G4Sphere.hh"
+#include "Geant4/G4SubtractionSolid.hh"
 #include "Geant4/G4ThreeVector.hh"
 #include "Geant4/G4Transform3D.hh"
-#include "Geant4/G4LogicalVolume.hh"
 #include "Geant4/G4VPhysicalVolume.hh"
-#include "Geant4/G4PVPlacement.hh"
-#include "Geant4/G4Box.hh"
-#include "Geant4/G4SubtractionSolid.hh"
+#include "Geant4/globals.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbRunConfig.hh"
 
 // local
-#include "RichTbUpgradeMirror.hh"
 #include "RichTbMaterial.hh"
 #include "RichTbMiscNames.hh"
+#include "RichTbUpgradeMirror.hh"
 
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbUpgradeMirror
@@ -28,94 +28,73 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-//RichTbUpgradeMirror* RichTbUpgradeMirror::RichTbUpgradeMirrorInstance=0;
+// RichTbUpgradeMirror* RichTbUpgradeMirror::RichTbUpgradeMirrorInstance=0;
 
-RichTbUpgradeMirror::RichTbUpgradeMirror( RichTbUpgradeCrystalMaster* aMaster, RichTbUpgradeRadiator* aRadiator) {
-	RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-	G4int aRadiatorConfiguration = aConfig ->getRadiatorConfiguration();
+RichTbUpgradeMirror::RichTbUpgradeMirror(RichTbUpgradeCrystalMaster *aMaster, RichTbUpgradeRadiator *aRadiator) {
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int aRadiatorConfiguration = aConfig->getRadiatorConfiguration();
 
-	if(aRadiatorConfiguration == 3) aRTbUpgradeRadiator = aRadiator;
-	else motherMaster =  aMaster;
+  if (aRadiatorConfiguration == 3)
+    aRTbUpgradeRadiator = aRadiator;
+  else
+    motherMaster = aMaster;
 
-	if(aRadiatorConfiguration == 3) constructRichTbUpgradeMirror15();
-	else constructRichTbUpgradeMirror();
-
-}
-RichTbUpgradeMirror::~RichTbUpgradeMirror(  ) {
+  if (aRadiatorConfiguration == 3)
+    constructRichTbUpgradeMirror15();
+  else
+    constructRichTbUpgradeMirror();
 }
-void RichTbUpgradeMirror::constructRichTbUpgradeMirror()
-{
-	//  RichTbRunConfig* RConfig = RichTbRunConfig::getRunConfigInstance();
-	RichTbMaterial* aMaterial =  RichTbMaterial::getRichTbMaterialInstance();
-	// G4int CurMirrorOrientationCode= RConfig -> getMirrorOrientCode();
-
-
-	// in the following theta is for the horizontal extent of the
-	// mirror and phi for the vertical extent of the mirror.
-
-	// G4double MirrThetaSize = pi/5*CLHEP::rad;
-
-	G4double MirrPhiSize  = 2*CLHEP::pi* CLHEP::rad;
-
-	// G4double MirrThetaStart = 0.0*CLHEP::rad;
-	G4double MirrThetaStart = MirrorMinThetaExtent;
-	G4double MirrThetaSize  = MirrorMaxThetaExtent-MirrorMinThetaExtent;
-
-
-	G4double MirrPhiStart = 0.0*CLHEP::rad;
-
-
-	G4Sphere* MirrorFull =  new G4Sphere("MirrorFull",MirrorInnerRadius,
-			MirrorOuterRadius,MirrPhiStart,
-			MirrPhiSize,MirrThetaStart,
-			MirrThetaSize);
-	G4Box * BoxS
-	= new G4Box("MirrBoxSub", 0.5* MirrorSubBoxLargeXSize,
-			0.5* MirrorSubBoxLargeYSize , 0.5*MirrorSubBoxLargeZSize );
+RichTbUpgradeMirror::~RichTbUpgradeMirror() {}
+void RichTbUpgradeMirror::constructRichTbUpgradeMirror() {
+  //  RichTbRunConfig* RConfig = RichTbRunConfig::getRunConfigInstance();
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  // G4int CurMirrorOrientationCode= RConfig -> getMirrorOrientCode();
 
+  // in the following theta is for the horizontal extent of the
+  // mirror and phi for the vertical extent of the mirror.
 
-	G4RotationMatrix BoxTopRot, BoxBotRot;
-	G4ThreeVector Box2PosTop (0.0, MirrorSubBoxYPosTop,0.0);
-	G4ThreeVector Box2PosBot (0.0, MirrorSubBoxYPosBot,0.0);
+  // G4double MirrThetaSize = pi/5*CLHEP::rad;
 
+  G4double MirrPhiSize = 2 * CLHEP::pi * CLHEP::rad;
 
-	G4Transform3D BoxTopTransform(BoxTopRot, Box2PosTop );
-	G4Transform3D BoxBotTransform(BoxBotRot, Box2PosBot );
+  // G4double MirrThetaStart = 0.0*CLHEP::rad;
+  G4double MirrThetaStart = MirrorMinThetaExtent;
+  G4double MirrThetaSize = MirrorMaxThetaExtent - MirrorMinThetaExtent;
 
+  G4double MirrPhiStart = 0.0 * CLHEP::rad;
 
-	G4SubtractionSolid* MirrorHA =
-			new G4SubtractionSolid("MirrorHA",MirrorFull  ,
-					BoxS , BoxTopTransform );
-	G4SubtractionSolid* MirrorSphe =
-			new G4SubtractionSolid("MirrorSphe",MirrorHA  ,
-					BoxS , BoxBotTransform );
+  G4Sphere *MirrorFull = new G4Sphere("MirrorFull", MirrorInnerRadius, MirrorOuterRadius, MirrPhiStart, MirrPhiSize,
+                                      MirrThetaStart, MirrThetaSize);
+  G4Box *BoxS =
+      new G4Box("MirrBoxSub", 0.5 * MirrorSubBoxLargeXSize, 0.5 * MirrorSubBoxLargeYSize, 0.5 * MirrorSubBoxLargeZSize);
 
+  G4RotationMatrix BoxTopRot, BoxBotRot;
+  G4ThreeVector Box2PosTop(0.0, MirrorSubBoxYPosTop, 0.0);
+  G4ThreeVector Box2PosBot(0.0, MirrorSubBoxYPosBot, 0.0);
 
-	G4RotationMatrix MirrorRotationX, MirrorRotationY;
-	MirrorRotationY.rotateY(180*CLHEP::degree);
+  G4Transform3D BoxTopTransform(BoxTopRot, Box2PosTop);
+  G4Transform3D BoxBotTransform(BoxBotRot, Box2PosBot);
 
-	G4ThreeVector MirrorPos ( MirrorPosX , MirrorPosY, MirrorPosZ);
+  G4SubtractionSolid *MirrorHA = new G4SubtractionSolid("MirrorHA", MirrorFull, BoxS, BoxTopTransform);
+  G4SubtractionSolid *MirrorSphe = new G4SubtractionSolid("MirrorSphe", MirrorHA, BoxS, BoxBotTransform);
 
-	G4Transform3D MirrorTransform(  MirrorRotationX * MirrorRotationY,
-			MirrorPos);
+  G4RotationMatrix MirrorRotationX, MirrorRotationY;
+  MirrorRotationY.rotateY(180 * CLHEP::degree);
 
-	G4LogicalVolume* MirrorLog =
-			new G4LogicalVolume( MirrorSphe,aMaterial->getMirrorQuartz(),
-					"MirrSpheLog",0,0,0);
+  G4ThreeVector MirrorPos(MirrorPosX, MirrorPosY, MirrorPosZ);
 
-	G4VPhysicalVolume* MirrorPhys=
-			new  G4PVPlacement( MirrorTransform, MirrorPhysName,
-					MirrorLog,
-					motherMaster->getRichTbUpgradeCrystalMasterPVol(),false,0);
+  G4Transform3D MirrorTransform(MirrorRotationX * MirrorRotationY, MirrorPos);
 
-	RichTbUpgradeMirrorLVol =  MirrorLog;
-	RichTbUpgradeMirrorPVol =   MirrorPhys;
+  G4LogicalVolume *MirrorLog = new G4LogicalVolume(MirrorSphe, aMaterial->getMirrorQuartz(), "MirrSpheLog", 0, 0, 0);
 
+  G4VPhysicalVolume *MirrorPhys = new G4PVPlacement(MirrorTransform, MirrorPhysName, MirrorLog,
+                                                    motherMaster->getRichTbUpgradeCrystalMasterPVol(), false, 0);
 
+  RichTbUpgradeMirrorLVol = MirrorLog;
+  RichTbUpgradeMirrorPVol = MirrorPhys;
 }
 
-
-//RichTbUpgradeMirror* RichTbUpgradeMirror::getRichTbUpgradeMirrorInstance()
+// RichTbUpgradeMirror* RichTbUpgradeMirror::getRichTbUpgradeMirrorInstance()
 //{
 //  if( RichTbUpgradeMirrorInstance == 0 ) {
 //    RichTbUpgradeMirrorInstance = new RichTbUpgradeMirror(RichTbCrystalMaster* aMaster  );
@@ -124,7 +103,6 @@ void RichTbUpgradeMirror::constructRichTbUpgradeMirror()
 //  return RichTbUpgradeMirrorInstance;
 //}
 
-
 /*
 RichTbUpgradeMirror* RichTbUpgradeMirror::getRichTbUpgradeMirrorInstance()
 {
@@ -137,71 +115,62 @@ RichTbUpgradeMirror* RichTbUpgradeMirror::getRichTbUpgradeMirrorInstance()
  */
 // END OF CHANGE
 
+void RichTbUpgradeMirror::constructRichTbUpgradeMirror15() {
+  //  RichTbRunConfig* RConfig = RichTbRunConfig::getRunConfigInstance();
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  // G4int CurMirrorOrientationCode= RConfig -> getMirrorOrientCode();
 
-void RichTbUpgradeMirror::constructRichTbUpgradeMirror15()
-{
-	//  RichTbRunConfig* RConfig = RichTbRunConfig::getRunConfigInstance();
-	RichTbMaterial* aMaterial =  RichTbMaterial::getRichTbMaterialInstance();
-	// G4int CurMirrorOrientationCode= RConfig -> getMirrorOrientCode();
-
-	// in the following theta is for the horizontal extent of the
-	// mirror and phi for the vertical extent of the mirror.
-
-	// G4double MirrThetaSize = pi/5*CLHEP::rad;
+  // in the following theta is for the horizontal extent of the
+  // mirror and phi for the vertical extent of the mirror.
 
-	G4double MirrPhiSize = 2*CLHEP::pi* CLHEP::rad;
+  // G4double MirrThetaSize = pi/5*CLHEP::rad;
 
-	// G4double MirrThetaStart = 0.0*CLHEP::rad;
-	G4double MirrThetaStart = MirrorMinThetaExtent15;
-	G4double MirrThetaSize = MirrorMaxThetaExtent15-MirrorMinThetaExtent15;
+  G4double MirrPhiSize = 2 * CLHEP::pi * CLHEP::rad;
 
-	G4double MirrPhiStart = 0.0*CLHEP::rad;
+  // G4double MirrThetaStart = 0.0*CLHEP::rad;
+  G4double MirrThetaStart = MirrorMinThetaExtent15;
+  G4double MirrThetaSize = MirrorMaxThetaExtent15 - MirrorMinThetaExtent15;
 
-	G4Sphere* MirrorFull =  new G4Sphere("MirrorFull",MirrorInnerRadius15,
-			MirrorOuterRadius15,MirrPhiStart,
-			MirrPhiSize,MirrThetaStart,
-			MirrThetaSize);
+  G4double MirrPhiStart = 0.0 * CLHEP::rad;
 
-//	G4Box * BoxS = new G4Box("MirrBoxSub", 0.5* MirrorSubBoxLargeXSize,
-//			0.5* MirrorSubBoxLargeYSize , 0.5*MirrorSubBoxLargeZSize );
-//
-//	G4RotationMatrix BoxTopRot, BoxBotRot;
-//	G4ThreeVector Box2PosTop(0.0,MirrorSubBoxYPosTop,0.0);
-//	G4ThreeVector Box2PosBot(0.0,MirrorSubBoxYPosBot,0.0);
-//
-//	G4Transform3D BoxTopTransform(BoxTopRot, Box2PosTop);
-//	G4Transform3D BoxBotTransform(BoxBotRot, Box2PosBot);
-//
-//	G4SubtractionSolid* MirrorHA = new G4SubtractionSolid("MirrorHA",MirrorFull,
-//			BoxS, BoxTopTransform);
-//
-//	G4SubtractionSolid* MirrorSphe = new G4SubtractionSolid("MirrorSphe",MirrorHA,
-//			BoxS, BoxBotTransform);
+  G4Sphere *MirrorFull = new G4Sphere("MirrorFull", MirrorInnerRadius15, MirrorOuterRadius15, MirrPhiStart, MirrPhiSize,
+                                      MirrThetaStart, MirrThetaSize);
 
-	G4RotationMatrix MirrorRotationX, MirrorRotationY;
-	MirrorRotationY.rotateY(180*CLHEP::degree);
+  //	G4Box * BoxS = new G4Box("MirrBoxSub", 0.5* MirrorSubBoxLargeXSize,
+  //			0.5* MirrorSubBoxLargeYSize , 0.5*MirrorSubBoxLargeZSize );
+  //
+  //	G4RotationMatrix BoxTopRot, BoxBotRot;
+  //	G4ThreeVector Box2PosTop(0.0,MirrorSubBoxYPosTop,0.0);
+  //	G4ThreeVector Box2PosBot(0.0,MirrorSubBoxYPosBot,0.0);
+  //
+  //	G4Transform3D BoxTopTransform(BoxTopRot, Box2PosTop);
+  //	G4Transform3D BoxBotTransform(BoxBotRot, Box2PosBot);
+  //
+  //	G4SubtractionSolid* MirrorHA = new G4SubtractionSolid("MirrorHA",MirrorFull,
+  //			BoxS, BoxTopTransform);
+  //
+  //	G4SubtractionSolid* MirrorSphe = new G4SubtractionSolid("MirrorSphe",MirrorHA,
+  //			BoxS, BoxBotTransform);
 
-	G4ThreeVector MirrorPos(MirrorPosX15, MirrorPosY15, MirrorVolPosZ15);
+  G4RotationMatrix MirrorRotationX, MirrorRotationY;
+  MirrorRotationY.rotateY(180 * CLHEP::degree);
 
-	G4Transform3D MirrorTransform(MirrorRotationX * MirrorRotationY,
-			MirrorPos);
+  G4ThreeVector MirrorPos(MirrorPosX15, MirrorPosY15, MirrorVolPosZ15);
 
-//	G4LogicalVolume* MirrorLog = new G4LogicalVolume(MirrorSphe,
-//			aMaterial->getMirrorQuartz(),
-//			"MirrSpheLog",0,0,0);
-	G4LogicalVolume* MirrorLog = new G4LogicalVolume(MirrorFull,
-			aMaterial->getMirrorQuartz(),
-			"MirrSpheLog",0,0,0);
+  G4Transform3D MirrorTransform(MirrorRotationX * MirrorRotationY, MirrorPos);
 
-	G4VPhysicalVolume* MirrorPhys= new G4PVPlacement(MirrorTransform,
-			MirrorPhysName,
-			MirrorLog,
-//			motherMaster->getRichTbUpgradeCrystalMasterPVol(),false,0);
-			aRTbUpgradeRadiator->getRichTbUpgradeRadiatorPVol(),false,0);
+  //	G4LogicalVolume* MirrorLog = new G4LogicalVolume(MirrorSphe,
+  //			aMaterial->getMirrorQuartz(),
+  //			"MirrSpheLog",0,0,0);
+  G4LogicalVolume *MirrorLog = new G4LogicalVolume(MirrorFull, aMaterial->getMirrorQuartz(), "MirrSpheLog", 0, 0, 0);
 
+  G4VPhysicalVolume *MirrorPhys =
+      new G4PVPlacement(MirrorTransform, MirrorPhysName, MirrorLog,
+                        //			motherMaster->getRichTbUpgradeCrystalMasterPVol(),false,0);
+                        aRTbUpgradeRadiator->getRichTbUpgradeRadiatorPVol(), false, 0);
 
-	RichTbUpgradeMirrorLVol = MirrorLog;
-	RichTbUpgradeMirrorPVol = MirrorPhys;
+  RichTbUpgradeMirrorLVol = MirrorLog;
+  RichTbUpgradeMirrorPVol = MirrorPhys;
 }
 
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradePhDFrame.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradePhDFrame.cc
index 6f213d6aa408560a26349f511ae6ad685076b665..aa4fa4d103804b3d8a40327f16e50d41bc5c76b5 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradePhDFrame.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradePhDFrame.cc
@@ -1,26 +1,24 @@
 // $Id: $
-// Include files 
-
-
+// Include files
 
 // local
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMiscNames.hh"
-#include "RichTbMaterial.hh"
-#include "RichTbUpgradeVessel.hh"
-#include "RichTbUpgradeCrystal.hh"
-#include "RichTbUpgradeCrystalMaster.hh"
 #include "RichTbUpgradePhDFrame.hh"
-#include "RichTbHall.hh"
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4PVPlacement.hh"
 #include "Geant4/G4RotationMatrix.hh"
+#include "Geant4/G4SubtractionSolid.hh"
 #include "Geant4/G4ThreeVector.hh"
 #include "Geant4/G4Transform3D.hh"
-#include "Geant4/G4SubtractionSolid.hh"
-#include "Geant4/G4Box.hh"
-#include "Geant4/G4LogicalVolume.hh"
 #include "Geant4/G4VPhysicalVolume.hh"
-#include "Geant4/G4PVPlacement.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbHall.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMiscNames.hh"
 #include "RichTbRunConfig.hh"
+#include "RichTbUpgradeCrystal.hh"
+#include "RichTbUpgradeCrystalMaster.hh"
+#include "RichTbUpgradeVessel.hh"
 
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbUpgradeVessel
@@ -32,37 +30,30 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbPhDFrame::RichTbPhDFrame(RichTbUpgradeCrystalMaster* rTbCrystalMaster ) {
+RichTbPhDFrame::RichTbPhDFrame(RichTbUpgradeCrystalMaster *rTbCrystalMaster) {
 
   aRTbCrystalMaster = rTbCrystalMaster;
-  
+
   constructRichTbPhDFrame();
-  
-}
-RichTbPhDFrame::~RichTbPhDFrame(  )
-{
 }
-void RichTbPhDFrame::constructRichTbPhDFrame()
-{
-  RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+RichTbPhDFrame::~RichTbPhDFrame() {}
+void RichTbPhDFrame::constructRichTbPhDFrame() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
   // RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-  
-  G4Box * RichTbPhDFrameBox 
-    = new G4Box("RichTbPhDFrameBox", 0.5*RichTbPhDFrameXSize,
-                0.5*RichTbPhDFrameYSize, 0.5*RichTbPhDFrameZSize);
-
-  G4ThreeVector PhDFramePos(RichTbPhDFrameXLocation,
-                          RichTbPhDFrameYLocation,
-                          RichTbPhDFrameZLocation);
- 
-  G4RotationMatrix PhDFrameRotX,PhDFrameRotY;
+
+  G4Box *RichTbPhDFrameBox =
+      new G4Box("RichTbPhDFrameBox", 0.5 * RichTbPhDFrameXSize, 0.5 * RichTbPhDFrameYSize, 0.5 * RichTbPhDFrameZSize);
+
+  G4ThreeVector PhDFramePos(RichTbPhDFrameXLocation, RichTbPhDFrameYLocation, RichTbPhDFrameZLocation);
+
+  G4RotationMatrix PhDFrameRotX, PhDFrameRotY;
   PhDFrameRotY.rotateY(RichTbPhDFrameYRotation);
   PhDFrameRotX.rotateX(RichTbPhDFrameXRotation);
-  /* G4int aSpeicalStudyVesselRotFlag =  
+  /* G4int aSpeicalStudyVesselRotFlag =
       aConfig ->getSpecialStudyVesselRotation();
 
   if( aSpeicalStudyVesselRotFlag != 1 ) {
-    
+
   VesselRotX.rotateX(RichTbUpgradeVesselXRotation);
   VesselRotY.rotateY(RichTbUpgradeVesselYRotation);
 
@@ -72,34 +63,23 @@ void RichTbPhDFrame::constructRichTbPhDFrame()
   //
   // G4cout<<" Vessel XRot Yrot "<<RichTbUpgradeVesselXRotation<<"   "
   //      <<RichTbUpgradeVesselYRotation<<G4endl;
-  
-  //G4Transform3D VesselUpsSubTransform(VesselUpsSubRot,VesselUpsSubPos);
-
-  G4Transform3D PhDFrameTransform(  PhDFrameRotX * PhDFrameRotY, PhDFramePos);
- 
-  G4LogicalVolume* PhDFrameLog;
-    
-     
-    //material
-     PhDFrameLog = 
-       new G4LogicalVolume(RichTbPhDFrameBox,
-                           aMaterial->getNitrogenGas(), "PhDFrameLog",0,0,0);
-
-     //position of the frame  
-     G4VPhysicalVolume* PhDFramePhys =
-       new G4PVPlacement(PhDFrameTransform, PhDFramePhysName, PhDFrameLog ,
-                         aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(),
-                         false,0);
-     
-     RichTbPhDFrameLVol =  PhDFrameLog;
-     RichTbPhDFramePVol =  PhDFramePhys;
-     
-
-} 
-void RichTbPhDFrame::constructRichTbPhDFrameEnvelope()
-{
-  
-}
 
+  // G4Transform3D VesselUpsSubTransform(VesselUpsSubRot,VesselUpsSubPos);
+
+  G4Transform3D PhDFrameTransform(PhDFrameRotX * PhDFrameRotY, PhDFramePos);
+
+  G4LogicalVolume *PhDFrameLog;
+
+  // material
+  PhDFrameLog = new G4LogicalVolume(RichTbPhDFrameBox, aMaterial->getNitrogenGas(), "PhDFrameLog", 0, 0, 0);
+
+  // position of the frame
+  G4VPhysicalVolume *PhDFramePhys = new G4PVPlacement(PhDFrameTransform, PhDFramePhysName, PhDFrameLog,
+                                                      aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(), false, 0);
+
+  RichTbPhDFrameLVol = PhDFrameLog;
+  RichTbPhDFramePVol = PhDFramePhys;
+}
+void RichTbPhDFrame::constructRichTbPhDFrameEnvelope() {}
 
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradePhDetSupFrame.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradePhDetSupFrame.cc
index 818f662f63fa95d961baa6d1042ac4fd123f5eb7..211f9f5e041cbeb6aad178d670ff08a507174aaa 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradePhDetSupFrame.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradePhDetSupFrame.cc
@@ -1,18 +1,16 @@
 // Include files
 
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMiscNames.hh"
-#include "RichTbMaterial.hh"
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4PVPlacement.hh"
 #include "Geant4/G4RotationMatrix.hh"
+#include "Geant4/G4SubtractionSolid.hh"
 #include "Geant4/G4ThreeVector.hh"
 #include "Geant4/G4Transform3D.hh"
-#include "Geant4/G4SubtractionSolid.hh"
-#include "Geant4/G4Box.hh"
-#include "Geant4/G4PVPlacement.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMiscNames.hh"
 #include "RichTbRunConfig.hh"
 
-
-
 // local
 #include "RichTbUpgradePhDetSupFrame.hh"
 
@@ -25,12 +23,10 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbUpgradePhDetSupFrame::RichTbUpgradePhDetSupFrame(RichTbUpgradeCrystalMaster * rTbCrysMaster   ) {
+RichTbUpgradePhDetSupFrame::RichTbUpgradePhDetSupFrame(RichTbUpgradeCrystalMaster *rTbCrysMaster) {
   aRTbCrystalMaster = rTbCrysMaster;
 
-
   // constructRichTbPhotoDetectorSupFrame();
-
 }
 //=============================================================================
 // Destructor
@@ -38,146 +34,132 @@ RichTbUpgradePhDetSupFrame::RichTbUpgradePhDetSupFrame(RichTbUpgradeCrystalMaste
 RichTbUpgradePhDetSupFrame::~RichTbUpgradePhDetSupFrame() {}
 
 //=============================================================================
-void RichTbUpgradePhDetSupFrame::constructRichTbPhotoDetectorSupFrame()
-{
-  RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+void RichTbUpgradePhDetSupFrame::constructRichTbPhotoDetectorSupFrame() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
   //  RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
 
-    G4Box * PhDetSupFrameBox
-       = new G4Box( "PhDetSupFrameBox",
-                    0.5*PhDetSupFrameXSize,0.5*PhDetSupFrameYSize,0.5*PhDetSupFrameZSize);
-
-
+  G4Box *PhDetSupFrameBox =
+      new G4Box("PhDetSupFrameBox", 0.5 * PhDetSupFrameXSize, 0.5 * PhDetSupFrameYSize, 0.5 * PhDetSupFrameZSize);
 
-    G4RotationMatrix PhDetSupRotX,PhDetSupRotY ;
+  G4RotationMatrix PhDetSupRotX, PhDetSupRotY;
 
-    G4ThreeVector PhDetSupFramePosLeft ( PhDetSupFrameXLocation[0],PhDetSupFrameYLocation[0],PhDetSupFrameZLocation);
-    G4ThreeVector PhDetSupFramePosRight ( PhDetSupFrameXLocation[1],PhDetSupFrameYLocation[1],PhDetSupFrameZLocation);
+  G4ThreeVector PhDetSupFramePosLeft(PhDetSupFrameXLocation[0], PhDetSupFrameYLocation[0], PhDetSupFrameZLocation);
+  G4ThreeVector PhDetSupFramePosRight(PhDetSupFrameXLocation[1], PhDetSupFrameYLocation[1], PhDetSupFrameZLocation);
 
-    G4Transform3D PhDetSupFrameTransformLeft(PhDetSupRotX*PhDetSupRotY,PhDetSupFramePosLeft );
-    G4Transform3D PhDetSupFrameTransformRight(PhDetSupRotX*PhDetSupRotY,PhDetSupFramePosRight );
-
-    G4LogicalVolume* PhDetSupFrameLogLeft = new   G4LogicalVolume(PhDetSupFrameBox,aMaterial->getNitrogenGas(),"PhDetSupFrameLeftLog", 0,0,0);
-
-    G4LogicalVolume* PhDetSupFrameLogRight = new  G4LogicalVolume(PhDetSupFrameBox,aMaterial->getNitrogenGas(),"PhDetSupFrameRightLog", 0,0,0);
-
-    G4VPhysicalVolume* PhDetSupFramePhysLeft = new G4PVPlacement(PhDetSupFrameTransformLeft,
-                                                                 PhDetSupPhysNameLeft,PhDetSupFrameLogLeft,
-                                                 aRTbCrystalMaster ->getRichTbUpgradeCrystalMasterPVol(),false,0);
-
-    G4VPhysicalVolume* PhDetSupFramePhysRight = new G4PVPlacement(PhDetSupFrameTransformRight,
-                                                        PhDetSupPhysNameRight,PhDetSupFrameLogRight,
-                                                 aRTbCrystalMaster ->getRichTbUpgradeCrystalMasterPVol(),false,1);
-
-    RichTbPhDetSupFrameLeftLVol  = PhDetSupFrameLogLeft;
-    RichTbPhDetSupFrameRightLVol = PhDetSupFrameLogRight;
-    RichTbPhDetSupFrameLeftPVol  = PhDetSupFramePhysLeft;
-    RichTbPhDetSupFrameRightPVol = PhDetSupFramePhysRight;
+  G4Transform3D PhDetSupFrameTransformLeft(PhDetSupRotX * PhDetSupRotY, PhDetSupFramePosLeft);
+  G4Transform3D PhDetSupFrameTransformRight(PhDetSupRotX * PhDetSupRotY, PhDetSupFramePosRight);
 
+  G4LogicalVolume *PhDetSupFrameLogLeft =
+      new G4LogicalVolume(PhDetSupFrameBox, aMaterial->getNitrogenGas(), "PhDetSupFrameLeftLog", 0, 0, 0);
 
+  G4LogicalVolume *PhDetSupFrameLogRight =
+      new G4LogicalVolume(PhDetSupFrameBox, aMaterial->getNitrogenGas(), "PhDetSupFrameRightLog", 0, 0, 0);
 
+  G4VPhysicalVolume *PhDetSupFramePhysLeft =
+      new G4PVPlacement(PhDetSupFrameTransformLeft, PhDetSupPhysNameLeft, PhDetSupFrameLogLeft,
+                        aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(), false, 0);
 
+  G4VPhysicalVolume *PhDetSupFramePhysRight =
+      new G4PVPlacement(PhDetSupFrameTransformRight, PhDetSupPhysNameRight, PhDetSupFrameLogRight,
+                        aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(), false, 1);
 
+  RichTbPhDetSupFrameLeftLVol = PhDetSupFrameLogLeft;
+  RichTbPhDetSupFrameRightLVol = PhDetSupFrameLogRight;
+  RichTbPhDetSupFrameLeftPVol = PhDetSupFramePhysLeft;
+  RichTbPhDetSupFrameRightPVol = PhDetSupFramePhysRight;
 }
 
-void RichTbUpgradePhDetSupFrame::constructRichTbPhotoDetectorSupFrameWithHpd()
-{
-  RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+void RichTbUpgradePhDetSupFrame::constructRichTbPhotoDetectorSupFrameWithHpd() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
   //  RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
 
-    G4Box * PhDetSupFrameBox
-       = new G4Box( "PhDetSupFrameBox",
-                    0.5*PhDetSupFrameXSize,0.5*PhDetSupFrameYSize,0.5*PhDetSupFrameZSize);
-
-
-
-    G4RotationMatrix PhDetSupRotX,PhDetSupRotY ;
-
-    G4ThreeVector PhDetSupFramePosLeft ( PhDetSupFrameXLocation[0],PhDetSupFrameYLocation[0],PhDetSupFrameZLocation);
-    G4Transform3D PhDetSupFrameTransformLeft(PhDetSupRotX*PhDetSupRotY,PhDetSupFramePosLeft );
-    G4LogicalVolume* PhDetSupFrameLogLeft = new   G4LogicalVolume(PhDetSupFrameBox,aMaterial->getNitrogenGas(),"PhDetSupFrameLeftLog", 0,0,0);
-    G4VPhysicalVolume* PhDetSupFramePhysLeft = new G4PVPlacement(PhDetSupFrameTransformLeft,
-                                                                 PhDetSupPhysNameLeft,PhDetSupFrameLogLeft,
-                                                 aRTbCrystalMaster ->getRichTbUpgradeCrystalMasterPVol(),false,0);
+  G4Box *PhDetSupFrameBox =
+      new G4Box("PhDetSupFrameBox", 0.5 * PhDetSupFrameXSize, 0.5 * PhDetSupFrameYSize, 0.5 * PhDetSupFrameZSize);
 
+  G4RotationMatrix PhDetSupRotX, PhDetSupRotY;
 
+  G4ThreeVector PhDetSupFramePosLeft(PhDetSupFrameXLocation[0], PhDetSupFrameYLocation[0], PhDetSupFrameZLocation);
+  G4Transform3D PhDetSupFrameTransformLeft(PhDetSupRotX * PhDetSupRotY, PhDetSupFramePosLeft);
+  G4LogicalVolume *PhDetSupFrameLogLeft =
+      new G4LogicalVolume(PhDetSupFrameBox, aMaterial->getNitrogenGas(), "PhDetSupFrameLeftLog", 0, 0, 0);
+  G4VPhysicalVolume *PhDetSupFramePhysLeft =
+      new G4PVPlacement(PhDetSupFrameTransformLeft, PhDetSupPhysNameLeft, PhDetSupFrameLogLeft,
+                        aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(), false, 0);
 
-    G4Box * PhDetHpdSupFrameBox
-       = new G4Box( "PhDetHpdSupFrameBox",
-                    0.5*HpdPhDetSupFrameXSize,0.5*HpdPhDetSupFrameYSize,0.5*HpdPhDetSupFrameZSize);
+  G4Box *PhDetHpdSupFrameBox = new G4Box("PhDetHpdSupFrameBox", 0.5 * HpdPhDetSupFrameXSize,
+                                         0.5 * HpdPhDetSupFrameYSize, 0.5 * HpdPhDetSupFrameZSize);
 
+  G4ThreeVector PhDetSupFramePosRight(HpdPhotonDetectorSupFrameXLocation, HpdPhotonDetectorSupFrameYLocation,
+                                      HpdPhDetSupFrameZLocation);
 
-    G4ThreeVector PhDetSupFramePosRight ( HpdPhotonDetectorSupFrameXLocation,
-                HpdPhotonDetectorSupFrameYLocation, HpdPhDetSupFrameZLocation);
-
-    G4RotationMatrix PhDetHpdSupRotX,PhDetHpdSupRotY ;
-
-    G4Transform3D PhDetSupFrameTransformRight(PhDetHpdSupRotX*PhDetHpdSupRotY,PhDetSupFramePosRight );
-
-
-    G4LogicalVolume* PhDetSupFrameLogRight = new  G4LogicalVolume(PhDetHpdSupFrameBox,aMaterial->getNitrogenGas(),"PhDetSupFrameRightLog", 0,0,0);
-
-
-    G4VPhysicalVolume* PhDetSupFramePhysRight = new G4PVPlacement(PhDetSupFrameTransformRight,
-                                                        PhDetSupPhysNameRight,PhDetSupFrameLogRight,
-                                                 aRTbCrystalMaster ->getRichTbUpgradeCrystalMasterPVol(),false,1);
-
-    RichTbPhDetSupFrameLeftLVol  = PhDetSupFrameLogLeft;
-    RichTbPhDetSupFrameRightLVol = PhDetSupFrameLogRight;
-    RichTbPhDetSupFrameLeftPVol  = PhDetSupFramePhysLeft;
-    RichTbPhDetSupFrameRightPVol  = PhDetSupFramePhysRight;
+  G4RotationMatrix PhDetHpdSupRotX, PhDetHpdSupRotY;
 
+  G4Transform3D PhDetSupFrameTransformRight(PhDetHpdSupRotX * PhDetHpdSupRotY, PhDetSupFramePosRight);
 
+  G4LogicalVolume *PhDetSupFrameLogRight =
+      new G4LogicalVolume(PhDetHpdSupFrameBox, aMaterial->getNitrogenGas(), "PhDetSupFrameRightLog", 0, 0, 0);
 
+  G4VPhysicalVolume *PhDetSupFramePhysRight =
+      new G4PVPlacement(PhDetSupFrameTransformRight, PhDetSupPhysNameRight, PhDetSupFrameLogRight,
+                        aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(), false, 1);
 
+  RichTbPhDetSupFrameLeftLVol = PhDetSupFrameLogLeft;
+  RichTbPhDetSupFrameRightLVol = PhDetSupFrameLogRight;
+  RichTbPhDetSupFrameLeftPVol = PhDetSupFramePhysLeft;
+  RichTbPhDetSupFrameRightPVol = PhDetSupFramePhysRight;
 }
 
-void RichTbUpgradePhDetSupFrame::constructRichTbPhotoDetectorSupFrame15()
-{
-  RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+void RichTbUpgradePhDetSupFrame::constructRichTbPhotoDetectorSupFrame15() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
   //  RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
 
-    G4Box * PhDetSupFrameBox = new G4Box( "PhDetSupFrameBox",
-                    0.5*PhDetSupFrameXSize,0.5*PhDetSupFrameYSize,0.5*PhDetSupFrameZSize);
-
-    G4RotationMatrix PhDetSupRotX,PhDetSupRotY ;
-
-    G4ThreeVector PhDetSupFramePosLeft(PhDetSupFrameXLocation15[0],PhDetSupFrameYLocation15[0],PhDetSupFrameZLocation15);
-    G4ThreeVector PhDetSupFramePosRight(PhDetSupFrameXLocation15[1],PhDetSupFrameYLocation15[1],PhDetSupFrameZLocation15);
-    G4ThreeVector PhDetSupFramePosBottomLeft(PhDetSupFrameBottomXLocation[0],PhDetSupFrameBottomYLocation[0],PhDetSupFrameZLocation15);
-    G4ThreeVector PhDetSupFramePosBottomRight(PhDetSupFrameBottomXLocation[1],PhDetSupFrameBottomYLocation[1],PhDetSupFrameZLocation15);
-
-    G4Transform3D PhDetSupFrameTransformLeft(PhDetSupRotX*PhDetSupRotY,PhDetSupFramePosLeft);
-    G4Transform3D PhDetSupFrameTransformRight(PhDetSupRotX*PhDetSupRotY,PhDetSupFramePosRight);
-    G4Transform3D PhDetSupFrameTransformBottomLeft(PhDetSupRotX*PhDetSupRotY,PhDetSupFramePosBottomLeft);
-    G4Transform3D PhDetSupFrameTransformBottomRight(PhDetSupRotX*PhDetSupRotY,PhDetSupFramePosBottomRight);
-
-    G4LogicalVolume* PhDetSupFrameLogLeft = new   G4LogicalVolume(PhDetSupFrameBox,aMaterial->getNitrogenGas(),"PhDetSupFrameLeftLog", 0,0,0);
-    G4LogicalVolume* PhDetSupFrameLogRight = new  G4LogicalVolume(PhDetSupFrameBox,aMaterial->getNitrogenGas(),"PhDetSupFrameRightLog", 0,0,0);
-    G4LogicalVolume* PhDetSupFrameLogBottomLeft = new   G4LogicalVolume(PhDetSupFrameBox,aMaterial->getNitrogenGas(),"PhDetSupFrameBottomLeftLog", 0,0,0);
-    G4LogicalVolume* PhDetSupFrameLogBottomRight = new  G4LogicalVolume(PhDetSupFrameBox,aMaterial->getNitrogenGas(),"PhDetSupFrameBottomRightLog", 0,0,0);
-
-    G4VPhysicalVolume* PhDetSupFramePhysLeft = new G4PVPlacement(PhDetSupFrameTransformLeft,
-                                                                 PhDetSupPhysNameLeft,PhDetSupFrameLogLeft,
-                                                 aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(),false,0);
-    G4VPhysicalVolume* PhDetSupFramePhysRight = new G4PVPlacement(PhDetSupFrameTransformRight,
-                                                        PhDetSupPhysNameRight,PhDetSupFrameLogRight,
-                                                 aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(),false,1);
-    G4VPhysicalVolume* PhDetSupFramePhysBottomLeft = new G4PVPlacement(PhDetSupFrameTransformBottomLeft,
-    														PhDetSupPhysNameBottomLeft,PhDetSupFrameLogBottomLeft,
-															aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(),false,0);
-    G4VPhysicalVolume* PhDetSupFramePhysBottomRight = new G4PVPlacement(PhDetSupFrameTransformBottomRight,
-															PhDetSupPhysNameBottomRight,PhDetSupFrameLogBottomRight,
-															aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(),false,1);
-
-    RichTbPhDetSupFrameLeftLVol  	= PhDetSupFrameLogLeft;
-    RichTbPhDetSupFrameRightLVol	= PhDetSupFrameLogRight;
-    RichTbPhDetSupFrameBottomLeftLVol  = PhDetSupFrameLogBottomLeft;
-    RichTbPhDetSupFrameBottomRightLVol = PhDetSupFrameLogBottomRight;
-    RichTbPhDetSupFrameLeftPVol  	= PhDetSupFramePhysLeft;
-    RichTbPhDetSupFrameRightPVol 	= PhDetSupFramePhysRight;
-    RichTbPhDetSupFrameBottomLeftPVol  = PhDetSupFramePhysBottomLeft;
-    RichTbPhDetSupFrameBottomRightPVol = PhDetSupFramePhysBottomRight;
+  G4Box *PhDetSupFrameBox =
+      new G4Box("PhDetSupFrameBox", 0.5 * PhDetSupFrameXSize, 0.5 * PhDetSupFrameYSize, 0.5 * PhDetSupFrameZSize);
+
+  G4RotationMatrix PhDetSupRotX, PhDetSupRotY;
+
+  G4ThreeVector PhDetSupFramePosLeft(PhDetSupFrameXLocation15[0], PhDetSupFrameYLocation15[0],
+                                     PhDetSupFrameZLocation15);
+  G4ThreeVector PhDetSupFramePosRight(PhDetSupFrameXLocation15[1], PhDetSupFrameYLocation15[1],
+                                      PhDetSupFrameZLocation15);
+  G4ThreeVector PhDetSupFramePosBottomLeft(PhDetSupFrameBottomXLocation[0], PhDetSupFrameBottomYLocation[0],
+                                           PhDetSupFrameZLocation15);
+  G4ThreeVector PhDetSupFramePosBottomRight(PhDetSupFrameBottomXLocation[1], PhDetSupFrameBottomYLocation[1],
+                                            PhDetSupFrameZLocation15);
+
+  G4Transform3D PhDetSupFrameTransformLeft(PhDetSupRotX * PhDetSupRotY, PhDetSupFramePosLeft);
+  G4Transform3D PhDetSupFrameTransformRight(PhDetSupRotX * PhDetSupRotY, PhDetSupFramePosRight);
+  G4Transform3D PhDetSupFrameTransformBottomLeft(PhDetSupRotX * PhDetSupRotY, PhDetSupFramePosBottomLeft);
+  G4Transform3D PhDetSupFrameTransformBottomRight(PhDetSupRotX * PhDetSupRotY, PhDetSupFramePosBottomRight);
+
+  G4LogicalVolume *PhDetSupFrameLogLeft =
+      new G4LogicalVolume(PhDetSupFrameBox, aMaterial->getNitrogenGas(), "PhDetSupFrameLeftLog", 0, 0, 0);
+  G4LogicalVolume *PhDetSupFrameLogRight =
+      new G4LogicalVolume(PhDetSupFrameBox, aMaterial->getNitrogenGas(), "PhDetSupFrameRightLog", 0, 0, 0);
+  G4LogicalVolume *PhDetSupFrameLogBottomLeft =
+      new G4LogicalVolume(PhDetSupFrameBox, aMaterial->getNitrogenGas(), "PhDetSupFrameBottomLeftLog", 0, 0, 0);
+  G4LogicalVolume *PhDetSupFrameLogBottomRight =
+      new G4LogicalVolume(PhDetSupFrameBox, aMaterial->getNitrogenGas(), "PhDetSupFrameBottomRightLog", 0, 0, 0);
+
+  G4VPhysicalVolume *PhDetSupFramePhysLeft =
+      new G4PVPlacement(PhDetSupFrameTransformLeft, PhDetSupPhysNameLeft, PhDetSupFrameLogLeft,
+                        aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(), false, 0);
+  G4VPhysicalVolume *PhDetSupFramePhysRight =
+      new G4PVPlacement(PhDetSupFrameTransformRight, PhDetSupPhysNameRight, PhDetSupFrameLogRight,
+                        aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(), false, 1);
+  G4VPhysicalVolume *PhDetSupFramePhysBottomLeft =
+      new G4PVPlacement(PhDetSupFrameTransformBottomLeft, PhDetSupPhysNameBottomLeft, PhDetSupFrameLogBottomLeft,
+                        aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(), false, 0);
+  G4VPhysicalVolume *PhDetSupFramePhysBottomRight =
+      new G4PVPlacement(PhDetSupFrameTransformBottomRight, PhDetSupPhysNameBottomRight, PhDetSupFrameLogBottomRight,
+                        aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(), false, 1);
+
+  RichTbPhDetSupFrameLeftLVol = PhDetSupFrameLogLeft;
+  RichTbPhDetSupFrameRightLVol = PhDetSupFrameLogRight;
+  RichTbPhDetSupFrameBottomLeftLVol = PhDetSupFrameLogBottomLeft;
+  RichTbPhDetSupFrameBottomRightLVol = PhDetSupFrameLogBottomRight;
+  RichTbPhDetSupFrameLeftPVol = PhDetSupFramePhysLeft;
+  RichTbPhDetSupFrameRightPVol = PhDetSupFramePhysRight;
+  RichTbPhDetSupFrameBottomLeftPVol = PhDetSupFramePhysBottomLeft;
+  RichTbPhDetSupFrameBottomRightPVol = PhDetSupFramePhysBottomRight;
 }
-
-
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeRadiator.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeRadiator.cc
index 05f5953acf4cee7dd9a0420a6f591669a18872c7..a5ab6eba3c216e81349afe085e9a112ef771f8e7 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeRadiator.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeRadiator.cc
@@ -1,30 +1,28 @@
 // $Id: $
 // Include files
 
-
-
 // local
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMiscNames.hh"
-#include "RichTbMaterial.hh"
-#include "RichTbUpgradeVessel.hh"
-#include "RichTbUpgradeCrystal.hh"
 #include "RichTbUpgradeRadiator.hh"
-#include "RichTbUpgradeCrystalMaster.hh"
-#include "RichTbHall.hh"
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4Orb.hh"
+#include "Geant4/G4PVPlacement.hh"
 #include "Geant4/G4RotationMatrix.hh"
+#include "Geant4/G4Sphere.hh"
+#include "Geant4/G4SubtractionSolid.hh"
 #include "Geant4/G4ThreeVector.hh"
 #include "Geant4/G4Transform3D.hh"
-#include "Geant4/G4SubtractionSolid.hh"
-#include "Geant4/G4UnionSolid.hh"
-#include "Geant4/G4Box.hh"
-#include "Geant4/G4Orb.hh"
 #include "Geant4/G4Tubs.hh"
-#include "Geant4/G4Sphere.hh"
-#include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4UnionSolid.hh"
 #include "Geant4/G4VPhysicalVolume.hh"
-#include "Geant4/G4PVPlacement.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbHall.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMiscNames.hh"
 #include "RichTbRunConfig.hh"
+#include "RichTbUpgradeCrystal.hh"
+#include "RichTbUpgradeCrystalMaster.hh"
+#include "RichTbUpgradeVessel.hh"
 
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbVessel
@@ -37,231 +35,185 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbUpgradeRadiator::RichTbUpgradeRadiator(RichTbUpgradeCrystalMaster* rTbCrystalMaster ) {
+RichTbUpgradeRadiator::RichTbUpgradeRadiator(RichTbUpgradeCrystalMaster *rTbCrystalMaster) {
 
-	aRTbCrystalMaster = rTbCrystalMaster;
+  aRTbCrystalMaster = rTbCrystalMaster;
 
-	RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-	G4int aRadiatorConfiguration = aConfig ->getRadiatorConfiguration();
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int aRadiatorConfiguration = aConfig->getRadiatorConfiguration();
 
-	if(aRadiatorConfiguration == 3) constructRichTbUpgradeRadiator15();
-	else constructRichTbUpgradeRadiator();
-
-}
-RichTbUpgradeRadiator::~RichTbUpgradeRadiator(  )
-{
+  if (aRadiatorConfiguration == 3)
+    constructRichTbUpgradeRadiator15();
+  else
+    constructRichTbUpgradeRadiator();
 }
+RichTbUpgradeRadiator::~RichTbUpgradeRadiator() {}
 
-void RichTbUpgradeRadiator::constructRichTbUpgradeRadiator()
-{
-	RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-	// RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-
-
-
-	G4Box * Box1
-	= new G4Box("Box1", 0.5*Box1XSize,
-			0.5*Box1YSize, 0.5*Box1ZSize);
-
-	G4Box * Box2
-	= new G4Box("Box2", 0.5*Box2XSize,
-			0.5*Box2YSize, 0.5*Box2ZSize);
-
-	G4ThreeVector Box2Pos(Box2XLocation,
-			Box2YLocation,
-			Box2ZLocation);
-
-	G4RotationMatrix Box2RotX,Box2RotY;
-
-	G4Transform3D Box2Transform(Box2RotX * Box2RotY, Box2Pos);
+void RichTbUpgradeRadiator::constructRichTbUpgradeRadiator() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  // RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
 
-	G4SubtractionSolid* SubBoxA =
-			new G4SubtractionSolid("SubBoxA", Box1 ,
-					Box2, Box2Transform);
+  G4Box *Box1 = new G4Box("Box1", 0.5 * Box1XSize, 0.5 * Box1YSize, 0.5 * Box1ZSize);
 
+  G4Box *Box2 = new G4Box("Box2", 0.5 * Box2XSize, 0.5 * Box2YSize, 0.5 * Box2ZSize);
 
-	G4Box * RichTbUpgradeDarkCoverSubBox
-	= new G4Box("RichTbUpgradeDarkCoverSubBox", 0.5*RichTbUpgradeDarkCoverXSize,
-			0.5*RichTbUpgradeDarkCoverYSize, 0.5*RichTbUpgradeDarkCoverZSize);
+  G4ThreeVector Box2Pos(Box2XLocation, Box2YLocation, Box2ZLocation);
 
-	G4ThreeVector DarkCoverSubPos(RichTbUpgradeDarkCoverXLocation,
-			RichTbUpgradeDarkCoverYLocation,
-			RichTbUpgradeDarkCoverZLocation);
+  G4RotationMatrix Box2RotX, Box2RotY;
 
-	G4RotationMatrix DarkCoverSubRotX, DarkCoverSubRotY;
+  G4Transform3D Box2Transform(Box2RotX * Box2RotY, Box2Pos);
 
-	G4Transform3D DarkCoverSubTransform(DarkCoverSubRotX * DarkCoverSubRotY, DarkCoverSubPos);
+  G4SubtractionSolid *SubBoxA = new G4SubtractionSolid("SubBoxA", Box1, Box2, Box2Transform);
 
+  G4Box *RichTbUpgradeDarkCoverSubBox = new G4Box("RichTbUpgradeDarkCoverSubBox", 0.5 * RichTbUpgradeDarkCoverXSize,
+                                                  0.5 * RichTbUpgradeDarkCoverYSize, 0.5 * RichTbUpgradeDarkCoverZSize);
 
+  G4ThreeVector DarkCoverSubPos(RichTbUpgradeDarkCoverXLocation, RichTbUpgradeDarkCoverYLocation,
+                                RichTbUpgradeDarkCoverZLocation);
 
-	G4SubtractionSolid* BigBox =
-			new G4SubtractionSolid("BigBox", SubBoxA ,
-					RichTbUpgradeDarkCoverSubBox, DarkCoverSubTransform);
+  G4RotationMatrix DarkCoverSubRotX, DarkCoverSubRotY;
 
+  G4Transform3D DarkCoverSubTransform(DarkCoverSubRotX * DarkCoverSubRotY, DarkCoverSubPos);
 
-	G4Orb* Sphere = new G4Orb("Sphere", SphereRadius);
+  G4SubtractionSolid *BigBox =
+      new G4SubtractionSolid("BigBox", SubBoxA, RichTbUpgradeDarkCoverSubBox, DarkCoverSubTransform);
 
-	G4ThreeVector BigBoxPos(BigBoxXLocation,
-			BigBoxYLocation,
-			BigBoxZLocation);
+  G4Orb *Sphere = new G4Orb("Sphere", SphereRadius);
 
-	G4RotationMatrix BigBoxRotX,BigBoxRotY;
+  G4ThreeVector BigBoxPos(BigBoxXLocation, BigBoxYLocation, BigBoxZLocation);
 
-	G4Transform3D BigBoxTransform(BigBoxRotX * BigBoxRotY, BigBoxPos);
+  G4RotationMatrix BigBoxRotX, BigBoxRotY;
 
-	G4SubtractionSolid* RichTbUpgradeRadiator =
-			new G4SubtractionSolid("Radiator", Sphere ,
-					BigBox, BigBoxTransform);
+  G4Transform3D BigBoxTransform(BigBoxRotX * BigBoxRotY, BigBoxPos);
 
-	G4ThreeVector RadiatorPos(RichTbUpgradeRadiatorXLocation,
-			RichTbUpgradeRadiatorYLocation,
-			RichTbUpgradeRadiatorZLocation);
+  G4SubtractionSolid *RichTbUpgradeRadiator = new G4SubtractionSolid("Radiator", Sphere, BigBox, BigBoxTransform);
 
-	G4RotationMatrix RadiatorRotX,RadiatorRotY;
+  G4ThreeVector RadiatorPos(RichTbUpgradeRadiatorXLocation, RichTbUpgradeRadiatorYLocation,
+                            RichTbUpgradeRadiatorZLocation);
 
+  G4RotationMatrix RadiatorRotX, RadiatorRotY;
 
-	// RadiatorRotY.rotateY(acos(-1));
+  // RadiatorRotY.rotateY(acos(-1));
 
-	G4Transform3D RadiatorTransform( RadiatorRotX * RadiatorRotY, RadiatorPos);
+  G4Transform3D RadiatorTransform(RadiatorRotX * RadiatorRotY, RadiatorPos);
 
+  G4LogicalVolume *RadiatorLog;
 
-	G4LogicalVolume* RadiatorLog;
-
-
-	//crystal material
-	RadiatorLog =
-			new G4LogicalVolume(RichTbUpgradeRadiator,
-					aMaterial->getCrystalMaterial(), "RadiatorLog",0,0,0);
-
-	//crystal location
-	G4VPhysicalVolume* RadiatorPhys =
-			new G4PVPlacement(RadiatorTransform, RadiatorPhysName, RadiatorLog ,
-					aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(),
-					false,0);
-
-	RichTbUpgradeRadiatorLVol =  RadiatorLog;
-	RichTbUpgradeRadiatorPVol =  RadiatorPhys;
+  // crystal material
+  RadiatorLog = new G4LogicalVolume(RichTbUpgradeRadiator, aMaterial->getCrystalMaterial(), "RadiatorLog", 0, 0, 0);
 
+  // crystal location
+  G4VPhysicalVolume *RadiatorPhys = new G4PVPlacement(RadiatorTransform, RadiatorPhysName, RadiatorLog,
+                                                      aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(), false, 0);
 
+  RichTbUpgradeRadiatorLVol = RadiatorLog;
+  RichTbUpgradeRadiatorPVol = RadiatorPhys;
 }
 
-void RichTbUpgradeRadiator::constructRichTbUpgradeRadiator15()
-{
-	RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-	// RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-
-	G4Box * Box1 = new G4Box("Box1", 0.5*Box1XSize,	0.5*Box1YSize, 0.5*Box1ZSize);
-
-	//	G4Box * Box2 = new G4Box("Box2", 0.5*Box2XSize15,	0.5*Box2YSize15, 0.5*Box2ZSize15);
-	G4Tubs * Cyl1 = new G4Tubs("Cyl1", cylRmin, cylRmax, cylHalfLength, cylSPhi, cylDPhi);
-
-	//	G4ThreeVector Box2Pos(Box2XLocation, Box2YLocation, Box2ZLocation);
-	G4ThreeVector Cyl1Pos(Cyl1XLocation, Cyl1YLocation, Cyl1ZLocation);
+void RichTbUpgradeRadiator::constructRichTbUpgradeRadiator15() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  // RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
 
-	//	G4RotationMatrix Box2RotX,Box2RotY;
-	G4RotationMatrix Cyl1RotX, Cyl1RotY;
+  G4Box *Box1 = new G4Box("Box1", 0.5 * Box1XSize, 0.5 * Box1YSize, 0.5 * Box1ZSize);
 
-	//	G4Transform3D Box2Transform(Box2RotX * Box2RotY, Box2Pos);
-	G4Transform3D Cyl1Transform(Cyl1RotX * Cyl1RotY, Cyl1Pos);
+  //	G4Box * Box2 = new G4Box("Box2", 0.5*Box2XSize15,	0.5*Box2YSize15, 0.5*Box2ZSize15);
+  G4Tubs *Cyl1 = new G4Tubs("Cyl1", cylRmin, cylRmax, cylHalfLength, cylSPhi, cylDPhi);
 
-	G4SubtractionSolid* SubBoxA = new G4SubtractionSolid("SubBoxA", Box1, Cyl1, Cyl1Transform);
+  //	G4ThreeVector Box2Pos(Box2XLocation, Box2YLocation, Box2ZLocation);
+  G4ThreeVector Cyl1Pos(Cyl1XLocation, Cyl1YLocation, Cyl1ZLocation);
 
-//	G4Box * RichTbUpgradeDarkCoverSubBox = new G4Box("RichTbUpgradeDarkCoverSubBox",
-//			0.5*RichTbUpgradeDarkCoverXSize15,
-//			0.5*RichTbUpgradeDarkCoverYSize15,
-//			0.5*RichTbUpgradeDarkCoverZSize15);
-	G4Tubs * RichTbUpgradeDarkCoverSubTubs = new G4Tubs("Cyl2", cylDarkRmin, cylDarkRmax, cylDarkHalfLength, cylSPhi, cylDPhi);
+  //	G4RotationMatrix Box2RotX,Box2RotY;
+  G4RotationMatrix Cyl1RotX, Cyl1RotY;
 
+  //	G4Transform3D Box2Transform(Box2RotX * Box2RotY, Box2Pos);
+  G4Transform3D Cyl1Transform(Cyl1RotX * Cyl1RotY, Cyl1Pos);
 
-	G4ThreeVector DarkCoverSubPos(RichTbUpgradeDarkCoverXLocation15,
-			RichTbUpgradeDarkCoverYLocation15,
-			RichTbUpgradeDarkCoverZLocation15);
+  G4SubtractionSolid *SubBoxA = new G4SubtractionSolid("SubBoxA", Box1, Cyl1, Cyl1Transform);
 
-	G4RotationMatrix DarkCoverSubRotX, DarkCoverSubRotY;
+  //	G4Box * RichTbUpgradeDarkCoverSubBox = new G4Box("RichTbUpgradeDarkCoverSubBox",
+  //			0.5*RichTbUpgradeDarkCoverXSize15,
+  //			0.5*RichTbUpgradeDarkCoverYSize15,
+  //			0.5*RichTbUpgradeDarkCoverZSize15);
+  G4Tubs *RichTbUpgradeDarkCoverSubTubs =
+      new G4Tubs("Cyl2", cylDarkRmin, cylDarkRmax, cylDarkHalfLength, cylSPhi, cylDPhi);
 
-	G4Transform3D DarkCoverSubTransform(DarkCoverSubRotX * DarkCoverSubRotY, DarkCoverSubPos);
+  G4ThreeVector DarkCoverSubPos(RichTbUpgradeDarkCoverXLocation15, RichTbUpgradeDarkCoverYLocation15,
+                                RichTbUpgradeDarkCoverZLocation15);
 
-	G4SubtractionSolid* BigBox = new G4SubtractionSolid("BigBox", SubBoxA ,
-			RichTbUpgradeDarkCoverSubTubs, DarkCoverSubTransform);
+  G4RotationMatrix DarkCoverSubRotX, DarkCoverSubRotY;
 
+  G4Transform3D DarkCoverSubTransform(DarkCoverSubRotX * DarkCoverSubRotY, DarkCoverSubPos);
 
+  G4SubtractionSolid *BigBox =
+      new G4SubtractionSolid("BigBox", SubBoxA, RichTbUpgradeDarkCoverSubTubs, DarkCoverSubTransform);
 
-	//mirror subvolume
-	G4double MirrPhiSize = 2*CLHEP::pi* CLHEP::rad;
+  // mirror subvolume
+  G4double MirrPhiSize = 2 * CLHEP::pi * CLHEP::rad;
 
-	// G4double MirrThetaStart = 0.0*CLHEP::rad;
-	G4double MirrThetaStart = MirrorMinThetaExtent15;
-	G4double MirrThetaSize = MirrorMaxThetaExtent15-MirrorMinThetaExtent15;
+  // G4double MirrThetaStart = 0.0*CLHEP::rad;
+  G4double MirrThetaStart = MirrorMinThetaExtent15;
+  G4double MirrThetaSize = MirrorMaxThetaExtent15 - MirrorMinThetaExtent15;
 
-	G4double MirrPhiStart = 0.0*CLHEP::rad;
+  G4double MirrPhiStart = 0.0 * CLHEP::rad;
 
-	G4Sphere* MirrorFull =  new G4Sphere("MirrorFull",MirrorInnerRadius15,
-			MirrorOuterRadius15,MirrPhiStart,
-			MirrPhiSize,MirrThetaStart,
-			MirrThetaSize);
+  G4Sphere *MirrorFull = new G4Sphere("MirrorFull", MirrorInnerRadius15, MirrorOuterRadius15, MirrPhiStart, MirrPhiSize,
+                                      MirrThetaStart, MirrThetaSize);
 
-	G4RotationMatrix MirrorRotationX, MirrorRotationY;
-	MirrorRotationY.rotateY(180*CLHEP::degree);
+  G4RotationMatrix MirrorRotationX, MirrorRotationY;
+  MirrorRotationY.rotateY(180 * CLHEP::degree);
 
-	G4ThreeVector MirrorPos(MirrorPosX15, MirrorPosY15, MirrorVolPosZ15);
+  G4ThreeVector MirrorPos(MirrorPosX15, MirrorPosY15, MirrorVolPosZ15);
 
-	G4Transform3D MirrorTransform(MirrorRotationX * MirrorRotationY,
-			MirrorPos);
+  G4Transform3D MirrorTransform(MirrorRotationX * MirrorRotationY, MirrorPos);
 
-//	G4SubtractionSolid* BigBox2 = new G4SubtractionSolid("BigBox2", BigBox ,
-//			MirrorFull, MirrorTransform);
-	//end mirror subvolume
+  //	G4SubtractionSolid* BigBox2 = new G4SubtractionSolid("BigBox2", BigBox ,
+  //			MirrorFull, MirrorTransform);
+  // end mirror subvolume
 
+  G4Orb *Sphere = new G4Orb("Sphere", SphereRadius15);
 
+  G4UnionSolid *SpherePlusMirror = new G4UnionSolid("SpherePlusMirror", Sphere, MirrorFull, MirrorTransform);
 
-	G4Orb* Sphere = new G4Orb("Sphere", SphereRadius15);
+  G4ThreeVector BigBoxPos(BigBoxXLocation, BigBoxYLocation, BigBoxZLocation);
 
-	G4UnionSolid * SpherePlusMirror = new G4UnionSolid("SpherePlusMirror", Sphere, MirrorFull, MirrorTransform);
+  G4RotationMatrix BigBoxRotX, BigBoxRotY;
 
-	G4ThreeVector BigBoxPos(BigBoxXLocation, BigBoxYLocation, BigBoxZLocation);
+  G4Transform3D BigBoxTransform(BigBoxRotX * BigBoxRotY, BigBoxPos);
 
-	G4RotationMatrix BigBoxRotX,BigBoxRotY;
+  G4SubtractionSolid *RichTbUpgradeRadiator =
+      new G4SubtractionSolid("Radiator", SpherePlusMirror, BigBox, BigBoxTransform);
 
-	G4Transform3D BigBoxTransform(BigBoxRotX * BigBoxRotY, BigBoxPos);
+  G4ThreeVector RadiatorPos(RichTbUpgradeRadiatorXLocation15, RichTbUpgradeRadiatorYLocation15,
+                            RichTbUpgradeRadiatorZLocation15);
 
-	G4SubtractionSolid* RichTbUpgradeRadiator = new G4SubtractionSolid("Radiator", SpherePlusMirror,
-			BigBox, BigBoxTransform);
+  G4RotationMatrix RadiatorRotX, RadiatorRotY;
 
-	G4ThreeVector RadiatorPos(RichTbUpgradeRadiatorXLocation15,
-			RichTbUpgradeRadiatorYLocation15,
-			RichTbUpgradeRadiatorZLocation15);
+  // RadiatorRotY.rotateY(acos(-1));
 
-	G4RotationMatrix RadiatorRotX,RadiatorRotY;
+  G4Transform3D RadiatorTransform(RadiatorRotX * RadiatorRotY, RadiatorPos);
 
-	// RadiatorRotY.rotateY(acos(-1));
+  G4LogicalVolume *RadiatorLog;
 
-	G4Transform3D RadiatorTransform( RadiatorRotX * RadiatorRotY, RadiatorPos);
+  // crystal material
+  RadiatorLog = new G4LogicalVolume(RichTbUpgradeRadiator, aMaterial->getCrystalMaterial(), "RadiatorLog", 0, 0, 0);
 
-	G4LogicalVolume* RadiatorLog;
-
-	//crystal material
-	RadiatorLog = new G4LogicalVolume(RichTbUpgradeRadiator, aMaterial->getCrystalMaterial(), "RadiatorLog",0,0,0);
-
-	//crystal location
-	G4VPhysicalVolume* RadiatorPhys = new G4PVPlacement(RadiatorTransform,
-			RadiatorPhysName, RadiatorLog,
-			aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(),
-			false,0);
-
-	RichTbUpgradeRadiatorLVol =  RadiatorLog;
-	RichTbUpgradeRadiatorPVol =  RadiatorPhys;
-//
-//	G4Transform3D * testTrans;
-//	G4Box * testbox = new G4Box("testbox", 0.5*10,	0.5*10, 0.5*10);
-//	G4LogicalVolume * testL = new G4LogicalVolume(testbox, aMaterial->getCrystalMaterial(), "testL",0,0,0);
-//	G4VPhysicalVolume * testP = new G4VPhysicalVolume(testTrans, "testP", testL, aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(),false,0);
-//
-//	testLvol = testL;
-//	testPvol = testP;
+  // crystal location
+  G4VPhysicalVolume *RadiatorPhys = new G4PVPlacement(RadiatorTransform, RadiatorPhysName, RadiatorLog,
+                                                      aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(), false, 0);
 
+  RichTbUpgradeRadiatorLVol = RadiatorLog;
+  RichTbUpgradeRadiatorPVol = RadiatorPhys;
+  //
+  //	G4Transform3D * testTrans;
+  //	G4Box * testbox = new G4Box("testbox", 0.5*10,	0.5*10, 0.5*10);
+  //	G4LogicalVolume * testL = new G4LogicalVolume(testbox, aMaterial->getCrystalMaterial(), "testL",0,0,0);
+  //	G4VPhysicalVolume * testP = new G4VPhysicalVolume(testTrans, "testP", testL,
+  //aRTbCrystalMaster->getRichTbUpgradeCrystalMasterPVol(),false,0);
+  //
+  //	testLvol = testL;
+  //	testPvol = testP;
 }
 
 void RichTbUpgradeRadiator::constructRichTbUpgradeRadiatorEnvelope() {}
 
-
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeVessel.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeVessel.cc
index 538925a4ce4c9089f279d0f44810154ae87f93da..eb0de1d25327e75a7b6d65335561975848cb3fcc 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeVessel.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcgy/RichTbUpgradeVessel.cc
@@ -1,22 +1,20 @@
 // $Id: $
-// Include files 
-
-
+// Include files
 
 // local
-#include "RichTbGeometryParameters.hh"
-#include "RichTbMiscNames.hh"
-#include "RichTbMaterial.hh"
 #include "RichTbUpgradeVessel.hh"
-#include "RichTbHall.hh"
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4PVPlacement.hh"
 #include "Geant4/G4RotationMatrix.hh"
+#include "Geant4/G4SubtractionSolid.hh"
 #include "Geant4/G4ThreeVector.hh"
 #include "Geant4/G4Transform3D.hh"
-#include "Geant4/G4SubtractionSolid.hh"
-#include "Geant4/G4Box.hh"
-#include "Geant4/G4LogicalVolume.hh"
 #include "Geant4/G4VPhysicalVolume.hh"
-#include "Geant4/G4PVPlacement.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbHall.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMiscNames.hh"
 #include "RichTbRunConfig.hh"
 
 //-----------------------------------------------------------------------------
@@ -29,91 +27,71 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbUpgradeVessel::RichTbUpgradeVessel(RichTbHall* rTbHall  ) {
+RichTbUpgradeVessel::RichTbUpgradeVessel(RichTbHall *rTbHall) {
 
   aRTbHall = rTbHall;
-  
+
   constructRichTbGasVessel();
-  
-}
-RichTbUpgradeVessel::~RichTbUpgradeVessel(  )
-{
 }
-void RichTbUpgradeVessel::constructRichTbGasVessel()
-{
-  RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
-  RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-  
-  G4Box * RichTbVesselBox 
-    = new G4Box("RichTbVesselBox", 0.5*RichTbVesselXSize,
-                0.5*RichTbVesselYSize, 0.5*RichTbVesselZSize);
- 
-  //volume substraction
+RichTbUpgradeVessel::~RichTbUpgradeVessel() {}
+void RichTbUpgradeVessel::constructRichTbGasVessel() {
+  RichTbMaterial *aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+
+  G4Box *RichTbVesselBox =
+      new G4Box("RichTbVesselBox", 0.5 * RichTbVesselXSize, 0.5 * RichTbVesselYSize, 0.5 * RichTbVesselZSize);
+
+  // volume substraction
   /*
-  G4Box* RichTbVesselUpsSubBox 
-   = new G4Box("RichTbVesselUpsSubBox", 
+  G4Box* RichTbVesselUpsSubBox
+   = new G4Box("RichTbVesselUpsSubBox",
               0.5*RichTbVesselUpsExternalPartXSize,
               0.5*RichTbVesselUpsExternalPartYLargeSize,
               0.5*RichTbVesselUpsExternalPartZLargeSize);
-  
+
 
   G4ThreeVector VesselUpsSubPos(RichTbVesselUpsExternalPartXShift ,
                                 RichTbVesselUpsExternalPartYShift,
                                 RichTbVesselUpsExternalPartZShift);
   */
 
-  G4ThreeVector VesselPos(RichTbVesselXLocation,
-                          RichTbVesselYLocation,
-                          RichTbVesselZLocation);
- 
-  G4RotationMatrix VesselUpsSubRot, VesselRotX,VesselRotY;
+  G4ThreeVector VesselPos(RichTbVesselXLocation, RichTbVesselYLocation, RichTbVesselZLocation);
+
+  G4RotationMatrix VesselUpsSubRot, VesselRotX, VesselRotY;
 
-  G4int aSpeicalStudyVesselRotFlag =  
-      aConfig ->getSpecialStudyVesselRotation();
+  G4int aSpeicalStudyVesselRotFlag = aConfig->getSpecialStudyVesselRotation();
 
-  if( aSpeicalStudyVesselRotFlag != 1 ) {
-    
-  VesselRotX.rotateX(RichTbVesselXRotation);
-  VesselRotY.rotateY(RichTbVesselYRotation);
+  if (aSpeicalStudyVesselRotFlag != 1) {
 
+    VesselRotX.rotateX(RichTbVesselXRotation);
+    VesselRotY.rotateY(RichTbVesselYRotation);
   }
-  
+
   //
   // G4cout<<" Vessel XRot Yrot "<<RichTbVesselXRotation<<"   "
   //      <<RichTbVesselYRotation<<G4endl;
-  
-  //G4Transform3D VesselUpsSubTransform(VesselUpsSubRot,VesselUpsSubPos);
 
-  G4Transform3D VesselTransform(  VesselRotX * VesselRotY, VesselPos);
-  
-  /* G4SubtractionSolid* VesselUpsSub = 
+  // G4Transform3D VesselUpsSubTransform(VesselUpsSubRot,VesselUpsSubPos);
+
+  G4Transform3D VesselTransform(VesselRotX * VesselRotY, VesselPos);
+
+  /* G4SubtractionSolid* VesselUpsSub =
       new G4SubtractionSolid("VesselUpsSub",  RichTbVesselBoxOverall ,
                              RichTbVesselUpsSubBox,VesselUpsSubTransform);
-  
+
   */
-    G4LogicalVolume* VesselLog;
-    
-     
-    //air in the vessel
-     VesselLog = 
-       new G4LogicalVolume(RichTbVesselBox,
-                           aMaterial->getNitrogenGas(), "VesselLog",0,0,0);
-
-     //location of the vessel   
-     G4VPhysicalVolume* VesselPhys =
-       new G4PVPlacement(VesselTransform,VesselPhysName, VesselLog ,
-                         aRTbHall->getRichTbHallPhysicalVolume(),
-                         false,0);
-     
-     RichTbGasVesselLVol =  VesselLog;
-     RichTbGasVesselPVol =  VesselPhys;
-     
-
-} 
-void RichTbUpgradeVessel::constructRichTbUpgradeVesselEnvelope()
-{
-  
-}
+  G4LogicalVolume *VesselLog;
+
+  // air in the vessel
+  VesselLog = new G4LogicalVolume(RichTbVesselBox, aMaterial->getNitrogenGas(), "VesselLog", 0, 0, 0);
 
+  // location of the vessel
+  G4VPhysicalVolume *VesselPhys =
+      new G4PVPlacement(VesselTransform, VesselPhysName, VesselLog, aRTbHall->getRichTbHallPhysicalVolume(), false, 0);
+
+  RichTbGasVesselLVol = VesselLog;
+  RichTbGasVesselPVol = VesselPhys;
+}
+void RichTbUpgradeVessel::constructRichTbUpgradeVesselEnvelope() {}
 
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcmain/RichTbSim.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcmain/RichTbSim.cc
index 8c0defe3c9a0164a0267f7c616262ff126081398..f7da41eb50dc9cf4eaf87727c2912f4cfc882a7c 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcmain/RichTbSim.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcmain/RichTbSim.cc
@@ -1,179 +1,171 @@
 //  Rich Test Beam Simulation   Main program
 // ----------------------------------------------------------------
-#include "RichTbRunAction.hh"
+#include "Geant4/G4RunManager.hh"
+#include "Geant4/G4UImanager.hh"
+#include "Geant4/G4UIterminal.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
 #include "RichTbEventAction.hh"
-#include "RichTbUpgradeDetectorConstruction.hh"
+#include "RichTbIOData.hh"
+#include "RichTbPhysicsList.hh"
 #include "RichTbPrimaryGeneratorAction.hh"
+#include "RichTbRunAction.hh"
+#include "RichTbRunConfig.hh"
 #include "RichTbStackingAction.hh"
 #include "RichTbSteppingActionBase.hh"
 #include "RichTbTrackingAction.hh"
-#include "RichTbPhysicsList.hh"
-#include "Geant4/G4VPhysicalVolume.hh"
-#include "Geant4/G4RunManager.hh"
+#include "RichTbUpgradeDetectorConstruction.hh"
 #include "RichTbVisManager.hh"
-#include "RichTbRunConfig.hh"
-#include "RichTbIOData.hh"
-#include "Geant4/G4UImanager.hh"
-#include "Geant4/G4UIterminal.hh"
 
 #ifdef G4UI_USE_XM
 #include "Geant4/G4UIXm.hh"
 #endif
 #include "Geant4/Randomize.hh"
-#include "RichTbVisManager.hh"
 #include "RichTbAnalysisManager.hh"
-
+#include "RichTbVisManager.hh"
 
 #include "Geant4/G4ios.hh"
 #include <cstdlib>
 #include <iostream>
 
-int main(int argc, char **argv)
-{
+int main(int argc, char **argv) {
 
-    // Seed the random number generator manually
-    // ------------------------------------------
+  // Seed the random number generator manually
+  // ------------------------------------------
   // G4long myseed = 345354;
-    G4long myseed = 755365;
-    //  HepRandom::setTheSeed(myseed);
-
-    // Run manager
-    // G4RunManager *runManager = new G4RunManager;
-    //Job and Run  options.
-
-    RichTbRunConfig *rConfig = RichTbRunConfig::getRunConfigInstance();
-    myseed = rConfig -> getRandomSeedInput();
-    G4cout<<"Current random number seed "<<myseed<<G4endl;
-    
-    CLHEP::HepRandom::setTheSeed(myseed);
-    
-    // Run manager
-    G4RunManager *runManager = new G4RunManager;
-
-    // Datafile streams for input and output
-    RichTbIOData *rIOData =  RichTbIOData::getRichTbIODataInstance();
-    
-    //Setup the analysis stuff.
-
-    RichTbAnalysisManager *analysisManager = 
-           RichTbAnalysisManager::getInstance();
-
-    if(rIOData) G4cout<<" IO Data initialized "<<G4endl;
-    if(analysisManager) G4cout<<" Analysis manager initialized "<<G4endl;
-
+  G4long myseed = 755365;
+  //  HepRandom::setTheSeed(myseed);
+
+  // Run manager
+  // G4RunManager *runManager = new G4RunManager;
+  // Job and Run  options.
+
+  RichTbRunConfig *rConfig = RichTbRunConfig::getRunConfigInstance();
+  myseed = rConfig->getRandomSeedInput();
+  G4cout << "Current random number seed " << myseed << G4endl;
+
+  CLHEP::HepRandom::setTheSeed(myseed);
+
+  // Run manager
+  G4RunManager *runManager = new G4RunManager;
+
+  // Datafile streams for input and output
+  RichTbIOData *rIOData = RichTbIOData::getRichTbIODataInstance();
+
+  // Setup the analysis stuff.
+
+  RichTbAnalysisManager *analysisManager = RichTbAnalysisManager::getInstance();
+
+  if (rIOData)
+    G4cout << " IO Data initialized " << G4endl;
+  if (analysisManager)
+    G4cout << " Analysis manager initialized " << G4endl;
+
+  //#ifdef G4VIS_USE
+  // visualization manager
+  RichTbVisManager *visManager = RichTbVisManager::getRichTbVisManagerInstance();
+  //  visManager->SetVerboseLevel(0);
+
+  visManager->Initialise();
+  // #endif
+
+  // UserInitialization classes - mandatory
+  RichTbDetectorConstruction *RichTbDet = new RichTbDetectorConstruction();
+  runManager->SetUserInitialization(RichTbDet);
+  RichTbPhysicsList *RichTbPhy = new RichTbPhysicsList();
+  runManager->SetUserInitialization(RichTbPhy);
+
+  // UserAction classes - optional
+
+  runManager->SetUserAction(new RichTbRunAction());
+  RichTbPrimaryGeneratorAction *PrimaryGenAction = new RichTbPrimaryGeneratorAction();
+  runManager->SetUserAction(PrimaryGenAction);
+  RichTbEventAction *eventAction = new RichTbEventAction();
+  runManager->SetUserAction(eventAction);
+  runManager->SetUserAction(new RichTbStackingAction);
+  RichTbSteppingActionBase *StepActionBase = new RichTbSteppingActionBase();
+  runManager->SetUserAction(StepActionBase);
+
+  runManager->SetUserAction(new RichTbTrackingAction);
+
+  G4UImanager *UI = G4UImanager::GetUIpointer();
+
+  G4UIsession *session = 0;
+  //   UI->ApplyCommand("/run/verbose 2");
+  // UI->ApplyCommand("/control/verbose 2");
+
+  // Initialize G4 kernel
+  runManager->Initialize();
+  // Test for running in batch mode
+  bool batchmode = false;
+  G4int numEvInBatch = 1;
+
+  if (rConfig->getBatchModeFlag() > 0) {
+    batchmode = true;
+    numEvInBatch = rConfig->getNumEventInBatchMode();
+  }
+
+  if (batchmode) {
+    runManager->BeamOn(numEvInBatch);
+    // runManager->BeamOn(200);
+  } else {
+    // ALL GUI stuff commented off for now.
+    // get the pointer to the User Interface manager
+    //  G4UImanager* UI = G4UImanager::GetUIpointer();
+    // G4UIsession* session=0;
+    // User interactions
+    // Define (G)UI for interactive mode
+    if (argc == 1) {
+      //   #ifdef G4UI_USE_XM
+      // session = new G4UIXm(argc,argv);
+      //#else
+      // G4UIterminal is a (dumb) terminal.
+      session = new G4UIterminal;
+      //#endif
+    }
     //#ifdef G4VIS_USE
     // visualization manager
-    RichTbVisManager * visManager =
-      RichTbVisManager::getRichTbVisManagerInstance();
-    //  visManager->SetVerboseLevel(0);
-    
-    visManager->Initialise();
-    // #endif
-
-    // UserInitialization classes - mandatory
-    RichTbDetectorConstruction* RichTbDet = new RichTbDetectorConstruction();
-    runManager->SetUserInitialization(RichTbDet);
-    RichTbPhysicsList* RichTbPhy = new RichTbPhysicsList();
-    runManager->SetUserInitialization(RichTbPhy);
-
-    // UserAction classes - optional
-
-    runManager->SetUserAction(new RichTbRunAction());
-    RichTbPrimaryGeneratorAction *PrimaryGenAction = 
-                         new RichTbPrimaryGeneratorAction();
-    runManager->SetUserAction(PrimaryGenAction);
-    RichTbEventAction *eventAction = 
-                         new RichTbEventAction();
-    runManager->SetUserAction(eventAction);
-    runManager->SetUserAction(new RichTbStackingAction);
-    RichTbSteppingActionBase *StepActionBase = 
-                         new RichTbSteppingActionBase();
-    runManager->SetUserAction(StepActionBase);
-
-    runManager->SetUserAction(new RichTbTrackingAction);
-
-    G4UImanager *UI = G4UImanager::GetUIpointer();
-
-    G4UIsession *session = 0;
-    //   UI->ApplyCommand("/run/verbose 2");
-    // UI->ApplyCommand("/control/verbose 2");
-
-    //Initialize G4 kernel
-    runManager->Initialize();
-    // Test for running in batch mode
-    bool batchmode = false;
-    G4int numEvInBatch = 1;
-
-    if( rConfig -> getBatchModeFlag() >  0 ) {
-      batchmode=true;
-      numEvInBatch= rConfig ->getNumEventInBatchMode();
-    }
-    
-
-    if (batchmode) {
-        runManager->BeamOn( numEvInBatch );
-        // runManager->BeamOn(200);
-    } else {
-        //ALL GUI stuff commented off for now.
-        // get the pointer to the User Interface manager
-        //  G4UImanager* UI = G4UImanager::GetUIpointer();
-        // G4UIsession* session=0;
-        // User interactions
-        // Define (G)UI for interactive mode
-        if (argc == 1) {
-            //   #ifdef G4UI_USE_XM
-            //session = new G4UIXm(argc,argv);
-            //#else
-            // G4UIterminal is a (dumb) terminal.
-            session = new G4UIterminal;
-            //#endif
-        }
-        //#ifdef G4VIS_USE
-        // visualization manager
-        //  G4VisManager* visManager = new RichTbVisManager();
-        // RichTbVisManager* visManager = new RichTbVisManager();
-        //visManager->SetVerboseLevel(0);
-        //visManager->Initialize();
-        //G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
-        //  std::cout << " PVVisManager " << pVVisManager <<  std::endl;
-
-        ///#endif
-
-        if (session) {          // Interactive mode
+    //  G4VisManager* visManager = new RichTbVisManager();
+    // RichTbVisManager* visManager = new RichTbVisManager();
+    // visManager->SetVerboseLevel(0);
+    // visManager->Initialize();
+    // G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
+    //  std::cout << " PVVisManager " << pVVisManager <<  std::endl;
+
+    ///#endif
+
+    if (session) { // Interactive mode
 #ifdef G4UI_USE_XM
-            // Customize the G4UIXm menubar with a macro file :
-            UI->ApplyCommand("/control/execute /afs/cern.ch/user/s/seaso/mycmt/RichTb/v1/macro/gui.mac");
+      // Customize the G4UIXm menubar with a macro file :
+      UI->ApplyCommand("/control/execute /afs/cern.ch/user/s/seaso/mycmt/RichTb/v1/macro/gui.mac");
 #endif
-            UI->ApplyCommand("/run/verbose 0");
-            UI->ApplyCommand("/event/verbose 0");
-            UI->ApplyCommand("/tracking/verbose 2");
-            UI->ApplyCommand("/particle/process/verbose 0");
-
-            //runManager->BeamOn(1);
-
-            session->SessionStart();
-            delete session;
-        } else {                // Batch mode
-            G4UImanager *UI = G4UImanager::GetUIpointer();
-            G4String command = "/control/execute ";
-            G4String fileName = argv[1];
-            UI->ApplyCommand(command + fileName);
-        }
+      UI->ApplyCommand("/run/verbose 0");
+      UI->ApplyCommand("/event/verbose 0");
+      UI->ApplyCommand("/tracking/verbose 2");
+      UI->ApplyCommand("/particle/process/verbose 0");
+
+      // runManager->BeamOn(1);
+
+      session->SessionStart();
+      delete session;
+    } else { // Batch mode
+      G4UImanager *UI = G4UImanager::GetUIpointer();
+      G4String command = "/control/execute ";
+      G4String fileName = argv[1];
+      UI->ApplyCommand(command + fileName);
     }
+  }
 
-    //#ifdef G4VIS_USE
-    delete visManager;
-    // #endif
-
-    G4cout << "\nVisManager deleted..\n" << G4endl;
-
+  //#ifdef G4VIS_USE
+  delete visManager;
+  // #endif
 
-    //  delete analysisManager;
+  G4cout << "\nVisManager deleted..\n" << G4endl;
 
+  //  delete analysisManager;
 
-    delete runManager;
+  delete runManager;
 
-    G4cout << "\nRunManager deleted..\n" << G4endl;
+  G4cout << "\nRunManager deleted..\n" << G4endl;
 
-    return 0;
+  return 0;
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbBeamProperty.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbBeamProperty.cc
index e9d14e77e75b2eac1af2c3898f1b700c1c78ceec..94b02b5581f15579c0b37b4df76793d7e7457962 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbBeamProperty.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbBeamProperty.cc
@@ -1,16 +1,14 @@
 // $Id: $
-// Include files 
-
-
+// Include files
 
 // local
 #include "RichTbBeamProperty.hh"
-#include "RichTbGeometryParameters.hh"
+#include "Geant4/G4OpticalPhoton.hh"
 #include "Geant4/G4ParticleDefinition.hh"
 #include "Geant4/G4PionMinus.hh"
-#include "Geant4/G4OpticalPhoton.hh"
 #include "Geant4/G4PionPlus.hh"
 #include "Geant4/G4Proton.hh"
+#include "RichTbGeometryParameters.hh"
 
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbBeamProperty
@@ -20,19 +18,15 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbBeamProperty* RichTbBeamProperty::RichTbBeamPropertyInstance=0;
+RichTbBeamProperty *RichTbBeamProperty::RichTbBeamPropertyInstance = 0;
+
+RichTbBeamProperty::RichTbBeamProperty() {
 
-RichTbBeamProperty::RichTbBeamProperty(  ) {
-    
-  ResetBeamProperty(); 
-  mNominalBeamPosition = G4ThreeVector(RichTbNominalBeamXPos,
-                                       RichTbNominalBeamYPos,
-                                       RichTbNominalBeamZPos);
-  
-  mNominalBeamDirectionCos= G4ThreeVector(RichTbNominalBeamDirCosX,
-                                          RichTbNominalBeamDirCosY,
-                                          RichTbNominalBeamDirCosZ);
-  
+  ResetBeamProperty();
+  mNominalBeamPosition = G4ThreeVector(RichTbNominalBeamXPos, RichTbNominalBeamYPos, RichTbNominalBeamZPos);
+
+  mNominalBeamDirectionCos =
+      G4ThreeVector(RichTbNominalBeamDirCosX, RichTbNominalBeamDirCosY, RichTbNominalBeamDirCosZ);
 }
 //=============================================================================
 // Destructor
@@ -40,37 +34,26 @@ RichTbBeamProperty::RichTbBeamProperty(  ) {
 RichTbBeamProperty::~RichTbBeamProperty() {}
 
 //=============================================================================
- RichTbBeamProperty* RichTbBeamProperty::getRichTbBeamPropertyInstance() 
-{
-  if( RichTbBeamPropertyInstance == 0 ) {
-    RichTbBeamPropertyInstance= new RichTbBeamProperty( );
-    
+RichTbBeamProperty *RichTbBeamProperty::getRichTbBeamPropertyInstance() {
+  if (RichTbBeamPropertyInstance == 0) {
+    RichTbBeamPropertyInstance = new RichTbBeamProperty();
   }
   return RichTbBeamPropertyInstance;
-  
 }
-void RichTbBeamProperty:: ResetBeamProperty() 
-{
-  mBeamPosition = G4ThreeVector(0.0,0.0,0.0);
-  mBeamDirection = G4ThreeVector(0.0,0.0,1.0);
+void RichTbBeamProperty::ResetBeamProperty() {
+  mBeamPosition = G4ThreeVector(0.0, 0.0, 0.0);
+  mBeamDirection = G4ThreeVector(0.0, 0.0, 1.0);
   mBeamPartDef = G4PionMinus::PionMinusDefinition();
-  mBeamPartName= "pi-";
-  mBeamPosUpstrAgel= G4ThreeVector(0.0,0.0,0.0);
-   mBeamDirUpstrAgel= G4ThreeVector(0.0,0.0,1.0);
-   mAgelNormal =  G4ThreeVector(0.0,0.0,1.0);
-
+  mBeamPartName = "pi-";
+  mBeamPosUpstrAgel = G4ThreeVector(0.0, 0.0, 0.0);
+  mBeamDirUpstrAgel = G4ThreeVector(0.0, 0.0, 1.0);
+  mAgelNormal = G4ThreeVector(0.0, 0.0, 1.0);
 }
-void RichTbBeamProperty::PrintBeamProperty() 
-{
-  G4cout<<"BeamPos XYZ    "<<  mBeamPosition.x() 
-        <<"    "<< mBeamPosition.y()<<"    "
-        << mBeamPosition.z()<<G4endl;
-  G4cout<<"BeamDirection XYZ  AgelNormal XYZ  "<< mBeamDirection.x()
-        << "    "<<mBeamDirection.y()<<"    "
-        <<mBeamDirection.z()<<"   "
-        <<mAgelNormal.x()<<"   "<<mAgelNormal.y()
-        <<"    "<<mAgelNormal.z()<<  G4endl;
-  G4cout<<"Beam Particle Name is  "<<mBeamPartName<<G4endl;
-  
-  
+void RichTbBeamProperty::PrintBeamProperty() {
+  G4cout << "BeamPos XYZ    " << mBeamPosition.x() << "    " << mBeamPosition.y() << "    " << mBeamPosition.z()
+         << G4endl;
+  G4cout << "BeamDirection XYZ  AgelNormal XYZ  " << mBeamDirection.x() << "    " << mBeamDirection.y() << "    "
+         << mBeamDirection.z() << "   " << mAgelNormal.x() << "   " << mAgelNormal.y() << "    " << mAgelNormal.z()
+         << G4endl;
+  G4cout << "Beam Particle Name is  " << mBeamPartName << G4endl;
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbHit.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbHit.cc
index e2f776430ce32d4bedc818523de84e8d4a5b4810..14049d661a1221c6c2e0394a8bbb941f5f1e385b 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbHit.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbHit.cc
@@ -1,16 +1,14 @@
 // $Id: $
-// Include files 
-
-
+// Include files
 
 // local
 #include "RichTbHit.hh"
-#include "Geant4/G4VVisManager.hh"
 #include "Geant4/G4Circle.hh"
 #include "Geant4/G4Colour.hh"
-#include "Geant4/G4VisAttributes.hh"
-#include "Geant4/G4Transform3D.hh"
 #include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4Transform3D.hh"
+#include "Geant4/G4VVisManager.hh"
+#include "Geant4/G4VisAttributes.hh"
 #include "RichTbVisManager.hh"
 G4Allocator<RichTbHit> RichTbHitAllocator;
 
@@ -23,165 +21,138 @@ G4Allocator<RichTbHit> RichTbHitAllocator;
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbHit::RichTbHit(  ) {
-
-}
+RichTbHit::RichTbHit() {}
 //=============================================================================
 // Destructor
 //=============================================================================
 RichTbHit::~RichTbHit() {}
-RichTbHit::RichTbHit(const RichTbHit &right):G4VHit(right)
-{
+RichTbHit::RichTbHit(const RichTbHit &right) : G4VHit(right) {
   edep = right.edep;
   pos = right.pos;
   CurPMTNum = right.CurPMTNum;
-  CurPixelNum=right.CurPixelNum;
-
-  mLocalPos=right.mLocalPos;
-  mPeOrigin=right.mPeOrigin;
-  mPhotonOrigin=right.mPhotonOrigin;
-  mRayleighScatFlag=right.mRayleighScatFlag;
-  mPhotonIncidenceOnPMTQW=right. mPhotonIncidenceOnPMTQW;
-  mCkvCosThetaProd=right.mCkvCosThetaProd;
-  mCkvPhiProd=right.mCkvPhiProd;
-  mCkvEnergyProd=right.mCkvEnergyProd;
-  mPhotonMultIncidenceQW=right.mPhotonMultIncidenceQW;
+  CurPixelNum = right.CurPixelNum;
+
+  mLocalPos = right.mLocalPos;
+  mPeOrigin = right.mPeOrigin;
+  mPhotonOrigin = right.mPhotonOrigin;
+  mRayleighScatFlag = right.mRayleighScatFlag;
+  mPhotonIncidenceOnPMTQW = right.mPhotonIncidenceOnPMTQW;
+  mCkvCosThetaProd = right.mCkvCosThetaProd;
+  mCkvPhiProd = right.mCkvPhiProd;
+  mCkvEnergyProd = right.mCkvEnergyProd;
+  mPhotonMultIncidenceQW = right.mPhotonMultIncidenceQW;
   mPeOriginInPhSupport = right.mPeOriginInPhSupport;
   mPhEmissionDir = right.mPhEmissionDir;
   mPixelLocalCenter = right.mPixelLocalCenter;
   mPixelGlobalCenter = right.mPixelGlobalCenter;
-  mTIRRadiatorCoord  = right.mTIRRadiatorCoord;
-  mMIRRadiatorCoord  = right.mMIRRadiatorCoord;
-  mRFRRadiatorCoord  = right.mRFRRadiatorCoord;
+  mTIRRadiatorCoord = right.mTIRRadiatorCoord;
+  mMIRRadiatorCoord = right.mMIRRadiatorCoord;
+  mRFRRadiatorCoord = right.mRFRRadiatorCoord;
   mMultipleReflFlag = right.mMultipleReflFlag;
-  mChTrackTotMom  = right.mChTrackTotMom;
+  mChTrackTotMom = right.mChTrackTotMom;
   mChTrackThreeMom = right.mChTrackThreeMom;
   mHitInPixelGapFlag = right.mHitInPixelGapFlag;
-  
 }
-const RichTbHit& RichTbHit::operator=(const RichTbHit &right)
-{
+const RichTbHit &RichTbHit::operator=(const RichTbHit &right) {
   edep = right.edep;
   pos = right.pos;
   CurPMTNum = right.CurPMTNum;
-  CurPixelNum=right.CurPixelNum;
-
-  mLocalPos=right.mLocalPos;
-  mPeOrigin=right.mPeOrigin;
-  mPhotonOrigin=right.mPhotonOrigin;
-  mRayleighScatFlag=right.mRayleighScatFlag;
-  mPhotonIncidenceOnPMTQW=right. mPhotonIncidenceOnPMTQW;
-  mCkvCosThetaProd=right.mCkvCosThetaProd;
-  mCkvPhiProd=right.mCkvPhiProd;
-  mCkvEnergyProd=right.mCkvEnergyProd;
-  mPhotonMultIncidenceQW=right.mPhotonMultIncidenceQW;
+  CurPixelNum = right.CurPixelNum;
+
+  mLocalPos = right.mLocalPos;
+  mPeOrigin = right.mPeOrigin;
+  mPhotonOrigin = right.mPhotonOrigin;
+  mRayleighScatFlag = right.mRayleighScatFlag;
+  mPhotonIncidenceOnPMTQW = right.mPhotonIncidenceOnPMTQW;
+  mCkvCosThetaProd = right.mCkvCosThetaProd;
+  mCkvPhiProd = right.mCkvPhiProd;
+  mCkvEnergyProd = right.mCkvEnergyProd;
+  mPhotonMultIncidenceQW = right.mPhotonMultIncidenceQW;
   mPeOriginInPhSupport = right.mPeOriginInPhSupport;
   mPhEmissionDir = right.mPhEmissionDir;
   mPixelLocalCenter = right.mPixelLocalCenter;
   mPixelGlobalCenter = right.mPixelGlobalCenter;
-  mTIRRadiatorCoord  = right.mTIRRadiatorCoord;
-  mMIRRadiatorCoord  = right.mMIRRadiatorCoord;
-  mRFRRadiatorCoord  = right.mRFRRadiatorCoord;
+  mTIRRadiatorCoord = right.mTIRRadiatorCoord;
+  mMIRRadiatorCoord = right.mMIRRadiatorCoord;
+  mRFRRadiatorCoord = right.mRFRRadiatorCoord;
   mMultipleReflFlag = right.mMultipleReflFlag;
-  mChTrackTotMom  = right.mChTrackTotMom;
+  mChTrackTotMom = right.mChTrackTotMom;
   mChTrackThreeMom = right.mChTrackThreeMom;
   mHitInPixelGapFlag = right.mHitInPixelGapFlag;
-  
-
 
   return *this;
- 
-}
-int RichTbHit::operator==(const RichTbHit &right) const
-{
-  return 0;
 }
+int RichTbHit::operator==(const RichTbHit & /* right */) const { return 0; }
 
-void RichTbHit::Draw()
-{
+void RichTbHit::Draw() {
 
   // The folowing does not work anymore .. SE 26-04-01
-  G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
-
-  if(pVVisManager)
-   {
-
-     //  G4Circle circle(pos);
-     // circle.SetScreenSize(0.04);
-     // circle.SetFillStyle(G4Circle::filled);
-     // G4Colour colour(1.0,0.0,0.0);
-     // G4VisAttributes attribs(colour);
-     // circle.SetVisAttributes(attribs);
-     //pVVisManager->Draw(circle);
+  G4VVisManager *pVVisManager = G4VVisManager::GetConcreteInstance();
+
+  if (pVVisManager) {
+
+    //  G4Circle circle(pos);
+    // circle.SetScreenSize(0.04);
+    // circle.SetFillStyle(G4Circle::filled);
+    // G4Colour colour(1.0,0.0,0.0);
+    // G4VisAttributes attribs(colour);
+    // circle.SetVisAttributes(attribs);
+    // pVVisManager->Draw(circle);
   }
 }
-void RichTbHit::DrawWithVisM(RichTbVisManager* pVisManager)
-{
-
-  G4VisManager* pVVisManager = pVisManager;
-  if(pVVisManager)
-   {
-
-     //  G4Circle circle(pos);
-     // circle.SetScreenSize(0.04);
-     //  circle.SetFillStyle(G4Circle::filled);
-     // G4Colour colour(1.0,0.0,0.0);
-     // G4VisAttributes attribs(colour);
-     // circle.SetVisAttributes(attribs);
-     // const  G4Circle aCircle=  circle;
-     // const G4Transform3D aTransform;
-  
-     // pVVisManager->Draw(aCircle, aTransform);
+void RichTbHit::DrawWithVisM(RichTbVisManager *pVisManager) {
+
+  G4VisManager *pVVisManager = pVisManager;
+  if (pVVisManager) {
+
+    //  G4Circle circle(pos);
+    // circle.SetScreenSize(0.04);
+    //  circle.SetFillStyle(G4Circle::filled);
+    // G4Colour colour(1.0,0.0,0.0);
+    // G4VisAttributes attribs(colour);
+    // circle.SetVisAttributes(attribs);
+    // const  G4Circle aCircle=  circle;
+    // const G4Transform3D aTransform;
+
+    // pVVisManager->Draw(aCircle, aTransform);
   }
 }
-void RichTbHit::Print()
-{
+void RichTbHit::Print() {
   // To print the info in the G4hit class.
-  G4cout<<" RichTbHit: Now Printing the info for a Hit "<<G4endl;
-  G4cout<<"RichTbHit: PMT Pix edep  "<<  CurPMTNum <<"  "<< CurPixelNum
-        <<"   "<<  edep<<G4endl;
-  G4cout<<"RichTbHit:XYZ  GlobalPos   "
-        << pos.x()<<"  "<<pos.y()<<"  "<<pos.z() <<" LocalPos "
-        <<mLocalPos.x()<<"  " <<mLocalPos.y()<<"  "<<mLocalPos.z()<<G4endl;
-  G4cout<<"RichTbHit:XYZ PeOrigin  "<<mPeOrigin.x() <<"   "
-        <<mPeOrigin.y()<<"   "<<mPeOrigin.z()<<" QWIncidence "
-        << mPhotonIncidenceOnPMTQW.x()<<"   "
-         << mPhotonIncidenceOnPMTQW.y()<<"   "
-        << mPhotonIncidenceOnPMTQW.z()<<G4endl;
-  G4cout<<" PeOrigin in Ph Support XYZ   "<<
-    mPeOriginInPhSupport.x()<<"   "<<mPeOriginInPhSupport.y()
-        <<"   "<<mPeOriginInPhSupport.z()<<G4endl;
-  
-  
-  G4cout<<"RichTbHit: NumPMTQWIncidence CosCkv Phi PhotEnergy  "
-        << mPhotonMultIncidenceQW<<"   "<<mCkvCosThetaProd
-        <<"    "<< mCkvPhiProd<<"   "<<mCkvEnergyProd<<G4endl;
-
-  G4cout<<" Global Photon dir XYZ at its origin   " <<mPhEmissionDir.x()
-	<<"  "<<mPhEmissionDir.y()<<"   "<<mPhEmissionDir.z()<<G4endl;
-
-  G4cout<<" RichTbHit Local Global pixel center "<< mPixelLocalCenter <<"  "
-        << mPixelGlobalCenter << G4endl; 
-
-  G4cout<<"RichTbHit: End of Printing the info for a Hit "<<G4endl;
-  
-  G4cout<<" RichTbHit TIR MIR RFR coord "<<mTIRRadiatorCoord<<"   "
-        <<mMIRRadiatorCoord<<"   "<<mRFRRadiatorCoord<<G4endl;
-  
-  G4cout<<" RichTbHit: Multrefl flag "<< mMultipleReflFlag <<G4endl;
-  G4cout<< "RichTbHit: Ch Track tot MOm ThreeMom " << mChTrackTotMom
-        <<"   "<< mChTrackThreeMom <<G4endl;
-  
+  G4cout << " RichTbHit: Now Printing the info for a Hit " << G4endl;
+  G4cout << "RichTbHit: PMT Pix edep  " << CurPMTNum << "  " << CurPixelNum << "   " << edep << G4endl;
+  G4cout << "RichTbHit:XYZ  GlobalPos   " << pos.x() << "  " << pos.y() << "  " << pos.z() << " LocalPos "
+         << mLocalPos.x() << "  " << mLocalPos.y() << "  " << mLocalPos.z() << G4endl;
+  G4cout << "RichTbHit:XYZ PeOrigin  " << mPeOrigin.x() << "   " << mPeOrigin.y() << "   " << mPeOrigin.z()
+         << " QWIncidence " << mPhotonIncidenceOnPMTQW.x() << "   " << mPhotonIncidenceOnPMTQW.y() << "   "
+         << mPhotonIncidenceOnPMTQW.z() << G4endl;
+  G4cout << " PeOrigin in Ph Support XYZ   " << mPeOriginInPhSupport.x() << "   " << mPeOriginInPhSupport.y() << "   "
+         << mPeOriginInPhSupport.z() << G4endl;
+
+  G4cout << "RichTbHit: NumPMTQWIncidence CosCkv Phi PhotEnergy  " << mPhotonMultIncidenceQW << "   "
+         << mCkvCosThetaProd << "    " << mCkvPhiProd << "   " << mCkvEnergyProd << G4endl;
+
+  G4cout << " Global Photon dir XYZ at its origin   " << mPhEmissionDir.x() << "  " << mPhEmissionDir.y() << "   "
+         << mPhEmissionDir.z() << G4endl;
+
+  G4cout << " RichTbHit Local Global pixel center " << mPixelLocalCenter << "  " << mPixelGlobalCenter << G4endl;
+
+  G4cout << "RichTbHit: End of Printing the info for a Hit " << G4endl;
+
+  G4cout << " RichTbHit TIR MIR RFR coord " << mTIRRadiatorCoord << "   " << mMIRRadiatorCoord << "   "
+         << mRFRRadiatorCoord << G4endl;
+
+  G4cout << " RichTbHit: Multrefl flag " << mMultipleReflFlag << G4endl;
+  G4cout << "RichTbHit: Ch Track tot MOm ThreeMom " << mChTrackTotMom << "   " << mChTrackThreeMom << G4endl;
 }
 // This is a forward declarations of an instantiated G4Allocator<Type> object.
-// It has been added in order to make code portable for the GNU g++ 
-// (release 2.7.2) compiler. 
+// It has been added in order to make code portable for the GNU g++
+// (release 2.7.2) compiler.
 // Whenever a new Type is instantiated via G4Allocator, it has to be forward
-// declared to make object code (compiled with GNU g++) link successfully. 
-// 
+// declared to make object code (compiled with GNU g++) link successfully.
+//
 #ifdef GNU_GCC
-  template class G4Allocator<RichTbHit>;
+template class G4Allocator<RichTbHit>;
 #endif
 
-
 //=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbIOData.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbIOData.cc
index 274ea17b424ff22253e3f1ad99dbce5315ab0357..3c4cfa036ed6f5584242da8887045c3c41ec7bf4 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbIOData.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbIOData.cc
@@ -1,55 +1,45 @@
 #include "RichTbIOData.hh"
 #include "Geant4/G4HCofThisEvent.hh"
-#include "Geant4/G4VHitsCollection.hh"
 #include "Geant4/G4SDManager.hh"
-#include "Geant4/G4ios.hh"
 #include "Geant4/G4ThreeVector.hh"
+#include "Geant4/G4VHitsCollection.hh"
+#include "Geant4/G4ios.hh"
+#include "RichTbBeamProperty.hh"
 #include "RichTbHit.hh"
-#include <fstream>
 #include "RichTbMiscNames.hh"
-#include "RichTbBeamProperty.hh"
+#include <fstream>
 
 // CHANGED JDICKENS (02/06/05)
-#include "RichTbUpgradeMirror.hh"
 #include "RichTbGeometryParameters.hh"
+#include "RichTbUpgradeMirror.hh"
 // END OF CHANGE
 
+RichTbIOData *RichTbIOData::RichTbIODataInstance = 0;
 
-RichTbIOData* RichTbIOData::RichTbIODataInstance=0;
-
-RichTbIOData::RichTbIOData( )
-:  OutputDataFS(((RichTbRunConfig::getRunConfigInstance())
-               ->getOutputFileName()).c_str()),
-  m_IsFirstEvent(true) {
+RichTbIOData::RichTbIOData()
+    : OutputDataFS(((RichTbRunConfig::getRunConfigInstance())->getOutputFileName()).c_str()), m_IsFirstEvent(true) {
 
-  RichTbRunConfig* RConfig = RichTbRunConfig::getRunConfigInstance();
+  RichTbRunConfig *RConfig = RichTbRunConfig::getRunConfigInstance();
 
   //  OutputDataFS((RConfig->getOutputFileName()).c_str());
   aOutFileString = RConfig->getOutputFileName();
 
-    //   const char* aOutFilechar = aOutFileString.c_str();
-
-    //    std::ofstream  OutputDataFS(aOutFileString.c_str());
+  //   const char* aOutFilechar = aOutFileString.c_str();
 
+  //    std::ofstream  OutputDataFS(aOutFileString.c_str());
 }
 
+RichTbIOData::~RichTbIOData() {}
 
-RichTbIOData::~RichTbIOData()
-{
-}
-
-
-void RichTbIOData::WriteOutEventHeaderData(const G4Event * evt)
-{
-  RichTbRunConfig* RConfig = RichTbRunConfig::getRunConfigInstance();
-  G4int curVerboseOutputLevel=  RConfig->VerboseOutputFileFlag();
-  RichTbBeamProperty* aBeamProperty=
-    RichTbBeamProperty::getRichTbBeamPropertyInstance();
-  G4ThreeVector aBeamPos =  aBeamProperty->getBeamPosition();
-  G4ThreeVector aBeamDir =  aBeamProperty-> getBeamDirection();
+void RichTbIOData::WriteOutEventHeaderData(const G4Event *evt) {
+  RichTbRunConfig *RConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int curVerboseOutputLevel = RConfig->VerboseOutputFileFlag();
+  RichTbBeamProperty *aBeamProperty = RichTbBeamProperty::getRichTbBeamPropertyInstance();
+  G4ThreeVector aBeamPos = aBeamProperty->getBeamPosition();
+  G4ThreeVector aBeamDir = aBeamProperty->getBeamDirection();
   G4int aRadConf = RConfig->getRadiatorConfiguration();
 
-   // aBeamProperty->  PrintBeamProperty();
+  // aBeamProperty->  PrintBeamProperty();
 
   // CHANGED JDICKENS (02/06/05)
   /*
@@ -58,30 +48,28 @@ void RichTbIOData::WriteOutEventHeaderData(const G4Event * evt)
   */
   // END OF CHANGE
 
-  G4SDManager * SDman = G4SDManager::GetSDMpointer();
+  G4SDManager *SDman = G4SDManager::GetSDMpointer();
   G4String colNam;
-  G4int RichTbCID = SDman->GetCollectionID(colNam=RichTbHColname);
-  if(RichTbCID<0) return;
-  G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
-  RichTbHitsCollection* RHC = NULL;
-  if(HCE)
-  {
-    RHC = (RichTbHitsCollection*)(HCE->GetHC(RichTbCID));
+  G4int RichTbCID = SDman->GetCollectionID(colNam = RichTbHColname);
+  if (RichTbCID < 0)
+    return;
+  G4HCofThisEvent *HCE = evt->GetHCofThisEvent();
+  RichTbHitsCollection *RHC = NULL;
+  if (HCE) {
+    RHC = (RichTbHitsCollection *)(HCE->GetHC(RichTbCID));
   }
 
- if(RHC)
-  {
+  if (RHC) {
     G4int n_hit = RHC->entries();
     // G4cout << "     " << n_hit << "Hits being written out "<<G4endl;
 
-    if(  m_IsFirstEvent ) {
+    if (m_IsFirstEvent) {
       // now write the overall header word.
       // This is , for now , the verbose level.
-      OutputDataFS<< curVerboseOutputLevel<< std::endl;
-
-      //write radiator configuration (BLAGO 01/07/15)
-      OutputDataFS<< aRadConf<< std::endl;
+      OutputDataFS << curVerboseOutputLevel << std::endl;
 
+      // write radiator configuration (BLAGO 01/07/15)
+      OutputDataFS << aRadConf << std::endl;
 
       // CHANGED TO WRITE OUT MIRROR CoC (JDICKENS 02/06/05)
       /*
@@ -95,187 +83,121 @@ void RichTbIOData::WriteOutEventHeaderData(const G4Event * evt)
       G4double MirrorCoCZ = MirrorPivotZInGlobalArray[MirrorCode] - MirrorInnerRadius * MirrorDirCosZArray[MirrorCode];
 
       OutputDataFS << MirrorCoCX << "  "
-		   << MirrorCoCY << "  "
-		   << MirrorCoCZ << "  "
-		   << MirrorInnerRadius << std::endl;
+                   << MirrorCoCY << "  "
+                   << MirrorCoCZ << "  "
+                   << MirrorInnerRadius << std::endl;
       */
       // END OF CHANGE
 
-      m_IsFirstEvent=false;
-
+      m_IsFirstEvent = false;
     }
 
-    if( curVerboseOutputLevel  < 1 ) {
-
-      OutputDataFS<<n_hit<< std::endl;
+    if (curVerboseOutputLevel < 1) {
 
-    } else if ( curVerboseOutputLevel  < 3 ) {
-      OutputDataFS<<n_hit<< "   "
-                  << aBeamDir.x()<<"   "<<aBeamDir.y()
-                  <<"   "<<aBeamDir.z()<<"   "
-                  <<std::endl;
-    } else if ( curVerboseOutputLevel  < 5 ) {
+      OutputDataFS << n_hit << std::endl;
 
-     OutputDataFS<<n_hit<< "   "
-                << aBeamPos.x()<<"   "<<aBeamPos.y()
-                << "   "<< aBeamPos.z()<<"   "
-                << aBeamDir.x()<<"   "<<aBeamDir.y()
-                <<"   "<<aBeamDir.z()<<"   "
-                << std::endl;
+    } else if (curVerboseOutputLevel < 3) {
+      OutputDataFS << n_hit << "   " << aBeamDir.x() << "   " << aBeamDir.y() << "   " << aBeamDir.z() << "   "
+                   << std::endl;
+    } else if (curVerboseOutputLevel < 5) {
 
+      OutputDataFS << n_hit << "   " << aBeamPos.x() << "   " << aBeamPos.y() << "   " << aBeamPos.z() << "   "
+                   << aBeamDir.x() << "   " << aBeamDir.y() << "   " << aBeamDir.z() << "   " << std::endl;
     }
-
-
-
   }
-
-
-
-
 }
 
+void RichTbIOData::WriteOutHitData(const G4Event *evt) {
+  RichTbRunConfig *RConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int curVerboseOutputLevel = RConfig->VerboseOutputFileFlag();
 
-void RichTbIOData::WriteOutHitData(const G4Event * evt)
-{
-  RichTbRunConfig* RConfig = RichTbRunConfig::getRunConfigInstance();
-  G4int curVerboseOutputLevel=  RConfig->VerboseOutputFileFlag();
-
-
-  G4SDManager * SDman = G4SDManager::GetSDMpointer();
+  G4SDManager *SDman = G4SDManager::GetSDMpointer();
   G4String colNam;
-  G4int RichTbCID = SDman->GetCollectionID(colNam=RichTbHColname);
-  if(RichTbCID<0) return;
-  G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
-  RichTbHitsCollection* RHC = NULL;
-  if(HCE)
-  {
-    RHC = (RichTbHitsCollection*)(HCE->GetHC(RichTbCID));
+  G4int RichTbCID = SDman->GetCollectionID(colNam = RichTbHColname);
+  if (RichTbCID < 0)
+    return;
+  G4HCofThisEvent *HCE = evt->GetHCofThisEvent();
+  RichTbHitsCollection *RHC = NULL;
+  if (HCE) {
+    RHC = (RichTbHitsCollection *)(HCE->GetHC(RichTbCID));
   }
 
- if(RHC)
-  {
+  if (RHC) {
     G4int n_hit = RHC->entries();
     //    G4cout << "     " << n_hit << "Hits being written out "<<G4endl;
 
-    for (G4int ih=0; ih<n_hit; ih++ ) {
-      RichTbHit* aHit = (*RHC)[ih];
-      G4int aHitPMTNum = aHit -> GetCurPMTNum();
-      G4int aHitPixelNum = aHit -> GetCurPixNum();
-      G4ThreeVector aHitPos = aHit -> GetPos();
-      G4double aEdep =  aHit ->GetEdep() ;
-      G4ThreeVector aHitLocalPos =  aHit ->GetLocalPos();
-      G4ThreeVector aHitPeOrigin = aHit ->  GetPeOrigin();
+    for (G4int ih = 0; ih < n_hit; ih++) {
+      RichTbHit *aHit = (*RHC)[ih];
+      G4int aHitPMTNum = aHit->GetCurPMTNum();
+      G4int aHitPixelNum = aHit->GetCurPixNum();
+      G4ThreeVector aHitPos = aHit->GetPos();
+      G4double aEdep = aHit->GetEdep();
+      G4ThreeVector aHitLocalPos = aHit->GetLocalPos();
+      G4ThreeVector aHitPeOrigin = aHit->GetPeOrigin();
       G4ThreeVector aHitPhOrigin = aHit->GetPhotonOrigin();
-      G4ThreeVector  aHitPhOnQW =  aHit -> GetPhotonIncidenceOnPMTQW();
-      G4double aHitCkvCosTh =   aHit ->GetCkvCosThetaProd();
-      G4double aHitCkvPhi = aHit ->GetCkvPhiProd();
-      G4double aHitCkvPhEner =  aHit -> GetCkvEnergyProd() ;
-      G4int aHitRayleighFlag =  aHit ->GetRayleighScatFlag();
-      G4int aHitMultPMTQWFlag = aHit -> GetPhotonMultIncidenceQW() ;
-      G4ThreeVector aPeOriginInPhSupFrame =aHit -> GetPeOriginInPhSupport();
-      G4ThreeVector aPhEmisDir =  aHit -> GetPhEmissionDir();
-      G4ThreeVector aPixelLocalCenter = aHit ->  getPixelLocalCenter();
-      G4ThreeVector aPixelGlobalCenter = aHit ->  getPixelGlobalCenter() ;
-      G4ThreeVector aTIRCoord=  aHit -> getTIRRadiatorCoord();
-      G4ThreeVector aMIRCoord=  aHit -> getMIRRadiatorCoord();
-      G4ThreeVector aRFRCoord=  aHit -> getRFRRadiatorCoord();
-      G4int aMultRefl = aHit ->getMultipleReflFlag();
-      G4double aChTkTotMom =aHit ->getChTrackTotMom();
-      G4ThreeVector aChTrackThreeMom = aHit ->getChTrackThreeMom ();
-
-
-
-      if( curVerboseOutputLevel < 1 ) {
-      OutputDataFS<<"   "<< aHitPMTNum<<"   "<<aHitPixelNum
-                  <<"   "<<aHitPos.x()<<"   "<<aHitPos.y()
-                  <<"   "<<aHitPos.z()<<"   "<< aEdep <<std::endl;
-
-
-      }else if ( curVerboseOutputLevel < 2 ) {
-
-      OutputDataFS<<"   "<< aHitPMTNum<<"   "<<aHitPixelNum
-                  <<"   "<<aHitPos.x()<<"   "<<aHitPos.y()
-                  <<"   "<<aHitPos.z()<<"   "<< aEdep
-                  <<"   "<<aHitPeOrigin.x()<<"   "<<aHitPeOrigin.y()
-                  <<"   "<<aHitPeOrigin.z()<<"   "<<aHitPhOnQW.x()
-                  <<"   "<<aHitPhOnQW.y()  <<"   "<<aHitPhOnQW.z()
-                  <<"   "<<aHitCkvCosTh    <<"   "<<aHitCkvPhEner
-                  <<"   "<<aHitRayleighFlag <<std::endl;
-      } else if ( curVerboseOutputLevel < 3 ) {
-
-      OutputDataFS<<"   "<< aHitPMTNum<<"   "<<aHitPixelNum
-                  <<"   "<<aHitPos.x()<<"   "<<aHitPos.y()
-                  <<"   "<<aHitPos.z()<<"   "<< aEdep
-                  <<"   "<<aHitPeOrigin.x()<<"   "<<aHitPeOrigin.y()
-                  <<"   "<<aHitPeOrigin.z()<<"   "<<aHitPhOnQW.x()
-                  <<"   "<<aHitPhOnQW.y()  <<"   "<<aHitPhOnQW.z()
-                  <<"   "<<aHitCkvCosTh    <<"   "<<aHitCkvPhEner
-                  <<"   "<<aHitRayleighFlag
-                  <<"   "<<aPeOriginInPhSupFrame.x()
-                  <<"   "<<aPeOriginInPhSupFrame.y()
-                  <<"   "<<aPeOriginInPhSupFrame.z()
-                  <<"    "<<aHitPhOrigin.x()
-                  <<"    "<<aHitPhOrigin.y()
-                  <<"    "<<aHitPhOrigin.z()
-                  <<"    "<<aPhEmisDir.x()
-                  <<"    "<<aPhEmisDir.y()
-                  <<"    "<<aPhEmisDir.z()
-                  <<"    "<<aPixelLocalCenter.x()
-                  <<"    "<<aPixelLocalCenter.y()
-                  <<"    "<<aPixelLocalCenter.z()
-                  <<"    "<<aPixelGlobalCenter.x()
-                  <<"    "<<aPixelGlobalCenter.y()
-                  <<"    "<<aPixelGlobalCenter.z()
-                  <<"    "<< aMultRefl
-                  <<"    "<< aTIRCoord.x()
-                  <<"    "<< aTIRCoord.y()
-                  <<"    "<< aTIRCoord.z()
-                  <<"    "<< aMIRCoord.x()
-                  <<"    "<< aMIRCoord.y()
-                  <<"    "<< aMIRCoord.z()
-                  <<"    "<< aRFRCoord.x()
-                  <<"    "<< aRFRCoord.y()
-                  <<"    "<< aRFRCoord.z()
-                  <<"    "<< aChTkTotMom
-                  <<"    "<< aChTrackThreeMom.x()
-                  <<"    "<< aChTrackThreeMom.y()
-                  <<"    "<< aChTrackThreeMom.z()
-                  <<std::endl;
-
-      } else if (curVerboseOutputLevel < 5 ) {
-
-
-      OutputDataFS<<"   "<< aHitPMTNum<<"   "<<aHitPixelNum
-                  <<"   "<<aHitPos.x()<<"   "<<aHitPos.y()
-                  <<"   "<<aHitPos.z()<<"   "<< aEdep
-                  <<"   "<<aHitLocalPos.x()<<"   "<<aHitLocalPos.y()
-                  <<"   "<<aHitLocalPos.z()<<"   "<<aHitPeOrigin.x()
-                  <<"   "<<aHitPeOrigin.y()<<"   "<<aHitPeOrigin.z()
-                  <<"   "<< aHitPhOnQW.x()<<"   "<<aHitPhOnQW.y()
-                  <<"   "<< aHitPhOnQW.z()<<"   "<<aHitCkvCosTh
-                  <<"   "<< aHitCkvPhi<<"   "<<aHitCkvPhEner
-                  <<"   "<< aHitRayleighFlag<<"   "<<aHitMultPMTQWFlag
-                  <<"    "<< aHitPhOrigin.x()<<"   "<<  aHitPhOrigin.y()
-                  <<"     "<<aHitPhOrigin.z()
-                  <<std::endl;
+      G4ThreeVector aHitPhOnQW = aHit->GetPhotonIncidenceOnPMTQW();
+      G4double aHitCkvCosTh = aHit->GetCkvCosThetaProd();
+      G4double aHitCkvPhi = aHit->GetCkvPhiProd();
+      G4double aHitCkvPhEner = aHit->GetCkvEnergyProd();
+      G4int aHitRayleighFlag = aHit->GetRayleighScatFlag();
+      G4int aHitMultPMTQWFlag = aHit->GetPhotonMultIncidenceQW();
+      G4ThreeVector aPeOriginInPhSupFrame = aHit->GetPeOriginInPhSupport();
+      G4ThreeVector aPhEmisDir = aHit->GetPhEmissionDir();
+      G4ThreeVector aPixelLocalCenter = aHit->getPixelLocalCenter();
+      G4ThreeVector aPixelGlobalCenter = aHit->getPixelGlobalCenter();
+      G4ThreeVector aTIRCoord = aHit->getTIRRadiatorCoord();
+      G4ThreeVector aMIRCoord = aHit->getMIRRadiatorCoord();
+      G4ThreeVector aRFRCoord = aHit->getRFRRadiatorCoord();
+      G4int aMultRefl = aHit->getMultipleReflFlag();
+      G4double aChTkTotMom = aHit->getChTrackTotMom();
+      G4ThreeVector aChTrackThreeMom = aHit->getChTrackThreeMom();
+
+      if (curVerboseOutputLevel < 1) {
+        OutputDataFS << "   " << aHitPMTNum << "   " << aHitPixelNum << "   " << aHitPos.x() << "   " << aHitPos.y()
+                     << "   " << aHitPos.z() << "   " << aEdep << std::endl;
+
+      } else if (curVerboseOutputLevel < 2) {
+
+        OutputDataFS << "   " << aHitPMTNum << "   " << aHitPixelNum << "   " << aHitPos.x() << "   " << aHitPos.y()
+                     << "   " << aHitPos.z() << "   " << aEdep << "   " << aHitPeOrigin.x() << "   " << aHitPeOrigin.y()
+                     << "   " << aHitPeOrigin.z() << "   " << aHitPhOnQW.x() << "   " << aHitPhOnQW.y() << "   "
+                     << aHitPhOnQW.z() << "   " << aHitCkvCosTh << "   " << aHitCkvPhEner << "   " << aHitRayleighFlag
+                     << std::endl;
+      } else if (curVerboseOutputLevel < 3) {
+
+        OutputDataFS << "   " << aHitPMTNum << "   " << aHitPixelNum << "   " << aHitPos.x() << "   " << aHitPos.y()
+                     << "   " << aHitPos.z() << "   " << aEdep << "   " << aHitPeOrigin.x() << "   " << aHitPeOrigin.y()
+                     << "   " << aHitPeOrigin.z() << "   " << aHitPhOnQW.x() << "   " << aHitPhOnQW.y() << "   "
+                     << aHitPhOnQW.z() << "   " << aHitCkvCosTh << "   " << aHitCkvPhEner << "   " << aHitRayleighFlag
+                     << "   " << aPeOriginInPhSupFrame.x() << "   " << aPeOriginInPhSupFrame.y() << "   "
+                     << aPeOriginInPhSupFrame.z() << "    " << aHitPhOrigin.x() << "    " << aHitPhOrigin.y() << "    "
+                     << aHitPhOrigin.z() << "    " << aPhEmisDir.x() << "    " << aPhEmisDir.y() << "    "
+                     << aPhEmisDir.z() << "    " << aPixelLocalCenter.x() << "    " << aPixelLocalCenter.y() << "    "
+                     << aPixelLocalCenter.z() << "    " << aPixelGlobalCenter.x() << "    " << aPixelGlobalCenter.y()
+                     << "    " << aPixelGlobalCenter.z() << "    " << aMultRefl << "    " << aTIRCoord.x() << "    "
+                     << aTIRCoord.y() << "    " << aTIRCoord.z() << "    " << aMIRCoord.x() << "    " << aMIRCoord.y()
+                     << "    " << aMIRCoord.z() << "    " << aRFRCoord.x() << "    " << aRFRCoord.y() << "    "
+                     << aRFRCoord.z() << "    " << aChTkTotMom << "    " << aChTrackThreeMom.x() << "    "
+                     << aChTrackThreeMom.y() << "    " << aChTrackThreeMom.z() << std::endl;
+
+      } else if (curVerboseOutputLevel < 5) {
+
+        OutputDataFS << "   " << aHitPMTNum << "   " << aHitPixelNum << "   " << aHitPos.x() << "   " << aHitPos.y()
+                     << "   " << aHitPos.z() << "   " << aEdep << "   " << aHitLocalPos.x() << "   " << aHitLocalPos.y()
+                     << "   " << aHitLocalPos.z() << "   " << aHitPeOrigin.x() << "   " << aHitPeOrigin.y() << "   "
+                     << aHitPeOrigin.z() << "   " << aHitPhOnQW.x() << "   " << aHitPhOnQW.y() << "   "
+                     << aHitPhOnQW.z() << "   " << aHitCkvCosTh << "   " << aHitCkvPhi << "   " << aHitCkvPhEner
+                     << "   " << aHitRayleighFlag << "   " << aHitMultPMTQWFlag << "    " << aHitPhOrigin.x() << "   "
+                     << aHitPhOrigin.y() << "     " << aHitPhOrigin.z() << std::endl;
       }
-
     }
-
-
   }
-
-
 }
 
-RichTbIOData* RichTbIOData::getRichTbIODataInstance()
-{
-  if(  RichTbIODataInstance == 0) {
+RichTbIOData *RichTbIOData::getRichTbIODataInstance() {
+  if (RichTbIODataInstance == 0) {
     RichTbIODataInstance = new RichTbIOData();
-
   }
 
   return RichTbIODataInstance;
-
-
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbPmtPixelEfficiency.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbPmtPixelEfficiency.cc
index 7e7b8890ffb09c7fd8628ba40548ecd1c2ab4ac6..363964b57fe18a611a5c2ab7cbcacb54806113ca 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbPmtPixelEfficiency.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbPmtPixelEfficiency.cc
@@ -1,19 +1,17 @@
 // Include files
 
-
-#include <iostream>
-#include "Geant4/globals.hh"
 #include "Geant4/Randomize.hh"
+#include "Geant4/globals.hh"
 #include <cstdlib>
 #include <fstream>
+#include <iostream>
 #include <sstream>
 
 // local
-#include "RichTbPmtPixelEfficiency.hh"
 #include "RichTbGeometryParameters.hh"
+#include "RichTbPmtPixelEfficiency.hh"
 #include "RichTbRunConfig.hh"
 
-
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbPmtPixelEfficiency
 //
@@ -24,254 +22,226 @@
 //=============================================================================
 // Standard constructor, initializes variables
 
-RichTbPmtPixelEfficiency* RichTbPmtPixelEfficiency::RichTbPmtPixelEfficiencyInstance=0;
-
+RichTbPmtPixelEfficiency *RichTbPmtPixelEfficiency::RichTbPmtPixelEfficiencyInstance = 0;
 
 //=============================================================================
-RichTbPmtPixelEfficiency::RichTbPmtPixelEfficiency(  ):
-				  mPmtPixelEff (8,std::vector<G4double> (64)),
-				  mPmtPixelLabel(8,std::vector<G4String> (64)) {
-
-	PmtPixelEffInitialize();
-
+RichTbPmtPixelEfficiency::RichTbPmtPixelEfficiency()
+    : mPmtPixelEff(8, std::vector<G4double>(64)), mPmtPixelLabel(8, std::vector<G4String>(64)) {
 
+  PmtPixelEffInitialize();
 }
 
 void RichTbPmtPixelEfficiency::PmtPixelEffInitialize() {
 
-	// The following line does not work.
-	// mPmtPixelEff.resize(RichTbTotNumPmt, std::vector<G4double> (NumPixelTotInPmt, 1.0)  );
-	RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
-	G4int aRadiatorConfiguration = aConfig ->getRadiatorConfiguration();
-
-	if(aRadiatorConfiguration == 3) RichTbTotNumPmtFinal = RichTbTotNumPmt15;
-	else RichTbTotNumPmtFinal = RichTbTotNumPmt;
-
-	mPmtPixelEff.resize(RichTbTotNumPmtFinal);
-	mPmtPixelLabel.resize(RichTbTotNumPmtFinal);
-
-	std::vector<G4double> aEffInit (NumPixelTotInPmt, 1.0);
-	std::vector<G4String> aLabelnit (NumPixelTotInPmt, "JU00");
-
-	for (G4int ipmt =0; ipmt <RichTbTotNumPmtFinal ; ++ipmt){
-		mPmtPixelEff [ipmt]= aEffInit;
-		mPmtPixelLabel[ipmt]= aLabelnit;
-	}
-
-	std::vector <G4String> aPL(RichTbTotNumPmtFinal,"JA");
-	aPL[1]="JA";
-	aPL[1]="JA";
-	aPL[2]="JB";
-	aPL[3]="JB";
-	aPL[4]="SA";
-	aPL[5]="SA";
-	aPL[6]="SB";
-	aPL[7]="SB";
-	if(RichTbTotNumPmtFinal==RichTbTotNumPmt15) {
-		aPL[8]="JAB";
-		aPL[9]="JAB";
-		aPL[10]="JBB";
-		aPL[11]="JBB";
-		aPL[12]="SAB";
-		aPL[13]="SAB";
-		aPL[14]="SBB";
-		aPL[15]="SBB";
-	}
-
-	for (G4int ipm =0; ipm <RichTbTotNumPmtFinal ; ++ipm) {
-		for ( G4int ipx =0 ; ipx <NumPixelTotInPmt; ++ipx ) {
-			mPmtPixelLabel[ipm] [ipx] = aPL[ipm] + std::to_string(ipx+1);
-		}
-	}
-
-	ReadPixelEfficiency();
-	FillPixelEfficiency();
-
+  // The following line does not work.
+  // mPmtPixelEff.resize(RichTbTotNumPmt, std::vector<G4double> (NumPixelTotInPmt, 1.0)  );
+  RichTbRunConfig *aConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int aRadiatorConfiguration = aConfig->getRadiatorConfiguration();
+
+  if (aRadiatorConfiguration == 3)
+    RichTbTotNumPmtFinal = RichTbTotNumPmt15;
+  else
+    RichTbTotNumPmtFinal = RichTbTotNumPmt;
+
+  mPmtPixelEff.resize(RichTbTotNumPmtFinal);
+  mPmtPixelLabel.resize(RichTbTotNumPmtFinal);
+
+  std::vector<G4double> aEffInit(NumPixelTotInPmt, 1.0);
+  std::vector<G4String> aLabelnit(NumPixelTotInPmt, "JU00");
+
+  for (G4int ipmt = 0; ipmt < RichTbTotNumPmtFinal; ++ipmt) {
+    mPmtPixelEff[ipmt] = aEffInit;
+    mPmtPixelLabel[ipmt] = aLabelnit;
+  }
+
+  std::vector<G4String> aPL(RichTbTotNumPmtFinal, "JA");
+  aPL[1] = "JA";
+  aPL[1] = "JA";
+  aPL[2] = "JB";
+  aPL[3] = "JB";
+  aPL[4] = "SA";
+  aPL[5] = "SA";
+  aPL[6] = "SB";
+  aPL[7] = "SB";
+  if (RichTbTotNumPmtFinal == RichTbTotNumPmt15) {
+    aPL[8] = "JAB";
+    aPL[9] = "JAB";
+    aPL[10] = "JBB";
+    aPL[11] = "JBB";
+    aPL[12] = "SAB";
+    aPL[13] = "SAB";
+    aPL[14] = "SBB";
+    aPL[15] = "SBB";
+  }
+
+  for (G4int ipm = 0; ipm < RichTbTotNumPmtFinal; ++ipm) {
+    for (G4int ipx = 0; ipx < NumPixelTotInPmt; ++ipx) {
+      mPmtPixelLabel[ipm][ipx] = aPL[ipm] + std::to_string(ipx + 1);
+    }
+  }
+
+  ReadPixelEfficiency();
+  FillPixelEfficiency();
 }
 
-G4bool RichTbPmtPixelEfficiency::PmtPixelEffOK (G4int aPmtNum, G4int aPixelNum) {
-	RichTbRunConfig* aRunConfig =  RichTbRunConfig::getRunConfigInstance();
-	G4bool aEffFlag = true;
-	if(aRunConfig ->ApplyPixelEff() ) {
-		G4double curEff = getPixelEff (aPmtNum,aPixelNum);
-		G4double RandPx =  G4UniformRand();
-		if ( RandPx >  curEff )aEffFlag = false;
-		// G4cout<<" PmtPixelEfficiency CurEff randpx flag "<<  curEff <<"  "<< RandPx <<"  "<<aEffFlag<<G4endl;
-
-
-	}
-	return  aEffFlag;
-
+G4bool RichTbPmtPixelEfficiency::PmtPixelEffOK(G4int aPmtNum, G4int aPixelNum) {
+  RichTbRunConfig *aRunConfig = RichTbRunConfig::getRunConfigInstance();
+  G4bool aEffFlag = true;
+  if (aRunConfig->ApplyPixelEff()) {
+    G4double curEff = getPixelEff(aPmtNum, aPixelNum);
+    G4double RandPx = G4UniformRand();
+    if (RandPx > curEff)
+      aEffFlag = false;
+    // G4cout<<" PmtPixelEfficiency CurEff randpx flag "<<  curEff <<"  "<< RandPx <<"  "<<aEffFlag<<G4endl;
+  }
+  return aEffFlag;
 }
 
-
 void RichTbPmtPixelEfficiency::FillPixelEfficiency() {
-	RichTbRunConfig* aRunConfig =  RichTbRunConfig::getRunConfigInstance();
-	G4int aEffFlag = aRunConfig-> MapmtPixelEfficiencyFlag ();
-	if(aEffFlag  != 0 ){
-		for (G4int ipm =0; ipm <RichTbTotNumPmtFinal ; ++ipm) {
-			for ( G4int ipx =0 ; ipx <NumPixelTotInPmt; ++ipx ) {
-				G4double aEff = mPmtAnodeEffMap.find( mPmtPixelLabel[ipm][ipx] )->second ;
-				mPmtPixelEff [ipm] [ipx]= aEff;
-				//     G4cout<<" Pmt Pixel Label eff  "<< ipm <<"  "<<ipx <<"   "
-				//      << mPmtPixelLabel[ipm][ipx] <<"   "<<aEff<<G4endl;
-
-
-			}
-
-		}
-
-	}
-
+  RichTbRunConfig *aRunConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int aEffFlag = aRunConfig->MapmtPixelEfficiencyFlag();
+  if (aEffFlag != 0) {
+    for (G4int ipm = 0; ipm < RichTbTotNumPmtFinal; ++ipm) {
+      for (G4int ipx = 0; ipx < NumPixelTotInPmt; ++ipx) {
+        G4double aEff = mPmtAnodeEffMap.find(mPmtPixelLabel[ipm][ipx])->second;
+        mPmtPixelEff[ipm][ipx] = aEff;
+        //     G4cout<<" Pmt Pixel Label eff  "<< ipm <<"  "<<ipx <<"   "
+        //      << mPmtPixelLabel[ipm][ipx] <<"   "<<aEff<<G4endl;
+      }
+    }
+  }
 }
 
-
-
-
-
 void RichTbPmtPixelEfficiency::ReadPixelEfficiency() {
-	RichTbRunConfig* aRunConfig =  RichTbRunConfig::getRunConfigInstance();
-	G4int aEffFlag = aRunConfig-> MapmtPixelEfficiencyFlag ();
-	G4int aRadiatorConfiguration = aRunConfig->getRadiatorConfiguration();
-	G4String aJuraFileName;
-	G4String aSaleveFileName;
-	G4String aJuraFileNameUpgr;
-	G4String aSaleveFileNameUpgr;
-	G4String aJuraTop100;
-	G4String aJuraBottom100;
-	G4String aSaleveTop100;
-	G4String aSaleveBottom100;
-
-
-	if(aEffFlag  != 0 ){
-
-		if( aEffFlag   == 1 ) { // read the optimized effiency
-
-			aJuraFileName = aRunConfig->MapmtPixelOptEffFileNameJura();
-			aSaleveFileName = aRunConfig->MapmtPixelOptEffFileNameSaleve() ;
-
-
-		}else if ( aEffFlag   == 2 ) { // read the thrshold7 efficiency
-
-			aJuraFileName = aRunConfig->MapmtPixelThr7EffFileNameJura() ;
-			aSaleveFileName = aRunConfig->MapmtPixelThr7EffFileNameSaleve() ;
-
-		}
-
-		aJuraFileNameUpgr = aRunConfig->MapmtPixelOptEffFileNameJuraUpgr();
-		aSaleveFileNameUpgr = aRunConfig->MapmtPixelOptEffFileNameSaleveUpgr();
-
-		aJuraTop100 = aRunConfig->MapmtPixelEffFileNameJuraTop100();
-		aJuraBottom100 = aRunConfig->MapmtPixelEffFileNameJuraBottom100();
-		aSaleveTop100 = aRunConfig->MapmtPixelEffFileNameSaleveTop100();
-		aSaleveBottom100 = aRunConfig->MapmtPixelEffFileNameSaleveBottom100();
-
-		G4cout<<" Now reading Pmt pixel efficiency files "
-				<< aJuraFileName <<"\n"
-				<< aSaleveFileName<<"\n"
-				<< aJuraFileNameUpgr<<"\n"
-				<< aSaleveFileNameUpgr<<"\n"
-				<< aJuraTop100<<"\n"
-				<< aJuraBottom100<<"\n"
-				<< aSaleveTop100<<"\n"
-				<< aSaleveBottom100<<G4endl;
-
-		mPmtAnodeEffMap.clear();
-
-
-//		ReadAndCopyPixelEffFromFile(aJuraFileName);
-//		ReadAndCopyPixelEffFromFile(aSaleveFileName);
-		ReadAndCopyPixelEffFromFile(aJuraTop100);
-		ReadAndCopyPixelEffFromFile(aSaleveTop100);
-		if(aRadiatorConfiguration==3) {//testbeam 2015 upgrade dummy refls
-			//			ReadAndCopyPixelEffFromFile(aJuraFileNameUpgr);
-			//			ReadAndCopyPixelEffFromFile(aSaleveFileNameUpgr);
-			ReadAndCopyPixelEffFromFile(aJuraBottom100);
-			ReadAndCopyPixelEffFromFile(aSaleveBottom100);
-		}
-	}
-
+  RichTbRunConfig *aRunConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int aEffFlag = aRunConfig->MapmtPixelEfficiencyFlag();
+  G4int aRadiatorConfiguration = aRunConfig->getRadiatorConfiguration();
+  G4String aJuraFileName;
+  G4String aSaleveFileName;
+  G4String aJuraFileNameUpgr;
+  G4String aSaleveFileNameUpgr;
+  G4String aJuraTop100;
+  G4String aJuraBottom100;
+  G4String aSaleveTop100;
+  G4String aSaleveBottom100;
+
+  if (aEffFlag != 0) {
+
+    if (aEffFlag == 1) { // read the optimized effiency
+
+      aJuraFileName = aRunConfig->MapmtPixelOptEffFileNameJura();
+      aSaleveFileName = aRunConfig->MapmtPixelOptEffFileNameSaleve();
+
+    } else if (aEffFlag == 2) { // read the thrshold7 efficiency
+
+      aJuraFileName = aRunConfig->MapmtPixelThr7EffFileNameJura();
+      aSaleveFileName = aRunConfig->MapmtPixelThr7EffFileNameSaleve();
+    }
+
+    aJuraFileNameUpgr = aRunConfig->MapmtPixelOptEffFileNameJuraUpgr();
+    aSaleveFileNameUpgr = aRunConfig->MapmtPixelOptEffFileNameSaleveUpgr();
+
+    aJuraTop100 = aRunConfig->MapmtPixelEffFileNameJuraTop100();
+    aJuraBottom100 = aRunConfig->MapmtPixelEffFileNameJuraBottom100();
+    aSaleveTop100 = aRunConfig->MapmtPixelEffFileNameSaleveTop100();
+    aSaleveBottom100 = aRunConfig->MapmtPixelEffFileNameSaleveBottom100();
+
+    G4cout << " Now reading Pmt pixel efficiency files " << aJuraFileName << "\n"
+           << aSaleveFileName << "\n"
+           << aJuraFileNameUpgr << "\n"
+           << aSaleveFileNameUpgr << "\n"
+           << aJuraTop100 << "\n"
+           << aJuraBottom100 << "\n"
+           << aSaleveTop100 << "\n"
+           << aSaleveBottom100 << G4endl;
+
+    mPmtAnodeEffMap.clear();
+
+    //		ReadAndCopyPixelEffFromFile(aJuraFileName);
+    //		ReadAndCopyPixelEffFromFile(aSaleveFileName);
+    ReadAndCopyPixelEffFromFile(aJuraTop100);
+    ReadAndCopyPixelEffFromFile(aSaleveTop100);
+    if (aRadiatorConfiguration == 3) { // testbeam 2015 upgrade dummy refls
+      //			ReadAndCopyPixelEffFromFile(aJuraFileNameUpgr);
+      //			ReadAndCopyPixelEffFromFile(aSaleveFileNameUpgr);
+      ReadAndCopyPixelEffFromFile(aJuraBottom100);
+      ReadAndCopyPixelEffFromFile(aSaleveBottom100);
+    }
+  }
 }
 
-
-void  RichTbPmtPixelEfficiency::ReadAndCopyPixelEffFromFile(G4String aInpFileName  ) {
-
-	const char* aFileName_char = aInpFileName.c_str();
-	std::ifstream aInpFileStr (aFileName_char);
-	if( !aInpFileStr ) {
-		G4cout<<" Unable to read from "<<aInpFileName  <<G4endl;
-
-	}else {
-
-
-
-		G4String aAnodeName="AnodeName";
-		G4String ClaroNumberS = "0";
-		G4String ClaroChanNumS = "0";
-		G4String aPmtEffS = "1.0";
-		G4double aPmtEff =1.0;
-		G4int NumItemsPerLine=4;
-		G4String HeaderName_PixelName,HeaderName_ClaroNum,HeaderName_ClaroChanNum, HeaderName_Eff;
-
-		G4int curLineNum=-1;
-		std::vector<G4String>line_record;
-
-		while  (aInpFileStr ) {
-			std::string aLine;
-			if(!std::getline (aInpFileStr , aLine) ) break;
-			curLineNum++;
-			std::istringstream ss(aLine);
-			line_record.clear();
-			line_record.reserve(NumItemsPerLine);
-
-			while (ss) {
-				std::string aWord;
-				if(!std::getline(ss,aWord,','))break;
-				line_record.push_back(aWord);
-			}
-
-			if(curLineNum == 0 ) {
-				HeaderName_PixelName=line_record[0];
-				HeaderName_ClaroNum=line_record[1];
-				HeaderName_ClaroChanNum=  line_record[2];
-				HeaderName_Eff =line_record[3];
-
-				// G4cout<<"FileHeader "<<HeaderName_PixelName  <<"  "<<HeaderName_ClaroNum<<"  "
-				//             << HeaderName_ClaroChanNum<<"  "<<HeaderName_Eff<<G4endl;
-
-
-			}else {
-				aAnodeName = line_record[0];
-				ClaroNumberS = line_record[1];
-				ClaroChanNumS  = line_record[2];
-				aPmtEffS = line_record[3];
-				aPmtEff = atof( aPmtEffS.c_str());
-
-				//  G4cout<<" Reading Anode name claronum clarochan eff "<< aAnodeName<<"  "
-				//      <<ClaroNumberS<<"  "<<ClaroChanNumS<<"  "<<aPmtEff<<G4endl;
-
-				mPmtAnodeEffMap.insert(std::make_pair(aAnodeName,aPmtEff));
-
-			}
-		}
-	}
+void RichTbPmtPixelEfficiency::ReadAndCopyPixelEffFromFile(G4String aInpFileName) {
+
+  const char *aFileName_char = aInpFileName.c_str();
+  std::ifstream aInpFileStr(aFileName_char);
+  if (!aInpFileStr) {
+    G4cout << " Unable to read from " << aInpFileName << G4endl;
+
+  } else {
+
+    G4String aAnodeName = "AnodeName";
+    G4String ClaroNumberS = "0";
+    G4String ClaroChanNumS = "0";
+    G4String aPmtEffS = "1.0";
+    G4double aPmtEff = 1.0;
+    G4int NumItemsPerLine = 4;
+    G4String HeaderName_PixelName, HeaderName_ClaroNum, HeaderName_ClaroChanNum, HeaderName_Eff;
+
+    G4int curLineNum = -1;
+    std::vector<G4String> line_record;
+
+    while (aInpFileStr) {
+      std::string aLine;
+      if (!std::getline(aInpFileStr, aLine))
+        break;
+      curLineNum++;
+      std::istringstream ss(aLine);
+      line_record.clear();
+      line_record.reserve(NumItemsPerLine);
+
+      while (ss) {
+        std::string aWord;
+        if (!std::getline(ss, aWord, ','))
+          break;
+        line_record.push_back(aWord);
+      }
+
+      if (curLineNum == 0) {
+        HeaderName_PixelName = line_record[0];
+        HeaderName_ClaroNum = line_record[1];
+        HeaderName_ClaroChanNum = line_record[2];
+        HeaderName_Eff = line_record[3];
+
+        // G4cout<<"FileHeader "<<HeaderName_PixelName  <<"  "<<HeaderName_ClaroNum<<"  "
+        //             << HeaderName_ClaroChanNum<<"  "<<HeaderName_Eff<<G4endl;
+
+      } else {
+        aAnodeName = line_record[0];
+        ClaroNumberS = line_record[1];
+        ClaroChanNumS = line_record[2];
+        aPmtEffS = line_record[3];
+        aPmtEff = atof(aPmtEffS.c_str());
+
+        //  G4cout<<" Reading Anode name claronum clarochan eff "<< aAnodeName<<"  "
+        //      <<ClaroNumberS<<"  "<<ClaroChanNumS<<"  "<<aPmtEff<<G4endl;
+
+        mPmtAnodeEffMap.insert(std::make_pair(aAnodeName, aPmtEff));
+      }
+    }
+  }
 }
 
-
-
-
 //=============================================================================
 // Destructor
 //=============================================================================
-RichTbPmtPixelEfficiency::~RichTbPmtPixelEfficiency() { ;}
+RichTbPmtPixelEfficiency::~RichTbPmtPixelEfficiency() { ; }
 
 //=============================================================================
 
-RichTbPmtPixelEfficiency*  RichTbPmtPixelEfficiency::getRichTbPmtPixelEfficiencyInstance() {
-	if(RichTbPmtPixelEfficiencyInstance == 0 ) {
-		RichTbPmtPixelEfficiencyInstance = new RichTbPmtPixelEfficiency();
-	}
-
-	return RichTbPmtPixelEfficiencyInstance;
+RichTbPmtPixelEfficiency *RichTbPmtPixelEfficiency::getRichTbPmtPixelEfficiencyInstance() {
+  if (RichTbPmtPixelEfficiencyInstance == 0) {
+    RichTbPmtPixelEfficiencyInstance = new RichTbPmtPixelEfficiency();
+  }
 
+  return RichTbPmtPixelEfficiencyInstance;
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbRunAction.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbRunAction.cc
index 2ff01dbe7eb450c7425468a1daf902ed72c0ab50..9f7bbbc95e7ea7b1293ebe26db7b69807caf7b99 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbRunAction.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbRunAction.cc
@@ -11,71 +11,57 @@
 
 #include "RichTbRunAction.hh"
 
-#include "Geant4/G4ios.hh"
 #include "Geant4/G4Run.hh"
 #include "Geant4/G4UImanager.hh"
+#include "Geant4/G4ios.hh"
 #include "RichTbAnalysisManager.hh"
-#include "RichTbCounter.hh"
 #include "RichTbBeamProperty.hh"
+#include "RichTbCounter.hh"
 
-RichTbRunAction::RichTbRunAction()
-{
+RichTbRunAction::RichTbRunAction() {
 
-    timer = new G4Timer;
-            ranalysisManager = RichTbAnalysisManager::getInstance();
+  timer = new G4Timer;
+  ranalysisManager = RichTbAnalysisManager::getInstance();
 
-       ranalysisManager->BeginOfRunAnalysis();
+  ranalysisManager->BeginOfRunAnalysis();
 
   // now for the counters
 
-  RichTbCounter* aRichCounter =  
-        RichTbCounter::getRichTbCounterInstance();
-
+  // RichTbCounter *aRichCounter = RichTbCounter::getRichTbCounterInstance();
 }
 
+RichTbRunAction::~RichTbRunAction() { delete timer; }
 
-RichTbRunAction::~RichTbRunAction()
-{
-    delete timer;
-}
-
+void RichTbRunAction::BeginOfRunAction(const G4Run *aRun) {
+  G4UImanager *UI = G4UImanager::GetUIpointer();
+  //   UI->ApplyCommand("/run/verbose 2");
+  // UI->ApplyCommand("/event/verbose 2");
+  UI->ApplyCommand("/run/verbose 1");
+  UI->ApplyCommand("/event/verbose 0");
+  //    UI->ApplyCommand("/tracking/verbose 0");
+  // UI->ApplyCommand("/tracking/verbose 4");
+  UI->ApplyCommand("/tracking/verbose 0");
+  UI->ApplyCommand("/particle/process/verbose 0");
+  UI->ApplyCommand("/control/verbose 0");
 
-void RichTbRunAction::BeginOfRunAction(const G4Run * aRun)
-{
-    G4UImanager *UI = G4UImanager::GetUIpointer();
-    //   UI->ApplyCommand("/run/verbose 2");
-    // UI->ApplyCommand("/event/verbose 2");
-    UI->ApplyCommand("/run/verbose 1");
-    UI->ApplyCommand("/event/verbose 0");
-    //    UI->ApplyCommand("/tracking/verbose 0");
-    // UI->ApplyCommand("/tracking/verbose 4");
-    UI->ApplyCommand("/tracking/verbose 0");
-    UI->ApplyCommand("/particle/process/verbose 0");
-    UI->ApplyCommand("/control/verbose 0");
+  G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
 
-    G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
+  timer->Start();
 
-    timer->Start();
+  //    ranalysisManager = RichTbAnalysisManager::getInstance();
 
-    //    ranalysisManager = RichTbAnalysisManager::getInstance();
+  //    ranalysisManager->BeginOfRunAnalysis();
+  // initialise the beam property.
 
-    //    ranalysisManager->BeginOfRunAnalysis();
-    // initialise the beam property.
-
-    RichTbBeamProperty* aBeamProperty= 
-       RichTbBeamProperty::getRichTbBeamPropertyInstance();
-    
+  // RichTbBeamProperty *aBeamProperty = RichTbBeamProperty::getRichTbBeamPropertyInstance();
 }
 
+void RichTbRunAction::EndOfRunAction(const G4Run *aRun) {
 
-void RichTbRunAction::EndOfRunAction(const G4Run * aRun)
-{
-
-      ranalysisManager = RichTbAnalysisManager::getInstance();
+  ranalysisManager = RichTbAnalysisManager::getInstance();
 
-      ranalysisManager->EndOfRunAnalysis();
+  ranalysisManager->EndOfRunAnalysis();
 
-    timer->Stop();
-    G4cout << "number of event = " << aRun->GetNumberOfEvent()
-        << " " << *timer << G4endl;
+  timer->Stop();
+  G4cout << "number of event = " << aRun->GetNumberOfEvent() << " " << *timer << G4endl;
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbRunConfig.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbRunConfig.cc
index ff523407868146a66c961f021e275d33906bba65..c306b0f31e6f522017b031c3e55226be3c5a3ea1 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbRunConfig.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbRunConfig.cc
@@ -1,477 +1,423 @@
-#include <iostream>
-#include <fstream>
 #include "RichTbRunConfig.hh"
-#include "RichTbMaterialParameters.hh"
 #include "Geant4/globals.hh"
 #include "RichTbGeometryParameters.hh"
+#include "RichTbMaterialParameters.hh"
+#include <fstream>
+#include <iostream>
 
 RichTbRunConfig *RichTbRunConfig::RunConfigInstance = 0;
 
 RichTbRunConfig::RichTbRunConfig()
-: mDemagConstShiftAtAnodeX(6), mDemagConstShiftAtAnodeY(6),
-  mPMTAdditionalLocalRotationZ(6),mPMTAlignmentLocalShiftX(6),
-  mPMTAlignmentLocalShiftY(6),
-  mPhSupFrameAdditionalShift(std::vector<G4double>(3))  {
+    : mDemagConstShiftAtAnodeX(6), mDemagConstShiftAtAnodeY(6), mPMTAdditionalLocalRotationZ(6),
+      mPMTAlignmentLocalShiftX(6), mPMTAlignmentLocalShiftY(6), mPhSupFrameAdditionalShift(std::vector<G4double>(3)) {
 
   // in the above 3 is a dummy value.
 
-
   // Now open the Run Configuration file.
 
- const std::string G4RICHTBSIMHROOT = std::string(std::getenv("G4RICHTBSIMHTESTROOT")) + "/";
- const std::string RunConfigFile = G4RICHTBSIMHROOT + "options/RunConfig.dat";
- G4cout<<" Run Configuration Input is from "<< RunConfigFile<<G4endl;
-
- std::ifstream finpconf( RunConfigFile);
-
- G4double  NitrogenPressureInAtmos=1.0;
- G4double NitrogenTemperatureInKelvin = 293.0*0;
- G4double  c4f10PressureInAtmos=1.0;
- G4double c4f10TemperatureInKelvin = 293.0*0;
-
- G4double MirrorAdditionalTiltX = 0.0;
- G4double MirrorAdditionalTiltY = 0.0;
-
-
- G4double aDemagConstShiftAtAnodeXPMT0 = 0.0;
- G4double aDemagConstShiftAtAnodeXPMT1 = 0.0;
- G4double aDemagConstShiftAtAnodeXPMT2 = 0.0;
- G4double aDemagConstShiftAtAnodeXPMT3 = 0.0;
- G4double aDemagConstShiftAtAnodeXPMT4 = 0.0;
- G4double aDemagConstShiftAtAnodeXPMT5 = 0.0;
-
- G4double aDemagConstShiftAtAnodeYPMT0 = 0.0;
- G4double aDemagConstShiftAtAnodeYPMT1 = 0.0;
- G4double aDemagConstShiftAtAnodeYPMT2 = 0.0;
- G4double aDemagConstShiftAtAnodeYPMT3 = 0.0;
- G4double aDemagConstShiftAtAnodeYPMT4 = 0.0;
- G4double aDemagConstShiftAtAnodeYPMT5 = 0.0;
-
- G4double aPMT0AdditionalLocalRotationZ =0.0;
- G4double aPMT1AdditionalLocalRotationZ =0.0;
- G4double aPMT2AdditionalLocalRotationZ =0.0;
- G4double aPMT3AdditionalLocalRotationZ =0.0;
- G4double aPMT4AdditionalLocalRotationZ =0.0;
- G4double aPMT5AdditionalLocalRotationZ =0.0;
-
- G4double aPMT0AlignmentShiftX=0.0*CLHEP::mm;
- G4double aPMT1AlignmentShiftX=0.0*CLHEP::mm;
- G4double aPMT2AlignmentShiftX=0.0*CLHEP::mm;
- G4double aPMT3AlignmentShiftX=0.0*CLHEP::mm;
- G4double aPMT4AlignmentShiftX=0.0*CLHEP::mm;
- G4double aPMT5AlignmentShiftX=0.0*CLHEP::mm;
-
- G4double aPMT0AlignmentShiftY=0.0*CLHEP::mm;
- G4double aPMT1AlignmentShiftY=0.0*CLHEP::mm;
- G4double aPMT2AlignmentShiftY=0.0*CLHEP::mm;
- G4double aPMT3AlignmentShiftY=0.0*CLHEP::mm;
- G4double aPMT4AlignmentShiftY=0.0*CLHEP::mm;
- G4double aPMT5AlignmentShiftY=0.0*CLHEP::mm;
-
- G4double aPhSupFrameAdditionalShiftX=0.0;
- G4double aPhSupFrameAdditionalShiftY=0.0;
- G4double aPhSupFrameAdditionalShiftZ=0.0;
-
-
- if(!finpconf) {
-   G4cout<<" Unable to open the Run Configuration file.   "
-         <<"  Please check the directory and file names "<<G4endl;
-
-
- }else {
-
-   //while(! (finpconf.eof())) {
-
-     G4cout<<"Now reading the Run Configuration "<<G4endl;
-
-     //line 1
-     finpconf>>RichTbHall_visib;
-     finpconf>>RichTbUpgradeVessel_visib;
-     finpconf>>RichTbCrystal_visib;
-     finpconf>>RichTbCrystalCover_visib;
-     finpconf>>RichTbPhDFrame_visib;
-     finpconf>>RichTbEC_visib;
-     finpconf>>RichTbPMTMaster_visib;
-     finpconf>>RichTbPMTSMaster_visib;
-     finpconf>>RichTbPMTEnvelope_visib;
-     finpconf>>RichTbPMTQuartzW_visib;
-     finpconf>>RichTbPMTPhCathode_visib;
-     finpconf>>RichTbPMTAnode_visib;
-     finpconf>>RichTbPMTFrontRing_visib;
-     finpconf>>RichTbLens_visib;
-     finpconf>>RichTbUpgradeRadiator_visib;
-     finpconf>> RichTbUpgradeMirror_visib;
-     finpconf>> RichTbUpgradeDarkCover_visib;
-     finpconf>> RichTbUpgradeUpsDarkCover_visib;
-     finpconf>> RichTbUpgradeSideDarkCover_visib;
-     finpconf>> RichTbUpgradeDnsDarkCover_visib;
-
-     finpconf>> RichTbHpdQW_visib;
-     finpconf>> RichTbHpdPHC_visib;
-     finpconf>> RichTbHpdSID_visib;
-     finpconf>> RichTbHpdENV_visib;
-     finpconf>> RichTbHpdENVCAP_visib;
-     finpconf>> RichTbHpdSM_visib;
-     finpconf>> RichTbHpdMas_visib;
-     finpconf>> RichTbHpdSiPix_visib;
-
-
-     RichTbPhDetSupFrame_visib=RichTbPhDFrame_visib;
-
-
-     // finpconf>> RichTbPhDetSupFrame_visib;
-     // finpconf>> RichTbGasQuWin_visib;
-     // finpconf>> RichTbPMTMaster_visib;
-     // finpconf>> RichTbPMTSMaster_visib;
-     // finpconf>> RichTbPMTEnvelope_visib;
-     // finpconf>> RichTbPMTEndCap_visib;
-     // finpconf>> RichTbPMTQuartzW_visib;
-     // finpconf>> RichTbPMTPhCathode_visib;
-
-     //line 2
-     finpconf>>  GasTypeCode;
-     finpconf>>  NitrogenPressureInAtmos;
-     finpconf>>  NitrogenTemperatureInKelvin;
-     finpconf>>  c4f10PressureInAtmos;
-     finpconf>>  c4f10TemperatureInKelvin;
-     finpconf>>  MirrorOrientCode;
-     finpconf>>  MirrorAdditionalTiltX;
-     finpconf>>  MirrorAdditionalTiltY;
-
-     //line 3
-     finpconf>> mNonOptimalPMTCondition;
-     finpconf>> mNonOptimalPMTAbsEff;
-     finpconf>> mHpdpeBackScaProb;
-     finpconf>> mRandomSeedInput;
-
-     //line 4
-     finpconf>> RichTbNumPartEvent;
-     finpconf>> RichTbParticleTypeCode;
-     finpconf>> RichTbParticleStartPosCode;
-     finpconf>> RichTbParticleDirectionCode;
-     finpconf>> RichTbParticleEnergyCode;
-
-     finpconf>>  RichTbParticleMomentum;
-     finpconf>>  PosBeamFraction;
-     finpconf>>  mBeamDirX;
-     finpconf>>  mBeamDirY;
-     finpconf>>  mBeamDivergenceX;
-     finpconf>>  mBeamDivergenceY;
-     finpconf>>  mBeamXPosShift;
-     finpconf>>  mBeamYPosShift;
-     finpconf>> mBeamSpecialXPos;
-     finpconf>> mBeamSpecialYPos;
-     finpconf>> mBeamSpecialZPos;
-     finpconf>> mBeamSpecialXRange;
-     finpconf>> mConstPhotWlenBeam;
-     finpconf>> mPhotWlenMinBeam;
-     finpconf>> mPhotWlenMaxBeam;
-
-     finpconf>> PMTPEMomInit;
-
-     finpconf>>  WriteOutputFile;
-     finpconf>>  HitCreationOption;
-
-     finpconf>> ECXShift; //starting point is 70.6 CLHEP::mm
-
-     //line 5
-     finpconf>> MirrorReflFileName;
-       MirrorReflFileName = G4RICHTBSIMHROOT + MirrorReflFileName;
-     //line 6
-     finpconf>> OutputFileName;
-     //line 7
-     finpconf>> OutputHistoFileName;
-     //line 8
-     finpconf>> OutputNtupleFileName;
-
-     //line 9
-     finpconf>>  mBatchModeFlag;
-     finpconf>> mNumEventInBatchMode;
-     finpconf>> mVerboseInfoFlag ;
-     finpconf>> mVerboseOutputFileFlag ;
-     finpconf>> mSpecialStudyVesselRotation;
-     finpconf>>   mPMTSiReflFlag;
-
-
-     //line 10
-     finpconf>> aDemagConstShiftAtAnodeXPMT0;
-     finpconf>> aDemagConstShiftAtAnodeXPMT1;
-     finpconf>> aDemagConstShiftAtAnodeXPMT2;
-     finpconf>> aDemagConstShiftAtAnodeXPMT3;
-     finpconf>> aDemagConstShiftAtAnodeXPMT4;
-     finpconf>> aDemagConstShiftAtAnodeXPMT5;
-
-     finpconf>> aDemagConstShiftAtAnodeYPMT0;
-     finpconf>> aDemagConstShiftAtAnodeYPMT1;
-     finpconf>> aDemagConstShiftAtAnodeYPMT2;
-     finpconf>> aDemagConstShiftAtAnodeYPMT3;
-     finpconf>> aDemagConstShiftAtAnodeYPMT4;
-     finpconf>> aDemagConstShiftAtAnodeYPMT5;
-
-     finpconf>> aPMT0AdditionalLocalRotationZ;
-     finpconf>> aPMT1AdditionalLocalRotationZ;
-     finpconf>> aPMT2AdditionalLocalRotationZ;
-     finpconf>> aPMT3AdditionalLocalRotationZ;
-     finpconf>> aPMT4AdditionalLocalRotationZ;
-     finpconf>> aPMT5AdditionalLocalRotationZ;
-
-     //line 11
-     finpconf>>  aPMT0AlignmentShiftX;
-     finpconf>>  aPMT1AlignmentShiftX;
-     finpconf>>  aPMT2AlignmentShiftX;
-     finpconf>>  aPMT3AlignmentShiftX;
-     finpconf>>  aPMT4AlignmentShiftX;
-     finpconf>>  aPMT5AlignmentShiftX;
-
-     finpconf>>  aPMT0AlignmentShiftY;
-     finpconf>>  aPMT1AlignmentShiftY;
-     finpconf>>  aPMT2AlignmentShiftY;
-     finpconf>>  aPMT3AlignmentShiftY;
-     finpconf>>  aPMT4AlignmentShiftY;
-     finpconf>>  aPMT5AlignmentShiftY;
-
-     //line 12
-     finpconf>> aPhSupFrameAdditionalShiftX;
-     finpconf>> aPhSupFrameAdditionalShiftY;
-     finpconf>> aPhSupFrameAdditionalShiftZ;
-
-     finpconf>>  mPhSupFrameAdditionalVertTilt;
-     finpconf>>   mPhSupFrameAdditionalZRot;
-
-     //line 13
-     finpconf>> mSpecialStudyCrystalRotation;
-     finpconf>> mSpecialStudyCrystalRotationX;
-     finpconf>> mSpecialStudyCrystalRotationY;
-
-     //line 14
-     finpconf>> mSpecialStudyMasterRotation;
-     finpconf>> mSpecialStudyMasterRotationX;
-     finpconf>> mSpecialStudyMasterRotationY;
-
-     //line 15
-     finpconf>> mRadiatorConfiguration;
-     //line 16
-     finpconf>> mMapmtDetectionEfficiency;
-     finpconf>> mMapmtPixelEfficiencyFlag;
-     //line 17
-     finpconf>> mMapmtPixelOptEffFileNameJura;
-       mMapmtPixelOptEffFileNameJura = G4RICHTBSIMHROOT + mMapmtPixelOptEffFileNameJura;
-     //line 18
-     finpconf>> mMapmtPixelThr7EffFileNameJura;
-       mMapmtPixelThr7EffFileNameJura = G4RICHTBSIMHROOT + mMapmtPixelThr7EffFileNameJura;
-     //line 19
-     finpconf>> mMapmtPixelOptEffFileNameSaleve;
-       mMapmtPixelOptEffFileNameSaleve = G4RICHTBSIMHROOT + mMapmtPixelOptEffFileNameSaleve;
-     //line 20
-     finpconf>> mMapmtPixelThr7EffFileNameSaleve;
-       mMapmtPixelThr7EffFileNameSaleve = G4RICHTBSIMHROOT + mMapmtPixelThr7EffFileNameSaleve;
-     //line 21
-     finpconf>> mMapmtPixelOptEffFileNameJuraUpgradeDummy;
-       mMapmtPixelOptEffFileNameJuraUpgradeDummy = G4RICHTBSIMHROOT + mMapmtPixelOptEffFileNameJuraUpgradeDummy;
-     //line 22
-     finpconf>> mMapmtPixelOptEffFileNameSaleveUpgradeDummy;
-       mMapmtPixelOptEffFileNameSaleveUpgradeDummy = G4RICHTBSIMHROOT + mMapmtPixelOptEffFileNameSaleveUpgradeDummy;
-     //line 23
-     finpconf>> mMapmtPixelEffFileNameJuraTop100;
-       mMapmtPixelEffFileNameJuraTop100 = G4RICHTBSIMHROOT + mMapmtPixelEffFileNameJuraTop100;
-     //line 24
-     finpconf>> mMapmtPixelEffFileNameSaleveTop100;
-       mMapmtPixelEffFileNameSaleveTop100 = G4RICHTBSIMHROOT + mMapmtPixelEffFileNameSaleveTop100;
-     //line 25
-     finpconf>> mMapmtPixelEffFileNameJuraBottom100;
-       mMapmtPixelEffFileNameJuraBottom100 = G4RICHTBSIMHROOT + mMapmtPixelEffFileNameJuraBottom100;
-     //line 26
-     finpconf>> mMapmtPixelEffFileNameSaleveBottom100;
-       mMapmtPixelEffFileNameSaleveBottom100 = G4RICHTBSIMHROOT + mMapmtPixelEffFileNameSaleveBottom100;
-
-
-     G4cout<<"End of reading the Run Configuration "<<G4endl;
-
-
-   //}
-
-
- }
-
- mDemagConstShiftAtAnodeX.clear();
- mDemagConstShiftAtAnodeY.clear();
- mPMTAdditionalLocalRotationZ.clear();
- mPMTAlignmentLocalShiftX.clear();
- mPMTAlignmentLocalShiftY.clear();
-
- mDemagConstShiftAtAnodeX.push_back(aDemagConstShiftAtAnodeXPMT0*CLHEP::mm);
- mDemagConstShiftAtAnodeX.push_back(aDemagConstShiftAtAnodeXPMT1*CLHEP::mm);
- mDemagConstShiftAtAnodeX.push_back(aDemagConstShiftAtAnodeXPMT2*CLHEP::mm);
- mDemagConstShiftAtAnodeX.push_back(aDemagConstShiftAtAnodeXPMT3*CLHEP::mm);
- mDemagConstShiftAtAnodeX.push_back(aDemagConstShiftAtAnodeXPMT4*CLHEP::mm);
- mDemagConstShiftAtAnodeX.push_back(aDemagConstShiftAtAnodeXPMT5*CLHEP::mm);
- mDemagConstShiftAtAnodeY.push_back(aDemagConstShiftAtAnodeYPMT0*CLHEP::mm);
- mDemagConstShiftAtAnodeY.push_back(aDemagConstShiftAtAnodeYPMT1*CLHEP::mm);
- mDemagConstShiftAtAnodeY.push_back(aDemagConstShiftAtAnodeYPMT2*CLHEP::mm);
- mDemagConstShiftAtAnodeY.push_back(aDemagConstShiftAtAnodeYPMT3*CLHEP::mm);
- mDemagConstShiftAtAnodeY.push_back(aDemagConstShiftAtAnodeYPMT4*CLHEP::mm);
- mDemagConstShiftAtAnodeY.push_back(aDemagConstShiftAtAnodeYPMT5*CLHEP::mm);
- mPMTAdditionalLocalRotationZ.push_back(aPMT0AdditionalLocalRotationZ* CLHEP::rad);
- mPMTAdditionalLocalRotationZ.push_back(aPMT1AdditionalLocalRotationZ* CLHEP::rad);
- mPMTAdditionalLocalRotationZ.push_back(aPMT2AdditionalLocalRotationZ* CLHEP::rad);
- mPMTAdditionalLocalRotationZ.push_back(aPMT3AdditionalLocalRotationZ* CLHEP::rad);
- mPMTAdditionalLocalRotationZ.push_back(aPMT4AdditionalLocalRotationZ* CLHEP::rad);
- mPMTAdditionalLocalRotationZ.push_back(aPMT5AdditionalLocalRotationZ* CLHEP::rad);
-
- mPMTAlignmentLocalShiftX.push_back(aPMT0AlignmentShiftX*CLHEP::mm);
- mPMTAlignmentLocalShiftX.push_back(aPMT1AlignmentShiftX*CLHEP::mm);
- mPMTAlignmentLocalShiftX.push_back(aPMT2AlignmentShiftX*CLHEP::mm);
- mPMTAlignmentLocalShiftX.push_back(aPMT3AlignmentShiftX*CLHEP::mm);
- mPMTAlignmentLocalShiftX.push_back(aPMT4AlignmentShiftX*CLHEP::mm);
- mPMTAlignmentLocalShiftX.push_back(aPMT5AlignmentShiftX*CLHEP::mm);
-
- mPMTAlignmentLocalShiftY.push_back( aPMT0AlignmentShiftY*CLHEP::mm);
- mPMTAlignmentLocalShiftY.push_back( aPMT1AlignmentShiftY*CLHEP::mm);
- mPMTAlignmentLocalShiftY.push_back( aPMT2AlignmentShiftY*CLHEP::mm);
- mPMTAlignmentLocalShiftY.push_back( aPMT3AlignmentShiftY*CLHEP::mm);
- mPMTAlignmentLocalShiftY.push_back( aPMT4AlignmentShiftY*CLHEP::mm);
- mPMTAlignmentLocalShiftY.push_back( aPMT5AlignmentShiftY*CLHEP::mm);
-
-
-
-
- mPhSupFrameAdditionalShift.clear();
- mPhSupFrameAdditionalShift.push_back( aPhSupFrameAdditionalShiftX);
- mPhSupFrameAdditionalShift.push_back( aPhSupFrameAdditionalShiftY);
- mPhSupFrameAdditionalShift.push_back( aPhSupFrameAdditionalShiftZ);
-
- G4cout<<"Current Run Configuration  is as follows "<<G4endl;
- G4cout<<" Graphics Visibility : Hall Vessel Crystal "
-       << RichTbHall_visib<<"   "<<RichTbUpgradeVessel_visib<<"   "
-       << RichTbCrystal_visib<<"  "
-       <<"    " <<G4endl;
- G4cout<<"  Graphics Visibility : PhDetSupFrame EC PMTMaster PMTSMaster "
-       << " PMTEnvelope  PMTEndCap PMTQuartzW PMTPhCathode   "
-       << RichTbPhDetSupFrame_visib<<"   "
-       << RichTbEC_visib<<"   "<< RichTbPMTMaster_visib<<"   "
-       <<RichTbPMTSMaster_visib<<"   "<<RichTbPMTEnvelope_visib<<"   "
-       <<RichTbPMTEndCap_visib<<"   "<<RichTbPMTQuartzW_visib<<"   "
-       <<RichTbPMTPhCathode_visib<<"   "<<G4endl;
- G4cout<<"Nitrogen Pressure Temp  "<<NitrogenPressureInAtmos<<"    "
-       <<NitrogenTemperatureInKelvin<<G4endl;
- G4cout<<"c4f10 Pressure Temp  "<<c4f10PressureInAtmos<<"    "
-       <<c4f10TemperatureInKelvin<<G4endl;
- G4cout<<" Mirror Orientation code Additional Tilt wrt XAxis YAxis  "
-       <<  MirrorOrientCode<<"   "
-       << MirrorAdditionalTiltX  <<"  "<<MirrorAdditionalTiltY <<G4endl;
-
-
- G4cout<<" NonOptimal PMT Condition  NonOptimal PMT absolute Efficiency  "
-       << mNonOptimalPMTCondition<<"   "<<mNonOptimalPMTAbsEff<<G4endl;
-
-
- G4cout<<" ParticleGun  Generation: Num of Particles generated per event   "
-       << RichTbNumPartEvent<<G4endl;
- G4cout<<" ParticleGun : Code for ParticleType StartPos Direction  Energy  "
-       << "and   Value for MomValue PosBeamFraction:   "
-       << RichTbParticleTypeCode<<"    "
-       << RichTbParticleStartPosCode<<"   "
-       << RichTbParticleDirectionCode<<"    "
-       <<RichTbParticleEnergyCode<<"   "
-       <<RichTbParticleMomentum<<"    "
-       <<PosBeamFraction<<G4endl;
-    G4cout<<" ParticleGun : BeamDirXY  BeamDivXY BeamPosShift XY   "
-       <<   mBeamDirX <<"   "<< mBeamDirY<<"   "
-       << mBeamDivergenceX<<"   "<<mBeamDivergenceY
-          << "   "<<mBeamXPosShift<<"  "<< mBeamYPosShift <<G4endl;
-
-    G4cout<<" Special studies Beam XYZ BeamXRange phot wlen wlenmin wlenmax "
-          <<mBeamSpecialXPos<<"  "<< mBeamSpecialYPos<<"  "
-          <<mBeamSpecialZPos<<"  "
-          <<mBeamSpecialXRange<<"   "
-          <<mConstPhotWlenBeam<<"   "
-          << mPhotWlenMinBeam<<"   "
-          << mPhotWlenMaxBeam<< G4endl;
-
-  G4cout<<"Activate beamshiftntuple "<<mActivateBeamShiftNtuple<<G4endl;
-
- G4cout<<"  PMTPEMomInit  "<< PMTPEMomInit<<G4endl;
- G4cout<<"Flag to WriteOut  HitCreationOption   "
-       <<WriteOutputFile<<"    "<<  HitCreationOption<<"     "
-       << G4endl;
- G4cout<<" Mirror refl file name "<<MirrorReflFileName<<G4endl;
-
- G4cout<<" Event Output FileName "<<OutputFileName<<G4endl;
- G4cout<<"Histo Output file Name  "<< OutputHistoFileName<<G4endl;
- G4cout<<"Ntuple Output file Name  "<< OutputNtupleFileName<<G4endl;
-
- G4cout<<"BatchMode NumEvInBatchMode  VerboseInfo "
-       <<"  VerboseOutput studyvesselRot   "
-       <<  mBatchModeFlag<<"   "<< mNumEventInBatchMode
-       << "    " <<mVerboseInfoFlag<<"   "
-       << mVerboseOutputFileFlag<<"   "
-       << mSpecialStudyVesselRotation<< G4endl;
-
- // G4cout<< " Mapmt Pixel gap "<<  mMapmtPixelGap<<G4endl;
- G4cout<< "Pmt pixel efficiency flag  "<< mMapmtPixelEfficiencyFlag <<G4endl;
-
- /*
-  for(G4int ihp=0; ihp< NumPMTs; ihp++) {
-   G4cout<<"PMT Demag Const shiftX in PMT  "<<ihp <<"  "<<
-           mDemagConstShiftAtAnodeX[ihp]<<G4endl;
-   G4cout<<"PMT Demag Const ShiftY in PMT "<<ihp<<"  "<<
-            mDemagConstShiftAtAnodeY[ihp]<<G4endl;
-
-   G4cout<<"PMT Additional RotZ wrt its Axis  "<<ihp<<"   "<<
-          mPMTAdditionalLocalRotationZ[ihp]<<G4endl;
-
-   G4cout<<"PMT Additional Xshift in phdetsupframe "<<ihp<<"  "<<
-   mPMTAlignmentLocalShiftX[ihp]<<G4endl;
-
-   G4cout<<"PMT additionl Y shift in phdet supframe "<<ihp<<"  "<<
-     mPMTAlignmentLocalShiftY[ihp]<<G4endl;
- }
- */
- G4cout<<" PhDet Frame Additional Shift XYZ   "
-       << mPhSupFrameAdditionalShift[0]<<"    "
-       << mPhSupFrameAdditionalShift[1]<<"    "
-       << mPhSupFrameAdditionalShift[2]<<"    "
-       <<G4endl;
-
- G4cout<<" PhDet Frame Additional VertTilt Zrot "
-       << mPhSupFrameAdditionalVertTilt<<"    "
-       <<  mPhSupFrameAdditionalZRot<<G4endl;
-
-
-  NitrogenPressure = NitrogenPressureInAtmos* CLHEP::atmosphere;
-  NitrogenTemperature = NitrogenTemperatureInKelvin*CLHEP::kelvin;
-
-  NominalNitrogenPressure = 1.0*CLHEP::atmosphere;
-  NominalNitrogenTemperature = 293.0*CLHEP::kelvin;
-
-  c4f10Pressure = c4f10PressureInAtmos* CLHEP::atmosphere;
-  c4f10Temperature = c4f10TemperatureInKelvin*CLHEP::kelvin;
-
-  Nominalc4f10Pressure = 1.0*CLHEP::atmosphere;
-  Nominalc4f10Temperature = 293.0*CLHEP::kelvin;
-
-  MirrorAddTiltX= MirrorAdditionalTiltX* CLHEP::rad;
-  MirrorAddTiltY = MirrorAdditionalTiltY* CLHEP::rad;
-
-
-}
-
-
-RichTbRunConfig::~RichTbRunConfig()
-{
-    ;
+  const std::string G4RICHTBSIMHROOT = std::string(std::getenv("G4RICHTBSIMHTESTROOT")) + "/";
+  const std::string RunConfigFile = G4RICHTBSIMHROOT + "options/RunConfig.dat";
+  G4cout << " Run Configuration Input is from " << RunConfigFile << G4endl;
+
+  std::ifstream finpconf(RunConfigFile);
+
+  G4double NitrogenPressureInAtmos = 1.0;
+  G4double NitrogenTemperatureInKelvin = 293.0 * 0;
+  G4double c4f10PressureInAtmos = 1.0;
+  G4double c4f10TemperatureInKelvin = 293.0 * 0;
+
+  G4double MirrorAdditionalTiltX = 0.0;
+  G4double MirrorAdditionalTiltY = 0.0;
+
+  G4double aDemagConstShiftAtAnodeXPMT0 = 0.0;
+  G4double aDemagConstShiftAtAnodeXPMT1 = 0.0;
+  G4double aDemagConstShiftAtAnodeXPMT2 = 0.0;
+  G4double aDemagConstShiftAtAnodeXPMT3 = 0.0;
+  G4double aDemagConstShiftAtAnodeXPMT4 = 0.0;
+  G4double aDemagConstShiftAtAnodeXPMT5 = 0.0;
+
+  G4double aDemagConstShiftAtAnodeYPMT0 = 0.0;
+  G4double aDemagConstShiftAtAnodeYPMT1 = 0.0;
+  G4double aDemagConstShiftAtAnodeYPMT2 = 0.0;
+  G4double aDemagConstShiftAtAnodeYPMT3 = 0.0;
+  G4double aDemagConstShiftAtAnodeYPMT4 = 0.0;
+  G4double aDemagConstShiftAtAnodeYPMT5 = 0.0;
+
+  G4double aPMT0AdditionalLocalRotationZ = 0.0;
+  G4double aPMT1AdditionalLocalRotationZ = 0.0;
+  G4double aPMT2AdditionalLocalRotationZ = 0.0;
+  G4double aPMT3AdditionalLocalRotationZ = 0.0;
+  G4double aPMT4AdditionalLocalRotationZ = 0.0;
+  G4double aPMT5AdditionalLocalRotationZ = 0.0;
+
+  G4double aPMT0AlignmentShiftX = 0.0 * CLHEP::mm;
+  G4double aPMT1AlignmentShiftX = 0.0 * CLHEP::mm;
+  G4double aPMT2AlignmentShiftX = 0.0 * CLHEP::mm;
+  G4double aPMT3AlignmentShiftX = 0.0 * CLHEP::mm;
+  G4double aPMT4AlignmentShiftX = 0.0 * CLHEP::mm;
+  G4double aPMT5AlignmentShiftX = 0.0 * CLHEP::mm;
+
+  G4double aPMT0AlignmentShiftY = 0.0 * CLHEP::mm;
+  G4double aPMT1AlignmentShiftY = 0.0 * CLHEP::mm;
+  G4double aPMT2AlignmentShiftY = 0.0 * CLHEP::mm;
+  G4double aPMT3AlignmentShiftY = 0.0 * CLHEP::mm;
+  G4double aPMT4AlignmentShiftY = 0.0 * CLHEP::mm;
+  G4double aPMT5AlignmentShiftY = 0.0 * CLHEP::mm;
+
+  G4double aPhSupFrameAdditionalShiftX = 0.0;
+  G4double aPhSupFrameAdditionalShiftY = 0.0;
+  G4double aPhSupFrameAdditionalShiftZ = 0.0;
+
+  if (!finpconf) {
+    G4cout << " Unable to open the Run Configuration file.   "
+           << "  Please check the directory and file names " << G4endl;
+
+  } else {
+
+    // while(! (finpconf.eof())) {
+
+    G4cout << "Now reading the Run Configuration " << G4endl;
+
+    // line 1
+    finpconf >> RichTbHall_visib;
+    finpconf >> RichTbUpgradeVessel_visib;
+    finpconf >> RichTbCrystal_visib;
+    finpconf >> RichTbCrystalCover_visib;
+    finpconf >> RichTbPhDFrame_visib;
+    finpconf >> RichTbEC_visib;
+    finpconf >> RichTbPMTMaster_visib;
+    finpconf >> RichTbPMTSMaster_visib;
+    finpconf >> RichTbPMTEnvelope_visib;
+    finpconf >> RichTbPMTQuartzW_visib;
+    finpconf >> RichTbPMTPhCathode_visib;
+    finpconf >> RichTbPMTAnode_visib;
+    finpconf >> RichTbPMTFrontRing_visib;
+    finpconf >> RichTbLens_visib;
+    finpconf >> RichTbUpgradeRadiator_visib;
+    finpconf >> RichTbUpgradeMirror_visib;
+    finpconf >> RichTbUpgradeDarkCover_visib;
+    finpconf >> RichTbUpgradeUpsDarkCover_visib;
+    finpconf >> RichTbUpgradeSideDarkCover_visib;
+    finpconf >> RichTbUpgradeDnsDarkCover_visib;
+
+    finpconf >> RichTbHpdQW_visib;
+    finpconf >> RichTbHpdPHC_visib;
+    finpconf >> RichTbHpdSID_visib;
+    finpconf >> RichTbHpdENV_visib;
+    finpconf >> RichTbHpdENVCAP_visib;
+    finpconf >> RichTbHpdSM_visib;
+    finpconf >> RichTbHpdMas_visib;
+    finpconf >> RichTbHpdSiPix_visib;
+
+    RichTbPhDetSupFrame_visib = RichTbPhDFrame_visib;
+
+    // finpconf>> RichTbPhDetSupFrame_visib;
+    // finpconf>> RichTbGasQuWin_visib;
+    // finpconf>> RichTbPMTMaster_visib;
+    // finpconf>> RichTbPMTSMaster_visib;
+    // finpconf>> RichTbPMTEnvelope_visib;
+    // finpconf>> RichTbPMTEndCap_visib;
+    // finpconf>> RichTbPMTQuartzW_visib;
+    // finpconf>> RichTbPMTPhCathode_visib;
+
+    // line 2
+    finpconf >> GasTypeCode;
+    finpconf >> NitrogenPressureInAtmos;
+    finpconf >> NitrogenTemperatureInKelvin;
+    finpconf >> c4f10PressureInAtmos;
+    finpconf >> c4f10TemperatureInKelvin;
+    finpconf >> MirrorOrientCode;
+    finpconf >> MirrorAdditionalTiltX;
+    finpconf >> MirrorAdditionalTiltY;
+
+    // line 3
+    finpconf >> mNonOptimalPMTCondition;
+    finpconf >> mNonOptimalPMTAbsEff;
+    finpconf >> mHpdpeBackScaProb;
+    finpconf >> mRandomSeedInput;
+
+    // line 4
+    finpconf >> RichTbNumPartEvent;
+    finpconf >> RichTbParticleTypeCode;
+    finpconf >> RichTbParticleStartPosCode;
+    finpconf >> RichTbParticleDirectionCode;
+    finpconf >> RichTbParticleEnergyCode;
+
+    finpconf >> RichTbParticleMomentum;
+    finpconf >> PosBeamFraction;
+    finpconf >> mBeamDirX;
+    finpconf >> mBeamDirY;
+    finpconf >> mBeamDivergenceX;
+    finpconf >> mBeamDivergenceY;
+    finpconf >> mBeamXPosShift;
+    finpconf >> mBeamYPosShift;
+    finpconf >> mBeamSpecialXPos;
+    finpconf >> mBeamSpecialYPos;
+    finpconf >> mBeamSpecialZPos;
+    finpconf >> mBeamSpecialXRange;
+    finpconf >> mConstPhotWlenBeam;
+    finpconf >> mPhotWlenMinBeam;
+    finpconf >> mPhotWlenMaxBeam;
+
+    finpconf >> PMTPEMomInit;
+
+    finpconf >> WriteOutputFile;
+    finpconf >> HitCreationOption;
+
+    finpconf >> ECXShift; // starting point is 70.6 CLHEP::mm
+
+    // line 5
+    finpconf >> MirrorReflFileName;
+    MirrorReflFileName = G4RICHTBSIMHROOT + MirrorReflFileName;
+    // line 6
+    finpconf >> OutputFileName;
+    // line 7
+    finpconf >> OutputHistoFileName;
+    // line 8
+    finpconf >> OutputNtupleFileName;
+
+    // line 9
+    finpconf >> mBatchModeFlag;
+    finpconf >> mNumEventInBatchMode;
+    finpconf >> mVerboseInfoFlag;
+    finpconf >> mVerboseOutputFileFlag;
+    finpconf >> mSpecialStudyVesselRotation;
+    finpconf >> mPMTSiReflFlag;
+
+    // line 10
+    finpconf >> aDemagConstShiftAtAnodeXPMT0;
+    finpconf >> aDemagConstShiftAtAnodeXPMT1;
+    finpconf >> aDemagConstShiftAtAnodeXPMT2;
+    finpconf >> aDemagConstShiftAtAnodeXPMT3;
+    finpconf >> aDemagConstShiftAtAnodeXPMT4;
+    finpconf >> aDemagConstShiftAtAnodeXPMT5;
+
+    finpconf >> aDemagConstShiftAtAnodeYPMT0;
+    finpconf >> aDemagConstShiftAtAnodeYPMT1;
+    finpconf >> aDemagConstShiftAtAnodeYPMT2;
+    finpconf >> aDemagConstShiftAtAnodeYPMT3;
+    finpconf >> aDemagConstShiftAtAnodeYPMT4;
+    finpconf >> aDemagConstShiftAtAnodeYPMT5;
+
+    finpconf >> aPMT0AdditionalLocalRotationZ;
+    finpconf >> aPMT1AdditionalLocalRotationZ;
+    finpconf >> aPMT2AdditionalLocalRotationZ;
+    finpconf >> aPMT3AdditionalLocalRotationZ;
+    finpconf >> aPMT4AdditionalLocalRotationZ;
+    finpconf >> aPMT5AdditionalLocalRotationZ;
+
+    // line 11
+    finpconf >> aPMT0AlignmentShiftX;
+    finpconf >> aPMT1AlignmentShiftX;
+    finpconf >> aPMT2AlignmentShiftX;
+    finpconf >> aPMT3AlignmentShiftX;
+    finpconf >> aPMT4AlignmentShiftX;
+    finpconf >> aPMT5AlignmentShiftX;
+
+    finpconf >> aPMT0AlignmentShiftY;
+    finpconf >> aPMT1AlignmentShiftY;
+    finpconf >> aPMT2AlignmentShiftY;
+    finpconf >> aPMT3AlignmentShiftY;
+    finpconf >> aPMT4AlignmentShiftY;
+    finpconf >> aPMT5AlignmentShiftY;
+
+    // line 12
+    finpconf >> aPhSupFrameAdditionalShiftX;
+    finpconf >> aPhSupFrameAdditionalShiftY;
+    finpconf >> aPhSupFrameAdditionalShiftZ;
+
+    finpconf >> mPhSupFrameAdditionalVertTilt;
+    finpconf >> mPhSupFrameAdditionalZRot;
+
+    // line 13
+    finpconf >> mSpecialStudyCrystalRotation;
+    finpconf >> mSpecialStudyCrystalRotationX;
+    finpconf >> mSpecialStudyCrystalRotationY;
+
+    // line 14
+    finpconf >> mSpecialStudyMasterRotation;
+    finpconf >> mSpecialStudyMasterRotationX;
+    finpconf >> mSpecialStudyMasterRotationY;
+
+    // line 15
+    finpconf >> mRadiatorConfiguration;
+    // line 16
+    finpconf >> mMapmtDetectionEfficiency;
+    finpconf >> mMapmtPixelEfficiencyFlag;
+    // line 17
+    finpconf >> mMapmtPixelOptEffFileNameJura;
+    mMapmtPixelOptEffFileNameJura = G4RICHTBSIMHROOT + mMapmtPixelOptEffFileNameJura;
+    // line 18
+    finpconf >> mMapmtPixelThr7EffFileNameJura;
+    mMapmtPixelThr7EffFileNameJura = G4RICHTBSIMHROOT + mMapmtPixelThr7EffFileNameJura;
+    // line 19
+    finpconf >> mMapmtPixelOptEffFileNameSaleve;
+    mMapmtPixelOptEffFileNameSaleve = G4RICHTBSIMHROOT + mMapmtPixelOptEffFileNameSaleve;
+    // line 20
+    finpconf >> mMapmtPixelThr7EffFileNameSaleve;
+    mMapmtPixelThr7EffFileNameSaleve = G4RICHTBSIMHROOT + mMapmtPixelThr7EffFileNameSaleve;
+    // line 21
+    finpconf >> mMapmtPixelOptEffFileNameJuraUpgradeDummy;
+    mMapmtPixelOptEffFileNameJuraUpgradeDummy = G4RICHTBSIMHROOT + mMapmtPixelOptEffFileNameJuraUpgradeDummy;
+    // line 22
+    finpconf >> mMapmtPixelOptEffFileNameSaleveUpgradeDummy;
+    mMapmtPixelOptEffFileNameSaleveUpgradeDummy = G4RICHTBSIMHROOT + mMapmtPixelOptEffFileNameSaleveUpgradeDummy;
+    // line 23
+    finpconf >> mMapmtPixelEffFileNameJuraTop100;
+    mMapmtPixelEffFileNameJuraTop100 = G4RICHTBSIMHROOT + mMapmtPixelEffFileNameJuraTop100;
+    // line 24
+    finpconf >> mMapmtPixelEffFileNameSaleveTop100;
+    mMapmtPixelEffFileNameSaleveTop100 = G4RICHTBSIMHROOT + mMapmtPixelEffFileNameSaleveTop100;
+    // line 25
+    finpconf >> mMapmtPixelEffFileNameJuraBottom100;
+    mMapmtPixelEffFileNameJuraBottom100 = G4RICHTBSIMHROOT + mMapmtPixelEffFileNameJuraBottom100;
+    // line 26
+    finpconf >> mMapmtPixelEffFileNameSaleveBottom100;
+    mMapmtPixelEffFileNameSaleveBottom100 = G4RICHTBSIMHROOT + mMapmtPixelEffFileNameSaleveBottom100;
+
+    G4cout << "End of reading the Run Configuration " << G4endl;
+
+    //}
+  }
+
+  mDemagConstShiftAtAnodeX.clear();
+  mDemagConstShiftAtAnodeY.clear();
+  mPMTAdditionalLocalRotationZ.clear();
+  mPMTAlignmentLocalShiftX.clear();
+  mPMTAlignmentLocalShiftY.clear();
+
+  mDemagConstShiftAtAnodeX.push_back(aDemagConstShiftAtAnodeXPMT0 * CLHEP::mm);
+  mDemagConstShiftAtAnodeX.push_back(aDemagConstShiftAtAnodeXPMT1 * CLHEP::mm);
+  mDemagConstShiftAtAnodeX.push_back(aDemagConstShiftAtAnodeXPMT2 * CLHEP::mm);
+  mDemagConstShiftAtAnodeX.push_back(aDemagConstShiftAtAnodeXPMT3 * CLHEP::mm);
+  mDemagConstShiftAtAnodeX.push_back(aDemagConstShiftAtAnodeXPMT4 * CLHEP::mm);
+  mDemagConstShiftAtAnodeX.push_back(aDemagConstShiftAtAnodeXPMT5 * CLHEP::mm);
+  mDemagConstShiftAtAnodeY.push_back(aDemagConstShiftAtAnodeYPMT0 * CLHEP::mm);
+  mDemagConstShiftAtAnodeY.push_back(aDemagConstShiftAtAnodeYPMT1 * CLHEP::mm);
+  mDemagConstShiftAtAnodeY.push_back(aDemagConstShiftAtAnodeYPMT2 * CLHEP::mm);
+  mDemagConstShiftAtAnodeY.push_back(aDemagConstShiftAtAnodeYPMT3 * CLHEP::mm);
+  mDemagConstShiftAtAnodeY.push_back(aDemagConstShiftAtAnodeYPMT4 * CLHEP::mm);
+  mDemagConstShiftAtAnodeY.push_back(aDemagConstShiftAtAnodeYPMT5 * CLHEP::mm);
+  mPMTAdditionalLocalRotationZ.push_back(aPMT0AdditionalLocalRotationZ * CLHEP::rad);
+  mPMTAdditionalLocalRotationZ.push_back(aPMT1AdditionalLocalRotationZ * CLHEP::rad);
+  mPMTAdditionalLocalRotationZ.push_back(aPMT2AdditionalLocalRotationZ * CLHEP::rad);
+  mPMTAdditionalLocalRotationZ.push_back(aPMT3AdditionalLocalRotationZ * CLHEP::rad);
+  mPMTAdditionalLocalRotationZ.push_back(aPMT4AdditionalLocalRotationZ * CLHEP::rad);
+  mPMTAdditionalLocalRotationZ.push_back(aPMT5AdditionalLocalRotationZ * CLHEP::rad);
+
+  mPMTAlignmentLocalShiftX.push_back(aPMT0AlignmentShiftX * CLHEP::mm);
+  mPMTAlignmentLocalShiftX.push_back(aPMT1AlignmentShiftX * CLHEP::mm);
+  mPMTAlignmentLocalShiftX.push_back(aPMT2AlignmentShiftX * CLHEP::mm);
+  mPMTAlignmentLocalShiftX.push_back(aPMT3AlignmentShiftX * CLHEP::mm);
+  mPMTAlignmentLocalShiftX.push_back(aPMT4AlignmentShiftX * CLHEP::mm);
+  mPMTAlignmentLocalShiftX.push_back(aPMT5AlignmentShiftX * CLHEP::mm);
+
+  mPMTAlignmentLocalShiftY.push_back(aPMT0AlignmentShiftY * CLHEP::mm);
+  mPMTAlignmentLocalShiftY.push_back(aPMT1AlignmentShiftY * CLHEP::mm);
+  mPMTAlignmentLocalShiftY.push_back(aPMT2AlignmentShiftY * CLHEP::mm);
+  mPMTAlignmentLocalShiftY.push_back(aPMT3AlignmentShiftY * CLHEP::mm);
+  mPMTAlignmentLocalShiftY.push_back(aPMT4AlignmentShiftY * CLHEP::mm);
+  mPMTAlignmentLocalShiftY.push_back(aPMT5AlignmentShiftY * CLHEP::mm);
+
+  mPhSupFrameAdditionalShift.clear();
+  mPhSupFrameAdditionalShift.push_back(aPhSupFrameAdditionalShiftX);
+  mPhSupFrameAdditionalShift.push_back(aPhSupFrameAdditionalShiftY);
+  mPhSupFrameAdditionalShift.push_back(aPhSupFrameAdditionalShiftZ);
+
+  G4cout << "Current Run Configuration  is as follows " << G4endl;
+  G4cout << " Graphics Visibility : Hall Vessel Crystal " << RichTbHall_visib << "   " << RichTbUpgradeVessel_visib
+         << "   " << RichTbCrystal_visib << "  "
+         << "    " << G4endl;
+  G4cout << "  Graphics Visibility : PhDetSupFrame EC PMTMaster PMTSMaster "
+         << " PMTEnvelope  PMTEndCap PMTQuartzW PMTPhCathode   " << RichTbPhDetSupFrame_visib << "   " << RichTbEC_visib
+         << "   " << RichTbPMTMaster_visib << "   " << RichTbPMTSMaster_visib << "   " << RichTbPMTEnvelope_visib
+         << "   " << RichTbPMTEndCap_visib << "   " << RichTbPMTQuartzW_visib << "   " << RichTbPMTPhCathode_visib
+         << "   " << G4endl;
+  G4cout << "Nitrogen Pressure Temp  " << NitrogenPressureInAtmos << "    " << NitrogenTemperatureInKelvin << G4endl;
+  G4cout << "c4f10 Pressure Temp  " << c4f10PressureInAtmos << "    " << c4f10TemperatureInKelvin << G4endl;
+  G4cout << " Mirror Orientation code Additional Tilt wrt XAxis YAxis  " << MirrorOrientCode << "   "
+         << MirrorAdditionalTiltX << "  " << MirrorAdditionalTiltY << G4endl;
+
+  G4cout << " NonOptimal PMT Condition  NonOptimal PMT absolute Efficiency  " << mNonOptimalPMTCondition << "   "
+         << mNonOptimalPMTAbsEff << G4endl;
+
+  G4cout << " ParticleGun  Generation: Num of Particles generated per event   " << RichTbNumPartEvent << G4endl;
+  G4cout << " ParticleGun : Code for ParticleType StartPos Direction  Energy  "
+         << "and   Value for MomValue PosBeamFraction:   " << RichTbParticleTypeCode << "    "
+         << RichTbParticleStartPosCode << "   " << RichTbParticleDirectionCode << "    " << RichTbParticleEnergyCode
+         << "   " << RichTbParticleMomentum << "    " << PosBeamFraction << G4endl;
+  G4cout << " ParticleGun : BeamDirXY  BeamDivXY BeamPosShift XY   " << mBeamDirX << "   " << mBeamDirY << "   "
+         << mBeamDivergenceX << "   " << mBeamDivergenceY << "   " << mBeamXPosShift << "  " << mBeamYPosShift
+         << G4endl;
+
+  G4cout << " Special studies Beam XYZ BeamXRange phot wlen wlenmin wlenmax " << mBeamSpecialXPos << "  "
+         << mBeamSpecialYPos << "  " << mBeamSpecialZPos << "  " << mBeamSpecialXRange << "   " << mConstPhotWlenBeam
+         << "   " << mPhotWlenMinBeam << "   " << mPhotWlenMaxBeam << G4endl;
+
+  G4cout << "Activate beamshiftntuple " << mActivateBeamShiftNtuple << G4endl;
+
+  G4cout << "  PMTPEMomInit  " << PMTPEMomInit << G4endl;
+  G4cout << "Flag to WriteOut  HitCreationOption   " << WriteOutputFile << "    " << HitCreationOption << "     "
+         << G4endl;
+  G4cout << " Mirror refl file name " << MirrorReflFileName << G4endl;
+
+  G4cout << " Event Output FileName " << OutputFileName << G4endl;
+  G4cout << "Histo Output file Name  " << OutputHistoFileName << G4endl;
+  G4cout << "Ntuple Output file Name  " << OutputNtupleFileName << G4endl;
+
+  G4cout << "BatchMode NumEvInBatchMode  VerboseInfo "
+         << "  VerboseOutput studyvesselRot   " << mBatchModeFlag << "   " << mNumEventInBatchMode << "    "
+         << mVerboseInfoFlag << "   " << mVerboseOutputFileFlag << "   " << mSpecialStudyVesselRotation << G4endl;
+
+  // G4cout<< " Mapmt Pixel gap "<<  mMapmtPixelGap<<G4endl;
+  G4cout << "Pmt pixel efficiency flag  " << mMapmtPixelEfficiencyFlag << G4endl;
+
+  /*
+   for(G4int ihp=0; ihp< NumPMTs; ihp++) {
+    G4cout<<"PMT Demag Const shiftX in PMT  "<<ihp <<"  "<<
+            mDemagConstShiftAtAnodeX[ihp]<<G4endl;
+    G4cout<<"PMT Demag Const ShiftY in PMT "<<ihp<<"  "<<
+             mDemagConstShiftAtAnodeY[ihp]<<G4endl;
+
+    G4cout<<"PMT Additional RotZ wrt its Axis  "<<ihp<<"   "<<
+           mPMTAdditionalLocalRotationZ[ihp]<<G4endl;
+
+    G4cout<<"PMT Additional Xshift in phdetsupframe "<<ihp<<"  "<<
+    mPMTAlignmentLocalShiftX[ihp]<<G4endl;
+
+    G4cout<<"PMT additionl Y shift in phdet supframe "<<ihp<<"  "<<
+      mPMTAlignmentLocalShiftY[ihp]<<G4endl;
+  }
+  */
+  G4cout << " PhDet Frame Additional Shift XYZ   " << mPhSupFrameAdditionalShift[0] << "    "
+         << mPhSupFrameAdditionalShift[1] << "    " << mPhSupFrameAdditionalShift[2] << "    " << G4endl;
+
+  G4cout << " PhDet Frame Additional VertTilt Zrot " << mPhSupFrameAdditionalVertTilt << "    "
+         << mPhSupFrameAdditionalZRot << G4endl;
+
+  NitrogenPressure = NitrogenPressureInAtmos * CLHEP::atmosphere;
+  NitrogenTemperature = NitrogenTemperatureInKelvin * CLHEP::kelvin;
+
+  NominalNitrogenPressure = 1.0 * CLHEP::atmosphere;
+  NominalNitrogenTemperature = 293.0 * CLHEP::kelvin;
+
+  c4f10Pressure = c4f10PressureInAtmos * CLHEP::atmosphere;
+  c4f10Temperature = c4f10TemperatureInKelvin * CLHEP::kelvin;
+
+  Nominalc4f10Pressure = 1.0 * CLHEP::atmosphere;
+  Nominalc4f10Temperature = 293.0 * CLHEP::kelvin;
+
+  MirrorAddTiltX = MirrorAdditionalTiltX * CLHEP::rad;
+  MirrorAddTiltY = MirrorAdditionalTiltY * CLHEP::rad;
 }
 
+RichTbRunConfig::~RichTbRunConfig() { ; }
 
-RichTbRunConfig *RichTbRunConfig::getRunConfigInstance()
-{
+RichTbRunConfig *RichTbRunConfig::getRunConfigInstance() {
 
-    if (RunConfigInstance == 0) {
-        RunConfigInstance = new RichTbRunConfig();
-    }
-
-    return RunConfigInstance;
+  if (RunConfigInstance == 0) {
+    RunConfigInstance = new RichTbRunConfig();
+  }
 
+  return RunConfigInstance;
 }
-
-
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbUpgradeHpdSD.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbUpgradeHpdSD.cc
index 4ac3ac09d170e3774d50729c67fb186a309ae3e0..6da7c943a8801c9dad8c728efad97e147b6ebea0 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbUpgradeHpdSD.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbUpgradeHpdSD.cc
@@ -1,25 +1,22 @@
-// Include files 
-
-
+// Include files
 
 // local
 #include "RichTbUpgradeHpdSD.hh"
-#include "RichTbHit.hh"
-#include "RichTbGeometryParameters.hh"
-#include "Geant4/G4Step.hh"
 #include "Geant4/G4HCofThisEvent.hh"
-#include "Geant4/G4Track.hh"
+#include "Geant4/G4Navigator.hh"
 #include "Geant4/G4SDManager.hh"
-#include "Geant4/G4ios.hh"
+#include "Geant4/G4Step.hh"
 #include "Geant4/G4TouchableHistory.hh"
-#include "RichTbRunConfig.hh"
-#include "RichTbUserTrackInfo.hh"
-#include "RichTbPhotoElectron.hh"
+#include "Geant4/G4Track.hh"
 #include "Geant4/G4TransportationManager.hh"
-#include "Geant4/G4Navigator.hh"
-#include "RichTbUserTrackInfo.hh"
 #include "Geant4/G4VProcess.hh"
+#include "Geant4/G4ios.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbHit.hh"
 #include "RichTbMiscNames.hh"
+#include "RichTbPhotoElectron.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbUserTrackInfo.hh"
 
 //-----------------------------------------------------------------------------
 // Implementation file for class : RichTbUpgradeHpdSD
@@ -30,203 +27,180 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbUpgradeHpdSD::RichTbUpgradeHpdSD(G4String DetName):G4VSensitiveDetector(DetName),
-                                                         HpdSDID(std::vector<G4int>(NumHpds*NumPixelTotInSingleHpd , -1)),HCID(-1)
-{
+RichTbUpgradeHpdSD::RichTbUpgradeHpdSD(G4String DetName)
+    : G4VSensitiveDetector(DetName), HpdSDID(std::vector<G4int>(NumHpds * NumPixelTotInSingleHpd, -1)), HCID(-1) {
 
-  //  if ((int) collectionName.size() == 0) { 
+  //  if ((int) collectionName.size() == 0) {
   //  collectionName.clear();
   //  collectionName.reserve(2);
   // collectionName.push_back(RichTbHColname);
-   collectionName.push_back(RichTbHColnameHpd);
-   // }
-   // G4cout<<" Collection name size in hpdsd "<< (int) collectionName.size()<<G4endl;
-   
-  RichTbHitCollIndex=0;
-  RichTbSDHpdName=DetName;
-  
-
+  collectionName.push_back(RichTbHColnameHpd);
+  // }
+  // G4cout<<" Collection name size in hpdsd "<< (int) collectionName.size()<<G4endl;
 
+  RichTbHitCollIndex = 0;
+  RichTbSDHpdName = DetName;
 }
 
 //=============================================================================
 // Destructor
 //=============================================================================
-RichTbUpgradeHpdSD::~RichTbUpgradeHpdSD() {} 
+RichTbUpgradeHpdSD::~RichTbUpgradeHpdSD() {}
 
 //=============================================================================
-void RichTbUpgradeHpdSD::Initialize(G4HCofThisEvent*  HCE   ) {
+void RichTbUpgradeHpdSD::Initialize(G4HCofThisEvent *HCE) {
   //   G4cout<<" Now init  RichTbUpgradeSD Hpd "<<G4endl;
 
-     RichTbHitCollectionHpd = new RichTbHitsCollection(SensitiveDetectorName,collectionName[RichTbHitCollIndex]); 
+  RichTbHitCollectionHpd = new RichTbHitsCollection(SensitiveDetectorName, collectionName[RichTbHitCollIndex]);
 
-   // RichTbHitCollectionHpd = new RichTbHitsCollection(RichTbSDHpdName,collectionName[RichTbHitCollIndex]);
- 
-     // G4cout<<" RichTbUpgradeSD : Created RichTbHitCollection with "<< collectionName[RichTbHitCollIndex]  <<G4endl;
-  if( HCID < 0 ){
-    HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[RichTbHitCollIndex]); 
-  }
-  
-    HCE->AddHitsCollection( HCID, RichTbHitCollectionHpd );    
+  // RichTbHitCollectionHpd = new RichTbHitsCollection(RichTbSDHpdName,collectionName[RichTbHitCollIndex]);
 
-  for(G4int ipx = 0; ipx < (int) HpdSDID.size(); ipx++){
-      HpdSDID[ipx]=-1;
+  // G4cout<<" RichTbUpgradeSD : Created RichTbHitCollection with "<< collectionName[RichTbHitCollIndex]  <<G4endl;
+  if (HCID < 0) {
+    HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[RichTbHitCollIndex]);
   }
-  
-  RichTbRunConfig* aRunConfig =  RichTbRunConfig::getRunConfigInstance();
-  CurrentHitCreationOption= aRunConfig->getHitCreationOption();
 
-  //   G4cout<<" Now end init  RichTbUpgradeSD Hpd "<<G4endl;
+  HCE->AddHitsCollection(HCID, RichTbHitCollectionHpd);
+
+  for (G4int ipx = 0; ipx < (int)HpdSDID.size(); ipx++) {
+    HpdSDID[ipx] = -1;
+  }
 
+  RichTbRunConfig *aRunConfig = RichTbRunConfig::getRunConfigInstance();
+  CurrentHitCreationOption = aRunConfig->getHitCreationOption();
 
+  //   G4cout<<" Now end init  RichTbUpgradeSD Hpd "<<G4endl;
 }
-                                             
-void  RichTbUpgradeHpdSD::EndOfEvent(G4HCofThisEvent*  /* HCE  */){
+
+void RichTbUpgradeHpdSD::EndOfEvent(G4HCofThisEvent * /* HCE  */) {
   //  if( HCID < 0 ){
   //  HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[RichTbHitCollIndex]); }
-  //  HCE->AddHitsCollection( HCID, RichTbHitCollectionHpd );    
-
+  //  HCE->AddHitsCollection( HCID, RichTbHitCollectionHpd );
 }
 
-G4bool RichTbUpgradeHpdSD::ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist) {
+G4bool RichTbUpgradeHpdSD::ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist) {
 
   //  G4cout<<" Now in hpd SD process hits   "<< ROhist <<G4endl;
-  
-  if(!ROhist) return false;
+
+  if (!ROhist)
+    return false;
   G4double edep = aStep->GetTotalEnergyDeposit();
-  if(edep < 0.0001) return false;
-
-  G4StepPoint* pPreStepPoint =  aStep->GetPreStepPoint();
-  G4TouchableHistory* CurTT =  
-    (G4TouchableHistory*)(pPreStepPoint->GetTouchable());
-   CurTT -> MoveUpHistory(2);
-   G4String curnameVol =  CurTT -> GetVolume()->GetName();
-   G4int CurrentHpdNumber= CurTT -> GetVolume() -> GetCopyNo();
-   // G4cout<< " RichTbUpgradeSD: Hpd Number name "<<  CurrentHpdNumber <<"  "<<curnameVol<<G4endl;
-   G4VPhysicalVolume* ROphysVol = ROhist->GetVolume();
-   G4int CurrentPixelNumber = ROphysVol->GetCopyNo();
-   G4int CopyId = CurrentPixelNumber + ( CurrentHpdNumber * NumPixelTotInSingleHpd ) ;
-  if( (CurrentHitCreationOption==0 &&  HpdSDID[CopyId ] == -1) || 
-      (CurrentHitCreationOption==1 )) {
-
-     G4ThreeVector CurGlobalPos =aStep->GetPreStepPoint()->GetPosition();
-     G4Navigator* theNavigator =
-           G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
-    
-     G4ThreeVector CurLocalPos = theNavigator->GetGlobalToLocalTransform().TransformPoint(CurGlobalPos );
-     G4ThreeVector CurLocalPixelCenter = ROphysVol ->GetTranslation() ;
-     G4ThreeVector CurGlobalPixelCenter =theNavigator ->GetLocalToGlobalTransform().TransformPoint(CurLocalPixelCenter) ;
-     G4ThreeVector CurLocalPosWrtLocalPixelCenter =  CurLocalPos - CurLocalPixelCenter;
-     G4bool CurHitInPixelGapFlag = false;
-     
-
-
-    G4Track* aTrack = aStep->GetTrack();
+  if (edep < 0.0001)
+    return false;
+
+  G4StepPoint *pPreStepPoint = aStep->GetPreStepPoint();
+  G4TouchableHistory *CurTT = (G4TouchableHistory *)(pPreStepPoint->GetTouchable());
+  CurTT->MoveUpHistory(2);
+  G4String curnameVol = CurTT->GetVolume()->GetName();
+  G4int CurrentHpdNumber = CurTT->GetVolume()->GetCopyNo();
+  // G4cout<< " RichTbUpgradeSD: Hpd Number name "<<  CurrentHpdNumber <<"  "<<curnameVol<<G4endl;
+  G4VPhysicalVolume *ROphysVol = ROhist->GetVolume();
+  G4int CurrentPixelNumber = ROphysVol->GetCopyNo();
+  G4int CopyId = CurrentPixelNumber + (CurrentHpdNumber * NumPixelTotInSingleHpd);
+  if ((CurrentHitCreationOption == 0 && HpdSDID[CopyId] == -1) || (CurrentHitCreationOption == 1)) {
+
+    G4ThreeVector CurGlobalPos = aStep->GetPreStepPoint()->GetPosition();
+    G4Navigator *theNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
+
+    G4ThreeVector CurLocalPos = theNavigator->GetGlobalToLocalTransform().TransformPoint(CurGlobalPos);
+    G4ThreeVector CurLocalPixelCenter = ROphysVol->GetTranslation();
+    G4ThreeVector CurGlobalPixelCenter = theNavigator->GetLocalToGlobalTransform().TransformPoint(CurLocalPixelCenter);
+    G4ThreeVector CurLocalPosWrtLocalPixelCenter = CurLocalPos - CurLocalPixelCenter;
+    G4bool CurHitInPixelGapFlag = false;
+
+    G4Track *aTrack = aStep->GetTrack();
     G4ThreeVector aPeOrigin;
     G4ThreeVector aPhOrigin;
-    G4double aCkvCosTh=0.0;
-    G4double aCkvPhi=0.0;
-    G4double aPhEner=0.0;
+    G4double aCkvCosTh = 0.0;
+    G4double aCkvPhi = 0.0;
+    G4double aPhEner = 0.0;
     G4ThreeVector aPeOrginInPhSup;
-    G4ThreeVector aPhEmisDir;    
-    G4ThreeVector aTIRCoord ;
-    G4ThreeVector aMIRCoord ;
-    G4ThreeVector aRFRCoord ;
-    G4int  aMultReflFlag =0;
+    G4ThreeVector aPhEmisDir;
+    G4ThreeVector aTIRCoord;
+    G4ThreeVector aMIRCoord;
+    G4ThreeVector aRFRCoord;
+    G4int aMultReflFlag = 0;
     G4double aChTrackMom = 0.0;
     G4ThreeVector aChTrackThreeMom;
-    G4int aHitInPixelGapFlag=  CurHitInPixelGapFlag ? 1  : 0   ;
-    
+    G4int aHitInPixelGapFlag = CurHitInPixelGapFlag ? 1 : 0;
+
     G4String aCreatorProcessName = "NullProcess";
 
-    const G4VProcess* aProcess = aTrack->GetCreatorProcess();
-    if(aProcess) aCreatorProcessName = aProcess->GetProcessName();
-    if((aTrack->GetDefinition() == RichTbPhotoElectron::PhotoElectron()) &&
-       (aCreatorProcessName  == HpdPhotElectProc )) {
-    
-         aPeOrigin=aTrack->GetVertexPosition();
-         G4VUserTrackInformation* aUserTrackinfo=aTrack->GetUserInformation();
-         if(  aUserTrackinfo ) 
-         {
-            RichTbUserTrackInfo* aPeTrackUserInfo=  (RichTbUserTrackInfo*) aUserTrackinfo ;
-            if(aPeTrackUserInfo && aPeTrackUserInfo->HasUserPEInfo()){
-
-              // G4cout<<" Now get pe user track info " <<aPeTrackUserInfo<<G4endl;
- 
-                RichTbPEInfo* aPeInfo = aPeTrackUserInfo->getRichTbPEInfo();
-        
-             if(aPeInfo){
-                   aPhOrigin= aPeInfo -> PhOrigin();
-                  aPeOrginInPhSup=aPeInfo -> PeOriginInHpdSupFrame();
-                  aPhEmisDir=  aPeInfo-> getPhotEmisDir();
-                   RichTbPhotonInfo* aPhotonInfo = aPeInfo ->  MotherPhotonInfo();
-                   if( aPhotonInfo ){
-                     aCkvCosTh = aPhotonInfo->CkvCosThetaAtProd();
-                     aCkvPhi   = aPhotonInfo->CkvPhiAtProd();
-                     aPhEner   = aPhotonInfo->CkvPhotonEnergyAtProd() ;
-                     aTIRCoord = aPhotonInfo-> PhotonCrystalDnsTIRCoord();
-                     aMIRCoord = aPhotonInfo-> PhotonSphMirrReflCoord();
-                     aRFRCoord = aPhotonInfo-> PhotonCrystalDnsExitCoord();
-                     aMultReflFlag =  aPhotonInfo->PhotonRadiatorMultipleIncidenceFlag();
-                     aChTrackMom = aPhotonInfo-> ParentChTrackMomentum();
-                     aChTrackThreeMom = aPhotonInfo->ParentChTrackThreeMom();
-                   }
-             }
+    const G4VProcess *aProcess = aTrack->GetCreatorProcess();
+    if (aProcess)
+      aCreatorProcessName = aProcess->GetProcessName();
+    if ((aTrack->GetDefinition() == RichTbPhotoElectron::PhotoElectron()) &&
+        (aCreatorProcessName == HpdPhotElectProc)) {
+
+      aPeOrigin = aTrack->GetVertexPosition();
+      G4VUserTrackInformation *aUserTrackinfo = aTrack->GetUserInformation();
+      if (aUserTrackinfo) {
+        RichTbUserTrackInfo *aPeTrackUserInfo = (RichTbUserTrackInfo *)aUserTrackinfo;
+        if (aPeTrackUserInfo && aPeTrackUserInfo->HasUserPEInfo()) {
+
+          // G4cout<<" Now get pe user track info " <<aPeTrackUserInfo<<G4endl;
+
+          RichTbPEInfo *aPeInfo = aPeTrackUserInfo->getRichTbPEInfo();
+
+          if (aPeInfo) {
+            aPhOrigin = aPeInfo->PhOrigin();
+            aPeOrginInPhSup = aPeInfo->PeOriginInHpdSupFrame();
+            aPhEmisDir = aPeInfo->getPhotEmisDir();
+            RichTbPhotonInfo *aPhotonInfo = aPeInfo->MotherPhotonInfo();
+            if (aPhotonInfo) {
+              aCkvCosTh = aPhotonInfo->CkvCosThetaAtProd();
+              aCkvPhi = aPhotonInfo->CkvPhiAtProd();
+              aPhEner = aPhotonInfo->CkvPhotonEnergyAtProd();
+              aTIRCoord = aPhotonInfo->PhotonCrystalDnsTIRCoord();
+              aMIRCoord = aPhotonInfo->PhotonSphMirrReflCoord();
+              aRFRCoord = aPhotonInfo->PhotonCrystalDnsExitCoord();
+              aMultReflFlag = aPhotonInfo->PhotonRadiatorMultipleIncidenceFlag();
+              aChTrackMom = aPhotonInfo->ParentChTrackMomentum();
+              aChTrackThreeMom = aPhotonInfo->ParentChTrackThreeMom();
             }
-         }
-         
-
-
+          }
+        }
+      }
     }
-    
-    
-      RichTbHit* newHit = new RichTbHit();
-      newHit->SetEdep( edep );
-      newHit->SetPos(CurGlobalPos  );
-      newHit->SetCurHPDNum ( CurrentHpdNumber );
-      newHit->SetCurPixNum (CurrentPixelNumber   );
-      
-      newHit -> SetLocalPos(  CurLocalPos);
-      newHit->SetPeOrigin( aPeOrigin );
-      newHit->SetPhotonOrigin( aPhOrigin );
-      newHit->SetCkvCosThetaProd( aCkvCosTh );
-      newHit->SetCkvPhiProd( aCkvPhi );
-      newHit->SetCkvEnergyProd( aPhEner );
-      newHit->SetPeOriginInPhSupport( aPeOrginInPhSup );
-      newHit->SetPhEmissionDir( aPhEmisDir );
-      newHit->SetPixelLocalCenter(CurLocalPixelCenter);
-      newHit->SetPixelGlobalCenter(CurGlobalPixelCenter);
-      newHit->SetTIRRadiatorCoord(aTIRCoord);
-      newHit->SetMIRRadiatorCoord(aMIRCoord);
-      newHit->SetRFRRadiatorCoord(aRFRCoord);
-      newHit->SetMultipleReflFlag(aMultReflFlag);
-      newHit->SetChTrackTotMom(aChTrackMom);
-      newHit->SetChTrackThreeMom(aChTrackThreeMom);
-      newHit->SetHitInPixelGapFlag(aHitInPixelGapFlag );
-      
- 
-      G4int NumHits = RichTbHitCollectionHpd->insert( newHit );
-      HpdSDID[CopyId]= NumHits -1 ;
-      // newHit->Print();
-      
-      int verboseLevel=0;
-      if( verboseLevel > 0 ) G4cout << "Num hpd Hits stored in this event "<<NumHits<<G4endl;
-    
 
+    RichTbHit *newHit = new RichTbHit();
+    newHit->SetEdep(edep);
+    newHit->SetPos(CurGlobalPos);
+    newHit->SetCurHPDNum(CurrentHpdNumber);
+    newHit->SetCurPixNum(CurrentPixelNumber);
+
+    newHit->SetLocalPos(CurLocalPos);
+    newHit->SetPeOrigin(aPeOrigin);
+    newHit->SetPhotonOrigin(aPhOrigin);
+    newHit->SetCkvCosThetaProd(aCkvCosTh);
+    newHit->SetCkvPhiProd(aCkvPhi);
+    newHit->SetCkvEnergyProd(aPhEner);
+    newHit->SetPeOriginInPhSupport(aPeOrginInPhSup);
+    newHit->SetPhEmissionDir(aPhEmisDir);
+    newHit->SetPixelLocalCenter(CurLocalPixelCenter);
+    newHit->SetPixelGlobalCenter(CurGlobalPixelCenter);
+    newHit->SetTIRRadiatorCoord(aTIRCoord);
+    newHit->SetMIRRadiatorCoord(aMIRCoord);
+    newHit->SetRFRRadiatorCoord(aRFRCoord);
+    newHit->SetMultipleReflFlag(aMultReflFlag);
+    newHit->SetChTrackTotMom(aChTrackMom);
+    newHit->SetChTrackThreeMom(aChTrackThreeMom);
+    newHit->SetHitInPixelGapFlag(aHitInPixelGapFlag);
+
+    G4int NumHits = RichTbHitCollectionHpd->insert(newHit);
+    HpdSDID[CopyId] = NumHits - 1;
+    // newHit->Print();
+
+    int verboseLevel = 0;
+    if (verboseLevel > 0)
+      G4cout << "Num hpd Hits stored in this event " << NumHits << G4endl;
   }
-  
-  
-  return true;  
-  
-}
-                                             
-                                             
-                                             
-
 
+  return true;
+}
 
-void  RichTbUpgradeHpdSD::clear(){} 
+void RichTbUpgradeHpdSD::clear() {}
 
-void   RichTbUpgradeHpdSD::DrawAll(){ } 
+void RichTbUpgradeHpdSD::DrawAll() {}
 
-void   RichTbUpgradeHpdSD::PrintAll(){ } 
+void RichTbUpgradeHpdSD::PrintAll() {}
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbUpgradeSD.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbUpgradeSD.cc
index 07c671525413103edf81ae6e9925955c15ad973a..1ab1093ec915212bbf9ed7ba7948b85b72d4893e 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbUpgradeSD.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcmn/RichTbUpgradeSD.cc
@@ -1,44 +1,41 @@
 // $Id: $
 // Include files
 
-
-
 // local
 #include "RichTbUpgradeSD.hh"
-#include "RichTbHit.hh"
-#include "RichTbGeometryParameters.hh"
-#include "Geant4/G4Step.hh"
 #include "Geant4/G4HCofThisEvent.hh"
-#include "Geant4/G4Track.hh"
+#include "Geant4/G4Navigator.hh"
 #include "Geant4/G4SDManager.hh"
-#include "Geant4/G4ios.hh"
+#include "Geant4/G4Step.hh"
 #include "Geant4/G4TouchableHistory.hh"
-#include "RichTbRunConfig.hh"
-#include "RichTbUserTrackInfo.hh"
-#include "RichTbPhotoElectron.hh"
+#include "Geant4/G4Track.hh"
 #include "Geant4/G4TransportationManager.hh"
-#include "Geant4/G4Navigator.hh"
-#include "RichTbUserTrackInfo.hh"
 #include "Geant4/G4VProcess.hh"
+#include "Geant4/G4ios.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbHit.hh"
 #include "RichTbMiscNames.hh"
+#include "RichTbPhotoElectron.hh"
 #include "RichTbPmtPixelEfficiency.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbUserTrackInfo.hh"
 
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-RichTbUpgradeSD::RichTbUpgradeSD(G4String DetName  )
-:G4VSensitiveDetector(DetName),
- PmtSDID(std::vector<G4int>( NumPmts*NumPixelTotInPmt,-1)),HCID(-1) {
-//	 PmtSDID(std::vector<G4int>( RichTbPMTGeometryParameters::getNumPmts()*NumPixelTotInPmt,-1)),HCID(-1) { //TESTnumPmts
-
-	collectionName.clear();
-	collectionName.reserve(1);
-	collectionName.push_back(RichTbHColname);
-	//collectionName.push_back(RichTbHColnameHpd);
-	RichTbHitCollIndex=0;
-	RichTbSensDetName= DetName;
-
-	// G4cout<<"constructing the sensitive detector "<<G4endl;
+RichTbUpgradeSD::RichTbUpgradeSD(G4String DetName)
+    : G4VSensitiveDetector(DetName), PmtSDID(std::vector<G4int>(NumPmts * NumPixelTotInPmt, -1)), HCID(-1) {
+  //	 PmtSDID(std::vector<G4int>( RichTbPMTGeometryParameters::getNumPmts()*NumPixelTotInPmt,-1)),HCID(-1) {
+  ////TESTnumPmts
+
+  collectionName.clear();
+  collectionName.reserve(1);
+  collectionName.push_back(RichTbHColname);
+  // collectionName.push_back(RichTbHColnameHpd);
+  RichTbHitCollIndex = 0;
+  RichTbSensDetName = DetName;
+
+  // G4cout<<"constructing the sensitive detector "<<G4endl;
 }
 
 //=============================================================================
@@ -47,255 +44,205 @@ RichTbUpgradeSD::RichTbUpgradeSD(G4String DetName  )
 RichTbUpgradeSD::~RichTbUpgradeSD() {}
 //=============================================================================
 
-void RichTbUpgradeSD::Initialize(G4HCofThisEvent*  HCE )
-{
-
-	//  G4cout<<" Now init  RichTbUpgradeSD "<<collectionName[0]<<  G4endl;
-
+void RichTbUpgradeSD::Initialize(G4HCofThisEvent *HCE) {
 
-	RichTbHitCollection = new RichTbHitsCollection(SensitiveDetectorName,collectionName[0]);
+  //  G4cout<<" Now init  RichTbUpgradeSD "<<collectionName[0]<<  G4endl;
 
-	// RichTbHitCollection = new RichTbHitsCollection(RichTbSensDetName,collectionName[0]);
+  RichTbHitCollection = new RichTbHitsCollection(SensitiveDetectorName, collectionName[0]);
 
-	//  G4cout<<" RichTbUpgradeSD : Created RichTbHitCollection with "<< collectionName[0]  <<G4endl;
+  // RichTbHitCollection = new RichTbHitsCollection(RichTbSensDetName,collectionName[0]);
 
-	if( HCID < 0 ){
-		HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
-	}
-	//  G4cout<<" RichTbUpgradeSD : HCID "<<HCID<<G4endl;
+  //  G4cout<<" RichTbUpgradeSD : Created RichTbHitCollection with "<< collectionName[0]  <<G4endl;
 
-	HCE->AddHitsCollection( HCID, RichTbHitCollection );
+  if (HCID < 0) {
+    HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
+  }
+  //  G4cout<<" RichTbUpgradeSD : HCID "<<HCID<<G4endl;
 
-	// G4cout<<" RichTbUpgradeSD : HCID hitcolladded "<<HCID<<G4endl;
+  HCE->AddHitsCollection(HCID, RichTbHitCollection);
 
+  // G4cout<<" RichTbUpgradeSD : HCID hitcolladded "<<HCID<<G4endl;
 
-	for(G4int ipx = 0; ipx < (int) PmtSDID.size(); ipx++)
-	{
-		PmtSDID[ipx]=-1;
-	}
+  for (G4int ipx = 0; ipx < (int)PmtSDID.size(); ipx++) {
+    PmtSDID[ipx] = -1;
+  }
 
-	RichTbRunConfig* aRunConfig =  RichTbRunConfig::getRunConfigInstance();
-	CurrentHitCreationOption= aRunConfig->getHitCreationOption();
-	// CurrentPmtPixelGap = aRunConfig-> getMapmtPixelGap();
-	CurrentPmtPixelGap = RichTbPmtPixelGap;
-
-	//    G4cout<<" Now end init  RichTbUpgradeSD "<<G4endl;
+  RichTbRunConfig *aRunConfig = RichTbRunConfig::getRunConfigInstance();
+  CurrentHitCreationOption = aRunConfig->getHitCreationOption();
+  // CurrentPmtPixelGap = aRunConfig-> getMapmtPixelGap();
+  CurrentPmtPixelGap = RichTbPmtPixelGap;
 
+  //    G4cout<<" Now end init  RichTbUpgradeSD "<<G4endl;
 }
-void  RichTbUpgradeSD::EndOfEvent(G4HCofThisEvent* /* HCE  */){
-	//  if( HCID < 0 ){
-	//  HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
-	//  HCE->AddHitsCollection( HCID, RichTbHitCollection );
-
-
+void RichTbUpgradeSD::EndOfEvent(G4HCofThisEvent * /* HCE  */) {
+  //  if( HCID < 0 ){
+  //  HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
+  //  HCE->AddHitsCollection( HCID, RichTbHitCollection );
 }
-G4bool RichTbUpgradeSD::ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist)
-{
-
-	//  G4cout<<" Now in Process Hits Pmt SD "<<G4endl;
-
-	if(!ROhist) return false;
-
-
-
-
-	G4double edep = aStep->GetTotalEnergyDeposit();
-	if(edep < 0.0001) return false;
-	G4StepPoint* pPreStepPoint =  aStep->GetPreStepPoint();
-	G4TouchableHistory* CurTT =	(G4TouchableHistory*)(pPreStepPoint->GetTouchable());
-	CurTT -> MoveUpHistory(2);
-	G4String curnameVol =  CurTT -> GetVolume()->GetName();
-	G4int CurrentPmtNumber= CurTT -> GetVolume() -> GetCopyNo();
-	// G4cout<< " RichTbUpgradeSD: PMT Number name "<<  CurrentPmtNumber <<"  "<<curnameVol<<G4endl;
-	G4VPhysicalVolume* ROphysVol = ROhist->GetVolume();
-	G4int CurrentPixelNumber = ROphysVol->GetCopyNo();
-	G4int CopyId = CurrentPixelNumber + CurrentPmtNumber * NumPixelTotInPmt;
-
-	// now apply pixel efficiency when the flag to activate this efficiency is set to true.
-
-	RichTbPmtPixelEfficiency* aPixelEff = RichTbPmtPixelEfficiency::getRichTbPmtPixelEfficiencyInstance();
-	if(!(  aPixelEff -> PmtPixelEffOK (CurrentPmtNumber,CurrentPixelNumber )) ) return false;
-
-	// end apply pixel eff
-
-	if( (CurrentHitCreationOption==0 &&  PmtSDID[CopyId ] == -1) ||
-			(CurrentHitCreationOption==1 ))
-	{
-		G4ThreeVector CurGlobalPos =aStep->GetPreStepPoint()->GetPosition();
-		G4Navigator* theNavigator =
-				G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
-
-		G4ThreeVector CurLocalPos = theNavigator->GetGlobalToLocalTransform().TransformPoint(CurGlobalPos );
-		// G4int CopyId =  CurrentPmtNumber;
-
-		G4ThreeVector CurLocalPixelCenter = ROphysVol ->GetTranslation() ;
-		G4ThreeVector CurGlobalPixelCenter =theNavigator ->GetLocalToGlobalTransform().TransformPoint(CurLocalPixelCenter) ;
-
-		G4ThreeVector CurLocalPosWrtLocalPixelCenter =  CurLocalPos - CurLocalPixelCenter;
-		G4bool CurHitInPixelGapFlag = false;
-
-		if( fabs((CurLocalPosWrtLocalPixelCenter.x()) > (0.5*(PmtAnodePixelXSize-CurrentPmtPixelGap)) ) ||
-				fabs((CurLocalPosWrtLocalPixelCenter.y()) > (0.5*(PmtAnodePixelYSize-CurrentPmtPixelGap)) ) ) CurHitInPixelGapFlag=true;
-
-
-
-		/*
-     // test print start
-     G4cout<<" Sensdet pmt num pixel num copyid "<< CurrentPmtNumber <<"  "
-                 <<  CurrentPixelNumber  <<" "<<CopyId<<G4endl;
-
-     G4cout<<" Sensdet pixelcenter global local globalpixelcenter pos "<< CurLocalPixelCenter <<"  "<<CurGlobalPos <<"  "
-     <<CurLocalPos<<" "<<CurGlobalPixelCenter<< "   "<<CurLocalPosWrtLocalPixelCenter<<   G4endl;
-
-    G4cout<<" Sensdet pixelcenter global local globalpixelcenter pos differtpixel  gapflag  "<< CurLocalPixelCenter <<"  "<<CurGlobalPos <<"  "
-          <<CurLocalPos<<" "<<CurGlobalPixelCenter<< "   "<<CurLocalPosWrtLocalPixelCenter<<"  "
-          << CurHitInPixelGapFlag<< G4endl;
-
-    // test print end
-		 */
-
-		G4Track* aTrack = aStep->GetTrack();
-		G4ThreeVector aPeOrigin;
-		G4ThreeVector aPhOrigin;
-		G4double aCkvCosTh=0.0;
-		G4double aCkvPhi=0.0;
-		G4double aPhEner=0.0;
-		G4ThreeVector aPeOrginInPhSup;
-		G4ThreeVector aPhEmisDir;
-		G4ThreeVector aTIRCoord ;
-		G4ThreeVector aMIRCoord ;
-		G4ThreeVector aRFRCoord ;
-		G4int  aMultReflFlag =0;
-		G4double aChTrackMom = 0.0;
-		G4ThreeVector aChTrackThreeMom;
-		G4int aHitInPixelGapFlag=  CurHitInPixelGapFlag ? 1  : 0   ;
-
-		G4String aCreatorProcessName = "NullProcess";
-
-		const G4VProcess* aProcess = aTrack->GetCreatorProcess();
-		if(aProcess) aCreatorProcessName = aProcess->GetProcessName();
-		// G4cout<<" Upgrade SD creator proc "<<aCreatorProcessName <<G4endl;
-
-
-		if((aTrack->GetDefinition() == RichTbPhotoElectron::PhotoElectron()) &&
-				(aCreatorProcessName  == PmtPhotElectProc )) {
-
-
-			aPeOrigin=aTrack->GetVertexPosition();
-			//G4cout<<" Upgrade SD Now get pe origin "<<  aPeOrigin <<G4endl;
-
-
-			G4VUserTrackInformation* aUserTrackinfo=aTrack->GetUserInformation();
-			if(  aUserTrackinfo )
-			{
-				RichTbUserTrackInfo* aPeTrackUserInfo=  (RichTbUserTrackInfo*) aUserTrackinfo ;
-				if(aPeTrackUserInfo && aPeTrackUserInfo->HasUserPEInfo()){
-
-					// G4cout<<" Now get pe user track info " <<aPeTrackUserInfo<<G4endl;
-
-					RichTbPEInfo* aPeInfo = aPeTrackUserInfo->getRichTbPEInfo();
-
-					if(aPeInfo){
-						aPhOrigin= aPeInfo -> PhOrigin();
-						aPeOrginInPhSup=aPeInfo -> PeOriginInHpdSupFrame();
-						aPhEmisDir=  aPeInfo-> getPhotEmisDir();
-
-						RichTbPhotonInfo* aPhotonInfo = aPeInfo ->  MotherPhotonInfo();
-						if( aPhotonInfo ){
-							aCkvCosTh = aPhotonInfo->CkvCosThetaAtProd();
-							aCkvPhi   = aPhotonInfo->CkvPhiAtProd();
-							aPhEner   = aPhotonInfo->CkvPhotonEnergyAtProd() ;
-							aTIRCoord = aPhotonInfo-> PhotonCrystalDnsTIRCoord();
-							aMIRCoord = aPhotonInfo-> PhotonSphMirrReflCoord();
-							aRFRCoord = aPhotonInfo-> PhotonCrystalDnsExitCoord();
-							aMultReflFlag =  aPhotonInfo->PhotonRadiatorMultipleIncidenceFlag();
-							aChTrackMom = aPhotonInfo-> ParentChTrackMomentum();
-							aChTrackThreeMom = aPhotonInfo->ParentChTrackThreeMom();
-
-
-						}
-
-
-
-					}
-
-
-
-				}
-
-
-
-
-			}
-
-
-
-		}
-
-
-
-
-
-
-
-
-
-
-
-
-
-		/*
-    G4cout<<" Upgrade SD PeOrgin aPeOrginInPhSup CkvTh  aPhOrigin phener "<<  aPeOrigin <<"   "
-          << aPeOrginInPhSup <<"   "<<aCkvCosTh<<"  "<< aPhOrigin<<"  "<<  aPhEner<<G4endl;
-		 */
-		//G4cout<<" RichTbSD : Mulrefl flag "<< aMultReflFlag <<G4endl;
-
-
-		RichTbHit* newHit = new RichTbHit();
-		newHit->SetEdep( edep );
-		newHit->SetPos(CurGlobalPos  );
-		newHit->SetCurPMTNum ( CurrentPmtNumber );
-		newHit->SetCurPixNum (CurrentPixelNumber   );
-
-		newHit -> SetLocalPos(  CurLocalPos);
-		newHit->SetPeOrigin( aPeOrigin );
-		newHit->SetPhotonOrigin( aPhOrigin );
-		newHit->SetCkvCosThetaProd( aCkvCosTh );
-		newHit->SetCkvPhiProd( aCkvPhi );
-		newHit->SetCkvEnergyProd( aPhEner );
-		newHit->SetPeOriginInPhSupport( aPeOrginInPhSup );
-		newHit->SetPhEmissionDir( aPhEmisDir );
-		newHit->SetPixelLocalCenter(CurLocalPixelCenter);
-		newHit->SetPixelGlobalCenter(CurGlobalPixelCenter);
-		newHit->SetTIRRadiatorCoord(aTIRCoord);
-		newHit->SetMIRRadiatorCoord(aMIRCoord);
-		newHit->SetRFRRadiatorCoord(aRFRCoord);
-		newHit->SetMultipleReflFlag(aMultReflFlag);
-		newHit->SetChTrackTotMom(aChTrackMom);
-		newHit->SetChTrackThreeMom(aChTrackThreeMom);
-		newHit->SetHitInPixelGapFlag(aHitInPixelGapFlag );
-
-
-		G4int NumHits = RichTbHitCollection->insert( newHit );
-
-		PmtSDID[CopyId]= NumHits -1 ;
-		int verboseLevel=0;
-		if( verboseLevel > 0 ) G4cout << "NumHits from pmt stored in this event "<<NumHits<<G4endl;
-	}
-
-
-
-
-
-
-
-	return true;
+G4bool RichTbUpgradeSD::ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist) {
+
+  //  G4cout<<" Now in Process Hits Pmt SD "<<G4endl;
+
+  if (!ROhist)
+    return false;
+
+  G4double edep = aStep->GetTotalEnergyDeposit();
+  if (edep < 0.0001)
+    return false;
+  G4StepPoint *pPreStepPoint = aStep->GetPreStepPoint();
+  G4TouchableHistory *CurTT = (G4TouchableHistory *)(pPreStepPoint->GetTouchable());
+  CurTT->MoveUpHistory(2);
+  G4String curnameVol = CurTT->GetVolume()->GetName();
+  G4int CurrentPmtNumber = CurTT->GetVolume()->GetCopyNo();
+  // G4cout<< " RichTbUpgradeSD: PMT Number name "<<  CurrentPmtNumber <<"  "<<curnameVol<<G4endl;
+  G4VPhysicalVolume *ROphysVol = ROhist->GetVolume();
+  G4int CurrentPixelNumber = ROphysVol->GetCopyNo();
+  G4int CopyId = CurrentPixelNumber + CurrentPmtNumber * NumPixelTotInPmt;
+
+  // now apply pixel efficiency when the flag to activate this efficiency is set to true.
+
+  RichTbPmtPixelEfficiency *aPixelEff = RichTbPmtPixelEfficiency::getRichTbPmtPixelEfficiencyInstance();
+  if (!(aPixelEff->PmtPixelEffOK(CurrentPmtNumber, CurrentPixelNumber)))
+    return false;
+
+  // end apply pixel eff
+
+  if ((CurrentHitCreationOption == 0 && PmtSDID[CopyId] == -1) || (CurrentHitCreationOption == 1)) {
+    G4ThreeVector CurGlobalPos = aStep->GetPreStepPoint()->GetPosition();
+    G4Navigator *theNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
+
+    G4ThreeVector CurLocalPos = theNavigator->GetGlobalToLocalTransform().TransformPoint(CurGlobalPos);
+    // G4int CopyId =  CurrentPmtNumber;
+
+    G4ThreeVector CurLocalPixelCenter = ROphysVol->GetTranslation();
+    G4ThreeVector CurGlobalPixelCenter = theNavigator->GetLocalToGlobalTransform().TransformPoint(CurLocalPixelCenter);
+
+    G4ThreeVector CurLocalPosWrtLocalPixelCenter = CurLocalPos - CurLocalPixelCenter;
+    G4bool CurHitInPixelGapFlag = false;
+
+    if (fabs((CurLocalPosWrtLocalPixelCenter.x()) > (0.5 * (PmtAnodePixelXSize - CurrentPmtPixelGap))) ||
+        fabs((CurLocalPosWrtLocalPixelCenter.y()) > (0.5 * (PmtAnodePixelYSize - CurrentPmtPixelGap))))
+      CurHitInPixelGapFlag = true;
+
+    /*
+// test print start
+G4cout<<" Sensdet pmt num pixel num copyid "<< CurrentPmtNumber <<"  "
+     <<  CurrentPixelNumber  <<" "<<CopyId<<G4endl;
+
+G4cout<<" Sensdet pixelcenter global local globalpixelcenter pos "<< CurLocalPixelCenter <<"  "<<CurGlobalPos <<"  "
+<<CurLocalPos<<" "<<CurGlobalPixelCenter<< "   "<<CurLocalPosWrtLocalPixelCenter<<   G4endl;
+
+G4cout<<" Sensdet pixelcenter global local globalpixelcenter pos differtpixel  gapflag  "<< CurLocalPixelCenter <<"
+"<<CurGlobalPos <<"  "
+<<CurLocalPos<<" "<<CurGlobalPixelCenter<< "   "<<CurLocalPosWrtLocalPixelCenter<<"  "
+<< CurHitInPixelGapFlag<< G4endl;
+
+// test print end
+     */
+
+    G4Track *aTrack = aStep->GetTrack();
+    G4ThreeVector aPeOrigin;
+    G4ThreeVector aPhOrigin;
+    G4double aCkvCosTh = 0.0;
+    G4double aCkvPhi = 0.0;
+    G4double aPhEner = 0.0;
+    G4ThreeVector aPeOrginInPhSup;
+    G4ThreeVector aPhEmisDir;
+    G4ThreeVector aTIRCoord;
+    G4ThreeVector aMIRCoord;
+    G4ThreeVector aRFRCoord;
+    G4int aMultReflFlag = 0;
+    G4double aChTrackMom = 0.0;
+    G4ThreeVector aChTrackThreeMom;
+    G4int aHitInPixelGapFlag = CurHitInPixelGapFlag ? 1 : 0;
+
+    G4String aCreatorProcessName = "NullProcess";
+
+    const G4VProcess *aProcess = aTrack->GetCreatorProcess();
+    if (aProcess)
+      aCreatorProcessName = aProcess->GetProcessName();
+    // G4cout<<" Upgrade SD creator proc "<<aCreatorProcessName <<G4endl;
+
+    if ((aTrack->GetDefinition() == RichTbPhotoElectron::PhotoElectron()) &&
+        (aCreatorProcessName == PmtPhotElectProc)) {
+
+      aPeOrigin = aTrack->GetVertexPosition();
+      // G4cout<<" Upgrade SD Now get pe origin "<<  aPeOrigin <<G4endl;
+
+      G4VUserTrackInformation *aUserTrackinfo = aTrack->GetUserInformation();
+      if (aUserTrackinfo) {
+        RichTbUserTrackInfo *aPeTrackUserInfo = (RichTbUserTrackInfo *)aUserTrackinfo;
+        if (aPeTrackUserInfo && aPeTrackUserInfo->HasUserPEInfo()) {
+
+          // G4cout<<" Now get pe user track info " <<aPeTrackUserInfo<<G4endl;
+
+          RichTbPEInfo *aPeInfo = aPeTrackUserInfo->getRichTbPEInfo();
+
+          if (aPeInfo) {
+            aPhOrigin = aPeInfo->PhOrigin();
+            aPeOrginInPhSup = aPeInfo->PeOriginInHpdSupFrame();
+            aPhEmisDir = aPeInfo->getPhotEmisDir();
+
+            RichTbPhotonInfo *aPhotonInfo = aPeInfo->MotherPhotonInfo();
+            if (aPhotonInfo) {
+              aCkvCosTh = aPhotonInfo->CkvCosThetaAtProd();
+              aCkvPhi = aPhotonInfo->CkvPhiAtProd();
+              aPhEner = aPhotonInfo->CkvPhotonEnergyAtProd();
+              aTIRCoord = aPhotonInfo->PhotonCrystalDnsTIRCoord();
+              aMIRCoord = aPhotonInfo->PhotonSphMirrReflCoord();
+              aRFRCoord = aPhotonInfo->PhotonCrystalDnsExitCoord();
+              aMultReflFlag = aPhotonInfo->PhotonRadiatorMultipleIncidenceFlag();
+              aChTrackMom = aPhotonInfo->ParentChTrackMomentum();
+              aChTrackThreeMom = aPhotonInfo->ParentChTrackThreeMom();
+            }
+          }
+        }
+      }
+    }
+
+    /*
+G4cout<<" Upgrade SD PeOrgin aPeOrginInPhSup CkvTh  aPhOrigin phener "<<  aPeOrigin <<"   "
+<< aPeOrginInPhSup <<"   "<<aCkvCosTh<<"  "<< aPhOrigin<<"  "<<  aPhEner<<G4endl;
+     */
+    // G4cout<<" RichTbSD : Mulrefl flag "<< aMultReflFlag <<G4endl;
+
+    RichTbHit *newHit = new RichTbHit();
+    newHit->SetEdep(edep);
+    newHit->SetPos(CurGlobalPos);
+    newHit->SetCurPMTNum(CurrentPmtNumber);
+    newHit->SetCurPixNum(CurrentPixelNumber);
+
+    newHit->SetLocalPos(CurLocalPos);
+    newHit->SetPeOrigin(aPeOrigin);
+    newHit->SetPhotonOrigin(aPhOrigin);
+    newHit->SetCkvCosThetaProd(aCkvCosTh);
+    newHit->SetCkvPhiProd(aCkvPhi);
+    newHit->SetCkvEnergyProd(aPhEner);
+    newHit->SetPeOriginInPhSupport(aPeOrginInPhSup);
+    newHit->SetPhEmissionDir(aPhEmisDir);
+    newHit->SetPixelLocalCenter(CurLocalPixelCenter);
+    newHit->SetPixelGlobalCenter(CurGlobalPixelCenter);
+    newHit->SetTIRRadiatorCoord(aTIRCoord);
+    newHit->SetMIRRadiatorCoord(aMIRCoord);
+    newHit->SetRFRRadiatorCoord(aRFRCoord);
+    newHit->SetMultipleReflFlag(aMultReflFlag);
+    newHit->SetChTrackTotMom(aChTrackMom);
+    newHit->SetChTrackThreeMom(aChTrackThreeMom);
+    newHit->SetHitInPixelGapFlag(aHitInPixelGapFlag);
+
+    G4int NumHits = RichTbHitCollection->insert(newHit);
+
+    PmtSDID[CopyId] = NumHits - 1;
+    int verboseLevel = 0;
+    if (verboseLevel > 0)
+      G4cout << "NumHits from pmt stored in this event " << NumHits << G4endl;
+  }
+
+  return true;
 }
 
+void RichTbUpgradeSD::clear() {}
 
-void  RichTbUpgradeSD::clear(){}
-
-void   RichTbUpgradeSD::DrawAll(){ }
-
-void   RichTbUpgradeSD::PrintAll(){ }
+void RichTbUpgradeSD::DrawAll() {}
 
+void RichTbUpgradeSD::PrintAll() {}
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcph/HpdSiEnergyLoss.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcph/HpdSiEnergyLoss.cc
index e179542cfbb6773332d194ccfb66c5f1f54b843c..68bd07c5dbc75275f690642f5ea9c3a5543adb70 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcph/HpdSiEnergyLoss.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcph/HpdSiEnergyLoss.cc
@@ -1,19 +1,19 @@
 // $Id: $
-// Include files 
-#include "Geant4/globals.hh"
+// Include files
 #include "Geant4/G4Material.hh"
+#include "Geant4/G4TouchableHistory.hh"
+#include "Geant4/G4TransportationManager.hh"
+#include "Geant4/G4VProcess.hh"
 #include "Geant4/Randomize.hh"
+#include "Geant4/globals.hh"
+#include "RichTbGeometryParameters.hh"
 #include "RichTbMaterialParameters.hh"
-#include "Geant4/G4VProcess.hh"
-#include "RichTbRunConfig.hh"
 #include "RichTbMiscNames.hh"
-#include "RichTbGeometryParameters.hh"
-#include "Geant4/G4TransportationManager.hh"
-#include "Geant4/G4TouchableHistory.hh"
+#include "RichTbRunConfig.hh"
 // local
 #include "HpdSiEnergyLoss.hh"
-#include "RichTbPhotoElectron.hh"
 #include "RichTbPeUserInfoAttach.hh"
+#include "RichTbPhotoElectron.hh"
 //-----------------------------------------------------------------------------
 // Implementation file for class : HpdSiEnergyLoss
 //
@@ -23,251 +23,215 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-HpdSiEnergyLoss::HpdSiEnergyLoss(const G4String& processName )
- :G4VContinuousDiscreteProcess(processName),
-  MinKineticEnergy(1.*CLHEP::eV),MipEnergy(30000.0*CLHEP::eV),finalRangeforStep(0.15*CLHEP::mm)
- {
-
-  static const G4MaterialTable* theMaterialTable = 
-                     G4Material::GetMaterialTable();
-  ElossMaterialName=  HpdSiDetMaterialName;
-  EkillMaterialName=  HpdEnvelopeMaterialName;
-  
-  
-  G4int numberOfMat= (G4int) ((*theMaterialTable).size()) ;
+HpdSiEnergyLoss::HpdSiEnergyLoss(const G4String &processName)
+    : G4VContinuousDiscreteProcess(processName), MinKineticEnergy(1. * CLHEP::eV), MipEnergy(30000.0 * CLHEP::eV),
+      finalRangeforStep(0.15 * CLHEP::mm) {
+
+  static const G4MaterialTable *theMaterialTable = G4Material::GetMaterialTable();
+  ElossMaterialName = HpdSiDetMaterialName;
+  EkillMaterialName = HpdEnvelopeMaterialName;
+
+  G4int numberOfMat = (G4int)((*theMaterialTable).size());
   //  G4cout<<"Hpd Si Eloss number of Mat "<<numberOfMat<<G4endl;
-  G4int iMat=0;
-  fMatIndex=-1;
+  G4int iMat = 0;
+  fMatIndex = -1;
 
-  while(iMat<numberOfMat && fMatIndex < 0  ) {
-    if ( ElossMaterialName == (*theMaterialTable)[iMat]->GetName()){
-      fMatIndex=(*theMaterialTable)[iMat]->GetIndex();
+  while (iMat < numberOfMat && fMatIndex < 0) {
+    if (ElossMaterialName == (*theMaterialTable)[iMat]->GetName()) {
+      fMatIndex = (*theMaterialTable)[iMat]->GetIndex();
       //  G4cout<<"Hpd Si energy Loss construct Material "<<ElossMaterialName
       //      <<"   "<< fMatIndex<<G4endl;
     }
     iMat++;
-    
   }
-  
-  G4int iMatK=0;
-  fMatIndexK=-1;
-  while(iMatK<numberOfMat && fMatIndexK < 0  ) {
-    if ( EkillMaterialName == (*theMaterialTable)[iMatK]->GetName()){
-      fMatIndexK=(*theMaterialTable)[iMatK]->GetIndex();
+
+  G4int iMatK = 0;
+  fMatIndexK = -1;
+  while (iMatK < numberOfMat && fMatIndexK < 0) {
+    if (EkillMaterialName == (*theMaterialTable)[iMatK]->GetName()) {
+      fMatIndexK = (*theMaterialTable)[iMatK]->GetIndex();
       //  G4cout<<"Hpd Si Energy Loss: hpd endcap  Material "
       //    <<EkillMaterialName
       //      <<"   "<< fMatIndexK<<G4endl;
     }
     iMatK++;
-    
   }
 
-
-  if(iMat > numberOfMat ||  iMatK >  numberOfMat ) {
-    G4cout<<"Invalid material Name in HpdSiEnergyLoss constructor" <<G4endl;
+  if (iMat > numberOfMat || iMatK > numberOfMat) {
+    G4cout << "Invalid material Name in HpdSiEnergyLoss constructor" << G4endl;
   }
-     G4cout<<GetProcessName() <<" is created "<<G4endl;
-  
-
+  G4cout << GetProcessName() << " is created " << G4endl;
 }
 //=============================================================================
 // Destructor
 //=============================================================================
 HpdSiEnergyLoss::~HpdSiEnergyLoss() {}
-G4bool HpdSiEnergyLoss::IsApplicable(const G4ParticleDefinition& 
-                                     aParticleType) {
-   return(aParticleType.GetPDGCharge()!= 0.);
+G4bool HpdSiEnergyLoss::IsApplicable(const G4ParticleDefinition &aParticleType) {
+  return (aParticleType.GetPDGCharge() != 0.);
 }
 
-G4double HpdSiEnergyLoss::GetContinuousStepLimit(const G4Track& track,
-                                                 G4double /* previousStepSize */,
-                                                 G4double /* currentMinimumStep */,
-                                                 G4double& /* currentSafety*/){
+G4double HpdSiEnergyLoss::GetContinuousStepLimit(const G4Track &track, G4double /* previousStepSize */,
+                                                 G4double /* currentMinimumStep */, G4double & /* currentSafety*/) {
 
-  G4double  RangeForStep =  finalRangeforStep;
+  G4double RangeForStep = finalRangeforStep;
 
-  if( ( fMatIndex != (int) track.GetMaterial() -> GetIndex()) && 
-      ( fMatIndexK != (int) track.GetMaterial() -> GetIndex()) ) { 
+  if ((fMatIndex != (int)track.GetMaterial()->GetIndex()) && (fMatIndexK != (int)track.GetMaterial()->GetIndex())) {
     RangeForStep = DBL_MAX;
   }
-    
-   
-  return RangeForStep;
 
+  return RangeForStep;
 }
-G4double  HpdSiEnergyLoss::GetMeanFreePath(const G4Track& /* track */,
-                         G4double /* previousStepSize */,
-                         G4ForceCondition* condition) {
+G4double HpdSiEnergyLoss::GetMeanFreePath(const G4Track & /* track */, G4double /* previousStepSize */,
+                                          G4ForceCondition *condition) {
   // return infinity so that it does nothing.
   *condition = NotForced;
   return DBL_MAX;
-
 }
-G4VParticleChange*  HpdSiEnergyLoss::PostStepDoIt(const G4Track& aTrack,
-                                 const G4Step& aStep) {
+G4VParticleChange *HpdSiEnergyLoss::PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) {
   // Do nothing
-   aParticleChange.Initialize(aTrack) ;
-  return G4VContinuousDiscreteProcess::PostStepDoIt(aTrack,aStep);
-   
+  aParticleChange.Initialize(aTrack);
+  return G4VContinuousDiscreteProcess::PostStepDoIt(aTrack, aStep);
 }
-G4VParticleChange* HpdSiEnergyLoss::AlongStepDoIt(const G4Track& aTrack,
-                                                  const G4Step& /* aStep */) {
+G4VParticleChange *HpdSiEnergyLoss::AlongStepDoIt(const G4Track &aTrack, const G4Step & /* aStep */) {
 
   //  G4cout<<" Now in  HpdSiEnergyLoss alongstep "<<G4endl;
-  
+
   aParticleChange.Initialize(aTrack);
-  G4int aMaterialIndex =  (G4int) aTrack.GetMaterial()->GetIndex();
+  G4int aMaterialIndex = (G4int)aTrack.GetMaterial()->GetIndex();
   // G4String aMaterialName =  aTrack.GetMaterial()->GetName();
   // G4cout<<" HpdSiEnergyLoss  fmatindex fmatindexK  material index "<< fMatIndex <<"  "
   //      << fMatIndexK <<"   "<< aMaterialIndex <<"  "<< aMaterialName <<G4endl;
-  
 
-  // if( ( fMatIndex != (int) aTrack.GetMaterial()->GetIndex() ) && 
+  // if( ( fMatIndex != (int) aTrack.GetMaterial()->GetIndex() ) &&
   //     (fMatIndexK != (int) aTrack.GetMaterial()->GetIndex()  ) ) {
-  if( ( fMatIndex !=  aMaterialIndex  ) && 
-      (fMatIndexK !=  aMaterialIndex    ) ) {
+  if ((fMatIndex != aMaterialIndex) && (fMatIndexK != aMaterialIndex)) {
     return &aParticleChange;
   }
-  const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
-   G4double aKinEnergyInitParticle=aParticle->GetKineticEnergy(); 
-   G4double aKinEnergyInit = aKinEnergyInitParticle;
-    G4String  aCreatorProcessName= "NullProcess";
-    const G4VProcess* aProcess = aTrack.GetCreatorProcess();
-    if(aProcess) aCreatorProcessName =  aProcess->GetProcessName();
-    // if the particle hits the hpd envelope or the endcap
-    // return. If it is a photoelectron hitting the
-    // endcap or envelope kill the photoelectron.
-    if( fMatIndexK ==   (G4int) aTrack.GetMaterial() -> GetIndex()){
-      if( aCreatorProcessName ==  HpdPhotElectProc) {
-       aParticleChange.ProposeTrackStatus(fStopAndKill);
-       aParticleChange.ProposeEnergy(0.0);
-       // aParticleChange.SetStatusChange(fStopAndKill);        
-      }      
-      return &aParticleChange;
+  const G4DynamicParticle *aParticle = aTrack.GetDynamicParticle();
+  G4double aKinEnergyInitParticle = aParticle->GetKineticEnergy();
+  G4double aKinEnergyInit = aKinEnergyInitParticle;
+  G4String aCreatorProcessName = "NullProcess";
+  const G4VProcess *aProcess = aTrack.GetCreatorProcess();
+  if (aProcess)
+    aCreatorProcessName = aProcess->GetProcessName();
+  // if the particle hits the hpd envelope or the endcap
+  // return. If it is a photoelectron hitting the
+  // endcap or envelope kill the photoelectron.
+  if (fMatIndexK == (G4int)aTrack.GetMaterial()->GetIndex()) {
+    if (aCreatorProcessName == HpdPhotElectProc) {
+      aParticleChange.ProposeTrackStatus(fStopAndKill);
+      aParticleChange.ProposeEnergy(0.0);
+      // aParticleChange.SetStatusChange(fStopAndKill);
     }
+    return &aParticleChange;
+  }
+
+  // if( aCreatorProcessName != HpdPhotElectProc )   G4cout<<" Hpd energy loss proc  " << aCreatorProcessName <<G4endl;
 
-    // if( aCreatorProcessName != HpdPhotElectProc )   G4cout<<" Hpd energy loss proc  " << aCreatorProcessName <<G4endl;
-    
-    RichTbRunConfig* rConfig = RichTbRunConfig::getRunConfigInstance();
-  //  G4int aNonOptimalHpdCondition=  rConfig-> getNonOptimalHpdCondition();     
+  RichTbRunConfig *rConfig = RichTbRunConfig::getRunConfigInstance();
+  //  G4int aNonOptimalHpdCondition=  rConfig-> getNonOptimalHpdCondition();
   // G4double aNonOptimalHpdAbsEff = rConfig->getNonOptimalHpdAbsEff();
-   
+
   G4double Eloss, aKinEnergyFinal;
   //     G4cout<<" Now in Hpd Si energy loss with pheln initial energy = "
   //      << aKinEnergyInit<<G4endl;
-  
-  if(aKinEnergyInit < MinKineticEnergy ) {  Eloss=0.0 ; }
-  else if( aKinEnergyInit < MipEnergy ) {Eloss= aKinEnergyInit ;}
-  else { Eloss = MipEnergy; }
 
+  if (aKinEnergyInit < MinKineticEnergy) {
+    Eloss = 0.0;
+  } else if (aKinEnergyInit < MipEnergy) {
+    Eloss = aKinEnergyInit;
+  } else {
+    Eloss = MipEnergy;
+  }
 
   // if( aCreatorProcessName != HpdPhotElectProc )G4cout<<" backsca energy loss "<<Eloss <<G4endl;
-  
 
-  aKinEnergyFinal=aKinEnergyInit-Eloss;
+  aKinEnergyFinal = aKinEnergyInit - Eloss;
 
-  //Now implement the back scattering in an ad hoc manner.
+  // Now implement the back scattering in an ad hoc manner.
 
   //  G4double Effs = 1.0 -  backscaprob * bckKillFactor;
   G4double Effs = HpdelectronicsDetAbsEff;
-  
-  //  if( aNonOptimalHpdCondition >= 1 ) 
+
+  //  if( aNonOptimalHpdCondition >= 1 )
   //  {
   //    Effs =  aNonOptimalHpdAbsEff;
   //   }
 
-//   G4cout << "Back scattering: " << Effs << G4endl;
-  
+  //   G4cout << "Back scattering: " << Effs << G4endl;
+
   //  G4cout<<"Hpd Si energy loss Effs "<< Effs<<G4endl;
 
-  G4double Randbsk =  G4UniformRand();
+  G4double Randbsk = G4UniformRand();
   //  G4cout<<"Hpd Si energy loss Effs randbsk "<< Effs
   //      <<"   "<< Randbsk<<G4endl;
 
-  if(Randbsk <= Effs && Eloss > 0.0 ) 
-    {
-      //   G4cout<<"Now deposting energy in Silicon Eloss=  " 
-  	  //  <<Eloss<<G4endl;
-    
-      //aParticleChange.SetLocalEnergyDeposit(Eloss);  
-      aParticleChange.ProposeLocalEnergyDeposit(Eloss);
-
-      // Now to create backscattered electrons
-
-      G4double abackScaProb =  rConfig->getHpdpeBackScaProb();
-      
-      if( abackScaProb > 0.0 ) {
-
-         G4double aBckRnd = G4UniformRand();
-         if( aBckRnd < abackScaProb ) {
-           
-         if( aCreatorProcessName  == HpdPhotElectProc) {
-
-          G4double RandXposition =  G4UniformRand() -0.5;
-          G4double RandYposition =  G4UniformRand() -0.5;
-          G4ThreeVector LocalElectronDirection( 0,0 ,1 );
-          G4ThreeVector LocalElectronOrigin( RandXposition*RichTbHpdSiDetRadiusSize,
-                                             RandYposition*RichTbHpdSiDetRadiusSize , -0.5*RichTbHpdSiDetZSize-1.0);
-         G4Navigator* theNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
-         G4ThreeVector GlobalElectronOrigin = theNavigator->GetLocalToGlobalTransform().TransformPoint(LocalElectronOrigin);
-         const G4ThreeVector GlobalElectronDirection = theNavigator->
-                                GetLocalToGlobalTransform().TransformAxis(LocalElectronDirection);
-
-         G4double aPElectronTime= aTrack.GetGlobalTime();
-
-         G4double aElecKineEnergyForTracking=(rConfig ->getHpdPEMomInit() ) * CLHEP::keV;
-         
-         G4DynamicParticle* aElectron= 
-	            new G4DynamicParticle (RichTbPhotoElectron::PhotoElectron() ,
-                                 GlobalElectronDirection, aElecKineEnergyForTracking) ;
-
-         G4Track * aSecPETrack =
-	             new G4Track(aElectron,aPElectronTime,GlobalElectronOrigin);
-         
-          aSecPETrack->SetTouchableHandle((G4VTouchable*)0);
-          aSecPETrack->SetParentID(aTrack.GetTrackID());
-          aSecPETrack->SetGoodForTrackingFlag(true);
+  if (Randbsk <= Effs && Eloss > 0.0) {
+    //   G4cout<<"Now deposting energy in Silicon Eloss=  "
+    //  <<Eloss<<G4endl;
+
+    // aParticleChange.SetLocalEnergyDeposit(Eloss);
+    aParticleChange.ProposeLocalEnergyDeposit(Eloss);
+
+    // Now to create backscattered electrons
+
+    G4double abackScaProb = rConfig->getHpdpeBackScaProb();
+
+    if (abackScaProb > 0.0) {
+
+      G4double aBckRnd = G4UniformRand();
+      if (aBckRnd < abackScaProb) {
+
+        if (aCreatorProcessName == HpdPhotElectProc) {
+
+          G4double RandXposition = G4UniformRand() - 0.5;
+          G4double RandYposition = G4UniformRand() - 0.5;
+          G4ThreeVector LocalElectronDirection(0, 0, 1);
+          G4ThreeVector LocalElectronOrigin(RandXposition * RichTbHpdSiDetRadiusSize,
+                                            RandYposition * RichTbHpdSiDetRadiusSize, -0.5 * RichTbHpdSiDetZSize - 1.0);
+          G4Navigator *theNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
+          G4ThreeVector GlobalElectronOrigin =
+              theNavigator->GetLocalToGlobalTransform().TransformPoint(LocalElectronOrigin);
+          const G4ThreeVector GlobalElectronDirection =
+              theNavigator->GetLocalToGlobalTransform().TransformAxis(LocalElectronDirection);
+
+          G4double aPElectronTime = aTrack.GetGlobalTime();
+
+          G4double aElecKineEnergyForTracking = (rConfig->getHpdPEMomInit()) * CLHEP::keV;
+
+          G4DynamicParticle *aElectron = new G4DynamicParticle(RichTbPhotoElectron::PhotoElectron(),
+                                                               GlobalElectronDirection, aElecKineEnergyForTracking);
 
+          G4Track *aSecPETrack = new G4Track(aElectron, aPElectronTime, GlobalElectronOrigin);
 
+          aSecPETrack->SetTouchableHandle((G4VTouchable *)0);
+          aSecPETrack->SetParentID(aTrack.GetTrackID());
+          aSecPETrack->SetGoodForTrackingFlag(true);
 
-          G4Track* aTaggedSecPETrack = RichTbPeBckAttach(aTrack,aSecPETrack );
+          G4Track *aTaggedSecPETrack = RichTbPeBckAttach(aTrack, aSecPETrack);
           // G4cout<<"Created a backsca electron "<<G4endl;
-          
+
           aParticleChange.AddSecondary(aTaggedSecPETrack);
-          //kill old pe
+          // kill old pe
           aParticleChange.ProposeTrackStatus(fStopAndKill);
           aParticleChange.ProposeEnergy(0.0);
-
-         }
-         
+        }
       }
-      
-         
-      }
-      
-
-
-
     }
-  
-  //  if( aCreatorProcessName != HpdPhotElectProc )G4cout<<" Kinnergy final finalke "<<aKinEnergyFinal<<"  "                       
+  }
+
+  //  if( aCreatorProcessName != HpdPhotElectProc )G4cout<<" Kinnergy final finalke "<<aKinEnergyFinal<<"  "
   //   << MinKineticEnergy<<  G4endl;
-  
-  if (aKinEnergyFinal <= MinKineticEnergy ) 
-    {
-      //   aParticleChange.SetStatusChange(fStopAndKill);
-      aParticleChange.ProposeTrackStatus(fStopAndKill);
-      aParticleChange.ProposeEnergy(0.0);
-      
-    }
-  else 
-    { 
-      aParticleChange.ProposeEnergy(aKinEnergyFinal);
-      //    aParticleChange.SetEnergyChange(aKinEnergyFinal);
-    }
 
+  if (aKinEnergyFinal <= MinKineticEnergy) {
+    //   aParticleChange.SetStatusChange(fStopAndKill);
+    aParticleChange.ProposeTrackStatus(fStopAndKill);
+    aParticleChange.ProposeEnergy(0.0);
 
-  
+  } else {
+    aParticleChange.ProposeEnergy(aKinEnergyFinal);
+    //    aParticleChange.SetEnergyChange(aKinEnergyFinal);
+  }
 
   return &aParticleChange;
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcph/PixelHpdPhotoElectricEffect.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcph/PixelHpdPhotoElectricEffect.cc
index 90928d0a35823d6d3b31b10ee0d2774d0fe53b42..0cf0a0f96ebe0e02465ae16e4a3734ea343c5d0b 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcph/PixelHpdPhotoElectricEffect.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcph/PixelHpdPhotoElectricEffect.cc
@@ -1,19 +1,18 @@
-// Include files 
+// Include files
 
-#include "Geant4/globals.hh"
-#include <math.h>
-#include <vector>
 #include "PixelHpdPhotoElectricEffect.hh"
-#include "RichTbGeometryParameters.hh"
+#include "Geant4/G4TouchableHistory.hh"
 #include "Geant4/G4TransportationManager.hh"
 #include "Geant4/Randomize.hh"
+#include "Geant4/globals.hh"
 #include "RichTbAnalysisManager.hh"
-#include "RichTbRunConfig.hh"
+#include "RichTbGeometryParameters.hh"
 #include "RichTbMaterialParameters.hh"
-#include "Geant4/G4TouchableHistory.hh"
-#include "RichTbPhotoElectron.hh"
 #include "RichTbPeUserInfoAttach.hh"
-
+#include "RichTbPhotoElectron.hh"
+#include "RichTbRunConfig.hh"
+#include <math.h>
+#include <vector>
 
 // local
 
@@ -26,235 +25,196 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-PixelHpdPhotoElectricEffect::PixelHpdPhotoElectricEffect
- (const G4String& processName):G4VDiscreteProcess(processName),
-                               NumHpdTot(NumHpds),NumDemagParam(NumDemagnificationParam),NumQEbins(HpdQENumBins),
-                               DemagnificationFactor( NumHpds, std::vector<G4double>(NumDemagnificationParam )),
-                               HpdQE( NumHpds, std::vector<G4double>( NumQEbins) ),
-                               HpdWabin( NumHpds, std::vector<G4double>( NumQEbins) )
-{
-  RichTbRunConfig* rConfig = RichTbRunConfig::getRunConfigInstance();
+PixelHpdPhotoElectricEffect::PixelHpdPhotoElectricEffect(const G4String &processName)
+    : G4VDiscreteProcess(processName), NumHpdTot(NumHpds), NumDemagParam(NumDemagnificationParam),
+      NumQEbins(HpdQENumBins), DemagnificationFactor(NumHpds, std::vector<G4double>(NumDemagnificationParam)),
+      HpdQE(NumHpds, std::vector<G4double>(NumQEbins)), HpdWabin(NumHpds, std::vector<G4double>(NumQEbins)) {
+  RichTbRunConfig *rConfig = RichTbRunConfig::getRunConfigInstance();
   PrePhotoElectricVolName = HpdQuartzWMaterialName;
   PostPhotoElectricVolName = HpdPhCathodeMaterialName;
-  HpdPhElectronMomentum = ( rConfig->getHpdPEMomInit() ) * CLHEP::keV;
+  HpdPhElectronMomentum = (rConfig->getHpdPEMomInit()) * CLHEP::keV;
   PhCathodeToSilDetDist = RichTbHpdSiDetDistZFromPhCathode;
   HpdPhCathodeRInner = RichTbHpdPhCathodeInnerRad;
   PSFsigma = PixelHpdPSFSigma;
-  for(G4int ihpd=0; ihpd<NumHpdTot; ihpd++) {
-      DemagnificationFactor[ihpd][0]= PixelHpdDemagLinearFactor;
-      DemagnificationFactor[ihpd][1]=  PixelHpdDemagQuadraticFactor;
-      std::vector<G4double>qeCurHpd =  InitializeHpdQE(ihpd);
-      std::vector<G4double>waCurHpd =  InitializeHpdWaveL(ihpd);
-      if( ((int)  qeCurHpd.size() != (int) waCurHpd.size()) ||((int) qeCurHpd.size() !=  (int) HpdQE[ihpd].size())  ){
-	          G4cout<<"PhotElectEffect: Wrong size for Hpd QE "<<ihpd<<" "<<(int) qeCurHpd.size()
-             		<<"  "<< (int) waCurHpd.size()
-	            	<<"  "<<(int)  HpdQE[ihpd].size() <<G4endl;
-      }else{
-	
-        for(G4int iqbin=0; iqbin < (int) qeCurHpd.size(); iqbin++){
-	        // in the following the 100 is to convert from percent to
-	        // regular fraction.
-	      
-	      HpdQE[ihpd][iqbin]=qeCurHpd[iqbin]/100;
-	      HpdWabin[ihpd][iqbin]=waCurHpd[iqbin];
-	      
-	        //        G4cout<<" PhotElect hpdnum ibin Hpd Wlen HpdQE   "
-	        //      << ihpd<<"   "<< iqbin<<"   "<< HpdWabin[ihpd][iqbin]
-	        //      <<"    "<<  HpdQE[ihpd][iqbin]<<G4endl;
-	      
-       }
+  for (G4int ihpd = 0; ihpd < NumHpdTot; ihpd++) {
+    DemagnificationFactor[ihpd][0] = PixelHpdDemagLinearFactor;
+    DemagnificationFactor[ihpd][1] = PixelHpdDemagQuadraticFactor;
+    std::vector<G4double> qeCurHpd = InitializeHpdQE(ihpd);
+    std::vector<G4double> waCurHpd = InitializeHpdWaveL(ihpd);
+    if (((int)qeCurHpd.size() != (int)waCurHpd.size()) || ((int)qeCurHpd.size() != (int)HpdQE[ihpd].size())) {
+      G4cout << "PhotElectEffect: Wrong size for Hpd QE " << ihpd << " " << (int)qeCurHpd.size() << "  "
+             << (int)waCurHpd.size() << "  " << (int)HpdQE[ihpd].size() << G4endl;
+    } else {
+
+      for (G4int iqbin = 0; iqbin < (int)qeCurHpd.size(); iqbin++) {
+        // in the following the 100 is to convert from percent to
+        // regular fraction.
 
+        HpdQE[ihpd][iqbin] = qeCurHpd[iqbin] / 100;
+        HpdWabin[ihpd][iqbin] = waCurHpd[iqbin];
 
+        //        G4cout<<" PhotElect hpdnum ibin Hpd Wlen HpdQE   "
+        //      << ihpd<<"   "<< iqbin<<"   "<< HpdWabin[ihpd][iqbin]
+        //      <<"    "<<  HpdQE[ihpd][iqbin]<<G4endl;
       }
-      
+    }
   }
-  
-  
-  
-   G4cout<<GetProcessName() <<" is created "<<G4endl;
 
+  G4cout << GetProcessName() << " is created " << G4endl;
 }
 //=============================================================================
 // Destructor
 //=============================================================================
-PixelHpdPhotoElectricEffect::~PixelHpdPhotoElectricEffect() {} 
+PixelHpdPhotoElectricEffect::~PixelHpdPhotoElectricEffect() {}
 
 //=============================================================================
-G4bool PixelHpdPhotoElectricEffect::IsApplicable(const G4ParticleDefinition& aParticleType)
-{
-  return ( &aParticleType == G4OpticalPhoton::OpticalPhoton() );
+G4bool PixelHpdPhotoElectricEffect::IsApplicable(const G4ParticleDefinition &aParticleType) {
+  return (&aParticleType == G4OpticalPhoton::OpticalPhoton());
 }
 
-
-G4double PixelHpdPhotoElectricEffect::GetMeanFreePath(const G4Track& ,
-                                                      G4double ,
-                                                      G4ForceCondition* condition)
-{
+G4double PixelHpdPhotoElectricEffect::GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *condition) {
   *condition = Forced;
 
   return DBL_MAX;
 }
-G4VParticleChange* PixelHpdPhotoElectricEffect::PostStepDoIt(const G4Track& aTrack,const G4Step& aStep)
-{
+G4VParticleChange *PixelHpdPhotoElectricEffect::PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) {
   aParticleChange.Initialize(aTrack);
 
-  G4StepPoint* pPreStepPoint  = aStep.GetPreStepPoint();
-  G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
+  G4StepPoint *pPreStepPoint = aStep.GetPreStepPoint();
+  G4StepPoint *pPostStepPoint = aStep.GetPostStepPoint();
 
   if (pPostStepPoint->GetStepStatus() != fGeomBoundary)
     return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
 
-  G4String PrePhName = pPreStepPoint -> GetPhysicalVolume() ->
-    GetLogicalVolume() -> GetMaterial()->GetName();
-  G4String PostPhName= pPostStepPoint -> GetPhysicalVolume() ->
-    GetLogicalVolume() -> GetMaterial() ->GetName();
-
-  if(( PrePhName == PrePhotoElectricVolName &&
-       PostPhName == PostPhotoElectricVolName) ||
-     ( PostPhName == PrePhotoElectricVolName &&
-       PrePhName == PostPhotoElectricVolName) )
-    {
-
-      //    G4cout<<"PadHpdPhElec effect PreVol Post Vol "<<PrePhName
-      //      <<"   "<<PostPhName<<G4endl;
-    }else {
-      return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-    }
+  G4String PrePhName = pPreStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetMaterial()->GetName();
+  G4String PostPhName = pPostStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetMaterial()->GetName();
+
+  if ((PrePhName == PrePhotoElectricVolName && PostPhName == PostPhotoElectricVolName) ||
+      (PostPhName == PrePhotoElectricVolName && PrePhName == PostPhotoElectricVolName)) {
+
+    //    G4cout<<"PadHpdPhElec effect PreVol Post Vol "<<PrePhName
+    //      <<"   "<<PostPhName<<G4endl;
+  } else {
+    return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+  }
 
   // if (aTrack.GetStepLength()<=kCarTolerance/2)
   //   return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
 
-
-  const G4DynamicParticle* aDynamicPhoton = aTrack.GetDynamicParticle();
+  const G4DynamicParticle *aDynamicPhoton = aTrack.GetDynamicParticle();
   G4double PhotonEnergy = aDynamicPhoton->GetKineticEnergy();
 
-  if(PhotonEnergy <= 0.0 ){
-      return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+  if (PhotonEnergy <= 0.0) {
+    return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
   }
-  
 
-  //Now use the QE for the current HPD to determine if a
+  // Now use the QE for the current HPD to determine if a
   // photoelectron should be produced or not.
 
-  G4TouchableHistory* CurTT =
-    (G4TouchableHistory*)(pPreStepPoint->GetTouchable());
-  G4int currentHpdNumber= CurTT -> GetReplicaNumber(2);
-  if(currentHpdNumber >= NumHpdTot ||currentHpdNumber < 0   )
+  G4TouchableHistory *CurTT = (G4TouchableHistory *)(pPreStepPoint->GetTouchable());
+  G4int currentHpdNumber = CurTT->GetReplicaNumber(2);
+  if (currentHpdNumber >= NumHpdTot || currentHpdNumber < 0)
     return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
 
-  G4double PhotWLength=PhotMomToWaveLength/PhotonEnergy;
-  G4double PhotWLengthNano =   PhotWLength/(CLHEP::nanometer);
+  G4double PhotWLength = PhotMomToWaveLength / PhotonEnergy;
+  // G4double PhotWLengthNano = PhotWLength / (CLHEP::nanometer);
   G4double PhCathodeQE = getHpdQEff(currentHpdNumber, PhotWLength);
   G4double randomnum = G4UniformRand();
-  if(randomnum <  PhCathodeQE ) {
-     G4double aPhotonTime= aTrack.GetGlobalTime();
- 
-  G4ThreeVector GlobalElectronOrigin= pPostStepPoint->GetPosition();
-
-  G4Navigator* theNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
-  G4ThreeVector LocalElectronOrigin = theNavigator->GetGlobalToLocalTransform().TransformPoint(GlobalElectronOrigin);
-
-      G4double CurDemagFactor=DemagnificationFactor[currentHpdNumber][0];
-      G4double CurDemagQuadFactor=DemagnificationFactor[currentHpdNumber][1];
-      G4double PsfRandomAzimuth = CLHEP::twopi*G4UniformRand();
-      G4double PsfRandomRad= G4RandGauss::shoot(0.0,PSFsigma);
-      G4double PsfX= PsfRandomRad*cos( PsfRandomAzimuth);
-      G4double PsfY= PsfRandomRad*sin( PsfRandomAzimuth);
-      G4double ElectronCathodeRadius = sqrt( pow(LocalElectronOrigin.x(), 2) +
-                                             pow(LocalElectronOrigin.y(), 2) );
-      G4double ElectronAnodeRadius = ((CurDemagQuadFactor*ElectronCathodeRadius) + 
-                                       CurDemagFactor) * ElectronCathodeRadius;
-
-      G4double scale = -1;
-      if(ElectronCathodeRadius != 0)
-        { scale = (ElectronAnodeRadius/ElectronCathodeRadius) - 1; }
-
-      G4ThreeVector LocalElectronDirection(LocalElectronOrigin.x()*scale + PsfX,
-                                           LocalElectronOrigin.y()*scale + PsfY,
-                                           -(PhCathodeToSilDetDist-
-                                             (HpdPhCathodeRInner-
-                                              LocalElectronOrigin.z())));
-  LocalElectronDirection = LocalElectronDirection.unit();
-
-  const G4ThreeVector GlobalElectronDirection = theNavigator->
-                                GetLocalToGlobalTransform().
-                                TransformAxis(LocalElectronDirection);
- 
-  G4double ElecKineEnergy= getHpdPhElectronMomentum();
-
-  G4TouchableHistory* CurTTP = (G4TouchableHistory*) (pPreStepPoint->GetTouchable());
-  CurTTP -> MoveUpHistory(2);
-  G4int   CurTTPDepth=  CurTTP->GetHistoryDepth();
-  G4ThreeVector ElnOrgInPhDet =  CurTTP->GetHistory()->GetTransform(CurTTPDepth).TransformPoint(GlobalElectronOrigin);
-
-
-
-  G4DynamicParticle* aElectron=
-    new G4DynamicParticle (RichTbPhotoElectron::PhotoElectron(),
-                                GlobalElectronDirection, ElecKineEnergy) ;
-
-   aParticleChange.SetNumberOfSecondaries(1) ;
-
-   G4Track* aSecPETrack =
-               new G4Track(aElectron,aPhotonTime,GlobalElectronOrigin);
-
-      aSecPETrack->SetTouchableHandle((G4VTouchable*)0);
-      aSecPETrack->SetParentID(aTrack.GetTrackID());
-      aSecPETrack->SetGoodForTrackingFlag(true);
-      G4Track* aTaggedSecPETrack = RichTbPeInfoAttach(aTrack,aSecPETrack,
-                                                          ElnOrgInPhDet);
-      //  G4cout<<" Now created a  secondary track from pixel hpd photoelectric effect "<<G4endl;
-      
-      aParticleChange.AddSecondary(aTaggedSecPETrack);
+  if (randomnum < PhCathodeQE) {
+    G4double aPhotonTime = aTrack.GetGlobalTime();
+
+    G4ThreeVector GlobalElectronOrigin = pPostStepPoint->GetPosition();
+
+    G4Navigator *theNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
+    G4ThreeVector LocalElectronOrigin = theNavigator->GetGlobalToLocalTransform().TransformPoint(GlobalElectronOrigin);
+
+    G4double CurDemagFactor = DemagnificationFactor[currentHpdNumber][0];
+    G4double CurDemagQuadFactor = DemagnificationFactor[currentHpdNumber][1];
+    G4double PsfRandomAzimuth = CLHEP::twopi * G4UniformRand();
+    G4double PsfRandomRad = G4RandGauss::shoot(0.0, PSFsigma);
+    G4double PsfX = PsfRandomRad * cos(PsfRandomAzimuth);
+    G4double PsfY = PsfRandomRad * sin(PsfRandomAzimuth);
+    G4double ElectronCathodeRadius = sqrt(pow(LocalElectronOrigin.x(), 2) + pow(LocalElectronOrigin.y(), 2));
+    G4double ElectronAnodeRadius =
+        ((CurDemagQuadFactor * ElectronCathodeRadius) + CurDemagFactor) * ElectronCathodeRadius;
+
+    G4double scale = -1;
+    if (ElectronCathodeRadius != 0) {
+      scale = (ElectronAnodeRadius / ElectronCathodeRadius) - 1;
+    }
+
+    G4ThreeVector LocalElectronDirection(LocalElectronOrigin.x() * scale + PsfX, LocalElectronOrigin.y() * scale + PsfY,
+                                         -(PhCathodeToSilDetDist - (HpdPhCathodeRInner - LocalElectronOrigin.z())));
+    LocalElectronDirection = LocalElectronDirection.unit();
+
+    const G4ThreeVector GlobalElectronDirection =
+        theNavigator->GetLocalToGlobalTransform().TransformAxis(LocalElectronDirection);
+
+    G4double ElecKineEnergy = getHpdPhElectronMomentum();
+
+    G4TouchableHistory *CurTTP = (G4TouchableHistory *)(pPreStepPoint->GetTouchable());
+    CurTTP->MoveUpHistory(2);
+    G4int CurTTPDepth = CurTTP->GetHistoryDepth();
+    G4ThreeVector ElnOrgInPhDet = CurTTP->GetHistory()->GetTransform(CurTTPDepth).TransformPoint(GlobalElectronOrigin);
+
+    G4DynamicParticle *aElectron =
+        new G4DynamicParticle(RichTbPhotoElectron::PhotoElectron(), GlobalElectronDirection, ElecKineEnergy);
+
+    aParticleChange.SetNumberOfSecondaries(1);
+
+    G4Track *aSecPETrack = new G4Track(aElectron, aPhotonTime, GlobalElectronOrigin);
+
+    aSecPETrack->SetTouchableHandle((G4VTouchable *)0);
+    aSecPETrack->SetParentID(aTrack.GetTrackID());
+    aSecPETrack->SetGoodForTrackingFlag(true);
+    G4Track *aTaggedSecPETrack = RichTbPeInfoAttach(aTrack, aSecPETrack, ElnOrgInPhDet);
+    //  G4cout<<" Now created a  secondary track from pixel hpd photoelectric effect "<<G4endl;
+
+    aParticleChange.AddSecondary(aTaggedSecPETrack);
     aParticleChange.ProposeTrackStatus(fStopAndKill);
     aParticleChange.ProposeEnergy(0.0);
-  
-    } else {
 
-    //photon is not killed if it is not converted to photoelectron
+  } else {
 
-    }
-  
-return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+    // photon is not killed if it is not converted to photoelectron
+  }
 
+  return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
 }
-G4double PixelHpdPhotoElectricEffect::getHpdQEff(G4int HpdNum,
-  G4double PhotonWLength){
-
-    G4double hq1=0.0;    G4double hq2=0.0;
-    G4double wa1=0.0; G4double wa2=0.0; G4double aslope=0.0;
-    // G4double aintc=0.0;
+G4double PixelHpdPhotoElectricEffect::getHpdQEff(G4int HpdNum, G4double PhotonWLength) {
+
+  G4double hq1 = 0.0;
+  G4double hq2 = 0.0;
+  G4double wa1 = 0.0;
+  G4double wa2 = 0.0;
+  G4double aslope = 0.0;
+  // G4double aintc=0.0;
   //  G4cout<<"Now in Hpd QE Finder hpdnum PhWlen   "
   //      <<HpdNum<<"    "<<PhotonWLength<<G4endl;
-    G4double qeff=0.0;
-
-  if( PhotonWLength ==  HpdWabin[HpdNum][ HpdQENumBins-1] ) {
-    qeff =  HpdQE[HpdNum] [HpdQENumBins-1] ;
-  }else if (  PhotonWLength ==  HpdWabin[HpdNum][ 0] ) {
-    qeff = HpdQE[HpdNum] [0];
-  } else if( ( PhotonWLength >= HpdWabin[HpdNum][0]) &&
-      ( PhotonWLength < HpdWabin[HpdNum][HpdQENumBins-1]) ) {
-  G4int ibinq=0;
-  G4bool BinFound=false;
-  while (ibinq< (NumQEbins-1)  && (! (BinFound))  ){
-  wa1 = HpdWabin[HpdNum][ibinq];
-  wa2 = HpdWabin[HpdNum][ibinq+1];
-  if( PhotonWLength >= wa1 && PhotonWLength < wa2 ) {
-   hq1 =   HpdQE[HpdNum][ibinq];
-   hq2 =   HpdQE[HpdNum][ibinq+1];
-   aslope = (hq2-hq1)/(wa2-wa1);
-   // aintc =  hq1 - (aslope * wa1 );
-   //   qeff= aintc + aslope * PhotonWLength ;
-   qeff= hq1 + aslope * (PhotonWLength-wa1) ;
-   BinFound=true;
-
-  }
-  ibinq++;
-  }
-
+  G4double qeff = 0.0;
+
+  if (PhotonWLength == HpdWabin[HpdNum][HpdQENumBins - 1]) {
+    qeff = HpdQE[HpdNum][HpdQENumBins - 1];
+  } else if (PhotonWLength == HpdWabin[HpdNum][0]) {
+    qeff = HpdQE[HpdNum][0];
+  } else if ((PhotonWLength >= HpdWabin[HpdNum][0]) && (PhotonWLength < HpdWabin[HpdNum][HpdQENumBins - 1])) {
+    G4int ibinq = 0;
+    G4bool BinFound = false;
+    while (ibinq < (NumQEbins - 1) && (!(BinFound))) {
+      wa1 = HpdWabin[HpdNum][ibinq];
+      wa2 = HpdWabin[HpdNum][ibinq + 1];
+      if (PhotonWLength >= wa1 && PhotonWLength < wa2) {
+        hq1 = HpdQE[HpdNum][ibinq];
+        hq2 = HpdQE[HpdNum][ibinq + 1];
+        aslope = (hq2 - hq1) / (wa2 - wa1);
+        // aintc =  hq1 - (aslope * wa1 );
+        //   qeff= aintc + aslope * PhotonWLength ;
+        qeff = hq1 + aslope * (PhotonWLength - wa1);
+        BinFound = true;
+      }
+      ibinq++;
+    }
   }
 
-
   return qeff;
-
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcph/PmtAnodeEnergyLoss.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcph/PmtAnodeEnergyLoss.cc
index 3ee56b32b10308a0235daf31aadf745043e1ee21..050ed38c488f8f7c74250a49ff7af2cdeb6fef21 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcph/PmtAnodeEnergyLoss.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcph/PmtAnodeEnergyLoss.cc
@@ -2,9 +2,9 @@
 // Include files
 
 #include "Geant4/G4Material.hh"
+#include "Geant4/G4VProcess.hh"
 #include "Geant4/Randomize.hh"
 #include "RichTbMaterialParameters.hh"
-#include "Geant4/G4VProcess.hh"
 #include "RichTbRunConfig.hh"
 
 #include "Geant4/G4TouchableHistory.hh" //test
@@ -15,194 +15,162 @@
 //=============================================================================
 // Standard constructor, initializes variables
 //=============================================================================
-PmtAnodeEnergyLoss::PmtAnodeEnergyLoss(const G4String& processName )
- :G4VContinuousDiscreteProcess(processName),
-  MinKineticEnergy(1.*CLHEP::eV),MipEnergy(30000.0*CLHEP::eV),finalRangeforStep(0.15*CLHEP::mm)
- {
-
-  static const G4MaterialTable* theMaterialTable =
-                     G4Material::GetMaterialTable();
-  ElossMaterialName=  PMTAnodeMaterialName;
-  EkillMaterialName=  PMTEnvelopeMaterialName;
-
-   G4int numberOfMat= (G4int) ((*theMaterialTable).size()) ;
-  G4cout<<"Pmt Anode Eloss number of Mat "<<numberOfMat<<G4endl;
-  G4int iMat=0;
-  fMatIndex=-1;
-
-  while(iMat<numberOfMat && fMatIndex < 0  ) {
-    if ( ElossMaterialName == (*theMaterialTable)[iMat]->GetName()){
-      fMatIndex=(*theMaterialTable)[iMat]->GetIndex();
-       G4cout<<"PMT anode energy Loss construct Material "<<ElossMaterialName
-            <<"   "<< fMatIndex<<G4endl;
+PmtAnodeEnergyLoss::PmtAnodeEnergyLoss(const G4String &processName)
+    : G4VContinuousDiscreteProcess(processName), MinKineticEnergy(1. * CLHEP::eV), MipEnergy(30000.0 * CLHEP::eV),
+      finalRangeforStep(0.15 * CLHEP::mm) {
+
+  static const G4MaterialTable *theMaterialTable = G4Material::GetMaterialTable();
+  ElossMaterialName = PMTAnodeMaterialName;
+  EkillMaterialName = PMTEnvelopeMaterialName;
+
+  G4int numberOfMat = (G4int)((*theMaterialTable).size());
+  G4cout << "Pmt Anode Eloss number of Mat " << numberOfMat << G4endl;
+  G4int iMat = 0;
+  fMatIndex = -1;
+
+  while (iMat < numberOfMat && fMatIndex < 0) {
+    if (ElossMaterialName == (*theMaterialTable)[iMat]->GetName()) {
+      fMatIndex = (*theMaterialTable)[iMat]->GetIndex();
+      G4cout << "PMT anode energy Loss construct Material " << ElossMaterialName << "   " << fMatIndex << G4endl;
     }
     iMat++;
-
   }
 
-  G4int iMatK=0;
-  fMatIndexK=-1;
-  while(iMatK<numberOfMat && fMatIndexK < 0  ) {
-    if ( EkillMaterialName == (*theMaterialTable)[iMatK]->GetName()){
-      fMatIndexK=(*theMaterialTable)[iMatK]->GetIndex();
-       G4cout<<"Pmt Anode Energy Loss: pmt envelope  Material "
-          <<EkillMaterialName
-            <<"   "<< fMatIndexK<<G4endl;
+  G4int iMatK = 0;
+  fMatIndexK = -1;
+  while (iMatK < numberOfMat && fMatIndexK < 0) {
+    if (EkillMaterialName == (*theMaterialTable)[iMatK]->GetName()) {
+      fMatIndexK = (*theMaterialTable)[iMatK]->GetIndex();
+      G4cout << "Pmt Anode Energy Loss: pmt envelope  Material " << EkillMaterialName << "   " << fMatIndexK << G4endl;
     }
     iMatK++;
-
   }
 
-  if(iMat > numberOfMat ||  iMatK >  numberOfMat ) {
-    G4cout << "Invalid material Name in PmtAnodeEnergyLoss constructor" <<G4endl ;
+  if (iMat > numberOfMat || iMatK > numberOfMat) {
+    G4cout << "Invalid material Name in PmtAnodeEnergyLoss constructor" << G4endl;
   }
-     G4cout<<GetProcessName() <<" is created "<<G4endl;
-
-
- }
-
+  G4cout << GetProcessName() << " is created " << G4endl;
+}
 
 PmtAnodeEnergyLoss::~PmtAnodeEnergyLoss() {}
 
-
-G4bool PmtAnodeEnergyLoss::IsApplicable(const G4ParticleDefinition&
-                                     aParticleType) {
-   return(aParticleType.GetPDGCharge()!= 0.);
+G4bool PmtAnodeEnergyLoss::IsApplicable(const G4ParticleDefinition &aParticleType) {
+  return (aParticleType.GetPDGCharge() != 0.);
 }
-G4VParticleChange* PmtAnodeEnergyLoss::AlongStepDoIt(const G4Track& aTrack,
-                                   const G4Step& aStep) {
-	//                                 const G4Step& ) {
+
+G4VParticleChange *PmtAnodeEnergyLoss::AlongStepDoIt(const G4Track &aTrack, const G4Step & /* aStep */) {
+  //                                 const G4Step& ) {
 
   aParticleChange.Initialize(aTrack);
   // G4int aMaterialIndex = aTrack.GetMaterial()->GetIndex();
-  if( ( fMatIndex != (int) aTrack.GetMaterial()->GetIndex() ) &&
-      (fMatIndexK != (int) aTrack.GetMaterial()->GetIndex()  ) ) {
+  if ((fMatIndex != (int)aTrack.GetMaterial()->GetIndex()) && (fMatIndexK != (int)aTrack.GetMaterial()->GetIndex())) {
     return &aParticleChange;
   }
-  RichTbRunConfig* rConfig = RichTbRunConfig::getRunConfigInstance();
+  RichTbRunConfig *rConfig = RichTbRunConfig::getRunConfigInstance();
 
-//  G4cout << "pmt anode energy loss   " << aTrack.GetMaterial()->GetName()<< G4endl;
-  const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
-   G4double aKinEnergyInitParticle=aParticle->GetKineticEnergy();
-   G4double aKinEnergyInit = aKinEnergyInitParticle;
-    G4String  aCreatorProcessName= "NullProcess";
-    const G4VProcess* aProcess = aTrack.GetCreatorProcess();
-    if(aProcess) aCreatorProcessName =  aProcess->GetProcessName();
-//    G4cout << "pmt anode energy loss particle creator process name "<<  aCreatorProcessName<<G4endl;
+  //  G4cout << "pmt anode energy loss   " << aTrack.GetMaterial()->GetName()<< G4endl;
+  const G4DynamicParticle *aParticle = aTrack.GetDynamicParticle();
+  G4double aKinEnergyInitParticle = aParticle->GetKineticEnergy();
+  G4double aKinEnergyInit = aKinEnergyInitParticle;
+  G4String aCreatorProcessName = "NullProcess";
+  const G4VProcess *aProcess = aTrack.GetCreatorProcess();
+  if (aProcess)
+    aCreatorProcessName = aProcess->GetProcessName();
+  //    G4cout << "pmt anode energy loss particle creator process name "<<  aCreatorProcessName<<G4endl;
 
-    if( aCreatorProcessName ==  PmtPhotElectProc) {
-      aKinEnergyInit = aKinEnergyInitParticle/100000;
+  if (aCreatorProcessName == PmtPhotElectProc) {
+    aKinEnergyInit = aKinEnergyInitParticle / 100000;
 
-      if( fMatIndexK ==   (G4int) aTrack.GetMaterial() -> GetIndex()){
+    if (fMatIndexK == (G4int)aTrack.GetMaterial()->GetIndex()) {
 
-       aParticleChange.ProposeTrackStatus(fStopAndKill);
-       aParticleChange.ProposeEnergy(0.0);
-       // aParticleChange.SetStatusChange(fStopAndKill);
+      aParticleChange.ProposeTrackStatus(fStopAndKill);
+      aParticleChange.ProposeEnergy(0.0);
+      // aParticleChange.SetStatusChange(fStopAndKill);
       return &aParticleChange;
-      }
-
     }
+  }
 
-    //begin test
-//	G4StepPoint* pPreStepPoint  = aStep.GetPreStepPoint();
-//	G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
-//
-//    G4TouchableHistory* CurTT =
-//    			(G4TouchableHistory*)(pPreStepPoint->GetTouchable());
-//
-//    	// CurTT -> MoveUpHistory(2);
-//    	G4int currentPmtNumber= CurTT -> GetReplicaNumber(2);
-//
-//    	G4cout<<"current Energy Loss PMT number "<<currentPmtNumber<<G4endl;
-    //end test
-
-
-    G4double Eloss, aKinEnergyFinal;
-   if(aKinEnergyInit < MinKineticEnergy ) {  Eloss=0.0 ; }
-    else if( aKinEnergyInit < MipEnergy ) { Eloss= aKinEnergyInit ;}
-    else { Eloss = MipEnergy; }
-
+  // begin test
+  //	G4StepPoint* pPreStepPoint  = aStep.GetPreStepPoint();
+  //	G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
+  //
+  //    G4TouchableHistory* CurTT =
+  //    			(G4TouchableHistory*)(pPreStepPoint->GetTouchable());
+  //
+  //    	// CurTT -> MoveUpHistory(2);
+  //    	G4int currentPmtNumber= CurTT -> GetReplicaNumber(2);
+  //
+  //    	G4cout<<"current Energy Loss PMT number "<<currentPmtNumber<<G4endl;
+  // end test
+
+  G4double Eloss, aKinEnergyFinal;
+  if (aKinEnergyInit < MinKineticEnergy) {
+    Eloss = 0.0;
+  } else if (aKinEnergyInit < MipEnergy) {
+    Eloss = aKinEnergyInit;
+  } else {
+    Eloss = MipEnergy;
+  }
 
-   //  G4cout<< "Eloss = "<<Eloss<<G4endl;
-  aKinEnergyFinal=aKinEnergyInit-Eloss;
+  //  G4cout<< "Eloss = "<<Eloss<<G4endl;
+  aKinEnergyFinal = aKinEnergyInit - Eloss;
 
   // Now apply the detection efficiency. When pixel efficiency is applied, this
   // detection efficiency is not applied.
 
   G4double EnergyTransfer = Eloss;
 
-  if( ! (rConfig -> ApplyPixelEff()) ) {
-     G4double Effrandom =  G4UniformRand();
-     if( Effrandom > ( rConfig -> getMapmtDetectionEfficiency() ) )
-     { EnergyTransfer =0.0; }
-     // G4cout<<" Overall eff "<<Effrandom<<"  "<< rConfig -> getMapmtDetectionEfficiency()
-     //      <<"   "<<EnergyTransfer<<G4endl;
-
-  }
-
-
-
-
-  if(EnergyTransfer > 0.0 )
-    {
-      //  G4cout<<"Now deposting energy in Pmt Anode Eloss=  " <<Eloss<<G4endl;
-
-      //aParticleChange.SetLocalEnergyDeposit(Eloss);
-      aParticleChange.ProposeLocalEnergyDeposit(EnergyTransfer  );
-    }else if ( aKinEnergyInit >  MipEnergy )  {
-     aParticleChange.ProposeLocalEnergyDeposit(Eloss);
-    }
-
-
-  if (aKinEnergyFinal <= MinKineticEnergy )
-    {
-      //   aParticleChange.SetStatusChange(fStopAndKill);
-      aParticleChange.ProposeTrackStatus(fStopAndKill);
-      aParticleChange.ProposeEnergy(0.0);
-
-    }
-  else
-    {
-      aParticleChange.ProposeEnergy(aKinEnergyFinal);
-      //    aParticleChange.SetEnergyChange(aKinEnergyFinal);
+  if (!(rConfig->ApplyPixelEff())) {
+    G4double Effrandom = G4UniformRand();
+    if (Effrandom > (rConfig->getMapmtDetectionEfficiency())) {
+      EnergyTransfer = 0.0;
     }
+    // G4cout<<" Overall eff "<<Effrandom<<"  "<< rConfig -> getMapmtDetectionEfficiency()
+    //      <<"   "<<EnergyTransfer<<G4endl;
+  }
 
+  if (EnergyTransfer > 0.0) {
+    //  G4cout<<"Now deposting energy in Pmt Anode Eloss=  " <<Eloss<<G4endl;
 
+    // aParticleChange.SetLocalEnergyDeposit(Eloss);
+    aParticleChange.ProposeLocalEnergyDeposit(EnergyTransfer);
+  } else if (aKinEnergyInit > MipEnergy) {
+    aParticleChange.ProposeLocalEnergyDeposit(Eloss);
+  }
 
- return &aParticleChange;
+  if (aKinEnergyFinal <= MinKineticEnergy) {
+    //   aParticleChange.SetStatusChange(fStopAndKill);
+    aParticleChange.ProposeTrackStatus(fStopAndKill);
+    aParticleChange.ProposeEnergy(0.0);
 
+  } else {
+    aParticleChange.ProposeEnergy(aKinEnergyFinal);
+    //    aParticleChange.SetEnergyChange(aKinEnergyFinal);
+  }
 
+  return &aParticleChange;
 }
 
-G4VParticleChange*  PmtAnodeEnergyLoss::PostStepDoIt(const G4Track& aTrack,
-                                 const G4Step& aStep) {
+G4VParticleChange *PmtAnodeEnergyLoss::PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) {
   // Do nothing
-   aParticleChange.Initialize(aTrack) ;
-  return G4VContinuousDiscreteProcess::PostStepDoIt(aTrack,aStep);
-
+  aParticleChange.Initialize(aTrack);
+  return G4VContinuousDiscreteProcess::PostStepDoIt(aTrack, aStep);
 }
 
-G4double  PmtAnodeEnergyLoss::GetMeanFreePath(const G4Track& /*atrack */ ,
-                         G4double /* previousStepSize */,
-                         G4ForceCondition* condition) {
+G4double PmtAnodeEnergyLoss::GetMeanFreePath(const G4Track & /*atrack */, G4double /* previousStepSize */,
+                                             G4ForceCondition *condition) {
   // return infinity so that it does nothing.
   *condition = NotForced;
   return DBL_MAX;
-
 }
-G4double PmtAnodeEnergyLoss::GetContinuousStepLimit(const G4Track& track,
-                                                     G4double /* previousStepSize */,
-                                                     G4double /* currentMinimumStep */,
-                                                     G4double& /* currentSafety */ ){
+G4double PmtAnodeEnergyLoss::GetContinuousStepLimit(const G4Track &track, G4double /* previousStepSize */,
+                                                    G4double /* currentMinimumStep */, G4double & /* currentSafety */) {
 
-  G4double  RangeForStep =  finalRangeforStep;
+  G4double RangeForStep = finalRangeforStep;
 
-  if( ( fMatIndex != (int) track.GetMaterial() -> GetIndex()) &&
-      ( fMatIndexK != (int) track.GetMaterial() -> GetIndex()) ) {
+  if ((fMatIndex != (int)track.GetMaterial()->GetIndex()) && (fMatIndexK != (int)track.GetMaterial()->GetIndex())) {
     RangeForStep = DBL_MAX;
   }
 
-
   return RangeForStep;
-
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcph/PmtPhotoElectricEffect.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcph/PmtPhotoElectricEffect.cc
index dbe9266e78eac1e1ace0014873db83cead47d106..4629d6e9d4db20b7070473d73360b62bbab010a8 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcph/PmtPhotoElectricEffect.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcph/PmtPhotoElectricEffect.cc
@@ -1,232 +1,196 @@
-#include "Geant4/globals.hh"
-#include <math.h>
-#include <vector>
 #include "PmtPhotoElectricEffect.hh"
-#include "RichTbGeometryParameters.hh"
+#include "Geant4/G4TouchableHistory.hh"
 #include "Geant4/G4TransportationManager.hh"
 #include "Geant4/Randomize.hh"
+#include "Geant4/globals.hh"
 #include "RichTbAnalysisManager.hh"
-#include "RichTbRunConfig.hh"
+#include "RichTbGeometryParameters.hh"
 #include "RichTbMaterialParameters.hh"
-#include "Geant4/G4TouchableHistory.hh"
-#include "RichTbPhotoElectron.hh"
-#include "RichTbPeUserInfoAttach.hh"
 #include "RichTbMiscNames.hh"
+#include "RichTbPeUserInfoAttach.hh"
+#include "RichTbPhotoElectron.hh"
+#include "RichTbRunConfig.hh"
+#include <math.h>
+#include <vector>
 
-
-PmtPhotoElectricEffect::PmtPhotoElectricEffect(const G4String& processName):
-G4VDiscreteProcess(processName),
-NumPmtTot(NumPmts),
-//NumPmtTot(RichTbPMTGeometryParameters::getNumPmts()), // TESTNumPmts
-NumQEbins(PmtQENumBins),
-PmtQE( NumPmts, std::vector<G4double>( NumQEbins) ),
-PmtWabin( NumPmts, std::vector<G4double>( NumQEbins) )
-//PmtQE( RichTbPMTGeometryParameters::getNumPmts(), std::vector<G4double>( NumQEbins) ), // TESTNumPmts
-//PmtWabin( RichTbPMTGeometryParameters::getNumPmts(), std::vector<G4double>( NumQEbins) ) // TESTNumPmts
+PmtPhotoElectricEffect::PmtPhotoElectricEffect(const G4String &processName)
+    : G4VDiscreteProcess(processName), NumPmtTot(NumPmts),
+      // NumPmtTot(RichTbPMTGeometryParameters::getNumPmts()), // TESTNumPmts
+      NumQEbins(PmtQENumBins), PmtQE(NumPmts, std::vector<G4double>(NumQEbins)),
+      PmtWabin(NumPmts, std::vector<G4double>(NumQEbins))
+// PmtQE( RichTbPMTGeometryParameters::getNumPmts(), std::vector<G4double>( NumQEbins) ), // TESTNumPmts
+// PmtWabin( RichTbPMTGeometryParameters::getNumPmts(), std::vector<G4double>( NumQEbins) ) // TESTNumPmts
 {
-	RichTbRunConfig* rConfig = RichTbRunConfig::getRunConfigInstance();
-	G4int aRadiatorConfiguration = rConfig->getRadiatorConfiguration();
-
-//	if(aRadiatorConfiguration == 3) {
-//		NumPmtTot = NumPmtsUpgrade15;
-////		PmtQE.reserve(NumPmtTot);
-////		PmtWabin.reserve(NumPmtTot);
-//	} else NumPmtTot = NumPmts;
+  RichTbRunConfig *rConfig = RichTbRunConfig::getRunConfigInstance();
+  // G4int aRadiatorConfiguration = rConfig->getRadiatorConfiguration();
 
+  //	if(aRadiatorConfiguration == 3) {
+  //		NumPmtTot = NumPmtsUpgrade15;
+  ////		PmtQE.reserve(NumPmtTot);
+  ////		PmtWabin.reserve(NumPmtTot);
+  //	} else NumPmtTot = NumPmts;
 
-	PrePhotoElectricVolName = PMTQwLogVolName;
-	PostPhotoElectricVolName = PMTPhCathLogVolName;
-	//PmtPhElectronMomentum = 2 * CLHEP::GeV;
-	PmtPhElectronMomentum = ( rConfig->getPMTPEMomInit() ) * CLHEP::keV;
-	PhCathodeToSilDetDist = PMTQuartzToAnodeSurfaceDistance;
+  PrePhotoElectricVolName = PMTQwLogVolName;
+  PostPhotoElectricVolName = PMTPhCathLogVolName;
+  // PmtPhElectronMomentum = 2 * CLHEP::GeV;
+  PmtPhElectronMomentum = (rConfig->getPMTPEMomInit()) * CLHEP::keV;
+  PhCathodeToSilDetDist = PMTQuartzToAnodeSurfaceDistance;
 
-	for (int ipmt=0; ipmt < NumPmtTot; ++ipmt ) {
+  for (int ipmt = 0; ipmt < NumPmtTot; ++ipmt) {
 
-		std::vector<G4double>qeCurPmt =  InitializePMTQE(ipmt);
-		std::vector<G4double>waCurPmt =  InitializePMTWaveL(ipmt);
-		for(G4int iqbin=0;  iqbin < (int) qeCurPmt.size(); iqbin++)
-		{
+    std::vector<G4double> qeCurPmt = InitializePMTQE(ipmt);
+    std::vector<G4double> waCurPmt = InitializePMTWaveL(ipmt);
+    for (G4int iqbin = 0; iqbin < (int)qeCurPmt.size(); iqbin++) {
 
-			PmtQE[ipmt][iqbin]=qeCurPmt[iqbin]/100;
-			PmtWabin[ipmt][iqbin]=waCurPmt[iqbin];
-		}
-
-	}
-
-	G4cout<<"PMT Photoelectic process created "<<G4endl;
+      PmtQE[ipmt][iqbin] = qeCurPmt[iqbin] / 100;
+      PmtWabin[ipmt][iqbin] = waCurPmt[iqbin];
+    }
+  }
 
+  G4cout << "PMT Photoelectic process created " << G4endl;
 }
 
-PmtPhotoElectricEffect::~PmtPhotoElectricEffect(){}
-
+PmtPhotoElectricEffect::~PmtPhotoElectricEffect() {}
 
-G4bool PmtPhotoElectricEffect::IsApplicable(const G4ParticleDefinition& aParticleType)
-{
-	return ( &aParticleType == G4OpticalPhoton::OpticalPhoton() );
+G4bool PmtPhotoElectricEffect::IsApplicable(const G4ParticleDefinition &aParticleType) {
+  return (&aParticleType == G4OpticalPhoton::OpticalPhoton());
 }
 
-G4double PmtPhotoElectricEffect::GetMeanFreePath(const G4Track& ,
-		G4double ,
-		G4ForceCondition* condition)
-{
-	*condition = Forced;
+G4double PmtPhotoElectricEffect::GetMeanFreePath(const G4Track &, G4double, G4ForceCondition *condition) {
+  *condition = Forced;
 
-	return DBL_MAX;
+  return DBL_MAX;
 }
 
-G4VParticleChange* PmtPhotoElectricEffect::PostStepDoIt(const G4Track& aTrack,const G4Step& aStep) {
-	aParticleChange.Initialize(aTrack);
-
-	G4StepPoint* pPreStepPoint  = aStep.GetPreStepPoint();
-	G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
-
-	if (pPostStepPoint->GetStepStatus() != fGeomBoundary)
-		return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-
-	G4String PrePhName = pPreStepPoint -> GetPhysicalVolume() ->
-			GetLogicalVolume() ->GetName();
-	G4String PostPhName= pPostStepPoint -> GetPhysicalVolume() ->
-			GetLogicalVolume() ->GetName();
-
-	//    G4cout<<"PMTPhElec effect PreVol Post Vol "<<PrePhName
-			//           <<"   "<<PostPhName<<G4endl;
-
-
-	if(( PrePhName == PrePhotoElectricVolName &&
-			PostPhName == PostPhotoElectricVolName) ||
-			( PostPhName == PrePhotoElectricVolName &&
-					PrePhName == PostPhotoElectricVolName) )
-	{
-		//   G4cout<<"PMTPhElec effect PreVol Post Vol "<<PrePhName
-		//      <<"   "<<PostPhName<<G4endl;
-
-
-	}  else  {
-		return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-	}
-
-	//  if (aTrack.GetStepLength()<=kCarTolerance/2)
-	// return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-
-	const G4DynamicParticle* aDynamicPhoton = aTrack.GetDynamicParticle();
-	G4double PhotonEnergy = aDynamicPhoton->GetKineticEnergy();
-	if(PhotonEnergy <= 0.0 )
-	{
-		return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-	}
-	G4TouchableHistory* CurTT =
-			(G4TouchableHistory*)(pPreStepPoint->GetTouchable());
-
-	// CurTT -> MoveUpHistory(2);
-	G4int currentPmtNumber= CurTT -> GetReplicaNumber(2);
-
-	if(currentPmtNumber >= NumPmtTot ||currentPmtNumber < 0   )
-		return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
-	G4double PhotWLength=PhotMomToWaveLength/PhotonEnergy;
-	// G4double PhotWLengthNano =   PhotWLength/(CLHEP::nanometer);
-	// G4cout<<"PhotElect pmtnum PhEn Wlen  "<<currentPmtNumber
-	//      <<"    "<<PhotonEnergy<<"   "
-	//      << PhotWLength<<G4endl;
-	G4double PhCathodeQE = getPmtQEff(currentPmtNumber, PhotWLength);
-	// G4cout<<"PhotElect pmtnum PhEn Wlen QE "<<currentPmtNumber
-	//      <<"    "<<PhotonEnergy<<"   "
-	//       << PhotWLength<< "  "<< PhCathodeQE<< G4endl;
-
-
-	G4double randomnum = G4UniformRand();
-	if(randomnum <  PhCathodeQE ) {
-		// create photoelectron
-		G4double aPhotonTime= aTrack.GetGlobalTime();
-		G4ThreeVector GlobalElectronOrigin= pPostStepPoint->GetPosition();
-		G4Navigator* theNavigator =
-				G4TransportationManager::GetTransportationManager()->
-				GetNavigatorForTracking();
-		G4ThreeVector LocalElectronOriginInit = theNavigator->
-				GetGlobalToLocalTransform().
-				TransformPoint(GlobalElectronOrigin);
-		G4double ElecOriginTolerence= 0.004*CLHEP::mm;
-		G4ThreeVector LocalElectronOrigin (LocalElectronOriginInit.x(),
-				LocalElectronOriginInit.y(),
-				LocalElectronOriginInit.z()- ElecOriginTolerence );
-		G4ThreeVector LocalElectronDirection(0,0,+1);
-		LocalElectronDirection = LocalElectronDirection.unit();
-		const G4ThreeVector GlobalElectronDirection = theNavigator->
-				GetLocalToGlobalTransform().
-				TransformAxis(LocalElectronDirection);
-		G4double ElecKineEnergy= 100000*PmtPhElectronMomentum;
-
-		G4TouchableHistory* CurTTP = (G4TouchableHistory*) (pPreStepPoint->GetTouchable());
-		CurTTP -> MoveUpHistory(2);
-		G4int   CurTTPDepth=  CurTTP->GetHistoryDepth();
-		G4ThreeVector ElnOrgInPhDet =  CurTTP->GetHistory()->GetTransform(CurTTPDepth).TransformPoint(GlobalElectronOrigin);
-
-
-		G4DynamicParticle* aElectron=
-				new G4DynamicParticle (RichTbPhotoElectron::PhotoElectron(),
-						GlobalElectronDirection, ElecKineEnergy) ;
-		aParticleChange.SetNumberOfSecondaries(1) ;
-		G4Track* aSecPETrack =
-				new G4Track(aElectron,aPhotonTime,GlobalElectronOrigin);
-		// G4cout<<" PMTPh electric: created photoelectron "<<G4endl;
-		aSecPETrack->SetTouchableHandle((G4VTouchable*)0);
-		aSecPETrack->SetParentID(aTrack.GetTrackID());
-		aSecPETrack->SetGoodForTrackingFlag(true);
-		G4Track* aTaggedSecPETrack = RichTbPeInfoAttach(aTrack,aSecPETrack,  ElnOrgInPhDet);
-		aParticleChange.AddSecondary(aTaggedSecPETrack);
-
-		//  G4cout<<" added a sec tagged track in photoelectric "<<G4endl;
-
-
-		//aParticleChange.AddSecondary(aTaggedSecPETrack);
-		//aParticleChange.AddSecondary(aSecPETrack);
-
-		aParticleChange.ProposeTrackStatus(fStopAndKill);
-		aParticleChange.ProposeLocalEnergyDeposit(PhotonEnergy);
-
-
-	}else {
-		//photon is not killed if it is not converted to photoelectron
-
-	}
-	return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+G4VParticleChange *PmtPhotoElectricEffect::PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) {
+  aParticleChange.Initialize(aTrack);
+
+  G4StepPoint *pPreStepPoint = aStep.GetPreStepPoint();
+  G4StepPoint *pPostStepPoint = aStep.GetPostStepPoint();
+
+  if (pPostStepPoint->GetStepStatus() != fGeomBoundary)
+    return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+
+  G4String PrePhName = pPreStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetName();
+  G4String PostPhName = pPostStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetName();
+
+  //    G4cout<<"PMTPhElec effect PreVol Post Vol "<<PrePhName
+  //           <<"   "<<PostPhName<<G4endl;
+
+  if ((PrePhName == PrePhotoElectricVolName && PostPhName == PostPhotoElectricVolName) ||
+      (PostPhName == PrePhotoElectricVolName && PrePhName == PostPhotoElectricVolName)) {
+    //   G4cout<<"PMTPhElec effect PreVol Post Vol "<<PrePhName
+    //      <<"   "<<PostPhName<<G4endl;
+
+  } else {
+    return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+  }
+
+  //  if (aTrack.GetStepLength()<=kCarTolerance/2)
+  // return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+
+  const G4DynamicParticle *aDynamicPhoton = aTrack.GetDynamicParticle();
+  G4double PhotonEnergy = aDynamicPhoton->GetKineticEnergy();
+  if (PhotonEnergy <= 0.0) {
+    return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+  }
+  G4TouchableHistory *CurTT = (G4TouchableHistory *)(pPreStepPoint->GetTouchable());
+
+  // CurTT -> MoveUpHistory(2);
+  G4int currentPmtNumber = CurTT->GetReplicaNumber(2);
+
+  if (currentPmtNumber >= NumPmtTot || currentPmtNumber < 0)
+    return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+  G4double PhotWLength = PhotMomToWaveLength / PhotonEnergy;
+  // G4double PhotWLengthNano =   PhotWLength/(CLHEP::nanometer);
+  // G4cout<<"PhotElect pmtnum PhEn Wlen  "<<currentPmtNumber
+  //      <<"    "<<PhotonEnergy<<"   "
+  //      << PhotWLength<<G4endl;
+  G4double PhCathodeQE = getPmtQEff(currentPmtNumber, PhotWLength);
+  // G4cout<<"PhotElect pmtnum PhEn Wlen QE "<<currentPmtNumber
+  //      <<"    "<<PhotonEnergy<<"   "
+  //       << PhotWLength<< "  "<< PhCathodeQE<< G4endl;
+
+  G4double randomnum = G4UniformRand();
+  if (randomnum < PhCathodeQE) {
+    // create photoelectron
+    G4double aPhotonTime = aTrack.GetGlobalTime();
+    G4ThreeVector GlobalElectronOrigin = pPostStepPoint->GetPosition();
+    G4Navigator *theNavigator = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
+    G4ThreeVector LocalElectronOriginInit =
+        theNavigator->GetGlobalToLocalTransform().TransformPoint(GlobalElectronOrigin);
+    G4double ElecOriginTolerence = 0.004 * CLHEP::mm;
+    G4ThreeVector LocalElectronOrigin(LocalElectronOriginInit.x(), LocalElectronOriginInit.y(),
+                                      LocalElectronOriginInit.z() - ElecOriginTolerence);
+    G4ThreeVector LocalElectronDirection(0, 0, +1);
+    LocalElectronDirection = LocalElectronDirection.unit();
+    const G4ThreeVector GlobalElectronDirection =
+        theNavigator->GetLocalToGlobalTransform().TransformAxis(LocalElectronDirection);
+    G4double ElecKineEnergy = 100000 * PmtPhElectronMomentum;
+
+    G4TouchableHistory *CurTTP = (G4TouchableHistory *)(pPreStepPoint->GetTouchable());
+    CurTTP->MoveUpHistory(2);
+    G4int CurTTPDepth = CurTTP->GetHistoryDepth();
+    G4ThreeVector ElnOrgInPhDet = CurTTP->GetHistory()->GetTransform(CurTTPDepth).TransformPoint(GlobalElectronOrigin);
+
+    G4DynamicParticle *aElectron =
+        new G4DynamicParticle(RichTbPhotoElectron::PhotoElectron(), GlobalElectronDirection, ElecKineEnergy);
+    aParticleChange.SetNumberOfSecondaries(1);
+    G4Track *aSecPETrack = new G4Track(aElectron, aPhotonTime, GlobalElectronOrigin);
+    // G4cout<<" PMTPh electric: created photoelectron "<<G4endl;
+    aSecPETrack->SetTouchableHandle((G4VTouchable *)0);
+    aSecPETrack->SetParentID(aTrack.GetTrackID());
+    aSecPETrack->SetGoodForTrackingFlag(true);
+    G4Track *aTaggedSecPETrack = RichTbPeInfoAttach(aTrack, aSecPETrack, ElnOrgInPhDet);
+    aParticleChange.AddSecondary(aTaggedSecPETrack);
+
+    //  G4cout<<" added a sec tagged track in photoelectric "<<G4endl;
+
+    // aParticleChange.AddSecondary(aTaggedSecPETrack);
+    // aParticleChange.AddSecondary(aSecPETrack);
+
+    aParticleChange.ProposeTrackStatus(fStopAndKill);
+    aParticleChange.ProposeLocalEnergyDeposit(PhotonEnergy);
+
+  } else {
+    // photon is not killed if it is not converted to photoelectron
+  }
+  return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
 }
-G4double PmtPhotoElectricEffect::getPmtQEff(G4int PmtNum,
-		G4double PhotonWLength){
-
-	G4double hq1=0.0;    G4double hq2=0.0;
-	G4double wa1=0.0; G4double wa2=0.0; G4double aslope=0.0;
-	// G4double aintc=0.0;
-	//  G4cout<<"Now in Hpd QE Finder hpdnum PhWlen   "
-	//      <<HpdNum<<"    "<<PhotonWLength<<G4endl;
-	G4double qeff=0.0;
-
-	if( PhotonWLength ==  PmtWabin[PmtNum][ PmtQENumBins-1] ) {
-		qeff =  PmtQE[PmtNum] [PmtQENumBins-1] ;
-	}else if (  PhotonWLength ==  PmtWabin[PmtNum][ 0] ) {
-		qeff = PmtQE[PmtNum] [0];
-	} else if( ( PhotonWLength >= PmtWabin[PmtNum][0]) &&
-			( PhotonWLength < PmtWabin[PmtNum][PmtQENumBins-1]) ) {
-		G4int ibinq=0;
-		G4bool BinFound=false;
-		while (ibinq< (NumQEbins-1)  && (! (BinFound))  ){
-			wa1 = PmtWabin[PmtNum][ibinq];
-			wa2 = PmtWabin[PmtNum][ibinq+1];
-			if( PhotonWLength >= wa1 && PhotonWLength < wa2 ) {
-				hq1 =   PmtQE[PmtNum][ibinq];
-				hq2 =   PmtQE[PmtNum][ibinq+1];
-				aslope = (hq2-hq1)/(wa2-wa1);
-				// aintc =  hq1 - (aslope * wa1 );
-				//   qeff= aintc + aslope * PhotonWLength ;
-				qeff= hq1 + aslope * (PhotonWLength-wa1) ;
-				BinFound=true;
-
-			}
-			ibinq++;
-		}
-
-	}
-
-
-	return qeff;
-
+G4double PmtPhotoElectricEffect::getPmtQEff(G4int PmtNum, G4double PhotonWLength) {
+
+  G4double hq1 = 0.0;
+  G4double hq2 = 0.0;
+  G4double wa1 = 0.0;
+  G4double wa2 = 0.0;
+  G4double aslope = 0.0;
+  // G4double aintc=0.0;
+  //  G4cout<<"Now in Hpd QE Finder hpdnum PhWlen   "
+  //      <<HpdNum<<"    "<<PhotonWLength<<G4endl;
+  G4double qeff = 0.0;
+
+  if (PhotonWLength == PmtWabin[PmtNum][PmtQENumBins - 1]) {
+    qeff = PmtQE[PmtNum][PmtQENumBins - 1];
+  } else if (PhotonWLength == PmtWabin[PmtNum][0]) {
+    qeff = PmtQE[PmtNum][0];
+  } else if ((PhotonWLength >= PmtWabin[PmtNum][0]) && (PhotonWLength < PmtWabin[PmtNum][PmtQENumBins - 1])) {
+    G4int ibinq = 0;
+    G4bool BinFound = false;
+    while (ibinq < (NumQEbins - 1) && (!(BinFound))) {
+      wa1 = PmtWabin[PmtNum][ibinq];
+      wa2 = PmtWabin[PmtNum][ibinq + 1];
+      if (PhotonWLength >= wa1 && PhotonWLength < wa2) {
+        hq1 = PmtQE[PmtNum][ibinq];
+        hq2 = PmtQE[PmtNum][ibinq + 1];
+        aslope = (hq2 - hq1) / (wa2 - wa1);
+        // aintc =  hq1 - (aslope * wa1 );
+        //   qeff= aintc + aslope * PhotonWLength ;
+        qeff = hq1 + aslope * (PhotonWLength - wa1);
+        BinFound = true;
+      }
+      ibinq++;
+    }
+  }
+
+  return qeff;
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcph/RichTbPhotoElectron.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcph/RichTbPhotoElectron.cc
index 3f7f625a82db42362757bfb5987a72ebddf57ec9..93d4ba12a82f5cb2323128260d7d1178a7d7ef7a 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcph/RichTbPhotoElectron.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcph/RichTbPhotoElectron.cc
@@ -23,8 +23,8 @@
 //
 // $Id: RichTbPhotoElectron.cpp,v 1.3 2003/08/05 11:50:18 witoldp Exp $
 // GEANT4 tag $Name:  $
-// 
-// 
+//
+//
 // ----------------------------------------------------------------------
 //      GEANT 4 class implementation file
 //
@@ -41,81 +41,57 @@
 //
 //#include "Geant4/G4std/fstream"
 //#include "Geant4/G4std/iomanip"
-    
+
 //#include "Geant4/G4Electron.hh"
 
-#include "Geant4/G4ParticleTable.hh"
 #include "RichTbPhotoElectron.hh"
+#include "Geant4/G4ParticleTable.hh"
 // ######################################################################
 // ###                         RICHTBPHOTOELECTRON                      ###
 // ######################################################################
 
+RichTbPhotoElectron *RichTbPhotoElectron::theRichTbPhotoElectronInstance = 0;
 
-RichTbPhotoElectron* RichTbPhotoElectron::theRichTbPhotoElectronInstance=0;
-
-RichTbPhotoElectron* RichTbPhotoElectron::Definition() 
-{
-  if (theRichTbPhotoElectronInstance !=0) return theRichTbPhotoElectronInstance;
+RichTbPhotoElectron *RichTbPhotoElectron::Definition() {
+  if (theRichTbPhotoElectronInstance != 0)
+    return theRichTbPhotoElectronInstance;
   const G4String name = "pe-";
   // search in particle table]
-  G4ParticleTable* pTable = G4ParticleTable::GetParticleTable();
-  G4ParticleDefinition* anInstance = pTable->FindParticle(name);
-  if (anInstance ==0)
-  {
-  // create particle
-  //
-  //    Arguments for constructor are as follows
-  //               name             mass          width         charge
-  //             2*spin           parity  C-conjugation
-  //          2*Isospin       2*Isospin3       G-parity
-  //               type    lepton number  baryon number   PDG encoding
-  //             stable         lifetime    decay table
-  //             shortlived      subType    anti_encoding
-   anInstance = new G4ParticleDefinition(
-                 name,  0.51099906*CLHEP::MeV,       0.0*CLHEP::MeV,    -1.*CLHEP::eplus,
-                    1,               0,             0,
-                    0,               0,             0,
-             "lepton",               1,             0,          9000011,
-                 true,            -1.0,          NULL,
-             false,           "e"
-              );
+  G4ParticleTable *pTable = G4ParticleTable::GetParticleTable();
+  G4ParticleDefinition *anInstance = pTable->FindParticle(name);
+  if (anInstance == 0) {
+    // create particle
+    //
+    //    Arguments for constructor are as follows
+    //               name             mass          width         charge
+    //             2*spin           parity  C-conjugation
+    //          2*Isospin       2*Isospin3       G-parity
+    //               type    lepton number  baryon number   PDG encoding
+    //             stable         lifetime    decay table
+    //             shortlived      subType    anti_encoding
+    anInstance = new G4ParticleDefinition(name, 0.51099906 * CLHEP::MeV, 0.0 * CLHEP::MeV, -1. * CLHEP::eplus, 1, 0, 0,
+                                          0, 0, 0, "lepton", 1, 0, 9000011, true, -1.0, NULL, false, "e");
 
     // Bohr Magnetron
-   //   G4double muB =  -0.5*CLHEP::eplus*hbar_Planck/(0.51099906*CLHEP::MeV/c_squared) ;
-   //
-   // anInstance->SetPDGMagneticMoment( muB * 1.0011596521859 );
-
-
+    //   G4double muB =  -0.5*CLHEP::eplus*hbar_Planck/(0.51099906*CLHEP::MeV/c_squared) ;
+    //
+    // anInstance->SetPDGMagneticMoment( muB * 1.0011596521859 );
   }
-  theRichTbPhotoElectronInstance = reinterpret_cast<RichTbPhotoElectron*>(anInstance);
+  theRichTbPhotoElectronInstance = reinterpret_cast<RichTbPhotoElectron *>(anInstance);
   return theRichTbPhotoElectronInstance;
 }
 
-
-
-
 // ......................................................................
 // ...                 static member definitions                      ...
 // ......................................................................
-//     
+//
 //    Arguments for constructor are as follows
 //               name             mass          width         charge
 //             2*spin           parity  C-conjugation
 //          2*Isospin       2*Isospin3       G-parity
 //               type    lepton number  baryon number   PDG encoding
-//             stable         lifetime    decay table 
-
-
-RichTbPhotoElectron* RichTbPhotoElectron::PhotoElectronDefinition()
-{return Definition(); }
-
-RichTbPhotoElectron* RichTbPhotoElectron::PhotoElectron()
-{  
-   return Definition();
-}
- 
-
-
-
+//             stable         lifetime    decay table
 
+RichTbPhotoElectron *RichTbPhotoElectron::PhotoElectronDefinition() { return Definition(); }
 
+RichTbPhotoElectron *RichTbPhotoElectron::PhotoElectron() { return Definition(); }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcph/RichTbPhysicsList.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcph/RichTbPhysicsList.cc
index 5f8567199112285492d80ab0109d77697b0b059e..4595a0c1d420d2b9ad0c4be0d6fb786a984f1b48 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcph/RichTbPhysicsList.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcph/RichTbPhysicsList.cc
@@ -1,381 +1,321 @@
 #include "Geant4/G4ios.hh"
 
 #include "Geant4/globals.hh"
-#include "RichTbPhysicsList.hh"
 #include "RichTbPhotoElectron.hh"
+#include "RichTbPhysicsList.hh"
 
+#include "Geant4/G4Material.hh"
+#include "Geant4/G4MaterialTable.hh"
 #include "Geant4/G4ParticleDefinition.hh"
+#include "Geant4/G4ParticleTable.hh"
 #include "Geant4/G4ParticleTypes.hh"
 #include "Geant4/G4ParticleWithCuts.hh"
-#include "Geant4/G4ParticleTable.hh"
-#include "Geant4/G4VUserPhysicsList.hh"
-#include "Geant4/G4ParticleTable.hh"
-#include "Geant4/G4UserPhysicsListMessenger.hh"
 #include "Geant4/G4UImanager.hh"
-#include "Geant4/G4Material.hh"
-#include "Geant4/G4MaterialTable.hh"
+#include "Geant4/G4UserPhysicsListMessenger.hh"
+#include "Geant4/G4VUserPhysicsList.hh"
 
 #include "Geant4/G4ProcessManager.hh"
 #include "Geant4/G4ProcessVector.hh"
 #include "Geant4/G4UnitsTable.hh"
 
-RichTbPhysicsList::RichTbPhysicsList():G4VUserPhysicsList()
-{
-
-    G4cout << " Now define the physics List" << std::endl;
-
-    // default cut value  (1.0CLHEP::mm)
-    //     defaultCutValue = 1.0*CLHEP::mm;
-    defaultCutValue = 0.1 * CLHEP::mm;
-    // defaultCutValue = 10.0*CLHEP::mm;
+RichTbPhysicsList::RichTbPhysicsList() : G4VUserPhysicsList() {
 
-    // set energy range for SetCut calculation
-    // G4ParticleWithCuts::SetEnergyRange(0.99*CLHEP::keV, 100*TeV);
+  G4cout << " Now define the physics List" << std::endl;
 
-    // pointer to the particle table
-    theParticleTable = G4ParticleTable::GetParticleTable();
-    theParticleIterator = theParticleTable->GetIterator();
+  // default cut value  (1.0CLHEP::mm)
+  //     defaultCutValue = 1.0*CLHEP::mm;
+  defaultCutValue = 0.1 * CLHEP::mm;
+  // defaultCutValue = 10.0*CLHEP::mm;
 
-    // UI Messenger
-    //  theMessenger = new G4UserPhysicsListMessenger(this);
+  // set energy range for SetCut calculation
+  // G4ParticleWithCuts::SetEnergyRange(0.99*CLHEP::keV, 100*TeV);
 
-    //  G4cout << " End of RichTbPhyslist constructor" <<  std::endl;
-
-}
+  // pointer to the particle table
+  theParticleTable = G4ParticleTable::GetParticleTable();
+  theParticleIterator = theParticleTable->GetIterator();
 
+  // UI Messenger
+  //  theMessenger = new G4UserPhysicsListMessenger(this);
 
-RichTbPhysicsList::~RichTbPhysicsList()
-{
+  //  G4cout << " End of RichTbPhyslist constructor" <<  std::endl;
 }
 
+RichTbPhysicsList::~RichTbPhysicsList() {}
 
-void RichTbPhysicsList::ConstructParticle()
-{
-    // In this method, static member functions should be called
-    // for all particles which you want to use.
-    // This ensures that objects of these particle types will be
-    // created in the program.
-
-    ConstructBosons();
-    ConstructLeptons();
-    ConstructMesons();
-    ConstructBaryons();
-
+void RichTbPhysicsList::ConstructParticle() {
+  // In this method, static member functions should be called
+  // for all particles which you want to use.
+  // This ensures that objects of these particle types will be
+  // created in the program.
 
+  ConstructBosons();
+  ConstructLeptons();
+  ConstructMesons();
+  ConstructBaryons();
 }
 
+void RichTbPhysicsList::ConstructBosons() {
+  // pseudo-particles
+  G4Geantino::GeantinoDefinition();
+  G4ChargedGeantino::ChargedGeantinoDefinition();
 
-void RichTbPhysicsList::ConstructBosons()
-{
-    // pseudo-particles
-    G4Geantino::GeantinoDefinition();
-    G4ChargedGeantino::ChargedGeantinoDefinition();
-
-    // gamma
-    G4Gamma::GammaDefinition();
+  // gamma
+  G4Gamma::GammaDefinition();
 
-    // optical photon
-    G4OpticalPhoton::OpticalPhotonDefinition();
+  // optical photon
+  G4OpticalPhoton::OpticalPhotonDefinition();
 }
 
-
-void RichTbPhysicsList::ConstructLeptons()
-{
-    // leptons
-    G4Electron::ElectronDefinition();
-    G4Positron::PositronDefinition();
-    G4NeutrinoE::NeutrinoEDefinition();
-    G4AntiNeutrinoE::AntiNeutrinoEDefinition();
-    G4MuonPlus::MuonPlusDefinition();
-    G4MuonMinus::MuonMinusDefinition();
-    G4NeutrinoMu::NeutrinoMuDefinition();
-    G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
-
-    RichTbPhotoElectron::PhotoElectronDefinition();
-
+void RichTbPhysicsList::ConstructLeptons() {
+  // leptons
+  G4Electron::ElectronDefinition();
+  G4Positron::PositronDefinition();
+  G4NeutrinoE::NeutrinoEDefinition();
+  G4AntiNeutrinoE::AntiNeutrinoEDefinition();
+  G4MuonPlus::MuonPlusDefinition();
+  G4MuonMinus::MuonMinusDefinition();
+  G4NeutrinoMu::NeutrinoMuDefinition();
+  G4AntiNeutrinoMu::AntiNeutrinoMuDefinition();
+
+  RichTbPhotoElectron::PhotoElectronDefinition();
 }
 
-
-void RichTbPhysicsList::ConstructMesons()
-{
-    //  mesons
-    G4PionPlus::PionPlusDefinition();
-    G4PionMinus::PionMinusDefinition();
-    G4PionZero::PionZeroDefinition();
+void RichTbPhysicsList::ConstructMesons() {
+  //  mesons
+  G4PionPlus::PionPlusDefinition();
+  G4PionMinus::PionMinusDefinition();
+  G4PionZero::PionZeroDefinition();
 }
 
-
-void RichTbPhysicsList::ConstructBaryons()
-{
-    //  barions
-    G4Proton::ProtonDefinition();
-    G4AntiProton::AntiProtonDefinition();
-    G4Neutron::NeutronDefinition();
-    G4AntiNeutron::AntiNeutronDefinition();
+void RichTbPhysicsList::ConstructBaryons() {
+  //  barions
+  G4Proton::ProtonDefinition();
+  G4AntiProton::AntiProtonDefinition();
+  G4Neutron::NeutronDefinition();
+  G4AntiNeutron::AntiNeutronDefinition();
 }
 
-
-void RichTbPhysicsList::ConstructProcess()
-{
-    AddTransportation();
-    ConstructGeneral();
-    ConstructEM();
-    ConstructOp();
+void RichTbPhysicsList::ConstructProcess() {
+  AddTransportation();
+  ConstructGeneral();
+  ConstructEM();
+  ConstructOp();
 }
 
-
 #include "Geant4/G4Decay.hh"
 
-void RichTbPhysicsList::ConstructGeneral()
-{
-    G4Decay *theDecayProcess = new G4Decay();
-    //  theParticleTable = G4ParticleTable::GetParticleTable();
+void RichTbPhysicsList::ConstructGeneral() {
+  G4Decay *theDecayProcess = new G4Decay();
+  //  theParticleTable = G4ParticleTable::GetParticleTable();
 
-    // theParticleTable-> DumpTable("ALL");
-    // G4cout << "part iter " << theParticleTable-> GetIterator() <<  std::endl;
-    theParticleIterator->reset();
-
-    while ((*theParticleIterator) ()) {
-        G4ParticleDefinition *particle = theParticleIterator->value();
-        G4ProcessManager *pmanager = particle->GetProcessManager();
-        if (theDecayProcess->IsApplicable(*particle)) {
-            pmanager->AddDiscreteProcess(theDecayProcess);
-            pmanager->SetProcessOrdering(theDecayProcess, idxPostStep);
-              pmanager->SetProcessOrdering(theDecayProcess, idxAtRest);
+  // theParticleTable-> DumpTable("ALL");
+  // G4cout << "part iter " << theParticleTable-> GetIterator() <<  std::endl;
+  theParticleIterator->reset();
 
-        }
+  while ((*theParticleIterator)()) {
+    G4ParticleDefinition *particle = theParticleIterator->value();
+    G4ProcessManager *pmanager = particle->GetProcessManager();
+    if (theDecayProcess->IsApplicable(*particle)) {
+      pmanager->AddDiscreteProcess(theDecayProcess);
+      pmanager->SetProcessOrdering(theDecayProcess, idxPostStep);
+      pmanager->SetProcessOrdering(theDecayProcess, idxAtRest);
     }
+  }
 }
 
-
-
 #include "Geant4/G4ComptonScattering.hh"
 #include "Geant4/G4GammaConversion.hh"
 #include "Geant4/G4PhotoElectricEffect.hh"
 
 //#include "Geant4/G4MultipleScattering.hh"
 
+#include "Geant4/G4MuMultipleScattering.hh"
 #include "Geant4/G4eMultipleScattering.hh"
 #include "Geant4/G4hMultipleScattering.hh"
-#include "Geant4/G4MuMultipleScattering.hh"
-
 
-#include "Geant4/G4eIonisation.hh"
 #include "Geant4/G4eBremsstrahlung.hh"
+#include "Geant4/G4eIonisation.hh"
 #include "Geant4/G4eplusAnnihilation.hh"
 
-#include "Geant4/G4MuIonisation.hh"
 #include "Geant4/G4MuBremsstrahlung.hh"
+#include "Geant4/G4MuIonisation.hh"
 #include "Geant4/G4MuPairProduction.hh"
 
 #include "Geant4/G4hIonisation.hh"
 
-void RichTbPhysicsList::ConstructEM()
-{
+void RichTbPhysicsList::ConstructEM() {
   G4cout << " Now creating EM processes" << G4endl;
 
   theParticleIterator->reset();
-  while( (*theParticleIterator)() ){
-    G4ParticleDefinition* particle = theParticleIterator->value();
-    G4ProcessManager* pmanager = particle->GetProcessManager();
+  while ((*theParticleIterator)()) {
+    G4ParticleDefinition *particle = theParticleIterator->value();
+    G4ProcessManager *pmanager = particle->GetProcessManager();
     G4String particleName = particle->GetParticleName();
     if (particleName == "gamma") {
-    // gamma
+      // gamma
       // Construct processes for gamma
-       pmanager->AddDiscreteProcess(new G4GammaConversion("conv"));
-       pmanager->AddDiscreteProcess(new G4ComptonScattering("compt"));
-//      pmanager->AddDiscreteProcess(new G4PhotoElectricEffect());
+      pmanager->AddDiscreteProcess(new G4GammaConversion("conv"));
+      pmanager->AddDiscreteProcess(new G4ComptonScattering("compt"));
+      //      pmanager->AddDiscreteProcess(new G4PhotoElectricEffect());
 
     } else if (particleName == "e-") {
-    //electron
+      // electron
       // Construct processes for electron
-      pmanager->AddProcess(new G4eMultipleScattering(),-1, 1, 1);
-      pmanager->AddProcess(new G4eIonisation(),       -1, 2, 2);
-      pmanager->AddProcess(new G4eBremsstrahlung(),   -1,-1, 3);
+      pmanager->AddProcess(new G4eMultipleScattering(), -1, 1, 1);
+      pmanager->AddProcess(new G4eIonisation(), -1, 2, 2);
+      pmanager->AddProcess(new G4eBremsstrahlung(), -1, -1, 3);
 
     } else if (particleName == "e+") {
-    //positron
+      // positron
       // Construct processes for positron
-      pmanager->AddProcess(new G4eMultipleScattering(),-1, 1, 1);
-      pmanager->AddProcess(new G4eIonisation(),       -1, 2, 2);
-      pmanager->AddProcess(new G4eBremsstrahlung(),   -1,-1, 3);
-      pmanager->AddProcess(new G4eplusAnnihilation("annihil"),  0,-1, 4);
-    } else if( particleName == "mu+" ||
-               particleName == "mu-"    ) {
-    //muon
-     // Construct processes for muon
-     pmanager->AddProcess(new G4MuMultipleScattering(),-1, 1, 1);
-     pmanager->AddProcess(new G4MuIonisation(),      -1, 2, 2);
-     pmanager->AddProcess(new G4MuBremsstrahlung(),  -1,-1, 3);
-     pmanager->AddProcess(new G4MuPairProduction(),  -1,-1, 4);
+      pmanager->AddProcess(new G4eMultipleScattering(), -1, 1, 1);
+      pmanager->AddProcess(new G4eIonisation(), -1, 2, 2);
+      pmanager->AddProcess(new G4eBremsstrahlung(), -1, -1, 3);
+      pmanager->AddProcess(new G4eplusAnnihilation("annihil"), 0, -1, 4);
+    } else if (particleName == "mu+" || particleName == "mu-") {
+      // muon
+      // Construct processes for muon
+      pmanager->AddProcess(new G4MuMultipleScattering(), -1, 1, 1);
+      pmanager->AddProcess(new G4MuIonisation(), -1, 2, 2);
+      pmanager->AddProcess(new G4MuBremsstrahlung(), -1, -1, 3);
+      pmanager->AddProcess(new G4MuPairProduction(), -1, -1, 4);
 
     } else {
-      if ((particle->GetPDGCharge() != 0.0) &&
-          (particle->GetParticleName() != "chargedgeantino") &&
-          (particle->GetParticleName() != "pe-" )) {
-     // all others charged particles except geantino
-       pmanager->AddProcess(new G4hMultipleScattering(),-1,1,1);
-       pmanager->AddProcess(new G4hIonisation(),       -1,2,2);
-
+      if ((particle->GetPDGCharge() != 0.0) && (particle->GetParticleName() != "chargedgeantino") &&
+          (particle->GetParticleName() != "pe-")) {
+        // all others charged particles except geantino
+        pmanager->AddProcess(new G4hMultipleScattering(), -1, 1, 1);
+        pmanager->AddProcess(new G4hIonisation(), -1, 2, 2);
       }
     }
   }
 
   G4cout << " End of creating EM processes" << G4endl;
-
 }
 #include "RichTbMiscNames.hh"
 #include "RichTbRunConfig.hh"
 
-#include "RichTbG4Cerenkov.hh"
 #include "Geant4/G4Scintillation.hh"
+#include "HpdSiEnergyLoss.hh"
+#include "PixelHpdPhotoElectricEffect.hh"
+#include "PmtAnodeEnergyLoss.hh"
+#include "PmtPhotoElectricEffect.hh"
+#include "RichTbG4Cerenkov.hh"
 #include "RichTbG4OpAbsorption.hh"
-#include "RichTbG4OpRayleigh.hh"
 #include "RichTbG4OpBoundaryProcess.hh"
-#include "PmtPhotoElectricEffect.hh"
-#include "PmtAnodeEnergyLoss.hh"
-#include "PixelHpdPhotoElectricEffect.hh"
-#include  "HpdSiEnergyLoss.hh"
-
-
-void RichTbPhysicsList::ConstructOp()
- {
-   //   G4cout << " Now creating Optical processes" << G4endl;
-
-   // G4cout << " Now creating Cherenkov process" << G4endl;
-   RichTbRunConfig* rConfig = RichTbRunConfig::getRunConfigInstance();
-   G4int aRadiatorConfiguration = rConfig ->getRadiatorConfiguration();
-
-
-   RichTbG4Cerenkov*  theCerenkovProcess = new RichTbG4Cerenkov("RichTbCerenkov");
-   PmtAnodeEnergyLoss* thePmtAnodeEnergyLossProcess = new PmtAnodeEnergyLoss("PmtAnodeEnergyLoss");
+#include "RichTbG4OpRayleigh.hh"
 
-   HpdSiEnergyLoss * theHpdSiEnergyLossProcess = (aRadiatorConfiguration == 2 ) ?
-     new  HpdSiEnergyLoss("HpdSiEnergyLoss") : 0;
+void RichTbPhysicsList::ConstructOp() {
+  //   G4cout << " Now creating Optical processes" << G4endl;
 
+  // G4cout << " Now creating Cherenkov process" << G4endl;
+  RichTbRunConfig *rConfig = RichTbRunConfig::getRunConfigInstance();
+  G4int aRadiatorConfiguration = rConfig->getRadiatorConfiguration();
 
-   // G4Scintillation* theScintillationProcess =
-   //                     new G4Scintillation("Scintillation");
-   // G4cout << " Now creating Absorption process" << G4endl;
-   RichTbG4OpAbsorption* theAbsorptionProcess     =
-              new RichTbG4OpAbsorption();
-   // used even in 2004 testbeam, although only neglibible effect expected.
-   //  G4cout << " Now creating Rayleigh process" <<G4endl;
-   //
-   RichTbG4OpRayleigh*  theRayleighScatteringProcess =
-              new RichTbG4OpRayleigh("RichTbG4OpRayleigh");
-   // G4cout << " Now creating Boundary process" << G4endl;
-   RichTbG4OpBoundaryProcess* theBoundaryProcess =
-              new RichTbG4OpBoundaryProcess("RichTbG4BoundaryProcess");
+  RichTbG4Cerenkov *theCerenkovProcess = new RichTbG4Cerenkov("RichTbCerenkov");
+  PmtAnodeEnergyLoss *thePmtAnodeEnergyLossProcess = new PmtAnodeEnergyLoss("PmtAnodeEnergyLoss");
 
-   //  G4cout << " Now creating PmtPhotoElectric process" << G4endl;
-   PmtPhotoElectricEffect*   thePmtPhotoElectricProcess=
-      new   PmtPhotoElectricEffect(PmtPhotElectProc);
+  HpdSiEnergyLoss *theHpdSiEnergyLossProcess =
+      (aRadiatorConfiguration == 2) ? new HpdSiEnergyLoss("HpdSiEnergyLoss") : 0;
 
-   PixelHpdPhotoElectricEffect * theHpdPhotoElectricProcess= (aRadiatorConfiguration == 2 ) ?
-       new PixelHpdPhotoElectricEffect(HpdPhotElectProc) : 0;
+  // G4Scintillation* theScintillationProcess =
+  //                     new G4Scintillation("Scintillation");
+  // G4cout << " Now creating Absorption process" << G4endl;
+  RichTbG4OpAbsorption *theAbsorptionProcess = new RichTbG4OpAbsorption();
+  // used even in 2004 testbeam, although only neglibible effect expected.
+  //  G4cout << " Now creating Rayleigh process" <<G4endl;
+  //
+  RichTbG4OpRayleigh *theRayleighScatteringProcess = new RichTbG4OpRayleigh("RichTbG4OpRayleigh");
+  // G4cout << " Now creating Boundary process" << G4endl;
+  RichTbG4OpBoundaryProcess *theBoundaryProcess = new RichTbG4OpBoundaryProcess("RichTbG4BoundaryProcess");
 
+  //  G4cout << " Now creating PmtPhotoElectric process" << G4endl;
+  PmtPhotoElectricEffect *thePmtPhotoElectricProcess = new PmtPhotoElectricEffect(PmtPhotElectProc);
 
+  PixelHpdPhotoElectricEffect *theHpdPhotoElectricProcess =
+      (aRadiatorConfiguration == 2) ? new PixelHpdPhotoElectricEffect(HpdPhotElectProc) : 0;
 
   //   theCerenkovProcess->SetMaxNumPhotonsPerStep(300);
-   theCerenkovProcess->SetMaxNumPhotonsPerStep(2000);
-   theCerenkovProcess->SetTrackSecondariesFirst(true);
-   // theScintillationProcess->SetScintillationYieldFactor(1.);
-   // theScintillationProcess->SetTrackSecondariesFirst(true);
-
-   //   G4OpticalSurfaceModel themodel = unified;
-      G4OpticalSurfaceModel themodel = glisur;
-      theBoundaryProcess->SetModel(themodel);
-//
-//there  seems to be a problem with the definition of
-// sigma_c++ particle. Until that is solved, avoid
-// creating the Cherekov process for this particle and
-// avoid make tests on its process manager.
-// this is to avoid a crash from the process index check.
-// SE 12-1-04.
-
-    theParticleIterator->reset();
-   while( (*theParticleIterator)() ){
-     G4ParticleDefinition* particle = theParticleIterator->value();
-     G4ProcessManager* pmanager = particle->GetProcessManager();
-     //  pmanager->DumpInfo();
-     G4String particleName = particle->GetParticleName();
-     if(particleName != "sigma_c++") {
-       //G4ProcessVector* aList= pmanager-> GetProcessList();
-       //
-     //   G4cout<<" Particle name numproc Procvectsize "<<particleName
-     //      <<"   "<<pmanager-> GetProcessListLength()
-     //      <<"  "<< aList->size()  <<G4endl;
-       // for(G4int ii=0; ii< (int) aList->size() ;ii++) {
-
-       //   G4cout<<"Proc num name Indexes  "<<ii<< "   "
-       //  << ( *aList ) [ii]->GetProcessName()
-       //      << "  "<<G4endl;
-
-       //    }
-
-
-       if (theCerenkovProcess->IsApplicable(*particle)) {
-              pmanager->AddContinuousProcess(theCerenkovProcess);
-       }
-
-	      //              pmanager->AddProcess(theCerenkovProcess,-1,2,-1);
-              if( thePmtAnodeEnergyLossProcess-> IsApplicable(*particle)){
-                pmanager-> AddProcess(thePmtAnodeEnergyLossProcess,-1,2,2);
-              }
-
-                if(theHpdSiEnergyLossProcess) {
-                  if(theHpdSiEnergyLossProcess -> IsApplicable(*particle)){
-                     pmanager-> AddProcess(theHpdSiEnergyLossProcess,-1,2,2);
-                  }
-
-                }
-
-
-
-
+  theCerenkovProcess->SetMaxNumPhotonsPerStep(2000);
+  theCerenkovProcess->SetTrackSecondariesFirst(true);
+  // theScintillationProcess->SetScintillationYieldFactor(1.);
+  // theScintillationProcess->SetTrackSecondariesFirst(true);
+
+  //   G4OpticalSurfaceModel themodel = unified;
+  G4OpticalSurfaceModel themodel = glisur;
+  theBoundaryProcess->SetModel(themodel);
+  //
+  // there  seems to be a problem with the definition of
+  // sigma_c++ particle. Until that is solved, avoid
+  // creating the Cherekov process for this particle and
+  // avoid make tests on its process manager.
+  // this is to avoid a crash from the process index check.
+  // SE 12-1-04.
 
+  theParticleIterator->reset();
+  while ((*theParticleIterator)()) {
+    G4ParticleDefinition *particle = theParticleIterator->value();
+    G4ProcessManager *pmanager = particle->GetProcessManager();
+    //  pmanager->DumpInfo();
+    G4String particleName = particle->GetParticleName();
+    if (particleName != "sigma_c++") {
+      // G4ProcessVector* aList= pmanager-> GetProcessList();
+      //
+      //   G4cout<<" Particle name numproc Procvectsize "<<particleName
+      //      <<"   "<<pmanager-> GetProcessListLength()
+      //      <<"  "<< aList->size()  <<G4endl;
+      // for(G4int ii=0; ii< (int) aList->size() ;ii++) {
+
+      //   G4cout<<"Proc num name Indexes  "<<ii<< "   "
+      //  << ( *aList ) [ii]->GetProcessName()
+      //      << "  "<<G4endl;
+
+      //    }
+
+      if (theCerenkovProcess->IsApplicable(*particle)) {
+        pmanager->AddContinuousProcess(theCerenkovProcess);
+      }
 
+      //              pmanager->AddProcess(theCerenkovProcess,-1,2,-1);
+      if (thePmtAnodeEnergyLossProcess->IsApplicable(*particle)) {
+        pmanager->AddProcess(thePmtAnodeEnergyLossProcess, -1, 2, 2);
+      }
 
+      if (theHpdSiEnergyLossProcess) {
+        if (theHpdSiEnergyLossProcess->IsApplicable(*particle)) {
+          pmanager->AddProcess(theHpdSiEnergyLossProcess, -1, 2, 2);
+        }
+      }
 
-       //    G4cout<<" End of adding Cherenkov process "<<G4endl;
-
-     //  if (theScintillationProcess->IsApplicable(*particle)) {
-       //  pmanager->AddProcess(theScintillationProcess);
-       //      pmanager->SetProcessOrderingToLast(theScintillationProcess, idxAtRest);
-       // pmanager->SetProcessOrderingToLast(theScintillationProcess, idxPostStep);
-     //  }
-     if (particleName == "opticalphoton") {
-       //  G4cout << " AddDiscreteProcess to OpticalPhoton " << G4endl;
-       pmanager->AddDiscreteProcess(theAbsorptionProcess);
-       pmanager->AddDiscreteProcess(theRayleighScatteringProcess);
-       pmanager->AddDiscreteProcess(theBoundaryProcess);
-       pmanager->AddDiscreteProcess(thePmtPhotoElectricProcess);
-       if(theHpdPhotoElectricProcess) pmanager->AddDiscreteProcess(theHpdPhotoElectricProcess);
-
-
-     }
-     }
-
-
-
-
-
-     // G4cout << " End of creating Optical processes" << G4endl;
-
- }
-
- }
-
-
-void RichTbPhysicsList::SetCuts()
-{
-    if (verboseLevel > 1) {
-        G4cout << "RichTbPhysicsList::SetCuts:";
+      //    G4cout<<" End of adding Cherenkov process "<<G4endl;
+
+      //  if (theScintillationProcess->IsApplicable(*particle)) {
+      //  pmanager->AddProcess(theScintillationProcess);
+      //      pmanager->SetProcessOrderingToLast(theScintillationProcess, idxAtRest);
+      // pmanager->SetProcessOrderingToLast(theScintillationProcess, idxPostStep);
+      //  }
+      if (particleName == "opticalphoton") {
+        //  G4cout << " AddDiscreteProcess to OpticalPhoton " << G4endl;
+        pmanager->AddDiscreteProcess(theAbsorptionProcess);
+        pmanager->AddDiscreteProcess(theRayleighScatteringProcess);
+        pmanager->AddDiscreteProcess(theBoundaryProcess);
+        pmanager->AddDiscreteProcess(thePmtPhotoElectricProcess);
+        if (theHpdPhotoElectricProcess)
+          pmanager->AddDiscreteProcess(theHpdPhotoElectricProcess);
+      }
     }
-    //  " G4VUserPhysicsList::SetCutsWithDefault" method sets
-    //   the default cut value for all particle types
-    SetCutsWithDefault();
-  if (verboseLevel>0) DumpCutValuesTable();
 
+    // G4cout << " End of creating Optical processes" << G4endl;
+  }
+}
+
+void RichTbPhysicsList::SetCuts() {
+  if (verboseLevel > 1) {
+    G4cout << "RichTbPhysicsList::SetCuts:";
+  }
+  //  " G4VUserPhysicsList::SetCutsWithDefault" method sets
+  //   the default cut value for all particle types
+  SetCutsWithDefault();
+  if (verboseLevel > 0)
+    DumpCutValuesTable();
 }
diff --git a/LHCbG4Tests/G4RichTbSimHTest/src/srcph/RichTbPrimaryGeneratorAction.cc b/LHCbG4Tests/G4RichTbSimHTest/src/srcph/RichTbPrimaryGeneratorAction.cc
index 0ef539813d316748d7052a45adb9f30f0ee3fdd8..b7448e5d1002952eddf4820db077a25f3a80bbce 100644
--- a/LHCbG4Tests/G4RichTbSimHTest/src/srcph/RichTbPrimaryGeneratorAction.cc
+++ b/LHCbG4Tests/G4RichTbSimHTest/src/srcph/RichTbPrimaryGeneratorAction.cc
@@ -1,138 +1,124 @@
 #include "RichTbPrimaryGeneratorAction.hh"
 
-#include "Geant4/globals.hh"
 #include "Geant4/G4Event.hh"
+#include "Geant4/G4ParticleDefinition.hh"
 #include "Geant4/G4ParticleGun.hh"
 #include "Geant4/G4ParticleTable.hh"
-#include "Geant4/G4ParticleDefinition.hh"
-#include "RichTbMaterialParameters.hh"
 #include "Geant4/Randomize.hh"
-#include "RichTbRunConfig.hh"
-#include "RichTbGeometryParameters.hh"
-#include  <math.h>
-#include "RichTbBeamProperty.hh"
+#include "Geant4/globals.hh"
 #include "RichTbAnalysisManager.hh"
+#include "RichTbBeamProperty.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMaterialParameters.hh"
+#include "RichTbRunConfig.hh"
+#include <math.h>
 
-RichTbPrimaryGeneratorAction::RichTbPrimaryGeneratorAction()
-{
-  //RichTbRunConfig* rConfig =  RichTbRunConfig::getRunConfigInstance();
-
-    G4int n_particle = 1;
-    particleGun = new G4ParticleGun(n_particle);
+RichTbPrimaryGeneratorAction::RichTbPrimaryGeneratorAction() {
+  // RichTbRunConfig* rConfig =  RichTbRunConfig::getRunConfigInstance();
 
+  G4int n_particle = 1;
+  particleGun = new G4ParticleGun(n_particle);
 }
 
-
-RichTbPrimaryGeneratorAction::~RichTbPrimaryGeneratorAction()
-{
-  if( particleGun != 0 )  delete particleGun;
+RichTbPrimaryGeneratorAction::~RichTbPrimaryGeneratorAction() {
+  if (particleGun != 0)
+    delete particleGun;
 }
 
-
-void RichTbPrimaryGeneratorAction::GeneratePrimaries(G4Event * anEvent)
-{
-  RichTbBeamProperty* aBeamProperty =
-    RichTbBeamProperty:: getRichTbBeamPropertyInstance();
+void RichTbPrimaryGeneratorAction::GeneratePrimaries(G4Event *anEvent) {
+  RichTbBeamProperty *aBeamProperty = RichTbBeamProperty::getRichTbBeamPropertyInstance();
   aBeamProperty->ResetBeamProperty();
-  RichTbRunConfig* rConfig =  RichTbRunConfig::getRunConfigInstance();
+  RichTbRunConfig *rConfig = RichTbRunConfig::getRunConfigInstance();
   G4int NumPart = rConfig->getRichTbNumPartEvent();
-  for(G4int ip=0; ip< NumPart ; ip++){
-    CurrentBeamParticle= SetParticleType();
-    particleGun->SetParticleTime(0.0*CLHEP::ns);
+  for (G4int ip = 0; ip < NumPart; ip++) {
+    CurrentBeamParticle = SetParticleType();
+    particleGun->SetParticleTime(0.0 * CLHEP::ns);
     SetParticleStartPos();
     SetParticleDirection();
     SetParticleKineticEnergy(CurrentBeamParticle);
     particleGun->GeneratePrimaryVertex(anEvent);
   }
-
 }
 
-G4ParticleDefinition* RichTbPrimaryGeneratorAction::SetParticleType()
-{
-  RichTbRunConfig* rConfig =  RichTbRunConfig::getRunConfigInstance();
-  RichTbBeamProperty* aBeamProperty =
-    RichTbBeamProperty:: getRichTbBeamPropertyInstance();
+G4ParticleDefinition *RichTbPrimaryGeneratorAction::SetParticleType() {
+  RichTbRunConfig *rConfig = RichTbRunConfig::getRunConfigInstance();
+  RichTbBeamProperty *aBeamProperty = RichTbBeamProperty::getRichTbBeamPropertyInstance();
 
   G4int patype = rConfig->getRichTbParticleTypeCode();
   // default is with patyp =0 which is for pi-.
   // the pi- beam is set to be not a mixture, for now.
   // the pi+ beam is a mixture of pi+ and protons.
 
-  G4String particleName="pi-";
+  G4String particleName = "pi-";
 
-  if(patype == 1 ) {
-    particleName="opticalphoton";
+  if (patype == 1) {
+    particleName = "opticalphoton";
 
-  }else if(patype == 2) {
-    G4double PosFr =  rConfig-> getPosBeamFraction();
+  } else if (patype == 2) {
+    G4double PosFr = rConfig->getPosBeamFraction();
     G4double randomQut1 = G4UniformRand();
-    if(randomQut1 >  PosFr ) {
-      particleName="pi+";
-    }else {
-      particleName="proton";
+    if (randomQut1 > PosFr) {
+      particleName = "pi+";
+    } else {
+      particleName = "proton";
     }
 
-  }else if(patype == 3) {
+  } else if (patype == 3) {
 
-    G4double ElnFr =  rConfig-> getPosBeamFraction();
+    G4double ElnFr = rConfig->getPosBeamFraction();
     G4double randomQut1 = G4UniformRand();
-    if(randomQut1 >  ElnFr ) {
-      particleName="pi-";
-    }else {
-      particleName="e-";
+    if (randomQut1 > ElnFr) {
+      particleName = "pi-";
+    } else {
+      particleName = "e-";
     }
 
-  } else if(patype == 4) {
+  } else if (patype == 4) {
 
-    G4double KaonFr =  rConfig-> getPosBeamFraction();
+    G4double KaonFr = rConfig->getPosBeamFraction();
     G4double randomQutk = G4UniformRand();
-    if(randomQutk >  KaonFr ) {
-      particleName="pi-";
-    }else {
-      particleName="kaon-";
+    if (randomQutk > KaonFr) {
+      particleName = "pi-";
+    } else {
+      particleName = "kaon-";
     }
 
-  }else if(patype == 5) {
+  } else if (patype == 5) {
 
-    G4double KaonFrp =  rConfig-> getPosBeamFraction();
+    G4double KaonFrp = rConfig->getPosBeamFraction();
     G4double randomQutp = G4UniformRand();
-    if(randomQutp >  KaonFrp ) {
-      particleName="pi+";
-    }else {
-      particleName="kaon+";
+    if (randomQutp > KaonFrp) {
+      particleName = "pi+";
+    } else {
+      particleName = "kaon+";
     }
 
-  }else if(patype == 6) {
-    particleName="proton";
-  }else if(patype == 7) {
-    particleName="mu-";
+  } else if (patype == 6) {
+    particleName = "proton";
+  } else if (patype == 7) {
+    particleName = "mu-";
   }
 
-  G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
-  G4ParticleDefinition* particle=
-            particleTable->FindParticle(particleName);
-
-   particleGun->SetParticleDefinition(particle);
-   //G4cout<<" Current Beam particle is  "<<particleName<<G4endl;
-
-   // now store the info.
-   aBeamProperty->setBeamPartDef(particle);
-   aBeamProperty-> setBeamPartName(particleName);
+  G4ParticleTable *particleTable = G4ParticleTable::GetParticleTable();
+  G4ParticleDefinition *particle = particleTable->FindParticle(particleName);
 
-   return particle;
+  particleGun->SetParticleDefinition(particle);
+  // G4cout<<" Current Beam particle is  "<<particleName<<G4endl;
 
+  // now store the info.
+  aBeamProperty->setBeamPartDef(particle);
+  aBeamProperty->setBeamPartName(particleName);
 
+  return particle;
 }
 
 void RichTbPrimaryGeneratorAction::SetParticleStartPos() {
 
-  RichTbRunConfig* rConfig =  RichTbRunConfig::getRunConfigInstance();
-  RichTbBeamProperty* aBeamProperty =
-    RichTbBeamProperty:: getRichTbBeamPropertyInstance();
-  G4ThreeVector  positionStd=  aBeamProperty->getNominalBeamPosition() ;
+  RichTbRunConfig *rConfig = RichTbRunConfig::getRunConfigInstance();
+  RichTbBeamProperty *aBeamProperty = RichTbBeamProperty::getRichTbBeamPropertyInstance();
+  G4ThreeVector positionStd = aBeamProperty->getNominalBeamPosition();
 
-
-  G4int PosCode=rConfig->getRichTbParticleStartPosCode();
+  G4int PosCode = rConfig->getRichTbParticleStartPosCode();
   // standard positon is at PosCode =0.
   //  G4double beamPosXStd = AgelTileXLocation[0];
   //  G4double beamPosYStd = AgelTileYLocation[0]+0.5*RichTbVesselYSize;
@@ -144,251 +130,225 @@ void RichTbPrimaryGeneratorAction::SetParticleStartPos() {
   //      <<positionStd.x()<<"  "<<positionStd.y()<<"  "<<positionStd.z()
   //      <<G4endl;
 
-
-   if(PosCode == 0 ) {
+  if (PosCode == 0) {
     particleGun->SetParticlePosition(positionStd);
-  // store the positon for writeOut.
-
-    aBeamProperty-> setBeamPosition( positionStd);
-
-   }else if (PosCode == 1 ) {
-
-     G4double aBeamXShift = rConfig->getBeamXPosShift();
-     G4double aBeamYShift = rConfig->getBeamYPosShift();
-     G4double aBeamPosX =  positionStd.x() +  aBeamXShift;
-     G4double aBeamPosY =  positionStd.y() + aBeamYShift;
-     G4double aBeamPosZ =  positionStd.z();
+    // store the positon for writeOut.
 
-     G4ThreeVector aBeamPosition(aBeamPosX,aBeamPosY, aBeamPosZ);
-     particleGun->SetParticlePosition(aBeamPosition);
-  // store the positon for writeOut.
-     //G4cout<<" Current beam part start pos is "
-     //   << aBeamPosX<<"  "<<  aBeamPosY<<"  "<< aBeamPosZ<<G4endl;
+    aBeamProperty->setBeamPosition(positionStd);
 
-    aBeamProperty-> setBeamPosition(aBeamPosition );
+  } else if (PosCode == 1) {
 
-   } else if ( PosCode == 2 ) {
-     //
+    G4double aBeamXShift = rConfig->getBeamXPosShift();
+    G4double aBeamYShift = rConfig->getBeamYPosShift();
+    G4double aBeamPosX = positionStd.x() + aBeamXShift;
+    G4double aBeamPosY = positionStd.y() + aBeamYShift;
+    G4double aBeamPosZ = positionStd.z();
 
-     G4double aSpBeamX=  rConfig->getBeamSpecialXPos();
-     G4double aSpBeamY=  rConfig->getBeamSpecialYPos();
-     G4double aSpBeamZ=  rConfig->getBeamSpecialZPos();
+    G4ThreeVector aBeamPosition(aBeamPosX, aBeamPosY, aBeamPosZ);
+    particleGun->SetParticlePosition(aBeamPosition);
+    // store the positon for writeOut.
+    // G4cout<<" Current beam part start pos is "
+    //   << aBeamPosX<<"  "<<  aBeamPosY<<"  "<< aBeamPosZ<<G4endl;
 
-     G4ThreeVector aSpBeam(  aSpBeamX,  aSpBeamY, aSpBeamZ);
-     particleGun->SetParticlePosition( aSpBeam );
+    aBeamProperty->setBeamPosition(aBeamPosition);
 
-  // store the positon for writeOut.
+  } else if (PosCode == 2) {
+    //
 
-     //G4cout<<" Current beam part start pos is "
-     //   << aSpBeamX<<"  "<<  aSpBeamY<<"  "<< aSpBeamZ<<G4endl;
+    G4double aSpBeamX = rConfig->getBeamSpecialXPos();
+    G4double aSpBeamY = rConfig->getBeamSpecialYPos();
+    G4double aSpBeamZ = rConfig->getBeamSpecialZPos();
 
-    aBeamProperty-> setBeamPosition(aSpBeam  );
+    G4ThreeVector aSpBeam(aSpBeamX, aSpBeamY, aSpBeamZ);
+    particleGun->SetParticlePosition(aSpBeam);
 
-   } else if (PosCode == 3 ) {
+    // store the positon for writeOut.
 
-     // make random beam pos along X axis to study the Gap betwen aerogel tiles.
-     G4double aSpBeamXInit=  rConfig->getBeamSpecialXPos();
-     G4double aSpBeamYInit=  rConfig->getBeamSpecialYPos();
-     G4double aSpBeamZInit=  rConfig->getBeamSpecialZPos();
+    // G4cout<<" Current beam part start pos is "
+    //   << aSpBeamX<<"  "<<  aSpBeamY<<"  "<< aSpBeamZ<<G4endl;
 
-     //     G4double aSpBeamXRange = 8.0*CLHEP::mm;
-     G4double aSpBeamXRange =  rConfig->getBeamSpecialXRange();
-     G4double rands = G4UniformRand();
-     // set up a flat random number from -1 to 1.
-     G4double aSpBeamXCurrent = aSpBeamXInit+((rands-0.5)*2.0)*aSpBeamXRange;
-     G4ThreeVector aSpBeam(  aSpBeamXCurrent,  aSpBeamYInit, aSpBeamZInit);
-     particleGun->SetParticlePosition( aSpBeam );
-  // store the positon for writeOut.
-     //G4cout<<" Current beam part start pos is "
-     //   << aSpBeamXCurrent<<"  "<<  aSpBeamYInit<<"  "
-     //      << aSpBeamZInit<<G4endl;
+    aBeamProperty->setBeamPosition(aSpBeam);
 
-    aBeamProperty-> setBeamPosition(aSpBeam  );
+  } else if (PosCode == 3) {
 
+    // make random beam pos along X axis to study the Gap betwen aerogel tiles.
+    G4double aSpBeamXInit = rConfig->getBeamSpecialXPos();
+    G4double aSpBeamYInit = rConfig->getBeamSpecialYPos();
+    G4double aSpBeamZInit = rConfig->getBeamSpecialZPos();
 
-   }
+    //     G4double aSpBeamXRange = 8.0*CLHEP::mm;
+    G4double aSpBeamXRange = rConfig->getBeamSpecialXRange();
+    G4double rands = G4UniformRand();
+    // set up a flat random number from -1 to 1.
+    G4double aSpBeamXCurrent = aSpBeamXInit + ((rands - 0.5) * 2.0) * aSpBeamXRange;
+    G4ThreeVector aSpBeam(aSpBeamXCurrent, aSpBeamYInit, aSpBeamZInit);
+    particleGun->SetParticlePosition(aSpBeam);
+    // store the positon for writeOut.
+    // G4cout<<" Current beam part start pos is "
+    //   << aSpBeamXCurrent<<"  "<<  aSpBeamYInit<<"  "
+    //      << aSpBeamZInit<<G4endl;
 
+    aBeamProperty->setBeamPosition(aSpBeam);
+  }
 }
-void RichTbPrimaryGeneratorAction::SetParticleKineticEnergy
-(G4ParticleDefinition* CurPart )
-{
-  RichTbRunConfig* rConfig =  RichTbRunConfig::getRunConfigInstance();
+void RichTbPrimaryGeneratorAction::SetParticleKineticEnergy(G4ParticleDefinition *CurPart) {
+  RichTbRunConfig *rConfig = RichTbRunConfig::getRunConfigInstance();
   //  RichTbAnalysisManager* rAnalysis =  RichTbAnalysisManager::getInstance();
   //  G4double paMass = CurPart->GetPDGMass();
   // G4cout<<"Cur beam paticle mass " <<paMass<<G4endl;
-  G4int PEnergyCode=rConfig->getRichTbParticleEnergyCode();
+  G4int PEnergyCode = rConfig->getRichTbParticleEnergyCode();
   G4int curpatype = rConfig->getRichTbParticleTypeCode();
   G4double paMass = 0.0;
 
-  if(  curpatype !=  1 ) {
+  if (curpatype != 1) {
 
-     paMass = CurPart->GetPDGMass();
+    paMass = CurPart->GetPDGMass();
   }
 
-  if( PEnergyCode == 0 ) {
-
-  G4double particleMom =(rConfig-> getRichTbParticleMomentum())*CLHEP::GeV;
-  G4double PKineticEnergy=
-           pow((particleMom*particleMom+paMass*paMass),0.5) - paMass;
-  particleGun->SetParticleEnergy(PKineticEnergy);
+  if (PEnergyCode == 0) {
 
-  //   G4cout<<"Current beam Name momentum mass and KE are  "
-  //        <<CurPart->GetParticleName()<<"  "<< particleMom
-  //  <<"  "<<paMass <<"  "<<  PKineticEnergy <<G4endl;
+    G4double particleMom = (rConfig->getRichTbParticleMomentum()) * CLHEP::GeV;
+    G4double PKineticEnergy = pow((particleMom * particleMom + paMass * paMass), 0.5) - paMass;
+    particleGun->SetParticleEnergy(PKineticEnergy);
 
+    //   G4cout<<"Current beam Name momentum mass and KE are  "
+    //        <<CurPart->GetParticleName()<<"  "<< particleMom
+    //  <<"  "<<paMass <<"  "<<  PKineticEnergy <<G4endl;
 
-  } else if (PEnergyCode == 1 && curpatype == 1 ) {
+  } else if (PEnergyCode == 1 && curpatype == 1) {
     // for photons get the wavelength.
 
-    G4double particlewlen = ( rConfig->getConstPhotWlenBeam()) *CLHEP::nanometer;
-
-    G4double photonparticleMom = 3.0*CLHEP::eV;
-    if ( particlewlen != 0.0 ) {
-      photonparticleMom =  (  PhotWaveLengthToMom / particlewlen);
+    G4double particlewlen = (rConfig->getConstPhotWlenBeam()) * CLHEP::nanometer;
 
+    G4double photonparticleMom = 3.0 * CLHEP::eV;
+    if (particlewlen != 0.0) {
+      photonparticleMom = (PhotWaveLengthToMom / particlewlen);
     }
-    G4double PhotonKineticEnergy=   photonparticleMom;
+    G4double PhotonKineticEnergy = photonparticleMom;
 
     particleGun->SetParticleEnergy(PhotonKineticEnergy);
 
     //    G4cout<<"Current beam Photon momentum and wlen are "
     // <<"  "<<  photonparticleMom <<"  "<<  particlewlen  <<G4endl;
 
+  } else if (PEnergyCode == 2 && curpatype == 1) {
 
-  } else if ( PEnergyCode == 2 && curpatype == 1  ) {
-
-         G4double photonparticleMinMom = 1.3*CLHEP::eV;
-         G4double photonparticleMaxMom = 6.5*CLHEP::eV;
-         G4double photonMinWlen = ( rConfig->getPhotWlenMinBeam()) * CLHEP::nanometer;
-         G4double  photonMaxWlen =  ( rConfig->getPhotWlenMaxBeam())* CLHEP::nanometer;
-         if(  photonMinWlen != 0.0 ) {
-           photonparticleMaxMom = PhotWaveLengthToMom/ photonMinWlen;
-
-         }
-         if(  photonMaxWlen != 0.0 ) {
-           photonparticleMinMom =  PhotWaveLengthToMom/ photonMaxWlen;
-
-         }
-
-          G4double randa = G4UniformRand();
-          G4double CurPhotMom =  photonparticleMinMom+
-            randa* ( photonparticleMaxMom -  photonparticleMinMom);
-          G4double curPhotonKineticEnergy= CurPhotMom;
-
-          particleGun->SetParticleEnergy( curPhotonKineticEnergy );
+    G4double photonparticleMinMom = 1.3 * CLHEP::eV;
+    G4double photonparticleMaxMom = 6.5 * CLHEP::eV;
+    G4double photonMinWlen = (rConfig->getPhotWlenMinBeam()) * CLHEP::nanometer;
+    G4double photonMaxWlen = (rConfig->getPhotWlenMaxBeam()) * CLHEP::nanometer;
+    if (photonMinWlen != 0.0) {
+      photonparticleMaxMom = PhotWaveLengthToMom / photonMinWlen;
+    }
+    if (photonMaxWlen != 0.0) {
+      photonparticleMinMom = PhotWaveLengthToMom / photonMaxWlen;
+    }
 
-          // G4double curPhotonWlenNano = 0.0;
-          //  if( CurPhotMom != 0.0 ) {
+    G4double randa = G4UniformRand();
+    G4double CurPhotMom = photonparticleMinMom + randa * (photonparticleMaxMom - photonparticleMinMom);
+    G4double curPhotonKineticEnergy = CurPhotMom;
 
-            //   curPhotonWlenNano = PhotMomToWaveLength /(CurPhotMom*CLHEP::nanometer);
-          // }
+    particleGun->SetParticleEnergy(curPhotonKineticEnergy);
 
-          // if( rAnalysis ->getfhistoWClarityProduced() ) {
-          //  rAnalysis ->getfhistoWClarityProduced()->fill(curPhotonWlenNano,1.0);
+    // G4double curPhotonWlenNano = 0.0;
+    //  if( CurPhotMom != 0.0 ) {
 
-          //  }
+    //   curPhotonWlenNano = PhotMomToWaveLength /(CurPhotMom*CLHEP::nanometer);
+    // }
 
-          //      G4cout<<"Current beam Photon momentum and wavlength are "
-          //     <<"  "<< CurPhotMom <<"  "<<curPhotonWlenNano<<G4endl;
+    // if( rAnalysis ->getfhistoWClarityProduced() ) {
+    //  rAnalysis ->getfhistoWClarityProduced()->fill(curPhotonWlenNano,1.0);
 
+    //  }
 
+    //      G4cout<<"Current beam Photon momentum and wavlength are "
+    //     <<"  "<< CurPhotMom <<"  "<<curPhotonWlenNano<<G4endl;
   }
-
-
-
-
 }
 
-void RichTbPrimaryGeneratorAction::SetParticleDirection()
-{
-  RichTbRunConfig* rConfig =  RichTbRunConfig::getRunConfigInstance();
-  RichTbBeamProperty* aBeamProperty =
-    RichTbBeamProperty:: getRichTbBeamPropertyInstance();
+void RichTbPrimaryGeneratorAction::SetParticleDirection() {
+  RichTbRunConfig *rConfig = RichTbRunConfig::getRunConfigInstance();
+  RichTbBeamProperty *aBeamProperty = RichTbBeamProperty::getRichTbBeamPropertyInstance();
   // default direction code is 0 for 001 direction with no
   // misalignment or divergence.
-  G4int DirCode=rConfig->getRichTbParticleDirectionCode();
+  G4int DirCode = rConfig->getRichTbParticleDirectionCode();
   //  G4ThreeVector direction(0.0,0.0,1.0)
-  G4ThreeVector directionStd=
-             aBeamProperty ->getNominalBeamDirectionCos();
+  G4ThreeVector directionStd = aBeamProperty->getNominalBeamDirectionCos();
 
   G4ThreeVector direction = directionStd;
 
-  G4double aBeamDirX= rConfig->getBeamDirX();
-  G4double aBeamDirY= rConfig->getBeamDirY();
-  G4double aBeamDiverX =  rConfig->getBeamDivergenceX();
-  G4double aBeamDiverY =  rConfig->getBeamDivergenceY();
+  G4double aBeamDirX = rConfig->getBeamDirX();
+  G4double aBeamDirY = rConfig->getBeamDirY();
+  G4double aBeamDiverX = rConfig->getBeamDivergenceX();
+  G4double aBeamDiverY = rConfig->getBeamDivergenceY();
 
-  if(DirCode == 1 ) {
-    G4ThreeVector aDirection( directionStd.x(),
-                  directionStd.y() ,-1.0*directionStd.z() );
-    direction=aDirection;
-  }else if ( DirCode == 2 ) {
+  if (DirCode == 1) {
+    G4ThreeVector aDirection(directionStd.x(), directionStd.y(), -1.0 * directionStd.z());
+    direction = aDirection;
+  } else if (DirCode == 2) {
     // with misalignment and no divergence.
 
-    G4ThreeVector bDirection( aBeamDirX,aBeamDirY,1.0);
-    direction=bDirection;
+    G4ThreeVector bDirection(aBeamDirX, aBeamDirY, 1.0);
+    direction = bDirection;
 
-  } else if (DirCode == 3 ) {
+  } else if (DirCode == 3) {
     // with misalignment and divergence.
 
-   G4double pxBeA = G4RandGauss::shoot( aBeamDirX ,aBeamDiverX);
-   G4double pyBeA = G4RandGauss::shoot(aBeamDirY , aBeamDiverY);
-   G4double thetaBeam=pow( (pxBeA*pxBeA + pyBeA*pyBeA),0.5);
-   G4double phiBeam = 0.0;
+    G4double pxBeA = G4RandGauss::shoot(aBeamDirX, aBeamDiverX);
+    G4double pyBeA = G4RandGauss::shoot(aBeamDirY, aBeamDiverY);
+    G4double thetaBeam = pow((pxBeA * pxBeA + pyBeA * pyBeA), 0.5);
+    G4double phiBeam = 0.0;
 
-   if (thetaBeam != 0.) {
-        phiBeam = acos(pxBeA/thetaBeam);
-        if ( pyBeA < 0.) phiBeam = -phiBeam;
-   }
-   G4double  pxBe = sin(thetaBeam) * cos(phiBeam);
-   G4double  pyBe =  sin(thetaBeam) * sin(phiBeam);
-   G4double  pzBe = cos(thetaBeam);
-
-    G4ThreeVector cDirection(pxBe,pyBe,pzBe);
-    direction=cDirection;
-
-  } else if (DirCode == 4 ) {
+    if (thetaBeam != 0.) {
+      phiBeam = acos(pxBeA / thetaBeam);
+      if (pyBeA < 0.)
+        phiBeam = -phiBeam;
+    }
+    G4double pxBe = sin(thetaBeam) * cos(phiBeam);
+    G4double pyBe = sin(thetaBeam) * sin(phiBeam);
+    G4double pzBe = cos(thetaBeam);
 
+    G4ThreeVector cDirection(pxBe, pyBe, pzBe);
+    direction = cDirection;
 
-    G4double aslpx=aBeamDirX/1.0;
-    G4double aslpy=aBeamDirY/1.0;
+  } else if (DirCode == 4) {
 
-   G4double rslpX = G4RandGauss::shoot( aslpx ,aBeamDiverX);
-   G4double rslpY = G4RandGauss::shoot( aslpy ,aBeamDiverY);
+    G4double aslpx = aBeamDirX / 1.0;
+    G4double aslpy = aBeamDirY / 1.0;
 
-   G4double rsfc = pow( (1.0+rslpX*rslpX+rslpY*rslpY),0.5);
-   G4double pxBe=0.0;  G4double pyBe=0.0;  G4double pzBe=1.0;
-   if( rsfc !=0.0) {
-       pzBe= 1.0/rsfc;
-       pxBe= rslpX/rsfc;
-       pyBe= rslpY/rsfc;
-   }
-   G4ThreeVector cDirection(pxBe,pyBe,pzBe);
-   direction=cDirection;
+    G4double rslpX = G4RandGauss::shoot(aslpx, aBeamDiverX);
+    G4double rslpY = G4RandGauss::shoot(aslpy, aBeamDiverY);
 
+    G4double rsfc = pow((1.0 + rslpX * rslpX + rslpY * rslpY), 0.5);
+    G4double pxBe = 0.0;
+    G4double pyBe = 0.0;
+    G4double pzBe = 1.0;
+    if (rsfc != 0.0) {
+      pzBe = 1.0 / rsfc;
+      pxBe = rslpX / rsfc;
+      pyBe = rslpY / rsfc;
+    }
+    G4ThreeVector cDirection(pxBe, pyBe, pzBe);
+    direction = cDirection;
   }
-   particleGun->SetParticleMomentumDirection(direction.unit());
+  particleGun->SetParticleMomentumDirection(direction.unit());
 
-   //G4cout<<" Current Beam direction is   "<<direction.x()
-   //   <<"    "<<direction.y()<<"    "<<direction.z()<<G4endl;
+  // G4cout<<" Current Beam direction is   "<<direction.x()
+  //   <<"    "<<direction.y()<<"    "<<direction.z()<<G4endl;
 
-   G4int patypa = rConfig->getRichTbParticleTypeCode();
+  G4int patypa = rConfig->getRichTbParticleTypeCode();
 
-  if(patypa == 1 ) {
-  G4double rand = G4UniformRand();
-  G4double phi = 2*M_PI*rand;
-  G4double sx= cos(phi);
-  G4double sy =sin(phi);
-  G4double sz=0.0;
-  G4ThreeVector polarization(sx,sy,sz);
+  if (patypa == 1) {
+    G4double rand = G4UniformRand();
+    G4double phi = 2 * M_PI * rand;
+    G4double sx = cos(phi);
+    G4double sy = sin(phi);
+    G4double sz = 0.0;
+    G4ThreeVector polarization(sx, sy, sz);
 
-  particleGun->SetParticlePolarization(polarization);
+    particleGun->SetParticlePolarization(polarization);
   }
   // store the beam direction for writeOut.
 
-  aBeamProperty-> setBeamDirection(direction);
-
-
+  aBeamProperty->setBeamDirection(direction);
 }
-
-