CMS 3D CMS Logo

Functions
modulediff.cc File Reference
#include <Riostream.h>
#include <TDirectory.h>
#include <TFile.h>
#include <TROOT.h>
#include <TStyle.h>
#include <TKey.h>
#include <TH1.h>
#include <TH2.h>
#include <TH2D.h>
#include <TCanvas.h>
#include <TGraph.h>
#include <TPaveStats.h>
#include <TText.h>
#include <TLegend.h>
#include <cstring>
#include <utility>
#include <vector>
#include <sstream>
#include <algorithm>
#include <TString.h>
#include <TColor.h>
#include <dirent.h>

Go to the source code of this file.

Functions

void get_difference (vector< int >, vector< int >, vector< int > &)
 
int get_filename (int, string, string &)
 
int main (int argc, char *argv[])
 
void modulediff (int run_2, string repro_run2)
 
int read_badmodlist (int, string, vector< int > &)
 
int search_closest_run (int, string)
 

Function Documentation

◆ get_difference()

void get_difference ( vector< int >  badlist1,
vector< int >  badlist2,
vector< int > &  difflist 
)

Definition at line 121 of file modulediff.cc.

References testProducerWithPsetDescEmpty_cfi::i1, and testProducerWithPsetDescEmpty_cfi::i2.

Referenced by modulediff().

121  {
122  //check if any element of badlist1 is in badlist2
123  for (unsigned int i1 = 0; i1 < badlist1.size(); i1++) {
124  bool thisrecovered = true;
125  for (unsigned int i2 = 0; i2 < badlist2.size(); i2++)
126  if (badlist1[i1] == badlist2[i2]) {
127  thisrecovered = false;
128  break;
129  }
130  if (thisrecovered)
131  difflist.push_back(badlist1[i1]);
132  }
133 }

◆ get_filename()

int get_filename ( int  run,
string  repro_type,
string &  filename 
)

Definition at line 182 of file modulediff.cc.

References gather_cfg::cout, dqmPostProcessing_online::DIR, Calorimetry_cff::dp, fileCollector::dqmfile, corrVsCorr::filename, writedatasetfile::run, fileinputsource_cfi::runstr, AlCaHLTBitMon_QueryRunRegistry::string, and compareTotals::thisdir.

Referenced by read_badmodlist(), and search_closest_run().

182  {
183  stringstream runstr;
184  runstr << run;
185 
186  stringstream rundirprefix;
187  rundirprefix << "000" << run / 100 << "xx/";
188 
189  stringstream thisdir;
190  //thisdir << "/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/data/OfflineData/Run2011/" << repro_type.c_str() << "/" << rundirprefix.str();
191  thisdir << "/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/data/OfflineData/HIRun2011/" << repro_type.c_str() << "/"
192  << rundirprefix.str();
193 
194  string thisdir2 = thisdir.str();
195  DIR* dp;
196 
197  if ((dp = opendir(thisdir2.c_str())) == nullptr) {
198  cout << "dir " << thisdir2.c_str() << " not found" << endl;
199  return -1;
200  }
201 
202  struct dirent* dirp;
203 
204  string dqmfile;
205 
206  while ((dirp = readdir(dp)) != nullptr) {
207  string dirfile = string(dirp->d_name);
208  if (dirfile.find("__DQM") != string::npos && dirfile.find(runstr.str()) != string::npos) {
209  dqmfile = dirfile;
210  break;
211  }
212  }
213 
214  closedir(dp);
215 
216  if (dqmfile.size() < 10) {
217  //cout << "file " << dqmfile << " not found" << endl;
218  return -1;
219  }
220 
221  filename = thisdir.str() + dqmfile;
222 
223  return 0;
224 }

◆ main()

int main ( int  argc,
char *  argv[] 
)

===============================================================================================================================================================================================


variant2: for each run define phi-averaged A for normalization channel (Dref,16) and then, divide Rijk on it, i.e. get RRijk




















































































eta=27

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=19

eta=17

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=20

eta=19

eta=18

eta=27 L1=1

eta=25 L1=1

eta=23 L1=1

eta=22 L1=1

eta=21 L1=1

eta=29 L1=1

eta=26 L1=1

eta=24 L1=1

eta=20 L1=1

eta=19 L1=1

eta=18 L1=1

eta=17 L1=1

eta=28 L7=1

eta=27 L7=1

eta=25 L7=1

eta=23 L7=1

eta=22 L7=1

eta=21 L7=1

eta=26 L7=1

eta=24 L7=1

eta=20 L7=1

eta=19 L7=1

eta=18 L7=1

eta=17 L7=1

eta=27

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=19

eta=17

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=20

eta=19

eta=18

eta=27 L1=1

eta=25 L1=1

eta=23 L1=1

eta=22 L1=1

eta=21 L1=1

eta=26 L1=1

eta=24 L1=1

eta=20 L1=1

eta=19 L1=1

eta=18 L1=1

eta=17 L1=1

eta=28 L7=1

eta=27 L7=1

eta=25 L7=1

eta=23 L7=1

eta=22 L7=1

eta=21 L7=1

eta=26 L7=1

eta=24 L7=1

eta=20 L7=1

eta=19 L7=1

eta=18 L7=1

eta=17 L7=1

eta=27

eta=28

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

Summed Amplitude Plots:





Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

RBX:

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

Summed Amplitude Plots:





Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

RBX:

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

Summed Amplitude Plots:





Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

RBX:

Prepare maps of good/bad channels:

Prepare maps of good/bad channels:

Prepare maps of good/bad channels:

Prepare maps of good/bad channels:

Definition at line 32 of file modulediff.cc.

References dir2webdir::argc, GCPpyPlots::argv, gather_cfg::cout, modulediff(), and compare_using_db::run2.

32  {
33  if (argc == 3) {
34  char* crun2 = argv[1];
35  char* repro_run2 = argv[2];
36 
37  int run2 = 0;
38  sscanf(crun2, "%d", &run2);
39 
40  std::cout << "ready to run modulediff " << run2 << " repro run " << repro_run2 << std::endl;
41 
42  modulediff(run2, repro_run2);
43 
44  } else {
45  std::cout << "Too few arguments: " << argc << std::endl;
46  return -1;
47  }
48  return 0;
49 }
void modulediff(int run_2, string repro_run2)
Definition: modulediff.cc:51

◆ modulediff()

void modulediff ( int  run_2,
string  repro_run2 
)

Definition at line 51 of file modulediff.cc.

References gather_cfg::cout, get_difference(), mps_fire::i, createfilelist::int, timingPdfMaker::outfile, read_badmodlist(), and search_closest_run().

Referenced by main().

51  {
52  vector<int> badmodlist_run1;
53  vector<int> badmodlist_run2;
54  vector<int> modules_recovered;
55  vector<int> modules_malformed;
56  int run_1;
57  string repro_run1;
58 
59  int res = search_closest_run(run_2, repro_run2);
60  if (res > 0) {
61  run_1 = res;
62  repro_run1 = repro_run2;
63  } else {
64  printf("closest run not found, exiting.\n");
65  return;
66  }
67 
68  int flag1 = read_badmodlist(run_1, repro_run1, badmodlist_run1);
69  int flag2 = read_badmodlist(run_2, repro_run2, badmodlist_run2);
70 
71  if (flag1 < 0 || flag2 < 0) {
72  cout << "Error: file not found." << endl;
73  return;
74  }
75 
76  get_difference(badmodlist_run1, badmodlist_run2, modules_recovered);
77  get_difference(badmodlist_run2, badmodlist_run1, modules_malformed);
78 
79  //save into file
80  std::ofstream outfile;
81  string namefile = "modulediff_emailbody.txt";
82  outfile.open(namefile.c_str());
83 
84  outfile << "Recovered modules in run " << run_2 << ": " << (int)modules_recovered.size() << endl;
85  outfile << "New bad modules in run " << run_2 << ": " << (int)modules_malformed.size() << endl;
86  outfile << "Using reference run " << run_1 << endl << endl;
87 
88  outfile << "Recovered modules in run " << run_2 << ":" << endl;
89  if (modules_recovered.empty())
90  outfile << " -" << endl;
91  for (unsigned int i = 0; i < modules_recovered.size(); i++)
92  outfile << " " << modules_recovered[i] << endl;
93 
94  outfile << "New bad modules that appeared in run " << run_2 << ":" << endl;
95  if (modules_malformed.empty())
96  outfile << " -" << endl;
97  for (unsigned int i = 0; i < modules_malformed.size(); i++)
98  outfile << " " << modules_malformed[i] << endl;
99 
100  outfile.close();
101 
102  //create two flat files to run the locatemodule script on later
103 
104  if (!modules_recovered.empty()) {
105  std::ofstream outfile_good;
106  outfile_good.open("modulediff_good.txt");
107  for (unsigned int i = 0; i < modules_recovered.size(); i++)
108  outfile_good << " " << modules_recovered[i] << endl;
109  outfile_good.close();
110  }
111 
112  if (!modules_malformed.empty()) {
113  std::ofstream outfile_bad;
114  outfile_bad.open("modulediff_bad.txt");
115  for (unsigned int i = 0; i < modules_malformed.size(); i++)
116  outfile_bad << " " << modules_malformed[i] << endl;
117  outfile_bad.close();
118  }
119 }
int read_badmodlist(int, string, vector< int > &)
Definition: modulediff.cc:135
int search_closest_run(int, string)
Definition: modulediff.cc:226
void get_difference(vector< int >, vector< int >, vector< int > &)
Definition: modulediff.cc:121
Definition: Electron.h:6

◆ read_badmodlist()

int read_badmodlist ( int  run,
string  repro_type,
vector< int > &  badlist 
)

Definition at line 135 of file modulediff.cc.

References gather_cfg::cout, fileCollector::dqmfile, corrVsCorr::filename, RemoveAddSevLevel::flag, get_filename(), mps_fire::i, submitPVResolutionJobs::key, GetRecoTauVFromDQM_MC_cff::next, and writedatasetfile::run.

Referenced by modulediff().

135  {
136  string filename;
137  int flag = get_filename(run, repro_type, filename);
138 
139  if (flag < 0) {
140  cout << "reading problem" << endl;
141  return -1;
142  }
143 
144  vector<string> subdet;
145  subdet.push_back("TIB");
146  subdet.push_back("TID/MINUS");
147  subdet.push_back("TID/PLUS");
148  subdet.push_back("TOB");
149  subdet.push_back("TEC/MINUS");
150  subdet.push_back("TEC/PLUS");
151 
152  string nrun = filename.substr(filename.find("_R000") + 5, 6);
153 
154  TFile* dqmfile = TFile::Open(filename.c_str(), "READ");
155  string topdir = "DQMData/Run " + nrun + "/SiStrip/Run summary/MechanicalView";
156  gDirectory->cd(topdir.c_str());
157  TDirectory* mec1 = gDirectory;
158 
159  for (unsigned int i = 0; i < subdet.size(); i++) {
160  string badmodule_dir = subdet[i] + "/BadModuleList";
161  if (gDirectory->cd(badmodule_dir.c_str())) {
162  TIter next(gDirectory->GetListOfKeys());
163  TKey* key;
164 
165  while ((key = dynamic_cast<TKey*>(next()))) {
166  string sflag = key->GetName();
167  if (sflag.empty())
168  continue;
169 
170  string detid = sflag.substr(sflag.find('<') + 1, 9);
171  badlist.push_back(atoi(detid.c_str()));
172  }
173  } else {
174  //cout << "no dir " << badmodule_dir << " in filename " << filename << endl;
175  }
176  mec1->cd();
177  }
178  dqmfile->Close();
179  return 0;
180 }
int get_filename(int, string, string &)
Definition: modulediff.cc:182
key
prepare the HTCondor submission files and eventually submit them

◆ search_closest_run()

int search_closest_run ( int  thisrun,
string  repro_type 
)

Definition at line 226 of file modulediff.cc.

References corrVsCorr::filename, and get_filename().

Referenced by modulediff().

226  {
227  string filename;
228 
229  for (int test_run = thisrun - 1; test_run > thisrun - 1000; test_run--) {
230  int res = get_filename(test_run, repro_type, filename);
231  if (res == 0)
232  return test_run;
233  }
234 
235  return -1;
236 }
Definition: Electron.h:6
int get_filename(int, string, string &)
Definition: modulediff.cc:182