5 #include "art/Framework/Services/Registry/ServiceHandle.h"
6 #include "art/Framework/Principal/Event.h"
9 #include "canvas/Persistency/Common/FindManyP.h"
10 #include "canvas/Persistency/Common/FindMany.h"
11 #include "canvas/Persistency/Common/FindOneP.h"
12 #include "canvas/Persistency/Common/FindOne.h"
14 #include "messagefacility/MessageLogger/MessageLogger.h"
18 #include "TGraphDelaunay.h"
21 namespace single_photon
25 int spacecharge_correction(
const art::Ptr<simb::MCParticle> & mcparticle, std::vector<double> & corrected, std::vector<double> & input){
43 corrected[1]=ky+yOffset;
44 corrected[2]=kz+zOffset;
55 double kx = mcparticle->Vx();
56 double ky = mcparticle->Vy();
57 double kz = mcparticle->Vz();
69 corrected[1]=ky+yOffset;
70 corrected[2]=kz+zOffset;
82 double kx = mcparticle.Vx();
83 double ky = mcparticle.Vy();
84 double kz = mcparticle.Vz();
97 const art::Event &
evt,
98 const std::string &label,
99 std::map< art::Ptr<simb::MCTruth>,
std::vector<art::Ptr<simb::MCParticle>>> &truthToParticles,
100 std::map< art::Ptr<simb::MCParticle>, art::Ptr<simb::MCTruth>> &particlesToTruth,
101 std::map<
int, art::Ptr<simb::MCParticle> > & MCParticleToTrackIdMap,
107 art::Handle< std::vector< simb::MCParticle> > theParticles;
108 evt.getByLabel(label, theParticles);
110 if (!theParticles.isValid())
112 mf::LogDebug(
"LArPandora") <<
" Failed to find MC particles... " << std::endl;
117 mf::LogDebug(
"LArPandora") <<
" Found: " << theParticles->size() <<
" MC particles " << std::endl;
120 art::FindOneP<simb::MCTruth> theTruthAssns(theParticles, evt, label);
122 for (
unsigned int i = 0, iEnd = theParticles->size(); i < iEnd; ++i)
124 const art::Ptr<simb::MCParticle> particle(theParticles, i);
125 const art::Ptr<simb::MCTruth> truth(theTruthAssns.at(i));
126 truthToParticles[truth].push_back(particle);
127 particlesToTruth[particle] = truth;
128 MCParticleToTrackIdMap[particle->TrackId()] = particle;
136 if (evt.isRealData())
137 throw cet::exception(
"LArPandora") <<
" PandoraCollector::CollectSimChannels --- Trying to access MC truth from real data ";
139 art::Handle< std::vector<sim::SimChannel> > theSimChannels;
140 evt.getByLabel(label, theSimChannels);
142 if (!theSimChannels.isValid())
144 mf::LogDebug(
"LArPandora") <<
" Failed to find sim channels... " << std::endl;
149 mf::LogDebug(
"LArPandora") <<
" Found: " << theSimChannels->size() <<
" SimChannels " << std::endl;
152 for (
unsigned int i = 0; i < theSimChannels->size(); ++i)
154 const art::Ptr<sim::SimChannel> channel(theSimChannels, i);
155 simChannelVector.push_back(channel);
161 const art::Event &
evt,
162 const std::string &label,
163 const std::vector<art::Ptr<recob::Hit>> &hitVector,
164 std::map< art::Ptr<simb::MCParticle>,
std::vector<art::Ptr<recob::Hit> > > &particlesToHits,
165 std::map< art::Ptr<recob::Hit>, art::Ptr<simb::MCParticle> > &hitsToParticles,
167 std::map<
int, art::Ptr<simb::MCParticle> > & MCParticleToTrackIdMap,
169 std::vector< art::Ptr<sim::SimChannel> > simChannelVector;
170 std::map< art::Ptr<simb::MCTruth>, std::vector<art::Ptr<simb::MCParticle>> > truthToParticles;
171 std::map< art::Ptr<simb::MCParticle>, art::Ptr<simb::MCTruth> > particlesToTruth;
172 std::map< art::Ptr<recob::Hit>, std::vector< sim::TrackIDE > > hitsToTrackIDEs;
175 CollectMCParticles(evt, label, truthToParticles, particlesToTruth, MCParticleToTrackIdMap, vars);
220 if(vars.
m_selected_set.find( {run, subrun, event} ) == vars.m_selected_set.end()){
221 if(vars.m_selected_set.find({run, subrun}) == vars.m_selected_set.end() ){
222 if(vars.m_selected_set.find({run}) == vars.m_selected_set.end())
235 int n_vertices = (int)rectangle.size();
240 for (i = 0, j = n_vertices-1; i < n_vertices; j = i++) {
242 double this_area = 0.5*
abs(rectangle[i][0]*(rectangle[j][1] - thishit_pos[1])
243 + rectangle[j][0]*(thishit_pos[1] - rectangle[i][1])
244 + thishit_pos[0]*(rectangle[i][1] - rectangle[j][1]));
251 if (
abs(areas - area_rectangle) <= 0.001 ){
297 for (
auto &thishitptr : hits){
299 int plane= thishitptr->View();
302 if (plane != this_plane )
continue;
329 double Q = thishitptr->Integral()*gain;
344 std::vector<double> dedx(n,0.0);
345 for (
int i = 0; i <
n; i++){
355 const art::Ptr<recob::Shower>&
shower,
356 const std::vector<art::Ptr<recob::Cluster>> & clusters,
357 std::map<art::Ptr<recob::Cluster>,
std::vector<art::Ptr<recob::Hit>> > & clusterToHitMap ,
359 double triggeroffset,
364 std::vector<double> dqdx;
368 TVector3 shower_dir(shower->Direction().X(), shower->Direction().Y(),shower->Direction().Z());
372 double pitch =
getPitch(shower_dir, paras)[plane];
374 if(
g_is_verbose)
std::cout<<
"AnalyzeShowers() \t||\t The pitch between the shower and plane "<<plane<<
" is "<<pitch<<std::endl;
377 for (
const art::Ptr<recob::Cluster> &thiscluster: clusters){
379 if(thiscluster->View() != plane)
continue;
382 std::vector<double> cluster_axis = {cos(thiscluster->StartAngle()), sin(thiscluster->StartAngle())};
388 std::vector<double> cluster_start = {thiscluster->StartWire() * paras.
s_wire_spacing,(thiscluster->StartTick() - triggeroffset)* paras.
_time2cm};
389 std::vector<double> cluster_end = {thiscluster->EndWire() * paras.
s_wire_spacing,(thiscluster->EndTick() - triggeroffset)* paras.
_time2cm };
392 double length = sqrt(pow(cluster_end[0] - cluster_start[0], 2) + pow(cluster_end[1] - cluster_start[1], 2));
395 std::cout<<
"skipping cluster on plane "<<plane<<
", length = "<<length<<std::endl;
404 std::vector<art::Ptr<recob::Hit>> hits = clusterToHitMap[thiscluster];
407 for (art::Ptr<recob::Hit> &thishit: hits){
409 std::vector<double> thishit_pos ={thishit->WireID().Wire * paras.
s_wire_spacing, (thishit->PeakTime() - triggeroffset)* paras.
_time2cm};
412 bool v2 =
isInsidev2(thishit_pos, rectangle, paras);
414 double q =
GetQHit(thishit, plane, paras);
415 double this_dqdx = q/pitch;
416 dqdx.push_back(this_dqdx);
426 std::vector<double> pitches;
435 TVector3 wire_vector;
436 if(
abs(angToVert) < 1
e-9 ){
437 wire_vector = {0,0,1};
439 wire_vector = { 0 , sin(angToVert) ,cos(angToVert) };
443 double cos =
abs(wire_vector.Dot(shower_dir))/(wire_vector.Mag()*shower_dir.Mag());
445 pitches.push_back((cos==0)? std::numeric_limits<double>::max() : paras.
s_wire_spacing/cos );
447 if(pitches.size()==3)
break;
457 for (art::Ptr<recob::Hit> thishitptr : hits){
459 int plane= thishitptr->View();
462 if (plane != this_plane)
continue;
464 widths += thishitptr->RMS();
467 return widths/(double)nhits;
474 for (art::Ptr<recob::Hit> thishitptr : hits){
476 int plane= thishitptr->View();
479 if (plane != this_plane)
continue;
490 double m2 = 1.0/25.0;
492 return fabs((a1*m1*(b2*m2-c2*m2)+b1*m1*(c2*m2-a2*m2)+c1*m1*(a2*m2-b2*m2))/2.0);
497 std::vector<double>
z(n,0.0);
499 TGraph2D *
g =
new TGraph2D(n,X,Y,&z[0]);
500 TGraphDelaunay delan(g);
501 delan.SetMarginBinsContent(0);
503 delan.FindAllTriangles();
504 (*num_triangles)=delan.GetNdt();
507 Int_t *MT = delan.GetMTried();
508 Int_t *NT = delan.GetNTried();
509 Int_t *PT = delan.GetPTried();
512 for(
int i = 0; i<delan.GetNdt(); i++){
513 (*area)+=
triangle_area(X[MT[i]-1],Y[MT[i]-1],X[NT[i]-1],Y[NT[i]-1],X[PT[i]-1],Y[PT[i]-1]);
523 std::vector<double> C0,
T0;
524 std::vector<double> C1,T1;
525 std::vector<double> C2,T2;
530 for(
int i=0;i<
n; i++){
531 const art::Ptr<recob::Hit>
hit = hits[i];
534 C0.push_back((
double)hit->WireID().Wire);
535 T0.push_back(hit->PeakTime());
539 C1.push_back((
double)hit->WireID().Wire);
540 T1.push_back(hit->PeakTime());
544 C2.push_back((
double)hit->WireID().Wire);
545 T2.push_back(hit->PeakTime());
std::vector< double > CalcdEdxFromdQdx(std::vector< double > dqdx, para_all ¶s)
process_name opflash particleana ie ie ie z
void CollectMCParticles(const art::Event &evt, const std::string &label, std::map< art::Ptr< simb::MCTruth >, std::vector< art::Ptr< simb::MCParticle >>> &truthToParticles, std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth >> &particlesToTruth, std::map< int, art::Ptr< simb::MCParticle > > &MCParticleToTrackIdMap, var_all &vars)
std::set< std::vector< int > > m_selected_set
int getNHitsPlane(std::vector< art::Ptr< recob::Hit >> hits, int this_plane)
IteratorBox< plane_iterator,&GeometryCore::begin_plane,&GeometryCore::end_plane > IteratePlanes() const
Enables ranged-for loops on all planes of the detector.
void BuildMCParticleHitMaps(const art::Event &evt, const std::string &label, const std::vector< art::Ptr< recob::Hit >> &hitVector, std::map< art::Ptr< simb::MCParticle >, std::vector< art::Ptr< recob::Hit > > > &particlesToHits, std::map< art::Ptr< recob::Hit >, art::Ptr< simb::MCParticle > > &hitsToParticles, const lar_pandora::LArPandoraHelper::DaughterMode daughterMode, std::map< int, art::Ptr< simb::MCParticle > > &MCParticleToTrackIdMap, var_all &vars)
int delaunay_hit_wrapper(const std::vector< art::Ptr< recob::Hit >> &hits, std::vector< int > &num_hits, std::vector< int > &num_triangles, std::vector< double > &area, para_all ¶s)
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
bool isInsidev2(std::vector< double > thishit_pos, std::vector< std::vector< double >> rectangle, para_all ¶s)
std::vector< double > s_gain_data
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::vector< double > s_gain_mc
bool Pi0PreselectionFilter2g0p(var_all &vars, para_all ¶s)
bool Pi0PreselectionFilter(var_all &vars, para_all ¶s)
std::vector< double > m_reco_shower_energy_max
void CollectSimChannels(const art::Event &evt, const std::string &label, std::vector< art::Ptr< sim::SimChannel > > &simChannelVector)
double getMeanHitWidthPlane(std::vector< art::Ptr< recob::Hit >> hits, int this_plane)
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
double s_recombination_factor
double triangle_area(double a1, double a2, double b1, double b2, double c1, double c2)
geo::GeometryCore const * s_geom
std::vector< std::vector< double > > buildRectangle(std::vector< double > cluster_start, std::vector< double > cluster_axis, double width, double length)
Calculates the four corners of a rectangle of given length and width around a cluster given the start...
std::vector< double > CalcdQdxShower(const art::Ptr< recob::Shower > &shower, const std::vector< art::Ptr< recob::Cluster >> &clusters, std::map< art::Ptr< recob::Cluster >, std::vector< art::Ptr< recob::Hit >> > &clusterToHitMap, int plane, double triggeroffset, detinfo::DetectorPropertiesData const &theDetector, para_all ¶s)
int spacecharge_correction(const art::Ptr< simb::MCParticle > &mcparticle, std::vector< double > &corrected, std::vector< double > &input)
DaughterMode
DaughterMode enumeration.
std::vector< size_t > m_reco_shower_ordered_energy_index
double CalcEShowerPlane(const std::vector< art::Ptr< recob::Hit >> &hits, int this_plane, para_all ¶s)
std::vector< double > getPitch(TVector3 shower_dir, para_all ¶s)
double GetQHit(art::Ptr< recob::Hit > thishitptr, int plane, para_all ¶s)
double QtoEConversion(double Q, para_all ¶s)
bool IsEventInList(int run, int subrun, int event, var_all &vars)
int quick_delaunay_fit(int n, double *X, double *Y, int *num_triangles, double *area)
static void BuildMCParticleHitMaps(const art::Event &evt, const HitVector &hitVector, const SimChannelVector &simChannelVector, HitsToTrackIDEs &hitsToTrackIDEs)
Collect the links from reconstructed hits to their true energy deposits.
std::vector< double > m_reco_shower_conversion_distance
double WireAngleToVertical(geo::View_t view, geo::TPCID const &tpcid) const
Returns the angle of the wires in the specified view from vertical.
BEGIN_PROLOG could also be cout
process_name opdaq physics producers generator physics producers generator physics producers generator physics producers generator physics producers generator physics producers generator physics producers generator physics producers generator T0