| 92 | /// use LAMBDA function to extract the charge from each item |
| 93 | template <class CONTAINER, typename LAMBDA> |
| 94 | void printChargeDistribution(const CONTAINER& data, LAMBDA lam, ostream& os, ostream& os_tsv, const String& header = "Charge") |
| 95 | { |
| 96 | std::map<Int, UInt> charges; |
| 97 | Int q; |
| 98 | for (const auto& item : data) |
| 99 | { |
| 100 | if (lam(item, q)) ++charges[q]; |
| 101 | } |
| 102 | |
| 103 | os << header << " distribution:" |
| 104 | << '\n'; |
| 105 | for (const auto& ch : charges) |
| 106 | { |
| 107 | os << " charge " << ch.first << ": " << ch.second << "x\n"; |
| 108 | os_tsv << "general: charge distribution: charge: " |
| 109 | << ch.first << '\t' |
| 110 | << ch.second << '\n'; |
| 111 | } |
| 112 | os << '\n'; |
| 113 | |
| 114 | |
| 115 | }; |
| 116 | |
| 117 | |
| 118 | //helper struct for identification data |