test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
cms::DiJetAnalyzer Class Reference

#include <DiJetAnalyzer.h>

Inheritance diagram for cms::DiJetAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 DiJetAnalyzer (const edm::ParameterSet &)
 
 ~DiJetAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 

Private Attributes

bool allowMissingInputs_
 
TClonesArray * cells
 
Float_t emEnergy
 
Float_t etVetoJet
 
UInt_t eventNumber
 
std::string fOutputFileName
 
TFile * hOutputFile
 
Int_t iEtaHit
 
UInt_t iPhiHit
 
HcalRespCorrsoldRespCorrs
 
Float_t probeJetEmFrac
 
TLorentzVector * probeJetP4
 
Float_t PxTrkHcal
 
Float_t PyTrkHcal
 
Float_t PzTrkHcal
 
UInt_t runNumber
 
Float_t tagJetEmFrac
 
TLorentzVector * tagJetP4
 
Float_t targetE
 
edm::EDGetTokenT
< EcalRecHitCollection
tok_ec_
 
edm::EDGetTokenT
< HBHERecHitCollection
tok_hbhe_
 
edm::EDGetTokenT
< HFRecHitCollection
tok_hf_
 
edm::EDGetTokenT
< HORecHitCollection
tok_ho_
 
edm::EDGetTokenT
< reco::CaloJetCollection
tok_jets_
 
TTree * tree
 
Float_t xTrkHcal
 
Float_t yTrkHcal
 
Float_t zTrkHcal
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 51 of file DiJetAnalyzer.h.

Constructor & Destructor Documentation

cms::DiJetAnalyzer::DiJetAnalyzer ( const edm::ParameterSet iConfig)
explicit

Definition at line 33 of file DiJetAnalyzer.cc.

References allowMissingInputs_, fOutputFileName, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), AlCaHLTBitMon_QueryRunRegistry::string, tok_ec_, tok_hbhe_, tok_hf_, tok_ho_, and tok_jets_.

34 {
35  tok_jets_ = consumes<reco::CaloJetCollection>(iConfig.getParameter<edm::InputTag>("jetsInput"));
36  tok_ec_ = consumes<EcalRecHitCollection>(iConfig.getParameter<edm::InputTag>("ecInput"));
37  tok_hbhe_ = consumes<HBHERecHitCollection>(iConfig.getParameter<edm::InputTag>("hbheInput"));
38  tok_ho_ = consumes<HORecHitCollection>(iConfig.getParameter<edm::InputTag>("hoInput"));
39  tok_hf_ = consumes<HFRecHitCollection>(iConfig.getParameter<edm::InputTag>("hfInput"));
40 
41  // get name of output file with histogramms
42  fOutputFileName = iConfig.getUntrackedParameter<std::string>("HistOutFile");
43 
44  allowMissingInputs_ = true;
45 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
Definition: DiJetAnalyzer.h:67
std::string fOutputFileName
Definition: DiJetAnalyzer.h:74
edm::EDGetTokenT< reco::CaloJetCollection > tok_jets_
Definition: DiJetAnalyzer.h:65
edm::EDGetTokenT< EcalRecHitCollection > tok_ec_
Definition: DiJetAnalyzer.h:66
edm::EDGetTokenT< HORecHitCollection > tok_ho_
Definition: DiJetAnalyzer.h:68
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
Definition: DiJetAnalyzer.h:69
cms::DiJetAnalyzer::~DiJetAnalyzer ( )

Definition at line 48 of file DiJetAnalyzer.cc.

49 {
50 
51 }

Member Function Documentation

void cms::DiJetAnalyzer::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 60 of file DiJetAnalyzer.cc.

References allowMissingInputs_, HcalDetId::depth(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, alignCSCRings::e, emEnergy, PV3DBase< T, PVType, FrameType >::eta(), etVetoJet, edm::EventID::event(), eventNumber, edm::EventSetup::get(), edm::Event::getByToken(), CaloGeometry::getValidDetIds(), DetId::Hcal, i, edm::EventBase::id(), HcalDetId::ieta(), iEtaHit, HcalDetId::iphi(), iPhiHit, metsig::jet, fwrapper::jets, PV3DBase< T, PVType, FrameType >::phi(), pi, probeJetEmFrac, probeJetP4, PxTrkHcal, PyTrkHcal, PzTrkHcal, dt_dqm_sourceclient_common_cff::reco, edm::EventID::run(), runNumber, funct::sin(), mathSSE::sqrt(), tagJetP4, targetE, tok_ec_, tok_hbhe_, tok_hf_, tok_ho_, tok_jets_, and tree.

61 {
62 
63  using namespace std;
64  using namespace edm;
65  using namespace reco;
66 
67  const double pi = 4.*atan(1.);
68 
69  // event number & run number
70  eventNumber = iEvent.id().event();
71  runNumber = iEvent.id().run();
72 
73 
74  // read jets
75  CaloJet jet1, jet2, jet3;
76  try {
78  iEvent.getByToken(tok_jets_,jets);
79  if(jets->size()>1){
80  jet1 = (*jets)[0];
81  jet2 = (*jets)[1];
82  if(fabs(jet1.eta())>fabs(jet2.eta())){
83  CaloJet jet = jet1;
84  jet1 = jet2;
85  jet2 = jet;
86  }
87  // if(fabs(jet1.eta())>eta_1 || (fabs(jet2.eta())-jet_R) < eta_2){ return;}
88  } else {return;}
89  tagJetP4->SetPxPyPzE(jet1.px(), jet1.py(), jet1.pz(), jet1.energy());
90  probeJetP4->SetPxPyPzE(jet2.px(), jet2.py(), jet2.pz(), jet2.energy());
91  if(jets->size()>2){
92  jet3 = (*jets)[2];
93  etVetoJet = jet3.et();
94  } else { etVetoJet = 0.;}
95  }catch (cms::Exception& e) { // can't find it!
96  if (!allowMissingInputs_) { throw e; }
97  }
98 
99 
100  double dR = 1000.;
102  iSetup.get<CaloGeometryRecord>().get(pG);
103  const CaloGeometry* geo = pG.product();
104  vector<DetId> vid = geo->getValidDetIds();
105  for(vector<DetId>::const_iterator idItr = vid.begin(); idItr != vid.end(); idItr++)
106  {
107  if( (*idItr).det() == DetId::Hcal ) {
108  GlobalPoint pos = geo->getPosition(*idItr);
109  double deta = fabs(jet2.eta() - pos.eta());
110  double dphi = fabs(jet2.phi() - pos.phi());
111  if(dphi>pi){dphi=2*pi-dphi;}
112  double dR_candidate = sqrt(deta*deta + dphi*dphi);
113  int ieta = HcalDetId(*idItr).ieta();
114  int iphi = HcalDetId(*idItr).iphi();
115  int idepth = HcalDetId(*idItr).depth();
116  if(dR_candidate < dR && idepth == 1){
117  dR = dR_candidate;
118  iEtaHit = ieta;
119  iPhiHit = iphi;
120  }
121  }
122  }
123 
124  targetE = jet1.et()/sin(jet2.theta());
125 
126  std::map<DetId,int> mapId;
127  vector<CaloTowerPtr> towers_fw = jet2.getCaloConstituents();
128  vector<CaloTowerPtr>::const_iterator towersItr;
129  for(towersItr = towers_fw.begin(); towersItr != towers_fw.end(); towersItr++){
130  size_t tower_size = (*towersItr)->constituentsSize();
131  for(size_t i=0; i<tower_size; i++){
132  DetId id = (*towersItr)->constituent(i);
133  mapId[id] = 1;
134  }
135  }
136 
137 
138  // probeJetEmFrac = 0.;
139  double emEnergy = 0.;
140  try {
142  iEvent.getByToken(tok_ec_,ec);
143  for(EcalRecHitCollection::const_iterator ecItr = (*ec).begin();
144  ecItr != (*ec).end(); ++ecItr)
145  {
146  DetId id = ecItr->detid();
147  if(mapId[id]==1){
148  emEnergy += ecItr->energy();
149  }
150  }
151  } catch (cms::Exception& e) { // can't find it!
152  if (!allowMissingInputs_) throw e;
153  }
154 
155  targetE += -emEnergy;
156  probeJetEmFrac = emEnergy/jet2.energy();
157 
158  int nHits = 0;
159  try {
161  iEvent.getByToken(tok_hbhe_, hbhe);
162  for(HBHERecHitCollection::const_iterator hbheItr=hbhe->begin();
163  hbheItr!=hbhe->end(); hbheItr++)
164  {
165  DetId id = hbheItr->detid();
166  if(mapId[id]==1){
167  TCell* cell = new TCell(id.rawId(),hbheItr->energy());
168  (*cells)[nHits] = cell;
169  nHits++;
170  }
171  }
172  } catch (cms::Exception& e) { // can't find it!
173  if (!allowMissingInputs_) throw e;
174  }
175 
176 
177  try {
179  iEvent.getByToken(tok_ho_, ho);
180  for(HORecHitCollection::const_iterator hoItr=ho->begin();
181  hoItr!=ho->end(); hoItr++)
182  {
183  DetId id = hoItr->detid();
184  if(mapId[id]==1){
185  TCell* cell = new TCell(id.rawId(),hoItr->energy());
186  (*cells)[nHits] = cell;
187  nHits++;
188  }
189  }
190  } catch (cms::Exception& e) { // can't find it!
191  if (!allowMissingInputs_) throw e;
192  }
193 
194  try {
196  iEvent.getByToken(tok_hf_, hf);
197  for(HFRecHitCollection::const_iterator hfItr=hf->begin();
198  hfItr!=hf->end(); hfItr++)
199  {
200  DetId id = hfItr->detid();
201  if(mapId[id]==1){
202  TCell* cell = new TCell(id.rawId(),hfItr->energy());
203  (*cells)[nHits] = cell;
204  nHits++;
205  }
206  }
207  } catch (cms::Exception& e) { // can't find it!
208  if (!allowMissingInputs_) throw e;
209  }
210 
211  probeJetEmFrac = emEnergy/jet2.energy();
212 
213 PxTrkHcal = 0;
214 PyTrkHcal = 0;
215 PzTrkHcal = 0;
216 
217  tree->Fill();
218 
219 }
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
int i
Definition: DBlmapReader.cc:9
Jets made from CaloTowers.
Definition: CaloJet.h:29
edm::EDGetTokenT< HBHERecHitCollection > tok_hbhe_
Definition: DiJetAnalyzer.h:67
TLorentzVector * tagJetP4
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
edm::EDGetTokenT< reco::CaloJetCollection > tok_jets_
Definition: DiJetAnalyzer.h:65
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: TCell.h:15
const Double_t pi
edm::EDGetTokenT< EcalRecHitCollection > tok_ec_
Definition: DiJetAnalyzer.h:66
int depth() const
get the tower depth
Definition: HcalDetId.h:40
T sqrt(T t)
Definition: SSEVec.h:48
vector< PseudoJet > jets
int ieta() const
get the cell ieta
Definition: HcalDetId.h:36
TLorentzVector * probeJetP4
edm::EDGetTokenT< HORecHitCollection > tok_ho_
Definition: DiJetAnalyzer.h:68
int iphi() const
get the cell iphi
Definition: HcalDetId.h:38
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:55
std::vector< DetId > getValidDetIds() const
Get the list of all valid detector ids.
Definition: CaloGeometry.cc:90
T eta() const
Definition: PV3DBase.h:76
edm::EventID id() const
Definition: EventBase.h:56
edm::EDGetTokenT< HFRecHitCollection > tok_hf_
Definition: DiJetAnalyzer.h:69
void cms::DiJetAnalyzer::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 224 of file DiJetAnalyzer.cc.

References cells, emEnergy, etVetoJet, eventNumber, fOutputFileName, hOutputFile, iEtaHit, iPhiHit, probeJetEmFrac, probeJetP4, PxTrkHcal, PyTrkHcal, PzTrkHcal, runNumber, tagJetEmFrac, tagJetP4, targetE, tree, xTrkHcal, yTrkHcal, and zTrkHcal.

225 {
226 
227  hOutputFile = new TFile( fOutputFileName.c_str(), "RECREATE" ) ;
228 
229  tree = new TTree("hcalCalibTree", "Tree for IsoTrack Calibration");
230 
231  cells = new TClonesArray("TCell");
232  tagJetP4 = new TLorentzVector();
233  probeJetP4 = new TLorentzVector();
234 
235 
236  tree->Branch("eventNumber", &eventNumber, "eventNumber/i");
237  tree->Branch("runNumber", &runNumber, "runNumber/i");
238  tree->Branch("iEtaHit", &iEtaHit, "iEtaHit/I");
239  tree->Branch("iPhiHit", &iPhiHit, "iPhiHit/i");
240 
241 
242  tree->Branch("xTrkHcal", &xTrkHcal, "xTrkHcal/F");
243  tree->Branch("yTrkHcal", &yTrkHcal, "yTrkHcal/F");
244  tree->Branch("zTrkHcal", &zTrkHcal, "zTrkHcal/F");
245 
246  tree->Branch("PxTrkHcal", &PxTrkHcal, "PxTrkHcal/F");
247  tree->Branch("PyTrkHcal", &PyTrkHcal, "PyTrkHcal/F");
248  tree->Branch("PzTrkHcal", &PzTrkHcal, "PzTrkHcal/F");
249 
250  tree->Branch("cells", &cells, 64000);
251  tree->Branch("emEnergy", &emEnergy, "emEnergy/F");
252  tree->Branch("targetE", &targetE, "targetE/F");
253  tree->Branch("etVetoJet", &etVetoJet, "etVetoJet/F");
254  tree->Branch("tagJetP4", "TLorentzVector", &tagJetP4);
255  tree->Branch("probeJetP4", "TLorentzVector", &probeJetP4);
256  tree->Branch("tagJetEmFrac", &tagJetEmFrac,"tagJetEmFrac/F");
257  tree->Branch("probeJetEmFrac", &probeJetEmFrac,"probeJetEmFrac/F");
258 
259 }
TLorentzVector * tagJetP4
std::string fOutputFileName
Definition: DiJetAnalyzer.h:74
TLorentzVector * probeJetP4
TClonesArray * cells
Definition: DiJetAnalyzer.h:94
void cms::DiJetAnalyzer::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 263 of file DiJetAnalyzer.cc.

References hOutputFile, and tree.

263  {
264 
265  hOutputFile->SetCompressionLevel(2);
266  hOutputFile->cd();
267  tree->Write();
268  hOutputFile->Close() ;
269 
270 }

Member Data Documentation

bool cms::DiJetAnalyzer::allowMissingInputs_
private

Definition at line 106 of file DiJetAnalyzer.h.

Referenced by analyze(), and DiJetAnalyzer().

TClonesArray* cms::DiJetAnalyzer::cells
private

Definition at line 94 of file DiJetAnalyzer.h.

Referenced by beginJob().

Float_t cms::DiJetAnalyzer::emEnergy
private

Definition at line 96 of file DiJetAnalyzer.h.

Referenced by analyze(), and beginJob().

Float_t cms::DiJetAnalyzer::etVetoJet
private

Definition at line 99 of file DiJetAnalyzer.h.

Referenced by analyze(), and beginJob().

UInt_t cms::DiJetAnalyzer::eventNumber
private
std::string cms::DiJetAnalyzer::fOutputFileName
private

Definition at line 74 of file DiJetAnalyzer.h.

Referenced by beginJob(), and DiJetAnalyzer().

TFile* cms::DiJetAnalyzer::hOutputFile
private

Definition at line 77 of file DiJetAnalyzer.h.

Referenced by beginJob(), and endJob().

Int_t cms::DiJetAnalyzer::iEtaHit
private

Definition at line 83 of file DiJetAnalyzer.h.

Referenced by analyze(), and beginJob().

UInt_t cms::DiJetAnalyzer::iPhiHit
private

Definition at line 84 of file DiJetAnalyzer.h.

Referenced by analyze(), and beginJob().

HcalRespCorrs* cms::DiJetAnalyzer::oldRespCorrs
private

Definition at line 108 of file DiJetAnalyzer.h.

Float_t cms::DiJetAnalyzer::probeJetEmFrac
private

Definition at line 103 of file DiJetAnalyzer.h.

Referenced by analyze(), and beginJob().

TLorentzVector* cms::DiJetAnalyzer::probeJetP4
private

Definition at line 101 of file DiJetAnalyzer.h.

Referenced by analyze(), and beginJob().

Float_t cms::DiJetAnalyzer::PxTrkHcal
private

Definition at line 90 of file DiJetAnalyzer.h.

Referenced by analyze(), and beginJob().

Float_t cms::DiJetAnalyzer::PyTrkHcal
private

Definition at line 91 of file DiJetAnalyzer.h.

Referenced by analyze(), and beginJob().

Float_t cms::DiJetAnalyzer::PzTrkHcal
private

Definition at line 92 of file DiJetAnalyzer.h.

Referenced by analyze(), and beginJob().

UInt_t cms::DiJetAnalyzer::runNumber
private

Definition at line 82 of file DiJetAnalyzer.h.

Referenced by analyze(), and beginJob().

Float_t cms::DiJetAnalyzer::tagJetEmFrac
private

Definition at line 102 of file DiJetAnalyzer.h.

Referenced by beginJob().

TLorentzVector* cms::DiJetAnalyzer::tagJetP4
private

Definition at line 100 of file DiJetAnalyzer.h.

Referenced by analyze(), and beginJob().

Float_t cms::DiJetAnalyzer::targetE
private

Definition at line 97 of file DiJetAnalyzer.h.

Referenced by analyze(), and beginJob().

edm::EDGetTokenT<EcalRecHitCollection> cms::DiJetAnalyzer::tok_ec_
private

Definition at line 66 of file DiJetAnalyzer.h.

Referenced by analyze(), and DiJetAnalyzer().

edm::EDGetTokenT<HBHERecHitCollection> cms::DiJetAnalyzer::tok_hbhe_
private

Definition at line 67 of file DiJetAnalyzer.h.

Referenced by analyze(), and DiJetAnalyzer().

edm::EDGetTokenT<HFRecHitCollection> cms::DiJetAnalyzer::tok_hf_
private

Definition at line 69 of file DiJetAnalyzer.h.

Referenced by analyze(), and DiJetAnalyzer().

edm::EDGetTokenT<HORecHitCollection> cms::DiJetAnalyzer::tok_ho_
private

Definition at line 68 of file DiJetAnalyzer.h.

Referenced by analyze(), and DiJetAnalyzer().

edm::EDGetTokenT<reco::CaloJetCollection> cms::DiJetAnalyzer::tok_jets_
private

Definition at line 65 of file DiJetAnalyzer.h.

Referenced by analyze(), and DiJetAnalyzer().

TTree* cms::DiJetAnalyzer::tree
private
Float_t cms::DiJetAnalyzer::xTrkHcal
private

Definition at line 86 of file DiJetAnalyzer.h.

Referenced by beginJob().

Float_t cms::DiJetAnalyzer::yTrkHcal
private

Definition at line 87 of file DiJetAnalyzer.h.

Referenced by beginJob().

Float_t cms::DiJetAnalyzer::zTrkHcal
private

Definition at line 88 of file DiJetAnalyzer.h.

Referenced by beginJob().