Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RecoTauTag] migration to stage-2 L1 #13480

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -0,0 +1,64 @@
#ifndef CaloTowerCreator_CaloTowerFromL1TCreatorForTauHLT_h
#define CaloTowerCreator_CaloTowerFromL1TCreatorForTauHLT_h

/** \class CaloTowerFromL1TCreatorForTauHLT
*
* Framework module that produces a collection
* of calo towers in the region of interest for Tau HLT reconnstruction,
* depending on tau type trigger:
* Tau1 - take location of 1st L1 Tau
* Tau2 - take location of 2nd L1 Tau; if does not exists,
* take location of 1st Calo Tower
* ETau - take L1 Tau candidate which is not collinear
* to HLT (or L1) electron candidate.
*
* \author A. Nikitenko. IC. based on L. Lista and J. Mans
*
*/

#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "DataFormats/CaloTowers/interface/CaloTower.h"
#include "DataFormats/L1Trigger/interface/Tau.h"
#include <string>

namespace edm {
class ParameterSet;
}

class CaloTowerFromL1TCreatorForTauHLT : public edm::global::EDProducer<> {
public:
/// constructor from parameter set
CaloTowerFromL1TCreatorForTauHLT( const edm::ParameterSet & );
/// destructor
~CaloTowerFromL1TCreatorForTauHLT();
///
static void fillDescriptions( edm::ConfigurationDescriptions& desc );

private:
/// process one event
void produce( edm::StreamID sid, edm::Event& evt, const edm::EventSetup& stp ) const override;

/// bunch crossing
const int mBX;
/// verbosity
const int mVerbose;
/// label of source collection
const edm::EDGetTokenT<CaloTowerCollection> mtowers_token;
/// use only towers in cone mCone around L1 candidate for regional jet reco
const double mCone;
/// label of tau trigger type analysis
const edm::EDGetTokenT<l1t::TauBxCollection> mTauTrigger_token;
/// imitator of L1 seeds
//edm::InputTag ml1seeds;
/// ET threshold
const double mEtThreshold;
/// E threshold
const double mEThreshold;
//
const int mTauId;

};

#endif
36 changes: 36 additions & 0 deletions RecoTauTag/HLTProducers/interface/L1THLTJetsMatching.h
@@ -0,0 +1,36 @@
#ifndef L1THLTJETSMATCHING_H
#define L1THLTJETSMATCHING_H

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/EDProducer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/L1Trigger/interface/Jet.h"
#include "DataFormats/JetReco/interface/CaloJetCollection.h"
#include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"


#include <map>
#include <vector>

class L1THLTJetsMatching: public edm::EDProducer {
public:
explicit L1THLTJetsMatching(const edm::ParameterSet&);
~L1THLTJetsMatching();
virtual void produce(edm::Event&, const edm::EventSetup&) override;

private:
l1t::JetVectorRef tauCandRefVec;
l1t::JetVectorRef jetCandRefVec;
l1t::JetVectorRef objL1CandRefVec;
l1t::JetRef tauCandRef;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taus at stage-2 have their own class type, the jet class is not reused (as it was in stage-1)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this module is not used anymore (since the advent of stage-1 I think) and I couldn't find it in the latest menus.
I would be for getting rid of it, if you agree.
Otherwise I'll fix it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removal is fine with me!

Copy link
Contributor

@fwyzard fwyzard Feb 25, 2016 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, then I leave the old L1HLTJetsMatching (w/o 'T') but will not add it's stage-2 sibling L1THLTJetsMatching (w/ 'T')

edm::EDGetTokenT<edm::View<reco::Candidate> > jetSrc;
edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> tauTrigger;
double mEt_Min;
};
#endif
36 changes: 36 additions & 0 deletions RecoTauTag/HLTProducers/interface/L1THLTTauMatching.h
@@ -0,0 +1,36 @@
#ifndef L1THLTTauMatching_H
#define L1THLTTauMatching_H

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/global/EDProducer.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/L1Trigger/interface/Tau.h"
#include "DataFormats/L1Trigger/interface/Jet.h"
#include "DataFormats/JetReco/interface/CaloJetCollection.h"
#include "DataFormats/TauReco/interface/PFTauFwd.h"
#include "DataFormats/HLTReco/interface/TriggerFilterObjectWithRefs.h"


#include <map>
#include <vector>
class L1THLTTauMatching: public edm::global::EDProducer<> {
public:
explicit L1THLTTauMatching(const edm::ParameterSet&);
~L1THLTTauMatching();
virtual void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:

const edm::EDGetTokenT<reco::PFTauCollection> jetSrc;
const edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> tauTrigger;
const double mEt_Min;

};
#endif
107 changes: 107 additions & 0 deletions RecoTauTag/HLTProducers/src/CaloTowerFromL1TCreatorForTauHLT.cc
@@ -0,0 +1,107 @@
// makes CaloTowerCandidates from CaloTowers
// original author: L.Lista INFN, modifyed by: F.Ratnikov UMd
// Author for regionality A. Nikitenko
// Modified by S. Gennai

#include "DataFormats/RecoCandidate/interface/RecoCaloTowerCandidate.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "RecoTauTag/HLTProducers/interface/CaloTowerFromL1TCreatorForTauHLT.h"
// Math
#include "Math/GenVector/VectorUtil.h"
#include <cmath>

using namespace edm ;
using namespace reco;
using namespace std ;

CaloTowerFromL1TCreatorForTauHLT::CaloTowerFromL1TCreatorForTauHLT( const ParameterSet & p )
:
mBX (p.getUntrackedParameter<int> ("BX" , 0) ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes physics so must be tracked.

mVerbose (p.getUntrackedParameter<int> ("verbose" , 0) ),
mtowers_token (consumes<CaloTowerCollection> (p.getParameter<InputTag> ("towers" ))),
mCone (p.getParameter<double> ("UseTowersInCone" ) ),
mTauTrigger_token (consumes<l1t::TauBxCollection> (p.getParameter<InputTag> ("TauTrigger" ))),
mEtThreshold (p.getParameter<double> ("minimumEt" ) ),
mEThreshold (p.getParameter<double> ("minimumE" ) ),
mTauId (p.getParameter<int> ("TauId" ) )
{
produces<CaloTowerCollection>();
}

CaloTowerFromL1TCreatorForTauHLT::~CaloTowerFromL1TCreatorForTauHLT() {
}

void CaloTowerFromL1TCreatorForTauHLT::produce( StreamID sid, Event& evt, const EventSetup& stp ) const {
edm::Handle<CaloTowerCollection> caloTowers;
evt.getByToken( mtowers_token, caloTowers );

// imitate L1 seeds
edm::Handle<l1t::TauBxCollection> jetsgen;
evt.getByToken( mTauTrigger_token, jetsgen);

std::auto_ptr<CaloTowerCollection> cands( new CaloTowerCollection );
cands->reserve( caloTowers->size() );

int idTau = 0;
if (jetsgen.isValid()){
for (auto myL1Jet = jetsgen->begin(mBX); myL1Jet != jetsgen->end(mBX); myL1Jet++){
if(idTau == mTauId){
double Sum08 = 0.;
unsigned idx = 0 ;
for (; idx < caloTowers->size(); idx++) {
const CaloTower* cal = &((*caloTowers) [idx]);
bool isAccepted = false;
if (mVerbose == 2) {
edm::LogInfo("JetDebugInfo") << "CaloTowerFromL1TCreatorForTauHLT::produce-> " << idx
<< " tower et/eta/phi/e: " << cal->et() << '/'
<< cal->eta() << '/'
<< cal->phi() << '/'
<< cal->energy()
<< " is...";
}
if (cal->et() >= mEtThreshold && cal->energy() >= mEThreshold ) {
math::PtEtaPhiELorentzVector p( cal->et(), cal->eta(), cal->phi(), cal->energy() );
double delta = ROOT::Math::VectorUtil::DeltaR((*myL1Jet).p4().Vect(), p);
if(delta < mCone) {
isAccepted = true;
Sum08 += cal->et();
cands->push_back( *cal );
}
}
if (mVerbose == 2){
if (isAccepted) edm::LogInfo("JetDebugInfo") << "accepted \n";
else edm::LogInfo("JetDebugInfo") << "rejected \n";
}
}
}
idTau++;
}
}
else {
edm::LogWarning("MissingProduct") << "L1Upgrade jet bx collection not found." << std::endl;
}

evt.put( cands );

}

void CaloTowerFromL1TCreatorForTauHLT::fillDescriptions( edm::ConfigurationDescriptions & desc ) {

edm::ParameterSetDescription aDesc;

aDesc.add<edm::InputTag>("TauTrigger" , edm::InputTag("l1extraParticles","Tau"))->setComment("L1ExtraJet collection for seeding" );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l1extra does not exist with stage-2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed to update the comments and oversaw that the input tag is still set to l1extra.
I am updating the PR

aDesc.add<edm::InputTag>("towers" , edm::InputTag("towerMaker" ))->setComment("Input tower collection" );
aDesc.add<int> ("TauId" , 0 )->setComment("Item from L1ExtraJet collection used for seeding" );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l1extra does not exist with stage-2

aDesc.add<double> ("UseTowersInCone", 0.8 )->setComment("Radius of cone around seed" );
aDesc.add<double> ("minimumE" , 0.8 )->setComment("Minimum tower energy" );
aDesc.add<double> ("minimumEt" , 0.5 )->setComment("Minimum tower ET" );
aDesc.addUntracked<int> ("verbose" , 0 )->setComment("Verbosity level; 0=silent" );
aDesc.addUntracked<int> ("BX" , 0 )->setComment("Set bunch crossing; 0 = in time, -1 = previous, 1 = following");

desc.add ("caloTowerMakerHLT", aDesc);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string should be the class name, at most starting with a lower-case 'c'.
Also to be different from the one in the old module!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean something like:
desc.add ("caloTowerFromL1TMakerHLT", aDesc);

desc.setComment ("Produce tower collection around L1ExtraJetParticle seed.");

}
100 changes: 100 additions & 0 deletions RecoTauTag/HLTProducers/src/L1THLTJetsMatching.cc
@@ -0,0 +1,100 @@
#include "RecoTauTag/HLTProducers/interface/L1THLTJetsMatching.h"
#include "Math/GenVector/VectorUtil.h"
#include "DataFormats/L1Trigger/interface/Jet.h"
#include "DataFormats/HLTReco/interface/TriggerTypeDefs.h"
#include "FWCore/Utilities/interface/EDMException.h"
//
// class decleration
//
using namespace reco;
using namespace std;
using namespace edm;
using namespace l1extra;

L1THLTJetsMatching::L1THLTJetsMatching(const edm::ParameterSet& iConfig)
{
jetSrc = consumes<edm::View<reco::Candidate> > (iConfig.getParameter<InputTag>("JetSrc" ) );
tauTrigger = consumes<trigger::TriggerFilterObjectWithRefs>(iConfig.getParameter<InputTag>("L1TauTrigger") );
mEt_Min = iConfig.getParameter<double> ("EtMin" ) ;

produces<CaloJetCollection>();
}

L1THLTJetsMatching::~L1THLTJetsMatching(){ }

void L1THLTJetsMatching::produce(edm::Event& iEvent, const edm::EventSetup& iES)
{

using namespace edm ;
using namespace std ;
using namespace reco ;
using namespace trigger;

typedef std::vector<LeafCandidate> LeafCandidateCollection;

auto_ptr<CaloJetCollection> tauL2jets(new CaloJetCollection);

double deltaR = 1.0;
double matchingR = 0.5;
//Getting HLT jets to be matched
edm::Handle<edm::View<Candidate> > tauJets;
iEvent.getByToken( jetSrc, tauJets );

// std::cout <<"Size of input jet collection "<<tauJets->size()<<std::endl;

edm::Handle<trigger::TriggerFilterObjectWithRefs> l1TriggeredTaus;
iEvent.getByToken(tauTrigger,l1TriggeredTaus);


tauCandRefVec.clear();
jetCandRefVec.clear();

l1TriggeredTaus->getObjects( trigger::TriggerL1TauJet,tauCandRefVec);
l1TriggeredTaus->getObjects( trigger::TriggerL1CenJet,jetCandRefVec);
math::XYZPoint a(0.,0.,0.);
CaloJet::Specific f;

for( unsigned int iL1Tau=0; iL1Tau <tauCandRefVec.size();iL1Tau++)
{
for(unsigned int iJet=0; iJet<tauJets->size(); iJet++)
{
//Find the relative L2TauJets, to see if it has been reconstructed
const Candidate & myJet = (*tauJets)[iJet];
deltaR = ROOT::Math::VectorUtil::DeltaR(myJet.p4().Vect(), (tauCandRefVec[iL1Tau]->p4()).Vect());
if(deltaR < matchingR ) {
// LeafCandidate myLC(myJet);
CaloJet myCaloJet(myJet.p4(),a,f);
if(myJet.pt() > mEt_Min) {
// tauL2LC->push_back(myLC);
tauL2jets->push_back(myCaloJet);
}
break;
}
}
}

for(unsigned int iL1Tau=0; iL1Tau <jetCandRefVec.size();iL1Tau++)
{
for(unsigned int iJet=0;iJet<tauJets->size();iJet++)
{
const Candidate & myJet = (*tauJets)[iJet];
//Find the relative L2TauJets, to see if it has been reconstructed
deltaR = ROOT::Math::VectorUtil::DeltaR(myJet.p4().Vect(), (jetCandRefVec[iL1Tau]->p4()).Vect());
if(deltaR < matchingR ) {
// LeafCandidate myLC(myJet);
CaloJet myCaloJet(myJet.p4(),a,f);
if(myJet.pt() > mEt_Min) {
//tauL2LC->push_back(myLC);
tauL2jets->push_back(myCaloJet);
}
break;
}
}
}


//std::cout <<"Size of L1HLT matched jets "<<tauL2jets->size()<<std::endl;

iEvent.put(tauL2jets);
// iEvent.put(tauL2LC);
}