14 #include "art_root_io/TFileService.h" 16 #include "cetlib/pow.h" 34 #include "TProfile2D.h" 107 const double X0 = 14;
131 cet::search_path sp(
"FW_SEARCH_PATH");
134 <<
"cannot find the root template file: \n" 159 "tranProfile_1",
"transverse shower profile [0 <= t < 1];dist (cm);Q",
TBINS,
TMIN,
TMAX);
161 "tranProfile_2",
"transverse shower profile [1 <= t < 2];dist (cm);Q",
TBINS,
TMIN,
TMAX);
163 "tranProfile_3",
"transverse shower profile [2 <= t < 3];dist (cm);Q",
TBINS,
TMIN,
TMAX);
165 "tranProfile_4",
"transverse shower profile [3 <= t < 4];dist (cm);Q",
TBINS,
TMIN,
TMAX);
167 "tranProfile_5",
"transverse shower profile [4 <= t < 5];dist (cm);Q",
TBINS,
TMIN,
TMAX);
177 energyDist = tfs->make<TH1F>(
"energyDist",
"true energy - guess energy", 41, -20.5, 20.5);
178 longLikelihoodHist = tfs->make<TH1F>(
"longLikelihoodHist",
"longitudinal likelihood", 20, 0, 2);
179 tranLikelihoodHist = tfs->make<TH1F>(
"tranLikelihoodHist",
"transverse likelihood", 20, 0, 3);
183 tfs->make<TH1F>(
"longProfHist",
"longitudinal e- profile (reco);t;Q",
LBINS,
LMIN,
LMAX);
185 "tranProfHist",
"transverse e- profile (reco) [0 <= t < 1];dist (cm);Q",
TBINS,
TMIN,
TMAX);
187 "tranProfHist",
"transverse e- profile (reco) [1 <= t < 2];dist (cm);Q",
TBINS,
TMIN,
TMAX);
189 "tranProfHist",
"transverse e- profile (reco) [2 <= t < 3];dist (cm);Q",
TBINS,
TMIN,
TMAX);
191 "tranProfHist",
"transverse e- profile (reco) [3 <= t < 4];dist (cm);Q",
TBINS,
TMIN,
TMAX);
193 "tranProfHist",
"transverse e- profile (reco) [4 <= t < 5];dist (cm);Q",
TBINS,
TMIN,
TMAX);
204 std::vector<art::Ptr<recob::Hit>> hitlist;
208 std::vector<art::Ptr<recob::Shower>> showerlist;
213 std::vector<art::Ptr<simb::MCTruth>> mclist;
219 if (showerlist.size()) {
220 auto const clock_data =
222 auto const det_prop =
224 std::vector<art::Ptr<recob::Hit>> showerhits = shwfm.at(0);
226 clock_data, det_prop, showerhits, showerlist[0]->ShowerStart(), showerlist[0]->
Direction());
228 maxt = std::ceil((90 - showerlist[0]->ShowerStart().
Z()) /
X0);
286 auto const& collectionPlane = wireReadoutGeom.Plane(collectionPlaneID);
289 auto const shwvtx_p =
toPoint(shwvtx);
290 auto const shwvtx_p2 = shwvtx_p +
toVector(shwdir);
292 double shwVtxTime = detProp.
ConvertXToTicks(shwvtx_p.X(), collectionPlaneID);
293 double shwVtxWire = collectionPlane.WireCoordinate(shwvtx_p);
295 double shwTwoTime = detProp.
ConvertXToTicks(shwvtx_p2.X(), collectionPlaneID);
296 double shwTwoWire = collectionPlane.WireCoordinate(shwvtx_p2);
298 for (
size_t i = 0; i < showerhits.size(); ++i) {
299 if (showerhits[i]->
WireID().Plane != collectionPlaneID.Plane)
continue;
301 double wirePitch = wireReadoutGeom.Plane(showerhits[i]->
WireID()).WirePitch();
305 double xvtx = shwVtxTime * tickToDist;
306 double yvtx = shwVtxWire * wirePitch;
308 double xtwo = shwTwoTime * tickToDist;
309 double ytwo = shwTwoWire * wirePitch;
311 double xtwoorth = (ytwo - yvtx) + xvtx;
312 double ytwoorth = -(xtwo - xvtx) + yvtx;
314 double xhit = showerhits[i]->PeakTime() * tickToDist;
315 double yhit = showerhits[i]->WireID().Wire * wirePitch;
317 double ldist =
std::abs((ytwoorth - yvtx) * xhit - (xtwoorth - xvtx) * yhit + xtwoorth * yvtx -
319 std::hypot(ytwoorth - yvtx, xtwoorth - xvtx);
320 double tdist = ((ytwo - yvtx) * xhit - (xtwo - xvtx) * yhit + xtwo * yvtx - ytwo * xvtx) /
321 std::hypot(ytwo - yvtx, xtwo - xvtx);
323 double to3D = 1. / std::hypot(xvtx - xtwo,
327 double t = ldist /
X0;
329 double Q = showerhits[i]->Integral() *
359 <<
"Bin mismatch in longitudinal profile template \n";
363 <<
"Bin mismatch in transverse profile template \n";
365 double chi2min = 999999;
372 for (
int i = 0; i < ebins; ++i) {
385 for (
int j = 0; j < lbins; ++j) {
387 double exp = ltemp->GetBinContent(j + 1);
389 thischi2 += cet::square(obs - exp) / exp;
394 for (
int j = 0; j < tbins; ++j) {
396 double exp = ttemp_1->GetBinContent(j + 1);
398 thischi2 += cet::square(obs - exp) / exp;
403 exp = ttemp_2->GetBinContent(j + 1);
405 thischi2 += cet::square(obs - exp) / exp;
410 exp = ttemp_3->GetBinContent(j + 1);
412 thischi2 += cet::square(obs - exp) / exp;
417 exp = ttemp_4->GetBinContent(j + 1);
419 thischi2 += cet::square(obs - exp) / exp;
424 exp = ttemp_5->GetBinContent(j + 1);
426 thischi2 += cet::square(obs - exp) / exp;
431 thischi2 /= (nlbins + ntbins);
433 if (thischi2 < chi2min) {
451 double longLikelihood = 0.;
454 for (
int i = 0; i <
LBINS; ++i) {
457 int binentries =
longTemplate->GetBinContent(i + 1, energyBin, qbin);
458 int totentries =
longTemplate->Integral(i + 1, i + 1, energyBin, energyBin, 0, 100);
461 double prob = (double)binentries / totentries * 100;
462 if (binentries > 0) longLikelihood += log(prob);
466 longLikelihood /= nbins;
468 std::cout << longLikelihood << std::endl;
469 return longLikelihood;
479 double tranLikelihood_1 = 0;
480 double tranLikelihood_2 = 0;
481 double tranLikelihood_3 = 0;
482 double tranLikelihood_4 = 0;
483 double tranLikelihood_5 = 0;
486 int qbin, binentries, totentries;
490 for (
int i = 0; i <
TBINS; ++i) {
493 binentries =
tranTemplate_1->GetBinContent(i + 1, energyBin, qbin);
494 totentries =
tranTemplate_1->Integral(i + 1, i + 1, energyBin, energyBin, 0, 100);
497 double prob = (double)binentries / totentries * 100;
498 if (binentries > 0) tranLikelihood_1 += log(prob);
503 binentries =
tranTemplate_2->GetBinContent(i + 1, energyBin, qbin);
504 totentries =
tranTemplate_2->Integral(i + 1, i + 1, energyBin, energyBin, 0, 100);
507 double prob = (double)binentries / totentries * 100;
508 if (binentries > 0) tranLikelihood_2 += log(prob);
513 binentries =
tranTemplate_3->GetBinContent(i + 1, energyBin, qbin);
514 totentries =
tranTemplate_3->Integral(i + 1, i + 1, energyBin, energyBin, 0, 100);
517 double prob = (double)binentries / totentries * 100;
518 if (binentries > 0) tranLikelihood_3 += log(prob);
523 binentries =
tranTemplate_4->GetBinContent(i + 1, energyBin, qbin);
524 totentries =
tranTemplate_4->Integral(i + 1, i + 1, energyBin, energyBin, 0, 100);
527 double prob = (double)binentries / totentries * 100;
528 if (binentries > 0) tranLikelihood_4 += log(prob);
533 binentries =
tranTemplate_5->GetBinContent(i + 1, energyBin, qbin);
534 totentries =
tranTemplate_5->Integral(i + 1, i + 1, energyBin, energyBin, 0, 100);
537 double prob = (double)binentries / totentries * 100;
538 if (binentries > 0) tranLikelihood_5 += log(prob);
543 double const tranLikelihood =
544 (tranLikelihood_1 + tranLikelihood_2 + tranLikelihood_3 + tranLikelihood_4 + tranLikelihood_5) /
546 std::cout << tranLikelihood << std::endl;
547 return tranLikelihood;
double E(const int i=0) const
std::string fDigitModuleLabel
const simb::MCNeutrino & GetNeutrino() const
TProfile2D * tranTemplateProf2D_5
TProfile2D * tranTemplateProf2D_4
void getShowerProfile(detinfo::DetectorClocksData const &clockdata, detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit >> showerhits, TVector3 shwvtx, TVector3 shwdir)
Declaration of signal hit object.
const simb::MCParticle & Nu() const
double Temperature() const
In kelvin.
TProfile2D * tranTemplateProf2D_3
constexpr auto abs(T v)
Returns the absolute value of the argument.
std::string fShowerModuleLabel
TH1F * tranLikelihoodHist
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
TProfile2D * tranTemplateProf2D
EDAnalyzer(fhicl::ParameterSet const &pset)
calo::CalorimetryAlg fCalorimetryAlg
TProfile2D * longTemplateProf2D
TCShowerElectronLikelihood(fhicl::ParameterSet const &pset)
double Efield(unsigned int planegap=0) const
kV/cm
IDparameter< geo::PlaneID > PlaneID
Member type of validated geo::PlaneID parameter.
std::string fTemplateModuleLabel
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::string fHitModuleLabel
Utilities to manipulate geometry vectors.The utilities include generic vector interface facilities al...
const simb::MCParticle & Lepton() const
#define DEFINE_ART_MODULE(klass)
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
T get(std::string const &key) const
double getTranLikelihood()
TProfile2D * tranTemplateProf2D_2
TProfile2D * tranTemplateProf2D_1
double ConvertXToTicks(double X, int p, int t, int c) const
Point_t toPoint(Point const &p)
Convert the specified point into a geo::Point_t.
double DriftVelocity(double efield=0., double temperature=0.) const
cm/us
Vector_t toVector(Vector const &v)
Convert the specified vector into a geo::Vector_t.
double getLongLikelihood()
std::string fGenieGenModuleLabel
std::string fTemplateFile
decltype(auto) get(T &&obj)
ADL-aware version of std::to_string.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Encapsulate the construction of a single detector plane .
Contains all timing reference information for the detector.
TH1F * longLikelihoodHist
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
void analyze(const art::Event &evt) override
double LifetimeCorrection(detinfo::DetectorClocksData const &clock_data, detinfo::DetectorPropertiesData const &det_prop, double time, double T0=0) const
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
cet::coded_exception< error, detail::translate > exception