CMS 3D CMS Logo

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

EgammaCoreTools. More...

#include <PiZeroAnalyzer.h>

Inheritance diagram for PiZeroAnalyzer:
DQMEDAnalyzer edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
 PiZeroAnalyzer (const edm::ParameterSet &)
 
 ~PiZeroAnalyzer () override
 
- Public Member Functions inherited from DQMEDAnalyzer
void accumulate (edm::Event const &event, edm::EventSetup const &setup) final
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer ()
 
void endLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) final
 
void endRun (edm::Run const &run, edm::EventSetup const &setup) final
 
virtual bool getCanSaveByLumi ()
 
- Public Member Functions inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Private Member Functions

void makePizero (const edm::EventSetup &es, const edm::Handle< EcalRecHitCollection > eb, const edm::Handle< EcalRecHitCollection > ee)
 

Private Attributes

edm::EDGetTokenT< edm::SortedCollection< EcalRecHit, edm::StrictWeakOrdering< EcalRecHit > > > barrelEcalHits_token_
 
const edm::ESGetToken< CaloGeometry, CaloGeometryRecordcaloGeometryToken_
 
const edm::ESGetToken< CaloTopology, CaloTopologyRecordcaloTopologyToken_
 
int clusEtaSize_
 
int clusPhiSize_
 
double clusSeedThr_
 parameters needed for pizero finding More...
 
std::stringstream currentFolder_
 
double cutStep_
 
edm::EDGetTokenT< edm::SortedCollection< EcalRecHit, edm::StrictWeakOrdering< EcalRecHit > > > endcapEcalHits_token_
 
std::string fName_
 
MonitorElementhIsoPi0EB_
 
MonitorElementhMinvPi0EB_
 
MonitorElementhPt1Pi0EB_
 
MonitorElementhPt2Pi0EB_
 
MonitorElementhPtPi0EB_
 
double minPhoEtCut_
 
int nEvt_
 
int numberOfSteps_
 
bool ParameterLogWeighted_
 
double ParameterT0_barl_
 
double ParameterW0_
 
double ParameterX0_
 
edm::ParameterSet posCalcParameters_
 
unsigned int prescaleFactor_
 
double seleMinvMaxPi0_
 
double seleMinvMinPi0_
 
double selePi0BeltDeta_
 
double selePi0BeltDR_
 
double selePi0Iso_
 
double selePtGammaOne_
 
double selePtGammaTwo_
 
double selePtPi0_
 
double seleS4S9GammaOne_
 
double seleS4S9GammaTwo_
 
double seleXtalMinEnergy_
 

Additional Inherited Members

- Public Types inherited from DQMEDAnalyzer
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::stream::EDProducer< edm::GlobalCache< DQMEDAnalyzerGlobalCache >, edm::EndRunProducer, edm::EndLuminosityBlockProducer, edm::Accumulator >
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static void globalEndJob (DQMEDAnalyzerGlobalCache const *)
 
static void globalEndLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &setup, LuminosityBlockContext const *context)
 
static void globalEndRunProduce (edm::Run &run, edm::EventSetup const &setup, RunContext const *context)
 
static std::unique_ptr< DQMEDAnalyzerGlobalCacheinitializeGlobalCache (edm::ParameterSet const &)
 
- Protected Member Functions inherited from DQMEDAnalyzer
uint64_t meId () const
 
- Protected Attributes inherited from DQMEDAnalyzer
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 
unsigned int streamId_
 

Detailed Description

EgammaCoreTools.

$Id: PiZeroAnalyzer authors: Nancy Marinelli, U. of Notre Dame, US Jamie Antonelli, U. of Notre Dame, US

$Id: PiZeroAnalyzer authors: Nancy Marinelli, U. of Notre Dame, US
Jamie Antonelli, U. of Notre Dame, US

Definition at line 75 of file PiZeroAnalyzer.h.

Constructor & Destructor Documentation

◆ PiZeroAnalyzer()

PiZeroAnalyzer::PiZeroAnalyzer ( const edm::ParameterSet pset)
explicit

Definition at line 20 of file PiZeroAnalyzer.cc.

References deDxTools::esConsumes().

22  fName_ = pset.getUntrackedParameter<std::string>("Name");
23  prescaleFactor_ = pset.getUntrackedParameter<int>("prescaleFactor", 1);
24 
25  barrelEcalHits_token_ = consumes<edm::SortedCollection<EcalRecHit, edm::StrictWeakOrdering<EcalRecHit> > >(
26  pset.getParameter<edm::InputTag>("barrelEcalHits"));
27  endcapEcalHits_token_ = consumes<edm::SortedCollection<EcalRecHit, edm::StrictWeakOrdering<EcalRecHit> > >(
28  pset.getParameter<edm::InputTag>("endcapEcalHits"));
29 
30  nEvt_ = 0;
31 
32  // parameters for Pizero finding
33  seleXtalMinEnergy_ = pset.getParameter<double>("seleXtalMinEnergy");
34  clusSeedThr_ = pset.getParameter<double>("clusSeedThr");
35  clusEtaSize_ = pset.getParameter<int>("clusEtaSize");
36  clusPhiSize_ = pset.getParameter<int>("clusPhiSize");
37  ParameterLogWeighted_ = pset.getParameter<bool>("ParameterLogWeighted");
38  ParameterX0_ = pset.getParameter<double>("ParameterX0");
39  ParameterT0_barl_ = pset.getParameter<double>("ParameterT0_barl");
40  ParameterW0_ = pset.getParameter<double>("ParameterW0");
41 
42  selePtGammaOne_ = pset.getParameter<double>("selePtGammaOne");
43  selePtGammaTwo_ = pset.getParameter<double>("selePtGammaTwo");
44  seleS4S9GammaOne_ = pset.getParameter<double>("seleS4S9GammaOne");
45  seleS4S9GammaTwo_ = pset.getParameter<double>("seleS4S9GammaTwo");
46  selePtPi0_ = pset.getParameter<double>("selePtPi0");
47  selePi0Iso_ = pset.getParameter<double>("selePi0Iso");
48  selePi0BeltDR_ = pset.getParameter<double>("selePi0BeltDR");
49  selePi0BeltDeta_ = pset.getParameter<double>("selePi0BeltDeta");
50  seleMinvMaxPi0_ = pset.getParameter<double>("seleMinvMaxPi0");
51  seleMinvMinPi0_ = pset.getParameter<double>("seleMinvMinPi0");
52 
53  posCalcParameters_ = pset.getParameter<edm::ParameterSet>("posCalcParameters");
54 }
double clusSeedThr_
parameters needed for pizero finding
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
double selePi0BeltDeta_
bool ParameterLogWeighted_
edm::EDGetTokenT< edm::SortedCollection< EcalRecHit, edm::StrictWeakOrdering< EcalRecHit > > > barrelEcalHits_token_
double seleS4S9GammaOne_
double seleS4S9GammaTwo_
edm::ParameterSet posCalcParameters_
double ParameterT0_barl_
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_
double seleMinvMaxPi0_
edm::EDGetTokenT< edm::SortedCollection< EcalRecHit, edm::StrictWeakOrdering< EcalRecHit > > > endcapEcalHits_token_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
double selePtGammaOne_
double selePtGammaTwo_
unsigned int prescaleFactor_
std::string fName_
double seleXtalMinEnergy_
double seleMinvMinPi0_

◆ ~PiZeroAnalyzer()

PiZeroAnalyzer::~PiZeroAnalyzer ( )
override

Definition at line 56 of file PiZeroAnalyzer.cc.

56 {}

Member Function Documentation

◆ analyze()

void PiZeroAnalyzer::analyze ( const edm::Event e,
const edm::EventSetup esup 
)
overridevirtual

Reimplemented from DQMEDAnalyzer.

Definition at line 81 of file PiZeroAnalyzer.cc.

References barrelEcalHits_token_, HLT_2024v13_cff::barrelRecHits, MillePedeFileConverter_cfg::e, endcapEcalHits_token_, HLT_2024v13_cff::endcapRecHits, edm::HandleBase::isValid(), makePizero(), nEvt_, and prescaleFactor_.

81  {
82  using namespace edm;
83 
84  if (nEvt_ % prescaleFactor_)
85  return;
86  nEvt_++;
87  LogInfo("PiZeroAnalyzer") << "PiZeroAnalyzer Analyzing event number: " << e.id() << " Global Counter " << nEvt_
88  << "\n";
89 
90  // Get EcalRecHits
91  bool validEcalRecHits = true;
92  Handle<EcalRecHitCollection> barrelHitHandle;
94  e.getByToken(barrelEcalHits_token_, barrelHitHandle);
95  if (!barrelHitHandle.isValid()) {
96  edm::LogError("PhotonProducer") << "Error! Can't get the product: barrelEcalHits_token_";
97  validEcalRecHits = false;
98  }
99 
100  Handle<EcalRecHitCollection> endcapHitHandle;
101  e.getByToken(endcapEcalHits_token_, endcapHitHandle);
103  if (!endcapHitHandle.isValid()) {
104  edm::LogError("PhotonProducer") << "Error! Can't get the product: endcapEcalHits_token_";
105  validEcalRecHits = false;
106  }
107 
108  if (validEcalRecHits)
109  makePizero(esup, barrelHitHandle, endcapHitHandle);
110 }
edm::EDGetTokenT< edm::SortedCollection< EcalRecHit, edm::StrictWeakOrdering< EcalRecHit > > > barrelEcalHits_token_
void makePizero(const edm::EventSetup &es, const edm::Handle< EcalRecHitCollection > eb, const edm::Handle< EcalRecHitCollection > ee)
Log< level::Error, false > LogError
edm::EDGetTokenT< edm::SortedCollection< EcalRecHit, edm::StrictWeakOrdering< EcalRecHit > > > endcapEcalHits_token_
Log< level::Info, false > LogInfo
unsigned int prescaleFactor_
bool isValid() const
Definition: HandleBase.h:70
HLT enums.

◆ bookHistograms()

void PiZeroAnalyzer::bookHistograms ( DQMStore::IBooker ibooker,
edm::Run const &  ,
edm::EventSetup const &   
)
overridevirtual

Implements DQMEDAnalyzer.

Definition at line 58 of file PiZeroAnalyzer.cc.

References dqm::implementation::IBooker::book1D(), currentFolder_, hIsoPi0EB_, hMinvPi0EB_, hPt1Pi0EB_, hPt2Pi0EB_, hPtPi0EB_, dqm::impl::MonitorElement::setAxisTitle(), and dqm::implementation::NavigatorBase::setCurrentFolder().

60  {
61  currentFolder_.str("");
62  currentFolder_ << "Egamma/PiZeroAnalyzer/";
63  ibooker.setCurrentFolder(currentFolder_.str());
64 
65  hMinvPi0EB_ = ibooker.book1D("Pi0InvmassEB", "Pi0 Invariant Mass in EB", 100, 0., 0.5);
66  hMinvPi0EB_->setAxisTitle("Inv Mass [GeV] ", 1);
67 
68  hPt1Pi0EB_ = ibooker.book1D("Pt1Pi0EB", "Pt 1st most energetic Pi0 photon in EB", 100, 0., 20.);
69  hPt1Pi0EB_->setAxisTitle("1st photon Pt [GeV] ", 1);
70 
71  hPt2Pi0EB_ = ibooker.book1D("Pt2Pi0EB", "Pt 2nd most energetic Pi0 photon in EB", 100, 0., 20.);
72  hPt2Pi0EB_->setAxisTitle("2nd photon Pt [GeV] ", 1);
73 
74  hPtPi0EB_ = ibooker.book1D("PtPi0EB", "Pi0 Pt in EB", 100, 0., 20.);
75  hPtPi0EB_->setAxisTitle("Pi0 Pt [GeV] ", 1);
76 
77  hIsoPi0EB_ = ibooker.book1D("IsoPi0EB", "Pi0 Iso in EB", 50, 0., 1.);
78  hIsoPi0EB_->setAxisTitle("Pi0 Iso", 1);
79 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
MonitorElement * hIsoPi0EB_
MonitorElement * hPtPi0EB_
MonitorElement * hMinvPi0EB_
std::stringstream currentFolder_
MonitorElement * hPt2Pi0EB_
MonitorElement * hPt1Pi0EB_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)

◆ makePizero()

void PiZeroAnalyzer::makePizero ( const edm::EventSetup es,
const edm::Handle< EcalRecHitCollection eb,
const edm::Handle< EcalRecHitCollection ee 
)
private

Definition at line 112 of file PiZeroAnalyzer.cc.

References edm::SortedCollection< T, SORT >::begin(), PositionCalc::Calculate_Location(), caloGeometryToken_, caloTopologyToken_, clusEtaSize_, clusPhiSize_, clusSeedThr_, funct::cos(), gather_cfg::cout, DetId::Ecal, EcalBarrel, EcalPreshower, edm::SortedCollection< T, SORT >::end(), hcalRecHitTable_cff::energy, JetChargeProducer_cfi::exp, dqm::impl::MonitorElement::Fill(), edm::EventSetup::getHandle(), CaloSubdetectorTopology::getWindow(), hIsoPi0EB_, hMinvPi0EB_, hPt1Pi0EB_, hPt2Pi0EB_, hPtPi0EB_, mps_fire::i, l1ctLayer2EG_cff::id, hcalRecHitTable_cff::ieta, EBDetId::ieta(), hcalRecHitTable_cff::iphi, EBDetId::iphi(), dqmiolumiharvest::j, dqmdumpme::k, posCalcParameters_, edm::Handle< T >::product(), HLT_2024v13_cff::seeds, seleMinvMaxPi0_, seleMinvMinPi0_, selePi0BeltDeta_, selePi0BeltDR_, selePi0Iso_, selePtGammaOne_, selePtGammaTwo_, selePtPi0_, seleS4S9GammaOne_, seleS4S9GammaTwo_, seleXtalMinEnergy_, funct::sin(), jetUpdater_cfi::sort, mathSSE::sqrt(), x, and y.

Referenced by analyze().

114  {
115  const EcalRecHitCollection* hitCollection_p = rhEB.product();
116 
117  //edm::ESHandle<CaloGeometry> geoHandle;
118  //es.get<CaloGeometryRecord>().get(geoHandle);
119  auto geoHandle = es.getHandle(caloGeometryToken_);
120 
121  //edm::ESHandle<CaloTopology> theCaloTopology;
122  //es.get<CaloTopologyRecord>().get(theCaloTopology);
123  auto theCaloTopology = es.getHandle(caloTopologyToken_);
124 
125  const CaloSubdetectorTopology* topology_p;
126  const CaloSubdetectorGeometry* geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
127  const CaloSubdetectorGeometry* geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
128 
129  // Parameters for the position calculation:
130  PositionCalc posCalculator_ = PositionCalc(posCalcParameters_);
131  //
132  std::map<DetId, EcalRecHit> recHitsEB_map;
133  //
134  std::vector<EcalRecHit> seeds;
135 
136  seeds.clear();
137  //
138  vector<EBDetId> usedXtals;
139  usedXtals.clear();
140  //
142  //
143  static const int MAXCLUS = 2000;
144  int nClus = 0;
145  vector<float> eClus;
146  vector<float> etClus;
147  vector<float> etaClus;
148  vector<float> phiClus;
149  vector<EBDetId> max_hit;
150  vector<vector<EcalRecHit> > RecHitsCluster;
151  vector<float> s4s9Clus;
152 
153  // find cluster seeds in EB
154  for (itb = rhEB->begin(); itb != rhEB->end(); ++itb) {
155  EBDetId id(itb->id());
156  double energy = itb->energy();
157  if (energy > seleXtalMinEnergy_) {
158  std::pair<DetId, EcalRecHit> map_entry(itb->id(), *itb);
159  recHitsEB_map.insert(map_entry);
160  }
161  if (energy > clusSeedThr_)
162  seeds.push_back(*itb);
163  } // Eb rechits
164 
165  sort(seeds.begin(), seeds.end(), [](auto& x, auto& y) { return (x.energy() > y.energy()); });
166  for (std::vector<EcalRecHit>::iterator itseed = seeds.begin(); itseed != seeds.end(); itseed++) {
167  EBDetId seed_id = itseed->id();
168  std::vector<EBDetId>::const_iterator usedIds;
169 
170  bool seedAlreadyUsed = false;
171  for (usedIds = usedXtals.begin(); usedIds != usedXtals.end(); usedIds++) {
172  if (*usedIds == seed_id) {
173  seedAlreadyUsed = true;
174  //cout<< " Seed with energy "<<itseed->energy()<<" was used !"<<endl;
175  break;
176  }
177  }
178  if (seedAlreadyUsed)
179  continue;
180  topology_p = theCaloTopology->getSubdetectorTopology(DetId::Ecal, EcalBarrel);
181  std::vector<DetId> clus_v = topology_p->getWindow(seed_id, clusEtaSize_, clusPhiSize_);
182  //std::vector<DetId> clus_used;
183  std::vector<std::pair<DetId, float> > clus_used;
184 
185  vector<EcalRecHit> RecHitsInWindow;
186 
187  double simple_energy = 0;
188 
189  for (std::vector<DetId>::iterator det = clus_v.begin(); det != clus_v.end(); det++) {
190  // EBDetId EBdet = *det;
191  // cout<<" det "<< EBdet<<" ieta "<<EBdet.ieta()<<" iphi "<<EBdet.iphi()<<endl;
192  bool HitAlreadyUsed = false;
193  for (usedIds = usedXtals.begin(); usedIds != usedXtals.end(); usedIds++) {
194  if (*usedIds == *det) {
195  HitAlreadyUsed = true;
196  break;
197  }
198  }
199  if (HitAlreadyUsed)
200  continue;
201  if (recHitsEB_map.find(*det) != recHitsEB_map.end()) {
202  // cout<<" Used det "<< EBdet<<endl;
203  std::map<DetId, EcalRecHit>::iterator aHit;
204  aHit = recHitsEB_map.find(*det);
205  usedXtals.push_back(*det);
206  RecHitsInWindow.push_back(aHit->second);
207  clus_used.push_back(std::pair<DetId, float>(*det, 1.));
208  simple_energy = simple_energy + aHit->second.energy();
209  }
210  }
211 
212  math::XYZPoint clus_pos = posCalculator_.Calculate_Location(clus_used, hitCollection_p, geometry_p, geometryES_p);
213  float theta_s = 2. * atan(exp(-clus_pos.eta()));
214  float p0x_s = simple_energy * sin(theta_s) * cos(clus_pos.phi());
215  float p0y_s = simple_energy * sin(theta_s) * sin(clus_pos.phi());
216  // float p0z_s = simple_energy * cos(theta_s);
217  float et_s = sqrt(p0x_s * p0x_s + p0y_s * p0y_s);
218 
219  //cout << " Simple Clustering: E,Et,px,py,pz: "<<simple_energy<<" "<<et_s<<" "<<p0x_s<<" "<<p0y_s<<" "<<endl;
220 
221  eClus.push_back(simple_energy);
222  etClus.push_back(et_s);
223  etaClus.push_back(clus_pos.eta());
224  phiClus.push_back(clus_pos.phi());
225  max_hit.push_back(seed_id);
226  RecHitsCluster.push_back(RecHitsInWindow);
227  //Compute S4/S9 variable
228  //We are not sure to have 9 RecHits so need to check eta and phi:
229  float s4s9_[4];
230  for (int i = 0; i < 4; i++)
231  s4s9_[i] = itseed->energy();
232  for (unsigned int j = 0; j < RecHitsInWindow.size(); j++) {
233  //cout << " Simple cluster rh, ieta, iphi : "<<((EBDetId)RecHitsInWindow[j].id()).ieta()<<" "<<((EBDetId)RecHitsInWindow[j].id()).iphi()<<endl;
234  if ((((EBDetId)RecHitsInWindow[j].id()).ieta() == seed_id.ieta() - 1 && seed_id.ieta() != 1) ||
235  (seed_id.ieta() == 1 && (((EBDetId)RecHitsInWindow[j].id()).ieta() == seed_id.ieta() - 2))) {
236  if (((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi() - 1 ||
237  ((EBDetId)RecHitsInWindow[j].id()).iphi() - 360 == seed_id.iphi() - 1) {
238  s4s9_[0] += RecHitsInWindow[j].energy();
239  } else {
240  if (((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi()) {
241  s4s9_[0] += RecHitsInWindow[j].energy();
242  s4s9_[1] += RecHitsInWindow[j].energy();
243  } else {
244  if (((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi() + 1 ||
245  ((EBDetId)RecHitsInWindow[j].id()).iphi() - 360 == seed_id.iphi() + 1) {
246  s4s9_[1] += RecHitsInWindow[j].energy();
247  }
248  }
249  }
250  } else {
251  if (((EBDetId)RecHitsInWindow[j].id()).ieta() == seed_id.ieta()) {
252  if (((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi() - 1 ||
253  ((EBDetId)RecHitsInWindow[j].id()).iphi() - 360 == seed_id.iphi() - 1) {
254  s4s9_[0] += RecHitsInWindow[j].energy();
255  s4s9_[3] += RecHitsInWindow[j].energy();
256  } else {
257  if (((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi() + 1 ||
258  ((EBDetId)RecHitsInWindow[j].id()).iphi() - 360 == seed_id.iphi() + 1) {
259  s4s9_[1] += RecHitsInWindow[j].energy();
260  s4s9_[2] += RecHitsInWindow[j].energy();
261  }
262  }
263  } else {
264  if ((((EBDetId)RecHitsInWindow[j].id()).ieta() == seed_id.ieta() + 1 && seed_id.ieta() != -1) ||
265  (seed_id.ieta() == -1 && (((EBDetId)RecHitsInWindow[j].id()).ieta() == seed_id.ieta() + 2))) {
266  if (((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi() - 1 ||
267  ((EBDetId)RecHitsInWindow[j].id()).iphi() - 360 == seed_id.iphi() - 1) {
268  s4s9_[3] += RecHitsInWindow[j].energy();
269  } else {
270  if (((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi()) {
271  s4s9_[2] += RecHitsInWindow[j].energy();
272  s4s9_[3] += RecHitsInWindow[j].energy();
273  } else {
274  if (((EBDetId)RecHitsInWindow[j].id()).iphi() == seed_id.iphi() + 1 ||
275  ((EBDetId)RecHitsInWindow[j].id()).iphi() - 360 == seed_id.iphi() + 1) {
276  s4s9_[2] += RecHitsInWindow[j].energy();
277  }
278  }
279  }
280  } else {
281  cout << " (EBDetId)RecHitsInWindow[j].id()).ieta() " << ((EBDetId)RecHitsInWindow[j].id()).ieta()
282  << " seed_id.ieta() " << seed_id.ieta() << endl;
283  cout << " Problem with S4 calculation " << endl;
284  return;
285  }
286  }
287  }
288  }
289  s4s9Clus.push_back(*max_element(s4s9_, s4s9_ + 4) / simple_energy);
290  // cout<<" s4s9Clus[0] "<<s4s9_[0]/simple_energy<<" s4s9Clus[1] "<<s4s9_[1]/simple_energy<<" s4s9Clus[2] "<<s4s9_[2]/simple_energy<<" s4s9Clus[3] "<<s4s9_[3]/simple_energy<<endl;
291  // cout<<" Max "<<*max_element( s4s9_,s4s9_+4)/simple_energy<<endl;
292  nClus++;
293  if (nClus == MAXCLUS)
294  return;
295  } // End loop over seed clusters
296 
297  // cout<< " Pi0 clusters: "<<nClus<<endl;
298 
299  // Selection, based on Simple clustering
300  //pi0 candidates
301  static const int MAXPI0S = 200;
302  int npi0_s = 0;
303 
304  vector<EBDetId> scXtals;
305  scXtals.clear();
306 
307  if (nClus <= 1)
308  return;
309  for (Int_t i = 0; i < nClus; i++) {
310  for (Int_t j = i + 1; j < nClus; j++) {
311  // cout<<" i "<<i<<" etClus[i] "<<etClus[i]<<" j "<<j<<" etClus[j] "<<etClus[j]<<endl;
312  if (etClus[i] > selePtGammaOne_ && etClus[j] > selePtGammaTwo_ && s4s9Clus[i] > seleS4S9GammaOne_ &&
313  s4s9Clus[j] > seleS4S9GammaTwo_) {
314  float theta_0 = 2. * atan(exp(-etaClus[i]));
315  float theta_1 = 2. * atan(exp(-etaClus[j]));
316 
317  float p0x = eClus[i] * sin(theta_0) * cos(phiClus[i]);
318  float p1x = eClus[j] * sin(theta_1) * cos(phiClus[j]);
319  float p0y = eClus[i] * sin(theta_0) * sin(phiClus[i]);
320  float p1y = eClus[j] * sin(theta_1) * sin(phiClus[j]);
321  float p0z = eClus[i] * cos(theta_0);
322  float p1z = eClus[j] * cos(theta_1);
323 
324  float pt_pi0 = sqrt((p0x + p1x) * (p0x + p1x) + (p0y + p1y) * (p0y + p1y));
325  // cout<<" pt_pi0 "<<pt_pi0<<endl;
326  if (pt_pi0 < selePtPi0_)
327  continue;
328  float m_inv = sqrt((eClus[i] + eClus[j]) * (eClus[i] + eClus[j]) - (p0x + p1x) * (p0x + p1x) -
329  (p0y + p1y) * (p0y + p1y) - (p0z + p1z) * (p0z + p1z));
330  if ((m_inv < seleMinvMaxPi0_) && (m_inv > seleMinvMinPi0_)) {
331  //New Loop on cluster to measure isolation:
332  vector<int> IsoClus;
333  IsoClus.clear();
334  float Iso = 0;
335  TVector3 pi0vect = TVector3((p0x + p1x), (p0y + p1y), (p0z + p1z));
336  for (Int_t k = 0; k < nClus; k++) {
337  if (k == i || k == j)
338  continue;
339  TVector3 Clusvect = TVector3(eClus[k] * sin(2. * atan(exp(-etaClus[k]))) * cos(phiClus[k]),
340  eClus[k] * sin(2. * atan(exp(-etaClus[k]))) * sin(phiClus[k]),
341  eClus[k] * cos(2. * atan(exp(-etaClus[k]))));
342  float dretaclpi0 = fabs(etaClus[k] - pi0vect.Eta());
343  float drclpi0 = Clusvect.DeltaR(pi0vect);
344 
345  if ((drclpi0 < selePi0BeltDR_) && (dretaclpi0 < selePi0BeltDeta_)) {
346  Iso = Iso + etClus[k];
347  IsoClus.push_back(k);
348  }
349  }
350 
351  if (Iso / pt_pi0 < selePi0Iso_) {
352  hMinvPi0EB_->Fill(m_inv);
353  hPt1Pi0EB_->Fill(etClus[i]);
354  hPt2Pi0EB_->Fill(etClus[j]);
355  hPtPi0EB_->Fill(pt_pi0);
356  hIsoPi0EB_->Fill(Iso / pt_pi0);
357 
358  npi0_s++;
359  }
360 
361  if (npi0_s == MAXPI0S)
362  return;
363  }
364  }
365  }
366  }
367 }
double clusSeedThr_
parameters needed for pizero finding
double selePi0BeltDeta_
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
MonitorElement * hIsoPi0EB_
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
MonitorElement * hPtPi0EB_
MonitorElement * hMinvPi0EB_
std::vector< EcalRecHit >::const_iterator const_iterator
double seleS4S9GammaOne_
double seleS4S9GammaTwo_
edm::ParameterSet posCalcParameters_
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
void Fill(long long x)
const edm::ESGetToken< CaloTopology, CaloTopologyRecord > caloTopologyToken_
double seleMinvMaxPi0_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > caloGeometryToken_
T sqrt(T t)
Definition: SSEVec.h:19
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
math::XYZPoint Calculate_Location(const HitsAndFractions &iDetIds, const edm::SortedCollection< HitType > *iRecHits, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorGeometry *iESGeom=nullptr)
Definition: PositionCalc.h:65
double selePtGammaOne_
double selePtGammaTwo_
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
MonitorElement * hPt2Pi0EB_
MonitorElement * hPt1Pi0EB_
double seleXtalMinEnergy_
double seleMinvMinPi0_

Member Data Documentation

◆ barrelEcalHits_token_

edm::EDGetTokenT<edm::SortedCollection<EcalRecHit, edm::StrictWeakOrdering<EcalRecHit> > > PiZeroAnalyzer::barrelEcalHits_token_
private

Definition at line 94 of file PiZeroAnalyzer.h.

Referenced by analyze().

◆ caloGeometryToken_

const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> PiZeroAnalyzer::caloGeometryToken_
private

Definition at line 97 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ caloTopologyToken_

const edm::ESGetToken<CaloTopology, CaloTopologyRecord> PiZeroAnalyzer::caloTopologyToken_
private

Definition at line 98 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ clusEtaSize_

int PiZeroAnalyzer::clusEtaSize_
private

Definition at line 107 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ clusPhiSize_

int PiZeroAnalyzer::clusPhiSize_
private

Definition at line 108 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ clusSeedThr_

double PiZeroAnalyzer::clusSeedThr_
private

parameters needed for pizero finding

Definition at line 106 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ currentFolder_

std::stringstream PiZeroAnalyzer::currentFolder_
private

Definition at line 128 of file PiZeroAnalyzer.h.

Referenced by bookHistograms().

◆ cutStep_

double PiZeroAnalyzer::cutStep_
private

Definition at line 102 of file PiZeroAnalyzer.h.

◆ endcapEcalHits_token_

edm::EDGetTokenT<edm::SortedCollection<EcalRecHit, edm::StrictWeakOrdering<EcalRecHit> > > PiZeroAnalyzer::endcapEcalHits_token_
private

Definition at line 95 of file PiZeroAnalyzer.h.

Referenced by analyze().

◆ fName_

std::string PiZeroAnalyzer::fName_
private

Definition at line 87 of file PiZeroAnalyzer.h.

◆ hIsoPi0EB_

MonitorElement* PiZeroAnalyzer::hIsoPi0EB_
private

Definition at line 133 of file PiZeroAnalyzer.h.

Referenced by bookHistograms(), and makePizero().

◆ hMinvPi0EB_

MonitorElement* PiZeroAnalyzer::hMinvPi0EB_
private

Definition at line 130 of file PiZeroAnalyzer.h.

Referenced by bookHistograms(), and makePizero().

◆ hPt1Pi0EB_

MonitorElement* PiZeroAnalyzer::hPt1Pi0EB_
private

Definition at line 131 of file PiZeroAnalyzer.h.

Referenced by bookHistograms(), and makePizero().

◆ hPt2Pi0EB_

MonitorElement* PiZeroAnalyzer::hPt2Pi0EB_
private

Definition at line 132 of file PiZeroAnalyzer.h.

Referenced by bookHistograms(), and makePizero().

◆ hPtPi0EB_

MonitorElement* PiZeroAnalyzer::hPtPi0EB_
private

Definition at line 134 of file PiZeroAnalyzer.h.

Referenced by bookHistograms(), and makePizero().

◆ minPhoEtCut_

double PiZeroAnalyzer::minPhoEtCut_
private

Definition at line 100 of file PiZeroAnalyzer.h.

◆ nEvt_

int PiZeroAnalyzer::nEvt_
private

Definition at line 90 of file PiZeroAnalyzer.h.

Referenced by analyze().

◆ numberOfSteps_

int PiZeroAnalyzer::numberOfSteps_
private

Definition at line 103 of file PiZeroAnalyzer.h.

◆ ParameterLogWeighted_

bool PiZeroAnalyzer::ParameterLogWeighted_
private

Definition at line 112 of file PiZeroAnalyzer.h.

◆ ParameterT0_barl_

double PiZeroAnalyzer::ParameterT0_barl_
private

Definition at line 114 of file PiZeroAnalyzer.h.

◆ ParameterW0_

double PiZeroAnalyzer::ParameterW0_
private

Definition at line 115 of file PiZeroAnalyzer.h.

◆ ParameterX0_

double PiZeroAnalyzer::ParameterX0_
private

Definition at line 113 of file PiZeroAnalyzer.h.

◆ posCalcParameters_

edm::ParameterSet PiZeroAnalyzer::posCalcParameters_
private

Definition at line 92 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ prescaleFactor_

unsigned int PiZeroAnalyzer::prescaleFactor_
private

Definition at line 88 of file PiZeroAnalyzer.h.

Referenced by analyze().

◆ seleMinvMaxPi0_

double PiZeroAnalyzer::seleMinvMaxPi0_
private

Definition at line 125 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ seleMinvMinPi0_

double PiZeroAnalyzer::seleMinvMinPi0_
private

Definition at line 126 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ selePi0BeltDeta_

double PiZeroAnalyzer::selePi0BeltDeta_
private

Definition at line 123 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ selePi0BeltDR_

double PiZeroAnalyzer::selePi0BeltDR_
private

Definition at line 122 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ selePi0Iso_

double PiZeroAnalyzer::selePi0Iso_
private

Definition at line 124 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ selePtGammaOne_

double PiZeroAnalyzer::selePtGammaOne_
private

Definition at line 117 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ selePtGammaTwo_

double PiZeroAnalyzer::selePtGammaTwo_
private

Definition at line 118 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ selePtPi0_

double PiZeroAnalyzer::selePtPi0_
private

Definition at line 119 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ seleS4S9GammaOne_

double PiZeroAnalyzer::seleS4S9GammaOne_
private

Definition at line 120 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ seleS4S9GammaTwo_

double PiZeroAnalyzer::seleS4S9GammaTwo_
private

Definition at line 121 of file PiZeroAnalyzer.h.

Referenced by makePizero().

◆ seleXtalMinEnergy_

double PiZeroAnalyzer::seleXtalMinEnergy_
private

Definition at line 110 of file PiZeroAnalyzer.h.

Referenced by makePizero().