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 Attributes | Static Private Attributes
ElectronStudy Class Reference

#include <ElectronStudy.h>

Inheritance diagram for ElectronStudy:
edm::EDAnalyzer

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 
 ElectronStudy (const edm::ParameterSet &ps)
 
 ~ElectronStudy ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

double etaBins [NEtaBins+1]
 
std::string g4Label
 
TH1F * histoE1x1 [NPBins+1][NEtaBins+1]
 
TH1F * histoE3x3 [NPBins+1][NEtaBins+1]
 
TH1F * histoE5x5 [NPBins+1][NEtaBins+1]
 
TH1F * histoR1 [NPBins+1][NEtaBins+1]
 
TH1F * histoR2 [NPBins+1][NEtaBins+1]
 
TH1F * histoR3 [NPBins+1][NEtaBins+1]
 
bool histos
 
std::string hitLabEB
 
std::string hitLabEE
 
double pBins [NPBins+1]
 
std::string sourceLabel
 
int verbose
 

Static Private Attributes

static const int NEtaBins = 3
 
static const int NPBins = 8
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 33 of file ElectronStudy.h.

Constructor & Destructor Documentation

ElectronStudy::ElectronStudy ( const edm::ParameterSet ps)

Definition at line 15 of file ElectronStudy.cc.

References etaBins, g4Label, edm::ParameterSet::getUntrackedParameter(), histoE1x1, histoE3x3, histoE5x5, histoR1, histoR2, histoR3, histos, hitLabEB, hitLabEE, i, edm::Service< T >::isAvailable(), j, TFileDirectory::make(), mergeVDriftHistosByStation::name, NEtaBins, NPBins, pBins, sourceLabel, and indexGen::title.

15  {
16 
17  sourceLabel = ps.getUntrackedParameter<std::string>("SourceLabel","generator");
18  g4Label = ps.getUntrackedParameter<std::string>("ModuleLabel","g4SimHits");
19  hitLabEB= ps.getUntrackedParameter<std::string>("EBCollection","EcalHitsEB");
20  hitLabEE= ps.getUntrackedParameter<std::string>("EECollection","EcalHitsEE");
21  verbose = ps.getUntrackedParameter<int>("Verbosity",0);
22  edm::LogInfo("ElectronStudy") << "Module Label: " << g4Label << " Hits: "
23  << hitLabEB << ", " << hitLabEE;
24 
25  double tempPBins[NPBins+1] = { 0.0, 10.0, 20.0, 40.0, 60.0,
26  100.0, 500.0, 1000.0, 10000.0};
27  double tempEta[NEtaBins+1] = {0.0, 1.2, 1.6, 3.0};
28 
29  for (int i=0; i<NPBins+1; i++) pBins[i] = tempPBins[i];
30  for(int i=0; i<NEtaBins+1; i++) etaBins[i] = tempEta[i];
31 
33  if ( !tfile.isAvailable() ) {
34  edm::LogInfo("ElectronStudy") << "TFileService unavailable: no histograms";
35  histos = false;
36  } else {
37  char name[20], title[200], cpbin[30], cebin[30];
38  histos = true;
39  for (unsigned int i=0; i<NPBins+1; ++i) {
40  if (i == 0) sprintf (cpbin, " All p");
41  else sprintf (cpbin, " p (%6.0f:%6.0f)", pBins[i-1], pBins[i]);
42  for (unsigned int j=0; j<NEtaBins+1; ++j) {
43  if (j == 0) sprintf (cebin, " All #eta");
44  else sprintf (cebin, " #eta (%4.1f:%4.1f)", etaBins[j-1], etaBins[j]);
45  sprintf (name, "R1%d%d", i, j);
46  sprintf (title,"E1/E9 for %s%s", cpbin, cebin);
47  histoR1[i][j] = tfile->make<TH1F>(name, title, 100, 0., 2.);
48  histoR1[i][j]->GetXaxis()->SetTitle(title);
49  histoR1[i][j]->GetYaxis()->SetTitle("Tracks");
50  sprintf (name, "R2%d%d", i, j);
51  sprintf (title,"E1/E25 for %s%s", cpbin, cebin);
52  histoR2[i][j] = tfile->make<TH1F>(name, title, 100, 0., 2.);
53  histoR2[i][j]->GetXaxis()->SetTitle(title);
54  histoR2[i][j]->GetYaxis()->SetTitle("Tracks");
55  sprintf (name, "R3%d%d", i, j);
56  sprintf (title,"E9/E25 for %s%s", cpbin, cebin);
57  histoR3[i][j] = tfile->make<TH1F>(name, title, 100, 0., 2.);
58  histoR3[i][j]->GetXaxis()->SetTitle(title);
59  histoR3[i][j]->GetYaxis()->SetTitle("Tracks");
60  sprintf (name, "E1x1%d%d", i, j);
61  sprintf (title,"E1/P for %s%s", cpbin, cebin);
62  histoE1x1[i][j] = tfile->make<TH1F>(name, title, 100, 0., 2.);
63  histoE1x1[i][j]->GetXaxis()->SetTitle(title);
64  histoE1x1[i][j]->GetYaxis()->SetTitle("Tracks");
65  sprintf (name, "E3x3%d%d", i, j);
66  sprintf (title,"E9/P for %s%s", cpbin, cebin);
67  histoE3x3[i][j] = tfile->make<TH1F>(name, title, 100, 0., 2.);
68  histoE3x3[i][j]->GetXaxis()->SetTitle(title);
69  histoE3x3[i][j]->GetYaxis()->SetTitle("Tracks");
70  sprintf (name, "E5x5%d%d", i, j);
71  sprintf (title,"E25/P for %s%s", cpbin, cebin);
72  histoE5x5[i][j] = tfile->make<TH1F>(name, title, 100, 0., 2.);
73  histoE5x5[i][j]->GetXaxis()->SetTitle(title);
74  histoE5x5[i][j]->GetYaxis()->SetTitle("Tracks");
75  }
76  }
77  }
78 }
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::string hitLabEE
Definition: ElectronStudy.h:48
TH1F * histoR2[NPBins+1][NEtaBins+1]
Definition: ElectronStudy.h:51
std::string g4Label
Definition: ElectronStudy.h:48
std::string hitLabEB
Definition: ElectronStudy.h:48
TH1F * histoE3x3[NPBins+1][NEtaBins+1]
Definition: ElectronStudy.h:53
TH1F * histoE1x1[NPBins+1][NEtaBins+1]
Definition: ElectronStudy.h:52
static const int NPBins
Definition: ElectronStudy.h:45
bool isAvailable() const
Definition: Service.h:47
int j
Definition: DBlmapReader.cc:9
TH1F * histoR3[NPBins+1][NEtaBins+1]
Definition: ElectronStudy.h:52
double etaBins[NEtaBins+1]
Definition: ElectronStudy.h:46
TH1F * histoR1[NPBins+1][NEtaBins+1]
Definition: ElectronStudy.h:51
std::string sourceLabel
Definition: ElectronStudy.h:48
TH1F * histoE5x5[NPBins+1][NEtaBins+1]
Definition: ElectronStudy.h:53
double pBins[NPBins+1]
Definition: ElectronStudy.h:46
T * make() const
make new ROOT object
static const int NEtaBins
Definition: ElectronStudy.h:44
ElectronStudy::~ElectronStudy ( )
inline

Definition at line 38 of file ElectronStudy.h.

38 {}

Member Function Documentation

void ElectronStudy::analyze ( const edm::Event e,
const edm::EventSetup c 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 80 of file ElectronStudy.cc.

References abs, ecalTB2006H4_GenSimDigiReco_cfg::bField, gather_cfg::cout, spr::propagatedTrackDirection::detIdECAL, EcalBarrel, EcalEndcap, spr::eECALmatrix(), eta(), etaBins, edm::EventID::event(), g4Label, edm::EventSetup::get(), edm::Event::getByLabel(), histoE1x1, histoE3x3, histoE5x5, histoR1, histoR2, histoR3, histos, hitLabEB, hitLabEE, edm::EventBase::id(), errorMatrix2Lands_multiChannel::id, edm::HandleBase::isValid(), NEtaBins, NPBins, spr::propagatedTrackDirection::okECAL, AlCaHLTBitMon_ParallelJobs::p, pBins, edm::ESHandle< class >::product(), spr::propagateCALO(), diffTwoXMLs::r1, diffTwoXMLs::r2, edm::EventID::run(), and DetId::subdetId().

80  {
81 
82  if (verbose > 1) std::cout << "Run = " << iEvent.id().run() << " Event = "
83  << iEvent.id().event() << std::endl;
84 
85  // get Geometry, B-field, Topology
87  iSetup.get<IdealMagneticFieldRecord>().get(bFieldH);
88  const MagneticField* bField = bFieldH.product();
89 
91  iSetup.get<CaloGeometryRecord>().get(pG);
92  const CaloGeometry* geo = pG.product();
93 
94  edm::ESHandle<CaloTopology> theCaloTopology;
95  iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
96  const CaloTopology* caloTopology = theCaloTopology.product();
97 
98  // get PCaloHits for ecal barrel
100  iEvent.getByLabel(g4Label,hitLabEB,caloHitEB);
101 
102  // get PCaloHits for ecal endcap
104  iEvent.getByLabel(g4Label,hitLabEE,caloHitEE);
105 
106  // get sim tracks
108  iEvent.getByLabel(g4Label, SimTk);
109 
110  // get sim vertices
112  iEvent.getByLabel(g4Label, SimVtx);
113 
114  if (verbose>0)
115  std::cout << "ElectronStudy: hits valid[EB]: " << caloHitEB.isValid()
116  << " valid[EE]: " << caloHitEE.isValid() << std::endl;
117 
118  if (caloHitEB.isValid() && caloHitEE.isValid()) {
119  unsigned int indx;
120  if (verbose>2) {
121  edm::PCaloHitContainer::const_iterator ihit;
122  for (ihit=caloHitEB->begin(),indx=0; ihit!=caloHitEB->end(); ihit++,indx++) {
123  EBDetId id = ihit->id();
124  std::cout << "Hit[" << indx << "] " << id << " E " << ihit->energy()
125  << " T " << ihit->time() << std::endl;
126  }
127  for (ihit=caloHitEE->begin(),indx=0; ihit!=caloHitEE->end(); ihit++,indx++) {
128  EEDetId id = ihit->id();
129  std::cout << "Hit[" << indx << "] " << id << " E " << ihit->energy()
130  << " T " << ihit->time() << std::endl;
131  }
132  }
133  edm::SimTrackContainer::const_iterator simTrkItr=SimTk->begin();
134  for (indx=0; simTrkItr!= SimTk->end(); simTrkItr++,indx++) {
135  if (verbose>0) std::cout << "ElectronStudy: Track[" << indx << "] ID "
136  << simTrkItr->trackId() << " type "
137  << simTrkItr->type() << " charge "
138  << simTrkItr->charge() << " p "
139  << simTrkItr->momentum()<< " Generator Index "
140  << simTrkItr->genpartIndex() << " vertex "
141  << simTrkItr->vertIndex() << std::endl;
142  if (std::abs(simTrkItr->type()) == 11 && simTrkItr->vertIndex() != -1) {
143  int thisTrk = simTrkItr->trackId();
144  spr::propagatedTrackDirection trkD = spr::propagateCALO(thisTrk, SimTk, SimVtx, geo, bField, (verbose>1));
145  if (trkD.okECAL) {
146  const DetId isoCell = trkD.detIdECAL;
147  double e1x1 = spr::eECALmatrix(isoCell, caloHitEB, caloHitEE, geo, caloTopology, 0, 0, -100.0, -100.0,-500.0, 500.0, (verbose>2));
148  double e3x3 = spr::eECALmatrix(isoCell, caloHitEB, caloHitEE, geo, caloTopology, 1, 1, -100.0, -100.0,-500.0, 500.0, (verbose>2));
149  double e5x5 = spr::eECALmatrix(isoCell, caloHitEB, caloHitEE, geo, caloTopology, 2, 2, -100.0, -100.0,-500.0, 500.0, (verbose>2));
150  double p = simTrkItr->momentum().P();
151  double eta = std::abs(simTrkItr->momentum().eta());
152  int etaBin=-1, momBin=-1;
153  for (int ieta=0; ieta<NEtaBins; ieta++) {
154  if (eta>etaBins[ieta] && eta<etaBins[ieta+1] ) etaBin = ieta+1;
155  }
156  for (int ipt=0; ipt<NPBins; ipt++) {
157  if (p>pBins[ipt] && p<pBins[ipt+1] ) momBin = ipt+1;
158  }
159  double r1=-1, r2=-1, r3=-1;
160  if (e3x3 > 0) r1 = e1x1/e3x3;
161  if (e5x5 > 0) {r2 = e1x1/e5x5; r3 = e3x3/e5x5;}
162  if (verbose>0) {
163  std::cout << "ElectronStudy: p " << p << " [" << momBin << "] eta "
164  << eta << " [" << etaBin << "]";
165  if (isoCell.subdetId() == EcalBarrel) {
166  EBDetId id = isoCell;
167  std::cout << " Cell 0x" << std::hex << isoCell() << std::dec
168  << " " << id;
169  } else if (isoCell.subdetId() == EcalEndcap) {
170  EEDetId id = isoCell;
171  std::cout << " Cell 0x" << std::hex << isoCell() << std::dec
172  << " " << id;
173  } else {
174  std::cout << " Cell 0x" << std::hex << isoCell() << std::dec
175  << " Unknown Type";
176  }
177  std::cout << " e1x1 " << e1x1 << "|" << r1 << "|" << r2 << " e3x3 "
178  << e3x3 << "|" << r3 << " e5x5 " << e5x5 << std::endl;
179  }
180  if (histos) {
181  histoR1[0][0]->Fill(r1);
182  histoR2[0][0]->Fill(r2);
183  histoR3[0][0]->Fill(r3);
184  histoE1x1[0][0]->Fill(e1x1/p);
185  histoE3x3[0][0]->Fill(e3x3/p);
186  histoE5x5[0][0]->Fill(e5x5/p);
187  if (momBin>0) {
188  histoR1[momBin][0]->Fill(r1);
189  histoR2[momBin][0]->Fill(r2);
190  histoR3[momBin][0]->Fill(r3);
191  histoE1x1[momBin][0]->Fill(e1x1/p);
192  histoE3x3[momBin][0]->Fill(e3x3/p);
193  histoE5x5[momBin][0]->Fill(e5x5/p);
194  }
195  if (etaBin>0) {
196  histoR1[0][etaBin]->Fill(r1);
197  histoR2[0][etaBin]->Fill(r2);
198  histoR3[0][etaBin]->Fill(r3);
199  histoE1x1[0][etaBin]->Fill(e1x1/p);
200  histoE3x3[0][etaBin]->Fill(e3x3/p);
201  histoE5x5[0][etaBin]->Fill(e5x5/p);
202  if (momBin>0) {
203  histoR1[momBin][etaBin]->Fill(r1);
204  histoR2[momBin][etaBin]->Fill(r2);
205  histoR3[momBin][etaBin]->Fill(r3);
206  histoE1x1[momBin][etaBin]->Fill(e1x1/p);
207  histoE3x3[momBin][etaBin]->Fill(e3x3/p);
208  histoE5x5[momBin][etaBin]->Fill(e5x5/p);
209  }
210  }
211  }
212  }
213  }
214  }
215  }
216 
217 }
std::string hitLabEE
Definition: ElectronStudy.h:48
TH1F * histoR2[NPBins+1][NEtaBins+1]
Definition: ElectronStudy.h:51
std::string g4Label
Definition: ElectronStudy.h:48
std::vector< spr::propagatedTrackID > propagateCALO(edm::Handle< reco::TrackCollection > &trkCollection, const CaloGeometry *geo, const MagneticField *bField, std::string &theTrackQuality, bool debug=false)
std::string hitLabEB
Definition: ElectronStudy.h:48
TH1F * histoE3x3[NPBins+1][NEtaBins+1]
Definition: ElectronStudy.h:53
TH1F * histoE1x1[NPBins+1][NEtaBins+1]
Definition: ElectronStudy.h:52
#define abs(x)
Definition: mlp_lapack.h:159
T eta() const
int iEvent
Definition: GenABIO.cc:243
static const int NPBins
Definition: ElectronStudy.h:45
TH1F * histoR3[NPBins+1][NEtaBins+1]
Definition: ElectronStudy.h:52
bool isValid() const
Definition: HandleBase.h:76
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
double etaBins[NEtaBins+1]
Definition: ElectronStudy.h:46
TH1F * histoR1[NPBins+1][NEtaBins+1]
Definition: ElectronStudy.h:51
Definition: DetId.h:20
TH1F * histoE5x5[NPBins+1][NEtaBins+1]
Definition: ElectronStudy.h:53
T const * product() const
Definition: ESHandle.h:62
double pBins[NPBins+1]
Definition: ElectronStudy.h:46
tuple cout
Definition: gather_cfg.py:121
static const int NEtaBins
Definition: ElectronStudy.h:44
double eECALmatrix(const DetId &detId, edm::Handle< T > &hitsEB, edm::Handle< T > &hitsEE, const CaloGeometry *geo, const CaloTopology *caloTopology, int ieta, int iphi, double ebThr=-100, double eeThr=-100, double tMin=-500, double tMax=500, bool debug=false)

Member Data Documentation

double ElectronStudy::etaBins[NEtaBins+1]
private

Definition at line 46 of file ElectronStudy.h.

Referenced by analyze(), and ElectronStudy().

std::string ElectronStudy::g4Label
private

Definition at line 48 of file ElectronStudy.h.

Referenced by analyze(), and ElectronStudy().

TH1F * ElectronStudy::histoE1x1[NPBins+1][NEtaBins+1]
private

Definition at line 52 of file ElectronStudy.h.

Referenced by analyze(), and ElectronStudy().

TH1F* ElectronStudy::histoE3x3[NPBins+1][NEtaBins+1]
private

Definition at line 53 of file ElectronStudy.h.

Referenced by analyze(), and ElectronStudy().

TH1F * ElectronStudy::histoE5x5[NPBins+1][NEtaBins+1]
private

Definition at line 53 of file ElectronStudy.h.

Referenced by analyze(), and ElectronStudy().

TH1F* ElectronStudy::histoR1[NPBins+1][NEtaBins+1]
private

Definition at line 51 of file ElectronStudy.h.

Referenced by analyze(), and ElectronStudy().

TH1F * ElectronStudy::histoR2[NPBins+1][NEtaBins+1]
private

Definition at line 51 of file ElectronStudy.h.

Referenced by analyze(), and ElectronStudy().

TH1F* ElectronStudy::histoR3[NPBins+1][NEtaBins+1]
private

Definition at line 52 of file ElectronStudy.h.

Referenced by analyze(), and ElectronStudy().

bool ElectronStudy::histos
private

Definition at line 50 of file ElectronStudy.h.

Referenced by analyze(), and ElectronStudy().

std::string ElectronStudy::hitLabEB
private

Definition at line 48 of file ElectronStudy.h.

Referenced by analyze(), and ElectronStudy().

std::string ElectronStudy::hitLabEE
private

Definition at line 48 of file ElectronStudy.h.

Referenced by analyze(), and ElectronStudy().

const int ElectronStudy::NEtaBins = 3
staticprivate

Definition at line 44 of file ElectronStudy.h.

Referenced by analyze(), and ElectronStudy().

const int ElectronStudy::NPBins = 8
staticprivate

Definition at line 45 of file ElectronStudy.h.

Referenced by analyze(), and ElectronStudy().

double ElectronStudy::pBins[NPBins+1]
private

Definition at line 46 of file ElectronStudy.h.

Referenced by analyze(), and ElectronStudy().

std::string ElectronStudy::sourceLabel
private

Definition at line 48 of file ElectronStudy.h.

Referenced by ElectronStudy().

int ElectronStudy::verbose
private