Process one event.
95 const std::vector<simb::MCParticle> &mc_particles = *ev.getValidHandle<std::vector<simb::MCParticle>>(
"largeant");
98 auto const &crt_hits_handle = ev.getValidHandle<std::vector<sbn::crt::CRTHit>>(
fCRTHitTag);;
99 const std::vector<sbn::crt::CRTHit> &crt_hits = *crt_hits_handle;
100 const std::vector<sim::AuxDetSimChannel> &crt_sim_channels = *ev.getValidHandle<std::vector<sim::AuxDetSimChannel>>(
"largeant");
101 art::FindManyP<icarus::crt::CRTData, void> hits_to_data(crt_hits_handle, ev,
fCRTHitTag);
105 std::map<int, std::vector<std::pair<std::pair<int, int>,
sim::AuxDetIDE>>> tracks_to_ides;
108 tracks_to_ides[ide.trackID].push_back({{simchannel.AuxDetID(), simchannel.AuxDetSensitiveID()}, ide});
113 for (
unsigned i = 0; i < crt_hits.size(); i++) {
115 std::vector<art::Ptr<icarus::crt::CRTData>> datas = hits_to_data.at(i);
116 assert(datas.size() == 1 || datas.size() == 2);
117 bool has_coincedence = datas.size() == 2;
121 int auxdetid_0 =
MacToAuxDetID(datas[0]->Mac5(), datas[0]->ChanTrig());
126 if (has_coincedence) {
127 int auxdetid_1 =
MacToAuxDetID(datas[1]->Mac5(), datas[1]->ChanTrig());
132 double hit_time = (int)hit.
ts0_ns;
137 double true_time_sum = 0.;
138 unsigned n_true_time = 0;
140 bool has_muon =
false;
141 bool has_proton =
false;
142 bool has_neutron =
false;
143 for (
unsigned j = 0; j < datas.size(); j++) {
145 if (
_verbose)
std::cout <<
"CRT Data at: " << data.TTrig() <<
" Mac5: " << data.Mac5() <<
" chan: " << data.ChanTrig() << std::endl;
146 const std::vector<icarus::crt::CRTChannelData> &channel_datas = data.ChanData();
149 for (
const icarus::crt::CRTChannelData &chan: channel_datas) {
150 const std::vector<int> track_ids = chan.TrackID();
151 if (
_verbose)
std::cout <<
"Channel Data at: " << chan.T0() <<
" chan: " << chan.Channel() << std::endl;
152 for (
int track_id: track_ids) {
153 int pdg_match =
abs(
GetPDG(mc_particles, track_id));
154 if (
abs(pdg_match) == 13) has_muon =
true;
155 else if (
abs(pdg_match) == 2212) has_proton =
true;
156 else if (
abs(pdg_match) == 2112) has_neutron =
true;
158 for (
const auto &ide_pair: tracks_to_ides.at(track_id)) {
160 std::pair<int, int> channel = ide_pair.first;
161 double true_time = ide.
entryT - 1.1e6;
162 if (
_verbose)
std::cout <<
"True Hit at: " << true_time <<
" X: " << ide.
entryX <<
" Y: " << ide.
entryY <<
" Z: " << ide.
entryZ <<
" Chan: " << channel.first <<
" " << channel.second << std::endl;
163 std::array<int, 3> crt_channel =
GetCRTChannel(channel.first, channel.second);
164 if (
_verbose)
std::cout <<
"Mapped FEB: " << crt_channel[0] <<
"Mapped channel: " << crt_channel[1] <<
" " << crt_channel[2] << std::endl;
166 if (data.Mac5() == crt_channel[0] && (data.ChanTrig() == crt_channel[1] || data.ChanTrig() == crt_channel[2])) {
167 true_time_sum += true_time;
176 std::cout <<
"Hit time: " << hit_time <<
" avg true time: " << (true_time_sum/n_true_time) << std::endl;
179 if (auxDetType ==
'm')
_true_v_hit_time_m->Fill((true_time_sum/n_true_time) - hit_time);
180 else if (auxDetType ==
'd')
_true_v_hit_time_d->Fill((true_time_sum/n_true_time) - hit_time);
181 else if (auxDetType ==
'c')
_true_v_hit_time_c->Fill((true_time_sum/n_true_time) - hit_time);
184 double pes = (hit.
peshit - 2*63.6) / (70.*2);
193 auto const &crt_hits_handle = ev.getValidHandle<std::vector<sbn::crt::CRTHit>>(
fCRTHitTag);;
194 const std::vector<sbn::crt::CRTHit> &crt_hits = *crt_hits_handle;
195 const std::vector<sim::AuxDetSimChannel> &crt_sim_channels = *ev.getValidHandle<std::vector<sim::AuxDetSimChannel>>(
"largeant");
196 art::FindManyP<sbnd::crt::CRTData, void> hits_to_data(crt_hits_handle, ev,
fCRTHitTag);
197 auto const &crt_data_handle = ev.getValidHandle<std::vector<sbnd::crt::CRTData>>(
"crt");
198 for (
unsigned i = 0; i < crt_hits.size(); i++) {
201 std::vector<art::Ptr<sbnd::crt::CRTData>> datas = hits_to_data.at(i);
202 art::FindManyP<sim::AuxDetIDE, void> sims(datas, ev,
"crt");
203 bool has_muon =
false;
204 bool has_proton =
false;
205 bool has_neutron =
false;
206 for (
unsigned j = 0; j < datas.size(); j++) {
207 for (
unsigned k = 0;
k < sims.at(j).size();
k++) {
208 track_id = sims.at(j).at(
k)->trackID;
209 int pdg_match =
GetPDG(mc_particles, track_id);
210 if (
abs(pdg_match) == 13) has_muon =
true;
211 else if (
abs(pdg_match) == 2212) has_proton =
true;
212 else if (
abs(pdg_match) == 2112) has_neutron =
true;
TH1D * _true_v_hit_time_coince
then if[["$THISISATEST"==1]]
char GetAuxDetType(geo::AuxDetGeo const &adgeo)
double ts1_ns
Timestamp T1 ([signal time w.r.t. Trigger time]), in UTC absolute time scale in nanoseconds from the ...
AuxDetGeo const & AuxDet(unsigned int const ad=0) const
Returns the specified auxiliary detector.
TH1D * _true_v_hit_time_c
float peshit
Total photo-electron (PE) in a crt hit.
const geo::AuxDetGeometryCore * GetAuxDetGeometryProvider() const
double ts0_ns_corr
[Honestly, not sure at this point, it was there since long time (BB)]
TH1D * _true_v_hit_time_d
Collection of particles crossing one auxiliary detector cell.
double ts0_ns
Timestamp T0 (from White Rabbit), in UTC absolute time scale in nanoseconds from the Epoch...
float entryT
Entry time of particle.
TH1D * _true_v_hit_time_m
Single hit (self trigger) of a CRT board.
float entryZ
Entry position Z of particle.
std::array< int, 3 > GetCRTChannel(int aux_det_id, int aux_det_sens_id)
float entryX
Entry position X of particle.
float entryY
Entry position Y of particle.
MC truth information to make RawDigits and do back tracking.
ProviderManager * fProviderManager
Interface for provider access.
int MacToAuxDetID(int mac, int chan)
int GetPDG(const std::vector< simb::MCParticle > &mc_particles, int trackID)
BEGIN_PROLOG could also be cout