40 vector<pair<CRTHit,vector<sim::AuxDetIDE>>> hitCol;
41 map<int,map<int,tagger>> trackTaggers;
45 for(
auto const& adsc : adscList) {
47 const int adID = adsc->AuxDetID();
51 const int adsID = adsc->AuxDetSensitiveID();
54 for(
auto const& ide : adsc->AuxDetIDEs()) {
57 if( ide.energyDeposited*1000 <
fEDepMin)
61 tagger& tag = (trackTaggers[ide.trackID])[adID];
70 int nmisscd=0, nmisspair=0;
74 for (
auto const& trk : trackTaggers) {
76 map <int,tagger> mTaggers;
78 for (
auto const& tag : trk.second) {
80 vector<sim::AuxDetIDE> vide;
82 TLorentzVector rHit(0.,0.,0.,0.);
84 map<uint8_t,vector< pair<int,float> > > pesmap;
86 double xerr=0., yerr=0., zerr = 0.;
89 if (tag.second.type==
'c' || tag.second.type==
'd') {
92 if (tag.second.layerID.size()>1) {
95 for (
auto const& ide : tag.second.stripIDE) {
97 vide.push_back(ide.second);
98 peshit+=ide.second.energyDeposited*1000;
99 pesmap[feb_id[0]].push_back(std::make_pair(ide.first,ide.second.energyDeposited*1000));
102 rHit*=1.0/tag.second.stripIDE.size();
106 for (
auto const& ide : tag.second.stripIDE) {
109 xerr += pow(point.X()-rHit.X(),2);
110 yerr += pow(point.Y()-rHit.Y(),2);
111 zerr += pow(point.Z()-rHit.Z(),2);
113 xerr = sqrt(xerr/(tag.second.stripIDE.size()-1));
114 yerr = sqrt(yerr/(tag.second.stripIDE.size()-1));
115 zerr = sqrt(zerr/(tag.second.stripIDE.size()-1));
123 hitCol.push_back(std::make_pair(
124 FillCrtHit(feb_id, pesmap, peshit, rHit.T(), rHit.T(), 0, rHit.X(), xerr,
125 rHit.Y(), yerr, rHit.Z(), zerr, tag.second.region),
130 if ( tag.second.type==
'm' ) {
131 mTaggers[tag.first] = tag.second;
137 for (
auto const& tag : mTaggers) {
139 if (mPairs.find(tag.first) != mPairs.end())
continue;
141 vector<sim::AuxDetIDE> vide;
143 TLorentzVector rHit(0.,0.,0.,0.);
145 uint8_t mac1 = macpair.first;
146 uint8_t mac11 = macpair.second;
147 vector<uint8_t> feb_id = {mac1};
148 if(mac1!=mac11) feb_id.push_back(mac11);
149 map<uint8_t,vector< pair<int,float> > > pesmap;
151 bool pairFound =
false;
152 double xerr=0., yerr=0., zerr = 0.;
154 layers.insert(*(tag.second.layerID.begin()));
155 mPairs.insert(tag.first);
157 for (
auto const& ide : tag.second.stripIDE) {
159 vide.push_back(ide.second);
160 peshit+=ide.second.energyDeposited*1000;
161 pesmap[mac1].push_back(std::make_pair(ide.first,ide.second.energyDeposited*1000));
165 for (
auto const& tag2 : mTaggers) {
166 if ( tag.first == tag2.first )
continue;
167 if ( mPairs.find(tag2.first) != mPairs.end())
continue;
168 if ( tag.second.region != tag2.second.region )
continue;
170 layers.insert(*(tag2.second.layerID.begin()));
173 mPairs.insert(tag2.first);
177 uint8_t mac2 = macpair.first;
178 uint8_t mac22 = macpair.second;
179 feb_id.push_back(mac2);
180 if(mac2!=mac22) feb_id.push_back(mac22);
183 for (
auto const& ide : tag2.second.stripIDE) {
185 vide.push_back(ide.second);
186 peshit+=ide.second.energyDeposited*1000;
187 pesmap[mac2].push_back(std::make_pair(ide.first,ide.second.energyDeposited*1000));
196 rHit*=1.0/vide.size();
200 for (
auto const& ide : vide) {
203 xerr += pow(point.X()-rHit.X(),2);
204 yerr += pow(point.Y()-rHit.Y(),2);
205 zerr += pow(point.Z()-rHit.Z(),2);
208 xerr = sqrt(xerr/(vide.size()-1));
209 yerr = sqrt(yerr/(vide.size()-1));
210 zerr = sqrt(zerr/(vide.size()-1));
212 hitCol.push_back(std::make_pair(
213 FillCrtHit(feb_id, pesmap, peshit, rHit.T(), rHit.T(), 0, rHit.X(), xerr,
214 rHit.Y(), yerr, rHit.Z(), zerr, tag.second.region),
223 std::cout <<
"CRTTrueHitRecoAlg: nmisscd=" << nmisscd <<
", nmissm=" << nmisspair << std::endl;
map< int, int > stripLayer
TLorentzVector AvgIDEPoint(sim::AuxDetIDE ide)
CRTHit FillCrtHit(vector< uint8_t > tfeb_id, map< uint8_t, vector< pair< int, float >>> tpesmap, float peshit, double time0, double time1, int plane, double x, double ex, double y, double ey, double z, double ez, std::string tagger)
map< int, sim::AuxDetIDE > stripIDE
CRTCommonUtils * fCrtutils
pair< uint8_t, uint8_t > ADToMac(size_t adid)
char GetAuxDetType(size_t adid)
int GetLayerID(sim::AuxDetSimChannel const &adsc)
string GetAuxDetRegion(size_t adid)
BEGIN_PROLOG could also be cout