diff --git a/LHCbG4Tests/G4RichTbSimH/CMakeLists.txt b/LHCbG4Tests/G4RichTbSimH/CMakeLists.txt
new file mode 100644
index 0000000000000000000000000000000000000000..cbd3569aec352f6453d444383bf45e77a80fe0aa
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/CMakeLists.txt
@@ -0,0 +1,32 @@
+gaudi_subdir(G4RichTbSimH v1r0)
+
+gaudi_depends_on_subdirs(Geant4/G4config)
+
+find_package(CLHEP REQUIRED COMPONENTS Random)
+find_package(ROOT REQUIRED COMPONENTS Hist Tree)
+
+include_directories(${CMAKE_INSTALL_PREFIX}/include)
+link_directories(${CMAKE_INSTALL_PREFIX}/lib)
+
+set(Geant4_LIBRARIES
+    -lG4global
+    -lG4run
+    -lG4processes
+    -lG4event
+    -lG4vis_management
+    -lG4OpenGL
+    -lG4UIbasic
+    -lG4UIGAG)
+
+gaudi_add_executable(G4RichTbSimH
+        src/srcmain/RichTbSim.cc
+        src/srcgy/*.cc
+        src/srcev/*.cc
+        src/srcmn/*.cc
+        src/srcph/*.cc
+        src/srcgr/*.cc
+        src/srcG4/proc/*.cc
+  INCLUDE_DIRS include src/srcG4/includeG4 CLHEP ROOT
+  LINK_LIBRARIES CLHEP ROOT ${Geant4_LIBRARIES})
+
+add_dependencies(G4RichTbSimH Geant4)
diff --git a/LHCbG4Tests/G4RichTbSimH/InputData/EffJuraBottom100.txt b/LHCbG4Tests/G4RichTbSimH/InputData/EffJuraBottom100.txt
new file mode 100644
index 0000000000000000000000000000000000000000..515e217d6354013eb5839be9ab76e2130cae9807
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/InputData/EffJuraBottom100.txt
@@ -0,0 +1,129 @@
+PixelName,ClaroNumber,ClaroChanNumber,Efficiency
+JBB8,8,7,1.0
+JBB7,8,5,1.0
+JBB6,8,3,1.0
+JBB5,8,1,1.0
+JBB4,6,6,1.0
+JBB3,6,4,1.0
+JBB2,6,2,1.0
+JBB1,6,0,1.0
+JAB1,4,7,1.0
+JAB9,4,5,1.0
+JAB17,4,3,1.0
+JAB25,4,1,1.0
+JAB33,2,6,1.0
+JAB41,2,4,1.0
+JAB49,2,2,1.0
+JAB57,2,0,1.0
+JBB16,8,6,1.0
+JBB15,8,4,1.0
+JBB14,8,2,1.0
+JBB13,8,0,1.0
+JBB12,6,7,1.0
+JBB11,6,5,1.0
+JBB10,6,3,1.0
+JBB9,6,1,1.0
+JAB2,4,6,1.0
+JAB10,4,4,1.0
+JAB18,4,2,1.0
+JAB26,4,0,1.0
+JAB34,2,7,1.0
+JAB42,2,5,1.0
+JAB50,2,3,1.0
+JAB58,2,1,1.0
+JBB24,7,0,1.0
+JBB23,7,2,1.0
+JBB22,7,4,1.0
+JBB21,7,6,1.0
+JBB20,5,0,1.0
+JBB19,5,3,1.0
+JBB18,5,5,1.0
+JBB17,5,7,1.0
+JAB3,3,0,1.0
+JAB11,3,2,1.0
+JAB19,3,4,1.0
+JAB27,3,7,1.0
+JAB35,1,1,1.0
+JAB43,1,3,1.0
+JAB51,1,5,1.0
+JAB59,1,7,1.0
+JBB32,7,1,1.0
+JBB31,7,3,1.0
+JBB30,7,5,1.0
+JBB29,7,7,1.0
+JBB28,5,1,1.0
+JBB27,5,2,1.0
+JBB26,5,4,1.0
+JBB25,5,6,1.0
+JAB4,3,1,1.0
+JAB12,3,3,1.0
+JAB20,3,5,1.0
+JAB28,3,6,1.0
+JAB36,1,0,1.0
+JAB44,1,2,1.0
+JAB52,1,4,1.0
+JAB60,1,6,1.0
+JBB40,16,6,1.0
+JBB39,16,4,1.0
+JBB38,16,2,1.0
+JBB37,16,0,1.0
+JBB36,14,6,1.0
+JBB35,14,5,1.0
+JBB34,14,3,1.0
+JBB33,14,1,1.0
+JAB5,12,6,1.0
+JAB13,12,4,1.0
+JAB21,12,2,1.0
+JAB29,12,1,1.0
+JAB37,10,7,1.0
+JAB45,10,5,1.0
+JAB53,10,3,1.0
+JAB61,10,1,1.0
+JBB48,16,7,1.0
+JBB47,16,5,1.0
+JBB46,16,3,1.0
+JBB45,16,1,1.0
+JBB44,14,7,1.0
+JBB43,14,4,1.0
+JBB42,14,2,1.0
+JBB41,14,0,1.0
+JAB6,12,7,1.0
+JAB14,12,5,1.0
+JAB22,12,3,1.0
+JAB30,12,0,1.0
+JAB38,10,6,1.0
+JAB46,10,4,1.0
+JAB54,10,2,1.0
+JAB62,10,0,1.0
+JBB56,15,1,1.0
+JBB55,15,3,1.0
+JBB54,15,5,1.0
+JBB53,15,7,1.0
+JBB52,13,0,1.0
+JBB51,13,2,1.0
+JBB50,13,4,1.0
+JBB49,13,6,1.0
+JAB7,11,1,1.0
+JAB15,11,3,1.0
+JAB23,11,5,1.0
+JAB31,11,7,1.0
+JAB39,9,0,1.0
+JAB47,9,2,1.0
+JAB55,9,4,1.0
+JAB63,9,6,1.0
+JBB64,15,0,1.0
+JBB63,15,2,1.0
+JBB62,15,4,1.0
+JBB61,15,6,1.0
+JBB60,13,1,1.0
+JBB59,13,3,1.0
+JBB58,13,5,1.0
+JBB57,13,7,1.0
+JAB8,11,0,1.0
+JAB16,11,2,1.0
+JAB24,11,4,1.0
+JAB32,11,6,1.0
+JAB40,9,1,1.0
+JAB48,9,3,1.0
+JAB56,9,5,1.0
+JAB64,9,7,1.0
diff --git a/LHCbG4Tests/G4RichTbSimH/InputData/EffJuraOpt.txt b/LHCbG4Tests/G4RichTbSimH/InputData/EffJuraOpt.txt
new file mode 100644
index 0000000000000000000000000000000000000000..b66a0479362aaf97369fbd4fcdaa8aa45258c510
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/InputData/EffJuraOpt.txt
@@ -0,0 +1,129 @@
+PixelName,ClaroNumber,ClaroChanNumber,Efficiency
+JB8,8,7,0.897781239569867
+JB7,8,5,0.937757761754946
+JB6,8,3,0.993702859783627
+JB5,8,1,0.948457149998585
+JB4,6,6,0.997347973942565
+JB3,6,4,0.480893861397262
+JB2,6,2,0.972363336018235
+JB1,6,0,0.5217019422415
+JA1,4,7,0.935283632677445
+JA9,4,5,0.95526275289161
+JA17,4,3,0.974544951169403
+JA25,4,1,0.929697846458022
+JA33,2,6,0.958390088727188
+JA41,2,4,0.694767396746418
+JA49,2,2,0.982751749066466
+JA57,2,0,0.970424183818323
+JB16,8,6,0.892448346720941
+JB15,8,4,0.889501360883355
+JB14,8,2,0.960150503303867
+JB13,8,0,0.920622704717032
+JB12,6,7,0.455594566356437
+JB11,6,5,0.973566421983313
+JB10,6,3,0.961846783903156
+JB9,6,1,0.427548145303064
+JA2,4,6,0.991421909545267
+JA10,4,4,0.977733086611831
+JA18,4,2,0.956179593283795
+JA26,4,0,0.945128245089106
+JA34,2,7,0.944863010038677
+JA42,2,5,0.942917785620417
+JA50,2,3,0.972762456866381
+JA58,2,1,1.00000028665174
+JB24,7,0,0.751922928059998
+JB23,7,2,0.928698676365685
+JB22,7,4,0.90344578220701
+JB21,7,6,0.974844467578798
+JB20,5,0,0.971200988498757
+JB19,5,3,0.939774612124283
+JB18,5,5,0.994502396199944
+JB17,5,7,0.955015402069043
+JA3,3,0,0.999965530010539
+JA11,3,2,0.993375696254047
+JA19,3,4,0.997060769190477
+JA27,3,7,0.500408277772461
+JA35,1,1,0.955103327882447
+JA43,1,3,0.840393397094676
+JA51,1,5,1.00000028665174
+JA59,1,7,0.909853239318748
+JB32,7,1,0.995611307511238
+JB31,7,3,0.999125712845934
+JB30,7,5,0.999740420210567
+JB29,7,7,0.991561090730543
+JB28,5,1,0.99596341639502
+JB27,5,2,0.969270297077115
+JB26,5,4,0.975951022927677
+JB25,5,6,0.972084727889169
+JA4,3,1,0.943919892217273
+JA12,3,3,0.999679969261329
+JA20,3,5,0.967468850157453
+JA28,3,6,0.955953207359095
+JA36,1,0,0.972864346070722
+JA44,1,2,0.916212271452709
+JA52,1,4,0.971741806201861
+JA60,1,6,0.974974212919028
+JB40,16,6,0.999915144305539
+JB39,16,4,0.999729380770563
+JB38,16,2,1.00000013282644
+JB37,16,0,0.537529682746424
+JB36,14,6,0.958119683069587
+JB35,14,5,0.971075965522791
+JB34,14,3,1.00000028665165
+JB33,14,1,0.999999586839577
+JA5,12,6,0.916014035449507
+JA13,12,4,0.624828222927313
+JA21,12,2,0.897487829228482
+JA29,12,1,0.879498126108906
+JA37,10,7,0.9208210629855
+JA45,10,5,0.999972638085184
+JA53,10,3,0.977849131749444
+JA61,10,1,0.949242243787101
+JB48,16,7,0.639524043283098
+JB47,16,5,0.926782750667149
+JB46,16,3,0.961969339245005
+JB45,16,1,0.983344223309454
+JB44,14,7,0.969168181821702
+JB43,14,4,0.999999965644794
+JB42,14,2,0.979658301204437
+JB41,14,0,0.865365836205939
+JA6,12,7,0.914605944540441
+JA14,12,5,0.700746608217464
+JA22,12,3,0.71786271699439
+JA30,12,0,0.818346494834048
+JA38,10,6,0.994361429094978
+JA46,10,4,0.910113035288444
+JA54,10,2,0.999999826470514
+JA62,10,0,1.00000028521963
+JB56,15,1,0.995817735156724
+JB55,15,3,0.989768017427792
+JB54,15,5,0.962434887764838
+JB53,15,7,0.986307645393519
+JB52,13,0,0.999997377614446
+JB51,13,2,0.981679828751434
+JB50,13,4,0.9995593195762
+JB49,13,6,0.971231492357077
+JA7,11,1,0.756489611771108
+JA15,11,3,0.873266237111017
+JA23,11,5,0.926655789948853
+JA31,11,7,0.990527272728344
+JA39,9,0,0.50117463661614
+JA47,9,2,0.963214376420841
+JA55,9,4,0.992776842213362
+JA63,9,6,0.993418266595117
+JB64,15,0,0.77058762520201
+JB63,15,2,0.972224389732796
+JB62,15,4,0.998896416578486
+JB61,15,6,0.801042632830848
+JB60,13,1,0.946272024977831
+JB59,13,3,0.78772541725041
+JB58,13,5,0.960353389185923
+JB57,13,7,0.999598328488866
+JA8,11,0,0.571887874083041
+JA16,11,2,0.613642706278049
+JA24,11,4,0.806778556125345
+JA32,11,6,0.889372634711821
+JA40,9,1,0.891381627886012
+JA48,9,3,0.998566516464377
+JA56,9,5,0.991310361946143
+JA64,9,7,0.986359478056764
diff --git a/LHCbG4Tests/G4RichTbSimH/InputData/EffJuraOpt_upgradeDummy.txt b/LHCbG4Tests/G4RichTbSimH/InputData/EffJuraOpt_upgradeDummy.txt
new file mode 100644
index 0000000000000000000000000000000000000000..59415d2588944d7ca6fb882631d50aa46e9480c5
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/InputData/EffJuraOpt_upgradeDummy.txt
@@ -0,0 +1,129 @@
+PixelName,ClaroNumber,ClaroChanNumber,Efficiency
+JBB8,8,7,0.897781239569867
+JBB7,8,5,0.937757761754946
+JBB6,8,3,0.993702859783627
+JBB5,8,1,0.948457149998585
+JBB4,6,6,0.997347973942565
+JBB3,6,4,0.480893861397262
+JBB2,6,2,0.972363336018235
+JBB1,6,0,0.5217019422415
+JAB1,4,7,0.935283632677445
+JAB9,4,5,0.95526275289161
+JAB17,4,3,0.974544951169403
+JAB25,4,1,0.929697846458022
+JAB33,2,6,0.958390088727188
+JAB41,2,4,0.694767396746418
+JAB49,2,2,0.982751749066466
+JAB57,2,0,0.970424183818323
+JBB16,8,6,0.892448346720941
+JBB15,8,4,0.889501360883355
+JBB14,8,2,0.960150503303867
+JBB13,8,0,0.920622704717032
+JBB12,6,7,0.455594566356437
+JBB11,6,5,0.973566421983313
+JBB10,6,3,0.961846783903156
+JBB9,6,1,0.427548145303064
+JAB2,4,6,0.991421909545267
+JAB10,4,4,0.977733086611831
+JAB18,4,2,0.956179593283795
+JAB26,4,0,0.945128245089106
+JAB34,2,7,0.944863010038677
+JAB42,2,5,0.942917785620417
+JAB50,2,3,0.972762456866381
+JAB58,2,1,1.00000028665174
+JBB24,7,0,0.751922928059998
+JBB23,7,2,0.928698676365685
+JBB22,7,4,0.90344578220701
+JBB21,7,6,0.974844467578798
+JBB20,5,0,0.971200988498757
+JBB19,5,3,0.939774612124283
+JBB18,5,5,0.994502396199944
+JBB17,5,7,0.955015402069043
+JAB3,3,0,0.999965530010539
+JAB11,3,2,0.993375696254047
+JAB19,3,4,0.997060769190477
+JAB27,3,7,0.500408277772461
+JAB35,1,1,0.955103327882447
+JAB43,1,3,0.840393397094676
+JAB51,1,5,1.00000028665174
+JAB59,1,7,0.909853239318748
+JBB32,7,1,0.995611307511238
+JBB31,7,3,0.999125712845934
+JBB30,7,5,0.999740420210567
+JBB29,7,7,0.991561090730543
+JBB28,5,1,0.99596341639502
+JBB27,5,2,0.969270297077115
+JBB26,5,4,0.975951022927677
+JBB25,5,6,0.972084727889169
+JAB4,3,1,0.943919892217273
+JAB12,3,3,0.999679969261329
+JAB20,3,5,0.967468850157453
+JAB28,3,6,0.955953207359095
+JAB36,1,0,0.972864346070722
+JAB44,1,2,0.916212271452709
+JAB52,1,4,0.971741806201861
+JAB60,1,6,0.974974212919028
+JBB40,16,6,0.999915144305539
+JBB39,16,4,0.999729380770563
+JBB38,16,2,1.00000013282644
+JBB37,16,0,0.537529682746424
+JBB36,14,6,0.958119683069587
+JBB35,14,5,0.971075965522791
+JBB34,14,3,1.00000028665165
+JBB33,14,1,0.999999586839577
+JAB5,12,6,0.916014035449507
+JAB13,12,4,0.624828222927313
+JAB21,12,2,0.897487829228482
+JAB29,12,1,0.879498126108906
+JAB37,10,7,0.9208210629855
+JAB45,10,5,0.999972638085184
+JAB53,10,3,0.977849131749444
+JAB61,10,1,0.949242243787101
+JBB48,16,7,0.639524043283098
+JBB47,16,5,0.926782750667149
+JBB46,16,3,0.961969339245005
+JBB45,16,1,0.983344223309454
+JBB44,14,7,0.969168181821702
+JBB43,14,4,0.999999965644794
+JBB42,14,2,0.979658301204437
+JBB41,14,0,0.865365836205939
+JAB6,12,7,0.914605944540441
+JAB14,12,5,0.700746608217464
+JAB22,12,3,0.71786271699439
+JAB30,12,0,0.818346494834048
+JAB38,10,6,0.994361429094978
+JAB46,10,4,0.910113035288444
+JAB54,10,2,0.999999826470514
+JAB62,10,0,1.00000028521963
+JBB56,15,1,0.995817735156724
+JBB55,15,3,0.989768017427792
+JBB54,15,5,0.962434887764838
+JBB53,15,7,0.986307645393519
+JBB52,13,0,0.999997377614446
+JBB51,13,2,0.981679828751434
+JBB50,13,4,0.9995593195762
+JBB49,13,6,0.971231492357077
+JAB7,11,1,0.756489611771108
+JAB15,11,3,0.873266237111017
+JAB23,11,5,0.926655789948853
+JAB31,11,7,0.990527272728344
+JAB39,9,0,0.50117463661614
+JAB47,9,2,0.963214376420841
+JAB55,9,4,0.992776842213362
+JAB63,9,6,0.993418266595117
+JBB64,15,0,0.77058762520201
+JBB63,15,2,0.972224389732796
+JBB62,15,4,0.998896416578486
+JBB61,15,6,0.801042632830848
+JBB60,13,1,0.946272024977831
+JBB59,13,3,0.78772541725041
+JBB58,13,5,0.960353389185923
+JBB57,13,7,0.999598328488866
+JAB8,11,0,0.571887874083041
+JAB16,11,2,0.613642706278049
+JAB24,11,4,0.806778556125345
+JAB32,11,6,0.889372634711821
+JAB40,9,1,0.891381627886012
+JAB48,9,3,0.998566516464377
+JAB56,9,5,0.991310361946143
+JAB64,9,7,0.986359478056764
diff --git a/LHCbG4Tests/G4RichTbSimH/InputData/EffJuraThr7.txt b/LHCbG4Tests/G4RichTbSimH/InputData/EffJuraThr7.txt
new file mode 100644
index 0000000000000000000000000000000000000000..79f39ecdd51cf0434ad683380e58645e4d547d41
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/InputData/EffJuraThr7.txt
@@ -0,0 +1,129 @@
+PixelName,ClaroNumber,ClaroChanNumber,Efficiency
+JB8,8,7,0.980822217737675
+JB7,8,5,0.985629806993064
+JB6,8,3,0.994919116760028
+JB5,8,1,0.978726493068799
+JB4,6,6,0.998230784736996
+JB3,6,4,0.480893861397262
+JB2,6,2,0.99638969945665
+JB1,6,0,0.52217868595549
+JA1,4,7,0.98306820851727
+JA9,4,5,0.987602621254564
+JA17,4,3,0.983997186808599
+JA25,4,1,0.966226384666654
+JA33,2,6,0.97792804175986
+JA41,2,4,0.709005537870474
+JA49,2,2,0.98840497857606
+JA57,2,0,0.99895556271341
+JB16,8,6,0.964421822265921
+JB15,8,4,0.935384688005462
+JB14,8,2,0.994439136055962
+JB13,8,0,0.927353354732708
+JB12,6,7,0.455594566356437
+JB11,6,5,0.998196247641377
+JB10,6,3,0.992047549865031
+JB9,6,1,0.427548145303064
+JA2,4,6,0.996513598730344
+JA10,4,4,0.998455476558349
+JA18,4,2,0.992188110024489
+JA26,4,0,0.981975574278006
+JA34,2,7,0.981969846787409
+JA42,2,5,0.986183621175614
+JA50,2,3,0.996531956264745
+JA58,2,1,1.00000028665175
+JB24,7,0,0.751922928059998
+JB23,7,2,0.976752562763142
+JB22,7,4,0.95914727750003
+JB21,7,6,0.998676219767619
+JB20,5,0,0.99716021892103
+JB19,5,3,0.979262700674157
+JB18,5,5,0.997354424059633
+JB17,5,7,0.990159410863723
+JA3,3,0,0.999965530010539
+JA11,3,2,0.995472699988398
+JA19,3,4,0.997863012700613
+JA27,3,7,0.50112924349832
+JA35,1,1,0.989200615536787
+JA43,1,3,0.889745826282643
+JA51,1,5,1.00000028665175
+JA59,1,7,0.977059904522896
+JB32,7,1,0.997747474450589
+JB31,7,3,0.999125712845934
+JB30,7,5,0.999740420210567
+JB29,7,7,0.996094478066933
+JB28,5,1,0.999533791350886
+JB27,5,2,0.995683421136232
+JB26,5,4,0.998389685670147
+JB25,5,6,0.994569678491648
+JA4,3,1,0.976861211150768
+JA12,3,3,0.999809731103978
+JA20,3,5,0.98673714869319
+JA28,3,6,0.978776939465194
+JA36,1,0,0.972864346070722
+JA44,1,2,0.938487184579877
+JA52,1,4,0.971741806201861
+JA60,1,6,0.997062996758093
+JB40,16,6,0.999915144305539
+JB39,16,4,0.999729380770563
+JB38,16,2,1.00000013282644
+JB37,16,0,0.554367694119379
+JB36,14,6,0.98930074317933
+JB35,14,5,0.995996316300024
+JB34,14,3,1.00000028665165
+JB33,14,1,0.999999586839577
+JA5,12,6,0.969544090063806
+JA13,12,4,0.803116260882809
+JA21,12,2,0.959607852081113
+JA29,12,1,0.951966795333291
+JA37,10,7,0.978751190389937
+JA45,10,5,0.999972638085184
+JA53,10,3,0.990981535560117
+JA61,10,1,0.993883195265427
+JB48,16,7,0.639809315068529
+JB47,16,5,0.988860087100096
+JB46,16,3,0.998387064446274
+JB45,16,1,0.998628961342779
+JB44,14,7,0.969168181821702
+JB43,14,4,0.999999965644794
+JB42,14,2,0.999232392871238
+JB41,14,0,0.937741774707613
+JA6,12,7,0.985888787835838
+JA14,12,5,0.792627882311062
+JA22,12,3,0.874819185175485
+JA30,12,0,0.942765068592775
+JA38,10,6,0.997995648359704
+JA46,10,4,0.974704411920792
+JA54,10,2,0.999999826470514
+JA62,10,0,1.00000028521963
+JB56,15,1,0.997278433567369
+JB55,15,3,0.994462381058943
+JB54,15,5,0.995227794533945
+JB53,15,7,0.989255334255761
+JB52,13,0,0.999997377614446
+JB51,13,2,0.999449766418428
+JB50,13,4,0.999700870409122
+JB49,13,6,0.998174403128301
+JA7,11,1,0.886915531632556
+JA15,11,3,0.998774643938901
+JA23,11,5,0.942447322099635
+JA31,11,7,0.997257858433498
+JA39,9,0,0.501219884200767
+JA47,9,2,0.996009087591077
+JA55,9,4,0.999444741597271
+JA63,9,6,0.999989706473051
+JB64,15,0,0.779465069301117
+JB63,15,2,0.996349160409961
+JB62,15,4,0.999431357046365
+JB61,15,6,0.989097061223666
+JB60,13,1,0.991964994275551
+JB59,13,3,0.983196062518381
+JB58,13,5,0.995825708439149
+JB57,13,7,0.999598328488866
+JA8,11,0,0.859795201935204
+JA16,11,2,0.792982929978584
+JA24,11,4,0.92094432992881
+JA32,11,6,0.987643083829806
+JA40,9,1,1.00000028663367
+JA48,9,3,0.999986728859493
+JA56,9,5,0.999937976420474
+JA64,9,7,0.999751714483191
diff --git a/LHCbG4Tests/G4RichTbSimH/InputData/EffJuraTop100.txt b/LHCbG4Tests/G4RichTbSimH/InputData/EffJuraTop100.txt
new file mode 100644
index 0000000000000000000000000000000000000000..9f12af4e1308cc608b10973768613d4706837c6a
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/InputData/EffJuraTop100.txt
@@ -0,0 +1,129 @@
+PixelName,ClaroNumber,ClaroChanNumber,Efficiency
+JB8,8,7,1.0
+JB7,8,5,1.0
+JB6,8,3,1.0
+JB5,8,1,1.0
+JB4,6,6,1.0
+JB3,6,4,1.0
+JB2,6,2,1.0
+JB1,6,0,1.0
+JA1,4,7,1.0
+JA9,4,5,1.0
+JA17,4,3,1.0
+JA25,4,1,1.0
+JA33,2,6,1.0
+JA41,2,4,1.0
+JA49,2,2,1.0
+JA57,2,0,1.0
+JB16,8,6,1.0
+JB15,8,4,1.0
+JB14,8,2,1.0
+JB13,8,0,1.0
+JB12,6,7,1.0
+JB11,6,5,1.0
+JB10,6,3,1.0
+JB9,6,1,1.0
+JA2,4,6,1.0
+JA10,4,4,1.0
+JA18,4,2,1.0
+JA26,4,0,1.0
+JA34,2,7,1.0
+JA42,2,5,1.0
+JA50,2,3,1.0
+JA58,2,1,1.0
+JB24,7,0,1.0
+JB23,7,2,1.0
+JB22,7,4,1.0
+JB21,7,6,1.0
+JB20,5,0,1.0
+JB19,5,3,1.0
+JB18,5,5,1.0
+JB17,5,7,1.0
+JA3,3,0,1.0
+JA11,3,2,1.0
+JA19,3,4,1.0
+JA27,3,7,1.0
+JA35,1,1,1.0
+JA43,1,3,1.0
+JA51,1,5,1.0
+JA59,1,7,1.0
+JB32,7,1,1.0
+JB31,7,3,1.0
+JB30,7,5,1.0
+JB29,7,7,1.0
+JB28,5,1,1.0
+JB27,5,2,1.0
+JB26,5,4,1.0
+JB25,5,6,1.0
+JA4,3,1,1.0
+JA12,3,3,1.0
+JA20,3,5,1.0
+JA28,3,6,1.0
+JA36,1,0,1.0
+JA44,1,2,1.0
+JA52,1,4,1.0
+JA60,1,6,1.0
+JB40,16,6,1.0
+JB39,16,4,1.0
+JB38,16,2,1.0
+JB37,16,0,1.0
+JB36,14,6,1.0
+JB35,14,5,1.0
+JB34,14,3,1.0
+JB33,14,1,1.0
+JA5,12,6,1.0
+JA13,12,4,1.0
+JA21,12,2,1.0
+JA29,12,1,1.0
+JA37,10,7,1.0
+JA45,10,5,1.0
+JA53,10,3,1.0
+JA61,10,1,1.0
+JB48,16,7,1.0
+JB47,16,5,1.0
+JB46,16,3,1.0
+JB45,16,1,1.0
+JB44,14,7,1.0
+JB43,14,4,1.0
+JB42,14,2,1.0
+JB41,14,0,1.0
+JA6,12,7,1.0
+JA14,12,5,1.0
+JA22,12,3,1.0
+JA30,12,0,1.0
+JA38,10,6,1.0
+JA46,10,4,1.0
+JA54,10,2,1.0
+JA62,10,0,1.0
+JB56,15,1,1.0
+JB55,15,3,1.0
+JB54,15,5,1.0
+JB53,15,7,1.0
+JB52,13,0,1.0
+JB51,13,2,1.0
+JB50,13,4,1.0
+JB49,13,6,1.0
+JA7,11,1,1.0
+JA15,11,3,1.0
+JA23,11,5,1.0
+JA31,11,7,1.0
+JA39,9,0,1.0
+JA47,9,2,1.0
+JA55,9,4,1.0
+JA63,9,6,1.0
+JB64,15,0,1.0
+JB63,15,2,1.0
+JB62,15,4,1.0
+JB61,15,6,1.0
+JB60,13,1,1.0
+JB59,13,3,1.0
+JB58,13,5,1.0
+JB57,13,7,1.0
+JA8,11,0,1.0
+JA16,11,2,1.0
+JA24,11,4,1.0
+JA32,11,6,1.0
+JA40,9,1,1.0
+JA48,9,3,1.0
+JA56,9,5,1.0
+JA64,9,7,1.0
diff --git a/LHCbG4Tests/G4RichTbSimH/InputData/EffSaleveBottom100.txt b/LHCbG4Tests/G4RichTbSimH/InputData/EffSaleveBottom100.txt
new file mode 100644
index 0000000000000000000000000000000000000000..fc52ed1a471b6d555186d108aa4386c35a300e3d
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/InputData/EffSaleveBottom100.txt
@@ -0,0 +1,129 @@
+PixelName,ClaroNumber,ClaroChanNumber,Efficiency
+SAB8,8,7,1.0
+SAB7,8,5,1.0
+SAB6,8,3,1.0
+SAB5,8,1,1.0
+SAB4,6,6,1.0
+SAB3,6,4,1.0
+SAB2,6,2,1.0
+SAB1,6,0,1.0
+SBB1,4,7,1.0
+SBB9,4,5,1.0
+SBB17,4,3,1.0
+SBB25,4,1,1.0
+SBB33,2,6,1.0
+SBB41,2,4,1.0
+SBB49,2,2,1.0
+SBB57,2,0,1.0
+SAB16,8,6,1.0
+SAB15,8,4,1.0
+SAB14,8,2,1.0
+SAB13,8,0,1.0
+SAB12,6,7,1.0
+SAB11,6,5,1.0
+SAB10,6,3,1.0
+SAB9,6,1,1.0
+SBB2,4,6,1.0
+SBB10,4,4,1.0
+SBB18,4,2,1.0
+SBB26,4,0,1.0
+SBB34,2,7,1.0
+SBB42,2,5,1.0
+SBB50,2,3,1.0
+SBB58,2,1,1.0
+SAB24,7,0,1.0
+SAB23,7,2,1.0
+SAB22,7,4,1.0
+SAB21,7,6,1.0
+SAB20,5,0,1.0
+SAB19,5,3,1.0
+SAB18,5,5,1.0
+SAB17,5,7,1.0
+SBB3,3,0,1.0
+SBB11,3,2,1.0
+SBB19,3,4,1.0
+SBB27,3,7,1.0
+SBB35,1,1,1.0
+SBB43,1,3,1.0
+SBB51,1,5,1.0
+SBB59,1,7,1.0
+SAB32,7,1,1.0
+SAB31,7,3,1.0
+SAB30,7,5,1.0
+SAB29,7,7,1.0
+SAB28,5,1,1.0
+SAB27,5,2,1.0
+SAB26,5,4,1.0
+SAB25,5,6,1.0
+SBB4,3,1,1.0
+SBB12,3,3,1.0
+SBB20,3,5,1.0
+SBB28,3,6,1.0
+SBB36,1,0,1.0
+SBB44,1,2,1.0
+SBB52,1,4,1.0
+SBB60,1,6,1.0
+SAB40,16,6,1.0
+SAB39,16,4,1.0
+SAB38,16,2,1.0
+SAB37,16,0,1.0
+SAB36,14,6,1.0
+SAB35,14,5,1.0
+SAB34,14,3,1.0
+SAB33,14,1,1.0
+SBB5,12,6,1.0
+SBB13,12,4,1.0
+SBB21,12,2,1.0
+SBB29,12,1,1.0
+SBB37,10,7,1.0
+SBB45,10,5,1.0
+SBB53,10,3,1.0
+SBB61,10,1,1.0
+SAB48,16,7,1.0
+SAB47,16,5,1.0
+SAB46,16,3,1.0
+SAB45,16,1,1.0
+SAB44,14,7,1.0
+SAB43,14,4,1.0
+SAB42,14,2,1.0
+SAB41,14,0,1.0
+SBB6,12,7,1.0
+SBB14,12,5,1.0
+SBB22,12,3,1.0
+SBB30,12,0,1.0
+SBB38,10,6,1.0
+SBB46,10,4,1.0
+SBB54,10,2,1.0
+SBB62,10,0,1.0
+SAB56,15,1,1.0
+SAB55,15,3,1.0
+SAB54,15,5,1.0
+SAB53,15,7,1.0
+SAB52,13,0,1.0
+SAB51,13,2,1.0
+SAB50,13,4,1.0
+SAB49,13,6,1.0
+SBB7,11,1,1.0
+SBB15,11,3,1.0
+SBB23,11,5,1.0
+SBB31,11,7,1.0
+SBB39,9,0,1.0
+SBB47,9,2,1.0
+SBB55,9,4,1.0
+SBB63,9,6,1.0
+SAB64,15,0,1.0
+SAB63,15,2,1.0
+SAB62,15,4,1.0
+SAB61,15,6,1.0
+SAB60,13,1,1.0
+SAB59,13,3,1.0
+SAB58,13,5,1.0
+SAB57,13,7,1.0
+SBB8,11,0,1.0
+SBB16,11,2,1.0
+SBB24,11,4,1.0
+SBB32,11,6,1.0
+SBB40,9,1,1.0
+SBB48,9,3,1.0
+SBB56,9,5,1.0
+SBB64,9,7,1.0
diff --git a/LHCbG4Tests/G4RichTbSimH/InputData/EffSaleveOpt.txt b/LHCbG4Tests/G4RichTbSimH/InputData/EffSaleveOpt.txt
new file mode 100644
index 0000000000000000000000000000000000000000..1e50ef4ee299693c76e41abdf3f98282f0eb56c9
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/InputData/EffSaleveOpt.txt
@@ -0,0 +1,129 @@
+PixelName,ClaroNumber,ClaroChanNumber,Efficiency
+SA8,8,7,0.999560013933973
+SA7,8,5,0.999769528623767
+SA6,8,3,1.00000028663178
+SA5,8,1,0.99980892612981
+SA4,6,6,0.869362462829479
+SA3,6,4,0.972590551074841
+SA2,6,2,0.997008764546396
+SA1,6,0,0.931720538355074
+SB1,4,7,0.992987430864402
+SB9,4,5,0.956286024482332
+SB17,4,3,0.999632275015327
+SB25,4,1,0.999461369718004
+SB33,2,6,0.978218487451243
+SB41,2,4,0.958216462886649
+SB49,2,2,1.000000286637
+SB57,2,0,0.947493817405178
+SA16,8,6,0.955253379596571
+SA15,8,4,0.997820586612946
+SA14,8,2,0.978207627637638
+SA13,8,0,0.998474177102202
+SA12,6,7,0.997523620599892
+SA11,6,5,0.999483422656953
+SA10,6,3,0.983780881464923
+SA9,6,1,0.986577862261211
+SB2,4,6,0.945935882084671
+SB10,4,4,0.939017835537793
+SB18,4,2,1.00000028665174
+SB26,4,0,0.899089785299179
+SB34,2,7,0.977487892168379
+SB42,2,5,0.923782688885066
+SB50,2,3,0.977683358678738
+SB58,2,1,0.956253130992381
+SA24,7,0,0.993819465365567
+SA23,7,2,0.972018869519341
+SA22,7,4,0.968648476479469
+SA21,7,6,0.716658951217431
+SA20,5,0,0.861815313130322
+SA19,5,3,0.967157162091805
+SA18,5,5,0.851810975201035
+SA17,5,7,0.939840736817279
+SB3,3,0,0.998166977612879
+SB11,3,2,0.99985380449213
+SB19,3,4,0.994475653836762
+SB27,3,7,0.999954445728983
+SB35,1,1,0.896597826104844
+SB43,1,3,1.00000028381553
+SB51,1,5,0.839373399726239
+SB59,1,7,0.364971748172486
+SA32,7,1,0.996538164961537
+SA31,7,3,0.789170913256283
+SA30,7,5,0.969128617132342
+SA29,7,7,0.977292228645615
+SA28,5,1,0.954679948549124
+SA27,5,2,0.998601994045195
+SA26,5,4,0.973797440465936
+SA25,5,6,0.999612989137414
+SB4,3,1,0.439469382801636
+SB12,3,3,0.955031973888798
+SB20,3,5,0.906341005975514
+SB28,3,6,0.999682091789736
+SB36,1,0,0.951967647880388
+SB44,1,2,0.772150636529801
+SB52,1,4,0.940435628029568
+SB60,1,6,0.872276579978948
+SA40,16,6,0.933944955585704
+SA39,16,4,0.398162731644494
+SA38,16,2,0.999558421943878
+SA37,16,0,0.748472092311728
+SA36,14,6,0.933101719359828
+SA35,14,5,0.938701490575451
+SA34,14,3,0.769294585461833
+SA33,14,1,0.870120367133116
+SB5,12,6,1.00000028582749
+SB13,12,4,0.384871690743696
+SB21,12,2,0.969961496943915
+SB29,12,1,0.894684187295863
+SB37,10,7,0.731300446756775
+SB45,10,5,0.62846918640167
+SB53,10,3,0.978232694165421
+SB61,10,1,0.981167863297551
+SA48,16,7,0.925634185134038
+SA47,16,5,0.979775206385928
+SA46,16,3,0.958160216304319
+SA45,16,1,0.985459044118786
+SA44,14,7,0.829537724610662
+SA43,14,4,0.781992251321654
+SA42,14,2,0.710001929163965
+SA41,14,0,0.982337290795909
+SB6,12,7,0.920191471151598
+SB14,12,5,1.00000028665174
+SB22,12,3,0.94740937508839
+SB30,12,0,0.932522271287258
+SB38,10,6,0.935606379866368
+SB46,10,4,0.999999146956372
+SB54,10,2,1.00000028665174
+SB62,10,0,0.967868252909376
+SA56,15,1,1.00000028665174
+SA55,15,3,1.00000028665174
+SA54,15,5,1.00000028665174
+SA53,15,7,1.00000028665174
+SA52,13,0,1.00000028665174
+SA51,13,2,0.974452843126998
+SA50,13,4,0.991738138967988
+SA49,13,6,0.885007502041414
+SB7,11,1,0.985450665901887
+SB15,11,3,0.91191441820477
+SB23,11,5,0.905254625586531
+SB31,11,7,1.00000027907067
+SB39,9,0,1.00000026565382
+SB47,9,2,0.989386508458801
+SB55,9,4,0.957187827555552
+SB63,9,6,0.841373875486352
+SA64,15,0,1.00000028665174
+SA63,15,2,1.00000028665174
+SA62,15,4,1.00000028656399
+SA61,15,6,1.00000028665174
+SA60,13,1,0.872844365140019
+SA59,13,3,0.996033680485157
+SA58,13,5,0.994808457393156
+SA57,13,7,0.998386892506374
+SB8,11,0,0.972284467486095
+SB16,11,2,0.769561421011328
+SB24,11,4,0.851374823601735
+SB32,11,6,0.987333151404578
+SB40,9,1,0.975158324586857
+SB48,9,3,0.967378938589373
+SB56,9,5,0.960564538823142
+SB64,9,7,0.999973063079098
diff --git a/LHCbG4Tests/G4RichTbSimH/InputData/EffSaleveOpt_upgradeDummy.txt b/LHCbG4Tests/G4RichTbSimH/InputData/EffSaleveOpt_upgradeDummy.txt
new file mode 100644
index 0000000000000000000000000000000000000000..45ea59084ae9ced4081c32abb8102ef02ed4eeca
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/InputData/EffSaleveOpt_upgradeDummy.txt
@@ -0,0 +1,129 @@
+PixelName,ClaroNumber,ClaroChanNumber,Efficiency
+SAB8,8,7,0.999560013933973
+SAB7,8,5,0.999769528623767
+SAB6,8,3,1.00000028663178
+SAB5,8,1,0.99980892612981
+SAB4,6,6,0.869362462829479
+SAB3,6,4,0.972590551074841
+SAB2,6,2,0.997008764546396
+SAB1,6,0,0.931720538355074
+SBB1,4,7,0.992987430864402
+SBB9,4,5,0.956286024482332
+SBB17,4,3,0.999632275015327
+SBB25,4,1,0.999461369718004
+SBB33,2,6,0.978218487451243
+SBB41,2,4,0.958216462886649
+SBB49,2,2,1.000000286637
+SBB57,2,0,0.947493817405178
+SAB16,8,6,0.955253379596571
+SAB15,8,4,0.997820586612946
+SAB14,8,2,0.978207627637638
+SAB13,8,0,0.998474177102202
+SAB12,6,7,0.997523620599892
+SAB11,6,5,0.999483422656953
+SAB10,6,3,0.983780881464923
+SAB9,6,1,0.986577862261211
+SBB2,4,6,0.945935882084671
+SBB10,4,4,0.939017835537793
+SBB18,4,2,1.00000028665174
+SBB26,4,0,0.899089785299179
+SBB34,2,7,0.977487892168379
+SBB42,2,5,0.923782688885066
+SBB50,2,3,0.977683358678738
+SBB58,2,1,0.956253130992381
+SAB24,7,0,0.993819465365567
+SAB23,7,2,0.972018869519341
+SAB22,7,4,0.968648476479469
+SAB21,7,6,0.716658951217431
+SAB20,5,0,0.861815313130322
+SAB19,5,3,0.967157162091805
+SAB18,5,5,0.851810975201035
+SAB17,5,7,0.939840736817279
+SBB3,3,0,0.998166977612879
+SBB11,3,2,0.99985380449213
+SBB19,3,4,0.994475653836762
+SBB27,3,7,0.999954445728983
+SBB35,1,1,0.896597826104844
+SBB43,1,3,1.00000028381553
+SBB51,1,5,0.839373399726239
+SBB59,1,7,0.364971748172486
+SAB32,7,1,0.996538164961537
+SAB31,7,3,0.789170913256283
+SAB30,7,5,0.969128617132342
+SAB29,7,7,0.977292228645615
+SAB28,5,1,0.954679948549124
+SAB27,5,2,0.998601994045195
+SAB26,5,4,0.973797440465936
+SAB25,5,6,0.999612989137414
+SBB4,3,1,0.439469382801636
+SBB12,3,3,0.955031973888798
+SBB20,3,5,0.906341005975514
+SBB28,3,6,0.999682091789736
+SBB36,1,0,0.951967647880388
+SBB44,1,2,0.772150636529801
+SBB52,1,4,0.940435628029568
+SBB60,1,6,0.872276579978948
+SAB40,16,6,0.933944955585704
+SAB39,16,4,0.398162731644494
+SAB38,16,2,0.999558421943878
+SAB37,16,0,0.748472092311728
+SAB36,14,6,0.933101719359828
+SAB35,14,5,0.938701490575451
+SAB34,14,3,0.769294585461833
+SAB33,14,1,0.870120367133116
+SBB5,12,6,1.00000028582749
+SBB13,12,4,0.384871690743696
+SBB21,12,2,0.969961496943915
+SBB29,12,1,0.894684187295863
+SBB37,10,7,0.731300446756775
+SBB45,10,5,0.62846918640167
+SBB53,10,3,0.978232694165421
+SBB61,10,1,0.981167863297551
+SAB48,16,7,0.925634185134038
+SAB47,16,5,0.979775206385928
+SAB46,16,3,0.958160216304319
+SAB45,16,1,0.985459044118786
+SAB44,14,7,0.829537724610662
+SAB43,14,4,0.781992251321654
+SAB42,14,2,0.710001929163965
+SAB41,14,0,0.982337290795909
+SBB6,12,7,0.920191471151598
+SBB14,12,5,1.00000028665174
+SBB22,12,3,0.94740937508839
+SBB30,12,0,0.932522271287258
+SBB38,10,6,0.935606379866368
+SBB46,10,4,0.999999146956372
+SBB54,10,2,1.00000028665174
+SBB62,10,0,0.967868252909376
+SAB56,15,1,1.00000028665174
+SAB55,15,3,1.00000028665174
+SAB54,15,5,1.00000028665174
+SAB53,15,7,1.00000028665174
+SAB52,13,0,1.00000028665174
+SAB51,13,2,0.974452843126998
+SAB50,13,4,0.991738138967988
+SAB49,13,6,0.885007502041414
+SBB7,11,1,0.985450665901887
+SBB15,11,3,0.91191441820477
+SBB23,11,5,0.905254625586531
+SBB31,11,7,1.00000027907067
+SBB39,9,0,1.00000026565382
+SBB47,9,2,0.989386508458801
+SBB55,9,4,0.957187827555552
+SBB63,9,6,0.841373875486352
+SAB64,15,0,1.00000028665174
+SAB63,15,2,1.00000028665174
+SAB62,15,4,1.00000028656399
+SAB61,15,6,1.00000028665174
+SAB60,13,1,0.872844365140019
+SAB59,13,3,0.996033680485157
+SAB58,13,5,0.994808457393156
+SAB57,13,7,0.998386892506374
+SBB8,11,0,0.972284467486095
+SBB16,11,2,0.769561421011328
+SBB24,11,4,0.851374823601735
+SBB32,11,6,0.987333151404578
+SBB40,9,1,0.975158324586857
+SBB48,9,3,0.967378938589373
+SBB56,9,5,0.960564538823142
+SBB64,9,7,0.999973063079098
diff --git a/LHCbG4Tests/G4RichTbSimH/InputData/EffSaleveThr7.txt b/LHCbG4Tests/G4RichTbSimH/InputData/EffSaleveThr7.txt
new file mode 100644
index 0000000000000000000000000000000000000000..c2ecd70bb701331109cd9d7afb1b12e0f244eaeb
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/InputData/EffSaleveThr7.txt
@@ -0,0 +1,129 @@
+PixelName,ClaroNumber,ClaroChanNumber,Efficiency
+SA8,8,7,0.999560013933973
+SA7,8,5,0.999769528623767
+SA6,8,3,1.00000028663178
+SA5,8,1,1.00000013018214
+SA4,6,6,0.984744092925925
+SA3,6,4,0.996527802257355
+SA2,6,2,0.999945909188029
+SA1,6,0,0.948564112465775
+SB1,4,7,0.997602183678685
+SB9,4,5,0.995767190841292
+SB17,4,3,0.999632275015327
+SB25,4,1,0.999603441817057
+SB33,2,6,0.996326237745373
+SB41,2,4,0.958216462886649
+SB49,2,2,1.000000286637
+SB57,2,0,0.974152843595268
+SA16,8,6,0.955253379596571
+SA15,8,4,0.999961794727309
+SA14,8,2,0.978207627637638
+SA13,8,0,0.999264202515873
+SA12,6,7,0.997523620599892
+SA11,6,5,0.999935978375307
+SA10,6,3,0.999322822242201
+SA9,6,1,0.989577312310986
+SB2,4,6,0.945935882084671
+SB10,4,4,0.966785290802617
+SB18,4,2,1.00000028665175
+SB26,4,0,0.950027340677009
+SB34,2,7,0.977487892168379
+SB42,2,5,0.981284030242378
+SB50,2,3,0.977683358678738
+SB58,2,1,0.990546731846574
+SA24,7,0,0.997412465363114
+SA23,7,2,0.972018869519341
+SA22,7,4,0.968648476479469
+SA21,7,6,0.716658951217431
+SA20,5,0,0.997975200057252
+SA19,5,3,0.984660363708313
+SA18,5,5,0.851810975201035
+SA17,5,7,0.939840736817279
+SB3,3,0,0.998166977612879
+SB11,3,2,0.99985380449213
+SB19,3,4,0.999999891179681
+SB27,3,7,0.999954445728983
+SB35,1,1,0.970533393754191
+SB43,1,3,1.00000028665174
+SB51,1,5,0.944907609919623
+SB59,1,7,0.364971748172486
+SA32,7,1,0.997366315488042
+SA31,7,3,1.00000028665104
+SA30,7,5,0.969630784481466
+SA29,7,7,0.977292228645615
+SA28,5,1,0.984659860964499
+SA27,5,2,0.998601994045195
+SA26,5,4,0.986330240859617
+SA25,5,6,0.999612989137414
+SB4,3,1,0.439469382801636
+SB12,3,3,0.993645196403396
+SB20,3,5,0.962547704908887
+SB28,3,6,0.999682091789736
+SB36,1,0,0.985761878821376
+SB44,1,2,0.961644378241487
+SB52,1,4,0.940435628029568
+SB60,1,6,0.872276579978948
+SA40,16,6,0.933944955585704
+SA39,16,4,0.398162731644494
+SA38,16,2,0.999558421943878
+SA37,16,0,0.811165522947953
+SA36,14,6,0.933101719359828
+SA35,14,5,0.938701490575451
+SA34,14,3,0.941614795461357
+SA33,14,1,0.870120367133116
+SB5,12,6,1.00000028582749
+SB13,12,4,0.384871690743696
+SB21,12,2,0.991085446919297
+SB29,12,1,0.999651522774599
+SB37,10,7,0.731300446756775
+SB45,10,5,0.62846918640167
+SB53,10,3,0.978232694165421
+SB61,10,1,0.981167863297551
+SA48,16,7,0.964488817917852
+SA47,16,5,0.979775206385928
+SA46,16,3,0.958160216304319
+SA45,16,1,0.998955147898793
+SA44,14,7,0.829537724610662
+SA43,14,4,1.00000028665174
+SA42,14,2,0.985192156088351
+SA41,14,0,0.989219249987398
+SB6,12,7,0.951366170484523
+SB14,12,5,1.00000028665174
+SB22,12,3,0.94740937508839
+SB30,12,0,0.976080513400325
+SB38,10,6,0.989547193331158
+SB46,10,4,0.999999146956372
+SB54,10,2,1.00000028665175
+SB62,10,0,0.976740878958675
+SA56,15,1,1.00000028665173
+SA55,15,3,1.00000028665173
+SA54,15,5,1.00000028665175
+SA53,15,7,1.00000028665175
+SA52,13,0,1.00000028665174
+SA51,13,2,0.974452843126998
+SA50,13,4,0.997719034517733
+SA49,13,6,0.885007502041414
+SB7,11,1,0.998424441309378
+SB15,11,3,0.991936131978537
+SB23,11,5,0.965020257294611
+SB31,11,7,1.00000027988485
+SB39,9,0,1.00000027597228
+SB47,9,2,0.997928555260421
+SB55,9,4,0.99693707522142
+SB63,9,6,0.95580398928142
+SA64,15,0,1.00000028665175
+SA63,15,2,1.00000028665175
+SA62,15,4,1.00000028665174
+SA61,15,6,1.00000028665175
+SA60,13,1,0.998691718504862
+SA59,13,3,0.996033680485157
+SA58,13,5,0.999444084837535
+SA57,13,7,0.99936926094372
+SB8,11,0,0.991507308362234
+SB16,11,2,0.973381215708061
+SB24,11,4,0.851374823601735
+SB32,11,6,0.99511370813941
+SB40,9,1,0.992857285397911
+SB48,9,3,0.967378938589373
+SB56,9,5,0.993729127328459
+SB64,9,7,0.999973063079098
diff --git a/LHCbG4Tests/G4RichTbSimH/InputData/EffSaleveTop100.txt b/LHCbG4Tests/G4RichTbSimH/InputData/EffSaleveTop100.txt
new file mode 100644
index 0000000000000000000000000000000000000000..c1ba055813900c6877ab93889b8286b1d77ce685
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/InputData/EffSaleveTop100.txt
@@ -0,0 +1,129 @@
+PixelName,ClaroNumber,ClaroChanNumber,Efficiency
+SA8,8,7,1.0
+SA7,8,5,1.0
+SA6,8,3,1.0
+SA5,8,1,1.0
+SA4,6,6,1.0
+SA3,6,4,1.0
+SA2,6,2,1.0
+SA1,6,0,1.0
+SB1,4,7,1.0
+SB9,4,5,1.0
+SB17,4,3,1.0
+SB25,4,1,1.0
+SB33,2,6,1.0
+SB41,2,4,1.0
+SB49,2,2,1.0
+SB57,2,0,1.0
+SA16,8,6,1.0
+SA15,8,4,1.0
+SA14,8,2,1.0
+SA13,8,0,1.0
+SA12,6,7,1.0
+SA11,6,5,1.0
+0A10,6,3,1.0
+SA9,6,1,1.0
+SB2,4,6,1.0
+SB10,4,4,1.0
+SB18,4,2,1.0
+SB26,4,0,1.0
+SB34,2,7,1.0
+SB42,2,5,1.0
+SB50,2,3,1.0
+SB58,2,1,1.0
+SA24,7,0,1.0
+SA23,7,2,1.0
+SA22,7,4,1.0
+SA21,7,6,1.0
+SA20,5,0,1.0
+SA19,5,3,1.0
+SA18,5,5,1.0
+SA17,5,7,1.0
+SB3,3,0,1.0
+SB11,3,2,1.0
+SB19,3,4,1.0
+SB27,3,7,1.0
+SB35,1,1,1.0
+SB43,1,3,1.0
+SB51,1,5,1.0
+SB59,1,7,1.0
+SA32,7,1,1.0
+SA31,7,3,1.0
+SA30,7,5,1.0
+SA29,7,7,1.0
+SA28,5,1,1.0
+SA27,5,2,1.0
+SA26,5,4,1.0
+SA25,5,6,1.0
+SB4,3,1,1.0
+SB12,3,3,1.0
+SB20,3,5,1.0
+SB28,3,6,1.0
+SB36,1,0,1.0
+SB44,1,2,1.0
+SB52,1,4,1.0
+SB60,1,6,1.0
+SA40,16,6,1.0
+SA39,16,4,1.0
+SA38,16,2,1.0
+SA37,16,0,1.0
+SA36,14,6,1.0
+SA35,14,5,1.0
+SA34,14,3,1.0
+SA33,14,1,1.0
+SB5,12,6,1.0
+SB13,12,4,1.0
+SB21,12,2,1.0
+SB29,12,1,1.0
+SB37,10,7,1.0
+SB45,10,5,1.0
+SB53,10,3,1.0
+SB61,10,1,1.0
+SA48,16,7,1.0
+SA47,16,5,1.0
+SA46,16,3,1.0
+SA45,16,1,1.0
+SA44,14,7,1.0
+SA43,14,4,1.0
+SA42,14,2,1.0
+SA41,14,0,1.0
+SB6,12,7,1.0
+SB14,12,5,1.0
+SB22,12,3,1.0
+SB30,12,0,1.0
+SB38,10,6,1.0
+SB46,10,4,1.0
+SB54,10,2,1.0
+SB62,10,0,1.0
+SA56,15,1,1.0
+SA55,15,3,1.0
+SA54,15,5,1.0
+SA53,15,7,1.0
+SA52,13,0,1.0
+SA51,13,2,1.0
+SA50,13,4,1.0
+SA49,13,6,1.0
+SB7,11,1,1.0
+SB15,11,3,1.0
+SB23,11,5,1.0
+SB31,11,7,1.0
+SB39,9,0,1.0
+SB47,9,2,1.0
+SB55,9,4,1.0
+SB63,9,6,1.0
+SA64,15,0,1.0
+SA63,15,2,1.0
+SA62,15,4,1.0
+SA61,15,6,1.0
+SA60,13,1,1.0
+SA59,13,3,1.0
+SA58,13,5,1.0
+SA57,13,7,1.0
+SB8,11,0,1.0
+SB16,11,2,1.0
+SB24,11,4,1.0
+SB32,11,6,1.0
+SB40,9,1,1.0
+SB48,9,3,1.0
+SB56,9,5,1.0
+SB64,9,7,1.0
diff --git a/LHCbG4Tests/G4RichTbSimH/InputData/Mirror_D200mm_240906.txt b/LHCbG4Tests/G4RichTbSimH/InputData/Mirror_D200mm_240906.txt
new file mode 100755
index 0000000000000000000000000000000000000000..b1c0904671b7a0652358b171d4d05ea54735461d
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/InputData/Mirror_D200mm_240906.txt
@@ -0,0 +1,401 @@
+600	78.144098
+599	78.140898
+598	78.182479
+597	78.217645
+596	78.252795
+595	78.31028
+594	78.396428
+593	78.412371
+592	78.460181
+591	78.523882
+590	78.568442
+589	78.593893
+588	78.654307
+587	78.724202
+586	78.790862
+585	78.860637
+584	78.892332
+583	78.917679
+582	78.98101
+581	79.037966
+580	79.107522
+579	79.135959
+578	79.243296
+577	79.284299
+576	79.303216
+575	79.385137
+574	79.448096
+573	79.485848
+572	79.545584
+571	79.630396
+570	79.680612
+569	79.771549
+568	79.824808
+567	79.884291
+566	79.949984
+565	80.02812
+564	80.087452
+563	80.137382
+562	80.218452
+561	80.290099
+560	80.346126
+559	80.423877
+558	80.513974
+557	80.572948
+556	80.628779
+555	80.684571
+554	80.783662
+553	80.8579
+552	80.928981
+551	81.015431
+550	81.070957
+549	81.151094
+548	81.237307
+547	81.314205
+546	81.394103
+545	81.455509
+544	81.553663
+543	81.621076
+542	81.697613
+541	81.771022
+540	81.859636
+539	81.942053
+538	82.012194
+537	82.097503
+536	82.179681
+535	82.286086
+534	82.346828
+533	82.44392
+532	82.513635
+531	82.586318
+530	82.686154
+529	82.773788
+528	82.852278
+527	82.978913
+526	83.039147
+525	83.138439
+524	83.258633
+523	83.30066
+522	83.390647
+521	83.48952
+520	83.579304
+519	83.666003
+518	83.767535
+517	83.877887
+516	83.964278
+515	84.068425
+514	84.187291
+513	84.267431
+512	84.362314
+511	84.471889
+510	84.587233
+509	84.666995
+508	84.773227
+507	84.885217
+506	84.979409
+505	85.06762
+504	85.149868
+503	85.281886
+502	85.39028
+501	85.501462
+500	85.594976
+499	85.685471
+498	85.772956
+497	85.898196
+496	86
+495	86.066834
+494	86.156834
+493	86.267027
+492	86.330759
+491	86.420484
+490	86.507225
+489	86.6112
+488	86.700634
+487	86.798618
+486	86.879227
+485	86.991379
+484	87.103387
+483	87.215251
+482	87.301203
+481	87.418534
+480	87.515713
+479	87.5871
+478	87.723999
+477	87.792369
+476	87.920419
+475	88.034084
+474	88.139095
+473	88.229814
+472	88.314778
+471	88.388348
+470	88.526832
+469	88.614333
+468	88.673559
+467	88.769364
+466	88.879131
+465	88.957855
+464	89.005618
+463	89.109483
+462	89.188004
+461	89.291657
+460	89.400783
+459	89.439924
+458	89.540494
+457	89.657682
+456	89.752437
+455	89.749652
+454	89.849875
+453	89.96666
+452	90.077744
+451	90.136008
+450	90.233032
+449	90.313343
+448	90.401881
+447	90.501381
+446	90.581455
+445	90.655943
+444	90.702811
+443	90.801982
+442	90.928543
+441	90.978019
+440	91.06042
+439	91.129029
+438	91.200329
+437	91.348235
+436	91.446706
+435	91.512294
+434	91.60786
+433	91.686967
+432	91.71423
+431	91.733309
+430	91.8477
+429	91.945636
+428	92.043468
+427	92.116774
+426	92.192733
+425	92.298429
+424	92.357999
+423	92.436465
+422	92.471617
+421	92.549986
+420	92.676858
+419	92.711919
+418	92.771224
+417	92.843955
+416	92.940841
+415	92.978492
+414	93.088667
+413	93.1531
+412	93.230896
+411	93.265749
+410	93.322023
+409	93.367553
+408	93.434469
+407	93.528071
+406	93.586858
+405	93.738999
+404	93.725664
+403	93.744333
+402	93.813645
+401	93.914855
+400	93.992021
+399	94.06115
+398	94.119605
+397	94.164749
+396	94.284145
+395	94.329211
+394	94.366308
+393	94.456339
+392	94.517194
+391	94.527774
+390	94.575367
+389	94.580653
+388	94.715363
+387	94.646712
+386	94.744393
+385	94.841974
+384	94.839338
+383	94.926287
+382	94.949987
+381	95.034204
+380	95.073656
+379	95.144627
+378	95.160391
+377	95.191911
+376	95.265419
+375	95.304774
+374	95.333625
+373	95.404402
+372	95.422744
+371	95.506544
+370	95.514397
+369	95.561499
+368	95.679151
+367	95.69744
+366	95.715725
+365	95.762728
+364	95.854056
+363	95.812317
+362	95.856664
+361	95.890563
+360	95.989583
+359	95.93748
+358	96.010416
+357	96.039055
+356	96.106712
+355	96.218501
+354	96.166522
+353	96.260064
+352	96.247078
+351	96.241883
+350	96.371676
+349	96.317184
+348	96.304206
+347	96.350921
+346	96.317184
+345	96.41058
+344	96.459836
+343	96.516838
+342	96.532378
+341	96.514248
+340	96.550505
+339	96.612629
+338	96.589337
+337	96.63074
+336	96.66954
+335	96.703154
+334	96.783263
+333	96.721249
+332	96.646262
+331	96.747093
+330	96.871048
+329	96.79876
+328	96.796178
+327	96.829747
+326	96.909752
+325	96.889112
+324	96.840074
+323	96.865887
+322	96.860725
+321	96.845237
+320	96.912332
+319	96.927808
+318	96.914911
+317	96.930387
+316	97.007732
+315	96.958754
+314	96.98969
+313	96.945861
+312	97.01804
+311	97.082439
+310	97.041228
+309	97.028346
+308	97.015463
+307	97.043805
+306	97.108187
+305	97.110762
+304	97.082439
+303	97.054109
+302	97.139076
+301	97.144223
+300	97.195679
+299	97.182817
+298	97.1751
+297	97.216254
+296	97.223968
+295	97.29851
+294	97.270242
+293	97.29851
+292	97.275382
+291	97.311356
+290	97.275382
+289	97.262531
+288	97.290801
+287	97.288232
+286	97.22654
+285	97.223968
+284	97.234253
+283	97.22654
+282	97.213682
+281	97.252249
+280	97.25482
+279	97.198251
+278	97.221397
+277	97.193107
+276	97.221397
+275	97.172527
+274	97.133928
+273	97.103038
+272	97.061836
+271	97.136502
+270	97.11591
+269	97.028346
+268	97.015463
+267	96.994845
+266	96.951019
+265	96.930387
+264	96.865887
+263	96.87879
+262	96.840074
+261	96.77293
+260	96.747093
+259	96.700569
+258	96.659195
+257	96.58416
+256	96.553094
+255	96.586749
+254	96.480568
+253	96.376864
+252	96.335352
+251	96.304206
+250	96.23409
+249	96.122318
+248	95.997396
+247	95.91663
+246	95.825362
+245	95.671312
+244	95.527483
+243	95.378195
+242	95.294281
+241	95.09469
+240	94.947354
+239	94.84461
+238	94.620294
+237	94.40339
+236	94.143507
+235	93.880243
+234	93.642939
+233	93.383617
+232	93.03494
+231	92.687648
+230	92.276758
+229	91.872194
+228	91.375598
+227	90.812995
+226	90.288427
+225	89.587946
+224	88.766548
+223	87.943163
+222	87.028731
+221	85.953476
+220	84.625646
+219	83.219589
+218	81.636389
+217	79.818544
+216	77.720654
+215	75.35914
+214	72.649845
+213	69.580888
+212	66.215557
+211	62.485998
+210	58.32238
+209	53.80985
+208	48.872283
+207	43.760713
+206	38.574603
+205	33.24906
+204	28.178006
+203	23.664319
+202	19.761073
+201	16.643317
+200	14.491377
diff --git a/LHCbG4Tests/G4RichTbSimH/InputData/Mirror_D200mm_dummyUpTo800nm.txt b/LHCbG4Tests/G4RichTbSimH/InputData/Mirror_D200mm_dummyUpTo800nm.txt
new file mode 100755
index 0000000000000000000000000000000000000000..b5e5faae960f5e3ea4f40dab96fb2672fcb8f86e
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/InputData/Mirror_D200mm_dummyUpTo800nm.txt
@@ -0,0 +1,601 @@
+800	78.144098
+799	78.144098
+798	78.144098
+797	78.144098
+796	78.144098
+795	78.144098
+794	78.144098
+793	78.144098
+792	78.144098
+791	78.144098
+790	78.144098
+789	78.144098
+788	78.144098
+787	78.144098
+786	78.144098
+785	78.144098
+784	78.144098
+783	78.144098
+782	78.144098
+781	78.144098
+780	78.144098
+779	78.144098
+778	78.144098
+777	78.144098
+776	78.144098
+775	78.144098
+774	78.144098
+773	78.144098
+772	78.144098
+771	78.144098
+770	78.144098
+769	78.144098
+768	78.144098
+767	78.144098
+766	78.144098
+765	78.144098
+764	78.144098
+763	78.144098
+762	78.144098
+761	78.144098
+760	78.144098
+759	78.144098
+758	78.144098
+757	78.144098
+756	78.144098
+755	78.144098
+754	78.144098
+753	78.144098
+752	78.144098
+751	78.144098
+750	78.144098
+749	78.144098
+748	78.144098
+747	78.144098
+746	78.144098
+745	78.144098
+744	78.144098
+743	78.144098
+742	78.144098
+741	78.144098
+740	78.144098
+739	78.144098
+738	78.144098
+737	78.144098
+736	78.144098
+735	78.144098
+734	78.144098
+733	78.144098
+732	78.144098
+731	78.144098
+730	78.144098
+729	78.144098
+728	78.144098
+727	78.144098
+726	78.144098
+725	78.144098
+724	78.144098
+723	78.144098
+722	78.144098
+721	78.144098
+720	78.144098
+719	78.144098
+718	78.144098
+717	78.144098
+716	78.144098
+715	78.144098
+714	78.144098
+713	78.144098
+712	78.144098
+711	78.144098
+710	78.144098
+709	78.144098
+708	78.144098
+707	78.144098
+706	78.144098
+705	78.144098
+704	78.144098
+703	78.144098
+702	78.144098
+701	78.144098
+700	78.144098
+699	78.144098
+698	78.144098
+697	78.144098
+696	78.144098
+695	78.144098
+694	78.144098
+693	78.144098
+692	78.144098
+691	78.144098
+690	78.144098
+689	78.144098
+688	78.144098
+687	78.144098
+686	78.144098
+685	78.144098
+684	78.144098
+683	78.144098
+682	78.144098
+681	78.144098
+680	78.144098
+679	78.144098
+678	78.144098
+677	78.144098
+676	78.144098
+675	78.144098
+674	78.144098
+673	78.144098
+672	78.144098
+671	78.144098
+670	78.144098
+669	78.144098
+668	78.144098
+667	78.144098
+666	78.144098
+665	78.144098
+664	78.144098
+663	78.144098
+662	78.144098
+661	78.144098
+660	78.144098
+659	78.144098
+658	78.144098
+657	78.144098
+656	78.144098
+655	78.144098
+654	78.144098
+653	78.144098
+652	78.144098
+651	78.144098
+650	78.144098
+649	78.144098
+648	78.144098
+647	78.144098
+646	78.144098
+645	78.144098
+644	78.144098
+643	78.144098
+642	78.144098
+641	78.144098
+640	78.144098
+639	78.144098
+638	78.144098
+637	78.144098
+636	78.144098
+635	78.144098
+634	78.144098
+633	78.144098
+632	78.144098
+631	78.144098
+630	78.144098
+629	78.144098
+628	78.144098
+627	78.144098
+626	78.144098
+625	78.144098
+624	78.144098
+623	78.144098
+622	78.144098
+621	78.144098
+620	78.144098
+619	78.144098
+618	78.144098
+617	78.144098
+616	78.144098
+615	78.144098
+614	78.144098
+613	78.144098
+612	78.144098
+611	78.144098
+610	78.144098
+609	78.144098
+608	78.144098
+607	78.144098
+606	78.144098
+605	78.144098
+604	78.144098
+603	78.144098
+602	78.144098
+601	78.144098
+600	78.144098
+599	78.140898
+598	78.182479
+597	78.217645
+596	78.252795
+595	78.31028
+594	78.396428
+593	78.412371
+592	78.460181
+591	78.523882
+590	78.568442
+589	78.593893
+588	78.654307
+587	78.724202
+586	78.790862
+585	78.860637
+584	78.892332
+583	78.917679
+582	78.98101
+581	79.037966
+580	79.107522
+579	79.135959
+578	79.243296
+577	79.284299
+576	79.303216
+575	79.385137
+574	79.448096
+573	79.485848
+572	79.545584
+571	79.630396
+570	79.680612
+569	79.771549
+568	79.824808
+567	79.884291
+566	79.949984
+565	80.02812
+564	80.087452
+563	80.137382
+562	80.218452
+561	80.290099
+560	80.346126
+559	80.423877
+558	80.513974
+557	80.572948
+556	80.628779
+555	80.684571
+554	80.783662
+553	80.8579
+552	80.928981
+551	81.015431
+550	81.070957
+549	81.151094
+548	81.237307
+547	81.314205
+546	81.394103
+545	81.455509
+544	81.553663
+543	81.621076
+542	81.697613
+541	81.771022
+540	81.859636
+539	81.942053
+538	82.012194
+537	82.097503
+536	82.179681
+535	82.286086
+534	82.346828
+533	82.44392
+532	82.513635
+531	82.586318
+530	82.686154
+529	82.773788
+528	82.852278
+527	82.978913
+526	83.039147
+525	83.138439
+524	83.258633
+523	83.30066
+522	83.390647
+521	83.48952
+520	83.579304
+519	83.666003
+518	83.767535
+517	83.877887
+516	83.964278
+515	84.068425
+514	84.187291
+513	84.267431
+512	84.362314
+511	84.471889
+510	84.587233
+509	84.666995
+508	84.773227
+507	84.885217
+506	84.979409
+505	85.06762
+504	85.149868
+503	85.281886
+502	85.39028
+501	85.501462
+500	85.594976
+499	85.685471
+498	85.772956
+497	85.898196
+496	86
+495	86.066834
+494	86.156834
+493	86.267027
+492	86.330759
+491	86.420484
+490	86.507225
+489	86.6112
+488	86.700634
+487	86.798618
+486	86.879227
+485	86.991379
+484	87.103387
+483	87.215251
+482	87.301203
+481	87.418534
+480	87.515713
+479	87.5871
+478	87.723999
+477	87.792369
+476	87.920419
+475	88.034084
+474	88.139095
+473	88.229814
+472	88.314778
+471	88.388348
+470	88.526832
+469	88.614333
+468	88.673559
+467	88.769364
+466	88.879131
+465	88.957855
+464	89.005618
+463	89.109483
+462	89.188004
+461	89.291657
+460	89.400783
+459	89.439924
+458	89.540494
+457	89.657682
+456	89.752437
+455	89.749652
+454	89.849875
+453	89.96666
+452	90.077744
+451	90.136008
+450	90.233032
+449	90.313343
+448	90.401881
+447	90.501381
+446	90.581455
+445	90.655943
+444	90.702811
+443	90.801982
+442	90.928543
+441	90.978019
+440	91.06042
+439	91.129029
+438	91.200329
+437	91.348235
+436	91.446706
+435	91.512294
+434	91.60786
+433	91.686967
+432	91.71423
+431	91.733309
+430	91.8477
+429	91.945636
+428	92.043468
+427	92.116774
+426	92.192733
+425	92.298429
+424	92.357999
+423	92.436465
+422	92.471617
+421	92.549986
+420	92.676858
+419	92.711919
+418	92.771224
+417	92.843955
+416	92.940841
+415	92.978492
+414	93.088667
+413	93.1531
+412	93.230896
+411	93.265749
+410	93.322023
+409	93.367553
+408	93.434469
+407	93.528071
+406	93.586858
+405	93.738999
+404	93.725664
+403	93.744333
+402	93.813645
+401	93.914855
+400	93.992021
+399	94.06115
+398	94.119605
+397	94.164749
+396	94.284145
+395	94.329211
+394	94.366308
+393	94.456339
+392	94.517194
+391	94.527774
+390	94.575367
+389	94.580653
+388	94.715363
+387	94.646712
+386	94.744393
+385	94.841974
+384	94.839338
+383	94.926287
+382	94.949987
+381	95.034204
+380	95.073656
+379	95.144627
+378	95.160391
+377	95.191911
+376	95.265419
+375	95.304774
+374	95.333625
+373	95.404402
+372	95.422744
+371	95.506544
+370	95.514397
+369	95.561499
+368	95.679151
+367	95.69744
+366	95.715725
+365	95.762728
+364	95.854056
+363	95.812317
+362	95.856664
+361	95.890563
+360	95.989583
+359	95.93748
+358	96.010416
+357	96.039055
+356	96.106712
+355	96.218501
+354	96.166522
+353	96.260064
+352	96.247078
+351	96.241883
+350	96.371676
+349	96.317184
+348	96.304206
+347	96.350921
+346	96.317184
+345	96.41058
+344	96.459836
+343	96.516838
+342	96.532378
+341	96.514248
+340	96.550505
+339	96.612629
+338	96.589337
+337	96.63074
+336	96.66954
+335	96.703154
+334	96.783263
+333	96.721249
+332	96.646262
+331	96.747093
+330	96.871048
+329	96.79876
+328	96.796178
+327	96.829747
+326	96.909752
+325	96.889112
+324	96.840074
+323	96.865887
+322	96.860725
+321	96.845237
+320	96.912332
+319	96.927808
+318	96.914911
+317	96.930387
+316	97.007732
+315	96.958754
+314	96.98969
+313	96.945861
+312	97.01804
+311	97.082439
+310	97.041228
+309	97.028346
+308	97.015463
+307	97.043805
+306	97.108187
+305	97.110762
+304	97.082439
+303	97.054109
+302	97.139076
+301	97.144223
+300	97.195679
+299	97.182817
+298	97.1751
+297	97.216254
+296	97.223968
+295	97.29851
+294	97.270242
+293	97.29851
+292	97.275382
+291	97.311356
+290	97.275382
+289	97.262531
+288	97.290801
+287	97.288232
+286	97.22654
+285	97.223968
+284	97.234253
+283	97.22654
+282	97.213682
+281	97.252249
+280	97.25482
+279	97.198251
+278	97.221397
+277	97.193107
+276	97.221397
+275	97.172527
+274	97.133928
+273	97.103038
+272	97.061836
+271	97.136502
+270	97.11591
+269	97.028346
+268	97.015463
+267	96.994845
+266	96.951019
+265	96.930387
+264	96.865887
+263	96.87879
+262	96.840074
+261	96.77293
+260	96.747093
+259	96.700569
+258	96.659195
+257	96.58416
+256	96.553094
+255	96.586749
+254	96.480568
+253	96.376864
+252	96.335352
+251	96.304206
+250	96.23409
+249	96.122318
+248	95.997396
+247	95.91663
+246	95.825362
+245	95.671312
+244	95.527483
+243	95.378195
+242	95.294281
+241	95.09469
+240	94.947354
+239	94.84461
+238	94.620294
+237	94.40339
+236	94.143507
+235	93.880243
+234	93.642939
+233	93.383617
+232	93.03494
+231	92.687648
+230	92.276758
+229	91.872194
+228	91.375598
+227	90.812995
+226	90.288427
+225	89.587946
+224	88.766548
+223	87.943163
+222	87.028731
+221	85.953476
+220	84.625646
+219	83.219589
+218	81.636389
+217	79.818544
+216	77.720654
+215	75.35914
+214	72.649845
+213	69.580888
+212	66.215557
+211	62.485998
+210	58.32238
+209	53.80985
+208	48.872283
+207	43.760713
+206	38.574603
+205	33.24906
+204	28.178006
+203	23.664319
+202	19.761073
+201	16.643317
+200	14.491377
diff --git a/LHCbG4Tests/G4RichTbSimH/include/HpdSiEnergyLoss.hh b/LHCbG4Tests/G4RichTbSimH/include/HpdSiEnergyLoss.hh
new file mode 100644
index 0000000000000000000000000000000000000000..7f5676bee6147f5272215b2761f60793c45a6f5f
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/HpdSiEnergyLoss.hh
@@ -0,0 +1,71 @@
+// $Id: $
+#ifndef INCLUDE_HPDSIENERGYLOSS_HH 
+#define INCLUDE_HPDSIENERGYLOSS_HH 1
+
+// Include files
+
+#include "Geant4/globals.hh"
+#include "Geant4/G4VEnergyLossProcess.hh"
+#include "Geant4/G4VParticleChange.hh"
+#include "Geant4/G4DynamicParticle.hh"
+#include "Geant4/G4Track.hh"
+#include "Geant4/G4Step.hh"
+#include "Geant4/G4ParticleDefinition.hh"
+
+/** @class HpdSiEnergyLoss HpdSiEnergyLoss.hh include/HpdSiEnergyLoss.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2003-12-10
+ */
+class HpdSiEnergyLoss : public G4VContinuousDiscreteProcess {
+public: 
+  /// Standard constructor
+  HpdSiEnergyLoss(const G4String& processName); 
+
+  virtual ~HpdSiEnergyLoss( ); ///< Destructor
+  G4bool IsApplicable(const G4ParticleDefinition&);
+  // true for all charged particles
+  G4double GetContinuousStepLimit(const G4Track& track,
+                                G4double previousStepSize,
+                                G4double currentMinimumStep,
+                                G4double& currentSafety);
+
+ 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;
+  }
+   
+private:
+
+   // 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;
+
+};
+#endif // INCLUDE_HPDSIENERGYLOSS_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/PixelHpdPhotoElectricEffect.hh b/LHCbG4Tests/G4RichTbSimH/include/PixelHpdPhotoElectricEffect.hh
new file mode 100644
index 0000000000000000000000000000000000000000..0dd4a84ed47fd7df6babae02b9304d1db0fd4a0f
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/PixelHpdPhotoElectricEffect.hh
@@ -0,0 +1,88 @@
+// $Id: $
+#ifndef INCLUDE_PIXELHPDPHOTOELECTRICEFFECT_HH 
+#define INCLUDE_PIXELHPDPHOTOELECTRICEFFECT_HH 1
+
+// Include files
+#include "Geant4/G4ios.hh"
+#include "Geant4/globals.hh"
+#include "Geant4/Randomize.hh"
+#include "Geant4/G4VDiscreteProcess.hh"
+#include "Geant4/G4PhotoElectricEffect.hh"
+#include "Geant4/G4DynamicParticle.hh"
+#include "Geant4/G4OpticalPhoton.hh"
+#include "Geant4/G4Electron.hh"
+#include "Geant4/G4Step.hh"
+#include "RichTbMaterialParameters.hh"
+#include <vector>
+#include "RichTbRunConfig.hh"
+#include "RichTbAnalysisManager.hh"
+
+/** @class PixelHpdPhotoElectricEffect PixelHpdPhotoElectricEffect.hh include/PixelHpdPhotoElectricEffect.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2003-12-09
+ */
+class PixelHpdPhotoElectricEffect:public G4VDiscreteProcess  {
+public: 
+  /// Standard constructor
+  PixelHpdPhotoElectricEffect(const G4String&) ; 
+
+  virtual ~PixelHpdPhotoElectricEffect( ); ///< Destructor
+  G4bool IsApplicable(const G4ParticleDefinition&  );
+  // is applicable for optical photon only
+  G4double GetMeanFreePath(const G4Track& ,
+                                 G4double ,
+                                 G4ForceCondition* condition);
+  //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 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;}
+
+G4int getNumDemagParam()
+{
+  return  NumDemagParam;
+}
+G4int getNumQEbins()
+{
+  return NumQEbins;
+}
+
+protected:
+
+private:
+
+  G4int NumHpdTot;
+  G4int NumDemagParam;
+  G4int NumQEbins;
+  G4String PrePhotoElectricVolName;
+  G4String PostPhotoElectricVolName;
+  G4double HpdPhElectronMomentum;
+  G4double PhCathodeToSilDetDist;
+  G4double  HpdPhCathodeRInner;
+  G4double PSFsigma;
+  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/G4RichTbSimH/include/PmtAnodeEnergyLoss.hh b/LHCbG4Tests/G4RichTbSimH/include/PmtAnodeEnergyLoss.hh
new file mode 100644
index 0000000000000000000000000000000000000000..40ca6007c3b83cd3666331198fcfddcca403997e
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/PmtAnodeEnergyLoss.hh
@@ -0,0 +1,71 @@
+// $Id: $
+#ifndef INCLUDE_PMTANODEENERGYLOSS_HH 
+#define INCLUDE_PMTANODEENERGYLOSS_HH 1
+
+// Include files
+
+#include "Geant4/globals.hh"
+#include "Geant4/G4VEnergyLossProcess.hh"
+#include "Geant4/G4VParticleChange.hh"
+#include "Geant4/G4DynamicParticle.hh"
+#include "Geant4/G4Track.hh"
+#include "Geant4/G4Step.hh"
+#include "Geant4/G4ParticleDefinition.hh"
+
+/** @class PmtAnodeEnergyLoss PmtAnodeEnergyLoss.hh include/PmtAnodeEnergyLoss.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2003-12-10
+ */
+class PmtAnodeEnergyLoss : public G4VContinuousDiscreteProcess {
+public: 
+  /// Standard constructor
+  PmtAnodeEnergyLoss(const G4String& processName); 
+
+  virtual ~PmtAnodeEnergyLoss( ); ///< Destructor
+  G4bool IsApplicable(const G4ParticleDefinition&);
+  // true for all charged particles
+  G4double GetContinuousStepLimit(const G4Track& track,
+                                G4double previousStepSize,
+                                G4double currentMinimumStep,
+                                G4double& currentSafety);
+
+ 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;
+  }
+   
+private:
+
+   // 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;
+
+};
+#endif // INCLUDE_PMTANODEENERGYLOSS_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/PmtPhotoElectricEffect.hh b/LHCbG4Tests/G4RichTbSimH/include/PmtPhotoElectricEffect.hh
new file mode 100644
index 0000000000000000000000000000000000000000..32eabdfdcf21b18b18ae88901ed643ce4d2043f1
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/PmtPhotoElectricEffect.hh
@@ -0,0 +1,81 @@
+// $Id: $
+#ifndef INCLUDE_PMTPHOTOELECTRICEFFECT_HH
+#define INCLUDE_PMTPHOTOELECTRICEFFECT_HH 1
+
+// Include files
+#include "Geant4/G4ios.hh"
+#include "Geant4/globals.hh"
+#include "Geant4/Randomize.hh"
+#include "Geant4/G4VDiscreteProcess.hh"
+#include "Geant4/G4PhotoElectricEffect.hh"
+#include "Geant4/G4DynamicParticle.hh"
+#include "Geant4/G4OpticalPhoton.hh"
+#include "Geant4/G4Electron.hh"
+#include "Geant4/G4Step.hh"
+#include "RichTbMaterialParameters.hh"
+#include <vector>
+#include "RichTbRunConfig.hh"
+#include "RichTbAnalysisManager.hh"
+
+/** @class PmtPhotoElectricEffect PmtPhotoElectricEffect.hh include/PmtPhotoElectricEffect.hh
+ *
+ *
+ *  @author Sajan EASO
+ *  @date   2003-12-09
+ */
+class PmtPhotoElectricEffect:public G4VDiscreteProcess  {
+public:
+  /// Standard constructor
+  PmtPhotoElectricEffect(const G4String&) ;
+
+  virtual ~PmtPhotoElectricEffect( ); ///< Destructor
+  G4bool IsApplicable(const G4ParticleDefinition&  );
+  // is applicable for optical photon only
+  G4double GetMeanFreePath(const G4Track& ,
+                                 G4double ,
+                                 G4ForceCondition* condition);
+  //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.
+  G4double getPmtQEff(G4int, G4double);
+  // To interpolate the QE from QE data.
+  G4double getPmtPhElectronMomentum()
+  {return PmtPhElectronMomentum; }
+  G4double getPhCathodeToSilDetDist()
+  {return PhCathodeToSilDetDist; }
+
+  G4int getNumPmtTot()
+  {
+    return  NumPmtTot;
+  }
+
+
+G4int getNumQEbins()
+{
+  return NumQEbins;
+}
+
+protected:
+
+private:
+
+	G4int NumPmts_; // TESTnumPmts
+
+  G4int NumPmtTot;
+
+  G4int NumQEbins;
+  G4String PrePhotoElectricVolName;
+  G4String PostPhotoElectricVolName;
+  G4double PmtPhElectronMomentum;
+  G4double PhCathodeToSilDetDist;
+
+
+  std::vector<std::vector<G4double> >PmtQE;
+  std::vector<std::vector<G4double> >PmtWabin;
+
+};
+#endif // INCLUDE_PMTPHOTOELECTRICEFFECT_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbAnalysisManager.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbAnalysisManager.hh
new file mode 100644
index 0000000000000000000000000000000000000000..22350ffbee21692c5d7772267a61e8683320d217
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbAnalysisManager.hh
@@ -0,0 +1,322 @@
+#ifndef RichTbAnalysisManager_h
+#define RichTbAnalysisManager_h 1
+
+
+//#include "Geant4/G4VAnalysisManager.hh"
+#include "Geant4/globals.hh"
+//#include "Geant4/G4std/vector"
+//#include "Geant4/G4std/fstream"
+#include "Geant4/G4ThreeVector.hh"
+//#include "AIDA/AIDA.h"
+#include "TH1D.h"
+#include "TH2D.h"
+#include "TProfile.h"
+//#ifdef G4ANALYSIS_USE_JAS
+//#include "Geant4/G4JasSystem.hh"
+//#include "JasHistogram1D.h"
+//#include "JasHistogram2D.h"
+//#include "JasHistogramFactory.h"
+//#endif
+
+//#ifdef G4ANALYSIS_USE_LAB
+//#include "Geant4/G4LabSystem.hh"
+//#endif
+
+//#include <AIDA/AIDA.h>
+//#include <AIDA/IAnalysisFactory.h>
+//#include <AIDA/IHistogramFactory.h>
+//#include <AIDA/ITupleFactory.h>
+//#include <AIDA/ITuple.h>
+//#include <AIDA/IHistogram1D.h>
+//#include <AIDA/IHistogram2D.h>
+
+//#ifdef G4ANALYSIS_USE_LIZARD//
+//#include <IPlotter.h>
+//#include <IVector.h>
+//#include <IVectorFactory.h>
+//#include "Geant4/G4LizardSystem.hh"
+//#endif
+
+#include <vector>
+
+class G4Run;
+class G4Event;
+class G4Step;
+class G4Timer;
+class G4SteppingManager;
+class RichTbRunConfig;
+
+
+ class TFile;
+ class TTree;
+// class TH1D;
+
+  const G4int MaxHisto = 5;
+
+
+//namespace AIDA {
+  //class IAnalysisFactory;
+//class IHistogramFactory;
+//class ITree;
+//class ITupleFactory;
+//class ITuple;
+//};
+
+
+
+class RichTbAnalysisManager {
+public:
+
+  virtual ~RichTbAnalysisManager();
+
+  void InitializeCounters();
+  void BookHisto();
+  void BookHistoHpd();
+
+  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;}
+
+  TH2D * getRadiusVsWL() {return fRadiusVsWL;}
+  TProfile * getRadiusVsWLProfile() {return fRadiusVsWLProfile;}
+  TH2D * getfGlobalPixelCenterXYCoord() {  return fGlobalPixelCenterXYCoord;}
+  TProfile * getfCkvRadiusVsEmisPtPhoton() {  return  fCkvRadiusVsEmisPtPhoton;}
+  TH1D * getfEmisPtPhoton()  {  return fEmisPtPhoton; }
+  TH1D * getfEmisPtPrimaryTrackPhoton()  {  return fEmisPtPrimaryTrackPhoton; }
+
+
+  TH2D * getfGlobalHitXYCoordPeOrigin()
+  {  return fGlobalHitXYCoordPeOrigin;}
+  TH2D * getfGlobalHitXYCoord()
+  {  return fGlobalHitXYCoord ;}
+  TH1D * getfNumHitInEvent()
+  {  return fNumHitInEvent;  }
+
+  TH1D*  getfNumHitInEventCentralPMT()
+  {  return fNumHitInEventCentralPMT;}
+
+  TH1D*  getfNumHitInEventCentralPMTJura() {return    fNumHitInEventCentralPMTJura ;}
+  TH1D*  getfNumHitInEventCentralPMTSaleve() {return    fNumHitInEventCentralPMTSaleve ;}
+
+
+  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 * getfTIRXYLocationPhoton()
+  {  return fTIRXYLocationPhoton;}
+  TH2D* getfXYRadiatorDnsPhoton()
+  {  return  fXYRadiatorDnsPhoton;}
+  TH2D* getfXYRadiatorTIRDnsPhoton()
+  {  return  fXYRadiatorTIRDnsPhoton;}
+
+  TH2D* getfXYRadiatorRFRDnsPhoton()
+  {  return fXYRadiatorRFRDnsPhoton;}
+
+  TH2D* getfMIRXYLocationPhoton()
+  {  return fMIRXYLocationPhoton;}
+
+  TH2D*  getfRFRXYLocationPhoton()
+  {  return fRFRXYLocationPhoton;}
+
+
+  TH1D* getfNumHitInHPD0()  {  return fNumHitInHPD0; }
+
+  TH2D* getfRFRXYLocationPhotonHpd() {return   fRFRXYLocationPhotonHpd; }
+
+  TH2D* getfGlobalHitXYCoordPeOriginHpd() {return   fGlobalHitXYCoordPeOriginHpd; }
+
+  TH2D* getfGlobalHitXYCoordHpd() {return   fGlobalHitXYCoordHpd; }
+
+  TH2D* getfGlobalPixelCenterXYCoordHpd() {return   fGlobalPixelCenterXYCoordHpd ;}
+
+  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/G4RichTbSimH/include/RichTbBeamGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbBeamGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..5e22742769833c73cba13c5d8994c72c3d905681
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbBeamGeometryParameters.hh
@@ -0,0 +1,14 @@
+// $Id: $
+#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;
+
+
+#endif // INCLUDE_RICHTBBEAMGEOMETRYPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbBeamProperty.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbBeamProperty.hh
new file mode 100644
index 0000000000000000000000000000000000000000..5dd0cb6c561b49d2c592a36b030381093f3afa59
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbBeamProperty.hh
@@ -0,0 +1,96 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBBEAMPROPERTY_HH 
+#define INCLUDE_RICHTBBEAMPROPERTY_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4ThreeVector.hh"
+#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;}
+  
+  void ResetBeamProperty();
+  void PrintBeamProperty();
+  
+protected:
+
+private:
+  /// Standard constructor
+  RichTbBeamProperty( ); 
+
+  static RichTbBeamProperty* RichTbBeamPropertyInstance;
+  
+  G4ThreeVector mBeamPosition;
+  G4ThreeVector mBeamDirection;
+  G4ThreeVector mNominalBeamPosition;
+  G4ThreeVector mNominalBeamDirectionCos;
+  G4ParticleDefinition* mBeamPartDef;
+  G4String mBeamPartName;
+  G4ThreeVector mBeamPosUpstrAgel;
+  G4ThreeVector mBeamDirUpstrAgel;
+  G4ThreeVector mAgelNormal;
+  G4ThreeVector mAgelBeamPostionLocal;
+  
+  
+};
+#endif // INCLUDE_RICHTBBEAMPROPERTY_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbCounter.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbCounter.hh
new file mode 100644
index 0000000000000000000000000000000000000000..b7bdd7b044718c9556947dddf814e43964d9f17a
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbCounter.hh
@@ -0,0 +1,348 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBCOUNTER_HH
+#define INCLUDE_RICHTBCOUNTER_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+
+/** @class RichTbCounter RichTbCounter.hh include/RichTbCounter.hh
+ *
+ *
+ *  @author Sajan EASO
+ *  @date   2004-01-12
+ */
+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++;}
+
+
+
+  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
+
+protected:
+
+private:
+
+  /// Standard constructor
+  RichTbCounter( );
+  static  RichTbCounter*  RichTbCounterInstance;
+
+  G4int numHitTotProd;
+  G4int numhitTotEv;
+  G4int numhitTotEvCentralPmt;
+  G4int numhitTotEvCentralPmtJura;
+  G4int numhitTotEvCentralPmtSaleve;
+
+
+  G4int numhitPMT0;
+  G4int numhitPMT1;
+  G4int numhitPMT2;
+  G4int numhitPMT3;
+  G4int numhitPMT4;
+  G4int numhitPMT5;
+  G4int numhitPMT6;
+  G4int numhitPMT7;
+  G4int numhitPMT8;
+  G4int numhitPMT9;
+  G4int numhitPMT10;
+  G4int numhitPMT11;
+  G4int numhitPMT12;
+  G4int numhitPMT13;
+  G4int numhitPMT14;
+  G4int numhitPMT15;
+
+  G4int numPhEnterMirror;
+  G4int numPhEnterPhSupFrame;
+  G4int numExitGasQuWin;
+  G4int numPhEnterPMT0QW;
+  G4int numPhEnterPMT1QW;
+  G4int numPhEnterPMT2QW;
+  G4int numPhEnterPMT3QW;
+  G4int numPhEnterPMT4QW;
+  G4int numPhEnterPMT5QW;
+  G4int numPhEnterPMT6QW;
+  G4int numPhEnterPMT7QW;
+  G4int numPhEnterPMT8QW;
+  G4int numPhEnterPMT9QW;
+  G4int numPhEnterPMT10QW;
+  G4int numPhEnterPMT11QW;
+  G4int numPhEnterPMT12QW;
+  G4int numPhEnterPMT13QW;
+  G4int numPhEnterPMT14QW;
+  G4int numPhEnterPMT15QW;
+  G4int numPhEnterAnPMTQW;
+  G4int numPhElecPMT0;
+  G4int numPhElecPMT1;
+  G4int numPhElecPMT2;
+  G4int numPhElecPMT3;
+  G4int numPhElecPMT4;
+  G4int numPhElecPMT5;
+  G4int numPhElecPMT6;
+  G4int numPhElecPMT7;
+  G4int numPhElecPMT8;
+  G4int numPhElecPMT9;
+  G4int numPhElecPMT10;
+  G4int numPhElecPMT11;
+  G4int numPhElecPMT12;
+  G4int numPhElecPMT13;
+  G4int numPhElecPMT14;
+  G4int numPhElecPMT15;
+
+
+
+  G4int numHitTotHpd0;
+  G4int numHitSignalHpd0;
+
+};
+#endif // INCLUDE_RICHTBCOUNTER_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbCrystalCoverGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbCrystalCoverGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..d186f6c2720e25ef141fba8642d2a0e9a58e6aa6
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbCrystalCoverGeometryParameters.hh
@@ -0,0 +1,54 @@
+// $Id: $
+#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 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 RichTbCrystalCoverYLocation = - RichTbCrystalCoverOriginShiftFromFloorY;
+const G4double RichTbCrystalCoverXShiftAlongCrystal = RichTbCrystalCoverOriginShiftFromLeftEdgeX;
+const G4double RichTbCrystalCoverZShiftAlongCrystal = -RichTbCrystalCoverOriginShiftFromLeftZ;
+
+const G4double RichTbCrystalCoverXLocation = RichTbCrystalCoverXShiftAlongCrystal;
+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;
+
+// now for variables used after creating the geometry in stepaction.
+
+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)+
+//                                          RichTbCrystalZDnsExtremeAlongCrystal*sin(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)+
+//                                        RichTbCrystalZDnsExtremeAlongCrystal*cos(RichTbCrystalYRotation);
+//const G4double  RichTbCrystalDnsZEnd = RichTbCrystalZDnsExtreme;
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbCrystalGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbCrystalGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..24868c44e2e86ca63865c91f279f3575b02bc61a
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbCrystalGeometryParameters.hh
@@ -0,0 +1,49 @@
+// $Id: $
+#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 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 RichTbCrystalXLocation = 0.0;
+const G4double RichTbCrystalZLocation = 0.0*CLHEP::mm;
+
+// now for variables used after creating the geometry in stepaction.
+
+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)+
+//                                          RichTbCrystalZDnsExtremeAlongCrystal*sin(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)+
+//                                        RichTbCrystalZDnsExtremeAlongCrystal*cos(RichTbCrystalYRotation);
+//const G4double  RichTbCrystalDnsZEnd = RichTbCrystalZDnsExtreme;
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbCrystalMasterGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbCrystalMasterGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..208acbff00121dac5f3940e4d3667e9f61e1f764
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbCrystalMasterGeometryParameters.hh
@@ -0,0 +1,54 @@
+// $Id: $
+#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 RichTbCrystalMasterYLocation = 0.0;
+//const G4double RichTbCrystalMasterXShiftAlongCrystal = RichTbCrystalMasterOriginShiftFromLeftEdgeX;
+//const G4double RichTbCrystalMasterZShiftAlongCrystal = -RichTbCrystalMasterOriginShiftFromLeftZ + 0.5 * RichTbCrystalMasterZSize;
+
+const G4double RichTbCrystalMasterXLocation = 0.0;
+const G4double RichTbCrystalMasterZLocation = -250*CLHEP::mm ;
+
+// now for variables used after creating the geometry in stepaction.
+
+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)+
+//                                          RichTbCrystalZDnsExtremeAlongCrystal*sin(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)+
+//                                        RichTbCrystalZDnsExtremeAlongCrystal*cos(RichTbCrystalYRotation);
+//const G4double  RichTbCrystalDnsZEnd = RichTbCrystalZDnsExtreme;
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbDarkCoverGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbDarkCoverGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..04a4462c2e984153a00b05d8fc184ac3006200fe
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbDarkCoverGeometryParameters.hh
@@ -0,0 +1,89 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBDARKCOVERGEOMETRYPARAMETERS_HH
+#define INCLUDE_RICHTBDARKCOVERGEOMETRYPARAMETERS_HH 1
+
+// Include files
+/** @class RichTbVesselGeometryParameters RichTbVesselGeometryParameters.hh include/RichTbVesselGeometryParameters.hh
+ *
+ *
+ *  @author Sajan EASO
+ *  @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 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 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;
+
+// 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 RichTbUpgradeDarkCoverYSize15 = RichTbUpgradeDarkCoverXSize15;
+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;
+
+//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);
+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 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;
+
+
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbEventAction.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbEventAction.hh
new file mode 100644
index 0000000000000000000000000000000000000000..9811f10303a869edc92ad5714d366ed7db42d90f
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbEventAction.hh
@@ -0,0 +1,29 @@
+#ifndef RichTbEventAction_h
+#define RichTbEventAction_h 1
+#include "Geant4/G4UserEventAction.hh"
+#include "Geant4/G4ThreeVector.hh"
+
+class G4Event;
+
+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;
+    }
+
+  private:
+
+    G4int RichTbCollID;
+    G4int RichTbCollIDHpd;
+
+};
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbExtHpdGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbExtHpdGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..8961e0338035fd3e37af8ef2de02032e2d4406f0
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbExtHpdGeometryParameters.hh
@@ -0,0 +1,159 @@
+#ifndef INCLUDE_RICHTBEXTHPDGEOMETRYPARAMETERS_HH 
+#define INCLUDE_RICHTBEXTHPDGEOMETRYPARAMETERS_HH 1
+
+// Include files
+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 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 RichTbHpdSMasterRadius = RichTbHpdMasterRadius;
+const G4double RichTbHpdSMasterZSize = RichTbHpdMasterZSize;
+const G4double RichTbHpdEnvEndCapRad = RichTbHpdEnvLargeTubInnR - RichTbHpdEnvEndCapRadTolerence;
+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 RichTbEnvLargeTubZLocation =
+ -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;
+
+
+// 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;
+
+// now for the HPD locations
+
+const G4String HpdNamesBox="Hpd0Box";
+const G4String HpdNamesLog= "Hpd0Log";
+const G4String HpdNamesPhys= "Hpd0Phys";
+
+const G4String HpdQuartzPhysName="HpdQuartzPhys";
+const G4String HpdPhCathodePhysName="HpdPhCathodePhys";
+const G4String HpdSMasterPhysName = "HpdSMasterPhys";
+const G4String  HpdSiDetPhysName = "HpdSiDetPhys";
+
+
+
+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;
+
+
+#endif // INCLUDE_RICHTBEXTHPDGEOMETRYPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..cf54eb7ede0ba8839d18743547668f02ecd20b71
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbGeometryParameters.hh
@@ -0,0 +1,44 @@
+#ifndef RichTbGeometryParameters_h
+#define RichTbGeometryParameters_h 1
+
+#include "Geant4/globals.hh"
+#include <math.h>
+
+extern void InitializeRichTbGeometry();
+//
+//
+
+static const G4double sqroot3 = pow(3.0, 0.5);
+
+#include "RichTbHallGeometryParameters.hh"
+#include "RichTbVesselGeometryParameters.hh"
+#include "RichTbCrystalGeometryParameters.hh"
+#include "RichTbCrystalMasterGeometryParameters.hh"
+#include "RichTbRadiatorGeometryParameters.hh"
+#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 */
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbGraphics.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbGraphics.hh
new file mode 100644
index 0000000000000000000000000000000000000000..fe4fb9abb0abed48b98d7dcc6a22040c813802c1
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbGraphics.hh
@@ -0,0 +1,25 @@
+#ifndef RichTbGraphics_h
+#define RichTbGraphics_h 1
+
+#include "Geant4/globals.hh"
+#include "Geant4/G4VUserDetectorConstruction.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "RichTbUpgradeDetectorConstruction.hh"
+
+class RichTbGraphics {
+
+  public:
+
+    RichTbGraphics();
+    RichTbGraphics(RichTbDetectorConstruction* );
+    virtual ~ RichTbGraphics();
+
+   void setAllGraphicsAttributes();
+   void setRichTbHallGraphicsAttibutes();
+  
+  private:
+
+  RichTbDetectorConstruction* curDetector;
+  
+};
+#endif                          /*RichTbGraphics_h */
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbHall.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbHall.hh
new file mode 100644
index 0000000000000000000000000000000000000000..2be6688349b5612dd8222288dd4a78243f474306
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbHall.hh
@@ -0,0 +1,31 @@
+#ifndef RichTbHall_h
+#define RichTbHall_h 1
+
+// Geant 4 headers
+#include "Geant4/globals.hh"
+#include "Geant4/G4VUserDetectorConstruction.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4LogicalVolume.hh"
+
+// local headers
+#include "RichTbMaterial.hh"
+
+class RichTbHall {
+
+  public:
+    RichTbHall();
+    virtual ~ RichTbHall();
+
+    G4LogicalVolume *getRichTbHallLogicalVolume() {
+        return RichTbHallLVol;
+    }
+    G4VPhysicalVolume *getRichTbHallPhysicalVolume() {
+        return RichTbHallPVol;
+    }
+
+  private:
+    G4LogicalVolume*  RichTbHallLVol;
+    G4VPhysicalVolume* RichTbHallPVol;
+};
+
+#endif                          /*RichTbHall_h */
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbHallGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbHallGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..03cc234328e971e58e333b50d8d726a3f1b0d1ec
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbHallGeometryParameters.hh
@@ -0,0 +1,28 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBHALLGEOMETRYPARAMETERS_HH 
+#define INCLUDE_RICHTBHALLGEOMETRYPARAMETERS_HH 1
+
+#include "CLHEP/Units/SystemOfUnits.h"
+
+// Include files
+
+/** @class RichTbHallGeometryParameters RichTbHallGeometryParameters.hh include/RichTbHallGeometryParameters.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2003-10-21
+ */
+//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;
+
+// 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 
+// beam enters the vessel.
+
+#endif // INCLUDE_RICHTBHALLGEOMETRYPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbHit.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbHit.hh
new file mode 100644
index 0000000000000000000000000000000000000000..e9376b1364d2990b2b1fbc3c6691164d2dc72757
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbHit.hh
@@ -0,0 +1,189 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBHIT_HH 
+#define INCLUDE_RICHTBHIT_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VHit.hh"
+#include "Geant4/G4THitsCollection.hh"
+#include "Geant4/G4Allocator.hh"
+#include "Geant4/G4ThreeVector.hh"
+class RichTbVisManager;
+
+/** @class RichTbHit RichTbHit.hh include/RichTbHit.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2003-12-12
+ */
+class RichTbHit : public G4VHit {
+public: 
+  /// Standard constructor
+  RichTbHit( ); 
+
+  virtual ~RichTbHit( ); ///< Destructor
+
+  RichTbHit(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();
+
+protected:
+
+private:
+  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.
+
+  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;}
+  
+
+
+};
+typedef G4THitsCollection<RichTbHit> RichTbHitsCollection;
+
+extern G4Allocator<RichTbHit> RichTbHitAllocator;
+inline void* RichTbHit::operator new(size_t)
+{
+  void *aHit;
+  aHit = (void *) RichTbHitAllocator.MallocSingle();
+  return aHit;
+}
+
+inline void RichTbHit::operator delete(void *aHit)
+{
+  RichTbHitAllocator.FreeSingle((RichTbHit*) aHit);
+}
+
+
+
+#endif // INCLUDE_RICHTBHIT_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbHpd.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbHpd.hh
new file mode 100644
index 0000000000000000000000000000000000000000..7436b43c900798c667fc7e346dc384aa5a7b3643
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbHpd.hh
@@ -0,0 +1,153 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBHPD_HH 
+#define INCLUDE_RICHTBHPD_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4LogicalVolume.hh"
+//#include "RichTbPhDetSupFrame.hh"
+#include <vector>
+#include "RichTbUpgradePhDetSupFrame.hh"
+
+/** @class RichTbHpd RichTbHpd.hh include/RichTbHpd.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2003-11-19
+ */
+class  RichTbPhDetSupFrame;
+
+class RichTbHpd {
+public:
+  /// Standard constructor
+  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;
+  }
+  
+  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;
+  }
+
+  void setTrackingSwitch(bool aV ) {
+    m_TrackingSwitch = aV;
+  }
+  bool TrackingSwitch(){
+    return  m_TrackingSwitch;
+  }
+  
+  void constructHpdMasterTree();
+  void constructHpdComponentsLVol();
+  void constructHpdComponentsPVol();
+  void constructHpdSiPixel();
+  void buildHpdGeometry();
+  
+  
+  
+protected:
+
+private:
+
+  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;
+  
+  
+  
+ 
+
+};
+#endif // INCLUDE_RICHTBHPD_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbHpdGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbHpdGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..62539d4ddb1ea7bf040b2995d70c2f39fbd8ff98
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbHpdGeometryParameters.hh
@@ -0,0 +1,158 @@
+#ifndef INCLUDE_RICHTBHPDGEOMETRYPARAMETERS_HH 
+#define INCLUDE_RICHTBHPDGEOMETRYPARAMETERS_HH 1
+
+// Include files
+
+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 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 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;
+
+// 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 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 RichTbHpdSMasterRadius = RichTbHpdMasterRadius;
+const G4double RichTbHpdSMasterZSize = RichTbHpdMasterZSize;
+const G4double RichTbHpdEnvEndCapRad = RichTbHpdEnvLargeTubInnR - RichTbHpdEnvEndCapRadTolerence;
+const G4double RichTbHpdQuartzWInnerRad = RichTbHpdQuartzWOuterRad - RichTbHpdQuartzWThickness;
+const G4double RichTbHpdPhCathodeOuterRad = RichTbHpdQuartzWInnerRad;
+const G4double RichTbHpdPhCathodeInnerRad = RichTbHpdPhCathodeOuterRad - RichTbHpdPhCathodeThickness;
+
+const G4double RichTbHpdQuartzWDeltaTheta = asin( RichTbHpdActiveInputRad / RichTbHpdQuartzWInnerRad );
+
+const G4double  RichTbHpdPhCathodeDeltaTheta = RichTbHpdQuartzWDeltaTheta;
+
+// now positioning the various parts in an hpd.
+const G4double RichTbEnvLargeTubZLocation =
+ -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;
+
+// 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;
+
+// now for the HPD locations.
+const G4String HpdNamesBox="Hpd0Box";
+
+const G4String HpdNamesLog= "Hpd0Log";
+
+const G4String HpdNamesPhys= "Hpd0Phys";
+const G4double HpdPhCathodeXCenterInPhSup= 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;
+
+
+
+#endif // INCLUDE_RICHTBHPDGEOMETRYPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbHpdRODummySD.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbHpdRODummySD.hh
new file mode 100644
index 0000000000000000000000000000000000000000..38e8fe3d0b755ebbf6ea48b7a742e269d2543e0e
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbHpdRODummySD.hh
@@ -0,0 +1,38 @@
+#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: 
+  /// Standard constructor
+  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() {}
+
+protected:
+
+private:
+
+
+};
+
+RichTbHpdRODummySD::RichTbHpdRODummySD(): G4VSensitiveDetector("RichTbHpdROdummySD") {}
+
+RichTbHpdRODummySD::~RichTbHpdRODummySD(){  }
+
+
+
+#endif // INCLUDE_RICHTBHPDRODUMMYSD_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbHpdSupportFrameGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbHpdSupportFrameGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..98f7ab8aeb71c331b2df1324fe76532250d6556f
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbHpdSupportFrameGeometryParameters.hh
@@ -0,0 +1,42 @@
+#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 RadiatorHpdGap = 25.5*CLHEP::mm + 26.4 CLHEP::mm;
+
+const G4double RadiatorHpdGap =    PhotonDetPlaneGapWrtRadiatorSurface + HpdExtraZShiftFromFocalPlane;
+
+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 ;
+
+
+#endif // INCLUDE_RICHTBHPDSUPPORTFRAMEGEOMETRYPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbIOData.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbIOData.hh
new file mode 100644
index 0000000000000000000000000000000000000000..715624fd827c5a2bd6317a6464f7d90f369859ce
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbIOData.hh
@@ -0,0 +1,29 @@
+#ifndef RichTbIOData_h
+#define RichTbIOData_h 1
+#include "Geant4/globals.hh"
+#include <iostream>
+#include <fstream>
+#include "RichTbRunConfig.hh"
+#include "Geant4/G4Event.hh"
+class RichTbIOData {
+
+  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;
+  
+};
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbLensGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbLensGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..443b1285166569e392aadb0e4339724bdbca7e11
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbLensGeometryParameters.hh
@@ -0,0 +1,32 @@
+// $Id: $
+#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 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 RichTbLensXLocation =0*CLHEP::mm;
+
+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;
+
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbMasterGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbMasterGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..6a6ff177262b723f74f932aea0774770cc97b93c
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbMasterGeometryParameters.hh
@@ -0,0 +1,51 @@
+// $Id: $
+#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 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 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;
+
+// now for variables used after creating the geometry in stepaction.
+
+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)+
+//                                          RichTbCrystalZDnsExtremeAlongCrystal*sin(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)+
+//                                        RichTbCrystalZDnsExtremeAlongCrystal*cos(RichTbCrystalYRotation);
+//const G4double  RichTbCrystalDnsZEnd = RichTbCrystalZDnsExtreme;
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbMaterial.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbMaterial.hh
new file mode 100644
index 0000000000000000000000000000000000000000..dc36e7055923b6559fbedd117004d120888b0465
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbMaterial.hh
@@ -0,0 +1,105 @@
+//This is the declaration of the LHCb RICH Testbeam Material description.
+//Author SE  1-3-2001
+//
+#ifndef RichTbMaterial_h
+#define RichTbMaterial_h 1
+#include "Geant4/globals.hh"
+#include "Geant4/G4Material.hh"
+#include "Geant4/G4MaterialTable.hh"
+#include "Geant4/G4Element.hh"
+#include "Geant4/G4ElementTable.hh"
+#include "Geant4/G4OpticalSurface.hh"
+#include <vector>
+
+class RichTbMaterial {
+
+  public:
+
+    virtual ~ RichTbMaterial();
+  static RichTbMaterial* getRichTbMaterialInstance();
+  
+    G4Material *getAir() {
+        return RichTbAmbientAir;
+    }
+
+    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*   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 */
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbMaterialParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbMaterialParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..9ef4bda7c3d45227d80a13189cadb0085d4fce7b
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbMaterialParameters.hh
@@ -0,0 +1,534 @@
+#ifndef RichTbMaterialParameters_h
+#define RichTbMaterialParameters_h
+#include "Geant4/globals.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbAnalysisManager.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbMiscNames.hh"
+
+//k.
+#include "Geant4/G4PhysicalConstants.hh"
+
+extern void InitializeRichTbMaterial();
+extern void  HistoRichMaterialProperty();
+extern std::vector<G4double> InitN2RefPhotMom();
+extern std::vector<G4double> Initc4f10RefPhotMom();
+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 std::vector<G4double> InitializePhotonMomentumVector();
+extern std::vector<G4double>  InitializePMTWaveL(G4int);
+extern std::vector<G4double> InitializePMTQE(G4int);
+extern G4double  FresnelLossAtNormalIncidence(G4double,G4double);
+
+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);
+
+// 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 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 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
+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
+
+// 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
+
+// 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;
+
+// END OF CHANGE
+
+//static const G4int NumDemagnificationParam=4;
+// The following change in March 2004.
+//static const G4int NumDemagnificationParam=5;
+//static const G4int NumDemagnificationParam=2;
+
+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};
+
+// CHANGED JDICKENS 20/06/05
+//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
+// END OF CHANGE
+
+const G4double PixelPMTDemagErrorLinearFactor=0.0;
+
+//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;
+// 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 };
+
+//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[] =
+//    {321,335,352,374,400,421,448,476,510,549,592,625,
+//     673,715,766,821,854,899};
+//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[] =
+//    {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[] =
+//{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,
+// 17.5,13.6,10.8,8.3,7,6.1,5.2,4.5,3.7,3,
+// 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[]=
+//  {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[]=
+//  {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[]=
+//  { 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[]=
+//  {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;
+// 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[]=
+//  {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.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 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,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,
+// 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};
+
+
+
+
+// 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;
+// 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 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 backscaprob = 0.18;
+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 HpdelectronicsDetAbsEff = 0.85;
+
+// now for the nominal refractive index of Gas Quartz Window
+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};
+
+
+
+// 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
+};
+
+
+#include "RichTbMiscNames.hh"
+
+
+
+#endif                          /*RichTbMaterialParameters_h */
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbMirrorGeometryParamters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbMirrorGeometryParamters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..b8189496a5dacf18ab8b165da792d55509871bda
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbMirrorGeometryParamters.hh
@@ -0,0 +1,60 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBMIRRORGEOMETRYPARAMTERS_HH
+#define INCLUDE_RICHTBMIRRORGEOMETRYPARAMTERS_HH
+
+// Include files
+
+//const G4double MirrorGap = 1.0* CLHEP::mm;
+const G4double MirrorGap = 0.0* CLHEP::mm;
+
+const G4double MirrorInnerRadius  = SphereRadius+MirrorGap;
+
+const G4double MirrorThickness = 5.0*CLHEP::mm;
+
+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 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=39.5*CLHEP::mm;
+const G4double MirrorMaxExtent=58.2*CLHEP::mm;
+
+const G4double MirrorMinThetaExtent = MirrorMinExtent/MirrorInnerRadius;
+const G4double MirrorMaxThetaExtent = MirrorMaxExtent/MirrorInnerRadius;
+
+
+const G4double  MirrorPosX =0.0;
+const G4double  MirrorPosZ = SphereRadius;
+const G4double  MirrorPosY =0.0;
+
+//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;
+
+
+
+
+#endif // INCLUDE_RICHTBMIRRORGEOMETRYPARAMTERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbMiscNames.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbMiscNames.hh
new file mode 100644
index 0000000000000000000000000000000000000000..6f5a82dabb55cd001b7bd7655cef95fc7f404fa6
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbMiscNames.hh
@@ -0,0 +1,65 @@
+// $Id: $
+#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 PMTSDname = "RichTbPMTSD";
+const G4String HPDSDname = "RichTbHPDSD";
+const G4String RichTbHColname="RichTbHitsCollection";
+const G4String RichTbHColnameHpd="RichTbHpdHitsCollection";
+const G4String VesselPhysName = "VesselPhys";
+const G4String LensPhysName = "LensPhys";
+const G4String MasterPhysName = "MasterPhys";
+const G4String PMTEnvelopeBoxPhysName = "PMTEnvelopeBoxPhys";
+const G4String PMTQuartzWPhysName = "PMTQuartzWPhys";
+const G4String PMTPhCathodePhysName = "PMTPhCathodePhys";
+const G4String PMTAnodePhysName = "PMTAnodePhys";
+const G4String CrystalPhysName = "CrystalPhys";
+const G4String CrystalMasterPhysName = "CrystalMasterPhys";
+const G4String CrystalCoverPhysName = "CrystalCoverPhys";
+const G4String DarkCoverPhysName = "DarkCoverPhys";
+const G4String PhDFramePhysName = "PhDFramePhys";
+const G4String MirrorPhysName = "MirrorPhys";
+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 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";
+
+
+
+
+
+
+#endif // INCLUDE_RICHTBMISCNAMES_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbPEInfo.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbPEInfo.hh
new file mode 100644
index 0000000000000000000000000000000000000000..9d000a7490ca811eef38f442ef8a77a05c11f0ae
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbPEInfo.hh
@@ -0,0 +1,51 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBPEINFO_HH 
+#define INCLUDE_RICHTBPEINFO_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4ThreeVector.hh"
+#include "RichTbPhotonInfo.hh"
+
+/** @class RichTbPEInfo RichTbPEInfo.hh include/RichTbPEInfo.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2004-01-20
+ */
+class RichTbPEInfo {
+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:
+
+private:
+
+  G4ThreeVector mPhOrigin;
+  RichTbPhotonInfo* mMotherPhotonInfo;  
+  G4ThreeVector mPeOriginInHpdSupFrame;
+  G4ThreeVector mPhotEmisDir;
+  
+  
+};
+#endif // INCLUDE_RICHTBPEINFO_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbPMT.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbPMT.hh
new file mode 100644
index 0000000000000000000000000000000000000000..316153815a0768db25d7eb45345bb58bebfed3ee
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbPMT.hh
@@ -0,0 +1,147 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBUPGRADEPMT_HH
+#define INCLUDE_RICHTBUPGRADEPMT_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "RichTbUpgradeEC.hh"
+#include "RichTbUpgradeMaster.hh"
+#include <vector>
+
+/** @class RichTbPMT RichTbPMT.hh include/RichTbPMT.hh
+ *
+ *
+ *  @author Sajan EASO
+ *  @date   2003-11-19
+ */
+class  RichTbMaster;
+
+class RichTbPMT {
+public:
+  /// Standard constructor
+  RichTbPMT(RichTbUpgradeEC* aECMaster  );
+
+  virtual ~RichTbPMT( ); ///< Destructor
+
+  void setTrackingSwitch(bool aSw)
+  {m_TrackingSwitch = aSw;}
+  void buildPMTGeometry();
+  void constructPMTComponentsLVol();
+  void constructPMTComponentsPVol(int CurPMTNum) ;
+  void constructPMTMasterTree(int CurPMTNum);
+
+  void constructPMTAnode();
+
+
+  std::vector<G4LogicalVolume*> getRichTbPMTMasterLVol()
+  {    return RichTbPMTMasterLVol;}
+
+  std::vector<G4LogicalVolume*> getRichTbPMTSMasterLVol()
+  {    return  RichTbPMTSMasterLVol;}
+
+
+  G4LogicalVolume* getRichTbPMTEnvelopeLVol()
+  {    return RichTbPMTEnvelopeLVol;}
+
+
+  /*
+  G4LogicalVolume* getRichTbPMTEnvelopeEndCapLVol()
+  {
+    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;
+  }
+
+  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;
+  bool m_TrackingSwitch;
+  G4int CurNumPmts;
+
+  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<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;
+
+
+};
+#endif // INCLUDE_RICHTBHPD_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbPMTGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbPMTGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..9864579cf2a71ff845b7eda16793fa1fe948b6ba
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbPMTGeometryParameters.hh
@@ -0,0 +1,208 @@
+// $Id: $
+#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;
+	}
+private:
+	G4int NumPmts= 8;
+	G4int NumPmtsUpgrade15 = 16;
+};*/
+
+//envelope size and position
+
+
+//static G4int NumPmtsUpgrade15 = RichTbPMTGeometryParameters::getNumPmtsUpgrade();
+static const G4int NumPmtsUpgrade15 = 16;
+//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 const G4int NumPmtsWithHpd = 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 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 PMTEnvelopeBoxXSize = PMTMasterBoxXSize - PMTLateralTolerence;
+const G4double PMTEnvelopeBoxYSize = PMTMasterBoxYSize - PMTLateralTolerence;
+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 PMTEnvelopeSubPartXSize = PMTEnvelopeBoxXSize - 2.0 * PMTEnvelopeThickness;
+const G4double PMTEnvelopeSubPartYSize = PMTEnvelopeBoxYSize - 2.0 * PMTEnvelopeThickness;
+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 RichTbPMTEnvBoxXLocation = 0;
+const G4double RichTbPMTEnvBoxYLocation = 0;
+//const G4double RichTbPMTEnvBoxZLocation = 10.2*CLHEP::mm - 0.5 * PMTEnvelopeBoxZSize - 1.0*CLHEP::mm;
+
+//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 RichTbPMTQuartzWindowXLocation = 0;
+const G4double RichTbPMTQuartzWindowYLocation = 0;
+//const G4double RichTbPMTQuartzWindowZLocation = -4.9*CLHEP::mm - 0.5 * PMTQuartzWindowSupZSize;
+
+const G4double RichTbPMTQuartzWindowZLocation = -0.5*PMTMasterBoxZSize +
+		PMTEndToQuartzOuterSurface + 0.5 * PMTQuartzWindowSupZSize;
+
+
+const G4double RichTbPMTEdgeToQuartzInsideEdgeDeltaZ= PMTEndToQuartzOuterSurface + PMTQuartzWindowSupZSize;
+
+
+const G4double RichTbPMTEnvBoxZLocation = RichTbPMTQuartzWindowZLocation + PMTGapInComponents +
+		0.5 * (PMTQuartzWindowSupZSize + PMTEnvelopeBoxZSize) ;
+
+
+//const G4double RichTbGasQuartzWindowThickness= 6.0*CLHEP::mm; // unused param
+
+//photocathode size and position
+
+const G4double PMTPhCathodeSupXSize = PMTQuartzWindowSupXSize;
+const G4double PMTPhCathodeSupYSize = PMTQuartzWindowSupYSize;
+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 );
+
+
+
+//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 RichTbPMTAnodeXLocation = 0.0;
+const G4double RichTbPMTAnodeYLocation = 0.0;
+//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;
+
+// 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;
+
+
+// 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;
+
+
+#endif // INCLUDE_RICHTBHPDGEOMETRYPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbPMTSupportFrameGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbPMTSupportFrameGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..2af2409d33a66cf75462b336f5dc3a182361ce60
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbPMTSupportFrameGeometryParameters.hh
@@ -0,0 +1,226 @@
+#ifndef INCLUDE_RICHTBPMTSUPPORTFRAMEGEOMETRYPARAMETERS_HH
+#define INCLUDE_RICHTBPMTSUPPORTFRAMEGEOMETRYPARAMETERS_HH 1
+//size and location of PMTPhDetSupport frames
+
+
+// Phot det sup frame in Test beam
+// Looking downstream from the origin of the beam towards +Z axis
+
+/*
+   --------------             -----------------
+   |   PhDet 0   |            |    PhDet 1    |
+   |             |            |               |
+   |  ---------  |            | -----------   |
+   |  |  EC 0 |  |      Beam  | |    EC 1  |  |
+   |  ---------  |            | -----------   |
+   |             |            |               |
+   |------------ |            |---------------|
+
+   Inside each EC the PMTs are arranged as follows. This also when looking towards downstream from the origin of beam.
+
+
+            EC 0                    EC 1
+
+     PMT 3        PMT 2         PMT 7     PMT 6
+
+     PMT 1        PMT 0         PMT 5     PMT 4
+
+
+  Coordinate system:   Z along beam line
+                       Y going upwards
+                       X goes left when looking downstream.
+
+
+   PMT label for efficiency:
+   PMT Number   PMT Label
+     0            JA
+     1            JA
+     2            JB
+     3            JB
+     4            SA
+     5            SA
+     6            SB
+     7            SB
+
+
+
+
+  PMT rotations
+
+     PMT number       rotation wrt postive Z axis in radians
+
+        0                pi
+        1                pi
+        2                pi/2
+        3                pi/2
+        4                -pi/2
+        5                -pi/2
+        6                 0.0
+        7                 0.0
+
+
+    PMT Pixel numbering for PMT 7 as one looks downstream along positive Z axis.
+    (Same as Paolo scheme sifted by 1. His scheme starts at 1, whereas here it starts at 0 for C++ arrays).
+
+
+    63  62  61    .....   56
+    55  54  53    .....   48
+    47 ...................40
+    39 ...................32
+    31 ...................24
+    23 ...................16
+    15 ...................8
+    7   6   5  4  3  2  1 0
+
+
+
+
+ */
+
+
+//#include "RichTbRunConfig.hh" //in order to make geometry changes without recompiling
+//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 NumPhDetSupFrames15 = 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 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 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;
+
+// PMT Rotation values wrt positive Z.
+//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;
+
+// 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 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 PhDetSupFrameFinalYPos = 0.0;
+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 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 ECSupportXLocation = ECXLocation;
+const G4double ECSupportYLocation = ECYLocation;
+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;
+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;
+
+
+
+#endif // INCLUDE_RICHTBPMTSUPPORTFRAMEGEOMETRYPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbPeUserInfoAttach.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbPeUserInfoAttach.hh
new file mode 100644
index 0000000000000000000000000000000000000000..c04f3b88c5285da9dd257a2ad99d44fd51bc46ac
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbPeUserInfoAttach.hh
@@ -0,0 +1,14 @@
+// $Id: $
+#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* RichTbPeBckAttach( const G4Track& aphotontk, G4Track* aSecPETrack ) ;
+
+#endif // INCLUDE_RICHTBPEUSERINFOATTACH_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbPhDFrameGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbPhDFrameGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..6e4c751d8c7f2d1ddd7ebe171557f0f026bdb269
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbPhDFrameGeometryParameters.hh
@@ -0,0 +1,51 @@
+// $Id: $
+#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 RichTbPhDFrameYLocation = -RichTbPhDFrameOriginShiftFromFloorY;
+const G4double RichTbPhDFrameXShiftAlongCrystal =0.0;
+const G4double RichTbPhDFrameZShiftAlongCrystal = +RichTbPhDFrameOriginShiftFromLeftZ;
+
+const G4double RichTbPhDFrameXLocation = RichTbPhDFrameXShiftAlongCrystal;
+const G4double RichTbPhDFrameZLocation = RichTbPhDFrameZShiftAlongCrystal;
+
+// now for variables used after creating the geometry in stepaction.
+
+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)+
+//                                          RichTbCrystalZDnsExtremeAlongCrystal*sin(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)+
+//                                        RichTbCrystalZDnsExtremeAlongCrystal*cos(RichTbCrystalYRotation);
+//const G4double  RichTbCrystalDnsZEnd = RichTbCrystalZDnsExtreme;
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbPhotoElectron.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbPhotoElectron.hh
new file mode 100644
index 0000000000000000000000000000000000000000..7671592acad5a2b3bf8a7c84d34b796a5a334d26
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbPhotoElectron.hh
@@ -0,0 +1,83 @@
+//
+// ********************************************************************
+// * DISCLAIMER                                                       *
+// *                                                                  *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in:                      *
+// *   http://cern.ch/geant4/license                                  *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.                                                             *
+// *                                                                  *
+// * This  code  implementation is the  intellectual property  of the *
+// * GEANT4 collaboration.                                            *
+// * By copying,  distributing  or modifying the Program (or any work *
+// * based  on  the Program)  you indicate  your  acceptance of  this *
+// * statement, and all its terms.                                    *
+// ********************************************************************
+//
+//
+// $Id: RichTbPhotoElectron.h,v 1.1 2003/04/29 15:04:49 seaso Exp $
+// GEANT4 tag $Name:  $
+//
+// 
+// ------------------------------------------------------------
+//      GEANT 4 class header file
+//
+//      History: first implementation, based on object model of
+//      4-th April 1996, G.Cosmo
+// ****************************************************************
+//  Added particle definitions, H.Kurashige, 19 April 1996
+//  Added SetCuts implementation for Electron, L.Urban, 30 May 1996
+//  Added not static GetEnergyCuts() and GetLengthCuts(), G.Cosmo, 11 July 1996
+// ----------------------------------------------------------------
+
+// Each class inheriting from G4VLepton
+// corresponds to a particle type; one and only one
+// instance for each class is guaranteed.
+// RichTbPhotoElectron created by SE 10-3-2003.
+#ifndef RichTbPhotoElectron_h
+#define RichTbPhotoElectron_h 1
+
+#include "Geant4/globals.hh"
+#include "Geant4/G4ios.hh"
+//#include "Geant4/G4VLepton.hh"
+#include "Geant4/G4ParticleDefinition.hh"
+class G4Positron;
+// ######################################################################
+// ###                         RICHPHOTOELECTRON                      ###
+// ######################################################################
+
+class RichTbPhotoElectron : public G4ParticleDefinition
+{
+  // friend class G4Positron;
+ private:
+   static RichTbPhotoElectron* theRichTbPhotoElectronInstance;
+
+ private: //hide constructor as private
+
+ public:
+   virtual ~RichTbPhotoElectron(){}
+
+   static RichTbPhotoElectron* Definition();
+   static RichTbPhotoElectron* PhotoElectronDefinition();
+   static RichTbPhotoElectron* PhotoElectron();
+
+};
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbPhotonInfo.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbPhotonInfo.hh
new file mode 100644
index 0000000000000000000000000000000000000000..914ce41776374ca8a2ec153d5a7dcd18265e8f6b
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbPhotonInfo.hh
@@ -0,0 +1,105 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBPHOTONINFO_HH 
+#define INCLUDE_RICHTBPHOTONINFO_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4ThreeVector.hh"
+
+/** @class RichTbPhotonInfo RichTbPhotonInfo.hh include/RichTbPhotonInfo.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2004-01-20
+ */
+class RichTbPhotonInfo {
+public: 
+  /// Standard constructor
+  RichTbPhotonInfo( ); 
+
+  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;}
+
+  
+  G4double ParentChTrackMomentum() 
+  {  return mParentChTrackMomentum;}
+  G4ThreeVector ParentChTrackThreeMom() 
+  {  return  mParentChTrackThreeMom;}
+  G4ThreeVector PhotonCrystalDnsTIRCoord() 
+  {  return mPhotonCrystalDnsTIRCoord;}
+  G4ThreeVector PhotonSphMirrReflCoord() 
+  {  return mPhotonSphMirrReflCoord;}
+  G4ThreeVector PhotonCrystalDnsExitCoord()
+  {  return mPhotonCrystalDnsExitCoord;}
+
+
+  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 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++;}
+  
+    
+    
+
+protected:
+
+private:
+
+  G4int mNumRayleighScat;
+  G4ThreeVector mPhotonCoordPMTQWExternal;
+  G4int mPhotonPMTQWMultipleIncidenceFlag;
+  G4double mCkvCosThetaAtProd;
+  G4double mCkvPhiAtProd;
+  G4double mCkvPhotonEnergyAtProd;
+  G4double mParentChTrackMomentum;
+  G4ThreeVector mParentChTrackThreeMom;
+  G4ThreeVector mPhotonCrystalDnsTIRCoord;
+  G4ThreeVector mPhotonSphMirrReflCoord;
+  G4ThreeVector mPhotonCrystalDnsExitCoord;
+  G4int mPhotonRadiatorMultipleIncidenceFlag;
+  
+};
+#endif // INCLUDE_RICHTBPHOTONINFO_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbPhotonProdHisto.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbPhotonProdHisto.hh
new file mode 100644
index 0000000000000000000000000000000000000000..eb80382fbeb191f93e14b9feec507c159254ef6a
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbPhotonProdHisto.hh
@@ -0,0 +1,15 @@
+// $Id: $
+#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);
+
+#endif // INCLUDE_RICHTBPHOTONPRODHISTO_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbPhotonUserInfoAttach.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbPhotonUserInfoAttach.hh
new file mode 100644
index 0000000000000000000000000000000000000000..81e246211aeb9390941fea1862157c9b7c00eb01
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbPhotonUserInfoAttach.hh
@@ -0,0 +1,18 @@
+// $Id: $
+#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);
+
+
+#endif // INCLUDE_RICHTBPHOTONUSERINFOATTACH_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbPhysicsList.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbPhysicsList.hh
new file mode 100644
index 0000000000000000000000000000000000000000..9e230134e3ca4a41c6842018d2c97d06af365ee2
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbPhysicsList.hh
@@ -0,0 +1,41 @@
+#ifndef RichTbPhysicsList_h
+#define RichTbPhysicsList_h 1
+
+#include "Geant4/globals.hh"
+#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;
+
+};
+#endif                          /* RichTbPhysicsList_h */
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbPmtPixelEfficiency.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbPmtPixelEfficiency.hh
new file mode 100644
index 0000000000000000000000000000000000000000..31092bbd607cdb83f2d56368a4acdda70db26744
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbPmtPixelEfficiency.hh
@@ -0,0 +1,49 @@
+#ifndef INCLUDE_RICHTBPMTPIXELEFFICIENCY_HH
+#define INCLUDE_RICHTBPMTPIXELEFFICIENCY_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include <vector>
+#include <cmath>
+#include <map>
+
+
+
+/** @class RichTbPmtPixelEfficiency RichTbPmtPixelEfficiency.hh include/RichTbPmtPixelEfficiency.hh
+ *
+ *
+ *  @author Sajan Easo
+ *  @date   2015-03-11
+ */
+class RichTbPmtPixelEfficiency {
+public:
+  /// Standard constructor
+  // RichTbPmtPixelEfficiency( );
+  static RichTbPmtPixelEfficiency* getRichTbPmtPixelEfficiencyInstance();
+
+  virtual ~RichTbPmtPixelEfficiency( ); ///< Destructor
+
+  void PmtPixelEffInitialize();
+  G4double getPixelEff(G4int aPmt, G4int aPixel)
+  {  return  mPmtPixelEff [aPmt] [aPixel]; }
+  G4bool PmtPixelEffOK (G4int aPmtNum, G4int aPixelNum);
+  void ReadPixelEfficiency();
+  void ReadAndCopyPixelEffFromFile(G4String aInpFileName  );
+  void FillPixelEfficiency();
+
+
+protected:
+
+private:
+  RichTbPmtPixelEfficiency( );
+  static RichTbPmtPixelEfficiency* RichTbPmtPixelEfficiencyInstance;
+
+  std::vector <std::vector <G4double> >  mPmtPixelEff;
+  std::vector <std::vector <G4String> >  mPmtPixelLabel;
+
+  std::multimap<G4String,G4double> mPmtAnodeEffMap;
+
+  G4int RichTbTotNumPmtFinal = 0;
+
+};
+#endif // INCLUDE_RICHTBPMTPIXELEFFICIENCY_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbPmtSteppingAction.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbPmtSteppingAction.hh
new file mode 100644
index 0000000000000000000000000000000000000000..c4c1b5163a3a20459e235307d6ab32757d85d9bd
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbPmtSteppingAction.hh
@@ -0,0 +1,22 @@
+#ifndef RichTbPmtSteppingAction_h
+#define RichTbPmtSteppingAction_h 1
+#include "Geant4/G4UserSteppingAction.hh"
+#include "Geant4/G4VDiscreteProcess.hh"
+#include "Geant4/G4VParticleChange.hh"
+#include "Geant4/G4ParticleChange.hh"
+#include "RichTbMiscNames.hh"
+
+
+class RichTbPmtSteppingAction:public  G4UserSteppingAction {
+
+public:
+  RichTbPmtSteppingAction();
+  virtual ~ RichTbPmtSteppingAction();
+  void UserSteppingAction(const G4Step * aStep);
+
+private:
+  G4double mChTrackMinMomFactorForHisto;
+
+
+};
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbPrimaryGeneratorAction.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbPrimaryGeneratorAction.hh
new file mode 100644
index 0000000000000000000000000000000000000000..cbf51bc495b6ab7c54abce9186cda9e994fa6c18
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbPrimaryGeneratorAction.hh
@@ -0,0 +1,35 @@
+#ifndef RichTbPrimaryGeneratorAction_h
+#define RichTbPrimaryGeneratorAction_h 1
+
+#include "Geant4/G4VUserPrimaryGeneratorAction.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbAnalysisManager.hh"
+#include "Geant4/G4ParticleDefinition.hh"
+
+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();
+  //    G4double GetCurGenPartEnergy() {
+  //      return CurGenPartEnergy;
+  //  }
+  private:
+
+     G4ParticleGun * particleGun;
+
+  // G4double CurGenPartEnergy;
+    G4ParticleDefinition *CurrentBeamParticle;
+};
+#endif                          /*RichTbPrimaryGeneratorAction_h */
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbRODummySD.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbRODummySD.hh
new file mode 100644
index 0000000000000000000000000000000000000000..aaf5a3cf0e0c778d19f7d642b70f68b3b37f94f1
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbRODummySD.hh
@@ -0,0 +1,35 @@
+// $Id: $
+#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: 
+  /// Standard constructor
+  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() {}
+};
+
+
+RichTbRODummySD::RichTbRODummySD()
+  : G4VSensitiveDetector("RichTbROdummySD") {}
+  
+  RichTbRODummySD::~RichTbRODummySD() 
+  {  }
+#endif // INCLUDE_RICHTBRODUMMYSD_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbROGeometry.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbROGeometry.hh
new file mode 100644
index 0000000000000000000000000000000000000000..0dcefb975cd1aaa1f7addf1102e5d140ca26d089
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbROGeometry.hh
@@ -0,0 +1,38 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBROGEOMETRY_HH 
+#define INCLUDE_RICHTBROGEOMETRY_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VReadOutGeometry.hh"
+#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: 
+  /// Standard constructor
+  RichTbROGeometry(G4String, RichTbDetectorConstruction* ); 
+
+  virtual ~RichTbROGeometry( ); ///< Destructor
+
+  G4VPhysicalVolume* Build();
+
+  RichTbDetectorConstruction* getCurDet() 
+  {
+    return CurDet;
+  }
+  
+protected:
+
+private:
+  RichTbDetectorConstruction* CurDet;
+  
+};
+#endif // INCLUDE_RICHTBROGEOMETRY_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbROGeometryHpd.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbROGeometryHpd.hh
new file mode 100644
index 0000000000000000000000000000000000000000..84ff3ac99c2a9fa721e0169f921c11e65f313e28
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbROGeometryHpd.hh
@@ -0,0 +1,37 @@
+#ifndef INCLUDE_RICHTBROGEOMETRYHPD_HH 
+#define INCLUDE_RICHTBROGEOMETRYHPD_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VReadOutGeometry.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+
+class RichTbDetectorConstruction;
+
+
+/** @class RichTbROGeometryHpd RichTbROGeometryHpd.hh include/RichTbROGeometryHpd.hh
+ *  
+ *
+ *  @author Sajan Easo
+ *  @date   2015-05-16
+ */
+class RichTbROGeometryHpd:public G4VReadOutGeometry  {
+public: 
+  /// Standard constructor
+  RichTbROGeometryHpd(G4String, RichTbDetectorConstruction* ); 
+
+  virtual ~RichTbROGeometryHpd( ); ///< Destructor
+
+  G4VPhysicalVolume* Build();
+  RichTbDetectorConstruction* getCurDet()
+  {
+    return CurDet;
+  }
+
+
+protected:
+
+private:
+  RichTbDetectorConstruction* CurDet;
+};
+#endif // INCLUDE_RICHTBROGEOMETRYHPD_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbRadiatorGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbRadiatorGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..0024a84aa90412e9fdbddb8cf1e0145be244982f
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbRadiatorGeometryParameters.hh
@@ -0,0 +1,109 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBRADIATORGEOMETRYPARAMETERS_HH
+#define INCLUDE_RICHTBRADIATORGEOMETRYPARAMETERS_HH 1
+
+// Include files
+/** @class RichTbVesselGeometryParameters RichTbVesselGeometryParameters.hh include/RichTbVesselGeometryParameters.hh
+ *
+ *
+ *  @author Sajan EASO
+ *  @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 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 BigBoxXLocation = 0.0;
+const G4double BigBoxYLocation = 0.0;
+const G4double BigBoxZLocation = 0.0;
+
+const G4double RichTbUpgradeRadiatorXLocation = 0.0;
+const G4double RichTbUpgradeRadiatorYLocation = 0.0;
+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 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  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;
+
+//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  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 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 Cyl1XLocation = 0.0;
+const G4double Cyl1YLocation = 0.0;
+//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/G4RichTbSimH/include/RichTbRunAction.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbRunAction.hh
new file mode 100644
index 0000000000000000000000000000000000000000..9b2d030671bb9df2d6751e220aa28f43fb7537bb
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbRunAction.hh
@@ -0,0 +1,29 @@
+#ifndef RichTbRunAction_h
+#define RichTbRunAction_h 1
+
+#include "Geant4/globals.hh"
+#include "Geant4/G4UserRunAction.hh"
+#include "RichTbAnalysisManager.hh"
+
+class G4Timer;
+class G4Run;
+
+class RichTbRunAction:public G4UserRunAction {
+  public:
+
+    RichTbRunAction();
+    virtual ~ RichTbRunAction();
+
+  public:
+
+    virtual void BeginOfRunAction(const G4Run * aRun);
+    virtual void EndOfRunAction(const G4Run * aRun);
+    RichTbAnalysisManager *getAnalysisMRun() {
+        return ranalysisManager;
+    }
+  private:
+
+     G4Timer * timer;
+    RichTbAnalysisManager *ranalysisManager;
+};
+#endif                          /*RichTbRunAction_h */
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbRunConfig.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbRunConfig.hh
new file mode 100644
index 0000000000000000000000000000000000000000..2b44d89bf14579fe6632ead000d16ac211393329
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbRunConfig.hh
@@ -0,0 +1,604 @@
+#ifndef RichTbRunConfig_h
+#define RichTbRunConfig_h 1
+
+#include "Geant4/globals.hh"
+#include <vector>
+#include <cmath>
+#include <fstream>
+#include "Geant4/G4ThreeVector.hh"
+#include "CLHEP/Units/SystemOfUnits.h"
+
+
+class RichTbRunConfig {
+  public:
+    //RichTbRunConfig();
+    virtual ~ RichTbRunConfig();
+
+    static RichTbRunConfig* getRunConfigInstance();
+
+  G4int getRichTbHall_visib()
+  {return  RichTbHall_visib;}
+
+  G4int   getRichTbUpgradeVessel_visib()
+  {    return RichTbUpgradeVessel_visib;  }
+
+ G4int   getRichTbCrystal_visib()
+  {    return RichTbCrystal_visib;  }
+
+ G4int   getRichTbLens_visib()
+  {    return RichTbLens_visib;  }
+
+  G4int   getRichTbUpgradeRadiator_visib()
+  {    return RichTbUpgradeRadiator_visib;  }
+
+  G4int   getRichTbUpgradeMirror_visib()
+  {    return RichTbUpgradeMirror_visib;  }
+
+  G4int   getRichTbUpgradeDarkCover_visib()
+  {    return RichTbUpgradeDarkCover_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   getRichTbMaster_visib()
+  // {    return RichTbMaster_visib;  }
+
+ G4int   getRichTbPMTEnvelope_visib()
+  {    return RichTbPMTEnvelope_visib;  }
+
+ G4int   getRichTbPMTQuartzW_visib()
+  {    return RichTbPMTQuartzW_visib;  }
+
+ G4int   getRichTbPMTPhCathode_visib()
+  {    return RichTbPMTPhCathode_visib;  }
+
+ G4int   getRichTbPMTAnode_visib()
+  {    return RichTbPMTAnode_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 getRichTbPMTMaster_visib()
+  { return  RichTbPMTMaster_visib;}
+  G4int getRichTbPMTSMaster_visib()
+  {  return RichTbPMTSMaster_visib;}
+  // G4int getRichTbPMTEnvelope_visib()
+  // {    return RichTbPMTEnvelope_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 getGasTypeCode() {return  GasTypeCode;}
+
+  G4double getNitrogenPressure()
+  {   return NitrogenPressure;}
+  G4double getNitrogenTemperature()
+  {    return NitrogenTemperature;}
+
+ G4double getNominalNitrogenPressure()
+  {   return NominalNitrogenPressure;}
+  G4double getNominalNitrogenTemperature()
+  {    return NominalNitrogenTemperature;}
+
+  G4double getc4f10Pressure()
+  {   return c4f10Pressure;}
+  G4double getc4f10Temperature()
+  {    return c4f10Temperature;}
+
+ G4double getNominalc4f10Pressure()
+  {   return Nominalc4f10Pressure;}
+  G4double getNominalc4f10Temperature()
+  {    return Nominalc4f10Temperature;}
+
+
+
+  G4int  getMirrorOrientCode() {
+    return MirrorOrientCode;
+  }
+
+  G4double  getMirrorAddTiltX()
+  {    return  MirrorAddTiltX;}
+
+  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 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 getBeamDirX()
+  {    return  mBeamDirX;  }
+  G4double getBeamDirY()
+  {  return mBeamDirY;}
+  G4double getBeamDivergenceX()
+  {    return mBeamDivergenceX;}
+  G4double getBeamDivergenceY()
+  {    return mBeamDivergenceY;}
+
+
+ G4double getPMTPEMomInit()
+  {
+    return PMTPEMomInit;
+  }
+ G4double getHpdPEMomInit ()
+  {
+    return PMTPEMomInit;
+  }
+
+
+  G4int getHitCreationOption()
+  {
+    return HitCreationOption;
+
+  }
+
+  G4double getECXShift() {
+	  return ECXShift;
+  }
+
+  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 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];
+
+    return aAdRot;
+  }
+
+  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;
+  }
+
+  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;
+  }
+
+  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;}
+  void setPhSupFrameAdditionalZRot(G4double aPhSupFrameAdditionalZRot) {
+    mPhSupFrameAdditionalZRot=aPhSupFrameAdditionalZRot;}
+
+  G4int getPMTSiReflFlag() {
+    return mPMTSiReflFlag;}
+
+   G4int getRadiatorConfiguration() {
+    return mRadiatorConfiguration;}
+
+   G4double getMapmtDetectionEfficiency()
+   {return mMapmtDetectionEfficiency;}
+
+  //   G4double getMapmtPixelGap()
+  //  {  return mMapmtPixelGap;}
+
+  G4bool ApplyPixelEff() {
+    return (mMapmtPixelEfficiencyFlag == 0 ) ? false : true;
+  }
+
+  G4int MapmtPixelEfficiencyFlag ()
+  {  return mMapmtPixelEfficiencyFlag;}
+
+
+
+  G4String MapmtPixelOptEffFileNameJura()
+  {  return mMapmtPixelOptEffFileNameJura;}
+
+  G4String MapmtPixelThr7EffFileNameJura()
+  {  return mMapmtPixelThr7EffFileNameJura;}
+
+  G4String MapmtPixelOptEffFileNameSaleve()
+  {  return mMapmtPixelOptEffFileNameSaleve;}
+
+  G4String MapmtPixelThr7EffFileNameSaleve()
+  {  return mMapmtPixelThr7EffFileNameSaleve;}
+
+  //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;}
+
+  G4int getRichTbHpdQW_visib() {return  RichTbHpdQW_visib;}
+
+
+  G4int  getRichTbHpdPHC_visib() {return RichTbHpdPHC_visib; }
+
+  G4int  getRichTbHpdSID_visib() {return RichTbHpdSID_visib; }
+
+  G4int  getRichTbHpdENV_visib() {return RichTbHpdENV_visib; }
+
+  G4int  getRichTbHpdENVCAP_visib() {return RichTbHpdENVCAP_visib; }
+
+  G4int  getRichTbHpdSM_visib() {return RichTbHpdSM_visib; }
+
+  G4int  getRichTbHpdMas_visib() {return RichTbHpdMas_visib; }
+
+  G4int  getRichTbHpdSiPix_visib()  {  return RichTbHpdSiPix_visib;}
+
+
+  G4long getRandomSeedInput () {  return mRandomSeedInput;}
+
+
+
+
+  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;
+  G4int RichTbUpgradeVessel_visib;
+  G4int RichTbCrystal_visib;
+  G4int RichTbLens_visib;
+  G4int RichTbUpgradeRadiator_visib;
+  G4int RichTbCrystalCover_visib;
+  G4int RichTbUpgradeDarkCover_visib;
+  G4int RichTbUpgradeUpsDarkCover_visib;
+  G4int RichTbUpgradeSideDarkCover_visib;
+   G4int RichTbUpgradeDnsDarkCover_visib;
+
+  G4int RichTbPMTEnvelope_visib;
+  G4int RichTbPMTQuartzW_visib;
+  G4int RichTbPMTPhCathode_visib;
+  G4int RichTbPMTAnode_visib;
+  G4int RichTbPhDFrame_visib;
+  G4int RichTbUpgradeMirror_visib;
+  G4int RichTbPhDetSupFrame_visib;
+  G4int  RichTbEC_visib;
+  G4int RichTbPMTMaster_visib;
+  G4int RichTbPMTSMaster_visib;
+  G4int RichTbPMTEndCap_visib;
+  G4int RichTbPMTFrontRing_visib;
+
+
+   G4int RichTbGasQuWin_visib;
+
+
+
+
+  G4int RichTbHpdQW_visib;
+  G4int RichTbHpdPHC_visib;
+  G4int RichTbHpdSID_visib;
+  G4int RichTbHpdENV_visib;
+  G4int RichTbHpdENVCAP_visib ;
+  G4int RichTbHpdSM_visib;
+  G4int RichTbHpdMas_visib;
+  G4int RichTbHpdSiPix_visib;
+
+
+
+  G4int GasTypeCode;
+
+  G4double NitrogenPressure;
+  G4double NitrogenTemperature;
+  G4double NominalNitrogenPressure;
+  G4double NominalNitrogenTemperature;
+
+  G4double c4f10Pressure;
+  G4double c4f10Temperature;
+  G4double Nominalc4f10Pressure;
+  G4double Nominalc4f10Temperature;
+
+  G4int MirrorOrientCode;
+  G4double MirrorAddTiltX;
+  G4double MirrorAddTiltY;
+  G4int mNonOptimalPMTCondition;
+  G4double mNonOptimalPMTAbsEff;
+  G4double mHpdpeBackScaProb;
+  G4long mRandomSeedInput;
+
+
+
+  G4int  RichTbNumPartEvent;
+  G4int  RichTbParticleTypeCode;
+  G4int  RichTbParticleStartPosCode;
+  G4int  RichTbParticleDirectionCode;
+  G4int  RichTbParticleEnergyCode;
+  G4double  RichTbParticleMomentum;
+  G4double PosBeamFraction;
+  G4double mBeamDirX;
+  G4double mBeamDirY;
+  G4double mBeamDivergenceX;
+  G4double mBeamDivergenceY;
+  G4double mBeamXPosShift;
+  G4double mBeamYPosShift;
+
+  G4double mBeamSpecialXPos;
+  G4double mBeamSpecialYPos;
+  G4double mBeamSpecialZPos;
+
+  G4double mBeamSpecialXRange;
+
+  G4int mActivateBeamShiftNtuple;
+
+  G4double PMTPEMomInit;
+
+  G4int HitCreationOption;
+
+  G4double ECXShift;
+
+  G4int WriteOutputFile;
+
+  G4String MirrorReflFileName;
+  G4String OutputFileName;
+  G4String OutputHistoFileName;
+  G4String OutputNtupleFileName;
+
+  G4int mVerboseInfoFlag ;
+  G4int mBatchModeFlag;
+  G4int mNumEventInBatchMode;
+  G4int mVerboseOutputFileFlag;
+  G4int mPMTSiReflFlag;
+
+
+  G4double mConstPhotWlenBeam;
+  G4double mPhotWlenMinBeam;
+  G4double mPhotWlenMaxBeam;
+
+  G4int mSpecialStudyVesselRotation;
+  G4int mSpecialStudyCrystalRotation;
+  G4double mSpecialStudyCrystalRotationX;
+  G4double mSpecialStudyCrystalRotationY;
+  G4int mSpecialStudyMasterRotation;
+  G4double mSpecialStudyMasterRotationX;
+  G4double mSpecialStudyMasterRotationY;
+  G4int mRadiatorConfiguration;
+
+  std::vector<G4double> mDemagConstShiftAtAnodeX;
+  std::vector<G4double> mDemagConstShiftAtAnodeY;
+  std::vector<G4double> mPMTAdditionalLocalRotationZ;
+  std::vector<G4double> mPMTAlignmentLocalShiftX;
+  std::vector<G4double> mPMTAlignmentLocalShiftY;
+  std::vector<G4double> mPhSupFrameAdditionalShift;
+  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.
+
+
+  G4String mMapmtPixelOptEffFileNameJura;
+  G4String mMapmtPixelThr7EffFileNameJura;
+  G4String mMapmtPixelOptEffFileNameSaleve;
+  G4String mMapmtPixelThr7EffFileNameSaleve;
+  G4String mMapmtPixelOptEffFileNameJuraUpgradeDummy;
+  G4String mMapmtPixelOptEffFileNameSaleveUpgradeDummy;
+  G4String mMapmtPixelEffFileNameJuraTop100;
+  G4String mMapmtPixelEffFileNameJuraBottom100;
+  G4String mMapmtPixelEffFileNameSaleveTop100;
+  G4String mMapmtPixelEffFileNameSaleveBottom100;
+
+
+
+
+
+};
+#endif                          /*RichTbRunConfig_h */
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbStackingAction.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbStackingAction.hh
new file mode 100644
index 0000000000000000000000000000000000000000..fd76e3340b4dea7856e372a247f6b039a249f6e4
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbStackingAction.hh
@@ -0,0 +1,16 @@
+#ifndef RichTbStackingAction_h
+#define RichTbStackingAction_h 1
+
+#include "Geant4/G4UserStackingAction.hh"
+class RichTbStackingAction:public G4UserStackingAction {
+
+  public:
+    RichTbStackingAction();
+    virtual ~ RichTbStackingAction();
+    void NewStage() {;
+    } void PrepareNewEvent() {;
+    }
+
+  private:
+};
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbSteppingAction.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbSteppingAction.hh
new file mode 100644
index 0000000000000000000000000000000000000000..8bac7df908de42760c13a892b159c804bed8460b
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbSteppingAction.hh
@@ -0,0 +1,41 @@
+#ifndef RichTbSteppingAction_h
+#define RichTbSteppingAction_h 1
+
+#include "Geant4/G4UserSteppingAction.hh"
+#include "Geant4/G4VDiscreteProcess.hh"
+#include "Geant4/G4VParticleChange.hh"
+#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);
+
+
+  //    G4double getPMTPhElectronKE() {
+  //      return PMTPhElectronKE;
+  //  }
+
+  private:
+  //    G4double PMTPhElectronKE;
+  // G4VParticleChange *uParticleChange;
+
+    double RichTbRadiatorXNegExtreme_;
+    double RichTbRadiatorXPosExtreme_;
+    double RichTbRadiatorYNegExtreme_;
+    double RichTbRadiatorYPosExtreme_;
+    double RichTbRadiatorZNegExtreme_;
+    double RichTbRadiatorZPosExtreme_;
+    double RichTbRadiatorDnsZLocation_;
+
+
+};
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbSteppingActionBase.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbSteppingActionBase.hh
new file mode 100644
index 0000000000000000000000000000000000000000..be99794541235d2452d4116b7ac7bb3466e65363
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbSteppingActionBase.hh
@@ -0,0 +1,38 @@
+#ifndef INCLUDE_RICHTBSTEPPINGACTIONBASE_HH 
+#define INCLUDE_RICHTBSTEPPINGACTIONBASE_HH 1
+
+// Include files
+#include "Geant4/G4UserSteppingAction.hh"
+#include "Geant4/G4VDiscreteProcess.hh"
+#include "Geant4/G4VParticleChange.hh"
+#include "Geant4/G4ParticleChange.hh"
+#include "Geant4/G4Step.hh"
+
+#include "RichTbSteppingAction.hh"
+#include "RichTbPmtSteppingAction.hh"
+
+/** @class RichTbSteppingActionBase RichTbSteppingActionBase.hh include/RichTbSteppingActionBase.hh
+ *  
+ *
+ *  @author Sajan Easo
+ *  @date   2015-03-06
+ */
+class RichTbSteppingActionBase:public G4UserSteppingAction {
+public: 
+  /// Standard constructor
+  RichTbSteppingActionBase( ); 
+
+  virtual ~RichTbSteppingActionBase( ); ///< Destructor
+  void UserSteppingAction(const G4Step * aStep);
+  void InitRichTbStepActions();
+  
+protected:
+
+private:
+
+  RichTbSteppingAction* mRichTbSteppingAction;
+  RichTbPmtSteppingAction* mRichTbPmtSteppingAction;
+  
+
+};
+#endif // INCLUDE_RICHTBSTEPPINGACTIONBASE_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbSurface.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbSurface.hh
new file mode 100644
index 0000000000000000000000000000000000000000..560ac88f1a1d51d46df94694bced95e36dbad5f8
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbSurface.hh
@@ -0,0 +1,38 @@
+// $Id: $
+#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
+ */
+class RichTbDetectorConstruction;
+
+class RichTbSurface {
+public:
+  /// Standard constructor
+  RichTbSurface(RichTbDetectorConstruction*  ); 
+
+  virtual ~RichTbSurface( ); ///< Destructor
+
+  RichTbDetectorConstruction* getcurDet()
+  {    return curDet; }
+
+  void createBorderSurfaces();
+  
+    
+protected:
+
+private:
+
+  RichTbDetectorConstruction* curDet;
+  
+
+};
+#endif // INCLUDE_RICHTBSURFACE_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbSurfaceDefinition.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbSurfaceDefinition.hh
new file mode 100644
index 0000000000000000000000000000000000000000..5364350cdd8d13d05eb9323681f34ff6f532e3bd
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbSurfaceDefinition.hh
@@ -0,0 +1,76 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBSURFACEDEFINITION_HH 
+#define INCLUDE_RICHTBSURFACEDEFINITION_HH 1
+
+// Include files
+#include "Geant4/G4Material.hh"
+#include "Geant4/G4MaterialTable.hh"
+#include "Geant4/G4Element.hh"
+#include "Geant4/G4ElementTable.hh"
+#include "Geant4/G4OpticalSurface.hh"
+#include "RichTbRunConfig.hh"
+#include <vector>
+
+/** @class RichTbSurfaceDefinition RichTbSurfaceDefinition.hh include/RichTbSurfaceDefinition.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2003-11-24
+ */
+class RichTbSurfaceDefinition {
+public:
+
+  virtual ~RichTbSurfaceDefinition( ); ///< Destructor
+
+  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;}
+
+  void createMirrorOpticalSurface();
+  void createVesselSurface();
+  void createPMTQuartzWSurface();
+  void createPMTQuartzWPhCathodeSurface();
+  void ReadMirrorReflectivity();
+  void createRichTbKovarSurface();
+  void createtRichTbSiDetSurface();
+  
+protected:
+
+private:
+
+  /// Standard constructor
+  RichTbSurfaceDefinition( ); 
+
+  static  RichTbSurfaceDefinition*  RichTbSurfaceDefinitionInstance;
+  
+  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/G4RichTbSimH/include/RichTbSurfaceParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbSurfaceParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..49c3ca5f0aadbdc9c8a7083cb8ebbe0fc3371739
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbSurfaceParameters.hh
@@ -0,0 +1,47 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBSURFACEPARAMETERS_HH 
+#define INCLUDE_RICHTBSURFACEPARAMETERS_HH 1
+
+// Include files
+
+
+
+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. 
+
+
+const G4double PhotonMirrReflWavelengthUnits= 1.0*CLHEP::nanometer;
+// for testbem in 2004 a file is read with mirror reflectivity values.
+
+//const G4double  PhotonWavelengthMirrRefl[] =
+//
+//
+//  {140.0,145.0,150.0,155.0,160.0,165.0,170.0,
+//   175.0,180.0,185.0,190.0,195.0,200.0,205.0,
+//   210.0,215.0,220.0,225.0,230.0,235.0,240.0,
+//   245.0,250.0,255.0,260.0,265.0,270.0,275.0,
+//   280.0,285.0,290.0,295.0,300.0,305.0,310.0,
+//   315.0,320.0,325.0,330.0,335.0,340.0,345.0,
+//   350.0,355.0,360.0,400.0,900.0,1000.0,1200.0
+//  };
+//
+//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,
+//   85.58822,86.15829,86.95603,87.50696,88.2192,
+//   87.25798,87.49368,87.3097,87.02457,87.04436,
+//   85.82494,86.69911,85.34895,85.38953,85.26953,
+//   85.40186,84.80862,84.66154,84.55714,84.52075,
+//   84.50029,83.35554,83.39278,84.26382,84.4191,
+//   84.8813,85.16248,85.06534,86.16501,86.36691,
+//   86.36691,86.36691,86.36691,86.36691
+//  };
+
+
+
+   
+#endif // INCLUDE_RICHTBSURFACEPARAMETERS_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbTrackingAction.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbTrackingAction.hh
new file mode 100644
index 0000000000000000000000000000000000000000..80778a94298fc9753ff96df60f4ff109102de089
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbTrackingAction.hh
@@ -0,0 +1,19 @@
+#ifndef RichTbTrackingAction_h
+#define RichTbTrackingAction_h 1
+
+#include "Geant4/G4UserTrackingAction.hh"
+#include "Geant4/G4Track.hh"
+
+class RichTbTrackingAction:public G4UserTrackingAction {
+
+  public:
+    RichTbTrackingAction();
+    virtual ~ RichTbTrackingAction();
+  void PreUserTrackingAction(const G4Track * aTrack);
+  
+  void PostUserTrackingAction(const G4Track * aTrack);
+  
+
+  private:
+};
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeCrystal.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeCrystal.hh
new file mode 100644
index 0000000000000000000000000000000000000000..cde071d709e9807e756ea0df495a56b08f0f8818
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeCrystal.hh
@@ -0,0 +1,68 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBUPGRADECRYSTAL_HH 
+#define INCLUDE_RICHTBUPGRADECRYSTAL_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VUserDetectorConstruction.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "RichTbHall.hh"
+#include "RichTbUpgradeVessel.hh"
+#include "RichTbUpgradeCrystalMaster.hh"
+
+/** @class RichTbVessel RichTbVessel.hh include/RichTbVessel.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2003-11-05
+ */
+class RichTbCrystal {
+public:
+  /// Standard constructor
+  RichTbCrystal(RichTbUpgradeCrystalMaster* rTbCrystalMaster ); 
+
+  virtual ~RichTbCrystal( ); ///< Destructor
+
+  void  constructRichTbCrystal();
+  void  constructRichTbCrystalEnvelope();
+  
+  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;
+  
+
+  G4VPhysicalVolume* RichTbCrystalPVol;
+  G4VPhysicalVolume* RichTbCrystalEnvelopeBottomPVol; 
+
+ 
+};
+#endif 
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeCrystalCover.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeCrystalCover.hh
new file mode 100644
index 0000000000000000000000000000000000000000..790d386d5d7e58c419ec8f24b63ebdeae9040929
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeCrystalCover.hh
@@ -0,0 +1,71 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBUPGRADECRYSTALCOVER_HH 
+#define INCLUDE_RICHTBUPGRADECRYSTALCOVER_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VUserDetectorConstruction.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "RichTbHall.hh"
+#include "RichTbUpgradeCrystalMaster.hh"
+
+/** @class (RichTbCrystalMaster (RichTbCrystalMaster.hh include/RichTbCrystalMaster.hh 
+
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2003-11-05
+ */
+class RichTbCrystalCover {
+public:
+  /// Standard constructor
+  RichTbCrystalCover(RichTbUpgradeCrystalMaster* rTbCrystalMaster ); 
+
+  virtual ~RichTbCrystalCover( ); ///< Destructor
+
+  void  constructRichTbCrystalCover();
+  void  constructRichTbCrystalCoverEnvelope();
+  
+  G4LogicalVolume* getRichTbCrystalCoverLVol() 
+  {
+    return RichTbCrystalCoverLVol;
+  }
+  /*
+ G4LogicalVolume* getRichTbCrystalCoverEnvelopeBottomLVol()
+  {
+    return RichTbCrystalCoverEnvelopeBottomLVol;
+    
+  }
+  */
+  G4VPhysicalVolume* getRichTbCrystalCoverPVol() 
+  {
+    return RichTbCrystalCoverPVol;
+  }
+  /*
+  G4VPhysicalVolume* getRichTbCrystalCoverEnvelopeBottomPVol()
+  {
+    return RichTbVesselEnvelopeBottomPVol;
+  }
+  */
+  RichTbUpgradeCrystalMaster* getaRTbCrystalMaster() 
+  { 
+    return aRTbCrystalMaster;
+  
+  }
+  
+protected:
+
+private:
+  RichTbUpgradeCrystalMaster* aRTbCrystalMaster;
+  
+  G4LogicalVolume* RichTbCrystalCoverLVol;
+  // G4LogicalVolume*  RichTbVesselEnvelopeBottomLVol;
+  
+
+  G4VPhysicalVolume* RichTbCrystalCoverPVol;
+  // G4VPhysicalVolume* RichTbVesselEnvelopeBottomPVol; 
+
+ 
+};
+#endif 
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeCrystalMaster.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeCrystalMaster.hh
new file mode 100644
index 0000000000000000000000000000000000000000..7f7a4c6396191a43938a5fccf00c937d9ec47d39
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeCrystalMaster.hh
@@ -0,0 +1,67 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBUPGRADECRYSTALMASTER_HH 
+#define INCLUDE_RICHTBUPGRADECRYSTALMASTER_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VUserDetectorConstruction.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "RichTbHall.hh"
+#include "RichTbUpgradeVessel.hh"
+
+/** @class RichTbUpgradeVessel RichTbUpgradeVessel.hh include/RichTbUpgradeVessel.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2003-11-05
+ */
+class RichTbUpgradeCrystalMaster {
+public:
+  /// Standard constructor
+  RichTbUpgradeCrystalMaster(RichTbUpgradeVessel* rTbVessel ); 
+
+  virtual ~RichTbUpgradeCrystalMaster( ); ///< Destructor
+
+  void  constructRichTbUpgradeCrystalMaster();
+  void  constructRichTbUpgradeCrystalMasterEnvelope();
+  
+  G4LogicalVolume* getRichTbUpgradeCrystalMasterLVol() 
+  {
+    return RichTbUpgradeCrystalMasterLVol;
+  }
+  G4LogicalVolume* getRichTbUpgradeCrystalMasterEnvelopeBottomLVol()
+  {
+    return RichTbUpgradeCrystalMasterEnvelopeBottomLVol;
+    
+  }
+
+  G4VPhysicalVolume* getRichTbUpgradeCrystalMasterPVol() 
+  {
+    return RichTbUpgradeCrystalMasterPVol;
+  }
+  G4VPhysicalVolume* getRichTbUpgradeCrystalMasterEnvelopeBottomPVol()
+  {
+    return RichTbUpgradeCrystalMasterEnvelopeBottomPVol;
+  }
+  RichTbUpgradeVessel* getaRTbVessel() 
+  { 
+    return aRTbVessel;
+  
+  }
+  
+protected:
+
+private:
+  RichTbUpgradeVessel * aRTbVessel;
+  
+  G4LogicalVolume* RichTbUpgradeCrystalMasterLVol;
+  G4LogicalVolume*  RichTbUpgradeCrystalMasterEnvelopeBottomLVol;
+  
+
+  G4VPhysicalVolume* RichTbUpgradeCrystalMasterPVol;
+  G4VPhysicalVolume* RichTbUpgradeCrystalMasterEnvelopeBottomPVol; 
+
+ 
+};
+#endif 
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeDarkCover.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeDarkCover.hh
new file mode 100644
index 0000000000000000000000000000000000000000..31df7c33e3024c0d965da5752652f8ad5e7b55bf
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeDarkCover.hh
@@ -0,0 +1,86 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBUPGRADEDARKCOVER_HH
+#define INCLUDE_RICHTBUPGRADEDARKCOVER_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VUserDetectorConstruction.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "RichTbHall.hh"
+#include "RichTbUpgradeRadiator.hh"
+#include "RichTbUpgradeCrystalMaster.hh"
+
+/** @class RichTbDarkCover RichTbDarkCover.hh include/RichTbDarkCover.hh
+ *
+ *
+ *  @author Sajan EASO
+ *  @date   2003-11-05
+ */
+class RichTbUpgradeDarkCover {
+public:
+  /// Standard constructor
+  RichTbUpgradeDarkCover(RichTbUpgradeRadiator* rTbRadiator );
+
+  virtual ~RichTbUpgradeDarkCover( ); ///< Destructor
+
+  void  constructRichTbUpgradeDarkCover();
+  void  constructRichTbUpgradeUpsDarkCoverEnvelope(RichTbUpgradeCrystalMaster* aMaster);
+  void  constructRichTbUpgradeSideDarkCoverEnvelope(RichTbUpgradeCrystalMaster* aMasterC);
+
+  //testbeam 2015 upgrade
+  void  constructRichTbUpgradeDarkCover15();
+  void  constructRichTbUpgradeUpsDarkCoverEnvelope15(RichTbUpgradeCrystalMaster* aMaster);
+  void  constructRichTbUpgradeSideDarkCoverEnvelope15(RichTbUpgradeCrystalMaster* aMasterC);
+
+  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 ;}
+
+
+
+protected:
+
+private:
+  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/G4RichTbSimH/include/RichTbUpgradeDetectorConstruction.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeDetectorConstruction.hh
new file mode 100644
index 0000000000000000000000000000000000000000..4acbd1d3d50e9f3e88b6f2ca23d2e79addd41efe
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeDetectorConstruction.hh
@@ -0,0 +1,191 @@
+//This is the definition of the LHCb RICH Testbeam Detector Construction
+//Author SE  1-3-2001
+//
+#ifndef RichTbUpgradeDetectorConstruction_h
+#define RichTbUpgradeDetectorConstruction_h 1
+
+#include "Geant4/globals.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbHall.hh"
+#include "RichTbUpgradeVessel.hh"
+//#include "RichTbUpgradeMaster.hh"
+#include "RichTbUpgradeCrystal.hh"
+#include "RichTbUpgradeRadiator.hh"
+#include "RichTbUpgradeCrystalMaster.hh"
+#include "RichTbUpgradeLens.hh"
+#include "RichTbUpgradeCrystalCover.hh"
+#include "RichTbUpgradeDarkCover.hh"
+#include "RichTbUpgradePhDFrame.hh"
+#include "RichTbUpgradePhDetSupFrame.hh"
+#include "RichTbUpgradeEC.hh"
+#include "RichTbPMT.hh"
+#include "RichTbUpgradeMirror.hh"
+#include "RichTbHpd.hh"
+
+//#include "RichTbPhDetSupFrame.hh"
+#include "RichTbSurface.hh"
+#include "Geant4/G4VUserDetectorConstruction.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbROGeometry.hh"
+#include "RichTbROGeometryHpd.hh"
+#include "RichTbAnalysisManager.hh"
+#include "Geant4/G4SDManager.hh"
+//#include "RichTbSD.hh"
+
+#include "RichTbGraphics.hh"
+
+class RichTbDetectorConstruction:public G4VUserDetectorConstruction {
+
+  public:
+    RichTbDetectorConstruction();
+    virtual ~ RichTbDetectorConstruction();
+    G4VPhysicalVolume *Construct();
+
+    RichTbHall *getRichTbHall() {
+        return rTbHall;
+    }
+  RichTbUpgradeVessel* getRichTbUpgradeVessel() 
+  {
+    return  rTbVessel;
+  }
+
+  /*
+  RichTbMaster* getRichTbMaster1() 
+  {
+    return  rTbMaster1;
+  }
+  RichTbMaster* getRichTbMaster2() 
+  {
+    return  rTbMaster2;
+  }
+  RichTbMaster* getRichTbMaster3() 
+  {
+    return  rTbMaster3;
+  }
+  RichTbMaster* getRichTbMaster4() 
+  {
+    return  rTbMaster4;
+  }
+
+  */
+
+
+  RichTbLens* getRichTbLens() 
+  {
+    return  rTbLens;
+  }
+  RichTbCrystal* getRichTbCrystal() 
+  {
+    return  rTbCrystal;
+  }
+ RichTbUpgradeRadiator* getRichTbUpgradeRadiator() 
+  {
+    return  rTbUpgradeRadiator;
+  }
+
+ RichTbUpgradeCrystalMaster* getRichTbUpgradeCrystalMaster() 
+  {
+    return  rTbCrystalMaster;
+  }
+  RichTbCrystalCover* getRichTbCrystalCover() 
+  {
+    return  rTbCrystalCover;
+  }
+
+ RichTbUpgradeDarkCover* getRichTbUpgradeDarkCover() 
+  {
+    return  rTbUpgradeDarkCover;
+  }
+
+  RichTbPhDFrame* getRichTbPhDFrame() 
+  {
+    return  rTbPhDFrame;
+  }
+
+ RichTbPMT* getRichTbPMT() 
+  {
+    return  rTbPMT;
+  }
+
+
+  RichTbUpgradeMirror* getRichTbUpgradeMirror() 
+  {
+    return rTbUpgradeMirror;
+    
+  }
+ 
+  RichTbUpgradePhDetSupFrame* getRichTbUpgradePhDetSupFrame() 
+  {  return   rTbUpgradePhotSupFrame;  }
+  
+  RichTbUpgradeEC* getRichTbEC() 
+  {
+    return rTbEC;
+  }
+  
+
+  /*  
+  RichTbPhDetSupFrame* getRichTbPhDetSupFrame() 
+  {
+    return  rTbPhotSupFrame;
+  }
+  */
+  RichTbSurface* getRichTbSurface() 
+  {
+    return rTbSurface;
+  }
+  
+   RichTbROGeometry *getROGeometry() { return rTbROGeom;}
+  RichTbROGeometryHpd *getROGeometryHpd( ){return rTbROGeomHpd;}
+  
+       
+   /* RichTbSD* getRichTbSD()
+  { return  PMTSD;
+  }
+  */
+
+  RichTbHpd* getRichTbHpd() {return  rTbHpd; }
+  
+ 
+  private:
+
+  RichTbHall *rTbHall;
+  RichTbUpgradeVessel* rTbVessel;
+  /*
+  RichTbMaster* rTbMaster1;
+  RichTbMaster* rTbMaster2;
+  RichTbMaster* rTbMaster3;
+  RichTbMaster* rTbMaster4;
+  */
+
+  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;
+  
+
+
+  RichTbSurface* rTbSurface;
+
+  // RichTbSD* PMTSD;
+  
+  RichTbROGeometry *rTbROGeom;
+  RichTbROGeometryHpd *rTbROGeomHpd;
+
+};
+
+#endif                          /*RichTbDetectorConstruction_h */
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeEC.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeEC.hh
new file mode 100644
index 0000000000000000000000000000000000000000..1e41ca400e694164f8b236064cf2ab66d14f323d
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeEC.hh
@@ -0,0 +1,83 @@
+#ifndef INCLUDE_RICHTBUPGRADEEC_HH
+#define INCLUDE_RICHTBUPGRADEEC_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VUserDetectorConstruction.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "RichTbUpgradePhDetSupFrame.hh"
+
+
+/** @class RichTbUpgradeEC RichTbUpgradeEC.hh include/RichTbUpgradeEC.hh
+ *
+ *
+ *  @author Sajan Easo
+ *  @date   2014-10-23
+ */
+class RichTbUpgradeEC {
+public:
+  /// Standard constructor
+  RichTbUpgradeEC( RichTbUpgradePhDetSupFrame * rTbPhotSupFrame  );
+
+  virtual ~RichTbUpgradeEC( ); ///< Destructor
+  void constructRichTbUpgradeEC();
+  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;}
+
+  RichTbUpgradePhDetSupFrame * getRTbPhotSupFrame()
+  {  return aRTbPhotSupFrame;}
+
+  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 ;
+
+
+};
+#endif // INCLUDE_RICHTBUPGRADEEC_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeHpdSD.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeHpdSD.hh
new file mode 100644
index 0000000000000000000000000000000000000000..43d59a0e867de88525ca34c7ca8a6e728b2feeae
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeHpdSD.hh
@@ -0,0 +1,47 @@
+#ifndef INCLUDE_RICHTBUPGRADEHPDSD_HH 
+#define INCLUDE_RICHTBUPGRADEHPDSD_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VSensitiveDetector.hh"
+#include "Geant4/G4ThreeVector.hh"
+#include "RichTbHit.hh"
+#include "RichTbGeometryParameters.hh"
+class G4Step;
+class G4HCofThisEvent;
+
+/** @class RichTbUpgradeHpdSD RichTbUpgradeHpdSD.hh include/RichTbUpgradeHpdSD.hh
+ *  
+ *
+ *  @author Sajan Easo
+ *  @date   2015-05-15
+ */
+class RichTbUpgradeHpdSD:public G4VSensitiveDetector {
+public: 
+  /// Standard constructor
+  RichTbUpgradeHpdSD(G4String ); 
+
+  virtual ~RichTbUpgradeHpdSD( ); ///< Destructor
+      void Initialize(G4HCofThisEvent*HCE);
+
+      G4bool ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist);
+      void EndOfEvent(G4HCofThisEvent*HCE);
+      void clear();
+      void DrawAll();
+      void PrintAll();
+      G4int getCurrentHitCreationOption(){
+        return  CurrentHitCreationOption;
+      }
+
+protected:
+
+private:
+      RichTbHitsCollection * RichTbHitCollectionHpd;
+      std::vector<G4int> HpdSDID;
+      G4int HCID;
+  G4int  CurrentHitCreationOption;
+  G4int RichTbHitCollIndex;
+  G4String RichTbSDHpdName;
+  
+};
+#endif // INCLUDE_RICHTBUPGRADEHPDSD_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeLens.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeLens.hh
new file mode 100644
index 0000000000000000000000000000000000000000..d0abefc8ffba2e45965a31b17af56ccdb7a11947
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeLens.hh
@@ -0,0 +1,56 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBUPGRADELENS_HH 
+#define INCLUDE_RICHTBUPGRADELENS_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VUserDetectorConstruction.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "RichTbHall.hh"
+#include "RichTbUpgradeVessel.hh"
+#include "RichTbUpgradeCrystalMaster.hh"
+
+/** @class RichTbVessel RichTbVessel.hh include/RichTbVessel.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2003-11-05
+ */
+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:
+
+private:
+  RichTbUpgradeCrystalMaster* aRTbCrystalMaster;
+  
+  G4LogicalVolume* RichTbLensLVol;
+ 
+  G4VPhysicalVolume* RichTbLensPVol;
+ 
+};
+#endif 
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeMaster.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeMaster.hh
new file mode 100644
index 0000000000000000000000000000000000000000..61f7fb2b7f2620ed00855148d136906a2662d5bb
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeMaster.hh
@@ -0,0 +1,82 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBUPGRADEMASTER_HH 
+#define INCLUDE_RICHTBUPGRADEMASTER_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VUserDetectorConstruction.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "RichTbHall.hh"
+#include "RichTbUpgradeVessel.hh"
+#include "RichTbUpgradePhDFrame.hh"
+
+/** @class RichTbVessel RichTbVessel.hh include/RichTbVessel.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2003-11-05
+ */
+class RichTbMaster {
+public:
+  /// Standard constructor
+  RichTbMaster(RichTbPhDFrame* rTbPhDFrame, int MasterNum ); 
+
+  virtual ~RichTbMaster( ); ///< Destructor
+
+  void  constructRichTbMaster1();
+  void  constructRichTbMasterEnvelope1();
+  
+  void  constructRichTbMaster2();
+  void  constructRichTbMasterEnvelope2();
+
+  void  constructRichTbMaster3();
+  void  constructRichTbMasterEnvelope3();
+
+  void  constructRichTbMaster4();
+  void  constructRichTbMasterEnvelope4();
+
+  G4LogicalVolume* getRichTbMasterLVol() 
+  {
+    return RichTbMasterLVol;
+  }
+  G4LogicalVolume* getRichTbMasterEnvelopeBottomLVol()
+  {
+    return RichTbMasterEnvelopeBottomLVol;
+  }
+
+  G4VPhysicalVolume* getRichTbMasterPVol() 
+  {
+    return RichTbMasterPVol;
+  }
+  G4VPhysicalVolume* getRichTbMasterEnvelopeBottomPVol()
+  {
+    return RichTbMasterEnvelopeBottomPVol;
+  }
+
+  RichTbPhDFrame* getaRTbPhDFrame() 
+  { 
+    return aRTbPhDFrame;
+  
+  }
+  int getaMasterNum() 
+  { 
+    return aMasterNum;
+  
+  }
+protected:
+
+private:
+  RichTbPhDFrame* aRTbPhDFrame;
+  int aMasterNum;
+  
+  G4LogicalVolume* RichTbMasterLVol;
+  G4LogicalVolume*  RichTbMasterEnvelopeBottomLVol;
+  
+
+  G4VPhysicalVolume* RichTbMasterPVol;
+  G4VPhysicalVolume* RichTbMasterEnvelopeBottomPVol; 
+
+ 
+};
+#endif 
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeMirror.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeMirror.hh
new file mode 100644
index 0000000000000000000000000000000000000000..88bd9370cc7e40f06428dfb29d96d01b247fd43e
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeMirror.hh
@@ -0,0 +1,64 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBUPGRADEMIRROR_HH
+#define INCLUDE_RICHTBUPFRADEMIRROR_HH 1
+
+// Include files
+
+#include "RichTbUpgradeCrystalMaster.hh"
+
+#include "RichTbUpgradeRadiator.hh"
+
+/** @class RichTbUpgradeMirror RichTbUpgradeMirror.hh include/RichTbUpgradeMirror.hh
+ *
+ *
+ *  @author Sajan EASO
+ *  @date   2003-11-07
+ */
+class RichTbUpgradeMirror {
+public:
+  /// Standard constructor
+  RichTbUpgradeMirror( RichTbUpgradeCrystalMaster* aMaster, RichTbUpgradeRadiator* aRadiator);
+
+  virtual ~RichTbUpgradeMirror( ); ///< Destructor
+
+
+  G4LogicalVolume* getRichTbUpgradeMirrorLVol()
+  {
+   return RichTbUpgradeMirrorLVol;
+
+  }
+  G4VPhysicalVolume* getRichTbUpgradeMirrorPVol()
+  {
+    return RichTbUpgradeMirrorPVol;
+  }
+
+  void constructRichTbUpgradeMirror();
+  void constructRichTbUpgradeMirror15(); //testbeam 2015 upgrade
+
+  RichTbUpgradeRadiator* getaRTbUpgradeRadiator()
+  {
+    return aRTbUpgradeRadiator;
+  }
+
+protected:
+
+private:
+
+  /// Standard constructor
+  //RichTbUpgradeMirror( RichTbCrystalMaster* aMaster );
+
+
+  //static RichTbUpgradeMirror* RichTbUpgradeMirrorInstance;
+  G4ThreeVector MirrorCoC;
+
+
+
+  RichTbUpgradeCrystalMaster* motherMaster;
+
+  RichTbUpgradeRadiator* aRTbUpgradeRadiator;
+
+  G4LogicalVolume* RichTbUpgradeMirrorLVol;
+  G4VPhysicalVolume* RichTbUpgradeMirrorPVol;
+
+};
+#endif // INCLUDE_RICHTBUPGRADEMIRROR_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradePhDFrame.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradePhDFrame.hh
new file mode 100644
index 0000000000000000000000000000000000000000..539e8e95f6ddf2e4bc50dc5dc752b4009b251135
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradePhDFrame.hh
@@ -0,0 +1,67 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBUPGRADEPHDFRAME_HH 
+#define INCLUDE_RICHTBUPGRADEPHDFRAME_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VUserDetectorConstruction.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "RichTbHall.hh"
+#include "RichTbUpgradeCrystalMaster.hh"
+
+/** @class RichTbVessel RichTbVessel.hh include/RichTbVessel.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2003-11-05
+ */
+class RichTbPhDFrame {
+public:
+  /// Standard constructor
+  RichTbPhDFrame(RichTbUpgradeCrystalMaster* rTbCrystalMaster ); 
+
+  virtual ~RichTbPhDFrame( ); ///< Destructor
+
+  void  constructRichTbPhDFrame();
+  void  constructRichTbPhDFrameEnvelope();
+  
+  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;
+  
+
+  G4VPhysicalVolume* RichTbPhDFramePVol;
+  G4VPhysicalVolume* RichTbPhDFrameEnvelopeBottomPVol; 
+
+ 
+};
+#endif 
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradePhDetSupFrame.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradePhDetSupFrame.hh
new file mode 100644
index 0000000000000000000000000000000000000000..eb299995ddba230f3529f04a4adb6c259e294099
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradePhDetSupFrame.hh
@@ -0,0 +1,70 @@
+#ifndef INCLUDE_RICHTBUPGRADEPHDETSUPFRAME_HH
+#define INCLUDE_RICHTBUPGRADEPHDETSUPFRAME_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VUserDetectorConstruction.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "RichTbUpgradeCrystalMaster.hh"
+
+/** @class RichTbUpgradePhDetSupFrame RichTbUpgradePhDetSupFrame.hh include/RichTbUpgradePhDetSupFrame.hh
+ *
+ *
+ *  @author Sajan Easo
+ *  @date   2014-10-23
+ */
+class RichTbUpgradePhDetSupFrame {
+public:
+  /// Standard constructor
+  RichTbUpgradePhDetSupFrame(RichTbUpgradeCrystalMaster*  rTbCrystalMaster );
+
+  virtual ~RichTbUpgradePhDetSupFrame( ); ///< Destructor
+
+  void constructRichTbPhotoDetectorSupFrame() ;
+  void constructRichTbPhotoDetectorSupFrameWithHpd();
+  void constructRichTbPhotoDetectorSupFrame15();
+
+
+  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;  }
+
+
+
+
+protected:
+
+private:
+
+
+  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/G4RichTbSimH/include/RichTbUpgradeRadiator.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeRadiator.hh
new file mode 100644
index 0000000000000000000000000000000000000000..0bc8359ccf009831a2d09dc7690ed985453b75f1
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeRadiator.hh
@@ -0,0 +1,79 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBUPGRADERADIATOR_HH
+#define INCLUDE_RICHTBUPGRADERADIATOR_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VUserDetectorConstruction.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "RichTbHall.hh"
+#include "RichTbUpgradeVessel.hh"
+#include "RichTbUpgradeCrystalMaster.hh"
+
+/** @class  RichTbUpgradeRadiator  RichTbUpgradeRadiator.hh include/ RichTbUpgradeRadiator.hh
+ *
+ *
+ *  @author Sajan EASO
+ *  @date   2003-11-05
+ */
+class RichTbUpgradeRadiator{
+public:
+  /// Standard constructor
+  RichTbUpgradeRadiator(RichTbUpgradeCrystalMaster* rTbCrystalMaster );
+
+  virtual ~RichTbUpgradeRadiator( ); ///< Destructor
+
+  void  constructRichTbUpgradeRadiator();
+  void  constructRichTbUpgradeRadiator15();
+  void  constructRichTbUpgradeRadiatorEnvelope();
+
+  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;
+  }
+
+protected:
+
+private:
+  RichTbUpgradeCrystalMaster* aRTbCrystalMaster;
+
+  G4LogicalVolume* RichTbUpgradeRadiatorLVol;
+  G4LogicalVolume*  RichTbUpgradeRadiatorEnvelopeBottomLVol;
+
+
+  G4VPhysicalVolume* RichTbUpgradeRadiatorPVol;
+  G4VPhysicalVolume* RichTbUpgradeRadiatorEnvelopeBottomPVol;
+
+  G4LogicalVolume * testLvol;
+  G4VPhysicalVolume * testPvol;
+
+};
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeSD.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeSD.hh
new file mode 100644
index 0000000000000000000000000000000000000000..6be735506afbaccb161649b549e01a73f7abce81
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeSD.hh
@@ -0,0 +1,56 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBUPGRADESD_HH 
+#define INCLUDE_RICHTBUPGRADESD_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VSensitiveDetector.hh"
+#include "Geant4/G4ThreeVector.hh"
+#include "RichTbHit.hh"
+#include "RichTbGeometryParameters.hh"
+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 
+ */
+class RichTbUpgradeSD:public G4VSensitiveDetector {
+public: 
+  /// Standard constructor
+  RichTbUpgradeSD(G4String ); 
+
+  virtual ~RichTbUpgradeSD( ); ///< Destructor
+      void Initialize(G4HCofThisEvent*HCE);
+
+      G4bool ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist);
+      void EndOfEvent(G4HCofThisEvent*HCE);
+      void clear();
+      void DrawAll();
+      void PrintAll();
+
+  G4int getCurrentHitCreationOption()
+  {
+    return  CurrentHitCreationOption;
+  }
+  
+    
+protected:
+
+private:
+      RichTbHitsCollection * RichTbHitCollection;
+      std::vector<G4int> PmtSDID;
+      G4int HCID;
+  G4int  CurrentHitCreationOption;
+  G4double CurrentPmtPixelGap;
+  G4int RichTbHitCollIndex;
+  G4String  RichTbSensDetName;
+  
+
+};
+#endif // INCLUDE_RICHTBUPGRADESD_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeVessel.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeVessel.hh
new file mode 100644
index 0000000000000000000000000000000000000000..5f23a0fb8e06198a0d1d38928b491766c1a48e08
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUpgradeVessel.hh
@@ -0,0 +1,66 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBUPGRADEVESSEL_HH 
+#define INCLUDE_RICHTBUPGRADEVESSEL_HH 1
+
+// Include files
+#include "Geant4/globals.hh"
+#include "Geant4/G4VUserDetectorConstruction.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "RichTbHall.hh"
+
+/** @class RichTbUpgradeVessel RichTbUpgradeVessel.hh include/RichTbUpgradeVessel.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2003-11-05
+ */
+class RichTbUpgradeVessel {
+public:
+  /// Standard constructor
+  RichTbUpgradeVessel(RichTbHall* rTbHall ); 
+
+  virtual ~RichTbUpgradeVessel( ); ///< Destructor
+
+  void  constructRichTbGasVessel();
+  void  constructRichTbUpgradeVesselEnvelope();
+  
+  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;
+  
+
+  G4VPhysicalVolume* RichTbGasVesselPVol;
+  G4VPhysicalVolume* RichTbUpgradeVesselEnvelopeBottomPVol; 
+
+ 
+};
+#endif // INCLUDE_RICHTBUPGRADEVESSEL_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbUserTrackInfo.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbUserTrackInfo.hh
new file mode 100644
index 0000000000000000000000000000000000000000..872da0c6e6a4aa0c43ad21f587bea10c8c1f007b
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbUserTrackInfo.hh
@@ -0,0 +1,55 @@
+// $Id: $
+#ifndef INCLUDE_RICHTBUSERTRACKINFO_HH 
+#define INCLUDE_RICHTBUSERTRACKINFO_HH 1
+
+// Include files
+#include "Geant4/G4VUserTrackInformation.hh"
+#include "RichTbPEInfo.hh"
+#include "RichTbPhotonInfo.hh"
+
+/** @class RichTbUserTrackInfo RichTbUserTrackInfo.hh include/RichTbUserTrackInfo.hh
+ *  
+ *
+ *  @author Sajan EASO
+ *  @date   2004-01-20
+ */
+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:
+
+private:
+  RichTbPhotonInfo* mRichTbPhotonInfo;
+  RichTbPEInfo* mRichTbPEInfo;
+  
+  bool mHasUserPhotonInfo;
+  bool mHasUserPEInfo;
+  
+ 
+};
+#endif // INCLUDE_RICHTBUSERTRACKINFO_HH
diff --git a/LHCbG4Tests/G4RichTbSimH/include/RichTbVesselGeometryParameters.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbVesselGeometryParameters.hh
new file mode 100644
index 0000000000000000000000000000000000000000..a0b9036a8b4bd9e6dfe1b43179efa3cc0d4807a5
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbVesselGeometryParameters.hh
@@ -0,0 +1,69 @@
+// $Id: $
+#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;
+
+// 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 RichTbVesselUpsExternalPartXShift=0.5*(RichTbVesselXSize-RichTbVesselUpsExternalPartXSize);
+const G4double RichTbVesselUpsExternalPartYShift=0.0*CLHEP::mm;
+const G4double RichTbVesselUpsExternalPartZShift=-0.5*RichTbVesselZSize+
+               RichTbVesselUpsExternalPartZSize-0.5*RichTbVesselUpsExternalPartZLargeSize;
+*/
+// 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 RichTbVesselYLocation = 0;
+//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)+ 
+//                                      RichTbVesselZShiftAlongVessel*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;
+// 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  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/G4RichTbSimH/include/RichTbVisManager.hh b/LHCbG4Tests/G4RichTbSimH/include/RichTbVisManager.hh
new file mode 100644
index 0000000000000000000000000000000000000000..565cd214f56f967919254e7c4fd915e075713d2e
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/include/RichTbVisManager.hh
@@ -0,0 +1,41 @@
+
+// Example Visualization Manager implementing virtual function
+//   RegisterGraphicsSystems.  Exploits C-pre-processor variables
+//   G4VIS_USE_DAWN, etc., which are set by the GNUmakefiles if
+//   environment variables of the same name are set.
+
+// So all you have to do is set environment variables and compile and
+//   instantiate this in your main().
+
+// Alternatively, you can implement an empty function here and just
+//   register the systems you want in your main(), e.g.:
+//   G4VisManager* myVisManager = new MyVisManager;
+//   myVisManager -> RegisterGraphicsSystem (new MyGraphicsSystem);
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#ifndef RichTbVisManager_h
+#define RichTbVisManager_h 1
+
+#include "Geant4/G4VisManager.hh"
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+class RichTbVisManager:public G4VisManager {
+
+  public:
+
+  //    RichTbVisManager();
+    virtual ~ RichTbVisManager();
+  static  RichTbVisManager*  getRichTbVisManagerInstance();
+  
+  private:
+
+     RichTbVisManager();
+   void RegisterGraphicsSystems();
+
+  static RichTbVisManager* RichTbVisManagerInstance;
+  
+};
+
+#endif
diff --git a/LHCbG4Tests/G4RichTbSimH/macro/RichTbHpdSi.mac b/LHCbG4Tests/G4RichTbSimH/macro/RichTbHpdSi.mac
new file mode 100644
index 0000000000000000000000000000000000000000..f4fa18eb995f994e506245fe6cd50484a986ba3c
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/macro/RichTbHpdSi.mac
@@ -0,0 +1,90 @@
+#######################################################################
+#  MACRO FILE NAME: RichTbVis0.mac                                    #
+#                                                                     #
+#  AUTHOR(S): Satoshi Tanaka                                          #
+#  Mod SE 20-3-01                                                     #
+#  DATE: November 10, 1999                                            #
+#        May      20, 2000                                            # 
+#        June     06, 2000                                            # 
+#                                                                     #
+#  CONTENTS: A simplest macro to demonstrate visualization of         #
+#            detector geometry and events                             #
+#                                                                     #
+#  USAGE:                                                             #
+#          Idle> /control/execute RichTbVis0.mac                      #
+#                                                                     #
+#  REQUIRED PLATFORMS & SOFTWARES: Unix, X-window, OpenGL,            #
+#                                  DAWN (version 3.80 or after)       #
+#                                  gv (Ghostview), Tcl/Tk             #
+#                                                                     #
+#  ENVIRONMENTAL VARIABLES (C-MACROS) FOR INSTALLATION:               #
+#  (See geant4/source/visualization/README for details.)              #
+#                                                                     #
+#    % setenv OGLHOME     ... (e.g. /usr/local)                       #
+#    % setenv G4VIS_BUILD_OPENGLX_DRIVER   1                          # 
+#    % setenv G4VIS_BUILD_DAWNFILE_DRIVER  1                          #
+#                                                                     #
+#  ENVIRONMENTAL VARIABLES (C-MACROS) FOR COMPILATION:                #
+#  (See geant4/source/visualization/README for details.)              #
+#                                                                     #
+#    % setenv G4VIS_USE_OPENGLX            1                          #
+#    % setenv G4VIS_USE_DAWNFILE           1                          #
+#                                                                     #
+#  Addional Notes:                                                    #
+#    The compound command "/vis/open <graphics-system-name>"          #
+#    is equivalent to the following set of commands:                  #
+#                                                                     #
+#      /vis/sceneHandler/create $1                                    #
+#      /vis/viewer/create                                             #
+#                                                                     #
+#    The compound command "/vis/drawVolume <physical-volume-name>"    #
+#    is equivalent to the following set of commands:                  #
+#                                                                     #
+#      /vis/scene/create                                              #
+#      /vis/scene/add/volume $1                                       #
+#      /vis/sceneHandler/attach                                       #
+#      /vis/viewer/refresh                                            #
+#      /vis/viewer/update                                             #
+#                                                                     #
+#######################################################################
+
+##############################################
+# Visualization of detector geometry 
+#  with the OGLIX (OpenGL Immediate X) driver
+##############################################
+
+# Invoke the OGLIX driver
+#/vis/open OGLSXm
+
+# Set camera 
+#  Note: Camera setting should be done
+#        for each scene handler.
+/vis/camera/reset 
+/vis/scene/create
+#/vis/sceneHandler/create OGLIX
+#/vis/sceneHandler/create OGLSX
+/vis/sceneHandler/create OGLSXm
+/vis/viewer/create
+/vis/scene/add/volume
+#/vis/camera/viewpoint 0 0
+
+/vis/camera/viewpoint 0 0
+#/vis/camera/viewpoint -90 -90
+#/vis/camera/viewpoint 270 0
+/vis/camera/zoom 1.0
+#/vis/camera/spin 20 10
+
+# Visualize of the whole detector geometry
+/vis/drawVolume
+/vis/viewer/update
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/macro/RichTbSiPix.mac b/LHCbG4Tests/G4RichTbSimH/macro/RichTbSiPix.mac
new file mode 100644
index 0000000000000000000000000000000000000000..f4fa18eb995f994e506245fe6cd50484a986ba3c
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/macro/RichTbSiPix.mac
@@ -0,0 +1,90 @@
+#######################################################################
+#  MACRO FILE NAME: RichTbVis0.mac                                    #
+#                                                                     #
+#  AUTHOR(S): Satoshi Tanaka                                          #
+#  Mod SE 20-3-01                                                     #
+#  DATE: November 10, 1999                                            #
+#        May      20, 2000                                            # 
+#        June     06, 2000                                            # 
+#                                                                     #
+#  CONTENTS: A simplest macro to demonstrate visualization of         #
+#            detector geometry and events                             #
+#                                                                     #
+#  USAGE:                                                             #
+#          Idle> /control/execute RichTbVis0.mac                      #
+#                                                                     #
+#  REQUIRED PLATFORMS & SOFTWARES: Unix, X-window, OpenGL,            #
+#                                  DAWN (version 3.80 or after)       #
+#                                  gv (Ghostview), Tcl/Tk             #
+#                                                                     #
+#  ENVIRONMENTAL VARIABLES (C-MACROS) FOR INSTALLATION:               #
+#  (See geant4/source/visualization/README for details.)              #
+#                                                                     #
+#    % setenv OGLHOME     ... (e.g. /usr/local)                       #
+#    % setenv G4VIS_BUILD_OPENGLX_DRIVER   1                          # 
+#    % setenv G4VIS_BUILD_DAWNFILE_DRIVER  1                          #
+#                                                                     #
+#  ENVIRONMENTAL VARIABLES (C-MACROS) FOR COMPILATION:                #
+#  (See geant4/source/visualization/README for details.)              #
+#                                                                     #
+#    % setenv G4VIS_USE_OPENGLX            1                          #
+#    % setenv G4VIS_USE_DAWNFILE           1                          #
+#                                                                     #
+#  Addional Notes:                                                    #
+#    The compound command "/vis/open <graphics-system-name>"          #
+#    is equivalent to the following set of commands:                  #
+#                                                                     #
+#      /vis/sceneHandler/create $1                                    #
+#      /vis/viewer/create                                             #
+#                                                                     #
+#    The compound command "/vis/drawVolume <physical-volume-name>"    #
+#    is equivalent to the following set of commands:                  #
+#                                                                     #
+#      /vis/scene/create                                              #
+#      /vis/scene/add/volume $1                                       #
+#      /vis/sceneHandler/attach                                       #
+#      /vis/viewer/refresh                                            #
+#      /vis/viewer/update                                             #
+#                                                                     #
+#######################################################################
+
+##############################################
+# Visualization of detector geometry 
+#  with the OGLIX (OpenGL Immediate X) driver
+##############################################
+
+# Invoke the OGLIX driver
+#/vis/open OGLSXm
+
+# Set camera 
+#  Note: Camera setting should be done
+#        for each scene handler.
+/vis/camera/reset 
+/vis/scene/create
+#/vis/sceneHandler/create OGLIX
+#/vis/sceneHandler/create OGLSX
+/vis/sceneHandler/create OGLSXm
+/vis/viewer/create
+/vis/scene/add/volume
+#/vis/camera/viewpoint 0 0
+
+/vis/camera/viewpoint 0 0
+#/vis/camera/viewpoint -90 -90
+#/vis/camera/viewpoint 270 0
+/vis/camera/zoom 1.0
+#/vis/camera/spin 20 10
+
+# Visualize of the whole detector geometry
+/vis/drawVolume
+/vis/viewer/update
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/macro/RichTbVis0.mac b/LHCbG4Tests/G4RichTbSimH/macro/RichTbVis0.mac
new file mode 100644
index 0000000000000000000000000000000000000000..edc248acfc7734d2a3f5320ef6d16e6b6d90dfd2
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/macro/RichTbVis0.mac
@@ -0,0 +1,89 @@
+#######################################################################
+#  MACRO FILE NAME: RichTbVis0.mac                                    #
+#                                                                     #
+#  AUTHOR(S): Satoshi Tanaka                                          #
+#  Mod SE 20-3-01                                                     #
+#  DATE: November 10, 1999                                            #
+#        May      20, 2000                                            # 
+#        June     06, 2000                                            # 
+#                                                                     #
+#  CONTENTS: A simplest macro to demonstrate visualization of         #
+#            detector geometry and events                             #
+#                                                                     #
+#  USAGE:                                                             #
+#          Idle> /control/execute RichTbVis0.mac                      #
+#                                                                     #
+#  REQUIRED PLATFORMS & SOFTWARES: Unix, X-window, OpenGL,            #
+#                                  DAWN (version 3.80 or after)       #
+#                                  gv (Ghostview), Tcl/Tk             #
+#                                                                     #
+#  ENVIRONMENTAL VARIABLES (C-MACROS) FOR INSTALLATION:               #
+#  (See geant4/source/visualization/README for details.)              #
+#                                                                     #
+#    % setenv OGLHOME     ... (e.g. /usr/local)                       #
+#    % setenv G4VIS_BUILD_OPENGLX_DRIVER   1                          # 
+#    % setenv G4VIS_BUILD_DAWNFILE_DRIVER  1                          #
+#                                                                     #
+#  ENVIRONMENTAL VARIABLES (C-MACROS) FOR COMPILATION:                #
+#  (See geant4/source/visualization/README for details.)              #
+#                                                                     #
+#    % setenv G4VIS_USE_OPENGLX            1                          #
+#    % setenv G4VIS_USE_DAWNFILE           1                          #
+#                                                                     #
+#  Addional Notes:                                                    #
+#    The compound command "/vis/open <graphics-system-name>"          #
+#    is equivalent to the following set of commands:                  #
+#                                                                     #
+#      /vis/sceneHandler/create $1                                    #
+#      /vis/viewer/create                                             #
+#                                                                     #
+#    The compound command "/vis/drawVolume <physical-volume-name>"    #
+#    is equivalent to the following set of commands:                  #
+#                                                                     #
+#      /vis/scene/create                                              #
+#      /vis/scene/add/volume $1                                       #
+#      /vis/sceneHandler/attach                                       #
+#      /vis/viewer/refresh                                            #
+#      /vis/viewer/update                                             #
+#                                                                     #
+#######################################################################
+
+##############################################
+# Visualization of detector geometry 
+#  with the OGLIX (OpenGL Immediate X) driver
+##############################################
+
+# Invoke the OGLIX driver
+#/vis/open OGLIX
+
+# Set camera 
+#  Note: Camera setting should be done
+#        for each scene handler.
+/vis/camera/reset 
+/vis/scene/create
+#/vis/sceneHandler/create OGLIX
+/vis/sceneHandler/create DAWNFILE
+#/vis/sceneHandler/create OGLSXm
+/vis/viewer/create
+/vis/scene/add/volume
+#/vis/camera/viewpoint 0 0
+
+/vis/camera/viewpoint -90 -90
+#/vis/camera/viewpoint 270 0
+/vis/camera/zoom 0.8
+#/vis/camera/spin 20 10
+
+# Visualize of the whole detector geometry
+/vis/drawVolume
+/vis/viewer/update
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/macro/RichTbVis1.mac b/LHCbG4Tests/G4RichTbSimH/macro/RichTbVis1.mac
new file mode 100644
index 0000000000000000000000000000000000000000..cd53cafd4badb3920d1d1d1a0f4b125602e670a7
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/macro/RichTbVis1.mac
@@ -0,0 +1,90 @@
+#######################################################################
+#  MACRO FILE NAME: RichTbVis0.mac                                    #
+#                                                                     #
+#  AUTHOR(S): Satoshi Tanaka                                          #
+#  Mod SE 20-3-01                                                     #
+#  DATE: November 10, 1999                                            #
+#        May      20, 2000                                            # 
+#        June     06, 2000                                            # 
+#                                                                     #
+#  CONTENTS: A simplest macro to demonstrate visualization of         #
+#            detector geometry and events                             #
+#                                                                     #
+#  USAGE:                                                             #
+#          Idle> /control/execute RichTbVis0.mac                      #
+#                                                                     #
+#  REQUIRED PLATFORMS & SOFTWARES: Unix, X-window, OpenGL,            #
+#                                  DAWN (version 3.80 or after)       #
+#                                  gv (Ghostview), Tcl/Tk             #
+#                                                                     #
+#  ENVIRONMENTAL VARIABLES (C-MACROS) FOR INSTALLATION:               #
+#  (See geant4/source/visualization/README for details.)              #
+#                                                                     #
+#    % setenv OGLHOME     ... (e.g. /usr/local)                       #
+#    % setenv G4VIS_BUILD_OPENGLX_DRIVER   1                          # 
+#    % setenv G4VIS_BUILD_DAWNFILE_DRIVER  1                          #
+#                                                                     #
+#  ENVIRONMENTAL VARIABLES (C-MACROS) FOR COMPILATION:                #
+#  (See geant4/source/visualization/README for details.)              #
+#                                                                     #
+#    % setenv G4VIS_USE_OPENGLX            1                          #
+#    % setenv G4VIS_USE_DAWNFILE           1                          #
+#                                                                     #
+#  Addional Notes:                                                    #
+#    The compound command "/vis/open <graphics-system-name>"          #
+#    is equivalent to the following set of commands:                  #
+#                                                                     #
+#      /vis/sceneHandler/create $1                                    #
+#      /vis/viewer/create                                             #
+#                                                                     #
+#    The compound command "/vis/drawVolume <physical-volume-name>"    #
+#    is equivalent to the following set of commands:                  #
+#                                                                     #
+#      /vis/scene/create                                              #
+#      /vis/scene/add/volume $1                                       #
+#      /vis/sceneHandler/attach                                       #
+#      /vis/viewer/refresh                                            #
+#      /vis/viewer/update                                             #
+#                                                                     #
+#######################################################################
+
+##############################################
+# Visualization of detector geometry 
+#  with the OGLIX (OpenGL Immediate X) driver
+##############################################
+
+# Invoke the OGLIX driver
+#/vis/open OGLSXm
+
+# Set camera 
+#  Note: Camera setting should be done
+#        for each scene handler.
+/vis/camera/reset 
+/vis/scene/create
+/vis/sceneHandler/create OGLIX
+#/vis/sceneHandler/create OGLSX
+#/vis/sceneHandler/create OGLSXm
+/vis/viewer/create
+/vis/scene/add/volume
+#/vis/camera/viewpoint 0 0
+
+#/vis/camera/viewpoint 0 0
+/vis/camera/viewpoint -90 -90
+#/vis/camera/viewpoint 270 0
+/vis/camera/zoom 1.0
+#/vis/camera/spin 20 10
+
+# Visualize of the whole detector geometry
+/vis/drawVolume
+/vis/viewer/update
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/macro/RichTbVis2.mac b/LHCbG4Tests/G4RichTbSimH/macro/RichTbVis2.mac
new file mode 100644
index 0000000000000000000000000000000000000000..4014f56e718b6b4af6f0e51b83eaf831892338c5
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/macro/RichTbVis2.mac
@@ -0,0 +1,83 @@
+#######################################################################
+#  MACRO FILE NAME: RichTbVis0.mac                                    #
+#                                                                     #
+#  AUTHOR(S): Satoshi Tanaka                                          #
+#  Mod SE 20-3-01                                                     #
+#  DATE: November 10, 1999                                            #
+#        May      20, 2000                                            # 
+#        June     06, 2000                                            # 
+#                                                                     #
+#  CONTENTS: A simplest macro to demonstrate visualization of         #
+#            detector geometry and events                             #
+#                                                                     #
+#  USAGE:                                                             #
+#          Idle> /control/execute RichTbVis0.mac                      #
+#                                                                     #
+#  REQUIRED PLATFORMS & SOFTWARES: Unix, X-window, OpenGL,            #
+#                                  DAWN (version 3.80 or after)       #
+#                                  gv (Ghostview), Tcl/Tk             #
+#                                                                     #
+#  ENVIRONMENTAL VARIABLES (C-MACROS) FOR INSTALLATION:               #
+#  (See geant4/source/visualization/README for details.)              #
+#                                                                     #
+#    % setenv OGLHOME     ... (e.g. /usr/local)                       #
+#    % setenv G4VIS_BUILD_OPENGLX_DRIVER   1                          # 
+#    % setenv G4VIS_BUILD_DAWNFILE_DRIVER  1                          #
+#                                                                     #
+#  ENVIRONMENTAL VARIABLES (C-MACROS) FOR COMPILATION:                #
+#  (See geant4/source/visualization/README for details.)              #
+#                                                                     #
+#    % setenv G4VIS_USE_OPENGLX            1                          #
+#    % setenv G4VIS_USE_DAWNFILE           1                          #
+#                                                                     #
+#  Addional Notes:                                                    #
+#    The compound command "/vis/open <graphics-system-name>"          #
+#    is equivalent to the following set of commands:                  #
+#                                                                     #
+#      /vis/sceneHandler/create $1                                    #
+#      /vis/viewer/create                                             #
+#                                                                     #
+#    The compound command "/vis/drawVolume <physical-volume-name>"    #
+#    is equivalent to the following set of commands:                  #
+#                                                                     #
+#      /vis/scene/create                                              #
+#      /vis/scene/add/volume $1                                       #
+#      /vis/sceneHandler/attach                                       #
+#      /vis/viewer/refresh                                            #
+#      /vis/viewer/update                                             #
+#                                                                     #
+#######################################################################
+
+##############################################
+# Visualization of detector geometry 
+#  with the OGLIX (OpenGL Immediate X) driver
+##############################################
+
+# Invoke the OGLIX driver
+#/vis/open OGLSXm
+
+# Set camera 
+#  Note: Camera setting should be done
+#        for each scene handler.
+/control/verbose 2
+/control/saveHistory
+
+/vis/open OGLSXm
+/vis/scene/add/volume
+
+#/vis/viewer/set/culling invisible false
+# Visualize of the whole detector geometry
+/vis/drawVolume
+/vis/viewer/update
+#/vis/viewer/flush
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/macro/RichTbVis2DAWN.mac b/LHCbG4Tests/G4RichTbSimH/macro/RichTbVis2DAWN.mac
new file mode 100644
index 0000000000000000000000000000000000000000..f79fec26eb26e3686bd8e112f89a9eb9741bdc05
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/macro/RichTbVis2DAWN.mac
@@ -0,0 +1,84 @@
+#######################################################################
+#  MACRO FILE NAME: RichTbVis0.mac                                    #
+#                                                                     #
+#  AUTHOR(S): Satoshi Tanaka                                          #
+#  Mod SE 20-3-01                                                     #
+#  DATE: November 10, 1999                                            #
+#        May      20, 2000                                            # 
+#        June     06, 2000                                            # 
+#                                                                     #
+#  CONTENTS: A simplest macro to demonstrate visualization of         #
+#            detector geometry and events                             #
+#                                                                     #
+#  USAGE:                                                             #
+#          Idle> /control/execute RichTbVis0.mac                      #
+#                                                                     #
+#  REQUIRED PLATFORMS & SOFTWARES: Unix, X-window, OpenGL,            #
+#                                  DAWN (version 3.80 or after)       #
+#                                  gv (Ghostview), Tcl/Tk             #
+#                                                                     #
+#  ENVIRONMENTAL VARIABLES (C-MACROS) FOR INSTALLATION:               #
+#  (See geant4/source/visualization/README for details.)              #
+#                                                                     #
+#    % setenv OGLHOME     ... (e.g. /usr/local)                       #
+#    % setenv G4VIS_BUILD_OPENGLX_DRIVER   1                          # 
+#    % setenv G4VIS_BUILD_DAWNFILE_DRIVER  1                          #
+#                                                                     #
+#  ENVIRONMENTAL VARIABLES (C-MACROS) FOR COMPILATION:                #
+#  (See geant4/source/visualization/README for details.)              #
+#                                                                     #
+#    % setenv G4VIS_USE_OPENGLX            1                          #
+#    % setenv G4VIS_USE_DAWNFILE           1                          #
+#                                                                     #
+#  Addional Notes:                                                    #
+#    The compound command "/vis/open <graphics-system-name>"          #
+#    is equivalent to the following set of commands:                  #
+#                                                                     #
+#      /vis/sceneHandler/create $1                                    #
+#      /vis/viewer/create                                             #
+#                                                                     #
+#    The compound command "/vis/drawVolume <physical-volume-name>"    #
+#    is equivalent to the following set of commands:                  #
+#                                                                     #
+#      /vis/scene/create                                              #
+#      /vis/scene/add/volume $1                                       #
+#      /vis/sceneHandler/attach                                       #
+#      /vis/viewer/refresh                                            #
+#      /vis/viewer/update                                             #
+#                                                                     #
+#######################################################################
+
+##############################################
+# Visualization of detector geometry 
+#  with the OGLIX (OpenGL Immediate X) driver
+##############################################
+
+# Invoke the OGLIX driver
+#/vis/open OGLSXm
+
+# Set camera 
+#  Note: Camera setting should be done
+#        for each scene handler.
+/control/verbose 2
+/control/saveHistory
+
+#/vis/open OGLSXm
+/vis/open DAWNFILE
+/vis/scene/add/volume
+
+#/vis/viewer/set/culling invisible false
+# Visualize of the whole detector geometry
+/vis/drawVolume
+/vis/viewer/update
+/vis/viewer/flush
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/macro/gui.mac b/LHCbG4Tests/G4RichTbSimH/macro/gui.mac
new file mode 100644
index 0000000000000000000000000000000000000000..ea6603577c292a2d40d04b63e4d77a966a686b39
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/macro/gui.mac
@@ -0,0 +1,33 @@
+#
+#  This file permits to customize, with commands,
+# the menu bar of the G4UIXm, G4UIWin32 sessions.
+# It has no effect with G4UIterminal.
+#
+# File :
+/gui/addMenu file File
+/gui/addButton file Continue continue
+/gui/addButton file Exit "exit"
+#
+# Run menu :
+/gui/addMenu run Run
+/gui/addButton run run1 "/control/execute ../macro/run1.mac"
+#/gui/addButton run run2 "/control/execute ../macro/run2.mac"
+
+#
+# Vis menu :
+/gui/addMenu vis Vis
+/gui/addButton vis Vis0 "/control/execute ../macro/RichTbVis0.mac"
+#/gui/addButton vis Vis1 "/control/execute ../macro/RichTbVis1.mac"
+
+#
+#Setup driver  Menu:
+/gui/addMenu setup Setup
+# /gui/addButton setup Init "/control/execute ../macro/InitRichTb.mac"
+/gui/addButton setup opgl "/control/execute ../macro/SetupOpenGL.mac"
+/gui/addButton setup dawn "/control/execute ../macro/SetupDawn.mac"
+#
+# To limit the output flow in the "dump" widget :
+/event/printModulo 100
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/macro/run1.mac b/LHCbG4Tests/G4RichTbSimH/macro/run1.mac
new file mode 100644
index 0000000000000000000000000000000000000000..7992fbe117c1d2db35659cd231baf2f4a58cbcc8
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/macro/run1.mac
@@ -0,0 +1,36 @@
+# $Id: run1.mac,v 1.1.1.1 2000/09/05 09:39:44 ranjard Exp $
+#
+# Macro file for "LHCbRichSim.cc"
+# 
+#/vis/open OGLIX
+# (can be run in batch, without graphic)
+#
+/control/verbose 4
+/control/saveHistory
+#
+#run/verbose 4
+#event/verbose 4
+#tracking/verbose 5
+#process/verbose 4
+#particle/process/verbose 4
+#vis/verbose 4
+
+/vis/scene/create
+/vis/sceneHandler/create OGLIX
+/vis/viewer/create
+/vis/scene/add/volume
+
+/vis/camera/reset
+/vis/camera/viewpoint -90. -90.
+
+/tracking/storeTrajectory 1
+/vis/scene/add/trajectories
+/vis/scene/notifyHandlers
+/run/beamOn 1
+
+/vis/viewer/update
+# 
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/macro/run2.mac b/LHCbG4Tests/G4RichTbSimH/macro/run2.mac
new file mode 100644
index 0000000000000000000000000000000000000000..9d090662edc4c36f7042c14402589b4dc095046e
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/macro/run2.mac
@@ -0,0 +1,36 @@
+# $Id: run1.mac,v 1.1.1.1 2000/09/05 09:39:44 ranjard Exp $
+#
+# Macro file for "LHCbRichSim.cc"
+# 
+#/vis/open OGLIX
+# (can be run in batch, without graphic)
+#
+/control/verbose 4
+/control/saveHistory
+#
+#run/verbose 4
+#event/verbose 4
+#tracking/verbose 5
+#process/verbose 4
+#particle/process/verbose 4
+#vis/verbose 4
+
+/vis/scene/create
+/vis/sceneHandler/create OGLSXm
+/vis/viewer/create
+/vis/scene/add/volume
+
+/vis/camera/reset
+/vis/camera/viewpoint -90. -90.
+
+/tracking/storeTrajectory 1
+/vis/scene/add/trajectories
+/vis/scene/notifyHandlers
+/run/beamOn 1
+
+/vis/viewer/update
+# 
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/macro/run3.mac b/LHCbG4Tests/G4RichTbSimH/macro/run3.mac
new file mode 100644
index 0000000000000000000000000000000000000000..0a5cd18099c6f6d2a98b0fd686ce0dce5d126530
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/macro/run3.mac
@@ -0,0 +1,34 @@
+# $Id: run3.mac,v 1.1.1.1 2000/09/05 09:39:44 ranjard Exp $
+#
+# Macro file for "LHCbRichSim.cc"
+# 
+#/vis/open OGLIX
+# (can be run in batch, without graphic)
+#
+/control/verbose 2
+/control/saveHistory
+#
+#run/verbose 4
+#event/verbose 4
+#tracking/verbose 5
+#process/verbose 4
+#particle/process/verbose 4
+#vis/verbose 4
+
+
+/vis/open OGLSXm
+/vis/scene/add/volume
+/vis/drawVolume
+/vis/viewer/update
+/tracking/storeTrajectory 1
+/vis/scene/add/trajectories
+/vis/scene/notifyHandlers
+/run/beamOn 1
+
+/vis/viewer/update
+#/vis/viewer/refresh
+ 
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/macro/run4.mac b/LHCbG4Tests/G4RichTbSimH/macro/run4.mac
new file mode 100644
index 0000000000000000000000000000000000000000..21cc7356480676c3c09c028cb10ceaa20c26e6b1
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/macro/run4.mac
@@ -0,0 +1,42 @@
+m# $Id: run1.mac,v 1.1.1.1 2000/09/05 09:39:44 ranjard Exp $
+#
+# Macro file for "LHCbRichSim.cc"
+# 
+#/vis/open OGLIX
+# (can be run in batch, without graphic)
+#
+/control/verbose 2
+/control/saveHistory
+#
+#run/verbose 4
+#event/verbose 4
+#tracking/verbose 5
+#process/verbose 4
+#particle/process/verbose 4
+#vis/verbose 4
+
+/vis/scene/create
+/vis/sceneHandler/create OGLSXm
+#/vis/sceneHandler/create OGLIX
+/vis/viewer/create
+/vis/scene/add/volume
+
+/vis/camera/reset
+/vis/viewer/update
+#/vis/camera/viewpoint 0. 0.
+/vis/viewer/viewpointThetaPhi 0. 0.
+/hits/list
+/hits/activate
+/hits/verbose 4
+/tracking/storeTrajectory 1
+/vis/scene/add/trajectories
+/vis/scene/notifyHandlers
+/run/beamOn 1
+
+/vis/viewer/update
+#/vis/viewer/refresh
+ 
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/macro/run5.mac b/LHCbG4Tests/G4RichTbSimH/macro/run5.mac
new file mode 100644
index 0000000000000000000000000000000000000000..6c8de5ad11f62d82fb04cae1e15578592ff9897a
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/macro/run5.mac
@@ -0,0 +1,42 @@
+m# $Id: run1.mac,v 1.1.1.1 2000/09/05 09:39:44 ranjard Exp $
+#
+# Macro file for "LHCbRichSim.cc"
+# 
+#/vis/open OGLIX
+# (can be run in batch, without graphic)
+#
+/control/verbose 2
+/control/saveHistory
+#
+#run/verbose 4
+#event/verbose 4
+#tracking/verbose 5
+#process/verbose 4
+#particle/process/verbose 4
+#vis/verbose 4
+
+/vis/scene/create
+/vis/sceneHandler/create OGLSXm
+#/vis/sceneHandler/create OGLIX
+/vis/viewer/create
+/vis/scene/add/volume
+
+/vis/camera/reset
+/vis/viewer/update
+#/vis/camera/viewpoint 0. 0.
+/vis/viewer/viewpointThetaPhi -90. -90.
+/hits/list
+/hits/activate
+/hits/verbose 4
+/tracking/storeTrajectory 1
+/vis/scene/add/trajectories
+/vis/scene/notifyHandlers
+/run/beamOn 1
+
+/vis/viewer/update
+#/vis/viewer/refresh
+ 
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/macro/run6.mac b/LHCbG4Tests/G4RichTbSimH/macro/run6.mac
new file mode 100644
index 0000000000000000000000000000000000000000..6c8de5ad11f62d82fb04cae1e15578592ff9897a
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/macro/run6.mac
@@ -0,0 +1,42 @@
+m# $Id: run1.mac,v 1.1.1.1 2000/09/05 09:39:44 ranjard Exp $
+#
+# Macro file for "LHCbRichSim.cc"
+# 
+#/vis/open OGLIX
+# (can be run in batch, without graphic)
+#
+/control/verbose 2
+/control/saveHistory
+#
+#run/verbose 4
+#event/verbose 4
+#tracking/verbose 5
+#process/verbose 4
+#particle/process/verbose 4
+#vis/verbose 4
+
+/vis/scene/create
+/vis/sceneHandler/create OGLSXm
+#/vis/sceneHandler/create OGLIX
+/vis/viewer/create
+/vis/scene/add/volume
+
+/vis/camera/reset
+/vis/viewer/update
+#/vis/camera/viewpoint 0. 0.
+/vis/viewer/viewpointThetaPhi -90. -90.
+/hits/list
+/hits/activate
+/hits/verbose 4
+/tracking/storeTrajectory 1
+/vis/scene/add/trajectories
+/vis/scene/notifyHandlers
+/run/beamOn 1
+
+/vis/viewer/update
+#/vis/viewer/refresh
+ 
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/macro/visgeom.mac b/LHCbG4Tests/G4RichTbSimH/macro/visgeom.mac
new file mode 100644
index 0000000000000000000000000000000000000000..eb6b660b476b82186a08cbc507e5cd21a82bac1c
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/macro/visgeom.mac
@@ -0,0 +1,34 @@
+m# $Id: run1.mac,v 1.1.1.1 2000/09/05 09:39:44 ranjard Exp $
+#
+# Macro file for "LHCbRichSim.cc"
+# 
+#/vis/open OGLIX
+# (can be run in batch, without graphic)
+#
+/control/verbose 2
+/control/saveHistory
+#
+#run/verbose 4
+#event/verbose 4
+#tracking/verbose 5
+#process/verbose 4
+#particle/process/verbose 4
+#vis/verbose 4
+
+
+/vis/open OGLSXm
+/vis/scene/add/volume
+/vis/drawVolume
+/vis/viewer/update
+/tracking/storeTrajectory 1
+/vis/scene/add/trajectories
+/vis/scene/notifyHandlers
+#/run/beamOn 1
+
+/vis/viewer/update
+#/vis/viewer/refresh
+ 
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RichTbSimH.config b/LHCbG4Tests/G4RichTbSimH/options/RichTbSimH.config
new file mode 100644
index 0000000000000000000000000000000000000000..8cec188b38b9176886d417469a701b599d82970f
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RichTbSimH.config
@@ -0,0 +1 @@
+// ADD PREDEFINED MACROS HERE!
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig-ECUp_nobeamdiv-defaultdir.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig-ECUp_nobeamdiv-defaultdir.dat
new file mode 100644
index 0000000000000000000000000000000000000000..c2ce74a9ee25f7425a56fd62750b83109a364fcf
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig-ECUp_nobeamdiv-defaultdir.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdata_pion_20K_NoBeamDivergence_defaultdir_ECUp_SetK_prod.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdataHisto_pion_20K_NoBeamDivergence_defaultdir_ECUp_SetK.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdatatestntup_pion_20K_NoBeamDivergence_defaultdir_ECUp_SetK.root
+1 20000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+1
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig-HPDSetup.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig-HPDSetup.dat
new file mode 100644
index 0000000000000000000000000000000000000000..6b906c93e6c0626b01b1cbe3f97c5d68d30512de
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig-HPDSetup.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0 1 1 1 0 0 0 0  
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.00095 -0.00019 0.00041 0.00025 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/test/MCOutputFile/tbMCdata_interactive_ECUp_HPD_test.file
+/afs/cern.ch/work/s/seaso/RichTb_output/test/MCOutputFile/tbMCdataHisto_interactive_ECUP_HPD_test.root
+/afs/cern.ch/work/s/seaso/RichTb_output/test/MCOutputFile/tbMCdatatestntup_interactive_ECup_HPD_Test.root
+0 2 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+2
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig.dat
new file mode 100644
index 0000000000000000000000000000000000000000..9faf65f928570caf41eda653b95240babaf4af2c
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig.dat
@@ -0,0 +1,26 @@
+0 0 0 0 2 2 2 2 2 2 2 2 2 1 1 0 0 0 0 0 0 0 0 0 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0
+1 0.737 0.1 56287
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0 -5.0
+InputData/Mirror_D200mm_240906.txt
+tbMCdata_7.file
+tbMCdataHisto_7.root
+tbMCdatatestntup_7.root
+1 1000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 0.0
+3
+0.9 1
+InputData/EffJuraOpt.txt
+InputData/EffJuraThr7.txt
+InputData/EffSaleveOpt.txt
+InputData/EffSaleveThr7.txt
+InputData/EffJuraOpt_upgradeDummy.txt
+InputData/EffSaleveOpt_upgradeDummy.txt
+InputData/EffJuraTop100.txt
+InputData/EffSaleveTop100.txt
+InputData/EffJuraBottom100.txt
+InputData/EffSaleveBottom100.txt
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfigDoc.txt b/LHCbG4Tests/G4RichTbSimH/options/RunConfigDoc.txt
new file mode 100644
index 0000000000000000000000000000000000000000..70f359205db693f9aceadc4cd23e6f706f9fc20b
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfigDoc.txt
@@ -0,0 +1,168 @@
+Info on the RunConfig.dat
+
+Line 1:
+ Visibility:
+ Hall, vessel, crystal, CrystalCcover, PhD_Frame, EC , PMTmaster , PMTSMaster, PmtEnvelope, PmtWindow, PmtCathode, PmtAnode, PMTFrontRing, lens, radiator, mirror, DarkCover , UpsDarkCover, SidedarkCover, DnsdarkCover,
+ hpdqw hpdphcath hpdsidet hpdenv hpdenvcap hpdsmaster hpdmaster hpdSipixel
+
+ ( visibility 0 1 2: invisible, solid, wireframe )
+ (for hpdsipixel visibility 0 10 11 12 : graphicsinactive (default), invisible, solid, wireframe )
+Line2
+
+  GasTypecode (0 = nitrogen, 1 = C4F10),
+   NitrogenPressure, NitrogenTemperature,
+  C4F10Pressure, C4F10Temperature,
+  Mirror default orientation code ( -1= C4F10 default
+                                     0->5 N2 defaults.
+                                     0= Towards hpd0
+                                     1= Towards hpd1
+                                     2= Towards hpd2
+                                     3= Towards hpd3
+                                     4= Towards hpd4
+                                     5= Towards hpd5 )
+               default= -3 (or 3)   means oriented towards C1 Hpd.
+
+
+
+   MirrorAdditonalTiltX,
+   MirrorAdditonalTiltY
+
+Line 3
+ HpdNonOptimalFlag, HpdAnodeEff., BackScatterProb., RandomSeed
+
+
+Line4 :
+  Number of Particles in beam per event (1)
+
+  beam particle type code 0= pi-  (default)
+                          1= optical photon
+                          2= mixture of pi+ and proton
+                          3= mixture of pi- and electron
+                          4= mixture of pi- and kaon-
+                          5= mixture of pi+ and kaon+
+			  6= proton
+                          7=muon
+
+  beam particle  startPos code (0= at 0,0,-200.0
+                                1= beam shifted in X, Y wrt 0,0.
+                                 X shift in Beam Pos X shift
+                                 Y shift in Beam Pos Y shift as indicated
+                                 below.
+
+                                2= X,Y,Z locations of the beam from the
+                                   options file , as indicated below
+                                   as 'Beam XYZ Special studies'
+                                3: X of Beam Pos randomly varied
+                                   with the range specified below
+                                   as Beam Pos X Range.
+
+                                 )
+  beam particle Direction (0=  along 001,
+                           1 = along 0,0,-1
+                           2 = misligned  beamX,Y values.
+                           3 = misaligned and with divergence.
+                           4 = with new beam divergence and misalignment )
+
+  beam  Particle energy code (0 = momentum GeV/c for charged particles
+                              1 = const wavelngth in CLHEP::nanometer for Photon ,
+                                   from options file
+                              2 = range of wavelengths in CLHEP::nanometer
+                                    from Min to Max
+                                   for photons. The Min and Max
+                                   wavelength are from this options file.)
+
+  beamParticle momentum (10.0) GeV/c.
+
+  Positive beam fraction (fraction of  proton in pi+ vs protons
+                         or fraction of  electron in pi- vs electrons ) (0.0)
+                         used only when particle type 2 or 3 in above.
+
+  Beam Dir X, Y
+  Beam Divergence X,Y
+  Beam Pos shift X,Y
+  Beam Pos XYZ for special studies. The nominal value is from
+      parameters file (0,0,-200.0) for normal running.
+
+  Beam PosX Range wrt its mean value given by BeamPosShiftX.
+
+   Beam Phot Wlen PhotMinWlen PhotMaxWlen (only for particle type 1
+                          which is optical photon as beam ).
+   Hpd Pe initial Momemtum
+
+   Flag to write output file (0= no write, 1= do write )
+
+   Flag for hit creation option (0)
+
+   Shift of the ECs in x direction. To use this parameter the include of "RichTbRunConfig.hh" has to be uncommented as well as
+   the line below which sets the shift to -5.0 mm towards the centre relativ to the position of 70.6 mm for the ECs to the left
+   and right of the centre. When using the reconstruction an include of "RichTbRunConfig.hh" is not working.
+
+Line 5
+
+	Input data mirror
+Line 6
+	Output file name
+Line 7
+	Output histo file name
+Line 8
+	Output ntuple file name
+
+Line 9
+
+  Batch mode flag (0= not batch mode, 1=batch mode)
+
+  Number of events to process in batch mode
+
+  verbose level for hit printout.
+
+  verbose level for outputfile.
+
+  Flag for SpecialStudy of vessel rotation. (0 = default rotation applied
+                                                to vessel wrt global coord
+                                                 system.
+                                             1 = no rotation applied to vessel)
+  flag to activate the SiDet reflection     (0 = no activation,
+                                             1= activated )
+
+Line 10
+    Additional Shift for Hpd Demag X in Hpd 0 1 2   in mm
+    Additional Shift for Hpd Demag Y in Hpd 0 1 2  in mm
+    Additonal Rotation of Hpd 0 1 2 wrt its own Z axis in rad.
+    Additional shiftX for HPD master location in Ph det support frame.
+    Additional shiftY for HPD master location in Ph det support frame.
+Line 11
+	Alignment Shift for PMT 0-5 in X in mm
+	Alignment Shift for PMT 0-5 in Y in mm
+Line 12
+   Additional Shift for PhDetSupFrame XYZ in mm
+   Additional vertical tilt for PhDetSupframe in Rad.
+   Additional ZRotation for PhDetsupframe in Rad.
+
+Line13
+	flag to activate crystal rotation (0 = no rotation
+     		 	 	  1 = rotation)
+	crystal X rotation [rad]
+	crystal Y rotation [rad]
+
+Line14
+	flag to activate master rotation (0 = no rotation
+     		 	 	  1 = rotation)
+	master X rotation [rad]
+	master Y rotation [rad]
+
+line 15
+	configuration (1 = crystal+lens
+	       			0 = solid  radiator sphere segment
+              		2 = hpd + solid radiator sphere segment
+              		3 = testbeam 2015 setup: 8 ECs and full radiator circle in xy-plane)
+
+line 16
+	Overall Mapmt detection efficiency , Pixel efficiency activation flag (1 or >1  apply, 0 not apply )
+      When the pixel efficiency is applied, the overall Mapmt detection efficiency is not applied.
+      When the efficiency flag =1, the standard optimized pixel efficiency files used
+      When the efficiency flag =2, the threshold7 pixel efficiency files used.
+line17: File name for  pmt pixel efficiency: Optimized Jura side (pmts on the left of beam line as one looks along the beam)
+line18: File name for  pmt pixel efficiency: Threshold7 Jura side (pmts on the left of beam line as one looks along the beam )
+line19: File name for  pmt pixel efficiency: Optimized Saleve side (pmts on the right of beam line as one looks along the beam )
+line20: File name for  pmt pixel efficiency: Threshold7 Saleve side (pmts on the right beam line as one looks along the beam )
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_Apr11.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_Apr11.dat
new file mode 100644
index 0000000000000000000000000000000000000000..4ee446a14d5538c484bc899eeab85a6a4c60de06
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_Apr11.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.00095 -0.00019 0.00041 0.00025 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdata_pion_OptEff_gap2_20K_BeamDivergence_SetF_prod.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdataHisto_pion_OptEff_gaps2_20K_BeamDivergence_SetF.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdatatestntup_pion_OpteEff_gap2_20K_BeamDivergence_SetF.root
+1 20000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+1
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_Std_ECup_May15_2015.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_Std_ECup_May15_2015.dat
new file mode 100644
index 0000000000000000000000000000000000000000..f33f1441211d7bfd0d24cbc4c0b270abe4a3b7a8
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_Std_ECup_May15_2015.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.00095 -0.00019 0.00041 0.00025 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdata_pion_20K_Std_ECUp_SetK_prod.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdataHisto_pion_20K_Std__ECUp_SetK.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdatatestntup_pion_20K_Std_ECUp_SetK.root
+1 20000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+1
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_Withbeamdiv_defaultdir.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_Withbeamdiv_defaultdir.dat
new file mode 100644
index 0000000000000000000000000000000000000000..9f48ea057f00185c7236df11fd3f83bcba5e31c0
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_Withbeamdiv_defaultdir.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.00041 0.00025 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdata_pion_20K_BeamDivergence_defaultdir_SetK_prod.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdataHisto_pion_20K_BeamDivergence_defaultdir_RefInd_SetK.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdatatestntup_pion_20K_BeamDivergence_defaultdir_SetK.root
+1 20000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+1
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_batch.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_batch.dat
new file mode 100644
index 0000000000000000000000000000000000000000..bd6c2832e54d0cf7526158b2304b1ed4d2992366
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_batch.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0001 0.0001 0.0 0.0 0.0 0.0 -5000.0 10.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdata_pion_OptEff_gap2_20K_BeamDiv_SetC_prod.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdataHisto_pion_OptEff_gaps2_20K_BeamDiv_SetC.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdatatestntup_pion_OpteEff_gap2_20K_BeamDiv_SetC.root
+1 20000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+1
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd.dat
new file mode 100644
index 0000000000000000000000000000000000000000..3082572a70828c507691cf1827b55c522abe5a74
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0 1 1 1 0 1 0 0 11  
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.00095 -0.00019 0.00041 0.00025 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/test/MCOutputFile/tbMCdata_ECUp_HPD_test.file
+/afs/cern.ch/work/s/seaso/RichTb_output/test/MCOutputFile/tbMCdataHisto_ECUP_HPD_test.root
+/afs/cern.ch/work/s/seaso/RichTb_output/test/MCOutputFile/tbMCdatatestntup_ECup_HPD_Test.root
+0 10 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+2
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_Interactive.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_Interactive.dat
new file mode 100644
index 0000000000000000000000000000000000000000..3bd175b25535c0cd5a4562f2900841fb022d7059
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_Interactive.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 2 0 0 0 1 1 1 0 0 1 1 0 0 0 0 1 1 1 0 0 0 0 0  
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737 0.1
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdata_ECUp_hpd_interactive.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdataHisto_ECUP_hpd_Interactive.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdatatestntup_ECup_hpd_Interactive.root
+0 10 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+2
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_SetK.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_SetK.dat
new file mode 100644
index 0000000000000000000000000000000000000000..3cffd86a7e0b693a73a247e1c733ff6aad6fb986
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_SetK.dat
@@ -0,0 +1,21 @@
+0 0 0 0 2 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 2 0 2 1 1 0  
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737 0.1 895473
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdata_ECUp_hpd_AugRef10K_SetK.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdataHisto_ECUP_hpd_AugRef10K_SetK.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdatatestntup_ECup_hpd_AugRef10K_SetK.root
+1 10000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+2
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_SetP.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_SetP.dat
new file mode 100644
index 0000000000000000000000000000000000000000..0acb3effddbf1300322c63ed5d51c58dbb6139ad
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_SetP.dat
@@ -0,0 +1,21 @@
+0 0 0 0 2 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 2 0 2 1 1 0  
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737 0.1 996773
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdata_ECUp_hpd_AugRef10K_SetP.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdataHisto_ECUP_hpd_AugRef10K_SetP.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdatatestntup_ECup_hpd_AugRef10K_SetP.root
+1 10000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+2
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_SetR.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_SetR.dat
new file mode 100644
index 0000000000000000000000000000000000000000..d7011ee97654ca0ddc72b009340dc4006ecae198
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_SetR.dat
@@ -0,0 +1,21 @@
+0 0 0 0 2 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 2 0 2 1 1 0  
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737 0.1 317173
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdata_ECUp_hpd_AugRef10K_SetR.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdataHisto_ECUP_hpd_AugRef10K_SetR.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdatatestntup_ECup_hpd_AugRef10K_SetR.root
+1 10000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+2
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_setF.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_setF.dat
new file mode 100644
index 0000000000000000000000000000000000000000..0889e072cabc8bf05cc80fb51211bfe73d395b67
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_setF.dat
@@ -0,0 +1,21 @@
+0 0 0 0 2 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 2 0 2 1 1 0  
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737 0.1 966377
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdata_ECUp_hpd_AugRef10K_SetF.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdataHisto_ECUP_hpd_AugRef10K_SetF.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdatatestntup_ECup_hpd_AugRef10K_SetF.root
+1 10000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+2
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_setQ.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_setQ.dat
new file mode 100644
index 0000000000000000000000000000000000000000..387e252244f33c326a9d8d7a24fa5953b297ba8e
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_hpd_setQ.dat
@@ -0,0 +1,21 @@
+0 0 0 0 2 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 1 1 2 0 2 1 1 0  
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737 0.1 916173
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdata_ECUp_hpd_AugRef10K_SetQ.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdataHisto_ECUP_hpd_AugRef10K_SetQ.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdatatestntup_ECup_hpd_AugRef10K_SetQ.root
+1 10000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+2
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_interactive.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_interactive.dat
new file mode 100644
index 0000000000000000000000000000000000000000..c2a85bf9b98d8388ec39a1d92499ff98747e291e
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_interactive.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 0 0 100.0 0.0 0.0 0.0 0.0001 0.0001 0.0 0.0 0.0 0.0 -5000.0 10.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/test/tbdatatest_SetB_B_i.file
+/afs/cern.ch/work/s/seaso/RichTb_output/test/tbdatatestHisto_SetB_i.root
+/afs/cern.ch/work/s/seaso/RichTb_output/test/tbdatatestntup_SetB_i.root
+0 10 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+1
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_noBeamdiv_defaultdir.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_noBeamdiv_defaultdir.dat
new file mode 100644
index 0000000000000000000000000000000000000000..c9fd757ac52e9423af32f8455235fac7e14f7563
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_noBeamdiv_defaultdir.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdata_pion_20K_NoBeamDivergence_defaultdir_SetK_prod.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdataHisto_pion_20K_NoBeamDivergence_defaultdir_RefInd_SetK.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdatatestntup_pion_20K_NoBeamDivergence_defaultdir_SetK.root
+1 20000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+1
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_noBeamdiv_defaultdir_defaultEff.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_noBeamdiv_defaultdir_defaultEff.dat
new file mode 100644
index 0000000000000000000000000000000000000000..5f512baeba98bf7de06ea26c1c0d7b29675f6598
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_noBeamdiv_defaultdir_defaultEff.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdata_pion_20K_NoBeamDivergence_defaultdir_defaulteff_SetK_prod.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdataHisto_pion_20K_NoBeamDivergence_defaultdir_defaulteff_RefInd_SetK.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/MCOutputFile/tbMCdatatestntup_pion_20K_NoBeamDivergence_defaultdir_defaulteff_SetK.root
+1 20000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+1
+0.9 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_prod_April10.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_prod_April10.dat
new file mode 100644
index 0000000000000000000000000000000000000000..0a90f339ef727081460254ac8c9ae3451379c601
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_prod_April10.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.00095 -0.00019 0.00041 0.00025 0.0 0.0 0.0 0.0 -10000.0 3.4 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdata_pion_OptEff_gap2_20K_BeamDivergence_SetE_prod.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdataHisto_pion_OptEff_gaps2_20K_BeamDivergence_SetE.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdatatestntup_pion_OpteEff_gap2_20K_BeamDivergence_SetE.root
+1 20000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+1
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_save.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_save.dat
new file mode 100644
index 0000000000000000000000000000000000000000..d6cee128debdff49462f5fd84113fc5dcf7b96bf
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_save.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0001 0.0001 0.0 0.0 0.0 0.0 -5000.0 10.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdata_pion_OptEff_gap2_10K_BeamDivBB.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdataHisto_pion_OptEff_gaps2_10K_BeamDivBB.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdatatestntup_pion_OpteEff_gap2_10K_BeamDivBB.root
+1 20000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+1
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_save_stdProd_AugAndStdrefindex.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_save_stdProd_AugAndStdrefindex.dat
new file mode 100644
index 0000000000000000000000000000000000000000..19053330ddb3cac9a723a769eaf8fca1aa18e36b
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_save_stdProd_AugAndStdrefindex.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.00095 -0.00019 0.00041 0.00025 0.0 0.0 0.0 0.0 -5000.0 4.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdata_pion_OptEff_gap2_20K_BeamDivergence_AugrefInd_SetG_prod.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdataHisto_pion_OptEff_gaps2_20K_BeamDivergence_AugRefInd_SetG.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdatatestntup_pion_OpteEff_gap2_20K_BeamDivergence_AugRefInd_SetG.root
+1 20000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+1
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_std_prod.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_std_prod.dat
new file mode 100644
index 0000000000000000000000000000000000000000..bd6c2832e54d0cf7526158b2304b1ed4d2992366
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_std_prod.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0001 0.0001 0.0 0.0 0.0 0.0 -5000.0 10.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdata_pion_OptEff_gap2_20K_BeamDiv_SetC_prod.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdataHisto_pion_OptEff_gaps2_20K_BeamDiv_SetC.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdatatestntup_pion_OpteEff_gap2_20K_BeamDiv_SetC.root
+1 20000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+1
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/RunConfig_std_prod_refindexAugment.dat b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_std_prod_refindexAugment.dat
new file mode 100644
index 0000000000000000000000000000000000000000..14d138ae5ea47e6d703863c454af75a9e3a977ba
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/RunConfig_std_prod_refindexAugment.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0001 0.0001 0.0 0.0 0.0 0.0 -5000.0 10.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdata_pion_OptEff_gap2_20K_BeamDiv_RefIndexAugment_SetD_prod.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdataHisto_pion_OptEff_gaps2_20K_BeamDiv_RefIndexAugment_SetD.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdatatestntup_pion_OpteEff_gap2_20K_RefIndexAugment_BeamDiv_SetC.root
+1 20000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+1
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/save_options/RichConfig_save_mapfileMake.dat b/LHCbG4Tests/G4RichTbSimH/options/save_options/RichConfig_save_mapfileMake.dat
new file mode 100644
index 0000000000000000000000000000000000000000..d6cee128debdff49462f5fd84113fc5dcf7b96bf
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/save_options/RichConfig_save_mapfileMake.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0001 0.0001 0.0 0.0 0.0 0.0 -5000.0 10.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdata_pion_OptEff_gap2_10K_BeamDivBB.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdataHisto_pion_OptEff_gaps2_10K_BeamDivBB.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdatatestntup_pion_OpteEff_gap2_10K_BeamDivBB.root
+1 20000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+1
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/options/save_options/RunConfig_save_AnalysisCkv_March30.dat b/LHCbG4Tests/G4RichTbSimH/options/save_options/RunConfig_save_AnalysisCkv_March30.dat
new file mode 100644
index 0000000000000000000000000000000000000000..5a7f96880de0a60f3eac242697a65dfd6555db61
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/options/save_options/RunConfig_save_AnalysisCkv_March30.dat
@@ -0,0 +1,21 @@
+0 0 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0
+0 0.975 288.45 0.976 283.65 5 0.0 0.0 
+1 0.737
+1 0 2 3 0 100.0 0.0 0.0 0.0 0.0001 0.0001 0.0 0.0 0.0 0.0 -5000.0 10.0 400.0 195. 850. 20.0 1 0
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/Mirror_D200mm_240906.txt
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdata_pion_OptEff_gap2_30K_BeamDiv_SetC_prod.file
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdataHisto_pion_OptEff_gaps2_30K_BeamDiv_SetC.root
+/afs/cern.ch/work/s/seaso/RichTb_output/prod/tbMCdatatestntup_pion_OpteEff_gap2_30K_BeamDiv_SetC.root
+1 30000 1 2 0 1
+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 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 0.0 0.0 0.0 0.0
+0.0 0.0 0.0 0.0 0.0
+0 0.0 0.0
+1 0.0 -1.57
+1
+0.9 1
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffJuraThr7.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveOpt.txt
+/afs/cern.ch/user/s/seaso/cmtuser/Gauss_v47r0/Sim/RichTbSimH/InputData/EffSaleveThr7.txt
+
diff --git a/LHCbG4Tests/G4RichTbSimH/runDir/G4History.macro b/LHCbG4Tests/G4RichTbSimH/runDir/G4History.macro
new file mode 100644
index 0000000000000000000000000000000000000000..cbf93562fa5f0b19266af9a44c64d93840d268cc
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/runDir/G4History.macro
@@ -0,0 +1,23 @@
+/vis/open OGLSXm
+/vis/sceneHandler/create OGLSXm
+/vis/viewer/create ! ! 600
+/vis/viewer/refresh
+/vis/scene/add/volume
+/vis/drawVolume
+/vis/scene/create
+/vis/scene/add/volume world
+/vis/sceneHandler/attach
+/vis/viewer/update
+/tracking/storeTrajectory 1
+/vis/scene/add/trajectories
+/tracking/storeTrajectory 1
+/vis/scene/notifyHandlers
+/vis/scene/notifyHandlers
+/run/beamOn 1
+/vis/scene/notifyHandlers scene-0
+/run/verbose 1
+/event/verbose 0
+/tracking/verbose 0
+/particle/process/verbose 0
+/control/verbose 0
+/vis/viewer/update
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcG4/includeG4/RichTbG4Cerenkov.hh b/LHCbG4Tests/G4RichTbSimH/src/srcG4/includeG4/RichTbG4Cerenkov.hh
new file mode 100644
index 0000000000000000000000000000000000000000..2ff7adb838fd5cf69a70bd003e0880dd77e2fae6
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcG4/includeG4/RichTbG4Cerenkov.hh
@@ -0,0 +1,206 @@
+//
+// ********************************************************************
+// * DISCLAIMER                                                       *
+// *                                                                  *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in:                      *
+// *   http://cern.ch/geant4/license                                  *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.                                                             *
+// *                                                                  *
+// * This  code  implementation is the  intellectual property  of the *
+// * GEANT4 collaboration.                                            *
+// * By copying,  distributing  or modifying the Program (or any work *
+// * based  on  the Program)  you indicate  your  acceptance of  this *
+// * statement, and all its terms.                                    *
+// ********************************************************************
+//
+//
+// $Id: RichTbG4Cerenkov.hh,v 1.5 2001/07/11 10:03:41 gunter Exp $
+// GEANT4 tag $Name: geant4-07-00 $
+//
+// 
+////////////////////////////////////////////////////////////////////////
+// Cerenkov Radiation Class Definition 
+////////////////////////////////////////////////////////////////////////
+//
+// File:        RichTbG4Cerenkov.hh  
+// Description:	Continuous Process -- Generation of Cerenkov Photons
+// Version:     2.0
+// Created:     1996-02-21
+// Author:      Juliet Armstrong
+// Updated:     1999-10-29 add method and class descriptors
+//              1997-04-09 by Peter Gumplinger
+//              > G4MaterialPropertiesTable; new physics/tracking scheme
+// mail:        gum@triumf.ca
+// modified and renamed to extract info into usertrackinfo to output and
+//  to fill histo.               SE 1-3-2005.
+////////////////////////////////////////////////////////////////////////
+
+#ifndef RichTbG4Cerenkov_h
+#define RichTbG4Cerenkov_h 1
+
+/////////////
+// Includes
+/////////////
+
+#include "Geant4/globals.hh"
+#include "Geant4/templates.hh"
+#include "Geant4/Randomize.hh"
+#include "Geant4/G4ThreeVector.hh"
+#include "Geant4/G4ParticleMomentum.hh"
+#include "Geant4/G4Step.hh"
+#include "Geant4/G4VContinuousProcess.hh"
+#include "Geant4/G4OpticalPhoton.hh"
+#include "Geant4/G4DynamicParticle.hh"
+#include "Geant4/G4Material.hh"
+#include "Geant4/G4PhysicsTable.hh"
+#include "Geant4/G4MaterialPropertiesTable.hh"
+#include "Geant4/G4PhysicsOrderedFreeVector.hh"
+
+// Class Description:
+// Continuous Process -- Generation of Cerenkov Photons.
+// Class inherits publicly from G4VContinuousProcess.
+// Class Description - End:
+
+/////////////////////
+// Class Definition
+/////////////////////
+
+class RichTbG4Cerenkov : public G4VContinuousProcess  
+{
+
+private:
+
+        //////////////
+        // Operators
+        //////////////
+
+	// RichTbG4Cerenkov& operator=(const RichTbG4Cerenkov &right);
+
+public: // Without description
+
+	////////////////////////////////
+	// Constructors and Destructor
+	////////////////////////////////
+
+	RichTbG4Cerenkov(const G4String& processName = "Cerenkov");
+
+	// RichTbG4Cerenkov(const RichTbG4Cerenkov &right);
+
+	~RichTbG4Cerenkov();	
+
+        ////////////
+        // Methods
+        ////////////
+
+public: // With description
+
+        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.
+
+private:
+
+        void BuildThePhysicsTable();
+
+	/////////////////////
+	// Helper Functions
+	/////////////////////
+
+	G4double GetAverageNumberOfPhotons(const G4DynamicParticle *aParticle,
+		    		const G4Material *aMaterial,
+				    G4MaterialPropertyVector* Rindex) const;
+
+        ///////////////////////
+        // 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).
+
+private:
+
+	G4bool fTrackSecondariesFirst;
+	G4int  fMaxPhotons;
+};
+
+////////////////////
+// Inline methods
+////////////////////
+
+inline 
+G4bool RichTbG4Cerenkov::IsApplicable(const G4ParticleDefinition& aParticleType)
+{
+   return (aParticleType.GetPDGCharge() != 0);
+}
+
+inline 
+void RichTbG4Cerenkov::SetTrackSecondariesFirst(const G4bool state) 
+{ 
+	fTrackSecondariesFirst = state;
+}
+
+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 G4PhysicsTable* RichTbG4Cerenkov::GetPhysicsTable() const
+{
+  return thePhysicsTable;
+}
+
+#endif /* RichTbG4Cerenkov_h */
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcG4/includeG4/RichTbG4OpAbsorption.hh b/LHCbG4Tests/G4RichTbSimH/src/srcG4/includeG4/RichTbG4OpAbsorption.hh
new file mode 100644
index 0000000000000000000000000000000000000000..8b9173d371840f8f2f2f9734e7a47d476a115122
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcG4/includeG4/RichTbG4OpAbsorption.hh
@@ -0,0 +1,126 @@
+//
+// ********************************************************************
+// * DISCLAIMER                                                       *
+// *                                                                  *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in:                      *
+// *   http://cern.ch/geant4/license                                  *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.                                                             *
+// *                                                                  *
+// * This  code  implementation is the  intellectual property  of the *
+// * GEANT4 collaboration.                                            *
+// * By copying,  distributing  or modifying the Program (or any work *
+// * based  on  the Program)  you indicate  your  acceptance of  this *
+// * statement, and all its terms.                                    *
+// ********************************************************************
+//
+//
+// $Id: G4OpAbsorption.hh,v 1.7 2001/08/31 16:43:32 gum Exp $
+// GEANT4 tag $Name: geant4-07-00 $
+//
+////////////////////////////////////////////////////////////////////////
+// Optical Photon Absorption Class Definition
+////////////////////////////////////////////////////////////////////////
+//
+// File:        RichTbG4OpAbsorption.hh
+// Description: Discrete Process -- Bulk absorption of Optical Photons
+// Version:     1.0
+// Created:     1996-05-21
+// Author:      Juliet Armstrong
+// Updated:     1999-10-29 add method and class descriptors
+//              1997-04-09 by Peter Gumplinger
+//              > new physics/tracking scheme
+//              1998-08-25 by Stefano Magni
+//              > Change process to use G4MaterialPropertiesTables
+// mail:        gum@triumf.ca
+//              magni@mi.infn.it
+//
+////////////////////////////////////////////////////////////////////////
+
+#ifndef RichTbG4OpAbsorption_h
+#define RichTbG4OpAbsorption_h 1
+
+/////////////
+// Includes
+/////////////
+
+#include "Geant4/globals.hh"
+#include "Geant4/templates.hh"
+#include "Geant4/Randomize.hh"
+#include "Geant4/G4Step.hh"
+#include "Geant4/G4VDiscreteProcess.hh"
+#include "Geant4/G4DynamicParticle.hh"
+#include "Geant4/G4Material.hh"
+#include "Geant4/G4OpticalPhoton.hh"
+
+// Class Description:
+// Discrete Process -- Bulk absorption of Optical Photons.
+// Class inherits publicly from G4VDiscreteProcess
+// Class Description - End:
+
+/////////////////////
+// Class Definition
+/////////////////////
+
+class RichTbG4OpAbsorption : public G4VDiscreteProcess 
+{
+
+private:
+
+        //////////////
+        // Operators
+        //////////////
+
+        // RichTbG4OpAbsorption& operator=(const RichTbG4OpAbsorption &right);
+
+public: // Without description
+
+        ////////////////////////////////
+        // Constructors and Destructor
+        ////////////////////////////////
+
+        RichTbG4OpAbsorption(const G4String& processName = "OpAbsorption");
+
+        // RichTbG4OpAbsorption(const RichTbG4OpAbsorption &right);
+
+	~RichTbG4OpAbsorption();
+
+	////////////
+	// Methods
+        ////////////
+
+public: // With description
+
+        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.
+
+};
+
+////////////////////
+// Inline methods
+////////////////////
+
+inline
+G4bool RichTbG4OpAbsorption::IsApplicable(const G4ParticleDefinition& aParticleType)
+{
+   return ( &aParticleType == G4OpticalPhoton::OpticalPhoton() );
+}
+
+#endif /* RichTbG4OpAbsorption_h */
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcG4/includeG4/RichTbG4OpBoundaryProcess.hh b/LHCbG4Tests/G4RichTbSimH/src/srcG4/includeG4/RichTbG4OpBoundaryProcess.hh
new file mode 100644
index 0000000000000000000000000000000000000000..a5b43bb9f53fe9204f2cb37d58a8d41638d883e4
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcG4/includeG4/RichTbG4OpBoundaryProcess.hh
@@ -0,0 +1,416 @@
+//
+// ********************************************************************
+// * DISCLAIMER                                                       *
+// *                                                                  *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in:                      *
+// *   http://cern.ch/geant4/license                                  *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.                                                             *
+// *                                                                  *
+// * This  code  implementation is the  intellectual property  of the *
+// * GEANT4 collaboration.                                            *
+// * By copying,  distributing  or modifying the Program (or any work *
+// * based  on  the Program)  you indicate  your  acceptance of  this *
+// * statement, and all its terms.                                    *
+// ********************************************************************
+//
+//
+// $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
+////////////////////////////////////////////////////////////////////////
+//
+// File:        RichTbG4OpBoundaryProcess.hh
+// Description: Discrete Process -- reflection/refraction at
+//                                  optical interfaces
+// Version:     1.1
+// Created:     1997-06-18
+// Modified:    1999-10-29 add method and class descriptors
+//              1999-10-10 - Fill NewMomentum/NewPolarization in 
+//                           DoAbsorption. These members need to be
+//                           filled since DoIt calls 
+//                           aParticleChange.SetMomentumChange etc.
+//                           upon return (thanks to: Clark McGrew)
+//
+// 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.
+// CVS version tag: 
+////////////////////////////////////////////////////////////////////////
+
+#ifndef RichTbG4OpBoundaryProcess_h
+#define RichTbG4OpBoundaryProcess_h 1
+
+/////////////
+// Includes
+/////////////
+
+#include "Geant4/globals.hh"
+#include "Geant4/templates.hh"
+#include "Geant4/geomdefs.hh"
+#include "Geant4/Randomize.hh"
+#include "Geant4/G4Step.hh"
+#include "Geant4/G4VDiscreteProcess.hh"
+#include "Geant4/G4DynamicParticle.hh"
+#include "Geant4/G4Material.hh"
+#include "Geant4/G4LogicalBorderSurface.hh"
+#include "Geant4/G4LogicalSkinSurface.hh"
+#include "Geant4/G4OpticalSurface.hh"
+#include "Geant4/G4OpticalPhoton.hh"
+#include "Geant4/G4TransportationManager.hh"
+
+// Class Description:
+// Discrete Process -- reflection/refraction at optical interfaces.
+// 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 };
+
+class RichTbG4OpBoundaryProcess : public G4VDiscreteProcess 
+{
+
+private:
+
+        //////////////
+        // Operators
+        //////////////
+
+        // RichTbG4OpBoundaryProcess& operator=(const RichTbG4OpBoundaryProcess &right);
+
+        // RichTbG4OpBoundaryProcess(const RichTbG4OpBoundaryProcess &right);
+
+public: // Without description
+
+        ////////////////////////////////
+        // Constructors and Destructor
+        ////////////////////////////////
+
+        RichTbG4OpBoundaryProcess(const G4String& processName = "OpBoundary");
+
+	~RichTbG4OpBoundaryProcess();
+
+	////////////
+	// Methods
+        ////////////
+
+public: // With description
+
+        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. 
+
+	G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
+				       const G4Step&  aStep);
+        // This is the method implementing boundary processes.
+
+	G4OpticalSurfaceModel GetModel() const;
+        // Returns the optical surface mode.
+
+        RichTbG4OpBoundaryProcessStatus GetStatus() const;
+        // Returns the current status.
+
+	void           SetModel(G4OpticalSurfaceModel model);
+	// Set the optical surface model to be followed 
+        // (glisur || unified). 
+
+private:
+
+	void G4Swap(G4double* a, G4double* b) const;
+
+	void G4Swap(G4Material* a, G4Material* b) const;
+
+	void G4VectorSwap(G4ThreeVector* vec1, G4ThreeVector* vec2) const;
+
+	G4bool G4BooleanRand(const G4double prob) const;
+
+	G4ThreeVector G4IsotropicRand() const;
+
+	G4ThreeVector G4LambertianRand(const G4ThreeVector& normal);
+
+	G4ThreeVector G4PlaneVectorRand(const G4ThreeVector& normal) const; 
+
+	G4ThreeVector GetFacetNormal(const G4ThreeVector& Momentum,
+				     const G4ThreeVector&  Normal) const;
+
+	void DielectricMetal();
+	void DielectricDielectric();
+
+	void ChooseReflection();
+	void DoAbsorption();
+	void DoReflection();
+
+private:
+
+	G4double thePhotonMomentum;
+
+	G4ThreeVector OldMomentum;
+	G4ThreeVector OldPolarization;
+
+	G4ThreeVector NewMomentum;
+	G4ThreeVector NewPolarization;
+
+	G4ThreeVector theGlobalNormal;
+	G4ThreeVector theFacetNormal;
+
+	G4Material* Material1;
+	G4Material* Material2;
+
+	G4OpticalSurface* OpticalSurface;
+
+	G4double Rindex1;
+	G4double Rindex2;
+
+	G4double cost1, cost2, sint1, sint2;
+
+	RichTbG4OpBoundaryProcessStatus theStatus;
+
+	G4OpticalSurfaceModel theModel;
+
+	G4OpticalSurfaceFinish theFinish;
+
+	G4double theReflectivity;
+	G4double theEfficiency;
+	G4double prob_sl, prob_ss, prob_bs;
+
+       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'!
+
+  G4double temp;
+
+  temp = *a;
+  *a = *b;
+  *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!
+
+   G4Material* temp = a;
+
+   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'!
+
+  G4ThreeVector temp;
+
+  temp = *vec1;
+  *vec1 = *vec2;
+  *vec2 = temp;
+}
+
+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
+{
+  /* Returns a random isotropic unit vector. */
+
+  G4ThreeVector vect;
+  G4double len2;
+
+  do {
+
+    vect.setX(G4UniformRand() - 0.5);
+    vect.setY(G4UniformRand() - 0.5);
+    vect.setZ(G4UniformRand() - 0.5);
+
+    len2 = vect.mag2();
+
+  } while (len2 < 0.01 || len2 > 0.25);
+
+  return vect.unit();
+}
+
+inline
+G4ThreeVector RichTbG4OpBoundaryProcess::
+	      G4LambertianRand(const G4ThreeVector& normal)
+{
+  /* Returns a random lambertian unit vector. */
+
+  G4ThreeVector vect;
+  G4double ndotv;
+
+  do {
+    vect = G4IsotropicRand();
+
+    ndotv = normal * vect;
+
+    if (ndotv < 0.0) {
+      vect = -vect;
+      ndotv = -ndotv;
+    }
+
+  } while (!G4BooleanRand(ndotv));
+  return vect;
+}
+
+inline
+G4ThreeVector RichTbG4OpBoundaryProcess::
+	      G4PlaneVectorRand(const G4ThreeVector& normal) const
+
+  /* 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 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
+G4OpticalSurfaceModel RichTbG4OpBoundaryProcess::GetModel() const
+{
+   return theModel;
+}
+
+inline
+RichTbG4OpBoundaryProcessStatus RichTbG4OpBoundaryProcess::GetStatus() const
+{
+   return theStatus;
+}
+
+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::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::DoReflection()
+{
+        if ( theStatus == LambertianReflection ) {
+
+          NewMomentum = G4LambertianRand(theGlobalNormal);
+          theFacetNormal = (NewMomentum - OldMomentum).unit();
+
+        }
+        else if ( theFinish == ground ) {
+
+	  theStatus = LobeReflection;
+          theFacetNormal = GetFacetNormal(OldMomentum,theGlobalNormal);
+          G4double PdotN = OldMomentum * theFacetNormal;
+          NewMomentum = OldMomentum - (2.*PdotN)*theFacetNormal;
+
+        }
+        else {
+
+          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/G4RichTbSimH/src/srcG4/includeG4/RichTbG4OpRayleigh.hh b/LHCbG4Tests/G4RichTbSimH/src/srcG4/includeG4/RichTbG4OpRayleigh.hh
new file mode 100644
index 0000000000000000000000000000000000000000..8843630ecc62293d381bb7bb549c89ff60e779ec
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcG4/includeG4/RichTbG4OpRayleigh.hh
@@ -0,0 +1,179 @@
+//
+// ********************************************************************
+// * DISCLAIMER                                                       *
+// *                                                                  *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in:                      *
+// *   http://cern.ch/geant4/license                                  *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.                                                             *
+// *                                                                  *
+// * This  code  implementation is the  intellectual property  of the *
+// * GEANT4 collaboration.                                            *
+// * By copying,  distributing  or modifying the Program (or any work *
+// * based  on  the Program)  you indicate  your  acceptance of  this *
+// * statement, and all its terms.                                    *
+// ********************************************************************
+//
+//
+// $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 
+// Version:     1.0
+// Created:     1996-05-31
+// Author:      Juliet Armstrong
+// Updated:     1999-10-29 add method and class descriptors
+//              1997-04-09 by Peter Gumplinger
+//              > new physics/tracking scheme
+// mail:        gum@triumf.ca
+// modified and renamed to extract info into usertrackinfo. SE 1-3-2005.
+////////////////////////////////////////////////////////////////////////
+
+#ifndef RichTbG4OpRayleigh_h
+#define RichTbG4OpRayleigh_h 1
+
+/////////////
+// Includes
+/////////////
+
+#include "Geant4/globals.hh"
+#include "Geant4/templates.hh"
+#include "Geant4/Randomize.hh"
+#include "Geant4/G4ThreeVector.hh"
+#include "Geant4/G4ParticleMomentum.hh"
+#include "Geant4/G4Step.hh"
+#include "Geant4/G4VDiscreteProcess.hh"
+#include "Geant4/G4DynamicParticle.hh"
+#include "Geant4/G4Material.hh"
+#include "Geant4/G4OpticalPhoton.hh"
+#include "Geant4/G4PhysicsTable.hh"
+#include "Geant4/G4PhysicsOrderedFreeVector.hh"
+
+// Class Description:
+// Discrete Process -- Rayleigh scattering of optical photons.
+// Class inherits publicly from G4VDiscreteProcess.
+// Class Description - End:
+
+/////////////////////
+// Class Definition
+/////////////////////
+
+class RichTbG4OpRayleigh : public G4VDiscreteProcess 
+{
+
+private:
+ 
+        //////////////
+        // Operators
+        //////////////
+
+        // RichTbG4OpRayleigh& operator=(const RichTbG4OpRayleigh &right);
+
+public: // Without description
+
+        ////////////////////////////////
+        // Constructors and Destructor
+        ////////////////////////////////
+ 
+        RichTbG4OpRayleigh(const G4String& processName = "OpRayleigh");
+
+        // RichTbG4OpRayleigh(const RichTbG4OpRayleigh &right);
+
+	~RichTbG4OpRayleigh();
+
+        ////////////
+        // Methods
+        ////////////
+
+public: // With description
+
+        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! ---
+
+        G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
+                                       const G4Step&  aStep);
+        // This is the method implementing Rayleigh scattering.
+
+        G4PhysicsTable* GetPhysicsTable() const;
+        // Returns the address of the physics table.
+
+        void DumpPhysicsTable() const;
+        // Prints the physics table.
+
+private:
+
+        void BuildThePhysicsTable();
+
+        /////////////////////
+        // Helper Functions
+        /////////////////////
+
+	G4PhysicsOrderedFreeVector* RayleighAttenuationLengthGenerator(
+					G4MaterialPropertiesTable *aMPT);
+
+        ///////////////////////
+        // 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).
+
+private:
+
+        G4bool DefaultWater;
+
+};
+
+////////////////////
+// Inline methods
+////////////////////
+
+inline
+G4bool RichTbG4OpRayleigh::IsApplicable(const G4ParticleDefinition& aParticleType)
+{
+  return ( &aParticleType == G4OpticalPhoton::OpticalPhoton() );
+}
+
+inline
+void RichTbG4OpRayleigh::DumpPhysicsTable() const
+
+{
+        G4int PhysicsTableSize = thePhysicsTable->entries();
+        G4PhysicsOrderedFreeVector *v;
+
+        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/G4RichTbSimH/src/srcG4/proc/RichTbG4Cerenkov.cc b/LHCbG4Tests/G4RichTbSimH/src/srcG4/proc/RichTbG4Cerenkov.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f0494642524086592261f3d6444e131443c43974
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcG4/proc/RichTbG4Cerenkov.cc
@@ -0,0 +1,592 @@
+//
+// ********************************************************************
+// * DISCLAIMER                                                       *
+// *                                                                  *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in:                      *
+// *   http://cern.ch/geant4/license                                  *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.                                                             *
+// *                                                                  *
+// * This  code  implementation is the  intellectual property  of the *
+// * GEANT4 collaboration.                                            *
+// * By copying,  distributing  or modifying the Program (or any work *
+// * based  on  the Program)  you indicate  your  acceptance of  this *
+// * statement, and all its terms.                                    *
+// ********************************************************************
+//
+//
+// $Id: RichTbG4Cerenkov.cc,v 1.17 2004/12/10 18:49:57 gcosmo Exp $
+// GEANT4 tag $Name: geant4-07-00 $
+//
+////////////////////////////////////////////////////////////////////////
+// Cerenkov Radiation Class Implementation
+////////////////////////////////////////////////////////////////////////
+//
+// File:        RichTbG4Cerenkov.cc 
+// Description: Continuous Process -- Generation of Cerenkov Photons
+// Version:     2.1
+// Created:     1996-02-21  
+// Author:      Juliet Armstrong
+// 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 
+//              > and a test for MeanNumPhotons <= 0.0 in DoIt
+//              2000-09-18 by Peter Gumplinger
+//              > change: aSecondaryPosition=x0+rand*aStep.GetDeltaPosition();
+//                        aSecondaryTrack->SetTouchable(0);
+//              1999-10-29 by Peter Gumplinger
+//              > change: == into <= in GetContinuousStepLimit
+//              1997-08-08 by Peter Gumplinger
+//              > add protection against /0
+//              > G4MaterialPropertiesTable; new physics/tracking scheme
+//
+// mail:        gum@triumf.ca
+// modifed  Se 1-3-2005 to extract some values to the usertrack for output.
+//        renamed the class.
+////////////////////////////////////////////////////////////////////////
+
+#include "Geant4/G4ios.hh"
+#include "Geant4/G4Poisson.hh"
+#include "RichTbG4Cerenkov.hh"
+#include "RichTbPhotonUserInfoAttach.hh"
+#include "RichTbPhotonProdHisto.hh"
+
+using namespace std;
+
+/////////////////////////
+// Class Implementation  
+/////////////////////////
+
+        //////////////
+        // Operators
+        //////////////
+
+// RichTbG4Cerenkov::operator=(const RichTbG4Cerenkov &right)
+// {
+// }
+
+        /////////////////
+        // Constructors
+        /////////////////
+
+RichTbG4Cerenkov::RichTbG4Cerenkov(const G4String& processName)
+           : G4VContinuousProcess(processName)
+{
+	fTrackSecondariesFirst = false;
+	fMaxPhotons = 0;
+
+        thePhysicsTable = NULL;
+
+	if (verboseLevel>0) {
+           G4cout << GetProcessName() << " is created " << G4endl;
+	}
+
+	BuildThePhysicsTable();
+}
+
+// RichTbG4Cerenkov::RichTbG4Cerenkov(const RichTbG4Cerenkov &right)
+// {
+// }
+
+        ////////////////
+        // Destructors
+        ////////////////
+
+RichTbG4Cerenkov::~RichTbG4Cerenkov() 
+{
+	if (thePhysicsTable != NULL) {
+	   thePhysicsTable->clearAndDestroy();
+           delete thePhysicsTable;
+	}
+}
+
+        ////////////
+        // Methods
+        ////////////
+
+// AlongStepDoIt
+// -------------
+//
+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. 
+
+{
+	//////////////////////////////////////////////////////
+	// Should we ensure that the material is dispersive?
+	//////////////////////////////////////////////////////
+
+        aParticleChange.Initialize(aTrack);
+
+	//        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();
+
+	G4ThreeVector x0 = pPreStepPoint->GetPosition();
+        G4ThreeVector p0 = aStep.GetDeltaPosition().unit();
+	G4double t0 = pPreStepPoint->GetGlobalTime();
+
+        G4MaterialPropertiesTable* aMaterialPropertiesTable =
+                               aMaterial->GetMaterialPropertiesTable();
+        if (!aMaterialPropertiesTable)
+           return G4VContinuousProcess::AlongStepDoIt(aTrack, aStep);
+
+	       G4MaterialPropertyVector* Rindex = 
+                aMaterialPropertiesTable->GetProperty("CKVRNDX"); 
+        if (!Rindex) 
+	   return G4VContinuousProcess::AlongStepDoIt(aTrack, aStep);
+
+	G4double MeanNumPhotons = 
+                 GetAverageNumberOfPhotons(aParticle,aMaterial,Rindex);
+
+        if (MeanNumPhotons <= 0.0) {
+
+                // return unchanged particle and no secondaries
+
+                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;
+
+	MeanNumPhotons = MeanNumPhotons * step_length;
+
+
+	G4int NumPhotons = (G4int) G4Poisson(MeanNumPhotons);
+
+	if (NumPhotons <= 0) {
+
+		// return unchanged particle and no secondaries  
+
+		aParticleChange.SetNumberOfSecondaries(0);
+		
+                return G4VContinuousProcess::AlongStepDoIt(aTrack, aStep);
+	}
+
+	////////////////////////////////////////////////////////////////
+
+	aParticleChange.SetNumberOfSecondaries(NumPhotons);
+
+        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 dp = Pmax - Pmin;
+
+  //	G4double nMax = Rindex->GetMaxProperty();
+  //	G4double nMin = Rindex->GetMinValue();	
+	G4double nMax = Rindex->GetMaxValue();
+
+        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);
+
+	for (G4int i = 0; i < NumPhotons; i++) {
+
+		// Determine photon momentum
+
+		G4double rand;
+    //	G4double sampledMomentum, sampledRI; 
+
+    G4double sampledEnergy, sampledRI; 
+
+		G4double cosTheta, sin2Theta;
+		
+		// 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;  
+      //	G4cout<<"RichG4cerenkov SampledMom sampledRI costh th "
+      //                      <<sampledMomentum<<"  "<<	sampledRI<<"   "
+      //                      <<cosTheta<< "   "<<acos(cosTheta)<<G4endl;
+
+			sin2Theta = (1.0 - cosTheta)*(1.0 + cosTheta);
+			rand = G4UniformRand();	
+
+		} while (rand*maxSin2 > sin2Theta);
+
+		// Generate random position of photon on cone surface 
+		// defined by Theta 
+
+		rand = G4UniformRand();
+
+		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)
+
+		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  
+
+		G4ParticleMomentum photonMomentum(px, py, pz);
+
+		// Rotate momentum direction back to global reference
+		// system 
+
+                photonMomentum.rotateUz(p0);
+
+		// Determine polarization of new photon 
+
+		G4double sx = cosTheta*cosPhi;
+		G4double sy = cosTheta*sinPhi; 
+		G4double sz = -sinTheta;
+
+		G4ThreeVector photonPolarization(sx, sy, sz);
+
+		// Rotate back to original coord system 
+
+                photonPolarization.rotateUz(p0);
+		
+                // Generate a new photon:
+
+                G4DynamicParticle* aCerenkovPhoton =
+                  new G4DynamicParticle(G4OpticalPhoton::OpticalPhoton(), 
+  					                 photonMomentum);
+		aCerenkovPhoton->SetPolarization
+				     (photonPolarization.x(),
+				      photonPolarization.y(),
+				      photonPolarization.z());
+
+    //	aCerenkovPhoton->SetKineticEnergy(sampledMomentum);
+		aCerenkovPhoton->SetKineticEnergy(sampledEnergy);
+
+                // Generate new G4Track object:
+
+		rand = G4UniformRand();
+
+                G4double delta = rand * aStep.GetStepLength();
+		G4double deltaTime = delta /
+                       ((pPreStepPoint->GetVelocity()+
+                         pPostStepPoint->GetVelocity())/2.);
+
+                G4double aSecondaryTime = t0 + deltaTime;
+
+                G4ThreeVector aSecondaryPosition =
+                                    x0 + rand * aStep.GetDeltaPosition();
+
+		G4Track* aSecondaryTrack = 
+		new G4Track(aCerenkovPhoton,aSecondaryTime,aSecondaryPosition);
+
+                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);
+    //		aParticleChange.AddSecondary(aSecondaryTrack);
+
+		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;
+	}
+
+	return G4VContinuousProcess::AlongStepDoIt(aTrack, aStep);
+}
+
+// BuildThePhysicsTable for the Cerenkov process
+// ---------------------------------------------
+//
+
+void RichTbG4Cerenkov::BuildThePhysicsTable()
+{
+	if (thePhysicsTable) return;
+
+	const G4MaterialTable* theMaterialTable=
+	 		       G4Material::GetMaterialTable();
+	G4int numOfMaterials = G4Material::GetNumberOfMaterials();
+
+	// create new physics table
+	
+	thePhysicsTable = new G4PhysicsTable(numOfMaterials);
+
+	// loop for materials
+
+	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 
+
+		G4Material* aMaterial = (*theMaterialTable)[i];
+
+		G4MaterialPropertiesTable* aMaterialPropertiesTable =
+				aMaterial->GetMaterialPropertiesTable();
+
+		if (aMaterialPropertiesTable) {
+
+		   G4MaterialPropertyVector* theRefractionIndexVector = 
+		    	   aMaterialPropertiesTable->GetProperty("CKVRNDX");
+
+		   if (theRefractionIndexVector) {
+		
+		      // Retrieve the first refraction index in vector
+		      // of (photon momentum, refraction index) pairs 
+
+		     // theRefractionIndexVector->ResetIterator();
+		     // ++(*theRefractionIndexVector);	// advance to 1st entry
+
+          G4double currentRI = (*theRefractionIndexVector)[0];
+		      //G4double currentRI = theRefractionIndexVector->
+          //		   GetProperty();
+
+		      if (currentRI > 1.0) {
+
+			 // Create first (photon momentum, Cerenkov Integral)
+			 // pair  
+
+            // G4double currentPM = theRefractionIndexVector->
+            //	 GetPhotonMomentum();
+            //G4double currentPM = theRefractionIndexVector->
+			 			// GetPhotonMomentum();
+
+       G4double currentPM = theRefractionIndexVector->Energy(0);
+			 G4double currentCAI = 0.0;
+
+			 aPhysicsOrderedFreeVector->
+			 	 InsertValues(currentPM , currentCAI);
+
+			 // Set previous values to current ones prior to loop
+
+			 G4double prevPM  = currentPM;
+			 G4double prevCAI = currentCAI;
+                	 G4double prevRI  = currentRI;
+
+			 // 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->	
+            //	GetProperty();
+
+            //	currentPM = theRefractionIndexVector->
+            //		GetPhotonMomentum();
+
+				currentCAI = 0.5*(1.0/(prevRI*prevRI) +
+					          1.0/(currentRI*currentRI));
+
+				currentCAI = prevCAI + 
+					     (currentPM - prevPM) * currentCAI;
+
+				aPhysicsOrderedFreeVector->
+				    InsertValues(currentPM, currentCAI);
+
+				prevPM  = currentPM;
+				prevCAI = currentCAI;
+				prevRI  = currentRI;
+			 }
+
+		      }
+		   }
+		}
+
+	// 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;
+
+        const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
+        const G4Material* aMaterial = aTrack.GetMaterial();
+
+        G4MaterialPropertiesTable* aMaterialPropertiesTable =
+                               aMaterial->GetMaterialPropertiesTable();
+        if (!aMaterialPropertiesTable) return DBL_MAX;
+
+         G4MaterialPropertyVector* Rindex =
+                aMaterialPropertiesTable->GetProperty("CKVRNDX");
+        if (!Rindex) return DBL_MAX;
+
+	G4double MeanNumPhotons = 
+                 GetAverageNumberOfPhotons(aParticle,aMaterial,Rindex);
+
+        if(MeanNumPhotons <= 0.0) return DBL_MAX;
+
+	G4double StepLimit = fMaxPhotons / MeanNumPhotons;
+
+	return StepLimit;
+}
+
+// GetAverageNumberOfPhotons
+// -------------------------
+// This routine computes the number of Cerenkov photons produced per
+// 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);
+
+        if(aParticle->GetTotalMomentum() <= 0.0)return 0.0;
+
+	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
+ 
+	G4int materialIndex = aMaterial->GetIndex();
+
+	// Retrieve the Cerenkov Angle Integrals for this material  
+
+	G4PhysicsOrderedFreeVector* CerenkovAngleIntegrals =
+	(G4PhysicsOrderedFreeVector*)((*thePhysicsTable)(materialIndex));
+
+        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 Refraction Indices 
+  //	G4double nMin = Rindex->GetMinProperty();	
+  //	G4double nMax = Rindex->GetMaxProperty();
+
+	G4double nMin = Rindex->GetMinValue();	
+	G4double nMax = Rindex->GetMaxValue();
+
+	// Max Cerenkov Angle Integral 
+	G4double CAImax = CerenkovAngleIntegrals->GetMaxValue();
+
+	G4double dp, ge;
+
+	// If n(Pmax) < 1/Beta -- no photons generated 
+
+	if (nMax < BetaInverse) {
+		dp = 0;
+		ge = 0;
+	} 
+
+	// otherwise if n(Pmin) >= 1/Beta -- photons generated  
+
+	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.  
+
+	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;		
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcG4/proc/RichTbG4OpAbsorption.cc b/LHCbG4Tests/G4RichTbSimH/src/srcG4/proc/RichTbG4OpAbsorption.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3df85d898be5684539ba29eb763c96869865649f
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcG4/proc/RichTbG4OpAbsorption.cc
@@ -0,0 +1,145 @@
+//
+// ********************************************************************
+// * DISCLAIMER                                                       *
+// *                                                                  *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in:                      *
+// *   http://cern.ch/geant4/license                                  *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.                                                             *
+// *                                                                  *
+// * This  code  implementation is the  intellectual property  of the *
+// * GEANT4 collaboration.                                            *
+// * By copying,  distributing  or modifying the Program (or any work *
+// * based  on  the Program)  you indicate  your  acceptance of  this *
+// * statement, and all its terms.                                    *
+// ********************************************************************
+//
+//
+// $Id: G4OpAbsorption.cc,v 1.5 2004/10/19 02:15:15 gum Exp $
+// GEANT4 tag $Name: geant4-07-00 $
+//
+////////////////////////////////////////////////////////////////////////
+// Optical Photon Absorption Class Implementation
+////////////////////////////////////////////////////////////////////////
+//
+// File:        RichTbG4OpAbsorption.cc
+// 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" 
+//              1997-04-09 by Peter Gumplinger
+//              > new physics/tracking scheme
+//              1998-08-25 by Stefano Magni
+//              > Change process to use G4MaterialPropertiesTables
+//              1998-09-03 by Peter Gumplinger
+//              > Protect G4MaterialPropertyVector* AttenuationLengthVector
+// mail:        gum@triumf.ca
+//              magni@mi.infn.it
+//
+////////////////////////////////////////////////////////////////////////
+
+#include "Geant4/G4ios.hh"
+#include "RichTbG4OpAbsorption.hh"
+
+/////////////////////////
+// Class Implementation
+/////////////////////////
+
+        //////////////
+        // Operators
+        //////////////
+
+// RichTbG4OpAbsorption::operator=(const RichTbG4OpAbsorption &right)
+// {
+// }
+
+        /////////////////
+        // Constructors
+        /////////////////
+
+RichTbG4OpAbsorption::RichTbG4OpAbsorption(const G4String& processName)
+              : G4VDiscreteProcess(processName)
+{
+        if (verboseLevel>0) {
+           G4cout << GetProcessName() << " is created " << G4endl;
+        }
+}
+
+// RichTbG4OpAbsorption::RichTbG4OpAbsorption(const G4OpAbsorpton &right)
+// {
+// }
+
+        ////////////////
+        // Destructors
+        ////////////////
+
+RichTbG4OpAbsorption::~RichTbG4OpAbsorption(){}
+
+        ////////////
+        // 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);
+}
+
+
+// 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;
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcG4/proc/RichTbG4OpBoundaryProcess.cc b/LHCbG4Tests/G4RichTbSimH/src/srcG4/proc/RichTbG4OpBoundaryProcess.cc
new file mode 100644
index 0000000000000000000000000000000000000000..50eefb81d627fa74b7fb29310e52d350c047b291
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcG4/proc/RichTbG4OpBoundaryProcess.cc
@@ -0,0 +1,963 @@
+//
+// ********************************************************************
+// * DISCLAIMER                                                       *
+// *                                                                  *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in:                      *
+// *   http://cern.ch/geant4/license                                  *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.                                                             *
+// *                                                                  *
+// * This  code  implementation is the  intellectual property  of the *
+// * GEANT4 collaboration.                                            *
+// * By copying,  distributing  or modifying the Program (or any work *
+// * based  on  the Program)  you indicate  your  acceptance of  this *
+// * statement, and all its terms.                                    *
+// ********************************************************************
+//
+////////////////////////////////////////////////////////////////////////
+// Optical Photon Boundary Process Class Implementation
+////////////////////////////////////////////////////////////////////////
+//
+// File:        RichTbG4OpBoundaryProcess.cc
+// Description: Discrete Process -- reflection/refraction at
+//                                  optical interfaces
+// Version:     1.1
+// Created:     1997-06-18
+// Modified:    1998-05-25 - Correct parallel component of polarization
+//                           (thanks to: Stefano Magni + Giovanni Pieri)
+//              1998-05-28 - NULL Rindex pointer before reuse
+//                           (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 
+//                           method: GetLocalExitNormal(&valid) to get
+//                           the surface normal in all cases
+//              1998-11-07 - NULL OpticalSurface pointer before use
+//                           comparison not sharp for: std::abs(cost1) < 1.0
+//                           remove sin1, sin2 in lines 556,567
+//                           (thanks to Stefano Magni)
+//              1999-10-10 - Accommodate changes done in DoAbsorption by
+//                           changing logic in DielectricMetal
+//              2001-10-18 - avoid Linux (gcc-2.95.2) warning about variables
+//                           might be used uninitialized in this function
+//                           moved E2_perp, E2_parl and E2_total out of 'if'
+//              2003-11-27 - Modified line 168-9 to reflect changes made to
+//                           G4OpticalSurface class ( by Fan Lei)
+//              2004-02-02 - Set theStatus = Undefined at start of DoIt
+//
+// 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. 
+////////////////////////////////////////////////////////////////////////
+
+#include "Geant4/G4ios.hh"
+#include "RichTbG4OpBoundaryProcess.hh"
+#include "RichTbMiscNames.hh"
+#include "Geant4/G4GeometryTolerance.hh"
+
+/////////////////////////
+// Class Implementation
+/////////////////////////
+
+        //////////////
+        // 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;
+
+
+}
+
+// RichTbG4OpBoundaryProcess::RichTbG4OpBoundaryProcess(const RichTbG4OpBoundaryProcess &right)
+// {
+// }
+
+        ////////////////
+        // Destructors
+        ////////////////
+
+RichTbG4OpBoundaryProcess::~RichTbG4OpBoundaryProcess(){}
+
+        ////////////
+        // Methods
+        ////////////
+
+// PostStepDoIt
+// ------------
+//
+G4VParticleChange*
+RichTbG4OpBoundaryProcess::PostStepDoIt(const G4Track& aTrack, const G4Step& aStep)
+{
+        theStatus = Undefined;
+
+        aParticleChange.Initialize(aTrack);
+
+        G4StepPoint* pPreStepPoint  = aStep.GetPreStepPoint();
+        G4StepPoint* pPostStepPoint = aStep.GetPostStepPoint();
+
+        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);
+	}
+
+	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;    
+  // end of printout by SE
+
+
+  G4int CurrentStepNumber = aTrack.GetCurrentStepNumber();
+  CurStepNum = CurrentStepNumber;
+  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();
+
+	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 
+  //   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 (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);
+           }
+        }
+
+        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);
+	      }
+           }
+        }
+
+        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();
+
+	G4ThreeVector theLocalPoint = theNavigator->
+        			      GetGlobalToLocalTransform().
+				      TransformPoint(theGlobalPoint);
+
+	G4ThreeVector theLocalNormal;	// Normal points back into volume
+
+	G4bool valid;
+	theLocalNormal = theNavigator->GetLocalExitNormal(&valid);
+
+	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) {
+#ifdef G4DEBUG_OPTICAL
+           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;
+        }
+
+	// 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);
+
+        return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+}
+
+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;
+}
+
+void RichTbG4OpBoundaryProcess::DielectricMetal()
+{
+        G4int n = 0;
+
+	do {
+
+           n++;
+
+           if( !G4BooleanRand(theReflectivity) && n == 1 ) {
+
+             DoAbsorption();
+             break;
+
+           }
+           else {
+
+             if ( theModel == glisur || theFinish == polished || 
+                                        prob_ss+prob_sl+prob_bs == 0.0 ) {
+               // G4cout << "reflection" << G4endl;
+                DoReflection();
+
+             } else {
+
+                if ( n == 1 ) ChooseReflection();
+                                                                                
+                if ( theStatus == LambertianReflection ) {
+                   DoReflection();
+                }
+                else if ( theStatus == BackScattering ) {
+                   NewMomentum = -OldMomentum;
+                   NewPolarization = -OldPolarization;
+                }
+                else {
+
+                   if(theStatus==LobeReflection)theFacetNormal = 
+                             GetFacetNormal(OldMomentum,theGlobalNormal);
+
+                   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);
+}
+
+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.
+
+	      }
+	      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;
+
+	return DBL_MAX;
+}
+
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcG4/proc/RichTbG4OpRayleigh.cc b/LHCbG4Tests/G4RichTbSimH/src/srcG4/proc/RichTbG4OpRayleigh.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8699f8ec65ffa82a78f2a5a3e97476dea82b48db
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcG4/proc/RichTbG4OpRayleigh.cc
@@ -0,0 +1,394 @@
+//
+// ********************************************************************
+// * DISCLAIMER                                                       *
+// *                                                                  *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in:                      *
+// *   http://cern.ch/geant4/license                                  *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.                                                             *
+// *                                                                  *
+// * This  code  implementation is the  intellectual property  of the *
+// * GEANT4 collaboration.                                            *
+// * By copying,  distributing  or modifying the Program (or any work *
+// * based  on  the Program)  you indicate  your  acceptance of  this *
+// * statement, and all its terms.                                    *
+// ********************************************************************
+//
+//
+// $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  
+// Version:     1.0
+// Created:     1996-05-31  
+// Author:      Juliet Armstrong
+// Updated:     2001-10-18 by Peter Gumplinger
+//              eliminate unused variable warning on Linux (gcc-2.95.2)
+// Updated:     2001-09-18 by mma
+//		>numOfMaterials=G4Material::GetNumberOfMaterials() in BuildPhy
+// Updated:     2001-01-30 by Peter Gumplinger
+//              > allow for positiv and negative CosTheta and force the
+//              > new momentum direction to be in the same plane as the
+//              > new and old polarization vectors
+//              2001-01-29 by Peter Gumplinger
+//              > fix calculation of SinTheta (from CosTheta)
+//              1997-04-09 by Peter Gumplinger
+//              > new physics/tracking scheme
+// mail:        gum@triumf.ca
+// modif and renamed for extracting info SE 1-3-2005.
+////////////////////////////////////////////////////////////////////////
+
+#include "Geant4/G4ios.hh"
+#include "RichTbG4OpRayleigh.hh"
+#include "RichTbPhotonUserInfoAttach.hh"
+
+/////////////////////////
+// Class Implementation
+/////////////////////////
+
+        //////////////
+        // Operators
+        //////////////
+
+// RichTbG4OpRayleigh::operator=(const RichTbG4OpRayleigh &right)
+// {
+// }
+
+        /////////////////
+        // Constructors
+        /////////////////
+
+RichTbG4OpRayleigh::RichTbG4OpRayleigh(const G4String& processName)
+           : G4VDiscreteProcess(processName)
+{
+
+        thePhysicsTable = 0;
+
+        DefaultWater = false;
+
+        if (verboseLevel>0) {
+           G4cout << GetProcessName() << " is created " << G4endl;
+        }
+
+        BuildThePhysicsTable();
+}
+
+// RichTbG4OpRayleigh::RichTbG4OpRayleigh(const RichTbG4OpRayleigh &right)
+// {
+// }
+
+        ////////////////
+        // Destructors
+        ////////////////
+
+RichTbG4OpRayleigh::~RichTbG4OpRayleigh()
+{
+        if (thePhysicsTable!= 0) {
+           thePhysicsTable->clearAndDestroy();
+           delete thePhysicsTable;
+        }
+}
+
+        ////////////
+        // 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);
+}
+
+// BuildThePhysicsTable for the Rayleigh Scattering process
+// --------------------------------------------------------
+//
+void RichTbG4OpRayleigh::BuildThePhysicsTable()
+{
+//      Builds a table of scattering lengths for each material
+
+        if (thePhysicsTable) return;
+
+        const G4MaterialTable* theMaterialTable=
+                               G4Material::GetMaterialTable();
+        G4int numOfMaterials = G4Material::GetNumberOfMaterials();
+
+        // create a new physics table
+
+        thePhysicsTable = new G4PhysicsTable(numOfMaterials);
+
+        // loop for materials
+
+        for (G4int i=0 ; i < numOfMaterials; i++)
+        {
+            G4PhysicsOrderedFreeVector* ScatteringLengths =
+                                new G4PhysicsOrderedFreeVector();
+
+            G4MaterialPropertiesTable *aMaterialPropertiesTable =
+                         (*theMaterialTable)[i]->GetMaterialPropertiesTable();
+                                                                                
+            if(aMaterialPropertiesTable){
+
+              G4MaterialPropertyVector* AttenuationLengthVector =
+                            aMaterialPropertiesTable->GetProperty("RAYLEIGH");
+
+              if(!AttenuationLengthVector){
+
+                if ((*theMaterialTable)[i]->GetName() == "Water")
+                {
+		   // Call utility routine to Generate
+		   // Rayleigh Scattering Lengths
+
+                   DefaultWater = true;
+
+		   ScatteringLengths =
+		   RayleighAttenuationLengthGenerator(aMaterialPropertiesTable);
+                }
+              }
+	    }
+
+	    thePhysicsTable->insertAt(i,ScatteringLengths);
+        } 
+}
+
+// GetMeanFreePath()
+// -----------------
+//
+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 AttenuationLength = DBL_MAX;
+
+        if (aMaterial->GetName() == "Water" && DefaultWater){
+
+           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; 
+           }
+        }
+
+        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;
+
+        // K Boltzman
+        G4double kboltz = 8.61739e-11*CLHEP::MeV/CLHEP::kelvin;
+
+        // 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;
+
+        // Retrieve vectors for refraction index
+        // and photon momentum from the material properties table
+
+        G4MaterialPropertyVector* Rindex = aMPT->GetProperty("RINDEX");
+
+        G4double refsq;
+        G4double e;
+        G4double xlambda;
+        G4double c1, c2, c3, c4;
+        G4double Dist;
+        G4double refraction_index;
+
+        G4PhysicsOrderedFreeVector *RayleighScatteringLengths = 
+				new G4PhysicsOrderedFreeVector();
+
+        if (Rindex ) {
+
+           for (size_t i = 0; i < Rindex->GetVectorLength(); i++) {
+
+                e = Rindex->Energy(i);
+
+                refraction_index = (*Rindex)[i];
+
+                refsq = refraction_index*refraction_index;
+                xlambda = CLHEP::h_Planck*CLHEP::c_light/e;
+
+	        if (verboseLevel>0) {
+        	        G4cout << Rindex->Energy(i) << " CLHEP::MeV\t";
+                	G4cout << xlambda << " mm\t";
+		}
+
+                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;
+
+                Dist = 1.0 / (c1*c2*c3*c4);
+
+	        if (verboseLevel>0) {
+	                G4cout << Dist << " mm" << G4endl;
+		}
+                RayleighScatteringLengths->
+			InsertValues(Rindex->Energy(i), Dist);
+           }
+
+        }
+        
+
+
+	return RayleighScatteringLengths;
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbAnalysisManager.cc b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbAnalysisManager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8cc098ea7ac465f37ca1470604c8d7c974f6f8f9
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbAnalysisManager.cc
@@ -0,0 +1,762 @@
+#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 "Geant4/G4Event.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/G4VHitsCollection.hh"
+#include "RichTbHit.hh"
+#include "RichTbCounter.hh"
+#include "RichTbMiscNames.hh"
+#include "RichTbGeometryParameters.hh"
+#include <TH1D.h>
+#include <TFile.h>
+#include <TTree.h>
+#include <CLHEP/Units/SystemOfUnits.h>
+#include <math.h>
+#include "RichTbMaterialParameters.hh"
+#include "CLHEP/Units/SystemOfUnits.h"
+
+
+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;
+
+}
+
+
+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);
+
+	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()
+{
+
+	//    delete hfactory;
+	//    hfactory = 0;
+
+	//  delete analysisFactory;
+	//   analysisFactory = 0;
+
+	// delete tree;
+	//if(fRootFile) delete fRootFile;
+
+	if(RichTbAnalysisInstance !=0 ) delete  RichTbAnalysisInstance;
+
+
+	G4cout << "RichTbAnalysisManager Deleted" << G4endl;
+
+}
+
+
+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::BeginOfEventAnalysis(const G4Event * /* evt */)
+{
+
+	//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::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::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);
+
+
+}
+
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbCounter.cc b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbCounter.cc
new file mode 100644
index 0000000000000000000000000000000000000000..54513ea9eb44647fc4158c924d7e1e26369bf3c8
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbCounter.cc
@@ -0,0 +1,85 @@
+// $Id: $
+// Include files
+
+
+
+// local
+#include "RichTbCounter.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbCounter
+//
+// 2004-01-12 : Sajan EASO
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbCounter* RichTbCounter::RichTbCounterInstance = 0;
+
+RichTbCounter::RichTbCounter(  ) {
+  resetRichTbCounter();
+
+}
+//=============================================================================
+// Destructor
+//=============================================================================
+RichTbCounter::~RichTbCounter() {}
+
+//=============================================================================
+RichTbCounter* RichTbCounter::getRichTbCounterInstance()
+{
+  if( RichTbCounterInstance == 0 ) {
+    RichTbCounterInstance = new RichTbCounter(  );
+
+  }
+  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;
+
+
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbEventAction.cc b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbEventAction.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bbdf70654711f3a563d4ad046d3f62591be24a24
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbEventAction.cc
@@ -0,0 +1,128 @@
+#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/G4UImanager.hh"
+#include "Geant4/G4ios.hh"
+//#include "RichTbSD.hh"
+#include "RichTbHit.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbAnalysisManager.hh"
+#include "RichTbIOData.hh"
+#include "RichTbMiscNames.hh"
+#include "RichTbCounter.hh"
+
+
+RichTbEventAction::RichTbEventAction( )
+{
+    RichTbCollID = -1;
+    RichTbCollIDHpd = -1;
+ 
+}
+
+
+RichTbEventAction::~RichTbEventAction()
+{
+
+}
+
+
+void RichTbEventAction::BeginOfEventAction(const G4Event * /*  evt */)
+{
+
+   // reset the counters.
+
+  RichTbCounter* aRichCounter =  
+           RichTbCounter::getRichTbCounterInstance();
+  aRichCounter-> resetRichTbCounter();
+
+ G4SDManager * SDman = G4SDManager::GetSDMpointer();
+  if(RichTbCollID<0){
+    G4String colNam;
+    RichTbCollID = SDman->GetCollectionID(colNam= RichTbHColname);
+
+
+}
+   RichTbRunConfig* RConfig =  RichTbRunConfig::getRunConfigInstance();
+   G4int aRadiatorConfiguration = RConfig ->getRadiatorConfiguration();
+
+   if(aRadiatorConfiguration == 2 ){
+     
+       if(RichTbCollIDHpd<0){
+         G4String colNamh;
+         RichTbCollIDHpd = SDman->GetCollectionID(colNamh= RichTbHColnameHpd);
+
+       }
+       
+   }
+   
+   
+
+  
+}
+
+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();
+  // aAnalysisManager->EndOfEventCountersHisto(evt);
+   aAnalysisManager->EndOfEventHisto(evt);
+  
+
+
+   // Now to write out the data
+
+   if(RConfig -> DoWriteOutputFile() ) {
+
+    RichTbIOData* rTbIOData= RichTbIOData::getRichTbIODataInstance();
+     
+   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/G4RichTbSimH/src/srcev/RichTbPEInfo.cc b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPEInfo.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b461d365eba4359752d7fd32726751414807b2c6
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPEInfo.cc
@@ -0,0 +1,27 @@
+// $Id: $
+// Include files 
+
+
+
+// local
+#include "RichTbPEInfo.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbPEInfo
+//
+// 2004-01-20 : Sajan EASO
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbPEInfo::RichTbPEInfo(  ): mPhOrigin(0), mMotherPhotonInfo(0),
+       mPeOriginInHpdSupFrame(0){
+
+}
+//=============================================================================
+// Destructor
+//=============================================================================
+RichTbPEInfo::~RichTbPEInfo() {}
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPeUserInfoAttach.cc b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPeUserInfoAttach.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f1c91ac6ca28c8974b47e1628366e94a7764b9aa
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPeUserInfoAttach.cc
@@ -0,0 +1,68 @@
+// $Id: $
+// 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);
+   
+  }
+
+   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;
+
+   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/G4RichTbSimH/src/srcev/RichTbPhotonInfo.cc b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPhotonInfo.cc
new file mode 100644
index 0000000000000000000000000000000000000000..90e78a8be6c1b11790f8b668dc11211efe64745a
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPhotonInfo.cc
@@ -0,0 +1,36 @@
+// $Id: $
+// Include files 
+
+
+
+// local
+#include "RichTbPhotonInfo.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbPhotonInfo
+//
+// 2004-01-20 : Sajan EASO
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// 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)  
+ {}
+//=============================================================================
+// Destructor
+//=============================================================================
+RichTbPhotonInfo::~RichTbPhotonInfo() {}
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPhotonProdHisto.cc b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPhotonProdHisto.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7a89f7f8540c385f55f3dc0bfe90dcb0140c256e
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPhotonProdHisto.cc
@@ -0,0 +1,69 @@
+#include "RichTbAnalysisManager.hh"
+#include "RichTbMaterialParameters.hh"
+#include "RichTbPhotonProdHisto.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbCounter.hh"
+
+
+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();
+  //  RichTbCounter* rCounter = RichTbCounter::getRichTbCounterInstance();
+
+  // G4double PhotWLength=0.0;
+  //  G4double PhotWLengthNano=0.0;
+  
+  if(  CkvPhEner != 0.0 ) {
+    
+    // PhotWLength=PhotMomToWaveLength/ CkvPhEner ;
+  // PhotWLengthNano =   PhotWLength/(CLHEP::nanometer);
+  }
+  // G4double CkvTh = acos( CkvCosTh);
+
+ // 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;
+
+ //  G4cout<<" RichTbPhotonProductionHisto Cur Vol "
+ //       <<  curVolName <<"  "<<  curVolFirstPart <<G4endl;
+  
+ G4ThreeVector avPos= aPhotTrack->GetVertexPosition() ;
+ // if( avPos.z() >= 0.0  && avPos.z() <= MirrrorNominalPivotZLocationInGlobal ) {
+ // rCounter->bumpnumHitTotProd();
+   
+ // }
+ 
+
+ //  if( rAnalysisPhy->getfhistoWProduced() ) {
+ //    rAnalysisPhy->getfhistoWProduced()->fill( PhotWLengthNano);
+ //  }
+
+
+ //  if( rAnalysisPhy-> getfhistoCkvProdTheta()) {
+    
+ //   rAnalysisPhy-> getfhistoCkvProdTheta()->fill( CkvTh );
+ //  }
+
+      
+ //  if(rAnalysisPhy-> getfhistoCkvProdPhi () ){//
+ //	rAnalysisPhy-> getfhistoCkvProdPhi ()->fill(CkvPhi);
+ // }
+
+ 
+
+  //  G4cout<<"end RichTbPhotonProductionHisto "<<G4endl;
+     
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPhotonUserInfoAttach.cc b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPhotonUserInfoAttach.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bf072112502a41de7f47fb466763ec854437a6fa
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPhotonUserInfoAttach.cc
@@ -0,0 +1,131 @@
+
+#include "RichTbPhotonInfo.hh"
+#include "Geant4/globals.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 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();
+  
+  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) {
+
+     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;
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPmtSteppingAction.cc b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPmtSteppingAction.cc
new file mode 100644
index 0000000000000000000000000000000000000000..081886d29a9123835b3b654e0d21e1478c50e858
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbPmtSteppingAction.cc
@@ -0,0 +1,319 @@
+#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/G4OpticalPhoton.hh"
+#include "Geant4/G4PionMinus.hh"
+#include "RichTbCounter.hh"
+#include "RichTbPhotonUserInfoAttach.hh"
+#include "RichTbBeamProperty.hh"
+#include "RichTbPhotoElectron.hh"
+#include "Geant4/G4Navigator.hh"
+#include "Geant4/G4TransportationManager.hh"
+#include "RichTbUserTrackInfo.hh"
+#include "Geant4/G4ThreeVector.hh"
+
+
+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;
+	      }
+	    }
+    }
+
+    */
+
+
+  // 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();
+
+      //  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( 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 ) {
+
+
+
+		      //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);
+		      }
+		    }
+
+		   // 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/G4RichTbSimH/src/srcev/RichTbStackingAction.cc b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbStackingAction.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f48826c5048f8dba1495962dea30790991b78ba9
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbStackingAction.cc
@@ -0,0 +1,12 @@
+#include "RichTbStackingAction.hh"
+
+RichTbStackingAction::RichTbStackingAction()
+{
+    ;
+}
+
+
+RichTbStackingAction::~RichTbStackingAction()
+{
+    ;
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbSteppingAction.cc b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbSteppingAction.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1f6a451c092c2d30014ce8ec3d50fe454b594fb6
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbSteppingAction.cc
@@ -0,0 +1,485 @@
+#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/G4OpticalPhoton.hh"
+#include "Geant4/G4PionMinus.hh"
+#include "RichTbCounter.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();
+}
+
+
+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.
+
+	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 ))
+			{
+
+				// G4double curPhotWavLenNano=PhotMomToWaveLength/(aTrackEnergy*CLHEP::nanometer);
+
+				// 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;
+
+
+					//   G4cout <<"RichTbstep pre post vol "<<tpreVol
+					// <<"  "<<tpostVol<<G4endl;
+
+
+
+
+					// now for photons entering the mirror
+					if(tpreVol == VesselPhysName &&
+							tpostVol ==  MirrorPhysName )
+					{
+						//  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);
+
+					}
+					// now for photons entering the ph det sup frame.
+					if(tpreVol == VesselPhysName &&
+							tpostVol ==  GasQuWinPhysName  )
+					{
+
+						// 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->bumpnumExitGasQuWin();
+
+						//  if( aRAnalysisManager->getfhistoWExitGasQuWin())
+						//	aRAnalysisManager->getfhistoWExitGasQuWin()
+						//  ->fill( curPhotWavLenNano);
+
+
+					}
+
+					// 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;
+}
+
+
+
+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::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/G4RichTbSimH/src/srcev/RichTbSteppingActionBase.cc b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbSteppingActionBase.cc
new file mode 100644
index 0000000000000000000000000000000000000000..63198f21ab4ea9a055e478dceb38821d5cb63ad7
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbSteppingActionBase.cc
@@ -0,0 +1,54 @@
+// Include files 
+
+
+
+// local
+
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbSteppingActionBase
+//
+// 2015-03-06 : Sajan Easo
+//-----------------------------------------------------------------------------
+#include "Geant4/globals.hh"
+#include "RichTbSteppingActionBase.hh"
+#include "Geant4/G4SteppingManager.hh"
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbSteppingActionBase::RichTbSteppingActionBase(  ) {
+
+  InitRichTbStepActions();
+  
+ 
+
+}
+//=============================================================================
+// Destructor
+//=============================================================================
+RichTbSteppingActionBase::~RichTbSteppingActionBase() {
+
+  if(mRichTbSteppingAction) delete mRichTbSteppingAction;
+  if(mRichTbPmtSteppingAction) delete mRichTbPmtSteppingAction;
+
+} 
+
+//=============================================================================
+void RichTbSteppingActionBase::UserSteppingAction(const G4Step * aStep){
+
+  mRichTbSteppingAction->UserSteppingAction(aStep);
+  mRichTbPmtSteppingAction->UserSteppingAction(aStep);
+
+
+
+}
+
+void  RichTbSteppingActionBase::InitRichTbStepActions(){
+
+  mRichTbSteppingAction=new RichTbSteppingAction();
+  mRichTbPmtSteppingAction = new RichTbPmtSteppingAction();
+  
+  
+
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbTrackingAction.cc b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbTrackingAction.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9b3d57d7cb3314907bcd1b807d8708f8e5f49fad
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbTrackingAction.cc
@@ -0,0 +1,90 @@
+#include "RichTbTrackingAction.hh"
+#include "Geant4/G4DynamicParticle.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 "RichTbRunConfig.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;
+     
+     G4VUserTrackInformation* aTkInfo = aTrack->GetUserInformation();
+     
+     if( aTkInfo) {
+       RichTbUserTrackInfo*  curPhotTrackUserInfo =
+                 (RichTbUserTrackInfo*)  aTkInfo;
+
+       if(curPhotTrackUserInfo && curPhotTrackUserInfo->HasUserPhotonInfo() ){
+           RichTbPhotonInfo* aRichTbPhotonInfo = 
+              curPhotTrackUserInfo->getRichTbPhotonInfo();
+           if( aRichTbPhotonInfo ) {
+
+             // cPhotTrueCkv=aRichTbPhotonInfo->CkvCosThetaAtProd();
+             
+             //  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) {
+
+       RichTbUserTrackInfo*  curPeTrackUserInfo =
+                 (RichTbUserTrackInfo*)  aTkInfoP;
+    
+       if( curPeTrackUserInfo && curPeTrackUserInfo-> HasUserPEInfo()) {
+           RichTbPEInfo* aRichTbPEInfo =
+             curPeTrackUserInfo->getRichTbPEInfo();
+           if(aRichTbPEInfo ) {
+             //  delete   aRichTbPEInfo;
+             
+           }
+           
+
+       }
+       
+       
+     }
+     
+   }   
+      
+    
+  }
+  
+  
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbUserTrackInfo.cc b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbUserTrackInfo.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5c21508f4127b70e36131f4a4e379f9b0731821c
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcev/RichTbUserTrackInfo.cc
@@ -0,0 +1,41 @@
+// $Id: $
+// Include files 
+
+
+
+// local
+#include "RichTbUserTrackInfo.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbUserTrackInfo
+//
+// 2004-01-20 : Sajan EASO
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbUserTrackInfo::RichTbUserTrackInfo(  ):  mRichTbPhotonInfo(0),
+ mRichTbPEInfo(0),mHasUserPhotonInfo(false),mHasUserPEInfo(false) {
+
+}
+RichTbUserTrackInfo::RichTbUserTrackInfo(RichTbPhotonInfo* aRichTbPhotonInfo): 
+ mRichTbPEInfo(0),mHasUserPEInfo(false){ 
+  mRichTbPhotonInfo= aRichTbPhotonInfo;
+  mHasUserPhotonInfo=true;
+  
+}
+RichTbUserTrackInfo::RichTbUserTrackInfo(RichTbPEInfo* aRichTbPEInfo): 
+mRichTbPhotonInfo(0), mHasUserPhotonInfo(false){
+  mRichTbPEInfo=aRichTbPEInfo;
+  mHasUserPEInfo=true;
+  
+}
+
+
+//=============================================================================
+// Destructor
+//=============================================================================
+RichTbUserTrackInfo::~RichTbUserTrackInfo() {}
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgr/RichTbGraphics.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgr/RichTbGraphics.cc
new file mode 100644
index 0000000000000000000000000000000000000000..836154663850fc8c30926fd90a9a00212e02b5af
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgr/RichTbGraphics.cc
@@ -0,0 +1,1955 @@
+#include <iostream>
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbGraphics.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4VisAttributes.hh"
+#include "Geant4/G4Colour.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbPMT.hh"
+RichTbGraphics::RichTbGraphics()
+{
+	;
+}
+
+
+RichTbGraphics::RichTbGraphics(RichTbDetectorConstruction* aDetector )
+
+{
+
+
+
+	curDetector = aDetector;
+
+	setAllGraphicsAttributes();
+
+}
+
+RichTbGraphics::~RichTbGraphics()
+{
+	;
+}
+
+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();
+
+		if( RichTbHall_LV != 0 ) {
+
+			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);
+
+				}
+
+			}
+
+		}
+
+		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 {
+
+					G4VisAttributes *  RichTbUpgradeMirror_LogVisAtt =
+							new G4VisAttributes(G4Colour(0.1,0.8,0.8));
+
+					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);
+					}
+
+					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 * 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 RichTbPMTFrontRing_vis = aRunConfig->getRichTbPMTFrontRing_visib();
+	G4cout<<"PMT front ring visib flag  "<<RichTbPMTFrontRing_vis<<G4endl;
+
+	if(  (curDetector != 0)  && (curDetector-> getRichTbPMT() != 0)){
+
+		G4cout<<"now setting front ring visib options  "<<RichTbPMTFrontRing_vis<<G4endl;
+
+		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);
+
+
+			}
+
+		}
+
+	}
+
+
+	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  RichTbHpdPHC_vis =  aRunConfig->getRichTbHpdPHC_visib();
+		if( (curDetector != 0) &&  (curDetector-> getRichTbHpd() != 0  ) ) {
+
+			G4cout<<"now setting HPD PHC visib options  "<< RichTbHpdPHC_vis <<G4endl;
+
+			G4LogicalVolume * RichTbHpdPHC_LV =curDetector->getRichTbHpd()->  getRichTbHpdPhCathodeLVol();
+			if( RichTbHpdPHC_LV != 0 ) {
+
+				if( RichTbHpdPHC_vis == 0 ){
+					RichTbHpdPHC_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);
+
+
+				}
+
+			}
+
+		}
+
+		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  RichTbHpdENV_vis =  aRunConfig->getRichTbHpdENV_visib();
+		if( (curDetector != 0) &&  (curDetector-> getRichTbHpd() != 0  ) ) {
+
+			G4cout<<"now setting HPD Envelope tube  visib options  "<< RichTbHpdENV_vis <<G4endl;
+
+			G4LogicalVolume * RichTbHpdENV_LV =curDetector->getRichTbHpd()->  getRichTbHpdEnvelopeTubeLVol  ();
+
+			if( RichTbHpdENV_LV != 0 ) {
+
+				if( RichTbHpdENV_vis == 0 ){
+					RichTbHpdENV_LV -> SetVisAttributes(G4VisAttributes::Invisible);
+				} else {
+
+					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 {
+
+					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);
+
+
+				}
+
+			}
+
+		}
+
+
+		G4int  RichTbHpdSM_vis =  aRunConfig->getRichTbHpdSM_visib();
+		if( (curDetector != 0) &&  (curDetector-> getRichTbHpd() != 0  ) ) {
+
+			G4cout<<"now setting HPD Smaster visib options  "<< RichTbHpdSM_vis <<G4endl;
+
+			G4LogicalVolume * RichTbHpdSM_LV =curDetector->getRichTbHpd()-> getRichTbHpdSMasterLVol ();
+
+			if( RichTbHpdSM_LV != 0 ) {
+
+				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 ();
+
+			if( RichTbHpdMas_LV != 0 ) {
+
+				if( RichTbHpdMas_vis == 0 ){
+					RichTbHpdMas_LV -> SetVisAttributes(G4VisAttributes::Invisible);
+				} else {
+
+					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);
+
+
+				}
+
+			}
+
+		}
+
+
+
+		G4int  RichTbHpdPix_vis =  aRunConfig->getRichTbHpdSiPix_visib();
+		if( RichTbHpdPix_vis > 5 ) {
+
+			if( (curDetector != 0) &&  (curDetector-> getRichTbHpd() != 0  ) ) {
+
+				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 !
+
+	// 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 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 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 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 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 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 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 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 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 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 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 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 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;
+
+      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 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 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 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 * 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);
+
+           }
+         }
+       }
+     }
+   }
+
+	 */
+
+
+
+
+
+}
+
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgr/RichTbVisManager.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgr/RichTbVisManager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d2cbe0b847ed56d17085edb50ad7af72f06387e9
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgr/RichTbVisManager.cc
@@ -0,0 +1,176 @@
+// This code implementation is the intellectual property of
+// the GEANT4 collaboration.
+//
+// By copying, distributing or modifying the Program (or any work
+// based on the Program) you indicate your acceptance of this statement,
+// and all its terms.
+//
+// $Id: RichTbVisManager.cc,v 1.3 2003/10/10 16:59:29 abuckley Exp $
+// GEANT4 tag $Name:  $
+//
+//
+// John Allison 24th January 1998.
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+#include "RichTbVisManager.hh"
+
+// Supported drivers...
+
+//#ifdef G4VIS_USE_DAWN
+//#include "Geant4/G4FukuiRenderer.hh"
+//#endif
+
+//#ifdef G4VIS_USE_DAWNFILE
+//#include "Geant4/G4DAWNFILE.hh"
+//#endif
+
+//#ifdef G4VIS_USE_OPACS
+//#include "Geant4/G4Wo.hh"
+//#include "Geant4/G4Xo.hh"
+//#endif
+
+//#ifdef G4VIS_USE_OPENGLX
+#include "Geant4/G4OpenGLImmediateX.hh"
+#include "Geant4/G4OpenGLStoredX.hh"
+//#endif
+
+//#ifdef G4VIS_USE_OPENGLWIN32
+//#include "Geant4/G4OpenGLImmediateWin32.hh"
+//#include "Geant4/G4OpenGLStoredWin32.hh"
+//#endif
+
+//#ifdef G4VIS_USE_OPENGLXM
+#include "Geant4/G4OpenGLImmediateXm.hh"
+#include "Geant4/G4OpenGLStoredXm.hh"
+//#endif
+
+ //#ifdef G4VIS_USE_OIX
+// #include "Geant4/G4OpenInventorX.hh"
+ //#endif
+
+//#ifdef G4VIS_USE_OIWIN32
+//#include "Geant4/G4OpenInventorWin32.hh"
+//#endif
+
+//ifdef G4VIS_USE_VRML
+//#include "Geant4/G4VRML1.hh"
+//#include "Geant4/G4VRML2.hh"
+//endif
+
+//ifdef G4VIS_USE_VRMLFILE
+//#include "Geant4/G4VRML1File.hh"
+//#include "Geant4/G4VRML2File.hh"
+//endif
+
+//ifdef G4VIS_USE_RAYTRACER
+//#include "Geant4/G4RayTracer.hh"
+//endif
+//#ifdef G4VIS_USE
+//#include "Geant4/G4VisExecutive.hh"
+//#endif
+
+
+
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+RichTbVisManager* RichTbVisManager::RichTbVisManagerInstance=0;
+
+RichTbVisManager::RichTbVisManager()
+{
+
+  //RegisterGraphicsSystems();
+  
+  // visualization manager
+  // G4VisManager* visManagerE = new G4VisExecutive;
+  //  visManagerE->Initialize();
+
+    
+}
+
+
+RichTbVisManager::~RichTbVisManager()
+{
+    ;
+}
+RichTbVisManager* RichTbVisManager::getRichTbVisManagerInstance()
+{
+  if(RichTbVisManagerInstance == 0 ) {
+    RichTbVisManagerInstance = new RichTbVisManager();
+    
+  }
+  return RichTbVisManagerInstance;
+  
+  
+}
+
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
+
+void RichTbVisManager::RegisterGraphicsSystems()
+{
+
+  //#ifdef G4VIS_USE_DAWN
+  //  RegisterGraphicsSystem(new G4FukuiRenderer);
+    //#endif
+
+    //#ifdef G4VIS_USE_DAWNFILE
+  //  RegisterGraphicsSystem(new G4DAWNFILE);
+    //#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_OPENGLWIN32
+  //  RegisterGraphicsSystem(new G4OpenGLImmediateWin32);
+  //  RegisterGraphicsSystem(new G4OpenGLStoredWin32);
+  //#endif
+
+    //#ifdef G4VIS_USE_OPENGLXM
+    RegisterGraphicsSystem(new G4OpenGLImmediateXm);
+    RegisterGraphicsSystem(new G4OpenGLStoredXm);
+    //#endif
+
+  //#ifdef G4VIS_USE_OIX
+    //  RegisterGraphicsSystem (new G4OpenInventorX);
+  //#endif
+
+  //#ifdef G4VIS_USE_OIWIN32
+  //  RegisterGraphicsSystem(new G4OpenInventorWin32);
+  //#endif
+
+    //#ifdef G4VIS_USE_VRML
+  // RegisterGraphicsSystem(new G4VRML1);
+  //  RegisterGraphicsSystem(new G4VRML2);
+    //#endif
+
+    //#ifdef G4VIS_USE_VRMLFILE
+  // RegisterGraphicsSystem(new G4VRML1File);
+  //  RegisterGraphicsSystem(new G4VRML2File);
+    //#endif
+
+    //#ifdef G4VIS_USE_RAYTRACER
+  // RegisterGraphicsSystem(new G4RayTracer);
+    //#endif
+
+    //#ifdef G4VIS_USE
+    //#endif
+
+
+
+  //    if (fVerbose > 0) {
+  //      G4cout << "\nYou have successfully chosen to use the following graphics systems." << G4endl;
+  //      PrintAvailableGraphicsSystems();
+  //  }
+}
+
+//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbGeometryParameters.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbGeometryParameters.cc
new file mode 100644
index 0000000000000000000000000000000000000000..839f14f70c85d1bc3d1f69a120307c1adcc963e5
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbGeometryParameters.cc
@@ -0,0 +1,6 @@
+#include "Geant4/globals.hh"
+#include "RichTbGeometryParameters.hh"
+
+void InitializeRichTbGeometry()
+{
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbHall.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbHall.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6608141111924ae5fd066267dc99760a7bb1d531
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbHall.cc
@@ -0,0 +1,36 @@
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4ThreeVector.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4PVPlacement.hh"
+
+#include <iostream>
+
+#include "RichTbUpgradeDetectorConstruction.hh"
+#include "RichTbHall.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbGeometryParameters.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);
+
+  RichTbHallLVol  = RichTbHallLog;
+  RichTbHallPVol  = RichTbHallPhys;
+
+}
+
+
+RichTbHall::~RichTbHall()
+{
+    ;
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbHpd.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbHpd.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c4a514a6448367d15c2675aace64fc34b9a906f0
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbHpd.cc
@@ -0,0 +1,441 @@
+// $Id: $
+// Include files 
+
+
+#include "Geant4/globals.hh"
+#include "Geant4/G4Tubs.hh"
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4Sphere.hh"
+#include "Geant4/G4Polyhedra.hh"
+
+// local
+#include "RichTbMaterial.hh"
+#include "RichTbHpd.hh"
+#include "RichTbUpgradePhDetSupFrame.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMaterialParameters.hh"
+#include "Geant4/G4RotationMatrix.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 "RichTbHpdRODummySD.hh"
+#include "RichTbMiscNames.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbHpd
+//
+// 2003-11-19 : Sajan EASO
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbHpd::RichTbHpd(G4int aHpdNum , RichTbUpgradePhDetSupFrame* aSupFrame  )
+{  MotherOfHpd = aSupFrame;
+  CurHpdNum = aHpdNum;
+  m_TrackingSwitch=true;
+  
+}
+
+RichTbHpd::~RichTbHpd(  ) {
+}
+
+void RichTbHpd::buildHpdGeometry() {
+
+
+  constructHpdMasterTree();
+  RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
+  G4int agraphics=   aConfig ->getRichTbHpdSiPix_visib() ;
+  
+  
+  if(m_TrackingSwitch) { 
+    constructHpdComponentsLVol();
+    constructHpdComponentsPVol();
+    if( agraphics > 5 ) {
+      // special config to just visualize the pixel geometry. Not for simulating data.
+      constructHpdSiPixel();
+
+    }
+    
+
+
+  }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::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(){
+
+  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 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);
+   
+   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()
+{
+
+  RichTbSiPixelPVol.clear();
+  RichTbSiPixelPVol.reserve(NumPixelTotInSingleHpd);
+  
+ 
+  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;
+      
+}
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbMaterial.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbMaterial.cc
new file mode 100644
index 0000000000000000000000000000000000000000..cf90e7a9a6ebf32c277d253a89c16d0908074c87
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbMaterial.cc
@@ -0,0 +1,865 @@
+
+// CLHEP
+#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/G4LogicalBorderSurface.hh"
+#include "Geant4/G4LogicalSkinSurface.hh"
+#include "Geant4/G4OpBoundaryProcess.hh"
+
+// STL etc
+#include <iostream>
+#include <vector>
+// local
+#include "RichTbMaterial.hh"
+#include "RichTbMaterialParameters.hh"
+#include "RichTbRunConfig.hh"
+//#include "RichTbGasQuWinProperty.hh"
+#include "RichTbAnalysisManager.hh"
+
+
+RichTbMaterial* RichTbMaterial::RichTbMaterialInstance =0;
+
+RichTbMaterial::RichTbMaterial( ){
+
+  InitializeRichTbMaterial();
+  
+  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();
+
+    TAirMPT->AddProperty("ABSLENGTH", PhotonMomentum, 
+                  TAirAbsorpLength, NumPhotWaveLengthBins);
+
+    TAirMPT->AddProperty("RINDEX", PhotonMomentum, TAirRindex, 
+                        NumPhotWaveLengthBins);
+
+    TAir->SetMaterialPropertiesTable(TAirMPT);
+    RichTbTubeAir = TAir;
+
+    //
+    //
+
+    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);
+
+    //    TAirAMPT->AddProperty("RINDEX", PhotonMomentum,
+    //               TAirARindex,NumPhotWaveLengthBins);
+
+    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();
+  
+
+  G4Material* NitrogenGas = new G4Material(name=NitrogenGasMaterialName, 
+                                 density, numel=1,
+                                 kStateGas,temperature,pressure);
+  NitrogenGas->AddElement(elN, natoms=2);
+
+  G4double* NitrogenGasAbsorpLength=new G4double[NumPhotWaveLengthBins];
+  G4double* NitrogenGasRindex=new G4double[NumPhotWaveLengthBins];
+  G4double* NitrogenGasPhotMom=new G4double[NumPhotWaveLengthBins];
+
+  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 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);
+
+    NitrogenGasMPT->AddProperty("RINDEX", NitrogenGasPhotMom, 
+                      NitrogenGasRindex,NumPhotWaveLengthBins);
+
+    NitrogenGasMPT->AddProperty("CKVRNDX", NitrogenGasPhotMomCkvProd , 
+                      NitrogenGasCkvProdRindex,CkvProdNumPhotWaveLengthBins);
+
+    NitrogenGas->SetMaterialPropertiesTable(NitrogenGasMPT);
+    RichTbNitrogenGas = NitrogenGas;
+
+    // test printout
+
+    // G4MaterialPropertyVector* theRefractionIndexVector = 
+    //		    	  NitrogenGasMPT ->GetProperty("CKVRNDX");
+
+    //  G4int itb=0;
+    //  theRefractionIndexVector->ResetIterator();
+    //  while(++(*theRefractionIndexVector))
+
+    //  {
+    // itb++;
+                               
+    //  G4double currentPM = theRefractionIndexVector->GetPhotonMomentum();
+    //  G4double currentRI=theRefractionIndexVector->GetProperty();
+
+
+    // G4cout<<" Richtbmaterial N2refindVect  "<< itb<<"  "<< currentPM<<"  "<<currentRI
+    //      <<G4endl;
+
+    //  }  
+
+  // end testprintout
+  //c4f10 gas.
+
+  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);
+
+  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];
+  
+
+  std::vector<G4double>c4f10RefInd= Initc4f10RefIndex(pressure,temperature);
+  std::vector<G4double>c4f10RefPhotMom=Initc4f10RefPhotMom();
+
+
+  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;
+  }
+  G4MaterialPropertiesTable* MirrorQuartzMPT = 
+                            new G4MaterialPropertiesTable();
+
+
+  MirrorQuartzMPT->AddProperty("ABSLENGTH",PhotonMomentum,
+                MirrorQuartzAbsorpLength,NumPhotWaveLengthBins);
+
+
+  //  MirrorQuartzMPT->AddProperty("RINDEX", PhotonMomentum, 
+  //                   MirrorQuartzRindex,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];
+ //  }
+
+  // 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;
+
+ // 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);
+ 
+
+  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;
+
+  // 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;
+  
+  // 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);
+  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;
+  }
+  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);
+
+  PMTWindowQuartzMPT->AddProperty("RINDEX",PMTWindowQuartzPhMom , 
+                        PMTWindowQuartzRindex,PMTQuartzRefIndNumBins);
+
+  PMTWindowQuartz->SetMaterialPropertiesTable(PMTWindowQuartzMPT);
+
+  PMTQuartzWindowMaterial=PMTWindowQuartz;
+
+  
+ //"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];
+
+ 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];
+    
+  }
+  
+  
+  G4MaterialPropertiesTable* HPDWindowQuartzMPT = 
+                            new G4MaterialPropertiesTable();
+
+  HPDWindowQuartzMPT->AddProperty("ABSLENGTH",PhotonMomentum,
+                HPDWindowQuartzAbsorpLength,NumPhotWaveLengthBins);
+
+  HPDWindowQuartzMPT->AddProperty("RINDEX",HPDWindowQuartzPhMom , 
+                        HPDWindowQuartzRindex,HPDQuartzRefIndNumBins);
+
+  HPDWindowQuartz->SetMaterialPropertiesTable(HPDWindowQuartzMPT);
+
+  HPDQuartzWindowMaterial=HPDWindowQuartz;
+
+
+
+// crystal material
+
+  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);
+ 
+  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];
+  //  test study for reconstruction
+  //  G4bool m_activateRefIndexStudy = false;
+
+   G4bool m_activateRefIndexStudy = true;
+  
+  //  G4double  CrysMatRefractiveIndexShift = m_activateRefIndexStudy ? 0.1 : 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;
+    //  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 << "Ckv crystal RI " << ibinp<< " " << CrystalMatCkvProdRindex[ibinp] << G4endl;
+    CrystalMatPhotMomCkvProd[ibinp]=  CrystalMatPhMom[ibina];
+    // G4cout << "Ckv momentum " << ibinp<< " " << CrystalMatPhotMomCkvProd[ibinp] << G4endl;
+  }
+  
+
+  
+  G4MaterialPropertiesTable* CrystalMPT = 
+                            new G4MaterialPropertiesTable();
+
+  CrystalMPT->AddProperty("ABSLENGTH",CrystalMatPhMom,
+			  CrystalMatAbsorpLength,CrystalMatRefIndNumBins);
+
+  CrystalMPT->AddProperty("RINDEX",CrystalMatPhMom , 
+                        CrystalMatRindex,CrystalMatRefIndNumBins);
+
+  CrystalMPT->AddProperty("CKVRNDX", CrystalMatPhotMomCkvProd , 
+                      CrystalMatCkvProdRindex,CrystalMatRefIndNumBins);
+
+  CrystalMat->SetMaterialPropertiesTable(CrystalMPT);
+
+  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;
+  //"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];
+  }
+  // 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;
+   }
+   
+
+  }
+
+
+ G4MaterialPropertiesTable* S20PhCathodeMPT = 
+                            new G4MaterialPropertiesTable();
+  S20PhCathodeMPT->AddProperty("ABSLENGTH",PhotonMomentum,
+                S20PhCathodeAbsorpLength,NumPhotWaveLengthBins);
+
+  //  S20PhCathodeMPT->AddProperty("RINDEX", PhotonMomentum, 
+  //                      S20PhCathodeRindex,NumPhotWaveLengthBins);
+  S20PhCathodeMPT->AddProperty("RINDEX",S20PhCathodeRefIndPhMom , 
+                        S20PhCathodeRindex,S20PhCathodeRefIndNumBins);
+
+
+
+  S20PhCathode->SetMaterialPropertiesTable(S20PhCathodeMPT);
+  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];
+
+  G4int  HPDS20PhCathodeRefIndNumBins=HPDQuartzRefIndNumBins;
+
+  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);
+
+  for(G4int ibins=0; ibins <HPDS20PhCathodeRefIndNumBins; ibins++ ) {
+  //    HPDS20PhCathodeRindex[ibin]=1.6;
+
+    HPDS20PhCathodeRefIndPhMom[ibins] =  HPDWindowQuartzPhMom[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;  
+     
+   } 
+
+ }
+ 
+
+ 
+
+  G4MaterialPropertiesTable* HPDS20PhCathodeMPT = 
+                            new G4MaterialPropertiesTable();
+  HPDS20PhCathodeMPT->AddProperty("ABSLENGTH",PhotonMomentum,
+                                  HPDS20PhCathodeAbsorpLength,NumPhotWaveLengthBins);
+
+  //  S20PhCathodeMPT->AddProperty("RINDEX", PhotonMomentum, 
+  //                      S20PhCathodeRindex,NumPhotWaveLengthBins);
+
+  HPDS20PhCathodeMPT->AddProperty("RINDEX",HPDS20PhCathodeRefIndPhMom , 
+                                  HPDS20PhCathodeRindex,HPDS20PhCathodeRefIndNumBins);
+
+  HPDS20PhCathode->SetMaterialPropertiesTable(HPDS20PhCathodeMPT);
+  HPDPhCathodeMaterial=HPDS20PhCathode;
+
+
+
+}
+
+
+
+
+
+RichTbMaterial* RichTbMaterial::getRichTbMaterialInstance() 
+{
+  if( RichTbMaterialInstance== 0 ) {
+    RichTbMaterialInstance= new RichTbMaterial();
+    
+  }
+
+  return RichTbMaterialInstance;
+  
+}
+
+
+RichTbMaterial::~RichTbMaterial()
+{
+    ;
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbMaterialParameters.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbMaterialParameters.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8c9e5482187c1d813e9c84c5f460e77788249b94
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbMaterialParameters.cc
@@ -0,0 +1,344 @@
+// Geant 4
+#include "Geant4/globals.hh"
+
+// STL etc
+#include <iostream>
+#include <vector>
+#include <cmath>
+
+// local
+#include "RichTbMaterialParameters.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbAnalysisManager.hh"
+
+
+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();
+
+
+}
+
+
+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 FresnelLossAtNormalIncidence(G4double RIndex1, G4double RIndex2 )
+{
+	G4double ALoss=0.0;
+
+	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){
+
+	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;
+
+
+	G4double GasRhoN2Cur=GasRhoN2atSTP*(GasTemperature_STP/temperature)*
+			(pressure/ GasPressure_STP);
+
+	//  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;
+
+	}
+
+	return RefN2;
+}
+
+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;
+
+
+	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;
+
+}
+
+
+std::vector<G4double> InitN2RefPhotMom() {
+	return InitializePhotonMomentumVector() ;
+}
+std::vector<G4double> Initc4f10RefPhotMom() {
+	return InitializePhotonMomentumVector() ;
+}
+
+std::vector<G4double> CrystalRefPhotMom() {
+	return InitializePhotonMomentumVector() ;
+}
+
+std::vector<G4double> Initc4f10RefIndex(G4double pressure, G4double temperature){
+
+	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;
+
+
+	G4double GasRhoC4F10Cur=GasRhoC4F10atSTP*(GasTemperature_STP/temperature)*
+			(pressure/ GasPressure_STP);
+
+	G4double epho=0.0;
+	G4double pfe=0.0;
+	G4double cpfe=0.0;
+
+	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;
+}
+
+G4double c4f10RefIndexAtAnEnergy(G4double pressure, G4double temperature ,
+		G4double PhotonEnergy){
+
+	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 epho=0.0;
+	G4double pfe=0.0;
+	G4double cpfe=0.0;
+
+	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);
+
+	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;
+		}
+
+
+	}else if ( ipmtqe == 6 ){
+
+		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
+            qeCurPerCent[iqb] =  Pmt6QEPerCent[iqb]* PmtQEReductionFactor;
+		}
+
+
+	}else if ( ipmtqe == 7 ){
+
+		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
+            qeCurPerCent[iqb] =  Pmt7QEPerCent[iqb]* PmtQEReductionFactor;
+		}
+
+	}else if( ipmtqe == 8 ){
+		for(G4int  iqb=0; iqb< PmtQENumBins ; iqb++){
+            qeCurPerCent[iqb] =  Pmt8QEPerCent[iqb]* PmtQEReductionFactor;
+		}
+
+	}else if( ipmtqe == 9 ){
+
+		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
+            qeCurPerCent[iqb] =  Pmt9QEPerCent[iqb]* PmtQEReductionFactor;
+		}
+
+	} else if ( ipmtqe == 10 ){
+
+		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
+            qeCurPerCent[iqb] =  Pmt1QEPerCent[iqb]* PmtQEReductionFactor;
+		}
+
+
+	} else if ( ipmtqe == 11 ){
+
+		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
+            qeCurPerCent[iqb] =  Pmt11QEPerCent[iqb]* PmtQEReductionFactor;
+		}
+
+	}else if ( ipmtqe == 12 ){
+
+		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
+            qeCurPerCent[iqb] =  Pmt12QEPerCent[iqb]* PmtQEReductionFactor;
+		}
+
+
+	}else if ( ipmtqe == 13 ){
+
+		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
+            qeCurPerCent[iqb] =  Pmt13QEPerCent[iqb]* PmtQEReductionFactor;
+		}
+
+
+	}else if ( ipmtqe == 14 ){
+
+		for(G4int iqb=0; iqb< PmtQENumBins ; iqb++){
+            qeCurPerCent[iqb] =  Pmt14QEPerCent[iqb]* PmtQEReductionFactor;
+		}
+
+	}else if ( ipmtqe == 15 ){
+
+		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>  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/G4RichTbSimH/src/srcgy/RichTbPMT.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbPMT.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3bd4f33bec24258ac297d2e6566666d46a80bf9f
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbPMT.cc
@@ -0,0 +1,489 @@
+// $Id: $
+// Include files
+
+
+#include "Geant4/globals.hh"
+#include "Geant4/G4Tubs.hh"
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4Sphere.hh"
+// local
+#include "RichTbMaterial.hh"
+#include "RichTbPMT.hh"
+#include "RichTbUpgradeMaster.hh"
+#include "RichTbUpgradePhDFrame.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMaterialParameters.hh"
+#include "Geant4/G4RotationMatrix.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 "RichTbSD.hh"
+#include "RichTbRODummySD.hh"
+#include "RichTbMiscNames.hh"
+#include "RichTbRunConfig.hh"
+
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbPMT
+//
+// 2003-11-19 : Sajan EASO
+// 2015-06-12: Michele BLAGO modified for the 2015 testbeam.
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// 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(  ) {
+}
+
+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
+
+
+	G4Box* PMTEnvelopeBox
+	= new G4Box( "PMTEnvelopeBox",
+			0.5 * PMTEnvelopeBoxXSize,
+			0.5 * PMTEnvelopeBoxYSize,
+			0.5 * PMTEnvelopeBoxZSize );
+
+	// G4cout<<"test Envelope size "<<PMTEnvelopeBoxXSize <<G4endl;
+
+	G4Box* PMTEnvelopeSubBox
+	= new G4Box("PMTEnvelopeSubBox",
+			0.5*PMTEnvelopeSubPartXSize,
+			0.5*PMTEnvelopeSubPartYSize,
+			0.5*PMTEnvelopeSubPartZSize);
+
+	G4ThreeVector PMTEnvelopeSubPos( PMTEnvelopeSubPartXLocation,
+			PMTEnvelopeSubPartYLocation,
+			PMTEnvelopeSubPartZLocation );
+
+	G4RotationMatrix  PMTEnvelopeSubRotX, PMTEnvelopeSubRotY;
+
+	G4Transform3D PMTEnvelopeSubTransform(PMTEnvelopeSubRotX * PMTEnvelopeSubRotY,
+			PMTEnvelopeSubPos);
+
+	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 );
+
+
+	//front ring
+	G4Box* PMTFrontRingOuterBox =
+			new G4Box("PMTFrontRingOuterBox" ,
+					0.5*RichTbPMTFrontRingLateralXSize,
+					0.5*RichTbPMTFrontRingLateralYSize,
+					0.5*  RichTbPMTFrontRingZSize);
+
+	G4Box* PMTFrontRingInnerSubBox =
+			new G4Box("PMTFrontRingInnerSubBox" ,
+					0.5*RichTbPMTFrontRingSubHoleXSize,
+					0.5*RichTbPMTFrontRingSubHoleYSize,
+					0.5*RichTbPMTFrontRingSubHoleZSize);
+
+
+	G4ThreeVector PMTFrontRingSubPos( RichTbPMTFrontRingSubHoleXLocation ,
+			RichTbPMTFrontRingSubHoleYLocation,
+			RichTbPMTFrontRingSubHoleZLocation );
+
+	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;
+
+
+
+}
+
+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);
+
+	G4Transform3D  PMTQuartzWindowTransform( PMTQuartzWindowRot,
+			PMTQuartzWindowPos);
+
+	G4ThreeVector   PMTPhCathodePos(RichTbPMTPhCathodeXLocation,
+			RichTbPMTPhCathodeYLocation,
+			RichTbPMTPhCathodeZLocation);
+
+	G4Transform3D PMTPhCathodeTransform( PMTPhCathodeRot, PMTPhCathodePos);
+
+
+
+	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);
+
+	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::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);
+
+	G4LogicalVolume* PMTAnodePxLog =
+			new G4LogicalVolume( PMTSiPxBox,
+					aMaterial->getPMTAnodeMaterial(),
+					"PMTAnodePxLog",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){
+		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;
+
+
+	for(G4int iPixelRowY = 0; iPixelRowY < NumPixelInPmtCol ; iPixelRowY++){
+		for (G4int iPixelColX = 0; iPixelColX < NumPixelInPmtRow ; iPixelColX++){
+
+			G4int PixelCopyNumber = iPixelColX + iPixelRowY*NumPixelInPmtRow;
+
+			G4double curPixelPosX =   aPixelColStartX +  iPixelColX*PmtAnodePixelXSize ;
+
+			G4double curPixelPosY =   aPixelColStartY +  iPixelRowY*PmtAnodePixelYSize;
+
+			G4ThreeVector PMTAnodePxPos(curPixelPosX, curPixelPosY, RichTbPMTAnodePixelPosZ);
+			G4Transform3D PMTAnodeTransform(PMTAnodeRot, PMTAnodePxPos);
+
+			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;
+
+}
+
+
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbPhDetSupFrame.SAVE b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbPhDetSupFrame.SAVE
new file mode 100644
index 0000000000000000000000000000000000000000..5e2e0468d81eb8cc39bd2958105ab1798696d6b1
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbPhDetSupFrame.SAVE
@@ -0,0 +1,185 @@
+// $Id: $
+// Include files 
+
+
+
+// local
+#include "RichTbPhDetSupFrame.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbVessel.hh"
+#include "RichTbHpd.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 <vector>
+#include "RichTbMiscNames.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbPhDetSupFrame
+//
+// 2003-11-19 : Sajan EASO
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbPhDetSupFrame::RichTbPhDetSupFrame(RichTbVessel* aVessel  ):
+   NumHpdVol( NumHpds), 
+   HpdVolVect( std::vector<RichTbHpd*>(NumHpds)),
+   ConstructTrackingSwitch(true) {
+
+  MotherVesselOfPhDetSupFrame= aVessel;
+  //  The following is done not as default from the
+  // constructor. This so that one can chane the value of the 
+  // ConstructTracking switch before calling the following.
+  //  constructPhDetSupFrame();
+  
+}
+
+RichTbPhDetSupFrame::~RichTbPhDetSupFrame()
+{
+  ;
+}
+void RichTbPhDetSupFrame::constructPhDetSupFrame() 
+{
+  RichTbMaterial* aMaterial =  RichTbMaterial::getRichTbMaterialInstance();
+  RichTbRunConfig* aRunConfig =  RichTbRunConfig::getRunConfigInstance();
+  std::vector<G4double> aPhDetSupFrameAdditionalShift =
+    aRunConfig->getPhSupFrameAdditionalShift();
+  G4double aPhDetSupFrameAdditionalVertTilt= 
+     aRunConfig->getPhSupFrameAdditionalVertTilt();
+  G4double aPhDetSupFrameAdditionalZRot=
+     aRunConfig->getPhSupFrameAdditionalZRot();
+
+  G4cout<<" PhDetSupFrame OrigXYZ ShiftXYZ  "
+	<< RichTbPhotDetSupXLocation<<"    "
+        << RichTbPhotDetSupYLocation<<"    "
+        <<  RichTbPhotDetSupZLocation<<"    "
+        << aPhDetSupFrameAdditionalShift[0]<< "    "
+        << aPhDetSupFrameAdditionalShift[1]<< "    "
+        << aPhDetSupFrameAdditionalShift[2]<< "    "
+        <<G4endl;
+  G4cout<<"PhdetSupframe original Vert tilt additional verttilt zrot "
+	<< RichTbPhotDetVerticalTilt<<"   "
+        << aPhDetSupFrameAdditionalVertTilt<<"    "
+        << aPhDetSupFrameAdditionalZRot<<G4endl;
+ 
+
+ G4Box * PhDetSupFrameOverallBox 
+   = new G4Box("PhDetSupFrameOverallBox",0.5* RichTbPhotDetSupXSize,
+               0.5*  RichTbPhotDetSupYSize,
+               0.5* RichTbPhotDetSupZSize );
+ 
+
+   G4RotationMatrix   PhDetSupRot;
+   PhDetSupRot.rotateZ(RichTbPhDetSupFrameRotZ+aPhDetSupFrameAdditionalZRot );
+   PhDetSupRot.rotateX(RichTbPhDetSupFrameRotX + 
+           aPhDetSupFrameAdditionalVertTilt );
+   PhDetSupRot.rotateY( RichTbPhDetSupFrameRotY);
+
+   // CHANGED JDICKENS (03/08/05)
+   G4cout << "rotateZ = " << RichTbPhDetSupFrameRotZ << " + " << aPhDetSupFrameAdditionalZRot << G4endl;
+   G4cout << "rotateX = " <<RichTbPhDetSupFrameRotX << " + " << aPhDetSupFrameAdditionalVertTilt << G4endl;
+   G4cout << "rotateY = " << RichTbPhDetSupFrameRotY << G4endl;
+   // END OF CHANGE
+
+   G4ThreeVector PhDetSupLocation( RichTbPhotDetSupXLocation + 
+				   aPhDetSupFrameAdditionalShift[0],
+				   RichTbPhotDetSupYLocation + 
+				   aPhDetSupFrameAdditionalShift[1],
+				   RichTbPhotDetSupZLocation + 
+				   aPhDetSupFrameAdditionalShift[2] );
+
+   G4Transform3D PhDetSupTransform( PhDetSupRot, PhDetSupLocation );
+
+
+   // CHANGED JDICKENS (03/08/05)
+   G4ThreeVector TopRow = PhDetSupRot.rowX();
+   G4ThreeVector MidRow = PhDetSupRot.rowY();
+   G4ThreeVector BotRow = PhDetSupRot.rowZ();
+
+   G4cout << "PhDetSupRot: Rotation" << G4endl;
+   G4cout << "TopRow = (" << TopRow.x() << ", " << TopRow.y() << ", " << TopRow.z() << ")" << G4endl;
+   G4cout << "MidRow = (" << MidRow.x() << ", " << MidRow.y() << ", " << MidRow.z() << ")" << G4endl;
+   G4cout << "BotRow = (" << BotRow.x() << ", " << BotRow.y() << ", " << BotRow.z() << ")" << G4endl;
+
+   G4cout << "Det(R) = " << TopRow.dot( MidRow.cross( BotRow ) ) << G4endl;
+
+   G4cout << "PhDetSupRot: Translation = (" << PhDetSupLocation.x() << ", " << PhDetSupLocation.y()
+	  << ", " << PhDetSupLocation.z() << ")" << G4endl;
+   // END OF CHANGE
+
+
+   G4LogicalVolume*   PhDetSupLog = 
+     new   G4LogicalVolume(PhDetSupFrameOverallBox,
+			   aMaterial->getNitrogenGas(),
+			   "RichTbPhDetLog",0,0,0);
+   G4VPhysicalVolume* PhDetSupPhys =
+     new   G4PVPlacement(PhDetSupTransform,PhDetSupName,
+			 PhDetSupLog, 
+			 MotherVesselOfPhDetSupFrame-> 
+			 getRichTbGasVesselPVol(),
+			 false,0);
+    
+ 
+  RichTbPhDetSupFrameLVol=PhDetSupLog;
+  RichTbPhDetSupFramePVol= PhDetSupPhys;
+  // Now create the Gas quartz window.
+
+  G4Box * GasQuartzWindowBox 
+   = new G4Box("GasQuartzWindowBox",0.5* RichTbGasQuWinXSize,
+               0.5*  RichTbGasQuWinYSize,
+               0.5* RichTbGasQuWinZSize );
+ 
+   G4RotationMatrix   GasQuWinRot;
+   G4ThreeVector GasQuWinPos(RichTbGasQuWinXLocation, RichTbGasQuWinYLocation,
+			     RichTbGasQuWinZLocation);
+   G4Transform3D  GasQuWinTransform( GasQuWinRot,GasQuWinPos );  
+
+  G4LogicalVolume*   GasQuWinLog= 
+    new   G4LogicalVolume(GasQuartzWindowBox,
+                          aMaterial->getRichTbGasWinQuartz(),
+                          "RichTbGasQuWinLog",0,0,0);
+  G4VPhysicalVolume*  GasQuWinPhys=
+      new   G4PVPlacement(GasQuWinTransform,GasQuWinPhysName,
+                          GasQuWinLog, RichTbPhDetSupFramePVol ,
+                          false,0);
+
+  RichTbGasQuWinLVol= GasQuWinLog;
+  RichTbGasQuWinPVol= GasQuWinPhys;
+
+
+  // Now create the Hpds. When the ConstructTracking switch is
+  // true create all the parts of each hpd. When it is
+  // false create only the part of the geometry 
+  // tree needed to create the silicon pixels, as is done
+  // for the ReadOut Geometry.
+
+  for(G4int ihpd=0 ; ihpd<  NumHpdVol; ihpd++) {
+    //    G4cout<<" Now building HPD "<<ihpd<<G4endl;
+    HpdVolVect[ihpd]= new RichTbHpd(ihpd,this);
+     HpdVolVect[ihpd]->constructHpdMasterTree();
+     if(ConstructTrackingSwitch) {       
+     HpdVolVect[ihpd]->constructHpdComponentsLVol();
+     HpdVolVect[ihpd]->constructHpdComponentsPVol();
+     }else {
+       HpdVolVect[ihpd]-> constructHpdSiPixel();
+       
+     }
+     
+     
+  }
+  
+  
+  
+}
+
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbPhDetSupFrame_cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbPhDetSupFrame_cc
new file mode 100644
index 0000000000000000000000000000000000000000..0194672978b65e5f80c02b1dab3501b91763db20
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbPhDetSupFrame_cc
@@ -0,0 +1,211 @@
+// $Id: $
+// Include files 
+
+
+
+// local
+#include "RichTbPhDetSupFrame.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbVessel.hh"
+#include "RichTbHpd.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 <vector>
+#include "RichTbMiscNames.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbPhDetSupFrame
+//
+// 2003-11-19 : Sajan EASO
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbPhDetSupFrame::RichTbPhDetSupFrame(RichTbVessel* aVessel  ):
+   NumHpdVol( NumHpds), 
+   HpdVolVect( std::vector<RichTbHpd*>(NumHpds)),
+   ConstructTrackingSwitch(true) {
+
+  MotherVesselOfPhDetSupFrame= aVessel;
+  //  The following is done not as default from the
+  // constructor. This so that one can chane the value of the 
+  // ConstructTracking switch before calling the following.
+  //  constructPhDetSupFrame();
+  
+}
+
+RichTbPhDetSupFrame::~RichTbPhDetSupFrame()
+{
+  ;
+}
+void RichTbPhDetSupFrame::constructPhDetSupFrame() 
+{
+  RichTbMaterial* aMaterial =  RichTbMaterial::getRichTbMaterialInstance();
+  RichTbRunConfig* aRunConfig =  RichTbRunConfig::getRunConfigInstance();
+  std::vector<G4double> aPhDetSupFrameAdditionalShift =
+    aRunConfig->getPhSupFrameAdditionalShift();
+  G4double aPhDetSupFrameAdditionalVertTilt= 
+    aRunConfig->getPhSupFrameAdditionalVertTilt();
+  G4double aPhDetSupFrameAdditionalZRot=
+    aRunConfig->getPhSupFrameAdditionalZRot();
+
+  G4cout <<" PhDetSupFrame OrigXYZ ShiftXYZ  "
+	 << RichTbPhotDetSupXLocation << "    "
+	 << RichTbPhotDetSupYLocation << "    "
+	 << RichTbPhotDetSupZLocation << "    "
+	 << aPhDetSupFrameAdditionalShift[0] << "    "
+	 << aPhDetSupFrameAdditionalShift[1] << "    "
+	 << aPhDetSupFrameAdditionalShift[2] << "    "
+	 << G4endl;
+
+  G4cout << "PhdetSupframe original Vert tilt additional verttilt zrot "
+	 << RichTbPhotDetVerticalTilt <<"   "
+	 << aPhDetSupFrameAdditionalVertTilt <<"    "
+	 << aPhDetSupFrameAdditionalZRot << G4endl;
+ 
+
+  G4Box* PhDetSupFrameOverallBox 
+    = new G4Box( "PhDetSupFrameOverallBox",
+		 0.5 * RichTbPhotDetSupXSize,
+		 0.5 * RichTbPhotDetSupYSize,
+		 0.5 * RichTbPhotDetSupZSize );
+ 
+  // CHANGED JDICKENS (05/08/05)
+  G4RotationMatrix PhDetSupRotInv;
+    
+  PhDetSupRotInv.rotateZ( RichTbPhDetSupFrameRotZ + aPhDetSupFrameAdditionalZRot );
+  PhDetSupRotInv.rotateX( RichTbPhDetSupFrameRotX + aPhDetSupFrameAdditionalVertTilt );
+  PhDetSupRotInv.rotateY( RichTbPhDetSupFrameRotY );
+
+  G4RotationMatrix PhDetSupRot = inverseOf( PhDetSupRotInv );
+ 
+//   G4ThreeVector DirCosX( RichTbPhDetSupFrameDirCosXX,
+// 			 RichTbPhDetSupFrameDirCosXY,
+// 			 RichTbPhDetSupFrameDirCosXZ );
+
+//   G4ThreeVector DirCosY( RichTbPhDetSupFrameDirCosYX,
+// 			 RichTbPhDetSupFrameDirCosYY,
+// 			 RichTbPhDetSupFrameDirCosYZ );
+
+//   G4ThreeVector DirCosZ( RichTbPhDetSupFrameDirCosZX,
+// 			 RichTbPhDetSupFrameDirCosZY,
+// 			 RichTbPhDetSupFrameDirCosZZ );
+
+//   G4RotationMatrix PhDetSupRot(DirCosX, DirCosY, DirCosZ);
+
+  // END OF CHANGE
+
+  // CHANGED JDICKENS (03/08/05)
+  G4cout << "rotateZ = " << RichTbPhDetSupFrameRotZ 
+	 << " + " << aPhDetSupFrameAdditionalZRot << G4endl;
+  G4cout << "rotateX = " <<RichTbPhDetSupFrameRotX 
+	 << " + " << aPhDetSupFrameAdditionalVertTilt << G4endl;
+  G4cout << "rotateY = " << RichTbPhDetSupFrameRotY << G4endl;
+   // END OF CHANGE
+
+   G4ThreeVector PhDetSupLocation( RichTbPhotDetSupXLocation + 
+				   aPhDetSupFrameAdditionalShift[0],
+				   RichTbPhotDetSupYLocation + 
+				   aPhDetSupFrameAdditionalShift[1],
+				   RichTbPhotDetSupZLocation + 
+				   aPhDetSupFrameAdditionalShift[2] );
+
+   G4Transform3D PhDetSupTransform( PhDetSupRot, PhDetSupLocation );
+
+
+   // CHANGED JDICKENS (03/08/05)
+   G4ThreeVector TopRow = PhDetSupRot.rowX();
+   G4ThreeVector MidRow = PhDetSupRot.rowY();
+   G4ThreeVector BotRow = PhDetSupRot.rowZ();
+
+   G4cout << "PhDetSupRot: Rotation" << G4endl;
+   G4cout << "TopRow = (" << TopRow.x() << ", " << TopRow.y() << ", " << TopRow.z() << ")" << G4endl;
+   G4cout << "MidRow = (" << MidRow.x() << ", " << MidRow.y() << ", " << MidRow.z() << ")" << G4endl;
+   G4cout << "BotRow = (" << BotRow.x() << ", " << BotRow.y() << ", " << BotRow.z() << ")" << G4endl;
+
+   G4cout << "TopRow . MidRow = " << TopRow.dot(MidRow) << G4endl;
+   G4cout << "TopRow . BotRow = " << TopRow.dot(BotRow) << G4endl;
+   G4cout << "MidRow . BotRow = " << MidRow.dot(BotRow) << G4endl;
+
+   G4cout << "Det(R) = " << TopRow.dot( MidRow.cross( BotRow ) ) << G4endl;
+
+   G4cout << "PhDetSupRot: Translation = (" << PhDetSupLocation.x() << ", " << PhDetSupLocation.y()
+	  << ", " << PhDetSupLocation.z() << ")" << G4endl;
+   // END OF CHANGE
+
+
+   G4LogicalVolume*   PhDetSupLog = 
+     new   G4LogicalVolume(PhDetSupFrameOverallBox,
+			   aMaterial->getNitrogenGas(),
+			   "RichTbPhDetLog",0,0,0);
+   G4VPhysicalVolume* PhDetSupPhys =
+     new   G4PVPlacement(PhDetSupTransform,PhDetSupName,
+			 PhDetSupLog, 
+			 MotherVesselOfPhDetSupFrame-> 
+			 getRichTbGasVesselPVol(),
+			 false,0);
+    
+ 
+  RichTbPhDetSupFrameLVol=PhDetSupLog;
+  RichTbPhDetSupFramePVol= PhDetSupPhys;
+  // Now create the Gas quartz window.
+
+  G4Box * GasQuartzWindowBox 
+   = new G4Box("GasQuartzWindowBox",0.5* RichTbGasQuWinXSize,
+               0.5*  RichTbGasQuWinYSize,
+               0.5* RichTbGasQuWinZSize );
+ 
+   G4RotationMatrix   GasQuWinRot;
+   G4ThreeVector GasQuWinPos(RichTbGasQuWinXLocation, RichTbGasQuWinYLocation,
+			     RichTbGasQuWinZLocation);
+   G4Transform3D  GasQuWinTransform( GasQuWinRot,GasQuWinPos );  
+
+  G4LogicalVolume*   GasQuWinLog= 
+    new   G4LogicalVolume(GasQuartzWindowBox,
+                          aMaterial->getRichTbGasWinQuartz(),
+                          "RichTbGasQuWinLog",0,0,0);
+  G4VPhysicalVolume*  GasQuWinPhys=
+      new   G4PVPlacement(GasQuWinTransform,GasQuWinPhysName,
+                          GasQuWinLog, RichTbPhDetSupFramePVol ,
+                          false,0);
+
+  RichTbGasQuWinLVol= GasQuWinLog;
+  RichTbGasQuWinPVol= GasQuWinPhys;
+
+
+  // Now create the Hpds. When the ConstructTracking switch is
+  // true create all the parts of each hpd. When it is
+  // false create only the part of the geometry 
+  // tree needed to create the silicon pixels, as is done
+  // for the ReadOut Geometry.
+
+  for(G4int ihpd=0 ; ihpd<  NumHpdVol; ihpd++) {
+    //    G4cout<<" Now building HPD "<<ihpd<<G4endl;
+    HpdVolVect[ihpd]= new RichTbHpd(ihpd,this);
+     HpdVolVect[ihpd]->constructHpdMasterTree();
+     if(ConstructTrackingSwitch) {       
+     HpdVolVect[ihpd]->constructHpdComponentsLVol();
+     HpdVolVect[ihpd]->constructHpdComponentsPVol();
+     }else {
+       HpdVolVect[ihpd]-> constructHpdSiPixel();
+       
+     }
+     
+     
+  }
+  
+  
+  
+}
+
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbROGeometry.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbROGeometry.cc
new file mode 100644
index 0000000000000000000000000000000000000000..717b926102235ed0de4afe7474ac790ce0a66b2d
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbROGeometry.cc
@@ -0,0 +1,97 @@
+// $Id: $
+// Include files
+
+
+
+// local
+#include "RichTbROGeometry.hh"
+#include "RichTbUpgradeDetectorConstruction.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbHall.hh"
+#include "RichTbUpgradeVessel.hh"
+#include "RichTbUpgradeCrystalMaster.hh"
+#include "RichTbUpgradePhDetSupFrame.hh"
+#include "RichTbUpgradeEC.hh"
+
+#include "RichTbPMT.hh"
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbROGeometry
+//
+// 2003-12-11 : Sajan EASO
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+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();
+
+}
+
+
+//=============================================================================
+// Destructor
+//=============================================================================
+RichTbROGeometry::~RichTbROGeometry() {}
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbROGeometryHpd.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbROGeometryHpd.cc
new file mode 100644
index 0000000000000000000000000000000000000000..594b636205117633d4c1858788a26b05fb18c119
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbROGeometryHpd.cc
@@ -0,0 +1,68 @@
+// Include files
+
+
+
+// local
+#include "RichTbROGeometryHpd.hh"
+#include "RichTbUpgradeDetectorConstruction.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbHall.hh"
+#include "RichTbUpgradeVessel.hh"
+#include "RichTbUpgradeCrystalMaster.hh"
+#include "RichTbUpgradePhDetSupFrame.hh"
+#include "RichTbUpgradeEC.hh"
+
+#include "RichTbHpd.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbROGeometryHpd
+//
+// 2015-05-16 : Sajan Easo
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbROGeometryHpd::RichTbROGeometryHpd(G4String RoNameString,
+            RichTbDetectorConstruction* aDet  )
+: G4VReadOutGeometry(RoNameString){
+
+  CurDet = aDet;
+
+}
+G4VPhysicalVolume* RichTbROGeometryHpd::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 == 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();
+
+
+}
+
+//=============================================================================
+// Destructor
+//=============================================================================
+RichTbROGeometryHpd::~RichTbROGeometryHpd() {}
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbSurface.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbSurface.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e63dc16f132651530b9d6639e3c23134fe041b57
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbSurface.cc
@@ -0,0 +1,128 @@
+// $Id: $
+// Include files 
+
+
+
+// local
+#include "RichTbSurface.hh"
+#include "Geant4/G4LogicalBorderSurface.hh"
+#include "RichTbSurfaceDefinition.hh"
+#include "RichTbUpgradeDetectorConstruction.hh"
+#include "RichTbPMT.hh"
+
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbSurface
+//
+// 2003-11-25 : Sajan EASO
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbSurface::RichTbSurface(
+  RichTbDetectorConstruction* 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());
+
+  
+   }
+   */   
+      
+}
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbSurfaceDefinition.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbSurfaceDefinition.cc
new file mode 100644
index 0000000000000000000000000000000000000000..539e06a88092f51226ac9ca9d191da7e58e24695
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbSurfaceDefinition.cc
@@ -0,0 +1,446 @@
+// $Id: $
+// Include files
+
+#include "Geant4/G4Material.hh"
+#include "Geant4/G4MaterialTable.hh"
+#include "Geant4/G4Element.hh"
+#include "Geant4/G4ElementTable.hh"
+#include "Geant4/G4OpticalSurface.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbMaterialParameters.hh"
+#include "RichTbSurfaceParameters.hh"
+#include <fstream>
+#include <vector>
+#include <cstdlib>
+
+
+// local
+#include "RichTbSurfaceDefinition.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbSurfaceDefinition
+//
+// 2003-11-24 : Sajan EASO
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbSurfaceDefinition* RichTbSurfaceDefinition::RichTbSurfaceDefinitionInstance=0;
+
+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::getRichTbSurfaceDefinitionInstance()
+{
+  if(RichTbSurfaceDefinitionInstance == 0) {
+    RichTbSurfaceDefinitionInstance= new RichTbSurfaceDefinition(  );
+  }
+  return RichTbSurfaceDefinitionInstance;
+
+}
+
+
+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;
+
+}
+
+
+
+
+void RichTbSurfaceDefinition::createVesselSurface()
+{
+  G4int NumPhotVesselSurfaceBins=10;
+
+  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};
+
+   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};
+
+ G4OpticalSurface* OpVesselSurface=
+   new G4OpticalSurface("VesselOpticalSurface");
+ OpVesselSurface->SetType(dielectric_metal);
+ OpVesselSurface->SetFinish(polished);
+ OpVesselSurface->SetModel(glisur);
+
+ G4MaterialPropertiesTable* OpVesselSurfaceMPT =
+          new G4MaterialPropertiesTable();
+
+ OpVesselSurfaceMPT->AddProperty("REFLECTIVITY",
+                                 VesselSurfacePhotMom,
+                                 VesselSurfaceReflectivity,
+                                 NumPhotVesselSurfaceBins);
+
+
+ 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");
+
+   OpPMTQuartzWMasterSurface->SetType(dielectric_dielectric);
+   OpPMTQuartzWMasterSurface->SetFinish(polished);
+   OpPMTQuartzWMasterSurface->SetModel(glisur);
+   //   OpPMTQuartzWMasterSurface->SetModel(unified);
+
+   G4MaterialPropertiesTable*  OpPMTQuartzWMasterSurfaceMPT =
+           new G4MaterialPropertiesTable();
+
+   OpPMTQuartzWMasterSurfaceMPT ->AddProperty("REFLECTIVITY",
+                  PMTQuartzWMasterSurfacePhotMom,
+                  PMTQuartzWMasterSurfaceReflectivity,
+                  NumPhotPMTQuartzWMasterSurfaceWavelengthBins);
+
+   OpPMTQuartzWMasterSurfaceMPT ->AddProperty( "EFFICIENCY",
+                  PMTQuartzWMasterSurfacePhotMom,
+                  PMTQuartzWMasterSurfaceEff,
+                  NumPhotPMTQuartzWMasterSurfaceWavelengthBins);
+
+    OpPMTQuartzWMasterSurface->
+      SetMaterialPropertiesTable(OpPMTQuartzWMasterSurfaceMPT);
+
+    RichTbPMTMasterQuartzWSurface=OpPMTQuartzWMasterSurface;
+
+}
+
+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};
+
+  G4OpticalSurface * OpPMTQuartzWPhCathodeSurface=
+            new  G4OpticalSurface("PMTQuartzWPhCathodeSurface");
+  OpPMTQuartzWPhCathodeSurface->SetType(dielectric_dielectric);
+  OpPMTQuartzWPhCathodeSurface->SetFinish(polished);
+  OpPMTQuartzWPhCathodeSurface->SetModel(glisur);
+
+  G4MaterialPropertiesTable* OpPMTQuartzWPhCathodeSurfaceMPT=
+           new G4MaterialPropertiesTable();
+
+  OpPMTQuartzWPhCathodeSurfaceMPT->AddProperty("REFLECTIVITY",
+            PMTQuartzWPhCathodeSurfacePhotMom,
+            PMTQuartzWPhCathodeSurfaceReflectivity,
+            NumPhotQuartzWPhCathodeSurfaceWavelengthBins);
+
+  OpPMTQuartzWPhCathodeSurfaceMPT->AddProperty("EFFICIENCY",
+            PMTQuartzWPhCathodeSurfacePhotMom,
+            PMTQuartzWPhCathodeSurfaceEff,
+            NumPhotQuartzWPhCathodeSurfaceWavelengthBins);
+
+  OpPMTQuartzWPhCathodeSurface->
+   SetMaterialPropertiesTable(OpPMTQuartzWPhCathodeSurfaceMPT);
+
+  RichTbPMTQuartzWPhCathodeSurface= OpPMTQuartzWPhCathodeSurface;
+
+}
+
+void RichTbSurfaceDefinition::ReadMirrorReflectivity() {
+
+
+  RichTbRunConfig* aRunConfig= RichTbRunConfig::getRunConfigInstance();
+  G4String MirrorFname= aRunConfig->getMirrorReflFileName();
+  G4cout<<" MirrorReflectivity being read from   "<<MirrorFname<<G4endl;
+  MirrorSurfWlen.clear();
+  MirrorSurfReflect.clear();
+  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;
+  } 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;
+
+      //  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());
+	      }
+
+      }
+
+      NumPhotMirrorReflectBins= numbinrefl;
+      reverse(MirrorSurfWlen.begin(),MirrorSurfWlen.end());
+      reverse(MirrorSurfReflect.begin(),MirrorSurfReflect.end());
+
+
+      // 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.
+
+
+    G4cout<<"End of reading Mirror reflectivity"<<G4endl;
+  }
+
+}
+
+void RichTbSurfaceDefinition::createRichTbKovarSurface() {
+
+   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 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);
+
+ G4MaterialPropertiesTable* OpKovarSurfaceMPT =
+          new G4MaterialPropertiesTable();
+
+ OpKovarSurfaceMPT->AddProperty("REFLECTIVITY",
+                                 KovarSurfacePhotMom,
+                                 KovarSurfaceReflectivity,
+                                 NumPhotKovarSurfaceBins);
+
+
+ OpKovarSurfaceMPT->AddProperty(" EFFICIENCY",
+                                 KovarSurfacePhotMom,
+                                 KovarSurfaceEfficiency,
+                                 NumPhotKovarSurfaceBins);
+ OpKovarSurface->SetMaterialPropertiesTable(OpKovarSurfaceMPT);
+
+ RichTbKovarSurface =  OpKovarSurface;
+
+}
+
+void   RichTbSurfaceDefinition::createtRichTbSiDetSurface(){
+
+  RichTbRunConfig* aRunConfig= RichTbRunConfig::getRunConfigInstance();
+  G4int aSiReflFlag= aRunConfig-> getPMTSiReflFlag();
+
+   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;
+
+    }
+
+  }
+
+
+   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];
+
+ 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);
+
+
+ OpSiDetSurfaceMPT->AddProperty(" EFFICIENCY",
+                                 SiDetSurfacePhotMom,
+                                 SiDetSurfaceEfficiency,
+                                 NumPhotSiDetSurfaceBins);
+
+ OpSiDetSurfaceMPT->AddProperty("RINDEX",
+                                 SiDetSurfacePhotMom,
+				 SiDetReflRefIndex,
+                                 NumPhotSiDetSurfaceBins );
+
+
+ OpSiDetSurface->SetMaterialPropertiesTable(OpSiDetSurfaceMPT);
+
+ RichTbSiDetSurface =  OpSiDetSurface;
+
+}
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeCrystal.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeCrystal.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8e91f931553d9657df2db4fb42a0df27a5e89980
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeCrystal.cc
@@ -0,0 +1,107 @@
+// $Id: $
+// 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/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"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbVessel
+//
+// 2003-11-05 : Sajan EASO
+// 2005-02-20:  SE Modifed for the 2004 testbeam.
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbCrystal::RichTbCrystal(RichTbUpgradeCrystalMaster* rTbCrystalMaster ) {
+
+  aRTbCrystalMaster = rTbCrystalMaster;
+  
+  constructRichTbCrystal();
+  
+}
+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;
+  /*
+   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 = 
+      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()
+{
+  
+}
+
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeCrystalCover.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeCrystalCover.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9a61e9d7778f075e41bef641c1e3afed1815dc2f
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeCrystalCover.cc
@@ -0,0 +1,155 @@
+// $Id: $
+// 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/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"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbVessel
+//
+// 2003-11-05 : Sajan EASO
+// 2005-02-20:  SE Modifed for the 2004 testbeam.
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+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);
+ 
+  G4RotationMatrix CrystalCoverSubRotX, CrystalCoverSubRotY, CrystalCoverRotX, CrystalCoverRotY;
+  /*
+  G4int aSpecialStudyCrystalCoverRotFlag =  
+      aConfig ->getSpecialStudyCrystalRotation();
+
+  if( aSpecialStudyCrystalCoverRotFlag != 1 ) {
+
+    G4double CrystalRotX = aConfig ->getSpecialStudyCrystalRotationX();
+    G4double CrystalRotY = aConfig ->getSpecialStudyCrystalRotationY();
+
+    //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)));
+    
+    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)));
+    
+     CrystalCoverSubRotX.rotateX(CrystalRotX);
+     CrystalCoverSubRotY.rotateY(CrystalRotY);
+    
+     
+
+  }
+  */
+  //
+  // 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()
+{
+  
+}
+
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeCrystalMaster.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeCrystalMaster.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5b1a9f1548f8b16448a5e19789cad5967c9bae52
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeCrystalMaster.cc
@@ -0,0 +1,106 @@
+// $Id: $
+// Include files
+
+
+
+// local
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMiscNames.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbUpgradeVessel.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"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbVessel
+//
+// 2003-11-05 : Sajan EASO
+// 2005-02-20:  SE Modifed for the 2004 testbeam.
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+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);
+
+  G4ThreeVector CrystalMasterPos(RichTbCrystalMasterXLocation,
+                          RichTbCrystalMasterYLocation,
+                          RichTbCrystalMasterZLocation);
+
+  G4RotationMatrix CrystalMasterRotX,CrystalMasterRotY;
+
+   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);
+
+  /* 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);
+
+     RichTbUpgradeCrystalMasterLVol =  CrystalMasterLog;
+     RichTbUpgradeCrystalMasterPVol =  CrystalMasterPhys;
+
+
+}
+void RichTbUpgradeCrystalMaster::constructRichTbUpgradeCrystalMasterEnvelope()
+{
+
+}
+
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeDarkCover.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeDarkCover.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bbac8a21f653e09025210e1ca77c987d34d38eb4
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeDarkCover.cc
@@ -0,0 +1,308 @@
+// $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/G4Sphere.hh"
+#include "Geant4/G4Tubs.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbVessel
+//
+// 2003-11-05 : Sajan EASO
+// 2005-02-20:  SE Modifed for the 2004 testbeam.
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbUpgradeDarkCover::RichTbUpgradeDarkCover(RichTbUpgradeRadiator* arTbRadiator ) {
+
+	aRTbUpgradeRadiator = arTbRadiator;
+
+	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);
+
+	/* G4SubtractionSolid* VesselUpsSub =
+      new G4SubtractionSolid("VesselUpsSub",  RichTbVesselBoxOverall ,
+                             RichTbVesselUpsSubBox,VesselUpsSubTransform);
+
+	 */
+	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();
+
+	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);
+
+	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 ( MirrorPosX , MirrorPosY, MirrorPosZ);
+
+
+	G4Transform3D UpsDarkTransform(  UpsDarkRotationX * UpsDarkRotationY, UpsDarkPos);
+
+	G4LogicalVolume* UpsDarkLog =
+			new G4LogicalVolume( UpsDarkSphe,aMaterial->getCarbon(),
+					"UpsDarkSpheLog",0,0,0);
+
+	G4VPhysicalVolume* UpsDarkPhys=
+			new  G4PVPlacement( UpsDarkTransform, "UpsDarkSphePhys",
+					UpsDarkLog,aMaster->getRichTbUpgradeCrystalMasterPVol(),false,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;
+
+}
+
+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);
+
+
+	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::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/G4RichTbSimH/src/srcgy/RichTbUpgradeDetectorConstruction.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeDetectorConstruction.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2fa3e97a3f6e6904e5dcbf28121a60f380bcaa59
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeDetectorConstruction.cc
@@ -0,0 +1,204 @@
+// 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"
+
+// STL etc
+#include <iostream>
+
+// local headers
+#include "RichTbMiscNames.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbUpgradeDetectorConstruction.hh"
+#include "RichTbHall.hh"
+
+#include "RichTbSurfaceDefinition.hh"
+#include "RichTbSurface.hh"
+
+#include "RichTbUpgradeSD.hh"
+#include "RichTbUpgradeHpdSD.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
+
+	rTbSurface = new  RichTbSurface(this);
+
+	//sensitive detector creation for PMT
+
+	G4SDManager* SDman = G4SDManager::GetSDMpointer();
+
+
+	RichTbUpgradeSD* PMTSD = new RichTbUpgradeSD( PMTSDname );
+
+
+	//sensitive detector creation for HPD
+	RichTbUpgradeHpdSD* HPDSD = (aRadiatorConfiguration == 2) ? new RichTbUpgradeHpdSD(HPDSDname):0;
+
+
+
+	// 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 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();
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeEC.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeEC.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e24645e437568055b5387b865623db378fb3d726
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeEC.cc
@@ -0,0 +1,205 @@
+// Include files
+
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMiscNames.hh"
+#include "RichTbMaterial.hh"
+#include "Geant4/G4RotationMatrix.hh"
+#include "Geant4/G4ThreeVector.hh"
+#include "Geant4/G4Transform3D.hh"
+#include "Geant4/G4SubtractionSolid.hh"
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4PVPlacement.hh"
+#include "RichTbRunConfig.hh"
+
+
+
+// local
+#include "RichTbUpgradeEC.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbUpgradeEC
+//
+// 2014-10-23 : Sajan Easo
+// 2015-06-11 : Michele Blago
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbUpgradeEC::RichTbUpgradeEC(RichTbUpgradePhDetSupFrame * rTbPhotSupFrame   ) {
+
+   aRTbPhotSupFrame = rTbPhotSupFrame ;
+   // constructRichTbUpgradeEC ();
+   // constructRichTbUpgradeECSupport ();
+
+
+}
+//=============================================================================
+// Destructor
+//=============================================================================
+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::constructRichTbUpgradeECSupport () {
+
+   RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+   G4Box * ECSupBox = new G4Box("ECBox", 0.5*ECSupportXSize,0.5*ECSupportYSize, 0.5*ECSupportZSize);
+
+   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);
+
+   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::constructRichTbUpgradeSingleECSupport () {
+
+   RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+   G4Box * ECSupBox = new G4Box("ECBox", 0.5*ECSupportXSize,0.5*ECSupportYSize, 0.5*ECSupportZSize);
+
+   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;
+
+}
+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;
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeLens.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeLens.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dede1b25f69b80f621b73bab7ae2f629fef75465
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeLens.cc
@@ -0,0 +1,148 @@
+// $Id: $
+// Include files
+
+
+
+// local
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMiscNames.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbUpgradeVessel.hh"
+#include "RichTbUpgradeLens.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/G4Orb.hh"
+#include "Geant4/G4LogicalVolume.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4PVPlacement.hh"
+#include "RichTbRunConfig.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbVessel
+//
+// 2003-11-05 : Sajan EASO
+// 2005-02-20:  SE Modifed for the 2004 testbeam.
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbLens::RichTbLens(RichTbUpgradeCrystalMaster* rTbCrystalMaster ) {
+
+  aRTbCrystalMaster = rTbCrystalMaster;
+
+  constructRichTbLens();
+
+}
+RichTbLens::~RichTbLens(  )
+{
+}
+void RichTbLens::constructRichTbLens()
+{
+  RichTbMaterial* aMaterial = RichTbMaterial::getRichTbMaterialInstance();
+  // RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
+
+
+  G4Orb * Sph1 = new G4Orb("Sph1", SphRadius1);
+
+  G4Orb * Sph2 = new G4Orb("Sph2", SphRadius2);
+
+  //   G4int aSpecialStudyCrystalRotFlag =
+  //    aConfig ->getSpecialStudyCrystalRotation();
+
+
+
+
+
+  G4double RichTbSph2XLocation, RichTbSph2YLocation, RichTbSph2ZLocation;
+
+  RichTbSph2XLocation = 0.0*CLHEP::mm;
+  RichTbSph2YLocation = 0.0*CLHEP::mm;
+  RichTbSph2ZLocation = DistanceSph;
+  G4cout << "distance " << RichTbSph2ZLocation  << G4endl;
+
+  G4ThreeVector Sph2Pos(RichTbSph2XLocation,
+                        RichTbSph2YLocation,
+                        RichTbSph2ZLocation);
+
+  G4RotationMatrix Sph2RotX, Sph2RotY;
+
+
+
+  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);
+
+  G4RotationMatrix ARotX, ARotY;
+
+  G4Transform3D ATransform(ARotX * ARotY, APos);
+
+  G4SubtractionSolid* Lens =
+      new G4SubtractionSolid("Lens", Sph2, A, ATransform);
+  /*
+  G4Box* C = new G4Box("CBox", 0.5*CBoxXSize,
+                0.5*CBoxYSize, 0.5*CBoxZSize);
+  G4RotationMatrix CRotX, CRotY;
+  G4ThreeVector CPos( 0.0*CLHEP::mm,
+                      0.0*CLHEP::mm,
+                     -0.5*CBoxZSize + SphRadius1 - 55.0*CLHEP::mm );
+
+  G4Transform3D CTransform(CRotX * CRotY, CPos);
+
+  G4SubtractionSolid* Lens =
+      new G4SubtractionSolid("Lens", B, C, ATransform);
+  */
+
+  G4ThreeVector LensPos(RichTbLensXLocation,
+                          RichTbLensYLocation,
+                          RichTbLensZLocation);
+
+  G4RotationMatrix LensRotX, LensRotY;
+  /*
+ if( aSpecialStudyCrystalRotFlag != 1 ) {
+
+    LensRotX.rotateX(aConfig ->getSpecialStudyCrystalRotationX());
+    LensRotY.rotateY(aConfig ->getSpecialStudyCrystalRotationY());
+
+  }
+
+  */
+
+  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;
+
+
+}
+void RichTbLens::constructRichTbLensEnvelope()
+{
+
+}
+
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeMaster.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeMaster.cc
new file mode 100644
index 0000000000000000000000000000000000000000..ccb93ad3fc7cb1abe0c5267a11a3c3b7fcfde7f3
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeMaster.cc
@@ -0,0 +1,261 @@
+// $Id: $
+// 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/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"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbVessel
+//
+// 2003-11-05 : Sajan EASO
+// 2005-02-20:  SE Modifed for the 2004 testbeam.
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbMaster::RichTbMaster(RichTbPhDFrame* rTbPhDFrame, int MasterNum ) {
+
+  aMasterNum = MasterNum;
+  aRTbPhDFrame = rTbPhDFrame;
+
+  if(aMasterNum == 1)
+    constructRichTbMaster1();
+  if(aMasterNum == 2)
+    constructRichTbMaster2();
+  if(aMasterNum == 3)
+    constructRichTbMaster3();
+  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());
+
+  }
+
+  
+ 
+  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());
+
+  }
+
+  
+ 
+  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());
+
+  }
+
+  
+ 
+  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());
+
+  }
+
+  
+ 
+  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()
+//{
+  
+//}
+
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeMirror.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeMirror.cc
new file mode 100644
index 0000000000000000000000000000000000000000..1c7075572a116b485e0d56875d2f7071c587d471
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeMirror.cc
@@ -0,0 +1,207 @@
+// $Id: $
+// Include files
+
+#include "RichTbGeometryParameters.hh"
+#include "Geant4/globals.hh"
+#include "RichTbRunConfig.hh"
+#include "Geant4/G4Sphere.hh"
+#include "Geant4/G4RotationMatrix.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"
+
+// local
+#include "RichTbUpgradeMirror.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbMiscNames.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbUpgradeMirror
+//
+// 2003-11-07 : Sajan EASO
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+//RichTbUpgradeMirror* RichTbUpgradeMirror::RichTbUpgradeMirrorInstance=0;
+
+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) constructRichTbUpgradeMirror15();
+	else constructRichTbUpgradeMirror();
+
+}
+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.
+
+	// 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 );
+
+
+	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 );
+
+
+	G4RotationMatrix MirrorRotationX, MirrorRotationY;
+	MirrorRotationY.rotateY(180*CLHEP::degree);
+
+	G4ThreeVector MirrorPos ( MirrorPosX , MirrorPosY, MirrorPosZ);
+
+	G4Transform3D MirrorTransform(  MirrorRotationX * MirrorRotationY,
+			MirrorPos);
+
+	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()
+//{
+//  if( RichTbUpgradeMirrorInstance == 0 ) {
+//    RichTbUpgradeMirrorInstance = new RichTbUpgradeMirror(RichTbCrystalMaster* aMaster  );
+//
+//  }
+//  return RichTbUpgradeMirrorInstance;
+//}
+
+
+/*
+RichTbUpgradeMirror* RichTbUpgradeMirror::getRichTbUpgradeMirrorInstance()
+{
+  if( RichTbUpgradeMirrorInstance == 0 )
+    {
+      G4cout << "ERROR - MIRROR NOT CONSTRUCTED" << G4endl;
+    }
+  return RichTbUpgradeMirrorInstance;
+}
+ */
+// END OF CHANGE
+
+
+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;
+
+	G4double MirrPhiSize = 2*CLHEP::pi* CLHEP::rad;
+
+	// G4double MirrThetaStart = 0.0*CLHEP::rad;
+	G4double MirrThetaStart = MirrorMinThetaExtent15;
+	G4double MirrThetaSize = MirrorMaxThetaExtent15-MirrorMinThetaExtent15;
+
+	G4double MirrPhiStart = 0.0*CLHEP::rad;
+
+	G4Sphere* MirrorFull =  new G4Sphere("MirrorFull",MirrorInnerRadius15,
+			MirrorOuterRadius15,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);
+//
+//	G4Transform3D BoxTopTransform(BoxTopRot, Box2PosTop);
+//	G4Transform3D BoxBotTransform(BoxBotRot, Box2PosBot);
+//
+//	G4SubtractionSolid* MirrorHA = new G4SubtractionSolid("MirrorHA",MirrorFull,
+//			BoxS, BoxTopTransform);
+//
+//	G4SubtractionSolid* MirrorSphe = new G4SubtractionSolid("MirrorSphe",MirrorHA,
+//			BoxS, BoxBotTransform);
+
+	G4RotationMatrix MirrorRotationX, MirrorRotationY;
+	MirrorRotationY.rotateY(180*CLHEP::degree);
+
+	G4ThreeVector MirrorPos(MirrorPosX15, MirrorPosY15, MirrorVolPosZ15);
+
+	G4Transform3D MirrorTransform(MirrorRotationX * MirrorRotationY,
+			MirrorPos);
+
+//	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;
+}
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradePhDFrame.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradePhDFrame.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6f213d6aa408560a26349f511ae6ad685076b665
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradePhDFrame.cc
@@ -0,0 +1,105 @@
+// $Id: $
+// 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/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"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbUpgradeVessel
+//
+// 2003-11-05 : Sajan EASO
+// 2005-02-20:  SE Modifed for the 2004 testbeam.
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbPhDFrame::RichTbPhDFrame(RichTbUpgradeCrystalMaster* rTbCrystalMaster ) {
+
+  aRTbCrystalMaster = rTbCrystalMaster;
+  
+  constructRichTbPhDFrame();
+  
+}
+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;
+  PhDFrameRotY.rotateY(RichTbPhDFrameYRotation);
+  PhDFrameRotX.rotateX(RichTbPhDFrameXRotation);
+  /* G4int aSpeicalStudyVesselRotFlag =  
+      aConfig ->getSpecialStudyVesselRotation();
+
+  if( aSpeicalStudyVesselRotFlag != 1 ) {
+    
+  VesselRotX.rotateX(RichTbUpgradeVesselXRotation);
+  VesselRotY.rotateY(RichTbUpgradeVesselYRotation);
+
+  }
+
+  */
+  //
+  // 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()
+{
+  
+}
+
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradePhDetSupFrame.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradePhDetSupFrame.cc
new file mode 100644
index 0000000000000000000000000000000000000000..818f662f63fa95d961baa6d1042ac4fd123f5eb7
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradePhDetSupFrame.cc
@@ -0,0 +1,183 @@
+// Include files
+
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMiscNames.hh"
+#include "RichTbMaterial.hh"
+#include "Geant4/G4RotationMatrix.hh"
+#include "Geant4/G4ThreeVector.hh"
+#include "Geant4/G4Transform3D.hh"
+#include "Geant4/G4SubtractionSolid.hh"
+#include "Geant4/G4Box.hh"
+#include "Geant4/G4PVPlacement.hh"
+#include "RichTbRunConfig.hh"
+
+
+
+// local
+#include "RichTbUpgradePhDetSupFrame.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbUpgradePhDetSupFrame
+//
+// 2014-10-23 : Sajan Easo
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbUpgradePhDetSupFrame::RichTbUpgradePhDetSupFrame(RichTbUpgradeCrystalMaster * rTbCrysMaster   ) {
+  aRTbCrystalMaster = rTbCrysMaster;
+
+
+  // constructRichTbPhotoDetectorSupFrame();
+
+}
+//=============================================================================
+// Destructor
+//=============================================================================
+RichTbUpgradePhDetSupFrame::~RichTbUpgradePhDetSupFrame() {}
+
+//=============================================================================
+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);
+
+
+
+    G4RotationMatrix PhDetSupRotX,PhDetSupRotY ;
+
+    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;
+
+
+
+
+
+}
+
+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 * PhDetHpdSupFrameBox
+       = new G4Box( "PhDetHpdSupFrameBox",
+                    0.5*HpdPhDetSupFrameXSize,0.5*HpdPhDetSupFrameYSize,0.5*HpdPhDetSupFrameZSize);
+
+
+    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;
+
+
+
+
+}
+
+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;
+}
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeRadiator.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeRadiator.cc
new file mode 100644
index 0000000000000000000000000000000000000000..05f5953acf4cee7dd9a0420a6f591669a18872c7
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeRadiator.cc
@@ -0,0 +1,267 @@
+// $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/G4RotationMatrix.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/G4VPhysicalVolume.hh"
+#include "Geant4/G4PVPlacement.hh"
+#include "RichTbRunConfig.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbVessel
+//
+// 2003-11-05 : Sajan EASO
+// 2005-02-20:  SE Modifed for the 2004 testbeam.
+// 2015-06-12: Michele BLAGO modified for the 2015 testbeam.
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbUpgradeRadiator::RichTbUpgradeRadiator(RichTbUpgradeCrystalMaster* rTbCrystalMaster ) {
+
+	aRTbCrystalMaster = rTbCrystalMaster;
+
+	RichTbRunConfig* aConfig = RichTbRunConfig::  getRunConfigInstance();
+	G4int aRadiatorConfiguration = aConfig ->getRadiatorConfiguration();
+
+	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);
+
+	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);
+
+	G4RotationMatrix DarkCoverSubRotX, DarkCoverSubRotY;
+
+	G4Transform3D DarkCoverSubTransform(DarkCoverSubRotX * DarkCoverSubRotY, DarkCoverSubPos);
+
+
+
+	G4SubtractionSolid* BigBox =
+			new G4SubtractionSolid("BigBox", SubBoxA ,
+					RichTbUpgradeDarkCoverSubBox, DarkCoverSubTransform);
+
+
+	G4Orb* Sphere = new G4Orb("Sphere", SphereRadius);
+
+	G4ThreeVector BigBoxPos(BigBoxXLocation,
+			BigBoxYLocation,
+			BigBoxZLocation);
+
+	G4RotationMatrix BigBoxRotX,BigBoxRotY;
+
+	G4Transform3D BigBoxTransform(BigBoxRotX * BigBoxRotY, BigBoxPos);
+
+	G4SubtractionSolid* RichTbUpgradeRadiator =
+			new G4SubtractionSolid("Radiator", Sphere ,
+					BigBox, BigBoxTransform);
+
+	G4ThreeVector RadiatorPos(RichTbUpgradeRadiatorXLocation,
+			RichTbUpgradeRadiatorYLocation,
+			RichTbUpgradeRadiatorZLocation);
+
+	G4RotationMatrix RadiatorRotX,RadiatorRotY;
+
+
+	// RadiatorRotY.rotateY(acos(-1));
+
+	G4Transform3D RadiatorTransform( RadiatorRotX * RadiatorRotY, RadiatorPos);
+
+
+	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;
+
+
+}
+
+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);
+
+	//	G4RotationMatrix Box2RotX,Box2RotY;
+	G4RotationMatrix Cyl1RotX, Cyl1RotY;
+
+	//	G4Transform3D Box2Transform(Box2RotX * Box2RotY, Box2Pos);
+	G4Transform3D Cyl1Transform(Cyl1RotX * Cyl1RotY, Cyl1Pos);
+
+	G4SubtractionSolid* SubBoxA = new G4SubtractionSolid("SubBoxA", Box1, Cyl1, Cyl1Transform);
+
+//	G4Box * RichTbUpgradeDarkCoverSubBox = new G4Box("RichTbUpgradeDarkCoverSubBox",
+//			0.5*RichTbUpgradeDarkCoverXSize15,
+//			0.5*RichTbUpgradeDarkCoverYSize15,
+//			0.5*RichTbUpgradeDarkCoverZSize15);
+	G4Tubs * RichTbUpgradeDarkCoverSubTubs = new G4Tubs("Cyl2", cylDarkRmin, cylDarkRmax, cylDarkHalfLength, cylSPhi, cylDPhi);
+
+
+	G4ThreeVector DarkCoverSubPos(RichTbUpgradeDarkCoverXLocation15,
+			RichTbUpgradeDarkCoverYLocation15,
+			RichTbUpgradeDarkCoverZLocation15);
+
+	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;
+
+	// G4double MirrThetaStart = 0.0*CLHEP::rad;
+	G4double MirrThetaStart = MirrorMinThetaExtent15;
+	G4double MirrThetaSize = MirrorMaxThetaExtent15-MirrorMinThetaExtent15;
+
+	G4double MirrPhiStart = 0.0*CLHEP::rad;
+
+	G4Sphere* MirrorFull =  new G4Sphere("MirrorFull",MirrorInnerRadius15,
+			MirrorOuterRadius15,MirrPhiStart,
+			MirrPhiSize,MirrThetaStart,
+			MirrThetaSize);
+
+	G4RotationMatrix MirrorRotationX, MirrorRotationY;
+	MirrorRotationY.rotateY(180*CLHEP::degree);
+
+	G4ThreeVector MirrorPos(MirrorPosX15, MirrorPosY15, MirrorVolPosZ15);
+
+	G4Transform3D MirrorTransform(MirrorRotationX * MirrorRotationY,
+			MirrorPos);
+
+//	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);
+
+	G4ThreeVector BigBoxPos(BigBoxXLocation, BigBoxYLocation, BigBoxZLocation);
+
+	G4RotationMatrix BigBoxRotX,BigBoxRotY;
+
+	G4Transform3D BigBoxTransform(BigBoxRotX * BigBoxRotY, BigBoxPos);
+
+	G4SubtractionSolid* RichTbUpgradeRadiator = new G4SubtractionSolid("Radiator", SpherePlusMirror,
+			BigBox, BigBoxTransform);
+
+	G4ThreeVector RadiatorPos(RichTbUpgradeRadiatorXLocation15,
+			RichTbUpgradeRadiatorYLocation15,
+			RichTbUpgradeRadiatorZLocation15);
+
+	G4RotationMatrix RadiatorRotX,RadiatorRotY;
+
+	// RadiatorRotY.rotateY(acos(-1));
+
+	G4Transform3D RadiatorTransform( RadiatorRotX * RadiatorRotY, RadiatorPos);
+
+	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;
+
+}
+
+void RichTbUpgradeRadiator::constructRichTbUpgradeRadiatorEnvelope() {}
+
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeVessel.cc b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeVessel.cc
new file mode 100644
index 0000000000000000000000000000000000000000..538925a4ce4c9089f279d0f44810154ae87f93da
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcgy/RichTbUpgradeVessel.cc
@@ -0,0 +1,119 @@
+// $Id: $
+// Include files 
+
+
+
+// local
+#include "RichTbGeometryParameters.hh"
+#include "RichTbMiscNames.hh"
+#include "RichTbMaterial.hh"
+#include "RichTbUpgradeVessel.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"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbUpgradeVessel
+//
+// 2003-11-05 : Sajan EASO
+// 2005-02-20:  SE Modifed for the 2004 testbeam.
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+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
+  /*
+  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;
+
+  G4int aSpeicalStudyVesselRotFlag =  
+      aConfig ->getSpecialStudyVesselRotation();
+
+  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 = 
+      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()
+{
+  
+}
+
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcmain/RichTbSim.cc b/LHCbG4Tests/G4RichTbSimH/src/srcmain/RichTbSim.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8c0defe3c9a0164a0267f7c616262ff126081398
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcmain/RichTbSim.cc
@@ -0,0 +1,179 @@
+//  Rich Test Beam Simulation   Main program
+// ----------------------------------------------------------------
+#include "RichTbRunAction.hh"
+#include "RichTbEventAction.hh"
+#include "RichTbUpgradeDetectorConstruction.hh"
+#include "RichTbPrimaryGeneratorAction.hh"
+#include "RichTbStackingAction.hh"
+#include "RichTbSteppingActionBase.hh"
+#include "RichTbTrackingAction.hh"
+#include "RichTbPhysicsList.hh"
+#include "Geant4/G4VPhysicalVolume.hh"
+#include "Geant4/G4RunManager.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 "Geant4/G4ios.hh"
+#include <cstdlib>
+#include <iostream>
+
+int main(int argc, char **argv)
+{
+
+    // 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;
+
+    //#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
+#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");
+#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);
+        }
+    }
+
+    //#ifdef G4VIS_USE
+    delete visManager;
+    // #endif
+
+    G4cout << "\nVisManager deleted..\n" << G4endl;
+
+
+    //  delete analysisManager;
+
+
+    delete runManager;
+
+    G4cout << "\nRunManager deleted..\n" << G4endl;
+
+    return 0;
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbBeamProperty.cc b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbBeamProperty.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e9d14e77e75b2eac1af2c3898f1b700c1c78ceec
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbBeamProperty.cc
@@ -0,0 +1,76 @@
+// $Id: $
+// Include files 
+
+
+
+// local
+#include "RichTbBeamProperty.hh"
+#include "RichTbGeometryParameters.hh"
+#include "Geant4/G4ParticleDefinition.hh"
+#include "Geant4/G4PionMinus.hh"
+#include "Geant4/G4OpticalPhoton.hh"
+#include "Geant4/G4PionPlus.hh"
+#include "Geant4/G4Proton.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbBeamProperty
+//
+// 2004-01-22 : Sajan EASO
+//-----------------------------------------------------------------------------
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbBeamProperty* RichTbBeamProperty::RichTbBeamPropertyInstance=0;
+
+RichTbBeamProperty::RichTbBeamProperty(  ) {
+    
+  ResetBeamProperty(); 
+  mNominalBeamPosition = G4ThreeVector(RichTbNominalBeamXPos,
+                                       RichTbNominalBeamYPos,
+                                       RichTbNominalBeamZPos);
+  
+  mNominalBeamDirectionCos= G4ThreeVector(RichTbNominalBeamDirCosX,
+                                          RichTbNominalBeamDirCosY,
+                                          RichTbNominalBeamDirCosZ);
+  
+}
+//=============================================================================
+// Destructor
+//=============================================================================
+RichTbBeamProperty::~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);
+  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);
+
+}
+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/G4RichTbSimH/src/srcmn/RichTbHit.cc b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbHit.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e2f776430ce32d4bedc818523de84e8d4a5b4810
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbHit.cc
@@ -0,0 +1,187 @@
+// $Id: $
+// 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 "RichTbVisManager.hh"
+G4Allocator<RichTbHit> RichTbHitAllocator;
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbHit
+//
+// 2003-12-12 : Sajan EASO
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbHit::RichTbHit(  ) {
+
+}
+//=============================================================================
+// Destructor
+//=============================================================================
+RichTbHit::~RichTbHit() {}
+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;
+  mPeOriginInPhSupport = right.mPeOriginInPhSupport;
+  mPhEmissionDir = right.mPhEmissionDir;
+  mPixelLocalCenter = right.mPixelLocalCenter;
+  mPixelGlobalCenter = right.mPixelGlobalCenter;
+  mTIRRadiatorCoord  = right.mTIRRadiatorCoord;
+  mMIRRadiatorCoord  = right.mMIRRadiatorCoord;
+  mRFRRadiatorCoord  = right.mRFRRadiatorCoord;
+  mMultipleReflFlag = right.mMultipleReflFlag;
+  mChTrackTotMom  = right.mChTrackTotMom;
+  mChTrackThreeMom = right.mChTrackThreeMom;
+  mHitInPixelGapFlag = right.mHitInPixelGapFlag;
+  
+}
+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;
+  mPeOriginInPhSupport = right.mPeOriginInPhSupport;
+  mPhEmissionDir = right.mPhEmissionDir;
+  mPixelLocalCenter = right.mPixelLocalCenter;
+  mPixelGlobalCenter = right.mPixelGlobalCenter;
+  mTIRRadiatorCoord  = right.mTIRRadiatorCoord;
+  mMIRRadiatorCoord  = right.mMIRRadiatorCoord;
+  mRFRRadiatorCoord  = right.mRFRRadiatorCoord;
+  mMultipleReflFlag = right.mMultipleReflFlag;
+  mChTrackTotMom  = right.mChTrackTotMom;
+  mChTrackThreeMom = right.mChTrackThreeMom;
+  mHitInPixelGapFlag = right.mHitInPixelGapFlag;
+  
+
+
+  return *this;
+ 
+}
+int RichTbHit::operator==(const RichTbHit &right) const
+{
+  return 0;
+}
+
+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);
+  }
+}
+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()
+{
+  // 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;
+  
+}
+// 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. 
+// Whenever a new Type is instantiated via G4Allocator, it has to be forward
+// declared to make object code (compiled with GNU g++) link successfully. 
+// 
+#ifdef GNU_GCC
+  template class G4Allocator<RichTbHit>;
+#endif
+
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbIOData.cc b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbIOData.cc
new file mode 100644
index 0000000000000000000000000000000000000000..274ea17b424ff22253e3f1ad99dbce5315ab0357
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbIOData.cc
@@ -0,0 +1,281 @@
+#include "RichTbIOData.hh"
+#include "Geant4/G4HCofThisEvent.hh"
+#include "Geant4/G4VHitsCollection.hh"
+#include "Geant4/G4SDManager.hh"
+#include "Geant4/G4ios.hh"
+#include "Geant4/G4ThreeVector.hh"
+#include "RichTbHit.hh"
+#include <fstream>
+#include "RichTbMiscNames.hh"
+#include "RichTbBeamProperty.hh"
+
+// CHANGED JDICKENS (02/06/05)
+#include "RichTbUpgradeMirror.hh"
+#include "RichTbGeometryParameters.hh"
+// END OF CHANGE
+
+
+RichTbIOData* RichTbIOData::RichTbIODataInstance=0;
+
+RichTbIOData::RichTbIOData( )
+:  OutputDataFS(((RichTbRunConfig::getRunConfigInstance())
+               ->getOutputFileName()).c_str()),
+  m_IsFirstEvent(true) {
+
+  RichTbRunConfig* RConfig = RichTbRunConfig::getRunConfigInstance();
+
+  //  OutputDataFS((RConfig->getOutputFileName()).c_str());
+  aOutFileString = RConfig->getOutputFileName();
+
+    //   const char* aOutFilechar = aOutFileString.c_str();
+
+    //    std::ofstream  OutputDataFS(aOutFileString.c_str());
+
+}
+
+
+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();
+  G4int aRadConf = RConfig->getRadiatorConfiguration();
+
+   // aBeamProperty->  PrintBeamProperty();
+
+  // CHANGED JDICKENS (02/06/05)
+  /*
+  RichTbUpgradeMirror* aMirror = RichTbUpgradeMirror::getRichTbUpgradeMirrorInstance();
+  G4ThreeVector MirrorCoC = aMirror->getMirrorCoC();
+  */
+  // END OF CHANGE
+
+  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));
+  }
+
+ if(RHC)
+  {
+    G4int n_hit = RHC->entries();
+    // G4cout << "     " << n_hit << "Hits being written out "<<G4endl;
+
+    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;
+
+
+      // CHANGED TO WRITE OUT MIRROR CoC (JDICKENS 02/06/05)
+      /*
+      //OutputDataFS << MirrorCoC.x() << "   "
+      //	   << MirrorCoC.y() << "   "
+      //	   << MirrorCoC.z() << "   "
+      //	   << MirrorInnerRadius << std::endl;
+      G4int MirrorCode = RConfig->getMirrorOrientCode();
+      G4double MirrorCoCX = MirrorPivotXInGlobalArray[MirrorCode] - MirrorInnerRadius * MirrorDirCosXArray[MirrorCode];
+      G4double MirrorCoCY = MirrorPivotYInGlobalArray[MirrorCode] - MirrorInnerRadius * MirrorDirCosYArray[MirrorCode];
+      G4double MirrorCoCZ = MirrorPivotZInGlobalArray[MirrorCode] - MirrorInnerRadius * MirrorDirCosZArray[MirrorCode];
+
+      OutputDataFS << MirrorCoCX << "  "
+		   << MirrorCoCY << "  "
+		   << MirrorCoCZ << "  "
+		   << MirrorInnerRadius << std::endl;
+      */
+      // END OF CHANGE
+
+      m_IsFirstEvent=false;
+
+    }
+
+    if( curVerboseOutputLevel  < 1 ) {
+
+      OutputDataFS<<n_hit<< 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();
+
+
+  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));
+  }
+
+ 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();
+      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;
+      }
+
+    }
+
+
+  }
+
+
+}
+
+RichTbIOData* RichTbIOData::getRichTbIODataInstance()
+{
+  if(  RichTbIODataInstance == 0) {
+    RichTbIODataInstance = new RichTbIOData();
+
+  }
+
+  return RichTbIODataInstance;
+
+
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbPmtPixelEfficiency.cc b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbPmtPixelEfficiency.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7e7b8890ffb09c7fd8628ba40548ecd1c2ab4ac6
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbPmtPixelEfficiency.cc
@@ -0,0 +1,277 @@
+// Include files
+
+
+#include <iostream>
+#include "Geant4/globals.hh"
+#include "Geant4/Randomize.hh"
+#include <cstdlib>
+#include <fstream>
+#include <sstream>
+
+// local
+#include "RichTbPmtPixelEfficiency.hh"
+#include "RichTbGeometryParameters.hh"
+#include "RichTbRunConfig.hh"
+
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbPmtPixelEfficiency
+//
+// 2015-03-11 : Sajan Easo
+// 2015-06-27 : Michele Blago modified for 2015 testbeam
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+
+RichTbPmtPixelEfficiency* RichTbPmtPixelEfficiency::RichTbPmtPixelEfficiencyInstance=0;
+
+
+//=============================================================================
+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();
+
+}
+
+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;
+
+
+			}
+
+		}
+
+	}
+
+}
+
+
+
+
+
+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);
+		}
+	}
+
+}
+
+
+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::getRichTbPmtPixelEfficiencyInstance() {
+	if(RichTbPmtPixelEfficiencyInstance == 0 ) {
+		RichTbPmtPixelEfficiencyInstance = new RichTbPmtPixelEfficiency();
+	}
+
+	return RichTbPmtPixelEfficiencyInstance;
+
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbRunAction.cc b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbRunAction.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2ff01dbe7eb450c7425468a1daf902ed72c0ab50
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbRunAction.cc
@@ -0,0 +1,81 @@
+// This code implementation is the intellectual property of
+// the GEANT4 collaboration.
+//
+// By copying, distributing or modifying the Program (or any work
+// based on the Program) you indicate your acceptance of this statement,
+// and all its terms.
+//
+
+// Make this appear first!
+#include "Geant4/G4Timer.hh"
+
+#include "RichTbRunAction.hh"
+
+#include "Geant4/G4ios.hh"
+#include "Geant4/G4Run.hh"
+#include "Geant4/G4UImanager.hh"
+#include "RichTbAnalysisManager.hh"
+#include "RichTbCounter.hh"
+#include "RichTbBeamProperty.hh"
+
+RichTbRunAction::RichTbRunAction()
+{
+
+    timer = new G4Timer;
+            ranalysisManager = RichTbAnalysisManager::getInstance();
+
+       ranalysisManager->BeginOfRunAnalysis();
+
+  // now for the counters
+
+  RichTbCounter* aRichCounter =  
+        RichTbCounter::getRichTbCounterInstance();
+
+}
+
+
+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");
+
+    G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
+
+    timer->Start();
+
+    //    ranalysisManager = RichTbAnalysisManager::getInstance();
+
+    //    ranalysisManager->BeginOfRunAnalysis();
+    // initialise the beam property.
+
+    RichTbBeamProperty* aBeamProperty= 
+       RichTbBeamProperty::getRichTbBeamPropertyInstance();
+    
+}
+
+
+void RichTbRunAction::EndOfRunAction(const G4Run * aRun)
+{
+
+      ranalysisManager = RichTbAnalysisManager::getInstance();
+
+      ranalysisManager->EndOfRunAnalysis();
+
+    timer->Stop();
+    G4cout << "number of event = " << aRun->GetNumberOfEvent()
+        << " " << *timer << G4endl;
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbRunActionccSave b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbRunActionccSave
new file mode 100644
index 0000000000000000000000000000000000000000..c087be1a47f2f1f114a5dd4d0ab0ed6d6296af81
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbRunActionccSave
@@ -0,0 +1,77 @@
+// This code implementation is the intellectual property of
+// the GEANT4 collaboration.
+//
+// By copying, distributing or modifying the Program (or any work
+// based on the Program) you indicate your acceptance of this statement,
+// and all its terms.
+//
+
+// Make this appear first!
+#include "Geant4/G4Timer.hh"
+
+#include "RichTbRunAction.hh"
+
+#include "Geant4/G4ios.hh"
+#include "Geant4/G4Run.hh"
+#include "Geant4/G4UImanager.hh"
+#include "RichTbAnalysisManager.hh"
+#include "RichTbCounter.hh"
+#include "RichTbBeamProperty.hh"
+
+RichTbRunAction::RichTbRunAction()
+{
+
+    timer = new G4Timer;
+        ranalysisManager = RichTbAnalysisManager::getInstance();
+
+      ranalysisManager->BeginOfRunAnalysis();
+
+  // now for the counters
+
+  RichTbCounter* aRichCounter =  
+        RichTbCounter::getRichTbCounterInstance();
+
+}
+
+
+RichTbRunAction::~RichTbRunAction()
+{
+    delete timer;
+}
+
+
+void RichTbRunAction::BeginOfRunAction(const G4Run * aRun)
+{
+    G4UImanager *UI = G4UImanager::GetUIpointer();
+    UI->ApplyCommand("/run/verbose 2");
+    UI->ApplyCommand("/event/verbose 0");
+    UI->ApplyCommand("/tracking/verbose 0");
+    UI->ApplyCommand("/particle/process/verbose 0");
+    UI->ApplyCommand("/control/verbose 0");
+
+    G4cout << "### Run " << aRun->GetRunID() << " start." << G4endl;
+
+    timer->Start();
+
+    //    ranalysisManager = RichTbAnalysisManager::getInstance();
+
+    //    ranalysisManager->BeginOfRunAnalysis();
+    // initialise the beam property.
+
+    RichTbBeamProperty* aBeamProperty= 
+       RichTbBeamProperty::getRichTbBeamPropertyInstance();
+    
+}
+
+
+void RichTbRunAction::EndOfRunAction(const G4Run * aRun)
+{
+
+    ranalysisManager = RichTbAnalysisManager::getInstance();
+
+    ranalysisManager->EndOfRunAnalysis();
+
+    timer->Stop();
+    G4cout << "number of event = " << aRun->GetNumberOfEvent()
+        << " " << *timer << G4endl;
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbRunConfig.cc b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbRunConfig.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9c20ed21b577f09ceca79d386b0bb2fee165588c
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbRunConfig.cc
@@ -0,0 +1,477 @@
+#include <iostream>
+#include <fstream>
+#include "RichTbRunConfig.hh"
+#include "RichTbMaterialParameters.hh"
+#include "Geant4/globals.hh"
+#include "RichTbGeometryParameters.hh"
+
+RichTbRunConfig *RichTbRunConfig::RunConfigInstance = 0;
+
+RichTbRunConfig::RichTbRunConfig()
+: 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("G4RICHTBSIMHROOT")) + "/";
+ 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()
+{
+
+    if (RunConfigInstance == 0) {
+        RunConfigInstance = new RichTbRunConfig();
+    }
+
+    return RunConfigInstance;
+
+}
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbSD_cc b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbSD_cc
new file mode 100644
index 0000000000000000000000000000000000000000..78fde08f5da21050bd61bd25f8edc22475edf240
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbSD_cc
@@ -0,0 +1,228 @@
+// $Id: $
+// Include files 
+
+
+
+// local
+#include "RichTbSD.hh"
+#include "RichTbHit.hh"
+#include "RichTbGeometryParameters.hh"
+#include "Geant4/G4Step.hh"
+#include "Geant4/G4HCofThisEvent.hh"
+#include "Geant4/G4Track.hh"
+#include "Geant4/G4SDManager.hh"
+#include "Geant4/G4ios.hh"
+#include "Geant4/G4TouchableHistory.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbUserTrackInfo.hh"
+#include "RichTbPhotoElectron.hh"
+#include "Geant4/G4TransportationManager.hh"
+#include "Geant4/G4Navigator.hh"
+#include "RichTbUserTrackInfo.hh"
+#include "Geant4/G4VProcess.hh"
+#include "RichTbMiscNames.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbSD
+//
+// 2003-12-12 : Sajan EASO
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbSD::RichTbSD(G4String DetName, G4String CollectionName  )
+:G4VSensitiveDetector(DetName),
+ HpdSDID(std::vector<G4int>( NumHpds,-1)),HCID(-1) {
+  G4String HCname;
+  collectionName.insert(HCname=CollectionName);
+
+}
+//=============================================================================
+// Destructor
+//=============================================================================
+RichTbSD::~RichTbSD() {}
+
+//=============================================================================
+void RichTbSD::Initialize(G4HCofThisEvent* HCE)
+{
+  RichTbHitCollection = new RichTbHitsCollection(SensitiveDetectorName,collectionName[0]); 
+
+  for(G4int ipx = 0; ipx < (int) HpdSDID.size(); ipx++) 
+    {
+      HpdSDID[ipx]=-1;
+    }
+
+  RichTbRunConfig* aRunConfig =  RichTbRunConfig::getRunConfigInstance();
+  CurrentHitCreationOption= aRunConfig->getHitCreationOption();
+}
+         
+         
+G4bool RichTbSD::ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist)
+{
+   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();
+  G4VPhysicalVolume* ROphysVol = ROhist -> GetVolume();
+  G4int CurrentPixelNumber =  ROphysVol->GetCopyNo();
+
+  
+  //   G4cout<<" RichTbSD Hpd VolName number = "
+  //     <<curnameVol<<"  "<<CurrentHpdNumber<<G4endl;
+  
+  G4int CopyId = CurrentPixelNumber + CurrentHpdNumber * NumPixelTotInSingleHpd;
+  // Create hit only if the pixel is not already hit in the same event.
+  // depending upon the flag set.
+
+    
+  if( (CurrentHitCreationOption==0 &&  HpdSDID[CopyId ] == -1) || 
+      (CurrentHitCreationOption==1 )) {
+    //            G4cout<<"Now storing a new hit with edep hpd pix "
+    //      <<edep<<"   "<<CurrentHpdNumber<<"    "
+    //      << CurrentPixelNumber<<G4endl;
+        
+
+    G4ThreeVector CurGlobalPos =aStep->GetPreStepPoint()->GetPosition();
+  
+    G4Navigator* theNavigator =
+      G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
+    
+    G4ThreeVector CurLocalPos = theNavigator->GetGlobalToLocalTransform().TransformPoint(CurGlobalPos );
+    
+    // CHANGED JDICKENS (28/07/05)
+    // PRINT theNavigator properties
+    //     G4RotationMatrix Rot = theNavigator->GetGlobalToLocalTransform().NetRotation();
+    //     G4ThreeVector Vec = theNavigator->GetGlobalToLocalTransform().NetTranslation();
+    //     G4RotationMatrix Rot = theNavigator->GetLocalToGlobalTransform().NetRotation();
+    //     G4ThreeVector Vec = theNavigator->GetLocalToGlobalTransform().NetTranslation();
+    
+    //     G4ThreeVector RotX = Rot.rowX();
+    //     G4ThreeVector RotY = Rot.rowY();
+    //     G4ThreeVector RotZ = Rot.rowZ();
+    
+    
+    //     G4cout << "Rotation MatrixX:\t" << RotX.x() << "\t" << RotX.y() << "\t" << RotX.z() << G4endl;
+    //     G4cout << "Rotation MatrixY:\t" << RotY.x() << "\t" << RotY.y() << "\t" << RotY.z() << G4endl;
+    //     G4cout << "Rotation MatrixZ:\t" << RotZ.x() << "\t" << RotZ.y() << "\t" << RotZ.z() << G4endl;
+    
+    //     G4cout << "Translation Vec: \t" << Vec.x() << "\t" << Vec.y() << "\t" << Vec.z() << G4endl;
+    // END OF CHANGE    
+
+    G4ThreeVector aPeOrigin;
+    G4ThreeVector aPhOrigin;
+    G4int aRayleighFlag=0;
+    G4ThreeVector aPhIncidenceHpdQW;
+    G4int aPhHpdIncidenceNum=0;
+    G4double aCkvCosTh=0.0;
+    G4double aCkvPhi=0.0;
+    G4double aPhEner=0.0;
+    G4ThreeVector aPeOrginInPhSup;
+    G4ThreeVector aPhEmisDir;    
+    
+  G4Track* aTrack = aStep->GetTrack();
+  G4String aCreatorProcessName = "NullProcess";
+  const G4VProcess* aProcess = aTrack->GetCreatorProcess();
+  if(aProcess) aCreatorProcessName =  aProcess->GetProcessName();
+  if((aTrack->GetDefinition() == RichTbPhotoElectron::PhotoElectron()) &&
+     (aCreatorProcessName  ==PixelHpdPhotElectProc ))
+  {
+    aPeOrigin=aTrack->GetVertexPosition();
+
+   G4VUserTrackInformation* aUserTrackinfo=aTrack->GetUserInformation();
+   RichTbUserTrackInfo* aPeTrackUserInfo=
+                  (RichTbUserTrackInfo*) aUserTrackinfo ;
+           
+   if(aPeTrackUserInfo && aPeTrackUserInfo-> HasUserPEInfo()) {
+
+     RichTbPEInfo* aPeInfo = aPeTrackUserInfo-> getRichTbPEInfo();
+     
+     if( aPeInfo) {
+        
+       aPhOrigin= aPeInfo -> PhOrigin();
+       aPeOrginInPhSup=aPeInfo -> PeOriginInHpdSupFrame();
+       aPhEmisDir=  aPeInfo-> getPhotEmisDir();
+  
+
+       RichTbPhotonInfo* aPhotonInfo = aPeInfo ->  MotherPhotonInfo();
+       if( aPhotonInfo ) {
+        
+         aRayleighFlag=aPhotonInfo-> NumRayleighScat();
+         aPhIncidenceHpdQW= aPhotonInfo-> PhotonCoordHpdQWExternal();
+         aPhHpdIncidenceNum=aPhotonInfo->  PhotonHpdQWMultipleIncidenceFlag() ;
+         aCkvCosTh=aPhotonInfo->CkvCosThetaAtProd();
+         aCkvPhi= aPhotonInfo-> CkvPhiAtProd();
+         aPhEner= aPhotonInfo->  CkvPhotonEnergyAtProd() ;
+         // G4cout<<"RichTbSD: PhotQW   aPhHpdIncidenceNum Phener "
+         //      <<  aPhIncidenceHpdQW.x() <<"  "<<  aPhIncidenceHpdQW.y()
+         //      <<"   "<<  aPhIncidenceHpdQW.z()<<"   "
+         //      << aPhHpdIncidenceNum<<"   "<<aPhEner<<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 -> SetRayleighScatFlag( aRayleighFlag);
+  newHit -> SetPhotonIncidenceOnHpdQW( aPhIncidenceHpdQW);
+  newHit ->  SetPhotonMultIncidenceQW( aPhHpdIncidenceNum);
+  newHit -> SetCkvCosThetaProd( aCkvCosTh);
+  newHit -> SetCkvPhiProd( aCkvPhi);
+  newHit ->SetCkvEnergyProd(  aPhEner);
+  newHit ->SetPeOriginInPhSupport(aPeOrginInPhSup);
+  newHit ->  SetPhEmissionDir( aPhEmisDir);
+  
+  G4int NumHits = RichTbHitCollection->insert( newHit );
+  HpdSDID[CopyId]= NumHits -1 ;
+  
+  }else {
+    // the current pixel is already hit in this event.
+    // here we can add extra energy (adc counts) to the 
+    // existing hit. But this may  not be relevant to the
+    // current Tb analysis.
+     (*RichTbHitCollection)[HpdSDID[CopyId]]->AddEdep( edep );
+         G4cout << " Multiple hits in Hpd sector pixel " << CurrentHpdNumber  
+           <<"   "<< CurrentPixelNumber<< G4endl;
+
+  }
+  
+ return true;  
+
+}
+void  RichTbSD::EndOfEvent(G4HCofThisEvent*HCE){
+  if( HCID < 0 ){
+    HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
+    HCE->AddHitsCollection( HCID, RichTbHitCollection );    
+
+}
+void  RichTbSD::clear(){} 
+
+void   RichTbSD::DrawAll(){ } 
+
+void   RichTbSD::PrintAll(){ } 
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbUpgradeHpdSD.cc b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbUpgradeHpdSD.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4ac3ac09d170e3774d50729c67fb186a309ae3e0
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbUpgradeHpdSD.cc
@@ -0,0 +1,232 @@
+// 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/G4SDManager.hh"
+#include "Geant4/G4ios.hh"
+#include "Geant4/G4TouchableHistory.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbUserTrackInfo.hh"
+#include "RichTbPhotoElectron.hh"
+#include "Geant4/G4TransportationManager.hh"
+#include "Geant4/G4Navigator.hh"
+#include "RichTbUserTrackInfo.hh"
+#include "Geant4/G4VProcess.hh"
+#include "RichTbMiscNames.hh"
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : RichTbUpgradeHpdSD
+//
+// 2015-05-15 : Sajan Easo
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// Standard constructor, initializes variables
+//=============================================================================
+RichTbUpgradeHpdSD::RichTbUpgradeHpdSD(G4String DetName):G4VSensitiveDetector(DetName),
+                                                         HpdSDID(std::vector<G4int>(NumHpds*NumPixelTotInSingleHpd , -1)),HCID(-1)
+{
+
+  //  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;
+  
+
+
+}
+
+//=============================================================================
+// Destructor
+//=============================================================================
+RichTbUpgradeHpdSD::~RichTbUpgradeHpdSD() {} 
+
+//=============================================================================
+void RichTbUpgradeHpdSD::Initialize(G4HCofThisEvent*  HCE   ) {
+  //   G4cout<<" Now init  RichTbUpgradeSD Hpd "<<G4endl;
+
+     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 );    
+
+  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  */){
+  //  if( HCID < 0 ){
+  //  HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[RichTbHitCollIndex]); }
+  //  HCE->AddHitsCollection( HCID, RichTbHitCollectionHpd );    
+
+}
+
+G4bool RichTbUpgradeHpdSD::ProcessHits(G4Step*aStep,G4TouchableHistory*ROhist) {
+
+  //  G4cout<<" Now in hpd SD process hits   "<< ROhist <<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 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;
+    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();
+    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;
+    
+
+  }
+  
+  
+  return true;  
+  
+}
+                                             
+                                             
+                                             
+
+
+
+void  RichTbUpgradeHpdSD::clear(){} 
+
+void   RichTbUpgradeHpdSD::DrawAll(){ } 
+
+void   RichTbUpgradeHpdSD::PrintAll(){ } 
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbUpgradeSD.cc b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbUpgradeSD.cc
new file mode 100644
index 0000000000000000000000000000000000000000..07c671525413103edf81ae6e9925955c15ad973a
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcmn/RichTbUpgradeSD.cc
@@ -0,0 +1,301 @@
+// $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/G4SDManager.hh"
+#include "Geant4/G4ios.hh"
+#include "Geant4/G4TouchableHistory.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbUserTrackInfo.hh"
+#include "RichTbPhotoElectron.hh"
+#include "Geant4/G4TransportationManager.hh"
+#include "Geant4/G4Navigator.hh"
+#include "RichTbUserTrackInfo.hh"
+#include "Geant4/G4VProcess.hh"
+#include "RichTbMiscNames.hh"
+#include "RichTbPmtPixelEfficiency.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;
+}
+
+//=============================================================================
+// Destructor
+//=============================================================================
+RichTbUpgradeSD::~RichTbUpgradeSD() {}
+//=============================================================================
+
+void RichTbUpgradeSD::Initialize(G4HCofThisEvent*  HCE )
+{
+
+	//  G4cout<<" Now init  RichTbUpgradeSD "<<collectionName[0]<<  G4endl;
+
+
+	RichTbHitCollection = new RichTbHitsCollection(SensitiveDetectorName,collectionName[0]);
+
+	// RichTbHitCollection = new RichTbHitsCollection(RichTbSensDetName,collectionName[0]);
+
+	//  G4cout<<" RichTbUpgradeSD : Created RichTbHitCollection with "<< collectionName[0]  <<G4endl;
+
+	if( HCID < 0 ){
+		HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
+	}
+	//  G4cout<<" RichTbUpgradeSD : HCID "<<HCID<<G4endl;
+
+	HCE->AddHitsCollection( HCID, RichTbHitCollection );
+
+	// G4cout<<" RichTbUpgradeSD : HCID hitcolladded "<<HCID<<G4endl;
+
+
+	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;
+
+}
+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;
+}
+
+
+void  RichTbUpgradeSD::clear(){}
+
+void   RichTbUpgradeSD::DrawAll(){ }
+
+void   RichTbUpgradeSD::PrintAll(){ }
+
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcph/HpdSiEnergyLoss.cc b/LHCbG4Tests/G4RichTbSimH/src/srcph/HpdSiEnergyLoss.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e179542cfbb6773332d194ccfb66c5f1f54b843c
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcph/HpdSiEnergyLoss.cc
@@ -0,0 +1,275 @@
+// $Id: $
+// Include files 
+#include "Geant4/globals.hh"
+#include "Geant4/G4Material.hh"
+#include "Geant4/Randomize.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"
+// local
+#include "HpdSiEnergyLoss.hh"
+#include "RichTbPhotoElectron.hh"
+#include "RichTbPeUserInfoAttach.hh"
+//-----------------------------------------------------------------------------
+// Implementation file for class : HpdSiEnergyLoss
+//
+// 2003-12-10 : Sajan EASO
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// 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()) ;
+  //  G4cout<<"Hpd Si 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<<"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();
+      //  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;
+  }
+     G4cout<<GetProcessName() <<" is created "<<G4endl;
+  
+
+}
+//=============================================================================
+// Destructor
+//=============================================================================
+HpdSiEnergyLoss::~HpdSiEnergyLoss() {}
+G4bool HpdSiEnergyLoss::IsApplicable(const G4ParticleDefinition& 
+                                     aParticleType) {
+   return(aParticleType.GetPDGCharge()!= 0.);
+}
+
+G4double HpdSiEnergyLoss::GetContinuousStepLimit(const G4Track& track,
+                                                 G4double /* previousStepSize */,
+                                                 G4double /* currentMinimumStep */,
+                                                 G4double& /* currentSafety*/){
+
+  G4double  RangeForStep =  finalRangeforStep;
+
+  if( ( fMatIndex != (int) track.GetMaterial() -> GetIndex()) && 
+      ( fMatIndexK != (int) track.GetMaterial() -> GetIndex()) ) { 
+    RangeForStep = DBL_MAX;
+  }
+    
+   
+  return RangeForStep;
+
+}
+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) {
+  // Do nothing
+   aParticleChange.Initialize(aTrack) ;
+  return G4VContinuousDiscreteProcess::PostStepDoIt(aTrack,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();
+  // G4String aMaterialName =  aTrack.GetMaterial()->GetName();
+  // G4cout<<" HpdSiEnergyLoss  fmatindex fmatindexK  material index "<< fMatIndex <<"  "
+  //      << fMatIndexK <<"   "<< aMaterialIndex <<"  "<< aMaterialName <<G4endl;
+  
+
+  // if( ( fMatIndex != (int) aTrack.GetMaterial()->GetIndex() ) && 
+  //     (fMatIndexK != (int) aTrack.GetMaterial()->GetIndex()  ) ) {
+  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;
+    }
+
+    // if( aCreatorProcessName != HpdPhotElectProc )   G4cout<<" Hpd energy loss proc  " << aCreatorProcessName <<G4endl;
+    
+    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( aCreatorProcessName != HpdPhotElectProc )G4cout<<" backsca energy loss "<<Eloss <<G4endl;
+  
+
+  aKinEnergyFinal=aKinEnergyInit-Eloss;
+
+  //Now implement the back scattering in an ad hoc manner.
+
+  //  G4double Effs = 1.0 -  backscaprob * bckKillFactor;
+  G4double Effs = HpdelectronicsDetAbsEff;
+  
+  //  if( aNonOptimalHpdCondition >= 1 ) 
+  //  {
+  //    Effs =  aNonOptimalHpdAbsEff;
+  //   }
+
+//   G4cout << "Back scattering: " << Effs << G4endl;
+  
+  //  G4cout<<"Hpd Si energy loss Effs "<< Effs<<G4endl;
+
+  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);
+
+
+
+          G4Track* aTaggedSecPETrack = RichTbPeBckAttach(aTrack,aSecPETrack );
+          // G4cout<<"Created a backsca electron "<<G4endl;
+          
+          aParticleChange.AddSecondary(aTaggedSecPETrack);
+          //kill old pe
+          aParticleChange.ProposeTrackStatus(fStopAndKill);
+          aParticleChange.ProposeEnergy(0.0);
+
+         }
+         
+      }
+      
+         
+      }
+      
+
+
+
+    }
+  
+  //  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);
+    }
+
+
+  
+
+  return &aParticleChange;
+}
+
+//=============================================================================
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcph/PixelHpdPhotoElectricEffect.cc b/LHCbG4Tests/G4RichTbSimH/src/srcph/PixelHpdPhotoElectricEffect.cc
new file mode 100644
index 0000000000000000000000000000000000000000..90928d0a35823d6d3b31b10ee0d2774d0fe53b42
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcph/PixelHpdPhotoElectricEffect.cc
@@ -0,0 +1,260 @@
+// Include files 
+
+#include "Geant4/globals.hh"
+#include <math.h>
+#include <vector>
+#include "PixelHpdPhotoElectricEffect.hh"
+#include "RichTbGeometryParameters.hh"
+#include "Geant4/G4TransportationManager.hh"
+#include "Geant4/Randomize.hh"
+#include "RichTbAnalysisManager.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbMaterialParameters.hh"
+#include "Geant4/G4TouchableHistory.hh"
+#include "RichTbPhotoElectron.hh"
+#include "RichTbPeUserInfoAttach.hh"
+
+
+// local
+
+//-----------------------------------------------------------------------------
+// Implementation file for class : PixelHpdPhotoElectricEffect
+//
+// 2015-05-10 : Sajan Easo
+//-----------------------------------------------------------------------------
+
+//=============================================================================
+// 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();
+  PrePhotoElectricVolName = HpdQuartzWMaterialName;
+  PostPhotoElectricVolName = HpdPhCathodeMaterialName;
+  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;
+	      
+       }
+
+
+      }
+      
+  }
+  
+  
+  
+   G4cout<<GetProcessName() <<" is created "<<G4endl;
+
+}
+//=============================================================================
+// Destructor
+//=============================================================================
+PixelHpdPhotoElectricEffect::~PixelHpdPhotoElectricEffect() {} 
+
+//=============================================================================
+G4bool PixelHpdPhotoElectricEffect::IsApplicable(const G4ParticleDefinition& aParticleType)
+{
+  return ( &aParticleType == G4OpticalPhoton::OpticalPhoton() );
+}
+
+
+G4double PixelHpdPhotoElectricEffect::GetMeanFreePath(const G4Track& ,
+                                                      G4double ,
+                                                      G4ForceCondition* condition)
+{
+  *condition = Forced;
+
+  return DBL_MAX;
+}
+G4VParticleChange* PixelHpdPhotoElectricEffect::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() -> 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();
+  G4double PhotonEnergy = aDynamicPhoton->GetKineticEnergy();
+
+  if(PhotonEnergy <= 0.0 ){
+      return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+  }
+  
+
+  //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   )
+    return G4VDiscreteProcess::PostStepDoIt(aTrack, aStep);
+
+  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);
+    aParticleChange.ProposeTrackStatus(fStopAndKill);
+    aParticleChange.ProposeEnergy(0.0);
+  
+    } else {
+
+    //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;
+  //  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++;
+  }
+
+  }
+
+
+  return qeff;
+
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcph/PmtAnodeEnergyLoss.cc b/LHCbG4Tests/G4RichTbSimH/src/srcph/PmtAnodeEnergyLoss.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3ee56b32b10308a0235daf31aadf745043e1ee21
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcph/PmtAnodeEnergyLoss.cc
@@ -0,0 +1,208 @@
+// $Id: $
+// Include files
+
+#include "Geant4/G4Material.hh"
+#include "Geant4/Randomize.hh"
+#include "RichTbMaterialParameters.hh"
+#include "Geant4/G4VProcess.hh"
+#include "RichTbRunConfig.hh"
+
+#include "Geant4/G4TouchableHistory.hh" //test
+
+// local
+#include "PmtAnodeEnergyLoss.hh"
+
+//=============================================================================
+// 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;
+    }
+    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;
+    }
+    iMatK++;
+
+  }
+
+  if(iMat > numberOfMat ||  iMatK >  numberOfMat ) {
+    G4cout << "Invalid material Name in PmtAnodeEnergyLoss constructor" <<G4endl ;
+  }
+     G4cout<<GetProcessName() <<" is created "<<G4endl;
+
+
+ }
+
+
+PmtAnodeEnergyLoss::~PmtAnodeEnergyLoss() {}
+
+
+G4bool PmtAnodeEnergyLoss::IsApplicable(const G4ParticleDefinition&
+                                     aParticleType) {
+   return(aParticleType.GetPDGCharge()!= 0.);
+}
+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()  ) ) {
+    return &aParticleChange;
+  }
+  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;
+
+    if( aCreatorProcessName ==  PmtPhotElectProc) {
+      aKinEnergyInit = aKinEnergyInitParticle/100000;
+
+      if( fMatIndexK ==   (G4int) aTrack.GetMaterial() -> GetIndex()){
+
+       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; }
+
+
+   //  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);
+    }
+
+
+
+ return &aParticleChange;
+
+
+}
+
+G4VParticleChange*  PmtAnodeEnergyLoss::PostStepDoIt(const G4Track& aTrack,
+                                 const G4Step& aStep) {
+  // Do nothing
+   aParticleChange.Initialize(aTrack) ;
+  return G4VContinuousDiscreteProcess::PostStepDoIt(aTrack,aStep);
+
+}
+
+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  RangeForStep =  finalRangeforStep;
+
+  if( ( fMatIndex != (int) track.GetMaterial() -> GetIndex()) &&
+      ( fMatIndexK != (int) track.GetMaterial() -> GetIndex()) ) {
+    RangeForStep = DBL_MAX;
+  }
+
+
+  return RangeForStep;
+
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcph/PmtPhotoElectricEffect.cc b/LHCbG4Tests/G4RichTbSimH/src/srcph/PmtPhotoElectricEffect.cc
new file mode 100644
index 0000000000000000000000000000000000000000..dbe9266e78eac1e1ace0014873db83cead47d106
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcph/PmtPhotoElectricEffect.cc
@@ -0,0 +1,232 @@
+#include "Geant4/globals.hh"
+#include <math.h>
+#include <vector>
+#include "PmtPhotoElectricEffect.hh"
+#include "RichTbGeometryParameters.hh"
+#include "Geant4/G4TransportationManager.hh"
+#include "Geant4/Randomize.hh"
+#include "RichTbAnalysisManager.hh"
+#include "RichTbRunConfig.hh"
+#include "RichTbMaterialParameters.hh"
+#include "Geant4/G4TouchableHistory.hh"
+#include "RichTbPhotoElectron.hh"
+#include "RichTbPeUserInfoAttach.hh"
+#include "RichTbMiscNames.hh"
+
+
+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;
+
+
+	PrePhotoElectricVolName = PMTQwLogVolName;
+	PostPhotoElectricVolName = PMTPhCathLogVolName;
+	//PmtPhElectronMomentum = 2 * CLHEP::GeV;
+	PmtPhElectronMomentum = ( rConfig->getPMTPEMomInit() ) * CLHEP::keV;
+	PhCathodeToSilDetDist = PMTQuartzToAnodeSurfaceDistance;
+
+	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++)
+		{
+
+			PmtQE[ipmt][iqbin]=qeCurPmt[iqbin]/100;
+			PmtWabin[ipmt][iqbin]=waCurPmt[iqbin];
+		}
+
+	}
+
+	G4cout<<"PMT Photoelectic process created "<<G4endl;
+
+}
+
+PmtPhotoElectricEffect::~PmtPhotoElectricEffect(){}
+
+
+G4bool PmtPhotoElectricEffect::IsApplicable(const G4ParticleDefinition& aParticleType)
+{
+	return ( &aParticleType == G4OpticalPhoton::OpticalPhoton() );
+}
+
+G4double PmtPhotoElectricEffect::GetMeanFreePath(const G4Track& ,
+		G4double ,
+		G4ForceCondition* condition)
+{
+	*condition = Forced;
+
+	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);
+}
+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/G4RichTbSimH/src/srcph/RichTbPhotoElectron.cc b/LHCbG4Tests/G4RichTbSimH/src/srcph/RichTbPhotoElectron.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3f7f625a82db42362757bfb5987a72ebddf57ec9
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcph/RichTbPhotoElectron.cc
@@ -0,0 +1,121 @@
+//
+// ********************************************************************
+// * DISCLAIMER                                                       *
+// *                                                                  *
+// * The following disclaimer summarizes all the specific disclaimers *
+// * of contributors to this software. The specific disclaimers,which *
+// * govern, are listed with their locations in:                      *
+// *   http://cern.ch/geant4/license                                  *
+// *                                                                  *
+// * Neither the authors of this software system, nor their employing *
+// * institutes,nor the agencies providing financial support for this *
+// * work  make  any representation or  warranty, express or implied, *
+// * regarding  this  software system or assume any liability for its *
+// * use.                                                             *
+// *                                                                  *
+// * This  code  implementation is the  intellectual property  of the *
+// * GEANT4 collaboration.                                            *
+// * By copying,  distributing  or modifying the Program (or any work *
+// * based  on  the Program)  you indicate  your  acceptance of  this *
+// * statement, and all its terms.                                    *
+// ********************************************************************
+//
+//
+// $Id: RichTbPhotoElectron.cpp,v 1.3 2003/08/05 11:50:18 witoldp Exp $
+// GEANT4 tag $Name:  $
+// 
+// 
+// ----------------------------------------------------------------------
+//      GEANT 4 class implementation file
+//
+//      History: first implementation, based on object model of
+//      4th April 1996, G.Cosmo
+// **********************************************************************
+//  Added particle definitions, H.Kurashige, 19 April 1996
+//  Added SetCuts implementation, L.Urban, 30 May 1996
+//  Revised, G.Cosmo, 6 June 1996
+//  Code uses operators (+=, *=, ++, -> etc.) correctly, P. Urban, 26/6/96
+//  Add ElectronDefinition() H.Kurashige 4 July 1996
+// ----------------------------------------------------------------------
+// RichTbPhotoelectron created by SE 10-3-2003.
+//
+//#include "Geant4/G4std/fstream"
+//#include "Geant4/G4std/iomanip"
+    
+//#include "Geant4/G4Electron.hh"
+
+#include "Geant4/G4ParticleTable.hh"
+#include "RichTbPhotoElectron.hh"
+// ######################################################################
+// ###                         RICHTBPHOTOELECTRON                      ###
+// ######################################################################
+
+
+RichTbPhotoElectron* RichTbPhotoElectron::theRichTbPhotoElectronInstance=0;
+
+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"
+              );
+
+    // Bohr Magnetron
+   //   G4double muB =  -0.5*CLHEP::eplus*hbar_Planck/(0.51099906*CLHEP::MeV/c_squared) ;
+   //
+   // anInstance->SetPDGMagneticMoment( muB * 1.0011596521859 );
+
+
+  }
+  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();
+}
+ 
+
+
+
+
+
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcph/RichTbPhysicsList.cc b/LHCbG4Tests/G4RichTbSimH/src/srcph/RichTbPhysicsList.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5f8567199112285492d80ab0109d77697b0b059e
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcph/RichTbPhysicsList.cc
@@ -0,0 +1,381 @@
+#include "Geant4/G4ios.hh"
+
+#include "Geant4/globals.hh"
+#include "RichTbPhysicsList.hh"
+#include "RichTbPhotoElectron.hh"
+
+#include "Geant4/G4ParticleDefinition.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/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;
+
+    // set energy range for SetCut calculation
+    // G4ParticleWithCuts::SetEnergyRange(0.99*CLHEP::keV, 100*TeV);
+
+    // pointer to the particle table
+    theParticleTable = G4ParticleTable::GetParticleTable();
+    theParticleIterator = theParticleTable->GetIterator();
+
+    // UI Messenger
+    //  theMessenger = new G4UserPhysicsListMessenger(this);
+
+    //  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::ConstructBosons()
+{
+    // pseudo-particles
+    G4Geantino::GeantinoDefinition();
+    G4ChargedGeantino::ChargedGeantinoDefinition();
+
+    // gamma
+    G4Gamma::GammaDefinition();
+
+    // 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::ConstructMesons()
+{
+    //  mesons
+    G4PionPlus::PionPlusDefinition();
+    G4PionMinus::PionMinusDefinition();
+    G4PionZero::PionZeroDefinition();
+}
+
+
+void RichTbPhysicsList::ConstructBaryons()
+{
+    //  barions
+    G4Proton::ProtonDefinition();
+    G4AntiProton::AntiProtonDefinition();
+    G4Neutron::NeutronDefinition();
+    G4AntiNeutron::AntiNeutronDefinition();
+}
+
+
+void RichTbPhysicsList::ConstructProcess()
+{
+    AddTransportation();
+    ConstructGeneral();
+    ConstructEM();
+    ConstructOp();
+}
+
+
+#include "Geant4/G4Decay.hh"
+
+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);
+
+        }
+    }
+}
+
+
+
+#include "Geant4/G4ComptonScattering.hh"
+#include "Geant4/G4GammaConversion.hh"
+#include "Geant4/G4PhotoElectricEffect.hh"
+
+//#include "Geant4/G4MultipleScattering.hh"
+
+#include "Geant4/G4eMultipleScattering.hh"
+#include "Geant4/G4hMultipleScattering.hh"
+#include "Geant4/G4MuMultipleScattering.hh"
+
+
+#include "Geant4/G4eIonisation.hh"
+#include "Geant4/G4eBremsstrahlung.hh"
+#include "Geant4/G4eplusAnnihilation.hh"
+
+#include "Geant4/G4MuIonisation.hh"
+#include "Geant4/G4MuBremsstrahlung.hh"
+#include "Geant4/G4MuPairProduction.hh"
+
+#include "Geant4/G4hIonisation.hh"
+
+void RichTbPhysicsList::ConstructEM()
+{
+  G4cout << " Now creating EM processes" << G4endl;
+
+  theParticleIterator->reset();
+  while( (*theParticleIterator)() ){
+    G4ParticleDefinition* particle = theParticleIterator->value();
+    G4ProcessManager* pmanager = particle->GetProcessManager();
+    G4String particleName = particle->GetParticleName();
+    if (particleName == "gamma") {
+    // gamma
+      // Construct processes for gamma
+       pmanager->AddDiscreteProcess(new G4GammaConversion("conv"));
+       pmanager->AddDiscreteProcess(new G4ComptonScattering("compt"));
+//      pmanager->AddDiscreteProcess(new G4PhotoElectricEffect());
+
+    } else if (particleName == "e-") {
+    //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);
+
+    } else if (particleName == "e+") {
+    //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);
+
+    } 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);
+
+      }
+    }
+  }
+
+  G4cout << " End of creating EM processes" << G4endl;
+
+}
+#include "RichTbMiscNames.hh"
+#include "RichTbRunConfig.hh"
+
+#include "RichTbG4Cerenkov.hh"
+#include "Geant4/G4Scintillation.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");
+
+   HpdSiEnergyLoss * theHpdSiEnergyLossProcess = (aRadiatorConfiguration == 2 ) ?
+     new  HpdSiEnergyLoss("HpdSiEnergyLoss") : 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);
+                  }
+
+                }
+
+
+
+
+
+
+
+
+       //    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:";
+    }
+    //  " G4VUserPhysicsList::SetCutsWithDefault" method sets
+    //   the default cut value for all particle types
+    SetCutsWithDefault();
+  if (verboseLevel>0) DumpCutValuesTable();
+
+}
diff --git a/LHCbG4Tests/G4RichTbSimH/src/srcph/RichTbPrimaryGeneratorAction.cc b/LHCbG4Tests/G4RichTbSimH/src/srcph/RichTbPrimaryGeneratorAction.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0ef539813d316748d7052a45adb9f30f0ee3fdd8
--- /dev/null
+++ b/LHCbG4Tests/G4RichTbSimH/src/srcph/RichTbPrimaryGeneratorAction.cc
@@ -0,0 +1,394 @@
+#include "RichTbPrimaryGeneratorAction.hh"
+
+#include "Geant4/globals.hh"
+#include "Geant4/G4Event.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 "RichTbAnalysisManager.hh"
+
+RichTbPrimaryGeneratorAction::RichTbPrimaryGeneratorAction()
+{
+  //RichTbRunConfig* rConfig =  RichTbRunConfig::getRunConfigInstance();
+
+    G4int n_particle = 1;
+    particleGun = new G4ParticleGun(n_particle);
+
+}
+
+
+RichTbPrimaryGeneratorAction::~RichTbPrimaryGeneratorAction()
+{
+  if( particleGun != 0 )  delete particleGun;
+}
+
+
+void RichTbPrimaryGeneratorAction::GeneratePrimaries(G4Event * anEvent)
+{
+  RichTbBeamProperty* aBeamProperty =
+    RichTbBeamProperty:: getRichTbBeamPropertyInstance();
+  aBeamProperty->ResetBeamProperty();
+  RichTbRunConfig* rConfig =  RichTbRunConfig::getRunConfigInstance();
+  G4int NumPart = rConfig->getRichTbNumPartEvent();
+  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();
+
+  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-";
+
+  if(patype == 1 ) {
+    particleName="opticalphoton";
+
+  }else if(patype == 2) {
+    G4double PosFr =  rConfig-> getPosBeamFraction();
+    G4double randomQut1 = G4UniformRand();
+    if(randomQut1 >  PosFr ) {
+      particleName="pi+";
+    }else {
+      particleName="proton";
+    }
+
+  }else if(patype == 3) {
+
+    G4double ElnFr =  rConfig-> getPosBeamFraction();
+    G4double randomQut1 = G4UniformRand();
+    if(randomQut1 >  ElnFr ) {
+      particleName="pi-";
+    }else {
+      particleName="e-";
+    }
+
+  } else if(patype == 4) {
+
+    G4double KaonFr =  rConfig-> getPosBeamFraction();
+    G4double randomQutk = G4UniformRand();
+    if(randomQutk >  KaonFr ) {
+      particleName="pi-";
+    }else {
+      particleName="kaon-";
+    }
+
+  }else if(patype == 5) {
+
+    G4double KaonFrp =  rConfig-> getPosBeamFraction();
+    G4double randomQutp = G4UniformRand();
+    if(randomQutp >  KaonFrp ) {
+      particleName="pi+";
+    }else {
+      particleName="kaon+";
+    }
+
+  }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);
+
+   return particle;
+
+
+}
+
+void RichTbPrimaryGeneratorAction::SetParticleStartPos() {
+
+  RichTbRunConfig* rConfig =  RichTbRunConfig::getRunConfigInstance();
+  RichTbBeamProperty* aBeamProperty =
+    RichTbBeamProperty:: getRichTbBeamPropertyInstance();
+  G4ThreeVector  positionStd=  aBeamProperty->getNominalBeamPosition() ;
+
+
+  G4int PosCode=rConfig->getRichTbParticleStartPosCode();
+  // standard positon is at PosCode =0.
+  //  G4double beamPosXStd = AgelTileXLocation[0];
+  //  G4double beamPosYStd = AgelTileYLocation[0]+0.5*RichTbVesselYSize;
+  //  G4double beamPosZStd=-200.0*CLHEP::mm;
+  //    G4ThreeVector positionStd(0.0*cm,0.0*cm,-200.0*CLHEP::mm);
+  //  G4ThreeVector positionStd( beamPosXStd,beamPosYStd, beamPosZStd);
+
+  //  G4cout<<" BeamPos code PosStdXYZ"<< PosCode<<"  "
+  //      <<positionStd.x()<<"  "<<positionStd.y()<<"  "<<positionStd.z()
+  //      <<G4endl;
+
+
+   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();
+
+     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(aBeamPosition );
+
+   } else if ( PosCode == 2 ) {
+     //
+
+     G4double aSpBeamX=  rConfig->getBeamSpecialXPos();
+     G4double aSpBeamY=  rConfig->getBeamSpecialYPos();
+     G4double aSpBeamZ=  rConfig->getBeamSpecialZPos();
+
+     G4ThreeVector aSpBeam(  aSpBeamX,  aSpBeamY, aSpBeamZ);
+     particleGun->SetParticlePosition( aSpBeam );
+
+  // store the positon for writeOut.
+
+     //G4cout<<" Current beam part start pos is "
+     //   << aSpBeamX<<"  "<<  aSpBeamY<<"  "<< aSpBeamZ<<G4endl;
+
+    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();
+  //  RichTbAnalysisManager* rAnalysis =  RichTbAnalysisManager::getInstance();
+  //  G4double paMass = CurPart->GetPDGMass();
+  // G4cout<<"Cur beam paticle mass " <<paMass<<G4endl;
+  G4int PEnergyCode=rConfig->getRichTbParticleEnergyCode();
+  G4int curpatype = rConfig->getRichTbParticleTypeCode();
+  G4double paMass = 0.0;
+
+  if(  curpatype !=  1 ) {
+
+     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);
+
+  //   G4cout<<"Current beam Name momentum mass and KE are  "
+  //        <<CurPart->GetParticleName()<<"  "<< particleMom
+  //  <<"  "<<paMass <<"  "<<  PKineticEnergy <<G4endl;
+
+
+  } 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 PhotonKineticEnergy=   photonparticleMom;
+
+    particleGun->SetParticleEnergy(PhotonKineticEnergy);
+
+    //    G4cout<<"Current beam Photon momentum and wlen are "
+    // <<"  "<<  photonparticleMom <<"  "<<  particlewlen  <<G4endl;
+
+
+  } 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 curPhotonWlenNano = 0.0;
+          //  if( CurPhotMom != 0.0 ) {
+
+            //   curPhotonWlenNano = PhotMomToWaveLength /(CurPhotMom*CLHEP::nanometer);
+          // }
+
+          // 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();
+  // default direction code is 0 for 001 direction with no
+  // misalignment or divergence.
+  G4int DirCode=rConfig->getRichTbParticleDirectionCode();
+  //  G4ThreeVector direction(0.0,0.0,1.0)
+  G4ThreeVector directionStd=
+             aBeamProperty ->getNominalBeamDirectionCos();
+
+  G4ThreeVector direction = directionStd;
+
+  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 ) {
+    // with misalignment and no divergence.
+
+    G4ThreeVector bDirection( aBeamDirX,aBeamDirY,1.0);
+    direction=bDirection;
+
+  } 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;
+
+   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 ) {
+
+
+    G4double aslpx=aBeamDirX/1.0;
+    G4double aslpy=aBeamDirY/1.0;
+
+   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());
+
+   //G4cout<<" Current Beam direction is   "<<direction.x()
+   //   <<"    "<<direction.y()<<"    "<<direction.z()<<G4endl;
+
+   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);
+
+  particleGun->SetParticlePolarization(polarization);
+  }
+  // store the beam direction for writeOut.
+
+  aBeamProperty-> setBeamDirection(direction);
+
+
+}
+
+