44 #include "TProfile2D.h" 139 const double X0 = 14;
173 cet::search_path sp(
"FW_SEARCH_PATH");
175 throw cet::exception(
"TCShowerElectronLikelihood") <<
"cannot find the root template file: \n" 177 <<
"\n bail ungracefully.\n";
181 longTemplate = (TH3F*)file->Get(
"tcshowertemplate/fLongitudinal");
182 tranTemplate = (TH3F*)file->Get(
"tcshowertemplate/fTransverse");
183 tranTemplate_1 = (TH3F*)file->Get(
"tcshowertemplate/fTransverse_1");
184 tranTemplate_2 = (TH3F*)file->Get(
"tcshowertemplate/fTransverse_2");
185 tranTemplate_3 = (TH3F*)file->Get(
"tcshowertemplate/fTransverse_3");
186 tranTemplate_4 = (TH3F*)file->Get(
"tcshowertemplate/fTransverse_4");
187 tranTemplate_5 = (TH3F*)file->Get(
"tcshowertemplate/fTransverse_5");
189 longTemplateProf2D = (TProfile2D*)file->Get(
"tcshowertemplate/fShowerProfileRecoLong2D");
190 tranTemplateProf2D = (TProfile2D*)file->Get(
"tcshowertemplate/fShowerProfileRecoTrans2D");
215 energyDist = tfs->
make<TH1F>(
"energyDist",
"true energy - guess energy", 41, -20.5, 20.5);
236 std::vector<art::Ptr<recob::Hit> > hitlist;
241 std::vector<art::Ptr<recob::Shower> > showerlist;
246 std::vector<art::Ptr<simb::MCTruth> > mclist;
252 if (showerlist.size()) {
253 std::vector< art::Ptr<recob::Hit> > showerhits = shwfm.at(0);
256 maxt = std::ceil((90 - showerlist[0]->ShowerStart().
Z())/
X0);
322 auto const* detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
327 double shwVtxTime = detprop->ConvertXToTicks(shwvtx[0], collectionPlane);
328 double shwVtxWire = geom->WireCoordinate(shwvtx[1], shwvtx[2], collectionPlane);
330 double shwTwoTime = detprop->ConvertXToTicks(shwvtx[0]+shwdir[0], collectionPlane);
331 double shwTwoWire = geom->WireCoordinate(shwvtx[1]+shwdir[1], shwvtx[2]+shwdir[2], collectionPlane);
333 for (
size_t i = 0; i < showerhits.size(); ++i) {
334 if (showerhits[i]->WireID().Plane != collectionPlane.Plane)
continue;
336 double wirePitch = geom->WirePitch(showerhits[i]->WireID());
337 double tickToDist = detprop->DriftVelocity(detprop->Efield(),detprop->Temperature());
338 tickToDist *= 1.e-3 * detprop->SamplingRate();
340 double xvtx = shwVtxTime * tickToDist;
341 double yvtx = shwVtxWire * wirePitch;
343 double xtwo = shwTwoTime * tickToDist;
344 double ytwo = shwTwoWire * wirePitch;
346 double xtwoorth = (ytwo - yvtx) + xvtx;
347 double ytwoorth = -(xtwo - xvtx) + yvtx;
349 double xhit = showerhits[i]->PeakTime() * tickToDist;
350 double yhit = showerhits[i]->WireID().Wire * wirePitch;
352 double ldist = std::abs((ytwoorth-yvtx)*xhit - (xtwoorth-xvtx)*yhit + xtwoorth*yvtx - ytwoorth*xvtx)/std::sqrt( pow((ytwoorth-yvtx), 2) + pow((xtwoorth-xvtx), 2) );
353 double tdist = ((ytwo-yvtx)*xhit - (xtwo-xvtx)*yhit + xtwo*yvtx - ytwo*xvtx)/std::sqrt( pow((ytwo-yvtx), 2) + pow((xtwo-xvtx), 2) );
355 double to3D = 1. / sqrt( pow(xvtx-xtwo,2) + pow(yvtx-ytwo,2) ) ;
382 throw cet::exception(
"TCShowerElectronLikelihood") <<
"Bin mismatch in longitudinal profile template \n";
385 throw cet::exception(
"TCShowerElectronLikelihood") <<
"Bin mismatch in transverse profile template \n";
387 double chi2min = 999999;
403 for (
int i = 0; i < ebins; ++i) {
416 for (
int j = 0; j < lbins; ++j) {
418 double exp = ltemp->GetBinContent(j+1);
420 thischi2 += pow(obs - exp, 2) / exp;
425 for (
int j = 0; j < tbins; ++j) {
427 double exp = ttemp_1->GetBinContent(j+1);
429 thischi2 += pow(obs - exp, 2) / exp;
434 exp = ttemp_2->GetBinContent(j+1);
436 thischi2 += pow(obs - exp, 2) / exp;
441 exp = ttemp_3->GetBinContent(j+1);
443 thischi2 += pow(obs - exp, 2) / exp;
448 exp = ttemp_4->GetBinContent(j+1);
450 thischi2 += pow(obs - exp, 2) / exp;
455 exp = ttemp_5->GetBinContent(j+1);
457 thischi2 += pow(obs - exp, 2) / exp;
462 thischi2 /= (nlbins+ntbins);
464 if (thischi2 < chi2min) {
488 for (
int i = 0; i <
LBINS; ++i) {
491 int binentries =
longTemplate->GetBinContent(i+1, energyBin, qbin);
492 int totentries =
longTemplate->Integral(i+1, i+1, energyBin, energyBin, 0, 100);
495 double prob = (double)binentries/totentries * 100;
522 int qbin, binentries, totentries;
526 for (
int i = 0; i <
TBINS; ++i) {
530 totentries =
tranTemplate_1->Integral(i+1, i+1, energyBin, energyBin, 0, 100);
533 double prob = (double)binentries/totentries * 100;
540 totentries =
tranTemplate_2->Integral(i+1, i+1, energyBin, energyBin, 0, 100);
543 double prob = (double)binentries/totentries * 100;
550 totentries =
tranTemplate_3->Integral(i+1, i+1, energyBin, energyBin, 0, 100);
553 double prob = (double)binentries/totentries * 100;
560 totentries =
tranTemplate_4->Integral(i+1, i+1, energyBin, energyBin, 0, 100);
563 double prob = (double)binentries/totentries * 100;
570 totentries =
tranTemplate_5->Integral(i+1, i+1, energyBin, energyBin, 0, 100);
573 double prob = (double)binentries/totentries * 100;
double E(const int i=0) const
std::string fDigitModuleLabel
const simb::MCNeutrino & GetNeutrino() const
TProfile2D * tranTemplateProf2D_5
TProfile2D * tranTemplateProf2D_4
Declaration of signal hit object.
const simb::MCParticle & Nu() const
The data type to uniquely identify a Plane.
TProfile2D * tranTemplateProf2D_3
std::string fShowerModuleLabel
TH1F * tranLikelihoodHist
TProfile2D * tranTemplateProf2D
calo::CalorimetryAlg fCalorimetryAlg
void getShowerProfile(std::vector< art::Ptr< recob::Hit > > showerhits, TVector3 shwvtx, TVector3 shwdir)
TProfile2D * longTemplateProf2D
object containing MC flux information
TCShowerElectronLikelihood(fhicl::ParameterSet const &pset)
std::string fTemplateModuleLabel
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::string fHitModuleLabel
const simb::MCParticle & Lepton() const
#define DEFINE_ART_MODULE(klass)
Provides recob::Track data product.
T get(std::string const &key) const
TProfile2D * tranTemplateProf2D_2
TProfile2D * tranTemplateProf2D_1
void analyze(const art::Event &evt)
EDAnalyzer(Table< Config > const &config)
Declaration of cluster object.
std::string fGenieGenModuleLabel
std::string fTemplateFile
T * make(ARGS...args) const
Utility object to perform functions of association.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
TH1F * longLikelihoodHist
object containing MC truth information necessary for making RawDigits and doing back tracking ...
void reconfigure(fhicl::ParameterSet const &pset)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
double LifetimeCorrection(double time, double T0=0) const
virtual ~TCShowerElectronLikelihood()
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception