CMS 3D CMS Logo

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

#include <EcalPedHists.h>

Inheritance diagram for EcalPedHists:
edm::one::EDAnalyzer< edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 EcalPedHists (const edm::ParameterSet &ps)
 
 ~EcalPedHists () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDAnalyzerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginRun (edm::Run const &, edm::EventSetup const &c) override
 
void endJob (void) override
 
void endRun (edm::Run const &, edm::EventSetup const &c) override
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

Private Member Functions

void initHists (int FED)
 
std::string intToString (int num)
 
void readEBdigis (edm::Handle< EBDigiCollection > digis)
 
void readEEdigis (edm::Handle< EEDigiCollection > digis)
 

Private Attributes

bool allFEDsSelected_
 
const edm::InputTag barrelDigiCollection_
 
const edm::EDGetTokenT< EBDigiCollectionebDigiToken_
 
const EcalElectronicsMappingecalElectronicsMap_
 
const edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcdecalMappingToken_
 
const edm::EDGetTokenT< EEDigiCollectioneeDigiToken_
 
const edm::InputTag endcapDigiCollection_
 
EcalFedMapfedMap_
 
std::map< int, stringHistMapFEDsAndHistMaps_
 
std::string fileName_
 
const edm::InputTag headerProducer_
 
bool histsFilled_
 
bool inputIsOk_
 
std::vector< int > listChannels_
 
std::vector< std::string > listEBs_
 
std::vector< int > listFEDs_
 
std::vector< int > listSamples_
 
const edm::EDGetTokenT< EcalRawDataCollectionrawDataToken_
 
TFile * root_file_
 
int runNum_
 
std::set< int > theRealFedSet_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

Definition at line 35 of file EcalPedHists.h.

Constructor & Destructor Documentation

◆ EcalPedHists()

EcalPedHists::EcalPedHists ( const edm::ParameterSet ps)

Module which outputs a root file of ADC counts (all three gains) of user-selected channels (defaults to channel 1) for user-selected samples (defaults to samples 1,2,3) for user-selected supermodules.

Author
S. Cooper

Definition at line 13 of file EcalPedHists.cc.

References allFEDsSelected_, gather_cfg::cout, fedMap_, EcalFedMap::getFedFromSlice(), edm::ParameterSet::getUntrackedParameter(), histsFilled_, mps_fire::i, inputIsOk_, listChannels_, listEBs_, listFEDs_, listSamples_, and theRealFedSet_.

14  : runNum_(-1),
15  fileName_(ps.getUntrackedParameter<std::string>("fileName", std::string("ecalPedDigiDump"))),
16  barrelDigiCollection_(ps.getParameter<edm::InputTag>("EBdigiCollection")),
17  endcapDigiCollection_(ps.getParameter<edm::InputTag>("EEdigiCollection")),
18  headerProducer_(ps.getParameter<edm::InputTag>("headerProducer")),
19  rawDataToken_(consumes<EcalRawDataCollection>(headerProducer_)),
20  ebDigiToken_(consumes<EBDigiCollection>(barrelDigiCollection_)),
21  eeDigiToken_(consumes<EEDigiCollection>(endcapDigiCollection_)),
22  ecalMappingToken_(esConsumes<edm::Transition::BeginRun>()) {
23  using namespace std;
24 
25  fedMap_ = new EcalFedMap();
26  histsFilled_ = false;
27  //for(int i=601; i<655; ++i)
28  //{
29  // listDefaults.push_back(i);
30  //}
31  listFEDs_ = ps.getUntrackedParameter<vector<int> >("listFEDs");
32  listEBs_ = ps.getUntrackedParameter<vector<string> >("listEBs");
33 
34  if (listFEDs_.empty()) {
35  allFEDsSelected_ = false;
36  //if "actual" EB id given, then convert to FEDid and put in listFEDs_
37  if (!listEBs_.empty()) {
38  listFEDs_.clear();
39  for (vector<string>::const_iterator itr = listEBs_.begin(); itr != listEBs_.end(); ++itr) {
40  listFEDs_.push_back(fedMap_->getFedFromSlice(*itr));
41  }
42  }
43  } else if (listFEDs_[0] == -1) {
44  // Apply no selection if -1 is passed in FED list
45  allFEDsSelected_ = true;
46  //debug
47  //cout << "no selection on FEDs!" << endl;
48  //inputIsOk_=false;
49  //return;
50  //listFEDs_ = listDefaults;
51  } else {
52  //in this case, listFEDs should be populated
53  allFEDsSelected_ = false;
54  }
55 
56  if (!allFEDsSelected_) {
57  // Verify FED numbers are valid
58  for (vector<int>::const_iterator intIter = listFEDs_.begin(); intIter != listFEDs_.end(); intIter++) {
59  if (((*intIter) < 601) || (654 < (*intIter))) {
60  cout << "[EcalPedHists] FED value: " << (*intIter) << " found in listFEDs. "
61  << " Valid range is 601-654. Returning." << endl;
62  inputIsOk_ = false;
63  return;
64  } else
65  theRealFedSet_.insert(*intIter);
66  }
67  }
68 
69  vector<int> listDefaults = vector<int>();
70  listDefaults.clear();
71  for (int i = 1; i < 1701; ++i) {
72  listDefaults.push_back(i);
73  }
74  listChannels_ = ps.getUntrackedParameter<vector<int> >("listChannels", listDefaults);
75  listDefaults.clear();
76  // Get samples to plot (default to 1,2,3)
77  listDefaults.push_back(0);
78  listDefaults.push_back(1);
79  listDefaults.push_back(2);
80  listSamples_ = ps.getUntrackedParameter<vector<int> >("listSamples", listDefaults);
81 
82  inputIsOk_ = true;
83  vector<int>::iterator intIter;
84 
85  // Verify crystal numbers are valid
86  for (intIter = listChannels_.begin(); intIter != listChannels_.end(); ++intIter) {
87  //TODO: Fix crystal index checking?
88  //if ( ((*intIter) < 1)||(1700 < (*intIter)) )
89  //{
90  // cout << "[EcalPedHists] ic value: " << (*intIter) << " found in listChannels. "
91  // << " Valid range is 1-1700. Returning." << endl;
92  // inputIsOk_ = false;
93  // return;
94  //}
95  }
96  // Verify sample numbers are valid
97  for (intIter = listSamples_.begin(); intIter != listSamples_.end(); intIter++) {
98  if (((*intIter) < 1) || (10 < (*intIter))) {
99  cout << "[EcalPedHists] sample number: " << (*intIter) << " found in listSamples. "
100  << " Valid range is 1-10. Returning." << endl;
101  inputIsOk_ = false;
102  return;
103  }
104  }
105 }
std::vector< int > listFEDs_
Definition: EcalPedHists.h:62
std::set< int > theRealFedSet_
Definition: EcalPedHists.h:65
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::EDGetTokenT< EEDigiCollection > eeDigiToken_
Definition: EcalPedHists.h:71
const edm::InputTag headerProducer_
Definition: EcalPedHists.h:59
int getFedFromSlice(std::string)
Definition: EcalFedMap.cc:96
T getUntrackedParameter(std::string const &, T const &) const
const edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > ecalMappingToken_
Definition: EcalPedHists.h:72
std::vector< std::string > listEBs_
Definition: EcalPedHists.h:63
const edm::EDGetTokenT< EBDigiCollection > ebDigiToken_
Definition: EcalPedHists.h:70
bool histsFilled_
Definition: EcalPedHists.h:55
const edm::InputTag barrelDigiCollection_
Definition: EcalPedHists.h:57
EcalFedMap * fedMap_
Definition: EcalPedHists.h:66
std::vector< int > listChannels_
Definition: EcalPedHists.h:60
bool allFEDsSelected_
Definition: EcalPedHists.h:54
std::string fileName_
Definition: EcalPedHists.h:56
const edm::EDGetTokenT< EcalRawDataCollection > rawDataToken_
Definition: EcalPedHists.h:69
const edm::InputTag endcapDigiCollection_
Definition: EcalPedHists.h:58
std::vector< int > listSamples_
Definition: EcalPedHists.h:61

◆ ~EcalPedHists()

EcalPedHists::~EcalPedHists ( )
override

Definition at line 107 of file EcalPedHists.cc.

107 {}

Member Function Documentation

◆ analyze()

void EcalPedHists::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overrideprotectedvirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 174 of file EcalPedHists.cc.

References allFEDsSelected_, barrelDigiCollection_, mtdUncalibratedRecHits_cfi::barrelDigis, edm::SortedCollection< T, SORT >::begin(), MillePedeFileConverter_cfg::e, ebDigiToken_, eeDigiToken_, edm::SortedCollection< T, SORT >::end(), endcapDigiCollection_, mtdUncalibratedRecHits_cfi::endcapDigis, FEDsAndHistMaps_, headerProducer_, initHists(), inputIsOk_, edm::HandleBase::isValid(), rawDataToken_, readEBdigis(), readEEdigis(), runNum_, and theRealFedSet_.

174  {
175  using namespace std;
176  using namespace edm;
177 
178  if (!inputIsOk_)
179  return;
180 
181  // loop over the headers, this is to detect missing FEDs if all are selected
182  if (allFEDsSelected_) {
184  e.getByToken(rawDataToken_, DCCHeaders);
185  if (!DCCHeaders.isValid()) {
186  edm::LogError("EcalPedHists") << "Error! can't get the product " << headerProducer_;
187  return;
188  }
189 
190  for (EcalRawDataCollection::const_iterator headerItr = DCCHeaders->begin(); headerItr != DCCHeaders->end();
191  ++headerItr) {
192  int FEDid = 600 + headerItr->id();
193  theRealFedSet_.insert(FEDid);
194  }
195  }
196 
197  // loop over fed list and make sure that there are histo maps
198  for (set<int>::const_iterator fedItr = theRealFedSet_.begin(); fedItr != theRealFedSet_.end(); ++fedItr) {
199  if (FEDsAndHistMaps_.find(*fedItr) == FEDsAndHistMaps_.end())
200  initHists(*fedItr);
201  }
202 
203  //debug
204  //cout << "analyze...input is ok? " << inputIsOk_ << endl;
205 
206  bool barrelDigisFound = true;
207  bool endcapDigisFound = true;
208  // get the barrel digis
209  // (one digi for each crystal)
210  // TODO; SIC: fix this behavior
212  e.getByToken(ebDigiToken_, barrelDigis);
213  if (!barrelDigis.isValid()) {
214  edm::LogError("EcalPedOffset") << "Error! can't get the product " << barrelDigiCollection_;
215  barrelDigisFound = false;
216  }
217  // get the endcap digis
218  // (one digi for each crystal)
219  // TODO; SIC: fix this behavior
221  e.getByToken(eeDigiToken_, endcapDigis);
222  if (!endcapDigis.isValid()) {
223  edm::LogError("EcalPedOffset") << "Error! can't get the product " << endcapDigiCollection_;
224  endcapDigisFound = false;
225  }
226 
227  if (barrelDigisFound)
229  if (endcapDigisFound)
231  if (!barrelDigisFound && !endcapDigisFound)
232  edm::LogError("EcalPedOffset") << "No digis found in the event!";
233 
234  if (runNum_ == -1)
235  runNum_ = e.id().run();
236 }
std::set< int > theRealFedSet_
Definition: EcalPedHists.h:65
void initHists(int FED)
const edm::EDGetTokenT< EEDigiCollection > eeDigiToken_
Definition: EcalPedHists.h:71
const edm::InputTag headerProducer_
Definition: EcalPedHists.h:59
std::vector< T >::const_iterator const_iterator
std::map< int, stringHistMap > FEDsAndHistMaps_
Definition: EcalPedHists.h:64
Log< level::Error, false > LogError
const_iterator begin() const
const edm::EDGetTokenT< EBDigiCollection > ebDigiToken_
Definition: EcalPedHists.h:70
void readEBdigis(edm::Handle< EBDigiCollection > digis)
const_iterator end() const
const edm::InputTag barrelDigiCollection_
Definition: EcalPedHists.h:57
bool isValid() const
Definition: HandleBase.h:70
bool allFEDsSelected_
Definition: EcalPedHists.h:54
HLT enums.
const edm::EDGetTokenT< EcalRawDataCollection > rawDataToken_
Definition: EcalPedHists.h:69
void readEEdigis(edm::Handle< EEDigiCollection > digis)
const edm::InputTag endcapDigiCollection_
Definition: EcalPedHists.h:58

◆ beginRun()

void EcalPedHists::beginRun ( edm::Run const &  ,
edm::EventSetup const &  c 
)
overrideprotected

Definition at line 109 of file EcalPedHists.cc.

References DummyCfis::c, ecalElectronicsMap_, and ecalMappingToken_.

109  {
111 }
const edm::ESGetToken< EcalElectronicsMapping, EcalMappingRcd > ecalMappingToken_
Definition: EcalPedHists.h:72
const EcalElectronicsMapping * ecalElectronicsMap_
Definition: EcalPedHists.h:74

◆ endJob()

void EcalPedHists::endJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 115 of file EcalPedHists.cc.

References DMR_cfg::cerr, DeadROC_duringRun::dir, fedMap_, FEDsAndHistMaps_, fileName_, EcalFedMap::getSliceFromFed(), compareTotals::hist, histsFilled_, inputIsOk_, intToString(), listChannels_, hfnoseParametersInitialization_cfi::name2, root_file_, runNum_, and theRealFedSet_.

Referenced by o2olib.O2ORunMgr::executeJob().

115  {
116  using namespace std;
117  if (inputIsOk_) {
118  //debug
119  //cout << "endJob:creating root file!" << endl;
120 
121  fileName_ += "-" + intToString(runNum_) + ".graph.root";
122 
123  TFile root_file_(fileName_.c_str(), "RECREATE");
124  //Loop over FEDs first
125  for (set<int>::const_iterator FEDitr = theRealFedSet_.begin(); FEDitr != theRealFedSet_.end(); ++FEDitr) {
126  if (!histsFilled_)
127  break;
128  string dir = fedMap_->getSliceFromFed(*FEDitr);
129  TDirectory* FEDdir = gDirectory->mkdir(dir.c_str());
130  FEDdir->cd();
131  //root_file_.mkdir(dir.c_str());
132  //root_file_.cd(dir.c_str());
133  map<string, TH1F*> mapHistos = FEDsAndHistMaps_[*FEDitr];
134 
135  //Loop over channels; write histos and directory structure
136  for (vector<int>::const_iterator itr = listChannels_.begin(); itr != listChannels_.end(); itr++) {
137  //debug
138  //cout << "loop over channels" << endl;
139 
140  TH1F* hist = nullptr;
141  string chnl = intToString(*itr);
142  string name1 = "Cry";
143  name1.append(chnl + "Gain1");
144  string name2 = "Cry";
145  name2.append(chnl + "Gain6");
146  string name3 = "Cry";
147  name3.append(chnl + "Gain12");
148  hist = mapHistos[name1];
149  // This is a sanity check only
150  if (hist != nullptr) {
151  string cryDirName = "Cry_" + chnl;
152  TDirectory* cryDir = FEDdir->mkdir(cryDirName.c_str());
153  cryDir->cd();
154  hist->SetDirectory(cryDir);
155  hist->Write();
156  hist = mapHistos[name2];
157  hist->SetDirectory(cryDir);
158  hist->Write();
159  hist = mapHistos[name3];
160  hist->SetDirectory(cryDir);
161  hist->Write();
162  //root_file_.cd(dir.c_str());
163  root_file_.cd();
164  } else {
165  cerr << "EcalPedHists: Error: This shouldn't happen!" << endl;
166  }
167  }
168  root_file_.cd();
169  }
170  root_file_.Close();
171  }
172 }
std::set< int > theRealFedSet_
Definition: EcalPedHists.h:65
std::string intToString(int num)
std::map< int, stringHistMap > FEDsAndHistMaps_
Definition: EcalPedHists.h:64
std::string getSliceFromFed(int)
Definition: EcalFedMap.cc:86
bool histsFilled_
Definition: EcalPedHists.h:55
EcalFedMap * fedMap_
Definition: EcalPedHists.h:66
std::vector< int > listChannels_
Definition: EcalPedHists.h:60
std::string fileName_
Definition: EcalPedHists.h:56
TFile * root_file_
Definition: EcalPedHists.h:67

◆ endRun()

void EcalPedHists::endRun ( edm::Run const &  ,
edm::EventSetup const &  c 
)
overrideprotected

Definition at line 113 of file EcalPedHists.cc.

113 {}

◆ initHists()

void EcalPedHists::initHists ( int  FED)
private

Definition at line 239 of file EcalPedHists.cc.

References FEDsAndHistMaps_, intToString(), listChannels_, and hfnoseParametersInitialization_cfi::name2.

Referenced by analyze().

239  {
240  using namespace std;
241  //using namespace edm;
242 
243  std::map<string, TH1F*> histMap;
244  //debug
245  //cout << "Initializing map for FED:" << *FEDitr << endl;
246  for (vector<int>::const_iterator intIter = listChannels_.begin(); intIter != listChannels_.end(); ++intIter) {
247  //Put 3 histos (1 per gain) for the channel into the map
248  string FEDid = intToString(FED);
249  string chnl = intToString(*intIter);
250  string title1 = "Gain1 ADC Counts for channel ";
251  title1.append(chnl);
252  string name1 = "Cry";
253  name1.append(chnl + "Gain1");
254  string title2 = "Gain6 ADC Counts for channel ";
255  title2.append(chnl);
256  string name2 = "Cry";
257  name2.append(chnl + "Gain6");
258  string title3 = "Gain12 ADC Counts for channel ";
259  title3.append(chnl);
260  string name3 = "Cry";
261  name3.append(chnl + "Gain12");
262  histMap.insert(make_pair(name1, new TH1F(name1.c_str(), title1.c_str(), 75, 175.0, 250.0)));
263  histMap[name1]->SetDirectory(nullptr);
264  histMap.insert(make_pair(name2, new TH1F(name2.c_str(), title2.c_str(), 75, 175.0, 250.0)));
265  histMap[name2]->SetDirectory(nullptr);
266  histMap.insert(make_pair(name3, new TH1F(name3.c_str(), title3.c_str(), 75, 175.0, 250.0)));
267  histMap[name3]->SetDirectory(nullptr);
268  }
269  FEDsAndHistMaps_.insert(make_pair(FED, histMap));
270 }
std::string intToString(int num)
std::map< int, stringHistMap > FEDsAndHistMaps_
Definition: EcalPedHists.h:64
std::vector< int > listChannels_
Definition: EcalPedHists.h:60

◆ intToString()

std::string EcalPedHists::intToString ( int  num)
private

Definition at line 377 of file EcalPedHists.cc.

References EgammaValidation_cff::num.

Referenced by endJob(), initHists(), readEBdigis(), and readEEdigis().

377  {
378  using namespace std;
379  //
380  // outputs the number into the string stream and then flushes
381  // the buffer (makes sure the output is put into the stream)
382  //
383  ostringstream myStream; //creates an ostringstream object
384  myStream << num << flush;
385  return (myStream.str()); //returns the string form of the stringstream object
386 }

◆ readEBdigis()

void EcalPedHists::readEBdigis ( edm::Handle< EBDigiCollection digis)
private

Definition at line 272 of file EcalPedHists.cc.

References gpuClustering::adc, edm::DataFrameContainer::begin(), DMR_cfg::cerr, EcalElectronicsId::dccId(), hcalRecHitTable_cff::detId, ecalElectronicsMap_, edm::DataFrameContainer::end(), FEDsAndHistMaps_, spr::find(), ecalLiteDTU::gainId(), EcalElectronicsMapping::getElectronicsId(), compareTotals::hist, histsFilled_, intToString(), listChannels_, listSamples_, hfnoseParametersInitialization_cfi::name2, ecalGpuTask_cfi::sample, and theRealFedSet_.

Referenced by analyze().

272  {
273  using namespace std;
274  using namespace edm;
275  //debug
276  //cout << "readEBdigis" << endl;
277 
278  // Loop over digis
279  for (EBDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr) {
280  EBDetId detId = EBDetId(digiItr->id());
282  int FEDid = 600 + elecId.dccId();
283  int crystalId = detId.ic();
284 
285  //debug
286  //cout << "FEDid:" << FEDid << " cryId:" << crystalId << endl;
287  //cout << "FEDid:" << FEDid << endl;
288  //Select desired supermodules only
289  set<int>::const_iterator fedIter = find(theRealFedSet_.begin(), theRealFedSet_.end(), FEDid);
290  if (fedIter == theRealFedSet_.end())
291  continue;
292 
293  // Select desired channels only
294  vector<int>::iterator icIter;
295  icIter = find(listChannels_.begin(), listChannels_.end(), crystalId);
296  if (icIter == listChannels_.end())
297  continue;
298 
299  // Get the adc counts from the selected samples and fill the corresponding histogram
300  // Must subtract 1 from user-given sample list (e.g., user's sample 1 -> sample 0)
301  for (vector<int>::iterator itr = listSamples_.begin(); itr != listSamples_.end(); itr++) {
302  histsFilled_ = true;
303  map<string, TH1F*> mapHistos = FEDsAndHistMaps_[FEDid];
304  string chnl = intToString(crystalId);
305  string name1 = "Cry";
306  name1.append(chnl + "Gain1");
307  string name2 = "Cry";
308  name2.append(chnl + "Gain6");
309  string name3 = "Cry";
310  name3.append(chnl + "Gain12");
311  TH1F* hist = nullptr;
312  if (((EBDataFrame)(*digiItr)).sample(*itr - 1).gainId() == 3)
313  hist = mapHistos[name1];
314  if (((EBDataFrame)(*digiItr)).sample(*itr - 1).gainId() == 2)
315  hist = mapHistos[name2];
316  if (((EBDataFrame)(*digiItr)).sample(*itr - 1).gainId() == 1)
317  hist = mapHistos[name3];
318  if (hist != nullptr)
319  hist->Fill(((EBDataFrame)(*digiItr)).sample(*itr - 1).adc());
320  else
321  cerr << "EcalPedHistDumper: Error: This shouldn't happen!" << endl;
322  }
323  }
324 }
std::set< int > theRealFedSet_
Definition: EcalPedHists.h:65
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
std::string intToString(int num)
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
std::map< int, stringHistMap > FEDsAndHistMaps_
Definition: EcalPedHists.h:64
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const_iterator end() const
bool histsFilled_
Definition: EcalPedHists.h:55
const EcalElectronicsMapping * ecalElectronicsMap_
Definition: EcalPedHists.h:74
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
const_iterator begin() const
The iterator returned can not safely be used across threads.
std::vector< int > listChannels_
Definition: EcalPedHists.h:60
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
HLT enums.
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
uint16_t *__restrict__ uint16_t const *__restrict__ adc
std::vector< int > listSamples_
Definition: EcalPedHists.h:61

◆ readEEdigis()

void EcalPedHists::readEEdigis ( edm::Handle< EEDigiCollection digis)
private

Definition at line 326 of file EcalPedHists.cc.

References gpuClustering::adc, edm::DataFrameContainer::begin(), DMR_cfg::cerr, EcalElectronicsId::dccId(), hcalRecHitTable_cff::detId, ecalElectronicsMap_, edm::DataFrameContainer::end(), FEDsAndHistMaps_, spr::find(), ecalLiteDTU::gainId(), EcalElectronicsMapping::getElectronicsId(), compareTotals::hist, histsFilled_, intToString(), listChannels_, listSamples_, hfnoseParametersInitialization_cfi::name2, ecalGpuTask_cfi::sample, and theRealFedSet_.

Referenced by analyze().

326  {
327  using namespace std;
328  using namespace edm;
329  //debug
330  //cout << "readEEdigis" << endl;
331 
332  // Loop over digis
333  for (EEDigiCollection::const_iterator digiItr = digis->begin(); digiItr != digis->end(); ++digiItr) {
334  EEDetId detId = EEDetId(digiItr->id());
336  int FEDid = 600 + elecId.dccId();
337  int crystalId = 10000 * FEDid + 100 * elecId.towerId() + 5 * (elecId.stripId() - 1) + elecId.xtalId();
338 
339  //Select desired FEDs only
340  set<int>::const_iterator fedIter = find(theRealFedSet_.begin(), theRealFedSet_.end(), FEDid);
341  if (fedIter == theRealFedSet_.end())
342  continue;
343 
344  // Select desired channels only
345  vector<int>::iterator icIter;
346  icIter = find(listChannels_.begin(), listChannels_.end(), crystalId);
347  if (icIter == listChannels_.end())
348  continue;
349 
350  // Get the adc counts from the selected samples and fill the corresponding histogram
351  // Must subtract 1 from user-given sample list (e.g., user's sample 1 -> sample 0)
352  for (vector<int>::iterator itr = listSamples_.begin(); itr != listSamples_.end(); itr++) {
353  histsFilled_ = true;
354  map<string, TH1F*> mapHistos = FEDsAndHistMaps_[FEDid];
355  string chnl = intToString(crystalId);
356  string name1 = "Cry";
357  name1.append(chnl + "Gain1");
358  string name2 = "Cry";
359  name2.append(chnl + "Gain6");
360  string name3 = "Cry";
361  name3.append(chnl + "Gain12");
362  TH1F* hist = nullptr;
363  if (((EBDataFrame)(*digiItr)).sample(*itr - 1).gainId() == 3)
364  hist = mapHistos[name1];
365  if (((EBDataFrame)(*digiItr)).sample(*itr - 1).gainId() == 2)
366  hist = mapHistos[name2];
367  if (((EBDataFrame)(*digiItr)).sample(*itr - 1).gainId() == 1)
368  hist = mapHistos[name3];
369  if (hist != nullptr)
370  hist->Fill(((EBDataFrame)(*digiItr)).sample(*itr - 1).adc());
371  else
372  cerr << "EcalPedHistDumper: Error: This shouldn't happen!" << endl;
373  }
374  }
375 }
std::set< int > theRealFedSet_
Definition: EcalPedHists.h:65
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
std::string intToString(int num)
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
std::map< int, stringHistMap > FEDsAndHistMaps_
Definition: EcalPedHists.h:64
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const_iterator end() const
bool histsFilled_
Definition: EcalPedHists.h:55
const EcalElectronicsMapping * ecalElectronicsMap_
Definition: EcalPedHists.h:74
constexpr int gainId(sample_type sample)
get the gainId (2 bits)
const_iterator begin() const
The iterator returned can not safely be used across threads.
std::vector< int > listChannels_
Definition: EcalPedHists.h:60
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
HLT enums.
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
uint16_t *__restrict__ uint16_t const *__restrict__ adc
std::vector< int > listSamples_
Definition: EcalPedHists.h:61

Member Data Documentation

◆ allFEDsSelected_

bool EcalPedHists::allFEDsSelected_
private

Definition at line 54 of file EcalPedHists.h.

Referenced by analyze(), and EcalPedHists().

◆ barrelDigiCollection_

const edm::InputTag EcalPedHists::barrelDigiCollection_
private

Definition at line 57 of file EcalPedHists.h.

Referenced by analyze().

◆ ebDigiToken_

const edm::EDGetTokenT<EBDigiCollection> EcalPedHists::ebDigiToken_
private

Definition at line 70 of file EcalPedHists.h.

Referenced by analyze().

◆ ecalElectronicsMap_

const EcalElectronicsMapping* EcalPedHists::ecalElectronicsMap_
private

Definition at line 74 of file EcalPedHists.h.

Referenced by beginRun(), readEBdigis(), and readEEdigis().

◆ ecalMappingToken_

const edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> EcalPedHists::ecalMappingToken_
private

Definition at line 72 of file EcalPedHists.h.

Referenced by beginRun().

◆ eeDigiToken_

const edm::EDGetTokenT<EEDigiCollection> EcalPedHists::eeDigiToken_
private

Definition at line 71 of file EcalPedHists.h.

Referenced by analyze().

◆ endcapDigiCollection_

const edm::InputTag EcalPedHists::endcapDigiCollection_
private

Definition at line 58 of file EcalPedHists.h.

Referenced by analyze().

◆ fedMap_

EcalFedMap* EcalPedHists::fedMap_
private

Definition at line 66 of file EcalPedHists.h.

Referenced by EcalPedHists(), and endJob().

◆ FEDsAndHistMaps_

std::map<int, stringHistMap> EcalPedHists::FEDsAndHistMaps_
private

Definition at line 64 of file EcalPedHists.h.

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

◆ fileName_

std::string EcalPedHists::fileName_
private

Definition at line 56 of file EcalPedHists.h.

Referenced by endJob().

◆ headerProducer_

const edm::InputTag EcalPedHists::headerProducer_
private

Definition at line 59 of file EcalPedHists.h.

Referenced by analyze().

◆ histsFilled_

bool EcalPedHists::histsFilled_
private

Definition at line 55 of file EcalPedHists.h.

Referenced by EcalPedHists(), endJob(), readEBdigis(), and readEEdigis().

◆ inputIsOk_

bool EcalPedHists::inputIsOk_
private

Definition at line 53 of file EcalPedHists.h.

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

◆ listChannels_

std::vector<int> EcalPedHists::listChannels_
private

Definition at line 60 of file EcalPedHists.h.

Referenced by EcalPedHists(), endJob(), initHists(), readEBdigis(), and readEEdigis().

◆ listEBs_

std::vector<std::string> EcalPedHists::listEBs_
private

Definition at line 63 of file EcalPedHists.h.

Referenced by EcalPedHists().

◆ listFEDs_

std::vector<int> EcalPedHists::listFEDs_
private

Definition at line 62 of file EcalPedHists.h.

Referenced by EcalPedHists().

◆ listSamples_

std::vector<int> EcalPedHists::listSamples_
private

Definition at line 61 of file EcalPedHists.h.

Referenced by EcalPedHists(), readEBdigis(), and readEEdigis().

◆ rawDataToken_

const edm::EDGetTokenT<EcalRawDataCollection> EcalPedHists::rawDataToken_
private

Definition at line 69 of file EcalPedHists.h.

Referenced by analyze().

◆ root_file_

TFile* EcalPedHists::root_file_
private

Definition at line 67 of file EcalPedHists.h.

Referenced by endJob().

◆ runNum_

int EcalPedHists::runNum_
private

Definition at line 52 of file EcalPedHists.h.

Referenced by analyze(), and endJob().

◆ theRealFedSet_

std::set<int> EcalPedHists::theRealFedSet_
private

Definition at line 65 of file EcalPedHists.h.

Referenced by analyze(), EcalPedHists(), endJob(), readEBdigis(), and readEEdigis().