Deprecated/UpgradeASCIITests/SdSimulationCalibrationFillerASCII/SdSimulationCalibrationFiller.cc
Go to the documentation of this file.
1 #include <det/Detector.h>
2 
3 #include <sdet/SDetector.h>
4 
5 #include <evt/Event.h>
6 
7 #include <fwk/CentralConfig.h>
8 
9 #include <sevt/SEvent.h>
10 #include <sevt/Station.h>
11 #include <sevt/StationSimData.h>
12 #include <sevt/StationCalibData.h>
13 #include <sevt/PMTCalibData.h>
14 #include <sevt/PMTSimData.h>
15 #include <sevt/PMT.h>
16 
17 #include <sdet/PMT.h>
18 #include <sdet/PMTConstants.h>
19 
20 #include <utl/Reader.h>
21 
23 
24 using namespace std;
25 using namespace sevt;
26 using namespace utl;
27 using namespace fwk;
28 using namespace evt;
29 
30 using namespace SdSimulationCalibrationFillerASCII;
31 
32 
35 {
36  Branch topB =
37  CentralConfig::GetInstance()->GetTopBranch("SdSimulationCalibrationFillerASCII");
38 
39  topB.GetChild("calibrationVersion").GetData(fcalibVersion);
40 
41  Branch calibBranch =
42  CentralConfig::GetInstance()->GetTopBranch("SdCalibrator");
43 
44  calibBranch.GetChild("peakVEMConversionFactor").
45  GetData(fPeakVEMConversionFactor);
46  calibBranch.GetChild("chargeVEMConversionFactor").
47  GetData(fChargeVEMConversionFactor);
48  calibBranch.GetChild("onlineChargeVEMFactor").
49  GetData(fOnlineChargeVEMFactor);
50 
51  cout << "got magic numbers " << fPeakVEMConversionFactor << ' ' <<
52  fChargeVEMConversionFactor << ' ' << fOnlineChargeVEMFactor << endl;
53 
54  return eSuccess;
55 }
56 
57 
59 SdSimulationCalibrationFiller::Run(Event& event)
60 {
61  if (!event.HasSEvent())
62  event.MakeSEvent();
63 
64  SEvent& sevent = event.GetSEvent();
65 
67  seIt != sevent.CandidateStationsEnd(); ++seIt) {
68 
69  string signature;
70  if (seIt->HasSimData()) {
71  signature = seIt->GetSimData().GetSimulatorSignature();
72 
73  // FIXME ( for some reason the SdSimCalibrationManager does not load the values in the SdSimCalibrationConstants.xml )
74  if (signature == "G4TankSimulatorFullASCII")
75  signature="G4TankSimulatorFullOG";
76  else if (signature == "G4TankSimulatorASCII")
77  signature="G4TankSimulatorOG";
78  } else
79  ERROR("No SimData found, though it should exist at this point");
80 
81  if (!seIt->HasCalibData())
82  seIt->MakeCalibData();
83 
84  sevt::StationCalibData& statCalib = seIt->GetCalibData();
85 
86  statCalib.SetVersion(fCalibVersion);
87  statCalib.SetStartSecond(1);
88  statCalib.SetEndSecond(3);
89  statCalib.SetNT1(100);
90  statCalib.SetNT2(20);
91  statCalib.SetNTot(1);
92 
93  for (sevt::Station::PMTIterator pmtIt = seIt->PMTsBegin(sdet::PMTConstants::eAnyType);
94  pmtIt != seIt->PMTsEnd(sdet::PMTConstants::eAnyType); ++pmtIt) {
95 
96  if (!pmtIt->HasCalibData())
97  pmtIt->MakeCalibData();
98 
99  try {
100  PMTCalibData& pmtCal = pmtIt->GetCalibData();
101 
102  // Currently, there is no way to make a new PMT in SDetector (and it is forbidden to get a
103  // PMT with an index higher than those required by the WCD PMTs). This will be resolved,
104  // but until now, the sdet PMT contents of WCD PMT1 are called here.
105  const sdet::PMT& detPMT =
106  det::Detector::GetInstance().GetSDetector().GetStation(*seIt).GetPMT((pmtIt->GetType() == sdet::PMTConstants::eWaterCherenkovLarge) ? pmtIt->GetId() : 1);
107 
108  // apply calibration magic numbers from Laura (in reverse)
109  pmtCal.SetVEMPeak(detPMT.GetVEMPeak(signature) * fPeakVEMConversionFactor);
110  pmtCal.SetVEMCharge(detPMT.GetVEMCharge(signature) * fChargeVEMConversionFactor/fOnlineChargeVEMFactor);
111 
118 
119  pmtCal.SetIsTubeOk(true);
120  pmtCal.SetRate(7e3);
121  pmtCal.SetDynodeAnodeRatio(detPMT.GetDA(), detPMT.GetDARMS());
122 
123  pmtCal.SetEvolution(0);
124  pmtCal.SetNumberTDA(0);
125  pmtCal.SetDynodeAnodeDelay(0, 0);
126  pmtCal.SetDynodeAnodeDelayChi2(0);
128  ostringstream msg;
129  msg << "Skipping station " << seIt->GetId() << ", pmt " << pmtIt->GetId();
130  INFO(msg);
131  continue;
132  }
133  }
134  }
135 
136  return eSuccess;
137 }
138 
139 
141 SdSimulationCalibrationFiller::Finish()
142 {
143  return eSuccess;
144 }
Branch GetTopBranch() const
Definition: Branch.cc:63
double GetBaseline(const sdet::PMTConstants::PMTGain gain) const
Get baseline level for the PMT (for simulations)
void SetNTot(const unsigned int ntot)
total number of triggers recevied during calibration
Detector description interface for PMT-related data.
Definition: SDetector/PMT.h:26
Interface class to access to the SD part of an event.
Definition: SEvent.h:39
void SetNumberTDA(const int num)
Definition: PMTCalibData.h:95
#define INFO(message)
Macro for logging informational messages.
Definition: ErrorLogger.h:161
boost::filter_iterator< CandidateStationFilter, StationIterator > CandidateStationIterator
Iterator over candidate stations.
Definition: SEvent.h:68
void Init()
Initialise the registry.
Base class for exceptions trying to access non-existing components.
Branch GetChild(const std::string &childName) const
Get child of this Branch by child name.
Definition: Branch.cc:211
boost::filter_iterator< PMTFilter, InternalPMTIterator > PMTIterator
Iterator over station for read/write.
CandidateStationIterator CandidateStationsBegin()
Definition: SEvent.h:72
Class representing a document branch.
Definition: Branch.h:107
Online Calibration data.
Definition: PMTCalibData.h:27
void SetVersion(const int version)
version of the onboard calibration
Station Calibration data
double GetVEMPeak(const std::string &simulationIdentifier) const
Get VEM peak for the PMT (for simulations)
SEventSimData & GetSimData()
Get the object with simulated data, throw if n.a.
Definition: SEvent.h:138
void GetData(bool &b) const
Overloads of the GetData member template function.
Definition: Branch.cc:644
void SetNT1(const unsigned int nt1)
number of T1 received during calibration
void SetRate(const double rate)
Definition: PMTCalibData.h:81
ResultFlag
Flag returned by module methods to the RunController.
Definition: VModule.h:60
void SetNT2(const unsigned int nt2)
number of T2 received during calibration
void SetStartSecond(const unsigned int ss)
GPS second of start of calibration.
void SetEndSecond(const unsigned int es)
GPS second of end of calibration.
CandidateStationIterator CandidateStationsEnd()
Definition: SEvent.h:74
void SetEvolution(const int ev)
Definition: PMTCalibData.h:94
double GetVEMCharge(const std::string &simulationIdentifier) const
Get VEM charge for the PMT (for simulations)
#define ERROR(message)
Macro for logging error messages.
Definition: ErrorLogger.h:165
bool HasSEvent() const
void SetIsTubeOk(const bool ok)
Definition: PMTCalibData.h:79
double GetBaselineRMS(const sdet::PMTConstants::PMTGain gain) const
Get baseline noise for the PMT (for simulations)
void SetBaseline(const double base, const double rms, const sdet::PMTConstants::PMTGain gain=sdet::PMTConstants::eHighGain)
Set baseline and baseline RMS for a particular channel (defaults to high gain channel) ...
Definition: PMTCalibData.h:86

, generated on Tue Sep 26 2023.