20 m_expectedChamberLayer(2),
21 m_detailedHashIds(nullptr),
22 m_onlyExpectPrecisionHashIds(false),
23 m_hashName(
"hash_overview"),
25 m_allChan1dName(
"all_chan_1d"),
26 m_allChan1dTitle(
"(View of All Channels)"),
27 m_allChan2dName(
"all_chan_2d"),
28 m_allChan2dTitle(
"(View of All Channels)"),
29 m_chamProfName(
"profile_all_sectors"),
31 m_layHistName(
"overview"),
33 m_chamSummHistName(
"spectrum"),
34 m_chamSummHistTitle(
""),
35 m_chamHistName(
"overview"),
37 m_laySummHistName(
"spectrum"),
38 m_laySummHistTitle(
""),
41 m_monGroupVec(nullptr),
75 ATH_MSG_DEBUG(
"Constructing list of expected chamber layers" );
80 const std::vector<Identifier> &
ids =
m_idHelperSvc->cscIdHelper().idVector();
83 for(
const auto & thisChamberId:
ids)
86 m_idHelperSvc->cscIdHelper().get_module_hash(thisChamberId,chamberHash);
90 std::vector<Identifier> stripVect;
91 m_idHelperSvc->cscIdHelper().idChannels(thisChamberId,stripVect);
92 for(
const auto & thisStrip:stripVect)
95 m_idHelperSvc->cscIdHelper().get_channel_hash(thisStrip,stripHash);
96 bool measuresPhi =
m_idHelperSvc->cscIdHelper().measuresPhi(thisStrip);
102 == (
unsigned int)
m_idHelperSvc->cscIdHelper().chamberLayer(thisStrip)
108 ATH_MSG_VERBOSE(
"hash " << (
int)stripHash <<
" is prec and expected" );
113 ATH_MSG_VERBOSE(
"hash " << (
int)stripHash <<
" is NOT expected (Not a bug, just populating list)." );
119 for(
unsigned int chanItr =0; chanItr <=
m_maxHashId; chanItr++)
127 return StatusCode::SUCCESS;
140 std::string dataTypeName, std::string dataTypeTitle, std::string categoryName, std::string categoryTitle,
141 std::string axisLabel,
int numBins,
float lowBound,
float highBound, std::string parDir,
157 std::string endDir =
"";
159 endDir =
"/" + parDir;
162 std::string allChambersDirectory =
"/GeneralCscHists";
176 std::string nameStart = std::move(dataTypeName) ;
177 if(categoryName !=
"" )
178 nameStart +=
"_" + categoryName;
180 std::string titleStart = categoryTitle +
" " + dataTypeTitle;
181 std::string yaxis=
"", xaxis =
"";
183 ATH_MSG_DEBUG(
"In bookHistCollection for " << nameStart <<
" series." );
187 for(
int measuresPhi =0; measuresPhi <=1; measuresPhi++) {
188 std::string
name =
"h_" + nameStart+
"_" + (measuresPhi ?
"phi" :
"eta") +
"_spectrum" ;
189 std::string
title = titleStart +
" " + (measuresPhi ?
"Phi Strips" :
"Eta Strips") +
" spectrum";
191 specHist->GetYaxis()->SetTitle(
"Counts");
192 specHist->GetXaxis()->SetTitle(axisLabel.c_str());
214 std::string
title = categoryTitle +
" " + dataTypeTitle +
" " +
m_hashTitle;
216 xaxis =
"Channel Hash ID";
218 hashHist->GetXaxis()->SetTitle(xaxis.c_str());
219 hashHist->GetYaxis()->SetTitle(yaxis.c_str());
225 if (!
monGroup.regHist(hashHist).isSuccess())
246 TH1F * allChan1dHistX =
new TH1F((
name+
"X").c_str(), (
title+
" - Precision strips").c_str(),
248 allChan1dHistX->GetXaxis()->SetTitle(xaxis.c_str());
249 allChan1dHistX->GetYaxis()->SetTitle(yaxis.c_str());
254 if (!
monGroup.regHist(allChan1dHistX).isSuccess())
264 TH1F * allChan1dHistY =
new TH1F((
name+
"Y").c_str(), (
title +
" - Transverse strips").c_str(),
266 allChan1dHistY->GetXaxis()->SetTitle(xaxis.c_str());
267 allChan1dHistY->GetYaxis()->SetTitle(yaxis.c_str());
270 if (!
monGroup.regHist(allChan1dHistY).isSuccess())
288 yaxis =
"Sector/Layer";
289 xaxis =
"Strip Number (Negative for Transverse Strips)";
315 nxbins,nxmin,nxmax,nybins,nymin,nymax);
316 allChan2dHist->GetXaxis()->SetTitle(xaxis.c_str());
317 allChan2dHist->GetYaxis()->SetTitle(yaxis.c_str());
322 if (!
monGroup.regHist(allChan2dHist).isSuccess())
336 yaxis =
"Average " + axisLabel;
337 xaxis =
"Sector * eta";
340 numSectors + 1, -16, 17);
341 chamProf->GetXaxis()->SetTitle(xaxis.c_str());
342 chamProf->GetYaxis()->SetTitle(yaxis.c_str());
347 if (!
monGroup.regHist(chamProf).isSuccess())
362 ATH_MSG_DEBUG(
"Registering set with prefix" << namePrefix );
367 ATH_MSG_ERROR(
"failed to register " << namePrefix <<
" (layer histograms) " );
379 ATH_MSG_DEBUG(
"Registering set with prefix" << namePrefix );
385 <<
" (chamber summary histograms) " );
397 ATH_MSG_DEBUG(
"Registering set with prefix" << namePrefix );
403 <<
" (chamber summary histograms) " );
415 ATH_MSG_DEBUG(
"Registering set with prefix" << namePrefix );
418 namePrefix, titlePrefix, xaxis,yaxis,
421 ATH_MSG_ERROR(
" Failed to register " << namePrefix <<
" (Layer summary hists) " );
426 return StatusCode::SUCCESS;
428 return StatusCode::FAILURE;
432 std::string xaxis, std::string yaxis,
433 bool chanView,
bool ignoreY,
unsigned int numBins,
443 std::string orientationName =
"prec";
444 std::string orientationTitle =
"Precision Direction";
446 int numHists = 32 * ( (ignoreY) ? 4 : 8);
447 histVector.resize(numHists,
nullptr);
449 ATH_MSG_DEBUG(
"Allocated space for " << numHists <<
" histograms" );
451 const std::vector<Identifier> &
ids =
m_idHelperSvc->cscIdHelper().idVector();
452 for(
const auto & thisChamberId:
ids)
455 m_idHelperSvc->cscIdHelper().get_module_hash(thisChamberId,chamHash);
456 ATH_MSG_DEBUG(
"Booking histograms for chamber with hash " << (
int)chamHash );
458 stationSize =
m_idHelperSvc->cscIdHelper().stationName(thisChamberId);
463 for(
unsigned int orientationItr = 0; orientationItr < 2; orientationItr++)
465 if(orientationItr ==1)
475 orientationName =
"trans";
476 orientationTitle =
"Transverse Direction";
486 orientationName =
"prec";
487 orientationTitle =
"Precision Direction";
490 for(
unsigned int layItr = 1; layItr <= 4; layItr++)
493 <<
" With highbound/lowbound/nbins "
496 std::stringstream nameStream;
497 nameStream.setf(std::ios::right, std::ios::adjustfield);
498 nameStream << namePrefix;
499 nameStream <<
"_" << orientationName <<
"_eta_";
500 nameStream << ((
stationEta == 1) ?
"1" :
"0");
501 nameStream <<
"_sector_" << std::setw(2) << std::setfill(
'0') << sector;
502 nameStream <<
"_layer_" << layItr;
504 std::stringstream titleStream;
505 titleStream << titlePrefix <<
", " << orientationTitle;
506 titleStream <<
", Sector " << sector;
508 titleStream <<
", Layer " << layItr;
511 << titleStream.str() <<
"On orientation " << orientationItr <<
" With highbound/lowbound/nbins " <<
highBound <<
"/" <<
lowBound <<
"/" << numBins );
513 TH1F*
hist =
new TH1F(nameStream.str().c_str(), titleStream.str().c_str(),
515 hist->GetXaxis()->SetTitle(xaxis.c_str());
516 hist->GetYaxis()->SetTitle(yaxis.c_str());
530 <<
" with layIndex" << layIndex );
531 return StatusCode::FAILURE;
535 ATH_MSG_DEBUG(
"Succesfully registered histogram with layIndex "
536 << layIndex <<
" and name " <<
hist->GetName() );
537 histVector[layIndex] =
hist;
542 return StatusCode::SUCCESS;
547 std::string namePrefix, std::string titlePrefix,
548 std::string xaxis, std::string yaxis,
bool chanView,
549 bool ignoreY,
unsigned int numBins,
554 static const int chanViewNBinsX = 800;
555 static const double chanViewLowBoundX = .5;
556 static const double chanViewHighBoundX = 800.5;
558 static const int chanViewNBinsY = 200;
559 static const double chanViewLowBoundY = .5;
560 static const double chanViewHighBoundY = 200.5;
567 std::string orientationName =
"prec";
568 std::string orientationTitle =
"Precision Direction";
570 int numHists = (ignoreY) ? 32 : 64;
571 histVector.resize(numHists,
nullptr);
573 const std::vector<Identifier> &
ids =
m_idHelperSvc->cscIdHelper().idVector();
575 for(
const auto & thisChamberId:
ids)
578 m_idHelperSvc->cscIdHelper().get_module_hash(thisChamberId,chamHash);
579 ATH_MSG_DEBUG(
"Booking histograms for chamber with hash " << (
int)chamHash );
581 stationSize =
m_idHelperSvc->cscIdHelper().stationName(thisChamberId);
586 for(
unsigned int orientationItr = 0; orientationItr < 2; orientationItr++)
588 if(orientationItr ==1)
592 orientationName =
"trans";
593 orientationTitle =
"Transverse Direction";
595 numBins = chanViewNBinsY;
602 orientationName =
"prec";
603 orientationTitle =
"Precision Direction";
605 numBins = chanViewNBinsX;
611 std::stringstream nameStream;
612 nameStream.setf(std::ios::right, std::ios::adjustfield);
613 nameStream << namePrefix <<
"_" << orientationName <<
"_eta_"
614 << ((
stationEta == 1) ?
"1" :
"0") <<
"_sector_"
615 << std::setw(2) << std::setfill(
'0')
618 std::stringstream titleStream;
620 titleStream << titlePrefix <<
", " << orientationTitle
622 <<
", Sector " << sector;
624 TH1F*
hist =
new TH1F(nameStream.str().c_str(), titleStream.str().c_str()
626 hist->GetXaxis()->SetTitle(xaxis.c_str());
627 hist->GetYaxis()->SetTitle(yaxis.c_str());
633 <<
hist->GetName() <<
" and chamIndex " << chamIndex );
635 histVector[chamIndex] =
hist;
647 return StatusCode::SUCCESS;
665 std::string statDbName =
"stat_cool";
666 std::string statDbTitle =
"Status Word Value From COOL";
667 std::string statDbAxisLabel =
"Stat Word Value";
668 unsigned int statDbNumBins = 8;
669 float statDbMin = -0.5;
670 float statDbMax = 7.5;
671 std::string statDbSubDir =
"StatCool";
674 statDbAxisLabel, statDbNumBins, statDbMin, statDbMax, statDbSubDir);
680 for(
unsigned int chanItr = 0; chanItr <=
m_maxHashId; chanItr++){
683 if(!readCdo->readChannelStatus(chanItr, statWord).isSuccess()){
696 return StatusCode::SUCCESS;
702 ATH_MSG_DEBUG(
"CscCalibMonToolBase :: in fillHistograms()" );
704 return StatusCode::SUCCESS;
711 ATH_MSG_DEBUG(
"CscCalibMonToolBase : in procHistograms()" );
719 return StatusCode::RECOVERABLE;
722 ATH_MSG_DEBUG(
"There are " << calibContainer->
size() <<
" parameters to monitor" );
729 return StatusCode::SUCCESS;
740 return StatusCode::SUCCESS;
749 return StatusCode::SUCCESS;
756 ATH_MSG_DEBUG(
"CscCalibMonToolBase : in preProcParameter" );
757 return StatusCode::SUCCESS;
774 if (procParameterInput->
doChi2)
785 int numFailures = 0, maxFailures = 10;
788 const int hashId =
chan->hashId();
789 const float val =
chan->value();
794 missingChannels.erase(hashId);
797 if(procParameterInput->
dbName !=
"")
800 if(!(readCdo->readChannelParam(hashId, oldVal, procParameterInput->
dbName)).isSuccess())
804 <<
" for channel " << hashId
805 <<
" from COOL database. Continuing with COOL value = 0"
807 if(numFailures==maxFailures)
810 << maxFailures <<
" failed retrievals. Quiting. " );
811 return StatusCode::FAILURE;
826 ATH_MSG_INFO(
"CscCalibMonToolBase : Possible problem! " << parVals->parName()
827 <<
" measurement of " <<
val <<
" varies by " <<
diff
828 <<
" from expected value of " << oldVal <<
" on channel with hash Id "
829 << hashId <<
". Specified maximum variance is " << procParameterInput->
maxDiff );
831 procParameterInput->
badHist->Fill(procParameterInput->
badBin);
835 if(procParameterInput->
doChi2)
837 chi2_ndf =
chan->chi2()/
chan->ndf();
838 if(chi2_ndf > procParameterInput->
chi2Max)
855 (*procParameterInput->
vals)[hashId] =
val;
856 if((procParameterInput->
errors->size()))
858 if(procParameterInput->
oldVals)
859 (*procParameterInput->
oldVals)[hashId] = oldVal;
860 if(procParameterInput->
diffs)
861 (*procParameterInput->
diffs)[hashId] =
diff;
862 if(procParameterInput->
doChi2)
863 (*procParameterInput->
chi2s)[hashId] = chi2_ndf;
867 if(missingChannels.size() !=0)
869 for(
const auto & thisChan: missingChannels)
875 if(!procParameterInput->
missingChans->GetBinContent(thisChan+1))
883 return StatusCode::SUCCESS;
905 ATH_MSG_DEBUG(
"Copying data to hist collection, doing: All Channels (hash view):"
907 <<
"All Channels (1d view) " << (
int)doHash
908 <<
"All Channels (2d view) " << (
int)doHash
909 <<
" layer overview " << (
int)doLayChan
910 <<
" layer spectrum " << (
int)doLaySummary
911 <<
" sector prof " << (
int)doChamAvg
912 <<
" chamber overview " << (
int)doChamChan
913 <<
" chamber spectrum " << (
int)doChamSummary
921 const std::vector<Identifier> &
ids =
m_idHelperSvc->cscIdHelper().idVector();
922 for(
const auto & thisChamberId:
ids)
925 m_idHelperSvc->cscIdHelper().get_module_hash(thisChamberId,chamHash);
926 ATH_MSG_DEBUG(
"Copying data to histograms for chamber with hash" << (
int)chamHash );
928 unsigned int stationSize =
m_idHelperSvc->cscIdHelper().stationName(thisChamberId);
937 std::vector<Identifier> stripVect;
938 m_idHelperSvc->cscIdHelper().idChannels(thisChamberId,stripVect);
940 for(
const auto & thisStrip:stripVect)
942 unsigned int chamberLayer =
m_idHelperSvc->cscIdHelper().chamberLayer(thisStrip);
943 if(chamberLayer != 2)
945 int measuresPhi =
m_idHelperSvc->cscIdHelper().measuresPhi(thisStrip);
950 m_idHelperSvc->cscIdHelper().get_channel_hash(thisStrip,stripHash);
954 float datum =
data.at(stripHash);
958 <<
"\tsecLayer: " << secLayer
959 <<
"\tdata: " << datum );
974 <<
"\tsecLayer: " << secLayer
975 <<
"\tdata: " << datum );
978 double modifiedStripNum =
981 + ((
strip-1) * .25 /(48))
987 modifiedStripNum, datum);
989 double modifiedStripNum =
992 + ((
strip-1) * .25 /(192 ))
997 modifiedStripNum, datum);
1005 <<
"\tsecLayer: " << secLayer
1006 <<
"\tdata: " << datum );
1009 int modifiedStripNum =
static_cast<int>(
strip) * (measuresPhi ? -1 : 1);
1011 modifiedStripNum, secLayer, std::abs(datum));
1041 int shiftedStrip =
strip + (
layer-1)*( measuresPhi ? 50 : 200);
1043 (*(
histCollection->chamHistVect))[chamIndex]->SetBinContent(shiftedStrip,datum);
1052 return StatusCode::SUCCESS;
1057 int layIndex = measuresPhi*32*4
1066 int chamIndex = measuresPhi*32
1099 std::stringstream
ss;
1101 static const std::string histStr =
"/_hists";
1102 static const std::string errorDir =
"/ERROR";
1104 ss << std::setfill(
'0');
1109 ss <<
"/CscOverview";
1114 if(endCap ==
"ERROR")
1120 ss <<
"/EndCap" << endCap;
1128 if(sector <1 || sector > 16)
1134 ss <<
"/Sector" << std::setw(2) << sector;
1136 if(wireLayer == -9999)
1142 if(wireLayer < 1 || wireLayer > 4)
1144 ATH_MSG_ERROR(
"WireLayer " << wireLayer <<
" is invalid." );
1148 ss <<
"/Layer" << wireLayer;
1150 if(measuresPhi == -9999)
1156 if(measuresPhi < 0 || measuresPhi > 1)
1158 ATH_MSG_ERROR(
"MeasuresPhi " << measuresPhi <<
" is invalid." );
1162 ss << (measuresPhi ?
"/Phi" :
"/Eta");
1172 ATH_MSG_ERROR(
"Channel " <<
channel <<
" is invalid for a " << (measuresPhi ?
"phi layers" :
"eta layer") );
1177 ss <<
"/Channel" << std::setw( measuresPhi ? 2 : 3 ) <<
channel;
1186 std::stringstream
ss;
1190 if(histTypeDir !=
"")
1191 ss <<
"/" << histTypeDir;
1193 if(parTypeDir !=
"")
1194 ss <<
"/" << parTypeDir;