26 #include "art_root_io/TFileDirectory.h" 27 #include "art_root_io/TFileService.h" 70 bool insideContVol(
const double posX,
const double posY,
const double posZ);
109 produces< std::vector<cnn::RegCNNResult> >(
fResultLabel);
135 for (
int ii = 0; ii < 3; ii++){
138 cm_list[2*ii] = mean_tdc;
139 cm_list[2*ii+1] = mean_wire;
150 std::unique_ptr< std::vector<RegCNNResult> >
151 resultCol(
new std::vector<RegCNNResult>);
154 std::vector< art::Ptr< cnn::RegPixelMap > > pixelmaplist;
156 auto pixelmapListHandle = evt.
getHandle< std::vector< cnn::RegPixelMap > >(itag1);
157 if (pixelmapListHandle){
162 std::vector< art::Ptr< cnn::RegPixelMap3D > > pixelmap3Dlist;
164 auto pixelmap3DListHandle = evt.
getHandle< std::vector< cnn::RegPixelMap3D > >(itag2);
165 if (pixelmap3DListHandle) {
172 if(pixelmaplist.size() > 0){
173 std::vector<float> networkOutput;
178 else if (
fTarget ==
"nuevertex"){
179 std::vector<float> center_of_mass(6,0);
180 getCM(*pixelmaplist[0], center_of_mass);
181 std::cout <<
"cm: " << center_of_mass[0] <<
" " << center_of_mass[1] <<
" " << center_of_mass[2] <<
std::endl;
183 std::cout <<
"cnn nuevertex : "<<networkOutput[0] <<
" " << networkOutput[1] <<
" " << networkOutput[2] <<
std::endl;
185 else if (
fTarget ==
"nuevertex_on_img"){
190 else if (
fTarget ==
"numuenergy") {
194 std::cout <<
"Wrong Target with 2D 3-view pixel maps" <<
std::endl;
199 resultCol->emplace_back(networkOutput);
202 mf::LogError(
"RegCNNEvaluator::produce") <<
"CNN Type not in the allowed list: Tensorflow, Torch" <<
std::endl;
215 std::vector<art::Ptr<recob::Track> > tracklist;
224 int ntracks = tracklist.size();
226 double fMaxTrackLength = -1.0;
227 int iLongestTrack = -1;
229 for (
int i = 0; i <
ntracks; ++i){
230 if(tracklist[i]->
Length() > fMaxTrackLength){
231 fMaxTrackLength = tracklist[i]->Length();
237 if (iLongestTrack >= 0 && iLongestTrack <= ntracks-1) {
238 if (fmth.isValid()) {
239 std::vector< art::Ptr<recob::Hit> > vhit = fmth.at(iLongestTrack);
240 for (
size_t h = 0;
h < vhit.size(); ++
h) {
241 if (vhit[
h]->
WireID().Plane == 2) {
242 std::vector< art::Ptr<recob::SpacePoint> > spts = fmhs.at(vhit[
h].
key());
244 if (!
insideContVol(spts[0]->XYZ()[0], spts[0]->XYZ()[1], spts[0]->XYZ()[2]))
254 double vtx[3] = {posX, posY, posZ};
261 double minx = tpcgeo.
MinX();
double maxx = tpcgeo.
MaxX();
262 double miny = tpcgeo.
MinY();
double maxy = tpcgeo.
MaxY();
263 double minz = tpcgeo.
MinZ();
double maxz = tpcgeo.
MaxZ();
267 for (
size_t t = 0;
t < cryostat.
NTPC();
t++) {
269 if (tpcg.
MinX() < minx) minx = tpcg.
MinX();
270 if (tpcg.
MaxX() > maxx) maxx = tpcg.
MaxX();
271 if (tpcg.
MinY() < miny) miny = tpcg.
MinY();
272 if (tpcg.
MaxY() > maxy) maxy = tpcg.
MaxY();
273 if (tpcg.
MinZ() < minz) minz = tpcg.
MinZ();
274 if (tpcg.
MaxZ() > maxz) maxz = tpcg.
MaxZ();
279 double dista = fabs(minx - posX);
280 double distb = fabs(posX - maxx);
281 if ((posX > minx) && (posX < maxx) &&
284 dista = fabs(maxy - posY);
285 distb = fabs(posY - miny);
286 if (inside && (posY > miny) && (posY < maxy) &&
290 dista = fabs(maxz - posZ);
291 distb = fabs(posZ - minz);
292 if (inside && (posZ > minz) && (posZ < maxz) &&
Wrapper for caffe::Net which handles construction and prediction.
float Length(const PFPStruct &pfp)
CryostatGeo const & GetElement(geo::CryostatID const &cryoid) const
int fFirstTDC[3]
Minimum TDC in each view, inclusive.
Handle< PROD > getHandle(SelectorBase const &) const
unsigned int fNTdc
Number of tdcs, width of pixel map.
RegCNNEvaluator(fhicl::ParameterSet const &pset)
RegPixelMap, basic input to CNN neural net.
EDProducer(fhicl::ParameterSet const &pset)
unsigned int fNWire
Number of wires, length of pixel map.
double MinX() const
Returns the world x coordinate of the start of the box.
Geometry information for a single TPC.
std::string fPixelMapInput
int fFirstWire[3]
Minimum wire, inclusive.
double MaxX() const
Returns the world x coordinate of the end of the box.
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Geometry information for a single cryostat.
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
RegCNNVtxHandler, basic output of CNN neural net.
art framework interface to geometry description
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
#define DEFINE_ART_MODULE(klass)
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
std::vector< float > Predict(const RegPixelMap &pm)
Return prediction arrays for RegPixelMap.
std::vector< float > Predict(const RegPixelMap &pm, bool fLongestTrackContained)
Return prediction arrays for RegPixelMap.
double MinZ() const
Returns the world z coordinate of the start of the box.
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
unsigned int NTPC() const
Number of TPCs in this cryostat.
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
std::string fTrackModuleLabel
The data type to uniquely identify a TPC.
cnn::RegCNNNumuHandler fRegCNNNumuHandler
Wrapper for caffe::Net which handles construction and prediction.
art::ServiceHandle< geo::Geometry > fGeom
RegCNNNumuHandler for numu energy estimation.
double MaxY() const
Returns the world y coordinate of the end of the box.
bool HasTPC(geo::TPCID const &tpcid) const
Returns whether we have the specified TPC.
Defines an enumeration for cellhit classification.
RegCNNResult for RegCNN modified from Result.h.
void produce(art::Event &evt)
Declaration of signal hit object.
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
TFRegNetHandler for RegCNN modified from TFNetHandler.h.
double MaxZ() const
Returns the world z coordinate of the end of the box.
Provides recob::Track data product.
cnn::RegCNNVtxHandler fRegCNNVtxHandler
bool fLongestTrackContained
auto const & get(AssnsNode< L, R, D > const &r)
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
RegPixelMap for RegCNN modified from PixelMap.h.
std::vector< float > GetVertex(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, art::Event &evt, const RegPixelMap &pixelmap)
bool insideContVol(const double posX, const double posY, const double posZ)
double MinY() const
Returns the world y coordinate of the start of the box.
void PrepareEvent(const art::Event &event)
std::string fHitsModuleLabel
QTextStream & endl(QTextStream &s)
Event finding and building.
void getCM(const RegPixelMap &pm, std::vector< float > &cm_list)
cnn::TFRegNetHandler fTFHandler