9 #include "CLHEP/Random/RandFlat.h" 19 assert(chip >= 1 && chip <= 8);
20 assert(chan >= 0 && chan <= 15);
23 int chipMin = -1, chanMin = -1;
25 int chipSign = 0, chanSign = 0;
27 if(chip == 1 || chip == 2){
28 wireMin = 1; chipMin = 2; chipSign = -1; chanSign = -1;
29 if(chan <= 4){view =
geo::kU; chanMin = 4; height = 5;}
30 else if(chan <= 9){view =
geo::kV; chanMin = 9; height = 5;}
31 else{view =
geo::kW; chanMin = 15; height = 6;}
34 if(chip == 3 || chip == 4){
35 wireMin = 2; chipMin = 4; chipSign = -1; chanSign = +1;
36 if(chan <= 5){view =
geo::kW; chanMin = 0; height = 6;}
37 else if(chan <= 10){view =
geo::kV; chanMin = 6; height = 5;}
38 else{view =
geo::kU; chanMin = 11; height = 5;}
41 if(chip == 5 || chip == 6){
42 chipMin = 5; chipSign = +1; chanSign = -1;
43 if(chan <= 4){view =
geo::kU; wireMin = 21; chanMin = 4; height = 5;}
44 else if(chan <= 9){view =
geo::kV; wireMin = 21; chanMin = 9; height = 5;}
45 else{view =
geo::kW; wireMin = 25; chanMin = 15; height = 6;}
48 if(chip == 7 || chip == 8){
49 chipMin = 7; chipSign = +1; chanSign = +1;
50 if(chan <= 5){view =
geo::kW; wireMin = 26; chanMin = 0; height = 6;}
51 else if(chan <= 10){view =
geo::kV; wireMin = 22; chanMin = 6; height = 5;}
52 else{view =
geo::kU; wireMin = 22; chanMin = 11; height = 5;}
55 assert(wireMin >= 0 && chipMin >= 0 && chanMin >= 0 && height >= 0 && chipSign != 0 && chanSign != 0);
58 wire = wireMin+2*((chan-chanMin)*chanSign + (chip-chipMin)*height*chipSign);
60 assert(wire >= 1 && wire <= 48);
68 const std::set<T>
s(begin, end);
69 return std::vector<T>(s.begin(), s.end());
77 geom->end_cryostat_id()))
91 const std::vector<geo::TPCID>& ts =
fTPCs.find(c)->second;
92 return ts[gRandom->Integer(ts.size())];
98 const std::vector<readout::TPCsetID>& ts =
fTPCsets.find(c)->second;
99 return ts[gRandom->Integer(ts.size())];
104 std::map<geo::CryostatID, std::vector<geo::TPCID>>
fTPCs;
105 std::map<geo::CryostatID, std::vector<readout::TPCsetID>>
fTPCsets;
114 return GetZ(a) < GetZ(b);
125 const std::vector<geo::WireID> wires = geom->ChannelToWire(c);
146 std::vector<std::vector<raw::ChannelID_t>>
151 std::set<raw::ChannelID_t> chanset[3];
159 chanset[geom->
View(chan)].insert(chan);
163 std::vector<std::vector<raw::ChannelID_t>> chans;
164 for(
int i = 0; i < 3; ++i){
165 chans.emplace_back(chanset[i].
begin(), chanset[i].
end());
167 std::sort(chans.back().begin(), chans.back().end(), scz);
176 const double badfrac = pset.
get<
double>(
"BadChanFrac");
181 if(modestr ==
"channels") mode = kRandomChans;
182 if(modestr ==
"APAs") mode = kRandomAPAs;
183 if(modestr ==
"APAsides") mode = kRandomAPAsides;
184 if(modestr ==
"boards") mode = kRandomBoards;
185 if(modestr ==
"chips") mode = kRandomChips;
187 std::cout <<
"RandomChannelStatusService: unknown mode '" 203 case kRandomChans: MarkChansBad(target);
break;
205 case kRandomAPAs: MarkAPAsBad(target);
break;
207 case kRandomAPAsides: MarkAPASidesBad(target);
break;
211 MarkBoardsOrChipsBad(mode, target);
219 std::set<raw::ChannelID_t> allchans;
223 std::set_difference(allchans.begin(), allchans.end(),
224 fBadChans.begin(), fBadChans.end(),
225 std::inserter(fGoodChans, fGoodChans.begin()));
235 std::set<raw::ChannelID_t> allchans;
241 const std::vector<raw::ChannelID_t> vchans(allchans.begin(),
247 while(fBadChans.size() <
target){
251 fBadChans.insert(vchans[gRandom->Integer(vchans.size())]);
260 std::map<readout::TPCsetID, std::set<raw::ChannelID_t>> tpcset_to_chans;
267 tpcset_to_chans[ts].insert(chan);
274 while(fBadChans.size() <
target){
278 fBadChans.insert(chan);
281 std::cout <<
"RandomChannelStatusService: Generated " 282 << fBadChans.size() <<
" bad channels of " 292 std::map<geo::TPCID, std::vector<raw::ChannelID_t>> tpc_to_chans;
309 while(fBadChans.size() <
target){
314 fBadChans.insert(chan);
317 std::cout <<
"RandomChannelStatusService: Generated " 318 << fBadChans.size() <<
" bad channels of " 334 while(fBadChans.size() <
target){
337 const std::vector<std::vector<raw::ChannelID_t>> chans =
ChannelsForTPC(geom.
get(),
t);
341 const int board = gRandom->Integer(10);
343 if(mode == kRandomBoards) MarkBoardBad(board, chans);
345 if(mode == kRandomChips){
346 const int chip = 1+gRandom->Integer(8);
347 MarkChipBad(board, chip, geom.
get(), chans);
350 std::cout <<
"RandomChannelStatusService: Generated " 351 << fBadChans.size() <<
" bad channels of " 359 const std::vector<std::vector<raw::ChannelID_t>>& chans)
366 for(
int i = 0; i < 40; ++i) fBadChans.insert(chans[
geo::kU][board*40+i]);
367 for(
int i = 0; i < 40; ++i) fBadChans.insert(chans[
geo::kV][board*40+i]);
368 for(
int i = 0; i < 48; ++i) fBadChans.insert(chans[
geo::kW][board*48+i]);
375 const std::vector<std::vector<raw::ChannelID_t>>& chans)
383 for(
int chan = 0; chan <= 15; ++chan){
394 const int stride = (view ==
geo::kW) ? 48 : 40;
396 assert(spot+board*stride <=
int(chans[view].
size()));
397 fBadChans.insert(chans[view][spot+board*stride-1]);
end
while True: pbar.update(maxval-len(onlies[E][S])) #print iS, "/", len(onlies[E][S]) found = False for...
void GetStart(double *xyz) const
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
IDparameter< geo::CryostatID > CryostatID
Member type of validated geo::CryostatID parameter.
TPC_id_iterator begin_TPC_id() const
Returns an iterator pointing to the first TPC ID in the detector.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Class identifying a set of TPC sharing readout channels.
std::vector< std::vector< raw::ChannelID_t > > ChannelsForTPC(const geo::GeometryCore *geom, geo::TPCID tpc)
readout::TPCsetID GetTPCset() const
std::vector< geo::WireID > ChannelToWire(raw::ChannelID_t const channel) const
Returns a list of wires connected to the specified TPC channel.
TPCset_id_iterator end_TPCset_id() const
Returns an iterator pointing after the last TPC set ID in the detector.
bool operator()(const raw::ChannelID_t &a, const raw::ChannelID_t &b) const
geo::TPCID GetTPC() const
IteratorBox< TPC_id_iterator,&GeometryCore::begin_TPC_id,&GeometryCore::end_TPC_id > IterateTPCIDs() const
Enables ranged-for loops on all TPC IDs of the detector.
art framework interface to geometry description
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
std::map< geo::CryostatID, std::vector< geo::TPCID > > fTPCs
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
IteratorBox< wire_id_iterator,&GeometryCore::begin_wire_id,&GeometryCore::end_wire_id > IterateWireIDs() const
Enables ranged-for loops on all wire IDs of the detector.
fInnerVessel push_back(Point(-578.400000, 0.000000, 0.000000))
void MarkBoardsOrChipsBad(EMode_t mode, unsigned int target)
art::ServiceHandle< geo::Geometry > geom
void MarkBoardBad(int board, const std::vector< std::vector< raw::ChannelID_t >> &chans)
T get(std::string const &key) const
TPCset_id_iterator begin_TPCset_id() const
Returns an iterator pointing to the first TPC set ID in the detector.
void MarkChansBad(unsigned int target)
The data type to uniquely identify a TPC.
Description of geometry of one entire detector.
RandomTPC(const geo::GeometryCore *geom)
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
TPC_id_iterator end_TPC_id() const
Returns an iterator pointing after the last TPC ID in the detector.
std::vector< geo::CryostatID > fCryos
double GetZ(const raw::ChannelID_t &c) const
void MarkAPAsBad(unsigned int target)
raw::ChannelID_t PlaneWireToChannel(WireID const &wireid) const
Returns the ID of the TPC channel connected to the specified wire.
void MarkAPASidesBad(unsigned int target)
void GetEnd(double *xyz) const
void MarkChipBad(int board, int chip, const geo::GeometryCore *geom, const std::vector< std::vector< raw::ChannelID_t >> &chans)
IteratorBox< TPCset_id_iterator,&GeometryCore::begin_TPCset_id,&GeometryCore::end_TPCset_id > IterateTPCsetIDs() const
Enables ranged-for loops on all TPC set IDs of the detector.
std::map< geo::CryostatID, std::vector< readout::TPCsetID > > fTPCsets
decltype(auto) constexpr begin(T &&obj)
ADL-aware version of std::begin.
Planes which measure W (third view for Bo, MicroBooNE, etc).
Tools and modules for checking out the basics of the Monte Carlo.
unsigned int ChannelID_t
Type representing the ID of a readout channel.
std::vector< geo::TPCID > TPCsetToTPCs(readout::TPCsetID const &tpcsetid) const
Returns a list of ID of TPCs belonging to the specified TPC set.
void ChipAndChannelToSpot(int chip, int chan, geo::View_t &view, int &wire)
LArSoft geometry interface.
RandomChannelStatusProvider(const fhicl::ParameterSet &pset)
std::vector< T > VectorViaSet(It_t begin, It_t end)
QTextStream & endl(QTextStream &s)
Service providing information about the quality of channels.
The data type to uniquely identify a cryostat.
#define DEFINE_ART_SERVICE_INTERFACE_IMPL(svc, iface)