Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run3-alca225 Update the comments and correct a few macros in Calibration/HcalCalibAlgos #39049

Merged
merged 3 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Calibration/HcalCalibAlgos/macros/CalibCorr.C
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@
// Defines depth of the DetId guided by the value of truncateFlag
// double puFactor(type, ieta, pmom, eHcal, ediff, debug)
// Returns a multiplicative factor to the energy as PU correction
// int type = The type of data being considered
// (1: Run 1 old; 2: Run1 new; 3: Run2 2016;
// 4: Run 2 2017; 5: Run2 2018; 6: Run3 Old;
// 7: Run 3 June 2021; 97: dlphin Try 3;
// 98: dlphin Try 2; 99: dlphin Try 1)
// double puFactorRho(type, ieta, rho, double eHcal)
// Returns a multiplicative factor as PU correction evaluated from rho
// int type = The type of data being considered
// (1: 2017 Data; 2: 2017 MC; 3: 2018 MC; 4: 2018AB;
// 5: 2018BC; 6: 2016 MC)
// double puweight(vtx)
// Return PU weight for QCD PU sample
// bool fillChain(chain, inputFileList)
Expand Down
9 changes: 7 additions & 2 deletions Calibration/HcalCalibAlgos/macros/CalibSort.C
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,11 @@ void CalibFitPU::Loop(bool extract_PU_parameters, std::string fileName) {

} //End of Event Loop to extract PU correction parameters

for (int k = 0; k < n; k++)
std::cout << "Bin " << k << " for 2D Hist " << vec_h2[k] << ":" << vec_h2[k]->GetEntries() << " Graph "
<< vec_gr[k] << ":" << points[k] << " Profile " << vec_hp[k] << ":" << vec_hp[k]->GetEntries()
<< std::endl;

std::ofstream myfile0, myfile1, myfile2;
sprintf(filename, "%s_par2d.txt", fileName.c_str());
myfile0.open(filename);
Expand Down Expand Up @@ -1677,7 +1682,7 @@ void CalibFitPU::Loop(bool extract_PU_parameters, std::string fileName) {
sprintf(namepng, "%s.png", pad1->GetName());
pad1->Print(namepng);

TF1 *f2 = ((k < 2) ? (new TF1("f2", "[0]+[1]*x", 0, 5)) : (new TF1("f1", "[0]+[1]*x+[2]*x*x", 0, 5)));
TF1 *f2 = ((k < 2) ? (new TF1("f2", "[0]+[1]*x", 0, 5)) : (new TF1("f2", "[0]+[1]*x+[2]*x*x", 0, 5)));
sprintf(name, "c_ieta%dPr", k);
TCanvas *pad2 = new TCanvas(name, name, 500, 500);
pad2->SetLeftMargin(0.10);
Expand Down Expand Up @@ -1706,7 +1711,7 @@ void CalibFitPU::Loop(bool extract_PU_parameters, std::string fileName) {
sprintf(namepng, "%s.png", pad2->GetName());
pad2->Print(namepng);

TF1 *f3 = ((k < 2) ? (new TF1("f3", "[0]+[1]*x", 0, 5)) : (new TF1("f1", "[0]+[1]*x+[2]*x*x", 0, 5)));
TF1 *f3 = ((k < 2) ? (new TF1("f3", "[0]+[1]*x", 0, 5)) : (new TF1("f3", "[0]+[1]*x+[2]*x*x", 0, 5)));
sprintf(name, "c_ieta%dGr", k);
TCanvas *pad3 = new TCanvas(name, name, 500, 500);
pad3->SetLeftMargin(0.10);
Expand Down
9 changes: 4 additions & 5 deletions Calibration/HcalCalibAlgos/macros/isotrackApplyRegressor.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
######################################################################################
# Evaluates regressor from loaded model
# Usage:
# python3 isotrackApplyRegressor.py -PU root://cmseos.fnal.gov//store/user/sghosh/ISOTRACK/DIPI_2021_PUpart.root -M ./models/model1.h5 -B endcap -O corrfac1.txt
# python3 isotrackApplyRegressor.py -PU root://cmseos.fnal.gov//store/user/sghosh/ISOTRACK/DIPI_2021_PUpart.root -M ./models/model2.h5 -B barrel -O corrfac2.txt
# source /cvmfs/sft.cern.ch/lcg/views/LCG_97apython3/x86_64-centos7-gcc8-opt/setup.csh
# python3 isotrackApplyRegressor.py -PU root://eoscms.cern.ch//eos/cms/store/group/dpg_hcal/comm_hcal/ISOTRACK/SinglePion_E-50_Eta-0to3_Run3Winter21_112X_PU.root -M ./models/model1.h5 -B endcap -O corrfac1.txt
# python3 isotrackApplyRegressor.py -PU root://eoscms.cern.ch//eos/cms/store/group/dpg_hcal/comm_hcal/ISOTRACK/SinglePion_E-50_Eta-0to3_Run3Winter21_112X_PU.root -M ./models/model2.h5 -B barrel -O corrfac2.txt
######################################################################################
# coding: utf-8

# In[1]:


import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
Expand All @@ -30,8 +30,7 @@
# In[2]:

parser = argparse.ArgumentParser()
parser.add_argument("-PU", "--filePU",help="input PU file",default="root://cmseos.fnal.gov//store/user/sghosh/ISOTRACK/DIPI_2021_PUpart.root")
#parser.add_argument("-PU", "--filePU",help="input PU file",default="/eos/uscms/store/user/sghosh/ISOTRACK/DIPI_2021_noPU.root")
parser.add_argument("-PU", "--filePU",help="input PU file",default="root://eoscms.cern.ch//eos/cms/store/group/dpg_hcal/comm_hcal/ISOTRACK/SinglePion_E-50_Eta-0to3_Run3Winter21_112X_PU.root")
parser.add_argument("-B", "--ifbarrel",help="barrel / endcap",default='barrel')
parser.add_argument("-M", "--modelname",help="model file name",default="./models/model.h5")
parser.add_argument("-O", "--opfilename",help="output text file name",default="corrfac_regression.txt")
Expand Down
7 changes: 4 additions & 3 deletions Calibration/HcalCalibAlgos/macros/isotrackNtupler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
######################################################################################
# Makes pkl and text files comparing PU and noPU samples for training regressor and other stuff
# Usage:
# python3 isotrackNtupler.py -PU root://cmseos.fnal.gov//store/user/sghosh/ISOTRACK/DIPI_2021_PUpart.root -NPU root://cmseos.fnal.gov//store/user/sghosh/ISOTRACK/DIPI_2021_noPU.root -O isotk_relval
# source /cvmfs/sft.cern.ch/lcg/views/LCG_97apython3/x86_64-centos7-gcc8-opt/setup.csh
# python3 isotrackNtupler.py -PU root://eoscms.cern.ch//eos/cms/store/group/dpg_hcal/comm_hcal/ISOTRACK/SinglePion_E-50_Eta-0to3_Run3Winter21_112X_PU.root -NPU root://eoscms.cern.ch//eos/cms/store/group/dpg_hcal/comm_hcal/ISOTRACK/SinglePion_E-50_Eta-0to3_Run3Winter21_112X_PU.root -O isotk_relval
######################################################################################


Expand All @@ -13,8 +14,8 @@
import matplotlib.pyplot as plt

parser = argparse.ArgumentParser()
parser.add_argument("-PU", "--filePU",help="input PU file",default="root://cmseos.fnal.gov//store/user/sghosh/ISOTRACK/DIPI_2021_PUpart.root")
parser.add_argument("-NPU", "--fileNPU",help="input no PU file",default="root://cmseos.fnal.gov//store/user/sghosh/ISOTRACK/DIPI_2021_noPU.root")
parser.add_argument("-PU", "--filePU",help="input PU file",default="root://eoscms.cern.ch//eos/cms/store/group/dpg_hcal/comm_hcal/ISOTRACK/SinglePion_E-50_Eta-0to3_Run3Winter21_112X_PU.root")
parser.add_argument("-NPU", "--fileNPU",help="input no PU file",default="//eoscms.cern.ch//eos/cms/store/group/dpg_hcal/comm_hcal/ISOTRACK/SinglePion_E-50_Eta-0to3_Run3Winter21_112X_PU.root")
parser.add_argument("-O", "--opfilename",help="ouput file name",default="isotk_relval")


Expand Down
3 changes: 2 additions & 1 deletion Calibration/HcalCalibAlgos/macros/isotrackRootTreeMaker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
######################################################################################
# Makes pkl, root and text files comparing PU and noPU samples for training regressor and other stuff
# Usage:
# python3 isotrackRootTreeMaker.py -PU root://cmseos.fnal.gov//store/user/sghosh/ISOTRACK/DIPI_2021_PUpart.root -NPU root://cmseos.fnal.gov//store/user/sghosh/ISOTRACK/DIPI_2021_noPU.root -O isotrackRelval
# source /cvmfs/sft.cern.ch/lcg/views/LCG_97apython3/x86_64-centos7-gcc8-opt/setup.csh
# python3 isotrackRootTreeMaker.py -PU root://eoscms.cern.ch//eos/cms/store/group/dpg_hcal/comm_hcal/ISOTRACK/SinglePion_E-50_Eta-0to3_Run3Winter21_112X_PU.root -NPU root://eoscms.cern.ch//eos/cms/store/group/dpg_hcal/comm_hcal/ISOTRACK/SinglePion_E-50_Eta-0to3_Run3Winter21_112X_PU.root -O isotrackRelval
######################################################################################

import uproot
Expand Down
4 changes: 2 additions & 2 deletions Calibration/HcalCalibAlgos/macros/isotrackTrainRegressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def propweights(y_true):
# In[6]:


from keras import optimizers
from tensorflow.keras import optimizers
print ("creating model=========>")
model = Sequential()
model.add(Dense(128, input_shape=(X_train.shape[1],), activation='relu'))
Expand All @@ -153,7 +153,7 @@ def propweights(y_true):
model.add(Dense(60, activation='relu',kernel_regularizer=regularizers.l2(0.01)))
model.add(Dense(1))

RMS = keras.optimizers.RMSprop(lr=0.001, rho=0.9)
RMS = tensorflow.keras.optimizers.RMSprop(learning_rate=0.001, rho=0.9)
# Compile model
print ("compilation up next=======>")
model.compile(loss='logcosh',optimizer='adam')
Expand Down
Loading