153 loginfo <<
"Filling Board Map - fNBoardsPerAPA: " <<
fNBoardsPerAPA <<
"\n";
156 if(
fLogLevel>0) loginfo <<
"Looping over apas" <<
"\n";
159 for(
auto id_apa_pair:
fAPAMap){
161 std::shared_ptr<Hardware::APA> apa_ptr = id_apa_pair.second;
163 unsigned int max_channels_in_board = apa_ptr->getNChannels() /
fNBoardsPerAPA;
171 std::vector< std::shared_ptr<Hardware::Board> > BoardsFromAPA;
172 std::vector< TVector3 > ZPosOfColWires;
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;
185 if(
fLogLevel>1) loginfo <<
"Looping over channels" <<
"\n";
189 double ThisAPA_MinZ = DBL_MAX;
190 double ThisAPA_MaxZ = -DBL_MAX;
192 for(
auto channel : apa_ptr->getChannels()) {
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];
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.";
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" 213 int NumColPush = 0, PushToBoard = 0;
214 for(
auto channel : apa_ptr->getChannels()) {
217 double WireSt[3], WireEn[3];
219 BoardsFromAPA[ PushToBoard ]->addChannel(
channel);
221 if( WireSt[2] < ZPosOfColWires[ PushToBoard ][0] ) ZPosOfColWires[ PushToBoard ][0] = WireSt[2];
222 if( WireEn[2] > ZPosOfColWires[ PushToBoard ][1] ) ZPosOfColWires[ PushToBoard ][1] = WireEn[2];
233 if ( NumColPush%NumColWiresPerBoard == 0 ) {
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;
246 for(
auto channel : apa_ptr->getChannels()) {
252 double WireSt[3], WireEn[3];
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);
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()
284 if(
fLogLevel>0) loginfo <<
"Finished this APA\n" << *apa_ptr <<
"\n" <<
"Total Boards in fBoardMap: " <<
getNBoards() <<
"\n-----------------------\n\n";
289 loginfo<<
"Finished filling Board Map\n Filled: " <<
getNBoards() <<
" Boards";
unsigned int getNBoards() const
static constexpr double nb
art::ServiceHandle< geo::Geometry > fGeometryService
Hardware::BoardMap fBoardMap
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.
unsigned int fNBoardsPerAPA
geo::TPCID FindTPCAtPosition(double const worldLoc[3]) const
Returns the ID of the TPC at specified location.
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.
cet::coded_exception< error, detail::translate > exception
QTextStream & endl(QTextStream &s)