Go to the documentation of this file.00001 #include <iostream>
00002 #include <stdio.h>
00003 #include <TDirectory.h>
00004 #include <TFile.h>
00005 #include <TKey.h>
00006 #include <TH1.h>
00007 #include <Riostream.h>
00008 #include <string>
00009 #include <vector>
00010 #include <fstream>
00011 #include <string>
00012 #include <stdint.h>
00013 #include <cstdlib>
00014 #include <cstdio>
00015
00016 #include "listbadmodule.h"
00017
00018
00019
00020 int main(int argc , char *argv[]) {
00021
00022 if(argc==2) {
00023 char* filename = argv[1];
00024
00025 std::cout << "ready to prepare list of bad modules " << filename << std::endl;
00026
00027 listbadmodule(filename);
00028
00029 }
00030 else {std::cout << "Too few arguments: " << argc << std::endl; return -1; }
00031 return 0;
00032
00033 }
00034
00035
00036 void listbadmodule(std::string filename) {
00037
00038 int debug = 1;
00039
00040 cout << " here " << endl;
00041 std::vector<std::string> subdet;
00042 subdet.push_back("TIB");
00043 subdet.push_back("TID/side_1");
00044 subdet.push_back("TID/side_2");
00045 subdet.push_back("TOB");
00046 subdet.push_back("TEC/side_1");
00047 subdet.push_back("TEC/side_2");
00048
00049 std::string nrun = filename.substr(filename.find("_R000")+5, 6);
00050 int fileNum = atoi(nrun.c_str());
00051 cout << " ------ Run " << fileNum << endl;
00052
00053 ofstream outfile;
00054 std::string namefile;
00055 namefile = "QualityTest_run" + nrun + ".txt";
00056 outfile.open(namefile.c_str());
00057
00058 TFile *myfile = TFile::Open(filename.c_str());
00059 if (debug == 1){
00060 std::cout <<" Opened "<< filename << std::endl;
00061 }
00062 std::string topdir = "DQMData/Run " + nrun + "/SiStrip/Run summary/MechanicalView";
00063 gDirectory->cd(topdir.c_str());
00064 TDirectory* mec1 = gDirectory;
00065
00066 for (unsigned int i=0; i < subdet.size(); i++){
00067 std::string badmodule_dir = subdet[i] + "/BadModuleList";
00068 outfile << " " << endl;
00069 outfile << "SubDetector " << subdet[i] << endl;
00070 outfile << " " << endl;
00071 cout << badmodule_dir.c_str() << endl;
00072 if (gDirectory->cd(badmodule_dir.c_str())){
00073
00074
00075
00076 TIter next(gDirectory->GetListOfKeys());
00077 TKey *key;
00078
00079 while ( (key = dynamic_cast<TKey*>(next())) ) {
00080 std::string sflag = key->GetName();
00081 if (sflag.size() == 0) continue;
00082 std::string detid = sflag.substr(sflag.find("<")+1,9);
00083 size_t pos1 = sflag.find("/");
00084 sflag = sflag.substr(sflag.find("<")+13,pos1-2);
00085 int flag = atoi(sflag.c_str());
00086 std::string message;
00087 message = "Module " + detid;
00088 if (((flag >> 0) & 0x1) > 0) message += " Fed BadChannel : ";
00089 if (((flag >> 1) & 0x1) > 0) message += " # of Digi : ";
00090 if (((flag >> 2) & 0x1) > 0) message += " # of Clusters :";
00091 if (((flag >> 3) & 0x1) > 0) message += " Excluded FED Channel ";
00092 if (((flag >> 4) & 0x1) > 0) message += " DCSError ";
00093 outfile << message.c_str() << std::endl;
00094
00095 }
00096 }
00097 mec1->cd();
00098 }
00099 myfile->Close();
00100 outfile.close();
00101 }
00102
00103
00104