CMS 3D CMS Logo

ZeePlots.cc

Go to the documentation of this file.
00001 
00002 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00003 
00004 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
00005 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00006 #include "DataFormats/DetId/interface/DetId.h"
00007 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h"
00008 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h"
00009 #include "Calibration/Tools/interface/calibXMLwriter.h"
00010 #include "Calibration/Tools/interface/CalibrationCluster.h"
00011 #include "Calibration/Tools/interface/CalibElectron.h"
00012 #include "Calibration/Tools/interface/HouseholderDecomposition.h"
00013 #include "Calibration/Tools/interface/MinL3Algorithm.h"
00014 #include "Calibration/EcalAlCaRecoProducers/interface/AlCaPhiSymRecHitsProducer.h"
00015 #include "Calibration/EcalCalibAlgos/interface/ZeePlots.h"
00016 #include "Calibration/EcalCalibAlgos/interface/ZeeKinematicTools.h"
00017 #include "DataFormats/EgammaCandidates/interface/Electron.h"
00018 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00019 #include "DataFormats/TrackReco/interface/Track.h"
00020 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00021 #include "DataFormats/TrackReco/interface/TrackExtraFwd.h"
00022 #include "TFile.h"
00023 #include "TH1.h"
00024 #include "TH2.h"
00025 #include "TF1.h"
00026 #include "TRandom.h"
00027 
00028 
00029 #include <iostream>
00030 #include <string>
00031 #include <stdexcept>
00032 #include <vector>
00033 
00034 #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
00035 
00036 ZeePlots::ZeePlots( char* fileName )
00037 {
00038 
00039   fileName_ = fileName;
00040   file_ = new TFile(fileName_, "RECREATE");
00041 }
00042 
00043 
00044 ZeePlots::~ZeePlots()
00045 {
00046   
00047   file_->Close();
00048   
00049   delete file_;
00050 
00051 }
00052 
00053 //========================================================================
00054 
00055 void ZeePlots::openFile(){
00056 
00057 
00058   file_ -> cd();
00059 
00060 }
00061 //========================================================================
00062 
00063 void ZeePlots::bookZMCHistograms(){
00064 
00065   file_ -> cd();
00066 
00067   h1_gen_ZMass_ = new TH1F("gen_ZMass","Generated Z mass",200,0.,150.);
00068   h1_gen_ZMass_->SetXTitle("gen_ZMass (GeV)");
00069   h1_gen_ZMass_->SetYTitle("events");
00070 
00071   h1_gen_ZEta_ = new TH1F("gen_ZEta","Eta of gen Z",200,-6.,6.);
00072   h1_gen_ZEta_->SetXTitle("#eta");
00073   h1_gen_ZEta_->SetYTitle("events");
00074 
00075   h1_gen_ZPhi_ = new TH1F("gen_ZPhi","Phi of gen Z",200,-4.,4.);
00076   h1_gen_ZPhi_->SetXTitle("#phi");
00077   h1_gen_ZPhi_->SetYTitle("events");
00078 
00079   h1_gen_ZRapidity_ = new TH1F("gen_ZRapidity","Rapidity of gen Z",200,-6.,6.);
00080   h1_gen_ZRapidity_->SetXTitle("Y");
00081   h1_gen_ZRapidity_->SetYTitle("events");
00082 
00083   h1_gen_ZPt_ = new TH1F("gen_ZPt","Pt of gen Z",200, 0.,100.);
00084   h1_gen_ZPt_->SetXTitle("p_{T} (GeV/c)");
00085   h1_gen_ZPt_->SetYTitle("events");
00086 
00087 
00088 }
00089 
00090 void ZeePlots::bookZHistograms(){
00091 
00092   file_ -> cd();
00093 
00094   h1_reco_ZEta_ = new TH1F("reco_ZEta","Eta of reco Z",200,-6.,6.);
00095   h1_reco_ZEta_->SetXTitle("#eta");
00096   h1_reco_ZEta_->SetYTitle("events");
00097   
00098   h1_reco_ZTheta_ = new TH1F("reco_ZTheta","Theta of reco Z",200, 0., 4.);
00099   h1_reco_ZTheta_->SetXTitle("#theta");
00100   h1_reco_ZTheta_->SetYTitle("events");
00101   
00102   h1_reco_ZRapidity_ = new TH1F("reco_ZRapidity","Rapidity of reco Z",200,-6.,6.);
00103   h1_reco_ZRapidity_->SetXTitle("Y");
00104   h1_reco_ZRapidity_->SetYTitle("events");
00105   
00106   h1_reco_ZPhi_ = new TH1F("reco_ZPhi","Phi of reco Z",100,-4.,4.);
00107   h1_reco_ZPhi_->SetXTitle("#phi");
00108   h1_reco_ZPhi_->SetYTitle("events");
00109   
00110   h1_reco_ZPt_ = new TH1F("reco_ZPt","Pt of reco Z",200,0.,100.);
00111   h1_reco_ZPt_->SetXTitle("p_{T} (GeV/c)");
00112   h1_reco_ZPt_->SetYTitle("events");
00113   
00114   
00115 }
00116 
00117 //========================================================================
00118 
00119 void ZeePlots::fillZInfo( pair<calib::CalibElectron*,calib::CalibElectron*> myZeeCandidate ) {
00120 
00121   h1_reco_ZEta_->Fill( ZeeKinematicTools::calculateZEta(myZeeCandidate) );
00122   h1_reco_ZTheta_->Fill( ZeeKinematicTools::calculateZTheta(myZeeCandidate) );
00123   h1_reco_ZRapidity_->Fill( ZeeKinematicTools::calculateZRapidity(myZeeCandidate) );
00124   h1_reco_ZPhi_->Fill( ZeeKinematicTools::calculateZPhi(myZeeCandidate) );
00125   h1_reco_ZPt_->Fill( ZeeKinematicTools::calculateZPt(myZeeCandidate) );
00126 
00127 }
00128 
00129 
00130 
00131 //========================================================================
00132 
00133 void ZeePlots::writeZHistograms() {
00134 
00135   file_->cd();
00136 
00137   h1_reco_ZEta_->Write();
00138   h1_reco_ZTheta_->Write();
00139   h1_reco_ZRapidity_->Write();
00140   h1_reco_ZPhi_->Write();
00141   h1_reco_ZPt_->Write();
00142   
00143 }
00144 
00145 //========================================================================
00146 
00147 void ZeePlots::writeMCZHistograms() {
00148 
00149   file_->cd();
00150   
00151   h1_gen_ZRapidity_->Write();
00152   h1_gen_ZPt_->Write();
00153   h1_gen_ZPhi_->Write();
00154 
00155 }
00156 
00157 //========================================================================
00158 
00159 void ZeePlots::fillZMCInfo( const HepMC::GenEvent* myGenEvent ) {
00160 
00161   file_->cd();
00162 
00163   for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
00164         p != myGenEvent->particles_end(); ++p ) {//loop over MC particles
00165  
00166     if ( (*p)->pdg_id() == 23 && (*p)->status() == 2 ){
00167       
00168       h1_gen_ZMass_->Fill( (*p)->momentum().m() );
00169       h1_gen_ZEta_->Fill( (*p)->momentum().eta() );
00170       
00171       float genZ_Y = 0.5 * log ( ( (*p)->momentum().e() + (*p)->momentum().pz() ) /  ( (*p)->momentum().e() - (*p)->momentum().pz() ) )   ;
00172       
00173       h1_gen_ZRapidity_->Fill( genZ_Y );
00174       h1_gen_ZPt_->Fill((*p)->momentum().perp());
00175       h1_gen_ZPhi_->Fill((*p)->momentum().phi());
00176 
00177       
00178 
00179     }
00180   }//end loop over MC particles
00181 
00182   return;  
00183 }
00184 
00185 //========================================================================
00186 
00187 void ZeePlots::bookEleMCHistograms(){
00188 
00189   file_->cd();
00190 
00191   h1_mcEle_Energy_ = new TH1F("mcEleEnergy","mc EleEnergy",300,0.,300.);
00192   h1_mcEle_Energy_->SetXTitle("E (GeV)");
00193   h1_mcEle_Energy_->SetYTitle("events");
00194 
00195   h1_mcElePt_ = new TH1F("mcElePt","p_{T} of MC electrons",300,0.,300.);
00196   h1_mcElePt_->SetXTitle("p_{T}(GeV/c)");
00197   h1_mcElePt_->SetYTitle("events");
00198   
00199   h1_mcEleEta_ = new TH1F("mcEleEta","Eta of MC electrons",100,-4.,4.);
00200   h1_mcEleEta_->SetXTitle("#eta");
00201   h1_mcEleEta_->SetYTitle("events");
00202 
00203   h1_mcElePhi_ = new TH1F("mcElePhi","Phi of MC electrons",100,-4.,4.);
00204   h1_mcElePhi_->SetXTitle("#phi");
00205   h1_mcElePhi_->SetYTitle("events");
00206 
00207 }
00208 
00209 //========================================================================
00210 
00211 void ZeePlots::fillEleMCInfo( const HepMC::GenEvent* myGenEvent ) {
00212 
00213   file_->cd();
00214   
00215   for ( HepMC::GenEvent::particle_const_iterator p = myGenEvent->particles_begin();
00216         p != myGenEvent->particles_end(); ++p ) {
00217     
00218     if (  abs( (*p)->pdg_id() ) == 11 )
00219       {
00220         h1_mcEle_Energy_->Fill( (*p)->momentum().e() );
00221         h1_mcElePt_->Fill( (*p)->momentum().perp() );
00222         h1_mcEleEta_->Fill( (*p)->momentum().eta() );
00223         h1_mcElePhi_->Fill( (*p)->momentum().phi() );
00224         
00225       }//matches if (  abs( (*p)->pdg_id() ) == 11 )
00226 
00227   }//end loop over MC particles
00228   
00229 }
00230 
00231 //========================================================================
00232 void ZeePlots::bookEleHistograms(){
00233 
00234   file_->cd();
00235 
00236   h1_nEleReco_ = new TH1F("h1_nEleReco", "h1_nEleReco", 20, 0, 20 );
00237   h1_nEleReco_->SetXTitle("Num. of reco electrons");
00238   
00239   h1_recoEleEnergy_ = new TH1F("recoEleEnergy","EleEnergy from SC",300,0.,300.);
00240   h1_recoEleEnergy_->SetXTitle("eleSCEnergy(GeV)");
00241   h1_recoEleEnergy_->SetYTitle("events");
00242   
00243   h1_recoElePt_ = new TH1F("recoElePt","p_{T} of reco electrons",300,0.,300.);
00244   h1_recoElePt_->SetXTitle("p_{T}(GeV/c)");
00245   h1_recoElePt_->SetYTitle("events");
00246 
00247   h1_recoEleEta_ = new TH1F("recoEleEta","Eta of reco electrons",100,-4.,4.);
00248   h1_recoEleEta_->SetXTitle("#eta");
00249   h1_recoEleEta_->SetYTitle("events");
00250 
00251    
00252   h1_recoElePhi_ = new TH1F("recoElePhi","Phi of reco electrons",100,-4.,4.);
00253   h1_recoElePhi_->SetXTitle("#phi");
00254   h1_recoElePhi_->SetYTitle("events");
00255 
00256 
00257 
00258 }
00259 
00260 //========================================================================
00261 
00262 void ZeePlots::fillEleInfo(const reco::PixelMatchGsfElectronCollection* electronCollection) {
00263 
00264   file_->cd();
00265 
00266   h1_nEleReco_->Fill(electronCollection->size());
00267   
00268   for(reco::PixelMatchGsfElectronCollection::const_iterator eleIt = electronCollection->begin();   eleIt != electronCollection->end(); eleIt++)
00269     {
00270       
00271   file_->cd();
00272 
00273       h1_recoEleEnergy_->Fill( eleIt->superCluster()->energy() );
00274       h1_recoElePt_->Fill( eleIt->pt() );
00275       h1_recoEleEta_->Fill( eleIt->eta() );
00276       h1_recoElePhi_->Fill( eleIt->phi() );
00277       
00278     }//end loop on electrons   
00279 
00280 }
00281 
00282 //========================================================================
00283 
00284 void ZeePlots::writeEleHistograms(){
00285 
00286   file_->cd();
00287 
00288   std::cout << "Start with ZeePlots::writeEleHistograms(), done file_->cd(); " << std::endl;
00289  
00290   h1_recoEleEnergy_->Write();
00291   h1_recoElePt_->Write();
00292   h1_recoEleEta_->Write();
00293   h1_recoElePhi_->Write();
00294 
00295   std::cout << "Done with ZeePlots::writeEleHistograms() " << std::endl;
00296 
00297 }
00298 
00299 //========================================================================
00300 
00301 void ZeePlots::writeMCEleHistograms(){
00302 
00303   file_->cd();
00304 
00305   std::cout << "Start with ZeePlots::writeMCEleHistograms(), done file_->cd(); " << std::endl;
00306 
00307   h1_mcEle_Energy_->Write();
00308   h1_mcElePt_->Write();
00309   h1_mcEleEta_->Write();
00310   h1_mcElePhi_->Write();
00311 
00312   std::cout << "Done with ZeePlots::writeMCEleHistograms() " << std::endl;
00313 
00314 }
00315 
00316 //========================================================================
00317 
00318 void ZeePlots::bookHLTHistograms(){
00319 
00320   file_->cd();
00321 
00322   h1_FiredTriggers_= new TH1F("h1_FiredTriggers", "h1_FiredTriggers", 5,0,5);
00323  
00324   h1_HLTVisitedEvents_ = new TH1F("h1_HLTVisitedEvents", "h1_HLTVisitedEvents", 5,0,5);
00325 
00326   h1_HLT1Electron_FiredEvents_ =  new TH1F("h1_HLT1Electron_FiredEvents", "h1_HLT1Electron_FiredEvents", 5,0,5);
00327   h1_HLT2Electron_FiredEvents_ =  new TH1F("h1_HLT2Electron_FiredEvents", "h1_HLT2Electron_FiredEvents", 5,0,5);
00328   h1_HLT2ElectronRelaxed_FiredEvents_ =  new TH1F("h1_HLT2ElectronRelaxed_FiredEvents", "h1_HLT2ElectronRelaxed_FiredEvents", 5,0,5);
00329 
00330   h1_HLT1Electron_HLT2Electron_FiredEvents_ =  new TH1F("h1_HLT1Electron_HLT2Electron_FiredEvents", "h1_HLT1Electron_HLT2Electron_FiredEvents", 5,0,5);
00331   h1_HLT1Electron_HLT2ElectronRelaxed_FiredEvents_ =  new TH1F("h1_HLT1Electron_HLT2ElectronRelaxed_FiredEvents", "h1_HLT1Electron_HLT2ElectronRelaxed_FiredEvents", 5,0,5);
00332   h1_HLT2Electron_HLT2ElectronRelaxed_FiredEvents_ =  new TH1F("h1_HLT2Electron_HLT2ElectronRelaxed_FiredEvents", "h1_HLT2Electron_HLT2ElectronRelaxed_FiredEvents", 5,0,5);
00333 
00334   h1_HLT1Electron_HLT2Electron_HLT2ElectronRelaxed_FiredEvents_ =  new TH1F("h1_HLT1Electron_HLT2Electron_HLT2ElectronRelaxed_FiredEvents", "h1_HLT1Electron_HLT2Electron_HLT2ElectronRelaxed_FiredEvents", 5,0,5);
00335 
00336 
00337 }
00338 
00339 
00340 //========================================================================
00341 
00342 void ZeePlots::fillHLTInfo( edm::Handle<edm::TriggerResults> hltTriggerResultHandle ){
00343 
00344   file_->cd();
00345   
00346   int hltCount = hltTriggerResultHandle->size();
00347 
00348   bool aHLTResults[200] = { false };
00349     
00350   for(int i = 0 ; i < hltCount ; i++) {
00351 
00352     aHLTResults[i] = hltTriggerResultHandle->accept(i);
00353     if(aHLTResults[i])
00354       h1_FiredTriggers_->Fill(i);
00355 
00356     //HLT bit 32 = HLT1Electron
00357     //HLT bit 34 = HLT2Electron
00358     //HLT bit 35 = HLT2ElectronRelaxed
00359 
00360   }
00361 
00362   h1_HLTVisitedEvents_->Fill(1);
00363     
00364   if(aHLTResults[32] && !aHLTResults[34] && !aHLTResults[35])
00365     h1_HLT1Electron_FiredEvents_->Fill(1);
00366 
00367   if(aHLTResults[34] && !aHLTResults[32] && !aHLTResults[35])
00368     h1_HLT2Electron_FiredEvents_->Fill(1);
00369 
00370   if(aHLTResults[35] && !aHLTResults[32] && !aHLTResults[34])
00371     h1_HLT2ElectronRelaxed_FiredEvents_->Fill(1);
00372 
00373   if(aHLTResults[32] && aHLTResults[34] && !aHLTResults[35])
00374     h1_HLT1Electron_HLT2Electron_FiredEvents_->Fill(1);
00375 
00376   if(aHLTResults[32] && aHLTResults[35] && !aHLTResults[34])
00377     h1_HLT1Electron_HLT2ElectronRelaxed_FiredEvents_->Fill(1);
00378 
00379   if(aHLTResults[34] && aHLTResults[35] && !aHLTResults[32])
00380     h1_HLT2Electron_HLT2ElectronRelaxed_FiredEvents_->Fill(1);
00381 
00382   if(aHLTResults[32] && aHLTResults[34] && aHLTResults[35])
00383     h1_HLT1Electron_HLT2Electron_HLT2ElectronRelaxed_FiredEvents_->Fill(1);
00384 
00385 
00386 
00387 }
00388 
00389 
00390 void ZeePlots::fillEleClassesPlots( calib::CalibElectron* myEle ){
00391 
00392   int myClass = myEle->getRecoElectron()->classification();
00393 
00394   float myEta = myEle->getRecoElectron()->eta();
00395   
00396   if(myClass==0 || myClass==100)
00397     h1_occupancyVsEtaGold_->Fill(myEta);
00398   
00399   cout<< "[ZeePlots::fillEleClassesPlots]Done gold"<< std::endl;
00400   
00401   if(myClass==40 || myClass==140)
00402     h1_occupancyVsEtaCrack_->Fill(myEta);
00403   
00404   cout<< "[ZeePlots::fillEleClassesPlots]Done crack"<< std::endl;
00405   
00406   if( (myClass>=30 && myClass<=34) || (myClass>=130 && myClass<=134) )
00407     h1_occupancyVsEtaShower_->Fill(myEta);
00408   
00409   cout<< "[ZeePlots::fillEleClassesPlots]Done shower"<< std::endl;
00410   
00411   if( myClass==10 || myClass==20 || myClass==110 || myClass ==120)
00412     h1_occupancyVsEtaSilver_->Fill(myEta);
00413   
00414   cout<< "[ZeePlots::fillEleClassesPlots]Done"<< std::endl;
00415   
00416 }
00417 
00418 
00419 void ZeePlots::bookEleClassesPlots(){
00420 
00421   file_->cd();
00422 
00423   h1_occupancyVsEtaGold_ = new TH1F("occupancyVsEtaGold","occupancyVsEtaGold", 200, -4.,4.);
00424   h1_occupancyVsEtaGold_->SetYTitle("Electron statistics");
00425   h1_occupancyVsEtaGold_->SetXTitle("Eta channel");
00426 
00427   h1_occupancyVsEtaSilver_ = new TH1F("occupancyVsEtaSilver","occupancyVsEtaSilver", 200, -4.,4.);
00428   h1_occupancyVsEtaSilver_->SetYTitle("Electron statistics");
00429   h1_occupancyVsEtaSilver_->SetXTitle("Eta channel");
00430 
00431   h1_occupancyVsEtaShower_ = new TH1F("occupancyVsEtaShower","occupancyVsEtaShower", 200, -4.,4.);
00432   h1_occupancyVsEtaShower_->SetYTitle("Electron statistics");
00433   h1_occupancyVsEtaShower_->SetXTitle("Eta channel");
00434 
00435   h1_occupancyVsEtaCrack_ = new TH1F("occupancyVsEtaCrack","occupancyVsEtaCrack", 200, -4.,4.);
00436   h1_occupancyVsEtaCrack_->SetYTitle("Electron statistics");
00437   h1_occupancyVsEtaCrack_->SetXTitle("Eta channel");
00438 
00439 }
00440 
00441 void ZeePlots::writeEleClassesPlots(){
00442 
00443   file_->cd();
00444 
00445   h1_occupancyVsEtaGold_->Write();
00446   h1_occupancyVsEtaSilver_->Write();
00447   h1_occupancyVsEtaShower_->Write();
00448   h1_occupancyVsEtaCrack_->Write();
00449 
00450 }

Generated on Tue Jun 9 17:25:32 2009 for CMSSW by  doxygen 1.5.4