Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/examples/advanced/ChargeExchangeMC/src/CexmcEventAction.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/advanced/ChargeExchangeMC/src/CexmcEventAction.cc (Version 11.3.0) and /examples/advanced/ChargeExchangeMC/src/CexmcEventAction.cc (Version 10.1.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 /*                                                 26 /*
 27  * ===========================================     27  * ============================================================================
 28  *                                                 28  *
 29  *       Filename:  CexmcEventAction.cc            29  *       Filename:  CexmcEventAction.cc
 30  *                                                 30  *
 31  *    Description:  event action                   31  *    Description:  event action
 32  *                                                 32  *
 33  *        Version:  1.0                            33  *        Version:  1.0
 34  *        Created:  27.10.2009 22:48:08            34  *        Created:  27.10.2009 22:48:08
 35  *       Revision:  none                           35  *       Revision:  none
 36  *       Compiler:  gcc                            36  *       Compiler:  gcc
 37  *                                                 37  *
 38  *         Author:  Alexey Radkov (),              38  *         Author:  Alexey Radkov (), 
 39  *        Company:  PNPI                           39  *        Company:  PNPI
 40  *                                                 40  *
 41  * ===========================================     41  * ============================================================================
 42  */                                                42  */
 43                                                    43 
 44 #include <cmath>                                   44 #include <cmath>
 45 #ifdef CEXMC_USE_PERSISTENCY                       45 #ifdef CEXMC_USE_PERSISTENCY
 46 #include <boost/archive/binary_oarchive.hpp>       46 #include <boost/archive/binary_oarchive.hpp>
 47 #endif                                             47 #endif
 48 #include <G4DigiManager.hh>                        48 #include <G4DigiManager.hh>
 49 #include <G4Event.hh>                              49 #include <G4Event.hh>
 50 #include <G4Circle.hh>                             50 #include <G4Circle.hh>
 51 #include <G4VisAttributes.hh>                      51 #include <G4VisAttributes.hh>
 52 #include <G4VisManager.hh>                         52 #include <G4VisManager.hh>
 53 #include <G4VTrajectory.hh>                        53 #include <G4VTrajectory.hh>
 54 #include <G4TrajectoryContainer.hh>                54 #include <G4TrajectoryContainer.hh>
 55 #include <G4Colour.hh>                             55 #include <G4Colour.hh>
 56 #include <G4SystemOfUnits.hh>                      56 #include <G4SystemOfUnits.hh>
 57 #include "CexmcEventAction.hh"                     57 #include "CexmcEventAction.hh"
 58 #include "CexmcEventActionMessenger.hh"            58 #include "CexmcEventActionMessenger.hh"
 59 #include "CexmcEventInfo.hh"                       59 #include "CexmcEventInfo.hh"
 60 #include "CexmcEventSObject.hh"                    60 #include "CexmcEventSObject.hh"
 61 #include "CexmcEventFastSObject.hh"                61 #include "CexmcEventFastSObject.hh"
 62 #include "CexmcTrackingAction.hh"                  62 #include "CexmcTrackingAction.hh"
 63 #include "CexmcChargeExchangeReconstructor.hh"     63 #include "CexmcChargeExchangeReconstructor.hh"
 64 #include "CexmcRunManager.hh"                      64 #include "CexmcRunManager.hh"
 65 #include "CexmcHistoManager.hh"                    65 #include "CexmcHistoManager.hh"
 66 #include "CexmcRun.hh"                             66 #include "CexmcRun.hh"
 67 #include "CexmcPhysicsManager.hh"                  67 #include "CexmcPhysicsManager.hh"
 68 #include "CexmcProductionModel.hh"                 68 #include "CexmcProductionModel.hh"
 69 #include "CexmcProductionModelData.hh"             69 #include "CexmcProductionModelData.hh"
 70 #include "CexmcEnergyDepositDigitizer.hh"          70 #include "CexmcEnergyDepositDigitizer.hh"
 71 #include "CexmcEnergyDepositStore.hh"              71 #include "CexmcEnergyDepositStore.hh"
 72 #include "CexmcTrackPointsDigitizer.hh"            72 #include "CexmcTrackPointsDigitizer.hh"
 73 #include "CexmcTrackPointsStore.hh"                73 #include "CexmcTrackPointsStore.hh"
 74 #include "CexmcTrackPointInfo.hh"                  74 #include "CexmcTrackPointInfo.hh"
 75 #include "CexmcException.hh"                       75 #include "CexmcException.hh"
 76 #include "CexmcCommon.hh"                          76 #include "CexmcCommon.hh"
 77                                                    77 
 78                                                    78 
 79 namespace                                          79 namespace
 80 {                                                  80 {
 81     G4double  CexmcSmallCircleScreenSize( 5.0      81     G4double  CexmcSmallCircleScreenSize( 5.0 );
 82     G4double  CexmcBigCircleScreenSize( 10.0 )     82     G4double  CexmcBigCircleScreenSize( 10.0 );
 83     G4Colour  CexmcTrackPointsMarkerColour( 0.     83     G4Colour  CexmcTrackPointsMarkerColour( 0.0, 1.0, 0.4 );
 84     G4Colour  CexmcRecTrackPointsMarkerColour(     84     G4Colour  CexmcRecTrackPointsMarkerColour( 1.0, 0.4, 0.0 );
 85                                                    85 
 86 #ifdef CEXMC_USE_ROOT                          <<  86 
 87     inline G4double  CexmcGetKinEnergy( G4doub     87     inline G4double  CexmcGetKinEnergy( G4double  momentumAmp, G4double  mass )
 88     {                                              88     {
 89         return std::sqrt( momentumAmp * moment     89         return std::sqrt( momentumAmp * momentumAmp + mass * mass ) - mass;
 90     }                                              90     }
 91 #endif                                         << 
 92 }                                                  91 }
 93                                                    92 
 94                                                    93 
 95 CexmcEventAction::CexmcEventAction( CexmcPhysi <<  94 CexmcEventAction::CexmcEventAction( CexmcPhysicsManager *  physicsManager,
 96                                     G4int  ver <<  95                                     G4int  verbose ) :
 97     physicsManager( physicsManager_ ), reconst <<  96     physicsManager( physicsManager ), reconstructor( NULL ), opKinEnergy( 0. ),
 98 #ifdef CEXMC_USE_ROOT                          <<  97     verbose( verbose ), verboseDraw( 4 ), messenger( NULL )
 99     opKinEnergy( 0. ),                         << 
100 #endif                                         << 
101     verbose( verbose_ ), verboseDraw( 4 ), mes << 
102 {                                                  98 {
103     G4DigiManager *  digiManager( G4DigiManage     99     G4DigiManager *  digiManager( G4DigiManager::GetDMpointer() );
104     digiManager->AddNewModule( new CexmcEnergy    100     digiManager->AddNewModule( new CexmcEnergyDepositDigitizer(
105                                                   101                                                     CexmcEDDigitizerName ) );
106     digiManager->AddNewModule( new CexmcTrackP    102     digiManager->AddNewModule( new CexmcTrackPointsDigitizer(
107                                                   103                                                     CexmcTPDigitizerName ) );
108     reconstructor = new CexmcChargeExchangeRec    104     reconstructor = new CexmcChargeExchangeReconstructor(
109                                         physic    105                                         physicsManager->GetProductionModel() );
110     messenger = new CexmcEventActionMessenger(    106     messenger = new CexmcEventActionMessenger( this );
111 }                                                 107 }
112                                                   108 
113                                                   109 
114 CexmcEventAction::~CexmcEventAction()             110 CexmcEventAction::~CexmcEventAction()
115 {                                                 111 {
116     delete reconstructor;                         112     delete reconstructor;
117     delete messenger;                             113     delete messenger;
118 }                                                 114 }
119                                                   115 
120                                                   116 
121 void  CexmcEventAction::BeamParticleChangeHook    117 void  CexmcEventAction::BeamParticleChangeHook( void )
122 {                                                 118 {
123     reconstructor->SetupBeamParticle();           119     reconstructor->SetupBeamParticle();
124 }                                                 120 }
125                                                   121 
126                                                   122 
127 void  CexmcEventAction::BeginOfEventAction( co    123 void  CexmcEventAction::BeginOfEventAction( const G4Event * )
128 {                                                 124 {
129     G4RunManager *         runManager( G4RunMa    125     G4RunManager *         runManager( G4RunManager::GetRunManager() );
130     CexmcTrackingAction *  trackingAction         126     CexmcTrackingAction *  trackingAction
131             ( static_cast< CexmcTrackingAction    127             ( static_cast< CexmcTrackingAction * >(
132                         const_cast< G4UserTrac    128                         const_cast< G4UserTrackingAction * >(
133                                     runManager    129                                     runManager->GetUserTrackingAction() ) ) );
134     trackingAction->BeginOfEventAction();         130     trackingAction->BeginOfEventAction();
135                                                   131 
136     physicsManager->ResetNumberOfTriggeredStud    132     physicsManager->ResetNumberOfTriggeredStudiedInteractions();
137 }                                                 133 }
138                                                   134 
139                                                   135 
140 CexmcEnergyDepositStore *  CexmcEventAction::M    136 CexmcEnergyDepositStore *  CexmcEventAction::MakeEnergyDepositStore(
141                                 const CexmcEne    137                                 const CexmcEnergyDepositDigitizer *  digitizer )
142 {                                                 138 {
143     G4double  monitorED( digitizer->GetMonitor    139     G4double  monitorED( digitizer->GetMonitorED() );
144     G4double  vetoCounterEDLeft( digitizer->Ge    140     G4double  vetoCounterEDLeft( digitizer->GetVetoCounterEDLeft() );
145     G4double  vetoCounterEDRight( digitizer->G    141     G4double  vetoCounterEDRight( digitizer->GetVetoCounterEDRight() );
146     G4double  calorimeterEDLeft( digitizer->Ge    142     G4double  calorimeterEDLeft( digitizer->GetCalorimeterEDLeft() );
147     G4double  calorimeterEDRight( digitizer->G    143     G4double  calorimeterEDRight( digitizer->GetCalorimeterEDRight() );
148     G4int     calorimeterEDLeftMaxX( digitizer    144     G4int     calorimeterEDLeftMaxX( digitizer->GetCalorimeterEDLeftMaxX() );
149     G4int     calorimeterEDLeftMaxY( digitizer    145     G4int     calorimeterEDLeftMaxY( digitizer->GetCalorimeterEDLeftMaxY() );
150     G4int     calorimeterEDRightMaxX( digitize    146     G4int     calorimeterEDRightMaxX( digitizer->GetCalorimeterEDRightMaxX() );
151     G4int     calorimeterEDRightMaxY( digitize    147     G4int     calorimeterEDRightMaxY( digitizer->GetCalorimeterEDRightMaxY() );
152                                                   148 
153     const CexmcEnergyDepositCalorimeterCollect    149     const CexmcEnergyDepositCalorimeterCollection &
154               calorimeterEDLeftCollection(        150               calorimeterEDLeftCollection(
155                             digitizer->GetCalo    151                             digitizer->GetCalorimeterEDLeftCollection() );
156     const CexmcEnergyDepositCalorimeterCollect    152     const CexmcEnergyDepositCalorimeterCollection &
157               calorimeterEDRightCollection(       153               calorimeterEDRightCollection(
158                             digitizer->GetCalo    154                             digitizer->GetCalorimeterEDRightCollection() );
159                                                   155 
160     /* ATTENTION: return object in heap - must    156     /* ATTENTION: return object in heap - must be freed by caller! */
161     return new CexmcEnergyDepositStore( monito    157     return new CexmcEnergyDepositStore( monitorED, vetoCounterEDLeft,
162                     vetoCounterEDRight, calori    158                     vetoCounterEDRight, calorimeterEDLeft, calorimeterEDRight,
163                     calorimeterEDLeftMaxX, cal    159                     calorimeterEDLeftMaxX, calorimeterEDLeftMaxY,
164                     calorimeterEDRightMaxX, ca    160                     calorimeterEDRightMaxX, calorimeterEDRightMaxY,
165                     calorimeterEDLeftCollectio    161                     calorimeterEDLeftCollection, calorimeterEDRightCollection );
166 }                                                 162 }
167                                                   163 
168                                                   164 
169 CexmcTrackPointsStore *  CexmcEventAction::Mak    165 CexmcTrackPointsStore *  CexmcEventAction::MakeTrackPointsStore(
170                                 const CexmcTra    166                                 const CexmcTrackPointsDigitizer *  digitizer )
171 {                                                 167 {
172     const CexmcTrackPointInfo &                   168     const CexmcTrackPointInfo &
173                 monitorTP( digitizer->GetMonit    169                 monitorTP( digitizer->GetMonitorTP() );
174     const CexmcTrackPointInfo &                   170     const CexmcTrackPointInfo &
175                 targetTPBeamParticle(             171                 targetTPBeamParticle(
176                     digitizer->GetTargetTPBeam    172                     digitizer->GetTargetTPBeamParticle() );
177     const CexmcTrackPointInfo &                   173     const CexmcTrackPointInfo &
178                 targetTPOutputParticle(           174                 targetTPOutputParticle(
179                     digitizer->GetTargetTPOutp    175                     digitizer->GetTargetTPOutputParticle() );
180     const CexmcTrackPointInfo &                   176     const CexmcTrackPointInfo &
181                 targetTPNucleusParticle(          177                 targetTPNucleusParticle(
182                     digitizer->GetTargetTPNucl    178                     digitizer->GetTargetTPNucleusParticle() );
183     const CexmcTrackPointInfo &                   179     const CexmcTrackPointInfo &
184                 targetTPOutputParticleDecayPro    180                 targetTPOutputParticleDecayProductParticle1(
185                     digitizer->                   181                     digitizer->
186                     GetTargetTPOutputParticleD    182                     GetTargetTPOutputParticleDecayProductParticle( 0 ) );
187     const CexmcTrackPointInfo &                   183     const CexmcTrackPointInfo &
188                 targetTPOutputParticleDecayPro    184                 targetTPOutputParticleDecayProductParticle2(
189                     digitizer->                   185                     digitizer->
190                     GetTargetTPOutputParticleD    186                     GetTargetTPOutputParticleDecayProductParticle( 1 ) );
191     const CexmcTrackPointInfo &                   187     const CexmcTrackPointInfo &
192                 vetoCounterTPLeft(                188                 vetoCounterTPLeft(
193                     digitizer->GetVetoCounterT    189                     digitizer->GetVetoCounterTPLeft() );
194     const CexmcTrackPointInfo &                   190     const CexmcTrackPointInfo &
195                 vetoCounterTPRight(               191                 vetoCounterTPRight(
196                     digitizer->GetVetoCounterT    192                     digitizer->GetVetoCounterTPRight() );
197     const CexmcTrackPointInfo &                   193     const CexmcTrackPointInfo &
198                 calorimeterTPLeft(                194                 calorimeterTPLeft(
199                     digitizer->GetCalorimeterT    195                     digitizer->GetCalorimeterTPLeft() );
200     const CexmcTrackPointInfo &                   196     const CexmcTrackPointInfo &
201                 calorimeterTPRight(               197                 calorimeterTPRight(
202                     digitizer->GetCalorimeterT    198                     digitizer->GetCalorimeterTPRight() );
203                                                   199 
204     /* ATTENTION: return object in heap - must    200     /* ATTENTION: return object in heap - must be freed by caller! */
205     return new CexmcTrackPointsStore( monitorT    201     return new CexmcTrackPointsStore( monitorTP, targetTPBeamParticle,
206                   targetTPOutputParticle, targ    202                   targetTPOutputParticle, targetTPNucleusParticle,
207                   targetTPOutputParticleDecayP    203                   targetTPOutputParticleDecayProductParticle1,
208                   targetTPOutputParticleDecayP    204                   targetTPOutputParticleDecayProductParticle2,
209                   vetoCounterTPLeft, vetoCount    205                   vetoCounterTPLeft, vetoCounterTPRight,
210                   calorimeterTPLeft, calorimet    206                   calorimeterTPLeft, calorimeterTPRight );
211 }                                                 207 }
212                                                   208 
213                                                   209 
214 void  CexmcEventAction::PrintEnergyDeposit(       210 void  CexmcEventAction::PrintEnergyDeposit(
215                                     const Cexm    211                                     const CexmcEnergyDepositStore *  edStore )
216 {                                                 212 {
217     G4cout << " --- Energy Deposit" << G4endl;    213     G4cout << " --- Energy Deposit" << G4endl;
218     G4cout << "       monitor : " <<              214     G4cout << "       monitor : " <<
219             G4BestUnit( edStore->monitorED, "E    215             G4BestUnit( edStore->monitorED, "Energy" ) << G4endl;
220     G4cout << "        vc (l) : " <<              216     G4cout << "        vc (l) : " <<
221             G4BestUnit( edStore->vetoCounterED    217             G4BestUnit( edStore->vetoCounterEDLeft, "Energy" ) << G4endl;
222     G4cout << "        vc (r) : " <<              218     G4cout << "        vc (r) : " <<
223             G4BestUnit( edStore->vetoCounterED    219             G4BestUnit( edStore->vetoCounterEDRight, "Energy" ) << G4endl;
224     G4cout << "       cal (l) : " <<              220     G4cout << "       cal (l) : " <<
225             G4BestUnit( edStore->calorimeterED    221             G4BestUnit( edStore->calorimeterEDLeft, "Energy" );
226     G4cout << edStore->calorimeterEDLeftCollec    222     G4cout << edStore->calorimeterEDLeftCollection;
227     G4cout << "       cal (r) : " <<              223     G4cout << "       cal (r) : " <<
228             G4BestUnit( edStore->calorimeterED    224             G4BestUnit( edStore->calorimeterEDRight, "Energy" );
229     G4cout << edStore->calorimeterEDRightColle    225     G4cout << edStore->calorimeterEDRightCollection;
230 }                                                 226 }
231                                                   227 
232                                                   228 
233 void  CexmcEventAction::PrintTrackPoints(         229 void  CexmcEventAction::PrintTrackPoints(
234                                     const Cexm    230                                     const CexmcTrackPointsStore *  tpStore )
235 {                                                 231 {
236     if ( ! tpStore )                              232     if ( ! tpStore )
237         return;                                   233         return;
238                                                   234 
239     G4cout << " --- Track Points" << G4endl;      235     G4cout << " --- Track Points" << G4endl;
240     G4cout << "       monitor : " << tpStore->    236     G4cout << "       monitor : " << tpStore->monitorTP << G4endl;
241     G4cout << "        target : " << tpStore->    237     G4cout << "        target : " << tpStore->targetTPBeamParticle << G4endl;
242     G4cout << "               : " << tpStore->    238     G4cout << "               : " << tpStore->targetTPOutputParticle << G4endl;
243     G4cout << "               : " << tpStore->    239     G4cout << "               : " << tpStore->targetTPNucleusParticle << G4endl;
244     G4cout << "               : " <<              240     G4cout << "               : " <<
245             tpStore->targetTPOutputParticleDec    241             tpStore->targetTPOutputParticleDecayProductParticle1 << G4endl;
246     G4cout << "               : " <<              242     G4cout << "               : " <<
247             tpStore->targetTPOutputParticleDec    243             tpStore->targetTPOutputParticleDecayProductParticle2 << G4endl;
248     G4cout << "        vc (l) : " << tpStore->    244     G4cout << "        vc (l) : " << tpStore->vetoCounterTPLeft << G4endl;
249     G4cout << "        vc (r) : " << tpStore->    245     G4cout << "        vc (r) : " << tpStore->vetoCounterTPRight << G4endl;
250     G4cout << "       cal (l) : " << tpStore->    246     G4cout << "       cal (l) : " << tpStore->calorimeterTPLeft << G4endl;
251     G4cout << "       cal (r) : " << tpStore->    247     G4cout << "       cal (r) : " << tpStore->calorimeterTPRight << G4endl;
252     G4cout << "      ---" << G4endl;              248     G4cout << "      ---" << G4endl;
253     G4cout << "      angle between the " <<       249     G4cout << "      angle between the " <<
254         tpStore->targetTPOutputParticle.partic    250         tpStore->targetTPOutputParticle.particle->GetParticleName() <<
255         " decay products : " <<                   251         " decay products : " <<
256         tpStore->targetTPOutputParticleDecayPr    252         tpStore->targetTPOutputParticleDecayProductParticle1.directionWorld.
257             angle(                                253             angle(
258         tpStore->targetTPOutputParticleDecayPr    254         tpStore->targetTPOutputParticleDecayProductParticle2.directionWorld ) /
259             deg << " deg" << G4endl;              255             deg << " deg" << G4endl;
260 }                                                 256 }
261                                                   257 
262                                                   258 
263 void  CexmcEventAction::PrintProductionModelDa    259 void  CexmcEventAction::PrintProductionModelData(
264                                 const CexmcAng    260                                 const CexmcAngularRangeList &  angularRanges,
265                                 const CexmcPro    261                                 const CexmcProductionModelData &  pmData )
266 {                                                 262 {
267     G4cout << " --- Triggered angular ranges:     263     G4cout << " --- Triggered angular ranges: " << angularRanges;
268     G4cout << " --- Production model data: " <    264     G4cout << " --- Production model data: " << pmData;
269 }                                                 265 }
270                                                   266 
271                                                   267 
272 void  CexmcEventAction::PrintReconstructedData    268 void  CexmcEventAction::PrintReconstructedData(
273                     const CexmcAngularRangeLis    269                     const CexmcAngularRangeList &  triggeredRecAngularRanges,
274                     const CexmcAngularRange &     270                     const CexmcAngularRange &  angularGap ) const
275 {                                                 271 {
276     G4cout << " --- Reconstructed data: " << G    272     G4cout << " --- Reconstructed data: " << G4endl;
277     G4cout << "       -- entry points:" << G4e    273     G4cout << "       -- entry points:" << G4endl;
278     G4cout << "              left: " << G4Best    274     G4cout << "              left: " << G4BestUnit(
279         reconstructor->GetCalorimeterEPLeftPos    275         reconstructor->GetCalorimeterEPLeftPosition(), "Length" ) << G4endl;
280     G4cout << "             right: " << G4Best    276     G4cout << "             right: " << G4BestUnit(
281         reconstructor->GetCalorimeterEPRightPo    277         reconstructor->GetCalorimeterEPRightPosition(), "Length" ) << G4endl;
282     G4cout << "            target: " << G4Best    278     G4cout << "            target: " << G4BestUnit(
283         reconstructor->GetTargetEPPosition(),     279         reconstructor->GetTargetEPPosition(), "Length" ) << G4endl;
284     G4cout << "       -- the angle: " << recon    280     G4cout << "       -- the angle: " << reconstructor->GetTheAngle() / deg <<
285         " deg" << G4endl;                         281         " deg" << G4endl;
286     G4cout << "       -- mass of the output pa    282     G4cout << "       -- mass of the output particle: " << G4BestUnit(
287         reconstructor->GetOutputParticleMass()    283         reconstructor->GetOutputParticleMass(), "Energy" ) << G4endl;
288     G4cout << "       -- mass of the nucleus o    284     G4cout << "       -- mass of the nucleus output particle: " << G4BestUnit(
289         reconstructor->GetNucleusOutputParticl    285         reconstructor->GetNucleusOutputParticleMass(), "Energy" ) << G4endl;
290     if ( reconstructor->IsMassCutUsed() )         286     if ( reconstructor->IsMassCutUsed() )
291     {                                             287     {
292         if ( reconstructor->HasMassCutTriggere    288         if ( reconstructor->HasMassCutTriggered() )
293             G4cout << "            < mass cut     289             G4cout << "            < mass cut passed >" << G4endl;
294         else                                      290         else
295             G4cout << "            < mass cut     291             G4cout << "            < mass cut failed >" << G4endl;
296     }                                             292     }
297     if ( reconstructor->IsAbsorbedEnergyCutUse    293     if ( reconstructor->IsAbsorbedEnergyCutUsed() )
298     {                                             294     {
299         if ( reconstructor->HasAbsorbedEnergyC    295         if ( reconstructor->HasAbsorbedEnergyCutTriggered() )
300             G4cout << "            < absorbed     296             G4cout << "            < absorbed energy cut passed >" << G4endl;
301         else                                      297         else
302             G4cout << "            < absorbed     298             G4cout << "            < absorbed energy cut failed >" << G4endl;
303     }                                             299     }
304     const CexmcProductionModelData &  pmData(     300     const CexmcProductionModelData &  pmData(
305                                     reconstruc    301                                     reconstructor->GetProductionModelData() );
306     G4cout << "       -- production model data    302     G4cout << "       -- production model data: " << pmData;
307     G4cout << "       -- triggered angular ran    303     G4cout << "       -- triggered angular ranges: ";
308     if ( triggeredRecAngularRanges.empty() )      304     if ( triggeredRecAngularRanges.empty() )
309         G4cout << "< orphan detected, gap " <<    305         G4cout << "< orphan detected, gap " << angularGap << " >" << G4endl;
310     else                                          306     else
311         G4cout << triggeredRecAngularRanges;      307         G4cout << triggeredRecAngularRanges;
312 }                                                 308 }
313                                                   309 
314                                                   310 
315 #ifdef CEXMC_USE_ROOT                             311 #ifdef CEXMC_USE_ROOT
316                                                   312 
317 void  CexmcEventAction::FillEDTHistos( const C    313 void  CexmcEventAction::FillEDTHistos( const CexmcEnergyDepositStore *  edStore,
318                 const CexmcAngularRangeList &     314                 const CexmcAngularRangeList &  triggeredAngularRanges ) const
319 {                                                 315 {
320     CexmcHistoManager *  histoManager( CexmcHi    316     CexmcHistoManager *  histoManager( CexmcHistoManager::Instance() );
321                                                   317 
322     histoManager->Add( CexmcAbsorbedEnergy_EDT    318     histoManager->Add( CexmcAbsorbedEnergy_EDT_Histo, 0,
323                        edStore->calorimeterEDL    319                        edStore->calorimeterEDLeft,
324                        edStore->calorimeterEDR    320                        edStore->calorimeterEDRight );
325                                                   321 
326     for ( CexmcAngularRangeList::const_iterato    322     for ( CexmcAngularRangeList::const_iterator
327                         k( triggeredAngularRan    323                         k( triggeredAngularRanges.begin() );
328                                     k != trigg    324                                     k != triggeredAngularRanges.end(); ++k )
329     {                                             325     {
330         histoManager->Add( CexmcAbsEnInLeftCal    326         histoManager->Add( CexmcAbsEnInLeftCalorimeter_ARReal_EDT_Histo,
331                            k->index, edStore->    327                            k->index, edStore->calorimeterEDLeft );
332         histoManager->Add( CexmcAbsEnInRightCa    328         histoManager->Add( CexmcAbsEnInRightCalorimeter_ARReal_EDT_Histo,
333                            k->index, edStore->    329                            k->index, edStore->calorimeterEDRight );
334     }                                             330     }
335 }                                                 331 }
336                                                   332 
337                                                   333 
338 void  CexmcEventAction::FillTPTHistos( const C    334 void  CexmcEventAction::FillTPTHistos( const CexmcTrackPointsStore *  tpStore,
339                 const CexmcProductionModelData    335                 const CexmcProductionModelData &  pmData,
340                 const CexmcAngularRangeList &     336                 const CexmcAngularRangeList &  triggeredAngularRanges ) const
341 {                                                 337 {
342     CexmcHistoManager *  histoManager( CexmcHi    338     CexmcHistoManager *  histoManager( CexmcHistoManager::Instance() );
343                                                   339 
344     if ( tpStore->monitorTP.IsValid() )           340     if ( tpStore->monitorTP.IsValid() )
345     {                                             341     {
346         histoManager->Add( CexmcMomentumBP_TPT    342         histoManager->Add( CexmcMomentumBP_TPT_Histo, 0,
347                            tpStore->monitorTP.    343                            tpStore->monitorTP.momentumAmp );
348         histoManager->Add( CexmcTPInMonitor_TP    344         histoManager->Add( CexmcTPInMonitor_TPT_Histo, 0,
349                            tpStore->monitorTP.    345                            tpStore->monitorTP.positionLocal.x(),
350                            tpStore->monitorTP.    346                            tpStore->monitorTP.positionLocal.y() );
351     }                                             347     }
352                                                   348 
353     if ( tpStore->targetTPOutputParticle.IsVal    349     if ( tpStore->targetTPOutputParticle.IsValid() )
354     {                                             350     {
355         histoManager->Add( CexmcTPInTarget_TPT    351         histoManager->Add( CexmcTPInTarget_TPT_Histo, 0,
356                            tpStore->targetTPOu    352                            tpStore->targetTPOutputParticle.positionLocal.x(),
357                            tpStore->targetTPOu    353                            tpStore->targetTPOutputParticle.positionLocal.y(),
358                            tpStore->targetTPOu    354                            tpStore->targetTPOutputParticle.positionLocal.z() );
359         if ( histoManager->GetVerboseLevel() >    355         if ( histoManager->GetVerboseLevel() > 0 )
360         {                                         356         {
361             histoManager->Add( CexmcMomentumIP    357             histoManager->Add( CexmcMomentumIP_TPT_Histo, 0,
362                                pmData.incident    358                                pmData.incidentParticleLAB.rho() );
363         }                                         359         }
364     }                                             360     }
365                                                   361 
366     for ( CexmcAngularRangeList::const_iterato    362     for ( CexmcAngularRangeList::const_iterator
367                         k( triggeredAngularRan    363                         k( triggeredAngularRanges.begin() );
368                                     k != trigg    364                                     k != triggeredAngularRanges.end(); ++k )
369     {                                             365     {
370         if ( tpStore->calorimeterTPLeft.IsVali    366         if ( tpStore->calorimeterTPLeft.IsValid() )
371         {                                         367         {
372             /* kinetic energy and momentum of     368             /* kinetic energy and momentum of gamma are equal */
373             G4double  kinEnergy( tpStore->calo    369             G4double  kinEnergy( tpStore->calorimeterTPLeft.momentumAmp );
374             histoManager->Add( CexmcKinEnAtLef    370             histoManager->Add( CexmcKinEnAtLeftCalorimeter_ARReal_TPT_Histo,
375                                k->index, kinEn    371                                k->index, kinEnergy );
376         }                                         372         }
377         if ( tpStore->calorimeterTPRight.IsVal    373         if ( tpStore->calorimeterTPRight.IsValid() )
378         {                                         374         {
379             G4double  kinEnergy( tpStore->calo    375             G4double  kinEnergy( tpStore->calorimeterTPRight.momentumAmp );
380             histoManager->Add( CexmcKinEnAtRig    376             histoManager->Add( CexmcKinEnAtRightCalorimeter_ARReal_TPT_Histo,
381                                k->index, kinEn    377                                k->index, kinEnergy );
382         }                                         378         }
383         if ( tpStore->targetTPOutputParticle.I    379         if ( tpStore->targetTPOutputParticle.IsValid() )
384         {                                         380         {
385             histoManager->Add( CexmcTPInTarget    381             histoManager->Add( CexmcTPInTarget_ARReal_TPT_Histo, k->index,
386                            tpStore->targetTPOu    382                            tpStore->targetTPOutputParticle.positionLocal.x(),
387                            tpStore->targetTPOu    383                            tpStore->targetTPOutputParticle.positionLocal.y(),
388                            tpStore->targetTPOu    384                            tpStore->targetTPOutputParticle.positionLocal.z() );
389             histoManager->Add( CexmcKinEnOP_LA    385             histoManager->Add( CexmcKinEnOP_LAB_ARReal_TPT_Histo, k->index,
390                                opKinEnergy );     386                                opKinEnergy );
391             histoManager->Add( CexmcAngleOP_SC    387             histoManager->Add( CexmcAngleOP_SCM_ARReal_TPT_Histo, k->index,
392                                pmData.outputPa    388                                pmData.outputParticleSCM.cosTheta() );
393         }                                         389         }
394         if ( tpStore->targetTPOutputParticleDe    390         if ( tpStore->targetTPOutputParticleDecayProductParticle1.IsValid() &&
395              tpStore->targetTPOutputParticleDe    391              tpStore->targetTPOutputParticleDecayProductParticle2.IsValid() )
396         {                                         392         {
397             G4double  openAngle(                  393             G4double  openAngle(
398                         tpStore->targetTPOutpu    394                         tpStore->targetTPOutputParticleDecayProductParticle1.
399                         directionWorld.angle(     395                         directionWorld.angle( tpStore->
400                                 targetTPOutput    396                                 targetTPOutputParticleDecayProductParticle2.
401                                         direct    397                                         directionWorld ) / deg );
402             histoManager->Add( CexmcOpenAngle_    398             histoManager->Add( CexmcOpenAngle_ARReal_TPT_Histo, k->index,
403                                openAngle );       399                                openAngle );
404         }                                         400         }
405     }                                             401     }
406 }                                                 402 }
407                                                   403 
408                                                   404 
409 void  CexmcEventAction::FillRTHistos( G4bool      405 void  CexmcEventAction::FillRTHistos( G4bool  reconstructorHasFullTrigger,
410                 const CexmcEnergyDepositStore     406                 const CexmcEnergyDepositStore *  edStore,
411                 const CexmcTrackPointsStore *     407                 const CexmcTrackPointsStore *  tpStore,
412                 const CexmcProductionModelData    408                 const CexmcProductionModelData &  pmData,
413                 const CexmcAngularRangeList &     409                 const CexmcAngularRangeList &  triggeredAngularRanges ) const
414 {                                                 410 {
415     CexmcHistoManager *  histoManager( CexmcHi    411     CexmcHistoManager *  histoManager( CexmcHistoManager::Instance() );
416                                                   412 
417     G4double    opMass( reconstructor->GetOutp    413     G4double    opMass( reconstructor->GetOutputParticleMass() );
418     G4double    nopMass( reconstructor->GetNuc    414     G4double    nopMass( reconstructor->GetNucleusOutputParticleMass() );
419                                                   415 
420     histoManager->Add( CexmcRecMasses_EDT_Hist    416     histoManager->Add( CexmcRecMasses_EDT_Histo, 0, opMass, nopMass );
421                                                   417 
422     for ( CexmcAngularRangeList::const_iterato    418     for ( CexmcAngularRangeList::const_iterator
423                         k( triggeredAngularRan    419                         k( triggeredAngularRanges.begin() );
424                                     k != trigg    420                                     k != triggeredAngularRanges.end(); ++k )
425     {                                             421     {
426         if ( tpStore->calorimeterTPLeft.IsVali    422         if ( tpStore->calorimeterTPLeft.IsValid() )
427         {                                         423         {
428             histoManager->Add( CexmcOPDPAtLeft    424             histoManager->Add( CexmcOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
429                                k->index,          425                                k->index,
430                                tpStore->calori    426                                tpStore->calorimeterTPLeft.positionLocal.x(),
431                                tpStore->calori    427                                tpStore->calorimeterTPLeft.positionLocal.y() );
432         }                                         428         }
433         if ( tpStore->calorimeterTPRight.IsVal    429         if ( tpStore->calorimeterTPRight.IsValid() )
434         {                                         430         {
435             histoManager->Add( CexmcOPDPAtRigh    431             histoManager->Add( CexmcOPDPAtRightCalorimeter_ARReal_EDT_Histo,
436                                k->index,          432                                k->index,
437                                tpStore->calori    433                                tpStore->calorimeterTPRight.positionLocal.x(),
438                                tpStore->calori    434                                tpStore->calorimeterTPRight.positionLocal.y() );
439         }                                         435         }
440         histoManager->Add( CexmcRecOPDPAtLeftC    436         histoManager->Add( CexmcRecOPDPAtLeftCalorimeter_ARReal_EDT_Histo,
441                            k->index,              437                            k->index,
442                            reconstructor->GetC    438                            reconstructor->GetCalorimeterEPLeftPosition().x(),
443                            reconstructor->GetC    439                            reconstructor->GetCalorimeterEPLeftPosition().y() );
444         histoManager->Add( CexmcRecOPDPAtRight    440         histoManager->Add( CexmcRecOPDPAtRightCalorimeter_ARReal_EDT_Histo,
445                            k->index,              441                            k->index,
446                            reconstructor->GetC    442                            reconstructor->GetCalorimeterEPRightPosition().x(),
447                            reconstructor->GetC    443                            reconstructor->GetCalorimeterEPRightPosition().y() );
448     }                                             444     }
449                                                   445 
450     if ( ! reconstructorHasFullTrigger )          446     if ( ! reconstructorHasFullTrigger )
451         return;                                   447         return;
452                                                   448 
453     if ( tpStore->monitorTP.IsValid() )           449     if ( tpStore->monitorTP.IsValid() )
454     {                                             450     {
455         histoManager->Add( CexmcMomentumBP_RT_    451         histoManager->Add( CexmcMomentumBP_RT_Histo, 0,
456                            tpStore->monitorTP.    452                            tpStore->monitorTP.momentumAmp );
457     }                                             453     }
458                                                   454 
459     if ( tpStore->targetTPOutputParticle.IsVal    455     if ( tpStore->targetTPOutputParticle.IsValid() )
460     {                                             456     {
461         histoManager->Add( CexmcTPInTarget_RT_    457         histoManager->Add( CexmcTPInTarget_RT_Histo, 0,
462                            tpStore->targetTPOu    458                            tpStore->targetTPOutputParticle.positionLocal.x(),
463                            tpStore->targetTPOu    459                            tpStore->targetTPOutputParticle.positionLocal.y(),
464                            tpStore->targetTPOu    460                            tpStore->targetTPOutputParticle.positionLocal.z() );
465     }                                             461     }
466                                                   462 
467     histoManager->Add( CexmcRecMasses_RT_Histo    463     histoManager->Add( CexmcRecMasses_RT_Histo, 0,
468                        reconstructor->GetOutpu    464                        reconstructor->GetOutputParticleMass(),
469                        reconstructor->GetNucle    465                        reconstructor->GetNucleusOutputParticleMass() );
470                                                   466 
471     histoManager->Add( CexmcAbsorbedEnergy_RT_    467     histoManager->Add( CexmcAbsorbedEnergy_RT_Histo, 0,
472                        edStore->calorimeterEDL    468                        edStore->calorimeterEDLeft,
473                        edStore->calorimeterEDR    469                        edStore->calorimeterEDRight );
474                                                   470 
475     G4double  recCosTheta( reconstructor->GetP    471     G4double  recCosTheta( reconstructor->GetProductionModelData().
476                                                   472                                                outputParticleSCM.cosTheta());
477                                                   473 
478     for ( CexmcAngularRangeList::const_iterato    474     for ( CexmcAngularRangeList::const_iterator
479                         k( triggeredAngularRan    475                         k( triggeredAngularRanges.begin() );
480                                     k != trigg    476                                     k != triggeredAngularRanges.end(); ++k )
481     {                                             477     {
482         histoManager->Add( CexmcRecMassOP_ARRe    478         histoManager->Add( CexmcRecMassOP_ARReal_RT_Histo, k->index, opMass );
483         histoManager->Add( CexmcRecMassNOP_ARR    479         histoManager->Add( CexmcRecMassNOP_ARReal_RT_Histo, k->index, nopMass );
484         if ( tpStore->calorimeterTPLeft.IsVali    480         if ( tpStore->calorimeterTPLeft.IsValid() )
485         {                                         481         {
486             G4double  kinEnergy( tpStore->calo    482             G4double  kinEnergy( tpStore->calorimeterTPLeft.momentumAmp );
487             histoManager->Add( CexmcKinEnAtLef    483             histoManager->Add( CexmcKinEnAtLeftCalorimeter_ARReal_RT_Histo,
488                                k->index, kinEn    484                                k->index, kinEnergy );
489             histoManager->Add( CexmcMissEnFrom    485             histoManager->Add( CexmcMissEnFromLeftCalorimeter_ARReal_RT_Histo,
490                                k->index,          486                                k->index,
491                                kinEnergy - edS    487                                kinEnergy - edStore->calorimeterEDLeft );
492         }                                         488         }
493         if ( tpStore->calorimeterTPRight.IsVal    489         if ( tpStore->calorimeterTPRight.IsValid() )
494         {                                         490         {
495             G4double  kinEnergy( tpStore->calo    491             G4double  kinEnergy( tpStore->calorimeterTPRight.momentumAmp );
496             histoManager->Add( CexmcKinEnAtRig    492             histoManager->Add( CexmcKinEnAtRightCalorimeter_ARReal_RT_Histo,
497                                k->index, kinEn    493                                k->index, kinEnergy );
498             histoManager->Add( CexmcMissEnFrom    494             histoManager->Add( CexmcMissEnFromRightCalorimeter_ARReal_RT_Histo,
499                                k->index,          495                                k->index,
500                                kinEnergy - edS    496                                kinEnergy - edStore->calorimeterEDRight );
501         }                                         497         }
502         if ( tpStore->targetTPOutputParticle.I    498         if ( tpStore->targetTPOutputParticle.IsValid() )
503         {                                         499         {
504             histoManager->Add( CexmcTPInTarget    500             histoManager->Add( CexmcTPInTarget_ARReal_RT_Histo, k->index,
505                            tpStore->targetTPOu    501                            tpStore->targetTPOutputParticle.positionLocal.x(),
506                            tpStore->targetTPOu    502                            tpStore->targetTPOutputParticle.positionLocal.y(),
507                            tpStore->targetTPOu    503                            tpStore->targetTPOutputParticle.positionLocal.z() );
508             histoManager->Add( CexmcKinEnOP_LA    504             histoManager->Add( CexmcKinEnOP_LAB_ARReal_RT_Histo, k->index,
509                                opKinEnergy );     505                                opKinEnergy );
510             histoManager->Add( CexmcAngleOP_SC    506             histoManager->Add( CexmcAngleOP_SCM_ARReal_RT_Histo, k->index,
511                                pmData.outputPa    507                                pmData.outputParticleSCM.cosTheta() );
512             G4double  diffCosTheta( pmData.out    508             G4double  diffCosTheta( pmData.outputParticleSCM.cosTheta() -
513                                     recCosThet    509                                     recCosTheta );
514             histoManager->Add( CexmcDiffAngleO    510             histoManager->Add( CexmcDiffAngleOP_SCM_ARReal_RT_Histo, k->index,
515                                diffCosTheta );    511                                diffCosTheta );
516         }                                         512         }
517         if ( tpStore->targetTPOutputParticleDe    513         if ( tpStore->targetTPOutputParticleDecayProductParticle1.IsValid() &&
518              tpStore->targetTPOutputParticleDe    514              tpStore->targetTPOutputParticleDecayProductParticle2.IsValid() )
519         {                                         515         {
520             G4double  openAngle(                  516             G4double  openAngle(
521                         tpStore->targetTPOutpu    517                         tpStore->targetTPOutputParticleDecayProductParticle1.
522                         directionWorld.angle(     518                         directionWorld.angle( tpStore->
523                                 targetTPOutput    519                                 targetTPOutputParticleDecayProductParticle2.
524                                         direct    520                                         directionWorld ) / deg );
525             histoManager->Add( CexmcOpenAngle_    521             histoManager->Add( CexmcOpenAngle_ARReal_RT_Histo, k->index,
526                                openAngle );       522                                openAngle );
527             G4double  diffOpenAngle( openAngle    523             G4double  diffOpenAngle( openAngle - reconstructor->GetTheAngle() /
528                                      deg );       524                                      deg );
529             histoManager->Add( CexmcDiffOpenAn    525             histoManager->Add( CexmcDiffOpenAngle_ARReal_RT_Histo, k->index,
530                                diffOpenAngle )    526                                diffOpenAngle );
531         }                                         527         }
532         if ( tpStore->calorimeterTPLeft.IsVali    528         if ( tpStore->calorimeterTPLeft.IsValid() )
533         {                                         529         {
534             histoManager->Add( CexmcOPDPAtLeft    530             histoManager->Add( CexmcOPDPAtLeftCalorimeter_ARReal_RT_Histo,
535                                k->index,          531                                k->index,
536                                tpStore->calori    532                                tpStore->calorimeterTPLeft.positionLocal.x(),
537                                tpStore->calori    533                                tpStore->calorimeterTPLeft.positionLocal.y() );
538         }                                         534         }
539         if ( tpStore->calorimeterTPRight.IsVal    535         if ( tpStore->calorimeterTPRight.IsValid() )
540         {                                         536         {
541             histoManager->Add( CexmcOPDPAtRigh    537             histoManager->Add( CexmcOPDPAtRightCalorimeter_ARReal_RT_Histo,
542                                k->index,          538                                k->index,
543                                tpStore->calori    539                                tpStore->calorimeterTPRight.positionLocal.x(),
544                                tpStore->calori    540                                tpStore->calorimeterTPRight.positionLocal.y() );
545         }                                         541         }
546         histoManager->Add( CexmcAbsEnInLeftCal    542         histoManager->Add( CexmcAbsEnInLeftCalorimeter_ARReal_RT_Histo,
547                            k->index, edStore->    543                            k->index, edStore->calorimeterEDLeft );
548         histoManager->Add( CexmcAbsEnInRightCa    544         histoManager->Add( CexmcAbsEnInRightCalorimeter_ARReal_RT_Histo,
549                            k->index, edStore->    545                            k->index, edStore->calorimeterEDRight );
550         histoManager->Add( CexmcRecAngleOP_SCM    546         histoManager->Add( CexmcRecAngleOP_SCM_ARReal_RT_Histo,
551                            k->index, recCosThe    547                            k->index, recCosTheta );
552         histoManager->Add( CexmcRecOpenAngle_A    548         histoManager->Add( CexmcRecOpenAngle_ARReal_RT_Histo,
553                            k->index, reconstru    549                            k->index, reconstructor->GetTheAngle() / deg );
554         histoManager->Add( CexmcRecOPDPAtLeftC    550         histoManager->Add( CexmcRecOPDPAtLeftCalorimeter_ARReal_RT_Histo,
555                            k->index,              551                            k->index,
556                            reconstructor->GetC    552                            reconstructor->GetCalorimeterEPLeftPosition().x(),
557                            reconstructor->GetC    553                            reconstructor->GetCalorimeterEPLeftPosition().y() );
558         histoManager->Add( CexmcRecOPDPAtRight    554         histoManager->Add( CexmcRecOPDPAtRightCalorimeter_ARReal_RT_Histo,
559                            k->index,              555                            k->index,
560                            reconstructor->GetC    556                            reconstructor->GetCalorimeterEPRightPosition().x(),
561                            reconstructor->GetC    557                            reconstructor->GetCalorimeterEPRightPosition().y() );
562     }                                             558     }
563 }                                                 559 }
564                                                   560 
565 #endif                                            561 #endif
566                                                   562 
567                                                   563 
568 void  CexmcEventAction::DrawTrajectories( cons    564 void  CexmcEventAction::DrawTrajectories( const G4Event *  event )
569 {                                                 565 {
570     G4VisManager *  visManager( static_cast< G    566     G4VisManager *  visManager( static_cast< G4VisManager * >(
571                                     G4VVisMana    567                                     G4VVisManager::GetConcreteInstance() ) );
572     if ( ! visManager || ! visManager->GetCurr    568     if ( ! visManager || ! visManager->GetCurrentGraphicsSystem() )
573         return;                                   569         return;
574                                                   570 
575     G4int                    nTraj( 0 );          571     G4int                    nTraj( 0 );
576     G4TrajectoryContainer *  trajContainer( ev    572     G4TrajectoryContainer *  trajContainer( event->GetTrajectoryContainer() );
577                                                   573 
578     if ( ! trajContainer )                        574     if ( ! trajContainer )
579         return;                                   575         return;
580                                                   576 
581     nTraj = trajContainer->entries();             577     nTraj = trajContainer->entries();
582                                                   578 
583     for ( int  i( 0 ); i < nTraj; ++i )           579     for ( int  i( 0 ); i < nTraj; ++i )
584     {                                             580     {
585         G4VTrajectory *  traj( ( *trajContaine    581         G4VTrajectory *  traj( ( *trajContainer )[ i ] );
586         traj->DrawTrajectory();                   582         traj->DrawTrajectory();
587     }                                             583     }
588 }                                                 584 }
589                                                   585 
590                                                   586 
591 void  CexmcEventAction::DrawTrackPoints(          587 void  CexmcEventAction::DrawTrackPoints(
592                                 const CexmcTra    588                                 const CexmcTrackPointsStore *  tpStore ) const
593 {                                                 589 {
594     G4VisManager *  visManager( static_cast< G    590     G4VisManager *  visManager( static_cast< G4VisManager * >(
595                                     G4VVisMana    591                                     G4VVisManager::GetConcreteInstance() ) );
596     if ( ! visManager || ! visManager->GetCurr    592     if ( ! visManager || ! visManager->GetCurrentGraphicsSystem() )
597         return;                                   593         return;
598                                                   594 
599     G4Circle         circle;                      595     G4Circle         circle;
600     G4VisAttributes  visAttributes( CexmcTrack    596     G4VisAttributes  visAttributes( CexmcTrackPointsMarkerColour );
601     circle.SetScreenSize( CexmcSmallCircleScre    597     circle.SetScreenSize( CexmcSmallCircleScreenSize );
602     circle.SetFillStyle( G4Circle::filled );      598     circle.SetFillStyle( G4Circle::filled );
603     circle.SetVisAttributes( visAttributes );     599     circle.SetVisAttributes( visAttributes );
604                                                   600 
605     if ( tpStore->monitorTP.IsValid() )           601     if ( tpStore->monitorTP.IsValid() )
606     {                                             602     {
607         circle.SetPosition( tpStore->monitorTP    603         circle.SetPosition( tpStore->monitorTP.positionWorld );
608         visManager->Draw( circle );               604         visManager->Draw( circle );
609     }                                             605     }
610                                                   606 
611     if ( tpStore->targetTPBeamParticle.IsValid    607     if ( tpStore->targetTPBeamParticle.IsValid() )
612     {                                             608     {
613         circle.SetPosition( tpStore->targetTPB    609         circle.SetPosition( tpStore->targetTPBeamParticle.positionWorld );
614         visManager->Draw( circle );               610         visManager->Draw( circle );
615     }                                             611     }
616                                                   612 
617     if ( tpStore->targetTPOutputParticle.IsVal    613     if ( tpStore->targetTPOutputParticle.IsValid() )
618     {                                             614     {
619         circle.SetPosition( tpStore->targetTPO    615         circle.SetPosition( tpStore->targetTPOutputParticle.positionWorld );
620         visManager->Draw( circle );               616         visManager->Draw( circle );
621     }                                             617     }
622                                                   618 
623     if ( tpStore->vetoCounterTPLeft.IsValid()     619     if ( tpStore->vetoCounterTPLeft.IsValid() )
624     {                                             620     {
625         circle.SetPosition( tpStore->vetoCount    621         circle.SetPosition( tpStore->vetoCounterTPLeft.positionWorld );
626         visManager->Draw( circle );               622         visManager->Draw( circle );
627     }                                             623     }
628                                                   624 
629     if ( tpStore->vetoCounterTPRight.IsValid()    625     if ( tpStore->vetoCounterTPRight.IsValid() )
630     {                                             626     {
631         circle.SetPosition( tpStore->vetoCount    627         circle.SetPosition( tpStore->vetoCounterTPRight.positionWorld );
632         visManager->Draw( circle );               628         visManager->Draw( circle );
633     }                                             629     }
634                                                   630 
635     if ( tpStore->calorimeterTPLeft.IsValid()     631     if ( tpStore->calorimeterTPLeft.IsValid() )
636     {                                             632     {
637         circle.SetPosition( tpStore->calorimet    633         circle.SetPosition( tpStore->calorimeterTPLeft.positionWorld );
638         visManager->Draw( circle );               634         visManager->Draw( circle );
639     }                                             635     }
640                                                   636 
641     if ( tpStore->calorimeterTPRight.IsValid()    637     if ( tpStore->calorimeterTPRight.IsValid() )
642     {                                             638     {
643         circle.SetPosition( tpStore->calorimet    639         circle.SetPosition( tpStore->calorimeterTPRight.positionWorld );
644         visManager->Draw( circle );               640         visManager->Draw( circle );
645     }                                             641     }
646 }                                                 642 }
647                                                   643 
648                                                   644 
649 void  CexmcEventAction::DrawReconstructionData    645 void  CexmcEventAction::DrawReconstructionData( void )
650 {                                                 646 {
651     G4VisManager *  visManager( static_cast< G    647     G4VisManager *  visManager( static_cast< G4VisManager * >(
652                                     G4VVisMana    648                                     G4VVisManager::GetConcreteInstance() ) );
653     if ( ! visManager || ! visManager->GetCurr    649     if ( ! visManager || ! visManager->GetCurrentGraphicsSystem() )
654         return;                                   650         return;
655                                                   651 
656     G4Circle  circle( reconstructor->GetTarget    652     G4Circle  circle( reconstructor->GetTargetEPWorldPosition() );
657     circle.SetScreenSize( CexmcSmallCircleScre    653     circle.SetScreenSize( CexmcSmallCircleScreenSize );
658     circle.SetFillStyle( G4Circle::filled );      654     circle.SetFillStyle( G4Circle::filled );
659     G4VisAttributes  visAttributes( CexmcRecTr    655     G4VisAttributes  visAttributes( CexmcRecTrackPointsMarkerColour );
660     circle.SetVisAttributes( visAttributes );     656     circle.SetVisAttributes( visAttributes );
661     visManager->Draw( circle );                   657     visManager->Draw( circle );
662                                                   658 
663     circle.SetScreenSize( CexmcBigCircleScreen    659     circle.SetScreenSize( CexmcBigCircleScreenSize );
664     circle.SetPosition( reconstructor->GetCalo    660     circle.SetPosition( reconstructor->GetCalorimeterEPLeftWorldPosition() );
665     visManager->Draw( circle );                   661     visManager->Draw( circle );
666                                                   662 
667     circle.SetPosition( reconstructor->GetCalo    663     circle.SetPosition( reconstructor->GetCalorimeterEPRightWorldPosition() );
668     visManager->Draw( circle );                   664     visManager->Draw( circle );
669 }                                                 665 }
670                                                   666 
671                                                   667 
672 void  CexmcEventAction::UpdateRunHits(            668 void  CexmcEventAction::UpdateRunHits(
673                                     const Cexm    669                                     const CexmcAngularRangeList &  aRangesReal,
674                                     const Cexm    670                                     const CexmcAngularRangeList &  aRangesRec,
675                                     G4bool  tp    671                                     G4bool  tpDigitizerHasTriggered,
676                                     G4bool  ed    672                                     G4bool  edDigitizerHasTriggered,
677                                     G4bool  ed    673                                     G4bool  edDigitizerMonitorHasTriggered,
678                                     G4bool  re    674                                     G4bool  reconstructorHasFullTrigger,
679                                     const Cexm    675                                     const CexmcAngularRange &  aGap )
680 {                                                 676 {
681     G4RunManager *    runManager( G4RunManager    677     G4RunManager *    runManager( G4RunManager::GetRunManager() );
682     const CexmcRun *  run( static_cast< const     678     const CexmcRun *  run( static_cast< const CexmcRun * >(
683                                                   679                                                 runManager->GetCurrentRun() ) );
684     CexmcRun *        theRun( const_cast< Cexm    680     CexmcRun *        theRun( const_cast< CexmcRun * >( run ) );
685                                                   681 
686     if ( tpDigitizerHasTriggered )                682     if ( tpDigitizerHasTriggered )
687     {                                             683     {
688         for ( CexmcAngularRangeList::const_ite    684         for ( CexmcAngularRangeList::const_iterator  k( aRangesReal.begin() );
689                                                   685                                                 k != aRangesReal.end(); ++k )
690         {                                         686         {
691             theRun->IncrementNmbOfHitsSampledF    687             theRun->IncrementNmbOfHitsSampledFull( k->index );
692             if ( edDigitizerMonitorHasTriggere    688             if ( edDigitizerMonitorHasTriggered )
693                 theRun->IncrementNmbOfHitsSamp    689                 theRun->IncrementNmbOfHitsSampled( k->index );
694             if ( reconstructorHasFullTrigger )    690             if ( reconstructorHasFullTrigger )
695                 theRun->IncrementNmbOfHitsTrig    691                 theRun->IncrementNmbOfHitsTriggeredRealRange( k->index );
696         }                                         692         }
697         if ( reconstructorHasFullTrigger )        693         if ( reconstructorHasFullTrigger )
698         {                                         694         {
699             if ( aRangesRec.empty() )             695             if ( aRangesRec.empty() )
700             {                                     696             {
701                 theRun->IncrementNmbOfOrphanHi    697                 theRun->IncrementNmbOfOrphanHits( aGap.index );
702             }                                     698             }
703             else                                  699             else
704             {                                     700             {
705                 for ( CexmcAngularRangeList::c    701                 for ( CexmcAngularRangeList::const_iterator
706                         k( aRangesRec.begin()     702                         k( aRangesRec.begin() ); k != aRangesRec.end(); ++k )
707                 {                                 703                 {
708                     theRun->IncrementNmbOfHits    704                     theRun->IncrementNmbOfHitsTriggeredRecRange( k->index );
709                 }                                 705                 }
710             }                                     706             }
711         }                                         707         }
712     }                                             708     }
713     else                                          709     else
714     {                                             710     {
715         if ( edDigitizerHasTriggered )            711         if ( edDigitizerHasTriggered )
716             theRun->IncrementNmbOfFalseHitsTri    712             theRun->IncrementNmbOfFalseHitsTriggeredEDT();
717         if ( reconstructorHasFullTrigger )        713         if ( reconstructorHasFullTrigger )
718             theRun->IncrementNmbOfFalseHitsTri    714             theRun->IncrementNmbOfFalseHitsTriggeredRec();
719     }                                             715     }
720 }                                                 716 }
721                                                   717 
722                                                   718 
723 #ifdef CEXMC_USE_PERSISTENCY                      719 #ifdef CEXMC_USE_PERSISTENCY
724                                                   720 
725 void  CexmcEventAction::SaveEvent( const G4Eve    721 void  CexmcEventAction::SaveEvent( const G4Event *  event,
726                                    G4bool  edD    722                                    G4bool  edDigitizerHasTriggered,
727                                    const Cexmc    723                                    const CexmcEnergyDepositStore *  edStore,
728                                    const Cexmc    724                                    const CexmcTrackPointsStore *  tpStore,
729                                    const Cexmc    725                                    const CexmcProductionModelData &  pmData )
730 {                                                 726 {
731     CexmcRunManager *  runManager( static_cast    727     CexmcRunManager *  runManager( static_cast< CexmcRunManager * >(
732                                             G4    728                                             G4RunManager::GetRunManager() ) );
733     if ( ! runManager->ProjectIsSaved() )         729     if ( ! runManager->ProjectIsSaved() )
734         return;                                   730         return;
735                                                   731 
736     if ( runManager->GetEventDataVerboseLevel(    732     if ( runManager->GetEventDataVerboseLevel() == CexmcWriteNoEventData )
737         return;                                   733         return;
738                                                   734 
739     if ( ! edDigitizerHasTriggered && runManag    735     if ( ! edDigitizerHasTriggered && runManager->GetEventDataVerboseLevel() !=
740                                                   736                                                 CexmcWriteEventDataOnEveryTPT )
741         return;                                   737         return;
742                                                   738 
743     boost::archive::binary_oarchive *  archive    739     boost::archive::binary_oarchive *  archive(
744                                             ru    740                                             runManager->GetEventsArchive() );
745     if ( archive )                                741     if ( archive )
746     {                                             742     {
747         CexmcEventSObject  sObject = { event->    743         CexmcEventSObject  sObject = { event->GetEventID(),
748             edDigitizerHasTriggered, edStore->    744             edDigitizerHasTriggered, edStore->monitorED,
749             edStore->vetoCounterEDLeft, edStor    745             edStore->vetoCounterEDLeft, edStore->vetoCounterEDRight,
750             edStore->calorimeterEDLeft, edStor    746             edStore->calorimeterEDLeft, edStore->calorimeterEDRight,
751             edStore->calorimeterEDLeftCollecti    747             edStore->calorimeterEDLeftCollection,
752             edStore->calorimeterEDRightCollect    748             edStore->calorimeterEDRightCollection,
753             tpStore->monitorTP, tpStore->targe    749             tpStore->monitorTP, tpStore->targetTPBeamParticle,
754             tpStore->targetTPOutputParticle, t    750             tpStore->targetTPOutputParticle, tpStore->targetTPNucleusParticle,
755             tpStore->targetTPOutputParticleDec    751             tpStore->targetTPOutputParticleDecayProductParticle1,
756             tpStore->targetTPOutputParticleDec    752             tpStore->targetTPOutputParticleDecayProductParticle2,
757             tpStore->vetoCounterTPLeft, tpStor    753             tpStore->vetoCounterTPLeft, tpStore->vetoCounterTPRight,
758             tpStore->calorimeterTPLeft, tpStor    754             tpStore->calorimeterTPLeft, tpStore->calorimeterTPRight, pmData };
759         archive->operator<<( sObject );           755         archive->operator<<( sObject );
760         const CexmcRun *  run( static_cast< co    756         const CexmcRun *  run( static_cast< const CexmcRun * >(
761                                                   757                                                 runManager->GetCurrentRun() ) );
762         CexmcRun *        theRun( const_cast<     758         CexmcRun *        theRun( const_cast< CexmcRun * >( run ) );
763         theRun->IncrementNmbOfSavedEvents();      759         theRun->IncrementNmbOfSavedEvents();
764     }                                             760     }
765 }                                                 761 }
766                                                   762 
767                                                   763 
768 void  CexmcEventAction::SaveEventFast( const G    764 void  CexmcEventAction::SaveEventFast( const G4Event *  event,
769                                        G4bool     765                                        G4bool  tpDigitizerHasTriggered,
770                                        G4bool     766                                        G4bool  edDigitizerHasTriggered,
771                                        G4bool     767                                        G4bool  edDigitizerMonitorHasTriggered,
772                                        G4doubl    768                                        G4double  opCosThetaSCM )
773 {                                                 769 {
774     CexmcRunManager *  runManager( static_cast    770     CexmcRunManager *  runManager( static_cast< CexmcRunManager * >(
775                                             G4    771                                             G4RunManager::GetRunManager() ) );
776     if ( ! runManager->ProjectIsSaved() )         772     if ( ! runManager->ProjectIsSaved() )
777         return;                                   773         return;
778                                                   774 
779     if ( runManager->GetEventDataVerboseLevel(    775     if ( runManager->GetEventDataVerboseLevel() == CexmcWriteNoEventData )
780         return;                                   776         return;
781                                                   777 
782     boost::archive::binary_oarchive *  archive    778     boost::archive::binary_oarchive *  archive(
783                                         runMan    779                                         runManager->GetFastEventsArchive() );
784     if ( archive )                                780     if ( archive )
785     {                                             781     {
786         if ( ! tpDigitizerHasTriggered )          782         if ( ! tpDigitizerHasTriggered )
787             opCosThetaSCM = CexmcInvalidCosThe    783             opCosThetaSCM = CexmcInvalidCosTheta;
788                                                   784 
789         CexmcEventFastSObject  sObject = { eve    785         CexmcEventFastSObject  sObject = { event->GetEventID(), opCosThetaSCM,
790                                            edD    786                                            edDigitizerHasTriggered,
791                                            edD    787                                            edDigitizerMonitorHasTriggered };
792         archive->operator<<( sObject );           788         archive->operator<<( sObject );
793         const CexmcRun *  run( static_cast< co    789         const CexmcRun *  run( static_cast< const CexmcRun * >(
794                                                   790                                                 runManager->GetCurrentRun() ) );
795         CexmcRun *        theRun( const_cast<     791         CexmcRun *        theRun( const_cast< CexmcRun * >( run ) );
796         theRun->IncrementNmbOfSavedFastEvents(    792         theRun->IncrementNmbOfSavedFastEvents();
797     }                                             793     }
798 }                                                 794 }
799                                                   795 
800 #endif                                            796 #endif
801                                                   797 
802                                                   798 
803 void  CexmcEventAction::EndOfEventAction( cons    799 void  CexmcEventAction::EndOfEventAction( const G4Event *  event )
804 {                                                 800 {
805     G4DigiManager *                digiManager    801     G4DigiManager *                digiManager( G4DigiManager::GetDMpointer() );
806     CexmcEnergyDepositDigitizer *  energyDepos    802     CexmcEnergyDepositDigitizer *  energyDepositDigitizer(
807             static_cast< CexmcEnergyDepositDig    803             static_cast< CexmcEnergyDepositDigitizer * >( digiManager->
808                                 FindDigitizerM    804                                 FindDigitizerModule( CexmcEDDigitizerName ) ) );
809     CexmcTrackPointsDigitizer *    trackPoints    805     CexmcTrackPointsDigitizer *    trackPointsDigitizer(
810             static_cast< CexmcTrackPointsDigit    806             static_cast< CexmcTrackPointsDigitizer * >( digiManager->
811                                 FindDigitizerM    807                                 FindDigitizerModule( CexmcTPDigitizerName ) ) );
812                                                   808 
813     energyDepositDigitizer->Digitize();           809     energyDepositDigitizer->Digitize();
814     trackPointsDigitizer->Digitize();             810     trackPointsDigitizer->Digitize();
815                                                   811 
816     G4bool  edDigitizerMonitorHasTriggered(       812     G4bool  edDigitizerMonitorHasTriggered(
817                                 energyDepositD    813                                 energyDepositDigitizer->MonitorHasTriggered() );
818     G4bool  edDigitizerHasTriggered( false );     814     G4bool  edDigitizerHasTriggered( false );
819                                                   815 
820     CexmcEventInfo *  eventInfo( static_cast<     816     CexmcEventInfo *  eventInfo( static_cast< CexmcEventInfo * >(
821                                                   817                                                 event->GetUserInformation() ) );
822     if ( ! eventInfo || eventInfo->EdTriggerIs    818     if ( ! eventInfo || eventInfo->EdTriggerIsOk() )
823         edDigitizerHasTriggered = energyDeposi    819         edDigitizerHasTriggered = energyDepositDigitizer->HasTriggered();
824                                                   820 
825     G4bool  tpDigitizerHasTriggered( trackPoin    821     G4bool  tpDigitizerHasTriggered( trackPointsDigitizer->HasTriggered() );
826     G4bool  reconstructorHasBasicTrigger( fals    822     G4bool  reconstructorHasBasicTrigger( false );
827     G4bool  reconstructorHasFullTrigger( false    823     G4bool  reconstructorHasFullTrigger( false );
828                                                   824 
829     CexmcEnergyDepositStore *  edStore( MakeEn    825     CexmcEnergyDepositStore *  edStore( MakeEnergyDepositStore(
830                                                   826                                                     energyDepositDigitizer ) );
831     CexmcTrackPointsStore *    tpStore( MakeTr    827     CexmcTrackPointsStore *    tpStore( MakeTrackPointsStore(
832                                                   828                                                     trackPointsDigitizer ) );
833                                                   829 
834     try                                           830     try
835     {                                             831     {
836         CexmcProductionModel *  productionMode    832         CexmcProductionModel *  productionModel(
837                                         physic    833                                         physicsManager->GetProductionModel() );
838                                                   834 
839         if ( ! productionModel )                  835         if ( ! productionModel )
840             throw CexmcException( CexmcWeirdEx    836             throw CexmcException( CexmcWeirdException );
841                                                   837 
842         const CexmcAngularRangeList &     angu    838         const CexmcAngularRangeList &     angularRanges(
843                                 productionMode    839                                 productionModel->GetAngularRanges() );
844         const CexmcAngularRangeList &     trig    840         const CexmcAngularRangeList &     triggeredAngularRanges(
845                                 productionMode    841                                 productionModel->GetTriggeredAngularRanges() );
846         const CexmcProductionModelData &  pmDa    842         const CexmcProductionModelData &  pmData(
847                                 productionMode    843                                 productionModel->GetProductionModelData() );
848                                                   844 
849         if ( edDigitizerHasTriggered )            845         if ( edDigitizerHasTriggered )
850         {                                         846         {
851             reconstructor->Reconstruct( edStor    847             reconstructor->Reconstruct( edStore );
852             reconstructorHasBasicTrigger = rec    848             reconstructorHasBasicTrigger = reconstructor->HasBasicTrigger();
853             reconstructorHasFullTrigger = reco    849             reconstructorHasFullTrigger = reconstructor->HasFullTrigger();
854         }                                         850         }
855                                                   851 
856         CexmcAngularRangeList  triggeredRecAng    852         CexmcAngularRangeList  triggeredRecAngularRanges;
857                                                   853 
858         if ( reconstructorHasBasicTrigger )       854         if ( reconstructorHasBasicTrigger )
859         {                                         855         {
860             for ( CexmcAngularRangeList::const    856             for ( CexmcAngularRangeList::const_iterator
861                   k( angularRanges.begin() );     857                   k( angularRanges.begin() ); k != angularRanges.end(); ++k )
862             {                                     858             {
863                 G4double  cosTheta( reconstruc    859                 G4double  cosTheta( reconstructor->GetProductionModelData().
864                                     outputPart    860                                     outputParticleSCM.cosTheta() );
865                 if ( cosTheta <= k->top && cos    861                 if ( cosTheta <= k->top && cosTheta > k->bottom )
866                     triggeredRecAngularRanges.    862                     triggeredRecAngularRanges.push_back( CexmcAngularRange(
867                                                   863                                                 k->top, k->bottom, k->index ) );
868             }                                     864             }
869         }                                         865         }
870                                                   866 
871         CexmcAngularRange  angularGap( 0.0, 0.    867         CexmcAngularRange  angularGap( 0.0, 0.0, 0 );
872         if ( triggeredRecAngularRanges.empty()    868         if ( triggeredRecAngularRanges.empty() )
873         {                                         869         {
874             CexmcAngularRangeList  angularGaps    870             CexmcAngularRangeList  angularGaps;
875             GetAngularGaps( angularRanges, ang    871             GetAngularGaps( angularRanges, angularGaps );
876             for ( CexmcAngularRangeList::const    872             for ( CexmcAngularRangeList::const_iterator
877                     k( angularGaps.begin() );     873                     k( angularGaps.begin() ); k != angularGaps.end(); ++k )
878             {                                     874             {
879                 G4double  cosTheta( reconstruc    875                 G4double  cosTheta( reconstructor->GetProductionModelData().
880                                     outputPart    876                                     outputParticleSCM.cosTheta() );
881                 if ( cosTheta <= k->top && cos    877                 if ( cosTheta <= k->top && cosTheta > k->bottom )
882                 {                                 878                 {
883                     angularGap = *k;              879                     angularGap = *k;
884                     break;                        880                     break;
885                 }                                 881                 }
886             }                                     882             }
887         }                                         883         }
888                                                   884 
889         UpdateRunHits( triggeredAngularRanges,    885         UpdateRunHits( triggeredAngularRanges, triggeredRecAngularRanges,
890                        tpDigitizerHasTriggered    886                        tpDigitizerHasTriggered, edDigitizerHasTriggered,
891                        edDigitizerMonitorHasTr    887                        edDigitizerMonitorHasTriggered,
892                        reconstructorHasFullTri    888                        reconstructorHasFullTrigger, angularGap );
893                                                   889 
894         if ( verbose > 0 )                        890         if ( verbose > 0 )
895         {                                         891         {
896             G4bool  printMessages( verbose > 3    892             G4bool  printMessages( verbose > 3 ||
897                         ( ( verbose == 1 ) &&     893                         ( ( verbose == 1 ) && tpDigitizerHasTriggered ) ||
898                         ( ( verbose == 2 ) &&     894                         ( ( verbose == 2 ) && edDigitizerHasTriggered ) ||
899                         ( ( verbose == 3 ) &&     895                         ( ( verbose == 3 ) && ( tpDigitizerHasTriggered ||
900                                                   896                                                 edDigitizerHasTriggered ) ) );
901             if ( printMessages )                  897             if ( printMessages )
902             {                                     898             {
903                 G4cout << "Event " << event->G    899                 G4cout << "Event " << event->GetEventID() << G4endl;
904                 if ( tpDigitizerHasTriggered )    900                 if ( tpDigitizerHasTriggered )
905                 {                                 901                 {
906                     PrintTrackPoints( tpStore     902                     PrintTrackPoints( tpStore );
907                     PrintProductionModelData(     903                     PrintProductionModelData( triggeredAngularRanges, pmData );
908                 }                                 904                 }
909                 if ( reconstructorHasBasicTrig    905                 if ( reconstructorHasBasicTrigger )
910                     PrintReconstructedData( tr    906                     PrintReconstructedData( triggeredRecAngularRanges,
911                                             an    907                                             angularGap );
912                 if ( edDigitizerHasTriggered )    908                 if ( edDigitizerHasTriggered )
913                     PrintEnergyDeposit( edStor    909                     PrintEnergyDeposit( edStore );
914             }                                     910             }
915         }                                         911         }
916                                                   912 
917         if ( verboseDraw > 0 )                    913         if ( verboseDraw > 0 )
918         {                                         914         {
919             G4bool  drawTrajectories( verboseD    915             G4bool  drawTrajectories( verboseDraw > 3 ||
920                         ( ( verboseDraw == 1 )    916                         ( ( verboseDraw == 1 ) && tpDigitizerHasTriggered ) ||
921                         ( ( verboseDraw == 2 )    917                         ( ( verboseDraw == 2 ) && edDigitizerHasTriggered ) ||
922                         ( ( verboseDraw == 3 )    918                         ( ( verboseDraw == 3 ) && ( tpDigitizerHasTriggered ||
923                                                   919                                                 edDigitizerHasTriggered ) ) );
924             if ( drawTrajectories )               920             if ( drawTrajectories )
925             {                                     921             {
926                 DrawTrajectories( event );        922                 DrawTrajectories( event );
927                 if ( tpDigitizerHasTriggered )    923                 if ( tpDigitizerHasTriggered )
928                     DrawTrackPoints( tpStore )    924                     DrawTrackPoints( tpStore );
929                 if ( reconstructorHasBasicTrig    925                 if ( reconstructorHasBasicTrigger )
930                     DrawReconstructionData();     926                     DrawReconstructionData();
931             }                                     927             }
932         }                                         928         }
933                                                   929 
934 #ifdef CEXMC_USE_PERSISTENCY                      930 #ifdef CEXMC_USE_PERSISTENCY
935         if ( edDigitizerHasTriggered || tpDigi    931         if ( edDigitizerHasTriggered || tpDigitizerHasTriggered )
936         {                                         932         {
937             SaveEventFast( event, tpDigitizerH    933             SaveEventFast( event, tpDigitizerHasTriggered,
938                            edDigitizerHasTrigg    934                            edDigitizerHasTriggered,
939                            edDigitizerMonitorH    935                            edDigitizerMonitorHasTriggered,
940                            pmData.outputPartic    936                            pmData.outputParticleSCM.cosTheta() );
941             SaveEvent( event, edDigitizerHasTr    937             SaveEvent( event, edDigitizerHasTriggered, edStore, tpStore,
942                        pmData );                  938                        pmData );
943         }                                         939         }
944 #endif                                            940 #endif
945                                                   941 
946 #ifdef CEXMC_USE_ROOT                             942 #ifdef CEXMC_USE_ROOT
947         /* opKinEnergy will be used in several    943         /* opKinEnergy will be used in several histos */
948         if ( tpStore->targetTPOutputParticle.I    944         if ( tpStore->targetTPOutputParticle.IsValid() )
949         {                                         945         {
950             opKinEnergy = CexmcGetKinEnergy(      946             opKinEnergy = CexmcGetKinEnergy(
951                     tpStore->targetTPOutputPar    947                     tpStore->targetTPOutputParticle.momentumAmp,
952                     tpStore->targetTPOutputPar    948                     tpStore->targetTPOutputParticle.particle->GetPDGMass() );
953         }                                         949         }
954                                                   950 
955         if ( edDigitizerHasTriggered )            951         if ( edDigitizerHasTriggered )
956             FillEDTHistos( edStore, triggeredA    952             FillEDTHistos( edStore, triggeredAngularRanges );
957                                                   953 
958         /* fill TPT histos only when the monit    954         /* fill TPT histos only when the monitor has triggered because events
959          * when it was missed have less value     955          * when it was missed have less value for us */
960         if ( tpDigitizerHasTriggered && edDigi    956         if ( tpDigitizerHasTriggered && edDigitizerMonitorHasTriggered )
961             FillTPTHistos( tpStore, pmData, tr    957             FillTPTHistos( tpStore, pmData, triggeredAngularRanges );
962                                                   958 
963         if ( reconstructorHasBasicTrigger )       959         if ( reconstructorHasBasicTrigger )
964             FillRTHistos( reconstructorHasFull    960             FillRTHistos( reconstructorHasFullTrigger, edStore, tpStore,
965                           pmData, triggeredAng    961                           pmData, triggeredAngularRanges );
966 #endif                                            962 #endif
967                                                   963 
968         G4Event *  theEvent( const_cast< G4Eve    964         G4Event *  theEvent( const_cast< G4Event * >( event ) );
969         if ( eventInfo )                          965         if ( eventInfo )
970         {                                         966         {
971             delete eventInfo;                     967             delete eventInfo;
972             theEvent->SetUserInformation( NULL    968             theEvent->SetUserInformation( NULL );
973         }                                         969         }
974         theEvent->SetUserInformation( new Cexm    970         theEvent->SetUserInformation( new CexmcEventInfo(
975                                                   971                                                 edDigitizerHasTriggered,
976                                                   972                                                 tpDigitizerHasTriggered,
977                                                   973                                                 reconstructorHasFullTrigger ) );
978     }                                             974     }
979     catch ( CexmcException &  e )                 975     catch ( CexmcException &  e )
980     {                                             976     {
981         G4cout << e.what() << G4endl;             977         G4cout << e.what() << G4endl;
982     }                                             978     }
983     catch ( ... )                                 979     catch ( ... )
984     {                                             980     {
985         G4cout << "Unknown exception caught" <    981         G4cout << "Unknown exception caught" << G4endl;
986     }                                             982     }
987                                                   983 
988     delete edStore;                               984     delete edStore;
989     delete tpStore;                               985     delete tpStore;
990 }                                                 986 }
991                                                   987 
992                                                   988