CMS 3D CMS Logo

EcalURecHitHists.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EcalURecHitHists
4 // Class: EcalURecHitHists
5 //
13 //
14 // Original Author: Seth COOPER
15 // Created: Th Nov 22 5:46:22 CEST 2007
16 //
17 //
18 
20 
21 using namespace cms;
22 using namespace edm;
23 using namespace std;
24 
25 //
26 // constants, enums and typedefs
27 //
28 
29 //
30 // static data member definitions
31 //
32 
33 //
34 // constructors and destructor
35 //
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 }
73 
75 
76 //
77 // member functions
78 //
79 
80 // ------------ method called to for each event ------------
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 
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 
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 }
171 
172 // insert the hist map into the map keyed by FED number
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 }
194 
195 // ------------ method called once each job just before starting event loop ------------
198  c.get<EcalMappingRcd>().get(elecHandle);
199  ecalElectronicsMap_ = elecHandle.product();
200 }
201 
202 // ------------ method called once each job just after ending the event loop ------------
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 
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 }
241 
243  using namespace std;
244  ostringstream myStream;
245  myStream << num << flush;
246  return (myStream.str()); //returns the string form of the stringstream object
247 }
EBDetId::hashedIndex
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:82
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
EcalURecHitHists::EcalURecHitHists
EcalURecHitHists(const edm::ParameterSet &)
Definition: EcalURecHitHists.cc:36
edm::SortedCollection::const_iterator
std::vector< T >::const_iterator const_iterator
Definition: SortedCollection.h:80
hit::id
unsigned int id
Definition: SiStripHitEffFromCalibTree.cc:92
EcalURecHitHists::analyze
void analyze(edm::Event const &, edm::EventSetup const &) override
Definition: EcalURecHitHists.cc:81
EcalURecHitHists::FEDsAndTimingHists_
std::map< int, TH1F * > FEDsAndTimingHists_
Definition: EcalURecHitHists.h:78
EBDetId::ic
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:41
edm::Run
Definition: Run.h:45
EBDetId
Definition: EBDetId.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
EcalURecHitHists::intToString
std::string intToString(int num)
Definition: EcalURecHitHists.cc:242
edm::SortedCollection::size
size_type size() const
Definition: SortedCollection.h:215
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EcalURecHitHists::allFedsHist_
TH1F * allFedsHist_
Definition: EcalURecHitHists.h:80
EcalURecHitHists::maskedEBs_
std::vector< std::string > maskedEBs_
Definition: EcalURecHitHists.h:76
EcalElectronicsId::dccId
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
Definition: EcalElectronicsId.h:31
EcalURecHitHists::maskedFEDs_
std::vector< int > maskedFEDs_
Definition: EcalURecHitHists.h:75
spr::find
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
EcalURecHitHists::maskedChannels_
std::vector< int > maskedChannels_
Definition: EcalURecHitHists.h:74
edm::Handle
Definition: AssociativeIterator.h:50
EcalURecHitHists.h
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
EEDetId::ic
int ic() const
Definition: EEDetId.cc:245
EcalURecHitHists::allFedsTimingHist_
TH1F * allFedsTimingHist_
Definition: EcalURecHitHists.h:81
edm::SortedCollection::begin
const_iterator begin() const
Definition: SortedCollection.h:262
EcalURecHitHists::~EcalURecHitHists
~EcalURecHitHists() override
Definition: EcalURecHitHists.cc:74
edm::ESHandle< EcalElectronicsMapping >
EcalElectronicsMapping::getElectronicsId
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
Definition: EcalElectronicsMapping.cc:324
EcalURecHitHists::histRangeMin_
double histRangeMin_
Definition: EcalURecHitHists.h:71
EcalElectronicsId
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
Definition: EcalElectronicsId.h:18
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalURecHitHists::fedMap_
EcalFedMap * fedMap_
Definition: EcalURecHitHists.h:84
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
gpuVertexFinder::hist
__shared__ Hist hist
Definition: gpuClusterTracksDBSCAN.h:48
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
EcalURecHitHists::ecalElectronicsMap_
const EcalElectronicsMapping * ecalElectronicsMap_
Definition: EcalURecHitHists.h:85
EcalURecHitHists::runNum_
int runNum_
Definition: EcalURecHitHists.h:70
EEDetId::hashedIndex
int hashedIndex() const
Definition: EEDetId.h:183
createfilelist.int
int
Definition: createfilelist.py:10
iEvent
int iEvent
Definition: GenABIO.cc:224
EcalFedMap::getSliceFromFed
std::string getSliceFromFed(int)
Definition: EcalFedMap.cc:86
EcalURecHitHists::fileName_
std::string fileName_
Definition: EcalURecHitHists.h:72
edm::EventSetup
Definition: EventSetup.h:58
get
#define get
EcalURecHitHists::initHists
void initHists(int)
Definition: EcalURecHitHists.cc:173
EgammaValidation_cff.num
num
Definition: EgammaValidation_cff.py:34
EcalUncalibratedRecHit
Definition: EcalUncalibratedRecHit.h:8
EcalURecHitHists::EEUncalibratedRecHitCollection_
edm::InputTag EEUncalibratedRecHitCollection_
Definition: EcalURecHitHists.h:69
std
Definition: JetResolutionObject.h:76
EcalMappingRcd
Definition: EcalMappingRcd.h:15
EcalFedMap
Definition: EcalFedMap.h:7
EcalURecHitHists::EBUncalibratedRecHitCollection_
edm::InputTag EBUncalibratedRecHitCollection_
Definition: EcalURecHitHists.h:68
ewkTauDQM_cfi.channels
channels
Definition: ewkTauDQM_cfi.py:14
EcalURecHitHists::beginRun
void beginRun(edm::Run const &, edm::EventSetup const &) override
Definition: EcalURecHitHists.cc:196
EcalURecHitHists::endJob
void endJob() override
Definition: EcalURecHitHists.cc:203
EcalFedMap::getFedFromSlice
int getFedFromSlice(std::string)
Definition: EcalFedMap.cc:96
mps_fire.result
result
Definition: mps_fire.py:311
c
auto & c
Definition: CAHitNtupletGeneratorKernelsImpl.h:46
edm::Event
Definition: Event.h:73
EcalURecHitHists::histRangeMax_
double histRangeMax_
Definition: EcalURecHitHists.h:71
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
ecalpyutils::hashedIndex
int hashedIndex(int ieta, int iphi)
Definition: EcalPyUtils.cc:38
edm::InputTag
Definition: InputTag.h:15
hit
Definition: SiStripHitEffFromCalibTree.cc:88
EcalURecHitHists::FEDsAndHists_
std::map< int, TH1F * > FEDsAndHists_
Definition: EcalURecHitHists.h:77
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
cms
Namespace of DDCMS conversion namespace.
Definition: ProducerAnalyzer.cc:21