CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes
CastorPedestalAnalysis Class Reference

#include <CastorPedestalAnalysis.h>

Public Member Functions

 CastorPedestalAnalysis (const edm::ParameterSet &ps)
 Constructor. More...
 
int done (const CastorPedestals *fInputPedestals, const CastorPedestalWidths *fInputWidths, CastorPedestals *fOutputPedestals, CastorPedestalWidths *fOutputWidths)
 
void processEvent (const CastorDigiCollection &castor, const CastorDbService &cond)
 
void SampleAnalysis ()
 
void setup (const std::string &m_outputFileROOT)
 
 ~CastorPedestalAnalysis ()
 Destructor. More...
 

Static Public Member Functions

static int CastorPedVal (int nstat[4], const CastorPedestals *fRefPedestals, const CastorPedestalWidths *fRefPedestalWidths, CastorPedestals *fRawPedestals, CastorPedestalWidths *fRawPedestalWidths, CastorPedestals *fValPedestals, CastorPedestalWidths *fValPedestalWidths)
 

Private Types

typedef std::pair< TH1F *, std::pair< std::map< int, std::vector< double > >, std::vector< TH1F * > > > PEDBUNCH
 

Private Member Functions

void AllChanHists (const HcalDetId detid, const HcalQIESample &qie0, const HcalQIESample &qie1, const HcalQIESample &qie2, const HcalQIESample &qie3, const HcalQIESample &qie4, const HcalQIESample &qie5, std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT)
 
void GetPedConst (std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, TH1F *PedMeans, TH1F *PedWidths)
 
void per2CapsHists (int flag, int id, const HcalDetId detid, const HcalQIESample &qie1, const HcalQIESample &qie2, std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, const CastorDbService &cond)
 
void Trendings (std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, TH1F *Chi2, TH1F *CapidAverage, TH1F *CapidChi2)
 

Private Attributes

std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
 
struct {
   TH1F *   ALLPEDS
 
   TH1F *   CAPID_AVERAGE
 
   TH1F *   CAPID_CHI2
 
   TH1F *   CHI2
 
   TH1F *   PEDMEAN
 
   TH1F *   PEDRMS
 
   std::map< HcalDetId, std::map< int, PEDBUNCH > >   PEDTRENDS
 
castorHists
 
int evt
 
int evt_curr
 
CastorPedestalsfRawPedestals
 
CastorPedestalWidthsfRawPedestalWidths
 
const CastorPedestalsfRefPedestals
 
const CastorPedestalWidthsfRefPedestalWidths
 
CastorPedestalsfValPedestals
 
CastorPedestalWidthsfValPedestalWidths
 
int m_AllPedsOK
 
const CastorQIECoderm_coder
 
int m_endTS
 
TFile * m_file
 
int m_hiSaveflag
 
std::ofstream m_logFile
 
int m_nevtsample
 
std::string m_outputFileMean
 
std::string m_outputFileROOT
 
std::string m_outputFileWidth
 
int m_pedsinADC
 
int m_pedValflag
 
const CastorQIEShapem_shape
 
int m_startTS
 
float m_stat [4]
 
int sample
 
std::vector< bool > state
 

Static Private Attributes

static const int fitflag = 0
 

Detailed Description

Definition at line 36 of file CastorPedestalAnalysis.h.

Member Typedef Documentation

◆ PEDBUNCH

typedef std::pair<TH1F*, std::pair<std::map<int, std::vector<double> >, std::vector<TH1F*> > > CastorPedestalAnalysis::PEDBUNCH
private

Definition at line 82 of file CastorPedestalAnalysis.h.

Constructor & Destructor Documentation

◆ CastorPedestalAnalysis()

CastorPedestalAnalysis::CastorPedestalAnalysis ( const edm::ParameterSet ps)

Constructor.

Definition at line 14 of file CastorPedestalAnalysis.cc.

References castorHists, evt, edm::ParameterSet::getUntrackedParameter(), mps_fire::i, dqmdumpme::k, m_AllPedsOK, m_endTS, m_file, m_hiSaveflag, m_nevtsample, m_outputFileMean, m_outputFileROOT, m_outputFileWidth, m_pedsinADC, m_pedValflag, m_startTS, m_stat, sample, state, and AlCaHLTBitMon_QueryRunRegistry::string.

15  : fRefPedestals(nullptr),
16  fRefPedestalWidths(nullptr),
17  fRawPedestals(nullptr),
18  fRawPedestalWidths(nullptr),
19  fValPedestals(nullptr),
20  fValPedestalWidths(nullptr) {
21  evt = 0;
22  sample = 0;
23  m_file = nullptr;
24  m_AllPedsOK = 0;
25  for (int i = 0; i < 4; i++)
26  m_stat[i] = 0;
27  for (int k = 0; k < 4; k++)
28  state.push_back(true);
29 
30  // user cfg parameters
31  m_outputFileMean = ps.getUntrackedParameter<std::string>("outputFileMeans", "");
32  if (!m_outputFileMean.empty()) {
33  edm::LogWarning("Castor") << "Castor pedestal means will be saved to " << m_outputFileMean.c_str();
34  }
35  m_outputFileWidth = ps.getUntrackedParameter<std::string>("outputFileWidths", "");
36  if (!m_outputFileWidth.empty()) {
37  edm::LogWarning("Castor") << "Castor pedestal widths will be saved to " << m_outputFileWidth.c_str();
38  }
39  m_outputFileROOT = ps.getUntrackedParameter<std::string>("outputFileHist", "");
40  if (!m_outputFileROOT.empty()) {
41  edm::LogWarning("Castor") << "Castor pedestal histograms will be saved to " << m_outputFileROOT.c_str();
42  }
43  m_nevtsample = ps.getUntrackedParameter<int>("nevtsample", 0);
44  // for compatibility with previous versions
45  if (m_nevtsample == 9999999)
46  m_nevtsample = 0;
47  m_pedsinADC = ps.getUntrackedParameter<int>("pedsinADC", 0);
48  m_hiSaveflag = ps.getUntrackedParameter<int>("hiSaveflag", 0);
49  m_pedValflag = ps.getUntrackedParameter<int>("pedValflag", 0);
50  if (m_pedValflag < 0)
51  m_pedValflag = 0;
52  if (m_nevtsample > 0 && m_pedValflag > 0) {
53  edm::LogWarning("Castor") << "WARNING - incompatible cfg options: nevtsample = " << m_nevtsample
54  << ", pedValflag = " << m_pedValflag;
55  edm::LogWarning("Castor") << "Setting pedValflag = 0";
56  m_pedValflag = 0;
57  }
58  if (m_pedValflag > 1)
59  m_pedValflag = 1;
60  m_startTS = ps.getUntrackedParameter<int>("firstTS", 0);
61  if (m_startTS < 0)
62  m_startTS = 0;
63  m_endTS = ps.getUntrackedParameter<int>("lastTS", 9);
64 
65  // m_logFile.open("CastorPedestalAnalysis.log");
66 
67  castorHists.ALLPEDS = new TH1F("Castor All Pedestals", "HF All Peds", 10, 0, 9);
68  castorHists.PEDRMS = new TH1F("Castor All Pedestal Widths", "HF All Pedestal RMS", 100, 0, 3);
69  castorHists.PEDMEAN = new TH1F("Castor All Pedestal Means", "HF All Pedestal Means", 100, 0, 9);
70  castorHists.CHI2 = new TH1F("Castor Chi2/ndf for whole range Gauss fit", "HF Chi2/ndf Gauss", 200, 0., 50.);
71 }
CastorPedestalWidths * fRawPedestalWidths
T getUntrackedParameter(std::string const &, T const &) const
CastorPedestalWidths * fValPedestalWidths
struct CastorPedestalAnalysis::@44 castorHists
const CastorPedestalWidths * fRefPedestalWidths
Log< level::Warning, false > LogWarning
const CastorPedestals * fRefPedestals

◆ ~CastorPedestalAnalysis()

CastorPedestalAnalysis::~CastorPedestalAnalysis ( )

Destructor.

Definition at line 74 of file CastorPedestalAnalysis.cc.

References _meot, castorHists, and mps_fire::i.

74  {
75  for (_meot = castorHists.PEDTRENDS.begin(); _meot != castorHists.PEDTRENDS.end(); _meot++) {
76  for (int i = 0; i < 16; i++)
77  _meot->second[i].first->Delete();
78  }
79 
80  castorHists.ALLPEDS->Delete();
81  castorHists.PEDRMS->Delete();
82  castorHists.PEDMEAN->Delete();
83  castorHists.CHI2->Delete();
84 }
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
struct CastorPedestalAnalysis::@44 castorHists

Member Function Documentation

◆ AllChanHists()

void CastorPedestalAnalysis::AllChanHists ( const HcalDetId  detid,
const HcalQIESample qie0,
const HcalQIESample qie1,
const HcalQIESample qie2,
const HcalQIESample qie3,
const HcalQIESample qie4,
const HcalQIESample qie5,
std::map< HcalDetId, std::map< int, PEDBUNCH > > &  toolT 
)
private

Definition at line 286 of file CastorPedestalAnalysis.cc.

References _meot, and HcalQIESample::adc().

Referenced by processEvent().

293  {
294  // this function is due to be called for every channel
295 
296  _meot = toolT.find(detid);
297  std::map<int, PEDBUNCH> _mei = _meot->second;
298  _mei[16].first->Fill(qie4.adc() + qie5.adc() - 1.);
299  _mei[17].first->Fill(qie4.adc() + qie5.adc() - qie2.adc() - qie3.adc());
300  _mei[18].first->Fill(qie4.adc() + qie5.adc() - (qie0.adc() + qie1.adc() + qie2.adc() + qie3.adc()) / 2.);
301 }
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
constexpr int adc() const
get the ADC sample
Definition: HcalQIESample.h:43

◆ CastorPedVal()

int CastorPedestalAnalysis::CastorPedVal ( int  nstat[4],
const CastorPedestals fRefPedestals,
const CastorPedestalWidths fRefPedestalWidths,
CastorPedestals fRawPedestals,
CastorPedestalWidths fRawPedestalWidths,
CastorPedestals fValPedestals,
CastorPedestalWidths fValPedestalWidths 
)
static

Definition at line 715 of file CastorPedestalAnalysis.cc.

References CastorCondObjectContainer< Item >::addValues(), DMR_cfg::cerr, fRawPedestals, fRawPedestalWidths, fRefPedestals, fRefPedestalWidths, fValPedestals, fValPedestalWidths, CastorCondObjectContainer< Item >::getAllChannels(), CastorPedestalWidth::getSigma(), CastorPedestal::getValue(), CastorCondObjectContainer< Item >::getValues(), HcalForward, mps_fire::i, createfilelist::int, B2GTnPMonitor_cfi::item, CastorPedestalWidth::setSigma(), mathSSE::sqrt(), and ApeEstimator_cff::width.

Referenced by done().

721  {
722  // new version of pedestal validation - it is designed to be as independent of
723  // all the rest as possible - you only need to provide valid pedestal objects
724  // and a vector of statistics per capID to use this as standalone code
725  HcalDetId detid;
726  float RefPedVals[4];
727  float RefPedSigs[4][4];
728  float RawPedVals[4];
729  float RawPedSigs[4][4];
730  std::map<HcalDetId, bool> isinRaw;
731  std::map<HcalDetId, bool> isinRef;
732  std::vector<DetId> RefChanns = fRefPedestals->getAllChannels();
733  std::vector<DetId> RawChanns = fRawPedestals->getAllChannels();
734  std::ofstream PedValLog;
735  PedValLog.open("CastorPedVal.log");
736 
737  if (nstat[0] + nstat[1] + nstat[2] + nstat[3] < 2500)
738  PedValLog << "CastorPedVal: warning - low statistics" << std::endl;
739  // find complete list of channels in current data and reference
740  for (int i = 0; i < (int)RawChanns.size(); i++) {
741  isinRef[HcalDetId(RawChanns[i])] = false;
742  }
743  for (int i = 0; i < (int)RefChanns.size(); i++) {
744  detid = HcalDetId(RefChanns[i]);
745  isinRaw[detid] = false;
746  isinRef[detid] = true;
747  }
748  for (int i = 0; i < (int)RawChanns.size(); i++) {
749  detid = HcalDetId(RawChanns[i]);
750  isinRaw[detid] = true;
751  if (isinRef[detid] == false) {
752  PedValLog << "CastorPedVal: channel " << detid << " not found in reference set" << std::endl;
753  std::cerr << "CastorPedVal: channel " << detid << " not found in reference set" << std::endl;
754  }
755  }
756 
757  // main loop over channels
758  int erflag = 0;
759  for (int i = 0; i < (int)RefChanns.size(); i++) {
760  detid = HcalDetId(RefChanns[i]);
761  for (int icap = 0; icap < 4; icap++) {
762  RefPedVals[icap] = fRefPedestals->getValues(detid)->getValue(icap);
763  for (int icap2 = icap; icap2 < 4; icap2++) {
764  RefPedSigs[icap][icap2] = fRefPedestalWidths->getValues(detid)->getSigma(icap, icap2);
765  if (icap2 != icap)
766  RefPedSigs[icap2][icap] = RefPedSigs[icap][icap2];
767  }
768  }
769 
770  // read new raw values
771  if (isinRaw[detid]) {
772  for (int icap = 0; icap < 4; icap++) {
773  RawPedVals[icap] = fRawPedestals->getValues(detid)->getValue(icap);
774  for (int icap2 = icap; icap2 < 4; icap2++) {
775  RawPedSigs[icap][icap2] = fRawPedestalWidths->getValues(detid)->getSigma(icap, icap2);
776  if (icap2 != icap)
777  RawPedSigs[icap2][icap] = RawPedSigs[icap][icap2];
778  }
779  }
780 
781  // first quick check if raw values make sense: if not, the channel is treated like absent
782  for (int icap = 0; icap < 4; icap++) {
783  if (RawPedVals[icap] < 1. || RawPedSigs[icap][icap] < 0.01)
784  isinRaw[detid] = false;
785  for (int icap2 = icap; icap2 < 4; icap2++) {
786  if (fabs(RawPedSigs[icap][icap2] / sqrt(RawPedSigs[icap][icap] * RawPedSigs[icap2][icap2])) > 1.)
787  isinRaw[detid] = false;
788  }
789  }
790  }
791 
792  // check raw values against reference
793  if (isinRaw[detid]) {
794  for (int icap = 0; icap < 4; icap++) {
795  int icap2 = (icap + 1) % 4;
796  float width = sqrt(RawPedSigs[icap][icap]);
797  float erof1 = width / sqrt((float)nstat[icap]);
798  float erof2 = sqrt(erof1 * erof1 + RawPedSigs[icap][icap] / (float)nstat[icap]);
799  float erofwidth = width / sqrt(2. * nstat[icap]);
800  float diffof1 = RawPedVals[icap] - RefPedVals[icap];
801  float diffof2 = RawPedVals[icap] + RawPedVals[icap2] - RefPedVals[icap] - RefPedVals[icap2];
802  float diffofw = width - sqrt(RefPedSigs[icap][icap]);
803 
804  // validation in 2 TS for HB, HE, HO, in 1 TS for HF
805  int nTS = 2;
806  if (detid.subdet() == HcalForward)
807  nTS = 1;
808  if (nTS == 1 && fabs(diffof1) > 0.5 + erof1) {
809  erflag += 1;
810  PedValLog << "HcalPedVal: drift in channel " << detid << " cap " << icap << ": " << RawPedVals[icap] << " - "
811  << RefPedVals[icap] << " = " << diffof1 << std::endl;
812  }
813  if (nTS == 2 && fabs(diffof2) > 0.5 + erof2) {
814  erflag += 1;
815  PedValLog << "HcalPedVal: drift in channel " << detid << " caps " << icap << "+" << icap2 << ": "
816  << RawPedVals[icap] << "+" << RawPedVals[icap2] << " - " << RefPedVals[icap] << "+"
817  << RefPedVals[icap2] << " = " << diffof2 << std::endl;
818  }
819  if (fabs(diffofw) > 0.15 * width + erofwidth) {
820  erflag += 1;
821  PedValLog << "HcalPedVal: width changed in channel " << detid << " cap " << icap << ": " << width << " - "
822  << sqrt(RefPedSigs[icap][icap]) << " = " << diffofw << std::endl;
823  }
824  }
825  }
826 
827  // for disconnected/bad channels restore reference values
828  else {
829  PedValLog << "HcalPedVal: no valid data from channel " << detid << std::endl;
830  erflag += 100000;
831  CastorPedestal item(detid, RefPedVals[0], RefPedVals[1], RefPedVals[2], RefPedVals[3]);
833  CastorPedestalWidth widthsp(detid);
834  for (int icap = 0; icap < 4; icap++) {
835  for (int icap2 = icap; icap2 < 4; icap2++)
836  widthsp.setSigma(icap2, icap, RefPedSigs[icap2][icap]);
837  }
838  fValPedestalWidths->addValues(widthsp);
839  }
840 
841  // end of channel loop
842  }
843 
844  if (erflag == 0)
845  PedValLog << "HcalPedVal: all pedestals checked OK" << std::endl;
846 
847  // now construct the remaining part of the validated objects
848  // if nothing changed outside tolerance, validated set = reference set
849  if (erflag % 100000 == 0) {
850  for (int i = 0; i < (int)RefChanns.size(); i++) {
851  detid = HcalDetId(RefChanns[i]);
852  if (isinRaw[detid]) {
853  CastorPedestalWidth widthsp(detid);
854  for (int icap = 0; icap < 4; icap++) {
855  RefPedVals[icap] = fRefPedestals->getValues(detid)->getValue(icap);
856  for (int icap2 = icap; icap2 < 4; icap2++) {
857  RefPedSigs[icap][icap2] = fRefPedestalWidths->getValues(detid)->getSigma(icap, icap2);
858  if (icap2 != icap)
859  RefPedSigs[icap2][icap] = RefPedSigs[icap][icap2];
860  widthsp.setSigma(icap2, icap, RefPedSigs[icap2][icap]);
861  }
862  }
863  fValPedestalWidths->addValues(widthsp);
864  CastorPedestal item(detid, RefPedVals[0], RefPedVals[1], RefPedVals[2], RefPedVals[3]);
866  }
867  }
868  }
869 
870  // if anything changed, validated set = raw set + reference for missing/bad channels
871  else {
872  for (int i = 0; i < (int)RawChanns.size(); i++) {
873  detid = HcalDetId(RawChanns[i]);
874  if (isinRaw[detid]) {
875  CastorPedestalWidth widthsp(detid);
876  for (int icap = 0; icap < 4; icap++) {
877  RawPedVals[icap] = fRawPedestals->getValues(detid)->getValue(icap);
878  for (int icap2 = icap; icap2 < 4; icap2++) {
879  RawPedSigs[icap][icap2] = fRawPedestalWidths->getValues(detid)->getSigma(icap, icap2);
880  if (icap2 != icap)
881  RawPedSigs[icap2][icap] = RawPedSigs[icap][icap2];
882  widthsp.setSigma(icap2, icap, RawPedSigs[icap2][icap]);
883  }
884  }
885  fValPedestalWidths->addValues(widthsp);
886  CastorPedestal item(detid, RawPedVals[0], RawPedVals[1], RawPedVals[2], RawPedVals[3]);
888  }
889  }
890  }
891  return erflag;
892 }
const Item * getValues(DetId fId, bool throwOnFail=true) const
CastorPedestalWidths * fRawPedestalWidths
std::vector< DetId > getAllChannels() const
float getSigma(int fCapId1, int fCapId2) const
get correlation element for capId1/2 = 0..3
CastorPedestalWidths * fValPedestalWidths
T sqrt(T t)
Definition: SSEVec.h:19
bool addValues(const Item &myItem)
const CastorPedestalWidths * fRefPedestalWidths
float getValue(int fCapId) const
get value for capId = 0..3
const CastorPedestals * fRefPedestals

◆ done()

int CastorPedestalAnalysis::done ( const CastorPedestals fInputPedestals,
const CastorPedestalWidths fInputWidths,
CastorPedestals fOutputPedestals,
CastorPedestalWidths fOutputWidths 
)

Definition at line 477 of file CastorPedestalAnalysis.cc.

References castorHists, CastorPedVal(), evt, fRawPedestals, fRawPedestalWidths, fRefPedestals, fRefPedestalWidths, fValPedestals, fValPedestalWidths, mps_fire::i, m_AllPedsOK, m_file, m_nevtsample, m_outputFileROOT, m_pedValflag, m_stat, SampleAnalysis(), and Trendings().

480  {
481  int nstat[4];
482 
483  // Pedestal objects
484  // inputs...
485  fRefPedestals = fInputPedestals;
486  fRefPedestalWidths = fInputPedestalWidths;
487 
488  // outputs...
489  if (m_pedValflag > 0) {
490  fValPedestals = fOutputPedestals;
491  fValPedestalWidths = fOutputPedestalWidths;
494  } else {
495  fRawPedestals = fOutputPedestals;
496  fRawPedestalWidths = fOutputPedestalWidths;
499  }
500 
501  // compute pedestal constants
502  if (m_nevtsample < 1)
503  SampleAnalysis();
504  if (m_nevtsample > 0) {
505  if (evt % m_nevtsample != 0)
506  SampleAnalysis();
507  }
508 
509  // trending histos
510  if (m_nevtsample > 0) {
511  m_file->cd();
512  m_file->cd("Castor");
513  Trendings(castorHists.PEDTRENDS, castorHists.CHI2, castorHists.CAPID_AVERAGE, castorHists.CAPID_CHI2);
514  }
515 
516  if (m_nevtsample < 1) {
517  // pedestal validation: m_AllPedsOK=-1 means not validated,
518  // 0 everything OK,
519  // N>0 : mod(N,100000) drifts + width changes
520  // int(N/100000) missing channels
521  m_AllPedsOK = -1;
522  if (m_pedValflag > 0) {
523  for (int i = 0; i < 4; i++)
524  nstat[i] = (int)m_stat[i];
525  int NPedErrors = CastorPedVal(nstat,
532  m_AllPedsOK = NPedErrors;
533  }
534  // setting m_AllPedsOK=-2 will inhibit writing pedestals out
535  // if(m_pedValflag==1){
536  // if(evt<100)m_AllPedsOK=-2;
537  // }
538  }
539 
540  // Write other histograms.
541 
542  // Castor
543  m_file->cd();
544  m_file->cd("Castor");
545  castorHists.ALLPEDS->Write();
546  castorHists.PEDRMS->Write();
547  castorHists.PEDMEAN->Write();
548 
549  m_file->Close();
550  edm::LogWarning("Castor") << "Hcal/Castor histograms written to " << m_outputFileROOT.c_str();
551  return (int)m_AllPedsOK;
552 }
CastorPedestalWidths * fRawPedestalWidths
static int CastorPedVal(int nstat[4], const CastorPedestals *fRefPedestals, const CastorPedestalWidths *fRefPedestalWidths, CastorPedestals *fRawPedestals, CastorPedestalWidths *fRawPedestalWidths, CastorPedestals *fValPedestals, CastorPedestalWidths *fValPedestalWidths)
void Trendings(std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, TH1F *Chi2, TH1F *CapidAverage, TH1F *CapidChi2)
CastorPedestalWidths * fValPedestalWidths
struct CastorPedestalAnalysis::@44 castorHists
const CastorPedestalWidths * fRefPedestalWidths
Log< level::Warning, false > LogWarning
const CastorPedestals * fRefPedestals

◆ GetPedConst()

void CastorPedestalAnalysis::GetPedConst ( std::map< HcalDetId, std::map< int, PEDBUNCH > > &  toolT,
TH1F *  PedMeans,
TH1F *  PedWidths 
)
private

Definition at line 317 of file CastorPedestalAnalysis.cc.

References _meot, CastorCondObjectContainer< Item >::addValues(), HLT_2024v10_cff::cap, nano_mu_local_reco_cff::chi2, fitflag, fRawPedestals, fRawPedestalWidths, mps_fire::i, B2GTnPMonitor_cfi::item, dqmiolumiharvest::j, m_endTS, m_hiSaveflag, m_nevtsample, m_pedsinADC, m_startTS, m_stat, CastorPedestalWidth::setSigma(), and mathSSE::sqrt().

Referenced by SampleAnalysis().

319  {
320  // Completely rewritten version oct 2006
321  // Compute pedestal constants and fill into CastorPedestals and CastorPedestalWidths objects
322  float cap[4];
323  float sig[4][4];
324  float dcap[4];
325  float dsig[4][4];
326  float chi2[4];
327 
328  for (_meot = toolT.begin(); _meot != toolT.end(); _meot++) {
329  HcalDetId detid = _meot->first;
330 
331  // take mean and width from a Gaussian fit or directly from the histo
332  if (fitflag > 0) {
333  for (int i = 0; i < 4; i++) {
334  TF1* fit = _meot->second[i].first->GetFunction("gaus");
335  chi2[i] = 0;
336  if (fit->GetNDF() != 0)
337  chi2[i] = fit->GetChisquare() / fit->GetNDF();
338  cap[i] = fit->GetParameter(1);
339  sig[i][i] = fit->GetParameter(2);
340  dcap[i] = fit->GetParError(1);
341  dsig[i][i] = fit->GetParError(2);
342  }
343  } else {
344  for (int i = 0; i < 4; i++) {
345  cap[i] = _meot->second[i].first->GetMean();
346  sig[i][i] = _meot->second[i].first->GetRMS();
347  m_stat[i] = 0;
348 
349  for (int j = m_startTS; j < m_endTS + 1; j++) {
350  m_stat[i] += _meot->second[i].first->GetBinContent(j + 1);
351  }
352  dcap[i] = sig[i][i] / sqrt(m_stat[i]);
353  // dsig[i][i] = dcap[i]*sig[i][i]/cap[i];
354  dsig[i][i] = sig[i][i] / sqrt(2. * m_stat[i]);
355  chi2[i] = 0.;
356  }
357  }
358 
359  for (int i = 0; i < 4; i++) {
360  if (m_hiSaveflag > 0) {
361  if (m_pedsinADC)
362  _meot->second[i].first->GetXaxis()->SetTitle("ADC");
363  else
364  _meot->second[i].first->GetXaxis()->SetTitle("Charge, fC");
365  _meot->second[i].first->GetYaxis()->SetTitle("CapID samplings");
366  _meot->second[i].first->Write();
367  }
368  if (m_nevtsample > 0) {
369  _meot->second[i].second.first[0].push_back(cap[i]);
370  _meot->second[i].second.first[1].push_back(dcap[i]);
371  _meot->second[i].second.first[2].push_back(sig[i][i]);
372  _meot->second[i].second.first[3].push_back(dsig[i][i]);
373  _meot->second[i].second.first[4].push_back(chi2[i]);
374  }
375  PedMeans->Fill(cap[i]);
376  PedWidths->Fill(sig[i][i]);
377  }
378 
379  // special histos for Shuichi
380  if (m_hiSaveflag == -100) {
381  for (int i = 16; i < 19; i++) {
382  if (m_pedsinADC)
383  _meot->second[i].first->GetXaxis()->SetTitle("ADC");
384  else
385  _meot->second[i].first->GetXaxis()->SetTitle("Charge, fC");
386  _meot->second[i].first->GetYaxis()->SetTitle("Events");
387  _meot->second[i].first->Write();
388  }
389  }
390 
391  // diagonal sigma is width squared
392  sig[0][0] = sig[0][0] * sig[0][0];
393  sig[1][1] = sig[1][1] * sig[1][1];
394  sig[2][2] = sig[2][2] * sig[2][2];
395  sig[3][3] = sig[3][3] * sig[3][3];
396 
397  // off diagonal sigmas (correlations) are computed from 3 histograms
398  // here we still have all 4*3=12 combinations
399  sig[0][1] = _meot->second[4].first->GetMean() - cap[0] * cap[1];
400  sig[0][2] = _meot->second[8].first->GetMean() - cap[0] * cap[2];
401  sig[1][2] = _meot->second[5].first->GetMean() - cap[1] * cap[2];
402  sig[1][3] = _meot->second[9].first->GetMean() - cap[1] * cap[3];
403  sig[2][3] = _meot->second[6].first->GetMean() - cap[2] * cap[3];
404  sig[0][3] = _meot->second[12].first->GetMean() - cap[0] * cap[3];
405  sig[1][0] = _meot->second[13].first->GetMean() - cap[1] * cap[0];
406  sig[2][0] = _meot->second[10].first->GetMean() - cap[2] * cap[0];
407  sig[2][1] = _meot->second[14].first->GetMean() - cap[2] * cap[1];
408  sig[3][1] = _meot->second[11].first->GetMean() - cap[3] * cap[1];
409  sig[3][2] = _meot->second[15].first->GetMean() - cap[3] * cap[2];
410  sig[3][0] = _meot->second[7].first->GetMean() - cap[3] * cap[0];
411 
412  // there is no proper error calculation for the correlation coefficients
413  for (int i = 0; i < 4; i++) {
414  if (m_nevtsample > 0) {
415  _meot->second[i].second.first[5].push_back(sig[i][(i + 1) % 4]);
416  _meot->second[i].second.first[6].push_back(2 * sig[i][i] * dsig[i][i]);
417  _meot->second[i].second.first[7].push_back(sig[i][(i + 2) % 4]);
418  _meot->second[i].second.first[8].push_back(2 * sig[i][i] * dsig[i][i]);
419  _meot->second[i].second.first[9].push_back(sig[i][(i + 3) % 4]);
420  _meot->second[i].second.first[10].push_back(2 * sig[i][i] * dsig[i][i]);
421  }
422  // save product histos if desired
423  if (m_hiSaveflag > 10) {
424  if (m_pedsinADC)
425  _meot->second[i + 4].first->GetXaxis()->SetTitle("ADC^2");
426  else
427  _meot->second[i + 4].first->GetXaxis()->SetTitle("Charge^2, fC^2");
428  _meot->second[i + 4].first->GetYaxis()->SetTitle("2-CapID samplings");
429  _meot->second[i + 4].first->Write();
430  if (m_pedsinADC)
431  _meot->second[i + 8].first->GetXaxis()->SetTitle("ADC^2");
432  else
433  _meot->second[i + 8].first->GetXaxis()->SetTitle("Charge^2, fC^2");
434  _meot->second[i + 8].first->GetYaxis()->SetTitle("2-CapID samplings");
435  _meot->second[i + 8].first->Write();
436  if (m_pedsinADC)
437  _meot->second[i + 12].first->GetXaxis()->SetTitle("ADC^2");
438  else
439  _meot->second[i + 12].first->GetXaxis()->SetTitle("Charge^2, fC^2");
440  _meot->second[i + 12].first->GetYaxis()->SetTitle("2-CapID samplings");
441  _meot->second[i + 12].first->Write();
442  }
443  }
444 
445  // fill the objects - at this point only close and medium correlations are stored
446  // and the matrix is assumed symmetric
447  if (m_nevtsample < 1) {
448  sig[1][0] = sig[0][1];
449  sig[2][0] = sig[0][2];
450  sig[2][1] = sig[1][2];
451  sig[3][1] = sig[1][3];
452  sig[3][2] = sig[2][3];
453  sig[0][3] = sig[3][0];
454  if (fRawPedestals) {
455  CastorPedestal item(detid, cap[0], cap[1], cap[2], cap[3]);
457  }
458  if (fRawPedestalWidths) {
459  CastorPedestalWidth widthsp(detid);
460  widthsp.setSigma(0, 0, sig[0][0]);
461  widthsp.setSigma(0, 1, sig[0][1]);
462  widthsp.setSigma(0, 2, sig[0][2]);
463  widthsp.setSigma(1, 1, sig[1][1]);
464  widthsp.setSigma(1, 2, sig[1][2]);
465  widthsp.setSigma(1, 3, sig[1][3]);
466  widthsp.setSigma(2, 2, sig[2][2]);
467  widthsp.setSigma(2, 3, sig[2][3]);
468  widthsp.setSigma(3, 3, sig[3][3]);
469  widthsp.setSigma(3, 0, sig[0][3]);
470  fRawPedestalWidths->addValues(widthsp);
471  }
472  }
473  }
474 }
CastorPedestalWidths * fRawPedestalWidths
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
T sqrt(T t)
Definition: SSEVec.h:19
bool addValues(const Item &myItem)

◆ per2CapsHists()

void CastorPedestalAnalysis::per2CapsHists ( int  flag,
int  id,
const HcalDetId  detid,
const HcalQIESample qie1,
const HcalQIESample qie2,
std::map< HcalDetId, std::map< int, PEDBUNCH > > &  toolT,
const CastorDbService cond 
)
private

Definition at line 142 of file CastorPedestalAnalysis.cc.

References _meot, HcalQIESample::adc(), trigObjTnPSource_cfi::bins, HcalQIESample::capid(), castorHists, CastorQIECoder::charge(), HcalDetId::depth(), evt, RemoveAddSevLevel::flag, mps_fire::i, HcalDetId::ieta(), edm::eventsetup::heterocontainer::insert(), HcalDetId::iphi(), m_nevtsample, m_pedsinADC, Skims_PA_cff::name, l1trig_cff::shape, state, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by processEvent().

148  {
149  // this function is due to be called for every time slice, it fills either a charge
150  // histo for a single capID (flag=0) or a product histo for two capIDs (flag>0)
151 
152  static const int bins = 10;
153  static const int bins2 = 100;
154  float lo = -0.5;
155  float hi = 9.5;
156  std::map<int, PEDBUNCH> _mei;
157  static std::map<HcalDetId, std::map<int, float> > QieCalibMap;
158  std::string type = "Castor";
159 
160  /*
161  if(id==0){
162  if(detid.ieta()<16) type = "HB";
163  if(detid.ieta()>16) type = "HE";
164  if(detid.ieta()==16){
165  if(detid.depth()<3) type = "HB";
166  if(detid.depth()==3) type = "HE";
167  }
168  }
169  else if(id==1) type = "HO";
170  else if(id==2) type = "HF";
171  */
172 
173  _meot = toolT.find(detid);
174 
175  // if histos for the current channel do not exist, first create them,
176  if (_meot == toolT.end()) {
177  std::map<int, PEDBUNCH> insert;
178  std::map<int, float> qiecalib;
179  char name[1024];
180  for (int i = 0; i < 4; i++) {
181  lo = -0.5;
182  // fix from Andy: if you convert to fC and then bin in units of 1, you may 'skip' a bin while
183  // filling, since the ADCs are quantized
184  if (m_pedsinADC)
185  hi = 9.5;
186  else
187  hi = 11.5;
188  sprintf(
189  name, "%s Pedestal, eta=%d phi=%d d=%d cap=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth(), i);
190  insert[i].first = new TH1F(name, name, bins, lo, hi);
191  sprintf(name,
192  "%s Product, eta=%d phi=%d d=%d caps=%d*%d",
193  type.c_str(),
194  detid.ieta(),
195  detid.iphi(),
196  detid.depth(),
197  i,
198  (i + 1) % 4);
199  insert[4 + i].first = new TH1F(name, name, bins2, 0., 100.);
200  sprintf(name,
201  "%s Product, eta=%d phi=%d d=%d caps=%d*%d",
202  type.c_str(),
203  detid.ieta(),
204  detid.iphi(),
205  detid.depth(),
206  i,
207  (i + 2) % 4);
208  insert[8 + i].first = new TH1F(name, name, bins2, 0., 100.);
209  sprintf(name,
210  "%s Product, eta=%d phi=%d d=%d caps=%d*%d",
211  type.c_str(),
212  detid.ieta(),
213  detid.iphi(),
214  detid.depth(),
215  i,
216  (i + 3) % 4);
217  insert[12 + i].first = new TH1F(name, name, bins2, 0., 100.);
218  }
219  sprintf(name, "%s Signal in TS 4+5, eta=%d phi=%d d=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth());
220  insert[16].first = new TH1F(name, name, 21, -0.5, 20.5);
221  sprintf(
222  name, "%s Signal in TS 4+5-2-3, eta=%d phi=%d d=%d", type.c_str(), detid.ieta(), detid.iphi(), detid.depth());
223  insert[17].first = new TH1F(name, name, 21, -10.5, 10.5);
224  sprintf(name,
225  "%s Signal in TS 4+5-(0+1+2+3)/2., eta=%d phi=%d d=%d",
226  type.c_str(),
227  detid.ieta(),
228  detid.iphi(),
229  detid.depth());
230  insert[18].first = new TH1F(name, name, 21, -10.5, 10.5);
231  toolT[detid] = insert;
232  _meot = toolT.find(detid);
233  // store QIE calibrations in a map for later reuse
234  QieCalibMap[detid] = qiecalib;
235  }
236 
237  _mei = _meot->second;
238 
239  const CastorQIECoder* coder = cond.getCastorCoder(detid);
240  const CastorQIEShape* shape = cond.getCastorShape();
241  float charge1 = coder->charge(*shape, qie1.adc(), qie1.capid());
242  float charge2 = coder->charge(*shape, qie2.adc(), qie2.capid());
243 
244  // fill single capID histo
245  if (flag == 0) {
246  if (m_nevtsample > 0) {
247  if ((evt - 1) % m_nevtsample == 0 && state[qie1.capid()]) {
248  state[qie1.capid()] = false;
249  _mei[qie1.capid()].first->Reset();
250  _mei[qie1.capid() + 4].first->Reset();
251  _mei[qie1.capid() + 8].first->Reset();
252  _mei[qie1.capid() + 12].first->Reset();
253  }
254  }
255  if (qie1.adc() < bins) {
256  if (m_pedsinADC)
257  _mei[qie1.capid()].first->Fill(qie1.adc());
258  else
259  _mei[qie1.capid()].first->Fill(charge1);
260  } else if (qie1.adc() >= bins) {
261  _mei[qie1.capid()].first->AddBinContent(bins + 1, 1);
262  }
263  }
264 
265  // fill 2 capID histo
266  if (flag > 0) {
267  std::map<int, float> qiecalib = QieCalibMap[detid];
268  //float charge1=(qie1.adc()-qiecalib[qie1.capid()+4])/qiecalib[qie1.capid()];
269  //float charge2=(qie2.adc()-qiecalib[qie2.capid()+4])/qiecalib[qie2.capid()];
270  if (charge1 * charge2 < bins2) {
271  _mei[qie1.capid() + 4 * flag].first->Fill(charge1 * charge2);
272  } else {
273  _mei[qie1.capid() + 4 * flag].first->Fill(bins2);
274  }
275  }
276 
277  if (flag == 0) {
278  // if(id==0) hbHists.ALLPEDS->Fill(qie1.adc());
279  // else if(id==1) hoHists.ALLPEDS->Fill(qie1.adc());
280  // else if(id==2) castorHists.ALLPEDS->Fill(qie1.adc());
281  castorHists.ALLPEDS->Fill(qie1.adc());
282  }
283 }
float charge(const CastorQIEShape &fShape, unsigned fAdc, unsigned fCapId) const
ADC [0..127] + capid [0..3] -> fC conversion.
Definition: EPCuts.h:4
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
constexpr int capid() const
get the Capacitor id
Definition: HcalQIESample.h:47
struct CastorPedestalAnalysis::@44 castorHists
constexpr int adc() const
get the ADC sample
Definition: HcalQIESample.h:43
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164

◆ processEvent()

void CastorPedestalAnalysis::processEvent ( const CastorDigiCollection castor,
const CastorDbService cond 
)

Definition at line 95 of file CastorPedestalAnalysis.cc.

References AllChanHists(), castorDigitizer_cfi::castor, castorHists, evt, evt_curr, RemoveAddSevLevel::flag, mps_fire::i, CastorDataFrame::id(), createfilelist::int, dqmiolumiharvest::j, m_coder, m_endTS, m_nevtsample, m_shape, m_startTS, per2CapsHists(), CastorDataFrame::sample(), sample, SampleAnalysis(), and CastorDataFrame::size().

95  {
96  evt++;
97  sample = 1;
98  evt_curr = evt;
99  if (m_nevtsample > 0) {
100  sample = (evt - 1) / m_nevtsample + 1;
102  if (evt_curr == 0)
104  }
105 
106  m_shape = cond.getCastorShape();
107  // HF
108  if (castor.empty()) {
109  edm::LogError("CastorLedAnalysis") << "Event with " << (int)castor.size() << "Castor Digis passed." << std::endl;
110  return;
111  }
112 
113  for (CastorDigiCollection::const_iterator j = castor.begin(); j != castor.end(); ++j) {
114  const CastorDataFrame digi = (const CastorDataFrame)(*j);
115  m_coder = cond.getCastorCoder(digi.id());
116  for (int i = m_startTS; i < digi.size() && i <= m_endTS; i++) {
117  for (int flag = 0; flag < 4; flag++) {
118  if (i + flag < digi.size() && i + flag <= m_endTS) {
119  per2CapsHists(flag, 2, digi.id(), digi.sample(i), digi.sample(i + flag), castorHists.PEDTRENDS, cond);
120  }
121  }
122  }
123  if (m_startTS == 0 && m_endTS > 4) {
124  AllChanHists(digi.id(),
125  digi.sample(0),
126  digi.sample(1),
127  digi.sample(2),
128  digi.sample(3),
129  digi.sample(4),
130  digi.sample(5),
131  castorHists.PEDTRENDS);
132  }
133  }
134  // Call the function every m_nevtsample events
135  if (m_nevtsample > 0) {
136  if (evt % m_nevtsample == 0)
137  SampleAnalysis();
138  }
139 }
const HcalQIESample & sample(int i) const
access a sample
const CastorQIECoder * m_coder
std::vector< T >::const_iterator const_iterator
Log< level::Error, false > LogError
int size() const
total number of samples in the digi
void AllChanHists(const HcalDetId detid, const HcalQIESample &qie0, const HcalQIESample &qie1, const HcalQIESample &qie2, const HcalQIESample &qie3, const HcalQIESample &qie4, const HcalQIESample &qie5, std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT)
const HcalCastorDetId & id() const
const CastorQIEShape * m_shape
struct CastorPedestalAnalysis::@44 castorHists
void per2CapsHists(int flag, int id, const HcalDetId detid, const HcalQIESample &qie1, const HcalQIESample &qie2, std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, const CastorDbService &cond)

◆ SampleAnalysis()

void CastorPedestalAnalysis::SampleAnalysis ( )

Definition at line 304 of file CastorPedestalAnalysis.cc.

References castorHists, GetPedConst(), m_file, and sample.

Referenced by done(), and processEvent().

304  {
305  // it is called every m_nevtsample events (a sample) and the end of run
306  char PedSampleNum[20];
307 
308  // Compute pedestal constants for each HBHE, HO, HF
309  sprintf(PedSampleNum, "Castor_Sample%d", sample);
310  m_file->cd();
311  m_file->mkdir(PedSampleNum);
312  m_file->cd(PedSampleNum);
313  GetPedConst(castorHists.PEDTRENDS, castorHists.PEDMEAN, castorHists.PEDRMS);
314 }
struct CastorPedestalAnalysis::@44 castorHists
void GetPedConst(std::map< HcalDetId, std::map< int, PEDBUNCH > > &toolT, TH1F *PedMeans, TH1F *PedWidths)

◆ setup()

void CastorPedestalAnalysis::setup ( const std::string &  m_outputFileROOT)

Definition at line 87 of file CastorPedestalAnalysis.cc.

References m_file, and m_outputFileROOT.

Referenced by o2olib.O2OTool::execute().

87  {
88  // open the histogram file, create directories within
89  m_file = new TFile(m_outputFileROOT.c_str(), "RECREATE");
90  m_file->mkdir("Castor");
91  m_file->cd();
92 }

◆ Trendings()

void CastorPedestalAnalysis::Trendings ( std::map< HcalDetId, std::map< int, PEDBUNCH > > &  toolT,
TH1F *  Chi2,
TH1F *  CapidAverage,
TH1F *  CapidChi2 
)
private

Definition at line 555 of file CastorPedestalAnalysis.cc.

References _meot, trigObjTnPSource_cfi::bins, HcalDetId::depth(), nano_mu_digi_cff::float, mps_fire::i, HcalDetId::ieta(), HcalDetId::iphi(), dqmiolumiharvest::j, m_nevtsample, Skims_PA_cff::name, sample, and findQualityFiles::size.

Referenced by done().

558  {
559  // check stability of pedestal constants in a single long run
560 
561  std::map<int, std::vector<double> > AverageValues;
562 
563  for (_meot = toolT.begin(); _meot != toolT.end(); _meot++) {
564  for (int i = 0; i < 4; i++) {
565  char name[1024];
566  HcalDetId detid = _meot->first;
567  sprintf(name, "Pedestal trend, eta=%d phi=%d d=%d cap=%d", detid.ieta(), detid.iphi(), detid.depth(), i);
568  int bins = _meot->second[i].second.first[0].size();
569  float lo = 0.5;
570  float hi = (float)bins + 0.5;
571  _meot->second[i].second.second.push_back(new TH1F(name, name, bins, lo, hi));
572  sprintf(name, "Width trend, eta=%d phi=%d d=%d cap=%d", detid.ieta(), detid.iphi(), detid.depth(), i);
573  bins = _meot->second[i].second.first[2].size();
574  hi = (float)bins + 0.5;
575  _meot->second[i].second.second.push_back(new TH1F(name, name, bins, lo, hi));
576  sprintf(name,
577  "Correlation trend, eta=%d phi=%d d=%d caps=%d*%d",
578  detid.ieta(),
579  detid.iphi(),
580  detid.depth(),
581  i,
582  (i + 1) % 4);
583  bins = _meot->second[i].second.first[5].size();
584  hi = (float)bins + 0.5;
585  _meot->second[i].second.second.push_back(new TH1F(name, name, bins, lo, hi));
586  /* sprintf(name,"Correlation trend, eta=%d phi=%d d=%d caps=%d*%d",detid.ieta(),detid.iphi(),detid.depth(),i,(i+2)%4);
587  bins = _meot->second[i].second.first[7].size();
588  hi = (float)bins+0.5;
589  _meot->second[i].second.second.push_back(new TH1F(name,name,bins,lo,hi));
590  sprintf(name,"Correlation trend, eta=%d phi=%d d=%d caps=%d*%d",detid.ieta(),detid.iphi(),detid.depth(),i,(i+3)%4);
591  bins = _meot->second[i].second.first[9].size();
592  hi = (float)bins+0.5;
593  _meot->second[i].second.second.push_back(new TH1F(name,name,bins,lo,hi)); */
594 
595  std::vector<double>::iterator sample_it;
596  // Pedestal mean - put content and errors
597  int j = 0;
598  for (sample_it = _meot->second[i].second.first[0].begin(); sample_it != _meot->second[i].second.first[0].end();
599  ++sample_it) {
600  _meot->second[i].second.second[0]->SetBinContent(++j, *sample_it);
601  }
602  j = 0;
603  for (sample_it = _meot->second[i].second.first[1].begin(); sample_it != _meot->second[i].second.first[1].end();
604  ++sample_it) {
605  _meot->second[i].second.second[0]->SetBinError(++j, *sample_it);
606  }
607  // fit with a constant - extract parameters
608  _meot->second[i].second.second[0]->Fit("pol0", "Q");
609  TF1* fit = _meot->second[i].second.second[0]->GetFunction("pol0");
610  AverageValues[0].push_back(fit->GetParameter(0));
611  AverageValues[1].push_back(fit->GetParError(0));
612  if (sample > 1)
613  AverageValues[2].push_back(fit->GetChisquare() / fit->GetNDF());
614  else
615  AverageValues[2].push_back(fit->GetChisquare());
616  sprintf(name, "Sample (%d events)", m_nevtsample);
617  _meot->second[i].second.second[0]->GetXaxis()->SetTitle(name);
618  _meot->second[i].second.second[0]->GetYaxis()->SetTitle("Pedestal value");
619  _meot->second[i].second.second[0]->Write();
620  // Pedestal width - put content and errors
621  j = 0;
622  for (sample_it = _meot->second[i].second.first[2].begin(); sample_it != _meot->second[i].second.first[2].end();
623  ++sample_it) {
624  _meot->second[i].second.second[1]->SetBinContent(++j, *sample_it);
625  }
626  j = 0;
627  for (sample_it = _meot->second[i].second.first[3].begin(); sample_it != _meot->second[i].second.first[3].end();
628  ++sample_it) {
629  _meot->second[i].second.second[1]->SetBinError(++j, *sample_it);
630  }
631  _meot->second[i].second.second[1]->GetXaxis()->SetTitle(name);
632  _meot->second[i].second.second[1]->GetYaxis()->SetTitle("Pedestal width");
633  _meot->second[i].second.second[1]->Write();
634  // Correlation coeffs - put contents and errors
635  j = 0;
636  for (sample_it = _meot->second[i].second.first[5].begin(); sample_it != _meot->second[i].second.first[5].end();
637  ++sample_it) {
638  _meot->second[i].second.second[2]->SetBinContent(++j, *sample_it);
639  }
640  j = 0;
641  for (sample_it = _meot->second[i].second.first[6].begin(); sample_it != _meot->second[i].second.first[6].end();
642  ++sample_it) {
643  _meot->second[i].second.second[2]->SetBinError(++j, *sample_it);
644  }
645  _meot->second[i].second.second[2]->GetXaxis()->SetTitle(name);
646  _meot->second[i].second.second[2]->GetYaxis()->SetTitle("Close correlation");
647  _meot->second[i].second.second[2]->Write();
648  /* j=0;
649  for(sample_it=_meot->second[i].second.first[7].begin();
650  sample_it!=_meot->second[i].second.first[7].end();sample_it++){
651  _meot->second[i].second.second[3]->SetBinContent(++j,*sample_it);
652  }
653  j=0;
654  for(sample_it=_meot->second[i].second.first[8].begin();
655  sample_it!=_meot->second[i].second.first[8].end();sample_it++){
656  _meot->second[i].second.second[3]->SetBinError(++j,*sample_it);
657  }
658  _meot->second[i].second.second[3]->GetXaxis()->SetTitle(name);
659  _meot->second[i].second.second[3]->GetYaxis()->SetTitle("Intermediate correlation");
660  _meot->second[i].second.second[3]->Write();
661  j=0;
662  for(sample_it=_meot->second[i].second.first[9].begin();
663  sample_it!=_meot->second[i].second.first[9].end();sample_it++){
664  _meot->second[i].second.second[4]->SetBinContent(++j,*sample_it);
665  }
666  j=0;
667  for(sample_it=_meot->second[i].second.first[10].begin();
668  sample_it!=_meot->second[i].second.first[10].end();sample_it++){
669  _meot->second[i].second.second[4]->SetBinError(++j,*sample_it);
670  }
671  _meot->second[i].second.second[4]->GetXaxis()->SetTitle(name);
672  _meot->second[i].second.second[4]->GetYaxis()->SetTitle("Distant correlation");
673  _meot->second[i].second.second[4]->Write(); */
674  // chi2
675  j = 0;
676  for (sample_it = _meot->second[i].second.first[4].begin(); sample_it != _meot->second[i].second.first[4].end();
677  ++sample_it) {
678  Chi2->Fill(*sample_it);
679  }
680  }
681  }
682  CapidAverage = new TH1F("Constant fit: Pedestal Values",
683  "Constant fit: Pedestal Values",
684  AverageValues[0].size(),
685  0.,
686  AverageValues[0].size());
687  std::vector<double>::iterator sample_it;
688  int j = 0;
689  for (sample_it = AverageValues[0].begin(); sample_it != AverageValues[0].end(); ++sample_it) {
690  CapidAverage->SetBinContent(++j, *sample_it);
691  }
692  j = 0;
693  for (sample_it = AverageValues[1].begin(); sample_it != AverageValues[1].end(); ++sample_it) {
694  CapidAverage->SetBinError(++j, *sample_it);
695  }
696  CapidChi2 = new TH1F(
697  "Constant fit: Chi2/ndf", "Constant fit: Chi2/ndf", AverageValues[2].size(), 0., AverageValues[2].size());
698  j = 0;
699  for (sample_it = AverageValues[2].begin(); sample_it != AverageValues[2].end(); ++sample_it) {
700  CapidChi2->SetBinContent(++j, *sample_it);
701  //CapidChi2->SetBinError(++j,0);
702  }
703  Chi2->GetXaxis()->SetTitle("Chi2/ndf");
704  Chi2->GetYaxis()->SetTitle("50 x [(16+2) x 4 x 4] `events`");
705  Chi2->Write();
706  CapidAverage->GetYaxis()->SetTitle("Pedestal value");
707  CapidAverage->GetXaxis()->SetTitle("(16+2) x 4 x 4 `events`");
708  CapidAverage->Write();
709  CapidChi2->GetYaxis()->SetTitle("Chi2/ndf");
710  CapidChi2->GetXaxis()->SetTitle("(16+2) x 4 x 4 `events`");
711  CapidChi2->Write();
712 }
size
Write out results.
Definition: EPCuts.h:4
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
constexpr int ieta() const
get the cell ieta
Definition: HcalDetId.h:155
Definition: Chi2.h:15
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164

Member Data Documentation

◆ _meot

std::map<HcalDetId, std::map<int, PEDBUNCH> >::iterator CastorPedestalAnalysis::_meot
private

◆ ALLPEDS

TH1F* CastorPedestalAnalysis::ALLPEDS

Definition at line 123 of file CastorPedestalAnalysis.h.

◆ CAPID_AVERAGE

TH1F* CastorPedestalAnalysis::CAPID_AVERAGE

Definition at line 127 of file CastorPedestalAnalysis.h.

◆ CAPID_CHI2

TH1F* CastorPedestalAnalysis::CAPID_CHI2

Definition at line 128 of file CastorPedestalAnalysis.h.

◆ castorHists

struct { ... } CastorPedestalAnalysis::castorHists

◆ CHI2

TH1F* CastorPedestalAnalysis::CHI2

Definition at line 126 of file CastorPedestalAnalysis.h.

◆ evt

int CastorPedestalAnalysis::evt
private

◆ evt_curr

int CastorPedestalAnalysis::evt_curr
private

Definition at line 139 of file CastorPedestalAnalysis.h.

Referenced by processEvent().

◆ fitflag

const int CastorPedestalAnalysis::fitflag = 0
staticprivate

Definition at line 144 of file CastorPedestalAnalysis.h.

Referenced by GetPedConst().

◆ fRawPedestals

CastorPedestals* CastorPedestalAnalysis::fRawPedestals
private

Definition at line 133 of file CastorPedestalAnalysis.h.

Referenced by CastorPedVal(), done(), and GetPedConst().

◆ fRawPedestalWidths

CastorPedestalWidths* CastorPedestalAnalysis::fRawPedestalWidths
private

Definition at line 134 of file CastorPedestalAnalysis.h.

Referenced by CastorPedVal(), done(), and GetPedConst().

◆ fRefPedestals

const CastorPedestals* CastorPedestalAnalysis::fRefPedestals
private

Definition at line 131 of file CastorPedestalAnalysis.h.

Referenced by CastorPedVal(), and done().

◆ fRefPedestalWidths

const CastorPedestalWidths* CastorPedestalAnalysis::fRefPedestalWidths
private

Definition at line 132 of file CastorPedestalAnalysis.h.

Referenced by CastorPedVal(), and done().

◆ fValPedestals

CastorPedestals* CastorPedestalAnalysis::fValPedestals
private

Definition at line 135 of file CastorPedestalAnalysis.h.

Referenced by CastorPedVal(), and done().

◆ fValPedestalWidths

CastorPedestalWidths* CastorPedestalAnalysis::fValPedestalWidths
private

Definition at line 136 of file CastorPedestalAnalysis.h.

Referenced by CastorPedVal(), and done().

◆ m_AllPedsOK

int CastorPedestalAnalysis::m_AllPedsOK
private

Definition at line 117 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis(), and done().

◆ m_coder

const CastorQIECoder* CastorPedestalAnalysis::m_coder
private

Definition at line 120 of file CastorPedestalAnalysis.h.

Referenced by processEvent().

◆ m_endTS

int CastorPedestalAnalysis::m_endTS
private

Definition at line 112 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis(), GetPedConst(), and processEvent().

◆ m_file

TFile* CastorPedestalAnalysis::m_file
private

Definition at line 105 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis(), done(), SampleAnalysis(), and setup().

◆ m_hiSaveflag

int CastorPedestalAnalysis::m_hiSaveflag
private

Definition at line 115 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis(), and GetPedConst().

◆ m_logFile

std::ofstream CastorPedestalAnalysis::m_logFile
private

Definition at line 110 of file CastorPedestalAnalysis.h.

◆ m_nevtsample

int CastorPedestalAnalysis::m_nevtsample
private

◆ m_outputFileMean

std::string CastorPedestalAnalysis::m_outputFileMean
private

Definition at line 108 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis().

◆ m_outputFileROOT

std::string CastorPedestalAnalysis::m_outputFileROOT
private

Definition at line 107 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis(), done(), and setup().

◆ m_outputFileWidth

std::string CastorPedestalAnalysis::m_outputFileWidth
private

Definition at line 109 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis().

◆ m_pedsinADC

int CastorPedestalAnalysis::m_pedsinADC
private

Definition at line 114 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis(), GetPedConst(), and per2CapsHists().

◆ m_pedValflag

int CastorPedestalAnalysis::m_pedValflag
private

Definition at line 116 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis(), and done().

◆ m_shape

const CastorQIEShape* CastorPedestalAnalysis::m_shape
private

Definition at line 119 of file CastorPedestalAnalysis.h.

Referenced by processEvent().

◆ m_startTS

int CastorPedestalAnalysis::m_startTS
private

Definition at line 111 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis(), GetPedConst(), and processEvent().

◆ m_stat

float CastorPedestalAnalysis::m_stat[4]
private

Definition at line 140 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis(), done(), and GetPedConst().

◆ PEDMEAN

TH1F* CastorPedestalAnalysis::PEDMEAN

Definition at line 125 of file CastorPedestalAnalysis.h.

◆ PEDRMS

TH1F* CastorPedestalAnalysis::PEDRMS

Definition at line 124 of file CastorPedestalAnalysis.h.

◆ PEDTRENDS

std::map<HcalDetId, std::map<int, PEDBUNCH> > CastorPedestalAnalysis::PEDTRENDS

Definition at line 122 of file CastorPedestalAnalysis.h.

◆ sample

int CastorPedestalAnalysis::sample
private

◆ state

std::vector<bool> CastorPedestalAnalysis::state
private