56 _ah = std::make_shared<AnaHelpers>();
58 std::cout<<
"Track Selection"<<std::endl;
63 std::cout<<
"Vertex Selection"<<std::endl;
68 std::cout<<
"Making histos"<<std::endl;
69 _vtx_histos = std::make_shared<TridentHistos>(
"vtxSelection");
77 std::cout<<
"Starting Regions"<<std::endl;
80 std::cout<<
"Setting up region:: " << regname <<std::endl;
90 _reg_tuples[regname] = std::make_shared<FlatTupleMaker>(regname+
"_tree");
100 std::cout<<
"Setting up region:: " << regname <<std::endl;
124 std::cout<<
"Done with TridentWABAnaProcessor::initialization"<<std::endl;;
133 double apMass = -0.9;
137 if(
debug_)std::cout<<
"Number of MCParticles for this events = "<<
mcParts_->size()<<std::endl;
138 for(
int i = 0; i <
mcParts_->size(); i++){
139 if(
mcParts_->at(i)->getPDG() == 622) {
140 apMass =
mcParts_->at(i)->getMass();
141 apZ =
mcParts_->at(i)->getVertexPosition().at(2);
173 std::vector<Vertex*> selected_tri;
177 for (
int i_vtx = 0; i_vtx <
vtxs_->size(); i_vtx++ ) {
186 bool foundParts =
_ah->GetParticlesFromVtx(vtx,ele,pos);
188 if(
debug_) std::cout<<
"Checking Particles"<<std::endl;
190 std::cout<<
"TridentWABAnaProcessor::WARNING::Found vtx without ele/pos. Skip."<<std::endl;
195 if(
debug_) std::cout<<
"Checking Trigger"<<std::endl;
198 if(
debug_)std::cout<<
"events didn't pass singles2, check single3"<<std::endl;
200 if(
debug_)std::cout<<
"Skipping because event didn't pass singles2 or 3"<<std::endl;
233 if(
debug_)std::cout<<
" Going through cuts "<<std::endl;
234 if (!
vtxSelector->passCutGt(
"eleNHits_gt",n_hits_ele,weight))
236 if (!
vtxSelector->passCutGt(
"posNHits_gt",n_hits_pos,weight))
238 if(
debug_)std::cout<<
" Pass nHits for each track cut"<<std::endl;
239 if (!
vtxSelector->passCutLt(
"eleMom_lt",ele_mom.Mag(),weight))
241 if(
debug_)std::cout<<
" Pass electron momentum cut"<<std::endl;
250 if(
debug_)std::cout<<
" Pass chi^2 for each track"<<std::endl;
253 if (!
vtxSelector->passCutLt(
"chi2unc_lt",vtx->getChi2(),weight))
256 if(
debug_)std::cout<<
" Pass vertex chi2 cut"<<std::endl;
259 if (!
vtxSelector->passCutGt(
"eleMom_gt",ele_mom.Mag(),weight))
263 if (!
vtxSelector->passCutGt(
"posMom_gt",pos_mom.Mag(),weight))
266 if(
debug_)std::cout<<
" Pass min p for each track "<<std::endl;
271 if (!
vtxSelector->passCutLt(
"maxVtxMom_lt",(ele_mom+pos_mom).Mag(),weight))
274 if (!
vtxSelector->passCutGt(
"minVtxMom_gt",(ele_mom+pos_mom).Mag(),weight))
276 if(
debug_)std::cout<<
" Pass vertex momentum cuts"<<std::endl;
279 double corr_eleClusterTime=666;
280 double corr_posClusterTime=666;
285 double corr_eleTrackTime=-666;
286 double corr_posTrackTime=-666;
291 bool hasEleCluster=corr_eleClusterTime>-300;
292 bool hasPosCluster=corr_posClusterTime>-300;
295 if (!
vtxSelector->passCutLt(
"eleTrkTime_lt",fabs(corr_eleTrackTime),weight))
298 if (!
vtxSelector->passCutLt(
"posTrkTime_lt",fabs(corr_posTrackTime),weight))
301 if(
debug_)std::cout<<
" Pass track time cuts"<<std::endl;
305 if (!
vtxSelector->passCutLt(
"eleTrkCluTimeDiff_lt",fabs(corr_eleTrackTime - corr_eleClusterTime),weight))
310 if (!
vtxSelector->passCutLt(
"posTrkCluTimeDiff_lt",fabs(corr_posTrackTime - corr_posClusterTime),weight))
313 if(
debug_)std::cout<<
" Pass cluster match cuts"<<std::endl;
316 if(hasEleCluster && hasPosCluster)
317 if (!
vtxSelector->passCutLt(
"eleposCluTimeDiff_lt",fabs(corr_eleClusterTime - corr_posClusterTime),weight))
320 if(
debug_)std::cout<<
" Pass ele-pos cluster time difference...and that's it!"<<std::endl;
331 if(
debug_)std::cout<<
" Filled 1D vertex plots for vtx pre-selection "<<std::endl;
335 if(
debug_)std::cout<<
" Filled 2D vertex plots for vtx pre-selection "<<std::endl;
337 if(
debug_)std::cout<<
" Filled track-cluster plots pre-selection "<<std::endl;
338 selected_tri.push_back(vtx);
342 if(
debug_) std::cout<<
"Found "<<selected_tri.size()<<
" Selected Vertices"<<std::endl;
343 _vtx_histos->Fill1DHisto(
"n_vertices_h",selected_tri.size());
358 std::vector<Vertex*> final_tri;
359 for (
auto cand : selected_tri) {
366 bool foundParts =
_ah->GetParticlesFromVtx(vtx,ele,pos);
368 if(
debug_) std::cout<<
"Checking Particles"<<std::endl;
370 std::cout<<
"TridentWABAnaProcessor::WARNING::Found vtx without ele/pos. Skip."<<std::endl;
433 double corr_eleClusterTime=666;
434 double corr_posClusterTime=666;
439 double corr_eleTrackTime=-666;
440 double corr_posTrackTime=-666;
445 bool hasEleCluster=corr_eleClusterTime>-300;
446 bool hasPosCluster=corr_posClusterTime>-300;
453 bool foundL1ele =
false;
454 bool foundL2ele =
false;
457 _ah->InnermostLayerCheck(ele_trk, foundL1ele, foundL2ele);
459 bool foundL1pos =
false;
460 bool foundL2pos =
false;
461 _ah->InnermostLayerCheck(pos_trk, foundL1pos, foundL2pos);
464 if (foundL1pos&&foundL1ele)
466 if(!foundL1pos&&foundL2pos&&foundL1ele)
468 if(foundL1pos&&!foundL1ele&&foundL2ele)
470 if(!foundL1pos&&foundL2pos&&!foundL1ele&&foundL2ele)
475 if(
debug_)std::cout<<
"passed layer cut layer combo = "<<layerCombo<<std::endl;
483 final_tri.push_back(vtx);
487 _reg_vtx_histos[region]->Fill1DHisto(
"n_vertices_h",selected_tri.size(),weight);
488 _reg_vtx_histos[region]->Fill1DHisto(
"n_vertices_passallcuts_h",nvertPass,weight);
490 if(final_tri.size()==0)
497 _ah->GetParticlesFromVtx(vtx,ele,pos);
511 std::cout<<
"***********************************"<<std::endl;
515 std::cout<<
"positron Cluster: x = "<<pos_clu.
getPosition().at(0)
537 std::cout<<
"***********************************"<<std::endl;
546 std::cout<<
"***********************************"<<std::endl;
552 if(
debug_)std::cout<<
"fsp->getTrack():: electron time = "<<ele_trk->
getTrackTime()<<std::endl;
581 _reg_tuples[region]->setVariableValue(
"unc_vtx_mass", vtx->getInvMass());
585 vtxPosSvt.SetX(vtx->getX());
586 vtxPosSvt.SetY(vtx->getY());
587 vtxPosSvt.SetZ(vtx->getZ());
588 vtxPosSvt.RotateY(-0.0305);
590 _reg_tuples[region]->setVariableValue(
"unc_vtx_z" , vtxPosSvt.Z());
701 int minHitsForMatch=3;
704 std::map<int, std::vector<int> > trueHitIDs;
706 for(
int i = 0; i <
hits_->size(); i++) {
710 std::map<int, int> nHits4part;
711 for(
int i = 0; i < trk_hits.GetEntries(); i++){
713 for(
int idI = 0; idI < trueHitIDs[eleHit->
getID()].size(); idI++ ){
714 int partID = trueHitIDs[eleHit->
getID()].at(idI);
715 if ( nHits4part.find(partID) == nHits4part.end() ) {
717 nHits4part[partID] = 1;
721 nHits4part[partID]++;
729 for (std::map<int,int>::iterator it=nHits4part.begin(); it!=nHits4part.end(); ++it){
730 if(it->second > maxNHits){
731 maxNHits = it->second;
737 if(maxNHits>=minHitsForMatch){
738 for(
int i = 0; i < mcParts.size(); i++){
739 if(mcParts.at(i)->getID() != maxID)
continue;
741 matchedMCPart=mcParts.at(i);
745 return std::pair<Track*,MCParticle*>(trk,matchedMCPart);
CalCluster getCluster() const