67{
71
73 typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type;
78
79 JParallelFileScanner_t inputFile;
82 string detectorFile;
83 JCalibration_t calibrationFile;
84 double Tmax_s;
85 string pdfFile;
87 histogram_type calibrate;
89
90 try {
91
93
94 JParser<> zap(
"Program to perform detector calibration using reconstructed muon trajectories.");
95
103 zap[
'c'] =
make_field(calibrate,
"Histogram for time calibration per optical module.");
106
107 zap(argc, argv);
108 }
109 catch(const exception& error) {
110 FATAL(error.what() << endl);
111 }
112
113
114 if (!calibrate.is_valid()) {
115 FATAL(
"Invalid calibration data " << calibrate << endl);
116 }
117
120 }
121
123
124 try {
126 }
129 }
130
131 unique_ptr<JDynamics> dynamics;
132
133 try {
134
136
137 dynamics->load(calibrationFile);
138 }
139 catch(const exception& error) {
140 if (!calibrationFile.empty()) {
142 }
143 }
144
146
148
150
153
155
156
158
159 TH2D ha("ha", NULL, 256, -0.5, 255.5,
160 calibrate.getNumberOfBins(), calibrate.getLowerLimit(), calibrate.getUpperLimit());
161
162 TProfile hb("hb", NULL, 256, -0.5, 255.5);
163
164 TProfile hr("hr", NULL, 60, 0.0, 150.0);
165
167 calibrate.getNumberOfBins(), calibrate.getLowerLimit(), calibrate.getUpperLimit());
168
169 JManager_t
g1(
new TProfile(
"%", NULL,
detector.size(), -0.5,
detector.size() - 0.5, -1.0, +1.0));
170
171
172 while (inputFile.hasNext()) {
173
174 STATUS(
"event: " << setw(10) << inputFile.getCounter() <<
'\r');
DEBUG(endl);
175
176 multi_pointer_type ps = inputFile.next();
177
180
181 summary.update(*tev);
182
183 if (dynamics) {
184 dynamics->update(*tev);
185 }
186
188
189 JDataL0_t dataL0;
190
191 buildL0(*tev, router, true, back_inserter(dataL0));
192
193 for (JFIT::JEvt::const_iterator track = in->begin(); track != in->end(); ++track) {
194
198
201 }
202
204
205
206
208
209 for (JDataL0_t::const_iterator i = dataL0.begin(); i != dataL0.end(); ++i) {
210
211 double rate_Hz = summary.getRate(*i);
212
213 if (rate_Hz <= 0.0) {
214 rate_Hz = summary.getRate();
215 }
216
218
219 hit.rotate(R);
220
221 if (match(hit)) {
223 }
224 }
225
226
227
229
230 JDataW0_t::iterator __end = unique(
data.begin(),
data.end(), equal_to<JDAQPMTIdentifier>());
231
232
233
234
235 if (track->getE() > 0.1)
236 fit.JRegressor_t::E_GeV = track->getE();
237 else
238 fit.JRegressor_t::E_GeV = parameters.
E_GeV;
239
241
242 for (JDataW0_t::const_iterator hit =
data.begin(); hit != __end; ++hit) {
243 buffer.insert(hit->getModuleID());
244 }
245
247
249
250 JDataW0_t::iterator q = partition(
data.begin(), __end, make_predicate(&JHitW0::getModuleID, *
id,
JComparison::ne()));
251
252 if (
distance(
data.begin(), q) - fit.parameters.size() > 0) {
253
254 fit(ta,
data.begin(), q);
255
256 for (JDataW0_t::const_iterator hit = q; hit != __end; ++hit) {
257
258 const int index = router.getIndex(*id);
259 const double t1 = fit.value.getT(hit->getPosition());
260 JTrack3D gradient = fit(fit.value, *hit).gradient;
261
263
264 ha.Fill(hit->getToT(), hit->getT1() - t1);
265 hb.Fill(hit->getToT(), gradient.
getT());
266
267 hr.Fill(fit.value.getDistance(*hit), gradient.
getT());
268
269 h2.Fill(index, hit->getT() - t1);
270
271 g1[
"T"]->Fill(index, gradient.
getT());
272 g1[
"X"]->Fill(index, gradient.
getX());
273 g1[
"Y"]->Fill(index, gradient.
getY());
274 g1[
"Z"]->Fill(index, gradient.
getZ());
275 }
276 }
277 }
278 }
279 }
281
283
285
286 out << ha;
287 out << hb;
288 out << hr;
289 out << h2;
291
292 out.Write();
293 out.Close();
294}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Double_t g1(const Double_t x)
Function.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Router for direct addressing of module data in detector data structure.
Data structure for set of track fit results.
void select(const JSelector_t &selector)
Select fits.
Data structure for fit of straight line paralel to z-axis.
Data structure for fit of straight line in positive z-direction.
JAxis3D & rotate_back(const JRotation3D &R)
Rotate back axis.
JPosition3D & rotate(const JRotation3D &R)
Rotate.
double getT(const JVector3D &pos) const
Get arrival time of Cherenkov light at given position.
double getY() const
Get y position.
double getZ() const
Get z position.
double getX() const
Get x position.
Utility class to parse command line options.
Auxiliary class for a hit with background rate value.
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
General purpose class for object reading from a list of file names.
General purpose class for parallel reading of objects from a single file or multiple files.
File router for fast addressing of summary data.
static const int JSTART_LENGTH_METRES
distance between first and last hits in metres from JStart.cc
JDirection3D getDirection(const Vec &dir)
Get direction.
JPosition3D getPosition(const Vec &pos)
Get position.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
JTOOLS::JRange< double > JZRange
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool qualitySorter(const JFit &first, const JFit &second)
Comparison of fit results.
bool putObject(TDirectory &dir, const TObject &object)
Write object to ROOT directory.
KM3NeT DAQ data structures and auxiliaries.
Dynamic detector calibration.
Auxiliary class to match data points with given model.
Auxiliary class for recursive type list generation.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Data structure for fit parameters.
double TMin_ns
minimal time w.r.t. Cherenkov hypothesis [ns]
double roadWidth_m
road width [m]
double TMax_ns
maximal time w.r.t. Cherenkov hypothesis [ns]
double ZMax_m
maximal z-positon [m]
double ZMin_m
minimal z-positon [m]
double R_Hz
default rate [Hz]
size_t numberOfPrefits
number of prefits
Wrapper class to make final fit of muon trajectory.
Auxiliary class for defining the range of iterations of objects.
const JLimit & getLimit() const
Get limit.
static counter_type max()
Get maximum counter value.
Auxiliary data structure for sorting of hits.