Public Member Functions | Private Member Functions | Private Attributes | List of all members
HardwareMapperService Class Reference

#include <HardwareMapperService.h>

Public Member Functions

 HardwareMapperService (fhicl::ParameterSet const &pset, art::ActivityRegistry &reg)
 
void printASICMap (unsigned int num_asics_to_print=20)
 
void printBoardMap (unsigned int num_boards_to_print=20)
 
void printTPCMap (unsigned int num_tpcs_to_print=20)
 
void printAPAMap (unsigned int num_apas_to_print=20)
 
void printHardwareMaps ()
 
void printGeometryInfo ()
 
unsigned int getNASICs () const
 
unsigned int getNBoards () const
 
unsigned int getNAPAs () const
 
unsigned int getNTPCs () const
 
std::vector< raw::ChannelID_t > const & getTPCChannels (Hardware::ID tpc_id)
 
std::vector< raw::ChannelID_t > const & getAPAChannels (Hardware::ID apa_id)
 
std::set< raw::ChannelID_t > const & getTPCChannelsSet (Hardware::ID tpc_id)
 
std::set< raw::ChannelID_t > const & getAPAChannelsSet (Hardware::ID apa_id)
 
void checkGeomVsFileDetectorName (art::Run const &run)
 

Private Member Functions

void fillASICMap ()
 
void fillBoardMap ()
 
void fillTPCMap ()
 
void fillAPAMap ()
 
void fillHardwareMaps ()
 

Private Attributes

unsigned int fLogLevel
 
unsigned int fNASICsPerBoard
 
unsigned int fNBoardsPerAPA
 
std::string fServiceName
 
art::ServiceHandle< geo::GeometryfGeometryService
 
std::string fDetectorNameFromGeometry
 
std::string fDetectorNameFromFile
 
Hardware::ASICMap fASICMap
 
Hardware::BoardMap fBoardMap
 
Hardware::TPCMap fTPCMap
 
Hardware::APAMap fAPAMap
 

Detailed Description

Definition at line 40 of file HardwareMapperService.h.

Constructor & Destructor Documentation

HardwareMapperService::HardwareMapperService ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry reg 
)

Definition at line 18 of file HardwareMapperService_service.cc.

19  : fLogLevel(1), fNASICsPerBoard(1), fNBoardsPerAPA(1), fServiceName("HardwareMapperService") {
20  pset.get_if_present<unsigned int>("LogLevel", fLogLevel);
21  pset.get_if_present<unsigned int>("NASICsPerBoard", fNASICsPerBoard);
22  pset.get_if_present<unsigned int>("NBoardsPerAPA", fNBoardsPerAPA);
23  const std::string func_name = "HardwareMapperService";
24  {
25  mf::LogInfo loginfo(fServiceName);
26  loginfo << func_name << "\n"
27  << "fLogLevel: " << fLogLevel << "\n"
28  << "fNASICsPerBoard: " << fNASICsPerBoard << "\n"
29  << "fNBoardsPerAPA: " << fNBoardsPerAPA;
30  }
31  //jpd -- This is how to register a callback function to the activity registry
32  // -- This means that upon the preBeginRun (which I assume is immediately before
33  // -- begin run) this function (HardwareMapperService::preBeginRun) will be called
34 
37 }
std::string string
Definition: nybbler.cc:12
GlobalSignal< detail::SignalResponseType::FIFO, void(Run const &)> sPreBeginRun
void checkGeomVsFileDetectorName(art::Run const &run)

Member Function Documentation

void HardwareMapperService::checkGeomVsFileDetectorName ( art::Run const &  run)

Definition at line 40 of file HardwareMapperService_service.cc.

40  {
41  const std::string func_name = "checkGeomVsFileDetectorName";
42  if(fLogLevel>1) mf::LogInfo(fServiceName) << "In Function: " << func_name;
43 
44  //jpd -- Check that the Detector Name matches between the Geometry and the File
45  //Inspired by Geometry_service.cc
46  mf::LogInfo loginfo(fServiceName);
47 
48  auto const rdcol = run.getMany<sumdata::RunData>();
49  if (rdcol.empty()) {
50  mf::LogError(fServiceName) << "Can't find sumdata::RunData for geometry vs. file detector name checks";
51  return;
52  }
53 
54  fDetectorNameFromFile = rdcol.front()->DetName();
55 
56  loginfo << "This file has the following detector name: " << fDetectorNameFromFile << "\n";
57  loginfo << "The geometry service has this detector name: " << fDetectorNameFromGeometry << "\n";
58 
59  if(fDetectorNameFromGeometry != fDetectorNameFromFile){
60  throw cet::exception("HardwareMapperService") << "Detector Name missmatch!\n"
61  << "Detector Name from Geometry Service: " << fDetectorNameFromGeometry << "\n"
62  << "Detector Name from File: " << fDetectorNameFromFile << "\n"
63  << "This means that the HardwareMapperService is filled with information for the wrong Geometry\n"
64  << "Throwing an exception as the user should make sure the Geometry in their fcl and that used to produce their file match\n";
65  }
66 }
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void HardwareMapperService::fillAPAMap ( )
private

Definition at line 325 of file HardwareMapperService_service.cc.

325  {
326  const std::string func_name = "fillAPAMap";
327 
328  mf::LogInfo loginfo(fServiceName);
329  if(fLogLevel>1) loginfo << "In Function: " << func_name << "\n";
330 
331  unsigned int Nchannels = fGeometryService->Nchannels();
332  loginfo << "Filling APA Map with " << Nchannels << " channels" << "\n";
333 
334  for(raw::ChannelID_t channel=0; channel<Nchannels ;channel++){
335  std::vector<geo::WireID> const Wires = fGeometryService->ChannelToWire(channel);
336  for(auto wire : Wires){
337  auto apa_id = wire.TPC / 2;
338  //jpd -- See if we have already created a APA object for this apa_id in our map
339  auto find_result = fAPAMap.find(apa_id);
340  std::shared_ptr<Hardware::APA> this_apa;
341  if(find_result != fAPAMap.end()){
342  //jpd -- We already have one, add this channel
343  this_apa = (*find_result).second;
344  }
345  else{
346  //jpd -- We don't have one. Create a new one and add this channel
347  this_apa = std::shared_ptr<Hardware::APA>(new Hardware::APA(apa_id));
348  }
349  this_apa->addChannel(channel);
350  fAPAMap[apa_id] = this_apa;
351  }//loop over wires
352  }//loop over channels
353  loginfo << "Finished filling APA Map\n"
354  << "Filled: " << getNAPAs() << " APAs";
355 }
art::ServiceHandle< geo::Geometry > fGeometryService
std::string string
Definition: nybbler.cc:12
unsigned int getNAPAs() const
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
uint8_t channel
Definition: CRTFragment.hh:201
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
void HardwareMapperService::fillASICMap ( )
private

Definition at line 69 of file HardwareMapperService_service.cc.

69  {
70  const std::string func_name = "fillASICMap";
71 
72  mf::LogInfo loginfo(fServiceName);
73 
74  if(fLogLevel>1||true) loginfo << "In Function: " << func_name << "\n";//FIXME
75 
76  loginfo << "Filling ASIC Map - fNASICsPerBoard: " << fNASICsPerBoard << "\n";
77 
78  if(fLogLevel>0) loginfo << "Looping over Boards" << "\n";
79 
80  Hardware::ID current_asic_id = 0;
81  for(auto id_board_pair: fBoardMap){
82  std::shared_ptr<Hardware::Board> board_ptr = id_board_pair.second;
83 
84  if(fLogLevel>0) loginfo << *board_ptr << "\n";
85 
86  unsigned int channels_in_this_asic = 0;
87  unsigned int max_channels_in_asic = board_ptr->getNChannels() / fNASICsPerBoard;
88 
89  if(fLogLevel>1) loginfo << "current_asic_id: " << current_asic_id << "\n";
90 
91  board_ptr->addHardwareID(Hardware::ASIC(current_asic_id));
92  std::shared_ptr<Hardware::ASIC> this_asic_ptr = std::shared_ptr<Hardware::ASIC>(new Hardware::ASIC(current_asic_id));
93 
94  if(fLogLevel>1) loginfo << "Creating new asic"
95  << " registered to Board: " << board_ptr->getID()
96  << "- This Board has: " << board_ptr->getNHardwareIDs()
97  << " pieces of hardware"
98  << "\n\n";
99 
100  if(fLogLevel>1) loginfo << "Looping over channels" << "\n";
101 
102  for(auto channel : board_ptr->getChannels()){
103  if(channels_in_this_asic >= max_channels_in_asic){
104  if(fLogLevel>1) loginfo << "Need new asic - current_asic_id: " << current_asic_id
105  << " channels_in_this_asic: " << channels_in_this_asic
106  << "/" << max_channels_in_asic
107  << "\n";
108 
109 
110  fASICMap[this_asic_ptr->getID()] = this_asic_ptr;
111  current_asic_id++;
112  channels_in_this_asic=0;
113 
114  if(fLogLevel>1) loginfo << "Last ASIC: " << *this_asic_ptr << "\n\n";
115 
116  this_asic_ptr=std::shared_ptr<Hardware::ASIC>(new Hardware::ASIC(current_asic_id));
117 
118  board_ptr->addHardwareID(Hardware::ASIC(current_asic_id));
119  if(fLogLevel>1) loginfo << "Creating new asic"
120  << " registered to Board: " << board_ptr->getID()
121  << "- This Board has: " << board_ptr->getNHardwareIDs()
122  << " pieces of hardware"
123  << "\n\n";
124  }
125  this_asic_ptr->addChannel(channel);
126  channels_in_this_asic++;
127 
128  }//channel in this board
129  if(fLogLevel>1) loginfo << "Finished channel loop\n"
130  << "current_asic_id: " << current_asic_id
131  << " channels_in_this_asic: " << channels_in_this_asic
132  << "/" << max_channels_in_asic
133  << "\n";
134  fASICMap[this_asic_ptr->getID()] = this_asic_ptr;
135  current_asic_id++;//start each Board with a new ASIC
136  if(fLogLevel>0) loginfo << "Finished this Board\n"
137  << *board_ptr << "\n"
138  << "Total ASICs in fASICMap: " << getNASICs() << "\n"
139  << "-----------------------\n\n";
140  }//id_board_pair;
141  loginfo << "Finished filling ASIC Map\n"
142  << "Filled: " << getNASICs() << " ASICs";
143 
144 
145 }
Hardware::BoardMap fBoardMap
std::string string
Definition: nybbler.cc:12
unsigned int ID
uint8_t channel
Definition: CRTFragment.hh:201
unsigned int getNASICs() const
Hardware::ASICMap fASICMap
void HardwareMapperService::fillBoardMap ( )
private

Definition at line 148 of file HardwareMapperService_service.cc.

148  {
149  const std::string func_name = "fillBoardMap";
150  if(fLogLevel>1||true) mf::LogInfo(fServiceName) << "In Function: " << func_name;//FIXME
151 
152  mf::LogInfo loginfo(fServiceName);
153  loginfo << "Filling Board Map - fNBoardsPerAPA: " << fNBoardsPerAPA << "\n";
154 
155  Hardware::ID current_board_id = 0;
156  if(fLogLevel>0) loginfo << "Looping over apas" << "\n";
157 
158  // --- Lets loop over the APA map
159  for(auto id_apa_pair: fAPAMap){
160  // --- Get a handle to this APA object.
161  std::shared_ptr<Hardware::APA> apa_ptr = id_apa_pair.second;
162  // --- How many channels should there be per board?
163  unsigned int max_channels_in_board = apa_ptr->getNChannels() / fNBoardsPerAPA;
164 
165  // Karl::Added to only run on the first APA.
166  //if (apa_ptr->getID() > 1) continue;
167 
168  // --- Record the id of the current board that we are on.
169  Hardware::ID FirstBoard = current_board_id;
170  // --- Make an array of boards for this APA, and then create them.
171  std::vector< std::shared_ptr<Hardware::Board> > BoardsFromAPA;
172  std::vector< TVector3 > ZPosOfColWires;
173  for (unsigned int cb=0; cb<fNBoardsPerAPA; ++cb) {
174  // --- Add a board object to this APA
175  apa_ptr->addHardwareID(Hardware::Board( current_board_id ));
176  // --- Push back objects to my vectors.
177  BoardsFromAPA .push_back( std::shared_ptr<Hardware::Board>(new Hardware::Board( current_board_id )) );
178  ZPosOfColWires.push_back( {DBL_MAX, -DBL_MAX, -1} );
179  std::cout << "Creating a new board with id " << FirstBoard+cb << " - " << BoardsFromAPA[ cb ]->getID() << " on APA " << apa_ptr->getID() << std::endl;
180  // --- Incremment the current_board_id number.
181  ++current_board_id;
182  }
183 
184  // --- Now that I have a vector of boards for this APA, lets loop over the channels on this APA and assign them to each board!
185  if(fLogLevel>1) loginfo << "Looping over channels" << "\n";
186  // I need to find out the range of z values which this APA covers, and the number of collection plane wires, in order to correctly assign the channels.
187  // --- !!! I am going to explicitly assuming wrapped wires, and that both sides of the TPC are instrumented !!! ---
188  // --- !!! This is valid in all of the geometries that I am aware of 2nd June 2017 !!! ---
189  double ThisAPA_MinZ = DBL_MAX;
190  double ThisAPA_MaxZ = -DBL_MAX;
191  int TotColWires = 0;
192  for(auto channel : apa_ptr->getChannels()) {
193  if (fGeometryService->View(channel) != 2) continue; // Collection planes wires are view 2.
194  ++TotColWires; // Got a collection plane wire.
195  // Work out the Z position of this wire.
196  double WireSt[3], WireEn[3];
198  if (WireSt[2] < ThisAPA_MinZ ) ThisAPA_MinZ = WireSt[2];
199  if (WireSt[2] > ThisAPA_MaxZ ) ThisAPA_MaxZ = WireSt[2];
200  }
201  // --- Work out the number of collection plane wires per board.
202  const int NumColWiresPerBoard = TotColWires/fNBoardsPerAPA;
203  if (TotColWires%fNBoardsPerAPA != 0) {
204  throw cet::exception("HardwareMapperService") << "The number of collection plane wires doesn't divide evenly. There are " << TotColWires << " col wires,"
205  << " and you want " << fNBoardsPerAPA << ", leaving a remainder of " << TotColWires%fNBoardsPerAPA << " wires.";
206  }
207  std::cout << " There are " << TotColWires << " collection plane wires on this APA."
208  << " Each board will have " << NumColWiresPerBoard << " collection plane wires, and " << max_channels_in_board - TotColWires/fNBoardsPerAPA << " ind wires."
209  << " The wires go from " << ThisAPA_MinZ << " to " << ThisAPA_MaxZ << ".\n"
210  << std::endl;
211 
212  // --- Set the collection plane wires on our boards.
213  int NumColPush = 0, PushToBoard = 0;
214  for(auto channel : apa_ptr->getChannels()) {
215  if (fGeometryService->View(channel) != 2) continue; // Collection planes wires are view 2.
216  // Get the start and end points of the first wire segment for this channel.
217  double WireSt[3], WireEn[3];
219  BoardsFromAPA[ PushToBoard ]->addChannel(channel);
220  ++NumColPush;
221  if( WireSt[2] < ZPosOfColWires[ PushToBoard ][0] ) ZPosOfColWires[ PushToBoard ][0] = WireSt[2];
222  if( WireEn[2] > ZPosOfColWires[ PushToBoard ][1] ) ZPosOfColWires[ PushToBoard ][1] = WireEn[2];
223  ZPosOfColWires[ PushToBoard ][2] = fGeometryService->FindTPCAtPosition( WireSt ).TPC;
224  /*
225  std::cout << " Looking at channel " << channel << " on plane " << fGeometryService->View(channel) << " TPC [[" << fGeometryService->FindTPCAtPosition( WireSt ) << " ]]."
226  << " Start pos was (" << WireSt[0] << ", " << WireSt[1] << ", " << WireSt[2] << "). "
227  << " Endin pos was (" << WireEn[0] << ", " << WireEn[1] << ", " << WireEn[2] << ").\n"
228  << " Pushing it back to board " << PushToBoard << ", now pushed back " << NumColPush << " wires."
229  << " Extremes are " << ZPosOfColWires[ PushToBoard ].first << " - " << ZPosOfColWires[ PushToBoard ].second
230  << std::endl;
231  */
232  // --- Check that if I want to move to the next board.
233  if ( NumColPush%NumColWiresPerBoard == 0 ) {
234  ++PushToBoard;
235  }
236  }
237 
238  for (unsigned int nn=0; nn<fNBoardsPerAPA; ++nn) {
239  std::cout << " Looking at board " << BoardsFromAPA[ nn ]->getID() << ", in TPC " << ZPosOfColWires[ nn ][2]
240  << " the extremes are " << ZPosOfColWires[ nn ][0] << " - " << ZPosOfColWires[ nn ][1] << std::endl;
241  }
242 
243  // --- Now set the induction plane wires on our boards.
244  int NumIndPush = 0;
245 
246  for(auto channel : apa_ptr->getChannels()) {
247  if (fGeometryService->View(channel) == 2) continue; // Collection planes wires are view 2.
248  // --- When looking at induction plane wires whether I look at start or end wire pos depends on APA and TPC number.
249  // --- When looking at even APA number - WireEnd for even TPCs, WireStart for odd TPCs.
250  // --- When looking at odd APA number - WireStart for odd TPCs, WireEnd for even TPCs.
251  // Get the start and end points of the first wire segment for this channel.
252  double WireSt[3], WireEn[3];
254  /*
255  std::cout << "\nLooking at channel " << channel << " on plane " << fGeometryService->View(channel) << " TPC [[" << fGeometryService->FindTPCAtPosition( WireSt ) << " ]]."
256  << " Start pos was (" << WireSt[0] << ", " << WireSt[1] << ", " << WireSt[2] << "). "
257  << " Endin pos was (" << WireEn[0] << ", " << WireEn[1] << ", " << WireEn[2] << ")."
258  << std::endl;
259  */
260  for (unsigned int nb=0; nb<fNBoardsPerAPA; ++nb) {
261  if ( ZPosOfColWires[nb][2] != fGeometryService->FindTPCAtPosition( WireSt ).TPC ) continue;
262  if ( (abs(WireSt[1]) > 600 && WireSt[2] > ZPosOfColWires[nb][0] && WireSt[2] < ZPosOfColWires[nb][1] ) ||
263  (abs(WireEn[1]) > 600 && WireEn[2] > ZPosOfColWires[nb][0] && WireEn[2] < ZPosOfColWires[nb][1] ) ) {
264  BoardsFromAPA[ nb ]->addChannel(channel);
265  /*
266  std::cout << " Pushing this channel onto board: " << BoardsFromAPA[ nb ]->getID()
267  << ", Extremeities " << ZPosOfColWires[nb][0] << " - " << ZPosOfColWires[nb][1] << " in TPC " << ZPosOfColWires[nb][2]
268  << ". This board now has " << BoardsFromAPA[ nb ]->getNChannels() << std::endl;
269  */
270  break;
271  }
272  }
273  ++NumIndPush;
274  }//channel in this apa
275 
276  // --- Now that I have looped over all of the channels, lets update my map!
277  for (unsigned int cb=0; cb<fNBoardsPerAPA; ++cb) {
278  unsigned int ThisID = BoardsFromAPA[ cb ]->getID();
279  fBoardMap[ ThisID ] = BoardsFromAPA[ cb ];
280  std::cout << "Adding board " << BoardsFromAPA[ cb ]->getID() << " to APA " << apa_ptr->getID()
281  << ", it has " << BoardsFromAPA[ cb ]->getNChannels() << " - " << fBoardMap[ ThisID ]->getNChannels()
282  << std::endl;
283  }
284  if(fLogLevel>0) loginfo << "Finished this APA\n" << *apa_ptr << "\n" << "Total Boards in fBoardMap: " << getNBoards() << "\n-----------------------\n\n";
285  // --- Start each APA with a new board
286  //current_board_id++;
287  }//id_apa_pair;
288 
289  loginfo<< "Finished filling Board Map\n Filled: " << getNBoards() << " Boards";
290 }
unsigned int getNBoards() const
static constexpr double nb
Definition: Units.h:81
art::ServiceHandle< geo::Geometry > fGeometryService
Hardware::BoardMap fBoardMap
std::string string
Definition: nybbler.cc:12
unsigned int ID
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
uint8_t channel
Definition: CRTFragment.hh:201
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
T abs(T value)
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
void WireEndPoints(geo::WireID const &wireid, double *xyzStart, double *xyzEnd) const
Fills two arrays with the coordinates of the wire end points.
TPCID_t TPC
Index of the TPC within its cryostat.
Definition: geo_types.h:406
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
void HardwareMapperService::fillHardwareMaps ( )
private

Definition at line 359 of file HardwareMapperService_service.cc.

359  {
360  const std::string func_name = "fillHardwareMaps";
361  if(fLogLevel>1) mf::LogInfo(fServiceName) << "In Function: " << func_name;
363 
364  {
365  mf::LogInfo loginfo(fServiceName);
366 
367  loginfo << "HardwareMapperService\n";
368  loginfo << "Filling Hardware Maps using geometry service\n";
369  loginfo << "DetectorName: " << fGeometryService->DetectorName() << "\n";
370  loginfo << "Ncryostats: " << fGeometryService->Ncryostats() << "\n";
371  loginfo << "TotalNTPC: " << fGeometryService->TotalNTPC() << "\n";
372  loginfo << "Nchannels: " << fGeometryService->Nchannels() << "\n";
373  loginfo << "NOpChannels: " << fGeometryService->NOpChannels() << "\n";
374  }//using annonymous namespace to force mf::LogInfo destructor call to flush output
375 
376  fillTPCMap();
377  fillAPAMap();
378  fillBoardMap();
379  fillASICMap();
380 
381  mf::LogInfo loginfo(fServiceName);
382  loginfo << "Number of TPCs: " << getNTPCs() << "\n"
383  << "Number of APAs: " << getNAPAs() << "\n"
384  << "Number of Boards: " << getNBoards() << "\n"
385  << "Number of ASICs: " << getNASICs() << "\n";
386 
387 }
unsigned int getNBoards() const
unsigned int TotalNTPC() const
Returns the total number of TPCs in the detector.
art::ServiceHandle< geo::Geometry > fGeometryService
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
unsigned int getNAPAs() const
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
unsigned int getNASICs() const
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
unsigned int getNTPCs() const
void HardwareMapperService::fillTPCMap ( )
private

Definition at line 293 of file HardwareMapperService_service.cc.

293  {
294  const std::string func_name = "fillTPCMap";
295  mf::LogInfo loginfo(fServiceName);
296  if(fLogLevel>1) loginfo << "In Function: " << func_name << "\n";
297  unsigned int Nchannels = fGeometryService->Nchannels();
298  loginfo << "Filling TPC Map with " << Nchannels << " channels" << "\n";
299 
300  for(raw::ChannelID_t channel=0; channel<Nchannels ;channel++){
301  std::vector<geo::WireID> const Wires = fGeometryService->ChannelToWire(channel);
302  for(auto wire : Wires){
303  auto tpc_id = wire.TPC;
304  //jpd -- See if we have already created a TPC object for this tpc_id in our map
305  auto find_result = fTPCMap.find(tpc_id);
306  std::shared_ptr<Hardware::TPC> this_tpc;
307  if(find_result != fTPCMap.end()){
308  //jpd -- We already have one, add this channel
309  this_tpc = (*find_result).second;
310  }
311  else{
312  //jpd -- We don't have one. Create a new one and add this channel
313  this_tpc = std::shared_ptr<Hardware::TPC>(new Hardware::TPC(tpc_id));
314  }
315  this_tpc->addChannel(channel);
316  fTPCMap[tpc_id] = this_tpc;
317  }//loop over wires
318  }//loop over channels
319  loginfo << "Finished filling TPC Map\n"
320  << "Filled: " << getNTPCs() << " TPCs";
321 
322 }
art::ServiceHandle< geo::Geometry > fGeometryService
std::string string
Definition: nybbler.cc:12
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
uint8_t channel
Definition: CRTFragment.hh:201
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
unsigned int getNTPCs() const
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
std::vector< raw::ChannelID_t > const & HardwareMapperService::getAPAChannels ( Hardware::ID  apa_id)

Definition at line 539 of file HardwareMapperService_service.cc.

539  {
540  const std::string func_name = "getAPAChannels";
541  if(fLogLevel>1) mf::LogInfo(fServiceName) << "In Function: " << func_name;
542  mf::LogInfo loginfo(fServiceName);
543  if(fLogLevel>1) loginfo << "Finding channels for APA: " << apa_id << "\n";
544 
545  auto find_result = fAPAMap.find(apa_id);
546  std::shared_ptr<Hardware::APA> this_apa;
547 
548  if(find_result == fAPAMap.end()){
549  mf::LogError(fServiceName) << "Failed to find this APA: " << apa_id << "\n";
550  mf::LogError(fServiceName) << "Returning an empty vector of channels\n";
551  static std::vector<raw::ChannelID_t> emptyVector;
552  return emptyVector;
553  }
554  this_apa = (*find_result).second;
555  if(fLogLevel>1) loginfo << "Found " << *this_apa << "\n";
556  if(fLogLevel>1) loginfo << "\n";
557  return this_apa->getChannels();
558 }
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::set< raw::ChannelID_t > const & HardwareMapperService::getAPAChannelsSet ( Hardware::ID  apa_id)

Definition at line 583 of file HardwareMapperService_service.cc.

583  {
584  const std::string func_name = "getAPAChannelsSet";
585  if(fLogLevel>1) mf::LogInfo(fServiceName) << "In Function: " << func_name;
586  mf::LogInfo loginfo(fServiceName);
587  if(fLogLevel>1) loginfo << "Finding channels for APA: " << apa_id << "\n";
588 
589  auto find_result = fAPAMap.find(apa_id);
590  std::shared_ptr<Hardware::APA> this_apa;
591 
592  if(find_result == fAPAMap.end()){
593  mf::LogError(fServiceName) << "Failed to find this APA: " << apa_id << "\n";
594  mf::LogError(fServiceName) << "Returning an empty set of channels\n";
595  static std::set<raw::ChannelID_t> emptySet;
596  return emptySet;
597  }
598  this_apa = (*find_result).second;
599  if(fLogLevel>1) loginfo << "Found " << *this_apa << "\n";
600  if(fLogLevel>1) loginfo << "\n";
601  return this_apa->getChannelsSet();
602 }
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
unsigned int HardwareMapperService::getNAPAs ( ) const
inline

Definition at line 54 of file HardwareMapperService.h.

54 { return fAPAMap.size();}
unsigned int HardwareMapperService::getNASICs ( ) const
inline

Definition at line 52 of file HardwareMapperService.h.

52 { return fASICMap.size();}
Hardware::ASICMap fASICMap
unsigned int HardwareMapperService::getNBoards ( ) const
inline

Definition at line 53 of file HardwareMapperService.h.

53 { return fBoardMap.size();}
Hardware::BoardMap fBoardMap
unsigned int HardwareMapperService::getNTPCs ( ) const
inline

Definition at line 55 of file HardwareMapperService.h.

55 { return fTPCMap.size();}
std::vector< raw::ChannelID_t > const & HardwareMapperService::getTPCChannels ( Hardware::ID  tpc_id)

Definition at line 516 of file HardwareMapperService_service.cc.

516  {
517  const std::string func_name = "getTPCChannels";
518  mf::LogInfo loginfo(fServiceName);
519 
520  if(fLogLevel>1) loginfo << "In Function: " << func_name << "\n";
521  if(fLogLevel>1) loginfo << "Finding channels for TPC: " << tpc_id << "\n";
522 
523  auto find_result = fTPCMap.find(tpc_id);
524  std::shared_ptr<Hardware::TPC> this_tpc;
525 
526  if(find_result == fTPCMap.end()){
527  mf::LogError(fServiceName) << "Failed to find this TPC: " << tpc_id << "\n";
528  mf::LogError(fServiceName) << "Returning an empty vector of channels\n";
529  static std::vector<raw::ChannelID_t> emptyVector;
530  return emptyVector;
531  }
532  this_tpc = (*find_result).second;
533  if(fLogLevel>1) loginfo << "Found " << *this_tpc << "\n";
534  if(fLogLevel>1) loginfo << "\n";
535  return this_tpc->getChannels();
536 }
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::set< raw::ChannelID_t > const & HardwareMapperService::getTPCChannelsSet ( Hardware::ID  tpc_id)

Definition at line 561 of file HardwareMapperService_service.cc.

561  {
562  const std::string func_name = "getTPCChannelsSet";
563  if(fLogLevel>1) mf::LogInfo(fServiceName) << "In Function: " << func_name;
564  mf::LogInfo loginfo(fServiceName);
565  if(fLogLevel>1) loginfo << "Finding channels for TPC: " << tpc_id << "\n";
566 
567  auto find_result = fTPCMap.find(tpc_id);
568  std::shared_ptr<Hardware::TPC> this_tpc;
569 
570  if(find_result == fTPCMap.end()){
571  mf::LogError(fServiceName) << "Failed to find this TPC: " << tpc_id << "\n";
572  mf::LogError(fServiceName) << "Returning an empty set of channels\n";
573  static std::set<raw::ChannelID_t> emptySet;
574  return emptySet;
575  }
576  this_tpc = (*find_result).second;
577  if(fLogLevel>1) loginfo << "Found " << *this_tpc << "\n";
578  if(fLogLevel>1) loginfo << "\n";
579  return this_tpc->getChannelsSet();
580 }
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
void HardwareMapperService::printAPAMap ( unsigned int  num_apas_to_print = 20)

Definition at line 447 of file HardwareMapperService_service.cc.

447  {
448  const std::string func_name = "printAPAMap";
449  if(fLogLevel>1) mf::LogInfo(fServiceName) << "In Function: " << func_name;
450  mf::LogInfo loginfo(fServiceName);
451 
452  loginfo << "Printing the first: " << num_apas_to_print << " APAs\n";
453  unsigned int total_channels = 0;
454  unsigned int count = 0;
455  for(auto this_pair : fAPAMap ){
456  if(count++ >= num_apas_to_print) break;
457  std::shared_ptr<Hardware::APA> this_apa = this_pair.second;
458  total_channels += this_apa->getNChannels();
459  loginfo << *this_apa << "\n";
460  }
461  loginfo << "\n";
462  loginfo << "Total Channels: " << total_channels << "\n";
463  loginfo << "\n";
464 }
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void HardwareMapperService::printASICMap ( unsigned int  num_asics_to_print = 20)

Definition at line 390 of file HardwareMapperService_service.cc.

390  {
391  const std::string func_name = "printASICMap";
392  if(fLogLevel>1) mf::LogInfo(fServiceName) << "In Function: " << func_name;
393  mf::LogInfo loginfo(fServiceName);
394  loginfo << "Printing the first: " << num_asics_to_print << " ASICs\n";
395  unsigned int total_channels = 0;
396  unsigned int count = 0;
397  for(auto this_pair : fASICMap ){
398  if(count++ >= num_asics_to_print) break;
399  std::shared_ptr<Hardware::ASIC> this_asic = this_pair.second;
400  total_channels += this_asic->getNChannels();
401  loginfo << *this_asic << "\n";
402  }
403  loginfo << "\n";
404  loginfo << "Total Channels: " << total_channels << "\n";
405  loginfo << "\n";
406 }
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
Hardware::ASICMap fASICMap
void HardwareMapperService::printBoardMap ( unsigned int  num_boards_to_print = 20)

Definition at line 409 of file HardwareMapperService_service.cc.

409  {
410  const std::string func_name = "printBoardMap";
411  if(fLogLevel>1) mf::LogInfo(fServiceName) << "In Function: " << func_name;
412  mf::LogInfo loginfo(fServiceName);
413  loginfo << "Printing the first: " << num_boards_to_print << " Boards\n";
414  unsigned int total_channels = 0;
415  unsigned int count = 0;
416  for(auto this_pair : fBoardMap ){
417  if(count++ >= num_boards_to_print) break;
418  std::shared_ptr<Hardware::Board> this_board = this_pair.second;
419  total_channels += this_board->getNChannels();
420  loginfo << *this_board << "\n";
421  }
422  loginfo << "\n";
423  loginfo << "Total Channels: " << total_channels << "\n";
424  loginfo << "\n";
425 }
Hardware::BoardMap fBoardMap
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
void HardwareMapperService::printGeometryInfo ( )

Definition at line 491 of file HardwareMapperService_service.cc.

491  {
492  const std::string func_name = "printGeometryInfo";
493  if(fLogLevel>1) mf::LogInfo(fServiceName) << "In Function: " << func_name;
494  {
495  mf::LogInfo loginfo(fServiceName);
496  loginfo << "Geometry Information with current Geometry Service\n";
497  loginfo << "DetectorName: " << fGeometryService->DetectorName() << "\n";
498  loginfo << "TotalMass: " << fGeometryService->TotalMass() << "\n";
499  unsigned int Ncryostats = fGeometryService->Ncryostats();
500  unsigned int TotalNTPC = fGeometryService->TotalNTPC();
501  unsigned int Nchannels = fGeometryService->Nchannels();
502  unsigned int NOpChannels = fGeometryService->NOpChannels();
503  loginfo << "Ncryostats: " << Ncryostats << "\n";
504  loginfo << "TotalNTPC: " << TotalNTPC << "\n";
505  loginfo << "Nchannels: " << Nchannels << "\n";
506  loginfo << "NOpChannels: " << NOpChannels << "\n";
507  loginfo << "\n";
508  }//using annonymous namespace to force mf::LogInfo destructor (which makes flushes the output)
509 
511 
512  return;
513 }
unsigned int TotalNTPC() const
Returns the total number of TPCs in the detector.
art::ServiceHandle< geo::Geometry > fGeometryService
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
unsigned int Ncryostats() const
Returns the number of cryostats in the detector.
unsigned int NOpChannels() const
Number of electronics channels for all the optical detectors.
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
double TotalMass() const
Returns the total mass [kg] of the specified volume (default: world).
std::string DetectorName() const
Returns a string with the name of the detector, as configured.
Index NOpChannels(Index)
void HardwareMapperService::printHardwareMaps ( )

Definition at line 467 of file HardwareMapperService_service.cc.

467  {
468  const std::string func_name = "printHardwareMaps";
469  if(fLogLevel>1) mf::LogInfo(fServiceName) << "In Function: " << func_name;
471  << "fDetectorName: " << fDetectorNameFromGeometry << " taken from Geometry Service at time of fillHardwareMaps()"
472  << "\n"
473  << "N.B. the geometry service can reload a new geometry on beginRun(), which would be bad"
474  << "\n";
475 
480 
481 
483  << "Num ASICs: " << getNASICs() << "\n"
484  << "Num Boards: " << getNBoards() << "\n"
485  << "Num TPCs: " << getNTPCs() << "\n"
486  << "Num APAs: " << getNAPAs();
487 
488 }
unsigned int getNBoards() const
void printBoardMap(unsigned int num_boards_to_print=20)
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
unsigned int getNAPAs() const
void printASICMap(unsigned int num_asics_to_print=20)
unsigned int getNASICs() const
void printTPCMap(unsigned int num_tpcs_to_print=20)
void printAPAMap(unsigned int num_apas_to_print=20)
unsigned int getNTPCs() const
void HardwareMapperService::printTPCMap ( unsigned int  num_tpcs_to_print = 20)

Definition at line 428 of file HardwareMapperService_service.cc.

428  {
429  const std::string func_name = "printTPCMap";
430  if(fLogLevel>1) mf::LogInfo(fServiceName) << "In Function: " << func_name;
431  mf::LogInfo loginfo(fServiceName);
432  loginfo << "Printing the first: " << num_tpcs_to_print << " TPCs\n";
433  unsigned int total_channels = 0;
434  unsigned int count = 0;
435  for(auto this_pair : fTPCMap ){
436  if(count++ >= num_tpcs_to_print) break;
437  std::shared_ptr<Hardware::TPC> this_tpc = this_pair.second;
438  total_channels += this_tpc->getNChannels();
439  loginfo << *this_tpc << "\n";
440  }
441  loginfo << "\n";
442  loginfo << "Total Channels: " << total_channels << "\n";
443  loginfo << "\n";
444 }
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo

Member Data Documentation

Hardware::APAMap HardwareMapperService::fAPAMap
private

Definition at line 93 of file HardwareMapperService.h.

Hardware::ASICMap HardwareMapperService::fASICMap
private

Definition at line 90 of file HardwareMapperService.h.

Hardware::BoardMap HardwareMapperService::fBoardMap
private

Definition at line 91 of file HardwareMapperService.h.

std::string HardwareMapperService::fDetectorNameFromFile
private

Definition at line 81 of file HardwareMapperService.h.

std::string HardwareMapperService::fDetectorNameFromGeometry
private

Definition at line 80 of file HardwareMapperService.h.

art::ServiceHandle<geo::Geometry> HardwareMapperService::fGeometryService
private

Definition at line 78 of file HardwareMapperService.h.

unsigned int HardwareMapperService::fLogLevel
private

Definition at line 73 of file HardwareMapperService.h.

unsigned int HardwareMapperService::fNASICsPerBoard
private

Definition at line 74 of file HardwareMapperService.h.

unsigned int HardwareMapperService::fNBoardsPerAPA
private

Definition at line 75 of file HardwareMapperService.h.

std::string HardwareMapperService::fServiceName
private

Definition at line 76 of file HardwareMapperService.h.

Hardware::TPCMap HardwareMapperService::fTPCMap
private

Definition at line 92 of file HardwareMapperService.h.


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