CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/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.2 2012/01/28 11:53:18 yiiyama 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 class DQMStore;
00044 class MonitorElement;
00045 
00046 //
00047 // class declaration
00048 //
00049 
00050 class EcalZmassClient:public
00051   edm::EDAnalyzer
00052 {
00053 public:
00054   explicit
00055   EcalZmassClient (const edm::ParameterSet &);
00056    ~
00057   EcalZmassClient ();
00058 
00059   static void
00060   fillDescriptions (edm::ConfigurationDescriptions & descriptions);
00061 
00062 
00063 private:
00064   virtual void
00065   beginJob ();
00066   virtual void
00067   analyze (const edm::Event &, const edm::EventSetup &);
00068   virtual void
00069   endJob ();
00070 
00071   virtual void
00072   beginRun (edm::Run const &, edm::EventSetup const &);
00073   virtual void
00074   endRun (edm::Run const &, edm::EventSetup const &);
00075   virtual void
00076   beginLuminosityBlock (edm::LuminosityBlock const &,
00077                         edm::EventSetup const &);
00078   virtual void
00079   endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &);
00080 
00081   // ----------member data ---------------------------
00082 
00083   std::string prefixME_;
00084 
00085   MonitorElement *
00086     h_ee_invMass_EB;
00087   MonitorElement *
00088     h_ee_invMass_EE;
00089   MonitorElement *
00090     h_ee_invMass_BB;
00091   MonitorElement *
00092     h_95_ee_invMass_EB;
00093   MonitorElement *
00094     h_95_ee_invMass_EE;
00095   MonitorElement *
00096     h_95_ee_invMass_BB;
00097   MonitorElement *
00098     h_ee_invMass;
00099   MonitorElement *
00100     h_e1_et;
00101   MonitorElement *
00102     h_e2_et;
00103   MonitorElement *
00104     h_e1_eta;
00105   MonitorElement *
00106     h_e2_eta;
00107   MonitorElement *
00108     h_e1_phi;
00109   MonitorElement *
00110     h_e2_phi;
00111   MonitorElement *
00112     h_fitres1;
00113   MonitorElement *
00114     h_fitres1bis;
00115   MonitorElement *
00116     h_fitres1Chi2;
00117   MonitorElement *
00118     h_fitres2;
00119   MonitorElement *
00120     h_fitres2bis;
00121   MonitorElement *
00122     h_fitres2Chi2;
00123   MonitorElement *
00124     h_fitres3;
00125   MonitorElement *
00126     h_fitres3bis;
00127   MonitorElement *
00128     h_fitres3Chi2;
00129 
00130 
00131 };
00132 
00133 EcalZmassClient::EcalZmassClient (const edm::ParameterSet & iConfig)
00134 {
00135   prefixME_ = iConfig.getUntrackedParameter < std::string > ("prefixME", "");
00136 
00137 }
00138 
00139 
00140 EcalZmassClient::~EcalZmassClient ()
00141 {
00142 
00143   // do anything here that needs to be done at desctruction time
00144   // (e.g. close files, deallocate resources etc.)
00145 
00146 }
00147 
00148 
00149 //
00150 // member functions
00151 //
00152 
00153 // ------------ method called for each event  ------------
00154 void
00155 EcalZmassClient::analyze (const edm::Event & iEvent,
00156                           const edm::EventSetup & iSetup)
00157 {
00158 
00159 }
00160 
00161 
00162 // ------------ method called once each job just before starting event loop  ------------
00163 void
00164 EcalZmassClient::beginJob ()
00165 {
00166 }
00167 
00168 // ------------ method called once each job just after ending the event loop  ------------
00169 void
00170 EcalZmassClient::endJob ()
00171 {
00172 }
00173 
00174 // ------------ method called when starting to processes a run  ------------
00175 void
00176 EcalZmassClient::beginRun (edm::Run const &, edm::EventSetup const &)
00177 {
00178   DQMStore *theDbe = edm::Service < DQMStore > ().operator-> ();
00179 
00180   theDbe->setCurrentFolder (prefixME_ + "/Zmass");
00181   h_fitres1 =
00182     theDbe->book1D ("Gaussian mean WP80 EB-EB",
00183                     "Gaussian mean WP80 EB-EB", 1, 0, 1);
00184   h_fitres1bis =
00185     theDbe->book1D ("Gaussian sigma WP80 EB-EB",
00186                     "Gaussian sigma WP80 EB-EB", 1, 0, 1);
00187   h_fitres1Chi2 =
00188     theDbe->book1D ("Gaussian Chi2 result over NDF  WP80 EB-EB",
00189                     "Gaussian Chi2 result over NDF  WP80 EB-EB", 1, 0, 1);
00190 
00191   h_fitres3 =
00192     theDbe->book1D ("Gaussian mean WP80 EB-EE",
00193                     "Gaussian mean result WP80 EB-EE", 1, 0, 1);
00194   h_fitres3bis =
00195     theDbe->book1D ("Gaussian sigma WP80 EB-EE",
00196                     "Gaussian sigma WP80 EB-EE", 1, 0, 1);
00197   h_fitres3Chi2 =
00198     theDbe->book1D ("Gaussian Chi2 result over NDF WP80 EB-EE",
00199                     "Gaussian Chi2 result over NDF WP80 EB-EE", 1, 0, 1);
00200 
00201   h_fitres2 =
00202     theDbe->book1D ("Gaussian mean WP80 EE-EE",
00203                     "Gaussian mean WP80 EE-EE", 1, 0, 1);
00204   h_fitres2bis =
00205     theDbe->book1D ("Gaussian sigma WP80 EE-EE",
00206                     "Gaussian sigma WP80 EE-EE", 1, 0, 1);
00207   h_fitres2Chi2 =
00208     theDbe->book1D ("Gaussian Chi2 result over NDF WP80 EE-EE",
00209                     "Gaussian Chi2 result over NDF WP80 EE-EE", 1, 0, 1);
00210 }
00211 
00212 
00213 //Breit-Wigner function
00214 Double_t
00215 mybw (Double_t * x, Double_t * par)
00216 {
00217   Double_t arg1 = 14.0 / 22.0;  // 2 over pi
00218   Double_t arg2 = par[1] * par[1] * par[2] * par[2];    //Gamma=par[2]  M=par[1]
00219   Double_t arg3 =
00220     ((x[0] * x[0]) - (par[1] * par[1])) * ((x[0] * x[0]) - (par[1] * par[1]));
00221   Double_t arg4 =
00222     x[0] * x[0] * x[0] * x[0] * ((par[2] * par[2]) / (par[1] * par[1]));
00223   return par[0] * arg1 * arg2 / (arg3 + arg4);
00224 }
00225 
00226 //Gaussian
00227 Double_t
00228 mygauss (Double_t * x, Double_t * par)
00229 {
00230   Double_t arg = 0;
00231   if (par[2] < 0)
00232     par[2] = -par[2];           // par[2]: sigma
00233   if (par[2] != 0)
00234     arg = (x[0] - par[1]) / par[2];     // par[1]: mean
00235   return par[0] * TMath::Exp (-0.5 * arg * arg) / (TMath::Sqrt (2 * TMath::Pi ()) * par[2]);    // par[0] is constant
00236 
00237 }
00238 
00239 
00240 
00241 // ------------ method called when ending the processing of a run  ------------
00242 void
00243 EcalZmassClient::endRun (edm::Run const &, edm::EventSetup const &)
00244 {
00245   DQMStore *theDbe = edm::Service < DQMStore > ().operator-> ();
00246 
00247   LogTrace ("EwkAnalyzer") << "Parameters initialization";
00248 
00249   MonitorElement *me1 = theDbe->get (prefixME_ + "/Zmass/Z peak - WP80 EB-EB");
00250   MonitorElement *me2 = theDbe->get (prefixME_ + "/Zmass/Z peak - WP80 EE-EE");
00251   MonitorElement *me3 = theDbe->get (prefixME_ + "/Zmass/Z peak - WP80 EB-EE");
00252 
00253 
00254   if (me1 != 0)
00255     {
00256       TH1F *B = me1->getTH1F ();
00257       TH1F *R1 = h_fitres1->getTH1F ();
00258       int division = B->GetNbinsX ();
00259       float massMIN = B->GetBinLowEdge (1);
00260       float massMAX = B->GetBinLowEdge (division + 1);
00261       //float BIN_SIZE = B->GetBinWidth(1);
00262 
00263       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00264       func->SetParameter (0, 1.0);
00265       func->SetParName (0, "const");
00266       func->SetParameter (1, 95.0);
00267       func->SetParName (1, "mean");
00268       func->SetParameter (2, 5.0);
00269       func->SetParName (2, "sigma");
00270 
00271       double stats[4];
00272       R1->GetStats (stats);
00273       float N = 0;
00274       float mean = 0;
00275       float sigma = 0;
00276       N = B->GetEntries ();
00277 
00278       try
00279       {
00280         if (N != 0)
00281           {
00282 
00283             B->Fit ("mygauss", "QR");
00284             mean = fabs (func->GetParameter (1));
00285             sigma = fabs (func->GetParError (1));
00286           }
00287 
00288         if (N == 0 || mean < 50 || mean > 100 || sigma <= 0 || sigma > 20)
00289           {
00290             N = 1;
00291             mean = 0;
00292             sigma = 0;
00293           }
00294 
00295       }
00296       catch (...)
00297       {
00298         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00299         N = 1;
00300         mean = 40;
00301         sigma = 0;
00302       }
00303 
00304       stats[0] = N;
00305       stats[1] = N;
00306       stats[2] = mean * N;
00307       stats[3] = sigma * sigma * N + mean * mean * N;
00308 
00309       R1->SetEntries (N);
00310       R1->PutStats (stats);
00311     }
00312 /*******************************************************/
00313   if (me1 != 0)
00314     {
00315       TH1F *Bbis = me1->getTH1F ();
00316       TH1F *R1bis = h_fitres1bis->getTH1F ();
00317       int division = Bbis->GetNbinsX ();
00318       float massMIN = Bbis->GetBinLowEdge (1);
00319       float massMAX = Bbis->GetBinLowEdge (division + 1);
00320       //float BIN_SIZE = B->GetBinWidth(1);
00321 
00322       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00323       func->SetParameter (0, 1.0);
00324       func->SetParName (0, "const");
00325       func->SetParameter (1, 95.0);
00326       func->SetParName (1, "mean");
00327       func->SetParameter (2, 5.0);
00328       func->SetParName (2, "sigma");
00329 
00330       double stats[4];
00331       R1bis->GetStats (stats);
00332       float N = 0;
00333       float rms = 0;
00334       float rmsErr = 0;
00335       N = Bbis->GetEntries ();
00336 
00337       try
00338       {
00339         if (N != 0)
00340           {
00341 
00342             Bbis->Fit ("mygauss", "QR");
00343             rms = fabs (func->GetParameter (2));
00344             rmsErr = fabs (func->GetParError (2));
00345           }
00346 
00347         if (N == 0 || rms < 0 || rms > 50 || rmsErr <= 0 || rmsErr > 50)
00348           {
00349             N = 1;
00350             rms = 0;
00351             rmsErr = 0;
00352           }
00353 
00354       }
00355       catch (...)
00356       {
00357         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00358         N = 1;
00359         rms = 40;
00360         rmsErr = 0;
00361       }
00362 
00363       stats[0] = N;
00364       stats[1] = N;
00365       stats[2] = rms * N;
00366       stats[3] = rmsErr * rmsErr * N + rms * rms * N;
00367 
00368       R1bis->SetEntries (N);
00369       R1bis->PutStats (stats);
00370     }
00371 /****************************************/
00372 
00373   if (me2 != 0)
00374     {
00375       TH1F *E = me2->getTH1F ();
00376       TH1F *R2 = h_fitres2->getTH1F ();
00377       int division = E->GetNbinsX ();
00378       float massMIN = E->GetBinLowEdge (1);
00379       float massMAX = E->GetBinLowEdge (division + 1);
00380       //float BIN_SIZE = E->GetBinWidth(1);
00381 
00382       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00383       func->SetParameter (0, 1.0);
00384       func->SetParName (0, "const");
00385       func->SetParameter (1, 95.0);
00386       func->SetParName (1, "mean");
00387       func->SetParameter (2, 5.0);
00388       func->SetParName (2, "sigma");
00389 
00390       double stats[4];
00391       R2->GetStats (stats);
00392       float N = 0;
00393       float mean = 0;
00394       float sigma = 0;
00395       N = E->GetEntries ();
00396 
00397       try
00398       {
00399         if (N != 0)
00400           {
00401             E->Fit ("mygauss", "QR");
00402             mean = fabs (func->GetParameter (1));
00403             sigma = fabs (func->GetParError (1));
00404           }
00405 
00406         if (N == 0 || mean < 50 || mean > 100 || sigma <= 0 || sigma > 20)
00407           {
00408             N = 1;
00409             mean = 0;
00410             sigma = 0;
00411 
00412           }
00413 
00414       }
00415       catch (...)
00416       {
00417         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00418         N = 1;
00419         mean = 40;
00420         sigma = 0;
00421       }
00422 
00423       stats[0] = N;
00424       stats[1] = N;
00425       stats[2] = mean * N;
00426       stats[3] = sigma * sigma * N + mean * mean * N;
00427 
00428       R2->SetEntries (N);
00429       R2->PutStats (stats);
00430     }
00431 /**************************************************************************/
00432 
00433   if (me2 != 0)
00434     {
00435       TH1F *Ebis = me2->getTH1F ();
00436       TH1F *R2bis = h_fitres2bis->getTH1F ();
00437       int division = Ebis->GetNbinsX ();
00438       float massMIN = Ebis->GetBinLowEdge (1);
00439       float massMAX = Ebis->GetBinLowEdge (division + 1);
00440       //float BIN_SIZE = B->GetBinWidth(1);
00441 
00442       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00443       func->SetParameter (0, 1.0);
00444       func->SetParName (0, "const");
00445       func->SetParameter (1, 95.0);
00446       func->SetParName (1, "mean");
00447       func->SetParameter (2, 5.0);
00448       func->SetParName (2, "sigma");
00449 
00450       double stats[4];
00451       R2bis->GetStats (stats);
00452       float N = 0;
00453       float rms = 0;
00454       float rmsErr = 0;
00455       N = Ebis->GetEntries ();
00456 
00457       try
00458       {
00459         if (N != 0)
00460           {
00461 
00462             Ebis->Fit ("mygauss", "QR");
00463             rms = fabs (func->GetParameter (2));
00464             rmsErr = fabs (func->GetParError (2));
00465           }
00466 
00467         if (N == 0 || rms < 0 || rms > 50 || rmsErr <= 0 || rmsErr > 50)
00468           {
00469             N = 1;
00470             rms = 0;
00471             rmsErr = 0;
00472           }
00473 
00474       }
00475       catch (...)
00476       {
00477         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00478         N = 1;
00479         rms = 40;
00480         rmsErr = 0;
00481       }
00482 
00483       stats[0] = N;
00484       stats[1] = N;
00485       stats[2] = rms * N;
00486       stats[3] = rmsErr * rmsErr * N + rms * rms * N;
00487 
00488       R2bis->SetEntries (N);
00489       R2bis->PutStats (stats);
00490     }
00491 /*********************************************************************************************/
00492 
00493   if (me3 != 0)
00494     {
00495       TH1F *R3 = h_fitres3->getTH1F ();
00496       TH1F *M = me3->getTH1F ();
00497       int division = M->GetNbinsX ();
00498       float massMIN = M->GetBinLowEdge (1);
00499       float massMAX = M->GetBinLowEdge (division + 1);
00500       //float BIN_SIZE = M->GetBinWidth(1);
00501 
00502       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00503       func->SetParameter (0, 1.0);
00504       func->SetParName (0, "const");
00505       func->SetParameter (1, 95.0);
00506       func->SetParName (1, "mean");
00507       func->SetParameter (2, 5.0);
00508       func->SetParName (2, "sigma");
00509 
00510       double stats[4];
00511       R3->GetStats (stats);
00512       float N = 0;
00513       float mean = 0;
00514       float sigma = 0;
00515       N = M->GetEntries ();
00516 
00517 
00518       try
00519       {
00520         if (N != 0)
00521           {
00522 
00523             M->Fit ("mygauss", "QR");
00524             mean = fabs (func->GetParameter (1));
00525             sigma = fabs (func->GetParError (1));
00526           }
00527         if (N == 0 || mean < 50 || mean > 100 || sigma <= 0 || sigma > 20)
00528           {
00529             N = 1;
00530             mean = 0;
00531             sigma = 0;
00532           }
00533 
00534       }
00535       catch (...)
00536       {
00537         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00538         N = 1;
00539         mean = 40;
00540         sigma = 0;
00541       }
00542 
00543       stats[0] = N;
00544       stats[1] = N;
00545       stats[2] = mean * N;
00546       stats[3] = sigma * sigma * N + mean * mean * N;
00547 
00548       R3->SetEntries (N);
00549       R3->PutStats (stats);
00550     }
00551   /********************************************************************************/
00552 
00553   if (me3 != 0)
00554     {
00555       TH1F *Mbis = me3->getTH1F ();
00556       TH1F *R3bis = h_fitres3bis->getTH1F ();
00557       int division = Mbis->GetNbinsX ();
00558       float massMIN = Mbis->GetBinLowEdge (1);
00559       float massMAX = Mbis->GetBinLowEdge (division + 1);
00560       //float BIN_SIZE = B->GetBinWidth(1);
00561 
00562       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00563       func->SetParameter (0, 1.0);
00564       func->SetParName (0, "const");
00565       func->SetParameter (1, 95.0);
00566       func->SetParName (1, "mean");
00567       func->SetParameter (2, 5.0);
00568       func->SetParName (2, "sigma");
00569 
00570       double stats[4];
00571       R3bis->GetStats (stats);
00572       float N = 0;
00573       float rms = 0;
00574       float rmsErr = 0;
00575       N = Mbis->GetEntries ();
00576 
00577       try
00578       {
00579         if (N != 0)
00580           {
00581 
00582             Mbis->Fit ("mygauss", "QR");
00583             rms = fabs (func->GetParameter (2));
00584             rmsErr = fabs (func->GetParError (2));
00585           }
00586 
00587         if (N == 0 || rms < 0 || rms > 50 || rmsErr <= 0 || rmsErr > 50)
00588           {
00589             N = 1;
00590             rms = 0;
00591             rmsErr = 0;
00592           }
00593 
00594       }
00595       catch (...)
00596       {
00597         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00598         N = 1;
00599         rms = 40;
00600         rmsErr = 0;
00601       }
00602 
00603       stats[0] = N;
00604       stats[1] = N;
00605       stats[2] = rms * N;
00606       stats[3] = rmsErr * rmsErr * N + rms * rms * N;
00607 
00608       R3bis->SetEntries (N);
00609       R3bis->PutStats (stats);
00610     }
00611 
00612   /*Chi2 */
00613 
00614   if (me1 != 0)
00615     {
00616       TH1F *C1 = me1->getTH1F ();
00617       TH1F *S1 = h_fitres1Chi2->getTH1F ();
00618       int division = C1->GetNbinsX ();
00619       float massMIN = C1->GetBinLowEdge (1);
00620       float massMAX = C1->GetBinLowEdge (division + 1);
00621       //float BIN_SIZE = B->GetBinWidth(1);
00622 
00623       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00624       func->SetParameter (0, 1.0);
00625       func->SetParName (0, "const");
00626       func->SetParameter (1, 95.0);
00627       func->SetParName (1, "mean");
00628       func->SetParameter (2, 5.0);
00629       func->SetParName (2, "sigma");
00630 
00631       double stats[4];
00632       S1->GetStats (stats);
00633       float N = 0;
00634       float Chi2 = 0;
00635       float NDF = 0;
00636       N = C1->GetEntries ();
00637 
00638       try
00639       {
00640         if (N != 0)
00641           {
00642 
00643             C1->Fit ("mygauss", "QR");
00644             if ((func->GetNDF () != 0))
00645               {
00646                 Chi2 = fabs (func->GetChisquare ()) / fabs (func->GetNDF ());
00647                 NDF = 0.1;
00648               }
00649           }
00650 
00651         if (N == 0 || Chi2 < 0 || NDF < 0)
00652           {
00653             N = 1;
00654             Chi2 = 0;
00655             NDF = 0;
00656           }
00657 
00658       }
00659       catch (...)
00660       {
00661         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00662         N = 1;
00663         Chi2 = 40;
00664         NDF = 0;
00665       }
00666 
00667       stats[0] = N;
00668       stats[1] = N;
00669       stats[2] = Chi2 * N;
00670       stats[3] = NDF * NDF * N + Chi2 * Chi2 * N;
00671 
00672       S1->SetEntries (N);
00673       S1->PutStats (stats);
00674     }
00675   /**********************************************/
00676 
00677   if (me2 != 0)
00678     {
00679       TH1F *C2 = me2->getTH1F ();
00680       TH1F *S2 = h_fitres2Chi2->getTH1F ();
00681       int division = C2->GetNbinsX ();
00682       float massMIN = C2->GetBinLowEdge (1);
00683       float massMAX = C2->GetBinLowEdge (division + 1);
00684       //float BIN_SIZE = B->GetBinWidth(1);
00685 
00686       TF1 *func = new TF1 ("mygauss", mygauss, 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       S2->GetStats (stats);
00696       float N = 0;
00697       float Chi2 = 0;
00698       float NDF = 0;
00699       N = C2->GetEntries ();
00700 
00701       try
00702       {
00703         if (N != 0)
00704           {
00705             C2->Fit ("mygauss", "QR");
00706             if (func->GetNDF () != 0)
00707               {
00708                 Chi2 = fabs (func->GetChisquare ()) / fabs (func->GetNDF ());
00709                 NDF = 0.1;
00710               }
00711           }
00712 
00713         if (N == 0 || Chi2 < 0 || NDF < 0)
00714           {
00715             N = 1;
00716             Chi2 = 0;
00717             NDF = 0;
00718           }
00719 
00720       }
00721       catch (...)
00722       {
00723         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00724         N = 1;
00725         Chi2 = 40;
00726         NDF = 0;
00727       }
00728 
00729       stats[0] = N;
00730       stats[1] = N;
00731       stats[2] = Chi2 * N;
00732       stats[3] = NDF * NDF * N + Chi2 * Chi2 * N;
00733 
00734       S2->SetEntries (N);
00735       S2->PutStats (stats);
00736     }
00737   /**************************************************************************/
00738   if (me3 != 0)
00739     {
00740       TH1F *C3 = me3->getTH1F ();
00741       TH1F *S3 = h_fitres3Chi2->getTH1F ();
00742       int division = C3->GetNbinsX ();
00743       float massMIN = C3->GetBinLowEdge (1);
00744       float massMAX = C3->GetBinLowEdge (division + 1);
00745       //float BIN_SIZE = B->GetBinWidth(1);
00746 
00747       TF1 *func = new TF1 ("mygauss", mygauss, massMIN, massMAX, 3);
00748       func->SetParameter (0, 1.0);
00749       func->SetParName (0, "const");
00750       func->SetParameter (1, 95.0);
00751       func->SetParName (1, "mean");
00752       func->SetParameter (2, 5.0);
00753       func->SetParName (2, "sigma");
00754 
00755       double stats[4];
00756       S3->GetStats (stats);
00757       float N = 0;
00758       float Chi2 = 0;
00759       float NDF = 0;
00760       N = C3->GetEntries ();
00761 
00762       try
00763       {
00764         if (N != 0)
00765           {
00766             C3->Fit ("mygauss", "QR");
00767             if ((func->GetNDF () != 0))
00768               {
00769                 Chi2 = fabs (func->GetChisquare ()) / fabs (func->GetNDF ());
00770                 NDF = 0.1;
00771               }
00772           }
00773 
00774 
00775         if (N == 0 || Chi2 < 0 || NDF < 0)
00776           {
00777             N = 1;
00778             Chi2 = 0;
00779             NDF = 0;
00780           }
00781 
00782       }
00783       catch (...)
00784       {
00785         edm::LogError ("ZFitter") << "[Zfitter]: Exception when fitting...";
00786         N = 1;
00787         Chi2 = 40;
00788         NDF = 0;
00789       }
00790 
00791       stats[0] = N;
00792       stats[1] = N;
00793       stats[2] = Chi2 * N;
00794       stats[3] = NDF * NDF * N + Chi2 * Chi2 * N;
00795 
00796       S3->SetEntries (N);
00797       S3->PutStats (stats);
00798     }
00799 }
00800 
00801         // ------------ method called when starting to processes a luminosity block  ------------
00802 void
00803 EcalZmassClient::beginLuminosityBlock (edm::LuminosityBlock const &,
00804                                        edm::EventSetup const &)
00805 {
00806 }
00807 
00808         // ------------ method called when ending the processing of a luminosity block  ------------
00809 void
00810 EcalZmassClient::endLuminosityBlock (edm::LuminosityBlock const &,
00811                                      edm::EventSetup const &)
00812 {
00813 }
00814 
00815         // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
00816 void
00817 EcalZmassClient::fillDescriptions (edm::
00818                                    ConfigurationDescriptions & descriptions)
00819 {
00820   //The following says we do not know what parameters are allowed so do no validation
00821   // Please change this to state exactly what you do use, even if it is no parameters
00822   edm::ParameterSetDescription desc;
00823   desc.setUnknown ();
00824   descriptions.addDefault (desc);
00825 }
00826 
00827         //define this as a plug-in
00828 DEFINE_FWK_MODULE (EcalZmassClient);