~chris-rogers/maus/emr_mc_digitization

« back to all changes in this revision

Viewing changes to src/legacy/Config/ModuleConverter.cc

  • Committer: Chris Rogers
  • Date: 2014-04-16 11:48:45 UTC
  • mfrom: (707 merge)
  • mto: This revision was merged to the branch mainline in revision 711.
  • Revision ID: chris.rogers@stfc.ac.uk-20140416114845-h3u3q7pdcxkxvovs
Update to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// MAUS WARNING: THIS IS LEGACY CODE.
2
2
#include "Config/MiceModule.hh"
3
 
#include "Interface/Squeal.hh"
 
3
#include "Utils/Exception.hh"
4
4
#include "Config/ModuleConverter.hh"
5
5
#include "Interface/Squeak.hh"
6
6
 
22
22
  if     (longS == "Energy")        {mom[3] = longD;      mom[2] = sqrt(longD*longD  -mass*mass);}
23
23
  else if(longS == "KineticEnergy") {mom[3] = longD+mass; mom[2] = sqrt(mom[3]*mom[3]-mass*mass);}
24
24
  else if(longS == "Momentum" || longS == "ZMomentum") {mom[2] = longD; mom[3] = sqrt(longD*longD+mass*mass);}
25
 
  else throw(Squeal(Squeal::recoverable, "Beam ellipse longitudinal variable "+longS+" not recognised in Module "+mod->name(), "ModuleConverter::ModuleToHit(MiceModule*)"));
 
25
  else throw(MAUS::Exception(MAUS::Exception::recoverable, "Beam ellipse longitudinal variable "+longS+" not recognised in Module "+mod->name(), "ModuleConverter::ModuleToHit(MiceModule*)"));
26
26
  HepLorentzVector pos(mod->globalPosition(), mod->propertyDouble("Time"));
27
27
  mom *= mod->globalRotation();
28
28
  hit.setPosition(pos.v());
50
50
  }
51
51
 
52
52
  double dx=0., dy=0., dpx=0., dpy=0.; //dispersion, dispersion prime
53
 
  try{dx  = mod->propertyDouble("Dispersion_X"     );} catch(Squeal squee) {}
54
 
  try{dy  = mod->propertyDouble("Dispersion_Y"     );} catch(Squeal squee) {}
55
 
  try{dpx = mod->propertyDouble("DispersionPrime_X");} catch(Squeal squee) {}
56
 
  try{dpy = mod->propertyDouble("DispersionPrime_Y");} catch(Squeal squee) {}
 
53
  try{dx  = mod->propertyDouble("Dispersion_X"     );} catch(MAUS::Exception exc) {}
 
54
  try{dy  = mod->propertyDouble("Dispersion_Y"     );} catch(MAUS::Exception exc) {}
 
55
  try{dpx = mod->propertyDouble("DispersionPrime_X");} catch(MAUS::Exception exc) {}
 
56
  try{dpy = mod->propertyDouble("DispersionPrime_Y");} catch(MAUS::Exception exc) {}
57
57
  if(ellipseDef == "Penn")
58
58
  {
59
59
    double bz = 0;
106
106
  }
107
107
  std::stringstream iss;
108
108
  iss << mass; 
109
 
  throw(Squeal(Squeal::recoverable, "Did not recognise pid "+iss.str()+" for mass calculation", "ModuleConverter::MassToPdgPid"));
 
109
  throw(MAUS::Exception(MAUS::Exception::recoverable, "Did not recognise pid "+iss.str()+" for mass calculation", "ModuleConverter::MassToPdgPid"));
110
110
}
111
111
 
112
112
double ModuleConverter::PdgPidToMass(int pid)
114
114
  pid = abs(pid);
115
115
  FillPdgPidToMass();
116
116
  if(_pdgPidToMass.find(pid) != _pdgPidToMass.end()) return _pdgPidToMass[pid];
117
 
  else {std::stringstream iss; iss << pid; throw(Squeal(Squeal::recoverable, "Did not recognise pid "+iss.str()+" for mass calculation", "ModuleConverter::PdgPidToMass"));}
 
117
  else {std::stringstream iss; iss << pid; throw(MAUS::Exception(MAUS::Exception::recoverable, "Did not recognise pid "+iss.str()+" for mass calculation", "ModuleConverter::PdgPidToMass"));}
118
118
}
119
119
 
120
120
double ModuleConverter::PdgPidToCharge(int pid)
122
122
  int abs_pid = abs(pid);
123
123
  FillPdgPidToCharge();
124
124
  if(_pdgPidToCharge.find(abs_pid) != _pdgPidToCharge.end()) return _pdgPidToCharge[abs_pid]*abs_pid/pid*CLHEP::eplus;
125
 
  else {std::stringstream iss; iss << pid; throw(Squeal(Squeal::recoverable, "Did not recognise pid "+iss.str()+" for charge calculation", "ModuleConverter::PdgPidToCharge"));}
 
125
  else {std::stringstream iss; iss << pid; throw(MAUS::Exception(MAUS::Exception::recoverable, "Did not recognise pid "+iss.str()+" for charge calculation", "ModuleConverter::PdgPidToCharge"));}
126
126
}
127
127
 
128
128
CLHEP::HepSymMatrix ModuleConverter::SetCovariances(MCHit hit, double bz,