CMS 3D CMS Logo

CMSSW_4_4_3_patch1/src/DQM/SiStripHistoricInfoClient/bin/SiStripHDQMInspector.cc

Go to the documentation of this file.
00001 #include "DQMServices/Diagnostic/interface/HDQMInspector.h"
00002 #include "DQM/SiStripHistoricInfoClient/interface/HDQMInspectorConfigSiStrip.h"
00003 #include "DQMServices/Diagnostic/interface/DQMHistoryTrendsConfig.h"
00004 #include "DQMServices/Diagnostic/interface/DQMHistoryCreateTrend.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006 
00007 #include <string>
00008 #include <vector>
00009 
00010 #include "FWCore/FWLite/interface/AutoLibraryLoader.h"
00011 #include <TROOT.h>
00012 #include <TFile.h>
00013 #include <TSystem.h>
00014 
00015 using namespace std;
00016 
00018 string multiItems(const vector<string> & subDetectors, const string & item)
00019 {
00020   string multiItems;
00021   if( !subDetectors.empty() ) {
00022     // Fill the first and then the others, prepending the rest with a ","
00023     vector<string>::const_iterator subDet = subDetectors.begin();
00024     multiItems.append(*subDet+"@"+item);
00025     ++subDet;
00026     for( ; subDet != subDetectors.end(); ++subDet ) {
00027       multiItems.append(","+*subDet+"@"+item);
00028     }
00029   }
00030   return multiItems;
00031 }
00032 
00037 void runTrackingInspector( const string &dbName, const string &tagName, const string & Password, const string & whiteListFile,
00038                            const int Start, const int End, const int nRuns )
00039 {
00040   // IMPORTANT SETTINGS:
00041   string condition = "";
00042   // string condition = "369098752@Summary_TotalNumberOfClusters_OffTrack@entries > 10000 || 436207616@Summary_TotalNumberOfClusters_OffTrack@entries > 10000 || 402653184@Summary_TotalNumberOfClusters_OffTrack@entries > 10000 || 469762048@Summary_TotalNumberOfClusters_OffTrack@entries > 10000";
00043   string blackList = "109468";
00044 
00045   // string whiteList = readListFromFile(whiteListFile);
00046 
00047   string siStripTracker = "268435456";
00048   vector<string> subDetectors;
00049   subDetectors.push_back("369098752"); // TIB (check)
00050   subDetectors.push_back("436207616"); // TOB (check)
00051   // subDetectors.push_back("402653184"); // TID (check)
00052   subDetectors.push_back("402661376"); // TID- (check)
00053   subDetectors.push_back("402669568"); // TID+ (check)
00054   // subDetectors.push_back("469762048"); // TEC (check)
00055   subDetectors.push_back("470024192"); // TEC- (check)
00056   subDetectors.push_back("470286336"); // TEC+ (check)
00057   // -------------------
00058 
00059   HDQMInspectorConfigSiStrip siStripConfig;
00060   vector<string> ItemsForIntegration;
00061   ItemsForIntegration.push_back("TotalNumberOfClusters_OnTrack_entries");
00062   siStripConfig.computeIntegralList(ItemsForIntegration);
00063   DQMHistoryCreateTrend makeTrend(&siStripConfig);
00064 
00065   // Database and output configuration
00066   // makeTrend.setDB("oracle://cms_orcoff_prep/CMS_DQM_31X_OFFLINE",tagName,"cms_dqm_31x_offline", Password,"");
00067   // makeTrend.setDB(dbName,tagName,"cms_dqm_31x_offline", Password,"");
00068   makeTrend.setDB(dbName,tagName,"/afs/cern.ch/cms/DB/conddb");
00069   // makeTrend.setDB(dbName,tagName,"CMS_COND_GENERAL_R", Password,"");
00070   makeTrend.setDebug(0);
00071   makeTrend.setDoStat(1);
00072   makeTrend.setSkip99s(true);
00073   makeTrend.setBlackList(blackList);
00074   // makeTrend.setWhiteList(whiteList);
00075   makeTrend.setWhiteListFromFile(whiteListFile);
00076 
00077   // Definition of trends
00078   typedef DQMHistoryTrendsConfig Trend;
00079   vector<Trend> config;
00080   config.push_back(Trend( multiItems(subDetectors, "Summary_TotalNumberOfClusters_OnTrack@mean"), "OnTrackClusters_mean.gif", 0,
00081                           condition+"", "", Start, End, nRuns, 0 ));
00082   config.push_back(Trend( multiItems(subDetectors, "Summary_TotalNumberOfClusters_OnTrack@entries"), "OnTrackClusters_entries.gif", 0,
00083                           condition+"&& 369098752@Summary_TotalNumberOfClusters_OnTrack@entries > 0", "", Start, End, nRuns, 0 ));
00084   config.push_back(Trend( multiItems(subDetectors, "Summary_TotalNumberOfClusters_OffTrack@mean"), "TotalNumberOfClusters_OffTrack_mean.gif", 0,
00085                           condition+"&& 369098752@Summary_TotalNumberOfClusters_OffTrack@mean > 0", "", Start, End, nRuns, 0, 1000 ));
00086   config.push_back(Trend( multiItems(subDetectors, "Summary_TotalNumberOfClusters_OffTrack@entries"), "TotalNumberOfClusters_OffTrack_entries.gif", 0,
00087                           condition+"&& 369098752@Summary_TotalNumberOfClusters_OffTrack@entries > 0", "", Start, End, nRuns, 0 ));
00088   config.push_back(Trend( multiItems(subDetectors, "Summary_ClusterChargeCorr_OnTrack@landauPeak"), "ClusterChargeCorr_OnTrack_landau.gif", 0,
00089                           condition+"&& 369098752@Summary_ClusterChargeCorr_OnTrack@entries > 10000", "", Start, End, nRuns, 0 ));
00090   config.push_back(Trend( multiItems(subDetectors, "Summary_ClusterCharge_OffTrack@mean"), "ClusterCharge_OffTrack_mean.gif", 0,
00091                           condition+"&& 369098752@Summary_ClusterCharge_OffTrack@entries > 10000", "", Start, End, nRuns, 0 ));
00092   config.push_back(Trend( multiItems(subDetectors, "Summary_ClusterCharge_OffTrack@landauPeak"), "ClusterCharge_OffTrack_landau.gif", 0,
00093                           condition+"&& 369098752@Summary_ClusterCharge_OffTrack@entries > 10000", "", Start, End, nRuns, 0 ));
00094   config.push_back(Trend( multiItems(subDetectors, "Summary_ClusterNoise_OnTrack@gaussMean"), "ClusterNoise_OnTrack_gauss.gif", 0,
00095                           condition+"&& 369098752@Summary_ClusterNoise_OnTrack@entries > 10000", "", Start, End, nRuns, 0 ));
00096   config.push_back(Trend( multiItems(subDetectors, "Summary_ClusterNoise_OffTrack@gaussMean"), "ClusterNoise_OffTrack_gauss.gif", 0,
00097                           condition+"&& 369098752@Summary_ClusterNoise_OffTrack@entries > 10000", "", Start, End, nRuns, 0, 8 ));
00098   config.push_back(Trend( multiItems(subDetectors, "Summary_ClusterStoNCorr_OnTrack@landauPeak"), "ClusterStoNCorr_OnTrack_landauPeak.gif", 0,
00099                           condition+"&& 369098752@Summary_ClusterStoNCorr_OnTrack@landauPeak > 0", "", Start, End, nRuns, 0 ));
00100   config.push_back(Trend( multiItems(subDetectors, "Summary_ClusterStoNCorr_OnTrack@mean"), "ClusterStoNCorr_OnTrack_mean.gif", 0,
00101                           condition+"&& 369098752@Summary_ClusterStoNCorr_OnTrack@mean > 0", "", Start, End, nRuns, 0 ));
00102   config.push_back(Trend( multiItems(subDetectors, "Summary_ClusterStoN_OffTrack@landauPeak"), "ClusterStoN_OffTrack_landauPeak.gif", 0,
00103                           condition+"&& 369098752@Summary_ClusterStoN_OffTrack@entries > 10000", "", Start, End, nRuns, 0, 60 ));
00104   config.push_back(Trend( multiItems(subDetectors, "Summary_ClusterStoN_OffTrack@mean"), "ClusterStoN_OffTrack_mean.gif", 0,
00105                           condition+"&& 369098752@Summary_ClusterStoN_OffTrack@entries > 10000", "", Start, End, nRuns, 0, 80 ));
00106   config.push_back(Trend( multiItems(subDetectors, "Summary_ClusterWidth_OnTrack@mean"), "ClusterWidth_OnTrack_mean.gif", 0,
00107                           condition+"&& 369098752@Summary_ClusterWidth_OnTrack@mean > 0", "", Start, End, nRuns, 0 ));
00108   config.push_back(Trend( multiItems(subDetectors, "Summary_ClusterWidth_OffTrack@mean"), "ClusterWidth_OffTrack_mean.gif", 0,
00109                           condition+"", "", Start, End, nRuns, 0, 7 ));
00110   config.push_back(Trend( multiItems(subDetectors, "TotalNumberOfClusterProfile@yMean"), "TotalNumberOfClusterProfile_ymean.gif", 0,
00111                           condition+"", "", Start, End, nRuns, 0, 15 ));
00112 
00113   // FED errors entries
00114   config.push_back(Trend( siStripTracker+"@nFEDErrors@entries", "nFEDErrors.gif", 0,
00115                           condition, "", Start, End, nRuns ));
00116   config.push_back(Trend( siStripTracker+"@nBadActiveChannelStatusBits@entries", "nBadActiveChannelStatusBits.gif", 0,
00117                           condition, "", Start, End, nRuns ));
00118   config.push_back(Trend( siStripTracker+"@nBadChannelStatusBits@entries", "nBadChannelStatusBits.gif", 0,
00119                           condition, "", Start, End, nRuns ));
00120   config.push_back(Trend( siStripTracker+"@nAPVAddressError@entries", "nAPVAddressError.gif", 0,
00121                           condition, "", Start, End, nRuns ));
00122   config.push_back(Trend( siStripTracker+"@nUnlocked@entries", "nUnlocked.gif", 0,
00123                           condition, "", Start, End, nRuns ));
00124   config.push_back(Trend( siStripTracker+"@nOutOfSync@entries", "nOutOfSync.gif", 0,
00125                           condition, "", Start, End, nRuns ));
00126 
00127   // FED errors means
00128   config.push_back(Trend( siStripTracker+"@nFEDErrors@mean", "nFEDErrors_mean.gif", 0,
00129                           condition, "", Start, End, nRuns ));
00130   config.push_back(Trend( siStripTracker+"@nBadActiveChannelStatusBits@mean", "nBadActiveChannelStatusBits_mean.gif", 0,
00131                           condition, "", Start, End, nRuns ));
00132   config.push_back(Trend( siStripTracker+"@nBadChannelStatusBits@mean", "nBadChannelStatusBits_mean.gif", 0,
00133                           condition, "", Start, End, nRuns ));
00134   config.push_back(Trend( siStripTracker+"@nAPVAddressError@mean", "nAPVAddressError_mean.gif", 0,
00135                           condition, "", Start, End, nRuns ));
00136   config.push_back(Trend( siStripTracker+"@nUnlocked@mean", "nUnlocked_mean.gif", 0,
00137                           condition, "", Start, End, nRuns ));
00138   config.push_back(Trend( siStripTracker+"@nOutOfSync@mean", "nOutOfSync_mean.gif", 0,
00139                           condition, "", Start, End, nRuns ));
00140 
00141   // Creation of trends
00142   for_each(config.begin(), config.end(), makeTrend);
00143 
00144   // Close the output file
00145   makeTrend.closeFile();
00146 }
00147 
00148 void SiStripHDQMInspector( const string & dbName, const string & tagName, const string & password, const std::string & whiteListFile,
00149                            const int start, const int end )
00150 {
00151   runTrackingInspector(dbName, tagName, password, whiteListFile, start, end, 0);
00152 }
00153 
00154 void SiStripHDQMInspector( const string & dbName, const string & tagName, const string & password, const std::string & whiteListFile,
00155                            const int nRuns )
00156 {
00157   runTrackingInspector(dbName, tagName, password, whiteListFile, 0, 0, nRuns);
00158 }
00159 
00160 int main (int argc, char* argv[])
00161 {
00162   gSystem->Load( "libFWCoreFWLite" );
00163   AutoLibraryLoader::enable();
00164 
00165   if (argc != 6 && argc != 7) {
00166     std::cerr << "Usage: " << argv[0] << " [Database] [TagName] [Password] [WhiteListFile] [NRuns] " << std::endl;
00167     std::cerr << "Or:    " << argv[0] << " [Database] [TagName] [Password] [WhiteListFile] [FirstRun] [LastRun] " << std::endl;
00168     return 1;
00169   }
00170 
00171   if (argc == 6) {
00172     std::cout << "Creating trends for NRuns = " << argv[5] << " for tag: " << argv[2] << std::endl;
00173     SiStripHDQMInspector( argv[1], argv[2], argv[3], argv[4], atoi(argv[5]) );
00174   } else if(argc == 7) {
00175     std::cout << "Creating trends for range:  " << argv[5] << " " << argv[6] << " for tag: " << argv[2] << std::endl;
00176     SiStripHDQMInspector( argv[1], argv[2], argv[3], argv[4], atoi(argv[5]), atoi(argv[6]) );
00177   }
00178 
00179   return 0;
00180 }