CMS 3D CMS Logo

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

#include <EnergyScaleAnalyzer.h>

Inheritance diagram for EnergyScaleAnalyzer:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase 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::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDAnalyzerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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::EnergyScaleAnalyzer ( const edm::ParameterSet ps)
explicit

Definition at line 70 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, ProducerED_cfi::InputTag, outputFile_, rootFile_, and AlCaHLTBitMon_QueryRunRegistry::string.

72 {
73  hepMCLabel_ = consumes<edm::HepMCProduct>(ps.getParameter<std::string>("hepMCLabel"));
74  hybridSuperClusters_token = consumes<reco::SuperClusterCollection>(
75  ps.getUntrackedParameter<edm::InputTag>("hybridSuperClusters", edm::InputTag("hybridSuperClusters")));
76  dynamicHybridSuperClusters_token = consumes<reco::SuperClusterCollection>(ps.getUntrackedParameter<edm::InputTag>(
77  "dynamicHybridSuperClusters", edm::InputTag("dynamicHybridSuperClusters")));
78  correctedHybridSuperClusters_token = consumes<reco::SuperClusterCollection>(ps.getUntrackedParameter<edm::InputTag>(
79  "correctedHybridSuperClusters", edm::InputTag("correctedHybridSuperClusters")));
81  consumes<reco::SuperClusterCollection>(ps.getUntrackedParameter<edm::InputTag>(
82  "correctedDynamicHybridSuperClusters", edm::InputTag("correctedDynamicHybridSuperClusters")));
83  correctedFixedMatrixSuperClustersWithPreshower_token = consumes<reco::SuperClusterCollection>(
84  ps.getUntrackedParameter<edm::InputTag>("correctedFixedMatrixSuperClustersWithPreshower",
85  edm::InputTag("correctedFixedMatrixSuperClustersWithPreshower")));
87  consumes<reco::SuperClusterCollection>(ps.getUntrackedParameter<edm::InputTag>(
88  "fixedMatrixSuperClustersWithPreshower", edm::InputTag("fixedMatrixSuperClustersWithPreshower")));
89 
90  outputFile_ = ps.getParameter<std::string>("outputFile");
91  rootFile_ = TFile::Open(outputFile_.c_str(),
92  "RECREATE"); // open output file to store histograms
93 
94  evtN = 0;
95 }
edm::EDGetTokenT< reco::SuperClusterCollection > dynamicHybridSuperClusters_token
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::EDGetTokenT< reco::SuperClusterCollection > fixedMatrixSuperClustersWithPreshower_token
edm::EDGetTokenT< edm::HepMCProduct > hepMCLabel_
edm::EDGetTokenT< reco::SuperClusterCollection > correctedFixedMatrixSuperClustersWithPreshower_token
edm::EDGetTokenT< reco::SuperClusterCollection > hybridSuperClusters_token
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< reco::SuperClusterCollection > correctedDynamicHybridSuperClusters_token
edm::EDGetTokenT< reco::SuperClusterCollection > correctedHybridSuperClusters_token

◆ ~EnergyScaleAnalyzer()

EnergyScaleAnalyzer::~EnergyScaleAnalyzer ( )
override

Definition at line 98 of file EnergyScaleAnalyzer.cc.

References rootFile_.

100 {
101  delete rootFile_;
102 }

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 131 of file EnergyScaleAnalyzer.cc.

References funct::abs(), correctedDynamicHybridSuperClusters_token, correctedFixedMatrixSuperClustersWithPreshower_token, correctedHybridSuperClusters_token, kinem::delta_R(), dynamicHybridSuperClusters_cfi::dynamicHybridSuperClusters, dynamicHybridSuperClusters_token, Exception, fillTree(), fixedMatrixSuperClustersWithPreshower_token, genWeightsTable_cfi::genEvent, GenParticle::GenParticle, edm::Event::getByToken(), MuonClassifier_cff::hepMC, hepMCLabel_, unifiedSCCollection_cfi::hybridSuperClusters, hybridSuperClusters_token, mps_fire::i, sistrip::SpyUtilities::isValid(), MainPageGenerator::l, edm::EDConsumerBase::labelsForToken(), HLT_2024v14_cff::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, HerwigMaxPtPartonFilter_cfi::moduleLabel, AlCaHLTBitMon_ParallelJobs::p, EnergyScaleAnalyzer::tree_structure_::parID, edm::Handle< T >::product(), crab_script::provenance, funct::sin(), AlCaHLTBitMon_QueryRunRegistry::string, suppress, tree_, L1BJetProducer_cff::vtx, xVtx_, yVtx_, and zVtx_.

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

◆ beginJob()

void EnergyScaleAnalyzer::beginJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 105 of file EnergyScaleAnalyzer.cc.

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

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

◆ endJob()

void EnergyScaleAnalyzer::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 474 of file EnergyScaleAnalyzer.cc.

References rootFile_.

474  {
475  //========================================================================
476  // Fill ROOT tree
477  rootFile_->Write();
478 }

◆ fillTree()

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 344 of file EnergyScaleAnalyzer.cc.

References Matriplex::atan2(), kinem::delta_R(), HGC3DClusterGenMatchSelector_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, HBHEDarkening_cff::energy, energyMax_, etaMax_, etaMaxVtx_, eTMax_, eTMaxVtx_, CrabHelper::log, CaloTowersParam_cfi::mc, mytree_, phiMax_, phiMaxVtx_, rClust_vtx_, funct::sin(), mathSSE::sqrt(), funct::tan(), thetaMax_, thetaMaxVtx_, tree_, xClust_vtx_, xClust_zero_, yClust_vtx_, yClust_zero_, zClust_vtx_, and zClust_zero_.

Referenced by analyze().

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

Member Data Documentation

◆ correctedDynamicHybridSuperClusters_token

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

Definition at line 64 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), and EnergyScaleAnalyzer().

◆ correctedFixedMatrixSuperClustersWithPreshower_token

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

Definition at line 65 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), and EnergyScaleAnalyzer().

◆ correctedHybridSuperClusters_token

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

Definition at line 63 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), and EnergyScaleAnalyzer().

◆ dynamicHybridSuperClusters_token

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

Definition at line 62 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), and EnergyScaleAnalyzer().

◆ energyMax_

float EnergyScaleAnalyzer::energyMax_
private

Definition at line 137 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ etaMax_

float EnergyScaleAnalyzer::etaMax_
private

Definition at line 140 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ etaMaxVtx_

float EnergyScaleAnalyzer::etaMaxVtx_
private

Definition at line 141 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ eTMax_

float EnergyScaleAnalyzer::eTMax_
private

Definition at line 138 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ eTMaxVtx_

float EnergyScaleAnalyzer::eTMaxVtx_
private

Definition at line 139 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ evtN

int EnergyScaleAnalyzer::evtN
private

Definition at line 148 of file EnergyScaleAnalyzer.h.

Referenced by EnergyScaleAnalyzer().

◆ fixedMatrixSuperClustersWithPreshower_token

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

Definition at line 66 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), and EnergyScaleAnalyzer().

◆ hepMCLabel_

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

Definition at line 60 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), and EnergyScaleAnalyzer().

◆ hybridSuperClusters_token

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

Definition at line 61 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), and EnergyScaleAnalyzer().

◆ mytree_

TTree* EnergyScaleAnalyzer::mytree_
private

Definition at line 72 of file EnergyScaleAnalyzer.h.

Referenced by beginJob(), and fillTree().

◆ outputFile_

std::string EnergyScaleAnalyzer::outputFile_
private

Definition at line 58 of file EnergyScaleAnalyzer.h.

Referenced by EnergyScaleAnalyzer().

◆ phiMax_

float EnergyScaleAnalyzer::phiMax_
private

Definition at line 142 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ phiMaxVtx_

float EnergyScaleAnalyzer::phiMaxVtx_
private

Definition at line 143 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ rClust_vtx_

float EnergyScaleAnalyzer::rClust_vtx_
private

Definition at line 135 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ rootFile_

TFile* EnergyScaleAnalyzer::rootFile_
private

Definition at line 69 of file EnergyScaleAnalyzer.h.

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

◆ thetaMax_

float EnergyScaleAnalyzer::thetaMax_
private

Definition at line 144 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ thetaMaxVtx_

float EnergyScaleAnalyzer::thetaMaxVtx_
private

Definition at line 145 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ tree_

tree_structure_ EnergyScaleAnalyzer::tree_
private

Definition at line 120 of file EnergyScaleAnalyzer.h.

Referenced by analyze(), beginJob(), and fillTree().

◆ xClust_vtx_

float EnergyScaleAnalyzer::xClust_vtx_
private

Definition at line 131 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ xClust_zero_

float EnergyScaleAnalyzer::xClust_zero_
private

Definition at line 127 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ xVtx_

float EnergyScaleAnalyzer::xVtx_
private

Definition at line 123 of file EnergyScaleAnalyzer.h.

Referenced by analyze().

◆ yClust_vtx_

float EnergyScaleAnalyzer::yClust_vtx_
private

Definition at line 132 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ yClust_zero_

float EnergyScaleAnalyzer::yClust_zero_
private

Definition at line 128 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ yVtx_

float EnergyScaleAnalyzer::yVtx_
private

Definition at line 124 of file EnergyScaleAnalyzer.h.

Referenced by analyze().

◆ zClust_vtx_

float EnergyScaleAnalyzer::zClust_vtx_
private

Definition at line 133 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ zClust_zero_

float EnergyScaleAnalyzer::zClust_zero_
private

Definition at line 129 of file EnergyScaleAnalyzer.h.

Referenced by fillTree().

◆ zVtx_

float EnergyScaleAnalyzer::zVtx_
private

Definition at line 125 of file EnergyScaleAnalyzer.h.

Referenced by analyze().