CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalPreshowerSimHitsValidation.cc
Go to the documentation of this file.
1 /*
2  * \file EcalPreshowerSimHitsValidation.cc
3  *
4  * \author C.Rovelli
5  *
6 */
7 
13 
14 using namespace cms;
15 using namespace edm;
16 using namespace std;
17 
19 
20  HepMCLabel(ps.getParameter<std::string>("moduleLabelMC")),
21  g4InfoLabel(ps.getParameter<std::string>("moduleLabelG4")),
22  EEHitsCollection(ps.getParameter<std::string>("EEHitsCollection")),
23  ESHitsCollection(ps.getParameter<std::string>("ESHitsCollection")){
24 
25  // verbosity switch
26  verbose_ = ps.getUntrackedParameter<bool>("verbose", false);
27 
28  // get hold of back-end interface
29  dbe_ = 0;
30  dbe_ = edm::Service<DQMStore>().operator->();
31  if ( dbe_ ) {
32  if ( verbose_ ) { dbe_->setVerbose(1); }
33  else { dbe_->setVerbose(0); }
34  }
35 
36  if ( dbe_ ) {
37  if ( verbose_ ) dbe_->showDirStructure();
38  }
39 
40 
41  menESHits1zp_ = 0;
42  menESHits2zp_ = 0;
43  menESHits1zm_ = 0;
44  menESHits2zm_ = 0;
45 
50 
53 
54  meE1alphaE2zp_ = 0;
55  meE1alphaE2zm_ = 0;
56  meEEoverESzp_ = 0;
57  meEEoverESzm_ = 0;
58 
61 
62 
63  Char_t histo[200];
64 
65  if ( dbe_ ) {
66  dbe_->setCurrentFolder("EcalHitsV/EcalSimHitsValidation");
67 
68  sprintf (histo, "ES hits layer 1 multiplicity z+" ) ;
69  menESHits1zp_ = dbe_->book1D(histo, histo, 50, 0., 50. ) ;
70 
71  sprintf (histo, "ES hits layer 2 multiplicity z+" ) ;
72  menESHits2zp_ = dbe_->book1D(histo, histo, 50, 0., 50. ) ;
73 
74  sprintf (histo, "ES hits layer 1 multiplicity z-" ) ;
75  menESHits1zm_ = dbe_->book1D(histo, histo, 50, 0., 50. ) ;
76 
77  sprintf (histo, "ES hits layer 2 multiplicity z-" ) ;
78  menESHits2zm_ = dbe_->book1D(histo, histo, 50, 0., 50. ) ;
79 
80  sprintf (histo, "ES hits energy layer 1 z+" ) ;
81  meESEnergyHits1zp_ = dbe_->book1D(histo, histo, 100, 0., 0.05 ) ;
82 
83  sprintf (histo, "ES hits energy layer 2 z+" ) ;
84  meESEnergyHits2zp_ = dbe_->book1D(histo, histo, 100, 0., 0.05 ) ;
85 
86  sprintf (histo, "ES hits energy layer 1 z-" ) ;
87  meESEnergyHits1zm_ = dbe_->book1D(histo, histo, 100, 0., 0.05 ) ;
88 
89  sprintf (histo, "ES hits energy layer 2 z-" ) ;
90  meESEnergyHits2zm_ = dbe_->book1D(histo, histo, 100, 0., 0.05 ) ;
91 
92  sprintf (histo, "ES hits log10energy spectrum" );
93  meEShitLog10Energy_ = dbe_->book1D(histo, histo, 140, -10., 4.);
94 
95  sprintf (histo, "ES hits log10energy spectrum vs normalized energy" );
96  meEShitLog10EnergyNorm_ = dbe_->bookProfile(histo, histo, 140, -10., 4., 100, 0., 1.);
97 
98  sprintf (histo, "ES E1+07E2 z+" ) ;
99  meE1alphaE2zp_ = dbe_->book1D(histo, histo, 100, 0., 0.05);
100 
101  sprintf (histo, "ES E1+07E2 z-" ) ;
102  meE1alphaE2zm_ = dbe_->book1D(histo, histo, 100, 0., 0.05);
103 
104  sprintf (histo, "EE vs ES z+" ) ;
105  meEEoverESzp_ = dbe_->bookProfile(histo, histo, 250, 0., 500., 200, 0., 200.);
106 
107  sprintf (histo, "EE vs ES z-" ) ;
108  meEEoverESzm_ = dbe_->bookProfile(histo, histo, 250, 0., 500., 200, 0., 200.);
109 
110  sprintf (histo, "ES ene2oEne1 z+" ) ;
111  me2eszpOver1eszp_ = dbe_->book1D(histo, histo, 50, 0., 10.);
112 
113  sprintf (histo, "ES ene2oEne1 z-" ) ;
114  me2eszmOver1eszm_ = dbe_->book1D(histo, histo, 50, 0., 10.);
115  }
116 }
117 
119 
120 }
121 
123 
124 }
125 
127 
128 }
129 
131 
132  edm::LogInfo("EventInfo") << " Run = " << e.id().run() << " Event = " << e.id().event();
133 
135  e.getByLabel(HepMCLabel, MCEvt);
136 
139 
142 
143  std::vector<PCaloHit> theEECaloHits;
144  if( EcalHitsEE.isValid() ) {
145  theEECaloHits.insert(theEECaloHits.end(), EcalHitsEE->begin(), EcalHitsEE->end());
146  }
147 
148  std::vector<PCaloHit> theESCaloHits;
149  if( EcalHitsES.isValid() ) {
150  theESCaloHits.insert(theESCaloHits.end(), EcalHitsES->begin(), EcalHitsES->end());
151  }
152 
153  double ESEnergy_ = 0.;
154  //std::map<unsigned int, std::vector<PCaloHit>,std::less<unsigned int> > CaloHitMap;
155 
156  // endcap
157  double EEetzp_ = 0.;
158  double EEetzm_ = 0.;
159  for (std::vector<PCaloHit>::iterator isim = theEECaloHits.begin(); isim != theEECaloHits.end(); ++isim){
160  EEDetId eeid (isim->id()) ;
161  if (eeid.zside() > 0 ) EEetzp_ += isim->energy();
162  if (eeid.zside() < 0 ) EEetzm_ += isim->energy();
163  }
164 
165 
166  uint32_t nESHits1zp = 0;
167  uint32_t nESHits1zm = 0;
168  uint32_t nESHits2zp = 0;
169  uint32_t nESHits2zm = 0;
170  double ESet1zp_ = 0.;
171  double ESet2zp_ = 0.;
172  double ESet1zm_ = 0.;
173  double ESet2zm_ = 0.;
174  std::vector<double> econtr(140, 0. );
175 
176  for (std::vector<PCaloHit>::iterator isim = theESCaloHits.begin();
177  isim != theESCaloHits.end(); ++isim){
178  //CaloHitMap[(*isim).id()].push_back((*isim));
179 
180  ESDetId esid (isim->id()) ;
181 
182  LogDebug("HitInfo")
183  << " CaloHit " << isim->getName() << "\n"
184  << " DetID = "<<isim->id()<< " ESDetId: z side " << esid.zside() << " plane " << esid.plane() << esid.six() << ',' << esid.siy() << ':' << esid.strip() << "\n"
185  << " Time = " << isim->time() << "\n"
186  << " Track Id = " << isim->geantTrackId() << "\n"
187  << " Energy = " << isim->energy();
188 
189  ESEnergy_ += isim->energy();
190  if( isim->energy() > 0 ) {
191  meEShitLog10Energy_->Fill(log10(isim->energy()));
192  int log10i = int( ( log10(isim->energy()) + 10. ) * 10. );
193  if( log10i >=0 && log10i < 140 ) econtr[log10i] += isim->energy();
194  }
195 
196  if (esid.plane() == 1 ) {
197  if (esid.zside() > 0 ) {
198  nESHits1zp++ ;
199  ESet1zp_ += isim->energy();
200  if (meESEnergyHits1zp_) meESEnergyHits1zp_->Fill(isim->energy()) ;
201  }
202  else if (esid.zside() < 0 ) {
203  nESHits1zm++ ;
204  ESet1zm_ += isim->energy();
205  if (meESEnergyHits1zm_) meESEnergyHits1zm_->Fill(isim->energy()) ;
206  }
207  }
208  else if (esid.plane() == 2 ) {
209  if (esid.zside() > 0 ) {
210  nESHits2zp++ ;
211  ESet2zp_ += isim->energy();
212  if (meESEnergyHits2zp_) meESEnergyHits2zp_->Fill(isim->energy()) ;
213  }
214  else if (esid.zside() < 0 ) {
215  nESHits2zm++ ;
216  ESet2zm_ += isim->energy();
217  if (meESEnergyHits2zm_) meESEnergyHits2zm_->Fill(isim->energy()) ;
218  }
219  }
220 
221  }
222 
223  if (menESHits1zp_) menESHits1zp_->Fill(nESHits1zp);
224  if (menESHits1zm_) menESHits1zm_->Fill(nESHits1zm);
225 
226  if (menESHits2zp_) menESHits2zp_->Fill(nESHits2zp);
227  if (menESHits2zm_) menESHits2zm_->Fill(nESHits2zm);
228 
229  if( meEShitLog10EnergyNorm_ && ESEnergy_ != 0 ) {
230  for( int i=0; i<140; i++ ) {
231  meEShitLog10EnergyNorm_->Fill( -10.+(float(i)+0.5)/10., econtr[i]/ESEnergy_ );
232  }
233  }
234 
235 
236  for ( HepMC::GenEvent::particle_const_iterator p = MCEvt->GetEvent()->particles_begin();
237  p != MCEvt->GetEvent()->particles_end(); ++p ) {
238 
239  double htheta = (*p)->momentum().theta();
240  double heta = -99999.;
241  if( tan(htheta * 0.5) > 0 ) {
242  heta = -log(tan(htheta * 0.5));
243  }
244 
245  if ( heta > 1.653 && heta < 2.6 ) {
246 
247  if (meE1alphaE2zp_) meE1alphaE2zp_->Fill(ESet1zp_+0.7*ESet2zp_);
248  if (meEEoverESzp_) meEEoverESzp_ ->Fill((ESet1zp_+0.7*ESet2zp_)/0.00009, EEetzp_);
249  if ((me2eszpOver1eszp_) && (ESet1zp_ != 0.)) me2eszpOver1eszp_->Fill(ESet2zp_/ESet1zp_);
250  }
251  if ( heta < -1.653 && heta > -2.6 ) {
252  if (meE1alphaE2zm_) meE1alphaE2zm_->Fill(ESet1zm_+0.7*ESet2zm_);
253  if (meEEoverESzm_) meEEoverESzm_ ->Fill((ESet1zm_+0.7*ESet2zm_)/0.00009, EEetzm_);
254  if ((me2eszmOver1eszm_) && (ESet1zm_ != 0.)) me2eszmOver1eszm_->Fill(ESet2zm_/ESet1zm_);
255  }
256  }
257 }
258 
259 
260 // LocalWords: EcalSimHitsValidation
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:42
EventNumber_t event() const
Definition: EventID.h:44
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
EcalPreshowerSimHitsValidation(const edm::ParameterSet &ps)
Constructor.
void analyze(const edm::Event &e, const edm::EventSetup &c)
Analyze.
void Fill(long long x)
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
edm::EventID id() const
Definition: EventBase.h:56