Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:32:21

0001 #include "CrystalBall.C"
0002 #include "effSigma.C"
0003 
0004 #include "TChain.h"
0005 
0006 TChain* chain = new TChain("energyScale");
0007 void load_noET() {
0008   chain->Add("../SuperClusters.root");
0009  //Need to be added more files if there are multiple output root files
0010 }
0011 double fit0, fit1, fit2, fit3, fit4;
0012 double left, right;
0013 
0014 void plotEnergy(TString var, TString Eta, int etaBin, bool newFit) {
0015   
0016   float mean_value = 0;
0017   float mean_error = 0;
0018   float sigma_value = 0;
0019   float ChiSquare = 0;
0020   
0021   int nBin = 600;
0022   float xMin = 0.8;
0023   float xMax = 1.1;
0024   
0025   gStyle->SetOptFit(1);
0026   gStyle->SetStatX(0.48);
0027   gStyle->SetStatY(0.82);
0028   gStyle->SetStatW(0.2);
0029   gStyle->SetStatH(0.15);
0030  
0031   TString Cut = Eta + "&&em_scType==1";
0032   Cut = Cut + "&&mc_et>10&&mc_et<300&&!em_isInCrack";
0033   TH1F *h = new TH1F("h"," Et^{RECO}/Et^{GEN} GeV",nBin, xMin, xMax);
0034   chain->Draw(var + "/mc_et>>h",Cut);
0035 
0036   if ( newFit ) {
0037     fit0 = 25;
0038     fit1 = 0.4;
0039     fit2 = 3;
0040     fit3 = 1;
0041     fit4 = 0.016;
0042 
0043     left = 0.7;
0044     right = 1.1;
0045   }
0046   // This is for BR1/Full ============
0047   if ( true ) {
0048     if ( etaBin >= 0 ) {
0049       right = 1.05;
0050     }
0051     if ( etaBin >= 5  ) {
0052       right = 1.03;
0053     }
0054     if ( etaBin >= 10 ) {
0055       right = 1.03;
0056     }
0057   }
0058   
0059   if ( false ) {
0060     if ( etaBin >= 0 ) {
0061       right = 1.06;
0062     }
0063     if ( etaBin >= 20  ) {
0064       right = 1.05;
0065     }
0066     if ( etaBin >= 50 ) {
0067       right = 1.05;
0068     }
0069   }
0070   TF1* g1 = new TF1("g1",CrystalBall,0.85, 1.2, 5);
0071   g1->SetParameters(fit0, fit1, fit2, fit3, fit4);
0072   g1->SetLineColor(4);
0073   g1->SetLineWidth(3);
0074   h->Fit(g1,"","",left,right);
0075 
0076   mean_value  = g1->GetParameter(3);
0077   mean_error  = g1->GetParError(3); 
0078   sigma_value = g1->GetParameter(4); 
0079   ChiSquare = g1->GetChisquare();
0080   
0081   cout << "Result:\t" << var << "\t" << Eta << "\t" << mean_value << "\t" << mean_error << "\t" << effSigma(h) << endl;
0082 
0083   fit0 = g1->GetParameter(0);
0084   fit1 = g1->GetParameter(1);
0085   fit2 = g1->GetParameter(2);
0086   fit3 = g1->GetParameter(3);
0087   fit4 = g1->GetParameter(4);
0088   
0089   delete g1;
0090   delete h;
0091 } 
0092 
0093 void derivationEnergyCorrection_phiWidth() {
0094 
0095   TString vars[2] = {"emCorr_et", "em_et"};
0096 
0097   for (int i=0; i < 2; ++i) {
0098     bool newFit = true;
0099     for (int j=0; j < 145; ++j) {
0100       TString leftEt = FloatToString(10 + 2*j);
0101       TString rightEt = FloatToString(10 + 2*(j + 1));
0102 
0103       TString etaCut = "mc_et>" + leftEt + "&&mc_et<" + rightEt;
0104       plotEnergy(vars[i], etaCut, j, newFit);
0105       newFit = false;
0106     }
0107   } 
0108 }
0109 
0110 TString IntToString(int number){
0111   ostringstream oss;
0112   oss << number;
0113   return oss.str();
0114 }
0115 
0116 TString FloatToString(float number){
0117   ostringstream oss;
0118   oss << number;
0119   return oss.str();
0120 }
0121 
0122 
0123 void FitEt(){
0124   load_noET();
0125   derivationEnergyCorrection_phiWidth();
0126   gROOT->ProcessLine(".q");
0127 }
0128