67 for(
int i=0;
i<128;
i++)
adc[
i]=0;
90 for(
int i=1;i<25;i++) if(adc[i]>
max){ max=
adc[
i]; maxi=
i;}
92 for(
int i=from;
i<=to;
i++){
96 if(nSum>0) *ave=Sum/nSum;
else return false;
98 for(
int i=from;
i<=to;
i++) Sum+=
adc[
i]*(
i-*ave)*(
i-*ave);
104 for(
int i=0;
i<25;
i++) nSum+=
adc[
i];
235 if (prefixME_.size()>0 && prefixME_.substr(prefixME_.size()-1,prefixME_.size())!=
"/")
236 prefixME_.append(
"/");
256 emap=conditions_->getHcalMapping();
371 static int lastPEDorbit,nChecksPED;
372 if(
ievt_==-1){
ievt_=0; PEDseq=
false; lastPEDorbit=-1;nChecksPED=0; }
376 bool PedestalEvent=
false;
382 if(trigger_data->triggerWord()==5) PedestalEvent=
true;
385 if(
LocalRun && !PedestalEvent)
return;
389 if(PEDseq && (orbit-lastPEDorbit)>(11223*10) &&
ievt_>500){
394 if(nChecksPED==1 || (nChecksPED>1 && ((nChecksPED-1)%12)==0)){
414 if ( fedData.
size() < 24 )
continue ;
416 if ( calibType < 0 ) calibType =
value ;
417 if(value==
hc_Pedestal){ PEDseq=
true; lastPEDorbit=orbit;
break;}
435 eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
450 eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
460 eta=digi->id().ieta(); phi=digi->id().iphi(); depth=digi->id().depth(); nTS=digi->size();
485 double PED=0,RMS=0,nped=0,nrms=0,ave=0,
rms=0;
486 for(
int depth=1;depth<=3;depth++){
513 double PED=0,RMS=0,nped=0,nrms=0,ave,
rms;
524 for(
int eta=-16;
eta<=16;
eta++)
for(
int phi=1;
phi<=72;
phi++)
for(
int depth=1;depth<=2;depth++){
526 double ave,
rms,sum=0;
535 for(
int eta=-29;
eta<=29;
eta++)
for(
int phi=1;
phi<=72;
phi++)
for(
int depth=1;depth<=3;depth++){
537 double ave=0,
rms=0,sum=0;
546 for(
int eta=-15;
eta<=15;
eta++)
for(
int phi=1;
phi<=72;
phi++)
for(
int depth=4;depth<=4;depth++){
548 double ave,
rms,sum=0;
549 if((
eta>=11 && eta<=15 && phi>=59 &&
phi<=70) || (
eta>=5 && eta<=10 && phi>=47 &&
phi<=58)){
565 for(
int eta=-42;
eta<=42;
eta++)
for(
int phi=1;
phi<=72;
phi++)
for(
int depth=1;depth<=2;depth++){
567 double ave,
rms,sum=0;
577 for(
int i=0;
i<4;
i++){
598 for (std::vector <HcalElectronicsId>::iterator eid = AllElIds.begin(); eid != AllElIds.end(); eid++) {
622 double ped[4],
rms[4],ped_ref[4],rms_ref[4];
633 if(stat>0 && stat!=(
ievt_*2)){ status=(double)stat/(
double)(
ievt_*2);
643 if(
hb_data[eta+42][
phi-1][depth-1][0].get_reference(&ped_ref[0],&rms_ref[0])
644 &&
hb_data[eta+42][
phi-1][depth-1][0].get_average(&ped[0],&rms[0])){
651 double ave=(ped[0]+ped[1]+ped[2]+ped[3])/4.0;
652 double ave_ref=(ped_ref[0]+ped_ref[1]+ped_ref[2]+ped_ref[3])/4.0;
654 double deltaRms=rms[0]-rms_ref[0];
PedestalsRmsHBref->
Fill(deltaRms);
if(deltaRms<0) deltaRms=-deltaRms;
655 for(
int i=1;
i<4;
i++){
657 if(fabs(tmp)>fabs(deltaRms)) deltaRms=
tmp;
681 double ped[4],
rms[4],ped_ref[4],rms_ref[4];
692 if(stat>0 && stat!=(
ievt_*2)){ status=(double)stat/(
double)(
ievt_*2);
702 if(
he_data[eta+42][
phi-1][depth-1][0].get_reference(&ped_ref[0],&rms_ref[0])
703 &&
he_data[eta+42][
phi-1][depth-1][0].get_average(&ped[0],&rms[0])){
710 double ave=(ped[0]+ped[1]+ped[2]+ped[3])/4.0;
711 double ave_ref=(ped_ref[0]+ped_ref[1]+ped_ref[2]+ped_ref[3])/4.0;
713 double deltaRms=rms[0]-rms_ref[0];
PedestalsRmsHEref->
Fill(deltaRms);
if(deltaRms<0) deltaRms=-deltaRms;
714 for(
int i=1;
i<4;
i++){
716 if(fabs(tmp)>fabs(deltaRms)) deltaRms=
tmp;
740 double ped[4],
rms[4],ped_ref[4],rms_ref[4];
751 if(stat>0 && stat!=(
ievt_*2)){ status=(double)stat/(
double)(
ievt_*2);
761 if(
ho_data[eta+42][
phi-1][depth-1][0].get_reference(&ped_ref[0],&rms_ref[0])
762 &&
ho_data[eta+42][
phi-1][depth-1][0].get_average(&ped[0],&rms[0])){
771 if((eta>=11 && eta<=15 && phi>=59 &&
phi<=70) || (eta>=5 && eta<=10 && phi>=47 &&
phi<=58))THRESTHOLD*=2;
772 double ave=(ped[0]+ped[1]+ped[2]+ped[3])/4.0;
773 double ave_ref=(ped_ref[0]+ped_ref[1]+ped_ref[2]+ped_ref[3])/4.0;
775 double deltaRms=rms[0]-rms_ref[0];
PedestalsRmsHOref->
Fill(deltaRms);
if(deltaRms<0) deltaRms=-deltaRms;
776 for(
int i=1;
i<4;
i++){
778 if(fabs(tmp)>fabs(deltaRms)) deltaRms=
tmp;
788 if(deltaRms>THRESTHOLD){
802 double ped[4],
rms[4],ped_ref[4],rms_ref[4];
813 if(stat>0 && stat!=(
ievt_*2)){ status=(double)stat/(
double)(
ievt_*2);
823 if(
hf_data[eta+42][
phi-1][depth-1][0].get_reference(&ped_ref[0],&rms_ref[0])
824 &&
hf_data[eta+42][
phi-1][depth-1][0].get_average(&ped[0],&rms[0])){
831 double ave=(ped[0]+ped[1]+ped[2]+ped[3])/4.0;
832 double ave_ref=(ped_ref[0]+ped_ref[1]+ped_ref[2]+ped_ref[3])/4.0;
834 double deltaRms=rms[0]-rms_ref[0];
PedestalsRmsHFref->
Fill(deltaRms);
if(deltaRms<0) deltaRms=-deltaRms;
835 for(
int i=1;
i<4;
i++){
837 if(fabs(tmp)>fabs(deltaRms)) deltaRms=
tmp;
869 double ped[4],
rms[4];
871 char Subdet[10],str[500];
876 sprintf(str,
"%sHcalDetDiagPedestalData.root",
OutputFilePath.c_str());
878 TFile *
theFile =
new TFile(str,
"RECREATE");
879 if(!theFile->IsOpen())
return;
881 sprintf(str,
"%d",
run_number); TObjString
run(str); run.Write(
"run number");
882 sprintf(str,
"%d",
ievt_); TObjString
events(str); events.Write(
"Total events processed");
883 sprintf(str,
"%d",
dataset_seq_number); TObjString dsnum(str); dsnum.Write(
"Dataset number");
884 Long_t
t; t=
time(0); strftime(str,30,
"%F %T",localtime(&t)); TObjString tm(str); tm.Write(
"Dataset creation time");
886 TTree *
tree =
new TTree(
"HCAL Pedestal data",
"HCAL Pedestal data");
888 tree->Branch(
"Subdet", &Subdet,
"Subdet/C");
889 tree->Branch(
"eta", &Eta,
"Eta/I");
890 tree->Branch(
"phi", &Phi,
"Phi/I");
891 tree->Branch(
"depth", &Depth,
"Depth/I");
892 tree->Branch(
"statistic",&Statistic,
"Statistic/I");
893 tree->Branch(
"status", &Status,
"Status/I");
894 tree->Branch(
"cap0_ped", &ped[0],
"cap0_ped/D");
895 tree->Branch(
"cap0_rms", &rms[0],
"cap0_rms/D");
896 tree->Branch(
"cap1_ped", &ped[1],
"cap1_ped/D");
897 tree->Branch(
"cap1_rms", &rms[1],
"cap1_rms/D");
898 tree->Branch(
"cap2_ped", &ped[2],
"cap2_ped/D");
899 tree->Branch(
"cap2_rms", &rms[2],
"cap2_rms/D");
900 tree->Branch(
"cap3_ped", &ped[3],
"cap3_ped/D");
901 tree->Branch(
"cap3_rms", &rms[3],
"cap3_rms/D");
902 sprintf(Subdet,
"HB");
903 for(
int eta=-16;
eta<=16;
eta++)
for(
int phi=1;
phi<=72;
phi++)
for(
int depth=1;depth<=2;depth++){
904 if((Statistic=
hb_data[
eta+42][
phi-1][depth-1][0].get_statistics())>100){
905 Eta=
eta; Phi=
phi; Depth=depth;
914 sprintf(Subdet,
"HE");
915 for(
int eta=-29;
eta<=29;
eta++)
for(
int phi=1;
phi<=72;
phi++)
for(
int depth=1;depth<=3;depth++){
916 if((Statistic=
he_data[
eta+42][
phi-1][depth-1][0].get_statistics())>100){
917 Eta=
eta; Phi=
phi; Depth=depth;
926 sprintf(Subdet,
"HO");
927 for(
int eta=-15;
eta<=15;
eta++)
for(
int phi=1;
phi<=72;
phi++)
for(
int depth=4;depth<=4;depth++){
928 if((Statistic=
ho_data[
eta+42][
phi-1][depth-1][0].get_statistics())>100){
929 Eta=
eta; Phi=
phi; Depth=depth;
938 sprintf(Subdet,
"HF");
939 for(
int eta=-42;
eta<=42;
eta++)
for(
int phi=1;
phi<=72;
phi++)
for(
int depth=1;depth<=2;depth++){
940 if((Statistic=
hf_data[
eta+42][
phi-1][depth-1][0].get_statistics())>100){
941 Eta=
eta; Phi=
phi; Depth=depth;
958 sprintf(str,
"HcalDetDiagPedestals.xml");
960 std::string xmlName=str;
962 xmlFile.open(xmlName.c_str());
964 xmlFile<<
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
966 xmlFile<<
" <HEADER>\n";
967 xmlFile<<
" <HINTS mode='only-det-root'/>\n";
968 xmlFile<<
" <TYPE>\n";
969 xmlFile<<
" <EXTENSION_TABLE_NAME>HCAL_DETMON_PEDESTALS_V1</EXTENSION_TABLE_NAME>\n";
970 xmlFile<<
" <NAME>HCAL Pedestals [abort gap global]</NAME>\n";
971 xmlFile<<
" </TYPE>\n";
972 xmlFile<<
" <!-- run details -->\n";
974 xmlFile<<
" <RUN_TYPE>GLOBAL-RUN</RUN_TYPE>\n";
975 xmlFile<<
" <RUN_NUMBER>"<<
run_number<<
"</RUN_NUMBER>\n";
976 xmlFile<<
" <RUN_BEGIN_TIMESTAMP>2009-01-01 00:00:00</RUN_BEGIN_TIMESTAMP>\n";
977 xmlFile<<
" <COMMENT_DESCRIPTION>hcal ped data</COMMENT_DESCRIPTION>\n";
978 xmlFile<<
" <LOCATION>P5</LOCATION>\n";
979 xmlFile<<
" <INITIATED_BY_USER>dma</INITIATED_BY_USER>\n";
980 xmlFile<<
" </RUN>\n";
981 xmlFile<<
" </HEADER>\n";
982 xmlFile<<
" <DATA_SET>\n";
983 xmlFile<<
" <!-- optional dataset metadata -->\n\n";
985 xmlFile<<
" <SET_BEGIN_TIMESTAMP>2009-01-01 00:00:00</SET_BEGIN_TIMESTAMP>\n";
986 xmlFile<<
" <SET_END_TIMESTAMP>2009-01-01 00:00:00</SET_END_TIMESTAMP>\n";
987 xmlFile<<
" <NUMBER_OF_EVENTS_IN_SET>"<<
ievt_<<
"</NUMBER_OF_EVENTS_IN_SET>\n";
988 xmlFile<<
" <COMMENT_DESCRIPTION>Automatic DQM output</COMMENT_DESCRIPTION>\n";
989 xmlFile<<
" <DATA_FILE_NAME>"<< xmlName <<
"</DATA_FILE_NAME>\n";
990 xmlFile<<
" <IMAGE_FILE_NAME>data plot url or file path</IMAGE_FILE_NAME>\n";
991 xmlFile<<
" <!-- who and when created this dataset-->\n\n";
992 Long_t
t; t=
time(0); strftime(str,30,
"%F %T",localtime(&t));
993 xmlFile<<
" <CREATE_TIMESTAMP>"<<str<<
"</CREATE_TIMESTAMP>\n";
994 xmlFile<<
" <CREATED_BY_USER>dma</CREATED_BY_USER>\n";
995 xmlFile<<
" <!-- version (string) and subversion (number) -->\n";
996 xmlFile<<
" <!-- fields are used to read data back from the database -->\n\n";
997 xmlFile<<
" <VERSION>"<<run_number<<dataset_seq_number<<
"</VERSION>\n";
998 xmlFile<<
" <SUBVERSION>1</SUBVERSION>\n";
999 xmlFile<<
" <!-- Assign predefined dataset attributes -->\n\n";
1000 xmlFile<<
" <PREDEFINED_ATTRIBUTES>\n";
1001 xmlFile<<
" <ATTRIBUTE>\n";
1002 xmlFile<<
" <NAME>HCAL Dataset Status</NAME>\n";
1003 xmlFile<<
" <VALUE>VALID</VALUE>\n";
1004 xmlFile<<
" </ATTRIBUTE>\n";
1005 xmlFile<<
" </PREDEFINED_ATTRIBUTES>\n";
1006 xmlFile<<
" <!-- multiple data block records -->\n\n";
1009 for(std::vector <HcalElectronicsId>::iterator eid = AllElIds.begin(); eid != AllElIds.end(); eid++){
1022 std::string subdet=
"";
1028 double ped[4]={0,0,0,0},rms[4]={0,0,0,0};
1062 xmlFile<<
" <DATA>\n";
1063 xmlFile<<
" <NUMBER_OF_EVENTS_USED>"<<Statistic<<
"</NUMBER_OF_EVENTS_USED>\n";
1064 xmlFile<<
" <MEAN0>"<<ped[0]<<
"</MEAN0>\n";
1065 xmlFile<<
" <MEAN1>"<<ped[1]<<
"</MEAN1>\n";
1066 xmlFile<<
" <MEAN2>"<<ped[2]<<
"</MEAN2>\n";
1067 xmlFile<<
" <MEAN3>"<<ped[3]<<
"</MEAN3>\n";
1068 xmlFile<<
" <RMS0>"<<rms[0]<<
"</RMS0>\n";
1069 xmlFile<<
" <RMS1>"<<rms[1]<<
"</RMS1>\n";
1070 xmlFile<<
" <RMS2>"<<rms[2]<<
"</RMS2>\n";
1071 xmlFile<<
" <RMS3>"<<rms[3]<<
"</RMS3>\n";
1072 xmlFile<<
" <CHANNEL_STATUS_WORD>"<<Status<<
"</CHANNEL_STATUS_WORD>\n";
1073 xmlFile<<
" <CHANNEL_OBJECTNAME>HcalDetId</CHANNEL_OBJECTNAME>\n";
1074 xmlFile<<
" <SUBDET>"<<subdet<<
"</SUBDET>\n";
1075 xmlFile<<
" <IETA>"<<eta<<
"</IETA>\n";
1076 xmlFile<<
" <IPHI>"<<phi<<
"</IPHI>\n";
1077 xmlFile<<
" <DEPTH>"<<depth<<
"</DEPTH>\n";
1078 xmlFile<<
" <TYPE>0</TYPE>\n";
1079 xmlFile<<
" </DATA>\n";
1082 xmlFile<<
" </DATA_SET>\n";
1083 xmlFile<<
"</ROOT>\n";
1085 sprintf(str,
"zip %s.zip %s",xmlName.c_str(),xmlName.c_str());
1087 sprintf(str,
"rm -f %s",xmlName.c_str());
1089 sprintf(str,
"mv -f %s.zip %s",xmlName.c_str(),
XmlFilePath.c_str());
1096 double ped[4],
rms[4];
1102 if(!f->IsOpen())
return ;
1103 TObjString *STR=(TObjString *)f->Get(
"run number");
1107 TTree*
t=(TTree*)f->Get(
"HCAL Pedestal data");
1109 t->SetBranchAddress(
"Subdet", subdet);
1110 t->SetBranchAddress(
"eta", &Eta);
1111 t->SetBranchAddress(
"phi", &Phi);
1112 t->SetBranchAddress(
"depth", &Depth);
1113 t->SetBranchAddress(
"cap0_ped", &ped[0]);
1114 t->SetBranchAddress(
"cap0_rms", &rms[0]);
1115 t->SetBranchAddress(
"cap1_ped", &ped[1]);
1116 t->SetBranchAddress(
"cap1_rms", &rms[1]);
1117 t->SetBranchAddress(
"cap2_ped", &ped[2]);
1118 t->SetBranchAddress(
"cap2_rms", &rms[2]);
1119 t->SetBranchAddress(
"cap3_ped", &ped[3]);
1120 t->SetBranchAddress(
"cap3_rms", &rms[3]);
1121 for(
int ievt=0;ievt<t->GetEntries();ievt++){
1123 if(strcmp(subdet,
"HB")==0){
1129 if(strcmp(subdet,
"HE")==0){
1135 if(strcmp(subdet,
"HO")==0){
1141 if(strcmp(subdet,
"HF")==0){
MonitorElement * PedestalsAve4HEref
EtaPhiHists * ProblemCellsByDepth_badped_val
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * Pedestals2DHO
edm::InputTag inputLabelRawData_
edm::Ref< Container > Ref
MonitorElement * PedestalsRmsHFref
std::vector< HcalElectronicsId > allElectronicsIdPrecision() const
MonitorElement * PedestalsAve4HB
MonitorElement * PedestalsRmsHOref
void beginRun(const edm::Run &run, const edm::EventSetup &c)
virtual void analyze(const edm::Event &e, const edm::EventSetup &c)
MonitorElement * PedestalsRmsHEref
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
void setAxisRange(double xmin, double xmax, int axis=1)
set x-, y- or z-axis range (axis=1, 2, 3 respectively)
MonitorElement * PedestalsRmsHB
std::vector< std::string > problemnames_
EtaPhiHists * ProblemCellsByDepth_missing_val
#define DEFINE_FWK_MODULE(type)
MonitorElement * PedestalsAve4HE
HcalDetDiagPedestalData ho_data[85][72][4][4]
std::vector< T >::const_iterator const_iterator
void setup(DQMStore *&m_dbe, std::string Name, std::string Units="")
EtaPhiHists * ProblemCellsByDepth_badped
const HcalElectronicsMap * emap
bool getByType(Handle< PROD > &result) const
HcalDetDiagPedestalData he_data[85][72][4][4]
bool get_average(double *ave, double *rms)
void beginLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
MonitorElement * PedestalsAve4HBref
size_t size() const
Lenght of the data buffer in bytes.
MonitorElement * PedestalsAve4Simp
EtaPhiHists * ProblemCellsByDepth_badrms_val
void analyze(const edm::Event &, const edm::EventSetup &)
bool get_reference(double *val, double *rms)
std::string OutputFilePath
int depth() const
get the tower depth
std::vector< MonitorElement * > depth
MonitorElement * PedestalsRmsHF
MonitorElement * PedestalsRmsHBref
~HcalDetDiagPedestalMonitor()
const T & max(const T &a, const T &b)
MonitorElement * bookString(const char *name, const char *value)
Book string.
HcalDetDiagPedestalData hb_data[85][72][4][4]
MonitorElement * PedestalsAve4HF
HcalDetDiagPedestalMonitor(const edm::ParameterSet &)
int ieta() const
get the cell ieta
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
MonitorElement * PedestalsRmsHE
edm::InputTag inputLabelDigi_
void add_statistics(unsigned int val)
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
MonitorElement * PedestalsAve4HFref
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
static std::string from(" from ")
int iphi() const
get the cell iphi
MonitorElement * Pedestals2DErrorHBHEHF
std::string ReferenceData
MonitorElement * PedestalsRmsHO
EtaPhiHists * ProblemCellsByDepth_unstable_val
HcalDetDiagPedestalData()
void change_status(int val)
bool xmlFile(const std::string fParam)
int CalcEtaBin(int subdet, int ieta, int depth)
MonitorElement * PedestalsAve4HO
std::vector< std::vector< double > > tmp
EtaPhiHists * ProblemCellsByDepth_badrms
void set_reference(float val, float rms)
EtaPhiHists * ProblemCellsByDepth_missing
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
MonitorElement * PedestalsAve4HOref
MonitorElement * Pedestals2DRmsHBHEHF
EtaPhiHists * ProblemCellsByDepth_unstable
void endRun(const edm::Run &run, const edm::EventSetup &c)
MonitorElement * bookInt(const char *name)
Book int.
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Detector det() const
get the detector field from this detid
MonitorElement * PedestalsRmsSimp
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
MonitorElement * Pedestals2DHBHEHF
void setCurrentFolder(const std::string &fullpath)
MonitorElement * Pedestals2DErrorHO
HcalDetDiagPedestalData hf_data[85][72][4][4]
MonitorElement * Pedestals2DRmsHO