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

Public Member Functions

 TPCHitCluster (fhicl::ParameterSet const &p)
 
 TPCHitCluster (TPCHitCluster const &)=delete
 
 TPCHitCluster (TPCHitCluster &&)=delete
 
TPCHitClusteroperator= (TPCHitCluster const &)=delete
 
TPCHitClusteroperator= (TPCHitCluster &&)=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 Attributes

std::string fHitLabel
 label of module to get the hits from More...
 
int fClusterHits
 hit clustering algorithm number More...
 
float fHitClusterDx
 range in cm to look for hits to cluster in x More...
 
float fHitClusterDyDz
 range in cm to look for hits to cluster in y and z More...
 
float fHitClusterDr_I
 range in R to look for hits to cluster for IROC, in cm More...
 
float fHitClusterDfi_I
 range in R*dPhi to look for hits to cluster for IROC, in cm More...
 
float fHitClusterDrIO
 range in R to look for hits to cluster for IOROC, in cm More...
 
float fHitClusterDfiIO
 range in R*dPhi to look for hits to cluster for IROC, in cm More...
 
float fHitClusterDrOO
 range in R to look for hits to cluster for OOROC, in cm More...
 
float fHitClusterDfiOO
 range in R*dPhi to look for hits to cluster for IROC, in cm More...
 
int fPrintLevel
 debug printout: 0: none, 1: selected, 2: all 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 35 of file TPCHitCluster_module.cc.

Constructor & Destructor Documentation

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

Definition at line 73 of file TPCHitCluster_module.cc.

74  : EDProducer{p}
75  {
76  fHitLabel = p.get<std::string>("HitLabel","hit");
77  fPrintLevel = p.get<int>("PrintLevel",0);
78  fClusterHits = p.get<int>("ClusterHits",1);
79  fHitClusterDx = p.get<float>("HitClusterDx", 1.00);
80  fHitClusterDyDz = p.get<float>("HitClusterDyDz", 1.20);
81  fHitClusterDr_I = p.get<float>("HitClusterDr_I", 1.50);
82  fHitClusterDfi_I = p.get<float>("HitClusterDfi_I",1.06);
83  fHitClusterDrIO = p.get<float>("HitClusterDrIO", 2.00);
84  fHitClusterDfiIO = p.get<float>("HitClusterDfiIO",1.55);
85  fHitClusterDrOO = p.get<float>("HitClusterDrOO", 3.00);
86  fHitClusterDfiOO = p.get<float>("HitClusterDfiO)",1.73);
87 
88  art::InputTag hitTag(fHitLabel);
89  consumes< std::vector<gar::rec::Hit> >(hitTag);
90  produces< std::vector<gar::rec::TPCCluster> >();
91  produces< art::Assns<gar::rec::Hit, gar::rec::TPCCluster> >();
92  }
float fHitClusterDyDz
range in cm to look for hits to cluster in y and z
float fHitClusterDr_I
range in R to look for hits to cluster for IROC, in cm
std::string string
Definition: nybbler.cc:12
std::string fHitLabel
label of module to get the hits from
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
float fHitClusterDrOO
range in R to look for hits to cluster for OOROC, in cm
float fHitClusterDfi_I
range in R*dPhi to look for hits to cluster for IROC, in cm
float fHitClusterDx
range in cm to look for hits to cluster in x
float fHitClusterDfiIO
range in R*dPhi to look for hits to cluster for IROC, in cm
float fHitClusterDrIO
range in R to look for hits to cluster for IOROC, in cm
float fHitClusterDfiOO
range in R*dPhi to look for hits to cluster for IROC, in cm
p
Definition: test.py:223
int fClusterHits
hit clustering algorithm number
int fPrintLevel
debug printout: 0: none, 1: selected, 2: all
gar::rec::TPCHitCluster::TPCHitCluster ( TPCHitCluster const &  )
delete
gar::rec::TPCHitCluster::TPCHitCluster ( TPCHitCluster &&  )
delete

Member Function Documentation

TPCHitCluster& gar::rec::TPCHitCluster::operator= ( TPCHitCluster const &  )
delete
TPCHitCluster& gar::rec::TPCHitCluster::operator= ( TPCHitCluster &&  )
delete
void gar::rec::TPCHitCluster::produce ( art::Event e)
overridevirtual

Implements art::EDProducer.

Definition at line 99 of file TPCHitCluster_module.cc.

100  {
102  float xtpccent = euclid->TPCXCent();
103  float ytpccent = euclid->TPCYCent();
104  float ztpccent = euclid->TPCZCent();
105 
106  // input: hits
107 
108  auto hitHandle = e.getValidHandle< std::vector<gar::rec::Hit> >(fHitLabel);
109  auto const& hits = *hitHandle;
110 
111  // output: TPCCluster and associations with hits
112 
113  std::unique_ptr<std::vector<gar::rec::TPCCluster> > TPCClusterCol (new std::vector<gar::rec::TPCCluster> );
114  std::unique_ptr<art::Assns<gar::rec::Hit,gar::rec::TPCCluster> > hitClusterAssns(new ::art::Assns<gar::rec::Hit,gar::rec::TPCCluster>);
115 
116  auto const TPCClusterPtrMaker = art::PtrMaker<gar::rec::TPCCluster>(e);
117  auto const hitPtrMaker = art::PtrMaker<rec::Hit>(e, hitHandle.id());
118 
119  size_t nhits = hits.size();
120  std::vector<float> hptmp(nhits);
121  std::vector<int> hsi(nhits);
122  std::vector<int> used(nhits,0);
123 
124  // sort hits by position in x
125 
126  for (size_t ihit=0;ihit<nhits;++ihit)
127  {
128  hptmp[ihit] = hits.at(ihit).Position()[0];
129  }
130  TMath::Sort( (int) nhits, hptmp.data(), hsi.data() );
131 
132  // loop through hits in x, clustering as we go, marking hits as used.
133 
134  for (size_t ihitx=0; ihitx< nhits; ++ihitx)
135  {
136  size_t ihit = hsi[ihitx]; // unwound index to hit array
137  if (used[ihit]) continue;
138 
139  const float *xyz_fromhit = hits.at(ihit).Position();
140  float xyz[3] = {xyz_fromhit[0] -xtpccent, xyz_fromhit[1] -ytpccent, xyz_fromhit[2] -ztpccent};
141 
142  // start a cluster with just this hit
143  std::vector<size_t> hitsinclus; // keep track of hit indices in this cluster so we can make associations
144  hitsinclus.push_back(ihit);
145  used[ihit] = 1;
146 
147  int side=0; // detector side of the seed hit.
148  auto hitchan = hits.at(ihit).Channel();
149  float chanpos[3] = {0,0,0};
150  euclid->ChannelToPosition(hitchan, chanpos);
151  if (chanpos[0] > xtpccent)
152  {
153  side = 1;
154  }
155  else
156  {
157  side = -1;
158  }
159 
160  // Clusters can be displaced in time. We may want to save which end of the
161  // chamber the data came from however and not cluster together charge
162  // that comes from different sides.
163 
164  if (fPrintLevel > 1)
165  {
166  std::cout << "Started a new TPC cluster. Pos= " << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;
167  std::cout << "Side: " << side << std::endl;
168  }
169 
170  // Determine cluster position in endcap for cuts to accumulate more hits
171  float rHit = std::hypot(xyz[1],xyz[2]);
172  bool In_CROC = rHit < euclid->GetIROCInnerRadius();
173  bool In_IROC = euclid->GetIROCInnerRadius() < rHit && rHit < euclid->GetIROCOuterRadius();
174  bool InIOROC = euclid->GetOROCInnerRadius() < rHit && rHit < euclid->GetOROCPadHeightChangeRadius();
175  bool InOOROC = euclid->GetOROCPadHeightChangeRadius() < rHit && rHit < euclid->GetOROCOuterRadius();
176 
177  for (size_t ix = ihitx+1; ix<nhits; ++ix) // look for candidate hits to cluster in with this one
178  {
179  size_t ihc = hsi[ix]; // candidate hit to add to the cluster if it's in range
180  if (used[ihc]) continue;
181 
182  int sidetest = 0;
183  auto hitchantest = hits.at(ihc).Channel();
184  float chanpostest[3] = {0,0,0};
185  euclid->ChannelToPosition(hitchantest, chanpostest);
186  if (chanpostest[0] > xtpccent)
187  {
188  sidetest = 1;
189  }
190  else
191  {
192  sidetest = -1;
193  }
194  if (sidetest != side) continue; // don't cluster hits that were detected on opposite TPC endplates.
195 
196  const float *xyz2_fromhit = hits.at(ihc).Position();
197  float xyz2[3] = {xyz2_fromhit[0] -xtpccent, xyz2_fromhit[1] -ytpccent, xyz2_fromhit[2] -ztpccent};
198 
199  if (fPrintLevel > 1)
200  {
201  std::cout << " Testing a hit: " << xyz2[0] << " " << xyz2[1] << " " << xyz2[2] << " " << sidetest << " "
202  << used[ihc] << " " << ihc << " " << ix << std::endl;
203  }
204 
205  // Check if hit ix is close to ihit, first in drift direction, then
206  // in transverse plane depending on which ROC has ihit
207  if ( fabs(xyz2[0] -xyz[0]) > fHitClusterDx ) break;
208 
209  if (In_CROC) {
210  if ( fabs(xyz2[1] -xyz[1]) > fHitClusterDyDz ) continue;
211  if ( fabs(xyz2[2] -xyz[2]) > fHitClusterDyDz ) continue;
212  }
213  // Project out the radial and rotational components of xyz2 -xyz.
214  float RhatY = xyz[1]/std::hypot(xyz[1],xyz[2]);
215  float RhatZ = xyz[2]/std::hypot(xyz[1],xyz[2]);
216  float clustDist = std::hypot(xyz2[1] -xyz[1],xyz2[2] -xyz[2]);
217  float dR = TMath::Abs((xyz2[1] -xyz[1])*RhatY +(xyz2[2] -xyz[2])*RhatZ);
218  float Rdfi = sqrt(clustDist*clustDist -dR*dR);
219  if (In_IROC) {
220  if (dR > fHitClusterDr_I) continue;
221  if (Rdfi > fHitClusterDfi_I) continue;
222  }
223  if (InIOROC) {
224  if (dR > fHitClusterDrIO) continue;
225  if (Rdfi > fHitClusterDfiIO) continue;
226  }
227  if (InOOROC) {
228  if (dR > fHitClusterDrOO) continue;
229  if (Rdfi > fHitClusterDfiOO) continue;
230  }
231 
232  // add hit to cluster
233  hitsinclus.push_back(ihc);
234  used[ihc] = 1;
235  if (fPrintLevel > 1)
236  {
237  std::cout << "Added hit with pos: " << xyz2[0] << " " << xyz2[1] << " " << xyz2[2] << std::endl;
238  }
239 
240  }
241 
242  // calculate cluster charge, centroid, min and max times, and covariance
243 
244  double cpos[3] = {0,0,0}; // charge-weighted cluster position
245  double csig = 0; // cluster signal total
246  double cstime = 0; // cluster start time
247  double cetime = 0; // cluster end time
248  double crms = 0; // cluster RMS in X
249  double ctime = 0; // cluster time centroid
250  double cov[3][3] = { {0,0,0}, {0,0,0}, {0,0,0} };
251 
252  for (size_t ix = 0; ix < hitsinclus.size(); ++ix)
253  {
254  size_t ihx = hitsinclus.at(ix);
255  double hsig = hits.at(ihx).Signal();
256  csig += hsig;
257  for (size_t idim=0; idim<3; ++idim)
258  {
259  cpos[idim] += hsig * hits.at(ihx).Position()[idim];
260  }
261  ctime += hsig * hits.at(ihx).Time();
262  if (ix == 0)
263  {
264  cstime = hits.at(ihx).StartTime();
265  cetime = hits.at(ihx).EndTime();
266  }
267  else
268  {
269  cstime = TMath::Min(cstime, (double) hits.at(ihx).StartTime());
270  cetime = TMath::Max(cetime, (double) hits.at(ihx).EndTime());
271  }
272  }
273  if (csig != 0)
274  {
275  ctime /= csig;
276  for (size_t idim=0; idim<3; ++idim)
277  {
278  cpos[idim] /= csig;
279  }
280 
281  // calculate covariance. Do a numerical sum over hit widths assuming Gaussians.
282 
283  for (size_t ix = 0; ix < hitsinclus.size(); ++ix)
284  {
285  size_t ihx = hitsinclus.at(ix);
286  double cfrac = hits.at(ihx).Signal()/csig;
287  const float *hpos = hits.at(ihx).Position();
288  for (size_t idim=0; idim<3; ++idim)
289  {
290  for (size_t jdim=0; jdim<3; ++jdim)
291  {
292  cov[idim][jdim] += cfrac*(hpos[idim]-cpos[idim])*(hpos[jdim]-cpos[jdim]);
293  }
294  }
295  cov[0][0] += cfrac*TMath::Sq(hits.at(ihx).RMS());
296  }
297  }
298  crms = TMath::Sqrt(cov[0][0]); // to mean what it meant before -- RMS along the drift direction
299 
300  float fcpos[3] = {0,0,0};
301  for (int i=0;i<3;++i)
302  {
303  fcpos[i] = cpos[i];
304  }
305  float fccov[6] = {(float) cov[0][0], (float) cov[1][0], (float) cov[2][0],
306  (float) cov[1][1], (float) cov[1][2], (float) cov[2][2]};
307 
308  TPCClusterCol->emplace_back(csig,
309  fcpos,
310  cstime,
311  cetime,
312  ctime,
313  crms,
314  fccov);
315 
316  if (fPrintLevel > 0)
317  {
318  std::cout << "Made a TPC Cluster pos: " << fcpos[0] << " " << fcpos[1] << " " << fcpos[2] <<
319  " signal: " << csig << " nHits: " << hitsinclus.size() << std::endl;
320  }
321  auto const TPCClusterPointer = TPCClusterPtrMaker(TPCClusterCol->size()-1);
322  for (size_t i=0; i<hitsinclus.size(); ++i)
323  {
324  auto const HitPointer = hitPtrMaker(hitsinclus.at(i));
325  hitClusterAssns->addSingle(HitPointer,TPCClusterPointer);
326  }
327 
328  }
329 
330  e.put(std::move(TPCClusterCol));
331  e.put(std::move(hitClusterAssns));
332 
333  }
float fHitClusterDyDz
range in cm to look for hits to cluster in y and z
float fHitClusterDr_I
range in R to look for hits to cluster for IROC, in cm
std::string fHitLabel
label of module to get the hits from
float fHitClusterDrOO
range in R to look for hits to cluster for OOROC, in cm
float fHitClusterDfi_I
range in R*dPhi to look for hits to cluster for IROC, in cm
std::enable_if_t< std::is_arithmetic_v< T >, T > hypot(T x, T y)
Definition: hypot.h:60
const double e
float fHitClusterDx
range in cm to look for hits to cluster in x
float fHitClusterDfiIO
range in R*dPhi to look for hits to cluster for IROC, in cm
float fHitClusterDrIO
range in R to look for hits to cluster for IOROC, in cm
def move(depos, offset)
Definition: depos.py:107
float fHitClusterDfiOO
range in R*dPhi to look for hits to cluster for IROC, in cm
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
Definition: DataViewImpl.h:441
int fPrintLevel
debug printout: 0: none, 1: selected, 2: all
if(!yymsg) yymsg
QTextStream & endl(QTextStream &s)

Member Data Documentation

int gar::rec::TPCHitCluster::fClusterHits
private

hit clustering algorithm number

Definition at line 53 of file TPCHitCluster_module.cc.

float gar::rec::TPCHitCluster::fHitClusterDfi_I
private

range in R*dPhi to look for hits to cluster for IROC, in cm

Definition at line 58 of file TPCHitCluster_module.cc.

float gar::rec::TPCHitCluster::fHitClusterDfiIO
private

range in R*dPhi to look for hits to cluster for IROC, in cm

Definition at line 60 of file TPCHitCluster_module.cc.

float gar::rec::TPCHitCluster::fHitClusterDfiOO
private

range in R*dPhi to look for hits to cluster for IROC, in cm

Definition at line 62 of file TPCHitCluster_module.cc.

float gar::rec::TPCHitCluster::fHitClusterDr_I
private

range in R to look for hits to cluster for IROC, in cm

Definition at line 57 of file TPCHitCluster_module.cc.

float gar::rec::TPCHitCluster::fHitClusterDrIO
private

range in R to look for hits to cluster for IOROC, in cm

Definition at line 59 of file TPCHitCluster_module.cc.

float gar::rec::TPCHitCluster::fHitClusterDrOO
private

range in R to look for hits to cluster for OOROC, in cm

Definition at line 61 of file TPCHitCluster_module.cc.

float gar::rec::TPCHitCluster::fHitClusterDx
private

range in cm to look for hits to cluster in x

Definition at line 54 of file TPCHitCluster_module.cc.

float gar::rec::TPCHitCluster::fHitClusterDyDz
private

range in cm to look for hits to cluster in y and z

Definition at line 55 of file TPCHitCluster_module.cc.

std::string gar::rec::TPCHitCluster::fHitLabel
private

label of module to get the hits from

Definition at line 52 of file TPCHitCluster_module.cc.

int gar::rec::TPCHitCluster::fPrintLevel
private

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

Definition at line 64 of file TPCHitCluster_module.cc.


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