162 std::unique_ptr<std::vector<recob::Hit> > hcol(
new std::vector<recob::Hit>);
163 std::vector< art::Ptr<recob::Hit> > ChHitsDisambig;
165 if (ChannelHitsDisambig)
169 std::vector< art::Ptr<recob::Hit> > ChHitsCheater;
171 if (ChannelHitsCheater)
175 int incorrecthits = 0;
178 std::map< int, std::pair< TVector3, std::pair < std::pair< double,double >, TVector3 > > > ParticleMap;
180 if (ChannelHitsDisambig.isValid()) {
181 for(
size_t h = 0;
h < ChHitsCheater.size();
h++ ){
183 uint32_t cheatchannel = ChHitsCheater[
h]->Channel();
184 double cheatpeaktime = ChHitsCheater[
h]->PeakTime();
185 uint32_t cheatwire = ChHitsCheater[
h]->WireID().Wire;
187 std::vector<sim::IDE> ides;
191 for(
size_t e = 0;
e < TrackIDs.size(); ++
e){
192 if ( TrackIDs[
e].
energy > MaxE ) {
193 TrackID = TrackIDs[
e].trackID;
194 MaxE = TrackIDs[
e].energy;
199 if ( ParticleMap.count(TrackID) == 0) {
202 MC_NormMom[0] = ( particle->
Px() / particle->
P() );
203 MC_NormMom[1] = ( particle->
Py() / particle->
P() );
204 MC_NormMom[2] = ( particle->
Pz() / particle->
P() );
205 double MC_Theta = MC_NormMom.Theta();
206 double MC_Phi = MC_NormMom.Phi();
207 ParticleMap[
TrackID].second.second[0] = MC_NormMom[0];
208 ParticleMap[
TrackID].second.second[1] = MC_NormMom[1];
209 ParticleMap[
TrackID].second.second[2] = MC_NormMom[2];
210 ParticleMap[
TrackID].second.first.first = MC_Theta;
211 ParticleMap[
TrackID].second.first.second = MC_Phi;
214 for(
size_t w = 0;
w < ChHitsDisambig.size();
w++ ) {
215 uint32_t disambigchannel = ChHitsDisambig[
w]->Channel();
216 double disambigpeaktime = ChHitsDisambig[
w]->PeakTime();
217 uint32_t disambigwire = ChHitsDisambig[
w]->WireID().Wire;
219 if((cheatchannel == disambigchannel)&&(TMath::Abs(cheatpeaktime - disambigpeaktime)< 0.1)) {
222 if(cheatwire==disambigwire){
224 ++ParticleMap[
TrackID].first[0];
228 ++ParticleMap[
TrackID].first[1];
234 ++ParticleMap[
TrackID].first[2];
240 int totalhits = (correcthits + incorrecthits + missinghits);
243 if ( totalhits != 0 ) {
244 fCorrect ->Fill( (
double)correcthits / (
double)totalhits );
245 fMissed ->Fill( (
double)missinghits / (
double)totalhits );
246 fIncorrect->Fill( (
double)incorrecthits / (
double)totalhits );
247 if ( (
double)correcthits / (
double)totalhits == 0 ) std::cout <<
"WHY IS THIS EVENT NOT MATCHING ANY HITS!!!????" <<
std::endl;
249 std::cout <<
"\nTotal hits " << totalhits <<
", correct hits " << correcthits <<
", incorrect hits " << incorrecthits <<
", missing hits " << missinghits <<
std::endl;
251 for (std::map<
int, std::pair< TVector3, std::pair < std::pair< double,double >, TVector3 > > >::
iterator ii = ParticleMap.begin(); ii!=ParticleMap.end(); ++ii){
252 int MapTotalHits = ii->second.first[0] + ii->second.first[1] + ii->second.first[2];
253 std::cout <<
"Total hits for this TrackID " << ii->first <<
" is; " << MapTotalHits <<
", Correct " << ii->second.first[0] <<
", Incorrect " << ii->second.first[1] <<
", Missed " << ii->second.first[2] <<
std::endl;
254 if ( MapTotalHits != 0 ) {
255 fXCorrect -> Fill ( ii->second.second.second[0], (
double)ii->second.first[0] / (
double)MapTotalHits );
256 fXMissed -> Fill ( ii->second.second.second[0], (
double)ii->second.first[1] / (
double)MapTotalHits );
257 fXIncorrect -> Fill ( ii->second.second.second[0], (
double)ii->second.first[2] / (
double)MapTotalHits );
258 fYCorrect -> Fill ( ii->second.second.second[1], (
double)ii->second.first[0] / (
double)MapTotalHits );
259 fYMissed -> Fill ( ii->second.second.second[1], (
double)ii->second.first[1] / (
double)MapTotalHits );
260 fYIncorrect -> Fill ( ii->second.second.second[1], (
double)ii->second.first[2] / (
double)MapTotalHits );
261 fZCorrect -> Fill ( ii->second.second.second[2], (
double)ii->second.first[0] / (
double)MapTotalHits );
262 fZMissed -> Fill ( ii->second.second.second[2], (
double)ii->second.first[1] / (
double)MapTotalHits );
263 fZIncorrect -> Fill ( ii->second.second.second[2], (
double)ii->second.first[2] / (
double)MapTotalHits );
265 fThetaCorrect -> Fill ( ii->second.second.first.first , (
double)ii->second.first[0] / (
double)MapTotalHits );
266 fThetaMissed -> Fill ( ii->second.second.first.first , (
double)ii->second.first[1] / (
double)MapTotalHits );
267 fThetaIncorrect -> Fill ( ii->second.second.first.first , (
double)ii->second.first[2] / (
double)MapTotalHits );
268 fPhiCorrect -> Fill ( ii->second.second.first.second, (
double)ii->second.first[0] / (
double)MapTotalHits );
269 fPhiMissed -> Fill ( ii->second.second.first.second, (
double)ii->second.first[1] / (
double)MapTotalHits );
270 fPhiIncorrect -> Fill ( ii->second.second.first.second, (
double)ii->second.first[2] / (
double)MapTotalHits );
double Py(const int i=0) const
std::vector< sim::TrackIDE > HitToTrackIDEs(detinfo::DetectorClocksData const &clockData, recob::Hit const &hit) const
AdcChannelData::View View
Handle< PROD > getHandle(SelectorBase const &) const
std::vector< TrackID > TrackIDs
const simb::MCParticle * TrackIdToParticle_P(int id) const
double Px(const int i=0) const
Planes which measure Z direction.
art::ServiceHandle< cheat::BackTrackerService > bt_serv
double P(const int i=0) const
double Pz(const int i=0) const
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
art::ServiceHandle< cheat::ParticleInventoryService > pi_serv
std::string fChanHitDisambig
QTextStream & endl(QTextStream &s)
std::string fChanHitCheater