CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
DeepCMVATagInfoProducer Class Reference
Inheritance diagram for DeepCMVATagInfoProducer:
edm::stream::EDProducer<>

Public Member Functions

 DeepCMVATagInfoProducer (const edm::ParameterSet &)
 
 ~DeepCMVATagInfoProducer () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 

Private Member Functions

void beginStream (edm::StreamID) override
 
void endStream () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

Private Attributes

double cMVAPtThreshold_
 
const edm::EDGetTokenT< std::vector< reco::ShallowTagInfo > > deepNNSrc_
 
const edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > elInfoSrc_
 
const edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > ipInfoSrc_
 
std::string jpbComputer_
 
std::string jpComputer_
 
const edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > muInfoSrc_
 
std::string softelComputer_
 
std::string softmuComputer_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 

Detailed Description

Definition at line 60 of file DeepCMVATagInfoProducer.cc.

Constructor & Destructor Documentation

DeepCMVATagInfoProducer::DeepCMVATagInfoProducer ( const edm::ParameterSet iConfig)
explicit

Definition at line 93 of file DeepCMVATagInfoProducer.cc.

93  :
94  deepNNSrc_(consumes< std::vector<reco::ShallowTagInfo> >(iConfig.getParameter<edm::InputTag>("deepNNTagInfos"))),
95  ipInfoSrc_(consumes< edm::View<reco::BaseTagInfo> >(iConfig.getParameter<edm::InputTag>("ipInfoSrc"))),
96  muInfoSrc_(consumes< edm::View<reco::BaseTagInfo> >(iConfig.getParameter<edm::InputTag>("muInfoSrc"))),
97  elInfoSrc_(consumes< edm::View<reco::BaseTagInfo> >(iConfig.getParameter<edm::InputTag>("elInfoSrc"))),
98  jpComputer_(iConfig.getParameter<std::string>("jpComputerSrc")),
99  jpbComputer_(iConfig.getParameter<std::string>("jpbComputerSrc")),
100  softmuComputer_(iConfig.getParameter<std::string>("softmuComputerSrc")),
101  softelComputer_(iConfig.getParameter<std::string>("softelComputerSrc")),
102  cMVAPtThreshold_(iConfig.getParameter<double>("cMVAPtThreshold"))
103 {
104 
105  produces<std::vector<reco::ShallowTagInfo> >();
106 
107 }
T getParameter(std::string const &) const
const edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > elInfoSrc_
const edm::EDGetTokenT< std::vector< reco::ShallowTagInfo > > deepNNSrc_
const edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > ipInfoSrc_
const edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > muInfoSrc_
DeepCMVATagInfoProducer::~DeepCMVATagInfoProducer ( )
override

Definition at line 110 of file DeepCMVATagInfoProducer.cc.

111 {
112 
113  // do anything here that needs to be done at destruction time
114  // (e.g. close files, deallocate resources etc.)
115 
116 }

Member Function Documentation

void DeepCMVATagInfoProducer::beginStream ( edm::StreamID  )
inlineoverrideprivate

Definition at line 68 of file DeepCMVATagInfoProducer.cc.

68 {}
void DeepCMVATagInfoProducer::endStream ( )
inlineoverrideprivate

Definition at line 70 of file DeepCMVATagInfoProducer.cc.

70 {}
void DeepCMVATagInfoProducer::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 214 of file DeepCMVATagInfoProducer.cc.

References edm::ConfigurationDescriptions::addDefault(), DEFINE_FWK_MODULE, and edm::ParameterSetDescription::setUnknown().

214  {
215  //The following says we do not know what parameters are allowed so do no validation
216  // Please change this to state exactly what you do use, even if it is no parameters
218  desc.setUnknown();
219  descriptions.addDefault(desc);
220 }
void addDefault(ParameterSetDescription const &psetDescription)
void DeepCMVATagInfoProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivate

Definition at line 125 of file DeepCMVATagInfoProducer.cc.

References cMVAPtThreshold_, deepNNSrc_, elInfoSrc_, equals, Exception, reco::TaggingVariableList::finalize(), edm::EventSetup::get(), edm::Event::getByToken(), training_settings::idx, reco::TaggingVariableList::insert(), ipInfoSrc_, reco::btau::Jet_JBP, reco::btau::Jet_JP, reco::btau::Jet_SoftEl, reco::btau::Jet_SoftMu, jpbComputer_, jpComputer_, eostools::move(), muInfoSrc_, edm::ESHandle< T >::product(), EnergyCorrector::pt, edm::Event::put(), softelComputer_, softmuComputer_, and combinedMVAV2BJetTags_cfi::tagInfos.

126 {
127  // get input TagInfos from DeepCSV
129  iEvent.getByToken(deepNNSrc_, nnInfos);
130 
131  // get other Taginfos
133  iEvent.getByToken(ipInfoSrc_, ipInfos);
135  iEvent.getByToken(muInfoSrc_, muInfos);
137  iEvent.getByToken(elInfoSrc_, elInfos);
138 
139  //get computers
141  iSetup.get<JetTagComputerRecord>().get(jpComputer_,jp);
142  const JetTagComputer* compjp = jp.product();
144  iSetup.get<JetTagComputerRecord>().get(jpbComputer_,jpb);
145  const JetTagComputer* compjpb = jpb.product();
147  iSetup.get<JetTagComputerRecord>().get(softmuComputer_,softmu);
148  const JetTagComputer* compsoftmu = softmu.product();
150  iSetup.get<JetTagComputerRecord>().get(softelComputer_,softel);
151  const JetTagComputer* compsoftel = softel.product();
152 
153  // create the output collection
154  auto tagInfos = std::make_unique<std::vector<reco::ShallowTagInfo> >();
155 
156  // loop over TagInfos, assume they are ordered in the same way, check later and throw exception if not
157  for(size_t idx = 0; idx<nnInfos->size(); ++idx) {
158  auto& nnInfo = nnInfos->at(idx);
159  auto& ipInfo = ipInfos->at(idx);
160  auto& muInfo = muInfos->at(idx);
161  auto& elInfo = elInfos->at(idx);
162 
163  if(
164  !equals(nnInfo.jet(), ipInfo.jet()) ||
165  !equals(nnInfo.jet(), muInfo.jet()) ||
166  !equals(nnInfo.jet(), elInfo.jet())
167  ) {
168  throw cms::Exception("ValueError") << "DeepNNTagInfoProducer::produce: The tagInfos taken belong to different jets!" << std::endl
169  << "This could be due to: " << std::endl
170  << " - You passed tagInfos computed on different jet collection" << std::endl
171  << " - The assumption that the tagInfos are filled in the same order is actually wrong" << std::endl;
172  }
173 
174  // Make vector of BaseTagInfo, needed for TagInfoHelper
175  std::vector<const BaseTagInfo*> ipBaseInfo;
176  ipBaseInfo.push_back(&ipInfo);
177  std::vector<const BaseTagInfo*> muBaseInfo;
178  muBaseInfo.push_back(&muInfo);
179  std::vector<const BaseTagInfo*> elBaseInfo;
180  elBaseInfo.push_back(&elInfo);
181 
182  // Copy the DeepNN TaggingVariables + add the other discriminators
183  TaggingVariableList vars = nnInfo.taggingVariables();
184  float softmu_discr = (*compsoftmu)( JetTagComputer::TagInfoHelper(muBaseInfo) );
185  float softel_discr = (*compsoftel)( JetTagComputer::TagInfoHelper(elBaseInfo) );
186  float jp_discr = (*compjp)( JetTagComputer::TagInfoHelper(ipBaseInfo) );
187  float jpb_discr = (*compjpb)( JetTagComputer::TagInfoHelper(ipBaseInfo) );
188 
189  //if jetPt larger than cMVAPtThreshold_ --> default these taggers for easier SF measurements
190  if ((nnInfo.jet().get())->pt() < cMVAPtThreshold_){
191  vars.insert(reco::btau::Jet_SoftMu, !(isinf(softmu_discr)) ? softmu_discr : -0.2 , true);
192  vars.insert(reco::btau::Jet_SoftEl, !(isinf(softel_discr)) ? softel_discr : -0.2 , true);
193  vars.insert(reco::btau::Jet_JBP, !(isinf(jpb_discr)) ? jpb_discr : -0.2 , true);
194  vars.insert(reco::btau::Jet_JP, !(isinf(jp_discr)) ? jp_discr : -0.2 , true);
195  }
196 
197  vars.finalize();
198  tagInfos->emplace_back(vars, nnInfo.jet());
199 
200  // just to be sure, clear all containers
201  ipBaseInfo.clear();
202  muBaseInfo.clear();
203  elBaseInfo.clear();
204 
205 
206  }
207 
208  // put the output in the event
209  iEvent.put( std::move(tagInfos) );
210 }
const edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > elInfoSrc_
const edm::EDGetTokenT< std::vector< reco::ShallowTagInfo > > deepNNSrc_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
const edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > ipInfoSrc_
const edm::EDGetTokenT< edm::View< reco::BaseTagInfo > > muInfoSrc_
T get() const
Definition: EventSetup.h:71
vars
Definition: DeepTauId.cc:77
T const * product() const
Definition: ESHandle.h:86
def move(src, dest)
Definition: eostools.py:511
void insert(const TaggingVariable &variable, bool delayed=false)

Member Data Documentation

double DeepCMVATagInfoProducer::cMVAPtThreshold_
private

Definition at line 78 of file DeepCMVATagInfoProducer.cc.

Referenced by produce().

const edm::EDGetTokenT< std::vector<reco::ShallowTagInfo> > DeepCMVATagInfoProducer::deepNNSrc_
private

Definition at line 73 of file DeepCMVATagInfoProducer.cc.

Referenced by produce().

const edm::EDGetTokenT< edm::View<reco::BaseTagInfo> > DeepCMVATagInfoProducer::elInfoSrc_
private

Definition at line 76 of file DeepCMVATagInfoProducer.cc.

Referenced by produce().

const edm::EDGetTokenT< edm::View<reco::BaseTagInfo> > DeepCMVATagInfoProducer::ipInfoSrc_
private

Definition at line 74 of file DeepCMVATagInfoProducer.cc.

Referenced by produce().

std::string DeepCMVATagInfoProducer::jpbComputer_
private

Definition at line 77 of file DeepCMVATagInfoProducer.cc.

Referenced by produce().

std::string DeepCMVATagInfoProducer::jpComputer_
private

Definition at line 77 of file DeepCMVATagInfoProducer.cc.

Referenced by produce().

const edm::EDGetTokenT< edm::View<reco::BaseTagInfo> > DeepCMVATagInfoProducer::muInfoSrc_
private

Definition at line 75 of file DeepCMVATagInfoProducer.cc.

Referenced by produce().

std::string DeepCMVATagInfoProducer::softelComputer_
private

Definition at line 77 of file DeepCMVATagInfoProducer.cc.

Referenced by produce().

std::string DeepCMVATagInfoProducer::softmuComputer_
private

Definition at line 77 of file DeepCMVATagInfoProducer.cc.

Referenced by produce().