Public Member Functions | Private Attributes | List of all members
beamlineutil::BeamlineMagneticField Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-11-28/BeamlineUtils/BeamlineMagneticField.h"

Public Member Functions

 BeamlineMagneticField (fhicl::ParameterSet const &pset)
 
 BeamlineMagneticField (fhicl::ParameterSet const &pset, art::ActivityRegistry &)
 
float MagnetCurrent (unsigned int beamline_run)
 Return the magnet current for a given beamline data run. More...
 
float MagneticField (unsigned int beamline_run)
 Return the magnetic field for a given beamline data run. More...
 
float FieldFromCurrent (float magnet_current)
 Convert magnet current to magnetic field using field mapping information. More...
 

Private Attributes

float fCurrentToField
 
std::map< unsigned int, float > fMagnetInfo
 

Detailed Description

Definition at line 32 of file BeamlineMagneticField.h.

Constructor & Destructor Documentation

beamlineutil::BeamlineMagneticField::BeamlineMagneticField ( fhicl::ParameterSet const &  pset)

Definition at line 15 of file BeamlineMagneticField_service.cc.

References fCurrentToField, fMagnetInfo, and fhicl::ParameterSet::get().

15  {
16  fhicl::ParameterSet magnet_currents = pset.get<fhicl::ParameterSet>("MagnetCurrents");
17  std::vector<std::pair<unsigned int, float> > current_table
18  = magnet_currents.get<std::vector<std::pair<unsigned int, float> > >("table");
19  for (std::vector<std::pair<unsigned int, float > >::const_iterator current_table_it = current_table.begin();
20  current_table_it != current_table.end(); ++current_table_it)
21  fMagnetInfo[current_table_it->first] = current_table_it->second;
22  fCurrentToField = pset.get<float>("CurrentToField");
23 }
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::map< unsigned int, float > fMagnetInfo
beamlineutil::BeamlineMagneticField::BeamlineMagneticField ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry  
)

Definition at line 26 of file BeamlineMagneticField_service.cc.

27  : BeamlineMagneticField(pset) {
28 }
BeamlineMagneticField(fhicl::ParameterSet const &pset)

Member Function Documentation

float beamlineutil::BeamlineMagneticField::FieldFromCurrent ( float  magnet_current)

Convert magnet current to magnetic field using field mapping information.

Definition at line 56 of file BeamlineMagneticField_service.cc.

References abs(), DEFINE_ART_SERVICE, and cet::pow().

Referenced by MagneticField(), and beamlinereco::WCTrackReco::produce().

56  {
57 
58  // eqn from Mark (technote doesn't exist yet - add docdb info here once it does)
59  // eqn gives you the aboslute value of the field - use the sign of the current to determine sign of field
60  float field_magnitude = -0.0294 + abs(magnet_current)/985.3 - pow(abs(magnet_current)/3451.2,2);
61  // returns value of field with sign of current
62  float b_field = copysign(field_magnitude, magnet_current);
63 
64  return b_field;
65 
66 }
constexpr T pow(T x)
Definition: pow.h:75
void abs(TH1 *hist)
float beamlineutil::BeamlineMagneticField::MagnetCurrent ( unsigned int  beamline_run)

Return the magnet current for a given beamline data run.

Definition at line 31 of file BeamlineMagneticField_service.cc.

References fMagnetInfo, and updateRunHistoryTables::run.

Referenced by MagneticField().

31  {
32 
33  if (run < fMagnetInfo.begin()->first)
34  throw cet::exception("BeamlineMagneticField")
35  << "Requested run " << run << " has no magnet current information available.";
36 
37  unsigned int run_with_current = run;
38  while (!fMagnetInfo.count(run_with_current))
39  run_with_current -= 1;
40 
41  return fMagnetInfo[run_with_current];
42 
43 }
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
Definition: run.py:1
std::map< unsigned int, float > fMagnetInfo
float beamlineutil::BeamlineMagneticField::MagneticField ( unsigned int  beamline_run)

Return the magnetic field for a given beamline data run.

Definition at line 46 of file BeamlineMagneticField_service.cc.

References FieldFromCurrent(), and MagnetCurrent().

Referenced by beamlinereco::WCTrackReco::produce(), and daq2raw::BeamlineUnpack::UnpackConfig().

46  {
47 
48  float magnet_current = this->MagnetCurrent(run);
49  float b_field = this->FieldFromCurrent(magnet_current);
50 
51  return b_field;
52 
53 }
Definition: run.py:1
float FieldFromCurrent(float magnet_current)
Convert magnet current to magnetic field using field mapping information.
float MagnetCurrent(unsigned int beamline_run)
Return the magnet current for a given beamline data run.

Member Data Documentation

float beamlineutil::BeamlineMagneticField::fCurrentToField
private

Definition at line 51 of file BeamlineMagneticField.h.

Referenced by BeamlineMagneticField().

std::map<unsigned int, float> beamlineutil::BeamlineMagneticField::fMagnetInfo
private

Definition at line 52 of file BeamlineMagneticField.h.

Referenced by BeamlineMagneticField(), and MagnetCurrent().


The documentation for this class was generated from the following files: