22 #ifndef BeamFlashCompatabilityCheck_h 23 #define BeamFlashCompatabilityCheck_h 1 51 std::vector<double> GetMIPHypotheses(
trkf::BezierTrack* BTrack,
double XOffset=0);
52 bool CheckCompatibility(std::vector<double>& hypothesis, std::vector<double>& signal);
129 #include "CLHEP/Random/RandFlat.h" 130 #include "CLHEP/Random/RandGaussQ.h" 142 produces< std::vector<anab::CosmicTag> >();
143 produces< art::Assns<recob::Track, anab::CosmicTag> >();
145 this->reconfigure(pset);
153 fTrackModuleLabel = pset.
get<std::string>(
"TrackModuleLabel");
154 fFlashModuleLabel = pset.
get<std::string>(
"FlashModuleLabel");
155 fBezierResolution = pset.
get<
int>(
"BezierResolution");
156 fSingleChannelCut = pset.
get<
int>(
"SingleChannelCut");
157 fIntegralCut = pset.
get<
int>(
"IntegralCut");
171 BeamFlashCompatabilityCheck::~BeamFlashCompatabilityCheck()
182 std::vector<double> BeamFlashCompatabilityCheck::GetMIPHypotheses(
trkf::BezierTrack* Btrack,
double XOffset)
185 std::vector<double> ReturnVector(geom->
NOpDets(),0);
192 for (
int b=0; b!=fBezierResolution; b++)
194 float s = float(b) / float(fBezierResolution);
196 double MIPYield = 24000;
198 double MIPdQdx = 2.1;
199 double PromptFrac = 0.25;
200 double PromptMIPScintYield = MIPYield * QE * MIPdQdx * PromptFrac;
205 const float* PointVisibility = pvs->GetAllVisibilities(xyz);
206 if (!PointVisibility)
continue;
208 float LightAmount = PromptMIPScintYield*TrackLength/float(fBezierResolution);
210 for(
size_t OpDet =0; OpDet!=pvs->NOpChannels(); OpDet++)
212 ReturnVector.at(OpDet)+= PointVisibility[OpDet] * LightAmount;
230 std::vector<art::Ptr<recob::OpFlash> > Flashes;
231 for(
unsigned int i=0; i < flashh->size(); ++i)
234 Flashes.push_back(flash);
240 std::vector<art::Ptr<recob::Track> > Tracks;
241 for(
unsigned int i=0; i < trackh->size(); ++i)
244 Tracks.push_back(track);
249 std::vector<trkf::BezierTrack*> BTracks;
251 for(
size_t i=0; i!=Tracks.size(); i++)
255 std::vector<std::vector<double> > TrackHypotheses;
256 std::vector<std::vector<double> > FlashShapes;
260 for (
size_t i=0; i!=BTracks.size(); ++i)
262 TrackHypotheses.push_back(GetMIPHypotheses(BTracks.at(i)));
266 size_t NOpDets = geom->
NOpDets();
269 std::vector<bool> Compatible(TrackHypotheses.size(),
false);
271 for(
size_t f=0;
f!=Flashes.size(); ++
f)
273 if(Flashes.at(
f)->OnBeamTime())
275 std::vector<double> ThisFlashShape(NOpDets,0);
276 for(
size_t i=0; i!=NOpDets; ++i)
277 ThisFlashShape[i] = 0;
278 for(
size_t i=0; i < NOpChannels; ++i) {
280 ThisFlashShape[opdet] += Flashes.at(
f)->PE(i);
282 FlashShapes.push_back(ThisFlashShape);
284 for(
size_t i=0; i!=TrackHypotheses.size(); ++i)
286 if(CheckCompatibility(TrackHypotheses.at(i),ThisFlashShape))
294 std::unique_ptr< std::vector<anab::CosmicTag> > CosmicTagPtr (
new std::vector<anab::CosmicTag>);
302 for(
size_t itrack=0; itrack<BTracks.size(); itrack++){
305 if(Compatible.at(itrack)) cosmic_score = 0;
306 else if(!Compatible.at(itrack)) cosmic_score = 1;
308 BTracks.at(itrack)->GetTrackPoint(0,xyz_begin);
309 std::vector<float> endPt1 = { (float)xyz_begin[0], (
float)xyz_begin[1], (float)xyz_begin[2] };
310 BTracks.at(itrack)->GetTrackPoint(1,xyz_end);
311 std::vector<float> endPt2 = { (float)xyz_end[0], (
float)xyz_end[1], (float)xyz_end[2] };
314 util::CreateAssn(*
this, evt, *(CosmicTagPtr.get()), Tracks.at(itrack), *(assn_track.get()), itrack);
319 evt.
put(std::move(CosmicTagPtr));
320 evt.
put(std::move(assn_track));
333 bool BeamFlashCompatabilityCheck::CheckCompatibility(std::vector<double>& hypothesis, std::vector<double>& signal)
335 double sigintegral=0, hypintegral=0;
336 for(
size_t i=0; i!=hypothesis.size(); ++i)
338 sigintegral+=signal.at(i);
339 hypintegral+=hypothesis.at(i);
340 double HypErr = pow(hypothesis.at(i),0.5);
341 if(( (hypothesis.at(i) - signal.at(i)) / HypErr) > fSingleChannelCut)
return false;
343 double HypIntErr= pow(hypintegral,0.5);
345 if( ( (hypintegral - sigintegral)/HypIntErr) > fIntegralCut)
return false;
Reconstruction base classes.
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
void GetTrackPoint(double s, double *xyz) const
unsigned int OpDetFromOpChannel(int opChannel) const
Convert unique channel to detector number.
ProductID put(std::unique_ptr< PROD > &&product)
bool BeamFlashCompatabilityCheck_tracksort(art::Ptr< recob::Track > t1, art::Ptr< recob::Track > t2)
#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.
unsigned int NOpDets() const
Number of OpDets in the whole detector.
Utility object to perform functions of association.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
std::vector< art::Ptr< anab::CosmicTag > > CosmicTagVector
std::string fTrackModuleLabel
art framework interface to geometry description
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
std::string fFlashModuleLabel