80 rootFile_ = TFile::Open(outputFile_.c_str(),
"RECREATE");
98 mytree_ =
new TTree(
"energyScale",
"");
99 TString treeVariables =
"mc_npar/I:parID:mc_sep/F:mc_e:mc_et:mc_phi:mc_eta:mc_theta:";
100 treeVariables +=
"em_dR/F:";
101 treeVariables +=
"em_isInCrack/I:em_scType:em_e/F:em_et:em_phi:em_eta:em_theta:em_nCell/I:em_nBC:";
102 treeVariables +=
"em_pet/F:em_pe:em_peta:em_ptheta:" ;
104 treeVariables +=
"emCorr_e/F:emCorr_et:emCorr_eta:emCorr_phi:emCorr_theta:";
105 treeVariables +=
"emCorr_pet/F:emCorr_peta:emCorr_ptheta:" ;
107 treeVariables +=
"em_pw/F:em_ew:em_br" ;
127 const HepMC::GenEvent*
genEvent = hepMC->GetEvent();
128 if ( !(hepMC.isValid())) {
129 LogInfo(
"EnergyScaleAnalyzer") <<
"Could not get MC Product!";
135 std::vector< Handle< HepMCProduct > > evtHandles ;
138 for (
unsigned int i=0;
i<evtHandles.size(); ++
i) {
139 if ( evtHandles[
i].isValid() ) {
140 const HepMC::GenEvent* evt = evtHandles[
i]->GetEvent() ;
144 HepMC::GenEvent::vertex_const_iterator vtx = evt->vertices_begin() ;
145 if ( evtHandles[
i].provenance()->moduleLabel() ==
hepMCLabel_ ) {
147 xVtx_ = 0.1*(*vtx)->position().x();
148 yVtx_ = 0.1*(*vtx)->position().y();
149 zVtx_ = 0.1*(*vtx)->position().z();
160 edm::LogError(
"EnergyScaleAnalyzer") <<
"Can't get collection with producer hybridSuperClusters.";
167 edm::LogError(
"EnergyScaleAnalyzer") <<
"Can't get collection with producer dynamicHybridSuperClusters.";
172 evt.
getByLabel(
"fixedMatrixSuperClustersWithPreshower",
"",fixedMatrixSuperClustersWithPS);
174 edm::LogError(
"EnergyScaleAnalyzer") <<
"Can't get collection with producer fixedMatrixSuperClustersWithPreshower.";
180 evt.
getByLabel(
"correctedHybridSuperClusters",
"",correctedHybridSC);
182 edm::LogError(
"EnergyScaleAnalyzer") <<
"Can't get collection with producer correctedHybridSuperClusters.";
187 evt.
getByLabel(
"correctedDynamicHybridSuperClusters",
"",correctedDynamicHybridSC);
189 edm::LogError(
"EnergyScaleAnalyzer") <<
"Can't get collection with producer correctedDynamicHybridSuperClusters.";
194 evt.
getByLabel(
"correctedFixedMatrixSuperClustersWithPreshower",
"",correctedFixedMatrixSCWithPS);
196 edm::LogError(
"EnergyScaleAnalyzer") <<
"Can't get collection with producer correctedFixedMatrixSuperClustersWithPreshower.";
242 HepMC::GenEvent::particle_const_iterator
p =
genEvent->particles_begin();
248 std::vector<HepMC::GenParticle* > mcParticles;
250 for ( HepMC::GenEvent::particle_const_iterator
p =
genEvent->particles_begin();
256 if ( (*p)->pdg_id() != 22 &&
abs((*p)->pdg_id()) != 11 )
continue;
259 bool satisfySelectionCriteria =
260 (*p)->momentum().perp() > min_eT &&
261 fabs((*p)->momentum().eta()) < max_eta;
263 if ( ! satisfySelectionCriteria )
continue;
266 mcParticles.push_back(*
p);
270 if ( mcParticles.size() == 2 ) {
274 mc2->momentum().eta(), mc2->momentum().phi());
281 for(std::vector<HepMC::GenParticle* >::const_iterator
p = mcParticles.begin();
282 p != mcParticles.end(); ++
p) {
289 tree_.
mc_et = mc->momentum().e()*
sin(mc->momentum().theta());
319 reco::SuperClusterCollection::const_iterator em = scColl->end();
320 float energyMax = -100.0;
321 for(reco::SuperClusterCollection::const_iterator aClus = scColl->begin();
322 aClus != scColl->end(); ++aClus) {
325 aClus->position().eta(), aClus->position().phi());
327 float energy = aClus->energy();
328 if ( energy < energyMax )
continue;
334 if (em == scColl->end() ) {
344 double emAbsEta = fabs(em->position().eta());
346 if ( emAbsEta < 0.018 ||
347 (emAbsEta > 0.423 && emAbsEta < 0.461) ||
348 (emAbsEta > 0.770 && emAbsEta < 0.806) ||
349 (emAbsEta > 1.127 && emAbsEta < 1.163) ||
350 (emAbsEta > 1.460 && emAbsEta < 1.558) )
354 em->position().eta(), em->position().phi());
355 tree_.
em_e = em->energy();
356 tree_.
em_et = em->energy() *
sin(em->position().theta());
357 tree_.
em_phi = em->position().phi();
358 tree_.
em_eta = em->position().eta();
359 tree_.
em_theta = em->position().theta();
361 tree_.
em_nBC = em->clustersSize();
375 etaMax_ = em->position().eta();
376 phiMax_ = em->position().phi();
395 em = corrSCColl->end();
397 for(reco::SuperClusterCollection::const_iterator aClus = corrSCColl->begin();
398 aClus != corrSCColl->end(); ++aClus) {
401 aClus->position().eta(), aClus->position().phi());
403 float energy = aClus->energy();
404 if ( energy < energyMax )
continue;
410 if (em == corrSCColl->end() ) {
419 tree_.
emCorr_et = em->energy() *
sin(em->position().theta());
431 tree_.
em_pw = em->phiWidth();
432 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)
Abs< T >::type abs(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