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 38 of file CastorPedestalAnalysis.h.

Member Typedef Documentation

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

Definition at line 84 of file CastorPedestalAnalysis.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 15 of file CastorPedestalAnalysis.cc.

References castorHists, gather_cfg::cout, evt, edm::ParameterSet::getUntrackedParameter(), mps_fire::i, gen::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, and state.

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

Destructor.

Definition at line 75 of file CastorPedestalAnalysis.cc.

References _meot, castorHists, and mps_fire::i.

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

Member Function Documentation

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 288 of file CastorPedestalAnalysis.cc.

References _meot, and HcalQIESample::adc().

Referenced by processEvent().

295  {
296  // this function is due to be called for every channel
297 
298  _meot = toolT.find(detid);
299  map<int, PEDBUNCH> _mei = _meot->second;
300  _mei[16].first->Fill(qie4.adc() + qie5.adc() - 1.);
301  _mei[17].first->Fill(qie4.adc() + qie5.adc() - qie2.adc() - qie3.adc());
302  _mei[18].first->Fill(qie4.adc() + qie5.adc() - (qie0.adc() + qie1.adc() + qie2.adc() + qie3.adc()) / 2.);
303 }
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
constexpr int adc() const
get the ADC sample
Definition: HcalQIESample.h:59
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(), MessageLogger_cfi::cerr, CastorCondObjectContainer< Item >::getAllChannels(), CastorPedestalWidth::getSigma(), CastorPedestal::getValue(), CastorCondObjectContainer< Item >::getValues(), HcalForward, mps_fire::i, createfilelist::int, 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  map<HcalDetId, bool> isinRaw;
731  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]);
832  fValPedestals->addValues(item);
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]);
865  fValPedestals->addValues(item);
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]);
887  fValPedestals->addValues(item);
888  }
889  }
890  }
891  return erflag;
892 }
float getValue(int fCapId) const
get value for capId = 0..3
std::vector< DetId > getAllChannels() const
const Item * getValues(DetId fId, bool throwOnFail=true) const
T sqrt(T t)
Definition: SSEVec.h:18
float getSigma(int fCapId1, int fCapId2) const
get correlation element for capId1/2 = 0..3
bool addValues(const Item &myItem)
int CastorPedestalAnalysis::done ( const CastorPedestals fInputPedestals,
const CastorPedestalWidths fInputWidths,
CastorPedestals fOutputPedestals,
CastorPedestalWidths fOutputWidths 
)

Definition at line 477 of file CastorPedestalAnalysis.cc.

References castorHists, CastorPedVal(), gather_cfg::cout, 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  cout << "Hcal/Castor histograms written to " << m_outputFileROOT.c_str() << endl;
551  return (int)m_AllPedsOK;
552 }
CastorPedestalWidths * fRawPedestalWidths
struct CastorPedestalAnalysis::@41 castorHists
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
const CastorPedestalWidths * fRefPedestalWidths
const CastorPedestals * fRefPedestals
void CastorPedestalAnalysis::GetPedConst ( std::map< HcalDetId, std::map< int, PEDBUNCH > > &  toolT,
TH1F *  PedMeans,
TH1F *  PedWidths 
)
private

Definition at line 319 of file CastorPedestalAnalysis.cc.

References _meot, CastorCondObjectContainer< Item >::addValues(), vertices_cff::chi2, fitflag, fRawPedestals, fRawPedestalWidths, mps_fire::i, 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]);
456  fRawPedestals->addValues(item);
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:18
bool addValues(const Item &myItem)
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 144 of file CastorPedestalAnalysis.cc.

References _meot, HcalQIESample::adc(), create_public_pileup_plots::bins, HcalQIESample::capid(), castorHists, CastorQIECoder::charge(), HcalDetId::depth(), evt, RemoveAddSevLevel::flag, CastorDbService::getCastorCoder(), CastorDbService::getCastorShape(), mps_fire::i, HcalDetId::ieta(), edm::eventsetup::heterocontainer::insert(), HcalDetId::iphi(), m_nevtsample, m_pedsinADC, dataset::name, and state.

Referenced by processEvent().

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

Definition at line 96 of file CastorPedestalAnalysis.cc.

References AllChanHists(), edm::SortedCollection< T, SORT >::begin(), castorHists, edm::SortedCollection< T, SORT >::empty(), edm::SortedCollection< T, SORT >::end(), evt, evt_curr, RemoveAddSevLevel::flag, CastorDbService::getCastorCoder(), CastorDbService::getCastorShape(), mps_fire::i, CastorDataFrame::id(), m_coder, m_endTS, m_nevtsample, m_shape, m_startTS, per2CapsHists(), CastorDataFrame::sample(), sample, SampleAnalysis(), CastorDataFrame::size(), and edm::SortedCollection< T, SORT >::size().

96  {
97  evt++;
98  sample = 1;
99  evt_curr = evt;
100  if (m_nevtsample > 0) {
101  sample = (evt - 1) / m_nevtsample + 1;
103  if (evt_curr == 0)
105  }
106 
107  m_shape = cond.getCastorShape();
108  // HF
109  try {
110  if (castor.empty())
111  throw(int) castor.size();
112  for (CastorDigiCollection::const_iterator j = castor.begin(); j != castor.end(); ++j) {
113  const CastorDataFrame digi = (const CastorDataFrame)(*j);
114  m_coder = cond.getCastorCoder(digi.id());
115  for (int i = m_startTS; i < digi.size() && i <= m_endTS; i++) {
116  for (int flag = 0; flag < 4; flag++) {
117  if (i + flag < digi.size() && i + flag <= m_endTS) {
118  per2CapsHists(flag, 2, digi.id(), digi.sample(i), digi.sample(i + flag), castorHists.PEDTRENDS, cond);
119  }
120  }
121  }
122  if (m_startTS == 0 && m_endTS > 4) {
123  AllChanHists(digi.id(),
124  digi.sample(0),
125  digi.sample(1),
126  digi.sample(2),
127  digi.sample(3),
128  digi.sample(4),
129  digi.sample(5),
130  castorHists.PEDTRENDS);
131  }
132  }
133  } catch (int i) {
134  // m_logFile << "Event with " << i<<" Castor Digis passed." << std::endl;
135  }
136  // Call the function every m_nevtsample events
137  if (m_nevtsample > 0) {
138  if (evt % m_nevtsample == 0)
139  SampleAnalysis();
140  }
141 }
struct CastorPedestalAnalysis::@41 castorHists
const CastorQIECoder * m_coder
const HcalQIESample & sample(int i) const
access a sample
std::vector< T >::const_iterator const_iterator
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 CastorQIEShape * getCastorShape() const
const_iterator end() const
const CastorQIEShape * m_shape
size_type size() const
const HcalCastorDetId & id() const
int size() const
total number of samples in the digi
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)
const_iterator begin() const
const CastorQIECoder * getCastorCoder(const HcalGenericDetId &fId) const
void CastorPedestalAnalysis::SampleAnalysis ( )

Definition at line 306 of file CastorPedestalAnalysis.cc.

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

Referenced by done(), and processEvent().

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

Definition at line 88 of file CastorPedestalAnalysis.cc.

References m_file.

Referenced by o2olib.O2OTool::execute().

88  {
89  // open the histogram file, create directories within
90  m_file = new TFile(m_outputFileROOT.c_str(), "RECREATE");
91  m_file->mkdir("Castor");
92  m_file->cd();
93 }
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, begin, create_public_pileup_plots::bins, HcalDetId::depth(), objects.autophobj::float, mps_fire::i, HcalDetId::ieta(), HcalDetId::iphi(), m_nevtsample, dataset::name, sample, and findQualityFiles::size.

Referenced by done().

558  {
559  // check stability of pedestal constants in a single long run
560 
561  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.
int depth() const
get the tower depth
Definition: HcalDetId.h:166
std::map< HcalDetId, std::map< int, PEDBUNCH > >::iterator _meot
int ieta() const
get the cell ieta
Definition: HcalDetId.h:159
int iphi() const
get the cell iphi
Definition: HcalDetId.h:161
#define begin
Definition: vmac.h:32
Definition: Chi2.h:15

Member Data Documentation

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

Definition at line 125 of file CastorPedestalAnalysis.h.

TH1F* CastorPedestalAnalysis::CAPID_AVERAGE

Definition at line 129 of file CastorPedestalAnalysis.h.

TH1F* CastorPedestalAnalysis::CAPID_CHI2

Definition at line 130 of file CastorPedestalAnalysis.h.

struct { ... } CastorPedestalAnalysis::castorHists
TH1F* CastorPedestalAnalysis::CHI2

Definition at line 128 of file CastorPedestalAnalysis.h.

int CastorPedestalAnalysis::evt
private
int CastorPedestalAnalysis::evt_curr
private

Definition at line 141 of file CastorPedestalAnalysis.h.

Referenced by processEvent().

const int CastorPedestalAnalysis::fitflag = 0
staticprivate

Definition at line 146 of file CastorPedestalAnalysis.h.

Referenced by GetPedConst().

CastorPedestals* CastorPedestalAnalysis::fRawPedestals
private

Definition at line 135 of file CastorPedestalAnalysis.h.

Referenced by done(), and GetPedConst().

CastorPedestalWidths* CastorPedestalAnalysis::fRawPedestalWidths
private

Definition at line 136 of file CastorPedestalAnalysis.h.

Referenced by done(), and GetPedConst().

const CastorPedestals* CastorPedestalAnalysis::fRefPedestals
private

Definition at line 133 of file CastorPedestalAnalysis.h.

Referenced by done().

const CastorPedestalWidths* CastorPedestalAnalysis::fRefPedestalWidths
private

Definition at line 134 of file CastorPedestalAnalysis.h.

Referenced by done().

CastorPedestals* CastorPedestalAnalysis::fValPedestals
private

Definition at line 137 of file CastorPedestalAnalysis.h.

Referenced by done().

CastorPedestalWidths* CastorPedestalAnalysis::fValPedestalWidths
private

Definition at line 138 of file CastorPedestalAnalysis.h.

Referenced by done().

int CastorPedestalAnalysis::m_AllPedsOK
private

Definition at line 119 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis(), and done().

const CastorQIECoder* CastorPedestalAnalysis::m_coder
private

Definition at line 122 of file CastorPedestalAnalysis.h.

Referenced by processEvent().

int CastorPedestalAnalysis::m_endTS
private

Definition at line 114 of file CastorPedestalAnalysis.h.

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

TFile* CastorPedestalAnalysis::m_file
private

Definition at line 107 of file CastorPedestalAnalysis.h.

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

int CastorPedestalAnalysis::m_hiSaveflag
private

Definition at line 117 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis(), and GetPedConst().

std::ofstream CastorPedestalAnalysis::m_logFile
private

Definition at line 112 of file CastorPedestalAnalysis.h.

int CastorPedestalAnalysis::m_nevtsample
private
std::string CastorPedestalAnalysis::m_outputFileMean
private

Definition at line 110 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis().

std::string CastorPedestalAnalysis::m_outputFileROOT
private

Definition at line 109 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis(), and done().

std::string CastorPedestalAnalysis::m_outputFileWidth
private

Definition at line 111 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis().

int CastorPedestalAnalysis::m_pedsinADC
private

Definition at line 116 of file CastorPedestalAnalysis.h.

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

int CastorPedestalAnalysis::m_pedValflag
private

Definition at line 118 of file CastorPedestalAnalysis.h.

Referenced by CastorPedestalAnalysis(), and done().

const CastorQIEShape* CastorPedestalAnalysis::m_shape
private

Definition at line 121 of file CastorPedestalAnalysis.h.

Referenced by processEvent().

int CastorPedestalAnalysis::m_startTS
private

Definition at line 113 of file CastorPedestalAnalysis.h.

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

float CastorPedestalAnalysis::m_stat[4]
private

Definition at line 142 of file CastorPedestalAnalysis.h.

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

TH1F* CastorPedestalAnalysis::PEDMEAN

Definition at line 127 of file CastorPedestalAnalysis.h.

TH1F* CastorPedestalAnalysis::PEDRMS

Definition at line 126 of file CastorPedestalAnalysis.h.

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

Definition at line 124 of file CastorPedestalAnalysis.h.

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