00001
00002
00003
00004
00005 #include "DQM/HLXMonitor/interface/HLXMonitor.h"
00006 #include "FWCore/Version/interface/GetReleaseVersion.h"
00007
00008
00009
00010 #include <math.h>
00011 #include <iomanip>
00012 #include <TSystem.h>
00013
00014 using std::cout;
00015 using std::endl;
00016
00017 HLXMonitor::HLXMonitor(const edm::ParameterSet& iConfig)
00018 {
00019
00020 NUM_HLX = iConfig.getUntrackedParameter< unsigned int >("numHlx", 36);
00021 NUM_BUNCHES = iConfig.getUntrackedParameter< unsigned int >("numBunches", 3564);
00022 MAX_LS = iConfig.getUntrackedParameter< unsigned int >("maximumNumLS", 480);
00023 listenPort = iConfig.getUntrackedParameter< unsigned int >("SourcePort", 51001);
00024 OutputFilePrefix = iConfig.getUntrackedParameter< std::string >("outputFile", "lumi");
00025 OutputDir = iConfig.getUntrackedParameter< std::string >("outputDir"," data");
00026 SavePeriod = iConfig.getUntrackedParameter< unsigned int >("SavePeriod", 10);
00027 NBINS = iConfig.getUntrackedParameter< unsigned int >("NBINS", 297);
00028 XMIN = iConfig.getUntrackedParameter< double >("XMIN", 0);
00029 XMAX = iConfig.getUntrackedParameter< double >("XMAX", 3564);
00030 Style = iConfig.getUntrackedParameter< std::string >("Style", "BX");
00031 AquireMode = iConfig.getUntrackedParameter< unsigned int >("AquireMode", 0);
00032 Accumulate = iConfig.getUntrackedParameter< bool >("Accumulate", true);
00033 TriggerBX = iConfig.getUntrackedParameter< unsigned int >("TriggerBX", 50);
00034 MinLSBeforeSave = iConfig.getUntrackedParameter< unsigned int >("MinLSBeforeSave", 1);
00035 reconnTime = iConfig.getUntrackedParameter< unsigned int >("ReconnectionTime",5);
00036 DistribIP1 = iConfig.getUntrackedParameter< std::string >("PrimaryHLXDAQIP", "vmepcs2f17-18");
00037 DistribIP2 = iConfig.getUntrackedParameter< std::string >("SecondaryHLXDAQIP", "vmepcs2f17-19");
00038 ResetAtNewRun = iConfig.getUntrackedParameter< bool >("NewRun_Reset","true");
00039 SaveAtEndJob = iConfig.getUntrackedParameter< bool >("SaveAtEndJob","true");
00040
00041 eventInfoFolderHLX_ = iConfig.getUntrackedParameter<std::string>("eventInfoFolderHLX", "EventInfoHLX") ;
00042 eventInfoFolder_ = iConfig.getUntrackedParameter<std::string >("eventInfoFolder", "EventInfo") ;
00043 subSystemName_ = iConfig.getUntrackedParameter<std::string >("subSystemName", "HLX") ;
00044
00045
00046 lsBinOld = 0;
00047 previousSection = 0;
00048 lumiSectionCount = 0;
00049 sectionInstantSumEt = 0;
00050 sectionInstantErrSumEt = 0;
00051 sectionInstantSumOcc1 = 0;
00052 sectionInstantErrSumOcc1 = 0;
00053 sectionInstantSumOcc2 = 0;
00054 sectionInstantErrSumOcc2 = 0;
00055 sectionInstantNorm = 0;
00056
00057
00058
00059 set1BelowIndex = 0;
00060 set1BetweenIndex = 1;
00061 set1AboveIndex = 2;
00062 set2BelowIndex = 3;
00063 set2BetweenIndex = 4;
00064 set2AboveIndex = 5;
00065
00066 runNumLength = 9;
00067 secNumLength = 8;
00068
00069 if(NUM_HLX > 36)
00070 NUM_HLX = 36;
00071
00072 if(NUM_BUNCHES > 3564)
00073 NUM_BUNCHES = 3564;
00074
00075 if(XMAX <= XMIN){
00076 XMIN = 0;
00077 if(XMAX <= 0) XMAX = 3564;
00078 }
00079
00080 if((Style.compare("History")==0) || (NBINS == 0)){
00081 NBINS = (unsigned int)(XMAX-XMIN);
00082 }
00083
00084 dbe_ = edm::Service<DQMStore>().operator->();
00085
00086 if ( dbe_ ) {
00087 dbe_->setVerbose(1);
00088 }
00089
00090 monitorName_ = iConfig.getUntrackedParameter<std::string>("monitorName","HLX");
00091
00092 prescaleEvt_ = iConfig.getUntrackedParameter<int>("prescaleEvt", -1);
00093
00094
00095 unsigned int HLXHFMapTemp[] = {31,32,33,34,35,18,
00096 13,14,15,16,17,0,
00097 25,26,27,28,29,30,
00098 7, 8, 9, 10,11,12,
00099 19,20,21,22,23,24,
00100 1, 2, 3, 4, 5, 6};
00101
00102 currentRunEnded_ = true;
00103 runNumber_ = 0;
00104 expectedNibbles_ = 0;
00105
00106 for( int iHLX = 0; iHLX < 36; ++iHLX ){
00107 HLXHFMap[iHLX] = HLXHFMapTemp[iHLX];
00108
00109 totalNibbles_[iHLX] = 0;
00110 }
00111
00112 num4NibblePerLS_ = 16.0;
00113
00114 SetupHists();
00115 SetupEventInfo();
00116 }
00117
00118 HLXMonitor::~HLXMonitor()
00119 {
00120 HLXTCP.Disconnect();
00121 }
00122
00123
00124 void
00125 HLXMonitor::SetupHists()
00126 {
00127
00128 dbe_->setCurrentFolder(monitorName_+"/HFPlus");
00129
00130 for( unsigned int iWedge = 0; iWedge < 18 && iWedge < NUM_HLX; ++iWedge )
00131 {
00132 std::ostringstream tempStreamer;
00133 tempStreamer << std::dec << std::setw(2) << std::setfill('0') << (iWedge+1);
00134
00135 std::ostringstream wedgeNum;
00136 wedgeNum << std::dec << (iWedge % 18) + 1;
00137
00138 dbe_->setCurrentFolder(monitorName_+"/HFPlus/Wedge"+tempStreamer.str());
00139
00140 Set1Below[iWedge] = dbe_->book1D("Set1_Below",
00141 "HF+ Wedge "+wedgeNum.str()+": Below Threshold 1 - Set 1",
00142 NBINS, XMIN, XMAX);
00143 Set1Between[iWedge] = dbe_->book1D("Set1_Between",
00144 "HF+ Wedge "+wedgeNum.str()+": Between Threshold 1 & 2 - Set 1",
00145 NBINS, XMIN, XMAX);
00146 Set1Above[iWedge] = dbe_->book1D("Set1_Above",
00147 "HF+ Wedge "+wedgeNum.str()+": Above Threshold 2 - Set 1",
00148 NBINS, XMIN, XMAX);
00149 Set2Below[iWedge] = dbe_->book1D("Set2_Below",
00150 "HF+ Wedge "+wedgeNum.str()+": Below Threshold 1 - Set 2",
00151 NBINS, XMIN, XMAX);
00152 Set2Between[iWedge] = dbe_->book1D("Set2_Between",
00153 "HF+ Wedge "+wedgeNum.str()+": Between Threshold 1 & 2 - Set 2",
00154 NBINS, XMIN, XMAX);
00155 Set2Above[iWedge] = dbe_->book1D("Set2_Above",
00156 "HF+ Wedge "+wedgeNum.str()+": Above Threshold 2 - Set 2",
00157 NBINS, XMIN, XMAX);
00158 ETSum[iWedge] = dbe_->book1D("ETSum",
00159 "HF+ Wedge "+wedgeNum.str()+": Transverse Energy",
00160 NBINS, XMIN, XMAX);
00161
00162 dbe_->tagContents(monitorName_+"/HFPlus/Wedge"+tempStreamer.str(), iWedge+1);
00163 }
00164
00165 if(NUM_HLX > 17)
00166 {
00167 dbe_->setCurrentFolder(monitorName_+"/HFMinus");
00168
00169 for( unsigned int iWedge=18; iWedge < NUM_HLX; ++iWedge )
00170 {
00171 std::ostringstream tempStreamer;
00172 tempStreamer << std::dec << std::setw(2) << std::setfill('0') << (iWedge+1);
00173
00174 std::ostringstream wedgeNum;
00175 wedgeNum << std::dec << (iWedge % 18) + 1;
00176
00177 dbe_->setCurrentFolder(monitorName_+"/HFMinus/Wedge"+tempStreamer.str());
00178 Set1Below[iWedge] = dbe_->book1D("Set1_Below",
00179 "HF- Wedge "+wedgeNum.str()+": Below Threshold 1 - Set 1",
00180 NBINS, XMIN, XMAX);
00181 Set1Between[iWedge] = dbe_->book1D("Set1_Between",
00182 "HF- Wedge "+wedgeNum.str()+": Between Threshold 1 & 2 - Set 1",
00183 NBINS, XMIN, XMAX);
00184 Set1Above[iWedge] = dbe_->book1D("Set1_Above",
00185 "HF- Wedge "+wedgeNum.str()+": Above Threshold 2 - Set 1",
00186 NBINS, XMIN, XMAX);
00187 Set2Below[iWedge] = dbe_->book1D("Set2_Below",
00188 "HF- Wedge "+wedgeNum.str()+": Below Threshold 1 - Set 2",
00189 NBINS, XMIN, XMAX);
00190 Set2Between[iWedge] = dbe_->book1D("Set2_Between",
00191 "HF- Wedge "+wedgeNum.str()+": Between Threshold 1 & 2 - Set 2",
00192 NBINS, XMIN, XMAX);
00193 Set2Above[iWedge] = dbe_->book1D("Set2_Above",
00194 "HF- Wedge "+wedgeNum.str()+": Above Threshold 2 - Set 2",
00195 NBINS, XMIN, XMAX);
00196 ETSum[iWedge] = dbe_->book1D("ETSum",
00197 "HF- Wedge "+wedgeNum.str()+": Transverse Energy",
00198 NBINS, XMIN, XMAX);
00199
00200 dbe_->tagContents(monitorName_+"/HFMinus/Wedge"+tempStreamer.str(), iWedge+1);
00201 }
00202 }
00203
00204 if(!Accumulate){
00205 for( unsigned int iWedge = 0; iWedge < NUM_HLX; ++iWedge ){
00206 Set1Below[iWedge]-> setResetMe(true);
00207 Set1Between[iWedge]->setResetMe(true);
00208 Set1Above[iWedge]-> setResetMe(true);
00209 Set2Below[iWedge]-> setResetMe(true);
00210 Set2Between[iWedge]->setResetMe(true);
00211 Set2Above[iWedge]-> setResetMe(true);
00212 ETSum[iWedge]-> setResetMe(true);
00213 }
00214 }
00215
00216 if(Style.compare("BX") == 0){
00217 OccXAxisTitle = "Bunch Crossing";
00218 OccYAxisTitle = "Tower Occupancy";
00219 EtXAxisTitle = "Bunch Crossing";
00220 EtYAxisTitle = "E_{T} Sum";
00221 }else if(Style.compare("Distribution")==0){
00222 OccXAxisTitle = "Tower Occupancy";
00223 OccYAxisTitle = "Count";
00224 EtXAxisTitle = "E_{T} Sum";
00225 EtYAxisTitle = "Count";
00226 }
00227
00228 for( unsigned int iWedge=0; iWedge < NUM_HLX; ++iWedge )
00229 {
00230 Set1Below[iWedge]-> setAxisTitle(OccXAxisTitle, 1);
00231 Set1Below[iWedge]-> setAxisTitle(OccYAxisTitle, 2);
00232 Set1Between[iWedge]->setAxisTitle(OccXAxisTitle, 1);
00233 Set1Between[iWedge]->setAxisTitle(OccYAxisTitle, 2);
00234 Set1Above[iWedge]-> setAxisTitle(OccXAxisTitle, 1);
00235 Set1Above[iWedge]-> setAxisTitle(OccYAxisTitle, 2);
00236 Set2Below[iWedge]-> setAxisTitle(OccXAxisTitle, 1);
00237 Set2Below[iWedge]-> setAxisTitle(OccYAxisTitle, 2);
00238 Set2Between[iWedge]->setAxisTitle(OccXAxisTitle, 1);
00239 Set2Between[iWedge]->setAxisTitle(OccYAxisTitle, 2);
00240 Set2Above[iWedge]-> setAxisTitle(OccXAxisTitle, 1);
00241 Set2Above[iWedge]-> setAxisTitle(OccYAxisTitle, 2);
00242 ETSum[iWedge]-> setAxisTitle(EtXAxisTitle, 1);
00243 ETSum[iWedge]-> setAxisTitle(EtYAxisTitle, 2);
00244 }
00245
00246
00247
00248 dbe_->setCurrentFolder(monitorName_+"/HFCompare");
00249
00250 std::string CompXTitle = "HF Wedge";
00251 std::string CompEtSumYTitle = "E_{T} Sum per active tower";
00252 std::string CompOccYTitle = "Occupancy per active tower";
00253
00254 HFCompareEtSum = dbe_->book1D("HFCompareEtSum","E_{T} Sum",NUM_HLX, 0, NUM_HLX );
00255 HFCompareEtSum->setAxisTitle( CompXTitle, 1 );
00256 HFCompareEtSum->setAxisTitle( CompEtSumYTitle, 2 );
00257
00258 HFCompareOccBelowSet1 = dbe_->book1D("HFCompareOccBelowSet1",
00259 "Occupancy Below Threshold 1 - Set 1",
00260 NUM_HLX, 0, NUM_HLX );
00261 HFCompareOccBelowSet1->setAxisTitle( CompXTitle, 1 );
00262 HFCompareOccBelowSet1->setAxisTitle( CompOccYTitle, 2 );
00263
00264 HFCompareOccBetweenSet1 = dbe_->book1D("HFCompareOccBetweenSet1",
00265 "Occupancy Between Threshold 1 & 2 - Set 1",
00266 NUM_HLX, 0, NUM_HLX );
00267 HFCompareOccBetweenSet1->setAxisTitle( CompXTitle, 1 );
00268 HFCompareOccBetweenSet1->setAxisTitle( CompOccYTitle, 2 );
00269
00270 HFCompareOccAboveSet1 = dbe_->book1D("HFCompareOccAboveSet1",
00271 "Occupancy Above Threshold 2 - Set 1",
00272 NUM_HLX, 0, NUM_HLX );
00273 HFCompareOccAboveSet1->setAxisTitle( CompXTitle, 1 );
00274 HFCompareOccAboveSet1->setAxisTitle( CompOccYTitle, 2 );
00275
00276 HFCompareOccBelowSet2 = dbe_->book1D("HFCompareOccBelowSet2",
00277 "Occupancy Below Threshold 1 - Set 2",
00278 NUM_HLX, 0, NUM_HLX);
00279 HFCompareOccBelowSet2->setAxisTitle(CompXTitle,1);
00280 HFCompareOccBelowSet2->setAxisTitle(CompOccYTitle,2);
00281
00282 HFCompareOccBetweenSet2 = dbe_->book1D("HFCompareOccBetweenSet2",
00283 "Occupancy Between Threshold 1 & 2 - Set 2",
00284 NUM_HLX, 0, NUM_HLX);
00285 HFCompareOccBetweenSet2->setAxisTitle(CompXTitle,1);
00286 HFCompareOccBetweenSet2->setAxisTitle(CompOccYTitle,2);
00287
00288 HFCompareOccAboveSet2 = dbe_->book1D( "HFCompareOccAboveSet2",
00289 "Occupancy Above Threshold 2 - Set 2",
00290 NUM_HLX, 0, NUM_HLX);
00291 HFCompareOccAboveSet2->setAxisTitle(CompXTitle,1);
00292 HFCompareOccAboveSet2->setAxisTitle(CompOccYTitle,2);
00293
00294
00295
00296 dbe_->setCurrentFolder(monitorName_+"/Average");
00297
00298 int OccBins = 10000;
00299 double OccMin = 0;
00300 double OccMax = 0;
00301
00302 int EtSumBins = 10000;
00303 double EtSumMin = 0;
00304 double EtSumMax = 0;
00305
00306 std::string errorOpt = "i";
00307
00308 std::string AvgXTitle = "HF Wedge";
00309 std::string AvgEtSumYTitle = "Average E_{T} Sum";
00310 std::string AvgOccYTitle = "Average Tower Occupancy";
00311
00312 AvgEtSum = dbe_->bookProfile( "AvgEtSum",
00313 "Average E_{T} Sum",
00314 NUM_HLX, 0, NUM_HLX, EtSumBins, EtSumMin, EtSumMax);
00315 AvgEtSum->setAxisTitle( AvgXTitle, 1 );
00316 AvgEtSum->setAxisTitle( AvgEtSumYTitle, 2 );
00317
00318 AvgOccBelowSet1 = dbe_->bookProfile( "AvgOccBelowSet1",
00319 "Average Occupancy Below Threshold 1 - Set1",
00320 NUM_HLX, 0, NUM_HLX, OccBins, OccMin, OccMax, errorOpt.c_str());
00321 AvgOccBelowSet1->setAxisTitle( AvgXTitle, 1 );
00322 AvgOccBelowSet1->setAxisTitle( AvgOccYTitle, 2 );
00323
00324 AvgOccBetweenSet1 = dbe_->bookProfile( "AvgOccBetweenSet1",
00325 "Average Occupancy Between Threhold 1 & 2 - Set1",
00326 NUM_HLX, 0, NUM_HLX, OccBins, OccMin, OccMax, errorOpt.c_str());
00327 AvgOccBetweenSet1->setAxisTitle( AvgXTitle, 1 );
00328 AvgOccBetweenSet1->setAxisTitle( AvgOccYTitle, 2 );
00329
00330 AvgOccAboveSet1 = dbe_->bookProfile( "AvgOccAboveSet1",
00331 "Average Occupancy Above Threshold 2 - Set1",
00332 NUM_HLX, 0, NUM_HLX, OccBins, OccMin, OccMax, errorOpt.c_str());
00333 AvgOccAboveSet1->setAxisTitle( AvgXTitle, 1 );
00334 AvgOccAboveSet1->setAxisTitle( AvgOccYTitle, 2 );
00335
00336 AvgOccBelowSet2 = dbe_->bookProfile("AvgOccBelowSet2",
00337 "Average Occupancy Below Threshold 1 - Set2",
00338 NUM_HLX, 0, NUM_HLX, OccBins, OccMin, OccMax, errorOpt.c_str());
00339 AvgOccBelowSet2->setAxisTitle( AvgXTitle, 1 );
00340 AvgOccBelowSet2->setAxisTitle( AvgOccYTitle, 2 );
00341
00342 AvgOccBetweenSet2 = dbe_->bookProfile("AvgOccBetweenSet2",
00343 "Average Occupancy Between Threshold 1 & 2 - Set2",
00344 NUM_HLX, 0, NUM_HLX, OccBins, OccMin, OccMax, errorOpt.c_str());
00345 AvgOccBetweenSet2->setAxisTitle( AvgXTitle, 1 );
00346 AvgOccBetweenSet2->setAxisTitle( AvgOccYTitle, 2 );
00347
00348 AvgOccAboveSet2 = dbe_->bookProfile("AvgOccAboveSet2",
00349 "Average Occupancy Above Threshold 2 - Set2",
00350 NUM_HLX, 0, NUM_HLX, OccBins, OccMin, OccMax, errorOpt.c_str());
00351 AvgOccAboveSet2->setAxisTitle( AvgXTitle, 1 );
00352 AvgOccAboveSet2->setAxisTitle( AvgOccYTitle, 2 );
00353
00354
00355 dbe_->setCurrentFolder(monitorName_+"/Luminosity");
00356
00357 std::string LumiXTitle = "Bunch Crossing";
00358 std::string LumiEtSumYTitle = "Luminosity: E_{T} Sum";
00359 std::string LumiOccYTitle = "Luminosity: Occupancy";
00360
00361 LumiAvgEtSum = dbe_->bookProfile("LumiAvgEtSum","Average Luminosity ",int(XMAX-XMIN), XMIN, XMAX, EtSumBins, EtSumMin, EtSumMax );
00362 LumiAvgEtSum->setAxisTitle( LumiXTitle, 1 );
00363 LumiAvgEtSum->setAxisTitle( LumiEtSumYTitle, 2 );
00364
00365 LumiAvgOccSet1 = dbe_->bookProfile("LumiAvgOccSet1","Average Luminosity - Set 1", int(XMAX-XMIN), XMIN, XMAX, OccBins, OccMax, OccMin );
00366 LumiAvgOccSet1->setAxisTitle( LumiXTitle, 1 );
00367 LumiAvgOccSet1->setAxisTitle( LumiOccYTitle, 2 );
00368
00369 LumiAvgOccSet2 = dbe_->bookProfile("LumiAvgOccSet2","Average Luminosity - Set 2", int(XMAX-XMIN), XMIN, XMAX, OccBins, OccMax, OccMin );
00370 LumiAvgOccSet2->setAxisTitle( LumiXTitle, 1 );
00371 LumiAvgOccSet2->setAxisTitle( LumiOccYTitle, 2 );
00372
00373 LumiInstantEtSum = dbe_->book1D("LumiInstantEtSum","Instantaneous Luminosity ",int(XMAX-XMIN), XMIN, XMAX );
00374 LumiInstantEtSum->setAxisTitle( LumiXTitle, 1 );
00375 LumiInstantEtSum->setAxisTitle( LumiEtSumYTitle, 2 );
00376
00377 LumiInstantOccSet1 = dbe_->book1D("LumiInstantOccSet1","Instantaneous Luminosity - Set 1", int(XMAX-XMIN), XMIN, XMAX );
00378 LumiInstantOccSet1->setAxisTitle( LumiXTitle, 1 );
00379 LumiInstantOccSet1->setAxisTitle( LumiOccYTitle, 2 );
00380
00381 LumiInstantOccSet2 = dbe_->book1D("LumiInstantOccSet2","Instantaneous Luminosity - Set 2", int(XMAX-XMIN), XMIN, XMAX );
00382 LumiInstantOccSet2->setAxisTitle( LumiXTitle, 1 );
00383 LumiInstantOccSet2->setAxisTitle( LumiOccYTitle, 2 );
00384
00385 LumiIntegratedEtSum = dbe_->book1D("LumiIntegratedEtSum","Integrated Luminosity ",int(XMAX-XMIN), XMIN, XMAX );
00386 LumiIntegratedEtSum->setAxisTitle( LumiXTitle, 1 );
00387 LumiIntegratedEtSum->setAxisTitle( LumiEtSumYTitle, 2 );
00388
00389 LumiIntegratedOccSet1 = dbe_->book1D("LumiIntegratedOccSet1","Integrated Luminosity - Set 1", int(XMAX-XMIN), XMIN, XMAX );
00390 LumiIntegratedOccSet1->setAxisTitle( LumiXTitle, 1 );
00391 LumiIntegratedOccSet1->setAxisTitle( LumiOccYTitle, 2 );
00392
00393 LumiIntegratedOccSet2 = dbe_->book1D("LumiIntegratedOccSet2","Integrated Luminosity - Set 2", int(XMAX-XMIN), XMIN, XMAX );
00394 LumiIntegratedOccSet2->setAxisTitle( LumiXTitle, 1 );
00395 LumiIntegratedOccSet2->setAxisTitle( LumiOccYTitle, 2 );
00396
00397
00398
00399 dbe_->setCurrentFolder(monitorName_+"/CheckSums");
00400
00401 std::string sumXTitle = "HF Wedge";
00402 std::string sumYTitle = "Occupancy Sum (Below+Above+Between)";
00403
00404 SumAllOccSet1 = dbe_->bookProfile("SumAllOccSet1","Occupancy Check - Set 1",NUM_HLX, 0, NUM_HLX, OccBins, OccMax, OccMin );
00405 SumAllOccSet1->setAxisTitle( sumXTitle, 1 );
00406 SumAllOccSet1->setAxisTitle( sumYTitle, 2 );
00407
00408 SumAllOccSet2 = dbe_->bookProfile("SumAllOccSet2","Occupancy Check - Set 2",NUM_HLX, 0, NUM_HLX, OccBins, OccMax, OccMin );
00409 SumAllOccSet2->setAxisTitle( sumXTitle, 1 );
00410 SumAllOccSet2->setAxisTitle( sumYTitle, 2 );
00411
00412 MissingDQMDataCheck = dbe_->book1D( "MissingDQMDataCheck", "Missing Data Count",1, 0, 1);
00413 MissingDQMDataCheck->setAxisTitle( "", 1 );
00414 MissingDQMDataCheck->setAxisTitle( "Number Missing Nibbles", 2 );
00415
00416
00417 dbe_->setCurrentFolder(monitorName_+"/SigBkgLevels");
00418
00419 MaxInstLumiBX1 = dbe_->book1D("MaxInstLumiBX1","Max Instantaneous Luminosity BX: 1st",10000,-1e-5,0.01);
00420 MaxInstLumiBX1->setAxisTitle("Max Inst. L (10^{30}cm^{-2}s^{-1})",1);
00421 MaxInstLumiBX1->setAxisTitle("Entries",2);
00422 MaxInstLumiBX2 = dbe_->book1D("MaxInstLumiBX2","Max Instantaneous Luminosity BX: 2nd",10000,-1e-5,0.01);
00423 MaxInstLumiBX2->setAxisTitle("Max Inst. L (10^{30}cm^{-2}s^{-1})",1);
00424 MaxInstLumiBX2->setAxisTitle("Entries",2);
00425 MaxInstLumiBX3 = dbe_->book1D("MaxInstLumiBX3","Max Instantaneous Luminosity BX: 3rd",10000,-1e-5,0.01);
00426 MaxInstLumiBX3->setAxisTitle("Max Inst. L (10^{30}cm^{-2}s^{-1})",1);
00427 MaxInstLumiBX3->setAxisTitle("Entries",2);
00428 MaxInstLumiBX4 = dbe_->book1D("MaxInstLumiBX4","Max Instantaneous Luminosity BX: 4th",10000,-1e-5,0.01);
00429 MaxInstLumiBX4->setAxisTitle("Max Inst. L (10^{30}cm^{-2}s^{-1})",1);
00430 MaxInstLumiBX4->setAxisTitle("Entries",2);
00431
00432 MaxInstLumiBXNum1 = dbe_->book1D("MaxInstLumiBXNum1","BX Number of Max: 1st",3564,0,3564);
00433 MaxInstLumiBXNum1->setAxisTitle("BX",1);
00434 MaxInstLumiBXNum1->setAxisTitle("Num Time Max",2);
00435 MaxInstLumiBXNum2 = dbe_->book1D("MaxInstLumiBXNum2","BX Number of Max: 2nd",3564,0,3564);
00436 MaxInstLumiBXNum2->setAxisTitle("BX",1);
00437 MaxInstLumiBXNum2->setAxisTitle("Num Time Max",2);
00438 MaxInstLumiBXNum3 = dbe_->book1D("MaxInstLumiBXNum3","BX Number of Max: 3rd",3564,0,3564);
00439 MaxInstLumiBXNum3->setAxisTitle("BX",1);
00440 MaxInstLumiBXNum3->setAxisTitle("Num Time Max",2);
00441 MaxInstLumiBXNum4 = dbe_->book1D("MaxInstLumiBXNum4","BX Number of Max: 4th",3564,0,3564);
00442 MaxInstLumiBXNum4->setAxisTitle("BX",1);
00443 MaxInstLumiBXNum4->setAxisTitle("Num Time Max",2);
00444
00445
00446 dbe_->setCurrentFolder(monitorName_+"/HistoryRaw");
00447
00448 std::string HistXTitle = "Time (LS)";
00449 std::string RecentHistXTitle = "Time (LS/16)";
00450 std::string HistEtSumYTitle = "Average E_{T} Sum";
00451 std::string HistOccYTitle = "Average Occupancy";
00452 std::string HistLumiYTitle = "Luminosity";
00453 std::string HistLumiErrorYTitle = "Luminosity Error (%)";
00454 std::string BXvsTimeXTitle = "Time (LS)";
00455 std::string BXvsTimeYTitle = "BX";
00456
00457
00458 HistAvgEtSumHFP = dbe_->bookProfile( "HistAvgEtSumHFP", "Average Et Sum: HF+",
00459 MAX_LS, 0.5, (double)MAX_LS+0.5, EtSumBins, EtSumMin, EtSumMax);
00460 HistAvgEtSumHFP->setAxisTitle( HistXTitle, 1 );
00461 HistAvgEtSumHFP->setAxisTitle( HistEtSumYTitle, 2 );
00462
00463 HistAvgEtSumHFM = dbe_->bookProfile( "HistAvgEtSumHFM", "Average Et Sum: HF-",
00464 MAX_LS, 0.5, (double)MAX_LS+0.5, EtSumBins, EtSumMin, EtSumMax);
00465 HistAvgEtSumHFM->setAxisTitle( HistXTitle, 1 );
00466 HistAvgEtSumHFM->setAxisTitle( HistEtSumYTitle, 2 );
00467
00468
00469 HistAvgOccBelowSet1HFP = dbe_->bookProfile( "HistAvgOccBelowSet1HFP", "Average Occ Set1Below: HF+",
00470 MAX_LS, 0.5, (double)MAX_LS+0.5, OccBins, OccMin, OccMax );
00471 HistAvgOccBelowSet1HFP->setAxisTitle( HistXTitle, 1 );
00472 HistAvgOccBelowSet1HFP->setAxisTitle( HistOccYTitle, 2 );
00473
00474 HistAvgOccBelowSet1HFM = dbe_->bookProfile( "HistAvgOccBelowSet1HFM", "Average Occ Set1Below: HF-",
00475 MAX_LS, 0.5, (double)MAX_LS+0.5, OccBins, OccMin, OccMax );
00476 HistAvgOccBelowSet1HFM->setAxisTitle( HistXTitle, 1 );
00477 HistAvgOccBelowSet1HFM->setAxisTitle( HistOccYTitle, 2 );
00478
00479 HistAvgOccBetweenSet1HFP = dbe_->bookProfile( "HistAvgOccBetweenSet1HFP", "Average Occ Set1Between: HF+",
00480 MAX_LS, 0.5, (double)MAX_LS+0.5, OccBins, OccMin, OccMax );
00481 HistAvgOccBetweenSet1HFP->setAxisTitle( HistXTitle, 1 );
00482 HistAvgOccBetweenSet1HFP->setAxisTitle( HistOccYTitle, 2 );
00483
00484 HistAvgOccBetweenSet1HFM = dbe_->bookProfile( "HistAvgOccBetweenSet1HFM", "Average Occ Set1Between: HF-",
00485 MAX_LS, 0.5, (double)MAX_LS+0.5, OccBins, OccMin, OccMax );
00486 HistAvgOccBetweenSet1HFM->setAxisTitle( HistXTitle, 1 );
00487 HistAvgOccBetweenSet1HFM->setAxisTitle( HistOccYTitle, 2 );
00488
00489 HistAvgOccAboveSet1HFP = dbe_->bookProfile( "HistAvgOccAboveSet1HFP", "Average Occ Set1Above: HF+",
00490 MAX_LS, 0.5, (double)MAX_LS+0.5, OccBins, OccMin, OccMax );
00491 HistAvgOccAboveSet1HFP->setAxisTitle( HistXTitle, 1 );
00492 HistAvgOccAboveSet1HFP->setAxisTitle( HistOccYTitle, 2 );
00493
00494 HistAvgOccAboveSet1HFM = dbe_->bookProfile( "HistAvgOccAboveSet1HFM", "Average Occ Set1Above: HF-",
00495 MAX_LS, 0.5, (double)MAX_LS+0.5, OccBins, OccMin, OccMax );
00496 HistAvgOccAboveSet1HFM->setAxisTitle( HistXTitle, 1 );
00497 HistAvgOccAboveSet1HFM->setAxisTitle( HistOccYTitle, 2 );
00498
00499 HistAvgOccBelowSet2HFP = dbe_->bookProfile( "HistAvgOccBelowSet2HFP", "Average Occ Set2Below: HF+",
00500 MAX_LS, 0.5, (double)MAX_LS+0.5, OccBins, OccMin, OccMax );
00501 HistAvgOccBelowSet2HFP->setAxisTitle( HistXTitle, 1 );
00502 HistAvgOccBelowSet2HFP->setAxisTitle( HistOccYTitle, 2 );
00503
00504 HistAvgOccBelowSet2HFM = dbe_->bookProfile( "HistAvgOccBelowSet2HFM", "Average Occ Set2Below: HF-",
00505 MAX_LS, 0.5, (double)MAX_LS+0.5, OccBins, OccMin, OccMax );
00506 HistAvgOccBelowSet2HFM->setAxisTitle( HistXTitle, 1 );
00507 HistAvgOccBelowSet2HFM->setAxisTitle( HistOccYTitle, 2 );
00508
00509 HistAvgOccBetweenSet2HFP = dbe_->bookProfile( "HistAvgOccBetweenSet2HFP", "Average Occ Set2Between: HF+",
00510 MAX_LS, 0.5, (double)MAX_LS+0.5, OccBins, OccMin, OccMax );
00511 HistAvgOccBetweenSet2HFP->setAxisTitle( HistXTitle, 1 );
00512 HistAvgOccBetweenSet2HFP->setAxisTitle( HistOccYTitle, 2 );
00513
00514 HistAvgOccBetweenSet2HFM = dbe_->bookProfile( "HistAvgOccBetweenSet2HFM", "Average Occ Set2Between: HF-",
00515 MAX_LS, 0.5, (double)MAX_LS+0.5, OccBins, OccMin, OccMax );
00516 HistAvgOccBetweenSet2HFM->setAxisTitle( HistXTitle, 1 );
00517 HistAvgOccBetweenSet2HFM->setAxisTitle( HistOccYTitle, 2 );
00518
00519 HistAvgOccAboveSet2HFP = dbe_->bookProfile( "HistAvgOccAboveSet2HFP", "Average Occ Set2Above: HF+",
00520 MAX_LS, 0.5, (double)MAX_LS+0.5, OccBins, OccMin, OccMax );
00521 HistAvgOccAboveSet2HFP->setAxisTitle( HistXTitle, 1 );
00522 HistAvgOccAboveSet2HFP->setAxisTitle( HistOccYTitle, 2 );
00523
00524 HistAvgOccAboveSet2HFM = dbe_->bookProfile( "HistAvgOccAboveSet2HFM", "Average Occ Set2Above: HF-",
00525 MAX_LS, 0.5, (double)MAX_LS+0.5, OccBins, OccMin, OccMax );
00526 HistAvgOccAboveSet2HFM->setAxisTitle( HistXTitle, 1 );
00527 HistAvgOccAboveSet2HFM->setAxisTitle( HistOccYTitle, 2 );
00528
00529
00530 BXvsTimeAvgEtSumHFP = dbe_->book2D( "BXvsTimeAvgEtSumHFP", "Average Et Sum: HF+",
00531 MAX_LS, 0.5, (double)MAX_LS+0.5, NBINS, (double)XMIN, (double)XMAX);
00532 BXvsTimeAvgEtSumHFP->setAxisTitle( BXvsTimeXTitle, 1 );
00533 BXvsTimeAvgEtSumHFP->setAxisTitle( BXvsTimeYTitle, 2 );
00534
00535 BXvsTimeAvgEtSumHFM = dbe_->book2D( "BXvsTimeAvgEtSumHFM", "Average Et Sum: HF-",
00536 MAX_LS, 0.5, (double)MAX_LS+0.5, NBINS, (double)XMIN, (double)XMAX);
00537 BXvsTimeAvgEtSumHFM->setAxisTitle( BXvsTimeXTitle, 1 );
00538 BXvsTimeAvgEtSumHFM->setAxisTitle( BXvsTimeYTitle, 2 );
00539
00540 dbe_->setCurrentFolder(monitorName_+"/HistoryLumi");
00541
00542
00543 HistAvgLumiEtSum = dbe_->bookProfile( "HistAvgLumiEtSum", "Average Instant Luminosity: Et Sum",
00544 MAX_LS, 0.5, (double)MAX_LS+0.5, EtSumBins, EtSumMin, EtSumMax);
00545 HistAvgLumiEtSum->setAxisTitle( HistXTitle, 1 );
00546 HistAvgLumiEtSum->setAxisTitle( HistLumiYTitle, 2 );
00547
00548 HistAvgLumiOccSet1 = dbe_->bookProfile( "HistAvgLumiOccSet1", "Average Instant Luminosity: Occ Set1",
00549 MAX_LS, 0.5, (double)MAX_LS+0.5, OccBins, OccMin, OccMax);
00550 HistAvgLumiOccSet1->setAxisTitle( HistXTitle, 1 );
00551 HistAvgLumiOccSet1->setAxisTitle( HistLumiYTitle, 2 );
00552
00553 HistAvgLumiOccSet2 = dbe_->bookProfile( "HistAvgLumiOccSet2", "Average Instant Luminosity: Occ Set2",
00554 MAX_LS, 0.5, (double)MAX_LS+0.5, OccBins, OccMin, OccMax);
00555 HistAvgLumiOccSet2->setAxisTitle( HistXTitle, 1 );
00556 HistAvgLumiOccSet2->setAxisTitle( HistLumiYTitle, 2 );
00557
00558 HistInstantLumiEtSum = dbe_->book1D( "HistInstantLumiEtSum", "Instant Luminosity: Et Sum",
00559 MAX_LS, 0.5, (double)MAX_LS+0.5);
00560 HistInstantLumiEtSum->setAxisTitle( HistXTitle, 1 );
00561 HistInstantLumiEtSum->setAxisTitle( HistLumiYTitle, 2 );
00562
00563 HistInstantLumiOccSet1 = dbe_->book1D( "HistInstantLumiOccSet1", "Instant Luminosity: Occ Set1",
00564 MAX_LS, 0.5, (double)MAX_LS+0.5);
00565 HistInstantLumiOccSet1->setAxisTitle( HistXTitle, 1 );
00566 HistInstantLumiOccSet1->setAxisTitle( HistLumiYTitle, 2 );
00567
00568 HistInstantLumiOccSet2 = dbe_->book1D( "HistInstantLumiOccSet2", "Instant Luminosity: Occ Set2",
00569 MAX_LS, 0.5, (double)MAX_LS+0.5);
00570 HistInstantLumiOccSet2->setAxisTitle( HistXTitle, 1 );
00571 HistInstantLumiOccSet2->setAxisTitle( HistLumiYTitle, 2 );
00572
00573 HistInstantLumiEtSumError = dbe_->book1D( "HistInstantLumiEtSumError", "Luminosity Error: Et Sum",
00574 MAX_LS, 0.5, (double)MAX_LS+0.5);
00575 HistInstantLumiEtSumError->setAxisTitle( HistXTitle, 1 );
00576 HistInstantLumiEtSumError->setAxisTitle( HistLumiErrorYTitle, 2 );
00577
00578 HistInstantLumiOccSet1Error = dbe_->book1D( "HistInstantLumiOccSet1Error", "Luminosity Error: Occ Set1",
00579 MAX_LS, 0.5, (double)MAX_LS+0.5);
00580 HistInstantLumiOccSet1Error->setAxisTitle( HistXTitle, 1 );
00581 HistInstantLumiOccSet1Error->setAxisTitle( HistLumiErrorYTitle, 2 );
00582
00583 HistInstantLumiOccSet2Error = dbe_->book1D( "HistInstantLumiOccSet2Error", "Luminosity Error: Occ Set2",
00584 MAX_LS, 0.5, (double)MAX_LS+0.5);
00585 HistInstantLumiOccSet2Error->setAxisTitle( HistXTitle, 1 );
00586 HistInstantLumiOccSet2Error->setAxisTitle( HistLumiErrorYTitle, 2 );
00587
00588
00589 HistIntegratedLumiEtSum = dbe_->book1D( "HistIntegratedLumiEtSum", "Integrated Luminosity: Et Sum",
00590 MAX_LS, 0.5, (double)MAX_LS+0.5);
00591 HistIntegratedLumiEtSum->setAxisTitle( HistXTitle, 1 );
00592 HistIntegratedLumiEtSum->setAxisTitle( HistLumiYTitle, 2 );
00593
00594 HistIntegratedLumiOccSet1 = dbe_->book1D( "HistIntegratedLumiOccSet1", "Integrated Luminosity: Occ Set1",
00595 MAX_LS, 0.5, (double)MAX_LS+0.5);
00596 HistIntegratedLumiOccSet1->setAxisTitle( HistXTitle, 1 );
00597 HistIntegratedLumiOccSet1->setAxisTitle( HistLumiYTitle, 2 );
00598
00599 HistIntegratedLumiOccSet2 = dbe_->book1D( "HistIntegratedLumiOccSet2", "Integrated Luminosity: Occ Set2",
00600 MAX_LS, 0.5, (double)MAX_LS+0.5);
00601 HistIntegratedLumiOccSet2->setAxisTitle( HistXTitle, 1 );
00602 HistIntegratedLumiOccSet2->setAxisTitle( HistLumiYTitle, 2 );
00603
00604 dbe_->setCurrentFolder(monitorName_+"/RecentHistoryLumi");
00605
00606
00607 RecentInstantLumiEtSum = dbe_->book1D( "RecentInstantLumiEtSum", "Instant Luminosity: Et Sum",
00608 128, 0.5, (double)128+0.5);
00609 RecentInstantLumiEtSum->setAxisTitle( RecentHistXTitle, 1 );
00610 RecentInstantLumiEtSum->setAxisTitle( HistLumiYTitle, 2 );
00611
00612 RecentInstantLumiOccSet1 = dbe_->book1D( "RecentInstantLumiOccSet1", "Instant Luminosity: Occ Set1",
00613 128, 0.5, (double)128+0.5);
00614 RecentInstantLumiOccSet1->setAxisTitle( RecentHistXTitle, 1 );
00615 RecentInstantLumiOccSet1->setAxisTitle( HistLumiYTitle, 2 );
00616
00617 RecentInstantLumiOccSet2 = dbe_->book1D( "RecentInstantLumiOccSet2", "Instant Luminosity: Occ Set2",
00618 128, 0.5, (double)128+0.5);
00619 RecentInstantLumiOccSet2->setAxisTitle( RecentHistXTitle, 1 );
00620 RecentInstantLumiOccSet2->setAxisTitle( HistLumiYTitle, 2 );
00621
00622 RecentIntegratedLumiEtSum = dbe_->book1D( "RecentIntegratedLumiEtSum", "Integrated Luminosity: Et Sum",
00623 128, 0.5, (double)128+0.5);
00624 RecentIntegratedLumiEtSum->setAxisTitle( RecentHistXTitle, 1 );
00625 RecentIntegratedLumiEtSum->setAxisTitle( HistLumiYTitle, 2 );
00626
00627 RecentIntegratedLumiOccSet1 = dbe_->book1D( "RecentIntegratedLumiOccSet1", "Integrated Luminosity: Occ Set1",
00628 128, 0.5, (double)128+0.5);
00629 RecentIntegratedLumiOccSet1->setAxisTitle( RecentHistXTitle, 1 );
00630 RecentIntegratedLumiOccSet1->setAxisTitle( HistLumiYTitle, 2 );
00631
00632 RecentIntegratedLumiOccSet2 = dbe_->book1D( "RecentIntegratedLumiOccSet2", "Integrated Luminosity: Occ Set2",
00633 128, 0.5, (double)128+0.5);
00634 RecentIntegratedLumiOccSet2->setAxisTitle( RecentHistXTitle, 1 );
00635 RecentIntegratedLumiOccSet2->setAxisTitle( HistLumiYTitle, 2 );
00636
00637 std::vector<std::string> systems = (dbe_->cd(), dbe_->getSubdirs());
00638 for( size_t i=0, e = systems.size(); i<e; ++i ){
00639 std::cout << "Systems " << systems[i] << std::endl;
00640 }
00641
00642 dbe_->showDirStructure();
00643 }
00644
00645
00646 void HLXMonitor::SetupEventInfo( )
00647 {
00648
00649 using std::string;
00650
00651 string currentfolder = subSystemName_ + "/" + eventInfoFolderHLX_;
00652
00653
00654 dbe_->setCurrentFolder(currentfolder) ;
00655
00656 pEvent_ = 0;
00657 evtRateCount_ = 0;
00658 gettimeofday(¤tTime_,NULL);
00659 lastAvgTime_ = currentTime_;
00660 evtRateWindow_ = 0.5;
00661
00662
00663 runId_ = dbe_->bookInt("iRun");
00664 lumisecId_ = dbe_->bookInt("iLumiSection");
00665
00666 eventId_ = dbe_->bookInt("iEvent");
00667 eventId_->Fill(-1);
00668 eventTimeStamp_ = dbe_->bookFloat("eventTimeStamp");
00669
00670 dbe_->setCurrentFolder(currentfolder) ;
00671
00672 processTimeStamp_ = dbe_->bookFloat("processTimeStamp");
00673 processTimeStamp_->Fill(getUTCtime(¤tTime_));
00674 processLatency_ = dbe_->bookFloat("processLatency");
00675 processTimeStamp_->Fill(-1);
00676 processEvents_ = dbe_->bookInt("processedEvents");
00677 processEvents_->Fill(pEvent_);
00678 processEventRate_ = dbe_->bookFloat("processEventRate");
00679 processEventRate_->Fill(-1);
00680 nUpdates_= dbe_->bookInt("processUpdates");
00681 nUpdates_->Fill(-1);
00682
00683
00684 processId_= dbe_->bookInt("processID");
00685 processId_->Fill(gSystem->GetPid());
00686 processStartTimeStamp_ = dbe_->bookFloat("processStartTimeStamp");
00687 processStartTimeStamp_->Fill(getUTCtime(¤tTime_));
00688 runStartTimeStamp_ = dbe_->bookFloat("runStartTimeStamp");
00689 hostName_= dbe_->bookString("hostName",gSystem->HostName());
00690 processName_= dbe_->bookString("processName",subSystemName_);
00691 workingDir_= dbe_->bookString("workingDir",gSystem->pwd());
00692 cmsswVer_= dbe_->bookString("CMSSW_Version",edm::getReleaseVersion());
00693
00694
00695
00696
00697 currentfolder = subSystemName_ + "/" + eventInfoFolder_;
00698 dbe_->setCurrentFolder(currentfolder) ;
00699
00700 reportSummary_ = dbe_->bookFloat("reportSummary");
00701 reportSummaryMap_ = dbe_->book2D("reportSummaryMap", "reportSummaryMap", 18, 0., 18., 2, -1.5, 1.5);
00702
00703 currentfolder = subSystemName_ + "/" + eventInfoFolderHLX_;
00704 dbe_->setCurrentFolder(currentfolder) ;
00705
00706 TH2F *summaryHist = reportSummaryMap_->getTH2F();
00707 summaryHist->GetYaxis()->SetBinLabel(1,"HF-");
00708 summaryHist->GetYaxis()->SetBinLabel(2,"HF+");
00709 summaryHist->GetXaxis()->SetTitle("Wedge #");
00710
00711
00712
00713 reportSummary_->Fill(1.0);
00714
00715 for( unsigned int iHLX = 0; iHLX < NUM_HLX; ++iHLX ){
00716 unsigned int iWedge = HLXHFMap[iHLX] + 1;
00717 unsigned int iEta = 2;
00718 if( iWedge >= 19 ){ iEta = 1; iWedge -= 18; }
00719 reportSummaryMap_->setBinContent(iWedge,iEta,1.0);
00720 }
00721 }
00722
00723
00724
00725 void
00726 HLXMonitor::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00727 {
00728 using namespace edm;
00729
00730 while( HLXTCP.IsConnected() == false )
00731 {
00732 HLXTCP.SetIP(DistribIP1);
00733 if( HLXTCP.Connect() != 1 )
00734 {
00735 std::cout << "Failed to connect to " << DistribIP1 << "." << std::endl;
00736 sleep( 1 );
00737 std::cout << "Trying " << DistribIP2 << std::endl;
00738 HLXTCP.SetIP( DistribIP2 );
00739 if( HLXTCP.Connect() == 1) break;
00740 std::cout << "Failed to connect to " << DistribIP2 << "." << std::endl;
00741 std::cout << " Reconnect in " << reconnTime << " seconds." << std::endl;
00742 sleep(reconnTime);
00743 }
00744 }
00745 if( HLXTCP.IsConnected() == true )
00746 {
00747 std::cout << "Successfully connected." << std::endl;
00748 }
00749
00750 if( HLXTCP.ReceiveLumiSection( lumiSection ) == 1 )
00751 {
00752
00753 if( runNumber_ != lumiSection.hdr.runNumber ){
00754 if( !currentRunEnded_ && runNumber_ != 0 ) EndRun();
00755 runNumber_ = lumiSection.hdr.runNumber;
00756 currentRunEnded_ = false;
00757
00758 timeval startruntime;
00759 gettimeofday(&startruntime,NULL);
00760 runStartTimeStamp_->Fill(getUTCtime(&startruntime));
00761 }
00762
00763
00764 FillHistograms(lumiSection);
00765 FillHistoHFCompare(lumiSection);
00766 FillEventInfo(lumiSection,iEvent);
00767 FillReportSummary();
00768
00769 cout << "Run: " << lumiSection.hdr.runNumber
00770 << " Section: " << lumiSection.hdr.sectionNumber
00771 << " Orbit: " << lumiSection.hdr.startOrbit << endl;
00772 cout << "Et Lumi: " << lumiSection.lumiSummary.InstantETLumi << endl;
00773 cout << "Occ Lumi 1: " << lumiSection.lumiSummary.InstantOccLumi[0] << endl;
00774 cout << "Occ Lumi 2: " << lumiSection.lumiSummary.InstantOccLumi[1] << endl;
00775 }
00776 else
00777 {
00778 HLXTCP.Disconnect();
00779 EndRun();
00780 }
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804 }
00805
00806
00807 void HLXMonitor::SaveDQMFile(){
00808
00809 std::ostringstream tempStreamer;
00810 tempStreamer << OutputDir << "/" << OutputFilePrefix << "_" << subSystemName_
00811 << "_R" << std::setfill('0') << std::setw(runNumLength)
00812 << runNumber_ << "_T00000001.root";
00813
00814 std::vector<std::string> systems = (dbe_->cd(), dbe_->getSubdirs());
00815 char rewrite[64]; sprintf(rewrite, "\\1Run %d/\\2/Run summary", runNumber_);
00816 int saveReference_ = DQMStore::SaveWithoutReference;
00817 int saveReferenceQMin_ = dqm::qstatus::STATUS_OK;
00818
00819 for( size_t i = 0, e = systems.size(); i != e; ++i )
00820 if (systems[i] != "Reference")
00821 dbe_->save( tempStreamer.str(), systems[i], "^(Reference/)?([^/]+)", rewrite,
00822 (DQMStore::SaveReferenceTag)saveReference_, saveReferenceQMin_);
00823
00824
00825 }
00826
00827
00828 void HLXMonitor::beginJob()
00829 {
00830 HLXTCP.SetIP(DistribIP1);
00831 int errorCode = HLXTCP.SetPort(listenPort);
00832 cout << "SetPort: " << listenPort << " Success: " << errorCode << endl;
00833 errorCode = HLXTCP.SetMode(AquireMode);
00834 cout << "AquireMode: " << AquireMode << " Success: " << errorCode << endl;
00835
00836 while( HLXTCP.IsConnected() == false )
00837 {
00838 HLXTCP.SetIP(DistribIP1);
00839 if( HLXTCP.Connect() != 1 )
00840 {
00841 std::cout << "Failed to connect to " << DistribIP1 << "." << std::endl;
00842 sleep( 1 );
00843 std::cout << "Trying " << DistribIP2 << std::endl;
00844 HLXTCP.SetIP( DistribIP2 );
00845 if( HLXTCP.Connect() == 1) break;
00846 std::cout << "Failed to connect to " << DistribIP2 << "." << std::endl;
00847 std::cout << " Reconnect in " << reconnTime << " seconds." << std::endl;
00848 sleep(reconnTime);
00849 }
00850 }
00851 if( HLXTCP.IsConnected() == true )
00852 {
00853 std::cout << "Successfully connected." << std::endl;
00854 }
00855
00856 }
00857
00858
00859 void HLXMonitor::endJob()
00860 {
00861
00862
00863
00864 HLXTCP.Disconnect();
00865 EndRun( SaveAtEndJob );
00866 }
00867
00868 void HLXMonitor::EndRun( bool saveFile )
00869 {
00870 FillReportSummary();
00871
00872
00873 if( saveFile && runNumber_ != 0 ){
00874 if( int(lumiSectionCount/num4NibblePerLS_) >= (int)MinLSBeforeSave ) SaveDQMFile();
00875 else std::cout << "Num LS's (" << int(lumiSectionCount/num4NibblePerLS_) << ") "
00876 << "is less than required minumum (" << MinLSBeforeSave
00877 << "). File will not be saved!" << std::endl;
00878 }
00879 expectedNibbles_ = 0;
00880 for( unsigned int iHLX = 0; iHLX < NUM_HLX; ++iHLX ) totalNibbles_[iHLX] = 0;
00881
00882 std::cout << "** Here in end run **" << std::endl;
00883 if(ResetAtNewRun) ResetAll();
00884 runNumber_ = 0;
00885 currentRunEnded_ = true;
00886 sectionInstantSumEt = 0;
00887 sectionInstantErrSumEt = 0;
00888 sectionInstantSumOcc1 = 0;
00889 sectionInstantErrSumOcc1 = 0;
00890 sectionInstantSumOcc2 = 0;
00891 sectionInstantErrSumOcc2 = 0;
00892 sectionInstantNorm = 0;
00893 lsBinOld = 0;
00894 lumiSectionCount = 0;
00895 previousSection = 0;
00896 }
00897
00898
00899 void HLXMonitor::FillHistograms(const LUMI_SECTION & section)
00900 {
00901
00902 if( previousSection != (section.hdr.sectionNumber-1) ){
00903 double weight = (double)(section.hdr.sectionNumber-previousSection-1);
00904
00905 MissingDQMDataCheck->Fill(0.5,weight);
00906 }
00907 previousSection = section.hdr.sectionNumber;
00908
00909 int lsBin = int(lumiSectionCount/num4NibblePerLS_);
00910 int lsBinBX = int(lumiSectionCount/num4NibblePerLS_);
00911 HistAvgLumiEtSum->Fill(lsBin, section.lumiSummary.InstantETLumi);
00912 HistAvgLumiOccSet1->Fill(lsBin, section.lumiSummary.InstantOccLumi[0]);
00913 HistAvgLumiOccSet2->Fill(lsBin, section.lumiSummary.InstantOccLumi[1]);
00914
00915
00916
00917
00918
00919
00920
00921
00922 int fillBin = lumiSectionCount+1;
00923 if( fillBin > 128 )
00924 {
00925
00926
00927 for( int iBin = 1; iBin<128; ++iBin )
00928 {
00929 RecentInstantLumiEtSum->setBinContent(iBin,RecentInstantLumiEtSum->getBinContent(iBin+1));
00930 RecentInstantLumiOccSet1->setBinContent(iBin,RecentInstantLumiOccSet1->getBinContent(iBin+1));
00931 RecentInstantLumiOccSet2->setBinContent(iBin,RecentInstantLumiOccSet2->getBinContent(iBin+1));
00932 RecentIntegratedLumiEtSum->setBinContent(iBin,RecentIntegratedLumiEtSum->getBinContent(iBin+1));
00933 RecentIntegratedLumiOccSet1->setBinContent(iBin,RecentIntegratedLumiOccSet1->getBinContent(iBin+1));
00934 RecentIntegratedLumiOccSet2->setBinContent(iBin,RecentIntegratedLumiOccSet2->getBinContent(iBin+1));
00935 }
00936 fillBin = 128;
00937 }
00938
00939 RecentInstantLumiEtSum->setBinContent(fillBin,section.lumiSummary.InstantETLumi);
00940 RecentInstantLumiEtSum->setBinError(fillBin,section.lumiSummary.InstantETLumiErr);
00941 RecentInstantLumiOccSet1->setBinContent(fillBin,section.lumiSummary.InstantOccLumi[0]);
00942 RecentInstantLumiOccSet1->setBinError(fillBin,section.lumiSummary.InstantOccLumiErr[0]);
00943 RecentInstantLumiOccSet2->setBinContent(fillBin,section.lumiSummary.InstantOccLumi[1]);
00944 RecentInstantLumiOccSet2->setBinError(fillBin,section.lumiSummary.InstantOccLumiErr[1]);
00945
00946 double recentOldBinContent = RecentIntegratedLumiEtSum->getBinContent(fillBin-1);
00947 if( fillBin == 1 ) recentOldBinContent = 0;
00948 double recentNewBinContent = recentOldBinContent + section.lumiSummary.InstantETLumi;
00949 RecentIntegratedLumiEtSum->setBinContent(fillBin,recentNewBinContent);
00950 recentOldBinContent = RecentIntegratedLumiOccSet1->getBinContent(fillBin-1);
00951 if( fillBin == 1 ) recentOldBinContent = 0;
00952 recentNewBinContent = recentOldBinContent + section.lumiSummary.InstantOccLumi[0];
00953 RecentIntegratedLumiOccSet1->setBinContent(fillBin,recentNewBinContent);
00954 recentOldBinContent = RecentIntegratedLumiOccSet2->getBinContent(fillBin-1);
00955 if( fillBin == 1 ) recentOldBinContent = 0;
00956 recentNewBinContent = recentOldBinContent + section.lumiSummary.InstantOccLumi[0];
00957 RecentIntegratedLumiOccSet2->setBinContent(fillBin,recentNewBinContent);
00958
00959 double recentOldBinError = RecentIntegratedLumiEtSum->getBinError(fillBin-1);
00960 if( fillBin == 1 ) recentOldBinError = 0;
00961 double recentNewBinError = sqrt(recentOldBinError*recentOldBinError + section.lumiSummary.InstantETLumiErr*section.lumiSummary.InstantETLumiErr);
00962 RecentIntegratedLumiEtSum->setBinError(fillBin,recentNewBinError);
00963 recentOldBinError = RecentIntegratedLumiOccSet1->getBinError(fillBin-1);
00964 if( fillBin == 1 ) recentOldBinError = 0;
00965 recentNewBinError = sqrt(recentOldBinError*recentOldBinError + section.lumiSummary.InstantOccLumiErr[0]*section.lumiSummary.InstantOccLumiErr[0]);
00966 RecentIntegratedLumiOccSet1->setBinError(fillBin,recentNewBinError);
00967 recentOldBinError = RecentIntegratedLumiOccSet2->getBinError(fillBin-1);
00968 if( fillBin == 1 ) recentOldBinError = 0;
00969 recentNewBinError = sqrt(recentOldBinError*recentOldBinError + section.lumiSummary.InstantOccLumiErr[1]*section.lumiSummary.InstantOccLumiErr[1]);
00970 RecentIntegratedLumiOccSet2->setBinError(fillBin,recentNewBinError);
00971
00972
00973
00974
00975 if( lsBinOld != lsBin )
00976 {
00977 HistInstantLumiEtSum->setBinContent(lsBin,sectionInstantSumEt);
00978 HistInstantLumiEtSum->setBinError(lsBin,sqrt(sectionInstantErrSumEt));
00979 HistInstantLumiOccSet1->setBinContent(lsBin,sectionInstantSumOcc1);
00980 HistInstantLumiOccSet1->setBinError(lsBin,sqrt(sectionInstantErrSumOcc1));
00981 HistInstantLumiOccSet2->setBinContent(lsBin,sectionInstantSumOcc2);
00982 HistInstantLumiOccSet2->setBinError(lsBin,sqrt(sectionInstantErrSumOcc2));
00983
00984 double etDenom = fabs(sectionInstantSumEt);
00985 if( etDenom < 1e-10 ) etDenom = 1e-10;
00986 double occ1Denom = fabs(sectionInstantSumOcc1);
00987 if( occ1Denom < 1e-10 ) occ1Denom = 1e-10;
00988 double occ2Denom = fabs(sectionInstantSumOcc2);
00989 if( occ2Denom < 1e-10 ) occ2Denom = 1e-10;
00990 double etError = 100.0*sqrt(sectionInstantErrSumEt)/etDenom;
00991 double occ1Error = 100.0*sqrt(sectionInstantErrSumOcc1)/occ1Denom;
00992 double occ2Error = 100.0*sqrt(sectionInstantErrSumOcc2)/occ2Denom;
00993 HistInstantLumiEtSumError->setBinContent(lsBinOld,etError);
00994 HistInstantLumiOccSet1Error->setBinContent(lsBinOld,occ1Error);
00995 HistInstantLumiOccSet2Error->setBinContent(lsBinOld,occ2Error);
00996
00997 double histOldBinContent = HistIntegratedLumiEtSum->getBinContent(lsBinOld);
00998 if( lsBinOld == 0 ) histOldBinContent = 0;
00999 double histNewBinContent = histOldBinContent + sectionInstantSumEt;
01000 HistIntegratedLumiEtSum->setBinContent(lsBin,histNewBinContent);
01001 histOldBinContent = HistIntegratedLumiOccSet1->getBinContent(lsBinOld);
01002 if( lsBinOld == 0 ) histOldBinContent = 0;
01003 histNewBinContent = histOldBinContent + sectionInstantSumOcc1;
01004 HistIntegratedLumiOccSet1->setBinContent(lsBin,histNewBinContent);
01005 histOldBinContent = HistIntegratedLumiOccSet2->getBinContent(lsBinOld);
01006 if( lsBinOld == 0 ) histOldBinContent = 0;
01007 histNewBinContent = histOldBinContent + sectionInstantSumOcc2;
01008 HistIntegratedLumiOccSet2->setBinContent(lsBin,histNewBinContent);
01009
01010 double histOldBinError = HistIntegratedLumiEtSum->getBinError(lsBinOld);
01011 if( lsBinOld == 0 ) histOldBinError = 0;
01012 double histNewBinError = sqrt(histOldBinError*histOldBinError + sectionInstantErrSumEt);
01013 HistIntegratedLumiEtSum->setBinError(lsBin,histNewBinError);
01014 histOldBinError = HistIntegratedLumiOccSet1->getBinError(lsBinOld);
01015 if( lsBinOld == 0 ) histOldBinError = 0;
01016 histNewBinError = sqrt(histOldBinError*histOldBinError + sectionInstantErrSumOcc1);
01017 HistIntegratedLumiOccSet1->setBinError(lsBin,histNewBinError);
01018 histOldBinError = HistIntegratedLumiOccSet2->getBinError(lsBinOld);
01019 if( lsBinOld == 0 ) histOldBinError = 0;
01020 histNewBinError = sqrt(histOldBinError*histOldBinError + sectionInstantErrSumOcc2);
01021 HistIntegratedLumiOccSet2->setBinError(lsBin,histNewBinError);
01022
01023 sectionInstantSumEt = 0;
01024 sectionInstantErrSumEt = 0;
01025 sectionInstantSumOcc1 = 0;
01026 sectionInstantErrSumOcc1 = 0;
01027 sectionInstantSumOcc2 = 0;
01028 sectionInstantErrSumOcc2 = 0;
01029 sectionInstantNorm = 0;
01030 lsBinOld = lsBin;
01031 }
01032
01033 sectionInstantSumEt += section.lumiSummary.InstantETLumi;
01034 sectionInstantErrSumEt += section.lumiSummary.InstantETLumiErr*section.lumiSummary.InstantETLumiErr;
01035 sectionInstantSumOcc1 += section.lumiSummary.InstantOccLumi[0];
01036 sectionInstantErrSumOcc1 += section.lumiSummary.InstantOccLumiErr[0]*section.lumiSummary.InstantOccLumiErr[0];
01037 sectionInstantSumOcc2 += section.lumiSummary.InstantOccLumi[1];
01038 sectionInstantErrSumOcc2 += section.lumiSummary.InstantOccLumiErr[1]*section.lumiSummary.InstantOccLumiErr[1];
01039 ++sectionInstantNorm;
01040
01041 dbe_->softReset(LumiInstantEtSum);
01042 dbe_->softReset(LumiInstantOccSet1);
01043 dbe_->softReset(LumiInstantOccSet2);
01044
01045 for( int iHLX = 0; iHLX < (int)NUM_HLX; ++iHLX ){
01046 unsigned int utotal1= 0;
01047 unsigned int utotal2 = 0;
01048 unsigned int iWedge = HLXHFMap[iHLX];
01049 if(section.occupancy[iHLX].hdr.numNibbles != 0){
01050
01051
01052 for( unsigned int iBX = 0; iBX < NUM_BUNCHES; ++iBX ){
01053
01054
01055 unsigned int norm[2] = {0,0};
01056 norm[0] += section.occupancy[iHLX].data[set1BelowIndex ][iBX];
01057 norm[0] += section.occupancy[iHLX].data[set1BetweenIndex ][iBX];
01058 norm[0] += section.occupancy[iHLX].data[set1AboveIndex ][iBX];
01059 if( norm[0] == 0 ) norm[0]=1;
01060 norm[1] += section.occupancy[iHLX].data[set2BelowIndex ][iBX];
01061 norm[1] += section.occupancy[iHLX].data[set2BetweenIndex ][iBX];
01062 norm[1] += section.occupancy[iHLX].data[set2AboveIndex ][iBX];
01063 if( norm[1] == 0 ) norm[1]=1;
01064
01065 double normEt = section.etSum[iHLX].data[iBX]/(double)(norm[0]+norm[1]);
01066 double normOccSet1Below = (double)section.occupancy[iHLX].data[set1BelowIndex][iBX]/(double)norm[0];
01067 double normOccSet1Between = (double)section.occupancy[iHLX].data[set1BetweenIndex][iBX]/(double)norm[0];
01068 double normOccSet1Above = (double)section.occupancy[iHLX].data[set1AboveIndex][iBX]/(double)norm[0];
01069 double normOccSet2Below = (double)section.occupancy[iHLX].data[set2BelowIndex][iBX]/(double)norm[1];
01070 double normOccSet2Between = (double)section.occupancy[iHLX].data[set2BetweenIndex][iBX]/(double)norm[1];
01071 double normOccSet2Above = (double)section.occupancy[iHLX].data[set2AboveIndex][iBX]/(double)norm[1];
01072
01073
01074 if( iBX < NUM_BUNCHES-100 )
01075 {
01076 AvgEtSum->Fill( iWedge,normEt);
01077
01078 AvgOccBelowSet1-> Fill( iWedge, normOccSet1Below );
01079 AvgOccBetweenSet1->Fill( iWedge, normOccSet1Between );
01080 AvgOccAboveSet1-> Fill( iWedge, normOccSet1Above );
01081
01082 AvgOccBelowSet2-> Fill( iWedge, normOccSet2Below );
01083 AvgOccBetweenSet2->Fill( iWedge, normOccSet2Between );
01084 AvgOccAboveSet2-> Fill( iWedge, normOccSet2Above );
01085
01086 if( iWedge < 18 )
01087 {
01088 HistAvgEtSumHFP->Fill( lsBin,normEt);
01089 HistAvgOccBelowSet1HFP->Fill( lsBin, normOccSet1Below );
01090 HistAvgOccBetweenSet1HFP->Fill( lsBin, normOccSet1Between );
01091 HistAvgOccAboveSet1HFP->Fill( lsBin, normOccSet1Above );
01092 HistAvgOccBelowSet2HFP->Fill( lsBin, normOccSet2Below );
01093 HistAvgOccBetweenSet2HFP->Fill( lsBin, normOccSet2Between );
01094 HistAvgOccAboveSet2HFP->Fill( lsBin, normOccSet2Above );
01095
01096 if( iBX >= (XMIN-1) && iBX <= (XMAX-1) ) BXvsTimeAvgEtSumHFP->Fill(lsBinBX,iBX,normEt/(num4NibblePerLS_*18.0*12.0));
01097 }
01098 else
01099 {
01100 HistAvgEtSumHFM->Fill( lsBin,normEt);
01101 HistAvgOccBelowSet1HFM->Fill( lsBin, normOccSet1Below );
01102 HistAvgOccBetweenSet1HFM->Fill( lsBin, normOccSet1Between );
01103 HistAvgOccAboveSet1HFM->Fill( lsBin, normOccSet1Above );
01104 HistAvgOccBelowSet2HFM->Fill( lsBin, normOccSet2Below );
01105 HistAvgOccBetweenSet2HFM->Fill( lsBin, normOccSet2Between );
01106 HistAvgOccAboveSet2HFM->Fill( lsBin, normOccSet2Above );
01107
01108 if( iBX >= (XMIN-1) && iBX <= (XMAX-1) ) BXvsTimeAvgEtSumHFM->Fill(lsBinBX,iBX,normEt/(num4NibblePerLS_*18.0*12.0));
01109 }
01110
01111 utotal1 += section.occupancy[iHLX].data[set1BelowIndex ][iBX];
01112 utotal1 += section.occupancy[iHLX].data[set1BetweenIndex][iBX];
01113 utotal1 += section.occupancy[iHLX].data[set1AboveIndex ][iBX];
01114
01115 utotal2 += section.occupancy[iHLX].data[set2BelowIndex ][iBX];
01116 utotal2 += section.occupancy[iHLX].data[set2BetweenIndex][iBX];
01117 utotal2 += section.occupancy[iHLX].data[set2AboveIndex ][iBX];
01118
01119 }
01120
01121 if(Style.compare("BX") == 0)
01122 {
01123
01124 TH1F *Set1BelowHist = Set1Below[iWedge]->getTH1F();
01125 int iBin = Set1BelowHist->FindBin((float)iBX);
01126
01127
01128 if( lumiSectionCount > 0 ){
01129 double oldNormOccSet1Below = (Set1Below[iWedge]->getBinContent(iBin))*(double)(lumiSectionCount);
01130 normOccSet1Below += oldNormOccSet1Below;
01131 normOccSet1Below /= (double)(lumiSectionCount+1);
01132 double oldNormOccSet2Below = (Set2Below[iWedge]->getBinContent(iBin))*(double)(lumiSectionCount);
01133 normOccSet2Below += oldNormOccSet2Below;
01134 normOccSet2Below /= (double)(lumiSectionCount+1);
01135
01136 double oldNormOccSet1Between = (Set1Between[iWedge]->getBinContent(iBin))*(double)(lumiSectionCount);
01137 normOccSet1Between += oldNormOccSet1Between;
01138 normOccSet1Between /= (double)(lumiSectionCount+1);
01139 double oldNormOccSet2Between = (Set2Between[iWedge]->getBinContent(iBin))*(double)(lumiSectionCount);
01140 normOccSet2Between += oldNormOccSet2Between;
01141 normOccSet2Between /= (double)(lumiSectionCount+1);
01142
01143 double oldNormOccSet1Above = (Set1Above[iWedge]->getBinContent(iBin))*(double)(lumiSectionCount);
01144 normOccSet1Above += oldNormOccSet1Above;
01145 normOccSet1Above /= (double)(lumiSectionCount+1);
01146 double oldNormOccSet2Above = (Set2Above[iWedge]->getBinContent(iBin))*(double)(lumiSectionCount);
01147 normOccSet2Above += oldNormOccSet2Above;
01148 normOccSet2Above /= (double)(lumiSectionCount+1);
01149
01150 double oldNormEt = ETSum[iWedge]->getBinContent(iBin)*(double)(lumiSectionCount);
01151 normEt += oldNormEt;
01152 normEt /= (double)(lumiSectionCount+1);
01153 }
01154
01155 Set1Below[iWedge]-> setBinContent(iBin, normOccSet1Below );
01156 Set1Between[iWedge]->setBinContent(iBin, normOccSet1Between );
01157 Set1Above[iWedge]-> setBinContent(iBin, normOccSet1Above );
01158 Set2Below[iWedge]-> setBinContent(iBin, normOccSet2Below );
01159 Set2Between[iWedge]->setBinContent(iBin, normOccSet2Between );
01160 Set2Above[iWedge]-> setBinContent(iBin, normOccSet2Above );
01161 ETSum[iWedge]-> setBinContent(iBin, normEt);
01162
01163
01164
01165
01166
01167
01168
01169
01170 }
01171 else if(Style.compare("Dist")==0)
01172 {
01173 Set1Below[iWedge]-> Fill( normOccSet1Below );
01174 Set1Between[iWedge]->Fill( normOccSet1Between );
01175 Set1Above[iWedge]-> Fill( normOccSet1Above );
01176 Set2Below[iWedge]-> Fill( normOccSet2Below );
01177 Set2Between[iWedge]->Fill( normOccSet2Between );
01178 Set2Above[iWedge]-> Fill( normOccSet2Above );
01179 ETSum[iWedge]-> Fill( normEt );
01180 }
01181 }
01182
01183
01184 double total1 = 0;
01185 double total2 = 0;
01186 if( (NUM_BUNCHES-100)>0 )
01187 {
01188 total1 = (double)utotal1/(double)(NUM_BUNCHES-100);
01189 total2 = (double)utotal2/(double)(NUM_BUNCHES-100);
01190 }
01191 if( section.hdr.numOrbits > 0 )
01192 {
01193 total1 = total1/(double)section.hdr.numOrbits;
01194 total2 = total2/(double)section.hdr.numOrbits;
01195 }
01196
01197 SumAllOccSet1-> Fill( iWedge, total1 );
01198 SumAllOccSet2-> Fill( iWedge, total2 );
01199 }
01200 }
01201
01202 double max[4] = {-1000.0,-1000.0,-1000.0,-1000.0};
01203 int bxmax[4] = {-1,-1,-1,-1};
01204 for( unsigned int iBX = 0; iBX < NUM_BUNCHES; ++iBX ){
01205
01206 LumiAvgEtSum->Fill(iBX, section.lumiDetail.ETLumi[iBX]);
01207 LumiAvgOccSet1->Fill(iBX, section.lumiDetail.OccLumi[0][iBX]);
01208 LumiAvgOccSet2->Fill(iBX, section.lumiDetail.OccLumi[1][iBX]);
01209
01210 if( section.lumiDetail.OccLumi[0][iBX] > max[0] ){
01211 max[3] = max[2];
01212 bxmax[3] = bxmax[2];
01213 max[2] = max[1];
01214 bxmax[2] = bxmax[1];
01215 max[1] = max[0];
01216 bxmax[1] = bxmax[0];
01217 max[0] = section.lumiDetail.OccLumi[0][iBX];
01218 bxmax[0] = iBX;
01219 } else if( section.lumiDetail.OccLumi[0][iBX] > max[1] ){
01220 max[3] = max[2];
01221 bxmax[3] = bxmax[2];
01222 max[2] = max[1];
01223 bxmax[2] = bxmax[1];
01224 max[1] = section.lumiDetail.OccLumi[0][iBX];
01225 bxmax[1] = iBX;
01226 } else if( section.lumiDetail.OccLumi[0][iBX] > max[2] ){
01227 max[3] = max[2];
01228 bxmax[3] = bxmax[2];
01229 max[2] = section.lumiDetail.OccLumi[0][iBX];
01230 bxmax[2] = iBX;
01231 } else if( section.lumiDetail.OccLumi[0][iBX] > max[3] ){
01232 max[3] = section.lumiDetail.OccLumi[0][iBX];
01233 bxmax[3] = iBX;
01234 }
01235
01236 int iBin = iBX - (int)XMIN + 1;
01237 if( iBin <= int(XMAX-XMIN) && iBin >= 1 ){
01238
01239
01240
01241
01242
01243
01244
01245 LumiInstantEtSum->setBinContent(iBin, section.lumiDetail.ETLumi[iBX]);
01246 LumiInstantOccSet1->setBinContent(iBin, section.lumiDetail.OccLumi[0][iBX]);
01247 LumiInstantOccSet2->setBinContent(iBin, section.lumiDetail.OccLumi[1][iBX]);
01248 LumiInstantEtSum->setBinError(iBin, section.lumiDetail.ETLumiErr[iBX]);
01249 LumiInstantOccSet1->setBinError(iBin, section.lumiDetail.OccLumiErr[0][iBX]);
01250 LumiInstantOccSet2->setBinError(iBin, section.lumiDetail.OccLumiErr[1][iBX]);
01251
01252 double oldBinContent = LumiIntegratedEtSum->getBinContent(iBin);
01253 if( lumiSectionCount == 0 ) oldBinContent = 0;
01254 double newBinContent = oldBinContent + section.lumiDetail.ETLumi[iBX];
01255 LumiIntegratedEtSum->setBinContent(iBin, newBinContent);
01256 oldBinContent = LumiIntegratedOccSet1->getBinContent(iBin);
01257 if( lumiSectionCount == 0 ) oldBinContent = 0;
01258 newBinContent = oldBinContent + section.lumiDetail.OccLumi[0][iBX];
01259 LumiIntegratedOccSet1->setBinContent(iBin, newBinContent);
01260 oldBinContent = LumiIntegratedOccSet2->getBinContent(iBin);
01261 if( lumiSectionCount == 0 ) oldBinContent = 0;
01262 newBinContent = oldBinContent + section.lumiDetail.OccLumi[1][iBX];
01263 LumiIntegratedOccSet2->setBinContent(iBin, newBinContent);
01264
01265 double oldBinError = LumiIntegratedEtSum->getBinError(iBin);
01266 if( lumiSectionCount == 0 ) oldBinError = 0;
01267 double newBinError = sqrt(oldBinError*oldBinError + section.lumiDetail.ETLumiErr[iBX]*section.lumiDetail.ETLumiErr[iBX]);
01268 LumiIntegratedEtSum->setBinError(iBin, newBinError);
01269 oldBinError = LumiIntegratedOccSet1->getBinError(iBin);
01270 if( lumiSectionCount == 0 ) oldBinError = 0;
01271 newBinError = sqrt(oldBinError*oldBinError + section.lumiDetail.OccLumiErr[0][iBX]*section.lumiDetail.OccLumiErr[0][iBX]);
01272 LumiIntegratedOccSet1->setBinError(iBin, newBinError);
01273 oldBinError = LumiIntegratedOccSet1->getBinError(iBin);
01274 if( lumiSectionCount == 0 ) oldBinError = 0;
01275 newBinError = sqrt(oldBinError*oldBinError + section.lumiDetail.OccLumiErr[1][iBX]*section.lumiDetail.OccLumiErr[1][iBX]);
01276 LumiIntegratedOccSet2->setBinError(iBin, newBinError);
01277 }
01278 }
01279
01280
01281
01282
01283 int flag=1;
01284 for( int iM = 0; (iM<4)&&flag; ++iM ){
01285 flag = 0;
01286 for( int iN = 0; iN < 3; ++iN ){
01287 if( bxmax[iN+1] < bxmax[iN] ){
01288 int tmp = bxmax[iN];
01289 bxmax[iN] = bxmax[iN+1];
01290 bxmax[iN+1] = tmp;
01291
01292 double tmp2 = max[iN];
01293 max[iN] = max[iN+1];
01294 max[iN+1] = tmp2;
01295 flag=1;
01296 }
01297 }
01298 }
01299
01300
01301 MaxInstLumiBX1->Fill(max[0]*0.9e1);
01302 MaxInstLumiBXNum1->Fill(bxmax[0]);
01303 MaxInstLumiBX2->Fill(max[1]*0.9e1);
01304 MaxInstLumiBXNum2->Fill(bxmax[1]);
01305 MaxInstLumiBX3->Fill(max[2]*0.9e1);
01306 MaxInstLumiBXNum3->Fill(bxmax[2]);
01307 MaxInstLumiBX4->Fill(max[3]*0.9e1);
01308 MaxInstLumiBXNum4->Fill(bxmax[3]);
01309
01310 TH1F* tmpHist = MaxInstLumiBX1->getTH1F();
01311 double minX = tmpHist->GetBinLowEdge(1);
01312 double maxX = tmpHist->GetBinLowEdge(tmpHist->GetNbinsX()+1);
01313
01314 int inum4NibblePerLS = (int)num4NibblePerLS_;
01315 if( lumiSectionCount%inum4NibblePerLS == 0 ){
01316 double mean1 = MaxInstLumiBX1->getMean();
01317 double rms1 = MaxInstLumiBX1->getRMS();
01318 if( rms1 > 0 && mean1-5*rms1 > minX && mean1+5*rms1<maxX ) MaxInstLumiBX1->setAxisRange(mean1-5*rms1,mean1+5*rms1);
01319
01320 double mean2 = MaxInstLumiBX2->getMean();
01321 double rms2 = MaxInstLumiBX2->getRMS();
01322 if( rms2 > 0 && mean2-5*rms2 > minX && mean2+5*rms2<maxX ) MaxInstLumiBX2->setAxisRange(mean2-5*rms2,mean2+5*rms2);
01323
01324 double mean3 = MaxInstLumiBX3->getMean();
01325 double rms3 = MaxInstLumiBX3->getRMS();
01326 if( rms3 > 0 && mean3-5*rms3 > minX && mean3+5*rms3<maxX ) MaxInstLumiBX3->setAxisRange(mean3-5*rms3,mean3+5*rms3);
01327
01328 double mean4 = MaxInstLumiBX4->getMean();
01329 double rms4 = MaxInstLumiBX4->getRMS();
01330 if( rms4 > 0 && mean4-5*rms4 > minX && mean4+5*rms4<maxX ) MaxInstLumiBX4->setAxisRange(mean4-5*rms4,mean4+5*rms4);
01331 }
01332
01333
01334
01335 ++lumiSectionCount;
01336 }
01337
01338
01339 void HLXMonitor::FillHistoHFCompare(const LUMI_SECTION & section)
01340 {
01341
01342 for( unsigned int iHLX = 0; iHLX < NUM_HLX; ++iHLX ){
01343
01344 unsigned int iWedge = HLXHFMap[iHLX];
01345
01346 if(section.occupancy[iHLX].hdr.numNibbles != 0){
01347 float nActvTwrsSet1 = section.occupancy[iHLX].data[set1AboveIndex][TriggerBX]
01348 + section.occupancy[iHLX].data[set1BetweenIndex][TriggerBX]
01349 + section.occupancy[iHLX].data[set1BelowIndex][TriggerBX];
01350
01351 float nActvTwrsSet2 = section.occupancy[iHLX].data[set2AboveIndex][TriggerBX]
01352 + section.occupancy[iHLX].data[set2BetweenIndex][TriggerBX]
01353 + section.occupancy[iHLX].data[set2BelowIndex][TriggerBX];
01354
01355 float total = nActvTwrsSet1 + nActvTwrsSet2;
01356
01357 if( total > 0){
01358 float tempData = section.etSum[iHLX].data[TriggerBX]/total;
01359
01360 HFCompareEtSum->Fill( iWedge, tempData );
01361 }
01362
01363 if(nActvTwrsSet1 > 0){
01364 float tempData = (float)section.occupancy[iHLX].data[set1BelowIndex][TriggerBX]/nActvTwrsSet1;
01365 HFCompareOccBelowSet1->Fill( iWedge, tempData);
01366
01367 tempData = (float)section.occupancy[iHLX].data[set1BetweenIndex][TriggerBX]/nActvTwrsSet1;
01368 HFCompareOccBetweenSet1->Fill( iWedge, tempData);
01369
01370 tempData = (float)section.occupancy[iHLX].data[set1AboveIndex][TriggerBX]/nActvTwrsSet1;
01371 HFCompareOccAboveSet1->Fill( iWedge, tempData);
01372 }
01373
01374 if( nActvTwrsSet2 > 0){
01375 float tempData = (float)section.occupancy[iHLX].data[set2BelowIndex][TriggerBX]/nActvTwrsSet2;
01376 HFCompareOccBelowSet2->Fill( iWedge, tempData);
01377
01378 tempData = (float)section.occupancy[iHLX].data[set2BetweenIndex][TriggerBX]/nActvTwrsSet2;
01379 HFCompareOccBetweenSet2->Fill( iWedge, tempData);
01380
01381 tempData = (float)section.occupancy[iHLX].data[set2AboveIndex][TriggerBX]/nActvTwrsSet2;
01382 HFCompareOccAboveSet2->Fill( iWedge, tempData);
01383 }
01384 }
01385 }
01386 }
01387
01388 void HLXMonitor::FillEventInfo(const LUMI_SECTION & section, const edm::Event& e)
01389 {
01390
01391
01392
01393
01394 runId_->Fill( section.hdr.runNumber );
01395 lumisecId_->Fill( (int)(section.hdr.sectionNumber/num4NibblePerLS_) + 1 );
01396
01397
01398 expectedNibbles_ += section.hdr.numOrbits/4096;
01399 for( unsigned int iHLX = 0; iHLX < NUM_HLX; ++iHLX ){
01400 unsigned int iWedge = HLXHFMap[iHLX] + 1;
01401 totalNibbles_[iWedge-1] += section.occupancy[iHLX].hdr.numNibbles;
01402 }
01403
01404 eventId_->Fill(e.id().event());
01405 eventTimeStamp_->Fill(e.time().value()/(double)0xffffffff);
01406
01407 pEvent_++;
01408 evtRateCount_++;
01409 processEvents_->Fill(pEvent_);
01410
01411 lastUpdateTime_=currentTime_;
01412 gettimeofday(¤tTime_,NULL);
01413 processTimeStamp_->Fill(getUTCtime(¤tTime_));
01414 processLatency_->Fill(getUTCtime(&lastUpdateTime_,¤tTime_));
01415
01416 float time = getUTCtime(&lastAvgTime_,¤tTime_);
01417 if(time>=(evtRateWindow_*60.0)){
01418 processEventRate_->Fill((float)evtRateCount_/time);
01419 evtRateCount_ = 0;
01420 lastAvgTime_ = currentTime_;
01421 }
01422
01423 }
01424
01425 void HLXMonitor::FillReportSummary(){
01426
01427
01428 float overall = 0.0;
01429 for( unsigned int iHLX = 0; iHLX < NUM_HLX; ++iHLX ){
01430 unsigned int iWedge = HLXHFMap[iHLX] + 1;
01431 unsigned int iEta = 2;
01432 float frac = 0.0;
01433 if( expectedNibbles_ > 0 ) frac = (float)totalNibbles_[iWedge-1]/(float)expectedNibbles_;
01434 if( iWedge >= 19 ){ iEta = 1; iWedge -= 18; }
01435 reportSummaryMap_->setBinContent(iWedge,iEta,frac);
01436 overall += frac;
01437 }
01438
01439 overall /= (float)NUM_HLX;
01440 if( overall > 1.0 ) overall = 0.0;
01441
01442 reportSummary_->Fill(overall);
01443 }
01444
01445 void HLXMonitor::ResetAll()
01446 {
01447 for( unsigned int iHLX = 0; iHLX < NUM_HLX; ++iHLX )
01448 {
01449 dbe_->softReset( Set1Below[iHLX] );
01450 dbe_->softReset( Set1Between[iHLX] );
01451 dbe_->softReset( Set1Above[iHLX] );
01452 dbe_->softReset( Set2Below[iHLX] );
01453 dbe_->softReset( Set2Between[iHLX] );
01454 dbe_->softReset( Set2Above[iHLX] );
01455
01456 dbe_->softReset( ETSum[iHLX] );
01457
01458 }
01459
01460 dbe_->softReset(HFCompareEtSum);
01461 dbe_->softReset(HFCompareOccBelowSet1);
01462 dbe_->softReset(HFCompareOccBetweenSet1);
01463 dbe_->softReset(HFCompareOccAboveSet1);
01464 dbe_->softReset(HFCompareOccBelowSet2);
01465 dbe_->softReset(HFCompareOccBetweenSet2);
01466 dbe_->softReset(HFCompareOccAboveSet2);
01467
01468 dbe_->softReset(AvgEtSum);
01469 dbe_->softReset(AvgOccBelowSet1);
01470 dbe_->softReset(AvgOccBetweenSet1);
01471 dbe_->softReset(AvgOccAboveSet1);
01472 dbe_->softReset(AvgOccBelowSet2);
01473 dbe_->softReset(AvgOccBetweenSet2);
01474 dbe_->softReset(AvgOccAboveSet2);
01475
01476
01477 dbe_->softReset(LumiAvgEtSum);
01478 dbe_->softReset(LumiAvgOccSet1);
01479 dbe_->softReset(LumiAvgOccSet2);
01480 dbe_->softReset(LumiInstantEtSum);
01481 dbe_->softReset(LumiInstantOccSet1);
01482 dbe_->softReset(LumiInstantOccSet2);
01483 dbe_->softReset(LumiIntegratedEtSum);
01484 dbe_->softReset(LumiIntegratedOccSet1);
01485 dbe_->softReset(LumiIntegratedOccSet2);
01486
01487
01488 dbe_->softReset(SumAllOccSet1);
01489 dbe_->softReset(SumAllOccSet2);
01490 dbe_->softReset(MissingDQMDataCheck);
01491
01492 dbe_->softReset(MaxInstLumiBX1);
01493 dbe_->softReset(MaxInstLumiBX2);
01494 dbe_->softReset(MaxInstLumiBX3);
01495 dbe_->softReset(MaxInstLumiBX4);
01496
01497 dbe_->softReset(MaxInstLumiBXNum1);
01498 dbe_->softReset(MaxInstLumiBXNum2);
01499 dbe_->softReset(MaxInstLumiBXNum3);
01500 dbe_->softReset(MaxInstLumiBXNum4);
01501
01502
01503
01504 lumiSectionCount = 0;
01505 previousSection = 0;
01506 dbe_->softReset(HistAvgEtSumHFP);
01507 dbe_->softReset(HistAvgEtSumHFM);
01508
01509 dbe_->softReset(HistAvgOccBelowSet1HFP);
01510 dbe_->softReset(HistAvgOccBelowSet1HFM);
01511 dbe_->softReset(HistAvgOccBetweenSet1HFP);
01512 dbe_->softReset(HistAvgOccBetweenSet1HFM);
01513 dbe_->softReset(HistAvgOccAboveSet1HFP);
01514 dbe_->softReset(HistAvgOccAboveSet1HFM);
01515
01516 dbe_->softReset(HistAvgOccBelowSet2HFP);
01517 dbe_->softReset(HistAvgOccBelowSet2HFM);
01518 dbe_->softReset(HistAvgOccBetweenSet2HFP);
01519 dbe_->softReset(HistAvgOccBetweenSet2HFM);
01520 dbe_->softReset(HistAvgOccAboveSet2HFP);
01521 dbe_->softReset(HistAvgOccAboveSet2HFM);
01522
01523 dbe_->softReset(HistAvgLumiEtSum);
01524 dbe_->softReset(HistAvgLumiOccSet1);
01525 dbe_->softReset(HistAvgLumiOccSet2);
01526 dbe_->softReset(HistInstantLumiEtSum);
01527 dbe_->softReset(HistInstantLumiOccSet1);
01528 dbe_->softReset(HistInstantLumiOccSet2);
01529 dbe_->softReset(HistInstantLumiEtSumError);
01530 dbe_->softReset(HistInstantLumiOccSet1Error);
01531 dbe_->softReset(HistInstantLumiOccSet2Error);
01532 dbe_->softReset(HistIntegratedLumiEtSum);
01533 dbe_->softReset(HistIntegratedLumiOccSet1);
01534 dbe_->softReset(HistIntegratedLumiOccSet2);
01535
01536 dbe_->softReset(RecentInstantLumiEtSum);
01537 dbe_->softReset(RecentInstantLumiOccSet1);
01538 dbe_->softReset(RecentInstantLumiOccSet2);
01539 dbe_->softReset(RecentIntegratedLumiEtSum);
01540 dbe_->softReset(RecentIntegratedLumiOccSet1);
01541 dbe_->softReset(RecentIntegratedLumiOccSet2);
01542
01543 dbe_->softReset(BXvsTimeAvgEtSumHFP);
01544 dbe_->softReset(BXvsTimeAvgEtSumHFM);
01545 }
01546
01547 double HLXMonitor::getUTCtime(timeval* a, timeval* b){
01548 double deltaT=(*a).tv_sec*1000.0+(*a).tv_usec/1000.0;
01549 if(b!=NULL) deltaT=(*b).tv_sec*1000.0+(*b).tv_usec/1000.0 - deltaT;
01550 return deltaT/1000.0;
01551 }
01552
01553
01554
01555 DEFINE_FWK_MODULE(HLXMonitor);