23 using namespace susybsm;
38 useBetaFromTk = iConfig.
getParameter<
bool> (
"useBetaFromTk" );
39 useBetaFromMuon = iConfig.
getParameter<
bool> (
"useBetaFromMuon");
40 useBetaFromRpc = iConfig.
getParameter<
bool> (
"useBetaFromRpc" );
41 useBetaFromEcal = iConfig.
getParameter<
bool> (
"useBetaFromEcal");
49 maxInvPtDiff = iConfig.
getParameter<
double> (
"maxInvPtDiff");
51 if(useBetaFromTk )beta_calculator_TK =
new BetaCalculatorTK (iConfig, consumesCollector());
52 if(useBetaFromMuon)beta_calculator_MUON =
new BetaCalculatorMUON(iConfig, consumesCollector());
53 if(useBetaFromRpc )beta_calculator_RPC =
new BetaCalculatorRPC (iConfig, consumesCollector());
54 if(useBetaFromEcal)beta_calculator_ECAL =
new BetaCalculatorECAL(iConfig, consumesCollector());
57 std::vector<edm::ParameterSet> SelectionParameters = iConfig.
getParameter<std::vector<edm::ParameterSet> >(
"SelectionParameters");
58 for(
unsigned int i=0;
i<SelectionParameters.size();
i++){
63 produces<susybsm::HSCParticleCollection >();
64 if(useBetaFromEcal)produces<susybsm::HSCPCaloInfoCollection >();
84 using namespace susybsm;
88 iEvent.
getByToken(m_muonsToken,muonCollectionHandle);
92 iEvent.
getByToken(m_trackToken,trackCollectionHandle);
96 iEvent.
getByToken(m_trackIsoToken,trackIsoCollectionHandle);
101 std::auto_ptr<susybsm::HSCParticleCollection>
result(hscp);
104 std::auto_ptr<susybsm::HSCPCaloInfoCollection> caloInfoCollaptr(caloInfoColl);
108 *hscp = getHSCPSeedCollection(trackCollectionHandle, muonCollectionHandle);
111 for(susybsm::HSCParticleCollection::iterator hscpcandidate = hscp->begin(); hscpcandidate != hscp->end(); ++hscpcandidate) {
114 if(track.
isNull())
continue;
115 float dRMin=1000;
int found = -1;
116 for(
unsigned int t=0;
t<trackIsoCollectionHandle->size();
t++) {
118 if( fabs( (1.0/track->pt())-(1.0/Isotrack->pt())) > maxInvPtDiff)
continue;
119 float dR =
deltaR(track->momentum(), Isotrack->momentum());
120 if(dR <= minDR && dR < dRMin){ dRMin=
dR; found =
t;}
122 if(found>=0)hscpcandidate->setTrackIso(
reco::TrackRef( trackIsoCollectionHandle, found ));
127 for(susybsm::HSCParticleCollection::iterator hscpcandidate = hscp->begin(); hscpcandidate != hscp->end(); ++hscpcandidate) {
128 beta_calculator_TK->addInfoToCandidate(*hscpcandidate, iEvent,iSetup);
133 for(susybsm::HSCParticleCollection::iterator hscpcandidate = hscp->begin(); hscpcandidate != hscp->end(); ++hscpcandidate) {
134 beta_calculator_MUON->addInfoToCandidate(*hscpcandidate, iEvent,iSetup);
139 for(susybsm::HSCParticleCollection::iterator hscpcandidate = hscp->begin(); hscpcandidate != hscp->end(); ++hscpcandidate) {
140 beta_calculator_RPC->addInfoToCandidate(*hscpcandidate, iEvent, iSetup);
149 caloInfoColl->resize(hscp->size());
150 for(susybsm::HSCParticleCollection::iterator hscpcandidate = hscp->begin(); hscpcandidate != hscp->end(); ++hscpcandidate, Index++) {
151 beta_calculator_ECAL->addInfoToCandidate(*hscpcandidate,trackCollectionHandle,iEvent,iSetup, (*caloInfoColl)[Index]);
155 for(
int i=0;
i<(int)hscp->size();
i++) {
156 susybsm::HSCParticleCollection::iterator hscpcandidate = hscp->begin() +
i;
157 bool decision =
false;
158 for(
unsigned int s=0;
s<Selectors.size();
s++){decision |= Selectors[
s]->isSelected(*hscpcandidate);}
160 hscp->erase(hscpcandidate);
161 if(useBetaFromEcal)caloInfoColl->erase(caloInfoColl->begin() +
i);
165 bool filterResult = !Filter_ || (Filter_ && hscp->size()>=1);
174 for(
int i=0;
i<(int)hscp->size();
i++) {
175 susybsm::HSCParticleCollection::iterator hscpcandidate = hscp->begin() +
i;
207 std::vector<HSCParticle> HSCPCollection;
210 std::vector<reco::TrackRef>
tracks;
211 for(
unsigned int i=0;
i<trackCollectionHandle->size();
i++){
213 if(track->p()<minTkP || (track->chi2()/track->ndof())>maxTkChi2 || track->found()<minTkHits)
continue;
214 tracks.push_back( track );
218 for(
unsigned int m=0;
m<muonCollectionHandle->size();
m++){
220 if(muon->p()<minMuP )
continue;
221 TrackRef innertrack = muon->innerTrack();
222 if(innertrack.
isNull())
continue;
226 float dRMin=1000;
int found = -1;
227 for(
unsigned int t=0;
t<tracks.size();
t++) {
229 if( fabs( (1.0/innertrack->pt())-(1.0/track->pt())) > maxInvPtDiff)
continue;
230 float dR =
deltaR(innertrack->momentum(), track->momentum());
231 if(dR <= minDR && dR < dRMin){ dRMin=
dR; found =
t;}
239 tracks.erase(tracks.begin()+
found);
241 HSCPCollection.push_back(candidate);
245 for(
unsigned int m=0;
m<muonCollectionHandle->size();
m++){
247 if(muon->p()<minMuP)
continue;
248 TrackRef innertrack = muon->innerTrack();
252 float dRMin=1000;
int found = -1;
253 for(
unsigned int t=0;
t<tracks.size();
t++) {
255 if( fabs( (1.0/muon->pt())-(1.0/track->pt())) > maxInvPtDiff)
continue;
256 float dR =
deltaR(muon->momentum(), track->momentum());
257 if(dR <= minDR && dR < dRMin){ dRMin=
dR; found =
t;}
265 tracks.erase(tracks.begin()+
found);
267 HSCPCollection.push_back(candidate);
271 for(
unsigned int i=0;
i<tracks.size();
i++){
274 HSCPCollection.push_back(candidate);
277 return HSCPCollection;
void setMuon(const reco::MuonRef &data)
T getParameter(std::string const &) const
std::vector< susybsm::HSCParticle > getHSCPSeedCollection(edm::Handle< reco::TrackCollection > &trackCollectionHandle, edm::Handle< reco::MuonCollection > &muonCollectionHandle)
std::vector< HSCPCaloInfo > HSCPCaloInfoCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
bool isNonnull() const
Checks for non-null.
edm::Ref< HSCPCaloInfoCollection > HSCPCaloInfoRef
std::vector< HSCParticle > HSCParticleCollection
bool isNull() const
Checks for null.
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
edm::Ref< MuonCollection > MuonRef
presistent reference to a Muon
double deltaR(double eta1, double eta2, double phi1, double phi2)
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
HSCParticleProducer(const edm::ParameterSet &)
virtual bool filter(edm::Event &, const edm::EventSetup &)
void setTrack(const reco::TrackRef &data)