Public Member Functions | Private Attributes | List of all members
GoodWireAna Class Reference
Inheritance diagram for GoodWireAna:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Public Member Functions

 GoodWireAna (fhicl::ParameterSet const &p)
 
 GoodWireAna (GoodWireAna const &)=delete
 
 GoodWireAna (GoodWireAna &&)=delete
 
GoodWireAnaoperator= (GoodWireAna const &)=delete
 
GoodWireAnaoperator= (GoodWireAna &&)=delete
 
void analyze (art::Event const &e) override
 
void beginJob () override
 
void beginRun (art::Run const &r) override
 
void beginSubRun (art::SubRun const &sr) override
 
void endJob () override
 
void endRun (art::Run const &r) override
 
void endSubRun (art::SubRun const &sr) override
 
void reconfigure (fhicl::ParameterSet const &p)
 
void respondToCloseInputFile (art::FileBlock const &fb) override
 
void respondToCloseOutputFiles (art::FileBlock const &fb) override
 
void respondToOpenInputFile (art::FileBlock const &fb) override
 
void respondToOpenOutputFiles (art::FileBlock const &fb) override
 
void makeHistoSetForThisRun (int runID)
 
void writeListOfDeadWires ()
 
void fillHitOccDistHists (std::vector< std::vector< size_t > > &badWireVect)
 
void fitHitOccDistHists (std::vector< std::vector< size_t > > &badWireList, std::vector< std::vector< size_t > > &goodWireList)
 
void writeListOfBadWires (std::vector< std::vector< size_t > > badWireVect)
 
void writeListOfGoodWires (std::vector< std::vector< size_t > > goodWireVect)
 
void runDiagnostics (std::map< size_t, std::map< size_t, bool > > runToBadChannelMap)
 
void findRepeatingWireCutoff ()
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
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::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- 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::map< int, std::map< std::pair< size_t, size_t >, std::vector< TH1D * > > > fRunToCryTPCToPlaneMap
 
std::map< int, std::map< std::pair< size_t, size_t >, std::vector< TH1D * > > > fRunToCryTPCToPlaneMapDist
 
geo::GeometryfGeometry
 pointer to the Geometry service More...
 
art::TFileService * fTFS
 
size_t fNCry
 
std::string fHitModuleLabel
 
float fNSigmaGoodWireHigh
 
float fNSigmaGoodWireLow
 
double fHitOccLimit
 
size_t fNBinsDist
 
double fQuietWireFactor
 
size_t fHitLimitPerWirePerEventEvenTPC
 
size_t fHitLimitPerWirePerEventOddTPC
 
std::map< int, size_t > fNEvtsPerRun
 
bool fVerbose
 
bool fOnlyWriteCollectionPlane
 
std::map< size_t, size_t > fUPlaneRepeatingWireStart
 
std::map< size_t, size_t > fVPlaneRepeatingWireStart
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- 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 37 of file GoodWireAna_module.cc.

Constructor & Destructor Documentation

GoodWireAna::GoodWireAna ( fhicl::ParameterSet const &  p)
explicit

Definition at line 125 of file GoodWireAna_module.cc.

126  :
127  EDAnalyzer(pset) // ,
128  // More initializers here.
129 {
130 
131  std::cout << "GoodWireAna Constructor called." << std::endl;
132 
133 
134  //Setting geometry info
136  fGeometry = &*geometry;
138 
139  //TFile Service
141  fTFS = &*tfs;
142 
143 
144 
145  //Reconfigure to set the data members
146  this->reconfigure(pset);
147 
148  //Now we need to build our map telling us where the wires in the U and V planes start to repeat
150 
151 
152 }
art::TFileService * fTFS
void reconfigure(fhicl::ParameterSet const &p)
EDAnalyzer(fhicl::ParameterSet const &pset)
Definition: EDAnalyzer.h:25
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
geo::Geometry * fGeometry
pointer to the Geometry service
void findRepeatingWireCutoff()
QTextStream & endl(QTextStream &s)
GoodWireAna::GoodWireAna ( GoodWireAna const &  )
delete
GoodWireAna::GoodWireAna ( GoodWireAna &&  )
delete

Member Function Documentation

void GoodWireAna::analyze ( art::Event const &  e)
overridevirtual

Implements art::EDAnalyzer.

Definition at line 158 of file GoodWireAna_module.cc.

159 {
160 
161  // Implementation of required member function here.
162  std::cout << "Analyze starting." << std::endl;
163 
164  //Check to see if this is a new run. If it is, then make a new set of histos
165  if( !fRunToCryTPCToPlaneMap.count(e.run()) ) makeHistoSetForThisRun(e.run());
166 
167  //Increment nEvents for this run
168  if( fNEvtsPerRun.count(e.run()) ) fNEvtsPerRun.at(e.run())++;
169  else{ fNEvtsPerRun.emplace(e.run(),1); }
170 
171  //Now get all a da hits from this event
172  auto hitListHandle = e.getHandle<std::vector<recob::Hit> >(fHitModuleLabel);
173 
174  //Loop over the hits. Find their Cryo/TPC, plane, and fill the appropriate histogram
175  //labeled by those three things.
176  for( size_t iHit = 0; iHit < hitListHandle->size(); ++iHit ){
177 
178  //Get the hit
179  recob::Hit theHit = hitListHandle->at(iHit);
180 
181  //Get hit info
182  size_t iCry = theHit.WireID().Cryostat;
183  size_t iTPC = theHit.WireID().TPC;
184  size_t iPlane = theHit.WireID().Plane;
185  size_t iWire = theHit.WireID().Wire;
186 
187 
188  //Make the pair for Cryostat/TPC
189  std::pair<size_t,size_t> CryTPCPair( iCry,iTPC );
190 
191  //Now fill the appropriate histogram
192  fRunToCryTPCToPlaneMap.at( e.run() ).at( CryTPCPair ).at(iPlane)->Fill(iWire);
193 
194 
195 
196  }
197 
198 
199 }
geo::WireID WireID() const
Definition: Hit.h:233
CryostatID_t Cryostat
Index of cryostat.
Definition: geo_types.h:212
WireID_t Wire
Index of the wire within its plane.
Definition: geo_types.h:580
const double e
PlaneID_t Plane
Index of the plane within its TPC.
Definition: geo_types.h:493
void makeHistoSetForThisRun(int runID)
2D representation of charge deposited in the TDC/wire plane
Definition: Hit.h:48
std::map< int, size_t > fNEvtsPerRun
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
std::map< int, std::map< std::pair< size_t, size_t >, std::vector< TH1D * > > > fRunToCryTPCToPlaneMap
QTextStream & endl(QTextStream &s)
std::string fHitModuleLabel
void GoodWireAna::beginJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 998 of file GoodWireAna_module.cc.

999 {
1000  std::cout << "GoodWireAna beginJob called." << std::endl;
1001  /*
1002  //Setting geometry info
1003  art::ServiceHandle<geo::Geometry> geometry;
1004  fGeometry = &*geometry;
1005  fNCry = fGeometry->Ncryostats();
1006 
1007  //TFile Service
1008  art::ServiceHandle<art::TFileService> tfs;
1009  fTFS = &*tfs;
1010 
1011  //Geometry Helper
1012  art::ServiceHandle<dune::DUNEGeometryHelper> geometryHelper;
1013  */
1014 
1015 }
QTextStream & endl(QTextStream &s)
void GoodWireAna::beginRun ( art::Run const &  r)
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 1017 of file GoodWireAna_module.cc.

1018 {
1019  // Implementation of optional member function here.
1020  std::cout << "GoodWireAna beginRun called." << std::endl;
1021 
1022 }
QTextStream & endl(QTextStream &s)
void GoodWireAna::beginSubRun ( art::SubRun const &  sr)
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 1024 of file GoodWireAna_module.cc.

1025 {
1026  // Implementation of optional member function here.
1027 }
void GoodWireAna::endJob ( )
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 1034 of file GoodWireAna_module.cc.

1035 {
1036  if( fVerbose )
1037  std::cout << "EndJob reached." << std::endl;
1038 
1039  std::cout << "EndJob Reached." << std::endl;
1040 
1041 
1042  //Fill Occupancy Distribution histograms
1043  std::vector<std::vector<size_t> > badWireVect;
1044  std::vector<std::vector<size_t> > goodWireVect;
1045  if( fVerbose )
1046  std::cout << "Filling." << std::endl;
1047  fillHitOccDistHists(badWireVect);
1048 
1049  //Fit those histograms and return a set of bad hits
1050  if( fVerbose )
1051  std::cout << "Fitting." << std::endl;
1052  fitHitOccDistHists(badWireVect,goodWireVect);
1053 
1054  //Bad Wire Handling
1055  if( fVerbose )
1056  std::cout << "Writing Bad." << std::endl;
1057  writeListOfBadWires(badWireVect);
1058 
1059  //Good Wire Handling
1060  if( fVerbose )
1061  std::cout << "Writing Good." << std::endl;
1062  writeListOfGoodWires(goodWireVect);
1063 
1064  //Dead wire handling (wires with zero signal)
1065  // writeListOfDeadWires();
1066 
1067  //Bad wire handling (wires with noisy signal)
1068  // writeListOfNoisyWires();
1069 
1070 
1071 
1072 }
void writeListOfBadWires(std::vector< std::vector< size_t > > badWireVect)
void fitHitOccDistHists(std::vector< std::vector< size_t > > &badWireList, std::vector< std::vector< size_t > > &goodWireList)
void fillHitOccDistHists(std::vector< std::vector< size_t > > &badWireVect)
void writeListOfGoodWires(std::vector< std::vector< size_t > > goodWireVect)
QTextStream & endl(QTextStream &s)
void GoodWireAna::endRun ( art::Run const &  r)
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 1074 of file GoodWireAna_module.cc.

1075 {
1076  // Implementation of optional member function here.
1077 }
void GoodWireAna::endSubRun ( art::SubRun const &  sr)
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 1079 of file GoodWireAna_module.cc.

1080 {
1081  // Implementation of optional member function here.
1082 }
void GoodWireAna::fillHitOccDistHists ( std::vector< std::vector< size_t > > &  badWireVect)

Definition at line 392 of file GoodWireAna_module.cc.

393 {
394  //To do the induction planes, we modify a little bit. We know that there is redundancy
395  //in the induction wires, so that not all wires in a given plane are unique. To fix this
396  //problem, we consider the following fact for a pair of back-to-back TPCs. The wires from
397  //the U-plane of one of the TPCs wrap around to the U-plane of the other TPC, so to get
398  //all of the unique channels' signals, we just need to look at the wires of ONE of the
399  //back to back TPCs. We thus consider only the odd TPCs here for the U and V planes, and
400  //loop through the wires until we start having repetition in channel number.
401 
402 
403  //Loop through each run
404  for( std::map<int,std::map<std::pair<size_t,size_t>,std::vector<TH1D*> > >::iterator iter = fRunToCryTPCToPlaneMap.begin(); iter != fRunToCryTPCToPlaneMap.end(); ++iter ){
405 
406  //Basic info
407  int runID = iter->first;
408 
409  //Loop over the Cry/TPCs
410  for( std::map<std::pair<size_t,size_t>,std::vector<TH1D*> >::iterator iterCryTPC = iter->second.begin(); iterCryTPC != iter->second.end(); ++iterCryTPC ){
411 
412  //Get the TPC/Plane pair
413  std::pair<size_t,size_t> CryTPCPair = iterCryTPC->first;
414 
415  //Get the plane wire occupancy histograms corresponding to this pair
416  std::vector<TH1D*> planeHistos = iterCryTPC->second;
417 
418  //Loop over these histograms
419  for( size_t iPlane = 0; iPlane < planeHistos.size(); ++iPlane ){
420 
421  //If the plane is U or V, then only do the following for odd-TPC numbers
422  size_t repetitionStartWire = 9999;
423  if( iPlane == 0 || iPlane == 1 ){
424  if( CryTPCPair.second % 2 == 0 ) continue;
425 
426  //Furthermore, if the plane is U or V, then find the bin where channel repetition begins and only fill with wires up to there
427  if( iPlane == 0 )
428  repetitionStartWire = fUPlaneRepeatingWireStart.at(CryTPCPair.second);
429  if( iPlane == 1 )
430  repetitionStartWire = fVPlaneRepeatingWireStart.at(CryTPCPair.second);
431 
432  }
433 
434 
435 
436  //Get the histogram for this plane and loop over its bins
437  TH1D * thisPlaneHist = planeHistos.at(iPlane);
438  for( int iBin = 1; iBin <= thisPlaneHist->GetNbinsX(); ++iBin ){
439 
440  if( size_t(iBin)-1 == repetitionStartWire ) break;
441 
442  if( fVerbose )
443  std::cout << "BinID: " << iBin << ", binContent: " << thisPlaneHist->GetBinContent(iBin) << std::endl;
444 
445  //Get the bin occupancy and increment the correct dist histogram in the corresponding bin
446  int binContent = thisPlaneHist->GetBinContent(iBin);
447 
448  //If the bin content is too large (way larger than some reasonable expected value), then don't push
449  //it back into the distribution. This prevents us from having all of the good wires' occupancies fill
450  //a single bin.
451  //if( iPlane == 2 ) fHitOccLimit = fNEvtsPerRun.at(runID)*fHitLimitPerWirePerEventCol; //Messup - was here earlier
452  //if( iPlane != 2 ) fHitOccLimit = fNEvtsPerRun.at(runID)*fHitLimitPerWirePerEventInd;
453  if( CryTPCPair.second % 2 == 0 ) fHitOccLimit = fNEvtsPerRun.at(runID)*fHitLimitPerWirePerEventEvenTPC;
454  if( CryTPCPair.second % 2 == 1 ) fHitOccLimit = fNEvtsPerRun.at(runID)*fHitLimitPerWirePerEventOddTPC;
455 
456 
457  if( binContent > fHitOccLimit ){
458  if( fVerbose )
459  std::cout << "Not filling occupancy distributions with this wire - it's waaaay too big of an outlier on the high side." << std::endl;
460  }
461 
462  //Also, if the bin content is zero, then don't push it back into the distribution. We know that
463  //this is a dead wire.
464  else if( binContent == 0 ){
465  if( fVerbose )
466  std::cout << "Not filling occupancy distributions with this wire - it's waaaay too big of an outlier on the low side." << std::endl;
467  }
468 
469  else{
470  fRunToCryTPCToPlaneMapDist.at(runID).at(CryTPCPair).at(iPlane)->Fill(binContent);
471  }
472  }
473  }
474  }
475  }
476 }
size_t fHitLimitPerWirePerEventOddTPC
std::map< size_t, size_t > fVPlaneRepeatingWireStart
std::map< size_t, size_t > fUPlaneRepeatingWireStart
size_t fHitLimitPerWirePerEventEvenTPC
std::map< int, std::map< std::pair< size_t, size_t >, std::vector< TH1D * > > > fRunToCryTPCToPlaneMapDist
std::map< int, size_t > fNEvtsPerRun
std::map< int, std::map< std::pair< size_t, size_t >, std::vector< TH1D * > > > fRunToCryTPCToPlaneMap
QTextStream & endl(QTextStream &s)
void GoodWireAna::findRepeatingWireCutoff ( )

Definition at line 939 of file GoodWireAna_module.cc.

940 {
941  //We want to find the points at which the wires in each U/V plane start "repeating" so that
942  //later, we can stop filling our occupancy histograms at this point
943 
944  //Loop over TPCs
945  size_t iCry = 0;
946  size_t nTPCs = fGeometry->NTPC(iCry);
947  size_t nPlanes = 3;
948 
949  for( size_t iTPC = 0; iTPC < nTPCs; ++iTPC ){
950 
951  //Loop over planes
952  for( size_t iPlane = 0; iPlane < nPlanes; ++iPlane ){
953 
954  //Select the correct plane
955  if( iPlane == 2 ) continue;
956  std::map<size_t,size_t> tempMap;
957  size_t theFinalWire = 0;
958 
959  //Loop over wires
960  for( size_t iWire = 0; iWire < fGeometry->Nwires(iPlane,iTPC,iCry); ++iWire ){
961 
962  //Construct the wireID
963  geo::WireID theWireID( iCry, iTPC, iPlane, iWire );
964 
965  //Get the channel corresponding to this wire
966  size_t channel = fGeometry->PlaneWireToChannel(theWireID);
967 
968  //If the channel has been found already, then return false. There's now repetition
969  if( tempMap.count(channel) == 1 ){
970  theFinalWire = iWire;
971  break;
972  }
973 
974  //Otherwise, push back the tempMap
975  tempMap.emplace(channel,true);
976 
977  }
978 
979  //Now take the final Wire and push it into the correct persistent map
980  if( iPlane == 0 )
981  fUPlaneRepeatingWireStart.emplace(iTPC,theFinalWire);
982  if( iPlane == 1 )
983  fVPlaneRepeatingWireStart.emplace(iTPC,theFinalWire);
984 
985  //Just for kicks and gigabytes, let's print.
986  std::cout << "TheFinalWire: TPC/Plane/Wire: " << iTPC << "/" << iPlane << "/" << theFinalWire << std::endl;
987 
988  }
989 
990  }
991 
992  //Now we have this filled and can use it later.
993 
994 }
uint8_t channel
Definition: CRTFragment.hh:201
std::map< size_t, size_t > fVPlaneRepeatingWireStart
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
std::map< size_t, size_t > fUPlaneRepeatingWireStart
geo::Geometry * fGeometry
pointer to the Geometry service
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
QTextStream & endl(QTextStream &s)
void GoodWireAna::fitHitOccDistHists ( std::vector< std::vector< size_t > > &  badWireList,
std::vector< std::vector< size_t > > &  goodWireList 
)

Definition at line 483 of file GoodWireAna_module.cc.

484 {
485  //Loop through each run
486  for( std::map<int,std::map<std::pair<size_t,size_t>,std::vector<TH1D*> > >::iterator iter = fRunToCryTPCToPlaneMapDist.begin(); iter != fRunToCryTPCToPlaneMapDist.end(); ++iter ){
487 
488  //Basic info
489  int runID = iter->first;
490 
491  //Loop over the Cry/TPCs
492  for( std::map<std::pair<size_t,size_t>,std::vector<TH1D*> >::iterator iterCryTPC = iter->second.begin(); iterCryTPC != iter->second.end(); ++iterCryTPC ){
493 
494  //Get the TPC/Plane pair
495  std::pair<size_t,size_t> CryTPCPair = iterCryTPC->first;
496 
497  //Get the plane wire occupancy histograms corresponding to this pair
498  std::vector<TH1D*> planeHistos = iterCryTPC->second;
499 
500  //Loop over these histograms
501  for( size_t iPlane = 0; iPlane < planeHistos.size(); ++iPlane ){
502 
503  //If you're looking at an induction plane, then only consider Odd-# TPCs
504  if( iPlane != 2 ){
505  if( CryTPCPair.second % 2 == 0 ) continue;
506  }
507 
508 
509 
510  //Get the histogram for this plane and loop over its bins
511  TH1D * thisPlaneHist = planeHistos.at(iPlane);
512 
513  //If this histogram is unfilled, note that all wires are dead, and then
514  //continue. Otherwise we get segfaults
515  TH1D * occupancyHist = fRunToCryTPCToPlaneMap.at(runID).at(CryTPCPair).at(iPlane);
516  if( thisPlaneHist->Integral() == 0 ){
517  for( int iBin = 1; iBin <= occupancyHist->GetNbinsX(); ++iBin ){
518 
519  //Have to account for the induction planes and their wrapped wires...
520  size_t repetitionStartWire = 9999;
521  if( iPlane == 0 )
522  repetitionStartWire = fUPlaneRepeatingWireStart.at(CryTPCPair.second);
523  if( iPlane == 1 )
524  repetitionStartWire = fVPlaneRepeatingWireStart.at(CryTPCPair.second);
525  if( iPlane == 0 || iPlane == 1 ){
526  if( size_t(iBin)-1 == repetitionStartWire ) break;
527  }
528 
529 
530 
531  if( fVerbose )
532  std::cout << "Adding badwirevect to completely dead plane." << std::endl;
533  std::vector<size_t> theBadWire;
534 
535  //Fill the bad wire vector with information about the wire (pointing to it)
536  theBadWire.push_back(runID);
537  theBadWire.push_back(CryTPCPair.first);
538  theBadWire.push_back(CryTPCPair.second);
539  theBadWire.push_back(iPlane);
540  theBadWire.push_back(iBin);
541  theBadWire.push_back(0); //Tag wire as noisy
542 
543  //Now push the bad wire back into the bad wire vect
544  badWireList.push_back(theBadWire);
545  }
546  continue;
547 
548 
549  }
550  //Define fitting parameters and provide initial estimates
551  //based on the plane type
552  double gaus_mean = 0;
553  double gaus_sigma = 0;
554  // double gaus_amplitude = 0;
555 
556  /*
557  if( iPlane == 2 ){
558  gaus_mean = fInitGausMeanCol;
559  gaus_sigma = fInitGauSigmaCol;
560  gaus_amp = fInitGausAmpCol;
561  }
562  else{
563  gaus_mean = fInitGausMeanInd;
564  gaus_sigma = fInitGausSigmaInd;
565  gaus_amp = fInitGausAmpInd;
566  }
567 
568  TF1 f1("f1","gaus");
569  f1->SetParameters( gaus_amp, gaus_mean, gaus_sigma );
570  */
571 
572  //Fit the histogram
573  thisPlaneHist->Fit("gaus","0");
574  TF1* fit1 = (TF1*)thisPlaneHist->GetFunction("gaus");
575 
576 
577  //Get the parameters
578  gaus_mean = fit1->GetParameter(1);
579  gaus_sigma = fit1->GetParameter(2);
580  // gaus_amplitude = fit1->GetParameter(0);
581 
582  //Print parameters
583  if( fVerbose )
584  std::cout << "Fit Parameters, r" << runID << "tpc" << CryTPCPair.second << "plane" << iPlane << ": mean: " << gaus_mean << ", sigma: " << gaus_sigma << std::endl;
585 
586 
587  //Now loop through the hit occupancy histogram and find wires that
588  //are outside of the mean + n sigma. Get the appropriate histo first.
589 
590  //For the induction planes, we also look for where there is a "fault" in the channel number.
591  //This corresponds to adjacent wires that have nonadjacent channel numbers. Once the fault has been
592  //found, we stop the loop. This allows us to restrict our attention to the first, "real" wires for
593  //a given induction plane.
594  // bool channelFault = false;
595  size_t repetitionStartWire = 9999;
596  for( int iBin = 1; iBin <= occupancyHist->GetNbinsX(); ++iBin ){
597 
598  //If we're working with induction planes, make sure to only go as far
599  //as the wires don't repeat.
600  if( iPlane == 0 )
601  repetitionStartWire = fUPlaneRepeatingWireStart.at(CryTPCPair.second);
602  if( iPlane == 1 )
603  repetitionStartWire = fVPlaneRepeatingWireStart.at(CryTPCPair.second);
604  if( iPlane == 0 || iPlane == 1 ){
605  if( size_t(iBin)-1 == repetitionStartWire ) break;
606  }
607 
608 
609 
610 
611  //Consider only induction planes for a moment
612  /*
613  if( iPlane == 0 || iPlane == 1 ){
614 
615  //Breaking if we found the channel fault on the previous loop
616  // if( channelFault == true )break;
617 
618  //Searching for the channel fault
619  geo::WireID theWireID( CryTPCPair.first, CryTPCPair.second, iPlane, iBin-1 );
620  size_t channel = fGeometry->PlaneWireToChannel(theWireID);
621  geo::WireID theNextWireID( CryTPCPair.first, CryTPCPair.second, iPlane, iBin );
622  size_t nextChannel = fGeometry->PlaneWireToChannel(theNextWireID);
623  if( abs(nextChannel-channel) != 1 ){
624  std::cout << "Found the fault at wire: " << iBin-1 << std::endl;
625  // channelFault = true;
626  }
627  }
628  */
629 
630 
631  if( fVerbose )
632  std::cout << "Bin #" << iBin << ", occupancy: " << occupancyHist->GetBinContent(iBin) << std::endl;
633 
634  //Setting hit occupancy reasonable limits as before
635  if( CryTPCPair.second % 2 == 0 ) fHitOccLimit = fNEvtsPerRun.at(runID)*fHitLimitPerWirePerEventEvenTPC;
636  if( CryTPCPair.second % 2 == 1 ) fHitOccLimit = fNEvtsPerRun.at(runID)*fHitLimitPerWirePerEventOddTPC;
637  // if( iPlane == 2 ) fHitOccLimit = fNEvtsPerRun.at(runID)*fHitLimitPerWirePerEventCol;
638  //if( iPlane != 2 ) fHitOccLimit = fNEvtsPerRun.at(runID)*fHitLimitPerWirePerEventInd;
639  if( occupancyHist->GetBinContent(iBin) > fHitOccLimit ){
640  if( fVerbose )
641  std::cout << "Adding badwirevect." << std::endl;
642  std::vector<size_t> theBadWire;
643 
644  //Fill the bad wire vector with information about the wire (pointing to it)
645  theBadWire.push_back(runID);
646  theBadWire.push_back(CryTPCPair.first);
647  theBadWire.push_back(CryTPCPair.second);
648  theBadWire.push_back(iPlane);
649  theBadWire.push_back(iBin);
650  theBadWire.push_back(2); //Tag wire as noisy
651 
652  //Now push the bad wire back into the bad wire vect
653  badWireList.push_back(theBadWire);
654 
655  }
656 
657  //Also, if the bin content is zero, then don't push it back into the distribution. We know that
658  //this is a dead wire.
659  else if( occupancyHist->GetBinContent(iBin) == 0 ){
660  if( fVerbose )
661  std::cout << "Adding badwirevect." << std::endl;
662  std::vector<size_t> theBadWire;
663 
664  //Fill the bad wire vector with information about the wire (pointing to it)
665  theBadWire.push_back(runID);
666  theBadWire.push_back(CryTPCPair.first);
667  theBadWire.push_back(CryTPCPair.second);
668  theBadWire.push_back(iPlane);
669  theBadWire.push_back(iBin);
670  theBadWire.push_back(0); //Tag wire as dead
671 
672  //Now push the bad wire back into the bad wire vect
673  badWireList.push_back(theBadWire);
674  }
675 
676  else if( float(occupancyHist->GetBinContent(iBin))-(gaus_mean) > gaus_sigma*fNSigmaGoodWireHigh){ // ||
677  // (gaus_mean)-float(occupancyHist->GetBinContent(iBin)) > gaus_sigma*fNSigmaGoodWireLow ){
678  if( fVerbose )
679  std::cout << "Adding badwirevect." << std::endl;
680  std::vector<size_t> theBadWire;
681 
682  //Fill the bad wire vector with information about the wire (pointing to it)
683  theBadWire.push_back(runID);
684  theBadWire.push_back(CryTPCPair.first);
685  theBadWire.push_back(CryTPCPair.second);
686  theBadWire.push_back(iPlane);
687  theBadWire.push_back(iBin);
688 
689  //Now tag wires as either being dead (0), quiet (1) or noisy (2)
690  if( float(occupancyHist->GetBinContent(iBin)) < gaus_mean ){theBadWire.push_back(1); }
691  else{ theBadWire.push_back(2); }
692 
693  badWireList.push_back(theBadWire);
694  }
695 
696  //Now do quiet wire cuts
697  else if( float(occupancyHist->GetBinContent(iBin)) < fQuietWireFactor*(gaus_mean) ){
698  if( fVerbose )
699  std::cout << "Adding badwirevect." << std::endl;
700  std::vector<size_t> theBadWire;
701 
702  //Fill the bad wire vector with information about the wire (pointing to it)
703  theBadWire.push_back(runID);
704  theBadWire.push_back(CryTPCPair.first);
705  theBadWire.push_back(CryTPCPair.second);
706  theBadWire.push_back(iPlane);
707  theBadWire.push_back(iBin);
708  theBadWire.push_back(1);
709  badWireList.push_back(theBadWire);
710  }
711 
712  else{
713  std::vector<size_t> theGoodWire;
714 
715  //Fill the good wire vector with information about the wire (pointing to it)
716  theGoodWire.push_back(runID);
717  theGoodWire.push_back(CryTPCPair.first);
718  theGoodWire.push_back(CryTPCPair.second);
719  theGoodWire.push_back(iPlane);
720  theGoodWire.push_back(iBin);
721 
722  goodWireList.push_back(theGoodWire);
723 
724  if( fVerbose )
725  std::cout << "GoodWire run/TPC/Plane/Bin: " << runID << "/" << CryTPCPair.second << "/" << iPlane << "/" << iBin << std::endl;
726  }
727  }
728  }
729  }
730  }
731 }
size_t fHitLimitPerWirePerEventOddTPC
std::map< size_t, size_t > fVPlaneRepeatingWireStart
std::map< size_t, size_t > fUPlaneRepeatingWireStart
size_t fHitLimitPerWirePerEventEvenTPC
std::map< int, std::map< std::pair< size_t, size_t >, std::vector< TH1D * > > > fRunToCryTPCToPlaneMapDist
std::map< int, size_t > fNEvtsPerRun
std::map< int, std::map< std::pair< size_t, size_t >, std::vector< TH1D * > > > fRunToCryTPCToPlaneMap
QTextStream & endl(QTextStream &s)
void GoodWireAna::makeHistoSetForThisRun ( int  runID)

Definition at line 206 of file GoodWireAna_module.cc.

207 {
208  std::cout << "Making histo set." << std::endl;
209 
210  //Create the output map of (Cryo/TPC) to (HistoVect)
211  std::map< std::pair<size_t,size_t>, std::vector<TH1D*> > outputMap;
212 
213  //Create a second output map for histos plotting wire hit occupancy distributions (not the occupancies themselves)
214  std::map< std::pair<size_t,size_t>, std::vector<TH1D*> > outputDistMap;
215 
216  //Loop over the cryostats
217  for( size_t iCry = 0; iCry < fNCry; ++iCry ){
218 
219  //Find the number of TPCs in this cryostat
220  size_t nTPCs = fGeometry->NTPC(iCry);
221 
222  //Loop over TPCs and create a vector for each one that will
223  //hold the different planes' histograms
224  for( size_t iTPC = 0; iTPC < nTPCs; ++iTPC ){
225  std::vector<TH1D*> histoVect;
226  std::vector<TH1D*> histoDistVect;
227 
228  //Define the pair
229  std::pair<size_t,size_t> CryTPCPair(iCry,iTPC);
230 
231  //Get geometry information
232  size_t nWiresU = fGeometry->Nwires(0,iTPC,iCry);
233  size_t nWiresV = fGeometry->Nwires(1,iTPC,iCry);
234  size_t nWiresW = fGeometry->Nwires(2,iTPC,iCry);
235 
236  char name[50];
237  char title[105];
238 
239  //U Plane
240  int n = sprintf( name, "r%d_cry%lu_tpc%lu_U_WireHitOcc", runID, iCry, iTPC);
241  int t = sprintf( title, ";Run %d, Cryostat %lu, TPC %lu, U Plane Wire Hit Occupancies;", runID, iCry, iTPC);
242  TH1D* uHisto = fTFS->make<TH1D>(name,title,nWiresU,0,nWiresU);
243  uHisto->GetXaxis()->SetTitle("Wire Index in Plane");
244  uHisto->GetYaxis()->SetTitle("Hit Occupancy");
245 
246  //U Plane
247  n = sprintf( name, "r%d_cry%lu_tpc%lu_V_WireHitOcc", runID, iCry, iTPC);
248  t = sprintf( title, ";Run %d, Cryostat %lu, TPC %lu, V Plane Wire Hit Occupancies;", runID, iCry, iTPC);
249  TH1D* vHisto = fTFS->make<TH1D>(name,title,nWiresV,0,nWiresV);
250  vHisto->GetXaxis()->SetTitle("Wire Index in Plane");
251  vHisto->GetYaxis()->SetTitle("Hit Occupancy");
252 
253  //W Plane
254  n = sprintf( name, "r%d_cry%lu_tpc%lu_W_WireHitOcc", runID, iCry, iTPC);
255  t = sprintf( title, ";Run %d, Cryostat %lu, TPC %lu, W Plane Wire Hit Occupancies;", runID, iCry, iTPC);
256  TH1D* wHisto = fTFS->make<TH1D>(name,title,nWiresW,0,nWiresW);
257  wHisto->GetXaxis()->SetTitle("Wire Index in Plane");
258  wHisto->GetYaxis()->SetTitle("Hit Occupancy");
259 
260 
261  //Push the three histograms back into the histoVect
262  histoVect.push_back(uHisto);
263  histoVect.push_back(vHisto);
264  histoVect.push_back(wHisto);
265 
266  //Now make the hit occupancy distributions
267  //U Plane
268  n = sprintf( name, "r%d_cry%lu_tpc%lu_U_HitOccDist", runID, iCry, iTPC);
269  t = sprintf( title, ";Run %d, Cryostat %lu, TPC %lu, U Plane Hit Occupancy Distribution;", runID, iCry, iTPC);
270  TH1D* uHistoDist = fTFS->make<TH1D>(name,title,fNBinsDist,0,-1);
271  uHistoDist->GetXaxis()->SetTitle("Hit Occupancy");
272  uHistoDist->GetYaxis()->SetTitle("Number of Wires");
273 
274  //U Plane
275  n = sprintf( name, "r%d_cry%lu_tpc%lu_V_HitOccDist", runID, iCry, iTPC);
276  t = sprintf( title, ";Run %d, Cryostat %lu, TPC %lu, V Plane Hit Occupancy Distribution;", runID, iCry, iTPC);
277  TH1D* vHistoDist = fTFS->make<TH1D>(name,title,fNBinsDist,0,-1);
278  vHistoDist->GetXaxis()->SetTitle("Hit Occupancy");
279  vHistoDist->GetYaxis()->SetTitle("Number of Wires");
280 
281  //W Plane
282  n = sprintf( name, "r%d_cry%lu_tpc%lu_W_HitOccDist", runID, iCry, iTPC);
283  t = sprintf( title, ";Run %d, Cryostat %lu, TPC %lu, W Plane Hit Occupancy Distribution;", runID, iCry, iTPC);
284  TH1D* wHistoDist = fTFS->make<TH1D>(name,title,fNBinsDist,0,-1);
285  wHistoDist->GetXaxis()->SetTitle("Hit Occupancy");
286  wHistoDist->GetYaxis()->SetTitle("Number of Wires");
287 
288  //Push back these three histograms into the histoDistVect
289  histoDistVect.push_back(uHistoDist);
290  histoDistVect.push_back(vHistoDist);
291  histoDistVect.push_back(wHistoDist);
292 
293  //Have to "use" n and t for stupid compiler reasons
294  if( n ) n = 0;
295  if( t ) t = 0;
296 
297  //Now put this vector into the map to (Cryo/TPC) pair
298  outputMap.emplace(CryTPCPair,histoVect);
299  outputDistMap.emplace(CryTPCPair,histoDistVect);
300  }
301  }
302 
303  //Now push back this output vector into the persistent one, with the run
304  //number as the key
305  fRunToCryTPCToPlaneMap.emplace(runID,outputMap);
306  fRunToCryTPCToPlaneMapDist.emplace(runID,outputDistMap);
307 
308 
309  std::cout << "Done making histo set." << std::endl;
310 }
static QCString name
Definition: declinfo.cpp:673
art::TFileService * fTFS
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
geo::Geometry * fGeometry
pointer to the Geometry service
std::void_t< T > n
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
std::map< int, std::map< std::pair< size_t, size_t >, std::vector< TH1D * > > > fRunToCryTPCToPlaneMapDist
std::map< int, std::map< std::pair< size_t, size_t >, std::vector< TH1D * > > > fRunToCryTPCToPlaneMap
QTextStream & endl(QTextStream &s)
GoodWireAna& GoodWireAna::operator= ( GoodWireAna const &  )
delete
GoodWireAna& GoodWireAna::operator= ( GoodWireAna &&  )
delete
void GoodWireAna::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 1084 of file GoodWireAna_module.cc.

1085 {
1086  // Implementation of optional member function here.
1087  fHitModuleLabel = pset.get<std::string>("HitModuleLabel","fasthit");
1088  fNSigmaGoodWireHigh = pset.get<float>("NSigmaGoodWireHigh",5);
1089  fNSigmaGoodWireLow = pset.get<float>("NSigmaGoodWireLow",3);
1090  // fHitLimitPerWirePerEventCol = pset.get<size_t>("HitLimitPerWirePerEventCol",10);
1091  //fHitLimitPerWirePerEventInd = pset.get<size_t>("HitLimitPerWirePerEventInd",1);
1092  fHitLimitPerWirePerEventEvenTPC = pset.get<size_t>("HitLimitPerWirePerEventEvenTPC",1);
1093  fHitLimitPerWirePerEventOddTPC = pset.get<size_t>("HitLimitPerWirePerEventOddTPC",10);
1094  fVerbose = pset.get<bool>("Verbosity",false);
1095  fOnlyWriteCollectionPlane = pset.get<bool>("OnlyWriteCollectionPlane",true);
1096  fNBinsDist = pset.get<size_t>("NBinsDist",80);
1097  fQuietWireFactor = pset.get<float>("QuietWireFactor",0.1);
1098 
1099  std::cout << "NSigmaGoodWireHigh/Low: " << fNSigmaGoodWireHigh << "/" << fNSigmaGoodWireLow << std::endl;
1100 
1101  fHitOccLimit = 0;
1102 
1103 }
std::string string
Definition: nybbler.cc:12
size_t fHitLimitPerWirePerEventOddTPC
bool fOnlyWriteCollectionPlane
size_t fHitLimitPerWirePerEventEvenTPC
QTextStream & endl(QTextStream &s)
std::string fHitModuleLabel
void GoodWireAna::respondToCloseInputFile ( art::FileBlock const &  fb)
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 1105 of file GoodWireAna_module.cc.

1106 {
1107  // Implementation of optional member function here.
1108 }
void GoodWireAna::respondToCloseOutputFiles ( art::FileBlock const &  fb)
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 1110 of file GoodWireAna_module.cc.

1111 {
1112  // Implementation of optional member function here.
1113 }
void GoodWireAna::respondToOpenInputFile ( art::FileBlock const &  fb)
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 1115 of file GoodWireAna_module.cc.

1116 {
1117  // Implementation of optional member function here.
1118 }
void GoodWireAna::respondToOpenOutputFiles ( art::FileBlock const &  fb)
overridevirtual

Reimplemented from art::EDAnalyzer.

Definition at line 1120 of file GoodWireAna_module.cc.

1121 {
1122  // Implementation of optional member function here.
1123 }
void GoodWireAna::runDiagnostics ( std::map< size_t, std::map< size_t, bool > >  runToBadChannelMap)

Definition at line 854 of file GoodWireAna_module.cc.

855 {
856 
857  //Fill the times of each of the runs (manual for now)
858  std::map<size_t,float> runToDayCount;
859  runToDayCount.emplace(15651, 0);
860  runToDayCount.emplace(15652, 0.0048);
861  runToDayCount.emplace(15653, 0.0069);
862  runToDayCount.emplace(15654, 0.01);
863  runToDayCount.emplace(15655, 0.011);
864  runToDayCount.emplace(15864, 0.98);
865  runToDayCount.emplace(15865, 0.984);
866  runToDayCount.emplace(15866, 0.99);
867  runToDayCount.emplace(16488, 4.501);
868  runToDayCount.emplace(16489, 4.502);
869 
870  //Diagnostic 1: # of bad Channels vs. time of run
871  std::vector<float> badChannelCounts;
872  std::vector<float> timeInDays;
873 
874  //Loop through each run and get the size of that corresp map
875  for( std::map<size_t,std::map<size_t,bool> >::iterator iter = runToBadChannelMap.begin(); iter != runToBadChannelMap.end(); iter++ ){
876  badChannelCounts.push_back(iter->second.size());
877  timeInDays.push_back(runToDayCount.at(iter->first));
878  }
879 
880  //Fill the plot
881  //for( size_t iRun = 0; iRun < timeInDays.size(); ++iRun ){
882  // fNumBadChannelsVTime->SetPoint(iRun+1,timeInDays.at(iRun),badChannelCounts.at(iRun));
883  //}
884 
885 
886 
887 
888 
889 
890 }
void GoodWireAna::writeListOfBadWires ( std::vector< std::vector< size_t > >  badWireVect)

Definition at line 737 of file GoodWireAna_module.cc.

738 {
739  //Create an std::ofstream object (outfile)
740  std::ofstream outfile;
741  outfile.open("badChannelList.txt");
742 
743 
744 
745  //Create vectors for listing bulk properties of different runs
746  std::map<size_t,std::vector<size_t> > runToTPCVectMapNoisy;
747  std::map<size_t,std::vector<size_t> > runToTPCVectMapQuiet;
748  std::map<size_t,std::vector<size_t> > runToTPCVectMapDead;
749 
750  //Create blank initialization vectors
751  std::vector<size_t> tempVect;
752 
753  //Initialize these vectors to the standard of Alex
754  size_t nTPCs = fGeometry->NTPC(0);
755  for( size_t iQ = 0; iQ < nTPCs ; ++iQ ){
756  tempVect.push_back(0);
757  }
758 
759  //Now loop through the wire vector
760  if( fVerbose )
761  std::cout << "Size of badwirevect: " << badWireVect.size() << std::endl;
762  for( size_t iWire = 0; iWire < badWireVect.size(); ++iWire ){
763 
765  if( badWireVect.at(iWire).at(3) != 2 ) continue;
766  }
767 
768  //Identify the run
769  size_t runID = badWireVect.at(iWire).at(0);
770 
771 
772  //If the run has not already been seen, emplace maps back with empty vectors
773  if( runToTPCVectMapNoisy.count(runID) == 0 ){
774  runToTPCVectMapNoisy.emplace(runID,tempVect);
775  runToTPCVectMapQuiet.emplace(runID,tempVect);
776  runToTPCVectMapDead.emplace(runID,tempVect);
777  }
778 
779  //Now increment each vector in the appropriate spot corresp to this TPC and type of bad wire
780  size_t type = badWireVect.at(iWire).at(5);
781  size_t tpc = badWireVect.at(iWire).at(2);
782  if( type == 0 ){
783  runToTPCVectMapDead.at(runID).at(tpc)++;
784  }
785  if( type == 1 ){
786  runToTPCVectMapQuiet.at(runID).at(tpc)++;
787  }
788  if( type == 2 ){
789  runToTPCVectMapNoisy.at(runID).at(tpc)++;
790  }
791 
792  /*
793  //Specify group in Alex notation
794  int group = 0;
795  if( badWireVect.at(iWire).at(3) % 2 == 1 ) group = (badWireVect.at(iWire).at(2)-1)/2;
796  else group = badWireVect.at(iWire).at(2)/2;
797 
798  //
799  if( badWireVect.at(iWire).at(5) == 0 ) numDeadVect.at(group)++;
800  if( badWireVect.at(iWire).at(5) == 1 ) numQuietVect.at(group)++;
801  if( badWireVect.at(iWire).at(5) == 2 ) numNoisyVect.at(group)++;
802  */
803 
804 
805  //Get the channel from the Cryo, TPC, Plane, and Wire
806  geo::WireID theWireID( badWireVect.at(iWire).at(1), badWireVect.at(iWire).at(2), badWireVect.at(iWire).at(3),badWireVect.at(iWire).at(4)-1);
807  size_t channel = fGeometry->PlaneWireToChannel(theWireID);
808  std::cout << "We're in plane: " << badWireVect.at(iWire).at(3) << ", and wire: " << theWireID.Wire << " corresponds to channel: " << channel << std::endl;
809 
810  if( fVerbose )
811  std::cout << "Cryo/TPC/Plane/Wire/Channel: " << badWireVect.at(iWire).at(1) << "/" << badWireVect.at(iWire).at(2) << "/" << badWireVect.at(iWire).at(3) << "/" << badWireVect.at(iWire).at(4)-1 << "/" << channel << std::endl;
812 
813 
814  outfile << badWireVect.at(iWire).at(0) << " " << channel << " " << badWireVect.at(iWire).at(5) << " " << badWireVect.at(iWire).at(2) << " " << badWireVect.at(iWire).at(3) << " " << badWireVect.at(iWire).at(4) << "\n";
815 
816 
817  }
818 
819 
820  outfile.close();
821 
822  // if( fSummary ){
823  std::cout << "********************************************************" << std::endl;
824  std::cout << "*************** JOB SUMMARY OF BAD WIRES ***************" << std::endl;
825  std::cout << "********************************************************" << std::endl;
826 
827  std::cout << "Note: Collection plane only at the moment." << std::endl;
828 
829  //Loop over all runs
830  for( std::map<size_t,std::vector<size_t> >::iterator runIter = runToTPCVectMapNoisy.begin(); runIter != runToTPCVectMapNoisy.end(); ++runIter ){
831  size_t runID = runIter->first;
832  std::cout << "\n **** RUN #" << runID << " SUMMARY **** " << std::endl;
833 
834  //Now loop over all TPCs in a given run
835  for( size_t iTPC = 0; iTPC < nTPCs; ++iTPC ){
836  std::cout << "Number of noisy wires in TPC #" << iTPC << ": " << runToTPCVectMapNoisy.at(runID).at(iTPC) << std::endl;
837  std::cout << "Number of quiet wires in TPC #" << iTPC << ": " << runToTPCVectMapQuiet.at(runID).at(iTPC) << std::endl;
838  std::cout << "Number of dead wires in TPC #" << iTPC << ": " << runToTPCVectMapDead.at(runID).at(iTPC) << std::endl;
839  }
840 
841  }
842  /*
843  for(size_t iQ = 0; iQ < 4 ; ++iQ ){
844  std::cout << "Quarter: " << iQ << ", NumDead/Quiet/Noisy: " << numDeadVect.at(iQ) << "/" << numQuietVect.at(iQ) << "/" << numNoisyVect.at(iQ) << std::endl;
845  }
846  */
847  //}
848 
849 }
uint8_t channel
Definition: CRTFragment.hh:201
bool fOnlyWriteCollectionPlane
geo::Geometry * fGeometry
pointer to the Geometry service
unsigned int NTPC(unsigned int cstat=0) const
Returns the total number of TPCs in the specified cryostat.
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
QTextStream & endl(QTextStream &s)
void GoodWireAna::writeListOfDeadWires ( )

Definition at line 314 of file GoodWireAna_module.cc.

315 {
316  //Create an std::ofstream object (outfile)
317  std::ofstream outfile;
318  outfile.open("deadWireList.txt");
319 
320  if( fVerbose )
321  std::cout << "Inside writing function." << std::endl;
322 
323  //Loop through all hit occupancy histos
324  for( std::map<int,std::map<std::pair<size_t,size_t>,std::vector<TH1D*> > >::iterator iterRun = fRunToCryTPCToPlaneMap.begin(); iterRun != fRunToCryTPCToPlaneMap.end(); ++iterRun ){
325 
326  //Get run info
327  int runID = iterRun->first;
328  std::map<std::pair<size_t,size_t>,std::vector<TH1D*> > theCryTPCToPlaneVectMap = iterRun->second;
329 
330  //Debug
331  if( fVerbose )
332  std::cout << "runID: " << runID << std::endl;
333 
334  for( std::map<std::pair<size_t,size_t>,std::vector<TH1D*> >::iterator iterCryTPC = theCryTPCToPlaneVectMap.begin(); iterCryTPC != theCryTPCToPlaneVectMap.end(); ++iterCryTPC ){
335 
336  //Get Cry/TPC info
337  size_t CryID = iterCryTPC->first.first;
338  size_t TPCID = iterCryTPC->first.second;
339  std::vector<TH1D*> planeVect = iterCryTPC->second;
340 
341  if( fVerbose )
342  std::cout << "Cryo/TPC: " << CryID << "/" << TPCID << std::endl;
343 
344 
345  //Now loop over planes
346  for( size_t iPlane = 0; iPlane < planeVect.size(); ++iPlane ){
347 
348 
349  //Get the plane information
350  size_t PlaneID = iPlane;
351 
352  //Debug
353  if( fVerbose )
354  std::cout << "PlaneID: " << PlaneID << std::endl;
355 
356  //Get the histogram for this plane
357  TH1D * thisPlaneHist = planeVect.at(iPlane);
358 
359  //Now loop over histogram bins
360  for( int iBin = 1; iBin <= thisPlaneHist->GetNbinsX(); ++iBin ){
361 
362  std::cout << "BinID: " << iBin << ", binContent: " << thisPlaneHist->GetBinContent(iBin) << std::endl;
363 
364 
365  //If the bin occupancy is zero, then get the wire number (which is I believe offset from bin number by -1, but Imma check first.
366  if( thisPlaneHist->GetBinContent(iBin) == 0 ){
367  int WireID = iBin-1;
368 
369  std::cout << "Inside the final if statement." << std::endl;
370 
371  //Now print all of this info on one line in our text file.
372  outfile << runID << " " << CryID << " " << TPCID << " " << PlaneID << " " << WireID << "\n";
373 
374  }
375  }
376  }
377  }
378  }
379 
380  //Close file
381  outfile.close();
382 
383 }
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
detail::Node< FrameID, bool > PlaneID
Definition: CRTID.h:125
IDparameter< geo::TPCID > TPCID
Member type of validated geo::TPCID parameter.
std::map< int, std::map< std::pair< size_t, size_t >, std::vector< TH1D * > > > fRunToCryTPCToPlaneMap
QTextStream & endl(QTextStream &s)
void GoodWireAna::writeListOfGoodWires ( std::vector< std::vector< size_t > >  goodWireVect)

Definition at line 896 of file GoodWireAna_module.cc.

897 {
898  //Create an std::ofstream object (outfile)
899  std::ofstream outfile;
900  outfile.open("goodChannelList.txt");
901 
902  //Create an object for listing bulk properties
903  size_t numGood = 0;
904 
905  //Now loop through the vector
906  if( fVerbose )
907  std::cout << "Size of goodwirevect: " << goodWireVect.size() << std::endl;
908  for( size_t iWire = 0; iWire < goodWireVect.size(); ++iWire ){
909 
911  if( goodWireVect.at(iWire).at(3) != 2 ) continue;
912  }
913 
914  //Increment but restrict to collection planes
915  numGood++;
916 
917  //Get the channel from the Cryo, TPC, Plane, and Wire
918  geo::WireID theWireID( goodWireVect.at(iWire).at(1), goodWireVect.at(iWire).at(2), goodWireVect.at(iWire).at(3),goodWireVect.at(iWire).at(4)-1);
919  size_t channel = fGeometry->PlaneWireToChannel(theWireID);
920 
921  if( fVerbose )
922  std::cout << "Cryo/TPC/Plane/Wire/Channel: " << goodWireVect.at(iWire).at(1) << "/" << goodWireVect.at(iWire).at(2) << "/" << goodWireVect.at(iWire).at(3) << "/" << goodWireVect.at(iWire).at(4)-1 << "/" << channel << std::endl;
923 
924 
925  outfile << goodWireVect.at(iWire).at(0) << " " << channel << std::endl;
926 
927  }
928 
929 
930  outfile.close();
931 
932  if( fVerbose )
933  std::cout << "NumGood: " << numGood << std::endl;
934 
935 }
uint8_t channel
Definition: CRTFragment.hh:201
bool fOnlyWriteCollectionPlane
geo::Geometry * fGeometry
pointer to the Geometry service
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
QTextStream & endl(QTextStream &s)

Member Data Documentation

geo::Geometry* GoodWireAna::fGeometry
private

pointer to the Geometry service

Definition at line 86 of file GoodWireAna_module.cc.

size_t GoodWireAna::fHitLimitPerWirePerEventEvenTPC
private

Definition at line 105 of file GoodWireAna_module.cc.

size_t GoodWireAna::fHitLimitPerWirePerEventOddTPC
private

Definition at line 106 of file GoodWireAna_module.cc.

std::string GoodWireAna::fHitModuleLabel
private

Definition at line 95 of file GoodWireAna_module.cc.

double GoodWireAna::fHitOccLimit
private

Definition at line 100 of file GoodWireAna_module.cc.

size_t GoodWireAna::fNBinsDist
private

Definition at line 101 of file GoodWireAna_module.cc.

size_t GoodWireAna::fNCry
private

Definition at line 92 of file GoodWireAna_module.cc.

std::map<int,size_t> GoodWireAna::fNEvtsPerRun
private

Definition at line 109 of file GoodWireAna_module.cc.

float GoodWireAna::fNSigmaGoodWireHigh
private

Definition at line 98 of file GoodWireAna_module.cc.

float GoodWireAna::fNSigmaGoodWireLow
private

Definition at line 99 of file GoodWireAna_module.cc.

bool GoodWireAna::fOnlyWriteCollectionPlane
private

Definition at line 111 of file GoodWireAna_module.cc.

double GoodWireAna::fQuietWireFactor
private

Definition at line 102 of file GoodWireAna_module.cc.

std::map<int,std::map<std::pair<size_t,size_t>,std::vector<TH1D*> > > GoodWireAna::fRunToCryTPCToPlaneMap
private

Definition at line 81 of file GoodWireAna_module.cc.

std::map<int,std::map<std::pair<size_t,size_t>,std::vector<TH1D*> > > GoodWireAna::fRunToCryTPCToPlaneMapDist
private

Definition at line 82 of file GoodWireAna_module.cc.

art::TFileService* GoodWireAna::fTFS
private

Definition at line 89 of file GoodWireAna_module.cc.

std::map<size_t,size_t> GoodWireAna::fUPlaneRepeatingWireStart
private

Definition at line 114 of file GoodWireAna_module.cc.

bool GoodWireAna::fVerbose
private

Definition at line 110 of file GoodWireAna_module.cc.

std::map<size_t,size_t> GoodWireAna::fVPlaneRepeatingWireStart
private

Definition at line 115 of file GoodWireAna_module.cc.


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