104 typedef std::vector<std::string>
vstring;
105 typedef std::map<unsigned long int, float> LUTINPUT;
107 static const int NVAR=5;
108 static const int NDET=2;
109 static const int NDEP=7;
110 static const int NLEV=3;
112 const bool doRatio[NVAR] = {
false,
true,
true,
false,
true};
113 const char* titleVar[NVAR]= {
"Pedestals",
"RespCorrs",
"Gains",
"Threshold",
"LUTs"};
114 const char* titleHisR[NLEV]= {
"Old",
"New",
"Ratio"};
115 const char* titleHisD[NLEV]= {
"Old",
"New",
"Difference"};
116 const char* titleDet[4]= {
"HBHE",
"HF",
"HEP17",
"HO"};
117 const int DEP[NDET]={7,4};
118 const char* titleDep[NDEP]= {
"depth1",
"depth2",
"depth3",
"depth4",
"depth5",
"depth6",
"depth7"};
122 TProfile *
p[NVAR][NDET];
124 TH2D *
h[NVAR][NLEV][NDET][NDEP];
129 for(
int d=0;
d<4; ++
d){
130 for(
int i=0;
i<3; ++
i){
131 hlut[
d][
i] =
new TH2D(Form(
"Lut_%s_%s", titleDet[
d], titleHisR[
i]), Form(
"Input LUT, %s", (i==2?
"Ratio":
tags_[i].c_str())), 260, 0, 260, 240, 0, i==NLEV-1?3:2400);
132 hlut[
d][
i]->SetMarkerColor(d==0?kBlue:d==1? kGreen+2 : d==2?kRed : kCyan);
133 hlut[
d][
i]->SetXTitle(
"raw adc");
134 hlut[
d][
i]->SetYTitle(
"lin adc");
138 for(
int d=0;
d<NDET; ++
d){
139 hslope[
d] =
new TH2D(Form(
"GainLutScatter_%s", titleDet[
d]), Form(
"Gain-Lutslope scatter, %s",titleDet[d]), 200, 0, 2, 200, 0, 2);
140 hslope[
d]->SetXTitle(
"Gain x RespCorr ratio");
141 hslope[
d]->SetYTitle(
"Lut ratio");
143 for(
int j=0; j<NVAR; ++j){
144 double rmin=doRatio[j]?
Ymin:-6;
145 double rmax=doRatio[j]?
Ymax: 6;
146 r[j][
d] =
new TH2D(Form(
"r%s_%s", titleVar[j], titleDet[d]), Form(
"%s, %s",titleVar[j], titleDet[d]), 83,-41.5, 41.5, 250, rmin, rmax);
147 r[j][
d]->SetXTitle(
"iEta");
148 r[j][
d]->SetYTitle(doRatio[j]?
"New / Old":
"New - Old");
149 p[j][
d] =
new TProfile(Form(
"p%s_%s", titleVar[j], titleDet[d]), Form(
"%s, %s",titleVar[j], titleDet[d]), 83,-41.5, 41.5);
150 p[j][
d]->SetXTitle(
"iEta");
151 p[j][
d]->SetYTitle(doRatio[j]?
"New / Old":
"New - Old");
152 p[j][
d]->SetMarkerStyle(20);
153 p[j][
d]->SetMarkerSize(0.9);
154 p[j][
d]->SetMarkerColor(kBlue);
156 for(
int p=0; p<DEP[
d]; ++
p){
157 for(
int i=0;
i<NLEV; ++
i){
158 const char *titHist=doRatio[j]?titleHisR[
i]:titleHisD[
i];
159 h[j][
i][
d][
p] =
new TH2D(Form(
"h%s_%s_%s_%s", titleVar[j], titHist,titleDet[d],titleDep[p]),
160 Form(
"%s, %s, %s, %s",titleVar[j], titHist,titleDet[d],titleDep[p]), 83, -41.5, 41.5, 72, 0.5, 72.5);
161 h[j][
i][
d][
p]->SetXTitle(
"iEta");
162 h[j][
i][
d][
p]->SetYTitle(
"iPhi");
168 for(
int i=0;
i<4; ++
i){
169 int color=
i==0?kBlue :
i==1? kViolet :
i==2 ? kGreen+2 : kRed;
170 houtput[
i][0] =
new TH2D(Form(
"houtlut0_%d",
i), Form(
"Output LUT, %s",
tags_[0].c_str()), 2100,0,2100,260,0,260);
171 houtput[
i][1] =
new TH2D(Form(
"houtlut1_%d",
i), Form(
"Output LUT, %s",
tags_[1].c_str()), 2100,0,2100,260,0,260);
172 for(
int j=0; j<2; ++j) {
173 houtput[
i][j]->SetMarkerColor(color);
174 houtput[
i][j]->SetLineColor(color);
183 assert(
tags_.size()==2);
188 unsigned long int iraw;
189 int ieta, iphi, idep;
191 float val1, val2, val3, val4;
192 float wid1, wid2, wid3, wid4;
195 std::vector<HcalDetId> BadChans[2];
196 std::vector<HcalDetId> ZeroLuts[2];
199 for(
int ii=0;
ii<2; ++
ii){
202 assert(!infile.fail());
203 while(!infile.eof()){
204 infile.getline(buffer, 1024);
205 if(buffer[0]==
'#')
continue;
206 std::istringstream(buffer) >> ieta >> iphi >> idep >> det >> val1 >> val2 >> val3 >> val4 >> iraw ;
207 if(det!=
"HB" && det!=
"HE" && det!=
"HF")
continue;
209 float theval = (val1+val2+val3+val4)/4.0;
223 assert(!infped.fail());
224 while(!infped.eof()){
225 infped.getline(buffer, 1024);
226 if(buffer[0]==
'#')
continue;
227 std::istringstream(buffer) >> ieta >> iphi >> idep >> det >> val1 >> val2 >> val3 >> val4 >> wid1 >> wid2 >> wid3 >> wid4 >> iraw ;
228 if(det!=
"HB" && det!=
"HE" && det!=
"HF")
continue;
230 float theval = (val1+val2+val3+val4)/4.0;
245 assert(!inresp.fail());
246 while(!inresp.eof()){
247 inresp.getline(buffer, 1024);
248 if(buffer[0]==
'#')
continue;
249 std::istringstream(buffer) >> ieta >> iphi >> idep >> det >> val1 >> iraw ;
250 if(det!=
"HB" && det!=
"HE" && det!=
"HF")
continue;
266 assert(!inchan.fail());
267 while(!inchan.eof()){
268 inchan.getline(buffer, 1024);
269 if(buffer[0]==
'#')
continue;
270 std::istringstream(buffer) >> ieta >> iphi >> idep >> det >> base >> val1 >> iraw ;
281 if(theval!=0) BadChans[
ii].push_back(
id);
290 xmls2.create_lut_map();
292 for (
const auto& xml2 : xmls2){
297 if(!topology->
validHT(tid))
continue;
298 const auto& lut2 = xml2.second;
300 int D=
abs(tid.ieta())<29 ? (lut2.size()==1024 ? 0 : 3) :
301 tid.version()==0? 1: 2;
302 for(
size_t i=0;
i<lut2.size(); ++
i){
304 houtput[D][1]->
Fill(
i,lut2[
i]);
307 else if(topology->
valid(detid)){
310 int idet =
int(subdet);
311 const auto& lut2 = xml2.second;
314 lut2.size()==128 ? 0 : 2;
315 for(
size_t i=0;
i<lut2.size(); ++
i) {
316 hlut[
hbhe][1]->Fill(
i, lut2[
i]);
317 if(hbhe==2) hlut[
hbhe][1]->Fill(i, lut2[i]&0x3FF);
322 for (
const auto& xml1 : xmls1){
325 const auto& lut1 = xml1.second;
329 if(!topology->
validHT(tid))
continue;
330 int D=
abs(tid.ieta())<29 ? (lut1.size()==1024 ? 0 : 3) :
331 tid.version()==0? 1: 2;
332 for(
size_t i=0;
i<lut1.size(); ++
i){
334 houtput[D][0]->
Fill(
i,lut1[
i]);
336 }
else if(topology->
valid(detid)){
339 int idet =
int(subdet);
340 const auto& lut1 = xml1.second;
343 lut1.size()==128 ? 0 : 2;
344 for(
size_t i=0;
i<lut1.size(); ++
i) {
345 hlut[
hbhe][0]->Fill(
i, lut1[
i]);
346 if(hbhe==2) hlut[
hbhe][0]->Fill(i, lut1[i]&0x3FF);
350 auto xml2 =xmls2.find(detid.
rawId());
351 if(xml2==xmls2.end())
continue;
358 int idet =
int(subdet);
359 int ieta =
id.ieta();
360 int iphi =
id.iphi();
361 int idep =
id.depth()-1;
362 unsigned long int iraw =
id.rawId();
364 if(!topology->
valid(detid))
continue;
368 const auto& lut2 = xml2->second;
371 size_t size = lut1.size();
372 if(size != lut2.size())
continue;
374 std::vector<unsigned int> llut1(size);
375 std::vector<unsigned int> llut2(size);
377 llut1[
i]=hbhe==0? lut1[
i]&0x3FF: lut1[
i] ;
378 llut2[
i]=hbhe==0? lut2[
i]&0x3FF: lut2[
i] ;
389 ZeroLuts[0].push_back(
id);
398 ZeroLuts[1].push_back(
id);
407 h[0][0][
hbhe][idep]->Fill(ieta, iphi,lutpede[0][iraw]);
408 h[0][1][
hbhe][idep]->Fill(ieta, iphi,lutpede[1][iraw]);
409 xfill=lutpede[1][iraw]-lutpede[0][iraw];
410 h[0][2][
hbhe][idep]->Fill(ieta, iphi, xfill);
411 r[0][
hbhe]->Fill(ieta, xfill);
412 p[0][
hbhe]->Fill(ieta, xfill);
414 h[1][0][
hbhe][idep]->Fill(ieta, iphi,lutresp[0][iraw]);
415 h[1][1][
hbhe][idep]->Fill(ieta, iphi,lutresp[1][iraw]);
416 xfill=lutresp[1][iraw]/lutresp[0][iraw];
417 h[1][2][
hbhe][idep]->Fill(ieta, iphi, xfill);
418 r[1][
hbhe]->Fill(ieta, xfill);
419 p[1][
hbhe]->Fill(ieta, xfill);
421 h[2][0][
hbhe][idep]->Fill(ieta, iphi,lutgain[0][iraw]);
422 h[2][1][
hbhe][idep]->Fill(ieta, iphi,lutgain[1][iraw]);
423 xfill=lutgain[1][iraw]/lutgain[0][iraw];
424 h[2][2][
hbhe][idep]->Fill(ieta, iphi, xfill);
425 r[2][
hbhe]->Fill(ieta, xfill);
426 p[2][
hbhe]->Fill(ieta, xfill);
428 h[3][0][
hbhe][idep]->Fill(ieta, iphi, threshold[0]);
429 h[3][1][
hbhe][idep]->Fill(ieta, iphi, threshold[1]);
430 xfill=threshold[1]-threshold[0];
431 h[3][2][
hbhe][idep]->Fill(ieta, iphi, xfill);
432 r[3][
hbhe]->Fill(ieta, xfill);
433 p[3][
hbhe]->Fill(ieta, xfill);
435 size_t maxvalue=hbhe==0?1023:2047;
440 hlut[
hbhe][2]->Fill(
i, llut1[
i]==0?0:(
double)llut2[
i]/llut1[
i]);
442 if(i==size-1 || (llut1[i]==maxvalue || llut2[i]==maxvalue)){
443 if(llut1[i-1]==0 || llut2[i-1]==0) {
446 double condratio=lutgain[1][iraw]/lutgain[0][iraw] * lutresp[1][iraw]/lutresp[0][iraw];
447 xfill= (double)llut2[i-1]/llut1[i-1];
448 hslope[
hbhe]->Fill(condratio, xfill);
450 h[4][0][
hbhe][idep]->Fill(ieta, iphi, (
double)llut1[i-1]/(i-1));
451 h[4][1][
hbhe][idep]->Fill(ieta, iphi, (
double)llut2[i-1]/(i-1));
452 h[4][2][
hbhe][idep]->Fill(ieta, iphi, xfill);
453 r[4][
hbhe]->Fill(ieta, xfill);
454 p[4][
hbhe]->Fill(ieta, xfill);
461 gROOT->SetStyle(
"Plain");
462 gStyle->SetPalette(1);
463 gStyle->SetStatW(0.2);
464 gStyle->SetStatH(0.1);
465 gStyle->SetStatY(1.0);
466 gStyle->SetStatX(0.9);
467 gStyle->SetOptStat(110010);
468 gStyle->SetOptFit(111111);
471 TCanvas *cc =
new TCanvas(
"cc",
"cc", 0, 0, 1600, 1200);
473 for(
int j=0; j<NVAR; ++j){
474 gSystem->mkdir(TString(
plotsDir)+
"/_"+titleVar[j]);
475 for(
int d=0;
d<NDET; ++
d){
477 r[j][
d]->Draw(
"colz");
478 cc->Print(TString(
plotsDir)+
"/_"+titleVar[j]+
"/"+TString(r[j][
d]->GetName())+
".pdf");
483 p[j][
d]->SetMinimum(
Pmin);
484 p[j][
d]->SetMaximum(
Pmax);
486 cc->Print(TString(
plotsDir)+
"/_"+titleVar[j]+
"/"+TString(p[j][
d]->GetName())+
".pdf");
488 for(
int i=0;
i<NLEV; ++
i){
489 for(
int p=0; p<DEP[
d]; ++
p){
491 h[j][
i][
d][
p]->Draw(
"colz");
495 h[j][2][
d][
p]->SetMinimum(
Zmin);
496 h[j][2][
d][
p]->SetMaximum(
Zmax);
499 h[j][2][
d][
p]->SetMinimum(-3);
500 h[j][2][
d][
p]->SetMaximum( 3);
503 cc->Print(TString(
plotsDir)+
"/_"+titleVar[j]+
"/"+TString(h[j][
i][
d][p]->GetName())+
".pdf");
509 for(
int i=0;
i<NLEV; ++
i){
512 hlut[1][
i]->Draw(
"sames");
513 hlut[2][
i]->Draw(
"sames");
514 hlut[3][
i]->Draw(
"sames");
515 cc->Print(TString(
plotsDir)+Form(
"LUT_%d.gif",
i));
517 cc->Clear(); hslope[0]->Draw(
"colz"); cc->SetGridx(); cc->SetGridy(); cc->Print(TString(
plotsDir)+
"GainLutScatterHBHE.pdf");
518 cc->Clear(); hslope[1]->Draw(
"colz"); cc->SetGridx(); cc->SetGridy(); cc->Print(TString(
plotsDir)+
"GainLutScatterLutHF.pdf");
520 for(
int i=0;
i<2; ++
i){
522 houtput[0][
i]->Draw(
"box");
523 houtput[1][
i]->Draw(
"samebox");
524 houtput[2][
i]->Draw(
"samebox");
525 houtput[3][
i]->Draw(
"samebox");
526 cc->Print(TString(
plotsDir)+Form(
"OUT_%d.gif",
i));
T getParameter(std::string const &) const
bool valid(const DetId &id) const override
CaloTopology const * topology(0)
#define DEFINE_FWK_MODULE(type)
uint32_t rawId() const
get the raw id
Container::value_type value_type
void addDefault(ParameterSetDescription const &psetDescription)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Abs< T >::type abs(const T &t)
std::vector< std::string > quality_
std::vector< std::string > gains_
HcalLutAnalyzer(const edm::ParameterSet &)
base
Make Sure CMSSW is Setup ##.
~HcalLutAnalyzer() override
std::vector< std::string > pedestals_
void analyze(const edm::Event &, const edm::EventSetup &) override
DecomposeProduct< arg, typename Div::arg > D
std::vector< std::string > respcorrs_
std::vector< std::string > tags_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::string fullPath() const
HcalGenericSubdetector genericSubdet() const
bool validHT(const HcalTrigTowerDetId &id) const