82 rootFile_ = TFile::Open(outputFile_.c_str(),
"RECREATE");
100 mytree_ =
new TTree(
"energyScale",
"");
101 TString treeVariables =
"mc_npar/I:parID:mc_sep/F:mc_e:mc_et:mc_phi:mc_eta:mc_theta:";
102 treeVariables +=
"em_dR/F:";
103 treeVariables +=
"em_isInCrack/I:em_scType:em_e/F:em_et:em_phi:em_eta:em_theta:em_nCell/I:em_nBC:";
104 treeVariables +=
"em_pet/F:em_pe:em_peta:em_ptheta:" ;
106 treeVariables +=
"emCorr_e/F:emCorr_et:emCorr_eta:emCorr_phi:emCorr_theta:";
107 treeVariables +=
"emCorr_pet/F:emCorr_peta:emCorr_ptheta:" ;
109 treeVariables +=
"em_pw/F:em_ew:em_br" ;
129 const HepMC::GenEvent*
genEvent = hepMC->GetEvent();
130 if ( !(hepMC.isValid())) {
131 LogInfo(
"EnergyScaleAnalyzer") <<
"Could not get MC Product!";
137 std::vector< Handle< HepMCProduct > > evtHandles ;
140 for (
unsigned int i=0;
i<evtHandles.size(); ++
i) {
141 if ( evtHandles[
i].isValid() ) {
142 const HepMC::GenEvent* evt = evtHandles[
i]->GetEvent() ;
146 HepMC::GenEvent::vertex_const_iterator vtx = evt->vertices_begin() ;
147 if ( evtHandles[
i].provenance()->moduleLabel() ==
hepMCLabel_ ) {
149 xVtx_ = 0.1*(*vtx)->position().x();
150 yVtx_ = 0.1*(*vtx)->position().y();
151 zVtx_ = 0.1*(*vtx)->position().z();
162 edm::LogError(
"EnergyScaleAnalyzer") <<
"Can't get collection with producer hybridSuperClusters.";
169 edm::LogError(
"EnergyScaleAnalyzer") <<
"Can't get collection with producer dynamicHybridSuperClusters.";
174 evt.
getByLabel(
"fixedMatrixSuperClustersWithPreshower",
"",fixedMatrixSuperClustersWithPS);
176 edm::LogError(
"EnergyScaleAnalyzer") <<
"Can't get collection with producer fixedMatrixSuperClustersWithPreshower.";
182 evt.
getByLabel(
"correctedHybridSuperClusters",
"",correctedHybridSC);
184 edm::LogError(
"EnergyScaleAnalyzer") <<
"Can't get collection with producer correctedHybridSuperClusters.";
189 evt.
getByLabel(
"correctedDynamicHybridSuperClusters",
"",correctedDynamicHybridSC);
191 edm::LogError(
"EnergyScaleAnalyzer") <<
"Can't get collection with producer correctedDynamicHybridSuperClusters.";
196 evt.
getByLabel(
"correctedFixedMatrixSuperClustersWithPreshower",
"",correctedFixedMatrixSCWithPS);
198 edm::LogError(
"EnergyScaleAnalyzer") <<
"Can't get collection with producer correctedFixedMatrixSuperClustersWithPreshower.";
244 HepMC::GenEvent::particle_const_iterator
p =
genEvent->particles_begin();
250 std::vector<HepMC::GenParticle* > mcParticles;
252 for ( HepMC::GenEvent::particle_const_iterator
p =
genEvent->particles_begin();
258 if ( (*p)->pdg_id() != 22 &&
abs((*p)->pdg_id()) != 11 )
continue;
261 bool satisfySelectionCriteria =
262 (*p)->momentum().perp() > min_eT &&
263 fabs((*p)->momentum().eta()) < max_eta;
265 if ( ! satisfySelectionCriteria )
continue;
268 mcParticles.push_back(*
p);
272 if ( mcParticles.size() == 2 ) {
276 mc2->momentum().eta(), mc2->momentum().phi());
283 for(std::vector<HepMC::GenParticle* >::const_iterator
p = mcParticles.begin();
284 p != mcParticles.end(); ++
p) {
291 tree_.
mc_et = mc->momentum().e()*
sin(mc->momentum().theta());
321 reco::SuperClusterCollection::const_iterator em = scColl->end();
322 float energyMax = -100.0;
323 for(reco::SuperClusterCollection::const_iterator aClus = scColl->begin();
324 aClus != scColl->end(); ++aClus) {
327 aClus->position().eta(), aClus->position().phi());
329 float energy = aClus->energy();
330 if ( energy < energyMax )
continue;
336 if (em == scColl->end() ) {
346 double emAbsEta = fabs(em->position().eta());
348 if ( emAbsEta < 0.018 ||
349 (emAbsEta > 0.423 && emAbsEta < 0.461) ||
350 (emAbsEta > 0.770 && emAbsEta < 0.806) ||
351 (emAbsEta > 1.127 && emAbsEta < 1.163) ||
352 (emAbsEta > 1.460 && emAbsEta < 1.558) )
356 em->position().eta(), em->position().phi());
357 tree_.
em_e = em->energy();
358 tree_.
em_et = em->energy() *
sin(em->position().theta());
359 tree_.
em_phi = em->position().phi();
360 tree_.
em_eta = em->position().eta();
361 tree_.
em_theta = em->position().theta();
363 tree_.
em_nBC = em->clustersSize();
377 etaMax_ = em->position().eta();
378 phiMax_ = em->position().phi();
397 em = corrSCColl->end();
399 for(reco::SuperClusterCollection::const_iterator aClus = corrSCColl->begin();
400 aClus != corrSCColl->end(); ++aClus) {
403 aClus->position().eta(), aClus->position().phi());
405 float energy = aClus->energy();
406 if ( energy < energyMax )
continue;
412 if (em == corrSCColl->end() ) {
421 tree_.
emCorr_et = em->energy() *
sin(em->position().theta());
433 tree_.
em_pw = em->phiWidth();
434 tree_.
em_ew = em->etaWidth();
void getManyByType(std::vector< Handle< PROD > > &results) const
T getParameter(std::string const &) const
tuple hybridSuperClusters
virtual void analyze(const edm::Event &, const edm::EventSetup &)
#define DEFINE_FWK_MODULE(type)
Sin< T >::type sin(const T &t)
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
Tan< T >::type tan(const T &t)
double delta_R(double eta1, double phi1, double eta2, double phi2)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
EnergyScaleAnalyzer(const edm::ParameterSet &)
tuple dynamicHybridSuperClusters