CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/DQMOffline/Ecal/src/EcalZmassClient.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    ZfitterAnalyzer
00004 // Class:      ZfitterAnalyzer
00005 // 
00013 //
00014 // Original Author:  Vieri Candelise
00015 //         Created:  Mon Jun 13 09:49:08 CEST 2011
00016 // $Id: EcalZmassClient.cc,v 1.1 2011/07/25 14:34:56 vieri Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 
00024 // user include files
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDAnalyzer.h"
00027 #include "FWCore/ServiceRegistry/interface/Service.h"
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030 #include "DQM/Physics/src/EwkDQM.h"
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032 #include "TMath.h"
00033 #include <string>
00034 #include <cmath>
00035 #include "TH1.h"
00036 #include "DQMServices/Core/interface/DQMStore.h"
00037 #include "DQMServices/Core/interface/MonitorElement.h"
00038 #include "FWCore/Framework/interface/MakerMacros.h"
00039 #include "FWCore/Framework/interface/EventSetup.h"
00040 #include <iostream>
00041 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00042 
00043 using namespace std;
00044 using namespace edm;
00045 using namespace reco;
00046 
00047 class DQMStore;
00048 class MonitorElement;
00049 
00050 
00051 //
00052 // class declaration
00053 //
00054 
00055 class EcalZmassClient:public
00056   edm::EDAnalyzer
00057 {
00058 public:
00059   explicit
00060   EcalZmassClient (const edm::ParameterSet &);
00061    ~
00062   EcalZmassClient ();
00063 
00064   static void
00065   fillDescriptions (edm::ConfigurationDescriptions & descriptions);
00066 
00067 
00068 private:
00069   virtual void
00070   beginJob ();
00071   virtual void
00072   analyze (const edm::Event &, const edm::EventSetup &);
00073   virtual void
00074   endJob ();
00075 
00076   virtual void
00077   beginRun (edm::Run const &, edm::EventSetup const &);
00078   virtual void
00079   endRun (edm::Run const &, edm::EventSetup const &);
00080   virtual void
00081   beginLuminosityBlock (edm::LuminosityBlock const &,
00082                         edm::EventSetup const &);
00083   virtual void
00084   endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &);
00085 
00086   // ----------member data ---------------------------
00087 
00088   std::string
00089     prefixME_;
00090 
00091   MonitorElement *
00092     h_ee_invMass_EB;
00093   MonitorElement *
00094     h_ee_invMass_EE;
00095   MonitorElement *
00096     h_ee_invMass_BB;
00097   MonitorElement *
00098     h_95_ee_invMass_EB;
00099   MonitorElement *
00100     h_95_ee_invMass_EE;
00101   MonitorElement *
00102     h_95_ee_invMass_BB;
00103   MonitorElement *
00104     h_ee_invMass;
00105   MonitorElement *
00106     h_e1_et;
00107   MonitorElement *
00108     h_e2_et;
00109   MonitorElement *
00110     h_e1_eta;
00111   MonitorElement *
00112     h_e2_eta;
00113   MonitorElement *
00114     h_e1_phi;
00115   MonitorElement *
00116     h_e2_phi;
00117   MonitorElement *
00118     h_fitres1;
00119   MonitorElement *
00120     h_fitres1bis;
00121   MonitorElement *
00122     h_fitres1Chi2;
00123   MonitorElement *
00124     h_fitres2;
00125   MonitorElement *
00126     h_fitres2bis;
00127   MonitorElement *
00128     h_fitres2Chi2;
00129   MonitorElement *
00130     h_fitres3;
00131   MonitorElement *
00132     h_fitres3bis;
00133   MonitorElement *
00134     h_fitres3Chi2;
00135 
00136 
00137 };
00138 
00139 //
00140 // constants, enums and typedefs
00141 //
00142 
00143 //
00144 // static data member definitions
00145 //
00146 
00147 //
00148 // constructors and destructor
00149 //
00150 
00151 
00152 
00153 EcalZmassClient::EcalZmassClient (const edm::ParameterSet & iConfig)
00154 {
00155   prefixME_ = iConfig.getUntrackedParameter < string > ("prefixME", "");
00156 
00157 }
00158 
00159 
00160 EcalZmassClient::~EcalZmassClient ()
00161 {
00162 
00163   // do anything here that needs to be done at desctruction time
00164   // (e.g. close files, deallocate resources etc.)
00165 
00166 }
00167 
00168 
00169 //
00170 // member functions
00171 //
00172 
00173 // ------------ method called for each event  ------------
00174 void
00175 EcalZmassClient::analyze (const edm::Event & iEvent,
00176                           const edm::EventSetup & iSetup)
00177 {
00178   using namespace edm;
00179 
00180 
00181 
00182 #ifdef THIS_IS_AN_EVENT_EXAMPLE
00183   Handle < ExampleData > pIn;
00184   iEvent.getByLabel ("example", pIn);
00185 #endif
00186 
00187 #ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
00188   ESHandle < SetupData > pSetup;
00189   iSetup.get < SetupRecord > ().get (pSetup);
00190 #endif
00191 }
00192 
00193 
00194 // ------------ method called once each job just before starting event loop  ------------
00195 void
00196 EcalZmassClient::beginJob ()
00197 {
00198 }
00199 
00200 // ------------ method called once each job just after ending the event loop  ------------
00201 void
00202 EcalZmassClient::endJob ()
00203 {
00204 }
00205 
00206 // ------------ method called when starting to processes a run  ------------
00207 void
00208 EcalZmassClient::beginRun (edm::Run const &, edm::EventSetup const &)
00209 {
00210   DQMStore *theDbe = Service < DQMStore > ().operator-> ();
00211 
00212   theDbe->setCurrentFolder (prefixME_ + "/Zmass");
00213   h_fitres1 =
00214     theDbe->book1D ("Gaussian mean WP80 EB-EB",
00215                     "Gaussian mean WP80 EB-EB", 1, 0, 1);
00216   h_fitres1bis =
00217     theDbe->book1D ("Gaussian sigma WP80 EB-EB",
00218                     "Gaussian sigma WP80 EB-EB", 1, 0, 1);
00219   h_fitres1Chi2 =
00220     theDbe->book1D ("Gaussian Chi2 result over NDF  WP80 EB-EB",
00221                     "Gaussian Chi2 result over NDF  WP80 EB-EB", 1, 0, 1);
00222 
00223   h_fitres3 =
00224     theDbe->book1D ("Gaussian mean WP80 EB-EE",
00225                     "Gaussian mean result WP80 EB-EE", 1, 0, 1);
00226   h_fitres3bis =
00227     theDbe->book1D ("Gaussian sigma WP80 EB-EE",
00228                     "Gaussian sigma WP80 EB-EE", 1, 0, 1);
00229   h_fitres3Chi2 =
00230     theDbe->book1D ("Gaussian Chi2 result over NDF WP80 EB-EE",
00231                     "Gaussian Chi2 result over NDF WP80 EB-EE", 1, 0, 1);
00232 
00233   h_fitres2 =
00234     theDbe->book1D ("Gaussian mean WP80 EE-EE",
00235                     "Gaussian mean WP80 EE-EE", 1, 0, 1);
00236   h_fitres2bis =
00237     theDbe->book1D ("Gaussian sigma WP80 EE-EE",
00238                     "Gaussian sigma WP80 EE-EE", 1, 0, 1);
00239   h_fitres2Chi2 =
00240     theDbe->book1D ("Gaussian Chi2 result over NDF WP80 EE-EE",
00241                     "Gaussian Chi2 result over NDF WP80 EE-EE", 1, 0, 1);
00242 
00243   /*
00244      h_95_fitres1 =
00245      theDbe->book1D ("Breit-Wigner mean WP95 EB-EB",
00246      "Breit-Wigner mean WP95 EB-EB", 1, 0, 1);
00247      h_95_fitres1bis =
00248      theDbe->book1D ("Breit-Wigner sigma WP95 EB-EB",
00249      "Breit-Wigner sigma WP95 EB-EB", 1, 0, 1);
00250 
00251      h_95_fitres3 =
00252      theDbe->book1D ("Breit-Wigner  mean WP95 EB-EE",
00253      "Breit-Wigner  mean WP95 EB-EE", 1, 0, 1);
00254      h_95_fitres3bis =
00255      theDbe->book1D ("Breit-Wigner  sigma WP95 EB-EE",
00256      "Breit-Wigner  sigma WP95 EB-EE", 1, 0, 1);
00257 
00258      h_95_fitres2 =
00259      theDbe->book1D ("Gaussian mean WP95 EE-EE",
00260      "Gaussian mean WP95 EE-EE", 1, 0, 1);
00261      h_95_fitres2bis =
00262      theDbe->book1D ("Gaussian sigma WP95 EE-EE",
00263      "Gaussian sigma WP95 EE-EE", 1, 0, 1);
00264    */
00265 
00266 }
00267 
00268 
00269 //Breit-Wigner function
00270 Double_t
00271 mybw (Double_t * x, Double_t * par)
00272 {
00273   Double_t arg1 = 14.0 / 22.0;  // 2 over pi
00274   Double_t arg2 = par[1] * par[1] * par[2] * par[2];    //Gamma=par[2]  M=par[1]
00275   Double_t arg3 =
00276     ((x[0] * x[0]) - (par[1] * par[1])) * ((x[0] * x[0]) - (par[1] * par[1]));
00277   Double_t arg4 =
00278     x[0] * x[0] * x[0] * x[0] * ((par[2] * par[2]) / (par[1] * par[1]));
00279   return par[0] * arg1 * arg2 / (arg3 + arg4);
00280 }
00281 
00282 //Gaussian
00283 Double_t
00284 mygauss (Double_t * x, Double_t * par)
00285 {
00286   Double_t arg = 0;
00287   if (par[2] < 0)
00288     par[2] = -par[2];           // par[2]: sigma
00289   if (par[2] != 0)
00290     arg = (x[0] - par[1]) / par[2];     // par[1]: mean
00291   return par[0] * TMath::Exp (-0.5 * arg * arg) / (TMath::Sqrt (2 * TMath::Pi ()) * par[2]);    // par[0] is constant
00292 
00293 }
00294 
00295 
00296 
00297 // ------------ method called when ending the processing of a run  ------------
00298 void
00299 EcalZmassClient::endRun (edm::Run const &, edm::EventSetup const &)
00300 {
00301   DQMStore *theDbe = Service < DQMStore > ().operator-> ();
00302   std::string logTraceName;
00303   logTraceName = "EwkAnalyzer";
00304 
00305   LogTrace (logTraceName) << "Parameters initialization";
00306 
00307   MonitorElement *me1 = theDbe->get (prefixME_ + "/Zmass/Z peak - WP80 EB-EB");
00308   MonitorElement *me2 = theDbe->get (prefixME_ + "/Zmass/Z peak - WP80 EE-EE");
00309   MonitorElement *me3 = theDbe->get (prefixME_ + "/Zmass/Z peak - WP80 EB-EE");
00310 
00311 
00312   if (me1 != 0)
00313     {
00314       TH1F *B = me1->getTH1F ();
00315       TH1F *R1 = h_fitres1->getTH1F ();
00316       int division = B->GetNbinsX ();
00317       float massMIN = B->GetBinLowEdge (1);
00318       float massMAX = B->GetBinLowEdge (division + 1);
00319       //float BIN_SIZE = B->GetBinWidth(1);
00320 
00321       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00322       func->SetParameter (0, 1.0);
00323       func->SetParName (0, "const");
00324       func->SetParameter (1, 95.0);
00325       func->SetParName (1, "mean");
00326       func->SetParameter (2, 5.0);
00327       func->SetParName (2, "sigma");
00328 
00329       double stats[4];
00330       R1->GetStats (stats);
00331       float N = 0;
00332       float mean = 0;
00333       float sigma = 0;
00334       N = B->GetEntries ();
00335 
00336       try
00337       {
00338         if (N != 0)
00339           {
00340 
00341             B->Fit ("mygauss", "QR");
00342             mean = fabs (func->GetParameter (1));
00343             sigma = fabs (func->GetParError (1));
00344           }
00345 
00346         if (N == 0 || mean < 50 || mean > 100 || sigma <= 0 || sigma > 20)
00347           {
00348             N = 1;
00349             mean = 0;
00350             sigma = 0;
00351           }
00352 
00353       }
00354       catch (...)
00355       {
00356         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00357         N = 1;
00358         mean = 40;
00359         sigma = 0;
00360       }
00361 
00362       stats[0] = N;
00363       stats[1] = N;
00364       stats[2] = mean * N;
00365       stats[3] = sigma * sigma * N + mean * mean * N;
00366 
00367       R1->SetEntries (N);
00368       R1->PutStats (stats);
00369     }
00370 /*******************************************************/
00371   if (me1 != 0)
00372     {
00373       TH1F *Bbis = me1->getTH1F ();
00374       TH1F *R1bis = h_fitres1bis->getTH1F ();
00375       int division = Bbis->GetNbinsX ();
00376       float massMIN = Bbis->GetBinLowEdge (1);
00377       float massMAX = Bbis->GetBinLowEdge (division + 1);
00378       //float BIN_SIZE = B->GetBinWidth(1);
00379 
00380       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00381       func->SetParameter (0, 1.0);
00382       func->SetParName (0, "const");
00383       func->SetParameter (1, 95.0);
00384       func->SetParName (1, "mean");
00385       func->SetParameter (2, 5.0);
00386       func->SetParName (2, "sigma");
00387 
00388       double stats[4];
00389       R1bis->GetStats (stats);
00390       float N = 0;
00391       float rms = 0;
00392       float rmsErr = 0;
00393       N = Bbis->GetEntries ();
00394 
00395       try
00396       {
00397         if (N != 0)
00398           {
00399 
00400             Bbis->Fit ("mygauss", "QR");
00401             rms = fabs (func->GetParameter (2));
00402             rmsErr = fabs (func->GetParError (2));
00403           }
00404 
00405         if (N == 0 || rms < 0 || rms > 50 || rmsErr <= 0 || rmsErr > 50)
00406           {
00407             N = 1;
00408             rms = 0;
00409             rmsErr = 0;
00410           }
00411 
00412       }
00413       catch (...)
00414       {
00415         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00416         N = 1;
00417         rms = 40;
00418         rmsErr = 0;
00419       }
00420 
00421       stats[0] = N;
00422       stats[1] = N;
00423       stats[2] = rms * N;
00424       stats[3] = rmsErr * rmsErr * N + rms * rms * N;
00425 
00426       R1bis->SetEntries (N);
00427       R1bis->PutStats (stats);
00428     }
00429 /****************************************/
00430 
00431   if (me2 != 0)
00432     {
00433       TH1F *E = me2->getTH1F ();
00434       TH1F *R2 = h_fitres2->getTH1F ();
00435       int division = E->GetNbinsX ();
00436       float massMIN = E->GetBinLowEdge (1);
00437       float massMAX = E->GetBinLowEdge (division + 1);
00438       //float BIN_SIZE = E->GetBinWidth(1);
00439 
00440       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00441       func->SetParameter (0, 1.0);
00442       func->SetParName (0, "const");
00443       func->SetParameter (1, 95.0);
00444       func->SetParName (1, "mean");
00445       func->SetParameter (2, 5.0);
00446       func->SetParName (2, "sigma");
00447 
00448       double stats[4];
00449       R2->GetStats (stats);
00450       float N = 0;
00451       float mean = 0;
00452       float sigma = 0;
00453       N = E->GetEntries ();
00454 
00455       try
00456       {
00457         if (N != 0)
00458           {
00459             E->Fit ("mygauss", "QR");
00460             mean = fabs (func->GetParameter (1));
00461             sigma = fabs (func->GetParError (1));
00462           }
00463 
00464         if (N == 0 || mean < 50 || mean > 100 || sigma <= 0 || sigma > 20)
00465           {
00466             N = 1;
00467             mean = 0;
00468             sigma = 0;
00469 
00470           }
00471 
00472       }
00473       catch (...)
00474       {
00475         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00476         N = 1;
00477         mean = 40;
00478         sigma = 0;
00479       }
00480 
00481       stats[0] = N;
00482       stats[1] = N;
00483       stats[2] = mean * N;
00484       stats[3] = sigma * sigma * N + mean * mean * N;
00485 
00486       R2->SetEntries (N);
00487       R2->PutStats (stats);
00488     }
00489 /**************************************************************************/
00490 
00491   if (me2 != 0)
00492     {
00493       TH1F *Ebis = me2->getTH1F ();
00494       TH1F *R2bis = h_fitres2bis->getTH1F ();
00495       int division = Ebis->GetNbinsX ();
00496       float massMIN = Ebis->GetBinLowEdge (1);
00497       float massMAX = Ebis->GetBinLowEdge (division + 1);
00498       //float BIN_SIZE = B->GetBinWidth(1);
00499 
00500       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00501       func->SetParameter (0, 1.0);
00502       func->SetParName (0, "const");
00503       func->SetParameter (1, 95.0);
00504       func->SetParName (1, "mean");
00505       func->SetParameter (2, 5.0);
00506       func->SetParName (2, "sigma");
00507 
00508       double stats[4];
00509       R2bis->GetStats (stats);
00510       float N = 0;
00511       float rms = 0;
00512       float rmsErr = 0;
00513       N = Ebis->GetEntries ();
00514 
00515       try
00516       {
00517         if (N != 0)
00518           {
00519 
00520             Ebis->Fit ("mygauss", "QR");
00521             rms = fabs (func->GetParameter (2));
00522             rmsErr = fabs (func->GetParError (2));
00523           }
00524 
00525         if (N == 0 || rms < 0 || rms > 50 || rmsErr <= 0 || rmsErr > 50)
00526           {
00527             N = 1;
00528             rms = 0;
00529             rmsErr = 0;
00530           }
00531 
00532       }
00533       catch (...)
00534       {
00535         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00536         N = 1;
00537         rms = 40;
00538         rmsErr = 0;
00539       }
00540 
00541       stats[0] = N;
00542       stats[1] = N;
00543       stats[2] = rms * N;
00544       stats[3] = rmsErr * rmsErr * N + rms * rms * N;
00545 
00546       R2bis->SetEntries (N);
00547       R2bis->PutStats (stats);
00548     }
00549 /*********************************************************************************************/
00550 
00551   if (me3 != 0)
00552     {
00553       TH1F *R3 = h_fitres3->getTH1F ();
00554       TH1F *M = me3->getTH1F ();
00555       int division = M->GetNbinsX ();
00556       float massMIN = M->GetBinLowEdge (1);
00557       float massMAX = M->GetBinLowEdge (division + 1);
00558       //float BIN_SIZE = M->GetBinWidth(1);
00559 
00560       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00561       func->SetParameter (0, 1.0);
00562       func->SetParName (0, "const");
00563       func->SetParameter (1, 95.0);
00564       func->SetParName (1, "mean");
00565       func->SetParameter (2, 5.0);
00566       func->SetParName (2, "sigma");
00567 
00568       double stats[4];
00569       R3->GetStats (stats);
00570       float N = 0;
00571       float mean = 0;
00572       float sigma = 0;
00573       N = M->GetEntries ();
00574 
00575 
00576       try
00577       {
00578         if (N != 0)
00579           {
00580 
00581             M->Fit ("mygauss", "QR");
00582             mean = fabs (func->GetParameter (1));
00583             sigma = fabs (func->GetParError (1));
00584           }
00585         if (N == 0 || mean < 50 || mean > 100 || sigma <= 0 || sigma > 20)
00586           {
00587             N = 1;
00588             mean = 0;
00589             sigma = 0;
00590           }
00591 
00592       }
00593       catch (...)
00594       {
00595         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00596         N = 1;
00597         mean = 40;
00598         sigma = 0;
00599       }
00600 
00601       stats[0] = N;
00602       stats[1] = N;
00603       stats[2] = mean * N;
00604       stats[3] = sigma * sigma * N + mean * mean * N;
00605 
00606       R3->SetEntries (N);
00607       R3->PutStats (stats);
00608     }
00609   /********************************************************************************/
00610 
00611   if (me3 != 0)
00612     {
00613       TH1F *Mbis = me3->getTH1F ();
00614       TH1F *R3bis = h_fitres3bis->getTH1F ();
00615       int division = Mbis->GetNbinsX ();
00616       float massMIN = Mbis->GetBinLowEdge (1);
00617       float massMAX = Mbis->GetBinLowEdge (division + 1);
00618       //float BIN_SIZE = B->GetBinWidth(1);
00619 
00620       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00621       func->SetParameter (0, 1.0);
00622       func->SetParName (0, "const");
00623       func->SetParameter (1, 95.0);
00624       func->SetParName (1, "mean");
00625       func->SetParameter (2, 5.0);
00626       func->SetParName (2, "sigma");
00627 
00628       double stats[4];
00629       R3bis->GetStats (stats);
00630       float N = 0;
00631       float rms = 0;
00632       float rmsErr = 0;
00633       N = Mbis->GetEntries ();
00634 
00635       try
00636       {
00637         if (N != 0)
00638           {
00639 
00640             Mbis->Fit ("mygauss", "QR");
00641             rms = fabs (func->GetParameter (2));
00642             rmsErr = fabs (func->GetParError (2));
00643           }
00644 
00645         if (N == 0 || rms < 0 || rms > 50 || rmsErr <= 0 || rmsErr > 50)
00646           {
00647             N = 1;
00648             rms = 0;
00649             rmsErr = 0;
00650           }
00651 
00652       }
00653       catch (...)
00654       {
00655         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00656         N = 1;
00657         rms = 40;
00658         rmsErr = 0;
00659       }
00660 
00661       stats[0] = N;
00662       stats[1] = N;
00663       stats[2] = rms * N;
00664       stats[3] = rmsErr * rmsErr * N + rms * rms * N;
00665 
00666       R3bis->SetEntries (N);
00667       R3bis->PutStats (stats);
00668     }
00669 
00670   /* WP95 DO NOT USE IT ******************************************************************************************************************************
00671 
00672 
00673      MonitorElement *me4 = theDbe->get ("Physics/EwkDQM/Z peak - WP95 EB-EB");
00674      MonitorElement *me5 = theDbe->get ("Physics/EwkDQM/Z peak - WP95 EE-EE");
00675      MonitorElement *me6 = theDbe->get ("Physics/EwkDQM/Z peak - WP95 EB-EE");
00676 
00677 
00678      if (me4 != 0) {
00679      TH1F *B_95 = me4->getTH1F ();
00680      TH1F *R1_95 = h_95_fitres1->getTH1F ();
00681      int division = B_95->GetNbinsX ();
00682      float massMIN = B_95->GetBinLowEdge (1);
00683      float massMAX = B_95->GetBinLowEdge (division + 1);
00684      //float BIN_SIZE = B->GetBinWidth(1);
00685 
00686      TF1 *func = new TF1 ("mybw", mybw, massMIN, massMAX, 3);
00687      func->SetParameter (0, 1.0);
00688      func->SetParName (0, "const");
00689      func->SetParameter (1, 95.0);
00690      func->SetParName (1, "mean");
00691      func->SetParameter (2, 5.0);
00692      func->SetParName (2, "sigma");
00693 
00694      double stats[4];
00695      R1_95->GetStats (stats);
00696      float N = 0;
00697      float mean = 0;
00698      float sigma = 0;
00699      N = B_95->GetEntries ();
00700 
00701      try {
00702      if (N != 0) {
00703 
00704      B_95->Fit ("mybw", "QR");
00705      mean = fabs (func->GetParameter (1));
00706      sigma = fabs (func->GetParError (1));
00707      }
00708 
00709      if (N == 0 || mean < 50 || mean > 100 || sigma <= 0 || sigma > 20) {
00710      N = 1;
00711      mean = 50;
00712      sigma = 0;
00713      }
00714 
00715      }
00716      catch (...) {
00717      edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00718      N = 1;
00719      mean = 40;
00720      sigma = 0;
00721      }
00722 
00723      stats[0] = N;
00724      stats[1] = N;
00725      stats[2] = mean * N;
00726      stats[3] = sigma * sigma * N + mean * mean * N;
00727 
00728      R1_95->SetEntries (N);
00729      R1_95->PutStats (stats);
00730 
00731      }
00732      ***************************************************************************
00733      if (me4 != 0) {
00734      TH1F *B_95bis = me4->getTH1F ();
00735      TH1F *R1_95bis = h_95_fitres1bis->getTH1F ();
00736      int division = B_95bis->GetNbinsX ();
00737      float massMIN = B_95bis->GetBinLowEdge (1);
00738      float massMAX = B_95bis->GetBinLowEdge (division + 1);
00739      //float BIN_SIZE = B->GetBinWidth(1);
00740 
00741      TF1 *func = new TF1 ("mybw", mybw, massMIN, massMAX, 3);
00742      func->SetParameter (0, 1.0);
00743      func->SetParName (0, "const");
00744      func->SetParameter (1, 95.0);
00745      func->SetParName (1, "mean");
00746      func->SetParameter (2, 5.0);
00747      func->SetParName (2, "sigma");
00748 
00749      double stats[4];
00750      R1_95bis->GetStats (stats);
00751      float N = 0;
00752      float rms = 0;
00753      float rmsErr = 0;
00754      N = B_95bis->GetEntries ();
00755 
00756      try {
00757      if (N != 0) {
00758 
00759      B_95bis->Fit ("mybw", "QR");
00760      rms = fabs (func->GetParameter (2));
00761      rmsErr = fabs (func->GetParError (2));
00762      }
00763 
00764      if (N == 0 || rms < 0 || rms > 50 || rmsErr <= 0 || rmsErr > 50) {
00765      N = 1;
00766      rms = 50;
00767      rmsErr = 0;
00768      }
00769 
00770      }
00771      catch (...) {
00772      edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00773      N = 1;
00774      rms = 40;
00775      rmsErr = 0;
00776      }
00777 
00778      stats[0] = N;
00779      stats[1] = N;
00780      stats[2] = rms * N;
00781      stats[3] = rmsErr * rmsErr * N + rms * rms * N;
00782 
00783      R1_95bis->SetEntries (N);
00784      R1_95bis->PutStats (stats);
00785      }
00786      ***************************************************************
00787 
00788      if (me5 != 0) {
00789      TH1F *E_95 = me5->getTH1F ();
00790      TH1F *R2_95 = h_95_fitres2->getTH1F ();
00791      int division = E_95->GetNbinsX ();
00792      float massMIN = E_95->GetBinLowEdge (1);
00793      float massMAX = E_95->GetBinLowEdge (division + 1);
00794      //float BIN_SIZE = E->GetBinWidth(1);
00795 
00796      TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00797      func->SetParameter (0, 1.0);
00798      func->SetParName (0, "const");
00799      func->SetParameter (1, 95.0);
00800      func->SetParName (1, "mean");
00801      func->SetParameter (2, 5.0);
00802      func->SetParName (2, "sigma");
00803 
00804      double stats[4];
00805      R2_95->GetStats (stats);
00806      float N = 0;
00807      float mean = 0;
00808      float sigma = 0;
00809      N = E_95->GetEntries ();
00810 
00811      try {
00812      if (N != 0) {
00813 
00814      E_95->Fit ("mygauss", "QR");
00815      mean  =  fabs(func->GetParameter (1));
00816      sigma =  fabs(func->GetParError  (1));
00817      }
00818 
00819      if (N == 0 || mean < 50 || mean > 100 || sigma <= 0 || sigma > 20) {
00820      N = 1;
00821      mean = 50;
00822      sigma = 0;
00823      }
00824 
00825      }
00826      catch (...) {
00827      edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00828      N = 1;
00829      mean = 40;
00830      sigma = 0;
00831      }
00832 
00833      stats[0] = N;
00834      stats[1] = N;
00835      stats[2] = mean * N;
00836      stats[3] = sigma * sigma * N + mean * mean * N;
00837 
00838      R2_95->SetEntries (N);
00839      R2_95->PutStats (stats);
00840 
00841      }
00842      *******************************************************************
00843      if (me5 != 0) {
00844      TH1F *E_95bis = me5->getTH1F ();
00845      TH1F *R2_95bis = h_95_fitres2bis->getTH1F ();
00846      int division = E_95bis->GetNbinsX ();
00847      float massMIN = E_95bis->GetBinLowEdge (1);
00848      float massMAX = E_95bis->GetBinLowEdge (division + 1);
00849      //float BIN_SIZE = B->GetBinWidth(1);
00850 
00851      TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00852      func->SetParameter (0, 1.0);
00853      func->SetParName (0, "const");
00854      func->SetParameter (1, 95.0);
00855      func->SetParName (1, "mean");
00856      func->SetParameter (2, 5.0);
00857      func->SetParName (2, "sigma");
00858 
00859      double stats[4];
00860      R2_95bis->GetStats (stats);
00861      float N = 0;
00862      float rms = 0;
00863      float rmsErr = 0;
00864      N = E_95bis->GetEntries ();
00865 
00866      try {
00867      if (N != 0) {
00868 
00869      E_95bis->Fit ("mygauss", "QR");
00870      rms = fabs (func->GetParameter (2));
00871      rmsErr = fabs (func->GetParError (2));
00872      }
00873 
00874      if (N == 0 || rms < 0 || rms > 50 || rmsErr <= 0 || rmsErr > 50) {
00875      N = 1;
00876      rms = 50;
00877      rmsErr = 0;
00878      }
00879 
00880      }
00881      catch (...) {
00882      edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00883      N = 1;
00884      rms = 40;
00885      rmsErr = 0;
00886      }
00887 
00888      stats[0] = N;
00889      stats[1] = N;
00890      stats[2] = rms * N;
00891      stats[3] = rmsErr * rmsErr * N + rms * rms * N;
00892 
00893      R2_95bis->SetEntries (N);
00894      R2_95bis->PutStats (stats);
00895      }
00896      ****************************************************************************************
00897 
00898      if (me6 != 0) {
00899      TH1F *R3_95 = h_95_fitres3->getTH1F ();
00900      TH1F *M_95 = me6->getTH1F ();
00901      int division = M_95->GetNbinsX ();
00902      float massMIN = M_95->GetBinLowEdge (1);
00903      float massMAX = M_95->GetBinLowEdge (division + 1);
00904      //float BIN_SIZE = M->GetBinWidth(1);
00905 
00906      TF1 *func = new TF1 ("mybw", mybw, massMIN, massMAX, 3);
00907      func->SetParameter (0, 1.0);
00908      func->SetParName (0, "const");
00909      func->SetParameter (1, 95.0);
00910      func->SetParName (1, "mean");
00911      func->SetParameter (2, 5.0);
00912      func->SetParName (2, "sigma");
00913 
00914      double stats[4];
00915      R3_95->GetStats (stats);
00916      float N = 0;
00917      float mean = 0;
00918      float sigma = 0;
00919      N = M_95->GetEntries ();
00920 
00921 
00922      try {
00923      if (N != 0) {
00924 
00925      M_95->Fit ("mybw", "QR");
00926      mean = fabs (func->GetParameter (1));
00927      sigma = fabs (func->GetParError (1));
00928      }
00929 
00930      if (N == 0 || mean < 50 || mean > 100 || sigma <= 0 || sigma > 20) {
00931      N = 1;
00932      mean = 50;
00933      sigma = 0;
00934      }
00935 
00936      stats[0] = N;
00937      stats[1] = N;
00938      stats[2] = mean * N;
00939      stats[3] = sigma * sigma * N + mean * mean * N;
00940 
00941      R3_95->SetEntries (N);
00942      R3_95->PutStats (stats);
00943 
00944      }
00945      catch (...) {
00946      edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00947      N = 1;
00948      mean = 40;
00949      sigma = 0;
00950      }
00951      stats[0] = N;
00952      stats[1] = N;
00953      stats[2] = mean * N;
00954      stats[3] = sigma * sigma * N + mean * mean * N;
00955 
00956      R3_95->SetEntries (N);
00957      R3_95->PutStats (stats);
00958 
00959      }
00960      ***********************************************************
00961      if (me6 != 0) {
00962      TH1F *M_95bis = me6->getTH1F ();
00963      TH1F *R3_95bis = h_95_fitres3bis->getTH1F ();
00964      int division = M_95bis->GetNbinsX ();
00965      float massMIN = M_95bis->GetBinLowEdge (1);
00966      float massMAX = M_95bis->GetBinLowEdge (division + 1);
00967      //float BIN_SIZE = B->GetBinWidth(1);
00968 
00969      TF1 *func = new TF1 ("mybw", mybw, massMIN, massMAX, 3);
00970      func->SetParameter (0, 1.0);
00971      func->SetParName (0, "const");
00972      func->SetParameter (1, 95.0);
00973      func->SetParName (1, "mean");
00974      func->SetParameter (2, 5.0);
00975      func->SetParName (2, "sigma");
00976 
00977      double stats[4];
00978      R3_95bis->GetStats (stats);
00979      float N = 0;
00980      float rms = 0;
00981      float rmsErr = 0;
00982      N = M_95bis->GetEntries ();
00983 
00984      try {
00985      if (N != 0) {
00986 
00987      M_95bis->Fit ("mybw", "QR");
00988      rms = fabs (func->GetParameter (2));
00989      rmsErr = fabs (func->GetParError (2));
00990      }
00991 
00992      if (N == 0 || rms <= 0 || rms > 50 || rmsErr <= 0 || rmsErr > 100) {
00993      N = 1;
00994      rms = 50;
00995      rmsErr = 0;
00996      }
00997 
00998      }
00999      catch (...) {
01000      edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
01001      N = 1;
01002      rms = 40;
01003      rmsErr = 0;
01004      }
01005 
01006      stats[0] = N;
01007      stats[1] = N;
01008      stats[2] = rms * N;
01009      stats[3] = rmsErr * rmsErr * N + rms * rms * N;
01010 
01011      R3_95bis->SetEntries (N);
01012      R3_95bis->PutStats (stats);
01013      }******************************************************************************* */
01014 
01015   /*Chi2 */
01016 
01017   if (me1 != 0)
01018     {
01019       TH1F *C1 = me1->getTH1F ();
01020       TH1F *S1 = h_fitres1Chi2->getTH1F ();
01021       int division = C1->GetNbinsX ();
01022       float massMIN = C1->GetBinLowEdge (1);
01023       float massMAX = C1->GetBinLowEdge (division + 1);
01024       //float BIN_SIZE = B->GetBinWidth(1);
01025 
01026       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
01027       func->SetParameter (0, 1.0);
01028       func->SetParName (0, "const");
01029       func->SetParameter (1, 95.0);
01030       func->SetParName (1, "mean");
01031       func->SetParameter (2, 5.0);
01032       func->SetParName (2, "sigma");
01033 
01034       double stats[4];
01035       S1->GetStats (stats);
01036       float N = 0;
01037       float Chi2 = 0;
01038       float NDF = 0;
01039       N = C1->GetEntries ();
01040 
01041       try
01042       {
01043         if (N != 0)
01044           {
01045 
01046             C1->Fit ("mygauss", "QR");
01047             if ((func->GetNDF () != 0))
01048               {
01049                 Chi2 = fabs (func->GetChisquare ()) / fabs (func->GetNDF ());
01050                 NDF = 0.1;
01051               }
01052           }
01053 
01054         if (N == 0 || Chi2 < 0 || NDF < 0)
01055           {
01056             N = 1;
01057             Chi2 = 0;
01058             NDF = 0;
01059           }
01060 
01061       }
01062       catch (...)
01063       {
01064         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
01065         N = 1;
01066         Chi2 = 40;
01067         NDF = 0;
01068       }
01069 
01070       stats[0] = N;
01071       stats[1] = N;
01072       stats[2] = Chi2 * N;
01073       stats[3] = NDF * NDF * N + Chi2 * Chi2 * N;
01074 
01075       S1->SetEntries (N);
01076       S1->PutStats (stats);
01077     }
01078   /**********************************************/
01079 
01080   if (me2 != 0)
01081     {
01082       TH1F *C2 = me2->getTH1F ();
01083       TH1F *S2 = h_fitres2Chi2->getTH1F ();
01084       int division = C2->GetNbinsX ();
01085       float massMIN = C2->GetBinLowEdge (1);
01086       float massMAX = C2->GetBinLowEdge (division + 1);
01087       //float BIN_SIZE = B->GetBinWidth(1);
01088 
01089       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
01090       func->SetParameter (0, 1.0);
01091       func->SetParName (0, "const");
01092       func->SetParameter (1, 95.0);
01093       func->SetParName (1, "mean");
01094       func->SetParameter (2, 5.0);
01095       func->SetParName (2, "sigma");
01096 
01097       double stats[4];
01098       S2->GetStats (stats);
01099       float N = 0;
01100       float Chi2 = 0;
01101       float NDF = 0;
01102       N = C2->GetEntries ();
01103 
01104       try
01105       {
01106         if (N != 0)
01107           {
01108             C2->Fit ("mygauss", "QR");
01109             if (func->GetNDF () != 0)
01110               {
01111                 Chi2 = fabs (func->GetChisquare ()) / fabs (func->GetNDF ());
01112                 NDF = 0.1;
01113               }
01114           }
01115 
01116         if (N == 0 || Chi2 < 0 || NDF < 0)
01117           {
01118             N = 1;
01119             Chi2 = 0;
01120             NDF = 0;
01121           }
01122 
01123       }
01124       catch (...)
01125       {
01126         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
01127         N = 1;
01128         Chi2 = 40;
01129         NDF = 0;
01130       }
01131 
01132       stats[0] = N;
01133       stats[1] = N;
01134       stats[2] = Chi2 * N;
01135       stats[3] = NDF * NDF * N + Chi2 * Chi2 * N;
01136 
01137       S2->SetEntries (N);
01138       S2->PutStats (stats);
01139     }
01140   /**************************************************************************/
01141   if (me3 != 0)
01142     {
01143       TH1F *C3 = me3->getTH1F ();
01144       TH1F *S3 = h_fitres3Chi2->getTH1F ();
01145       int division = C3->GetNbinsX ();
01146       float massMIN = C3->GetBinLowEdge (1);
01147       float massMAX = C3->GetBinLowEdge (division + 1);
01148       //float BIN_SIZE = B->GetBinWidth(1);
01149 
01150       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
01151       func->SetParameter (0, 1.0);
01152       func->SetParName (0, "const");
01153       func->SetParameter (1, 95.0);
01154       func->SetParName (1, "mean");
01155       func->SetParameter (2, 5.0);
01156       func->SetParName (2, "sigma");
01157 
01158       double stats[4];
01159       S3->GetStats (stats);
01160       float N = 0;
01161       float Chi2 = 0;
01162       float NDF = 0;
01163       N = C3->GetEntries ();
01164 
01165       try
01166       {
01167         if (N != 0)
01168           {
01169             C3->Fit ("mygauss", "QR");
01170             if ((func->GetNDF () != 0))
01171               {
01172                 Chi2 = fabs (func->GetChisquare ()) / fabs (func->GetNDF ());
01173                 NDF = 0.1;
01174               }
01175           }
01176 
01177 
01178         if (N == 0 || Chi2 < 0 || NDF < 0)
01179           {
01180             N = 1;
01181             Chi2 = 0;
01182             NDF = 0;
01183           }
01184 
01185       }
01186       catch (...)
01187       {
01188         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
01189         N = 1;
01190         Chi2 = 40;
01191         NDF = 0;
01192       }
01193 
01194       stats[0] = N;
01195       stats[1] = N;
01196       stats[2] = Chi2 * N;
01197       stats[3] = NDF * NDF * N + Chi2 * Chi2 * N;
01198 
01199       S3->SetEntries (N);
01200       S3->PutStats (stats);
01201     }
01202 }
01203 
01204         // ------------ method called when starting to processes a luminosity block  ------------
01205 void
01206 EcalZmassClient::beginLuminosityBlock (edm::LuminosityBlock const &,
01207                                        edm::EventSetup const &)
01208 {
01209 }
01210 
01211         // ------------ method called when ending the processing of a luminosity block  ------------
01212 void
01213 EcalZmassClient::endLuminosityBlock (edm::LuminosityBlock const &,
01214                                      edm::EventSetup const &)
01215 {
01216 }
01217 
01218         // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
01219 void
01220 EcalZmassClient::fillDescriptions (edm::
01221                                    ConfigurationDescriptions & descriptions)
01222 {
01223   //The following says we do not know what parameters are allowed so do no validation
01224   // Please change this to state exactly what you do use, even if it is no parameters
01225   edm::ParameterSetDescription desc;
01226   desc.setUnknown ();
01227   descriptions.addDefault (desc);
01228 }
01229 
01230         //define this as a plug-in
01231 DEFINE_FWK_MODULE (EcalZmassClient);