Public Member Functions | Private Member Functions | Private Attributes | List of all members
gar::rec::vertexfinder1 Class Reference
Inheritance diagram for gar::rec::vertexfinder1:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 vertexfinder1 (fhicl::ParameterSet const &p)
 
 vertexfinder1 (vertexfinder1 const &)=delete
 
 vertexfinder1 (vertexfinder1 &&)=delete
 
vertexfinder1operator= (vertexfinder1 const &)=delete
 
vertexfinder1operator= (vertexfinder1 &&)=delete
 
void produce (art::Event &e) override
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

bool goodTrack (TrackPar trk, TrackEnd usebeg)
 

Private Attributes

float fChisquaredCut
 
int fPrintLevel
 
float fRCut
 
float fDCut
 
std::string fTrackLabel
 
int fNTPCClusCut
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 30 of file vertexfinder1_module.cc.

Constructor & Destructor Documentation

gar::rec::vertexfinder1::vertexfinder1 ( fhicl::ParameterSet const &  p)
explicit

Definition at line 60 of file vertexfinder1_module.cc.

60  : EDProducer{p}
61  {
62  fTrackLabel = p.get<std::string>("TrackLabel","track");
63  fChisquaredCut = p.get<float>("ChisquaredPerDOFCut",5.0);
64  fRCut = p.get<float>("RCut", 12.0); // endpoints must be within this distnace in cm
65  fDCut = p.get<float>("DCut", 2.0); // doca must be smaller than this in cm
66  fNTPCClusCut = p.get<int>("NTPCClusCut",20); // dimensionless
67  fPrintLevel = p.get<int>("PrintLevel",0);
68 
69  art::InputTag trackTag(fTrackLabel);
70  consumes< std::vector<rec::Track> >(trackTag);
71 
72  // Produce vertex, associated tracks & ends. TrackEnd is defined in Track.h
73  produces< std::vector<rec::Vertex> >();
74  produces< art::Assns<rec::Track, rec::Vertex, rec::TrackEnd> >();
75  }
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
p
Definition: test.py:223
gar::rec::vertexfinder1::vertexfinder1 ( vertexfinder1 const &  )
delete
gar::rec::vertexfinder1::vertexfinder1 ( vertexfinder1 &&  )
delete

Member Function Documentation

bool gar::rec::vertexfinder1::goodTrack ( TrackPar  trk,
TrackEnd  usebeg 
)
private

Definition at line 221 of file vertexfinder1_module.cc.

222  {
223  int trknclus = trk.getNTPCClusters();
224  if ( trknclus < fNTPCClusCut ) return false;
225  return true; // just a stub for now
226  }
vertexfinder1& gar::rec::vertexfinder1::operator= ( vertexfinder1 const &  )
delete
vertexfinder1& gar::rec::vertexfinder1::operator= ( vertexfinder1 &&  )
delete
void gar::rec::vertexfinder1::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 77 of file vertexfinder1_module.cc.

77  {
78  std::unique_ptr< std::vector<rec::Vertex> >
79  vtxCol(new std::vector<rec::Vertex>);
80  std::unique_ptr< art::Assns<rec::Track, rec::Vertex, rec::TrackEnd> >
82 
83  auto trackHandle = e.getValidHandle< std::vector<Track> >(fTrackLabel);
84  auto const& tracks = *trackHandle;
85 
86  auto const vtxPtrMaker = art::PtrMaker<rec::Vertex>(e);
87  auto const trackPtrMaker = art::PtrMaker<rec::Track>(e, trackHandle.id());
88 
89  size_t nTrack = tracks.size();
90  std::vector<int> usedflag_beg(nTrack,0); // to tell if we've used a track yet or not.
91  std::vector<int> usedflag_end(nTrack,0); // to tell if we've used a track yet or not.
92 
93  if (nTrack>=2) {
94 
95  // For each track, build a vector of ends that can be vertexed with it. Include
96  // the number of the track for later ouroboros test
97 
98  std::vector< std::tuple<TrackPar,TrackEnd,int> > trackParEnds;
99  for (size_t iTrack=0; iTrack<nTrack-1; ++iTrack) {
100  TrackPar thisTrack = tracks.at(iTrack);
101  // Build that vector for each of the 2 ends of the track
102  for (int fin=0; fin<2; ++fin) {
103  trackParEnds.clear();
104  TrackEnd thisTrackEnd(fin == 0 ? 1 : 0);
105  if (! goodTrack(thisTrack,thisTrackEnd)) continue;
106  trackParEnds.emplace_back( std::make_tuple(thisTrack,thisTrackEnd,iTrack) );
107  TVector3 thisEndinSpace;
108  if (thisTrackEnd == TrackEndBeg)
109  {
110  usedflag_beg.at(iTrack) = 1;
111  thisEndinSpace = thisTrack.getXYZBeg();
112  }
113  else
114  {
115  usedflag_end.at(iTrack) = 1;
116  thisEndinSpace = thisTrack.getXYZEnd();
117  }
118 
119  // Loop over other trackends to see what is close
120  for (size_t jTrack=iTrack+1; jTrack<nTrack; ++jTrack) {
121  TrackPar thatTrack = tracks.at(jTrack);
122  for (int fin2=0; fin2<2; ++fin2)
123  {
124  TrackEnd thatTrackEnd(fin2 == 0 ? 1 : 0);
125  if (thatTrackEnd == TrackEndBeg && usedflag_beg.at(jTrack) != 0) continue;
126  if (thatTrackEnd == TrackEndEnd && usedflag_end.at(jTrack) != 0) continue;
127  if (!goodTrack(thatTrack,thatTrackEnd)) continue;
128  TVector3 thatEndinSpace;
129  if (thatTrackEnd == TrackEndBeg)
130  {
131  thatEndinSpace = thatTrack.getXYZBeg();
132  }
133  else
134  {
135  thatEndinSpace = thatTrack.getXYZEnd();
136  }
137 
138  if ( (thisEndinSpace-thatEndinSpace).Mag() > fRCut) continue;
139 
140 
141  // call the fitter to see what the docas are and cut on the doca
142 
143  std::vector<TrackPar> vtracks;
144  std::vector<TrackEnd> usebeg;
145  vtracks.push_back(thisTrack);
146  vtracks.push_back(thatTrack);
147  usebeg.push_back(thisTrackEnd);
148  usebeg.push_back(thatTrackEnd);
149  std::vector<float> xyz(3,0);
150  std::vector< std::vector<float> > covmat;
151  std::vector<float> doca;
152  float chisquared=0;
153  double time;
154 
155  if (gar::rec::fitVertex(vtracks,xyz,chisquared,covmat,time,usebeg,doca) == 0)
156  {
157  if (doca.at(0) < fDCut && doca.at(1) < fDCut)
158  {
159  if (thatTrackEnd == TrackEndBeg)
160  {
161  usedflag_beg.at(jTrack) = 1;
162  }
163  else
164  {
165  usedflag_end.at(jTrack) = 1;
166  }
167  trackParEnds.emplace_back( std::make_tuple(thatTrack,thatTrackEnd,jTrack) );
168  continue; // don't add the other end of the same track
169  } // end if doca test
170  } // end if vertex fit succeeded
171  } // end loop over jtrack end
172  } // End loop over jTrack
173 
174  size_t nTrackEnds = trackParEnds.size();
175 
176  if ( nTrackEnds>=2) {
177  // Feed the vertexable ends into the vertex finder
178  std::vector<TrackPar> vtracks;
179  std::vector<TrackEnd> usebeg;
180  for (size_t iTrackEnd=0; iTrackEnd<nTrackEnds; ++iTrackEnd) {
181  vtracks.push_back( std::get<TrackPar>(trackParEnds[iTrackEnd]) );
182  usebeg.push_back ( std::get<1>(trackParEnds[iTrackEnd]) );
183  }
184  std::vector<float> xyz(3,0);
185  std::vector< std::vector<float> > covmat;
186  std::vector<float> doca;
187  float chisquared=0;
188  double time;
189  if (gar::rec::fitVertex(vtracks,xyz,chisquared,covmat,time,usebeg,doca) == 0) {
190  float cmv[9];
191  size_t icounter=0;
192  for (size_t i=0; i<3;++i) {
193  for (size_t j=0; j<3; ++j) {
194  cmv[icounter] = covmat.at(i).at(j);
195  }
196  }
197 
198  // Save vertex & its tracks into vectors that will be written
199  // to event.
200  vtxCol->emplace_back(xyz.data(),cmv,time);
201  auto const vtxpointer = vtxPtrMaker(vtxCol->size()-1);
202  for (size_t i=0; i<trackParEnds.size(); ++i) {
203  TrackEnd endInVertex = std::get<1>(trackParEnds[i]);
204  auto const trackpointer = trackPtrMaker( std::get<2>(trackParEnds[i]) );
205  trkVtxAssns->addSingle(trackpointer,vtxpointer,endInVertex);
206  }
207  } // end if (fitVertex...)
208  }
209  } // end loop on 2 ends of iTrack
210  } // end loop on iTrack
211  } // End test for nTrack>=2; might put empty vertex list & Assns into event
212  e.put(std::move(vtxCol));
213  e.put(std::move(trkVtxAssns));
214  } // end produce method.
int TrackEnd
Definition: Track.h:32
int fitVertex(std::vector< TrackPar > &tracks, std::vector< float > &xyz, float &chisquared, std::vector< std::vector< float > > &covmat, double &time, std::vector< TrackEnd > usebeg, std::vector< float > &doca)
Definition: vertex1algs.cxx:8
TrackEnd const TrackEndEnd
Definition: Track.h:33
const double e
def move(depos, offset)
Definition: depos.py:107
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
bool goodTrack(TrackPar trk, TrackEnd usebeg)
Definition: tracks.py:1
TrackEnd const TrackEndBeg
Definition: Track.h:33

Member Data Documentation

float gar::rec::vertexfinder1::fChisquaredCut
private

Definition at line 47 of file vertexfinder1_module.cc.

float gar::rec::vertexfinder1::fDCut
private

Definition at line 50 of file vertexfinder1_module.cc.

int gar::rec::vertexfinder1::fNTPCClusCut
private

Definition at line 52 of file vertexfinder1_module.cc.

int gar::rec::vertexfinder1::fPrintLevel
private

Definition at line 48 of file vertexfinder1_module.cc.

float gar::rec::vertexfinder1::fRCut
private

Definition at line 49 of file vertexfinder1_module.cc.

std::string gar::rec::vertexfinder1::fTrackLabel
private

Definition at line 51 of file vertexfinder1_module.cc.


The documentation for this class was generated from the following file: