81 std::map<ToFCounter,std::vector<unsigned int>>
channels = {
129 std::vector<std::pair<unsigned int, std::string>>
fChannels;
136 std::map<ToFCounter,std::vector<TH2D*>>
hPosn;
166 fChannels = pset.
get<std::vector<std::pair<unsigned int, std::string>>>(
"Channels");
170 for (
auto ch : fChannels) {
channelMap[ch.first] = ch.second; }
189 dtDir.
make<TH1D>(Form(
"h_dt_ch%d_%d", channels[tofc][
i], channels[tofc][
j]),
190 Form(
"dt for channels %d and %d", channels[tofc][i], channels[tofc][j]),
196 hFirstHits[tofc] = tofDir.
make<TH1D>(
"first_hits",
"Number of times each channel is first in a cluster",4,0,4);
204 this->
hPosn[tofc].push_back(posnstuff.
make<TH2D>(Form(
"hPosnS%.3f",
d),
205 Form(
"Hit position with side length constant %.3f",
d),
212 this->
hPosnSpread[tofc].push_back(posnstuff.
make<TH1D>(Form(
"hPosnSpreadS%.3f", d),
213 Form(
"Position spread with side length constant %.3f", d),
222 this->
hPosn[tofc].push_back(tofDir.
make<TH2D>(
"hPosn",
"Position",
228 (
POSN_ZOOM_IN ? SCINT_SIDE_LENGTH : 2*SCINT_SIDE_LENGTH)));
229 this->
hPosnSpread[tofc].push_back(tofDir.
make<TH1D>(
"hPosnSpread",
"Position spread",
236 for(TH2D* posnHist :
hPosn[tofc]) {
237 posnHist->SetOption(
"colz");
255 std::vector<art::Ptr<brb::ToF>> tofs;
259 unsigned int nToFs = tofs.size();
262 std::vector<double> flightTimes;
263 for(
unsigned int i = 0;
i < nToFs;
i++) {
264 flightTimes.push_back(tofs[
i]->Time());
268 for(
unsigned int i = 0;
i < nToFs;
i++) {
269 hToF->Fill(flightTimes[
i]);
275 std::vector<art::Ptr<brb::BeamlineDigit>> tofDigits;
281 std::unordered_map<int,double> startTimeByChannel;
286 startTimeByChannel[ch] = -1;
290 for(
auto d : tofDigits){
297 if(startTimeByChannel[ch] <= 0) {
306 for(
auto tofc : activeToFCounters) {
308 for (
int i=0;
i<4;
i++) {
309 for (
int j=
i+1;
j<4;
j++) {
310 if(startTimeByChannel[
channels[tofc][
i]] > 0 && startTimeByChannel[
channels[tofc][
j]] > 0) {
321 bool fourHits =
true;
322 for(
int i=0;
i<4;
i++) {
323 fourHits = fourHits && (startTimeByChannel[
channels[tofc][
i]] > 0);
326 for(
int i=0;
i<4;
i++) {
327 firstBin = startTimeByChannel[
channels[tofc][
i]] < startTimeByChannel[
channels[tofc][firstBin]] ?
i : firstBin;
343 Form(
"run%d_subrun%d_event%d_posndump", e.
run(), e.
subRun(), e.
id().
event()),
344 startTimeByChannel[
channels[tofc][0]],
345 startTimeByChannel[
channels[tofc][1]],
346 startTimeByChannel[
channels[tofc][2]],
347 startTimeByChannel[
channels[tofc][3]],
356 startTimeByChannel[
channels[tofc][1]],
357 startTimeByChannel[
channels[tofc][2]],
358 startTimeByChannel[
channels[tofc][3]],
363 startTimeByChannel[
channels[tofc][1]],
364 startTimeByChannel[
channels[tofc][2]],
365 startTimeByChannel[
channels[tofc][3]],
378 double t1 = startTimeByChannel[
channels[tofc][0]];
379 double t2 = startTimeByChannel[channels[tofc][1]];
380 double t3 = startTimeByChannel[channels[tofc][2]];
381 double t4 = startTimeByChannel[channels[tofc][3]];
387 hPosn[tofc][0]->Fill(loc.
x,loc.
y);
395 std::cout << Form(
"High spread for run %d subrun %d event %d with hits at %.2f,%.2f,%.2f,%.2f and reco posn %.2f,%.2f: %.2f\n", e.
run(), e.
subRun(), e.
id().
event(),
t1,
t2, t3, t4, loc.
x, loc.
y, spread);
421 posnRecoDumpDir.
make<TH2D>(*eventHist);
427 std::ofstream dtInfo;
428 dtInfo.open(
"dtInfo.txt");
431 for (
int i=0;
i<4;
i++) {
432 for (
int j=
i+1;
j<4;
j++) {
439 dtInfo << Form(
"| %2d | %2d | %7.4f | %6.4f |\n",
channels[tofc][
i],
channels[tofc][
j], mean, rms);
445 for(
auto tofc : activeToFCounters) {
451 << Form(
"for side = %.3f\n",
s);
453 << Form(
"for side = %.3f\n",
s);
468 for(
int i = 0;
i < 4;
i++) {
SubRunNumber_t subRun() const
std::map< ToFCounter, double > tofCounterDelays
TH2D GetSummaryHist(TString name, TString title, double tA, double tB, double tC, double tD, double s)
std::map< ToFCounter, std::vector< TH2D * > > hPosn
art::ServiceHandle< beamlineutil::BeamlineChannelMap > fChannelMap
art::InputTag fToFDigitLabel
std::map< ToFCounter, std::vector< TH2D * > > hPosnRecoDump
std::map< ToFCounter, TString > tofCounterStrings
art::InputTag fRecoToFLabel
TFileDirectory mkdir(std::string const &dir, std::string const &descr="")
std::map< ToFCounter, std::vector< int > > nPhysicalPosns
DEFINE_ART_MODULE(TestTMapFile)
unsigned int OnlineDigitChannel(ChannelID channel) const
Online digiziter channel number for this offline ChannelID.
std::vector< unsigned int > requiredChannels
std::map< ToFCounter, std::vector< unsigned int > > channels
double Get4CornerSpread(double tA, double tB, double tC, double tD, double s)
Encapsulation of reconstructed digitizer 'hits'. Used for ToF PMTs and SiPMs, and Cherenkov and Muon ...
void analyze(const art::Event &evt)
std::vector< std::pair< unsigned int, std::string > > fChannels
T get(std::string const &key) const
Encapsulation of reconstructed Time-of-Flight (ToF) information. Part of beamline reconstruction for ...
bool IsPhysical(posn_t p, double s)
Encapsulation of reconstructed Wire Chamber track. Part of beamline reconstruction for NOvA test beam...
std::map< ToFCounter, int > nFourHitEvents
EDAnalyzer(Table< Config > const &config)
std::map< int, std::map< int, TH1D * > > hdtByChannel
posn_t Get4CornerPosition(double tA, double tB, double tC, double tD, double s)
EventNumber_t event() const
T * make(ARGS...args) const
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
std::map< ToFCounter, int > nEvents
std::map< ToFCounter, int > nHighSpreadPosns
art::ServiceHandle< art::TFileService > tfs
ToFPositionFinder * posnfinder
Raw data definitions for beamline data used in NOvA test beam experiment.
std::map< ToFCounter, std::vector< int > > nNonphysicalPosns
ToFPositionRecoAnalysis(const fhicl::ParameterSet &pset)
void reconfigure(const fhicl::ParameterSet &pset)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Encapsulation of reconstructed PID information from detectors in the beamline (ToF, WCs, Cherenkov). Part of beamline reconstruction for NOvA test beam.
std::vector< ToFCounter > activeToFCounters
Channel mapping service which may be used to interpret the channels which are read out by the various...
std::unordered_map< unsigned int, std::string > channelMap
Encapsulation of reconstructed track in the muon stack downstream of test beam detector. Part of beamline reconstruction for NOvA test beam.
std::map< ToFCounter, std::vector< TH1D * > > hPosnSpread
std::map< ToFCounter, TH1D * > hFirstHits