CMS 3D CMS Logo

ZMuMuTrackUserData.cc
Go to the documentation of this file.
8 
14 
18 
19 #include <vector>
20 
21 using namespace edm;
22 using namespace std;
23 using namespace reco;
24 using namespace isodeposit;
25 //using namespace pat;
26 
28 public:
30 private:
31  void produce( edm::Event &, const edm::EventSetup & ) override;
32 
36  double ptThreshold_, etEcalThreshold_, etHcalThreshold_ ,dRVetoTrk_, dRTrk_, dREcal_ , dRHcal_;
37  double alpha_, beta_;
38  template<typename T>
39  vector<double> isolation(const T & t, double ptThreshold, double etEcalThreshold, double etHcalThreshold , double dRVetoTrk, double dRTrk, double dREcal , double dRHcal, double alpha, double beta);
40 
41 };
42 
43 template<typename T>
44 vector<double> ZMuMuTrackUserData::isolation(const T & t, double ptThreshold, double etEcalThreshold, double etHcalThreshold , double dRVetoTrk, double dRTrk, double dREcal , double dRHcal, double alpha, double beta) {
45 
46  vector<double> iso;
47  const pat::IsoDeposit * trkIso = t.isoDeposit(pat::TrackIso);
48  const pat::IsoDeposit * ecalIso = t.isoDeposit(pat::EcalIso);
49  const pat::IsoDeposit * hcalIso = t.isoDeposit(pat::HcalIso);
50 
51  Direction dir = Direction(t.eta(), t.phi());
52 
53 
55  vetosTrk.push_back(new ConeVeto( dir, dRVetoTrk ));
56  vetosTrk.push_back(new ThresholdVeto( ptThreshold ));
57 
58  pat::IsoDeposit::AbsVetos vetosEcal;
59  vetosEcal.push_back(new ConeVeto( dir, 0.));
60  vetosEcal.push_back(new ThresholdVeto( etEcalThreshold ));
61 
62  pat::IsoDeposit::AbsVetos vetosHcal;
63  vetosHcal.push_back(new ConeVeto( dir, 0. ));
64  vetosHcal.push_back(new ThresholdVeto( etHcalThreshold ));
65 
66  double isovalueTrk = (trkIso->sumWithin(dRTrk,vetosTrk));
67  double isovalueEcal = (ecalIso->sumWithin(dREcal,vetosEcal));
68  double isovalueHcal = (hcalIso->sumWithin(dRHcal,vetosHcal));
69 
70  iso.push_back(isovalueTrk);
71  iso.push_back(isovalueEcal);
72  iso.push_back(isovalueHcal);
73 
74  //double iso = isovalueTrk + isovalueEcal + isovalueHcal;
75  double combIso = alpha*( ((1+beta)/2*isovalueEcal) + ((1-beta)/2*isovalueHcal) ) + ((1-alpha)*isovalueTrk);
76 
77  iso.push_back(combIso);
78  double relIso = combIso /= t.pt();
79  iso.push_back(relIso);
80  return iso;
81 }
82 
84  srcToken_(consumes<vector<pat::GenericParticle> > ( cfg.getParameter<InputTag>( "src" ) ) ),
85  beamSpotToken_(consumes<BeamSpot> (cfg.getParameter<InputTag>( "beamSpot" ) ) ),
86  primaryVerticesToken_(consumes<VertexCollection> (cfg.getParameter<InputTag>( "primaryVertices" ) ) ),
87  ptThreshold_(cfg.getParameter<double >("ptThreshold") ),
88  etEcalThreshold_(cfg.getParameter<double >("etEcalThreshold") ),
89  etHcalThreshold_(cfg.getParameter<double >("etHcalThreshold") ),
90  dRVetoTrk_(cfg.getParameter<double >("dRVetoTrk") ),
91  dRTrk_(cfg.getParameter<double >("dRTrk") ),
92  dREcal_(cfg.getParameter<double >("dREcal") ),
93  dRHcal_(cfg.getParameter<double >("dRHcal") ),
94  alpha_(cfg.getParameter<double>("alpha") ),
95  beta_(cfg.getParameter<double>("beta") ){
96  produces<std::vector<pat::GenericParticle> >();
97 }
98 
101  evt.getByToken(srcToken_,tracks);
102 
103  Handle<BeamSpot> beamSpotHandle;
104  evt.getByToken(beamSpotToken_, beamSpotHandle);
105 
106  Handle<VertexCollection> primaryVertices; // Collection of primary Vertices
107  evt.getByToken(primaryVerticesToken_, primaryVertices);
108 
109  unique_ptr<vector<pat::GenericParticle> > tkColl( new vector<pat::GenericParticle> (*tracks) );
110  for (unsigned int i = 0; i< tkColl->size();++i){
111  pat::GenericParticle & tk = (*tkColl)[i];
113  tk.setIsolation(pat::User1Iso, iso[0]);
114  // cout << "track User1Iso " << iso[0] << endl;
115  tk.setIsolation(pat::User2Iso, iso[1]);
116  //cout << "track User2Iso " << iso[1] << endl;
117  tk.setIsolation(pat::User3Iso, iso[2]);
118  //cout << "track User3Iso " << iso[2] << endl;
119  tk.setIsolation(pat::User4Iso, iso[3]);
120  //cout << "track User4Iso " << iso[3] << endl;
121  tk.setIsolation(pat::User5Iso, iso[4]);
122  //cout << "track User5Iso " << iso[4] << endl;
123 
124 
125 
126  float zDaudxyFromBS = -1 ;
127  float zDaudzFromBS = -1;
128  float zDaudxyFromPV = -1;
129  float zDaudzFromPV = -1;
130  float zDauNofMuChambers = -1;
131  float zDauNofMuMatches = -1;
132  float zDauChi2 = -1;
133  float zDauTrkChi2 = -1;
134  float zDauSaChi2 = -1;
135  float zDauNofMuonHits =- 1;
136  float zDauNofStripHits = -1;
137  float zDauNofPixelHits = -1;
138  float zDauMuEnergyEm = -1;
139  float zDauMuEnergyHad = -1;
140 
141  TrackRef muTrkRef = tk.track();
142  if (muTrkRef.isNonnull()){
143  zDaudxyFromBS = muTrkRef->dxy(beamSpotHandle->position());
144  zDaudzFromBS = muTrkRef->dz(beamSpotHandle->position());
145  zDaudxyFromPV = muTrkRef->dxy(primaryVertices->begin()->position() );
146  zDaudzFromPV = muTrkRef->dz(primaryVertices->begin()->position() );
147  zDauChi2 = muTrkRef->normalizedChi2();
148  zDauTrkChi2 = muTrkRef->normalizedChi2();
149  zDauNofStripHits = muTrkRef->hitPattern().numberOfValidStripHits();
150  zDauNofPixelHits = muTrkRef->hitPattern().numberOfValidPixelHits();
151  }
152  tk.addUserFloat("zDau_dxyFromBS", zDaudxyFromBS);
153  tk.addUserFloat("zDau_dzFromBS", zDaudzFromBS);
154  tk.addUserFloat("zDau_dxyFromPV", zDaudxyFromPV);
155  tk.addUserFloat("zDau_dzFromPV", zDaudzFromPV);
156  tk.addUserFloat("zDau_NofMuonHits" , zDauNofMuonHits );
157  tk.addUserFloat("zDau_TrkNofStripHits" , zDauNofStripHits );
158  tk.addUserFloat("zDau_TrkNofPixelHits" , zDauNofPixelHits );
159  tk.addUserFloat("zDau_NofMuChambers", zDauNofMuChambers);
160  tk.addUserFloat("zDau_NofMuMatches", zDauNofMuMatches);
161  tk.addUserFloat("zDau_Chi2", zDauChi2);
162  tk.addUserFloat("zDau_TrkChi2", zDauTrkChi2);
163  tk.addUserFloat("zDau_SaChi2", zDauSaChi2);
164  tk.addUserFloat("zDau_MuEnergyEm", zDauMuEnergyEm);
165  tk.addUserFloat("zDau_MuEnergyHad", zDauMuEnergyHad);
166 
167 
168  }
169 
170  evt.put(std::move(tkColl));
171 }
172 
174 
176 
float alpha
Definition: AMPTWrapper.h:95
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:253
void setIsolation(IsolationKeys key, float value)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
ZMuMuTrackUserData(const edm::ParameterSet &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
void produce(edm::Event &, const edm::EventSetup &) override
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:813
double sumWithin(double coneSize, const AbsVetos &vetos=AbsVetos(), bool skipDepositVeto=false) const
Definition: IsoDeposit.cc:138
Definition: HeavyIon.h:7
Analysis-level Generic Particle class (e.g. for hadron or muon not fully reconstructed) ...
vector< double > isolation(const T &t, double ptThreshold, double etEcalThreshold, double etHcalThreshold, double dRVetoTrk, double dRTrk, double dREcal, double dRHcal, double alpha, double beta)
EDGetTokenT< vector< pat::GenericParticle > > srcToken_
primaryVertices
Definition: jets_cff.py:130
reco::TrackRef track() const override
EDGetTokenT< VertexCollection > primaryVerticesToken_
fixed size matrix
HLT enums.
const Point & position() const
position
Definition: BeamSpot.h:62
dbl *** dir
Definition: mlp_gen.cc:35
EDGetTokenT< BeamSpot > beamSpotToken_
isodeposit::AbsVetos AbsVetos
Definition: IsoDeposit.h:51
long double T
def move(src, dest)
Definition: eostools.py:511