Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "DQMOffline/L1Trigger/interface/L1TSync_Harvest.h"
00028
00029
00030
00031
00032
00033 #include "DQMServices/Core/interface/DQMStore.h"
00034
00035
00036 using namespace edm;
00037 using namespace std;
00038
00039
00040
00041 L1TSync_Harvest::L1TSync_Harvest(const ParameterSet & pset){
00042
00186 if (pset.getUntrackedParameter < bool > ("dqmStore", false)) {
00187 dbe = Service < DQMStore > ().operator->();
00188 dbe->setVerbose(0);
00189 }
00190
00191 m_outputFile = pset.getUntrackedParameter < std::string > ("outputFile","");
00192
00193 if (m_outputFile.size() != 0) {
00194 std::cout << "L1T Monitoring histograms will be saved to " << m_outputFile.c_str() << std::endl;
00195 }
00196
00197 bool disable = pset.getUntrackedParameter < bool > ("disableROOToutput", false);
00198 if (disable) {m_outputFile = "";}
00199
00200 if (dbe != NULL) {dbe->setCurrentFolder("L1T/L1TSync");}
00201
00202 }
00203
00204
00205
00206 L1TSync_Harvest::~L1TSync_Harvest(){}
00207
00208
00209
00210 void L1TSync_Harvest::beginJob(void){
00211
00212 if (m_verbose){cout << "[L1TSync_Harvest] Called beginJob." << endl;}
00213
00214
00215 DQMStore *dbe = 0;
00216 dbe = Service < DQMStore > ().operator->();
00217
00218 if (dbe) {
00219 dbe->setCurrentFolder("L1T/L1TSync");
00220 dbe->rmdir("L1T/L1TSync");
00221 }
00222
00223 }
00224
00225
00226
00227 void L1TSync_Harvest::endJob(void){
00228
00229 if (m_verbose){cout << "[L1TSync_Harvest] Called endJob." << endl;}
00230
00231 if (m_outputFile.size() != 0 && dbe)
00232 dbe->save(m_outputFile);
00233
00234 return;
00235
00236 }
00237
00238
00240
00241 void L1TSync_Harvest::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup){
00242
00312 }
00313
00314
00315
00316
00317 void L1TSync_Harvest::beginLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& c) {
00318
00319 if (m_verbose){cout << "[L1TSync_Harvest] Called beginLuminosityBlock." << endl;}
00320
00321
00322
00323 if(m_currentLS !=0 && m_currentLS+1 != lumiBlock.id().luminosityBlock()){
00324
00325 if (m_verbose){
00326 cout << "[L1TSync_Harvest] None consecutive: doFractionInSync() - LAST="
00327 << m_currentLS << " CURRENT=" << lumiBlock.id().luminosityBlock() << endl;
00328 }
00329
00330 doFractionInSync(true,false);
00331
00332 }
00333
00334
00335 m_currentLS = lumiBlock.id().luminosityBlock();
00336
00337
00338 for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
00339
00340 string theTriggerAlias = (*i).second;
00341 if(m_certFirstLS[theTriggerAlias]==0){m_certFirstLS[theTriggerAlias] = m_currentLS;}
00342
00343 }
00344
00345
00346
00347 m_currentLSValid = true;
00348
00349 }
00350
00351
00352
00353
00354
00355 void L1TSync_Harvest::endLuminosityBlock(LuminosityBlock const& lumiBlock, EventSetup const& c) {
00356
00357 if(m_verbose){cout << "[L1TSync_Harvest] Called endLuminosityBlock." << endl;}
00358
00359 if(m_verbose){
00360 cout << "[L1TSync_Harvest] m_currentLSValid : " << m_currentLSValid << endl;
00361 cout << "[L1TSync_Harvest] m_beamConfig.isValid(): " << m_beamConfig.isValid() << endl;
00362 }
00363
00364 for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
00365
00366
00367 string theTriggerAlias = (*i).second;
00368 m_certLastLS[theTriggerAlias] = m_currentLS;
00369
00370 }
00371
00372
00373 if(m_currentLSValid && m_beamConfig.isValid()){
00374
00375 if(m_verbose){cout << "[L1TSync_Harvest] Regular call: doFractionInSync()" << endl;}
00376 doFractionInSync(false,false);
00377
00378 }
00379
00380
00381
00382 else{
00383
00384
00385 for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
00386
00387 string theTriggerAlias = (*i).second;
00388
00389 int fLs = m_certFirstLS[theTriggerAlias];
00390 int lLS = m_certLastLS [theTriggerAlias];
00391
00392
00393 if(fLs == lLS){
00394 m_certFirstLS[theTriggerAlias] = 0;
00395 m_certLastLS [theTriggerAlias] = 0;
00396 }
00397
00398 else{
00399 m_certLastLS [theTriggerAlias] = m_currentLS-1;
00400 }
00401
00402 }
00403 doFractionInSync(true,false);
00404
00405
00406 for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
00407 string theTriggerAlias = (*i).second;
00408 m_certFirstLS[theTriggerAlias] = m_currentLS;
00409 m_certLastLS [theTriggerAlias] = m_currentLS;
00410 }
00411 doFractionInSync(true,true);
00412
00413 if(m_verbose){cout << "[L1TSync_Harvest] Error call: doFractionInSync()" << endl;}
00414
00415 }
00416
00417 }
00418
00419
00420 void L1TSync_Harvest::endRun(const edm::Run& run, const edm::EventSetup& iSetup){
00421
00422 if(m_verbose){cout << "[L1TSync_Harvest] Called endRun." << endl;}
00423
00424
00425
00426 doFractionInSync(true,false);
00427
00428 }
00429
00430
00431 void L1TSync_Harvest::analyze(const Event & iEvent, const EventSetup & eventSetup){
00432
00536 }
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553 void L1TSync_Harvest::doFractionInSync(bool iForce,bool iBad){
00554
00555 for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
00556
00557 string theCategory = (*i).first;
00558 string theTriggerAlias = (*i).second;
00559
00560
00561 unsigned int fLS = m_certFirstLS[theTriggerAlias];
00562 unsigned int lLS = m_certLastLS [theTriggerAlias];
00563
00564
00565 bool triggerAlias_isValid = theTriggerAlias != "Undefined" && theTriggerAlias != "Undefined (Wrong Name)";
00566 bool lsBlock_exists = !(fLS == 0 && lLS == 0);
00567 bool lsBlock_isValid = fLS <= lLS && fLS > 0 && lLS > 0;
00568
00569 if(triggerAlias_isValid && lsBlock_exists && lsBlock_isValid){
00570
00571
00572 if(iForce && iBad){
00573 certifyLSBlock(theTriggerAlias,fLS,lLS,-1);
00574 m_certFirstLS[theTriggerAlias] = 0;
00575 m_certLastLS [theTriggerAlias] = 0;
00576 }
00577
00578
00579 else{
00580
00581
00582 double CountSync = 0;
00583 double CountAll = 0;
00584
00585
00586 for(unsigned int ls=fLS ; ls<=lLS ; ls++){
00587
00588 CountSync += m_algoVsBunchStructure[theTriggerAlias]->getBinContent(ls+1,3);
00589 for(int a=1 ; a<6 ; a++){
00590 CountAll += m_algoVsBunchStructure[theTriggerAlias]->getBinContent(ls+1,a);
00591 }
00592 }
00593
00594 if(m_verbose){
00595 cout << "Alias = " << theTriggerAlias
00596 << " InitLS=" << fLS
00597 << " EndLS=" << lLS
00598 << " Events=" << CountAll ;
00599 }
00600
00601 if(iForce ||
00602 CountAll >= m_parameters.getParameter<ParameterSet>("Categories")
00603 .getParameter<ParameterSet>(theCategory)
00604 .getParameter<int>("CertMinEvents")){
00605
00606 if(m_verbose){cout << " <--------------- Enough Statistics: ";}
00607
00608
00609
00610 double fraction = 0;
00611 if(CountAll >0){fraction = CountSync/CountAll;}
00612
00613
00614
00615 if(fraction==0){fraction=0.000001;}
00616
00617 certifyLSBlock(theTriggerAlias,fLS,lLS,fraction);
00618 m_certFirstLS[theTriggerAlias] = 0;
00619 m_certLastLS [theTriggerAlias] = 0;
00620 }
00621
00622 if(m_verbose){cout << endl;}
00623
00624 }
00625 }
00626
00627
00628 else{
00629
00630
00631 if(!triggerAlias_isValid){
00632 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_TRIGGERALIAS_NOTVALID);
00633 eCount++;
00634 m_ErrorMonitor->getTH1()->SetBinContent(ERROR_TRIGGERALIAS_NOTVALID,eCount);
00635 certifyLSBlock(theTriggerAlias,fLS,lLS,-1);
00636 m_certFirstLS[theTriggerAlias] = 0;
00637 m_certLastLS [theTriggerAlias] = 0;
00638 }
00639
00640
00641 if(lsBlock_exists && !lsBlock_isValid){
00642 int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_LSBLOCK_NOTVALID);
00643 eCount++;
00644 m_ErrorMonitor->getTH1()->SetBinContent(ERROR_LSBLOCK_NOTVALID,eCount);
00645 certifyLSBlock(theTriggerAlias,fLS,lLS,-1);
00646 m_certFirstLS[theTriggerAlias] = 0;
00647 m_certLastLS [theTriggerAlias] = 0;
00648 }
00649
00650 }
00651 }
00652
00653 }
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664 void L1TSync_Harvest::certifyLSBlock(string iTrigger, int iInitLs, int iEndLs ,float iValue){
00665
00673
00674 }
00675
00676
00677 DEFINE_FWK_MODULE(L1TSync_Harvest);