3 #include "RichCharge.h"
5 #include "richradidOff.h"
6 #include "richrecOff.h"
10 void RichBaseData::Fill(RichRingR *ringPtr, RichRingBR *ringBPtr) {
15 RichBetaVariable<float> beta;
23 m_beta.emplace_back(type, beta);
26 void RichPlusData::Fill(AMSEventR *evPtr, RichRingR *ringPtr, TrTrackR *trackPtr) {
27 RichAdditionalData data;
29 data.NHitsTot = evPtr->NRichHit();
30 data.NPETotUncorr = RichHitR::getCollectedPhotoElectrons();
32 data.NHitsUsed = ringPtr->getUsedHits();
33 data.NPEExpUncorr = ringPtr->getExpectedPhotoElectrons(
false);
34 data.NPEMeasUncorr = ringPtr->getPhotoElectrons(
false);
35 data.Probability = ringPtr->getProb();
36 data.RingPMTs = ringPtr->NpColPMT.size();
37 data.ChargeConsistency = ringPtr->getPMTChargeConsistency();
39 FillHyp1Data(data, evPtr, ringPtr, trackPtr);
45 void RichPlusData::FillHyp1Data(RichAdditionalData &data, AMSEventR *evPtr, RichRingR *ringPtr, TrTrackR *trackPtr) {
47 RichPMTCalib *pmt_calib = (!
m_isMC) ? RichPMTCalib::getHead() :
nullptr;
53 std::array<float, 3> coo{0, 0, 0};
57 std::map<unsigned int, pmt_info> pmt_info_map;
58 std::vector<int> crossed_pmt[2];
59 std::vector<RichHitR *> rich_hit_on_ring_list;
60 std::map<int, RichHitR *> rich_hit_offline_map;
63 for (
const RichHitR &hit : evPtr->RichHit()) {
64 int pmt = int(hit.Channel / 16);
67 if ((pmt_calib) && (find(
begin(pmt_calib->BadPMTs),
end(pmt_calib->BadPMTs), pmt) !=
end(pmt_calib->BadPMTs)))
71 pmt_info_map[pmt].pmt = pmt;
72 pmt_info_map[pmt].nhit++;
73 pmt_info_map[pmt].np += np;
74 for (
int icoo = 0; icoo < 3; icoo++)
75 pmt_info_map[pmt].coo[icoo] += np * hit.Coo[icoo];
78 for (
auto &it : pmt_info_map) {
79 for (
int icoo = 0; icoo < 3; icoo++)
80 it.second.coo[icoo] /= it.second.np;
84 trackPtr->Interpolate(it.second.coo[2], coo, dir);
85 it.second.dist = sqrt(pow(it.second.coo[0] - coo.x(), 2.) + pow(it.second.coo[1] - coo.y(), 2.));
89 crossed_pmt[(it.second.dist < 3.5) ? 0 : 1].push_back(it.first);
92 std::vector<std::pair<int, pmt_info>> pmt_info_vec;
93 for (
const auto &it : pmt_info_map) {
94 pmt_info_vec.emplace_back(it.first, it.second);
96 std::sort(
begin(pmt_info_vec),
end(pmt_info_vec),
97 [](
const std::pair<int, pmt_info> &elem1,
const std::pair<int, pmt_info> &elem2) {
98 return elem1.second.np > elem2.second.np;
100 std::array<float, 5> pmt_np_uncorr;
101 std::array<float, 5> pmt_dist;
102 for (
const auto &it : pmt_info_vec) {
105 pmt_np_uncorr[index] = it.second.np;
106 pmt_dist[index] = it.second.dist;
111 for (
int ihit = 0; ihit < ringPtr->getUsedHits(
false); ihit++)
112 rich_hit_on_ring_list.push_back(evPtr->pRichHit(ringPtr->iRichHit(ihit)));
115 for (RichOffline::RichRawEvent *hit =
new RichOffline::RichRawEvent(evPtr); hit; hit = hit->next(), which++) {
116 rich_hit_offline_map.insert(std::make_pair(which, hit->getpointer()));
119 for (
int i = 0; i < ringPtr->RawBetas(); i++) {
120 int ihit = ringPtr->HitBeta(i);
121 RichHitR *rich_hit = rich_hit_offline_map[ihit];
125 int pmt = int(rich_hit->Channel / 16);
127 (pmt_calib) && (find(
begin(pmt_calib->BadPMTs),
end(pmt_calib->BadPMTs), pmt) !=
end(pmt_calib->BadPMTs));
130 bool is_bad_occupancy =
false;
133 bool is_crossed_pri = find(
begin(crossed_pmt[0]),
end(crossed_pmt[0]), pmt) !=
end(crossed_pmt[0]);
134 bool is_crossed_sec = find(
begin(crossed_pmt[1]),
end(crossed_pmt[1]), pmt) !=
end(crossed_pmt[1]);
135 bool is_not_in_selected_ring =
136 (find(
begin(rich_hit_on_ring_list),
end(rich_hit_on_ring_list), rich_hit) ==
end(rich_hit_on_ring_list));
137 int status2 = ((is_bad_pmt) ? 0x1 : 0) + ((is_bad_occupancy) ? 0x2 : 0) + ((is_crossed_pri) ? 0x4 : 0) +
138 ((is_crossed_sec) ? 0x8 : 0) + ((is_not_in_selected_ring) ? 0x10 : 0);
141 if ((rich_hit->Status >> 31) & 0x1)
143 if ((status2 & 0xf) != 0)
146 int kind_of_tile = ringPtr->IsNaF();
147 std::array<float, 2> simple_resolution{1.2e-3, 4e-3};
148 for (
int ibeta = 0; ibeta < 2; ibeta++) {
149 if (std::fabs(ringPtr->RawBeta(i, ibeta) - 1) > 3. * simple_resolution[kind_of_tile])
151 data.NHitsHyp1Tot[ibeta]++;
152 if ((ringPtr->UsedBeta(i) < 0) || (ringPtr->UsedBeta(i) > 1)) {
153 data.NHitsHyp1OutOfRing[ibeta]++;
154 data.NPEHyp1UncorrTot += rich_hit->Npe;
162 unsigned int nclus = ringPtr->ClusterizeZ1();
166 for (
int iclu = 0; iclu < std::min(10u, nclus); iclu++) {
167 ringPtr->GetClusters(iclu, dummy1, mean, dummy2);
168 if (std::fabs(mean - ringPtr->getBeta()) > 0.01)
174 for (
int is = 0; is < 5; is++) {
175 if ((pmt_np_uncorr[is] > 5) && (pmt_dist[is] > 3.5))
176 data.NSecondaryHits++;
std::vector< RichAdditionalData > m_data
std::vector< std::pair< Rich::RichMeasType, RichBetaVariable< float > > > m_beta
SingleTreeChain::EventItr end(SingleTreeChain &chain)
Rich container class description.
SingleTreeChain::EventItr begin(SingleTreeChain &chain)