3 #include <TDirectory.h>
26 char* pclfilename = argv[2];
28 std::cout <<
"ready to prepare list of bad modules " << filename << std::endl;
33 else {
std::cout <<
"Too few arguments: " << argc << std::endl;
return -1; }
45 std::set<unsigned int> pclbadmods;
47 std::ifstream pclfile(pclfilename);
50 unsigned int pcldetid;
51 char sixapvs[]=
"1 1 1 1 1 1";
52 char fourapvs[]=
"1 1 x x 1 1";
54 while(pclfile.getline(line,400)) {
55 if(strstr(line,sixapvs) || strstr(line,fourapvs)) {
56 std::stringstream linestream;
58 linestream >> pcldetid;
60 pclbadmods.insert(pcldetid);
64 std::vector<std::string> subdet;
65 subdet.push_back(
"TIB");
66 subdet.push_back(
"TID/MINUS");
67 subdet.push_back(
"TID/PLUS");
68 subdet.push_back(
"TOB");
69 subdet.push_back(
"TEC/MINUS");
70 subdet.push_back(
"TEC/PLUS");
72 std::string nrun = filename.substr(filename.find(
"_R000")+5, 6);
73 int fileNum = atoi(nrun.c_str());
74 std::cout <<
" ------ Run " << fileNum << std::endl;
78 namefile =
"QualityTestOBSOLETE_run" + nrun +
".txt";
79 outfile.open(namefile.c_str());
81 TFile *myfile = TFile::Open(filename.c_str());
83 std::cout <<
" Opened "<< filename << std::endl;
85 std::string topdir =
"DQMData/Run " + nrun +
"/SiStrip/Run summary/MechanicalView";
86 gDirectory->cd(topdir.c_str());
87 TDirectory* mec1 = gDirectory;
90 std::vector <int> nbadmod;
91 for (
unsigned int i=0;
i < subdet.size();
i++){
93 std::string badmodule_dir = subdet[
i] +
"/BadModuleList";
94 if (gDirectory->cd(badmodule_dir.c_str())){
95 TIter
next(gDirectory->GetListOfKeys());
97 while ( (key = dynamic_cast<TKey*>(
next())) ) {
99 if (sflag.size() == 0)
continue;
103 nbadmod.push_back(nbad);
107 outfile <<
"Number of bad modules in total excluding PCL-only bad modules:" << std::endl;
108 outfile <<
"--------------------------------------------------------------" << std::endl;
109 outfile << subdet.at(0) <<
": " << nbadmod.at(0) << std::endl;
110 outfile << subdet.at(1) <<
": " << nbadmod.at(1) << std::endl;
111 outfile << subdet.at(2) <<
": " << nbadmod.at(2) << std::endl;
112 outfile << subdet.at(3) <<
": " << nbadmod.at(3) << std::endl;
113 outfile << subdet.at(4) <<
": " << nbadmod.at(4) << std::endl;
114 outfile << subdet.at(5) <<
": " << nbadmod.at(5) << std::endl;
115 outfile <<
"-------------------------------" << std::endl;
118 <<
"List of bad modules per partition:" << std::endl;
119 outfile <<
"----------------------------------" << std::endl;
121 std::set<unsigned int>::const_iterator pclbadmod = pclbadmods.begin();
123 for (
unsigned int i=0;
i < subdet.size();
i++){
124 std::string badmodule_dir = subdet[
i] +
"/BadModuleList";
125 outfile <<
" " << std::endl;
126 outfile <<
"SubDetector " << subdet[
i] << std::endl;
127 outfile <<
" " << std::endl;
128 std::cout << badmodule_dir.c_str() << std::endl;
129 if (gDirectory->cd(badmodule_dir.c_str())){
133 TIter
next(gDirectory->GetListOfKeys());
136 while ( (key = dynamic_cast<TKey*>(
next())) ) {
138 if (sflag.size() == 0)
continue;
140 size_t pos1 = sflag.find(
"/");
141 sflag = sflag.substr(sflag.find(
"<")+13,pos1-2);
142 int flag = atoi(sflag.c_str());
143 sscanf(detid.c_str(),
"%u",&pcldetid);
146 while(pclbadmod!= pclbadmods.end() && pcldetid > *pclbadmod) {
147 outfile <<
"Module " << *pclbadmod <<
" PCLBadModule " << std::endl;
151 message =
"Module " +
detid;
152 if (((flag >> 0) & 0x1) > 0) message +=
" Fed BadChannel : ";
153 if (((flag >> 1) & 0x1) > 0) message +=
" # of Digi : ";
154 if (((flag >> 2) & 0x1) > 0) message +=
" # of Clusters :";
155 if (((flag >> 3) & 0x1) > 0) message +=
" Excluded FED Channel ";
156 if (((flag >> 4) & 0x1) > 0) message +=
" DCSError ";
157 if (pclbadmods.find(pcldetid) != pclbadmods.end()) {
158 message +=
" PCLBadModule ";
159 pclbadmod = pclbadmods.find(pcldetid);
162 outfile << message.c_str() << std::endl;
int main(int argc, char **argv)
void listbadmodule(std::string filename, std::string pclfilename)