43 std::vector<TFile*>& inputFilesToDelete) {
45 throw cms::Exception(
"PFRecoTauDiscriminationAgainstMuonMVA::loadMVA")
46 <<
" Failed to find File = " << inputFileName <<
" !!\n";
52 throw cms::Exception(
"PFRecoTauDiscriminationAgainstMuonMVA::loadMVA")
53 <<
" Failed to load MVA = " << mvaName.data() <<
" from file = " << inputFileName.
fullPath().data()
56 inputFilesToDelete.push_back(inputFile);
69 loadMVAfromDB_ = cfg.
getParameter<
bool>(
"loadMVAfromDB");
70 if (!loadMVAfromDB_) {
75 mvaInput_ =
new float[11];
78 Muons_token = consumes<reco::MuonCollection>(srcMuons_);
92 for (std::vector<TFile*>::iterator it = inputFilesToDelete_.begin(); it != inputFilesToDelete_.end(); ++it) {
116 std::vector<TFile*> inputFilesToDelete_;
123 if (loadMVAfromDB_) {
124 mvaReader_ = &es.
getData(mvaToken_);
126 mvaReader_ = loadMVAfromFile(inputFileName_, mvaName_, inputFilesToDelete_);
137 std::vector<int>& numHitsDT,
138 std::vector<int>& numHitsCSC,
139 std::vector<int>& numHitsRPC) {
149 if (muonStation >= 0 && muonStation < 4) {
151 ++numHitsDT[muonStation];
153 ++numHitsCSC[muonStation];
155 ++numHitsRPC[muonStation];
165 edm::LogPrint(
"PFTauAgainstMuonMVA") <<
"<PFRecoTauDiscriminationAgainstMuonMVA::discriminate>:";
174 if (tau->leadPFChargedHadrCand().
isNull())
178 double tauCaloEnECAL = 0.;
179 double tauCaloEnHCAL = 0.;
180 const std::vector<reco::PFCandidatePtr>& tauSignalPFCands = tau->signalPFCands();
181 for (std::vector<reco::PFCandidatePtr>::const_iterator tauSignalPFCand = tauSignalPFCands.begin();
182 tauSignalPFCand != tauSignalPFCands.end();
184 tauCaloEnECAL += (*tauSignalPFCand)->ecalEnergy();
185 tauCaloEnHCAL += (*tauSignalPFCand)->hcalEnergy();
187 mvaInput_[1] = TMath::Sqrt(
TMath::Max(0., tauCaloEnECAL));
188 mvaInput_[2] = TMath::Sqrt(
TMath::Max(0., tauCaloEnHCAL));
189 mvaInput_[3] = tau->leadPFChargedHadrCand()->pt() /
TMath::Max(1., Double_t(tau->pt()));
190 mvaInput_[4] = TMath::Sqrt(
TMath::Max(0., tau->leadPFChargedHadrCand()->ecalEnergy()));
191 mvaInput_[5] = TMath::Sqrt(
TMath::Max(0., tau->leadPFChargedHadrCand()->hcalEnergy()));
193 std::vector<int> numHitsDT(4);
194 std::vector<int> numHitsCSC(4);
195 std::vector<int> numHitsRPC(4);
196 for (
int iStation = 0; iStation < 4; ++iStation) {
197 numHitsDT[iStation] = 0;
198 numHitsCSC[iStation] = 0;
199 numHitsRPC[iStation] = 0;
201 if (tau->leadPFChargedHadrCand().
isNonnull()) {
202 reco::MuonRef muonRef = tau->leadPFChargedHadrCand()->muonRef();
205 countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC);
209 for (
size_t idxMuon = 0; idxMuon <
numMuons; ++idxMuon) {
211 if (tau->leadPFChargedHadrCand().
isNonnull() && tau->leadPFChargedHadrCand()->muonRef().
isNonnull() &&
212 muon == tau->leadPFChargedHadrCand()->muonRef()) {
215 double dR =
deltaR(muon->
p4(), tau->p4());
216 if (dR < dRmuonMatch_) {
218 countHits(*muon, numHitsDT, numHitsCSC, numHitsRPC);
221 mvaInput_[6] = numMatches;
222 mvaInput_[7] = numHitsDT[0] + numHitsCSC[0] + numHitsRPC[0];
223 mvaInput_[8] = numHitsDT[1] + numHitsCSC[1] + numHitsRPC[1];
224 mvaInput_[9] = numHitsDT[2] + numHitsCSC[2] + numHitsRPC[2];
225 mvaInput_[10] = numHitsDT[3] + numHitsCSC[3] + numHitsRPC[3];
227 result.
rawValues.at(0) = mvaReader_->GetClassifier(mvaInput_);
238 desc.
add<
double>(
"mvaMin", 0.0);
241 desc.add<
int>(
"verbosity", 0);
242 desc.add<
bool>(
"returnMVA",
true);
244 desc.add<
bool>(
"loadMVAfromDB",
true);
250 psd1.
add<
double>(
"cut");
256 desc.add<
double>(
"dRmuonMatch", 0.3);
258 descriptions.add(
"pfRecoTauDiscriminationAgainstMuonMVA",
desc);
ParameterDescriptionBase * addOptional(U const &iLabel, T const &value)
bool isNonnull() const
Checks for non-null.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
virtual TauDiscriminatorDataType discriminate(const TauRef &tau) const =0
bool getData(T &iHolder) const
static bool muonCSCHitFilter(uint16_t pattern)
static uint32_t getHitType(uint16_t pattern)
int numberOfAllHits(HitCategory category) const
virtual void beginEvent(const edm::Event &, const edm::EventSetup &)
LocationCode location() const
Where was the file found?
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Log< level::Warning, true > LogPrint
bool isNull() const
Checks for null.
virtual TrackRef outerTrack() const
reference to Track reconstructed in the muon detector only
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
static bool muonHitFilter(uint16_t pattern)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T getParameter(std::string const &) const
int numberOfMatches(ArbitrationType type=SegmentAndTrackArbitration) const
get number of chambers with matched segments
static bool muonDTHitFilter(uint16_t pattern)
std::string fullPath() const
static uint16_t getMuonStation(uint16_t pattern)
Muon station (1-4). Only valid for muon patterns, of course. only for patterns from muon...
uint16_t getHitPattern(HitCategory category, int position) const
static bool muonRPCHitFilter(uint16_t pattern)
void countHits(const reco::Muon &muon, std::vector< int > &numHitsDT, std::vector< int > &numHitsCSC, std::vector< int > &numHitsRPC)
std::vector< float > rawValues