CMS 3D CMS Logo

Classes | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes

L1TCompare Class Reference

#include <L1TCompare.h>

Inheritance diagram for L1TCompare:
edm::EDAnalyzer

List of all members.

Classes

class  RctObject
class  RctObjectComp

Public Member Functions

 L1TCompare (const edm::ParameterSet &ps)
virtual ~L1TCompare ()

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
void beginJob (void)
void endJob (void)

Private Types

typedef std::vector
< L1TCompare::RctObject
RctObjectCollection

Private Member Functions

bool verbose () const

Private Attributes

DQMStoredbe
MonitorElementecalTpgRctLeadingEmEta2_
MonitorElementecalTpgRctLeadingEmEta_
MonitorElementecalTpgRctLeadingEmPhi_
MonitorElementecalTpgRctLeadingEmRank_
edm::InputTag ecalTpgSource_
edm::InputTag gctSource_
ofstream logFile_
bool monitorDaemon_
int nev_
std::string outputFile_
MonitorElementrctGctLeadingIsoEmEta_
MonitorElementrctGctLeadingIsoEmPhi_
MonitorElementrctGctLeadingIsoEmRank_
MonitorElementrctGctLeadingNonIsoEmEta_
MonitorElementrctGctLeadingNonIsoEmPhi_
MonitorElementrctGctLeadingNonIsoEmRank_
edm::InputTag rctSource_
bool verbose_

Detailed Description

Definition at line 64 of file L1TCompare.h.


Member Typedef Documentation

Definition at line 127 of file L1TCompare.h.


Constructor & Destructor Documentation

L1TCompare::L1TCompare ( const edm::ParameterSet ps)

Definition at line 118 of file L1TCompare.cc.

References gather_cfg::cout, dbe, edm::ParameterSet::getUntrackedParameter(), NULL, cppFunctionSkipper::operator, outputFile_, DQMStore::setCurrentFolder(), DQMStore::setVerbose(), verbose(), and verbose_.

                                              :
  rctSource_( ps.getParameter< InputTag >("rctSource") )
  ,gctSource_( ps.getParameter< InputTag >("gctSource") )
  ,ecalTpgSource_(ps.getParameter<edm::InputTag>("ecalTpgSource"))

{

  // verbosity switch
  verbose_ = ps.getUntrackedParameter < bool > ("verbose", false);

  if (verbose())
    std::cout << "L1TCompare: constructor...." << std::endl;


  dbe = NULL;
  if (ps.getUntrackedParameter < bool > ("DQMStore", false)) {
    dbe = Service < DQMStore > ().operator->();
    dbe->setVerbose(0);
  }

  outputFile_ =
      ps.getUntrackedParameter < std::string > ("outputFile", "");
  if (outputFile_.size() != 0) {
    std::
	cout << "L1T Monitoring histograms will be saved to " <<
        outputFile_.c_str() << std::endl;
  }

  bool disable =
      ps.getUntrackedParameter < bool > ("disableROOToutput", false);
  if (disable) {
    outputFile_ = "";
  }


  if (dbe != NULL) {
    dbe->setCurrentFolder("L1T/Compare");
  }


}
L1TCompare::~L1TCompare ( ) [virtual]

Definition at line 160 of file L1TCompare.cc.

{
}

Member Function Documentation

void L1TCompare::analyze ( const edm::Event e,
const edm::EventSetup c 
) [protected, virtual]

Implements edm::EDAnalyzer.

Definition at line 265 of file L1TCompare.cc.

References dtNoiseDBValidation_cfg::cerr, gather_cfg::cout, ecalTpgRctLeadingEmEta2_, ecalTpgRctLeadingEmEta_, ecalTpgRctLeadingEmPhi_, ecalTpgRctLeadingEmRank_, ecalTpgSource_, MonitorElement::Fill(), gctSource_, edm::Event::getByLabel(), h, errorMatrix2Lands_multiChannel::id, edm::HandleBase::isValid(), edm::InputTag::label(), nev_, rctGctLeadingIsoEmEta_, rctGctLeadingIsoEmPhi_, rctGctLeadingIsoEmRank_, rctGctLeadingNonIsoEmEta_, rctGctLeadingNonIsoEmPhi_, rctGctLeadingNonIsoEmRank_, rctSource_, python::multivaluedict::sort(), and verbose().

{
  ++nev_;
  if (verbose()) {
    std::cout << "L1TCompare: analyze...." << std::endl;
  }

  // L1E 
  edm::Handle < L1EmParticleCollection > l1eIsoEm;
  edm::Handle < L1EmParticleCollection > l1eNonIsoEm;
  edm::Handle < L1JetParticleCollection > l1eCenJets;
  edm::Handle < L1JetParticleCollection > l1eForJets;
  edm::Handle < L1JetParticleCollection > l1eTauJets;
  //  edm::Handle < L1EtMissParticle > l1eEtMiss;
  edm::Handle < L1EtMissParticleCollection > l1eEtMiss;
  // RCT
  edm::Handle < L1CaloEmCollection > em; // collection of L1CaloEmCands
  edm::Handle < L1CaloRegionCollection > rctEmRgn;

  // GCT
  edm::Handle <L1GctJetCandCollection> gctCenJets;
  edm::Handle <L1GctEmCandCollection> gctIsoEmCands;
  edm::Handle <L1GctEmCandCollection> gctNonIsoEmCands;

  
  e.getByLabel(rctSource_,em);
  
  if (!em.isValid()) {
    edm::LogInfo("DataNotFound") << "can't find L1CaloEmCollection with label "
                               << rctSource_.label() ;
    return;
  }

  
  e.getByLabel(rctSource_,rctEmRgn);
  
  if (!rctEmRgn.isValid()) {
    edm::LogInfo("DataNotFound") << "can't find "
                               << "L1CaloRegionCollection with label "
                               << rctSource_.label() ;
    return;
  }

  
  e.getByLabel(gctSource_.label(),"cenJets", gctCenJets);
  e.getByLabel(gctSource_.label(), "isoEm", gctIsoEmCands);
  e.getByLabel(gctSource_.label(), "nonIsoEm", gctNonIsoEmCands);
  
  if (!gctCenJets.isValid()) {
    std::cerr << "L1TGCT: could not find one of the classes?" << std::endl;
    return;
  }
 if (!gctIsoEmCands.isValid()) {
    std::cerr << "L1TGCT: could not find one of the classes?" << std::endl;
    return;
  }
 if (!gctNonIsoEmCands.isValid()) {
    std::cerr << "L1TGCT: could not find one of the classes?" << std::endl;
    return;
  }
 

  // GCT
  if ( verbose() ) {
    for ( L1GctEmCandCollection::const_iterator iem = gctIsoEmCands->begin();
          iem != gctIsoEmCands->end(); ++iem) {
      if ( !iem->empty() ) 
        std::cout << "GCT EM: " << iem->rank() 
                  << ", " 
                  << iem->etaIndex() << "("
          //<< int(iem->etaIndex()&0x3)*((iem->etaIndex()&0x4)?1:-1)
                  << "), " 
                  << iem->phiIndex()
                  << std::endl;
    }
  }
  // rct phi: 0-17
  // rct eta: 0-21


  // Fill the RCT histograms

  // Regions
  RctObjectCollection rcj, rcj_iso, rcj_non_iso;
  for (L1CaloEmCollection::const_iterator iem = em->begin();
       iem != em->end(); ++iem) { 
    //   L1CaloRegionDetId id(false, iem->rctCrate(), iem->rctCard(), 
    //                   iem->rctRegion());
       L1CaloRegionDetId id(iem->rctCrate(), iem->rctCard(), 
                         iem->rctRegion());

       // RctObject h(id.gctEta(), id.gctPhi(), iem->rank());
    RctObject h(id.rctEta(), id.rctPhi(), iem->rank());
    if ( !iem->isolated() ) 
      rcj_non_iso.push_back(h);
    else 
      rcj_iso.push_back(h);
    rcj.push_back(h);
  }
  // not so smart but ...
  std::sort(rcj.begin(), rcj.end(), RctObjectComp());
  std::sort(rcj_non_iso.begin(), rcj_non_iso.end(), RctObjectComp());
  std::sort(rcj_iso.begin(), rcj_iso.end(), RctObjectComp());
  if ( verbose() ) {
    for (RctObjectCollection::reverse_iterator ij = rcj_iso.rbegin();
         ij != rcj_iso.rend() && ij != rcj_iso.rbegin()+8; ++ij) {
      std::cout << "RCT cj: " 
                << ij->rank_ << ", " << ij->eta_ << ", " << ij->phi_
                << std::endl;
    }
  }
  L1GctEmCandCollection::const_iterator lead_em = gctIsoEmCands->begin();
  if ( !lead_em->empty() ) { // equivalent to rank == 0
    rctGctLeadingIsoEmEta_->Fill(lead_em->etaIndex(), rcj_iso.rbegin()->eta_);
    rctGctLeadingIsoEmPhi_->Fill(lead_em->phiIndex(), rcj_iso.rbegin()->phi_);
    rctGctLeadingIsoEmRank_->Fill(lead_em->rank(), rcj_iso.rbegin()->rank_);
  }

  // non-isolated
  if ( verbose() ) {
    for ( L1GctEmCandCollection::const_iterator iem 
            = gctNonIsoEmCands->begin(); iem != gctNonIsoEmCands->end(); 
          ++iem) {
      if ( ! iem->empty() ) 
        std::cout << "GCT EM non: " << iem->rank() 
                  << ", " 
                  << iem->etaIndex() //<< "("
          //<< int(iem->etaIndex()&0x3)*((iem->etaIndex()&0x4)?1:-1)
                  //<< ")" 
                  << ", " 
                  << iem->phiIndex()
                  << std::endl;
    }
  }
  if ( verbose() ) {
    for (RctObjectCollection::reverse_iterator ij = rcj_non_iso.rbegin();
         ij != rcj_non_iso.rend() && ij != rcj_non_iso.rbegin()+8; ++ij) {
      std::cout << "RCT cj non: " 
                << ij->rank_ << ", " << ij->eta_ << ", " << ij->phi_
                << std::endl;
    }
  }
  lead_em = gctNonIsoEmCands->begin();
  if ( !lead_em->empty() ) { // equivalent to rank != 0
    rctGctLeadingNonIsoEmEta_->Fill(lead_em->etaIndex(), 
                                    rcj_non_iso.rbegin()->eta_);
    rctGctLeadingNonIsoEmPhi_->Fill(lead_em->phiIndex(), 
                                    rcj_non_iso.rbegin()->phi_);
    rctGctLeadingNonIsoEmRank_->Fill(lead_em->rank(), 
                                     rcj_non_iso.rbegin()->rank_);
  }

  // ECAL TPG's to RCT EM 
  edm::Handle < EcalTrigPrimDigiCollection > eTP;
  e.getByLabel(ecalTpgSource_,eTP);
  
  if (!eTP.isValid()) {
    edm::LogInfo("DataNotFound") 
      << "can't find EcalTrigPrimCollection with label "
      << ecalTpgSource_.label() ;
    return;
  }
  RctObjectCollection ecalobs;
  for (EcalTrigPrimDigiCollection::const_iterator ieTP = eTP->begin();
       ieTP != eTP->end(); ieTP++) {
    ecalobs.push_back(RctObject(ieTP->id().ieta(),
                                 ieTP->id().iphi(), 
                                 ieTP->compressedEt()));
  }
  std::sort(ecalobs.begin(), ecalobs.end(), RctObjectComp());
  if ( verbose() ) {
    for (RctObjectCollection::reverse_iterator ij = ecalobs.rbegin();
         ij != ecalobs.rend() && ij != ecalobs.rbegin()+8; ++ij) {
      std::cout << "ECAL cj : " 
                << ij->rank_ << ", " << ij->eta_ << ", " << ij->phi_
                << std::endl;
    }
  }
  // abritrary cut
  if ( rcj.rbegin()->rank_ > 4 ) {
    ecalTpgRctLeadingEmEta_->Fill(rcj.rbegin()->eta_,
                                  ecalobs.rbegin()->eta_);
    int e2 = (rcj.rbegin()->eta_&0x7UL)* ((rcj.rbegin()->eta_&0x8UL)?1:-1);
    ecalTpgRctLeadingEmEta2_->Fill(e2, ecalobs.rbegin()->eta_);
    ecalTpgRctLeadingEmPhi_->Fill(rcj.rbegin()->phi_, ecalobs.rbegin()->phi_);
    ecalTpgRctLeadingEmRank_->Fill(rcj.rbegin()->rank_,
                                   ecalobs.rbegin()->rank_);
  }
  if ( verbose() ) {
    int seta = rcj.rbegin()->eta_;
    seta = (seta&0x7UL)*(seta&0x8?-1:1);
    std::cout << "ZZ: " 
              << rcj.rbegin()->eta_ << " "
              << rcj.rbegin()->phi_ << " "
              << rcj.rbegin()->rank_ << " "
              << (++rcj.rbegin())->rank_<< " "
              << ecalobs.rbegin()->eta_ << " "
              << ecalobs.rbegin()->phi_ << " "
              << ecalobs.rbegin()->rank_ << " "
              << (++ecalobs.rbegin())->rank_<< " "
              << seta << " "
              << std::endl;
  }



}
void L1TCompare::beginJob ( void  ) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 164 of file L1TCompare.cc.

References DQMStore::book2D(), dbe, ecalTpgRctLeadingEmEta2_, ecalTpgRctLeadingEmEta_, ecalTpgRctLeadingEmPhi_, ecalTpgRctLeadingEmRank_, ETABINS, ETAMAX, ETAMIN, nev_, cppFunctionSkipper::operator, PHIBINS, PHIMAX, PHIMIN, R6BINS, R6MAX, R6MIN, rctGctLeadingIsoEmEta_, rctGctLeadingIsoEmPhi_, rctGctLeadingIsoEmRank_, rctGctLeadingNonIsoEmEta_, rctGctLeadingNonIsoEmPhi_, rctGctLeadingNonIsoEmRank_, DQMStore::rmdir(), MonitorElement::setAxisTitle(), DQMStore::setCurrentFolder(), TPETABINS, TPETAMAX, TPETAMIN, TPPHIBINS, TPPHIMAX, and TPPHIMIN.

{

  nev_ = 0;

  // get hold of back-end interface
  DQMStore *dbe = 0;
  dbe = Service < DQMStore > ().operator->();

  if (dbe) {
    dbe->setCurrentFolder("L1T/Compare");
    dbe->rmdir("L1T/Compare");
  }


  if (dbe) {
    dbe->setCurrentFolder("L1T/Compare");
    
    // -------------------------------------------
    // RCT-GCT
    // -------------------------------------------
    // Isolated
    rctGctLeadingIsoEmRank_ = dbe->book2D("rctGctLeadingIsoEmRank",
                                       "RCT-GCT: rank", R6BINS, R6MIN, R6MAX,
                                       R6BINS, R6MIN, R6MAX);
    rctGctLeadingIsoEmRank_->setAxisTitle(std::string("gct"), 1);
    rctGctLeadingIsoEmRank_->setAxisTitle(std::string("rct"), 2);
    rctGctLeadingIsoEmEta_ = dbe->book2D("rctGctLeadingIsoEmEta",
                                      "RCT-GCT: #eta", ETABINS, ETAMIN, ETAMAX,
                                       ETABINS, ETAMIN, ETAMAX);
    rctGctLeadingIsoEmEta_->setAxisTitle(std::string("gct"), 1);
    rctGctLeadingIsoEmEta_->setAxisTitle(std::string("rct"), 2);

    rctGctLeadingIsoEmPhi_ = dbe->book2D("rctGctLeadingIsoEmPhi",
                                      "RCT-GCT: #phi", PHIBINS, PHIMIN, PHIMAX,
                                       PHIBINS, PHIMIN, PHIMAX);
    rctGctLeadingIsoEmPhi_->setAxisTitle(std::string("gct"), 1);
    rctGctLeadingIsoEmPhi_->setAxisTitle(std::string("rct"), 2);
    // non-Isolated
    rctGctLeadingNonIsoEmRank_ = dbe->book2D("rctGctLeadingNonIsoEmRank",
                                       "RCT-GCT: rank", R6BINS, R6MIN, R6MAX,
                                       R6BINS, R6MIN, R6MAX);
    rctGctLeadingNonIsoEmRank_->setAxisTitle(std::string("gct"), 1);
    rctGctLeadingNonIsoEmRank_->setAxisTitle(std::string("rct"), 2);

    rctGctLeadingNonIsoEmEta_ = dbe->book2D("rctGctLeadingNonIsoEmEta",
                                      "RCT-GCT: #eta", ETABINS, ETAMIN, ETAMAX,
                                       ETABINS, ETAMIN, ETAMAX);
    rctGctLeadingNonIsoEmEta_->setAxisTitle(std::string("gct"), 1);
    rctGctLeadingNonIsoEmEta_->setAxisTitle(std::string("rct"), 2);

    rctGctLeadingNonIsoEmPhi_ = dbe->book2D("rctGctLeadingNonIsoEmPhi",
                                      "RCT-GCT: #phi", PHIBINS, PHIMIN, PHIMAX,
                                       PHIBINS, PHIMIN, PHIMAX);
    rctGctLeadingNonIsoEmPhi_->setAxisTitle(std::string("gct"), 1);
    rctGctLeadingNonIsoEmPhi_->setAxisTitle(std::string("rct"), 2);
    // -------------------------------------------
    // ECAL TPG - RCT
    // -------------------------------------------
    ecalTpgRctLeadingEmRank_ = dbe->book2D("ecalTpgRctLeadingEmRank",
                                           "ECAL TPG-RCT: rank", 
                                           R6BINS, R6MIN, R6MAX,
                                           R6BINS, R6MIN, R6MAX);
    ecalTpgRctLeadingEmRank_->setAxisTitle(std::string("rct"), 1);
    ecalTpgRctLeadingEmRank_->setAxisTitle(std::string("ecal tp"), 2);

    ecalTpgRctLeadingEmEta_ = dbe->book2D("ecalTpgRctLeadingEmEta",
                                          "ECAL TPG-RCT: #eta", 
                                          15, -0.5, 14.5,
                                          TPETABINS, TPETAMIN, TPETAMAX);
    ecalTpgRctLeadingEmEta_->setAxisTitle(std::string("rct"), 1);
    ecalTpgRctLeadingEmEta_->setAxisTitle(std::string("ecal tp"), 2);
    ecalTpgRctLeadingEmEta2_ = dbe->book2D("ecalTpgRctLeadingEmEta2",
                                           "ECAL TPG-RCT: #eta (2)", 
                                           13, -6.5, 6.5,
                                           TPETABINS, TPETAMIN, TPETAMAX);
    ecalTpgRctLeadingEmEta2_->setAxisTitle(std::string("rct"), 1);
    ecalTpgRctLeadingEmEta2_->setAxisTitle(std::string("ecal tp"), 2);
    ecalTpgRctLeadingEmPhi_ = dbe->book2D("ecalTpgRctLeadingEmPhi",
                                          "ECAL TPG-RCT: #phi", 
                                          PHIBINS, PHIMIN, PHIMAX,
                                          TPPHIBINS, TPPHIMIN, TPPHIMAX);
    ecalTpgRctLeadingEmPhi_->setAxisTitle(std::string("rct"), 1);
    ecalTpgRctLeadingEmPhi_->setAxisTitle(std::string("ecal tp"), 2);
  }

}
void L1TCompare::endJob ( void  ) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 253 of file L1TCompare.cc.

References gather_cfg::cout, dbe, nev_, outputFile_, DQMStore::save(), and verbose().

{
  if (verbose())
    std::cout << "L1TCompare: end job...." << std::endl;
  LogInfo("EndJob") << "analyzed " << nev_ << " events";

  if (outputFile_.size() != 0 && dbe)
    dbe->save(outputFile_);

  return;
}
bool L1TCompare::verbose ( ) const [inline, private]

Definition at line 109 of file L1TCompare.h.

References verbose_.

Referenced by analyze(), endJob(), and L1TCompare().

{ return verbose_; };

Member Data Documentation

Definition at line 86 of file L1TCompare.h.

Referenced by beginJob(), endJob(), and L1TCompare().

Definition at line 100 of file L1TCompare.h.

Referenced by analyze(), and beginJob().

Definition at line 99 of file L1TCompare.h.

Referenced by analyze(), and beginJob().

Definition at line 101 of file L1TCompare.h.

Referenced by analyze(), and beginJob().

Definition at line 102 of file L1TCompare.h.

Referenced by analyze(), and beginJob().

Definition at line 115 of file L1TCompare.h.

Referenced by analyze().

Definition at line 114 of file L1TCompare.h.

Referenced by analyze().

ofstream L1TCompare::logFile_ [private]

Definition at line 111 of file L1TCompare.h.

Definition at line 109 of file L1TCompare.h.

int L1TCompare::nev_ [private]

Definition at line 106 of file L1TCompare.h.

Referenced by analyze(), beginJob(), and endJob().

std::string L1TCompare::outputFile_ [private]

Definition at line 107 of file L1TCompare.h.

Referenced by endJob(), and L1TCompare().

Definition at line 90 of file L1TCompare.h.

Referenced by analyze(), and beginJob().

Definition at line 91 of file L1TCompare.h.

Referenced by analyze(), and beginJob().

Definition at line 92 of file L1TCompare.h.

Referenced by analyze(), and beginJob().

Definition at line 94 of file L1TCompare.h.

Referenced by analyze(), and beginJob().

Definition at line 95 of file L1TCompare.h.

Referenced by analyze(), and beginJob().

Definition at line 96 of file L1TCompare.h.

Referenced by analyze(), and beginJob().

Definition at line 113 of file L1TCompare.h.

Referenced by analyze().

bool L1TCompare::verbose_ [private]

Definition at line 108 of file L1TCompare.h.

Referenced by L1TCompare(), and verbose().