CMS 3D CMS Logo

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

#include <ContainmentCorrectionAnalyzer.h>

Inheritance diagram for ContainmentCorrectionAnalyzer:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginJob () override
 
 ContainmentCorrectionAnalyzer (const edm::ParameterSet &)
 
void endJob () override
 
 ~ContainmentCorrectionAnalyzer () 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 final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const 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
 
bool wantsStreamRuns () const
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

float ecalEta (float EtaParticle, float Zvertex, float plane_Radius)
 
void fillMcTruth (std::vector< SimTrack > &theSimTracks, std::vector< SimVertex > &theSimVertices)
 
std::vector< EcalSimPhotonMCTruthfindMcTruth (std::vector< SimTrack > &theSimTracks, std::vector< SimVertex > &theSimVertices)
 

Private Attributes

edm::EDGetTokenT< reco::SuperClusterCollectionBarrelSuperClusterCollection_
 
std::vector< float > e1
 
std::vector< float > e25
 
std::vector< float > e9
 
edm::EDGetTokenT< reco::SuperClusterCollectionEndcapSuperClusterCollection_
 
std::map< unsigned, unsigned > geantToIndex_
 
TH1F * h_EB_converted
 
TH1F * h_EB_e25EtrueReference
 
TH1F * h_EB_e9EtrueReference
 
TH1F * h_EB_eRecoEtrueReference
 
TH1F * h_EB_eTrue
 
TH1F * h_EE_converted
 
TH1F * h_EE_e25EtrueReference
 
TH1F * h_EE_e9EtrueReference
 
TH1F * h_EE_eRecoEtrueReference
 
TH1F * h_EE_eTrue
 
std::vector< int > iMC
 
std::vector< int > isConverted
 
std::vector< float > mcEnergy
 
std::vector< float > mcEta
 
std::vector< float > mcPhi
 
std::vector< float > mcPt
 
int nMCphotons
 
int nRECOphotons
 
edm::ESGetToken< CaloTopology, CaloTopologyRecordpTopologyToken
 
edm::EDGetTokenT< EcalRecHitCollectionreducedBarrelRecHitCollection_
 
edm::EDGetTokenT< EcalRecHitCollectionreducedEndcapRecHitCollection_
 
std::vector< int > seedXtal
 
edm::EDGetTokenT< edm::SimTrackContainerSimTrackCollection_
 
edm::EDGetTokenT< edm::SimVertexContainerSimVertexCollection_
 
std::vector< float > superClusterEnergy
 
std::vector< float > superClusterEt
 
std::vector< float > superClusterEta
 
std::vector< float > superClusterPhi
 
std::vector< float > x_vtx
 
std::vector< float > y_vtx
 
std::vector< float > z_vtx
 

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 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<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

Definition at line 48 of file ContainmentCorrectionAnalyzer.h.

Constructor & Destructor Documentation

◆ ContainmentCorrectionAnalyzer()

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

Definition at line 11 of file ContainmentCorrectionAnalyzer.cc.

References BarrelSuperClusterCollection_, EndcapSuperClusterCollection_, edm::ParameterSet::getParameter(), reducedBarrelRecHitCollection_, reducedEndcapRecHitCollection_, SimTrackCollection_, and SimVertexCollection_.

13  consumes<reco::SuperClusterCollection>(ps.getParameter<InputTag>("BarrelSuperClusterCollection"));
15  consumes<reco::SuperClusterCollection>(ps.getParameter<InputTag>("EndcapSuperClusterCollection"));
17  consumes<EcalRecHitCollection>(ps.getParameter<InputTag>("reducedBarrelRecHitCollection"));
19  consumes<EcalRecHitCollection>(ps.getParameter<InputTag>("reducedEndcapRecHitCollection"));
20  SimTrackCollection_ = consumes<SimTrackContainer>(ps.getParameter<InputTag>("simTrackCollection"));
21  SimVertexCollection_ = consumes<SimVertexContainer>(ps.getParameter<InputTag>("simVertexCollection"));
22 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollection_
edm::EDGetTokenT< edm::SimTrackContainer > SimTrackCollection_
edm::ESGetToken< CaloTopology, CaloTopologyRecord > pTopologyToken
edm::EDGetTokenT< reco::SuperClusterCollection > BarrelSuperClusterCollection_
edm::EDGetTokenT< edm::SimVertexContainer > SimVertexCollection_
edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollection_
edm::EDGetTokenT< reco::SuperClusterCollection > EndcapSuperClusterCollection_

◆ ~ContainmentCorrectionAnalyzer()

ContainmentCorrectionAnalyzer::~ContainmentCorrectionAnalyzer ( )
override

Definition at line 24 of file ContainmentCorrectionAnalyzer.cc.

24 {}

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 42 of file ContainmentCorrectionAnalyzer.cc.

References BarrelSuperClusterCollection_, PbPb_ZMuSkimMuonDPG_cff::deltaR, MillePedeFileConverter_cfg::e, e1, e25, e9, ecalEta(), cosmicPhotonAnalyzer_cfi::eMax, EndcapSuperClusterCollection_, PVValHelper::eta, findMcTruth(), edm::Event::getByToken(), edm::EventSetup::getData(), edm::EventSetup::getHandle(), SiStripPI::getMaximum(), h_EB_converted, h_EB_e25EtrueReference, h_EB_e9EtrueReference, h_EB_eRecoEtrueReference, h_EB_eTrue, h_EE_converted, h_EE_e25EtrueReference, h_EE_e9EtrueReference, h_EE_eRecoEtrueReference, h_EE_eTrue, mps_fire::i, edm::EventBase::id(), iMC, LEDCalibrationChannels::iphi, isConverted, edm::HandleBase::isValid(), MainPageGenerator::l, edm::EDConsumerBase::labelsForToken(), mcEnergy, mcEta, mcPhi, mcPt, nMCphotons, nRECOphotons, BPHMonitor_cfi::photons, pi, reco::CaloCluster::position(), funct::pow(), reco::SuperCluster::preshowerEnergy(), edm::Handle< T >::product(), pTopologyToken, reco::SuperCluster::rawEnergy(), reducedBarrelRecHitCollection_, reducedEndcapRecHitCollection_, reco::SuperCluster::seed(), seedXtal, SimTrackCollection_, SimVertexCollection_, mathSSE::sqrt(), superClusterEnergy, superClusterEt, superClusterEta, superClusterPhi, extraflags_cff::vtx, x_vtx, y_vtx, and z_vtx.

42  {
43  LogInfo("ContainmentCorrectionAnalyzer") << "Analyzing event " << evt.id() << "\n";
44 
45  // taking the needed collections
46  std::vector<SimTrack> theSimTracks;
48  evt.getByToken(SimTrackCollection_, SimTk);
49  Labels l;
51 
52  if (SimTk.isValid())
53  theSimTracks.insert(theSimTracks.end(), SimTk->begin(), SimTk->end());
54  else {
55  LogError("ContainmentCorrectionAnalyzer") << "Error! can't get collection with label " << l.module;
56  }
57 
58  std::vector<SimVertex> theSimVertexes;
60  evt.getByToken(SimVertexCollection_, SimVtx);
62 
63  if (SimVtx.isValid())
64  theSimVertexes.insert(theSimVertexes.end(), SimVtx->begin(), SimVtx->end());
65  else {
66  LogError("ContainmentCorrectionAnalyzer") << "Error! can't get collection with label " << l.module;
67  }
68 
69  const reco::SuperClusterCollection *BarrelSuperClusters = nullptr;
70  Handle<reco::SuperClusterCollection> pHybridBarrelSuperClusters;
71  evt.getByToken(BarrelSuperClusterCollection_, pHybridBarrelSuperClusters);
73 
74  if (pHybridBarrelSuperClusters.isValid()) {
75  BarrelSuperClusters = pHybridBarrelSuperClusters.product();
76  } else {
77  LogError("ContainmentCorrectionAnalyzer") << "Error! can't get collection with label " << l.module;
78  }
79 
80  const reco::SuperClusterCollection *EndcapSuperClusters = nullptr;
81  Handle<reco::SuperClusterCollection> pMulti5x5EndcapSuperClusters;
82  evt.getByToken(EndcapSuperClusterCollection_, pMulti5x5EndcapSuperClusters);
84 
85  if (pMulti5x5EndcapSuperClusters.isValid())
86  EndcapSuperClusters = pMulti5x5EndcapSuperClusters.product();
87  else {
88  LogError("ContainmentCorrectionAnalyzer") << "Error! can't get collection with label " << l.module;
89  }
90 
91  const EcalRecHitCollection *ebRecHits = nullptr;
95 
96  if (pEBRecHits.isValid())
97  ebRecHits = pEBRecHits.product();
98  else {
99  LogError("ContainmentCorrectionAnalyzer") << "Error! can't get collection with label " << l.module;
100  }
101 
102  const EcalRecHitCollection *eeRecHits = nullptr;
103  Handle<EcalRecHitCollection> pEERecHits;
106 
107  if (pEERecHits.isValid())
108  eeRecHits = pEERecHits.product();
109  else {
110  LogError("ContainmentCorrectionAnalyzer") << "Error! can't get collection with label " << l.module;
111  }
112 
113  const CaloTopology *topology = nullptr;
114  auto pTopology = es.getHandle(pTopologyToken);
115  if (pTopology.isValid())
116  topology = &es.getData(pTopologyToken);
117 
118  std::vector<EcalSimPhotonMCTruth> photons = findMcTruth(theSimTracks, theSimVertexes);
119 
120  nMCphotons = 0;
121  nRECOphotons = 0;
122 
123  int mc_size = photons.size();
124  mcEnergy.resize(mc_size);
125  mcEta.resize(mc_size);
126  mcPhi.resize(mc_size);
127  mcPt.resize(mc_size);
128  isConverted.resize(mc_size);
129  x_vtx.resize(mc_size);
130  y_vtx.resize(mc_size);
131  z_vtx.resize(mc_size);
132 
133  superClusterEnergy.resize(mc_size);
134  superClusterEta.resize(mc_size);
135  superClusterPhi.resize(mc_size);
136  superClusterEt.resize(mc_size);
137  e1.resize(mc_size);
138  e9.resize(mc_size);
139  e25.resize(mc_size);
140  seedXtal.resize(mc_size);
141  iMC.resize(mc_size);
142 
143  // loop over MC truth photons
144  for (unsigned int ipho = 0; ipho < photons.size(); ipho++) {
145  math::XYZTLorentzVectorD vtx = photons[ipho].primaryVertex();
146  double phiTrue = photons[ipho].fourMomentum().phi();
147  double vtxPerp = sqrt(vtx.x() * vtx.x() + vtx.y() * vtx.y());
148  double etaTrue = ecalEta(photons[ipho].fourMomentum().eta(), vtx.z(), vtxPerp);
149  double etTrue = photons[ipho].fourMomentum().e() / cosh(etaTrue);
150  nMCphotons++;
151  mcEnergy[nMCphotons - 1] = photons[ipho].fourMomentum().e();
152  mcEta[nMCphotons - 1] = etaTrue;
153  mcPhi[nMCphotons - 1] = phiTrue;
154  mcPt[nMCphotons - 1] = etTrue;
155  isConverted[nMCphotons - 1] = photons[ipho].isAConversion();
156  x_vtx[nMCphotons - 1] = vtx.x();
157  y_vtx[nMCphotons - 1] = vtx.y();
158  z_vtx[nMCphotons - 1] = vtx.z();
159 
160  // check histos for MC truth
161  if (std::fabs(etaTrue) < 1.479) {
162  h_EB_eTrue->Fill(photons[ipho].fourMomentum().e());
163  h_EB_converted->Fill(photons[ipho].isAConversion());
164  }
165  if (std::fabs(etaTrue) >= 1.6) {
166  h_EE_eTrue->Fill(photons[ipho].fourMomentum().e());
167  h_EE_converted->Fill(photons[ipho].isAConversion());
168  }
169 
170  // barrel
171  if (std::fabs(etaTrue) < 1.479) {
172  double etaCurrent; // , etaFound = 0; // UNUSED
173  double phiCurrent;
174  // double etCurrent, etFound = 0; // UNUSED
175  const reco::SuperCluster *nearSC = nullptr;
176 
177  double closestParticleDistance = 999;
178  for (reco::SuperClusterCollection::const_iterator aClus = BarrelSuperClusters->begin();
179  aClus != BarrelSuperClusters->end();
180  aClus++) {
181  etaCurrent = aClus->position().eta();
182  phiCurrent = aClus->position().phi();
183  // etCurrent = aClus->energy()/std::cosh(etaCurrent); // UNUSED
184  double deltaR = std::sqrt(std::pow(etaCurrent - etaTrue, 2) + std::pow(phiCurrent - phiTrue, 2));
185  if (deltaR < closestParticleDistance) {
186  // etFound = etCurrent; // UNUSED
187  // etaFound = etaCurrent; // UNUSED
188  closestParticleDistance = deltaR;
189  nearSC = &(*aClus);
190  }
191  }
192 
193  if (closestParticleDistance < 0.3) {
194  // Is a matched particle dumping informations
195  nRECOphotons++;
196  superClusterEnergy[nRECOphotons - 1] = nearSC->rawEnergy();
197  superClusterEta[nRECOphotons - 1] = nearSC->position().eta();
198  superClusterPhi[nRECOphotons - 1] = nearSC->position().phi();
199  superClusterEt[nRECOphotons - 1] = nearSC->rawEnergy() / std::cosh(nearSC->position().eta());
200  iMC[nRECOphotons - 1] = nMCphotons - 1;
201 
202  const reco::CaloClusterPtr &theSeed = nearSC->seed();
203  seedXtal[nRECOphotons - 1] = EcalClusterTools::getMaximum(*theSeed, ebRecHits).first;
204  e1[nRECOphotons - 1] = EcalClusterTools::eMax(*theSeed, ebRecHits);
205  e9[nRECOphotons - 1] = EcalClusterTools::e3x3(*theSeed, ebRecHits, topology);
206  e25[nRECOphotons - 1] = EcalClusterTools::e5x5(*theSeed, ebRecHits, topology);
207  }
208  }
209 
210  // endcap
211  if (std::fabs(etaTrue) >= 1.6) {
212  double etaCurrent; // , etaFound = 0; // UNUSED
213  double phiCurrent;
214  // double etCurrent, etFound = 0; // UNUSED
215  const reco::SuperCluster *nearSC = nullptr;
216 
217  double closestParticleDistance = 999;
218  for (reco::SuperClusterCollection::const_iterator aClus = EndcapSuperClusters->begin();
219  aClus != EndcapSuperClusters->end();
220  aClus++) {
221  etaCurrent = aClus->position().eta();
222  phiCurrent = aClus->position().phi();
223  // etCurrent = aClus->energy()/std::cosh(etaCurrent);
224  double deltaR = std::sqrt(std::pow(etaCurrent - etaTrue, 2) + std::pow(phiCurrent - phiTrue, 2));
225  if (deltaR < closestParticleDistance) {
226  // etFound = etCurrent; // UNUSED
227  // etaFound = etaCurrent; // UNUSED
228  closestParticleDistance = deltaR;
229  nearSC = &(*aClus);
230  }
231  }
232 
233  if (closestParticleDistance < 0.3) {
234  // Is a matched particle dumping informations
235  nRECOphotons++;
236  float psEnergy = nearSC->preshowerEnergy();
237  superClusterEnergy[nRECOphotons - 1] = nearSC->rawEnergy() + psEnergy;
238  superClusterEta[nRECOphotons - 1] = nearSC->position().eta();
239  superClusterPhi[nRECOphotons - 1] = nearSC->position().phi();
240  superClusterEt[nRECOphotons - 1] = (nearSC->rawEnergy() + psEnergy) / std::cosh(nearSC->position().eta());
241  iMC[nRECOphotons - 1] = nMCphotons - 1;
242 
243  const reco::CaloClusterPtr &theSeed = nearSC->seed();
244  seedXtal[nRECOphotons - 1] = EcalClusterTools::getMaximum(*theSeed, eeRecHits).first;
245  e1[nRECOphotons - 1] = EcalClusterTools::eMax(*theSeed, eeRecHits) + psEnergy;
246  e9[nRECOphotons - 1] = EcalClusterTools::e3x3(*theSeed, eeRecHits, topology) + psEnergy;
247  e25[nRECOphotons - 1] = EcalClusterTools::e5x5(*theSeed, eeRecHits, topology) + psEnergy;
248  }
249  }
250  }
251 
252  // containment analysis for unconverted photons in the reference region only
253  for (int i = 0; i < nRECOphotons; i++) {
254  // barrel
255  if (fabs(superClusterEta[i]) < 1.479) {
256  if (isConverted[iMC[i]] != 1) {
257  int ietaAbs = (seedXtal[i] >> 9) & 0x7F;
258  int iphi = seedXtal[i] & 0x1FF;
259  if (ietaAbs > 5 && ietaAbs < 21 && ((iphi % 20) > 5) && ((iphi % 20) < 16)) {
261  h_EB_e9EtrueReference->Fill(e9[i] / mcEnergy[iMC[i]]);
263  }
264  }
265  }
266 
267  // endcap
268  if (fabs(superClusterEta[i]) > 1.6) {
269  if (isConverted[iMC[i]] != 1) {
270  if (fabs(superClusterEta[i]) > 1.7 && fabs(superClusterEta[i] < 2.3) &&
271  ((superClusterPhi[i] > -CLHEP::pi / 2. + 0.1 && superClusterPhi[i] < CLHEP::pi / 2. - 0.1) ||
272  (superClusterPhi[i] > CLHEP::pi / 2. + 0.1) || (superClusterPhi[i] < -CLHEP::pi / 2. - 0.1))) {
274  h_EE_e9EtrueReference->Fill(e9[i] / mcEnergy[iMC[i]]);
276  }
277  }
278  }
279 
280  } // loop over reco photons
281 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:154
std::vector< EcalSimPhotonMCTruth > findMcTruth(std::vector< SimTrack > &theSimTracks, std::vector< SimVertex > &theSimVertices)
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollection_
double rawEnergy() const
raw uncorrected energy (sum of energies of component BasicClusters)
Definition: SuperCluster.h:58
T const * product() const
Definition: Handle.h:70
edm::EDGetTokenT< edm::SimTrackContainer > SimTrackCollection_
edm::ESGetToken< CaloTopology, CaloTopologyRecord > pTopologyToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
Log< level::Error, false > LogError
double getMaximum(TObjArray *array)
const Double_t pi
edm::EDGetTokenT< reco::SuperClusterCollection > BarrelSuperClusterCollection_
float ecalEta(float EtaParticle, float Zvertex, float plane_Radius)
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
T sqrt(T t)
Definition: SSEVec.h:19
edm::EDGetTokenT< edm::SimVertexContainer > SimVertexCollection_
edm::EventID id() const
Definition: EventBase.h:59
bool getData(T &iHolder) const
Definition: EventSetup.h:122
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
ProductLabels Labels
Log< level::Info, false > LogInfo
edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollection_
bool isValid() const
Definition: HandleBase.h:70
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:77
edm::EDGetTokenT< reco::SuperClusterCollection > EndcapSuperClusterCollection_
double preshowerEnergy() const
energy deposited in preshower
Definition: SuperCluster.h:61
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
void labelsForToken(EDGetToken iToken, Labels &oLabels) const

◆ beginJob()

void ContainmentCorrectionAnalyzer::beginJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 26 of file ContainmentCorrectionAnalyzer.cc.

References compareTotals::fs, h_EB_converted, h_EB_e25EtrueReference, h_EB_e9EtrueReference, h_EB_eRecoEtrueReference, h_EB_eTrue, h_EE_converted, h_EE_e25EtrueReference, h_EE_e9EtrueReference, h_EE_eRecoEtrueReference, and h_EE_eTrue.

26  {
28 
29  // Define reference histograms
30  h_EB_eRecoEtrueReference = fs->make<TH1F>("EB_eRecoEtrueReference", "EB_eRecoEtrueReference", 440, 0., 1.1);
31  h_EB_e9EtrueReference = fs->make<TH1F>("EB_e9EtrueReference", "EB_e9EtrueReference", 440, 0., 1.1);
32  h_EB_e25EtrueReference = fs->make<TH1F>("EB_e25EtrueReference", "EB_e25EtrueReference", 440, 0., 1.1);
33  h_EE_eRecoEtrueReference = fs->make<TH1F>("EE_eRecoEtrueReference", "EE_eRecoEtrueReference", 440, 0., 1.1);
34  h_EE_e9EtrueReference = fs->make<TH1F>("EE_e9EtrueReference", "EE_e9EtrueReference", 440, 0., 1.1);
35  h_EE_e25EtrueReference = fs->make<TH1F>("EE_e25EtrueReference", "EE_e25EtrueReference", 440, 0., 1.1);
36  h_EB_eTrue = fs->make<TH1F>("EB_eTrue", "EB_eTrue", 41, 40., 60.);
37  h_EE_eTrue = fs->make<TH1F>("EE_eTrue", "EE_eTrue", 41, 40., 60.);
38  h_EB_converted = fs->make<TH1F>("EB_converted", "EB_converted", 2, 0., 2.);
39  h_EE_converted = fs->make<TH1F>("EE_converted", "EE_converted", 2, 0., 2.);
40 }

◆ ecalEta()

float ContainmentCorrectionAnalyzer::ecalEta ( float  EtaParticle,
float  Zvertex,
float  plane_Radius 
)
private

Definition at line 285 of file ContainmentCorrectionAnalyzer.cc.

References ETA, etaBarrelEndcap, dqm-mbProfile::log, Geom::pi(), R_ECAL, funct::tan(), Z_Endcap, and ZEcal.

Referenced by analyze().

285  {
286  const float R_ECAL = 136.5;
287  const float Z_Endcap = 328.0;
288  const float etaBarrelEndcap = 1.479;
289 
290  if (EtaParticle != 0.) {
291  float Theta = 0.0;
292  float ZEcal = (R_ECAL - plane_Radius) * sinh(EtaParticle) + Zvertex;
293 
294  if (ZEcal != 0.0)
295  Theta = atan(R_ECAL / ZEcal);
296  if (Theta < 0.0)
297  Theta = Theta + Geom::pi();
298 
299  float ETA = -log(tan(0.5 * Theta));
300 
301  if (fabs(ETA) > etaBarrelEndcap) {
302  float Zend = Z_Endcap;
303  if (EtaParticle < 0.0)
304  Zend = -Zend;
305  float Zlen = Zend - Zvertex;
306  float RR = Zlen / sinh(EtaParticle);
307  Theta = atan((RR + plane_Radius) / Zend);
308  if (Theta < 0.0)
309  Theta = Theta + Geom::pi();
310  ETA = -log(tan(0.5 * Theta));
311  }
312 
313  return ETA;
314  } else {
315  LogWarning("") << "[ContainmentCorrectionAnalyzer::ecalEta] Warning: Eta "
316  "equals to zero, not correcting";
317  return EtaParticle;
318  }
319 }
static constexpr float R_ECAL
#define ETA
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
static constexpr float etaBarrelEndcap
static constexpr float ZEcal
Log< level::Warning, false > LogWarning
constexpr double pi()
Definition: Pi.h:31
static constexpr float Z_Endcap

◆ endJob()

void ContainmentCorrectionAnalyzer::endJob ( void  )
overridevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 283 of file ContainmentCorrectionAnalyzer.cc.

283 {}

◆ fillMcTruth()

void ContainmentCorrectionAnalyzer::fillMcTruth ( std::vector< SimTrack > &  theSimTracks,
std::vector< SimVertex > &  theSimVertices 
)
private

Definition at line 478 of file ContainmentCorrectionAnalyzer.cc.

References geantToIndex_, L1TkPrimaryVertex_cfi::nVtx, TrackCandidateProducer_cfi::simTracks, and HGCalValidator_cfi::simVertices.

Referenced by findMcTruth().

478  {
479  unsigned nVtx = simVertices.size();
480  unsigned nTks = simTracks.size();
481  if (nVtx == 0)
482  return;
483  // create a map associating geant particle id and position in the event
484  // SimTrack vector
485  for (unsigned it = 0; it < nTks; ++it) {
486  geantToIndex_[simTracks[it].trackId()] = it;
487  }
488 }
std::map< unsigned, unsigned > geantToIndex_

◆ findMcTruth()

std::vector< EcalSimPhotonMCTruth > ContainmentCorrectionAnalyzer::findMcTruth ( std::vector< SimTrack > &  theSimTracks,
std::vector< SimVertex > &  theSimVertices 
)
private

store this electron since it's from a converted photon

Definition at line 322 of file ContainmentCorrectionAnalyzer.cc.

References funct::abs(), fillMcTruth(), geantToIndex_, if(), objects.autophobj::motherId, CoreSimVertex::position(), mps_fire::result, and bphysicsOniaDQM_cfi::vertex.

Referenced by analyze().

323  {
324  std::vector<EcalSimPhotonMCTruth> result;
325 
326  geantToIndex_.clear();
327  // int idTrk1_[10]; // UNUSED
328  // int idTrk2_[10]; // UNUSED
329 
330  // Local variables
331  // const int SINGLE=1; // UNUSED
332  // const int DOUBLE=2; // UNUSED
333  // const int PYTHIA=3; // UNUSED
334  const int ELECTRON_FLAV = 1;
335  const int PIZERO_FLAV = 2;
336  const int PHOTON_FLAV = 3;
337 
338  // int ievtype=0; // UNUSED
339  int ievflav = 0;
340  std::vector<SimTrack *> photonTracks;
341  std::vector<SimTrack *> pizeroTracks;
342  std::vector<const SimTrack *> trkFromConversion;
343  SimVertex primVtx;
344  std::vector<int> convInd;
345 
346  fillMcTruth(theSimTracks, theSimVertices);
347  int iPV = -1;
348  int partType1 = 0;
349  int partType2 = 0;
350  std::vector<SimTrack>::iterator iFirstSimTk = theSimTracks.begin();
351  if (!(*iFirstSimTk).noVertex()) {
352  iPV = (*iFirstSimTk).vertIndex();
353  int vtxId = (*iFirstSimTk).vertIndex();
354  primVtx = theSimVertices[vtxId];
355  partType1 = (*iFirstSimTk).type();
356  }
357 
358  // Look at a second track
359  iFirstSimTk++;
360  if (iFirstSimTk != theSimTracks.end()) {
361  if ((*iFirstSimTk).vertIndex() == iPV) {
362  partType2 = (*iFirstSimTk).type();
363  }
364  }
365  int npv = 0;
366  int iPho = 0;
367  for (std::vector<SimTrack>::iterator iSimTk = theSimTracks.begin(); iSimTk != theSimTracks.end(); ++iSimTk) {
368  if ((*iSimTk).noVertex())
369  continue;
370  // int vertexId = (*iSimTk).vertIndex(); // UNUSED
371  // SimVertex vertex = theSimVertices[vertexId]; // UNUSED
372  if ((*iSimTk).vertIndex() == iPV) {
373  npv++;
374  if ((*iSimTk).type() == 22) {
375  convInd.push_back(0);
376  photonTracks.push_back(&(*iSimTk));
377  // math::XYZTLorentzVectorD momentum = (*iSimTk).momentum(); // UNUSED
378  }
379  }
380  }
381 
382  if (npv > 4) { // ievtype = PYTHIA; // UNUSED
383  } else if (npv == 1) {
384  if (abs(partType1) == 11) { /* ievtype = SINGLE; ==UNUSED== */
385  ievflav = ELECTRON_FLAV;
386  } else if (partType1 == 111) { /* ievtype = SINGLE; ==UNUSED== */
387  ievflav = PIZERO_FLAV;
388  } else if (partType1 == 22) { /* ievtype = SINGLE; ==UNUSED== */
389  ievflav = PHOTON_FLAV;
390  }
391  } else if (npv == 2) {
392  if (abs(partType1) == 11 && abs(partType2) == 11) { /* ievtype = DOUBLE; ==UNUSED== */
393  ievflav = ELECTRON_FLAV;
394  } else if (partType1 == 111 && partType2 == 111) { /* ievtype = DOUBLE; ==UNUSED== */
395  ievflav = PIZERO_FLAV;
396  } else if (partType1 == 22 && partType2 == 22) { /* ievtype = DOUBLE; ==UNUSED== */
397  ievflav = PHOTON_FLAV;
398  }
399  }
400 
401  // Look into converted photons
402  int isAconversion = 0;
403  if (ievflav == PHOTON_FLAV) {
404  int nConv = 0;
405  int iConv = 0;
406  iPho = 0;
407  for (std::vector<SimTrack *>::iterator iPhoTk = photonTracks.begin(); iPhoTk != photonTracks.end(); ++iPhoTk) {
408  trkFromConversion.clear();
409  for (std::vector<SimTrack>::iterator iSimTk = theSimTracks.begin(); iSimTk != theSimTracks.end(); ++iSimTk) {
410  if ((*iSimTk).noVertex())
411  continue;
412  if ((*iSimTk).vertIndex() == iPV)
413  continue;
414  if (abs((*iSimTk).type()) != 11)
415  continue;
416  int vertexId = (*iSimTk).vertIndex();
417  SimVertex vertex = theSimVertices[vertexId];
418  int motherId = -1;
419  if (vertex.parentIndex()) {
420  unsigned motherGeantId = vertex.parentIndex();
421  std::map<unsigned, unsigned>::iterator association = geantToIndex_.find(motherGeantId);
422  if (association != geantToIndex_.end())
423  motherId = association->second;
424  // int motherType = motherId == -1 ? 0 :
425  // theSimTracks[motherId].type();
426 
427  if (theSimTracks[motherId].trackId() == (*iPhoTk)->trackId()) {
429  trkFromConversion.push_back(&(*iSimTk));
430  }
431  }
432  } // loop over the SimTracks
433 
434  if (!trkFromConversion.empty()) {
435  isAconversion = 1;
436  nConv++;
437  convInd[iPho] = nConv;
438  int convVtxId = trkFromConversion[0]->vertIndex();
439  SimVertex convVtx = theSimVertices[convVtxId];
440  const math::XYZTLorentzVectorD &vtxPosition = convVtx.position();
441  // math::XYZTLorentzVectorD momentum = (*iPhoTk)->momentum(); // UNUSED
442  if (nConv <= 10) {
443  if (trkFromConversion.size() > 1) {
444  // idTrk1_[iConv]= trkFromConversion[0]->trackId(); // UNUSED
445  // idTrk2_[iConv]= trkFromConversion[1]->trackId(); // UNUSED
446  } else {
447  // idTrk1_[iConv]=trkFromConversion[0]->trackId(); // UNUSED
448  // idTrk2_[iConv]=-1; // UNUSED
449  }
450  }
451  iConv++;
452 
453  result.push_back(EcalSimPhotonMCTruth(isAconversion,
454  (*iPhoTk)->momentum(),
455  vtxPosition.pt(),
456  vtxPosition.z(),
457  vtxPosition,
458  primVtx.position(),
459  trkFromConversion));
460  } else {
461  isAconversion = 0;
462  math::XYZTLorentzVectorD vtxPosition(0., 0., 0., 0.);
463  result.push_back(EcalSimPhotonMCTruth(isAconversion,
464  (*iPhoTk)->momentum(),
465  vtxPosition.pt(),
466  vtxPosition.z(),
467  vtxPosition,
468  primVtx.position(),
469  trkFromConversion));
470  }
471  iPho++;
472  } // loop over the primary photons
473  } // Event with one or two photons
474 
475  return result;
476 }
ROOT::Math::LorentzVector< ROOT::Math::PxPyPzE4D< double > > XYZTLorentzVectorD
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:14
std::map< unsigned, unsigned > geantToIndex_
const math::XYZTLorentzVectorD & position() const
Definition: CoreSimVertex.h:21
std::tuple< layerClusterToCaloParticle, caloParticleToLayerCluster > association
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
void fillMcTruth(std::vector< SimTrack > &theSimTracks, std::vector< SimVertex > &theSimVertices)

Member Data Documentation

◆ BarrelSuperClusterCollection_

edm::EDGetTokenT<reco::SuperClusterCollection> ContainmentCorrectionAnalyzer::BarrelSuperClusterCollection_
private

Definition at line 65 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and ContainmentCorrectionAnalyzer().

◆ e1

std::vector<float> ContainmentCorrectionAnalyzer::e1
private

Definition at line 77 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ e25

std::vector<float> ContainmentCorrectionAnalyzer::e25
private

Definition at line 77 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ e9

std::vector<float> ContainmentCorrectionAnalyzer::e9
private

Definition at line 77 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ EndcapSuperClusterCollection_

edm::EDGetTokenT<reco::SuperClusterCollection> ContainmentCorrectionAnalyzer::EndcapSuperClusterCollection_
private

Definition at line 66 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and ContainmentCorrectionAnalyzer().

◆ geantToIndex_

std::map<unsigned, unsigned> ContainmentCorrectionAnalyzer::geantToIndex_
private

Definition at line 81 of file ContainmentCorrectionAnalyzer.h.

Referenced by fillMcTruth(), and findMcTruth().

◆ h_EB_converted

TH1F* ContainmentCorrectionAnalyzer::h_EB_converted
private

Definition at line 91 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and beginJob().

◆ h_EB_e25EtrueReference

TH1F* ContainmentCorrectionAnalyzer::h_EB_e25EtrueReference
private

Definition at line 85 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and beginJob().

◆ h_EB_e9EtrueReference

TH1F* ContainmentCorrectionAnalyzer::h_EB_e9EtrueReference
private

Definition at line 84 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and beginJob().

◆ h_EB_eRecoEtrueReference

TH1F* ContainmentCorrectionAnalyzer::h_EB_eRecoEtrueReference
private

Definition at line 83 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and beginJob().

◆ h_EB_eTrue

TH1F* ContainmentCorrectionAnalyzer::h_EB_eTrue
private

Definition at line 89 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and beginJob().

◆ h_EE_converted

TH1F* ContainmentCorrectionAnalyzer::h_EE_converted
private

Definition at line 92 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and beginJob().

◆ h_EE_e25EtrueReference

TH1F* ContainmentCorrectionAnalyzer::h_EE_e25EtrueReference
private

Definition at line 88 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and beginJob().

◆ h_EE_e9EtrueReference

TH1F* ContainmentCorrectionAnalyzer::h_EE_e9EtrueReference
private

Definition at line 87 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and beginJob().

◆ h_EE_eRecoEtrueReference

TH1F* ContainmentCorrectionAnalyzer::h_EE_eRecoEtrueReference
private

Definition at line 86 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and beginJob().

◆ h_EE_eTrue

TH1F* ContainmentCorrectionAnalyzer::h_EE_eTrue
private

Definition at line 90 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and beginJob().

◆ iMC

std::vector<int> ContainmentCorrectionAnalyzer::iMC
private

Definition at line 79 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ isConverted

std::vector<int> ContainmentCorrectionAnalyzer::isConverted
private

Definition at line 73 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ mcEnergy

std::vector<float> ContainmentCorrectionAnalyzer::mcEnergy
private

Definition at line 72 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ mcEta

std::vector<float> ContainmentCorrectionAnalyzer::mcEta
private

Definition at line 72 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ mcPhi

std::vector<float> ContainmentCorrectionAnalyzer::mcPhi
private

Definition at line 72 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ mcPt

std::vector<float> ContainmentCorrectionAnalyzer::mcPt
private

Definition at line 72 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ nMCphotons

int ContainmentCorrectionAnalyzer::nMCphotons
private

Definition at line 71 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ nRECOphotons

int ContainmentCorrectionAnalyzer::nRECOphotons
private

Definition at line 75 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ pTopologyToken

edm::ESGetToken<CaloTopology, CaloTopologyRecord> ContainmentCorrectionAnalyzer::pTopologyToken
private

Definition at line 69 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ reducedBarrelRecHitCollection_

edm::EDGetTokenT<EcalRecHitCollection> ContainmentCorrectionAnalyzer::reducedBarrelRecHitCollection_
private

Definition at line 67 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and ContainmentCorrectionAnalyzer().

◆ reducedEndcapRecHitCollection_

edm::EDGetTokenT<EcalRecHitCollection> ContainmentCorrectionAnalyzer::reducedEndcapRecHitCollection_
private

Definition at line 68 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and ContainmentCorrectionAnalyzer().

◆ seedXtal

std::vector<int> ContainmentCorrectionAnalyzer::seedXtal
private

Definition at line 78 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ SimTrackCollection_

edm::EDGetTokenT<edm::SimTrackContainer> ContainmentCorrectionAnalyzer::SimTrackCollection_
private

Definition at line 63 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and ContainmentCorrectionAnalyzer().

◆ SimVertexCollection_

edm::EDGetTokenT<edm::SimVertexContainer> ContainmentCorrectionAnalyzer::SimVertexCollection_
private

Definition at line 64 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze(), and ContainmentCorrectionAnalyzer().

◆ superClusterEnergy

std::vector<float> ContainmentCorrectionAnalyzer::superClusterEnergy
private

Definition at line 76 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ superClusterEt

std::vector<float> ContainmentCorrectionAnalyzer::superClusterEt
private

Definition at line 76 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ superClusterEta

std::vector<float> ContainmentCorrectionAnalyzer::superClusterEta
private

Definition at line 76 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ superClusterPhi

std::vector<float> ContainmentCorrectionAnalyzer::superClusterPhi
private

Definition at line 76 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ x_vtx

std::vector<float> ContainmentCorrectionAnalyzer::x_vtx
private

Definition at line 74 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ y_vtx

std::vector<float> ContainmentCorrectionAnalyzer::y_vtx
private

Definition at line 74 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().

◆ z_vtx

std::vector<float> ContainmentCorrectionAnalyzer::z_vtx
private

Definition at line 74 of file ContainmentCorrectionAnalyzer.h.

Referenced by analyze().