CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ImpactParameter.cc
Go to the documentation of this file.
1 /* class ImpactParameter
2  * EDProducer for TauImpactParameterInfoCollection
3  * author: Andrea Rizzi
4  */
5 
6 // system include files
7 #include <memory>
8 
9 // user include files
17 
19 
25 
27 
29 
30 
32 public:
33  explicit ImpactParameter(const edm::ParameterSet&);
35 
36 
37  virtual void produce(edm::Event&, const edm::EventSetup&);
38 private:
43 };
44 
45 
46 //
47 // constructors and destructor
48 //
50 
51  jetTrackSrc = iConfig.getParameter<edm::InputTag>("JetTagProd");
52  vertexSrc = iConfig.getParameter<edm::InputTag>("vertexSrc");
53  usingVertex = iConfig.getParameter<bool>("useVertex");
54 
55  algo = new ImpactParameterAlgorithm(iConfig);
56 
57  std::string modulname = iConfig.getParameter<std::string>( "@module_label" );
58  produces<reco::JetTagCollection>().setBranchAlias(modulname);
59  std::string infoBranchName = modulname + "Info";
60  produces<reco::TauImpactParameterInfoCollection>().setBranchAlias(infoBranchName);
61 }
62 
63 
65  delete algo;
66 }
67 
68 
69 
70 //
71 // member functions
72 //
73 // ------------ method called to produce the data ------------
75 
76  using namespace reco;
77 
79  iEvent.getByLabel(jetTrackSrc,isolatedTaus);
80 
81  std::unique_ptr<JetTagCollection> tagCollection;
82  auto extCollection = std::make_unique<TauImpactParameterInfoCollection>();
83  if (not isolatedTaus->empty()) {
84  edm::RefToBaseProd<reco::Jet> prod( edm::makeRefToBaseProdFrom(isolatedTaus->begin()->jet(), iEvent) );
85  tagCollection = std::make_unique<JetTagCollection>(prod);
86  } else {
87  tagCollection = std::make_unique<JetTagCollection>();
88  }
89 
91  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",builder);
92  algo->setTransientTrackBuilder(builder.product());
93 
94  Vertex PV;
95  if (usingVertex) {
97  iEvent.getByLabel(vertexSrc,vertices);
98 
99  const reco::VertexCollection vertCollection = *(vertices.product());
100  reco::VertexCollection::const_iterator iVertex;
101 
102  for(iVertex = vertCollection.begin();iVertex!=vertCollection.end();iVertex++){
103  PV = *iVertex;
104  }
105 
106  } else {
108  e(0,0)=0;
109  e(1,1)=0;
110  e(2,2)=0;
111  Vertex::Point p(0,0,0);
112 
113  Vertex dummyPV(p,e,1,1,1);
114  PV = dummyPV;
115  }
116 
117  for (unsigned int i = 0; i < isolatedTaus->size(); ++i) {
118  IsolatedTauTagInfoRef tauRef(isolatedTaus, i);
119  std::pair<float, TauImpactParameterInfo> ipInfo = algo->tag(tauRef,PV);
120  tagCollection->setValue(i, ipInfo.first);
121  extCollection->push_back(ipInfo.second);
122  }
123 
124  iEvent.put(std::move(extCollection));
125  iEvent.put(std::move(tagCollection));
126 }
127 
128 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
virtual void produce(edm::Event &, const edm::EventSetup &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
int iEvent
Definition: GenABIO.cc:230
void setTransientTrackBuilder(const TransientTrackBuilder *)
def move
Definition: eostools.py:510
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:413
ImpactParameter(const edm::ParameterSet &)
T const * product() const
Definition: Handle.h:81
edm::InputTag jetTrackSrc
const T & get() const
Definition: EventSetup.h:56
ImpactParameterAlgorithm * algo
edm::InputTag vertexSrc
RefToBaseProd< T > makeRefToBaseProdFrom(RefToBase< T > const &iRef, Event const &iEvent)
std::pair< float, reco::TauImpactParameterInfo > tag(const reco::IsolatedTauTagInfoRef &, const reco::Vertex &)