CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PlotEcalRecHits.cc
Go to the documentation of this file.
2 
6 
10 
12 
18 
20 
21 #include <vector>
22 
23 using namespace std;
24 
25 /*****************************************************************************/
27  (const edm::EventSetup& es, ofstream& file_) : file(file_)
28 {
29  // Get calorimetry
31  es.get<CaloGeometryRecord>().get(calo);
32  theCaloGeometry = (const CaloGeometry*)calo.product();
33 }
34 
35 /*****************************************************************************/
37 {
38 }
39 
40 /*****************************************************************************/
42  (const CaloCellGeometry* cell, float energy)
43 {
44  float x = energy;
45  if(x > 1) x = 1.;
46  float red = fabs(2*x-0.5);
47  float green = sin(180*x);
48  float blue = cos( 90*x);
49 
50  file << ", PointSize[" << energy*0.01 << "]";
51  file << ", RGBColor[" << red << "," << green << "," << blue << "]";
52  file << ", Point[{" << cell->getPosition().x() << ","
53  << cell->getPosition().y() << ",("
54  << cell->getPosition().z() << "-zs)*mz}]" << std::endl;
55 
56  const CaloCellGeometry::CornersVec & p(cell->getCorners()) ;
57 
58  file << ", If[sd, {RGBColor[0.5,0.5,0.5]";
59 
60  file << ", Line[{";
61  file << "{" << p[0].x() << "," <<p[0].y() << ",(" << p[0].z() << "-zs)*mz}, ";
62  file << "{" << p[1].x() << "," <<p[1].y() << ",(" << p[1].z() << "-zs)*mz}, ";
63  file << "{" << p[2].x() << "," <<p[2].y() << ",(" << p[2].z() << "-zs)*mz}, ";
64  file << "{" << p[3].x() << "," <<p[3].y() << ",(" << p[3].z() << "-zs)*mz}, ";
65  file << "{" << p[0].x() << "," <<p[0].y() << ",(" << p[0].z() << "-zs)*mz}";
66  file << "}]" << std::endl;
67 
68  file << ", Line[{";
69  file << "{" << p[4].x() << "," <<p[4].y() << ",(" << p[4].z() << "-zs)*mz}, ";
70  file << "{" << p[5].x() << "," <<p[5].y() << ",(" << p[5].z() << "-zs)*mz}, ";
71  file << "{" << p[6].x() << "," <<p[6].y() << ",(" << p[6].z() << "-zs)*mz}, ";
72  file << "{" << p[7].x() << "," <<p[7].y() << ",(" << p[7].z() << "-zs)*mz}, ";
73  file << "{" << p[4].x() << "," <<p[4].y() << ",(" << p[4].z() << "-zs)*mz}";
74  file << "}]" << std::endl;
75 
76  file << ", Line[{";
77  file << "{" << p[0].x() << "," <<p[0].y() << ",(" << p[0].z() << "-zs)*mz}, ";
78  file << "{" << p[4].x() << "," <<p[4].y() << ",(" << p[4].z() << "-zs)*mz}";
79  file << "}]" << std::endl;
80 
81  file << ", Line[{";
82  file << "{" << p[1].x() << "," <<p[1].y() << ",(" << p[1].z() << "-zs)*mz}, ";
83  file << "{" << p[5].x() << "," <<p[5].y() << ",(" << p[5].z() << "-zs)*mz}";
84  file << "}]" << std::endl;
85 
86  file << ", Line[{";
87  file << "{" << p[2].x() << "," <<p[2].y() << ",(" << p[2].z() << "-zs)*mz}, ";
88  file << "{" << p[6].x() << "," <<p[6].y() << ",(" << p[6].z() << "-zs)*mz}";
89  file << "}]" << std::endl;
90 
91  file << ", Line[{";
92  file << "{" << p[3].x() << "," <<p[3].y() << ",(" << p[3].z() << "-zs)*mz}, ";
93  file << "{" << p[7].x() << "," <<p[7].y() << ",(" << p[7].z() << "-zs)*mz}";
94  file << "}]" << std::endl;
95 
96  file << "}]" << std::endl;
97 }
98 
99 /*****************************************************************************/
101 {
102 // const float minEnergy = 0.060;
103 
104  edm::Handle<EBRecHitCollection> recHitsBarrel;
105  ev.getByLabel("ecalRecHit", "EcalRecHitsEB", recHitsBarrel);
106  edm::Handle<EERecHitCollection> recHitsEndcap;
107  ev.getByLabel("ecalRecHit", "EcalRecHitsEE", recHitsEndcap);
108 /*
109  edm::Handle<ESRecHitCollection> recHitsPreshower;
110  ev.getByLabel("ecalPreshowerRecHit", "EcalRecHitsES", recHitsPreshower);
111 */
112 
113  LogTrace("MinBiasTracking")
114  << " [EventPlotter] ecal barrel/endcap :"
115  << " " << recHitsBarrel->size()
116  << "/" << recHitsEndcap->size();
117 // << "/" << recHitsPreshower->size() << std::endl;
118 
120 
121  file << ", If[er, {RGBColor[0.0,0.0,0.0]";
122 
123  // Barrel
124  geom = theCaloGeometry->getSubdetectorGeometry(DetId::Ecal,EcalBarrel);
125  for(EBRecHitCollection::const_iterator recHit = recHitsBarrel->begin();
126  recHit!= recHitsBarrel->end();
127  recHit++)
128  {
129  EBDetId detId(recHit->id());
130  const CaloCellGeometry* cell = geom->getGeometry(detId);
131  if(cell != 0)
132  printEcalRecHit(cell, recHit->energy());
133  }
134 
135  // Endcap
136  geom = theCaloGeometry->getSubdetectorGeometry(DetId::Ecal,EcalEndcap);
137  for(EERecHitCollection::const_iterator recHit = recHitsEndcap->begin();
138  recHit!= recHitsEndcap->end();
139  recHit++)
140  {
141  EEDetId detId(recHit->id());
142  const CaloCellGeometry* cell = geom->getGeometry(detId);
143  if(cell != 0)
144  printEcalRecHit(cell, recHit->energy());
145  }
146 
147  // Preshower
148 /*
149  geom = theCaloGeometry->getSubdetectorGeometry(DetId::Ecal,EcalPreshower);
150  for(ESRecHitCollection::const_iterator recHit = recHitsPreshower->begin();
151  recHit!= recHitsPreshower->end();
152  recHit++)
153  {
154  ESDetId detId(recHit->id());
155  const CaloCellGeometry* cell = geom->getGeometry(detId);
156  printEcalRecHit(cell, recHit->energy() * 1e+3);
157  }
158 */
159  file << "}]";
160 }
161 
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< EcalRecHit >::const_iterator const_iterator
T y() const
Definition: PV3DBase.h:62
void printEcalRecHit(const CaloCellGeometry *cell, float energy)
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
PlotEcalRecHits(const edm::EventSetup &es, std::ofstream &file_)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
T z() const
Definition: PV3DBase.h:63
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
void printEcalRecHits(const edm::Event &ev)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
#define LogTrace(id)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
Definition: DDAxes.h:10
T x() const
Definition: PV3DBase.h:61
virtual const CornersVec & getCorners() const =0
Returns the corner points of this cell&#39;s volume.