15 #ifndef FlashClusterMatch_h 16 #define FlashClusterMatch_h 1 44 std::vector<double> GetLightHypothesis(std::vector<recob::SpacePoint> spts);
45 bool CheckCompatibility(std::vector<double>& hypothesis, std::vector<double>& signal);
118 produces< std::vector<anab::CosmicTag> >();
119 produces< art::Assns<recob::Cluster, anab::CosmicTag> >();
121 this->reconfigure(pset);
129 fClusterModuleLabel = pset.
get<std::string>(
"ClusterModuleLabel");
130 fFlashModuleLabel = pset.
get<std::string>(
"FlashModuleLabel");
131 fMinSptsForOverlap = pset.
get<
int>(
"MinSptsForOverlap");
133 fSingleChannelCut = pset.
get<
int>(
"SingleChannelCut");
134 fIntegralCut = pset.
get<
int>(
"IntegralCut");
152 FlashClusterMatch::~FlashClusterMatch()
173 mf::LogWarning(
"RecoBaseDefaultCtor") <<
"using default Hit ctor - should only ever" 174 <<
" be done when getting hits out of an event" 175 <<
" not when trying to produce new hits to store" 178 std::cerr<<
" Warning : you have disabled the RecoBaseDefaultCtor message." ;
179 std::cerr<<
" Should only ever be done when trying to avoid messages when getting hits out of an event, not when trying to produce new hits to store in the event."<< std::endl;
186 std::unique_ptr< std::vector<anab::CosmicTag> > cosmic_tags (
new std::vector<anab::CosmicTag>);
195 std::vector<art::Ptr<recob::OpFlash> > Flashes;
196 for(
unsigned int i=0; i < flashh->size(); ++i)
199 Flashes.push_back(flash);
204 evt.
getByLabel(fClusterModuleLabel, clusterh);
205 std::vector<art::Ptr<recob::Cluster> > Clusters;
206 for(
unsigned int i=0; i < clusterh->size(); ++i)
209 Clusters.push_back(cluster);
217 std::vector<std::vector<double> > FlashShapes;
219 size_t NOpDets = geom->
NOpDets();
221 for(
size_t f=0;
f!=Flashes.size(); ++
f)
223 if(Flashes.at(
f)->OnBeamTime())
225 std::vector<double> ThisFlashShape(NOpDets,0);
226 for (
unsigned int c = 0; c < geom->
NOpChannels(); c++){
228 ThisFlashShape[o]+=Flashes.at(
f)->PE(c);
230 FlashShapes.push_back(ThisFlashShape);
236 std::vector<std::vector<int> > SortedByViews(3);
241 std::vector<int> MaxTime(Clusters.size(), 0);
242 std::vector<int> MinTime(Clusters.size(), 10000);
246 for(
size_t iClus=0; iClus!=Clusters.size(); ++iClus)
248 SortedByViews[Clusters.at(iClus)->View()].push_back(iClus);
249 for(
size_t iHit=0; iHit!=hits.at(iClus).size(); ++iHit)
251 double Time = hits.at(iClus).at(iHit)->PeakTime();
252 if(Time > MaxTime[iClus]) MaxTime[iClus] = Time;
253 if(Time < MinTime[iClus]) MinTime[iClus] = Time;
263 std::vector<std::vector<double> > hypotheses;
266 for(
size_t nU=0; nU!=SortedByViews[0].size(); ++nU)
267 for(
size_t nV=0; nV!=SortedByViews[1].size(); ++nV)
268 for(
size_t nW=0; nW!=SortedByViews[2].size(); ++nW)
270 int indexU = SortedByViews[0][nU];
271 int indexV = SortedByViews[1][nV];
272 int indexW = SortedByViews[2][nW];
277 for(
size_t v=0; v!=3; ++v)
282 if(MinTime[v] >
std::min(MaxTime[v1],MaxTime[v2]))
285 if(MaxTime[v] <
std::max(MinTime[v1],MinTime[v2]))
289 if(NoOverlap)
continue;
294 FlatHits.
insert(FlatHits.
begin(), hits.at(indexU).begin(), hits.at(indexU).end());
295 FlatHits.
insert(FlatHits.
begin(), hits.at(indexV).begin(), hits.at(indexV).end());
296 FlatHits.
insert(FlatHits.
begin(), hits.at(indexW).begin(), hits.at(indexW).end());
299 std::vector<recob::SpacePoint> spts;
300 fSptalg->makeSpacePoints(FlatHits, spts);
302 if(
int(spts.size()) < fMinSptsForOverlap)
continue;
305 std::vector<double> hypothesis = GetLightHypothesis(spts);
307 bool IsCompatible =
false;
310 for(
size_t jFlash=0; jFlash!=FlashShapes.size(); ++jFlash)
313 if(CheckCompatibility(hypothesis,FlashShapes.at(jFlash)))
323 util::CreateAssn(*
this, evt, *(cosmic_tags.get()), Clusters.at(indexU), *(assn_tag.get()), cosmic_tags->size()-1);
324 util::CreateAssn(*
this, evt, *(cosmic_tags.get()), Clusters.at(indexV), *(assn_tag.get()), cosmic_tags->size()-1);
325 util::CreateAssn(*
this, evt, *(cosmic_tags.get()), Clusters.at(indexW), *(assn_tag.get()), cosmic_tags->size()-1);
333 evt.
put(std::move(cosmic_tags));
334 evt.
put(std::move(assn_tag));
343 std::vector<double> FlashClusterMatch::GetLightHypothesis(std::vector<recob::SpacePoint> spts)
346 std::vector<double> ReturnVector(geom->
NOpDets(),0);
351 for (
size_t s=0;
s!=spts.size();
s++)
356 double WirePitch = 0.3;
358 for(
size_t iHit=0; iHit!=assochits.
size(); ++iHit)
359 if(assochits.
at(iHit)->View()==2) Charge += WirePitch * fCaloAlg->dEdx_AMP(assochits.
at(iHit), 1);
364 for(
size_t i=0; i!=3; ++i) xyz[i] = spts.at(
s).XYZ()[i];
366 const float* PointVisibility = pvs->GetAllVisibilities(xyz);
367 if (!PointVisibility)
continue;
368 for(
size_t OpDet =0; OpDet!=pvs->NOpChannels(); OpDet++)
370 ReturnVector.at(OpDet)+= PointVisibility[OpDet];
373 double PhotonYield = 24000;
376 for(
size_t i=0; i!=ReturnVector.size(); ++i)
378 ReturnVector[i] *= QE * PhotonYield;
386 bool FlashClusterMatch::CheckCompatibility(std::vector<double>& hypothesis, std::vector<double>& signal)
388 double sigintegral=0, hypintegral=0;
389 for(
size_t i=0; i!=hypothesis.size(); ++i)
391 sigintegral+=signal.at(i);
392 hypintegral+=hypothesis.at(i);
393 double HypErr = pow(hypothesis.at(i),0.5);
394 if(( (hypothesis.at(i) - signal.at(i)) / HypErr) > fSingleChannelCut)
return false;
396 double HypIntErr= pow(hypintegral,0.5);
398 if( ( (hypintegral - sigintegral)/HypIntErr) > fIntegralCut)
return false;
Reconstruction base classes.
Declaration of signal hit object.
Cluster finding and building.
std::string fFlashModuleLabel
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
std::string fClusterModuleLabel
ProductID put(std::unique_ptr< PROD > &&product)
#define DEFINE_ART_MODULE(klass)
T get(std::string const &key) const
bool CreateAssn(PRODUCER const &prod, art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t indx=UINT_MAX)
Creates a single one-to-one association.
reference at(size_type n)
Declaration of cluster object.
unsigned int NOpDets() const
Number of OpDets in the whole detector.
iterator insert(iterator position, Ptr< U > const &p)
Utility object to perform functions of association.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
calo::CalorimetryAlg * fCaloAlg
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
trkf::SpacePointAlg * fSptalg
Algorithm for generating space points from hits.
art framework interface to geometry description