44 std::vector<TFile*>& inputFilesToDelete) {
46 throw cms::Exception(
"PFRecoTauDiscriminationAgainstMuonMVA::loadMVA")
53 throw cms::Exception(
"PFRecoTauDiscriminationAgainstMuonMVA::loadMVA")
54 <<
" Failed to load MVA = " <<
mvaName.data() <<
" from file = " <<
inputFileName.fullPath().data()
72 moduleLabel_(
cfg.getParameter<
std::
string>(
"@module_label")),
76 loadMVAfromDB_ =
cfg.getParameter<
bool>(
"loadMVAfromDB");
77 if (!loadMVAfromDB_) {
80 mvaInput_ =
new float[11];
83 Muons_token = consumes<reco::MuonCollection>(srcMuons_);
84 dRmuonMatch_ =
cfg.getParameter<
double>(
"dRmuonMatch");
86 verbosity_ =
cfg.getParameter<
int>(
"verbosity");
97 for (std::vector<TFile*>::iterator it = inputFilesToDelete_.begin(); it != inputFilesToDelete_.end(); ++it) {
120 std::vector<TFile*> inputFilesToDelete_;
127 if (loadMVAfromDB_) {
130 mvaReader_ = loadMVAfromFile(inputFileName_, mvaName_, inputFilesToDelete_);
141 std::vector<int>& numHitsDT,
142 std::vector<int>& numHitsCSC,
143 std::vector<int>& numHitsRPC) {
144 if (
muon.outerTrack().isNonnull()) {
153 if (muonStation >= 0 && muonStation < 4) {
155 ++numHitsDT[muonStation];
157 ++numHitsCSC[muonStation];
159 ++numHitsRPC[muonStation];
169 edm::LogPrint(
"PFTauAgainstMuonMVA") <<
"<PFRecoTauDiscriminationAgainstMuonMVA::discriminate>:";
170 edm::LogPrint(
"PFTauAgainstMuonMVA") <<
" moduleLabel = " << moduleLabel_;
175 result.rawValues = {-1., 0.};
178 if (
tau->leadPFChargedHadrCand().isNull())
182 double tauCaloEnECAL = 0.;
183 double tauCaloEnHCAL = 0.;
184 const std::vector<reco::PFCandidatePtr>& tauSignalPFCands =
tau->signalPFCands();
185 for (std::vector<reco::PFCandidatePtr>::const_iterator tauSignalPFCand = tauSignalPFCands.begin();
186 tauSignalPFCand != tauSignalPFCands.end();
188 tauCaloEnECAL += (*tauSignalPFCand)->ecalEnergy();
189 tauCaloEnHCAL += (*tauSignalPFCand)->hcalEnergy();
191 mvaInput_[1] = TMath::Sqrt(
TMath::Max(0., tauCaloEnECAL));
192 mvaInput_[2] = TMath::Sqrt(
TMath::Max(0., tauCaloEnHCAL));
193 mvaInput_[3] =
tau->leadPFChargedHadrCand()->pt() /
TMath::Max(1., Double_t(
tau->pt()));
194 mvaInput_[4] = TMath::Sqrt(
TMath::Max(0.,
tau->leadPFChargedHadrCand()->ecalEnergy()));
195 mvaInput_[5] = TMath::Sqrt(
TMath::Max(0.,
tau->leadPFChargedHadrCand()->hcalEnergy()));
197 std::vector<int> numHitsDT(4);
198 std::vector<int> numHitsCSC(4);
199 std::vector<int> numHitsRPC(4);
200 for (
int iStation = 0; iStation < 4; ++iStation) {
201 numHitsDT[iStation] = 0;
202 numHitsCSC[iStation] = 0;
203 numHitsRPC[iStation] = 0;
205 if (
tau->leadPFChargedHadrCand().isNonnull()) {
209 countHits(*muonRef, numHitsDT, numHitsCSC, numHitsRPC);
213 for (
size_t idxMuon = 0; idxMuon <
numMuons; ++idxMuon) {
215 if (
tau->leadPFChargedHadrCand().isNonnull() &&
tau->leadPFChargedHadrCand()->muonRef().isNonnull() &&
216 muon ==
tau->leadPFChargedHadrCand()->muonRef()) {
220 if (
dR < dRmuonMatch_) {
225 mvaInput_[6] = numMatches;
226 mvaInput_[7] = numHitsDT[0] + numHitsCSC[0] + numHitsRPC[0];
227 mvaInput_[8] = numHitsDT[1] + numHitsCSC[1] + numHitsRPC[1];
228 mvaInput_[9] = numHitsDT[2] + numHitsCSC[2] + numHitsRPC[2];
229 mvaInput_[10] = numHitsDT[3] + numHitsCSC[3] + numHitsRPC[3];
231 result.rawValues.at(0) = mvaReader_->GetClassifier(mvaInput_);
235 return result.rawValues.at(0);
242 desc.
add<
double>(
"mvaMin", 0.0);
243 desc.add<
std::string>(
"mvaName",
"againstMuonMVA");
245 desc.add<
int>(
"verbosity", 0);
246 desc.add<
bool>(
"returnMVA",
true);
248 desc.add<
bool>(
"loadMVAfromDB",
true);
254 psd1.
add<
double>(
"cut");
260 desc.
add<
double>(
"dRmuonMatch", 0.3);
262 descriptions.add(
"pfRecoTauDiscriminationAgainstMuonMVA", desc);