CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
EnergyScaleAnalyzer Class Reference

#include <EnergyScaleAnalyzer.h>

Inheritance diagram for EnergyScaleAnalyzer:
edm::EDAnalyzer edm::EDConsumerBase

Classes

struct  tree_structure_
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
void endJob () override
 
 EnergyScaleAnalyzer (const edm::ParameterSet &)
 
 ~EnergyScaleAnalyzer () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void fillTree (const reco::SuperClusterCollection *scColl, const reco::SuperClusterCollection *corrSCColl, HepMC::GenParticle *mc, tree_structure_ &tree_, float xV, float yV, float zV, int scType)
 

Private Attributes

edm::EDGetTokenT< reco::SuperClusterCollectioncorrectedDynamicHybridSuperClusters_token
 
edm::EDGetTokenT< reco::SuperClusterCollectioncorrectedFixedMatrixSuperClustersWithPreshower_token
 
edm::EDGetTokenT< reco::SuperClusterCollectioncorrectedHybridSuperClusters_token
 
edm::EDGetTokenT< reco::SuperClusterCollectiondynamicHybridSuperClusters_token
 
float energyMax_
 
float etaMax_
 
float etaMaxVtx_
 
float eTMax_
 
float eTMaxVtx_
 
int evtN
 
edm::EDGetTokenT< reco::SuperClusterCollectionfixedMatrixSuperClustersWithPreshower_token
 
edm::EDGetTokenT< edm::HepMCProducthepMCLabel_
 
edm::EDGetTokenT< reco::SuperClusterCollectionhybridSuperClusters_token
 
TTree * mytree_
 
std::string outputFile_
 
float phiMax_
 
float phiMaxVtx_
 
float rClust_vtx_
 
TFile * rootFile_
 
float thetaMax_
 
float thetaMaxVtx_
 
tree_structure_ tree_
 
float xClust_vtx_
 
float xClust_zero_
 
float xVtx_
 
float yClust_vtx_
 
float yClust_zero_
 
float yVtx_
 
float zClust_vtx_
 
float zClust_zero_
 
float zVtx_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

Validation/EcalClusters/src/EnergyScaleAnalyzer.cc

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 48 of file EnergyScaleAnalyzer.h.

Constructor & Destructor Documentation

EnergyScaleAnalyzer::EnergyScaleAnalyzer ( const edm::ParameterSet ps)
explicit

Definition at line 74 of file EnergyScaleAnalyzer.cc.

References correctedDynamicHybridSuperClusters_token, correctedFixedMatrixSuperClustersWithPreshower_token, correctedHybridSuperClusters_token, dynamicHybridSuperClusters_token, evtN, fixedMatrixSuperClustersWithPreshower_token, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), hepMCLabel_, hybridSuperClusters_token, outputFile_, rootFile_, and AlCaHLTBitMon_QueryRunRegistry::string.

76 {
77  hepMCLabel_ = consumes<edm::HepMCProduct>(ps.getParameter<std::string>("hepMCLabel"));
78  hybridSuperClusters_token = consumes<reco::SuperClusterCollection>(
79  ps.getUntrackedParameter<edm::InputTag>("hybridSuperClusters", edm::InputTag("hybridSuperClusters")));
80  dynamicHybridSuperClusters_token = consumes<reco::SuperClusterCollection>(ps.getUntrackedParameter<edm::InputTag>(
81  "dynamicHybridSuperClusters", edm::InputTag("dynamicHybridSuperClusters")));
82  correctedHybridSuperClusters_token = consumes<reco::SuperClusterCollection>(ps.getUntrackedParameter<edm::InputTag>(
83  "correctedHybridSuperClusters", edm::InputTag("correctedHybridSuperClusters")));
85  consumes<reco::SuperClusterCollection>(ps.getUntrackedParameter<edm::InputTag>(
86  "correctedDynamicHybridSuperClusters", edm::InputTag("correctedDynamicHybridSuperClusters")));
87  correctedFixedMatrixSuperClustersWithPreshower_token = consumes<reco::SuperClusterCollection>(
88  ps.getUntrackedParameter<edm::InputTag>("correctedFixedMatrixSuperClustersWithPreshower",
89  edm::InputTag("correctedFixedMatrixSuperClustersWithPreshower")));
91  consumes<reco::SuperClusterCollection>(ps.getUntrackedParameter<edm::InputTag>(
92  "fixedMatrixSuperClustersWithPreshower", edm::InputTag("fixedMatrixSuperClustersWithPreshower")));
93 
94  outputFile_ = ps.getParameter<std::string>("outputFile");
95  rootFile_ = TFile::Open(outputFile_.c_str(),
96  "RECREATE"); // open output file to store histograms
97 
98  evtN = 0;
99 }
edm::EDGetTokenT< reco::SuperClusterCollection > dynamicHybridSuperClusters_token
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::SuperClusterCollection > fixedMatrixSuperClustersWithPreshower_token
edm::EDGetTokenT< edm::HepMCProduct > hepMCLabel_
edm::EDGetTokenT< reco::SuperClusterCollection > correctedFixedMatrixSuperClustersWithPreshower_token
edm::EDGetTokenT< reco::SuperClusterCollection > hybridSuperClusters_token
edm::EDGetTokenT< reco::SuperClusterCollection > correctedDynamicHybridSuperClusters_token
edm::EDGetTokenT< reco::SuperClusterCollection > correctedHybridSuperClusters_token
EnergyScaleAnalyzer::~EnergyScaleAnalyzer ( )
override

Definition at line 102 of file EnergyScaleAnalyzer.cc.

References rootFile_.

104 {
105  delete rootFile_;
106 }

Member Function Documentation

void EnergyScaleAnalyzer::analyze ( const edm::Event evt,
const edm::EventSetup es 
)
override

Definition at line 135 of file EnergyScaleAnalyzer.cc.

References funct::abs(), correctedDynamicHybridSuperClusters_token, correctedFixedMatrixSuperClustersWithPreshower_token, correctedHybridSuperClusters_token, kinem::delta_R(), dynamicHybridSuperClusters_cfi::dynamicHybridSuperClusters, dynamicHybridSuperClusters_token, fillTree(), fixedMatrixSuperClustersWithPreshower_token, nano_cff::genEvent, GenParticle::GenParticle, edm::Event::getByToken(), edm::HepMCProduct::GetEvent(), edm::Event::getManyByType(), MuonClassifier_cff::hepMC, hepMCLabel_, unifiedSCCollection_cfi::hybridSuperClusters, hybridSuperClusters_token, mps_fire::i, edm::HandleBase::isValid(), checklumidiff::l, edm::EDConsumerBase::labelsForToken(), hiMultiTrackSelector_cfi::max_eta, CaloTowersParam_cfi::mc, EnergyScaleAnalyzer::tree_structure_::mc_e, EnergyScaleAnalyzer::tree_structure_::mc_et, EnergyScaleAnalyzer::tree_structure_::mc_eta, EnergyScaleAnalyzer::tree_structure_::mc_npar, EnergyScaleAnalyzer::tree_structure_::mc_phi, EnergyScaleAnalyzer::tree_structure_::mc_sep, EnergyScaleAnalyzer::tree_structure_::mc_theta, edm::ProductLabels::module, AlCaHLTBitMon_ParallelJobs::p, EnergyScaleAnalyzer::tree_structure_::parID, edm::Handle< T >::product(), funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, tree_, badGlobalMuonTaggersAOD_cff::vtx, xVtx_, yVtx_, and zVtx_.

135  {
136  using namespace edm; // needed for all fwk related classes
137  using namespace std;
138 
139  // std::cout << "Proceccing event # " << ++evtN << std::endl;
140 
141  // Get containers for MC truth, SC etc.
142  // ===================================================
143  // =======================================================================================
144  // =======================================================================================
146  evt.getByToken(hepMCLabel_, hepMC);
147 
148  Labels l;
150 
151  const HepMC::GenEvent *genEvent = hepMC->GetEvent();
152  if (!(hepMC.isValid())) {
153  LogInfo("EnergyScaleAnalyzer") << "Could not get MC Product!";
154  return;
155  }
156 
157  //=======================For Vertex correction
158  std::vector<Handle<HepMCProduct>> evtHandles;
159  evt.getManyByType(evtHandles);
160 
161  for (unsigned int i = 0; i < evtHandles.size(); ++i) {
162  if (evtHandles[i].isValid()) {
163  const HepMC::GenEvent *evt = evtHandles[i]->GetEvent();
164 
165  // take only 1st vertex for now - it's been tested only of PGuns...
166  //
167  HepMC::GenEvent::vertex_const_iterator vtx = evt->vertices_begin();
168  if (evtHandles[i].provenance()->moduleLabel() == std::string(l.module)) {
169  // Corrdinates of Vertex w.r.o. the point (0,0,0)
170  xVtx_ = 0.1 * (*vtx)->position().x();
171  yVtx_ = 0.1 * (*vtx)->position().y();
172  zVtx_ = 0.1 * (*vtx)->position().z();
173  }
174  }
175  }
176  //==============================================================================
177  // Get handle to SC collections
178 
180  try {
181  evt.getByToken(hybridSuperClusters_token, hybridSuperClusters);
182  } catch (cms::Exception &ex) {
183  edm::LogError("EnergyScaleAnalyzer") << "Can't get collection with producer hybridSuperClusters.";
184  }
185 
187  try {
188  evt.getByToken(dynamicHybridSuperClusters_token, dynamicHybridSuperClusters);
189  } catch (cms::Exception &ex) {
190  edm::LogError("EnergyScaleAnalyzer") << "Can't get collection with producer dynamicHybridSuperClusters.";
191  }
192 
193  Handle<reco::SuperClusterCollection> fixedMatrixSuperClustersWithPS;
194  try {
195  evt.getByToken(fixedMatrixSuperClustersWithPreshower_token, fixedMatrixSuperClustersWithPS);
196  } catch (cms::Exception &ex) {
197  edm::LogError("EnergyScaleAnalyzer") << "Can't get collection with producer "
198  "fixedMatrixSuperClustersWithPreshower.";
199  }
200 
201  // Corrected collections
202  Handle<reco::SuperClusterCollection> correctedHybridSC;
203  try {
204  evt.getByToken(correctedHybridSuperClusters_token, correctedHybridSC);
205  } catch (cms::Exception &ex) {
206  edm::LogError("EnergyScaleAnalyzer") << "Can't get collection with producer correctedHybridSuperClusters.";
207  }
208 
209  Handle<reco::SuperClusterCollection> correctedDynamicHybridSC;
210  try {
211  evt.getByToken(correctedDynamicHybridSuperClusters_token, correctedDynamicHybridSC);
212  } catch (cms::Exception &ex) {
213  edm::LogError("EnergyScaleAnalyzer") << "Can't get collection with producer "
214  "correctedDynamicHybridSuperClusters.";
215  }
216 
217  Handle<reco::SuperClusterCollection> correctedFixedMatrixSCWithPS;
218  try {
219  evt.getByToken(correctedFixedMatrixSuperClustersWithPreshower_token, correctedFixedMatrixSCWithPS);
220  } catch (cms::Exception &ex) {
221  edm::LogError("EnergyScaleAnalyzer") << "Can't get collection with producer "
222  "correctedFixedMatrixSuperClustersWithPreshower.";
223  }
224 
225  const reco::SuperClusterCollection *dSC = dynamicHybridSuperClusters.product();
226  const reco::SuperClusterCollection *hSC = hybridSuperClusters.product();
227  const reco::SuperClusterCollection *fmSC = fixedMatrixSuperClustersWithPS.product();
228  const reco::SuperClusterCollection *chSC = correctedHybridSC.product();
229  const reco::SuperClusterCollection *cdSC = correctedDynamicHybridSC.product();
230  const reco::SuperClusterCollection *cfmSC = correctedFixedMatrixSCWithPS.product();
231 
232  // ----------------------- Print outs for debugging
233  /*
234  std::cout << "MC truth" << std::endl;
235  int counterI = 0;
236  for( HepMC::GenEvent::particle_const_iterator p =
237  genEvent->particles_begin(); p != genEvent->particles_end(); ++p ) { if (
238  fabs((*p)->momentum().eta()) < 1.5 ) { std::cout << ++counterI << " " <<
239  (*p)->momentum().e() << " "
240  << (*p)->momentum().phi() << " " << (*p)->momentum().eta() <<
241  std::endl;
242  }
243  }
244 
245  std::cout << "Standard clusters" << std::endl;
246  counterI = 0;
247  for(reco::SuperClusterCollection::const_iterator em = hSC->begin();
248  em != hSC->end(); ++em )
249  std::cout << ++counterI << " " << em->energy() << " " <<
250  em->position().phi() << " " << em->position().eta() << std::endl;
251 
252  std::cout << "Dynamic clusters" << std::endl;
253  counterI = 0;
254  for(reco::SuperClusterCollection::const_iterator em = dSC->begin();
255  em != dSC->end(); ++em )
256  std::cout << ++counterI << " " << em->energy() << " " <<
257  em->position().phi() << " " << em->position().eta() << std::endl;
258 
259  std::cout << "FixedMatrix clusters with PS" << std::endl;
260  counterI = 0;
261  for(reco::SuperClusterCollection::const_iterator em = fmSC->begin();
262  em != fmSC->end(); ++em )
263  std::cout << ++counterI << " " << em->energy() << " " <<
264  em->position().phi() << " " << em->position().eta() << std::endl;
265  */
266  // -----------------------------
267  //=====================================================================
268  // All containers are loaded, perform the analysis
269  //====================================================================
270 
271  // --------------------------- Store MC particles
272  HepMC::GenEvent::particle_const_iterator p = genEvent->particles_begin();
273 
274  // Search for MC electrons or photons that satisfy the criteria
275  float min_eT = 5;
276  float max_eta = 2.5;
277 
278  std::vector<HepMC::GenParticle *> mcParticles;
279  // int counter = 0;
280  for (HepMC::GenEvent::particle_const_iterator p = genEvent->particles_begin(); p != genEvent->particles_end(); ++p) {
281  // LogInfo("EnergyScaleAnalyzer") << "Particle " << ++counter
282  //<< " PDG ID = " << (*p)->pdg_id() << " pT = " << (*p)->momentum().perp();
283  // require photon or electron
284  if ((*p)->pdg_id() != 22 && abs((*p)->pdg_id()) != 11)
285  continue;
286 
287  // require selection criteria
288  bool satisfySelectionCriteria = (*p)->momentum().perp() > min_eT && fabs((*p)->momentum().eta()) < max_eta;
289 
290  if (!satisfySelectionCriteria)
291  continue;
292 
293  // EM MC particle is found, save it in the vector
294  mcParticles.push_back(*p);
295  }
296  // separation in dR between 2 first MC particles
297  // should not be used for MC samples with > 2 em objects generated!
298  if (mcParticles.size() == 2) {
299  HepMC::GenParticle *mc1 = mcParticles[0];
300  HepMC::GenParticle *mc2 = mcParticles[1];
301  tree_.mc_sep =
302  kinem::delta_R(mc1->momentum().eta(), mc1->momentum().phi(), mc2->momentum().eta(), mc2->momentum().phi());
303  } else
304  tree_.mc_sep = -100;
305 
306  // now loop over MC particles, find the match with SC and do everything we
307  // need then save info in the tree for every MC particle
308  for (std::vector<HepMC::GenParticle *>::const_iterator p = mcParticles.begin(); p != mcParticles.end(); ++p) {
309  HepMC::GenParticle *mc = *p;
310 
311  // Fill MC information
312  tree_.mc_npar = mcParticles.size();
313  tree_.parID = mc->pdg_id();
314  tree_.mc_e = mc->momentum().e();
315  tree_.mc_et = mc->momentum().e() * sin(mc->momentum().theta());
316  tree_.mc_phi = mc->momentum().phi();
317  tree_.mc_eta = mc->momentum().eta();
318  tree_.mc_theta = mc->momentum().theta();
319 
320  // Call function to fill tree
321  // scType coprreponds:
322  // HybridSuperCluster -- 1
323  // DynamicHybridSuperCluster -- 2
324  // FixedMatrixSuperClustersWithPreshower -- 3
325 
326  fillTree(hSC, chSC, mc, tree_, xVtx_, yVtx_, zVtx_, 1);
327  // std::cout << " TYPE " << 1 << " : " << tree_.em_e << " : " <<
328  // tree_.em_phi << " : " << tree_.em_eta << std::endl;
329 
330  fillTree(dSC, cdSC, mc, tree_, xVtx_, yVtx_, zVtx_, 2);
331  // std::cout << " TYPE " << 2 << " : " << tree_.em_e << " : " <<
332  // tree_.em_phi << " : " << tree_.em_eta << std::endl;
333 
334  fillTree(fmSC, cfmSC, mc, tree_, xVtx_, yVtx_, zVtx_, 3);
335  // std::cout << " TYPE " << 3 << " : " << tree_.em_e << " : " <<
336  // tree_.em_phi << " : " << tree_.em_eta << std::endl;
337 
338  // mytree_->Fill();
339  } // loop over particles
340 }
edm::EDGetTokenT< reco::SuperClusterCollection > dynamicHybridSuperClusters_token
edm::EDGetTokenT< reco::SuperClusterCollection > fixedMatrixSuperClustersWithPreshower_token
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
edm::EDGetTokenT< edm::HepMCProduct > hepMCLabel_
void getManyByType(std::vector< Handle< PROD >> &results) const
Definition: Event.h:508
edm::EDGetTokenT< reco::SuperClusterCollection > correctedFixedMatrixSuperClustersWithPreshower_token
edm::EDGetTokenT< reco::SuperClusterCollection > hybridSuperClusters_token
void fillTree(const reco::SuperClusterCollection *scColl, const reco::SuperClusterCollection *corrSCColl, HepMC::GenParticle *mc, tree_structure_ &tree_, float xV, float yV, float zV, int scType)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double delta_R(double eta1, double phi1, double eta2, double phi2)
Definition: AnglesUtil.h:106
bool isValid() const
Definition: HandleBase.h:74
edm::EDGetTokenT< reco::SuperClusterCollection > correctedDynamicHybridSuperClusters_token
edm::EDGetTokenT< reco::SuperClusterCollection > correctedHybridSuperClusters_token
ProductLabels Labels
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
T const * product() const
Definition: Handle.h:74
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
HLT enums.
void EnergyScaleAnalyzer::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 109 of file EnergyScaleAnalyzer.cc.

References EnergyScaleAnalyzer::tree_structure_::mc_npar, mytree_, and tree_.

109  {
110  //========================================================================
111 
112  mytree_ = new TTree("energyScale", "");
113  TString treeVariables =
114  "mc_npar/I:parID:mc_sep/"
115  "F:mc_e:mc_et:mc_phi:mc_eta:mc_theta:"; // MC information
116  treeVariables += "em_dR/F:"; // MC <-> EM matching information
117  treeVariables +=
118  "em_isInCrack/I:em_scType:em_e/F:em_et:em_phi:em_eta:em_theta:em_nCell/"
119  "I:em_nBC:"; // EM SC info
120  treeVariables += "em_pet/F:em_pe:em_peta:em_ptheta:"; // EM SC physics (eta corrected
121  // information)
122 
123  treeVariables += "emCorr_e/F:emCorr_et:emCorr_eta:emCorr_phi:emCorr_theta:"; // CMSSW
124  // standard
125  // corrections
126  treeVariables += "emCorr_pet/F:emCorr_peta:emCorr_ptheta:"; // CMSSW standard physics
127 
128  treeVariables += "em_pw/F:em_ew:em_br"; // EM widths pw -- phiWidth, ew --
129  // etaWidth, ratios of pw/ew
130 
131  mytree_->Branch("energyScale", &(tree_.mc_npar), treeVariables);
132 }
void EnergyScaleAnalyzer::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 472 of file EnergyScaleAnalyzer.cc.

References DEFINE_FWK_MODULE, and rootFile_.

472  {
473  //========================================================================
474  // Fill ROOT tree
475  rootFile_->Write();
476 }
void EnergyScaleAnalyzer::fillTree ( const reco::SuperClusterCollection scColl,
const reco::SuperClusterCollection corrSCColl,
HepMC::GenParticle *  mc,
tree_structure_ tree_,
float  xV,
float  yV,
float  zV,
int  scType 
)
private

fill tree with kinematic variables of corrected Super Cluster

Definition at line 342 of file EnergyScaleAnalyzer.cc.

References kinem::delta_R(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, EnergyScaleAnalyzer::tree_structure_::em_br, EnergyScaleAnalyzer::tree_structure_::em_dR, EnergyScaleAnalyzer::tree_structure_::em_e, EnergyScaleAnalyzer::tree_structure_::em_et, EnergyScaleAnalyzer::tree_structure_::em_eta, EnergyScaleAnalyzer::tree_structure_::em_ew, EnergyScaleAnalyzer::tree_structure_::em_isInCrack, EnergyScaleAnalyzer::tree_structure_::em_nBC, EnergyScaleAnalyzer::tree_structure_::em_nCell, EnergyScaleAnalyzer::tree_structure_::em_pe, EnergyScaleAnalyzer::tree_structure_::em_pet, EnergyScaleAnalyzer::tree_structure_::em_peta, EnergyScaleAnalyzer::tree_structure_::em_phi, EnergyScaleAnalyzer::tree_structure_::em_ptheta, EnergyScaleAnalyzer::tree_structure_::em_pw, EnergyScaleAnalyzer::tree_structure_::em_scType, EnergyScaleAnalyzer::tree_structure_::em_theta, EnergyScaleAnalyzer::tree_structure_::emCorr_e, EnergyScaleAnalyzer::tree_structure_::emCorr_et, EnergyScaleAnalyzer::tree_structure_::emCorr_eta, EnergyScaleAnalyzer::tree_structure_::emCorr_pet, EnergyScaleAnalyzer::tree_structure_::emCorr_peta, EnergyScaleAnalyzer::tree_structure_::emCorr_phi, EnergyScaleAnalyzer::tree_structure_::emCorr_ptheta, EnergyScaleAnalyzer::tree_structure_::emCorr_theta, randomXiThetaGunProducer_cfi::energy, energyMax_, etaMax_, etaMaxVtx_, eTMax_, eTMaxVtx_, cmsBatch::log, mytree_, phiMax_, phiMaxVtx_, rClust_vtx_, funct::sin(), mathSSE::sqrt(), funct::tan(), thetaMax_, thetaMaxVtx_, xClust_vtx_, xClust_zero_, yClust_vtx_, yClust_zero_, zClust_vtx_, and zClust_zero_.

Referenced by analyze().

349  {
350  // ----------------------------- SuperClusters before energy correction
351  reco::SuperClusterCollection::const_iterator em = scColl->end();
352  float energyMax = -100.0; // dummy energy of the matched SC
353  for (reco::SuperClusterCollection::const_iterator aClus = scColl->begin(); aClus != scColl->end(); ++aClus) {
354  // check the matching
355  float dR =
356  kinem::delta_R(mc->momentum().eta(), mc->momentum().phi(), aClus->position().eta(), aClus->position().phi());
357  if (dR < 0.4) { // a rather loose matching cut
358  float energy = aClus->energy();
359  if (energy < energyMax)
360  continue;
361  energyMax = energy;
362  em = aClus;
363  }
364  }
365 
366  if (em == scColl->end()) {
367  // std::cout << "No matching SC with type " << scType << " was found for
368  // MC particle! " << std::endl; std::cout << "Going to next type of SC.
369  // " << std::endl;
370  return;
371  }
372  // ------------
373 
374  tree_.em_scType = scType;
375 
376  tree_.em_isInCrack = 0;
377  double emAbsEta = fabs(em->position().eta());
378  // copied from
379  // RecoEgama/EgammaElectronAlgos/src/EgammaElectronClassification.cc
380  if (emAbsEta < 0.018 || (emAbsEta > 0.423 && emAbsEta < 0.461) || (emAbsEta > 0.770 && emAbsEta < 0.806) ||
381  (emAbsEta > 1.127 && emAbsEta < 1.163) || (emAbsEta > 1.460 && emAbsEta < 1.558))
382  tree_.em_isInCrack = 1;
383 
384  tree_.em_dR = kinem::delta_R(mc->momentum().eta(), mc->momentum().phi(), em->position().eta(), em->position().phi());
385  tree_.em_e = em->energy();
386  tree_.em_et = em->energy() * sin(em->position().theta());
387  tree_.em_phi = em->position().phi();
388  tree_.em_eta = em->position().eta();
389  tree_.em_theta = em->position().theta();
390  tree_.em_nCell = em->size();
391  tree_.em_nBC = em->clustersSize();
392 
393  // Get physics e, et etc:
394  // Coordinates of EM object with respect of the point (0,0,0)
395  xClust_zero_ = em->position().x();
396  yClust_zero_ = em->position().y();
397  zClust_zero_ = em->position().z();
398  // Coordinates of EM object w.r.o. the Vertex position
399  xClust_vtx_ = xClust_zero_ - xV;
400  yClust_vtx_ = yClust_zero_ - yV;
401  zClust_vtx_ = zClust_zero_ - zV;
402 
403  energyMax_ = em->energy();
404  thetaMax_ = em->position().theta();
405  etaMax_ = em->position().eta();
406  phiMax_ = em->position().phi();
408  if (phiMax_ < 0)
409  phiMax_ += 2 * 3.14159;
410 
413  etaMaxVtx_ = -log(tan(thetaMaxVtx_ / 2));
416  if (phiMaxVtx_ < 0)
417  phiMaxVtx_ += 2 * 3.14159;
418  //=============================
419  // parametres of EM object after vertex correction
424 
425  //------------------------------- Get SC after energy correction
426  em = corrSCColl->end();
427  energyMax = -100.0; // dummy energy of the matched SC
428  for (reco::SuperClusterCollection::const_iterator aClus = corrSCColl->begin(); aClus != corrSCColl->end(); ++aClus) {
429  // check the matching
430  float dR =
431  kinem::delta_R(mc->momentum().eta(), mc->momentum().phi(), aClus->position().eta(), aClus->position().phi());
432  if (dR < 0.4) {
433  float energy = aClus->energy();
434  if (energy < energyMax)
435  continue;
436  energyMax = energy;
437  em = aClus;
438  }
439  }
440 
441  if (em == corrSCColl->end()) {
442  // std::cout << "No matching corrected SC with type " << scType << " was
443  // found for MC particle! " << std::endl; std::cout << "Going to next
444  // type of SC. " << std::endl;
445  return;
446  }
447  // ------------
448 
450  tree_.emCorr_e = em->energy();
451  tree_.emCorr_et = em->energy() * sin(em->position().theta());
452  tree_.emCorr_phi = em->position().phi();
453  tree_.emCorr_eta = em->position().eta();
454  tree_.emCorr_theta = em->position().theta();
455 
456  // =========== Eta and Theta wrt Vertex does not change after energy
457  // corrections are applied
458  // =========== So, no need to calculate them again
459 
463 
464  tree_.em_pw = em->phiWidth();
465  tree_.em_ew = em->etaWidth();
467 
468  mytree_->Fill();
469 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:18
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double delta_R(double eta1, double phi1, double eta2, double phi2)
Definition: AnglesUtil.h:106

Member Data Documentation

edm::EDGetTokenT<reco::SuperClusterCollection> EnergyScaleAnalyzer::correctedDynamicHybridSuperClusters_token
private

Definition at line 64 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), and EnergyScaleAnalyzer().

edm::EDGetTokenT<reco::SuperClusterCollection> EnergyScaleAnalyzer::correctedFixedMatrixSuperClustersWithPreshower_token
private

Definition at line 65 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), and EnergyScaleAnalyzer().

edm::EDGetTokenT<reco::SuperClusterCollection> EnergyScaleAnalyzer::correctedHybridSuperClusters_token
private

Definition at line 63 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), and EnergyScaleAnalyzer().

edm::EDGetTokenT<reco::SuperClusterCollection> EnergyScaleAnalyzer::dynamicHybridSuperClusters_token
private

Definition at line 62 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), and EnergyScaleAnalyzer().

float EnergyScaleAnalyzer::energyMax_
private

Definition at line 137 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

float EnergyScaleAnalyzer::etaMax_
private

Definition at line 140 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

float EnergyScaleAnalyzer::etaMaxVtx_
private

Definition at line 141 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

float EnergyScaleAnalyzer::eTMax_
private

Definition at line 138 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

float EnergyScaleAnalyzer::eTMaxVtx_
private

Definition at line 139 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

int EnergyScaleAnalyzer::evtN
private

Definition at line 148 of file EnergyScaleAnalyzer.h.

Referenced by EnergyScaleAnalyzer().

edm::EDGetTokenT<reco::SuperClusterCollection> EnergyScaleAnalyzer::fixedMatrixSuperClustersWithPreshower_token
private

Definition at line 66 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), and EnergyScaleAnalyzer().

edm::EDGetTokenT<edm::HepMCProduct> EnergyScaleAnalyzer::hepMCLabel_
private

Definition at line 60 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), and EnergyScaleAnalyzer().

edm::EDGetTokenT<reco::SuperClusterCollection> EnergyScaleAnalyzer::hybridSuperClusters_token
private

Definition at line 61 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), and EnergyScaleAnalyzer().

TTree* EnergyScaleAnalyzer::mytree_
private

Definition at line 72 of file EnergyScaleAnalyzer.h.

Referenced by beginJob(), and fillTree().

std::string EnergyScaleAnalyzer::outputFile_
private

Definition at line 58 of file EnergyScaleAnalyzer.h.

Referenced by EnergyScaleAnalyzer().

float EnergyScaleAnalyzer::phiMax_
private

Definition at line 142 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

float EnergyScaleAnalyzer::phiMaxVtx_
private

Definition at line 143 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

float EnergyScaleAnalyzer::rClust_vtx_
private

Definition at line 135 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

TFile* EnergyScaleAnalyzer::rootFile_
private

Definition at line 69 of file EnergyScaleAnalyzer.h.

Referenced by endJob(), EnergyScaleAnalyzer(), and ~EnergyScaleAnalyzer().

float EnergyScaleAnalyzer::thetaMax_
private

Definition at line 144 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

float EnergyScaleAnalyzer::thetaMaxVtx_
private

Definition at line 145 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

tree_structure_ EnergyScaleAnalyzer::tree_
private

Definition at line 120 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), and beginJob().

float EnergyScaleAnalyzer::xClust_vtx_
private

Definition at line 131 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

float EnergyScaleAnalyzer::xClust_zero_
private

Definition at line 127 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

float EnergyScaleAnalyzer::xVtx_
private

Definition at line 123 of file EnergyScaleAnalyzer.h.

Referenced by analyze().

float EnergyScaleAnalyzer::yClust_vtx_
private

Definition at line 132 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

float EnergyScaleAnalyzer::yClust_zero_
private

Definition at line 128 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

float EnergyScaleAnalyzer::yVtx_
private

Definition at line 124 of file EnergyScaleAnalyzer.h.

Referenced by analyze().

float EnergyScaleAnalyzer::zClust_vtx_
private

Definition at line 133 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

float EnergyScaleAnalyzer::zClust_zero_
private

Definition at line 129 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

float EnergyScaleAnalyzer::zVtx_
private

Definition at line 125 of file EnergyScaleAnalyzer.h.

Referenced by analyze().