24 #include "CLHEP/Random/RandFlat.h"
26 #include "GaudiKernel/IToolSvc.h"
45 m_muonSelectionTool(
"CP::MuonSelectionTool/MuonSelectionTool"),
47 m_doQualSelection ( false ),
48 m_doIsoSelection ( false ),
49 m_doPtSelection ( true ),
50 m_doIPSelection ( true ),
51 m_doMCPSelection ( true )
116 ISvcLocator* serviceLocator = Gaudi::svcLocator();
118 StatusCode sc = serviceLocator->service(
"ToolSvc", toolSvc,
true);
120 if (
sc.isFailure() || toolSvc ==
nullptr ) {
121 (*m_msgStream) << MSG::ERROR <<
" * MuonSelector::Init * Unable to retrieve ToolSvc " <<
endmsg;
127 ( *m_msgStream) << MSG::INFO <<
" * MuonSelector::Init * m_muonSelectionTool.initialize() success :)" <<
endmsg;
128 if(
m_doDebug){ std::cout <<
" * MuonSelector::Init * m_muonSelectionTool.initialize() success :)" << std::endl;}
131 (*m_msgStream) << MSG::ERROR <<
" * MuonSelector::Init * FAILURE * Muon selction tool retrieving failed :( " <<
endmsg;
148 if(
m_doDebug){ std::cout <<
" * MuonSelector::passSelection * START * new muon " << pxMuon <<
" with pt: " << pxMuon->
pt() << std::endl; }
150 std::vector<bool> passes;
160 passes.push_back(pass);
161 if (
m_doDebug && !pass) std::cout <<
" * MuonSelector::passSelection * Muon Fails QualSelection"<<std::endl;
167 passes.push_back(pass);
168 if (
m_doDebug && !pass) std::cout<<
" * MuonSelector::passSelection * Muon Fails Iso Selection"<<std::endl;
175 passes.push_back(pass);
176 if (
m_doDebug && !pass) std::cout<<
" * MuonSelector::passSelection * Muon Fails pT Selection"<<std::endl;
182 passes.push_back(pass);
183 if (
m_doDebug && !pass) std::cout<<
" * MuonSelector::passSelection * Muon Fails IP Selection"<<std::endl;
189 if (
m_doDebug) std::cout <<
" * MuonSelector::passSelection * muon quality from muonsSelectionTool: " << my_quality << std::endl;
197 passes.push_back(pass);
198 if (
m_doDebug && pass) std::cout<<
" * MuonSelector::passSelection * Muon Passes official m_muonSelectionTool (medium) Selection :)" << std::endl;
199 if (
m_doDebug && !pass) std::cout<<
" * MuonSelector::passSelection * Muon Fails official m_muonSelectionTool (medium) Selection" << std::endl;
204 for (
int i=0;
i <
int(passes.size());
i++)
206 if(
m_doDebug) std::cout <<
" * MuonSelector::passSelection * BAD MUON * muon haven't passed the " <<
i+1 <<
"th selection " << std::endl;
213 if(
m_doDebug){ std::cout <<
" * MuonSelector::passSelection * completed. GOOD MUON " << std::endl; }
231 bool goodTrack =
false;
254 if(
m_doDebug) std::cout <<
" * MuonSelector * passQualCuts() * eBLhits: " << eBLhits
255 <<
" nBLhits: " << nBLhits
256 <<
" nhitsPIX: " << nhitsPIX
257 <<
" nPIXLayers: " << nContribPixLayers
258 <<
" nhitsSCT: " << nhitsSCT
259 <<
" Silicon holes: " << nPIXH + nSCTH
260 <<
" nhitsTRT: " << nhitsTRT
261 <<
" nTRTholes: " << nTRTH
264 if (((!eBLhits) || (nBLhits > 0))
265 && (nhitsPIX + nPIXDS > 1 )
266 && (nhitsSCT + nSCTDS >=6 )
267 && (nPIXH + nSCTH < 2 ) ) {
274 std::cout <<
" * MuonSelector * passQualCuts() * this muon satisfies the hits number QualCuts " << std::endl;
277 std::cout <<
" * MuonSelector * passQualCuts() * this muon did not pass the hits number QualCuts " << std::endl;
287 if(
m_doDebug) std::cout <<
" * MuonSelector::passPtCuts * START *" << std::endl;
293 double pt = 0, ptID, ptMS,ptCB;
295 if ( !(pxMuonID || pxMuonMS || pxMuonCB)){
296 if(
m_doDebug) std::cout <<
" * MuonSelector::passPtCuts * NO inDetTrackParticle && muonSpectrometerTrackParticle && CombinedTrackParticle: " << std::endl;
302 ptID = pxMuonID ? pxMuonID->
pt() : 0.0 ;
303 ptMS = pxMuonMS ? pxMuonMS->
pt() : 0.0 ;
304 ptCB = pxMuonCB ? pxMuonCB->
pt() : 0.0 ;
307 if(
m_doDebug) std::cout <<
" * MuonSelector::passPtCuts * pt of each segments of this muon pxMuon: " <<
pt << std::endl
308 <<
" ptID: " << ptID << std::endl
309 <<
" ptMS: " << ptMS << std::endl
310 <<
" ptCB: " << ptCB << std::endl
311 <<
" fMEta pxMuon->eta(): " << fMEta << std::endl;
320 if(
m_doDebug) std::cout <<
" * MuonSelector::passPtCuts * this muon is in eta range |eta|= " << fMEta <<
" < EtaCut(" <<
m_fEtaCut <<
") " << std::endl
321 <<
" and passed the PtCuts (" <<
m_combPtCut <<
") "<< std::endl;
325 if(
m_doDebug) std::cout <<
" * MuonSelector::passPtCuts * this muon did not pass the PtCuts (reco pt=" <<
pt <<
") or Eta cut " <<
m_fEtaCut << std::endl;
335 std::cout <<
" * MuonSelector::passIsolCuts * WARNING * No isolation variable stored on the muon" << std::endl;
336 std::cout <<
" * MuonSelector::passIsolCuts * this muon did not pass the IsoCuts " << std::endl;
344 if(
m_doDebug) std::cout <<
" * MuonSelector::passIsolCuts * muon pt: " <<
pt <<
" ptSum(ptcone40): "<< ptSum << std::endl;
346 if(
m_doDebug) std::cout <<
" * MuonSelector::passIsolCuts * this muon passed the IsoCuts ptcone40 / pt= "
347 << ptSum <<
" / " <<
pt <<
" = " << ptSum /
pt
348 <<
" < IsoCut(" <<
m_IsoCut <<
") " << std::endl;
353 if(
m_doDebug) std::cout <<
" * MuonSelector::passIsolCuts * this muon did not pass the IsoCuts:" << std::endl;
368 if (
m_doDebug) std::cout <<
" * MuonSelector::passIPCuts * no IDTrk --> IP failure" << std::endl;
372 extz0 = IDTrk->
z0()+IDTrk->
vz();
374 std::cout <<
" * MuonSelector::passIPCuts *"
375 <<
" the IDTrack muon d0: " << extd0
376 <<
" the IDTrack muon z0: " << extz0 <<
" = " << IDTrk->
z0() <<
" + " << IDTrk->
vz() << std::endl;
380 if(
m_doDebug) std::cout <<
" * MuonSelector * passIPCuts() * no valid inDetTrackParticleLink(). Will use the combined muon IPs" << std::endl;
384 if(
m_doDebug) std::cout <<
" * MuonSelector * passIPCuts() * no valid CombinedTrackParticle. Giving up." << std::endl;
389 extz0 = CBTrk->
z0()+CBTrk->
vz();
391 std::cout <<
" * MuonSelector * passIPCuts() *"
392 <<
" the CBTrack muon d0: " << extd0
393 <<
" the CBTrack muon z0: " << extz0 <<
" = " << CBTrk->
z0() <<
" + " << CBTrk->
vz()<< std::endl;
402 if(
m_doDebug) std::cout <<
" * MuonSelector::passIPCuts ** fails because NO vertex collection "<< std::endl;
406 if ( vxContainer->
size()>1 ) {
408 std::cout <<
" * MuonSelector::passIPCuts ** vertex container is filled with " << vxContainer->
size() <<
" vertices" << std::endl;
411 for (
int ivtx=0; ivtx < (
int) vxContainer->
size(); ivtx++) {
413 std::cout <<
" vertex " << ivtx+1 <<
" (x,y,z) = (" << thisVtx->
position().x()
424 bool goodmuonIP =
false;
425 float minDeltaZ = 99999.;
427 for (
int ivtx=0; ivtx < (
int) vxContainer->
size(); ivtx++) {
431 if (std::abs(extz0 - thisVtx->
position().z()) < minDeltaZ) minDeltaZ = std::abs(extz0 - thisVtx->
position().z());
435 std::cout <<
" testing vtx: " << ivtx <<
" vtx.z= " << thisVtx->
position().z() <<
" trk.z= " << extz0 <<
" deltaZ= " << std::abs(extz0 - thisVtx->
position().z()) <<
" minDeltaZ= " << minDeltaZ << std::endl;
439 if(
m_doDebug) std::cout <<
" * MuonSelector::passIPCuts * this muon has passed the IPCuts for vertex " << ivtx+1
440 <<
" pVZcut= " << std::abs(extz0 - thisVtx->
position().z()) <<
" < " <<
m_diffZCut << std::endl
451 if(
m_doDebug) std::cout <<
" * MuonSelector::passIPCuts * this muon has passed the IPCuts. Zcut: "<<
m_pVZCut <<
" m_diffZCut " <<
m_diffZCut << std::endl;
456 if(
m_doDebug) std::cout <<
" * MuonSelector * passIPCuts() * this muon has not passed the IPCuts: " << std::endl;
464 std::cout <<
" * MuonSelector* -- STATS -- " << std::endl
471 std::cout <<
" passall : " <<
m_passall << std::endl
482 for_each (
newname.begin(),
newname.end(), [](
char &
c) {c = std::toupper(c);} );