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

Public Member Functions

 tpcpatreccheat (fhicl::ParameterSet const &p)
 
 tpcpatreccheat (tpcpatreccheat const &)=delete
 
 tpcpatreccheat (tpcpatreccheat &&)=delete
 
tpcpatreccheatoperator= (tpcpatreccheat const &)=delete
 
tpcpatreccheatoperator= (tpcpatreccheat &&)=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

int makepatrectrack (std::vector< gar::rec::TPCCluster > &hits, gar::rec::TrackPar &trackpar)
 

Private Attributes

std::string fHitLabel
 label of module making hits More...
 
std::string fTPCClusterLabel
 
int fPrintLevel
 label of module for input TPC clusters More...
 
size_t fMinNumTPCClusters
 minimum number of hits for a patrec track More...
 
float fSortTransWeight
 for use in the hit sorting algorithm – transverse distance weight factor More...
 
float fSortDistBack
 for use in the hit sorting algorithm – how far to go back before raising the distance figure of merit More...
 
float fTPCClusterRCut
 maximum radius from center of TPC in YZ to take a cluster More...
 
float fTPCClusterGapCut
 in cm – skip TPC clusters within this distance of a gap More...
 
unsigned int fInitialTPNTPCClusters
 number of hits to use for initial trackpar estimate, if present More...
 

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 42 of file tpcpatreccheat_module.cc.

Constructor & Destructor Documentation

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

Definition at line 79 of file tpcpatreccheat_module.cc.

79  : EDProducer{p}
80  {
81  fHitLabel = p.get<std::string>("HitLabel","hit");
82  fTPCClusterLabel = p.get<std::string>("TPCClusterLabel","tpccluster");
83  fPrintLevel = p.get<int>("PrintLevel",0);
84  fMinNumTPCClusters = p.get<size_t>("MinNumTPCClusters",20);
85  fInitialTPNTPCClusters = p.get<unsigned int>("InitialTPNTPCClusters",100);
86  fTPCClusterRCut = p.get<float>("TPCClusterRCut",280.0);
87  fTPCClusterGapCut = p.get<float>("TPCClusterGapCut",5.0);
88  fSortTransWeight = p.get<float>("SortTransWeight",0.1);
89  fSortDistBack = p.get<float>("SortDistBack",2.0);
90 
91  art::InputTag hitTag(fHitLabel);
92  art::InputTag TPCClusterTag(fTPCClusterLabel);
93 
94  consumes< std::vector<gar::rec::Hit> >(hitTag);
95  consumes< std::vector<gar::rec::TPCCluster> >(TPCClusterTag);
96  consumes< art::Assns<gar::rec::TPCCluster, gar::rec::Hit> >(TPCClusterTag);
97 
98  produces< std::vector<gar::rec::Track> >();
99  produces< art::Assns<gar::rec::TPCCluster, gar::rec::Track> >();
100  produces< art::Assns<gar::rec::VecHit, gar::rec::Track> >();
101  }
std::string string
Definition: nybbler.cc:12
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
float fTPCClusterGapCut
in cm – skip TPC clusters within this distance of a gap
std::string fHitLabel
label of module making hits
int fPrintLevel
label of module for input TPC clusters
p
Definition: test.py:223
unsigned int fInitialTPNTPCClusters
number of hits to use for initial trackpar estimate, if present
float fTPCClusterRCut
maximum radius from center of TPC in YZ to take a cluster
float fSortTransWeight
for use in the hit sorting algorithm – transverse distance weight factor
float fSortDistBack
for use in the hit sorting algorithm – how far to go back before raising the distance figure of meri...
size_t fMinNumTPCClusters
minimum number of hits for a patrec track
gar::rec::tpcpatreccheat::tpcpatreccheat ( tpcpatreccheat const &  )
delete
gar::rec::tpcpatreccheat::tpcpatreccheat ( tpcpatreccheat &&  )
delete

Member Function Documentation

int gar::rec::tpcpatreccheat::makepatrectrack ( std::vector< gar::rec::TPCCluster > &  hits,
gar::rec::TrackPar trackpar 
)
private

Definition at line 242 of file tpcpatreccheat_module.cc.

243  {
244  // track parameters: x is the independent variable
245  // 0: y
246  // 1: z
247  // 2: curvature
248  // 3: phi
249  // 4: lambda = angle from the cathode plane
250  // 5: x /// added on to the end
251 
252 
253  float lengthforwards = 0;
254  std::vector<int> hlf;
255  float lengthbackwards = 0;
256  std::vector<int> hlb;
257 
258  gar::rec::sort_TPCClusters_along_track(trackTPCClusters,hlf,hlb,fPrintLevel,lengthforwards,lengthbackwards,fSortTransWeight,fSortDistBack);
259 
260  std::vector<float> tparbeg(6,0);
261  float xother = 0;
262  if ( gar::rec::initial_trackpar_estimate(trackTPCClusters, hlf, tparbeg[2], tparbeg[4],
263  tparbeg[3], tparbeg[5], tparbeg[0], tparbeg[1], xother, fInitialTPNTPCClusters, fPrintLevel) != 0)
264  {
265  return 1;
266  }
267 
268  std::vector<float> tparend(6,0);
269  if ( gar::rec::initial_trackpar_estimate(trackTPCClusters, hlb, tparend[2], tparend[4],
270  tparend[3], tparend[5], tparend[0], tparend[1], xother, fInitialTPNTPCClusters, fPrintLevel) != 0)
271  {
272  return 1;
273  }
274 
275  // no chisquare or covariance in patrec tracks
276  float covmatbeg[25];
277  float covmatend[25];
278  for (size_t i=0; i<25; ++i) // no covmat in patrec tracks
279  {
280  covmatend[i] = 0;
281  covmatbeg[i] = 0;
282  }
283 
284  trackpar.setNTPCClusters(trackTPCClusters.size());
285  trackpar.setTime(0);
286  trackpar.setChisqForwards(0);
287  trackpar.setChisqBackwards(0);
288  trackpar.setLengthForwards(lengthforwards);
289  trackpar.setLengthBackwards(lengthbackwards);
290  trackpar.setCovMatBeg(covmatbeg);
291  trackpar.setCovMatEnd(covmatend);
292  trackpar.setTrackParametersBegin(tparbeg.data());
293  trackpar.setXBeg(tparbeg[5]);
294  trackpar.setTrackParametersEnd(tparend.data());
295  trackpar.setXEnd(tparend[5]);
296 
297  return 0;
298  }
void setNTPCClusters(const size_t nTPCClusters)
Definition: TrackPar.cxx:214
void setLengthForwards(const float lengthforwards)
Definition: TrackPar.cxx:251
void setCovMatBeg(const float *covmatbeg)
Definition: TrackPar.cxx:235
void setLengthBackwards(const float lengthbackwards)
Definition: TrackPar.cxx:256
void setTrackParametersBegin(const float *tparbeg)
Definition: TrackPar.cxx:219
int fPrintLevel
label of module for input TPC clusters
void setXEnd(const float xend)
Definition: TrackPar.cxx:276
void setTrackParametersEnd(const float *tparend)
Definition: TrackPar.cxx:227
void setChisqBackwards(const float chisqbackwards)
Definition: TrackPar.cxx:266
unsigned int fInitialTPNTPCClusters
number of hits to use for initial trackpar estimate, if present
void setCovMatEnd(const float *covmatend)
Definition: TrackPar.cxx:243
float fSortTransWeight
for use in the hit sorting algorithm – transverse distance weight factor
void sort_TPCClusters_along_track(const std::vector< gar::rec::TPCCluster > &TPCClusters, std::vector< int > &hlf, std::vector< int > &hlb, int printlevel, float &lengthforwards, float &lengthbackwards, float sorttransweight, float sortdistback)
void setXBeg(const float xbeg)
Definition: TrackPar.cxx:271
float fSortDistBack
for use in the hit sorting algorithm – how far to go back before raising the distance figure of meri...
void setChisqForwards(const float chisqforwards)
Definition: TrackPar.cxx:261
void setTime(const double time)
Definition: TrackPar.cxx:281
int initial_trackpar_estimate(const std::vector< gar::rec::TPCCluster > &TPCClusters, std::vector< int > &TPCClusterlist, float &curvature_init, float &lambda_init, float &phi_init, float &xpos, float &ypos, float &zpos, float &x_other_end, unsigned int initialtpnTPCClusters, int printlevel)
Definition: tracker2algs.cxx:8
tpcpatreccheat& gar::rec::tpcpatreccheat::operator= ( tpcpatreccheat const &  )
delete
tpcpatreccheat& gar::rec::tpcpatreccheat::operator= ( tpcpatreccheat &&  )
delete
void gar::rec::tpcpatreccheat::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 103 of file tpcpatreccheat_module.cc.

104  {
105 
106  if( e.isRealData() ){
107  throw cet::exception("tpcpatreccheat")
108  << "Attempting to cheat the track pattern recognition for real data. "
109  << "That will not work";
110  }
111 
112  auto TPCClusterHandle = e.getValidHandle< std::vector<gar::rec::TPCCluster> >(fTPCClusterLabel);
113  auto const& TPCClusters = *TPCClusterHandle;
114 
115  std::unique_ptr< std::vector<gar::rec::Track> > trkCol(new std::vector<gar::rec::Track>);
116  std::unique_ptr< art::Assns<gar::rec::VecHit,gar::rec::Track> > vhTrkAssns(new ::art::Assns<gar::rec::VecHit,gar::rec::Track>);
117  std::unique_ptr< art::Assns<gar::rec::TPCCluster,gar::rec::Track> > TPCClusterTrkAssns(new ::art::Assns<gar::rec::TPCCluster,gar::rec::Track>);
118 
119  auto const trackPtrMaker = art::PtrMaker<gar::rec::Track>(e);
120  auto const TPCClusterPtrMaker = art::PtrMaker<gar::rec::TPCCluster>(e, TPCClusterHandle.id());
121  const art::FindManyP<gar::rec::Hit> HitsFromTPCClusters(TPCClusterHandle,e,fTPCClusterLabel);
122 
123  auto bt = gar::providerFrom<cheat::BackTracker>();
124  auto geo = gar::providerFrom<geo::GeometryGAr>();
125  TVector3 xhat(1,0,0);
126  TVector3 tpccent(geo->TPCXCent(),geo->TPCYCent(),geo->TPCZCent());
127 
128 
129  // Do everything separately for the two sides -- do not make a single track out of pieces on either side of the cathode
130 
131  for (int iside=-1; iside <= 1; iside += 2)
132  {
133  std::map<int, std::set<size_t> > trackIDclusmap;
134  for (size_t iclus = 0; iclus<TPCClusters.size(); ++iclus)
135  {
136  TVector3 cluspos(TPCClusters.at(iclus).Position());
137  TVector3 cprel = cluspos - tpccent;
138  float rclus = (cprel.Cross(xhat)).Mag();
139  if ( rclus > fTPCClusterRCut ) continue;
140 
141  // logic to see if a hit is close to a gap and skip if it is
142  if ( rclus > geo->GetIROCInnerRadius())
143  {
144  float phi = TMath::ATan2(cprel.Z(),cprel.Y());
145  if (phi<0) phi += 2.0*TMath::Pi();
146  float phisc = phi/( TMath::Pi()/9.0 );
147  UInt_t isector = TMath::Floor(phisc); // assumes the sector boundary is at phi=0 // goes from 0 to 17
148  // rotate this back down to a single sector
149  float rotang = ( isector*TMath::Pi()/9.0 );
150  float crot = TMath::Cos(rotang);
151  float srot = TMath::Sin(rotang);
152  //float zrot = cprel.Z()*crot + cprel.Y()*srot;
153  float yrot = - cprel.Z()*srot + cprel.Y()*crot;
154  if (TMath::Abs(yrot) < fTPCClusterGapCut) continue;
155  }
156 
157  float totcharge = 0;
158  std::map<int, float> chargemap; // trackID to charge map -- charge is in electrons
159  auto hits = HitsFromTPCClusters.at(iclus);
160  for (size_t ihit=0; ihit< hits.size(); ++ihit)
161  {
162  unsigned int channel = hits.at(ihit)->Channel();
163  float chanpos[3];
164  geo->ChannelToPosition(channel,chanpos);
165  int hitside = 1;
166  if (chanpos[0] < tpccent.X())
167  {
168  hitside = -1;
169  }
170  if (hitside != iside) continue;
171  auto hitides = bt->HitToHitIDEs(hits.at(ihit));
172  //std::cout << "number of hitides: " << hitides.size() << std::endl;
173  for (size_t i=0; i<hitides.size(); ++i)
174  {
175  float charge = hitides.at(i).energyTot;
176  totcharge += charge;
177  int trackid = TMath::Abs(hitides.at(i).trackID);
178  auto cmf = chargemap.find(trackid);
179  if (cmf == chargemap.end())
180  {
181  chargemap[trackid]=charge;
182  }
183  else
184  {
185  cmf->second += charge;
186  }
187  }
188  }
189  if (totcharge > 0)
190  {
191  float maxcharge = 0;
192  int ibesttrackid = 0;
193  for (auto const& cm : chargemap)
194  {
195  if (cm.second > maxcharge)
196  {
197  maxcharge = cm.second;
198  ibesttrackid = cm.first;
199  }
200  }
201  trackIDclusmap[ibesttrackid].emplace(iclus);
202  }
203  } // end loop over TPC Clusters for grouping them by trackID
204 
205  // loop over the map associating trackIDs to TPC clusters and for each entry
206  // make a local list of TPCClusters for each track and find initial track parameters
207 
208  for (auto const& tic : trackIDclusmap)
209  {
210  std::vector<gar::rec::TPCCluster> TPCClusters_thistrack;
211  std::vector<art::Ptr<gar::rec::TPCCluster> > TPCClusterptrs;
212  for (auto const& iclus : tic.second)
213  {
214  TPCClusters_thistrack.push_back(TPCClusters.at(iclus));
215  TPCClusterptrs.push_back(TPCClusterPtrMaker(iclus));
216  }
217 
218 
219  if (TPCClusters_thistrack.size() >= fMinNumTPCClusters)
220  {
221  gar::rec::TrackPar trackpar;
222  if ( makepatrectrack(TPCClusters_thistrack,trackpar) == 0 )
223  {
224  trkCol->push_back(trackpar.CreateTrack());
225  auto const trackpointer = trackPtrMaker(trkCol->size()-1);
226  for (size_t iTPCCluster=0; iTPCCluster<TPCClusters_thistrack.size(); ++iTPCCluster)
227  {
228  TPCClusterTrkAssns->addSingle(TPCClusterptrs.at(iTPCCluster),trackpointer);
229  }
230  }
231  }
232  }
233  }
234  e.put(std::move(trkCol));
235  e.put(std::move(vhTrkAssns));
236  e.put(std::move(TPCClusterTrkAssns));
237  }
static constexpr double cm
Definition: Units.h:68
int makepatrectrack(std::vector< gar::rec::TPCCluster > &hits, gar::rec::TrackPar &trackpar)
float fTPCClusterGapCut
in cm – skip TPC clusters within this distance of a gap
uint8_t channel
Definition: CRTFragment.hh:201
bool isRealData() const
const double e
bt
Definition: tracks.py:83
def move(depos, offset)
Definition: depos.py:107
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
gar::rec::Track CreateTrack()
Definition: TrackPar.cxx:292
float fTPCClusterRCut
maximum radius from center of TPC in YZ to take a cluster
size_t fMinNumTPCClusters
minimum number of hits for a patrec track
LArSoft geometry interface.
Definition: ChannelGeo.h:16
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33

Member Data Documentation

std::string gar::rec::tpcpatreccheat::fHitLabel
private

label of module making hits

Definition at line 61 of file tpcpatreccheat_module.cc.

unsigned int gar::rec::tpcpatreccheat::fInitialTPNTPCClusters
private

number of hits to use for initial trackpar estimate, if present

Definition at line 71 of file tpcpatreccheat_module.cc.

size_t gar::rec::tpcpatreccheat::fMinNumTPCClusters
private

minimum number of hits for a patrec track

Definition at line 64 of file tpcpatreccheat_module.cc.

int gar::rec::tpcpatreccheat::fPrintLevel
private

label of module for input TPC clusters

debug printout: 0: none, 1: selected, 2: all

Definition at line 63 of file tpcpatreccheat_module.cc.

float gar::rec::tpcpatreccheat::fSortDistBack
private

for use in the hit sorting algorithm – how far to go back before raising the distance figure of merit

Definition at line 67 of file tpcpatreccheat_module.cc.

float gar::rec::tpcpatreccheat::fSortTransWeight
private

for use in the hit sorting algorithm – transverse distance weight factor

Definition at line 66 of file tpcpatreccheat_module.cc.

float gar::rec::tpcpatreccheat::fTPCClusterGapCut
private

in cm – skip TPC clusters within this distance of a gap

Definition at line 69 of file tpcpatreccheat_module.cc.

std::string gar::rec::tpcpatreccheat::fTPCClusterLabel
private

Definition at line 62 of file tpcpatreccheat_module.cc.

float gar::rec::tpcpatreccheat::fTPCClusterRCut
private

maximum radius from center of TPC in YZ to take a cluster

Definition at line 68 of file tpcpatreccheat_module.cc.


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