CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

EcalURecHitHists Class Reference

#include <EcalURecHitHists.h>

Inheritance diagram for EcalURecHitHists:
edm::EDAnalyzer

List of all members.

Public Member Functions

 EcalURecHitHists (const edm::ParameterSet &)
 ~EcalURecHitHists ()

Private Member Functions

virtual void analyze (edm::Event const &, edm::EventSetup const &)
virtual void beginRun (edm::Run const &, edm::EventSetup const &)
virtual void endJob ()
void initHists (int)
std::string intToString (int num)

Private Attributes

TH1F * allFedsHist_
TH1F * allFedsTimingHist_
edm::InputTag EBUncalibratedRecHitCollection_
const EcalElectronicsMappingecalElectronicsMap_
edm::InputTag EEUncalibratedRecHitCollection_
EcalFedMapfedMap_
std::map< int, TH1F * > FEDsAndHists_
std::map< int, TH1F * > FEDsAndTimingHists_
TFile * file
std::string fileName_
double histRangeMax_
double histRangeMin_
std::vector< int > maskedChannels_
std::vector< std::string > maskedEBs_
std::vector< int > maskedFEDs_
int runNum_

Detailed Description

Description: <one line="" class="" summary>="">

Implementation: <Notes on="" implementation>="">

Definition at line 56 of file EcalURecHitHists.h.


Constructor & Destructor Documentation

EcalURecHitHists::EcalURecHitHists ( const edm::ParameterSet iConfig) [explicit]

Definition at line 37 of file EcalURecHitHists.cc.

References allFedsHist_, allFedsTimingHist_, fedMap_, edm::ParameterSet::getUntrackedParameter(), histRangeMax_, histRangeMin_, maskedChannels_, maskedEBs_, and maskedFEDs_.

                                                                 :
  EBUncalibratedRecHitCollection_ (iConfig.getParameter<edm::InputTag>("EBUncalibratedRecHitCollection")),
  EEUncalibratedRecHitCollection_ (iConfig.getParameter<edm::InputTag>("EEUncalibratedRecHitCollection")),
  runNum_(-1),
  histRangeMax_ (iConfig.getUntrackedParameter<double>("histogramMaxRange",200.0)),
  histRangeMin_ (iConfig.getUntrackedParameter<double>("histogramMinRange",-10.0)),
  fileName_ (iConfig.getUntrackedParameter<std::string>("fileName", std::string("ecalURechHitHists")))
{
  vector<int> listDefaults;
  listDefaults.push_back(-1);
  
  maskedChannels_ = iConfig.getUntrackedParameter<vector<int> >("maskedChannels", listDefaults);
  maskedFEDs_ = iConfig.getUntrackedParameter<vector<int> >("maskedFEDs", listDefaults);

  vector<string> defaultMaskedEBs;
  defaultMaskedEBs.push_back("none");
  maskedEBs_ =  iConfig.getUntrackedParameter<vector<string> >("maskedEBs",defaultMaskedEBs);
  
  fedMap_ = new EcalFedMap();
  string title1 = "Uncalib Rec Hits (ADC counts)";
  string name1 = "URecHitsAllFEDs";
  int numBins = (int)round(histRangeMax_-histRangeMin_)+1;
  allFedsHist_ = new TH1F(name1.c_str(),title1.c_str(),numBins,histRangeMin_,histRangeMax_);
  title1 = "Jitter for all FEDs";
  name1 = "JitterAllFEDs";
  allFedsTimingHist_ = new TH1F(name1.c_str(),title1.c_str(),14,-7,7);

  // load up the maskedFED list with the proper FEDids
  if(maskedFEDs_[0]==-1)
  {
    //if "actual" EB id given, then convert to FEDid and put in listFEDs_
    if(maskedEBs_[0] != "none")
    {
      maskedFEDs_.clear();
      for(vector<string>::const_iterator ebItr = maskedEBs_.begin(); ebItr != maskedEBs_.end(); ++ebItr)
      {
        maskedFEDs_.push_back(fedMap_->getFedFromSlice(*ebItr));
      }
    }
  }
}
EcalURecHitHists::~EcalURecHitHists ( )

Definition at line 80 of file EcalURecHitHists.cc.

{
}

Member Function Documentation

void EcalURecHitHists::analyze ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 91 of file EcalURecHitHists.cc.

References allFedsHist_, allFedsTimingHist_, EcalUncalibratedRecHit::amplitude(), EcalElectronicsId::dccId(), EBUncalibratedRecHitCollection_, ecalElectronicsMap_, EEUncalibratedRecHitCollection_, edm::EventID::event(), L1Comparator_cfi::FEDid, FEDsAndHists_, FEDsAndTimingHists_, spr::find(), edm::Event::getByLabel(), EcalElectronicsMapping::getElectronicsId(), EEDetId::hashedIndex(), ecalpyutils::hashedIndex(), EBDetId::hashedIndex(), EEDetId::ic(), EBDetId::ic(), EcalUncalibratedRecHit::id(), edm::EventBase::id(), initHists(), EcalUncalibratedRecHit::jitter(), LogDebug, maskedChannels_, maskedFEDs_, query::result, edm::EventID::run(), and runNum_.

{
  int ievt = iEvent.id().event();
  Handle<EcalUncalibratedRecHitCollection> EBhits;
  Handle<EcalUncalibratedRecHitCollection> EEhits;

  iEvent.getByLabel(EBUncalibratedRecHitCollection_, EBhits);
  LogDebug("EcalURecHitHists") << "event " << ievt << " hits collection size " << EBhits->size();

  iEvent.getByLabel(EEUncalibratedRecHitCollection_, EEhits);
  LogDebug("EcalURecHitHists") << "event " << ievt << " hits collection size " << EEhits->size();

  for (EcalUncalibratedRecHitCollection::const_iterator hitItr = EBhits->begin(); hitItr != EBhits->end(); ++hitItr)
  {
    EcalUncalibratedRecHit hit = (*hitItr);
    EBDetId ebDet = hit.id();
    int ic = ebDet.ic();
    int hashedIndex = ebDet.hashedIndex();
    EcalElectronicsId elecId = ecalElectronicsMap_->getElectronicsId(ebDet);
    int FEDid = 600+elecId.dccId();
    float ampli = hit.amplitude();

    vector<int>::iterator result;
    result = find(maskedFEDs_.begin(), maskedFEDs_.end(), FEDid);
    if(result != maskedFEDs_.end())
    {
      LogWarning("EcalURecHitHists") << "skipping uncalRecHit for FED " << FEDid << " ; amplitude " << ampli;
      continue;
    }      

    result = find(maskedChannels_.begin(), maskedChannels_.end(), hashedIndex);
    if  (result != maskedChannels_.end())
    {
      LogWarning("EcalURecHitHists") << "skipping uncalRecHit for channel: " << ic << " with amplitude " << ampli ;
      continue;
    }      

    // fill the proper hist
    TH1F* uRecHist = FEDsAndHists_[FEDid];
    TH1F* timingHist = FEDsAndTimingHists_[FEDid];
    if(uRecHist==0)
    {
      initHists(FEDid);
      uRecHist = FEDsAndHists_[FEDid];
      timingHist = FEDsAndTimingHists_[FEDid];
    }
    
    uRecHist->Fill(ampli);
    allFedsHist_->Fill(ampli);
    timingHist->Fill(hit.jitter());
    allFedsTimingHist_->Fill(hit.jitter());
  }
  
  // Again for the endcap
  for (EcalUncalibratedRecHitCollection::const_iterator hitItr = EEhits->begin(); hitItr != EEhits->end(); ++hitItr)
  {
    EcalUncalibratedRecHit hit = (*hitItr);
    EEDetId eeDet = hit.id();
    int ic = eeDet.ic();
    int hashedIndex = eeDet.hashedIndex();
    EcalElectronicsId elecId = ecalElectronicsMap_->getElectronicsId(eeDet);
    int FEDid = 600+elecId.dccId();
    float ampli = hit.amplitude();

    vector<int>::iterator result;
    result = find(maskedFEDs_.begin(), maskedFEDs_.end(), FEDid);
    if(result != maskedFEDs_.end())
    {
      LogWarning("EcalURecHitHists") << "skipping uncalRecHit for FED " << FEDid << " ; amplitude " << ampli;
      continue;
    }      

    result = find(maskedChannels_.begin(), maskedChannels_.end(), hashedIndex);
    if  (result != maskedChannels_.end())
    {
      LogWarning("EcalURecHitHists") << "skipping uncalRecHit for channel: " << ic << " with amplitude " << ampli ;
      continue;
    }      

    // fill the proper hist
    TH1F* uRecHist = FEDsAndHists_[FEDid];
    TH1F* timingHist = FEDsAndTimingHists_[FEDid];
    if(uRecHist==0)
    {
      initHists(FEDid);
      uRecHist = FEDsAndHists_[FEDid];
      timingHist = FEDsAndTimingHists_[FEDid];
    }
    
    uRecHist->Fill(ampli);
    allFedsHist_->Fill(ampli);
    timingHist->Fill(hit.jitter());
    allFedsTimingHist_->Fill(hit.jitter());
  }

  if(runNum_==-1)
  {
    runNum_ = iEvent.id().run();
  }
}
void EcalURecHitHists::beginRun ( edm::Run const &  ,
edm::EventSetup const &  c 
) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 219 of file EcalURecHitHists.cc.

References ecalElectronicsMap_, edm::EventSetup::get(), and edm::ESHandle< T >::product().

{
  edm::ESHandle<EcalElectronicsMapping> elecHandle;
  c.get<EcalMappingRcd>().get(elecHandle);
  ecalElectronicsMap_ = elecHandle.product();
}
void EcalURecHitHists::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 228 of file EcalURecHitHists.cc.

References allFedsHist_, allFedsTimingHist_, benchmark_cfg::cerr, dir, fedMap_, FEDsAndHists_, FEDsAndTimingHists_, fileName_, EcalFedMap::getSliceFromFed(), estimatePileup::hist, intToString(), maskedChannels_, and runNum_.

{
  using namespace std;
  fileName_ += "-"+intToString(runNum_)+".graph.root";

  TFile root_file_(fileName_.c_str() , "RECREATE");

  for(map<int,TH1F*>::const_iterator itr = FEDsAndHists_.begin();
      itr != FEDsAndHists_.end(); ++itr)
  {
    string dir = fedMap_->getSliceFromFed(itr->first);
    TDirectory* FEDdir = gDirectory->mkdir(dir.c_str());
    FEDdir->cd();

    TH1F* hist = itr->second;
    if(hist!=0)
      hist->Write();
    else
    {
      cerr << "EcalPedHists: Error: This shouldn't happen!" << endl;
    }
    // Write out timing hist
    hist = FEDsAndTimingHists_[itr->first];
    if(hist!=0)
      hist->Write();
    else
    {
      cerr << "EcalPedHists: Error: This shouldn't happen!" << endl;
    }
    root_file_.cd();
  }
  allFedsHist_->Write();
  allFedsTimingHist_->Write();
  root_file_.Close();

  std::string channels;
  for(std::vector<int>::const_iterator itr = maskedChannels_.begin();
      itr != maskedChannels_.end(); ++itr)
  {
    channels+=intToString(*itr);
    channels+=",";
  }
  
  LogWarning("EcalMipGraphs") << "Masked channels are: " << channels << " and that is all!";
}
void EcalURecHitHists::initHists ( int  FED) [private]

Definition at line 194 of file EcalURecHitHists.cc.

References L1Comparator_cfi::FEDid, fedMap_, FEDsAndHists_, FEDsAndTimingHists_, EcalFedMap::getSliceFromFed(), estimatePileup::hist, histRangeMax_, histRangeMin_, and intToString().

Referenced by analyze().

{
  using namespace std;
  
  string FEDid = intToString(FED);
  string title1 = "Uncalib Rec Hits (ADC counts) for ";
  title1.append(fedMap_->getSliceFromFed(FED));
  string name1 = "URecHitsFED";
  name1.append(intToString(FED));
  int numBins = (int)round(histRangeMax_-histRangeMin_)+1;
  TH1F* hist = new TH1F(name1.c_str(),title1.c_str(), numBins, histRangeMin_, histRangeMax_);
  FEDsAndHists_[FED] = hist;
  FEDsAndHists_[FED]->SetDirectory(0);
  
  title1 = "Jitter for ";
  title1.append(fedMap_->getSliceFromFed(FED));
  name1 = "JitterFED";
  name1.append(intToString(FED));
  TH1F* timingHist = new TH1F(name1.c_str(),title1.c_str(),14,-7,7);
  FEDsAndTimingHists_[FED] = timingHist;
  FEDsAndTimingHists_[FED]->SetDirectory(0);
}
std::string EcalURecHitHists::intToString ( int  num) [private]

Definition at line 275 of file EcalURecHitHists.cc.

Referenced by endJob(), and initHists().

{
    using namespace std;
    ostringstream myStream;
    myStream << num << flush;
    return(myStream.str()); //returns the string form of the stringstream object
}

Member Data Documentation

Definition at line 83 of file EcalURecHitHists.h.

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

Definition at line 84 of file EcalURecHitHists.h.

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

Definition at line 71 of file EcalURecHitHists.h.

Referenced by analyze().

Definition at line 88 of file EcalURecHitHists.h.

Referenced by analyze(), and beginRun().

Definition at line 72 of file EcalURecHitHists.h.

Referenced by analyze().

Definition at line 87 of file EcalURecHitHists.h.

Referenced by EcalURecHitHists(), endJob(), and initHists().

std::map<int,TH1F*> EcalURecHitHists::FEDsAndHists_ [private]

Definition at line 80 of file EcalURecHitHists.h.

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

std::map<int,TH1F*> EcalURecHitHists::FEDsAndTimingHists_ [private]

Definition at line 81 of file EcalURecHitHists.h.

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

TFile* EcalURecHitHists::file [private]

Definition at line 86 of file EcalURecHitHists.h.

std::string EcalURecHitHists::fileName_ [private]

Definition at line 75 of file EcalURecHitHists.h.

Referenced by endJob().

Definition at line 74 of file EcalURecHitHists.h.

Referenced by EcalURecHitHists(), and initHists().

Definition at line 74 of file EcalURecHitHists.h.

Referenced by EcalURecHitHists(), and initHists().

std::vector<int> EcalURecHitHists::maskedChannels_ [private]

Definition at line 77 of file EcalURecHitHists.h.

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

std::vector<std::string> EcalURecHitHists::maskedEBs_ [private]

Definition at line 79 of file EcalURecHitHists.h.

Referenced by EcalURecHitHists().

std::vector<int> EcalURecHitHists::maskedFEDs_ [private]

Definition at line 78 of file EcalURecHitHists.h.

Referenced by analyze(), and EcalURecHitHists().

Definition at line 73 of file EcalURecHitHists.h.

Referenced by analyze(), and endJob().