CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalURecHitHists Class Reference

#include <EcalURecHitHists.h>

Inheritance diagram for EcalURecHitHists:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

 EcalURecHitHists (const edm::ParameterSet &)
 
 ~EcalURecHitHists () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

void analyze (edm::Event const &, edm::EventSetup const &) override
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
void endJob () override
 
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_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

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

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

Definition at line 54 of file EcalURecHitHists.h.

Constructor & Destructor Documentation

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

Definition at line 36 of file EcalURecHitHists.cc.

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

37  : EBUncalibratedRecHitCollection_(iConfig.getParameter<edm::InputTag>("EBUncalibratedRecHitCollection")),
38  EEUncalibratedRecHitCollection_(iConfig.getParameter<edm::InputTag>("EEUncalibratedRecHitCollection")),
39  runNum_(-1),
40  histRangeMax_(iConfig.getUntrackedParameter<double>("histogramMaxRange", 200.0)),
41  histRangeMin_(iConfig.getUntrackedParameter<double>("histogramMinRange", -10.0)),
42  fileName_(iConfig.getUntrackedParameter<std::string>("fileName", std::string("ecalURechHitHists"))) {
43  vector<int> listDefaults;
44  listDefaults.push_back(-1);
45 
46  maskedChannels_ = iConfig.getUntrackedParameter<vector<int> >("maskedChannels", listDefaults);
47  maskedFEDs_ = iConfig.getUntrackedParameter<vector<int> >("maskedFEDs", listDefaults);
48 
49  vector<string> defaultMaskedEBs;
50  defaultMaskedEBs.push_back("none");
51  maskedEBs_ = iConfig.getUntrackedParameter<vector<string> >("maskedEBs", defaultMaskedEBs);
52 
53  fedMap_ = new EcalFedMap();
54  string title1 = "Uncalib Rec Hits (ADC counts)";
55  string name1 = "URecHitsAllFEDs";
56  int numBins = (int)round(histRangeMax_ - histRangeMin_) + 1;
57  allFedsHist_ = new TH1F(name1.c_str(), title1.c_str(), numBins, histRangeMin_, histRangeMax_);
58  title1 = "Jitter for all FEDs";
59  name1 = "JitterAllFEDs";
60  allFedsTimingHist_ = new TH1F(name1.c_str(), title1.c_str(), 14, -7, 7);
61 
62  // load up the maskedFED list with the proper FEDids
63  if (maskedFEDs_[0] == -1) {
64  //if "actual" EB id given, then convert to FEDid and put in listFEDs_
65  if (maskedEBs_[0] != "none") {
66  maskedFEDs_.clear();
67  for (vector<string>::const_iterator ebItr = maskedEBs_.begin(); ebItr != maskedEBs_.end(); ++ebItr) {
68  maskedFEDs_.push_back(fedMap_->getFedFromSlice(*ebItr));
69  }
70  }
71  }
72 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::string fileName_
edm::InputTag EBUncalibratedRecHitCollection_
edm::InputTag EEUncalibratedRecHitCollection_
std::vector< int > maskedChannels_
std::vector< std::string > maskedEBs_
std::vector< int > maskedFEDs_
EcalFedMap * fedMap_
EcalURecHitHists::~EcalURecHitHists ( )
override

Definition at line 74 of file EcalURecHitHists.cc.

74 {}

Member Function Documentation

void EcalURecHitHists::analyze ( edm::Event const &  iEvent,
edm::EventSetup const &  iSetup 
)
overrideprivatevirtual

Implements edm::EDAnalyzer.

Definition at line 81 of file EcalURecHitHists.cc.

References allFedsHist_, allFedsTimingHist_, EcalUncalibratedRecHit::amplitude(), edm::SortedCollection< T, SORT >::begin(), EcalElectronicsId::dccId(), EBUncalibratedRecHitCollection_, ecalElectronicsMap_, EEUncalibratedRecHitCollection_, edm::SortedCollection< T, SORT >::end(), edm::EventID::event(), FEDsAndHists_, FEDsAndTimingHists_, spr::find(), edm::Event::getByLabel(), EcalElectronicsMapping::getElectronicsId(), ecalpyutils::hashedIndex(), EBDetId::hashedIndex(), EEDetId::hashedIndex(), EBDetId::ic(), EEDetId::ic(), EcalUncalibratedRecHit::id(), edm::EventBase::id(), initHists(), EcalUncalibratedRecHit::jitter(), LogDebug, maskedChannels_, maskedFEDs_, mps_fire::result, edm::EventID::run(), runNum_, and edm::SortedCollection< T, SORT >::size().

81  {
82  int ievt = iEvent.id().event();
85 
86  iEvent.getByLabel(EBUncalibratedRecHitCollection_, EBhits);
87  LogDebug("EcalURecHitHists") << "event " << ievt << " hits collection size " << EBhits->size();
88 
89  iEvent.getByLabel(EEUncalibratedRecHitCollection_, EEhits);
90  LogDebug("EcalURecHitHists") << "event " << ievt << " hits collection size " << EEhits->size();
91 
92  for (EcalUncalibratedRecHitCollection::const_iterator hitItr = EBhits->begin(); hitItr != EBhits->end(); ++hitItr) {
93  EcalUncalibratedRecHit hit = (*hitItr);
94  EBDetId ebDet = hit.id();
95  int ic = ebDet.ic();
96  int hashedIndex = ebDet.hashedIndex();
98  int FEDid = 600 + elecId.dccId();
99  float ampli = hit.amplitude();
100 
101  vector<int>::iterator result;
102  result = find(maskedFEDs_.begin(), maskedFEDs_.end(), FEDid);
103  if (result != maskedFEDs_.end()) {
104  LogWarning("EcalURecHitHists") << "skipping uncalRecHit for FED " << FEDid << " ; amplitude " << ampli;
105  continue;
106  }
107 
108  result = find(maskedChannels_.begin(), maskedChannels_.end(), hashedIndex);
109  if (result != maskedChannels_.end()) {
110  LogWarning("EcalURecHitHists") << "skipping uncalRecHit for channel: " << ic << " with amplitude " << ampli;
111  continue;
112  }
113 
114  // fill the proper hist
115  TH1F* uRecHist = FEDsAndHists_[FEDid];
116  TH1F* timingHist = FEDsAndTimingHists_[FEDid];
117  if (uRecHist == nullptr) {
118  initHists(FEDid);
119  uRecHist = FEDsAndHists_[FEDid];
120  timingHist = FEDsAndTimingHists_[FEDid];
121  }
122 
123  uRecHist->Fill(ampli);
124  allFedsHist_->Fill(ampli);
125  timingHist->Fill(hit.jitter());
126  allFedsTimingHist_->Fill(hit.jitter());
127  }
128 
129  // Again for the endcap
130  for (EcalUncalibratedRecHitCollection::const_iterator hitItr = EEhits->begin(); hitItr != EEhits->end(); ++hitItr) {
131  EcalUncalibratedRecHit hit = (*hitItr);
132  EEDetId eeDet = hit.id();
133  int ic = eeDet.ic();
134  int hashedIndex = eeDet.hashedIndex();
136  int FEDid = 600 + elecId.dccId();
137  float ampli = hit.amplitude();
138 
139  vector<int>::iterator result;
140  result = find(maskedFEDs_.begin(), maskedFEDs_.end(), FEDid);
141  if (result != maskedFEDs_.end()) {
142  LogWarning("EcalURecHitHists") << "skipping uncalRecHit for FED " << FEDid << " ; amplitude " << ampli;
143  continue;
144  }
145 
146  result = find(maskedChannels_.begin(), maskedChannels_.end(), hashedIndex);
147  if (result != maskedChannels_.end()) {
148  LogWarning("EcalURecHitHists") << "skipping uncalRecHit for channel: " << ic << " with amplitude " << ampli;
149  continue;
150  }
151 
152  // fill the proper hist
153  TH1F* uRecHist = FEDsAndHists_[FEDid];
154  TH1F* timingHist = FEDsAndTimingHists_[FEDid];
155  if (uRecHist == nullptr) {
156  initHists(FEDid);
157  uRecHist = FEDsAndHists_[FEDid];
158  timingHist = FEDsAndTimingHists_[FEDid];
159  }
160 
161  uRecHist->Fill(ampli);
162  allFedsHist_->Fill(ampli);
163  timingHist->Fill(hit.jitter());
164  allFedsTimingHist_->Fill(hit.jitter());
165  }
166 
167  if (runNum_ == -1) {
168  runNum_ = iEvent.id().run();
169  }
170 }
#define LogDebug(id)
const EcalElectronicsMapping * ecalElectronicsMap_
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:82
int ic() const
Definition: EEDetId.cc:245
edm::InputTag EBUncalibratedRecHitCollection_
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
std::vector< T >::const_iterator const_iterator
edm::InputTag EEUncalibratedRecHitCollection_
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:42
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
int iEvent
Definition: GenABIO.cc:224
std::map< int, TH1F * > FEDsAndHists_
std::map< int, TH1F * > FEDsAndTimingHists_
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:41
const_iterator end() const
int hashedIndex() const
Definition: EEDetId.h:183
std::vector< int > maskedChannels_
size_type size() const
std::vector< int > maskedFEDs_
const_iterator begin() const
void EcalURecHitHists::beginRun ( edm::Run const &  ,
edm::EventSetup const &  c 
)
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 196 of file EcalURecHitHists.cc.

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

196  {
198  c.get<EcalMappingRcd>().get(elecHandle);
199  ecalElectronicsMap_ = elecHandle.product();
200 }
const EcalElectronicsMapping * ecalElectronicsMap_
T const * product() const
Definition: ESHandle.h:86
void EcalURecHitHists::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 203 of file EcalURecHitHists.cc.

References allFedsHist_, allFedsTimingHist_, MessageLogger_cfi::cerr, dir, fedMap_, FEDsAndHists_, FEDsAndTimingHists_, fileName_, EcalFedMap::getSliceFromFed(), create_public_lumi_plots::hist, intToString(), maskedChannels_, runNum_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by o2olib.O2ORunMgr::executeJob().

203  {
204  using namespace std;
205  fileName_ += "-" + intToString(runNum_) + ".graph.root";
206 
207  TFile root_file_(fileName_.c_str(), "RECREATE");
208 
209  for (map<int, TH1F*>::const_iterator itr = FEDsAndHists_.begin(); itr != FEDsAndHists_.end(); ++itr) {
210  string dir = fedMap_->getSliceFromFed(itr->first);
211  TDirectory* FEDdir = gDirectory->mkdir(dir.c_str());
212  FEDdir->cd();
213 
214  TH1F* hist = itr->second;
215  if (hist != nullptr)
216  hist->Write();
217  else {
218  cerr << "EcalPedHists: Error: This shouldn't happen!" << endl;
219  }
220  // Write out timing hist
221  hist = FEDsAndTimingHists_[itr->first];
222  if (hist != nullptr)
223  hist->Write();
224  else {
225  cerr << "EcalPedHists: Error: This shouldn't happen!" << endl;
226  }
227  root_file_.cd();
228  }
229  allFedsHist_->Write();
230  allFedsTimingHist_->Write();
231  root_file_.Close();
232 
233  std::string channels;
234  for (std::vector<int>::const_iterator itr = maskedChannels_.begin(); itr != maskedChannels_.end(); ++itr) {
235  channels += intToString(*itr);
236  channels += ",";
237  }
238 
239  LogWarning("EcalMipGraphs") << "Masked channels are: " << channels << " and that is all!";
240 }
std::string fileName_
std::string getSliceFromFed(int)
Definition: EcalFedMap.cc:86
std::map< int, TH1F * > FEDsAndHists_
std::map< int, TH1F * > FEDsAndTimingHists_
std::vector< int > maskedChannels_
EcalFedMap * fedMap_
std::string intToString(int num)
dbl *** dir
Definition: mlp_gen.cc:35
void EcalURecHitHists::initHists ( int  FED)
private

Definition at line 173 of file EcalURecHitHists.cc.

References fedMap_, FEDsAndHists_, FEDsAndTimingHists_, EcalFedMap::getSliceFromFed(), create_public_lumi_plots::hist, histRangeMax_, histRangeMin_, createfilelist::int, and intToString().

Referenced by analyze().

173  {
174  using namespace std;
175 
176  string FEDid = intToString(FED);
177  string title1 = "Uncalib Rec Hits (ADC counts) for ";
178  title1.append(fedMap_->getSliceFromFed(FED));
179  string name1 = "URecHitsFED";
180  name1.append(intToString(FED));
181  int numBins = (int)round(histRangeMax_ - histRangeMin_) + 1;
182  TH1F* hist = new TH1F(name1.c_str(), title1.c_str(), numBins, histRangeMin_, histRangeMax_);
183  FEDsAndHists_[FED] = hist;
184  FEDsAndHists_[FED]->SetDirectory(nullptr);
185 
186  title1 = "Jitter for ";
187  title1.append(fedMap_->getSliceFromFed(FED));
188  name1 = "JitterFED";
189  name1.append(intToString(FED));
190  TH1F* timingHist = new TH1F(name1.c_str(), title1.c_str(), 14, -7, 7);
191  FEDsAndTimingHists_[FED] = timingHist;
192  FEDsAndTimingHists_[FED]->SetDirectory(nullptr);
193 }
std::string getSliceFromFed(int)
Definition: EcalFedMap.cc:86
std::map< int, TH1F * > FEDsAndHists_
std::map< int, TH1F * > FEDsAndTimingHists_
EcalFedMap * fedMap_
std::string intToString(int num)
std::string EcalURecHitHists::intToString ( int  num)
private

Definition at line 242 of file EcalURecHitHists.cc.

Referenced by endJob(), and initHists().

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

Member Data Documentation

TH1F* EcalURecHitHists::allFedsHist_
private

Definition at line 80 of file EcalURecHitHists.h.

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

TH1F* EcalURecHitHists::allFedsTimingHist_
private

Definition at line 81 of file EcalURecHitHists.h.

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

edm::InputTag EcalURecHitHists::EBUncalibratedRecHitCollection_
private

Definition at line 68 of file EcalURecHitHists.h.

Referenced by analyze().

const EcalElectronicsMapping* EcalURecHitHists::ecalElectronicsMap_
private

Definition at line 85 of file EcalURecHitHists.h.

Referenced by analyze(), and beginRun().

edm::InputTag EcalURecHitHists::EEUncalibratedRecHitCollection_
private

Definition at line 69 of file EcalURecHitHists.h.

Referenced by analyze().

EcalFedMap* EcalURecHitHists::fedMap_
private

Definition at line 84 of file EcalURecHitHists.h.

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

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

Definition at line 77 of file EcalURecHitHists.h.

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

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

Definition at line 78 of file EcalURecHitHists.h.

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

TFile* EcalURecHitHists::file
private

Definition at line 83 of file EcalURecHitHists.h.

Referenced by ztee.GZipLog::finish().

std::string EcalURecHitHists::fileName_
private

Definition at line 72 of file EcalURecHitHists.h.

Referenced by endJob().

double EcalURecHitHists::histRangeMax_
private

Definition at line 71 of file EcalURecHitHists.h.

Referenced by EcalURecHitHists(), and initHists().

double EcalURecHitHists::histRangeMin_
private

Definition at line 71 of file EcalURecHitHists.h.

Referenced by EcalURecHitHists(), and initHists().

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

Definition at line 74 of file EcalURecHitHists.h.

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

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

Definition at line 76 of file EcalURecHitHists.h.

Referenced by EcalURecHitHists().

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

Definition at line 75 of file EcalURecHitHists.h.

Referenced by analyze(), and EcalURecHitHists().

int EcalURecHitHists::runNum_
private

Definition at line 70 of file EcalURecHitHists.h.

Referenced by analyze(), and endJob().