QwGeant4
QweakSimEventAction.cc
Go to the documentation of this file.
1 //=============================================================================
2 //
3 // ---------------------------
4 // | Doxygen File Information |
5 // ---------------------------
6 //
7 /**
8 
9  \file QweakSimEventAction.cc
10 
11  $Date: Fri Jul 3 11:38:14 CDT 2009 $
12 
13  \author Klaus Hans Grimm
14  \author Jie Pan
15 
16 */
17 //=============================================================================
18 
19 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
20 
21 #include "QweakSimEventAction.hh"
23 
24 // geant4 includes
25 #include "G4Event.hh"
26 #include "G4UserEventAction.hh"
27 #include "G4SDManager.hh"
28 
29 // user includes
30 #include "QweakSimAnalysis.hh"
33 //#include "QweakSimGEM_WirePlaneHit.hh"
48 #include "QweakSimTrajectory.hh"
49 #include "QweakSimUserMainEvent.hh"
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
53 : analysis(AN),myUserInfo(UI)
54 {
55 //---------------------------------------------------------------------------------------------
56 //! Constructor of QweakSimEventAction
57  /*!
58 
59  \param AN class containing the Geamt4 hit data structure
60  \param myUI class containing user information like Q2 for this event or QE of some PMTs
61  which is needed for processing/saving hit information
62 
63 
64  */
65 //---------------------------------------------------------------------------------------------
66 
67 
85 
86  // Event action messenger
88 
89  // Initialize map from string to trigger mode
90  fTrigger.resize(kNumTriggers, false);
91  fTriggerName.resize(kNumTriggers);
92  if (kMapTriggerMode.size() == 0) {
94  fTriggerName[kTriggerAll] = "all";
95  kMapTriggerMode["4fold"] = kTrigger4Fold;
96  fTriggerName[kTrigger4Fold] = "4fold";
97  kMapTriggerMode["3fold"] = kTrigger3Fold;
98  fTriggerName[kTrigger3Fold] = "3fold";
99  kMapTriggerMode["scint"] = kTriggerScint;
100  fTriggerName[kTriggerScint] = "scint";
101  kMapTriggerMode["leadglass"] = kTriggerLeadGlass; // trigger for the lead glass
102  fTriggerName[kTriggerLeadGlass] = "leadglass";
103  // kMapTriggerMode["gem"] = kTriggerGEM;
104  // fTriggerName[kTriggerGEM] = "gem";
105  kMapTriggerMode["cer"] = kTriggerCer;
106  fTriggerName[kTriggerCer] = "cer";
107  kMapTriggerMode["hdc"] = kTriggerHDC;
108  fTriggerName[kTriggerHDC] = "hdc";
109  kMapTriggerMode["pmtonly"] = kTriggerPMTOnly;
110  fTriggerName[kTriggerPMTOnly] = "pmtonly";
113  fTriggerName[kTriggerLumi] = "lumi";
114  kMapTriggerMode["lumi"] = kTriggerLumi; // trigger for the lumi
115  }
116  if (kMapTriggerMode.size() != kNumTriggers)
117  G4cout << "Number of software triggers is not defined correctly!" << G4endl;
118 
119  // Initialize software trigger to false
120  for (size_t iTrigger = 0; iTrigger < fTrigger.size(); iTrigger++)
121  fTrigger[iTrigger] = false;
122 
123  // By default enable only cerenkov trigger
124  fTrigger[kTriggerCer] = true;
125 
126  // By default, enable print out of hit information
127  printhits = true;
128 }
129 
130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
132 {
133  // Delete the event action messenger
135 }
136 
137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
139 {
140  for (size_t iTrigger = 0; iTrigger < fTrigger.size(); iTrigger++)
141  G4cout << (fTrigger[iTrigger]? "Enabled":"Disabled")
142  << " software trigger " << fTriggerName[iTrigger] << "." << G4endl;
143 }
144 
145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
146 void QweakSimEventAction::SetTrigger(const G4String value, const G4bool status)
147 {
148  // No error checking here...
149  //std::transform(value.begin(), value.end(), value.begin(), std::tolower);
150  fTrigger[kMapTriggerMode[value]] = status;
151  G4cout << (status? "Enabled":"Disabled") << " software trigger " << value << "." << G4endl;
152 }
153 
154 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
155 void QweakSimEventAction::BeginOfEventAction(const G4Event* /*evt*/)
156 {
157  G4SDManager * SDman = G4SDManager::GetSDMpointer();
158 
159  // check for existing Target Collection ID (if it's -1 it will be assigned)
160  if (TargetDetector_CollID==-1) {
161  TargetDetector_CollID = SDman->GetCollectionID("TargetSD/TargetCollection");
162  }
163 
164  // check for existing GEM_WirePlane Collection ID (if it's -1 it will be assigned)
165 // if (GEM_WirePlane_CollID==-1) {
166 // GEM_WirePlane_CollID = SDman->GetCollectionID("GEMWirePlaneSD/GEMWirePlaneCollection");
167 // }
168 
169  // check for existing HDC_WirePlane Collection ID (if it's -1 it will be assigned)
170  if (HDC_WirePlane_CollID==-1) {
171  HDC_WirePlane_CollID = SDman->GetCollectionID("HDCWirePlaneSD/HDCWirePlaneCollection");
172  }
173 
174  // check for existing VDC_WirePlane Collection ID (if it's -1 it will be assigned)
175  if (VDC_WirePlane_CollID==-1) {
176  VDC_WirePlane_CollID = SDman->GetCollectionID("VDCWirePlaneSD/VDCWirePlaneCollection");
177  }
178 
179  // check for existing VDC_DriftCellFront Collection ID (if it's -1 it will be assigned)
180  if (VDC_DriftCellFront_CollID==-1) {
181  VDC_DriftCellFront_CollID = SDman->GetCollectionID("VDCDriftCellFrontSD/DriftCellFrontCollection");
182  }
183 
184  // check for existing VDC_DriftCellBack Collection ID (if it's -1 it will be assigned)
185  if (VDC_DriftCellBack_CollID==-1) {
186  VDC_DriftCellBack_CollID = SDman->GetCollectionID("VDCDriftCellBackSD/DriftCellBackCollection");
187  }
188 
189  // check for existing TriggerScintillator Collection ID (if it's -1 it will be assigned)
191  TriggerScintillatorDetector_CollID = SDman->GetCollectionID("TriggerScintillatorSD/TriggerScintillatorCollection");
192  }
193 
194  // check for existing LeadGlass Collection ID (if it's -1 it will be assigned)
195  if (LeadGlassDetector_CollID==-1) {
196  LeadGlassDetector_CollID = SDman->GetCollectionID("LeadGlassSD/LeadGlassCollection");
197  }
198 
199  // check for existing PMTOnly Collection ID (if it's -1 it will be assigned)
200  if (PMTOnlyDetector_CollID==-1) {
201  PMTOnlyDetector_CollID = SDman->GetCollectionID("PMTOnlySD/PMTOnlyCollection");
202  }
203 
204  // check for existing PMTOnly Collection ID (if it's -1 it will be assigned)
205  if (PMTOnlyDetectorPMT_CollID==-1) {
206  PMTOnlyDetectorPMT_CollID = SDman->GetCollectionID("PMTOnly_PMTSD/PMTHitCollection");
207  }
208 
209  // check for existing LumiDetector Collection ID (if it's -1 it will be assigned)
210  if (LumiDetector_CollID==-1) {
211  // Do we want to change this so that both US and DS lumis have the same SD?
212  LumiDetector_CollID = SDman->GetCollectionID("USLumiSD/LumiCollection");
213  }
214 
215  // check for existing TungstenPlug Collection ID (if it's -1 it will be assigned)
216  if (TungstenPlugDetector_CollID==-1) {
217  TungstenPlugDetector_CollID = SDman->GetCollectionID("TungstenPlugSD/TungstenPlugCollection");
218  }
219 
220  // check for existing CerenkovDetector Collection ID (if it's -1 it will be assigned)
221  if (CerenkovDetector_CollID==-1) {
222  CerenkovDetector_CollID = SDman->GetCollectionID("CerenkovDetectorSD/CerenkovDetectorCollection");
223  }
224 
225  // check for existing CerenkovRadiator Collection ID (if it's -1 it will be assigned)
226  if (CerenkovRadiator_CollID==-1) {
227  CerenkovRadiator_CollID = SDman->GetCollectionID("CerenkovRadiatorSD/CerenkovRadiatorCollection");
228  }
229 
230  // check for existing CerenkovDetectorPMT Collection ID (if it's -1 it will be assigned)
231  if (CerenkovDetectorPMT_CollID==-1) {
232  CerenkovDetectorPMT_CollID = SDman->GetCollectionID("CerenkovPMTSD/PMTHitCollection");
233  }
234 }
235 
236 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
237 
238 void QweakSimEventAction::EndOfEventAction(const G4Event* evt) {
239 
240 //-----------------------------------------------------------------------------
241 // I'm playing with the QweakSimTrajectory
242 // Startup: LXe example
243 // Goal: sace track or track points into ROOT file
244 //
245  G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer();
246 
247  G4int n_trajectories = 0;
248 
249  if (trajectoryContainer) n_trajectories = trajectoryContainer->entries();
250 
251  // extract the trajectories and draw them
252  if (G4VVisManager::GetConcreteInstance()) {
253 
254  for (G4int i=0; i<n_trajectories; i++) {
255 
256  QweakSimTrajectory* trj = (QweakSimTrajectory*) ((*(evt->GetTrajectoryContainer()))[i]);
257  trj->DrawTrajectory();
258 
259  }
260  }
261 
262 //-----------------------------------------------------------------------------
263 
264  // preset variables for hit collection
265  Initialize();
266 
267  // Get event number
268  G4int myEventCounter = myUserInfo->GetPrimaryEventNumber();
269 
270 
271  // Odd events: generated upstream and used to calculate prescattering energy loss
272  if (myEventCounter%2 == 1) {
273 
274  // Initialize Primary information
276 
277  // Store random seed
278  G4String RandomSeed = evt->GetRandomNumberStatus();
279  analysis->fRootEvent->Primary.StoreRandomSeed(TString(RandomSeed));
280 
281  // That's all for the prescattering energy loss events
282  return;
283  }
284 
285 
286  // Get hit collection
287  G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
288 
289  // initialize HitsCollection pointers
290  QweakSimTarget_DetectorHitsCollection* TargetDetector_HC = 0;
291  //QweakSimGEM_WirePlane_HitsCollection* GEM_WirePlane_HC = 0;
292  QweakSimHDC_WirePlane_HitsCollection* HDC_WirePlane_HC = 0;
293  QweakSimVDC_WirePlane_HitsCollection* VDC_WirePlane_HC = 0;
294  QweakSimVDC_DriftCellHitsCollection* VDC_DriftCellFront_HC = 0;
295  QweakSimVDC_DriftCellHitsCollection* VDC_DriftCellBack_HC = 0;
296  QweakSimTriggerScintillator_DetectorHitsCollection* TriggerScintillatorDetector_HC = 0;
297  //QweakSimTriggerScintillator_PMTHitsCollection* TriggerScintillatorPMT_HC = 0;
298  QweakSimLeadGlass_DetectorHitsCollection* LeadGlassDetector_HC = 0;
299  //QweakSimLeadGlass_PMTHitsCollection* LeadGlassPMT_HC = 0;
300  QweakSimPMTOnly_DetectorHitsCollection* PMTOnlyDetector_HC = 0;
301  QweakSimPMTOnly_PMTHitsCollection* PMTOnlyPMT_HC = 0;
302  QweakSimLumi_DetectorHitsCollection* LumiDetector_HC = 0;
303  QweakSimTungstenPlug_DetectorHitsCollection* TungstenPlugDetector_HC = 0;
304  QweakSimCerenkovDetectorHitsCollection* CerenkovDetector_HC = 0;
305  QweakSimCerenkovRadiatorHitsCollection* CerenkovRadiator_HC = 0;
306  QweakSimCerenkovDetector_PMTHitsCollection* CerenkovDetectorPMT_HC = 0;
307 
308  G4int n_hitTarget = 0;
309  //G4int n_GEMhitWirePlane = 0;
310  G4int n_HDChitWirePlane = 0;
311  G4int n_VDChitWirePlane = 0;
312  G4int n_VDChitDCFront = 0;
313  G4int n_VDChitDCBack = 0;
314  G4int n_hitTriggerScintillator = 0;
315  //G4int n_hitTriggerScintillatorPMT = 0;
316  G4int n_hitLeadGlass = 0;
317  //G4int n_hitLeadGlassPMT = 0;
318  G4int n_hitPMTOnly = 0;
319  G4int n_hitPMTOnlyPMT = 0;
320  G4int n_hitLumi = 0;
321  G4int n_hitTungstenPlug = 0;
322  G4int n_hitCerenkovDetector = 0;
323  G4int n_hitCerenkovRadiator = 0;
324  G4int n_hitCerenkovPMT = 0;
325 
326  if (HCE) {
327 
328  // get Target Hit Collector pointer
329  if (TargetDetector_CollID > -1) {
330  TargetDetector_HC = (QweakSimTarget_DetectorHitsCollection*)(HCE->GetHC(TargetDetector_CollID));
331  n_hitTarget = TargetDetector_HC -> entries();
332  }
333 
334  // get GEM_WirePlane Hit Collector pointer
335  //GEM_WirePlane_HC = (QweakSimGEM_WirePlane_HitsCollection*)(HCE->GetHC(GEM_WirePlane_CollID));
336  //n_GEMhitWirePlane = GEM_WirePlane_HC -> entries();
337 
338  // get HDC_WirePlane Hit Collector pointer
339  if (HDC_WirePlane_CollID > -1) {
340  HDC_WirePlane_HC = (QweakSimHDC_WirePlane_HitsCollection*)(HCE->GetHC(HDC_WirePlane_CollID));
341  n_HDChitWirePlane = HDC_WirePlane_HC -> entries();
342  }
343 
344  // get VDC_WirePlane Hit Collector pointer
345  if (VDC_WirePlane_CollID > -1) {
346  VDC_WirePlane_HC = (QweakSimVDC_WirePlane_HitsCollection*)(HCE->GetHC(VDC_WirePlane_CollID));
347  n_VDChitWirePlane = VDC_WirePlane_HC -> entries();
348  }
349 
350  // get VDC_DriftCellFront Hit Collector pointer
351  if (VDC_DriftCellFront_CollID > -1) {
352  VDC_DriftCellFront_HC = (QweakSimVDC_DriftCellHitsCollection*)(HCE->GetHC(VDC_DriftCellFront_CollID));
353  n_VDChitDCFront = VDC_DriftCellFront_HC -> entries();
354  }
355 
356  // get VDC_DriftCellFront Hit Collector pointer
357  if (VDC_DriftCellBack_CollID > -1) {
358  VDC_DriftCellBack_HC = (QweakSimVDC_DriftCellHitsCollection*)(HCE->GetHC(VDC_DriftCellBack_CollID));
359  n_VDChitDCBack = VDC_DriftCellBack_HC -> entries();
360  }
361 
362  // get TriggerScintillator Hit Collector pointer
364  TriggerScintillatorDetector_HC = (QweakSimTriggerScintillator_DetectorHitsCollection*)(HCE->GetHC(TriggerScintillatorDetector_CollID));
365  n_hitTriggerScintillator = TriggerScintillatorDetector_HC -> entries();
366  }
367 
368  // get TriggerScintillatorPMT Hit Collector pointer
369  //if (TriggerScintillatorPMT_CollID > -1) {
370  // TriggerScintillatorPMT_HC = (QweakSimTriggerScintillator_PMTHitsCollection*)(HCE->GetHC(TriggerScintillatorPMT_CollID));
371  // n_hitTriggerScintillatorPMT = TriggerScintillatorPMT_HC -> entries();
372  //}
373 
374  // get LeadGlass Hit Collector pointer
375  if (LeadGlassDetector_CollID > -1) {
376  LeadGlassDetector_HC = (QweakSimLeadGlass_DetectorHitsCollection*)(HCE->GetHC(LeadGlassDetector_CollID));
377  n_hitLeadGlass = LeadGlassDetector_HC -> entries();
378  }
379 
380  // get LeadGlassPMT Hit Collector pointer
381  //if (LeadGlassPMT_CollID > -1) {
382  // LeadGlassPMT_HC = (QweakSimLeadGlass_PMTHitsCollection*)(HCE->GetHC(LeadGlassPMT_CollID));
383  // n_hitLeadGlassPMT = LeadGlassPMT_HC -> entries();
384  //}
385 
386  // get PMTOnly Hit Collector pointer
387  if (PMTOnlyDetector_CollID > -1) {
388  PMTOnlyDetector_HC = (QweakSimPMTOnly_DetectorHitsCollection*)(HCE->GetHC(PMTOnlyDetector_CollID));
389  n_hitPMTOnly = PMTOnlyDetector_HC->entries();
390  }
391 
392  // get PMTOnly_PMT Hit Collection
393  if (PMTOnlyDetectorPMT_CollID > -1) {
394  PMTOnlyPMT_HC = (QweakSimPMTOnly_PMTHitsCollection*)(HCE->GetHC(PMTOnlyDetectorPMT_CollID));
395  n_hitPMTOnlyPMT = PMTOnlyPMT_HC->entries();
396  }
397 
398  // get LumiDetector Hit Collector pointer
399  if (LumiDetector_CollID > -1) {
400  LumiDetector_HC = (QweakSimLumi_DetectorHitsCollection*)(HCE->GetHC(LumiDetector_CollID));
401  n_hitLumi = LumiDetector_HC -> entries();
402  }
403 
404  // get TungstenPlug Hit Collector pointer
405  if (TungstenPlugDetector_CollID > -1) {
406  TungstenPlugDetector_HC = (QweakSimTungstenPlug_DetectorHitsCollection*)(HCE->GetHC(TungstenPlugDetector_CollID));
407  n_hitTungstenPlug = TungstenPlugDetector_HC->entries();
408  }
409 
410  // get CerenkovDetector Hit Collector pointer
411  if (CerenkovDetector_CollID > -1) {
412  CerenkovDetector_HC = (QweakSimCerenkovDetectorHitsCollection*)(HCE->GetHC(CerenkovDetector_CollID));
413  n_hitCerenkovDetector = CerenkovDetector_HC -> entries();
414  }
415 
416  // get CerenkovRadiator Hit Collector pointer
417  if (CerenkovRadiator_CollID > -1) {
418  CerenkovRadiator_HC = (QweakSimCerenkovRadiatorHitsCollection*)(HCE->GetHC(CerenkovRadiator_CollID));
419  n_hitCerenkovRadiator = CerenkovRadiator_HC -> entries();
420  }
421 
422  // get CerenkovDetectorPMT Hit Collector pointer
423  if (CerenkovDetectorPMT_CollID > -1) {
424  CerenkovDetectorPMT_HC = (QweakSimCerenkovDetector_PMTHitsCollection*)(HCE->GetHC(CerenkovDetectorPMT_CollID));
425  n_hitCerenkovPMT = CerenkovDetectorPMT_HC -> entries();
426  }
427  }
428 
429  if (printhits) {
430  G4cout << "Target " << n_hitTarget
431  << ",\tHDC " << n_HDChitWirePlane
432  << ",\tVDC_Front " << n_VDChitDCFront
433  << ",\tVDC_Back " << n_VDChitDCBack
434  << ",\tTS " << n_hitTriggerScintillator
435  << ",\tLeadGlass " << n_hitLeadGlass
436  << ",\tPMTOnly " << n_hitPMTOnly
437  << ",\tPMTOnlyPMT " << n_hitPMTOnlyPMT
438  << ",\tLumi " << n_hitLumi
439  << ",\tTungstenPlug " << n_hitTungstenPlug
440  << ",\tCerenkovRad " << n_hitCerenkovRadiator
441  << ",\tCerenkovDet " << n_hitCerenkovDetector
442  << ",\tCerenkovPMT " << n_hitCerenkovPMT << G4endl;
443  }
444 
445 
446  // Initialize/Clear Event variables in target scattering window
448 
449  // Initialize/Clear Event variables, initialize Cerenkov Detector with NoHit Flag
453 
454  // Initialize/Clear Event variables in Region 1
457 
458  // Initialize/Clear Event variables in Region 2
465  //
472 
473  // Initialize Region 3 wire planes (2: u,v ) with NoHit Flag
476  //
479 
480  // Initialize DriftCells with NoHit Flag
482  //
484 
485  // Initialize TriggerScintillator with NoHit Flag
487 
488  // Initialize LeadGlass, PMTOnly, and TungstenPlug //--- with NoHit Flag
494 
495  //#########################################################################################################################
496  //#########################################################################################################################
497  //
498  // ================================================================
499  // The Main "Software DAQ Trigger": setting the coincidence level
500  //
501  // or: what is required for filling the Root ntuple for this event
502  // =================================================================
503  //
504  //##########################################################################################################################
505  //##########################################################################################################################
506  //
507  if ( fTrigger[kTriggerAll] /* Trigger on every event */
508  || (fTrigger[kTrigger4Fold] && (n_VDChitWirePlane == 4) && (n_VDChitDCFront > 0) && (n_VDChitDCBack > 0) && (n_hitCerenkovDetector > 0) ) /* 4-fold coincidence */
509  || (fTrigger[kTrigger3Fold] && (n_VDChitWirePlane >= 2) && (n_VDChitDCFront > 0) && (n_VDChitDCBack > 0) ) /* 3-fold coincidence */
510  || (fTrigger[kTriggerScint] && (n_hitTriggerScintillator > 0) ) /* Qweak trigger on a hit in the trigger scintillator */
511  || (fTrigger[kTriggerHDC] && (n_HDChitWirePlane >= 6)) /* HDC Trigger */
512  || (fTrigger[kTriggerLeadGlass] && (n_hitLeadGlass >0)) /* a hit in the LeadGlass */
513  || (fTrigger[kTriggerPMTOnly] && (n_hitPMTOnly >0)) /* a hit in the PMTOnly */
514  || (fTrigger[kTriggerLumi] && (n_hitLumi > 0))
515  || (fTrigger[kTriggerTungstenPlug] && (n_hitTungstenPlug>0) ) // Hit on the TungstenPlug
516  || (fTrigger[kTriggerCer] && (n_hitCerenkovDetector > 0) ) /* Triggering on Main Detector */
517  ) {
518 
519  //========================================
520  // Store Primary Information into /Primary
521  //========================================
522 
523  //-------------------------------------------------------------------------------------------
524  G4int PrimaryEventNumber = myUserInfo->GetPrimaryEventNumber();
525  G4int ReactionRegion = myUserInfo->GetReactionRegion();
526  G4int ReactionType = myUserInfo->GetReactionType();
527  G4int PDGcode = myUserInfo->GetPDGcode();
528  G4int TrackID = myUserInfo->GetTrackID();
529  G4double GlobalTime = myUserInfo->GetGlobalTime();
530  G4double PrimaryQ2 = myUserInfo->GetPrimaryQ2();
531  G4double CrossSection = myUserInfo->GetCrossSection();
532  G4double CrossSectionWeight = myUserInfo->GetCrossSectionWeight();
533  G4double CrossSectionBornTotal = myUserInfo->GetCrossSectionBornTotal();
534  G4double CrossSectionBornInelastic = myUserInfo->GetCrossSectionBornInelastic();
535  G4double CrossSectionBornQE = myUserInfo->GetCrossSectionBornQE();
536  G4double CrossSectionRadTotal = myUserInfo->GetCrossSectionRadTotal();
537  G4double CrossSectionRadElastic = myUserInfo->GetCrossSectionRadElastic();
538  G4double CrossSectionRadQE = myUserInfo->GetCrossSectionRadQE();
539  G4double CrossSectionRadDIS = myUserInfo->GetCrossSectionRadDIS();
540  G4double CrossSectionRadTotalIntOnly = myUserInfo->GetCrossSectionRadTotalIntOnly();
541  G4double CrossSectionRadElasticIntOnly = myUserInfo->GetCrossSectionRadElasticIntOnly();
542  G4double CrossSectionRadQEIntOnly = myUserInfo->GetCrossSectionRadQEIntOnly();
543  G4double CrossSectionRadDISIntOnly = myUserInfo->GetCrossSectionRadDISIntOnly();
544  G4double CrossSectionRadElasticPeak = myUserInfo->GetCrossSectionRadElasticPeak();
545  G4double Asymmetry = myUserInfo->GetAsymmetry();
546  G4double OriginVertexPositionX = myUserInfo->GetOriginVertexPositionX();
547  G4double OriginVertexPositionY = myUserInfo->GetOriginVertexPositionY();
548  G4double OriginVertexPositionZ = myUserInfo->GetOriginVertexPositionZ();
549  G4double OriginVertexThetaAngle = myUserInfo->GetOriginVertexThetaAngle();
550  G4double OriginVertexPhiAngle = myUserInfo->GetOriginVertexPhiAngle();
551  G4double OriginVertexMomentumDirectionX = myUserInfo->GetOriginVertexMomentumDirectionX();
552  G4double OriginVertexMomentumDirectionY = myUserInfo->GetOriginVertexMomentumDirectionY();
553  G4double OriginVertexMomentumDirectionZ = myUserInfo->GetOriginVertexMomentumDirectionZ();
554  G4double PreScatteringKineticEnergy = myUserInfo->GetPreScatteringKineticEnergy();
555  G4double OriginVertexKineticEnergy = myUserInfo->GetOriginVertexKineticEnergy();
556  G4double OriginVertexTotalEnergy = myUserInfo->GetOriginVertexTotalEnergy();
557 
558  G4int NumberOfEventToBeProcessed = myUserInfo->GetNumberOfEventToBeProcessed();
559  G4double PhiAngle_Min = myUserInfo->GetPhiAngle_Min();
560  G4double PhiAngle_Max = myUserInfo->GetPhiAngle_Max();
561  G4double ThetaAngle_Min = myUserInfo->GetThetaAngle_Min();
562  G4double ThetaAngle_Max = myUserInfo->GetThetaAngle_Max();
563  G4double EPrime_Min = myUserInfo->GetEPrime_Min();
564  G4double EPrime_Max = myUserInfo->GetEPrime_Max();
565  G4double BeamEnergy = myUserInfo->GetBeamEnergy();
566  G4double Luminosity = myUserInfo->GetLuminosity();
567  G4double PhaseSpace = myUserInfo->GetPhaseSpace();
568  //CalculateKinematicVariables();
569  //G4double OriginVertexKinematicNu = myUserInfo->GetOriginVertexKinematicNu();
570  //G4double OriginVertexKinematicQ2 = myUserInfo->GetOriginVertexKinematicQ2();
571  //G4double OriginVertexKinematicX = myUserInfo->GetOriginVertexKinematicX();
572  //G4double OriginVertexKinematicW = myUserInfo->GetOriginVertexKinematicW();
573  //G4double EffectiveKinematicNu = myUserInfo->GetEffectiveKinematicNu();
574  //G4double EffectiveKinematicQ2 = myUserInfo->GetEffectiveKinematicQ2();
575  //G4double EffectiveKinematicX = myUserInfo->GetEffectiveKinematicX();
576  //G4double EffectiveKinematicW = myUserInfo->GetEffectiveKinematicW();
577 
578  analysis->fRootEvent->Primary.StoreTrackID((Int_t) TrackID);
579  analysis->fRootEvent->Primary.StoreGlobalTime((Float_t) GlobalTime);
580  analysis->fRootEvent->Primary.StoreOriginVertexPositionX((Float_t) OriginVertexPositionX);
581  analysis->fRootEvent->Primary.StoreOriginVertexPositionY((Float_t) OriginVertexPositionY);
582  analysis->fRootEvent->Primary.StoreOriginVertexPositionZ((Float_t) OriginVertexPositionZ);
583  analysis->fRootEvent->Primary.StoreOriginVertexMomentumDirectionX((Float_t) OriginVertexMomentumDirectionX);
584  analysis->fRootEvent->Primary.StoreOriginVertexMomentumDirectionY((Float_t) OriginVertexMomentumDirectionY);
585  analysis->fRootEvent->Primary.StoreOriginVertexMomentumDirectionZ((Float_t) OriginVertexMomentumDirectionZ);
586  analysis->fRootEvent->Primary.StoreOriginVertexThetaAngle((Float_t) OriginVertexThetaAngle);
587  analysis->fRootEvent->Primary.StoreOriginVertexPhiAngle((Float_t) OriginVertexPhiAngle);
588  analysis->fRootEvent->Primary.StorePreScatteringKineticEnergy((Float_t) PreScatteringKineticEnergy);
589  analysis->fRootEvent->Primary.StoreOriginVertexKineticEnergy((Float_t) OriginVertexKineticEnergy);
590  analysis->fRootEvent->Primary.StoreOriginVertexTotalEnergy((Float_t) OriginVertexTotalEnergy);
591  analysis->fRootEvent->Primary.StorePrimaryQ2((Float_t) PrimaryQ2);
592  analysis->fRootEvent->Primary.StoreCrossSection((Float_t) CrossSection);
593  analysis->fRootEvent->Primary.StoreCrossSectionWeight((Float_t) CrossSectionWeight);
594  analysis->fRootEvent->Primary.StoreCrossSectionBornTotal ((Float_t) CrossSectionBornTotal);
595  analysis->fRootEvent->Primary.StoreCrossSectionBornInelastic((Float_t) CrossSectionBornInelastic);
596  analysis->fRootEvent->Primary.StoreCrossSectionBornQE ((Float_t) CrossSectionBornQE);
597  analysis->fRootEvent->Primary.StoreCrossSectionRadTotal ((Float_t) CrossSectionRadTotal);
598  analysis->fRootEvent->Primary.StoreCrossSectionRadElastic ((Float_t) CrossSectionRadElastic);
599  analysis->fRootEvent->Primary.StoreCrossSectionRadQE ((Float_t) CrossSectionRadQE);
600  analysis->fRootEvent->Primary.StoreCrossSectionRadDIS ((Float_t) CrossSectionRadDIS);
601  analysis->fRootEvent->Primary.StoreCrossSectionRadTotalIntOnly ((Float_t) CrossSectionRadTotalIntOnly);
602  analysis->fRootEvent->Primary.StoreCrossSectionRadElasticIntOnly((Float_t) CrossSectionRadElasticIntOnly);
603  analysis->fRootEvent->Primary.StoreCrossSectionRadQEIntOnly ((Float_t) CrossSectionRadQEIntOnly);
604  analysis->fRootEvent->Primary.StoreCrossSectionRadDISIntOnly ((Float_t) CrossSectionRadDISIntOnly);
605  analysis->fRootEvent->Primary.StoreCrossSectionRadElasticPeak ((Float_t) CrossSectionRadElasticPeak);
606  analysis->fRootEvent->Primary.StoreAsymmetry((Float_t) Asymmetry);
607  analysis->fRootEvent->Primary.StorePrimaryEventNumber((Int_t) PrimaryEventNumber);
608  analysis->fRootEvent->Primary.StoreReactionRegion((Int_t) ReactionRegion);
609  analysis->fRootEvent->Primary.StoreReactionType((Int_t) ReactionType);
610  analysis->fRootEvent->Primary.StorePDGcode((Int_t) PDGcode);
611  analysis->fRootEvent->Primary.StoreNumberOfEventToBeProcessed((Int_t) NumberOfEventToBeProcessed);
612  analysis->fRootEvent->Primary.StorePhiAngle_Min((Float_t) PhiAngle_Min/degree);
613  analysis->fRootEvent->Primary.StorePhiAngle_Max((Float_t) PhiAngle_Max/degree);
614  analysis->fRootEvent->Primary.StoreThetaAngle_Min((Float_t) ThetaAngle_Min/degree);
615  analysis->fRootEvent->Primary.StoreThetaAngle_Max((Float_t) ThetaAngle_Max/degree);
616  analysis->fRootEvent->Primary.StoreEPrime_Min((Float_t) EPrime_Min);
617  analysis->fRootEvent->Primary.StoreEPrime_Max((Float_t) EPrime_Max);
618  analysis->fRootEvent->Primary.StoreBeamEnergy((Float_t) BeamEnergy);
619  analysis->fRootEvent->Primary.StoreLuminosity((Float_t) Luminosity);
620  analysis->fRootEvent->Primary.StorePhaseSpace((Float_t) PhaseSpace);
621  //analysis->fRootEvent->Primary.StoreOriginVertexKinematicNu((Float_t) OriginVertexKinematicNu);
622  //analysis->fRootEvent->Primary.StoreOriginVertexKinematicQ2((Float_t) OriginVertexKinematicQ2);
623  //analysis->fRootEvent->Primary.StoreOriginVertexKinematicX((Float_t) OriginVertexKinematicX);
624  //analysis->fRootEvent->Primary.StoreOriginVertexKinematicW((Float_t) OriginVertexKinematicW);
625  //analysis->fRootEvent->Primary.StoreEffectiveKinematicNu((Float_t) EffectiveKinematicNu);
626  //analysis->fRootEvent->Primary.StoreEffectiveKinematicQ2((Float_t) EffectiveKinematicQ2);
627  //analysis->fRootEvent->Primary.StoreEffectiveKinematicX((Float_t) EffectiveKinematicX);
628  //analysis->fRootEvent->Primary.StoreEffectiveKinematicW((Float_t) EffectiveKinematicW);
629 
630  ////////
631  // store energy loss variables into rootfile
632  // all Elosses are in MeV (see QweakSimSteppingAction.cc)
645  ///////
646 
647  //==========================================================================================
648 
649  //===========================================
650  // Store Number Of Hits of each Detector
651  //===========================================
652 
653  // Store Number of Hits for: UPlane DriftCell of Front Chamber
655 
656  // Store Number of Hits for: VPlane DriftCell of Front Chamber
658 
659  // Store Number of Hits for: Cerenkov Detector
660  analysis->fRootEvent->Cerenkov.Detector.StoreDetectorNbOfHits(n_hitCerenkovDetector);
661 
662  // Store Number of Hits for: Cerenkov Radiator
663  analysis->fRootEvent->Cerenkov.Radiator.StoreDetectorNbOfHits(n_hitCerenkovRadiator);
664 
665  // Store Number of Hits for: Cerenkov PMT Detector
667 
668  // Store Number of Hits for: Target Detector
670 
671  // Store Number of Hits for: LeadGlass Detector
673 
674  // Store Number of Hits for: PMTOnly Detector
676 
677  // Store Number of Hits for: PMTOnly PMT Detector
679 
680  // Store Number of Hits for: Lumi Detector
682 
683  // Store Number of Hits for: TungstenPlug Detector
685 
686  // Store Number of Hits for: Trigger Scintillator
688 
689  //==========================================================================================================
690 
691 
692  //========================================
693  // Store VDC Hit Information into /Region3
694  //========================================
695 
696  int VDC_Chamber_Plane_NbOfHits[2][2];
697  for (int chamber = 0; chamber < 2; chamber++)
698  for (int plane = 0; plane < 2; plane++)
699  VDC_Chamber_Plane_NbOfHits[chamber][plane] = 0;
700 
701  // loop over wire plane hits
702  for (int i1=0;i1<n_VDChitWirePlane;i1++) {
703 
704  // get hit pointer for each hit
705  QweakSimVDC_WirePlaneHit* aHit = (*VDC_WirePlane_HC)[i1];
706 
707  if (print_VDC_WirePlaneHit) aHit->Print();
708 
709  // get local position of hit
710  G4ThreeVector localPosition = aHit->GetLocalPosition();
711  Float_t rLocalPositionX = (Float_t) localPosition.x() / cm;
712  Float_t rLocalPositionY = (Float_t) localPosition.y() / cm;
713  Float_t rLocalPositionZ = (Float_t) localPosition.z() / cm;
714 
715  // get world position of hit
716  G4ThreeVector globalPosition = aHit->GetWorldPosition();
717  Float_t rGlobalPositionX = (Float_t) globalPosition.x() / cm;
718  Float_t rGlobalPositionY = (Float_t) globalPosition.y() / cm;
719  Float_t rGlobalPositionZ = (Float_t) globalPosition.z() / cm;
720 
721  // get local Momentum of hit
722  G4ThreeVector localMomentum = aHit->GetLocalMomentum();
723  Float_t rLocalMomentumX = (Float_t) localMomentum.x() / MeV;
724  Float_t rLocalMomentumY = (Float_t) localMomentum.y() / MeV;
725  Float_t rLocalMomentumZ = (Float_t) localMomentum.z() / MeV;
726 
727  // get world Momentum of hit
728  G4ThreeVector globalMomentum = aHit->GetWorldMomentum();
729  Float_t rGlobalMomentumX = (Float_t) globalMomentum.x() / MeV;
730  Float_t rGlobalMomentumY = (Float_t) globalMomentum.y() / MeV;
731  Float_t rGlobalMomentumZ = (Float_t) globalMomentum.z() / MeV;
732  Float_t rGlobalThetaAngle = (Float_t) globalMomentum.theta() / degree;
733  Float_t rGlobalPhiAngle = (Float_t) globalMomentum.phi() / degree - 90.0;
734 
735  // get total Energy of hit
736  Float_t rTotalEnergy = (Float_t) aHit->GetTotalEnergy() / MeV;
737 
738  // get kinetic Energy of hit
739  Float_t rKineticEnergy = (Float_t) aHit->GetKineticEnergy() / MeV;
740 
741 
742  G4ThreeVector originVertexPosition = aHit->GetOriginVertexPosition();
743  Float_t rOriginVertexPositionX = (Float_t) originVertexPosition.x() / cm;
744  Float_t rOriginVertexPositionY = (Float_t) originVertexPosition.y() / cm;
745  Float_t rOriginVertexPositionZ = (Float_t) originVertexPosition.z() / cm;
746 
747 
748  G4ThreeVector originVertexMomentumDirection = aHit->GetOriginVertexMomentumDirection();
749  Float_t rOriginVertexMomentumDirectionX = (Float_t) originVertexMomentumDirection.x();
750  Float_t rOriginVertexMomentumDirectionY = (Float_t) originVertexMomentumDirection.y();
751  Float_t rOriginVertexMomentumDirectionZ = (Float_t) originVertexMomentumDirection.z();
752  Float_t rOriginVertexPhiAngle = (Float_t) originVertexMomentumDirection.phi() / degree;
753  Float_t rOriginVertexThetaAngle = (Float_t) originVertexMomentumDirection.theta() / degree;
754 
755  Float_t rOriginVertexKineticEnergy = (Float_t) aHit->GetOriginVertexKineticEnergy() / MeV;
756  Float_t rOriginVertexTotalEnergy = (Float_t) aHit->GetOriginVertexTotalEnergy() / MeV;
757 
758  Float_t rGlobalTime = (Float_t) aHit->GetGlobalTime() / ns;
759 
760  TString rParticleName = TString(aHit->GetParticleName());
761  Int_t rParticleType = (Int_t) aHit->GetParticleType();
762 
763  //-----------------------------------
764  int iVDCID = aHit->GetVDCID();
765  int iVDC_Chamber = -1; // 0 corresponds to Front, 1 corresponds to Back
766  QweakSimUserVDC_SingleVDCEvent* single_vdc_event = 0;
767  if (iVDCID == 0 || iVDCID == 2){
768  iVDC_Chamber = 0;
769  single_vdc_event = &(analysis->fRootEvent->Region3.ChamberFront);
770  }
771  if (iVDCID == 1 || iVDCID == 3){
772  iVDC_Chamber = 1;
773  single_vdc_event = &(analysis->fRootEvent->Region3.ChamberBack);
774  }
775  int iVDCpackage = -1; // 0 Corresponds to pkg 1, 1 corresponds to pkg 2
776  if(iVDCID == 0 || iVDCID == 1)
777  iVDCpackage = 1;
778  if(iVDCID == 2 || iVDCID == 3)
779  iVDCpackage = 2;
780  //-----------------------------------
781  if (single_vdc_event == 0) {
782  G4cerr << "VDC hit with incorrect chamber ID: " << iVDCID << G4endl;
783  break;
784  }
785 
786  //-----------------------------------
787  int iWirePlaneID = aHit->GetWirePlaneID();
788  QweakSimUserVDC_WirePlaneEvent* wire_plane_event = 0;
789  if (iWirePlaneID == 0)
790  wire_plane_event = &(single_vdc_event->WirePlaneU);
791  if (iWirePlaneID == 1)
792  wire_plane_event = &(single_vdc_event->WirePlaneV);
793 
794  //-----------------------------------
795  if (wire_plane_event == 0) {
796  G4cerr << "VDC hit with incorrect plane ID." << G4endl;
797  break;
798  }
799 
800  //-----------------------------------
801  VDC_Chamber_Plane_NbOfHits[iVDC_Chamber][iWirePlaneID]++;
802  wire_plane_event->StoreNbOfHits(VDC_Chamber_Plane_NbOfHits[iVDC_Chamber][iWirePlaneID]);
803 
804  // mark wire plane as been hit
805  wire_plane_event->StoreHasBeenHit(5);
806 
807  wire_plane_event->StorePackageID(iVDCpackage);
808 
809  wire_plane_event->StoreParticleName(rParticleName);
810  wire_plane_event->StoreParticleType(rParticleType);
811 
812  // store total+kinetic energy of hit
813  wire_plane_event->StoreTotalEnergy(rTotalEnergy);
814  wire_plane_event->StoreKineticEnergy(rKineticEnergy);
815 
816  // store origin vertex info
817  wire_plane_event->StoreOriginVertexPositionX(rOriginVertexPositionX);
818  wire_plane_event->StoreOriginVertexPositionY(rOriginVertexPositionY);
819  wire_plane_event->StoreOriginVertexPositionZ(rOriginVertexPositionZ);
820 
821  wire_plane_event->StoreOriginVertexMomentumDirectionX(rOriginVertexMomentumDirectionX);
822  wire_plane_event->StoreOriginVertexMomentumDirectionY(rOriginVertexMomentumDirectionY);
823  wire_plane_event->StoreOriginVertexMomentumDirectionZ(rOriginVertexMomentumDirectionZ);
824  wire_plane_event->StoreOriginVertexPhiAngle(rOriginVertexPhiAngle);
825  wire_plane_event->StoreOriginVertexThetaAngle(rOriginVertexThetaAngle);
826 
827  wire_plane_event->StoreOriginVertexKineticEnergy(rOriginVertexKineticEnergy);
828  wire_plane_event->StoreOriginVertexTotalEnergy(rOriginVertexTotalEnergy);
829 
830  wire_plane_event->StoreGlobalTimeOfHit(rGlobalTime);
831 
832  // store wire plane hit position
833  wire_plane_event->StoreLocalPositionX(rLocalPositionX);
834  wire_plane_event->StoreLocalPositionY(rLocalPositionY);
835  wire_plane_event->StoreLocalPositionZ(rLocalPositionZ);
836 
837  wire_plane_event->StoreGlobalPositionX(rGlobalPositionX);
838  wire_plane_event->StoreGlobalPositionY(rGlobalPositionY);
839  wire_plane_event->StoreGlobalPositionZ(rGlobalPositionZ);
840 
841  // store wire plane hit momentum
842  wire_plane_event->StoreLocalMomentumX(rLocalMomentumX);
843  wire_plane_event->StoreLocalMomentumY(rLocalMomentumY);
844  wire_plane_event->StoreLocalMomentumZ(rLocalMomentumZ);
845 
846  wire_plane_event->StoreGlobalMomentumX(rGlobalMomentumX);
847  wire_plane_event->StoreGlobalMomentumY(rGlobalMomentumY);
848  wire_plane_event->StoreGlobalMomentumZ(rGlobalMomentumZ);
849 
850  // store global track angles Phi and Theta
851  wire_plane_event->StoreGlobalPhiAngle(rGlobalPhiAngle);
852  wire_plane_event->StoreGlobalThetaAngle(rGlobalThetaAngle);
853 
854  }
855 
856 //=========================================================================================================
857 
858  //----------------------------------
859  // Hit in Front VDC, Front DriftCells
860  //----------------------------------
861  if (n_VDChitDCFront) {
862 
863  // loop over DriftCell hits
864  for (G4int i1 = 0; i1 < n_VDChitDCFront; i1++) {
865 
866  QweakSimVDC_DriftCellHit* aHit = (*VDC_DriftCellFront_HC)[i1];
867  if (print_VDC_DriftCellHit) aHit->Print();
868 
869  } // end for (G4int i1 = 0; i1 < n_VDChitDCFront; i1++)
870 
871 
872  // Extract the DriftCell Config from the 1st DC hit
873  QweakSimVDC_DriftCellHit* aHit = (*VDC_DriftCellFront_HC)[0];
874 
875 
876  Float_t rDCWidthOnFrame = (Float_t) aHit->GetDCWidthOnFrame()/mm;
877  Float_t rDCFullThickness = (Float_t) aHit->GetDCFullThickness()/mm;
878  Float_t rDCUPlaneWireAngle = (Float_t) aHit->GetDCUPlaneWireAngle()/degree;
879  Float_t rDCVPlaneWireAngle = (Float_t) aHit->GetDCVPlaneWireAngle()/degree;
880 
881  // Store DriftCell Setup Parameter
886 
887  } // end of if(n_VDChitDCFront)
888 
889 
890  //----------------------------------
891  // Hit in Front VDC, Back DriftCells
892  //----------------------------------
893  if (n_VDChitDCBack) {
894  // loop over hits
895  for (G4int i1=0;i1<n_VDChitDCBack;i1++) {
896 
897  QweakSimVDC_DriftCellHit* aHit = (*VDC_DriftCellBack_HC)[i1];
898  if (print_VDC_DriftCellHit) aHit->Print();
899 
900  } // end for(int i1=0;i1<n_hitBack;i1++
901 
902 
903  } // end of if(n_VDChitDCBack)
904 
905 
906 
907  //===============================================================================================================
908 
909  //=========================================================
910  // Store Cerenkov Detector hits into /Cerenkov
911  //=========================================================
912 
913  if (n_hitCerenkovDetector > 0) {
914 
915  // loop over hits
916  for (int i1 = 0; i1 < n_hitCerenkovDetector; i1++) {
917 
918  QweakSimCerenkov_DetectorHit* aHit = (*CerenkovDetector_HC)[i1];
919 
920  G4int octantID = (Int_t) aHit->GetDetectorID() + 1;
921 
922  if (print_Cerenkov_DetectorHit) aHit->Print();
923 
924  // get local position of hit
925  G4ThreeVector localPosition = aHit->GetLocalPosition();
926  Float_t rLocalPositionX = (Float_t) localPosition.x() / cm;
927  Float_t rLocalPositionY = (Float_t) localPosition.y() / cm;
928  Float_t rLocalPositionZ = (Float_t) localPosition.z() / cm;
929 
930  // get world position of hit
931  G4ThreeVector globalPosition = aHit->GetWorldPosition();
932  Float_t rGlobalPositionX = (Float_t) globalPosition.x() / cm;
933  Float_t rGlobalPositionY = (Float_t) globalPosition.y() / cm;
934  Float_t rGlobalPositionZ = (Float_t) globalPosition.z() / cm;
935 
936  // get local Momentum of hit
937  G4ThreeVector localMomentum = aHit->GetLocalMomentum();
938  Float_t rLocalMomentumX = (Float_t) localMomentum.x() / MeV;
939  Float_t rLocalMomentumY = (Float_t) localMomentum.y() / MeV;
940  Float_t rLocalMomentumZ = (Float_t) localMomentum.z() / MeV;
941  Float_t rLocalPhiAngle = (Float_t) localMomentum.phi() / degree - 90.0;
942  Float_t rLocalThetaAngle = (Float_t) localMomentum.theta() / degree;
943 
944  // get world Momentum of hit
945  G4ThreeVector globalMomentum = aHit->GetWorldMomentum();
946  Float_t rGlobalMomentumX = (Float_t) globalMomentum.x() / MeV;
947  Float_t rGlobalMomentumY = (Float_t) globalMomentum.y() / MeV;
948  Float_t rGlobalMomentumZ = (Float_t) globalMomentum.z() / MeV;
949  Float_t rGlobalPhiAngle = (Float_t) globalMomentum.phi() / degree - 90.0;
950  Float_t rGlobalThetaAngle = (Float_t) globalMomentum.theta() / degree;
951 
952  G4ThreeVector localExitPosition = myUserInfo->GetLocalCerenkovExitPosition();
953  Float_t rLocalExitPositionX = (Float_t) localExitPosition.x() / cm;
954  Float_t rLocalExitPositionY = (Float_t) localExitPosition.y() / cm;
955  Float_t rLocalExitPositionZ = (Float_t) localExitPosition.z() / cm;
956 
957  G4ThreeVector originVertexPosition = aHit->GetOriginVertexPosition();
958  Float_t rOriginVertexPositionX = (Float_t) originVertexPosition.x() / cm;
959  Float_t rOriginVertexPositionY = (Float_t) originVertexPosition.y() / cm;
960  Float_t rOriginVertexPositionZ = (Float_t) originVertexPosition.z() / cm;
961 
962  G4ThreeVector originVertexMomentumDirection = aHit->GetOriginVertexMomentumDirection();
963  Float_t rOriginVertexMomentumDirectionX = (Float_t) originVertexMomentumDirection.x();
964  Float_t rOriginVertexMomentumDirectionY = (Float_t) originVertexMomentumDirection.y();
965  Float_t rOriginVertexMomentumDirectionZ = (Float_t) originVertexMomentumDirection.z();
966  Float_t rOriginVertexPhiAngle = (Float_t) originVertexMomentumDirection.phi() / degree;
967  Float_t rOriginVertexThetaAngle = (Float_t) originVertexMomentumDirection.theta() / degree;
968 
969  Float_t rOriginVertexKineticEnergy = (Float_t) aHit->GetOriginVertexKineticEnergy() / MeV;
970  Float_t rOriginVertexTotalEnergy = (Float_t) aHit->GetOriginVertexTotalEnergy() / MeV;
971 
972  Float_t rGlobalTime = (Float_t) aHit->GetGlobalTime() / ns;
973 
974  TString rParticleName = TString(aHit->GetParticleName());
975  G4int rParticleType = (Int_t) aHit->GetParticleType();
976  G4int rTrackId = (Int_t) aHit->GetTrackID();
977  G4int rParentId = (Int_t) aHit->GetParentID();
978  TString rCreatorName = TString(aHit->GetCreatorProcessName());
979 
980  // get total Energy of hit
981  Float_t rTotalEnergy = (Float_t) aHit->GetTotalEnergy() / MeV;
982 
983  // get kinetic Energy of hit
984  Float_t rKineticEnergy = (Float_t) aHit->GetKineticEnergy() / MeV;
985 
986  // get polarization of hit
987  G4ThreeVector rGlobalPolarizationVector = aHit->GetPolarization();
988  Float_t rGlobalPolarizationX = rGlobalPolarizationVector.x();
989  Float_t rGlobalPolarizationY = rGlobalPolarizationVector.y();
990  Float_t rGlobalPolarizationZ = rGlobalPolarizationVector.z();
991 
992  Float_t rLongitudinalPolarization = 0.0;
993  G4ThreeVector rTransversePolarizationVector = G4ThreeVector(0.0,0.0,0.0);
994  if (globalMomentum.mag() > 0){
995  // longitudinal polarization is along the momentum direction
996  rLongitudinalPolarization = rGlobalPolarizationVector.dot(globalMomentum)/globalMomentum.mag()/rGlobalPolarizationVector.mag();
997  // transverse polarization is all except longitudinal
998  rTransversePolarizationVector = rGlobalPolarizationVector - rLongitudinalPolarization*globalMomentum/globalMomentum.mag();
999  }
1000  Float_t rTransversePolarization = rTransversePolarizationVector.mag();
1001  Float_t rTransversePolarizationX = rTransversePolarizationVector.x();
1002  Float_t rTransversePolarizationY = rTransversePolarizationVector.y();
1003  Float_t rTransversePolarizationZ = rTransversePolarizationVector.z();
1004  Float_t rTransversePolarizationPhiAngle = rTransversePolarizationVector.phi() / degree;
1005 
1006  // edgeEvent = myUserInfo->GetEdgeEventDetected();
1007 
1008  //==========================================================
1020  analysis->fRootEvent->Cerenkov.Detector.StoreOriginVertexMomentumDirectionX(rOriginVertexMomentumDirectionX);
1021  analysis->fRootEvent->Cerenkov.Detector.StoreOriginVertexMomentumDirectionY(rOriginVertexMomentumDirectionY);
1022  analysis->fRootEvent->Cerenkov.Detector.StoreOriginVertexMomentumDirectionZ(rOriginVertexMomentumDirectionZ);
1025 
1026  analysis->fRootEvent->Cerenkov.Detector.StoreOriginVertexKineticEnergy(rOriginVertexKineticEnergy);
1028 
1038 
1039  // store polarization of hit
1040  analysis->fRootEvent->Cerenkov.Detector.StorePolarizationX(rGlobalPolarizationX);
1041  analysis->fRootEvent->Cerenkov.Detector.StorePolarizationY(rGlobalPolarizationY);
1042  analysis->fRootEvent->Cerenkov.Detector.StorePolarizationZ(rGlobalPolarizationZ);
1043  analysis->fRootEvent->Cerenkov.Detector.StoreLongitudinalPolarization(rLongitudinalPolarization);
1048  analysis->fRootEvent->Cerenkov.Detector.StoreTransversePolarizationPhiAngle(rTransversePolarizationPhiAngle);
1049 
1050  // store local momentum and track angles Phi and Theta
1056 
1057  // store global momentum and track angles Phi and Theta
1063 
1064  // store total+kinetic energy of a hit
1067 
1068  //-----------------------------------------------------------------------------
1069 //
1070 // Peiqing: comment out the followings for speeding up
1071 //
1072 // for (int sec = 0; sec < myUserInfo->GetCerenkovSecondaryParticleCount(); sec++) {
1073 //
1074 // SecondaryParticleOrigin = myUserInfo->GetCerenkovSecondaryParticleOrigin(sec);
1075 // rSecondaryPartOriginX = (Float_t) SecondaryParticleOrigin.x()/cm;
1076 // rSecondaryPartOriginY = (Float_t) SecondaryParticleOrigin.y()/cm;
1077 // rSecondaryPartOriginZ = (Float_t) SecondaryParticleOrigin.z()/cm;
1078 //
1079 // SecondaryParticleMomentum = myUserInfo->GetCerenkovSecondaryParticleMomentum(sec);
1080 // rSecondaryPartMomentumX = (Float_t) SecondaryParticleMomentum.x()/MeV;
1081 // rSecondaryPartMomentumY = (Float_t) SecondaryParticleMomentum.y()/MeV;
1082 // rSecondaryPartMomentumZ = (Float_t) SecondaryParticleMomentum.z()/MeV;
1083 //
1084 // rSecondaryPartEnergy = (Float_t) myUserInfo->GetCerenkovSecondaryParticleEnergy(sec)/MeV;
1085 // rSecondaryPartCharge = (Float_t) myUserInfo->GetCerenkovSecondaryParticleCharge(sec);
1086 //
1087 // analysis->fRootEvent->Cerenkov.Detector.AddSecondaryParticleEvent(rSecondaryPartOriginX,
1088 // rSecondaryPartOriginY,
1089 // rSecondaryPartOriginZ,
1090 // rSecondaryPartMomentumX,
1091 // rSecondaryPartMomentumY,
1092 // rSecondaryPartMomentumZ,
1093 // rSecondaryPartEnergy,
1094 // rSecondaryPartCharge);
1095 // } // end for (int sec = 0; sec < myUserInfo->GetCerenkovSecondaryParticleCount(); sec++)
1096  //-----------------------------------------------------------------------------
1097 
1098  //--------------------------------------------------------------------------------------------
1099  // Check if the track passed entirely thru the cerenkov detector without getting stuck
1100  // or hitting an edge
1101  Int_t edgeEvent;
1102  if (GetDistance(localPosition,localExitPosition)/cm < 1.15)
1103  edgeEvent = 1;
1104  else
1105  edgeEvent = 0;
1106 
1108 
1109  // G4cout << "Edge Event Flag = " << edgeEvent << G4endl;
1110  //--------------------------------------------------------------------------------------------
1111 
1112 
1113  } // end for (int i1 = 0; i1 < n_hitCerenkovDetector; i1++)
1114  } // end if (n_hitCerenkovDetector > 0)
1115 
1116 
1117  //=========================================================
1118  // Store Cerenkov radiator hits into /CerenkovRadiator
1119  //=========================================================
1120 
1121  if (n_hitCerenkovRadiator > 0) {
1122 
1123  // loop over hits
1124  for (int i1 = 0; i1 < n_hitCerenkovRadiator; i1++) {
1125 
1126  QweakSimCerenkov_RadiatorHit* aHit = (*CerenkovRadiator_HC)[i1];
1127 
1128  G4int octantID = (Int_t) aHit->GetDetectorID() + 1;
1129 
1130  if (print_Cerenkov_DetectorHit) aHit->Print();
1131 
1132  // get local position of hit
1133  G4ThreeVector localPosition = aHit->GetLocalPosition();
1134  Float_t rLocalPositionX = (Float_t) localPosition.x() / cm;
1135  Float_t rLocalPositionY = (Float_t) localPosition.y() / cm;
1136  Float_t rLocalPositionZ = (Float_t) localPosition.z() / cm;
1137 
1138  // get world position of hit
1139  G4ThreeVector globalPosition = aHit->GetWorldPosition();
1140  Float_t rGlobalPositionX = (Float_t) globalPosition.x() / cm;
1141  Float_t rGlobalPositionY = (Float_t) globalPosition.y() / cm;
1142  Float_t rGlobalPositionZ = (Float_t) globalPosition.z() / cm;
1143 
1144  // get local Momentum of hit
1145  G4ThreeVector localMomentum = aHit->GetLocalMomentum();
1146  Float_t rLocalMomentumX = (Float_t) localMomentum.x() / MeV;
1147  Float_t rLocalMomentumY = (Float_t) localMomentum.y() / MeV;
1148  Float_t rLocalMomentumZ = (Float_t) localMomentum.z() / MeV;
1149  Float_t rLocalPhiAngle = (Float_t) localMomentum.phi() / degree - 90.0;
1150  Float_t rLocalThetaAngle = (Float_t) localMomentum.theta() / degree;
1151 
1152  // get world Momentum of hit
1153  G4ThreeVector globalMomentum = aHit->GetWorldMomentum();
1154  Float_t rGlobalMomentumX = (Float_t) globalMomentum.x() / MeV;
1155  Float_t rGlobalMomentumY = (Float_t) globalMomentum.y() / MeV;
1156  Float_t rGlobalMomentumZ = (Float_t) globalMomentum.z() / MeV;
1157  Float_t rGlobalPhiAngle = (Float_t) globalMomentum.phi() / degree - 90.0;
1158  Float_t rGlobalThetaAngle = (Float_t) globalMomentum.theta() / degree;
1159 
1160  G4ThreeVector localExitPosition = myUserInfo->GetLocalCerenkovExitPosition();
1161  Float_t rLocalExitPositionX = (Float_t) localExitPosition.x() / cm;
1162  Float_t rLocalExitPositionY = (Float_t) localExitPosition.y() / cm;
1163  Float_t rLocalExitPositionZ = (Float_t) localExitPosition.z() / cm;
1164 
1165  G4ThreeVector originVertexPosition = aHit->GetOriginVertexPosition();
1166  Float_t rOriginVertexPositionX = (Float_t) originVertexPosition.x() / cm;
1167  Float_t rOriginVertexPositionY = (Float_t) originVertexPosition.y() / cm;
1168  Float_t rOriginVertexPositionZ = (Float_t) originVertexPosition.z() / cm;
1169 
1170  G4ThreeVector originVertexMomentumDirection = aHit->GetOriginVertexMomentumDirection();
1171  Float_t rOriginVertexMomentumDirectionX = (Float_t) originVertexMomentumDirection.x();
1172  Float_t rOriginVertexMomentumDirectionY = (Float_t) originVertexMomentumDirection.y();
1173  Float_t rOriginVertexMomentumDirectionZ = (Float_t) originVertexMomentumDirection.z();
1174  Float_t rOriginVertexPhiAngle = (Float_t) originVertexMomentumDirection.phi() / degree;
1175  Float_t rOriginVertexThetaAngle = (Float_t) originVertexMomentumDirection.theta() / degree;
1176 
1177  Float_t rOriginVertexKineticEnergy = (Float_t) aHit->GetOriginVertexKineticEnergy() / MeV;
1178  Float_t rOriginVertexTotalEnergy = (Float_t) aHit->GetOriginVertexTotalEnergy() / MeV;
1179 
1180  Float_t rGlobalTime = (Float_t) aHit->GetGlobalTime() / ns;
1181 
1182  TString rParticleName = TString(aHit->GetParticleName());
1183  G4int rParticleType = (Int_t) aHit->GetParticleType();
1184  G4int rTrackId = (Int_t) aHit->GetTrackID();
1185  G4int rParentId = (Int_t) aHit->GetParentID();
1186  TString rCreatorName = TString(aHit->GetCreatorProcessName());
1187 
1188  // get total Energy of hit
1189  Float_t rTotalEnergy = (Float_t) aHit->GetTotalEnergy() / MeV;
1190 
1191  // get kinetic Energy of hit
1192  Float_t rKineticEnergy = (Float_t) aHit->GetKineticEnergy() / MeV;
1193 
1194  // get polarization of hit
1195  G4ThreeVector rGlobalPolarizationVector = aHit->GetPolarization();
1196  Float_t rGlobalPolarizationX = rGlobalPolarizationVector.x();
1197  Float_t rGlobalPolarizationY = rGlobalPolarizationVector.y();
1198  Float_t rGlobalPolarizationZ = rGlobalPolarizationVector.z();
1199 
1200  Float_t rLongitudinalPolarization = 0.0;
1201  G4ThreeVector rTransversePolarizationVector = G4ThreeVector(0.0,0.0,0.0);
1202  if (globalMomentum.mag() > 0){
1203  // longitudinal polarization is along the momentum direction
1204  rLongitudinalPolarization = rGlobalPolarizationVector.dot(globalMomentum)/globalMomentum.mag()/rGlobalPolarizationVector.mag();
1205  // transverse polarization is all except longitudinal
1206  rTransversePolarizationVector = rGlobalPolarizationVector - rLongitudinalPolarization*globalMomentum/globalMomentum.mag();
1207  }
1208  Float_t rTransversePolarization = rTransversePolarizationVector.mag();
1209  Float_t rTransversePolarizationX = rTransversePolarizationVector.x();
1210  Float_t rTransversePolarizationY = rTransversePolarizationVector.y();
1211  Float_t rTransversePolarizationZ = rTransversePolarizationVector.z();
1212  Float_t rTransversePolarizationPhiAngle = rTransversePolarizationVector.phi() / degree;
1213 
1214  // edgeEvent = myUserInfo->GetEdgeEventDetected();
1215 
1216  //==========================================================
1228  analysis->fRootEvent->Cerenkov.Radiator.StoreOriginVertexMomentumDirectionX(rOriginVertexMomentumDirectionX);
1229  analysis->fRootEvent->Cerenkov.Radiator.StoreOriginVertexMomentumDirectionY(rOriginVertexMomentumDirectionY);
1230  analysis->fRootEvent->Cerenkov.Radiator.StoreOriginVertexMomentumDirectionZ(rOriginVertexMomentumDirectionZ);
1233 
1234  analysis->fRootEvent->Cerenkov.Radiator.StoreOriginVertexKineticEnergy(rOriginVertexKineticEnergy);
1236 
1246 
1247  // store polarization of hit
1248  analysis->fRootEvent->Cerenkov.Radiator.StorePolarizationX(rGlobalPolarizationX);
1249  analysis->fRootEvent->Cerenkov.Radiator.StorePolarizationY(rGlobalPolarizationY);
1250  analysis->fRootEvent->Cerenkov.Radiator.StorePolarizationZ(rGlobalPolarizationZ);
1251  analysis->fRootEvent->Cerenkov.Radiator.StoreLongitudinalPolarization(rLongitudinalPolarization);
1256  analysis->fRootEvent->Cerenkov.Radiator.StoreTransversePolarizationPhiAngle(rTransversePolarizationPhiAngle);
1257 
1258  // store local momentum and track angles Phi and Theta
1264 
1265  // store global momentum and track angles Phi and Theta
1271 
1272  // store total+kinetic energy of a hit
1275 
1276  } // end for (int i1 = 0; i1 < n_hitCerenkovRadiator; i1++)
1277 
1278  } // end if (n_hitCerenkovRadiator > 0)
1279 
1280 
1281  //=========================================================
1282  // Store Number of Photoelectrons of Cerenkov Detector hits
1283  //=========================================================
1284 
1285  if (n_hitCerenkovPMT > 0) {
1286 
1287  std::vector<G4int> PmtHasBeenHit(PmtMaxSize);
1288 
1289  std::vector<G4float> PmtTime(PmtMaxSize);
1290  std::vector<G4float> PmtEnergy(PmtMaxSize);
1291  std::vector<G4int> PmtOctant(PmtMaxSize);
1292 
1293  std::vector<G4int> PmtHitsLeft(PmtMaxSize);
1294  std::vector<G4int> PmtHitsRight(PmtMaxSize);
1295  std::vector<G4int> PmtHitsTotal(PmtMaxSize);
1296  std::vector<G4float> PmtNPELeft(PmtMaxSize);
1297  std::vector<G4float> PmtNPERight(PmtMaxSize);
1298  std::vector<G4float> PmtNPETotal(PmtMaxSize);
1299 
1300  std::vector<G4float> PmtRateLeft(PmtMaxSize);
1301  std::vector<G4float> PmtRateRight(PmtMaxSize);
1302  std::vector<G4float> PmtRateTotal(PmtMaxSize);
1303  std::vector<G4float> PmtRateLeftEL(PmtMaxSize);
1304  std::vector<G4float> PmtRateRightEL(PmtMaxSize);
1305  std::vector<G4float> PmtRateTotalEL(PmtMaxSize);
1306  std::vector<G4float> PmtRateLeftDIS(PmtMaxSize);
1307  std::vector<G4float> PmtRateRightDIS(PmtMaxSize);
1308  std::vector<G4float> PmtRateTotalDIS(PmtMaxSize);
1309  std::vector<G4float> PmtRateLeftQE(PmtMaxSize);
1310  std::vector<G4float> PmtRateRightQE(PmtMaxSize);
1311  std::vector<G4float> PmtRateTotalQE(PmtMaxSize);
1312  std::vector<G4float> PmtRateLeftELPeak(PmtMaxSize);
1313  std::vector<G4float> PmtRateRightELPeak(PmtMaxSize);
1314  std::vector<G4float> PmtRateTotalELPeak(PmtMaxSize);
1315 
1316  std::vector<G4float> PmtYieldLeft(PmtMaxSize);
1317  std::vector<G4float> PmtYieldRight(PmtMaxSize);
1318  std::vector<G4float> PmtYieldTotal(PmtMaxSize);
1319  std::vector<G4float> PmtYieldLeftEL(PmtMaxSize);
1320  std::vector<G4float> PmtYieldRightEL(PmtMaxSize);
1321  std::vector<G4float> PmtYieldTotalEL(PmtMaxSize);
1322  std::vector<G4float> PmtYieldLeftDIS(PmtMaxSize);
1323  std::vector<G4float> PmtYieldRightDIS(PmtMaxSize);
1324  std::vector<G4float> PmtYieldTotalDIS(PmtMaxSize);
1325  std::vector<G4float> PmtYieldLeftQE(PmtMaxSize);
1326  std::vector<G4float> PmtYieldRightQE(PmtMaxSize);
1327  std::vector<G4float> PmtYieldTotalQE(PmtMaxSize);
1328  std::vector<G4float> PmtYieldLeftELPeak(PmtMaxSize);
1329  std::vector<G4float> PmtYieldRightELPeak(PmtMaxSize);
1330  std::vector<G4float> PmtYieldTotalELPeak(PmtMaxSize);
1331 
1332  // loop over hits
1333  for (int i1 = 0; i1 < n_hitCerenkovPMT; i1++) {
1334 
1335  QweakSimCerenkov_PMTHit* aHit = (*CerenkovDetectorPMT_HC)[i1];
1336  G4int octantID = (Int_t) aHit->GetDetectorID() + 1;
1337 
1338  if (octantID > (Int_t) PmtHitsLeft.size()) {
1339  G4cerr << "octantID is larger than size of vectorPmtHitsLeft in QweakSimEventAction!" << G4endl;
1340  break;
1341  }
1342 
1343  //------------------------------------------------------------------------
1344  PmtTime.push_back(aHit->GetHitTime());
1345  PmtEnergy.push_back(aHit->GetPhotonEnergy());
1346  PmtOctant.push_back(0);
1347 
1348  //------------------------------------------------------------------------
1349  if (aHit->GetPMTID() == 0) { // left PMT
1350  //if(aHit->IsHitValid())
1351  {
1352  PmtOctant.back() = -octantID;
1353  PmtHitsLeft[octantID]++;
1354  PmtNPELeft[octantID] += myUserInfo->GetNumberOfPhotoelectronsS20(aHit->GetPhotonEnergy()*1.0e6);
1355  // G4cout<<"pmtNPELeft: "<<pmtNPELeft[octantID]<<G4endl;
1356  }
1357  }
1358 
1359  if (aHit->GetPMTID() == 1) { // right PMT
1360  //if(aHit->IsHitValid())
1361  {
1362  PmtOctant.back() = +octantID;
1363  PmtHitsRight[octantID]++;
1364  PmtNPERight[octantID] += myUserInfo->GetNumberOfPhotoelectronsS20(aHit->GetPhotonEnergy()*1.0e6);
1365  // G4cout<<"pmtNPERight: "<<pmtNPERight[octantID]<<G4endl;
1366  }
1367  }
1368 
1369  PmtHasBeenHit[octantID] = 5;
1370  PmtHitsTotal[octantID]++;
1371  PmtNPETotal[octantID] += myUserInfo->GetNumberOfPhotoelectronsS20(aHit->GetPhotonEnergy()*1.0e6);
1372  // G4cout<<"pmtNPETTotal: "<<pmtNPETotal[octantID]<<G4endl;
1373 
1374  //------------------------------------------------------------------------
1375 
1376  } // end for (int i1 = 0; i1 < n_hitCerenkovPMT; i1++)
1377 
1378  // Loop over all octants
1379  for (int octantID = 0; octantID < PmtMaxSize; octantID++) {
1380  if (PmtHasBeenHit[octantID] != 5) continue; // skip octants without hits
1381 
1382  PmtRateTotal[octantID] = CalculateRate( myUserInfo->GetCrossSection(), (Bool_t)PmtNPETotal[octantID] );
1383  PmtRateLeft[octantID] = CalculateRate( myUserInfo->GetCrossSection(), (Bool_t)PmtNPELeft[octantID] );
1384  PmtRateRight[octantID] = CalculateRate( myUserInfo->GetCrossSection(), (Bool_t)PmtNPERight[octantID] );
1385 
1386  PmtRateTotalEL[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadElastic(), (Bool_t)PmtNPETotal[octantID] );
1387  PmtRateLeftEL[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadElastic(), (Bool_t)PmtNPELeft[octantID] );
1388  PmtRateRightEL[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadElastic(), (Bool_t)PmtNPERight[octantID] );
1389 
1390  PmtRateTotalDIS[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadDIS(), (Bool_t)PmtNPETotal[octantID] );
1391  PmtRateLeftDIS[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadDIS(), (Bool_t)PmtNPELeft[octantID] );
1392  PmtRateRightDIS[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadDIS(), (Bool_t)PmtNPERight[octantID] );
1393 
1394  PmtRateTotalQE[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadQE(), (Bool_t)PmtNPETotal[octantID] );
1395  PmtRateLeftQE[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadQE(), (Bool_t)PmtNPELeft[octantID] );
1396  PmtRateRightQE[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadQE(), (Bool_t)PmtNPERight[octantID] );
1397 
1398  PmtRateTotalELPeak[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadElasticPeak(), (Bool_t)PmtNPETotal[octantID] );
1399  PmtRateLeftELPeak[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadElasticPeak(), (Bool_t)PmtNPELeft[octantID] );
1400  PmtRateRightELPeak[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadElasticPeak(), (Bool_t)PmtNPERight[octantID] );
1401 
1402  PmtYieldTotal[octantID] = CalculateRate( myUserInfo->GetCrossSection(), PmtNPETotal[octantID] );
1403  PmtYieldLeft[octantID] = CalculateRate( myUserInfo->GetCrossSection(), PmtNPELeft[octantID] );
1404  PmtYieldRight[octantID] = CalculateRate( myUserInfo->GetCrossSection(), PmtNPERight[octantID] );
1405 
1406  PmtYieldTotalEL[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadElastic(), PmtNPETotal[octantID] );
1407  PmtYieldLeftEL[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadElastic(), PmtNPELeft[octantID] );
1408  PmtYieldRightEL[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadElastic(), PmtNPERight[octantID] );
1409 
1410  PmtYieldTotalDIS[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadDIS(), PmtNPETotal[octantID] );
1411  PmtYieldLeftDIS[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadDIS(), PmtNPELeft[octantID] );
1412  PmtYieldRightDIS[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadDIS(), PmtNPERight[octantID] );
1413 
1414  PmtYieldTotalQE[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadQE(), PmtNPETotal[octantID] );
1415  PmtYieldLeftQE[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadQE(), PmtNPELeft[octantID] );
1416  PmtYieldRightQE[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadQE(), PmtNPERight[octantID] );
1417 
1418  PmtYieldTotalELPeak[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadElasticPeak(), PmtNPETotal[octantID] );
1419  PmtYieldLeftELPeak[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadElasticPeak(), PmtNPELeft[octantID] );
1420  PmtYieldRightELPeak[octantID] = CalculateRate( myUserInfo->GetCrossSectionRadElasticPeak(), PmtNPERight[octantID] );
1421 
1422  } // end for (int octantID = 0; octantID < PmtMaxSize; octantID++)
1423 
1424  // has the detector been hit
1426 
1427  //---------------------------------------------
1428  // store number of hits for left and right PMT
1429  //---------------------------------------------
1433 
1434  //---------------------------------------------
1435  // store number of hits for left and right PMT
1436  //---------------------------------------------
1443 
1444  //---------------------------------------------
1445  // store rates for left and right PMT
1446  //---------------------------------------------
1459  analysis->fRootEvent->Cerenkov.PMT.StorePMTLeftRateELPeak(PmtRateLeftELPeak);
1460  analysis->fRootEvent->Cerenkov.PMT.StorePMTRightRateELPeak(PmtRateRightELPeak);
1461  analysis->fRootEvent->Cerenkov.PMT.StorePMTTotalRateELPeak(PmtRateTotalELPeak);
1462 
1463  //---------------------------------------------
1464  // store yields for left and right PMT
1465  //---------------------------------------------
1478  analysis->fRootEvent->Cerenkov.PMT.StorePMTLeftYieldELPeak(PmtYieldLeftELPeak);
1479  analysis->fRootEvent->Cerenkov.PMT.StorePMTRightYieldELPeak(PmtYieldRightELPeak);
1480  analysis->fRootEvent->Cerenkov.PMT.StorePMTTotalYieldELPeak(PmtYieldTotalELPeak);
1481 
1482  //==============================================================================
1483 
1484  } // end if (n_hitCerenkovPMT > 0)
1485 
1486  //==============================
1487  // Store HDC hits into /Region2
1488  //==============================
1489 
1490  if (n_HDChitWirePlane > 0) {
1491 
1492  // loop over wire plane hits
1493  for (int i1=0;i1<n_HDChitWirePlane;i1++) {
1494 
1495  int HDC_Chamber_Plane_NbOfHits[2][6];
1496  for (int chamber = 0; chamber < 2; chamber++)
1497  for (int plane = 0; plane < 6; plane++)
1498  HDC_Chamber_Plane_NbOfHits[chamber][plane] = 0;
1499 
1500  // get hit pointer for each hit
1501  QweakSimHDC_WirePlaneHit* aHit = (*HDC_WirePlane_HC)[i1];
1502 
1503  // get local position of hit
1504  G4ThreeVector localPosition = aHit->GetLocalPosition();
1505  Float_t rLocalPositionX = (Float_t) localPosition.x() / cm;
1506  Float_t rLocalPositionY = (Float_t) localPosition.y() / cm;
1507  Float_t rLocalPositionZ = (Float_t) localPosition.z() / cm;
1508 
1509  // get world position of hit
1510  G4ThreeVector globalPosition = aHit->GetWorldPosition();
1511  Float_t rGlobalPositionX = (Float_t) globalPosition.x() / cm;
1512  Float_t rGlobalPositionY = (Float_t) globalPosition.y() / cm;
1513  Float_t rGlobalPositionZ = (Float_t) globalPosition.z() / cm;
1514 
1515  // get local Momentum of hit
1516  G4ThreeVector localMomentum = aHit->GetLocalMomentum();
1517  Float_t rLocalMomentumX = (Float_t) localMomentum.x() / MeV;
1518  Float_t rLocalMomentumY = (Float_t) localMomentum.y() / MeV;
1519  Float_t rLocalMomentumZ = (Float_t) localMomentum.z() / MeV;
1520 
1521  // get world Momentum of hit
1522  G4ThreeVector globalMomentum = aHit->GetWorldMomentum();
1523  Float_t rGlobalMomentumX = (Float_t) globalMomentum.x() / MeV;
1524  Float_t rGlobalMomentumY = (Float_t) globalMomentum.y() / MeV;
1525  Float_t rGlobalMomentumZ = (Float_t) globalMomentum.z() / MeV;
1526  Float_t rGlobalThetaAngle = (Float_t) globalMomentum.theta() / degree;
1527  Float_t rGlobalPhiAngle = (Float_t) globalMomentum.phi() / degree - 90.0;
1528 
1529  G4ThreeVector originVertexPosition = aHit->GetOriginVertexPosition();
1530  Float_t rOriginVertexPositionX = (Float_t) originVertexPosition.x() / cm;
1531  Float_t rOriginVertexPositionY = (Float_t) originVertexPosition.y() / cm;
1532  Float_t rOriginVertexPositionZ = (Float_t) originVertexPosition.z() / cm;
1533 
1534 
1535  G4ThreeVector originVertexMomentumDirection = aHit->GetOriginVertexMomentumDirection();
1536  Float_t rOriginVertexMomentumDirectionX = (Float_t) originVertexMomentumDirection.x();
1537  Float_t rOriginVertexMomentumDirectionY = (Float_t) originVertexMomentumDirection.y();
1538  Float_t rOriginVertexMomentumDirectionZ = (Float_t) originVertexMomentumDirection.z();
1539  Float_t rOriginVertexPhiAngle = (Float_t) originVertexMomentumDirection.phi() / degree;
1540  Float_t rOriginVertexThetaAngle = (Float_t) originVertexMomentumDirection.theta() / degree;
1541 
1542  Float_t rOriginVertexKineticEnergy = (Float_t) aHit->GetOriginVertexKineticEnergy() / MeV;
1543  Float_t rOriginVertexTotalEnergy = (Float_t) aHit->GetOriginVertexTotalEnergy() / MeV;
1544 
1545  Float_t rGlobalTime = (Float_t) aHit->GetGlobalTime() / ns;
1546  TString rParticleName = TString(aHit->GetParticleName());
1547  Int_t rParticleType = (Int_t) aHit->GetParticleType();
1548 
1549  // get total Energy of hit
1550  Float_t rTotalEnergy = (Float_t) aHit->GetTotalEnergy() / MeV;
1551 
1552  // get kinetic Energy of hit
1553  Float_t rKineticEnergy = (Float_t) aHit->GetKineticEnergy() / MeV;
1554 
1555  //-----------------------------------
1556  int iHDCID = aHit->GetHDCID();
1557  int iHDC_Chamber = -1; //0 Corresponds to Front, 1 Corresponds to Back
1558  QweakSimUserHDC_SingleHDCEvent* single_hdc_event = 0;
1559  if (iHDCID == 0 || iHDCID == 2){
1560  iHDC_Chamber = 0;
1561  single_hdc_event = &(analysis->fRootEvent->Region2.ChamberFront);
1562  }
1563  if (iHDCID == 1 || iHDCID == 3){
1564  iHDC_Chamber = 1;
1565  single_hdc_event = &(analysis->fRootEvent->Region2.ChamberBack);
1566  }
1567 
1568  //-----------------------------------
1569  if (single_hdc_event == 0) {
1570  G4cerr << "HDC hit with incorrect chamber ID." << G4endl;
1571  break;
1572  }
1573  int iHDCpackage = -1; // 0 correponds to package 1, 1 corresponds to package 2
1574  if(iHDCID == 0 || iHDCID == 1)
1575  iHDCpackage = 1;
1576  if(iHDCID == 2 || iHDCID == 3)
1577  iHDCpackage = 2;
1578  //-----------------------------------
1579  int iWirePlaneID = aHit->GetWirePlaneID();
1580  QweakSimUserHDC_WirePlaneEvent* wire_plane_event = 0;
1581  if (iWirePlaneID == 0)
1582  wire_plane_event = &(single_hdc_event->WirePlane1);
1583  if (iWirePlaneID == 1)
1584  wire_plane_event = &(single_hdc_event->WirePlane2);
1585  if (iWirePlaneID == 2)
1586  wire_plane_event = &(single_hdc_event->WirePlane3);
1587  if (iWirePlaneID == 3)
1588  wire_plane_event = &(single_hdc_event->WirePlane4);
1589  if (iWirePlaneID == 4)
1590  wire_plane_event = &(single_hdc_event->WirePlane5);
1591  if (iWirePlaneID == 5)
1592  wire_plane_event = &(single_hdc_event->WirePlane6);
1593 
1594  //-----------------------------------
1595  if (wire_plane_event == 0) {
1596  G4cerr << "HDC hit with incorrect plane ID." << G4endl;
1597  break;
1598  }
1599 
1600  //-----------------------------------
1601  // store number of hits
1602  HDC_Chamber_Plane_NbOfHits[iHDC_Chamber][iWirePlaneID]++;
1603  wire_plane_event->StoreNbOfHits(HDC_Chamber_Plane_NbOfHits[iHDC_Chamber][iWirePlaneID]);
1604 
1605  // mark wire plane as been hit
1606  wire_plane_event->StorePlaneHasBeenHit(5);
1607 
1608  // store package hit occurred in
1609  wire_plane_event->StorePackageID(iHDCpackage);
1610 
1611  // store origin vertex info
1612  wire_plane_event->StoreOriginVertexPositionX(rOriginVertexPositionX);
1613  wire_plane_event->StoreOriginVertexPositionY(rOriginVertexPositionY);
1614  wire_plane_event->StoreOriginVertexPositionZ(rOriginVertexPositionZ);
1615  wire_plane_event->StoreOriginVertexMomentumDirectionX(rOriginVertexMomentumDirectionX);
1616  wire_plane_event->StoreOriginVertexMomentumDirectionY(rOriginVertexMomentumDirectionY);
1617  wire_plane_event->StoreOriginVertexMomentumDirectionZ(rOriginVertexMomentumDirectionZ);
1618  wire_plane_event->StoreOriginVertexPhiAngle( rOriginVertexPhiAngle );
1619  wire_plane_event->StoreOriginVertexThetaAngle( rOriginVertexThetaAngle );
1620 
1621  wire_plane_event->StoreOriginVertexKineticEnergy(rOriginVertexKineticEnergy);
1622  wire_plane_event->StoreOriginVertexTotalEnergy(rOriginVertexTotalEnergy);
1623 
1624  wire_plane_event->StoreGlobalTimeOfHit(rGlobalTime);
1625  wire_plane_event->StoreParticleName(rParticleName);
1626  wire_plane_event->StoreParticleType(rParticleType);
1627 
1628  wire_plane_event->StorePlaneLocalPositionX(rLocalPositionX);
1629  wire_plane_event->StorePlaneLocalPositionY(rLocalPositionY);
1630  wire_plane_event->StorePlaneLocalPositionZ(rLocalPositionZ);
1631 
1632  wire_plane_event->StorePlaneGlobalPositionX(rGlobalPositionX);
1633  wire_plane_event->StorePlaneGlobalPositionY(rGlobalPositionY);
1634  wire_plane_event->StorePlaneGlobalPositionZ(rGlobalPositionZ);
1635 
1636  // store wire plane hit momentum
1637  wire_plane_event->StorePlaneLocalMomentumX(rLocalMomentumX);
1638  wire_plane_event->StorePlaneLocalMomentumY(rLocalMomentumY);
1639  wire_plane_event->StorePlaneLocalMomentumZ(rLocalMomentumZ);
1640 
1641  wire_plane_event->StorePlaneGlobalMomentumX(rGlobalMomentumX);
1642  wire_plane_event->StorePlaneGlobalMomentumY(rGlobalMomentumY);
1643  wire_plane_event->StorePlaneGlobalMomentumZ(rGlobalMomentumZ);
1644 
1645  // store global track angles Phi and Theta
1646  wire_plane_event->StoreGlobalPhiAngle(rGlobalPhiAngle);
1647  wire_plane_event->StoreGlobalThetaAngle(rGlobalThetaAngle);
1648 
1649  // store total+kinetic energy of hit
1650  wire_plane_event->StoreTotalEnergy(rTotalEnergy);
1651  wire_plane_event->StoreKineticEnergy(rKineticEnergy);
1652 
1653  //-----------------------------------
1654 
1655  } // end of for(int i1=0;i1<n_HDChitWirePlane;i1++){
1656 
1657  } // end of if (n_HDChitWirePlane > 0)
1658 
1659 
1660  //===============================================================================================================
1661 
1662  //==============================
1663  // Store GEM hits into /Region1
1664  //==============================
1665 
1666 /* start GEM comments
1667 
1668  if (n_GEMhitWirePlane > 0) {
1669  //========================================
1670  // Store GEM Hit Information into /Region1
1671  //========================================
1672 
1673  int GEM_ChamberFront_WirePlane_NbOfHits = 0;
1674  int GEM_ChamberBack_WirePlane_NbOfHits = 0;
1675 
1676  // loop over wire plane hits
1677  // up to now there should be only one GEM per octant
1678  for (int i1=0;i1<n_GEMhitWirePlane;i1++) {
1679 
1680  // get hit pointer for each hit
1681  QweakSimGEM_WirePlaneHit* aHit = (*GEM_WirePlane_HC)[i1];
1682 
1683  // G4cout << G4endl << "###### Printing GEM hit info within QweakSimEventAction::EndOfEventAction() " << G4endl << G4endl;
1684  if (print_GEM_WirePlaneHit) aHit->Print();
1685 
1686  // get local position of hit
1687  G4ThreeVector localPosition = aHit->GetLocalPosition();
1688  Float_t rLocalPositionX = (Float_t) localPosition.x() / cm;
1689  Float_t rLocalPositionY = (Float_t) localPosition.y() / cm;
1690  Float_t rLocalPositionZ = (Float_t) localPosition.z() / cm;
1691 
1692  // get world position of hit
1693  G4ThreeVector globalPosition = aHit->GetWorldPosition();
1694  Float_t rGlobalPositionX = (Float_t) globalPosition.x() / cm;
1695  Float_t rGlobalPositionY = (Float_t) globalPosition.y() / cm;
1696  Float_t rGlobalPositionZ = (Float_t) globalPosition.z() / cm;
1697 
1698  // get local Momentum of hit
1699  G4ThreeVector localMomentum = aHit->GetLocalMomentum();
1700  Float_t rLocalMomentumX = (Float_t) localMomentum.x() / MeV;
1701  Float_t rLocalMomentumY = (Float_t) localMomentum.y() / MeV;
1702  Float_t rLocalMomentumZ = (Float_t) localMomentum.z() / MeV;
1703 
1704  // get world Momentum of hit
1705  G4ThreeVector globalMomentum = aHit->GetWorldMomentum();
1706  Float_t rGlobalMomentumX = (Float_t) globalMomentum.x() / MeV;
1707  Float_t rGlobalMomentumY = (Float_t) globalMomentum.y() / MeV;
1708  Float_t rGlobalMomentumZ = (Float_t) globalMomentum.z() / MeV;
1709  Float_t rGlobalThetaAngle = globalMomentum.theta() / degree;
1710  Float_t rGlobalPhiAngle = globalMomentum.phi() / degree - 90.0;
1711 
1712  G4ThreeVector originVertexPosition = aHit->GetOriginVertexPosition();
1713  Float_t rOriginVertexPositionX = (Float_t) originVertexPosition.x() / cm;
1714  Float_t rOriginVertexPositionY = (Float_t) originVertexPosition.y() / cm;
1715  Float_t rOriginVertexPositionZ = (Float_t) originVertexPosition.z() / cm;
1716 
1717  G4ThreeVector originVertexMomentumDirection = aHit->GetOriginVertexMomentumDirection();
1718  Float_t rOriginVertexMomentumDirectionX = (Float_t) originVertexMomentumDirection.x();
1719  Float_t rOriginVertexMomentumDirectionY = (Float_t) originVertexMomentumDirection.y();
1720  Float_t rOriginVertexMomentumDirectionZ = (Float_t) originVertexMomentumDirection.z();
1721  Float_t rOriginVertexPhiAngle = (Float_t) originVertexMomentumDirection.phi() / degree;
1722  Float_t rOriginVertexThetaAngle = (Float_t) originVertexMomentumDirection.theta() / degree;
1723 
1724  Float_t rOriginVertexKineticEnergy = (Float_t) aHit->GetOriginVertexKineticEnergy() / MeV;
1725  Float_t rOriginVertexTotalEnergy = (Float_t) aHit->GetOriginVertexTotalEnergy() / MeV;
1726 
1727  Float_t rGlobalTime = (Float_t) aHit->GetGlobalTime() / ns;
1728 
1729  // get total Energy of hit
1730  Float_t rtotalEnergy = (Float_t) aHit->GetTotalEnergy() / MeV;
1731 
1732  // get kinetic Energy of hit
1733  Float_t rkineticEnergy = (Float_t) aHit->GetKineticEnergy() / MeV;
1734 
1735  //-----------------------------------
1736 
1737  if ((aHit->GetGEMID()==0) && (aHit->GetWirePlaneID()==0)) {
1738 
1739  GEM_ChamberFront_WirePlane_NbOfHits++;
1740  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreNbOfHits(GEM_ChamberFront_WirePlane_NbOfHits++);
1741 
1742  // mark wire plane as been hit
1743  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StorePlaneHasBeenHit(5);
1744 
1745 
1746  // store origin vertex info
1747  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreOriginVertexPositionX(rOriginVertexPositionX);
1748  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreOriginVertexPositionY(rOriginVertexPositionY);
1749  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreOriginVertexPositionZ(rOriginVertexPositionZ);
1750  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreOriginVertexMomentumDirectionX(rOriginVertexMomentumDirectionX);
1751  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreOriginVertexMomentumDirectionY(rOriginVertexMomentumDirectionY);
1752  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreOriginVertexMomentumDirectionZ(rOriginVertexMomentumDirectionZ);
1753  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreOriginVertexPhiAngle( rOriginVertexPhiAngle );
1754  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreOriginVertexThetaAngle( rOriginVertexThetaAngle );
1755  //------------------------------------------------------------------------------------------------------------------------------------------
1756 
1757  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreOriginVertexKineticEnergy(rOriginVertexKineticEnergy);
1758  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreOriginVertexTotalEnergy(rOriginVertexTotalEnergy);
1759 
1760  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreGlobalTimeOfHit(rGlobalTime);
1761 
1762 
1763  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StorePlaneLocalPositionX(rLocalPositionX);
1764  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StorePlaneLocalPositionY(rLocalPositionY);
1765  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StorePlaneLocalPositionZ(rLocalPositionZ);
1766 
1767  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StorePlaneGlobalPositionX(rGlobalPositionX);
1768  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StorePlaneGlobalPositionY(rGlobalPositionY);
1769  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StorePlaneGlobalPositionZ(rGlobalPositionZ);
1770 
1771  // store wire plane hit momentum
1772  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StorePlaneLocalMomentumX(rLocalMomentumX);
1773  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StorePlaneLocalMomentumY(rLocalMomentumY);
1774  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StorePlaneLocalMomentumZ(rLocalMomentumZ);
1775 
1776  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StorePlaneGlobalMomentumX(rGlobalMomentumX);
1777  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StorePlaneGlobalMomentumY(rGlobalMomentumY);
1778  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StorePlaneGlobalMomentumZ(rGlobalMomentumZ);
1779 
1780  // store global track angles Phi and Theta
1781  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreGlobalPhiAngle(rGlobalPhiAngle);
1782  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreGlobalThetaAngle(rGlobalThetaAngle);
1783 
1784  // store total+kinetic energy of hit
1785  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreTotalEnergy(rtotalEnergy);
1786  analysis->fRootEvent->Region1.ChamberFront.WirePlane.StoreKineticEnergy(rkineticEnergy);
1787 
1788  } //end of if((aHit->GetGEMID()==0) && (aHit->GetWirePlaneID()==0))
1789 
1790 
1791  //-----------------------------------
1792 
1793  if ((aHit->GetGEMID()==1) && (aHit->GetWirePlaneID()==0)) {
1794 
1795  GEM_ChamberBack_WirePlane_NbOfHits++;
1796  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreNbOfHits(GEM_ChamberBack_WirePlane_NbOfHits++);
1797 
1798  // mark wire plane as been hit
1799  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StorePlaneHasBeenHit(5);
1800 
1801  // store origin vertex info
1802  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreOriginVertexPositionX(rOriginVertexPositionX);
1803  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreOriginVertexPositionY(rOriginVertexPositionY);
1804  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreOriginVertexPositionZ(rOriginVertexPositionZ);
1805  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreOriginVertexMomentumDirectionX(rOriginVertexMomentumDirectionX);
1806  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreOriginVertexMomentumDirectionY(rOriginVertexMomentumDirectionY);
1807  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreOriginVertexMomentumDirectionZ(rOriginVertexMomentumDirectionZ);
1808  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreOriginVertexPhiAngle( rOriginVertexPhiAngle );
1809  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreOriginVertexThetaAngle( rOriginVertexThetaAngle );
1810 
1811  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreOriginVertexKineticEnergy(rOriginVertexKineticEnergy);
1812  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreOriginVertexTotalEnergy(rOriginVertexTotalEnergy);
1813 
1814  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreGlobalTimeOfHit(rGlobalTime);
1815 
1816 
1817 
1818  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StorePlaneLocalPositionX(rLocalPositionX);
1819  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StorePlaneLocalPositionY(rLocalPositionY);
1820  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StorePlaneLocalPositionZ(rLocalPositionZ);
1821 
1822  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StorePlaneGlobalPositionX(rGlobalPositionX);
1823  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StorePlaneGlobalPositionY(rGlobalPositionY);
1824  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StorePlaneGlobalPositionZ(rGlobalPositionZ);
1825 
1826  // store wire plane hit momentum
1827  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StorePlaneLocalMomentumX(rLocalMomentumX);
1828  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StorePlaneLocalMomentumY(rLocalMomentumY);
1829  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StorePlaneLocalMomentumZ(rLocalMomentumZ);
1830 
1831  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StorePlaneGlobalMomentumX(rGlobalMomentumX);
1832  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StorePlaneGlobalMomentumY(rGlobalMomentumY);
1833  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StorePlaneGlobalMomentumZ(rGlobalMomentumZ);
1834 
1835  // store global track angles Phi and Theta
1836  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreGlobalPhiAngle(rGlobalPhiAngle);
1837  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreGlobalThetaAngle(rGlobalThetaAngle);
1838 
1839  // store total+kinetic energy of hit
1840  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreTotalEnergy(rtotalEnergy);
1841  analysis->fRootEvent->Region1.ChamberBack.WirePlane.StoreKineticEnergy(rkineticEnergy);
1842 
1843  } // end of if((aHit->GetGEMID()==1) && (aHit->GetWirePlaneID()==0)) {
1844 
1845  //-----------------------------------
1846 
1847 
1848  } // end of for(int i1=0;i1<n_GEMhitWirePlane;i1++){
1849 
1850  } // end of if ( (n_GEMhitWirePlane == 1)
1851 
1852 */ // end of GEM comments
1853 
1854 
1855  //===========================================================
1856  // Store Target hits into /Target
1857  //===========================================================
1858 
1859  if (n_hitTarget >0) {
1860  // initialize deposited energy
1861  Float_t rTotalDepositedEnergy = 0.0;
1862 
1863  //--- loop over hits
1864  for (int i1=0;i1<n_hitTarget;i1++) {
1865 
1866  QweakSimTarget_DetectorHit* aHit = (*TargetDetector_HC)[i1];
1867 
1868  //--- track ID
1869  Float_t rTrackID = (Float_t) aHit->GetTrackID();
1870 
1871  //--- particle name & type
1872  TString rParticleName = TString(aHit->GetParticleName());
1873  Int_t rParticleType = (Int_t) aHit->GetParticleType();
1874 
1875  //--- get global time of hit
1876  Float_t rGlobalTime = (Float_t) aHit->GetGlobalTime() / ns;
1877 
1878  //--- get world position of hit
1879  G4ThreeVector globalPosition = aHit->GetWorldPosition();
1880  Float_t rGlobalPositionX = (Float_t) globalPosition.x() / cm;
1881  Float_t rGlobalPositionY = (Float_t) globalPosition.y() / cm;
1882  Float_t rGlobalPositionZ = (Float_t) globalPosition.z() / cm;
1883 
1884  //--- get local position of hit
1885  G4ThreeVector localPosition = aHit->GetLocalPosition();
1886  Float_t rLocalPositionX = (Float_t) localPosition.x() / cm;
1887  Float_t rLocalPositionY = (Float_t) localPosition.y() / cm;
1888  Float_t rLocalPositionZ = (Float_t) localPosition.z() / cm;
1889 
1890  //--- get origin vertex position
1891  G4ThreeVector originVertexPosition = aHit->GetOriginVertexPosition();
1892  Float_t rOriginVertexPositionX = (Float_t) originVertexPosition.x() / cm;
1893  Float_t rOriginVertexPositionY = (Float_t) originVertexPosition.y() / cm;
1894  Float_t rOriginVertexPositionZ = (Float_t) originVertexPosition.z() / cm;
1895 
1896  //--- get world momentum of hit
1897  G4ThreeVector globalMomentum = aHit->GetWorldMomentum();
1898  //Float_t rGlobalMomentumX = (Float_t) globalMomentum.x() / MeV;
1899  //Float_t rGlobalMomentumY = (Float_t) globalMomentum.y() / MeV;
1900  //Float_t rGlobalMomentumZ = (Float_t) globalMomentum.z() / MeV;
1901 
1902  //--- get global theta & phi angle
1903  Float_t rGlobalThetaAngle = (Float_t) globalMomentum.theta() / degree;
1904  Float_t rGlobalPhiAngle = (Float_t) globalMomentum.phi() / degree - 90.0;
1905 
1906  //--- get local momentum of hit
1907  //G4ThreeVector localMomentum = aHit->GetLocalMomentum();
1908  //Float_t rLocalMomentumX = (Float_t) localMomentum.x() / MeV;
1909  //Float_t rLocalMomentumY = (Float_t) localMomentum.y() / MeV;
1910  //Float_t rLocalMomentumZ = (Float_t) localMomentum.z() / MeV;
1911 
1912  //--- get local vertex momentum direction of hit
1913  G4ThreeVector localVertexMomentumDirection = aHit->GetMomentumDirection();
1914  Float_t rLocalVertexMomentumDirectionX = (Float_t) localVertexMomentumDirection.x();
1915  Float_t rLocalVertexMomentumDirectionY = (Float_t) localVertexMomentumDirection.y();
1916  Float_t rLocalVertexMomentumDirectionZ = (Float_t) localVertexMomentumDirection.z();
1917 
1918  //--- get origin vertex momentum direction of hit
1919  G4ThreeVector originVertexMomentumDirection = aHit->GetOriginVertexMomentumDirection();
1920  Float_t rOriginVertexMomentumDirectionX = (Float_t) originVertexMomentumDirection.x();
1921  Float_t rOriginVertexMomentumDirectionY = (Float_t) originVertexMomentumDirection.y();
1922  Float_t rOriginVertexMomentumDirectionZ = (Float_t) originVertexMomentumDirection.z();
1923 
1924  //--- get origin vertex theta & phi angle
1925  Float_t rOriginVertexThetaAngle = (Float_t) originVertexMomentumDirection.theta() / degree;
1926  Float_t rOriginVertexPhiAngle = (Float_t) originVertexMomentumDirection.phi() / degree;
1927 
1928  //--- get origin vertex kinetic energy & total energy
1929  Float_t rOriginVertexKineticEnergy = (Float_t ) aHit->GetOriginVertexKineticEnergy() / MeV;
1930  Float_t rOriginVertexTotalEnergy = (Float_t ) aHit->GetOriginVertexTotalEnergy() / MeV;
1931 
1932  //--- get total energy & total energy of hit
1933  Float_t rKineticEnergy = (Float_t) aHit->GetKineticEnergy() / MeV;
1934  Float_t rTotalEnergy = (Float_t) aHit->GetTotalEnergy() / MeV;
1935 
1936  //--- get Target deposited energy
1937  Float_t rDepositedEnergy = (Float_t) aHit->GetHitDepositedEnergy() / MeV;
1938  rTotalDepositedEnergy += rDepositedEnergy;
1939 
1940  // beam energy (before energy loss in target), explicitly in MeV
1941  G4double beamEnergy = myUserInfo->GetBeamEnergy() / MeV;
1942 
1943  // incoming and outgoing momentum (taking into account rastering)
1944  G4ThreeVector p_in = myUserInfo->GetNormMomentum();
1945  G4ThreeVector p_out = globalMomentum;
1946  // scattering angle between incoming and outgoing momentum direction
1947  G4double scatteringAngle = acos(p_out.dot(p_in)/p_in.mag()/p_out.mag());
1948 
1949  //--- determine elastic cross section
1950  G4double rElasticCrossSection = 0;
1951  G4double rElasticMomentumTransfer = 0;
1952  G4double rElasticScatteredEnergy = 0;
1954  /* input */ beamEnergy,
1955  scatteringAngle,
1956  /* output */ rElasticCrossSection,
1957  rElasticMomentumTransfer,
1958  rElasticScatteredEnergy);
1959 
1960  //--- store Primary Event Number
1961  analysis->fRootEvent->Target.Detector.StorePrimaryEventNumber((Int_t) PrimaryEventNumber);
1962 
1963  //--- store track ID
1965 
1966  //--- store particle name & type
1969 
1970  //--- store global time of hit
1972 
1973  //--- mark target detector as been hit
1975 
1976  //--- store global position
1980 
1981  //--- store local position
1985 
1986  //--- store origin vertex position
1987  analysis->fRootEvent->Target.Detector.StoreOriginVertexPositionX(rOriginVertexPositionX);
1988  analysis->fRootEvent->Target.Detector.StoreOriginVertexPositionY(rOriginVertexPositionY);
1989  analysis->fRootEvent->Target.Detector.StoreOriginVertexPositionZ(rOriginVertexPositionZ);
1990 
1991  //--- store local vertex momentum direction
1992  analysis->fRootEvent->Target.Detector.StoreLocalVertexMomentumDirectionX(rLocalVertexMomentumDirectionX);
1993  analysis->fRootEvent->Target.Detector.StoreLocalVertexMomentumDirectionY(rLocalVertexMomentumDirectionY);
1994  analysis->fRootEvent->Target.Detector.StoreLocalVertexMomentumDirectionZ(rLocalVertexMomentumDirectionZ);
1995 
1996  //--- store origin vertex momentum direction
1997  analysis->fRootEvent->Target.Detector.StoreOriginVertexMomentumDirectionX(rOriginVertexMomentumDirectionX);
1998  analysis->fRootEvent->Target.Detector.StoreOriginVertexMomentumDirectionY(rOriginVertexMomentumDirectionY);
1999  analysis->fRootEvent->Target.Detector.StoreOriginVertexMomentumDirectionZ(rOriginVertexMomentumDirectionZ);
2000 
2001  //--- store origin theta & phi angle
2002  analysis->fRootEvent->Target.Detector.StoreOriginVertexThetaAngle(rOriginVertexThetaAngle);
2003  analysis->fRootEvent->Target.Detector.StoreOriginVertexPhiAngle(rOriginVertexPhiAngle);
2004 
2005  //--- store origin kinetic energy & total energy
2006  analysis->fRootEvent->Target.Detector.StoreOriginVertexKineticEnergy(rOriginVertexKineticEnergy);
2007  analysis->fRootEvent->Target.Detector.StoreOriginVertexTotalEnergy(rOriginVertexTotalEnergy);
2008 
2009  //--- store local vertex kinetic & total energy
2012 
2013  //--- store global track theta & phi angle
2016 
2017  //--- store target deposited energy
2019 
2020  //--- store elastic cross section
2022  analysis->fRootEvent->Target.Detector.StoreElasticScatteredEnergy(rElasticScatteredEnergy);
2023  analysis->fRootEvent->Target.Detector.StoreElasticMomentumTransfer(rElasticMomentumTransfer);
2024 
2025  } // end for(int i1=0;i1<n_hitTarget;i1++)
2026 
2027  // Put the total energy into the thing.
2028  analysis->fRootEvent->Target.Detector.StoreTotalEnergyDeposit(rTotalDepositedEnergy);
2029 
2030  } // end if (n_hitTarget >0)
2031 
2032  //===========================================================
2033 
2034  // Moved these to after the target, so I can grab target energy variables
2036  G4double OriginVertexKinematicNu = myUserInfo->GetOriginVertexKinematicNu();
2037  G4double OriginVertexKinematicQ2 = myUserInfo->GetOriginVertexKinematicQ2();
2038  G4double OriginVertexKinematicX = myUserInfo->GetOriginVertexKinematicX();
2039  G4double OriginVertexKinematicW = myUserInfo->GetOriginVertexKinematicW();
2040  G4double EffectiveKinematicNu = myUserInfo->GetEffectiveKinematicNu();
2041  G4double EffectiveKinematicQ2 = myUserInfo->GetEffectiveKinematicQ2();
2042  G4double EffectiveKinematicX = myUserInfo->GetEffectiveKinematicX();
2043  G4double EffectiveKinematicW = myUserInfo->GetEffectiveKinematicW();
2044 
2045 
2046  analysis->fRootEvent->Primary.StoreOriginVertexKinematicNu((Float_t) OriginVertexKinematicNu);
2047  analysis->fRootEvent->Primary.StoreOriginVertexKinematicQ2((Float_t) OriginVertexKinematicQ2);
2048  analysis->fRootEvent->Primary.StoreOriginVertexKinematicX((Float_t) OriginVertexKinematicX);
2049  analysis->fRootEvent->Primary.StoreOriginVertexKinematicW((Float_t) OriginVertexKinematicW);
2050  analysis->fRootEvent->Primary.StoreEffectiveKinematicNu((Float_t) EffectiveKinematicNu);
2051  analysis->fRootEvent->Primary.StoreEffectiveKinematicQ2((Float_t) EffectiveKinematicQ2);
2052  analysis->fRootEvent->Primary.StoreEffectiveKinematicX((Float_t) EffectiveKinematicX);
2053  analysis->fRootEvent->Primary.StoreEffectiveKinematicW((Float_t) EffectiveKinematicW);
2054 
2055 
2056 
2057  //===========================================================
2058  // Store Trigger Scintillator hits into /TriggerScintillator
2059  //===========================================================
2060 
2061  if (n_hitTriggerScintillator >0) {
2062  // initialize deposited energy
2063  Float_t rTotalDepositedEnergy = 0.0;
2064 
2065  // loop over hits
2066  for (int i1=0;i1<n_hitTriggerScintillator;i1++) {
2067 
2068  QweakSimTriggerScintillator_DetectorHit* aHit = (*TriggerScintillatorDetector_HC)[i1];
2069 
2071 
2072  // get local position of hit
2073  G4ThreeVector localPosition = aHit->GetLocalPosition();
2074  Float_t rLocalPositionX = (Float_t) localPosition.x() / cm;
2075  Float_t rLocalPositionY = (Float_t) localPosition.y() / cm;
2076  Float_t rLocalPositionZ = (Float_t) localPosition.z() / cm;
2077 
2078  // get world position of hit
2079  G4ThreeVector globalPosition = aHit->GetWorldPosition();
2080  Float_t rGlobalPositionX = (Float_t) globalPosition.x() / cm;
2081  Float_t rGlobalPositionY = (Float_t) globalPosition.y() / cm;
2082  Float_t rGlobalPositionZ = (Float_t) globalPosition.z() / cm;
2083 
2084  // get local Momentum of hit
2085  //G4ThreeVector localMomentum = aHit->GetLocalMomentum();
2086  //Float_t rLocalMomentumX = (Float_t) localMomentum.x() / MeV;
2087  //Float_t rLocalMomentumY = (Float_t) localMomentum.y() / MeV;
2088  //Float_t rLocalMomentumZ = (Float_t) localMomentum.z() / MeV;
2089 
2090  // get world Momentum of hit
2091  G4ThreeVector globalMomentum = aHit->GetWorldMomentum();
2092  //Float_t rGlobalMomentumX = (Float_t) globalMomentum.x() / MeV;
2093  //Float_t rGlobalMomentumY = (Float_t) globalMomentum.y() / MeV;
2094  //Float_t rGlobalMomentumZ = (Float_t) globalMomentum.z() / MeV;
2095 
2096  // get global theta & phi angle
2097  Float_t rGlobalThetaAngle = (Float_t) globalMomentum.theta() / degree;
2098  Float_t rGlobalPhiAngle = (Float_t) globalMomentum.phi() / degree - 90.0;
2099 
2100  G4ThreeVector originVertexPosition = aHit->GetOriginVertexPosition();
2101  Float_t rOriginVertexPositionX = (Float_t) originVertexPosition.x() / cm;
2102  Float_t rOriginVertexPositionY = (Float_t) originVertexPosition.y() / cm;
2103  Float_t rOriginVertexPositionZ = (Float_t) originVertexPosition.z() / cm;
2104 
2105  G4ThreeVector originVertexMomentumDirection = aHit->GetOriginVertexMomentumDirection();
2106  Float_t rOriginVertexMomentumDirectionX = (Float_t) originVertexMomentumDirection.x();
2107  Float_t rOriginVertexMomentumDirectionY = (Float_t) originVertexMomentumDirection.y();
2108  Float_t rOriginVertexMomentumDirectionZ = (Float_t) originVertexMomentumDirection.z();
2109  Float_t rOriginVertexPhiAngle = (Float_t) originVertexMomentumDirection.phi() / degree;
2110  Float_t rOriginVertexThetaAngle = (Float_t) originVertexMomentumDirection.theta() / degree;
2111 
2112  Float_t rOriginVertexKineticEnergy = (Float_t) aHit->GetOriginVertexKineticEnergy() / MeV;
2113  Float_t rOriginVertexTotalEnergy = (Float_t) aHit->GetOriginVertexTotalEnergy() / MeV;
2114 
2115  Float_t rGlobalTime = (Float_t) aHit->GetGlobalTime() / ns;
2116  TString rParticleName = TString(aHit->GetParticleName());
2117  Int_t rParticleType = (Int_t) aHit->GetParticleType();
2118 
2119  //--- get TriggerScintillator deposited energy
2120  Float_t rDepositedEnergy = (Float_t) aHit->GetHitDepositedEnergy() / MeV;
2121  rTotalDepositedEnergy += rDepositedEnergy;
2122 
2123  // mark TriggerScintillator detector as been hit
2125 
2126  // store global time of hit
2128 
2129  //--- store particle name & type
2132 
2133  // Store origin vertex info for first hit
2134  if(i1==0) {
2145  }
2146 
2150 
2154 
2156 
2157  // store global track angles Phi and Theta
2160 
2161  // Store Energy deposited per hit
2163 
2164  } // end for(int i1=0;i1<n_hitTriggerScintillator;i1++)
2165 
2166  // Store total deposited energy
2168 
2169  } // end if (n_hitTriggerScintillator >0)
2170 
2171 
2172  //===========================================================
2173  // Store LeadGlass hits into /LeadGlass
2174  //===========================================================
2175 
2176  if (n_hitLeadGlass >0) {
2177 
2178  //--- loop over hits
2179  for (int i1=0;i1<n_hitLeadGlass;i1++) {
2180 
2181  QweakSimLeadGlass_DetectorHit* aHit = (*LeadGlassDetector_HC)[i1];
2182 
2183  //--- track ID
2184  Float_t rTrackID = (Float_t) aHit->GetTrackID();
2185 
2186  //--- particle name & type
2187  TString rParticleName = TString(aHit->GetParticleName());
2188  Int_t rParticleType = (Int_t) aHit->GetParticleType();
2189 
2190  //--- get global time of hit
2191  Float_t rGlobalTime = (Float_t) aHit->GetGlobalTime() / ns;
2192 
2193  //--- GetHasBeenHit();
2194  //GetEdgeEventFlag();
2195  //n_hitLeadGlass <---> GetNbOfHits();
2196 
2197  //--- get world position of hit
2198  G4ThreeVector globalPosition = aHit->GetWorldPosition();
2199  Float_t rGlobalPositionX = (Float_t) globalPosition.x() / cm;
2200  Float_t rGlobalPositionY = (Float_t) globalPosition.y() / cm;
2201  Float_t rGlobalPositionZ = (Float_t) globalPosition.z() / cm;
2202 
2203  //--- get local position of hit
2204  G4ThreeVector localPosition = aHit->GetLocalPosition();
2205  Float_t rLocalPositionX = (Float_t) localPosition.x() / cm;
2206  Float_t rLocalPositionY = (Float_t) localPosition.y() / cm;
2207  Float_t rLocalPositionZ = (Float_t) localPosition.z() / cm;
2208 
2209  //--- get local exit position of hit
2210  //G4ThreeVector localExitPosition = aHit->GetLocalExitPosition();
2211  //Float_t rLocalExitPositionX = (Float_t) localExitPosition.x() / cm;
2212  //Float_t rLocalExitPositionY = (Float_t) localExitPosition.y() / cm;
2213  //Float_t rLocalExitPositionZ = (Float_t) localExitPosition.z() / cm;
2214 
2215  //--- get origin vertex position
2216  G4ThreeVector originVertexPosition = aHit->GetOriginVertexPosition();
2217  Float_t rOriginVertexPositionX = (Float_t) originVertexPosition.x() / cm;
2218  Float_t rOriginVertexPositionY = (Float_t) originVertexPosition.y() / cm;
2219  Float_t rOriginVertexPositionZ = (Float_t) originVertexPosition.z() / cm;
2220 
2221  //--- get world momentum of hit
2222  G4ThreeVector globalMomentum = aHit->GetWorldMomentum();
2223  //Float_t rGlobalMomentumX = (Float_t) globalMomentum.x() / MeV;
2224  //Float_t rGlobalMomentumY = (Float_t) globalMomentum.y() / MeV;
2225  //Float_t rGlobalMomentumZ = (Float_t) globalMomentum.z() / MeV;
2226 
2227  //--- get global theta & phi angle
2228  Float_t rGlobalThetaAngle = (Float_t) globalMomentum.theta() / degree;
2229  Float_t rGlobalPhiAngle = (Float_t) globalMomentum.phi() / degree - 90.0;
2230 
2231  //--- get local momentum of hit
2232  //G4ThreeVector localMomentum = aHit->GetLocalMomentum();
2233  //Float_t rLocalMomentumX = (Float_t) localMomentum.x() / MeV;
2234  //Float_t rLocalMomentumY = (Float_t) localMomentum.y() / MeV;
2235  //Float_t rLocalMomentumZ = (Float_t) localMomentum.z() / MeV;
2236 
2237  //--- get local vertex momentum direction of hit
2238  G4ThreeVector localVertexMomentumDirection = aHit->GetMomentumDirection();
2239  Float_t rLocalVertexMomentumDirectionX = (Float_t) localVertexMomentumDirection.x();
2240  Float_t rLocalVertexMomentumDirectionY = (Float_t) localVertexMomentumDirection.y();
2241  Float_t rLocalVertexMomentumDirectionZ = (Float_t) localVertexMomentumDirection.z();
2242 
2243  //--- get origin vertex momentum direction of hit
2244  G4ThreeVector originVertexMomentumDirection = aHit->GetOriginVertexMomentumDirection();
2245  Float_t rOriginVertexMomentumDirectionX = (Float_t) originVertexMomentumDirection.x();
2246  Float_t rOriginVertexMomentumDirectionY = (Float_t) originVertexMomentumDirection.y();
2247  Float_t rOriginVertexMomentumDirectionZ = (Float_t) originVertexMomentumDirection.z();
2248 
2249  //--- get origin vertex theta & phi angle
2250  Float_t rOriginVertexThetaAngle = (Float_t) originVertexMomentumDirection.theta() / degree;
2251  Float_t rOriginVertexPhiAngle = (Float_t) originVertexMomentumDirection.phi() / degree;
2252 
2253  //--- get origin vertex kinetic energy & total energy
2254  Float_t rOriginVertexKineticEnergy = (Float_t ) aHit->GetOriginVertexKineticEnergy() / MeV;
2255  Float_t rOriginVertexTotalEnergy = (Float_t ) aHit->GetOriginVertexTotalEnergy() / MeV;
2256 
2257  //--- get total energy & total energy of hit
2258  Float_t rKineticEnergy = (Float_t) aHit->GetKineticEnergy() / MeV;
2259  Float_t rTotalEnergy = (Float_t) aHit->GetTotalEnergy() / MeV;
2260 
2261  //--- get LeadGlass deposited energy
2262  Float_t rDepositedEnergy = (Float_t) aHit->GetHitDepositedEnergy() / MeV;
2263  //--------------------------------------------------------------------------------------------
2264 
2265  //--- store Primary Event Number
2266  analysis->fRootEvent->LeadGlass.Detector.StorePrimaryEventNumber((Int_t) PrimaryEventNumber);
2267 
2268  //--- store track ID
2270 
2271  //--- store particle name & type
2274 
2275  //--- store global time of hit
2277 
2278  //--- mark LeadGlass detector as been hit
2280  //--- edge event flag
2281  //--- Store Nb of hits --- Done in previous code
2282  //analysis->fRootEvent->LeadGlass.Detector.StoreDetectorNbOfHits(n_hitLeadGlass);
2283 
2284  //--- store global position
2288 
2289  //--- store local position
2293 
2294  //analysis->fRootEvent->LeadGlass.Detector.StoreDetectorLocalExitPositionX(rLocalExitPositionX);
2295  //analysis->fRootEvent->LeadGlass.Detector.StoreDetectorLocalExitPositionY(rLocalExitPositionY);
2296  //analysis->fRootEvent->LeadGlass.Detector.StoreDetectorLocalExitPositionZ(rLocalExitPositionZ);
2297 
2298  //--- store origin vertex position
2302 
2303  //--- store local vertex momentum direction
2304  analysis->fRootEvent->LeadGlass.Detector.StoreLocalVertexMomentumDirectionX(rLocalVertexMomentumDirectionX);
2305  analysis->fRootEvent->LeadGlass.Detector.StoreLocalVertexMomentumDirectionY(rLocalVertexMomentumDirectionY);
2306  analysis->fRootEvent->LeadGlass.Detector.StoreLocalVertexMomentumDirectionZ(rLocalVertexMomentumDirectionZ);
2307 
2308  //--- store origin vertex momentum direction
2309  analysis->fRootEvent->LeadGlass.Detector.StoreOriginVertexMomentumDirectionX(rOriginVertexMomentumDirectionX);
2310  analysis->fRootEvent->LeadGlass.Detector.StoreOriginVertexMomentumDirectionY(rOriginVertexMomentumDirectionY);
2311  analysis->fRootEvent->LeadGlass.Detector.StoreOriginVertexMomentumDirectionZ(rOriginVertexMomentumDirectionZ);
2312 
2313  //--- store origin theta & phi angle
2316 
2317  //--- store origin kinetic energy & total energy
2320 
2321  //--- store local vertex kinetic & total energy
2324 
2325  //--- store global track theta & phi angle
2328 
2329  //--- sotre LeadGlass deposited energy
2331  // -- TotalDepositedEnergy is evaluated in UserLeadGlass class
2332 
2333  //--------------------------------------------------------------------------------------------
2334 
2335  } // end for(int i1=0;i1<n_hitLeadGlass;i1++)
2336  } // end if (n_hitLeadGlass >0)
2337 
2338 
2339  //===========================================================
2340  // Store PMTOnly hits into /PMTOnly
2341  //===========================================================
2342 
2343  if (n_hitPMTOnly >0) {
2344  // initialize deposited energy
2345  Float_t rTotalDepositedEnergy = 0.0;
2346 
2347  //--- loop over hits
2348  for (int i1=0;i1<n_hitPMTOnly;i1++) {
2349 
2350  QweakSimPMTOnly_DetectorHit* aHit = (*PMTOnlyDetector_HC)[i1];
2351 
2352  //--- track ID
2353  Float_t rTrackID = (Float_t) aHit->GetTrackID();
2354 
2355  //--- particle name & type
2356  TString rParticleName = TString(aHit->GetParticleName());
2357  Int_t rParticleType = (Int_t) aHit->GetParticleType();
2358 
2359  //--- get global time of hit
2360  Float_t rGlobalTime = (Float_t) aHit->GetGlobalTime() / ns;
2361 
2362  //--- get world position of hit
2363  G4ThreeVector globalPosition = aHit->GetWorldPosition();
2364  Float_t rGlobalPositionX = (Float_t) globalPosition.x() / cm;
2365  Float_t rGlobalPositionY = (Float_t) globalPosition.y() / cm;
2366  Float_t rGlobalPositionZ = (Float_t) globalPosition.z() / cm;
2367 
2368  //--- get local position of hit
2369  G4ThreeVector localPosition = aHit->GetLocalPosition();
2370  Float_t rLocalPositionX = (Float_t) localPosition.x() / cm;
2371  Float_t rLocalPositionY = (Float_t) localPosition.y() / cm;
2372  Float_t rLocalPositionZ = (Float_t) localPosition.z() / cm;
2373 
2374  //--- get origin vertex position
2375  G4ThreeVector originVertexPosition = aHit->GetOriginVertexPosition();
2376  Float_t rOriginVertexPositionX = (Float_t) originVertexPosition.x() / cm;
2377  Float_t rOriginVertexPositionY = (Float_t) originVertexPosition.y() / cm;
2378  Float_t rOriginVertexPositionZ = (Float_t) originVertexPosition.z() / cm;
2379 
2380  //--- get world momentum of hit
2381  G4ThreeVector globalMomentum = aHit->GetWorldMomentum();
2382  //Float_t rGlobalMomentumX = (Float_t) globalMomentum.x() / MeV;
2383  //Float_t rGlobalMomentumY = (Float_t) globalMomentum.y() / MeV;
2384  //Float_t rGlobalMomentumZ = (Float_t) globalMomentum.z() / MeV;
2385 
2386  //--- get global theta & phi angle
2387  Float_t rGlobalThetaAngle = (Float_t) globalMomentum.theta() / degree;
2388  Float_t rGlobalPhiAngle = (Float_t) globalMomentum.phi() / degree - 90.0;
2389 
2390  //--- get local momentum of hit
2391  //G4ThreeVector localMomentum = aHit->GetLocalMomentum();
2392  //Float_t rLocalMomentumX = (Float_t) localMomentum.x() / MeV;
2393  //Float_t rLocalMomentumY = (Float_t) localMomentum.y() / MeV;
2394  //Float_t rLocalMomentumZ = (Float_t) localMomentum.z() / MeV;
2395 
2396  //--- get local vertex momentum direction of hit
2397  G4ThreeVector localVertexMomentumDirection = aHit->GetMomentumDirection();
2398  Float_t rLocalVertexMomentumDirectionX = (Float_t) localVertexMomentumDirection.x();
2399  Float_t rLocalVertexMomentumDirectionY = (Float_t) localVertexMomentumDirection.y();
2400  Float_t rLocalVertexMomentumDirectionZ = (Float_t) localVertexMomentumDirection.z();
2401 
2402  //--- get origin vertex momentum direction of hit
2403  G4ThreeVector originVertexMomentumDirection = aHit->GetOriginVertexMomentumDirection();
2404  Float_t rOriginVertexMomentumDirectionX = (Float_t) originVertexMomentumDirection.x();
2405  Float_t rOriginVertexMomentumDirectionY = (Float_t) originVertexMomentumDirection.y();
2406  Float_t rOriginVertexMomentumDirectionZ = (Float_t) originVertexMomentumDirection.z();
2407 
2408  //--- get origin vertex theta & phi angle
2409  Float_t rOriginVertexThetaAngle = (Float_t) originVertexMomentumDirection.theta() / degree;
2410  Float_t rOriginVertexPhiAngle = (Float_t) originVertexMomentumDirection.phi() / degree;
2411 
2412  //--- get origin vertex kinetic energy & total energy
2413  Float_t rOriginVertexKineticEnergy = (Float_t ) aHit->GetOriginVertexKineticEnergy() / MeV;
2414  Float_t rOriginVertexTotalEnergy = (Float_t ) aHit->GetOriginVertexTotalEnergy() / MeV;
2415 
2416  //--- get total energy & total energy of hit
2417  Float_t rKineticEnergy = (Float_t) aHit->GetKineticEnergy() / MeV;
2418  Float_t rTotalEnergy = (Float_t) aHit->GetTotalEnergy() / MeV;
2419 
2420  //--- get PMTOnly deposited energy
2421  Float_t rDepositedEnergy = (Float_t) aHit->GetHitDepositedEnergy() / MeV;
2422  rTotalDepositedEnergy += rDepositedEnergy;
2423 
2424  //--- store Primary Event Number
2425  analysis->fRootEvent->PMTOnly.Detector.StorePrimaryEventNumber((Int_t) PrimaryEventNumber);
2426 
2427  //--- store track ID
2429 
2430  //--- store particle name & type
2433 
2434  //--- store global time of hit
2436 
2437  //--- mark PMTOnly detector as been hit
2439 
2440  //--- store global position
2444 
2445  //--- store local position
2449 
2450  //--- store origin vertex position
2454 
2455  //--- store local vertex momentum direction
2456  analysis->fRootEvent->PMTOnly.Detector.StoreLocalVertexMomentumDirectionX(rLocalVertexMomentumDirectionX);
2457  analysis->fRootEvent->PMTOnly.Detector.StoreLocalVertexMomentumDirectionY(rLocalVertexMomentumDirectionY);
2458  analysis->fRootEvent->PMTOnly.Detector.StoreLocalVertexMomentumDirectionZ(rLocalVertexMomentumDirectionZ);
2459 
2460  //--- store origin vertex momentum direction
2461  analysis->fRootEvent->PMTOnly.Detector.StoreOriginVertexMomentumDirectionX(rOriginVertexMomentumDirectionX);
2462  analysis->fRootEvent->PMTOnly.Detector.StoreOriginVertexMomentumDirectionY(rOriginVertexMomentumDirectionY);
2463  analysis->fRootEvent->PMTOnly.Detector.StoreOriginVertexMomentumDirectionZ(rOriginVertexMomentumDirectionZ);
2464 
2465  //--- store origin theta & phi angle
2466  analysis->fRootEvent->PMTOnly.Detector.StoreOriginVertexThetaAngle(rOriginVertexThetaAngle);
2468 
2469  //--- store origin kinetic energy & total energy
2470  analysis->fRootEvent->PMTOnly.Detector.StoreOriginVertexKineticEnergy(rOriginVertexKineticEnergy);
2471  analysis->fRootEvent->PMTOnly.Detector.StoreOriginVertexTotalEnergy(rOriginVertexTotalEnergy);
2472 
2473  //--- store local vertex kinetic & total energy
2476 
2477  //--- store global track theta & phi angle
2480 
2481  //--- store PMTOnly deposited energy
2483 
2484  } // end for(int i1=0;i1<n_hitPMTOnly;i1++)
2485 
2486  // Put the total energy into the thing.
2487  analysis->fRootEvent->PMTOnly.Detector.StoreTotalEnergyDeposit(rTotalDepositedEnergy);
2488 
2489  } // end if (n_hitPMTOnly >0)
2490 
2491  if (n_hitPMTOnlyPMT >0) { //--- loop over hits
2492 
2493  G4int PMTOnlyPMTHasBeenHit = 0;
2494  G4int PMTOnlyPMTHits = 0;
2495  G4float PMTOnlyNPE = 0;
2496 
2497  for (int i1=0;i1<n_hitPMTOnlyPMT;i1++) {
2498 
2499  QweakSimPMTOnly_PMTHit* aHit = (*PMTOnlyPMT_HC)[i1]; // This line causes a seg fault it seems.
2500 
2501  PMTOnlyPMTHasBeenHit = 5;
2502  PMTOnlyPMTHits++;
2503  PMTOnlyNPE += myUserInfo->GetNumberOfPhotoelectronsS20(aHit->GetPhotonEnergy()*1.0e6);
2504 
2505  } // end for(n_hitPMTOnlyPMT)
2506 
2507  // Write the PMT results to the ROOTfile
2508  analysis->fRootEvent->PMTOnly.PMT.StorePMTHasBeenHit(PMTOnlyPMTHasBeenHit);
2511 
2512  } // end if (n_hitPMTOnlyPMT >0)
2513 
2514  //===========================================================
2515  // Store Lumi hits into /Lumi
2516  //===========================================================
2517 
2518  if (n_hitLumi > 0) {
2519 
2520  //--- loop over hits
2521  for (int i1=0;i1<n_hitLumi;i1++) {
2522 
2523  QweakSimLumi_DetectorHit* aHit = (*LumiDetector_HC)[i1];
2524 
2525  //--- track ID
2526  Float_t rTrackID = (Float_t) aHit->GetTrackID();
2527 
2528  //--- particle name & type
2529  TString rParticleName = TString(aHit->GetParticleName());
2530  Int_t rParticleType = (Int_t) aHit->GetParticleType();
2531 
2532  //--- get global time of hit
2533  Float_t rGlobalTime = (Float_t) aHit->GetGlobalTime() / ns;
2534 
2535  //--- GetHasBeenHit();
2536  //GetEdgeEventFlag();
2537  //n_hitLumi <---> GetNbOfHits();
2538 
2539  //--- get world position of hit
2540  G4ThreeVector globalPosition = aHit->GetWorldPosition();
2541  Float_t rGlobalPositionX = (Float_t) globalPosition.x() / cm;
2542  Float_t rGlobalPositionY = (Float_t) globalPosition.y() / cm;
2543  Float_t rGlobalPositionZ = (Float_t) globalPosition.z() / cm;
2544 
2545  //--- get local position of hit
2546  G4ThreeVector localPosition = aHit->GetLocalPosition();
2547  Float_t rLocalPositionX = (Float_t) localPosition.x() / cm;
2548  Float_t rLocalPositionY = (Float_t) localPosition.y() / cm;
2549  Float_t rLocalPositionZ = (Float_t) localPosition.z() / cm;
2550 
2551  //--- get local exit position of hit
2552  //G4ThreeVector localExitPosition = aHit->GetLocalExitPosition();
2553  //Float_t rLocalExitPositionX = (Float_t) localExitPosition.x() / cm;
2554  //Float_t rLocalExitPositionY = (Float_t) localExitPosition.y() / cm;
2555  //Float_t rLocalExitPositionZ = (Float_t) localExitPosition.z() / cm;
2556 
2557  //--- get origin vertex position
2558  G4ThreeVector originVertexPosition = aHit->GetOriginVertexPosition();
2559  Float_t rOriginVertexPositionX = (Float_t) originVertexPosition.x() / cm;
2560  Float_t rOriginVertexPositionY = (Float_t) originVertexPosition.y() / cm;
2561  Float_t rOriginVertexPositionZ = (Float_t) originVertexPosition.z() / cm;
2562 
2563  //--- get world momentum of hit
2564  G4ThreeVector globalMomentum = aHit->GetWorldMomentum();
2565  //Float_t rGlobalMomentumX = (Float_t) globalMomentum.x() / MeV;
2566  //Float_t rGlobalMomentumY = (Float_t) globalMomentum.y() / MeV;
2567  //Float_t rGlobalMomentumZ = (Float_t) globalMomentum.z() / MeV;
2568 
2569  //--- get global theta & phi angle
2570  Float_t rGlobalThetaAngle = (Float_t) globalMomentum.theta() / degree;
2571  Float_t rGlobalPhiAngle = (Float_t) globalMomentum.phi() / degree - 90.0;
2572 
2573  //--- get local momentum of hit
2574  //G4ThreeVector localMomentum = aHit->GetLocalMomentum();
2575  //Float_t rLocalMomentumX = (Float_t) localMomentum.x() / MeV;
2576  //Float_t rLocalMomentumY = (Float_t) localMomentum.y() / MeV;
2577  //Float_t rLocalMomentumZ = (Float_t) localMomentum.z() / MeV;
2578 
2579  //--- get local vertex momentum direction of hit
2580  G4ThreeVector localVertexMomentumDirection = aHit->GetMomentumDirection();
2581  Float_t rLocalVertexMomentumDirectionX = (Float_t) localVertexMomentumDirection.x();
2582  Float_t rLocalVertexMomentumDirectionY = (Float_t) localVertexMomentumDirection.y();
2583  Float_t rLocalVertexMomentumDirectionZ = (Float_t) localVertexMomentumDirection.z();
2584 
2585  //--- get origin vertex momentum direction of hit
2586  G4ThreeVector originVertexMomentumDirection = aHit->GetOriginVertexMomentumDirection();
2587  Float_t rOriginVertexMomentumDirectionX = (Float_t) originVertexMomentumDirection.x();
2588  Float_t rOriginVertexMomentumDirectionY = (Float_t) originVertexMomentumDirection.y();
2589  Float_t rOriginVertexMomentumDirectionZ = (Float_t) originVertexMomentumDirection.z();
2590 
2591  //--- get origin vertex theta & phi angle
2592  Float_t rOriginVertexThetaAngle = (Float_t) originVertexMomentumDirection.theta() / degree;
2593  Float_t rOriginVertexPhiAngle = (Float_t) originVertexMomentumDirection.phi() / degree;
2594 
2595  //--- get origin vertex kinetic energy & total energy
2596  Float_t rOriginVertexKineticEnergy = (Float_t ) aHit->GetOriginVertexKineticEnergy() / MeV;
2597  Float_t rOriginVertexTotalEnergy = (Float_t ) aHit->GetOriginVertexTotalEnergy() / MeV;
2598 
2599  //--- get total energy & total energy of hit
2600  Float_t rKineticEnergy = (Float_t) aHit->GetKineticEnergy() / MeV;
2601  Float_t rTotalEnergy = (Float_t) aHit->GetTotalEnergy() / MeV;
2602 
2603  //--- get Lumi deposited energy
2604  Float_t rDepositedEnergy = (Float_t) aHit->GetHitDepositedEnergy() / MeV;
2605  //--------------------------------------------------------------------------------------------
2606 
2607  //--- store Primary Event Number
2608  analysis->fRootEvent->Lumi.Detector.StorePrimaryEventNumber((Int_t) PrimaryEventNumber);
2609 
2610  //--- store track ID
2612 
2613  //--- store particle name & type
2616 
2617  //--- store global time of hit
2619 
2620  //--- mark Lumi detector as been hit
2622  //--- edge event flag
2623  //--- Store Nb of hits --- Done in previous code
2624  //analysis->fRootEvent->Lumi.Detector.StoreDetectorNbOfHits(n_hitLumi);
2625 
2626  //--- store global position
2630 
2631  //--- store local position
2635 
2636  //analysis->fRootEvent->Lumi.Detector.StoreDetectorLocalExitPositionX(rLocalExitPositionX);
2637  //analysis->fRootEvent->Lumi.Detector.StoreDetectorLocalExitPositionY(rLocalExitPositionY);
2638  //analysis->fRootEvent->Lumi.Detector.StoreDetectorLocalExitPositionZ(rLocalExitPositionZ);
2639 
2640  //--- store origin vertex position
2641  analysis->fRootEvent->Lumi.Detector.StoreOriginVertexPositionX(rOriginVertexPositionX);
2642  analysis->fRootEvent->Lumi.Detector.StoreOriginVertexPositionY(rOriginVertexPositionY);
2643  analysis->fRootEvent->Lumi.Detector.StoreOriginVertexPositionZ(rOriginVertexPositionZ);
2644 
2645  //--- store local vertex momentum direction
2646  analysis->fRootEvent->Lumi.Detector.StoreLocalVertexMomentumDirectionX(rLocalVertexMomentumDirectionX);
2647  analysis->fRootEvent->Lumi.Detector.StoreLocalVertexMomentumDirectionY(rLocalVertexMomentumDirectionY);
2648  analysis->fRootEvent->Lumi.Detector.StoreLocalVertexMomentumDirectionZ(rLocalVertexMomentumDirectionZ);
2649 
2650  //--- store origin vertex momentum direction
2651  analysis->fRootEvent->Lumi.Detector.StoreOriginVertexMomentumDirectionX(rOriginVertexMomentumDirectionX);
2652  analysis->fRootEvent->Lumi.Detector.StoreOriginVertexMomentumDirectionY(rOriginVertexMomentumDirectionY);
2653  analysis->fRootEvent->Lumi.Detector.StoreOriginVertexMomentumDirectionZ(rOriginVertexMomentumDirectionZ);
2654 
2655  //--- store origin theta & phi angle
2656  analysis->fRootEvent->Lumi.Detector.StoreOriginVertexThetaAngle(rOriginVertexThetaAngle);
2657  analysis->fRootEvent->Lumi.Detector.StoreOriginVertexPhiAngle(rOriginVertexPhiAngle);
2658 
2659  //--- store origin kinetic energy & total energy
2660  analysis->fRootEvent->Lumi.Detector.StoreOriginVertexKineticEnergy(rOriginVertexKineticEnergy);
2661  analysis->fRootEvent->Lumi.Detector.StoreOriginVertexTotalEnergy(rOriginVertexTotalEnergy);
2662 
2663  //--- store local vertex kinetic & total energy
2666 
2667  //--- store global track theta & phi angle
2668  analysis->fRootEvent->Lumi.Detector.StoreGlobalThetaAngle(rGlobalThetaAngle);
2670 
2671  //--- store Lumi deposited energy
2673  // -- TotalDepositedEnergy is evaluated in UserLumi class
2675  //G4cout <<CalculateRate( myUserInfo->GetCrossSection(), 1)<<G4endl;
2676 
2677  //--------------------------------------------------------------------------------------------
2678 
2679  } // end for(int i1=0;i1<n_hitLumi;i1++)
2680  } // end if (n_hitLumi >0)
2681  //===========================================================
2682  // Store TungstenPlug hits into /TungstenPlug
2683  //===========================================================
2684 
2685  if (n_hitTungstenPlug >0) {
2686  // initialize deposited energy
2687  Float_t rTotalDepositedEnergy = 0.0;
2688 
2689  //--- loop over hits
2690  for (int i1=0;i1<n_hitTungstenPlug;i1++) {
2691 
2692  QweakSimTungstenPlug_DetectorHit* aHit = (*TungstenPlugDetector_HC)[i1];
2693 
2694  //--- track ID
2695  Float_t rTrackID = (Float_t) aHit->GetTrackID();
2696 
2697  //--- particle name & type
2698  TString rParticleName = TString(aHit->GetParticleName());
2699  Int_t rParticleType = (Int_t) aHit->GetParticleType();
2700 
2701  //--- get global time of hit
2702  Float_t rGlobalTime = (Float_t) aHit->GetGlobalTime() / ns;
2703 
2704  //--- get world position of hit
2705  G4ThreeVector globalPosition = aHit->GetWorldPosition();
2706  Float_t rGlobalPositionX = (Float_t) globalPosition.x() / cm;
2707  Float_t rGlobalPositionY = (Float_t) globalPosition.y() / cm;
2708  Float_t rGlobalPositionZ = (Float_t) globalPosition.z() / cm;
2709 
2710  //--- get local position of hit
2711  G4ThreeVector localPosition = aHit->GetLocalPosition();
2712  Float_t rLocalPositionX = (Float_t) localPosition.x() / cm;
2713  Float_t rLocalPositionY = (Float_t) localPosition.y() / cm;
2714  Float_t rLocalPositionZ = (Float_t) localPosition.z() / cm;
2715 
2716  //--- get origin vertex position
2717  G4ThreeVector originVertexPosition = aHit->GetOriginVertexPosition();
2718  Float_t rOriginVertexPositionX = (Float_t) originVertexPosition.x() / cm;
2719  Float_t rOriginVertexPositionY = (Float_t) originVertexPosition.y() / cm;
2720  Float_t rOriginVertexPositionZ = (Float_t) originVertexPosition.z() / cm;
2721 
2722  //--- get world momentum of hit
2723  G4ThreeVector globalMomentum = aHit->GetWorldMomentum();
2724  //Float_t rGlobalMomentumX = (Float_t) globalMomentum.x() / MeV;
2725  //Float_t rGlobalMomentumY = (Float_t) globalMomentum.y() / MeV;
2726  //Float_t rGlobalMomentumZ = (Float_t) globalMomentum.z() / MeV;
2727 
2728  //--- get global theta & phi angle
2729  Float_t rGlobalThetaAngle = (Float_t) globalMomentum.theta() / degree;
2730  Float_t rGlobalPhiAngle = (Float_t) globalMomentum.phi() / degree - 90.0;
2731 
2732  //--- get local momentum of hit
2733  //G4ThreeVector localMomentum = aHit->GetLocalMomentum();
2734  //Float_t rLocalMomentumX = (Float_t) localMomentum.x() / MeV;
2735  //Float_t rLocalMomentumY = (Float_t) localMomentum.y() / MeV;
2736  //Float_t rLocalMomentumZ = (Float_t) localMomentum.z() / MeV;
2737 
2738  //--- get local vertex momentum direction of hit
2739  G4ThreeVector localVertexMomentumDirection = aHit->GetMomentumDirection();
2740  Float_t rLocalVertexMomentumDirectionX = (Float_t) localVertexMomentumDirection.x();
2741  Float_t rLocalVertexMomentumDirectionY = (Float_t) localVertexMomentumDirection.y();
2742  Float_t rLocalVertexMomentumDirectionZ = (Float_t) localVertexMomentumDirection.z();
2743 
2744  //--- get origin vertex momentum direction of hit
2745  G4ThreeVector originVertexMomentumDirection = aHit->GetOriginVertexMomentumDirection();
2746  Float_t rOriginVertexMomentumDirectionX = (Float_t) originVertexMomentumDirection.x();
2747  Float_t rOriginVertexMomentumDirectionY = (Float_t) originVertexMomentumDirection.y();
2748  Float_t rOriginVertexMomentumDirectionZ = (Float_t) originVertexMomentumDirection.z();
2749 
2750  //--- get origin vertex theta & phi angle
2751  Float_t rOriginVertexThetaAngle = (Float_t) originVertexMomentumDirection.theta() / degree;
2752  Float_t rOriginVertexPhiAngle = (Float_t) originVertexMomentumDirection.phi() / degree;
2753 
2754  //--- get origin vertex kinetic energy & total energy
2755  Float_t rOriginVertexKineticEnergy = (Float_t ) aHit->GetOriginVertexKineticEnergy() / MeV;
2756  Float_t rOriginVertexTotalEnergy = (Float_t ) aHit->GetOriginVertexTotalEnergy() / MeV;
2757 
2758  //--- get total energy & total energy of hit
2759  Float_t rKineticEnergy = (Float_t) aHit->GetKineticEnergy() / MeV;
2760  Float_t rTotalEnergy = (Float_t) aHit->GetTotalEnergy() / MeV;
2761 
2762  //--- get TungstenPlug deposited energy
2763  Float_t rDepositedEnergy = (Float_t) aHit->GetHitDepositedEnergy() / MeV;
2764  rTotalDepositedEnergy += rDepositedEnergy;
2765 
2766  //--- store Primary Event Number
2767  analysis->fRootEvent->TungstenPlug.Detector.StorePrimaryEventNumber((Int_t) PrimaryEventNumber);
2768 
2769  //--- store track ID
2771 
2772  //--- store particle name & type
2775 
2776  //--- store global time of hit
2778 
2779  //--- mark TungstenPlug detector as been hit
2781 
2782  //--- store global position
2786 
2787  //--- store local position
2791 
2792  //--- store origin vertex position
2796 
2797  //--- store local vertex momentum direction
2801 
2802  //--- store origin vertex momentum direction
2806 
2807  //--- store origin theta & phi angle
2810 
2811  //--- store origin kinetic energy & total energy
2814 
2815  //--- store local vertex kinetic & total energy
2818 
2819  //--- store global track theta & phi angle
2822 
2823  //--- store TungstenPlug deposited energy
2825 
2826  } // end for(int i1=0;i1<n_hitTungstenPlug;i1++)
2827 
2828  // Put the total energy into the thing.
2830 
2831  } // end if (n_hitTungstenPlug >0)
2832 
2833 // G4cout << "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$" << G4endl;
2834 
2835  // Finally fill our event ntuple
2837 
2838  //jpan@nuclear.uwinnipeg.ca
2839  //clear vector contents
2843 
2844  } //end of if( (n_hitWirePlane == 2)&&(n_hitFront >0)&&(n_hitBack >0)&&(n_hitCerenkovDetector >0) )
2845 
2847 
2848  // print the Eloss for diagnostics
2850  // clear the Eloss variables for even PrimaryEventNumber events only,
2851  // after they have been stored in the rootfile
2852  //
2853  // odd PrimaryEventNumber events are used to generate physics
2854  // up to the scattering vertex Z
2855  //
2856  // NOTE:: in QweakSimPrimaryGenerator.cc, the PrimaryEventNumber is increased
2857  // at the end of GeneratePrimaries. GeneratePrimaries is called before EnfOfEventAction.
2858  // Therefore, even though, even events are used to generate physics events up to the
2859  // scattering vertex Z in GeneratePrimaries, the permutation is flipped inside this
2860  // routine.
2862 
2863 
2864 
2865  //=======================================================================
2866  // Save the Ntuple periodically so we have some data in case of a crash
2867 
2868  G4int eventNumber = evt->GetEventID();
2869 
2870  if (eventNumber%1000 == 1)
2872 
2873 //=======================================================================
2874 
2875 } // end of QweakSimEventAction::EndOfEventAction()
2876 
2877 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2879 {
2880 }
2881 
2882 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2883 G4double QweakSimEventAction::GetDistance(G4ThreeVector p1,G4ThreeVector p2) {
2884  return sqrt((p1.x()-p2.x())*(p1.x()-p2.x())+
2885  (p1.y()-p2.y())*(p1.y()-p2.y())+
2886  (p1.z()-p2.z())*(p1.z()-p2.z()));
2887 }
2888 
2889 
2890 ////....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2891 // Jim Dowd
2892 // ---------------------------------------------------------
2893 // Calculates and stores the kinematic variables Nu, Q2,
2894 // x, and W.
2895 // ---------------------------------------------------------
2897 {
2898  // Vertex Kinematic variables
2899  // These variables are only valid for events generated with the standard
2900  // generator (not the lookup table).
2901  G4double mp = 938.2796*MeV;
2902  G4double E_in = myUserInfo->GetPreScatteringKineticEnergy() + 0.511*MeV;
2903  G4double E_out = myUserInfo->GetOriginVertexTotalEnergy();
2904  G4double theta = myUserInfo->GetOriginVertexThetaAngle();
2905 
2906 
2907  std::vector<Float_t> TargetLocalVertexTotalEnergy = analysis->fRootEvent->Target.Detector.GetDetectorLocalVertexTotalEnergy();
2908  std::vector<Float_t> TargetGlobalThetaAngle = analysis->fRootEvent->Target.Detector.GetGlobalThetaAngle();
2909 
2910  G4double nu = E_in - E_out;
2911  G4double q2 = 4.0*E_in*E_out*sin(theta*degree/2.0)*sin(theta*degree/2.0);
2912  G4double x = q2/(2.0*mp*nu);
2913  G4double w = sqrt(mp*mp+2.0*mp*nu-q2);
2914 
2919 
2920  //G4cout << "==== Vertex Kinematics ====" << G4endl;
2921  //G4cout << "E_in: " << E_in << G4endl;
2922  //G4cout << "E_out: " << E_out << G4endl;
2923  //G4cout << "Theta: " << theta << G4endl;
2924  //G4cout << "Nu: " << nu << G4endl;
2925  //G4cout << "Q2: " << q2 << G4endl;
2926  //G4cout << "X: " << x << G4endl;
2927  //G4cout << "W: " << w << G4endl;
2928 
2929 
2930  // "Effective" kinematic variables
2931  // Calculates the "effective" or "detected" kinematic variables.
2932  // E_out and theta are grabbed from the target detector at the
2933  // target's exit window. Since ReactionType 7 bypasses the target,
2934  // OriginVertex values are used instead.
2935 
2936  E_in = myUserInfo->GetBeamEnergy();
2937  if (myUserInfo->GetReactionType() == 7 ||
2938  myUserInfo->GetReactionType() == 100) {
2941  }
2942  else {
2943  if (TargetLocalVertexTotalEnergy.size() > 0)
2944  E_out = TargetLocalVertexTotalEnergy[0];
2945  else
2946  E_out = -1.0 * GeV;
2947  if (TargetGlobalThetaAngle.size() > 0)
2948  theta = TargetGlobalThetaAngle[0];
2949  else {
2950  G4cerr << "no hits in scattering chamber" << G4endl;
2951  theta = -180.0 * deg;
2952  }
2953  }
2954 
2955  nu = E_in - E_out;
2956  q2 = 4.0*E_in*E_out*sin(theta*degree/2.0)*sin(theta*degree/2.0);
2957  x = q2/(2.0*mp*nu);
2958  w = sqrt(mp*mp+2.0*mp*nu-q2);
2959 
2961  myUserInfo->StoreEffectiveKinematicQ2(q2*0.000001);
2964 
2965  //G4cout << "==== Effective Kinematics ====" << G4endl;
2966  //G4cout << "E_in: " << E_in << G4endl;
2967  //G4cout << "E_out: " << E_out << G4endl;
2968  //G4cout << "Theta: " << theta << G4endl;
2969  //G4cout << "Nu: " << nu << G4endl;
2970  //G4cout << "Q2: " << q2 << G4endl;
2971  //G4cout << "X: " << x << G4endl;
2972  //G4cout << "W: " << w << G4endl;
2973  //G4cout << "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" << G4endl;
2974 }
2975 
2976 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2977 
2978 ////....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2979 // Jim Dowd
2980 // ---------------------------------------------------------
2981 // Calculates a rate based on the generation limits and
2982 // target type.
2983 // ---------------------------------------------------------
2984 G4double QweakSimEventAction::CalculateRate(G4double xsec, G4int PEs)
2985 {
2987  return rate;
2988 }
2989 
2990 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
2991 
void StoreCrossSectionRadElastic(Float_t cs)
void StorePMTRightRate(std::vector< Float_t > rr)
G4ThreeVector GetNormMomentum() const
ROOT Subtree structure for HDC WirePlaneEvent.
G4THitsCollection< QweakSimVDC_DriftCellHit > QweakSimVDC_DriftCellHitsCollection
void StorePMTRightYieldELPeak(std::vector< Float_t > yr)
G4double GetEffectiveKinematicQ2() const
QweakSimUserPMTOnly_PMTEvent PMT
PMT hit information.
G4ThreeVector GetOriginVertexPosition() const
G4ThreeVector GetLocalPosition() const
void EndOfEventAction(const G4Event *evt)
QweakSimUserTungstenPlug_MainEvent TungstenPlug
tree containing TungstenPlug info
void StorePMTTotalYieldQE(std::vector< Float_t > yt)
void StoreDCUPlaneWireAngle(Float_t dc_ua)
G4ThreeVector GetLocalPosition() const
G4double GetOriginVertexKineticEnergy() const
QweakSimUserHDC_SingleHDCEvent ChamberBack
Back HDC wire chamber hit information.
QweakSimUserVDC_Config Config
Drift chamber configuration information.
void StoreDCVPlaneWireAngle(Float_t dc_va)
void StorePMTTotalRateEL(std::vector< Float_t > rt)
G4double GetOriginVertexPositionX() const
void StoreDCWidthOnFrame(Float_t dcw)
std::vector< G4bool > fTrigger
void StorePMTTotalYieldELPeak(std::vector< Float_t > yt)
G4ThreeVector GetLocalMomentum() const
static const G4bool print_VDC_WirePlaneHit
QweakSimUserLumi_MainEvent Lumi
tree containing Lumi detector info
QweakSimUserVDC_MainEvent Region3
object containing VDC info
G4THitsCollection< QweakSimCerenkov_PMTHit > QweakSimCerenkovDetector_PMTHitsCollection
Handling of a hit in the Cerenkov detector.
void StorePMTTotalYield(std::vector< Float_t > yt)
void StoreOriginVertexKinematicQ2(Float_t q2)
std::vector< Float_t > GetGlobalThetaAngle() const
G4double GetEffectiveKinematicW() const
Stores the information about the various tracks.
#define ELOSS_DEBUG
G4THitsCollection< QweakSimTungstenPlug_DetectorHit > QweakSimTungstenPlug_DetectorHitsCollection
G4double GetOriginVertexMomentumDirectionX() const
void StoreCrossSectionBornInelastic(Float_t cs)
G4double GetCrossSectionRadDISIntOnly() const
void Clear(const Option_t *=0)
QweakSimUserGEM_SingleGEMEvent ChamberBack
Back GEM chamber hit information.
G4double GetOriginVertexTotalEnergy() const
QweakSimEventAction(QweakSimAnalysis *AN, QweakSimUserInformation *myUI)
Constructor.
QweakSimUserCerenkov_RadiatorEvent Radiator
Cerenkov radiator hit information.
QweakSimUserHDC_WirePlaneEvent WirePlane5
QweakSimUserVDC_DriftCellEvent DriftCell
Drift cell hit information.
Region 3 Vertical Drift Chamber Drift Cell Hit.
QweakSimAnalysis * analysis
ROOT Subtree structure for HDC SingleHDCEvent.
G4double GetDistance(G4ThreeVector, G4ThreeVector)
static const int PmtMaxSize
QweakSimUserVDC_SingleVDCEvent ChamberBack
Back chamber hit information.
G4ThreeVector GetMomentumDirection() const
void StorePMTRightRateQE(std::vector< Float_t > rr)
void StorePMTLeftYieldELPeak(std::vector< Float_t > yl)
G4double GetCrossSectionRadQEIntOnly() const
void StorePMTRightYield(std::vector< Float_t > yr)
G4double GetCrossSectionRadQE() const
void StoreCrossSectionRadTotalIntOnly(Float_t cs)
G4ThreeVector GetOriginVertexMomentumDirection() const
void StorePMTTotalYieldEL(std::vector< Float_t > yt)
void StorePMTLeftYieldQE(std::vector< Float_t > yl)
G4THitsCollection< QweakSimPMTOnly_PMTHit > QweakSimPMTOnly_PMTHitsCollection
G4ThreeVector GetOriginVertexMomentumDirection() const
G4THitsCollection< QweakSimTriggerScintillator_DetectorHit > QweakSimTriggerScintillator_DetectorHitsCollection
G4double GetOriginVertexKineticEnergy() const
QweakSimUserVDC_WirePlaneEvent WirePlaneU
U wire plane hit information.
G4ThreeVector GetWorldPosition() const
QweakSimUserTarget_MainEvent Target
object containing target hits
void StorePMTTotalRate(std::vector< Float_t > rt)
void StorePMTRightYieldQE(std::vector< Float_t > yr)
void StoreEPrime_Min(Float_t energy)
G4double GetCrossSectionRadElasticPeak() const
QweakSimUserLumi_DetectorEvent Detector
void StorePMTLeftRateELPeak(std::vector< Float_t > rl)
G4ThreeVector GetWorldPosition() const
G4THitsCollection< QweakSimHDC_WirePlaneHit > QweakSimHDC_WirePlane_HitsCollection
G4THitsCollection< QweakSimCerenkov_RadiatorHit > QweakSimCerenkovRadiatorHitsCollection
G4double GetEffectiveKinematicNu() const
G4ThreeVector GetOriginVertexMomentumDirection() const
QweakSimUserTriggerScintillator_MainEvent TriggerScintillator
object containing TriggerScintilliator info
void StoreOriginVertexMomentumDirectionY(Float_t vy)
void StoreOriginVertexKinematicX(G4double X)
void StorePMTLeftRateQE(std::vector< Float_t > rl)
void StorePMTRightNbOfPEs(std::vector< Float_t > npr)
G4THitsCollection< QweakSimVDC_WirePlaneHit > QweakSimVDC_WirePlane_HitsCollection
void StorePMTLeftYieldDIS(std::vector< Float_t > yl)
G4ThreeVector GetLocalCerenkovExitPosition()
QweakSimUserTarget_DetectorEvent Detector
void StoreCrossSectionRadElasticPeak(Float_t cs)
QweakSimUserLeadGlass_DetectorEvent Detector
QweakSimUserHDC_MainEvent Region2
object containing HDC info
QweakSimUserHDC_WirePlaneEvent WirePlane1
G4THitsCollection< QweakSimTarget_DetectorHit > QweakSimTarget_DetectorHitsCollection
G4ThreeVector GetLocalPosition() const
Handling of the output ROOT file.
QweakSimUserMainEvent * fRootEvent
G4double GetOriginVertexKineticEnergy() const
G4ThreeVector GetOriginVertexPosition() const
G4ThreeVector GetOriginVertexPosition() const
void StorePMTLeftRateEL(std::vector< Float_t > rl)
G4ThreeVector GetWorldMomentum() const
G4double GetOriginVertexKinematicNu() const
QweakSimUserHDC_WirePlaneEvent WirePlane2
void StorePMTRightYieldDIS(std::vector< Float_t > yr)
void StorePMTTotalYieldDIS(std::vector< Float_t > yt)
G4double GetOriginVertexPositionZ() const
G4THitsCollection< QweakSimLumi_DetectorHit > QweakSimLumi_DetectorHitsCollection
G4ThreeVector GetWorldPosition() const
void SetTrigger(const G4String value, const G4bool status)
QweakSimUserGEM_SingleGEMEvent ChamberFront
Front GEM chamber hit information.
G4ThreeVector GetMomentumDirection() const
void StoreEffectiveKinematicW(G4double W)
Handles hits of the HDC wire planes.
G4ThreeVector GetOriginVertexMomentumDirection() const
QweakSimUserVDC_SingleVDCEvent ChamberFront
Front chamber hit information.
G4ThreeVector GetWorldMomentum() const
void StoreNumberOfEventToBeProcessed(Int_t events)
void StoreOriginVertexKinematicNu(G4double Nu)
void StoreEffectiveKinematicNu(G4double Nu)
ROOT Subtree structure for VDC WirePlaneEvent.
G4double GetOriginVertexTotalEnergy() const
G4double GetOriginVertexKinematicW() const
void StoreOriginVertexKinematicW(G4double W)
void StorePMTTotalRateDIS(std::vector< Float_t > rt)
G4THitsCollection< QweakSimLeadGlass_DetectorHit > QweakSimLeadGlass_DetectorHitsCollection
void StoreOriginVertexMomentumDirectionZ(Float_t vz)
Handling of a hit in the Cerenkov radiator.
QweakSimUserHDC_WirePlaneEvent WirePlane4
void StorePMTTimeOfHits(std::vector< Float_t > time)
QweakSimUserCerenkov_MainEvent Cerenkov
object containing Cerenkov detector info
G4ThreeVector GetOriginVertexMomentumDirection() const
void StorePMTLeftRate(std::vector< Float_t > rl)
G4double GetCrossSectionBornQE() const
QweakSimUserCerenkov_DetectorEvent Detector
Cerenkov detector hit information.
Messenger for filling//storing the hit event structure at the end of an event.
void StoreEffectiveKinematicQ2(G4double Q2)
void StorePMTLeftNbOfHits(std::vector< Int_t > npl)
void StoreOriginVertexKineticEnergy(Float_t ekin)
G4ThreeVector GetOriginVertexMomentumDirection() const
static const G4bool print_VDC_DriftCellHit
G4double GetOriginVertexKinematicX() const
G4ThreeVector GetLocalMomentum() const
std::map< G4String, EQweakSimTriggerMode > kMapTriggerMode
QweakSimUserHDC_SingleHDCEvent ChamberFront
Front HDC wire chamber hit information.
void StorePMTLeftYield(std::vector< Float_t > yl)
G4double Elastic_Cross_Section_Proton(G4double E_in, G4double Theta, G4double &fWeightN, G4double &Q2, G4double &E_out)
G4double GetPreScatteringKineticEnergy() const
QweakSimUserGEM_MainEvent Region1
object containing HDC info
Handling of a U-WirePlane and/or V-WirePlane Hit of the VDC.
G4double GetNumberOfPhotoelectronsS20(G4double eng)
void StoreOriginVertexKinematicNu(Float_t nu)
void StorePMTRightYieldEL(std::vector< Float_t > yr)
void StoreEffectiveKinematicX(G4double X)
void StoreOriginVertexPhiAngle(Float_t phi)
QweakSimUserCerenkov_PMTEvent PMT
Cerenkov PMT hit information.
virtual void DrawTrajectory(G4int i_mode=0) const
void StorePMTOctantOfHits(std::vector< Int_t > octant)
G4double GetOriginVertexTotalEnergy() const
void StorePMTTotalNbOfHits(std::vector< Int_t > npt)
G4ThreeVector GetOriginVertexPosition() const
void StorePMTRightRateELPeak(std::vector< Float_t > rr)
G4double GetOriginVertexTotalEnergy() const
void StoreCrossSectionRadQEIntOnly(Float_t cs)
void StoreOriginVertexThetaAngle(Float_t theta)
virtual ~QweakSimEventAction()
Destructor.
G4double GetCrossSectionRadDIS() const
G4double GetCrossSectionRadTotalIntOnly() const
void StoreOriginVertexKinematicQ2(G4double Q2)
G4double GetCrossSectionBornTotal() const
void StoreOriginVertexTotalEnergy(Float_t etot)
ROOT Subtree structure for VDC SingleVDCEvent.
G4ThreeVector GetOriginVertexMomentumDirection() const
G4double GetOriginVertexPositionY() const
void StorePMTTotalNbOfPEs(std::vector< Float_t > npt)
std::vector< G4String > fTriggerName
G4double GetOriginVertexMomentumDirectionZ() const
void StorePMTRightRateDIS(std::vector< Float_t > rr)
G4double CalculateRate(G4double xsec, G4int PEs)
G4ThreeVector GetOriginVertexPosition() const
QweakSimUserVDC_WirePlaneEvent WirePlaneV
V wire plane hit information.
QweakSimUserTungstenPlug_DetectorEvent Detector
G4int GetNumberOfEventToBeProcessed() const
G4double GetCrossSectionWeight() const
void StorePMTTotalRateELPeak(std::vector< Float_t > rt)
G4double GetEffectiveKinematicX() const
QweakSimUserTriggerScintillator_DetectorEvent Detector
Detector event in the trigger scintillator.
void StorePMTRightRateEL(std::vector< Float_t > rr)
G4double GetPhotonEnergy() const
QweakSimUserPMTOnly_MainEvent PMTOnly
tree containing PMTOnly info
QweakSimUserHDC_WirePlaneEvent WirePlane6
static const G4bool print_TriggerScintillator_DetectorHit
QweakSimUserHDC_WirePlaneEvent WirePlane3
QweakSimEventActionMessenger * fEventActionMessenger
G4THitsCollection< QweakSimPMTOnly_DetectorHit > QweakSimPMTOnly_DetectorHitsCollection
QweakSimUserPMTOnly_DetectorEvent Detector
void StorePMTEnergyOfHits(std::vector< Float_t > time)
QweakSimUserPrimaryEvent Primary
object containing primary particle info