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::EDAnalyzer 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::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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
 
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::vector< ModuleDescription const * > &modules, 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
 
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::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::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<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)
 

Detailed Description

Definition at line 48 of file ContainmentCorrectionAnalyzer.h.

Constructor & Destructor Documentation

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

Definition at line 11 of file ContainmentCorrectionAnalyzer.cc.

References edm::ParameterSet::getParameter().

11  {
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
edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollection_
edm::EDGetTokenT< edm::SimTrackContainer > SimTrackCollection_
edm::EDGetTokenT< reco::SuperClusterCollection > BarrelSuperClusterCollection_
edm::EDGetTokenT< edm::SimVertexContainer > SimVertexCollection_
edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollection_
edm::EDGetTokenT< reco::SuperClusterCollection > EndcapSuperClusterCollection_
ContainmentCorrectionAnalyzer::~ContainmentCorrectionAnalyzer ( )
override

Definition at line 24 of file ContainmentCorrectionAnalyzer.cc.

24 {}

Member Function Documentation

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

Definition at line 42 of file ContainmentCorrectionAnalyzer.cc.

References boostedElectronIsolation_cff::deltaR, MillePedeFileConverter_cfg::e, egammaTools::ecalEta(), photonPostprocessing_cfi::eMax, PVValHelper::eta, edm::EventSetup::get(), edm::Event::getByToken(), mps_fire::i, edm::EventBase::id(), edm::ESHandleBase::isValid(), edm::HandleBase::isValid(), checklumidiff::l, edm::ProductLabels::module, muons_cff::photons, pi, reco::CaloCluster::position(), funct::pow(), reco::SuperCluster::preshowerEnergy(), edm::Handle< T >::product(), edm::ESHandle< T >::product(), reco::SuperCluster::rawEnergy(), reco::SuperCluster::seed(), mathSSE::sqrt(), ecaldqm::topology(), and extraflags_cff::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  ESHandle<CaloTopology> pTopology;
115  es.get<CaloTopologyRecord>().get(pTopology);
116  if (pTopology.isValid())
117  topology = pTopology.product();
118 
119  std::vector<EcalSimPhotonMCTruth> photons = findMcTruth(theSimTracks, theSimVertexes);
120 
121  nMCphotons = 0;
122  nRECOphotons = 0;
123 
124  int mc_size = photons.size();
125  mcEnergy.resize(mc_size);
126  mcEta.resize(mc_size);
127  mcPhi.resize(mc_size);
128  mcPt.resize(mc_size);
129  isConverted.resize(mc_size);
130  x_vtx.resize(mc_size);
131  y_vtx.resize(mc_size);
132  z_vtx.resize(mc_size);
133 
134  superClusterEnergy.resize(mc_size);
135  superClusterEta.resize(mc_size);
136  superClusterPhi.resize(mc_size);
137  superClusterEt.resize(mc_size);
138  e1.resize(mc_size);
139  e9.resize(mc_size);
140  e25.resize(mc_size);
141  seedXtal.resize(mc_size);
142  iMC.resize(mc_size);
143 
144  // loop over MC truth photons
145  for (unsigned int ipho = 0; ipho < photons.size(); ipho++) {
146  math::XYZTLorentzVectorD vtx = photons[ipho].primaryVertex();
147  double phiTrue = photons[ipho].fourMomentum().phi();
148  double vtxPerp = sqrt(vtx.x() * vtx.x() + vtx.y() * vtx.y());
149  double etaTrue = ecalEta(photons[ipho].fourMomentum().eta(), vtx.z(), vtxPerp);
150  double etTrue = photons[ipho].fourMomentum().e() / cosh(etaTrue);
151  nMCphotons++;
152  mcEnergy[nMCphotons - 1] = photons[ipho].fourMomentum().e();
153  mcEta[nMCphotons - 1] = etaTrue;
154  mcPhi[nMCphotons - 1] = phiTrue;
155  mcPt[nMCphotons - 1] = etTrue;
156  isConverted[nMCphotons - 1] = photons[ipho].isAConversion();
157  x_vtx[nMCphotons - 1] = vtx.x();
158  y_vtx[nMCphotons - 1] = vtx.y();
159  z_vtx[nMCphotons - 1] = vtx.z();
160 
161  // check histos for MC truth
162  if (std::fabs(etaTrue) < 1.479) {
163  h_EB_eTrue->Fill(photons[ipho].fourMomentum().e());
164  h_EB_converted->Fill(photons[ipho].isAConversion());
165  }
166  if (std::fabs(etaTrue) >= 1.6) {
167  h_EE_eTrue->Fill(photons[ipho].fourMomentum().e());
168  h_EE_converted->Fill(photons[ipho].isAConversion());
169  }
170 
171  // barrel
172  if (std::fabs(etaTrue) < 1.479) {
173  double etaCurrent; // , etaFound = 0; // UNUSED
174  double phiCurrent;
175  // double etCurrent, etFound = 0; // UNUSED
176  const reco::SuperCluster *nearSC = nullptr;
177 
178  double closestParticleDistance = 999;
179  for (reco::SuperClusterCollection::const_iterator aClus = BarrelSuperClusters->begin();
180  aClus != BarrelSuperClusters->end();
181  aClus++) {
182  etaCurrent = aClus->position().eta();
183  phiCurrent = aClus->position().phi();
184  // etCurrent = aClus->energy()/std::cosh(etaCurrent); // UNUSED
185  double deltaR = std::sqrt(std::pow(etaCurrent - etaTrue, 2) + std::pow(phiCurrent - phiTrue, 2));
186  if (deltaR < closestParticleDistance) {
187  // etFound = etCurrent; // UNUSED
188  // etaFound = etaCurrent; // UNUSED
189  closestParticleDistance = deltaR;
190  nearSC = &(*aClus);
191  }
192  }
193 
194  if (closestParticleDistance < 0.3) {
195  // Is a matched particle dumping informations
196  nRECOphotons++;
197  superClusterEnergy[nRECOphotons - 1] = nearSC->rawEnergy();
198  superClusterEta[nRECOphotons - 1] = nearSC->position().eta();
199  superClusterPhi[nRECOphotons - 1] = nearSC->position().phi();
200  superClusterEt[nRECOphotons - 1] = nearSC->rawEnergy() / std::cosh(nearSC->position().eta());
201  iMC[nRECOphotons - 1] = nMCphotons - 1;
202 
203  const reco::CaloClusterPtr &theSeed = nearSC->seed();
204  seedXtal[nRECOphotons - 1] = EcalClusterTools::getMaximum(*theSeed, ebRecHits).first;
205  e1[nRECOphotons - 1] = EcalClusterTools::eMax(*theSeed, ebRecHits);
206  e9[nRECOphotons - 1] = EcalClusterTools::e3x3(*theSeed, ebRecHits, topology);
207  e25[nRECOphotons - 1] = EcalClusterTools::e5x5(*theSeed, ebRecHits, topology);
208  }
209  }
210 
211  // endcap
212  if (std::fabs(etaTrue) >= 1.6) {
213  double etaCurrent; // , etaFound = 0; // UNUSED
214  double phiCurrent;
215  // double etCurrent, etFound = 0; // UNUSED
216  const reco::SuperCluster *nearSC = nullptr;
217 
218  double closestParticleDistance = 999;
219  for (reco::SuperClusterCollection::const_iterator aClus = EndcapSuperClusters->begin();
220  aClus != EndcapSuperClusters->end();
221  aClus++) {
222  etaCurrent = aClus->position().eta();
223  phiCurrent = aClus->position().phi();
224  // etCurrent = aClus->energy()/std::cosh(etaCurrent);
225  double deltaR = std::sqrt(std::pow(etaCurrent - etaTrue, 2) + std::pow(phiCurrent - phiTrue, 2));
226  if (deltaR < closestParticleDistance) {
227  // etFound = etCurrent; // UNUSED
228  // etaFound = etaCurrent; // UNUSED
229  closestParticleDistance = deltaR;
230  nearSC = &(*aClus);
231  }
232  }
233 
234  if (closestParticleDistance < 0.3) {
235  // Is a matched particle dumping informations
236  nRECOphotons++;
237  float psEnergy = nearSC->preshowerEnergy();
238  superClusterEnergy[nRECOphotons - 1] = nearSC->rawEnergy() + psEnergy;
239  superClusterEta[nRECOphotons - 1] = nearSC->position().eta();
240  superClusterPhi[nRECOphotons - 1] = nearSC->position().phi();
241  superClusterEt[nRECOphotons - 1] = (nearSC->rawEnergy() + psEnergy) / std::cosh(nearSC->position().eta());
242  iMC[nRECOphotons - 1] = nMCphotons - 1;
243 
244  const reco::CaloClusterPtr &theSeed = nearSC->seed();
245  seedXtal[nRECOphotons - 1] = EcalClusterTools::getMaximum(*theSeed, eeRecHits).first;
246  e1[nRECOphotons - 1] = EcalClusterTools::eMax(*theSeed, eeRecHits) + psEnergy;
247  e9[nRECOphotons - 1] = EcalClusterTools::e3x3(*theSeed, eeRecHits, topology) + psEnergy;
248  e25[nRECOphotons - 1] = EcalClusterTools::e5x5(*theSeed, eeRecHits, topology) + psEnergy;
249  }
250  }
251  }
252 
253  // containment analysis for unconverted photons in the reference region only
254  for (int i = 0; i < nRECOphotons; i++) {
255  // barrel
256  if (fabs(superClusterEta[i]) < 1.479) {
257  if (isConverted[iMC[i]] != 1) {
258  int ietaAbs = (seedXtal[i] >> 9) & 0x7F;
259  int iphi = seedXtal[i] & 0x1FF;
260  if (ietaAbs > 5 && ietaAbs < 21 && ((iphi % 20) > 5) && ((iphi % 20) < 16)) {
262  h_EB_e9EtrueReference->Fill(e9[i] / mcEnergy[iMC[i]]);
263  h_EB_e25EtrueReference->Fill(e25[i] / mcEnergy[iMC[i]]);
264  }
265  }
266  }
267 
268  // endcap
269  if (fabs(superClusterEta[i]) > 1.6) {
270  if (isConverted[iMC[i]] != 1) {
271  if (fabs(superClusterEta[i]) > 1.7 && fabs(superClusterEta[i] < 2.3) &&
272  ((superClusterPhi[i] > -CLHEP::pi / 2. + 0.1 && superClusterPhi[i] < CLHEP::pi / 2. - 0.1) ||
273  (superClusterPhi[i] > CLHEP::pi / 2. + 0.1) || (superClusterPhi[i] < -CLHEP::pi / 2. - 0.1))) {
275  h_EE_e9EtrueReference->Fill(e9[i] / mcEnergy[iMC[i]]);
276  h_EE_e25EtrueReference->Fill(e25[i] / mcEnergy[iMC[i]]);
277  }
278  }
279  }
280 
281  } // loop over reco photons
282 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:131
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
CaloTopology const * topology(0)
edm::EDGetTokenT< EcalRecHitCollection > reducedEndcapRecHitCollection_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< edm::SimTrackContainer > SimTrackCollection_
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:18
edm::EDGetTokenT< edm::SimVertexContainer > SimVertexCollection_
bool isValid() const
Definition: HandleBase.h:74
ProductLabels Labels
double rawEnergy() const
raw uncorrected energy (sum of energies of component BasicClusters)
Definition: SuperCluster.h:47
edm::EDGetTokenT< EcalRecHitCollection > reducedBarrelRecHitCollection_
T const * product() const
Definition: Handle.h:74
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
edm::EventID id() const
Definition: EventBase.h:59
T get() const
Definition: EventSetup.h:71
edm::EDGetTokenT< reco::SuperClusterCollection > EndcapSuperClusterCollection_
const CaloClusterPtr & seed() const
seed BasicCluster
Definition: SuperCluster.h:66
double preshowerEnergy() const
energy deposited in preshower
Definition: SuperCluster.h:50
bool isValid() const
Definition: ESHandle.h:44
T const * product() const
Definition: ESHandle.h:86
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void ContainmentCorrectionAnalyzer::beginJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 26 of file ContainmentCorrectionAnalyzer.cc.

References TFileService::make().

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 }
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
float ContainmentCorrectionAnalyzer::ecalEta ( float  EtaParticle,
float  Zvertex,
float  plane_Radius 
)
private

Definition at line 286 of file ContainmentCorrectionAnalyzer.cc.

References ETA, etaBarrelEndcap, cmsBatch::log, Geom::pi(), R_ECAL, funct::tan(), and Z_Endcap.

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

Reimplemented from edm::EDAnalyzer.

Definition at line 284 of file ContainmentCorrectionAnalyzer.cc.

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

Definition at line 479 of file ContainmentCorrectionAnalyzer.cc.

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

References funct::abs(), TrackValidation_cff::association, objects.autophobj::motherId, SimVertex::parentIndex(), CoreSimVertex::position(), and mps_fire::result.

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

Member Data Documentation

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

Definition at line 65 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 76 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 76 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 76 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 66 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 80 of file ContainmentCorrectionAnalyzer.h.

TH1F* ContainmentCorrectionAnalyzer::h_EB_converted
private

Definition at line 90 of file ContainmentCorrectionAnalyzer.h.

TH1F* ContainmentCorrectionAnalyzer::h_EB_e25EtrueReference
private

Definition at line 84 of file ContainmentCorrectionAnalyzer.h.

TH1F* ContainmentCorrectionAnalyzer::h_EB_e9EtrueReference
private

Definition at line 83 of file ContainmentCorrectionAnalyzer.h.

TH1F* ContainmentCorrectionAnalyzer::h_EB_eRecoEtrueReference
private

Definition at line 82 of file ContainmentCorrectionAnalyzer.h.

TH1F* ContainmentCorrectionAnalyzer::h_EB_eTrue
private

Definition at line 88 of file ContainmentCorrectionAnalyzer.h.

TH1F* ContainmentCorrectionAnalyzer::h_EE_converted
private

Definition at line 91 of file ContainmentCorrectionAnalyzer.h.

TH1F* ContainmentCorrectionAnalyzer::h_EE_e25EtrueReference
private

Definition at line 87 of file ContainmentCorrectionAnalyzer.h.

TH1F* ContainmentCorrectionAnalyzer::h_EE_e9EtrueReference
private

Definition at line 86 of file ContainmentCorrectionAnalyzer.h.

TH1F* ContainmentCorrectionAnalyzer::h_EE_eRecoEtrueReference
private

Definition at line 85 of file ContainmentCorrectionAnalyzer.h.

TH1F* ContainmentCorrectionAnalyzer::h_EE_eTrue
private

Definition at line 89 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 78 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 72 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 71 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 71 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 71 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 71 of file ContainmentCorrectionAnalyzer.h.

int ContainmentCorrectionAnalyzer::nMCphotons
private

Definition at line 70 of file ContainmentCorrectionAnalyzer.h.

int ContainmentCorrectionAnalyzer::nRECOphotons
private

Definition at line 74 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 67 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 68 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 77 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 63 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 64 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 75 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 75 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 75 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 75 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 73 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 73 of file ContainmentCorrectionAnalyzer.h.

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

Definition at line 73 of file ContainmentCorrectionAnalyzer.h.