2 #include <TDirectory.h>
12 #include <TPaveStats.h>
27 void get_difference ( vector < int > , vector < int > , vector < int >& );
30 void modulediff (
int run_2 ,
string repro_run2 );
35 char* crun2 =
argv[1];
36 char* repro_run2 =
argv[2];
39 sscanf(crun2,
"%d",&
run2);
41 std::cout <<
"ready to run modulediff " <<
run2 <<
" repro run " << repro_run2 << std::endl;
46 else {
std::cout <<
"Too few arguments: " <<
argc << std::endl;
return -1; }
53 vector < int > badmodlist_run1;
54 vector < int > badmodlist_run2;
55 vector < int > modules_recovered;
56 vector < int > modules_malformed;
64 repro_run1 = repro_run2;
68 printf(
"closest run not found, exiting.\n");
76 if ( flag1 < 0 || flag2 < 0 )
78 cout <<
"Error: file not found." << endl;
82 get_difference ( badmodlist_run1 , badmodlist_run2 , modules_recovered );
83 get_difference ( badmodlist_run2 , badmodlist_run1 , modules_malformed );
87 string namefile =
"modulediff_emailbody.txt";
90 outfile <<
"Recovered modules in run " << run_2 <<
": " << (
int)modules_recovered.size() << endl;
91 outfile <<
"New bad modules in run " << run_2 <<
": " << (
int)modules_malformed.size() << endl;
92 outfile <<
"Using reference run " << run_1 << endl << endl;
94 outfile <<
"Recovered modules in run " << run_2 <<
":" << endl;
95 if ( modules_recovered.empty() )
97 for (
unsigned int i = 0;
i < modules_recovered.size() ;
i++ )
98 outfile <<
" " << modules_recovered[
i ] << endl;
100 outfile <<
"New bad modules that appeared in run " << run_2 <<
":" << endl;
101 if ( modules_malformed.empty() )
103 for (
unsigned int i = 0;
i < modules_malformed.size() ;
i++ )
104 outfile <<
" " << modules_malformed[
i ] << endl;
110 if ( !modules_recovered.empty() )
112 std::ofstream outfile_good;
113 outfile_good.open(
"modulediff_good.txt");
114 for (
unsigned int i = 0;
i < modules_recovered.size() ;
i++ )
115 outfile_good <<
" " << modules_recovered[
i ] << endl;
116 outfile_good.close();
119 if ( !modules_malformed.empty() )
121 std::ofstream outfile_bad;
122 outfile_bad.open(
"modulediff_bad.txt");
123 for (
unsigned int i = 0;
i < modules_malformed.size() ;
i++ )
124 outfile_bad <<
" " << modules_malformed[
i ] << endl;
129 void get_difference ( vector < int > badlist1 , vector < int > badlist2 , vector < int > &difflist )
132 for (
unsigned int i1 = 0;
i1 < badlist1.size() ;
i1++ )
134 bool thisrecovered =
true;
135 for (
unsigned int i2 = 0;
i2 < badlist2.size() ;
i2++ )
136 if ( badlist1[
i1 ] == badlist2[
i2 ] )
138 thisrecovered =
false;
142 difflist.push_back ( badlist1[
i1 ] );
154 cout <<
"reading problem" << endl;
158 vector<string> subdet;
159 subdet.push_back(
"TIB");
160 subdet.push_back(
"TID/MINUS");
161 subdet.push_back(
"TID/PLUS");
162 subdet.push_back(
"TOB");
163 subdet.push_back(
"TEC/MINUS");
164 subdet.push_back(
"TEC/PLUS");
169 string topdir =
"DQMData/Run " + nrun +
"/SiStrip/Run summary/MechanicalView";
170 gDirectory->cd(topdir.c_str());
171 TDirectory* mec1 = gDirectory;
173 for (
unsigned int i=0;
i < subdet.size();
i++ )
175 string badmodule_dir = subdet[
i ] +
"/BadModuleList";
176 if ( gDirectory->cd ( badmodule_dir.c_str() ) )
178 TIter
next ( gDirectory->GetListOfKeys() );
181 while ( (
key = dynamic_cast<TKey*> (
next() ) ) )
183 string sflag =
key->GetName();
184 if ( sflag.empty() )
continue;
186 string detid = sflag.substr ( sflag.find (
"<" ) + 1 , 9 );
187 badlist.push_back ( atoi ( detid.c_str() ) );
206 stringstream rundirprefix;
207 rundirprefix <<
"000" <<
run / 100 <<
"xx/";
209 stringstream thisdir;
211 thisdir <<
"/afs/cern.ch/cms/CAF/CMSCOMM/COMM_DQM/data/OfflineData/HIRun2011/" << repro_type.c_str() <<
"/" << rundirprefix.str();
213 string thisdir2 = thisdir.str();
216 if ( (
dp = opendir( thisdir2.c_str() ) ) == nullptr )
218 cout <<
"dir " << thisdir2.c_str() <<
" not found" << endl;
226 while ( ( dirp = readdir (
dp ) ) !=
nullptr )
228 string dirfile =
string ( dirp->d_name );
230 dirfile.find (
"__DQM" ) != string::npos &&
231 dirfile.find (
runstr.str() ) != string::npos
257 for (
int test_run = thisrun - 1; test_run > thisrun - 1000; test_run-- )