CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
 ContainmentCorrectionAnalyzer (const edm::ParameterSet &)
 
virtual void endJob ()
 
 ~ContainmentCorrectionAnalyzer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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::SuperClusterCollection
BarrelSuperClusterCollection_
 
std::vector< float > e1
 
std::vector< float > e25
 
std::vector< float > e9
 
edm::EDGetTokenT
< reco::SuperClusterCollection
EndcapSuperClusterCollection_
 
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
< EcalRecHitCollection
reducedBarrelRecHitCollection_
 
edm::EDGetTokenT
< EcalRecHitCollection
reducedEndcapRecHitCollection_
 
std::vector< int > seedXtal
 
edm::EDGetTokenT
< edm::SimTrackContainer
SimTrackCollection_
 
edm::EDGetTokenT
< edm::SimVertexContainer
SimVertexCollection_
 
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 &)
 
- 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 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  {
12 
13  BarrelSuperClusterCollection_ = consumes<reco::SuperClusterCollection>(ps.getParameter<InputTag>("BarrelSuperClusterCollection"));
14  EndcapSuperClusterCollection_ = consumes<reco::SuperClusterCollection>(ps.getParameter<InputTag>("EndcapSuperClusterCollection"));
15  reducedBarrelRecHitCollection_ = consumes<EcalRecHitCollection>(ps.getParameter<InputTag>("reducedBarrelRecHitCollection"));
16  reducedEndcapRecHitCollection_ = consumes<EcalRecHitCollection>(ps.getParameter<InputTag>("reducedEndcapRecHitCollection"));
17  SimTrackCollection_ = consumes<SimTrackContainer>(ps.getParameter<InputTag>("simTrackCollection"));
18  SimVertexCollection_ = consumes<SimVertexContainer>(ps.getParameter<InputTag>("simVertexCollection"));
19 }
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 ( )

Definition at line 21 of file ContainmentCorrectionAnalyzer.cc.

21 { }

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 40 of file ContainmentCorrectionAnalyzer.cc.

References deltaR(), alignCSCRings::e, reco::e1, eta, HcalObjRepresent::Fill(), edm::EventSetup::get(), edm::Event::getByToken(), i, edm::EventBase::id(), edm::ESHandleBase::isValid(), edm::HandleBase::isValid(), cmsLHEtoEOSManager::l, edm::ProductLabels::module, interactiveExample::photons, pi, reco::CaloCluster::position(), funct::pow(), reco::SuperCluster::preshowerEnergy(), edm::Handle< T >::product(), edm::ESHandle< class >::product(), reco::SuperCluster::rawEnergy(), reco::SuperCluster::seed(), mathSSE::sqrt(), and ecaldqm::topology().

40  {
41 
42  LogInfo("ContainmentCorrectionAnalyzer") << "Analyzing event " << evt.id() << "\n";
43 
44  // taking the needed collections
45  std::vector<SimTrack> theSimTracks;
48  Labels l;
50 
51  if (SimTk.isValid() ) theSimTracks.insert(theSimTracks.end(),SimTk->begin(),SimTk->end());
52  else { LogError("ContainmentCorrectionAnalyzer") << "Error! can't get collection with label " << l.module; }
53 
54  std::vector<SimVertex> theSimVertexes;
56  evt.getByToken(SimVertexCollection_,SimVtx);
58 
59 
60  if (SimVtx.isValid()) theSimVertexes.insert(theSimVertexes.end(),SimVtx->begin(),SimVtx->end());
61  else {LogError("ContainmentCorrectionAnalyzer") << "Error! can't get collection with label " << l.module; }
62 
63  const reco::SuperClusterCollection* BarrelSuperClusters = 0;
64  Handle<reco::SuperClusterCollection> pHybridBarrelSuperClusters;
65  evt.getByToken(BarrelSuperClusterCollection_, pHybridBarrelSuperClusters);
67 
68  if (pHybridBarrelSuperClusters.isValid()) { BarrelSuperClusters = pHybridBarrelSuperClusters.product(); }
69  else {LogError("ContainmentCorrectionAnalyzer") << "Error! can't get collection with label " << l.module; }
70 
71  const reco::SuperClusterCollection* EndcapSuperClusters = 0;
72  Handle<reco::SuperClusterCollection> pMulti5x5EndcapSuperClusters;
73  evt.getByToken(EndcapSuperClusterCollection_, pMulti5x5EndcapSuperClusters);
75 
76  if (pMulti5x5EndcapSuperClusters.isValid()) EndcapSuperClusters = pMulti5x5EndcapSuperClusters.product();
77  else {LogError("ContainmentCorrectionAnalyzer") << "Error! can't get collection with label " << l.module; }
78 
79  const EcalRecHitCollection *ebRecHits = 0;
81  evt.getByToken( reducedBarrelRecHitCollection_, pEBRecHits );
83 
84  if (pEBRecHits.isValid()) ebRecHits = pEBRecHits.product();
85  else {LogError("ContainmentCorrectionAnalyzer") << "Error! can't get collection with label " << l.module; }
86 
87  const EcalRecHitCollection *eeRecHits = 0;
89  evt.getByToken( reducedEndcapRecHitCollection_, pEERecHits );
91 
92  if (pEERecHits.isValid()) eeRecHits = pEERecHits.product();
93  else {LogError("ContainmentCorrectionAnalyzer") << "Error! can't get collection with label " << l.module; }
94 
95  const CaloTopology *topology = 0;
96  ESHandle<CaloTopology> pTopology;
97  es.get<CaloTopologyRecord>().get(pTopology);
98  if(pTopology.isValid()) topology = pTopology.product();
99 
100  std::vector<EcalSimPhotonMCTruth> photons=findMcTruth(theSimTracks,theSimVertexes);
101 
102  nMCphotons = 0;
103  nRECOphotons = 0;
104 
105  int mc_size = photons.size();
106  mcEnergy.resize(mc_size);
107  mcEta.resize(mc_size);
108  mcPhi.resize(mc_size);
109  mcPt.resize(mc_size);
110  isConverted.resize(mc_size);
111  x_vtx.resize(mc_size);
112  y_vtx.resize(mc_size);
113  z_vtx.resize(mc_size);
114 
115  superClusterEnergy.resize(mc_size);
116  superClusterEta.resize(mc_size);
117  superClusterPhi.resize(mc_size);
118  superClusterEt.resize(mc_size);
119  e1.resize(mc_size);
120  e9.resize(mc_size);
121  e25.resize(mc_size);
122  seedXtal.resize(mc_size);
123  iMC.resize(mc_size);
124 
125 
126  // loop over MC truth photons
127  for (unsigned int ipho=0;ipho<photons.size();ipho++) {
128 
129  math::XYZTLorentzVectorD vtx = photons[ipho].primaryVertex();
130  double phiTrue = photons[ipho].fourMomentum().phi();
131  double vtxPerp = sqrt(vtx.x()*vtx.x() + vtx.y()*vtx.y());
132  double etaTrue = ecalEta(photons[ipho].fourMomentum().eta(), vtx.z(), vtxPerp);
133  double etTrue = photons[ipho].fourMomentum().e()/cosh(etaTrue);
134  nMCphotons++;
135  mcEnergy[nMCphotons-1]=photons[ipho].fourMomentum().e();
136  mcEta[nMCphotons-1]=etaTrue;
137  mcPhi[nMCphotons-1]=phiTrue;
138  mcPt[nMCphotons-1]=etTrue;
139  isConverted[nMCphotons-1]=photons[ipho].isAConversion();
140  x_vtx[nMCphotons-1]=vtx.x();
141  y_vtx[nMCphotons-1]=vtx.y();
142  z_vtx[nMCphotons-1]=vtx.z();
143 
144  // check histos for MC truth
145  if(std::fabs(etaTrue) < 1.479) {
146  h_EB_eTrue ->Fill(photons[ipho].fourMomentum().e());
147  h_EB_converted ->Fill(photons[ipho].isAConversion());
148  }
149  if(std::fabs(etaTrue) >= 1.6) {
150  h_EE_eTrue ->Fill(photons[ipho].fourMomentum().e());
151  h_EE_converted ->Fill(photons[ipho].isAConversion());
152  }
153 
154  // barrel
155  if(std::fabs(etaTrue) < 1.479) {
156  double etaCurrent; // , etaFound = 0; // UNUSED
157  double phiCurrent;
158  // double etCurrent, etFound = 0; // UNUSED
159  const reco::SuperCluster* nearSC = 0;
160 
161  double closestParticleDistance = 999;
162  for(reco::SuperClusterCollection::const_iterator aClus = BarrelSuperClusters->begin();
163  aClus != BarrelSuperClusters->end(); aClus++) {
164  etaCurrent = aClus->position().eta();
165  phiCurrent = aClus->position().phi();
166  // etCurrent = aClus->energy()/std::cosh(etaCurrent); // UNUSED
167  double deltaR = std::sqrt(std::pow(etaCurrent-etaTrue,2)+std::pow(phiCurrent-phiTrue,2));
168  if(deltaR < closestParticleDistance) {
169  // etFound = etCurrent; // UNUSED
170  // etaFound = etaCurrent; // UNUSED
171  closestParticleDistance = deltaR;
172  nearSC=&(*aClus);
173  }
174  }
175 
176  if(closestParticleDistance < 0.3) {
177  // Is a matched particle dumping informations
178  nRECOphotons++;
180  superClusterEta[nRECOphotons-1]=nearSC->position().eta();
181  superClusterPhi[nRECOphotons-1]=nearSC->position().phi();
182  superClusterEt[nRECOphotons-1]=nearSC->rawEnergy()/std::cosh(nearSC->position().eta());
184 
185  reco::CaloClusterPtr theSeed = nearSC->seed();
186  seedXtal[nRECOphotons-1] = EcalClusterTools::getMaximum(*theSeed, ebRecHits).first;
187  e1[nRECOphotons-1] = EcalClusterTools::eMax(*theSeed, ebRecHits);
188  e9[nRECOphotons-1] = EcalClusterTools::e3x3(*theSeed, ebRecHits, topology );
189  e25[nRECOphotons-1] = EcalClusterTools::e5x5(*theSeed, ebRecHits, topology );
190  }
191  }
192 
193  // endcap
194  if(std::fabs(etaTrue) >= 1.6) {
195  double etaCurrent; // , etaFound = 0; // UNUSED
196  double phiCurrent;
197  // double etCurrent, etFound = 0; // UNUSED
198  const reco::SuperCluster* nearSC = 0;
199 
200  double closestParticleDistance = 999;
201  for(reco::SuperClusterCollection::const_iterator aClus = EndcapSuperClusters->begin();
202  aClus != EndcapSuperClusters->end(); aClus++) {
203  etaCurrent = aClus->position().eta();
204  phiCurrent = aClus->position().phi();
205  // etCurrent = aClus->energy()/std::cosh(etaCurrent);
206  double deltaR = std::sqrt(std::pow(etaCurrent-etaTrue,2)+std::pow(phiCurrent-phiTrue,2));
207  if(deltaR < closestParticleDistance) {
208  // etFound = etCurrent; // UNUSED
209  // etaFound = etaCurrent; // UNUSED
210  closestParticleDistance = deltaR;
211  nearSC=&(*aClus);
212  }
213  }
214 
215  if(closestParticleDistance < 0.3) {
216  //Is a matched particle dumping informations
217  nRECOphotons++;
218  float psEnergy = nearSC->preshowerEnergy();
219  superClusterEnergy[nRECOphotons-1]=nearSC->rawEnergy() + psEnergy;
220  superClusterEta[nRECOphotons-1]=nearSC->position().eta();
221  superClusterPhi[nRECOphotons-1]=nearSC->position().phi();
222  superClusterEt[nRECOphotons-1]=(nearSC->rawEnergy() + psEnergy)/std::cosh(nearSC->position().eta());
224 
225  reco::CaloClusterPtr theSeed = nearSC->seed();
226  seedXtal[nRECOphotons-1] = EcalClusterTools::getMaximum(*theSeed, eeRecHits).first;
227  e1[nRECOphotons-1] = EcalClusterTools::eMax(*theSeed, eeRecHits) + psEnergy;
228  e9[nRECOphotons-1] = EcalClusterTools::e3x3(*theSeed, eeRecHits, topology ) + psEnergy;
229  e25[nRECOphotons-1] = EcalClusterTools::e5x5(*theSeed, eeRecHits, topology ) + psEnergy;
230  }
231  }
232  }
233 
234 
235  // containment analysis for unconverted photons in the reference region only
236  for (int i=0;i<nRECOphotons;i++) {
237 
238  // barrel
239  if (fabs(superClusterEta[i]) < 1.479 ) {
240  if (isConverted[iMC[i]] != 1){
241  int ietaAbs = (seedXtal[i]>>9)&0x7F;
242  int iphi = seedXtal[i]&0x1FF;
243  if (ietaAbs > 5 && ietaAbs < 21 && ((iphi % 20) > 5) && ((iphi % 20) < 16) ) {
247  }
248  }
249  }
250 
251  // endcap
252  if (fabs(superClusterEta[i]) > 1.6 ) {
253  if (isConverted[iMC[i]] != 1) {
254  if ( fabs(superClusterEta[i]) > 1.7 && fabs(superClusterEta[i] < 2.3) &&
255  ((superClusterPhi[i] > -CLHEP::pi/2. + 0.1 && superClusterPhi[i] < CLHEP::pi/2. - 0.1) ||
256  (superClusterPhi[i] > CLHEP::pi/2. + 0.1) ||
257  (superClusterPhi[i] < -CLHEP::pi/2. - 0.1)
258  ))
259  {
263  }
264  }
265  }
266 
267  } // loop over reco photons
268 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:126
int i
Definition: DBlmapReader.cc:9
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:462
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
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
T sqrt(T t)
Definition: SSEVec.h:18
edm::EDGetTokenT< edm::SimVertexContainer > SimVertexCollection_
bool isValid() const
Definition: HandleBase.h:75
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
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:81
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
edm::EventID id() const
Definition: EventBase.h:59
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:47
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void ContainmentCorrectionAnalyzer::beginJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 23 of file ContainmentCorrectionAnalyzer.cc.

References TFileService::make().

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

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

272  {
273 
274  const float R_ECAL = 136.5;
275  const float Z_Endcap = 328.0;
276  const float etaBarrelEndcap = 1.479;
277 
278  if(EtaParticle != 0.) {
279  float Theta = 0.0 ;
280  float ZEcal = (R_ECAL-plane_Radius)*sinh(EtaParticle)+Zvertex;
281 
282  if(ZEcal != 0.0) Theta = atan(R_ECAL/ZEcal);
283  if(Theta<0.0) Theta = Theta+Geom::pi() ;
284 
285  float ETA = - log(tan(0.5*Theta));
286 
287  if( fabs(ETA) > etaBarrelEndcap ) {
288  float Zend = Z_Endcap ;
289  if(EtaParticle<0.0 ) Zend = -Zend ;
290  float Zlen = Zend - Zvertex ;
291  float RR = Zlen/sinh(EtaParticle);
292  Theta = atan((RR+plane_Radius)/Zend);
293  if(Theta<0.0) Theta = Theta+Geom::pi() ;
294  ETA = - log(tan(0.5*Theta));
295  }
296 
297  return ETA;
298  }
299  else {
300  LogWarning("") << "[ContainmentCorrectionAnalyzer::ecalEta] Warning: Eta equals to zero, not correcting" ;
301  return EtaParticle;
302  }
303 }
#define ETA
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
static const float etaBarrelEndcap
static const float Z_Endcap
double pi()
Definition: Pi.h:31
static const float R_ECAL
void ContainmentCorrectionAnalyzer::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 270 of file ContainmentCorrectionAnalyzer.cc.

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

Definition at line 438 of file ContainmentCorrectionAnalyzer.cc.

438  {
439 
440  unsigned nVtx = simVertices.size();
441  unsigned nTks = simTracks.size();
442  if ( nVtx == 0 ) return;
443  // create a map associating geant particle id and position in the event SimTrack vector
444  for( unsigned it=0; it<nTks; ++it ) {
445  geantToIndex_[ simTracks[it].trackId() ] = it;
446  }
447 }
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 306 of file ContainmentCorrectionAnalyzer.cc.

References funct::abs(), reco::if(), SimVertex::parentIndex(), CoreSimVertex::position(), and query::result.

306  {
307 
308  std::vector<EcalSimPhotonMCTruth> result;
309 
310  geantToIndex_.clear();
311  // int idTrk1_[10]; // UNUSED
312  // int idTrk2_[10]; // UNUSED
313 
314  // Local variables
315  // const int SINGLE=1; // UNUSED
316  // const int DOUBLE=2; // UNUSED
317  // const int PYTHIA=3; // UNUSED
318  const int ELECTRON_FLAV=1;
319  const int PIZERO_FLAV=2;
320  const int PHOTON_FLAV=3;
321 
322  // int ievtype=0; // UNUSED
323  int ievflav=0;
324  std::vector<SimTrack*> photonTracks;
325  std::vector<SimTrack*> pizeroTracks;
326  std::vector<const SimTrack *> trkFromConversion;
327  SimVertex primVtx;
328  std::vector<int> convInd;
329 
330  fillMcTruth(theSimTracks, theSimVertices);
331  int iPV=-1;
332  int partType1=0;
333  int partType2=0;
334  std::vector<SimTrack>::iterator iFirstSimTk = theSimTracks.begin();
335  if ( !(*iFirstSimTk).noVertex() ) {
336  iPV = (*iFirstSimTk).vertIndex();
337  int vtxId = (*iFirstSimTk).vertIndex();
338  primVtx = theSimVertices[vtxId];
339  partType1 = (*iFirstSimTk).type();
340  }
341 
342  // Look at a second track
343  iFirstSimTk++;
344  if ( iFirstSimTk!= theSimTracks.end() ) {
345  if ( (*iFirstSimTk).vertIndex() == iPV) {
346  partType2 = (*iFirstSimTk).type();
347  }
348  }
349  int npv=0;
350  int iPho=0;
351  for (std::vector<SimTrack>::iterator iSimTk = theSimTracks.begin(); iSimTk != theSimTracks.end(); ++iSimTk){
352  if ( (*iSimTk).noVertex() ) continue;
353  // int vertexId = (*iSimTk).vertIndex(); // UNUSED
354  // SimVertex vertex = theSimVertices[vertexId]; // UNUSED
355  if ( (*iSimTk).vertIndex() == iPV ) {
356  npv++;
357  if ( (*iSimTk).type() == 22) {
358  convInd.push_back(0);
359  photonTracks.push_back( &(*iSimTk) );
360  // math::XYZTLorentzVectorD momentum = (*iSimTk).momentum(); // UNUSED
361  }
362  }
363  }
364 
365  if(npv > 4) { // ievtype = PYTHIA; // UNUSED
366  } else if(npv == 1) {
367  if( abs(partType1) == 11 ) { /* ievtype = SINGLE; ==UNUSED== */ ievflav = ELECTRON_FLAV; }
368  else if(partType1 == 111) { /* ievtype = SINGLE; ==UNUSED== */ ievflav = PIZERO_FLAV; }
369  else if(partType1 == 22) { /* ievtype = SINGLE; ==UNUSED== */ ievflav = PHOTON_FLAV; }
370  } else if(npv == 2) {
371  if ( abs(partType1) == 11 && abs(partType2) == 11 ) { /* ievtype = DOUBLE; ==UNUSED== */ ievflav = ELECTRON_FLAV; }
372  else if(partType1 == 111 && partType2 == 111) { /* ievtype = DOUBLE; ==UNUSED== */ ievflav = PIZERO_FLAV; }
373  else if(partType1 == 22 && partType2 == 22) { /* ievtype = DOUBLE; ==UNUSED== */ ievflav = PHOTON_FLAV; }
374  }
375 
376  // Look into converted photons
377  int isAconversion=0;
378  if(ievflav == PHOTON_FLAV) {
379 
380  int nConv=0;
381  int iConv=0;
382  iPho=0;
383  for (std::vector<SimTrack*>::iterator iPhoTk = photonTracks.begin(); iPhoTk != photonTracks.end(); ++iPhoTk){
384  trkFromConversion.clear();
385  for (std::vector<SimTrack>::iterator iSimTk = theSimTracks.begin(); iSimTk != theSimTracks.end(); ++iSimTk){
386  if ( (*iSimTk).noVertex() ) continue;
387  if ( (*iSimTk).vertIndex() == iPV ) continue;
388  if ( abs((*iSimTk).type()) != 11 ) continue;
389  int vertexId = (*iSimTk).vertIndex();
390  SimVertex vertex = theSimVertices[vertexId];
391  int motherId=-1;
392  if ( vertex.parentIndex() ) {
393  unsigned motherGeantId = vertex.parentIndex();
394  std::map<unsigned, unsigned >::iterator association = geantToIndex_.find( motherGeantId );
395  if(association != geantToIndex_.end() )
396  motherId = association->second;
397  //int motherType = motherId == -1 ? 0 : theSimTracks[motherId].type();
398 
399  if ( theSimTracks[motherId].trackId() == (*iPhoTk)->trackId() ) {
401  trkFromConversion.push_back(&(*iSimTk ) );
402  }
403  }
404  } // loop over the SimTracks
405 
406  if ( trkFromConversion.size() > 0 ) {
407  isAconversion=1;
408  nConv++;
409  convInd[iPho]=nConv;
410  int convVtxId = trkFromConversion[0]->vertIndex();
411  SimVertex convVtx = theSimVertices[convVtxId];
412  math::XYZTLorentzVectorD vtxPosition = convVtx.position();
413  // math::XYZTLorentzVectorD momentum = (*iPhoTk)->momentum(); // UNUSED
414  if ( nConv <= 10) {
415  if ( trkFromConversion.size() > 1) {
416  // idTrk1_[iConv]= trkFromConversion[0]->trackId(); // UNUSED
417  // idTrk2_[iConv]= trkFromConversion[1]->trackId(); // UNUSED
418  } else {
419  // idTrk1_[iConv]=trkFromConversion[0]->trackId(); // UNUSED
420  // idTrk2_[iConv]=-1; // UNUSED
421  }
422  }
423  iConv++;
424 
425  result.push_back( EcalSimPhotonMCTruth(isAconversion, (*iPhoTk)->momentum(), vtxPosition.pt(), vtxPosition.z() , vtxPosition, primVtx.position(), trkFromConversion ));
426  } else {
427  isAconversion=0;
428  math::XYZTLorentzVectorD vtxPosition(0.,0.,0.,0.);
429  result.push_back( EcalSimPhotonMCTruth(isAconversion, (*iPhoTk)->momentum(), vtxPosition.pt(), vtxPosition.z() , vtxPosition, primVtx.position(), trkFromConversion ));
430  }
431  iPho++;
432  } // loop over the primary photons
433  } // Event with one or two photons
434 
435  return result;
436 }
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:33
tuple result
Definition: query.py:137
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const math::XYZTLorentzVectorD & position() const
Definition: CoreSimVertex.h:26
if(dp >Float(M_PI)) dp-
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.