CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
EcalURecHitHists Class Reference

#include <EcalURecHitHists.h>

Inheritance diagram for EcalURecHitHists:
edm::EDAnalyzer

Public Member Functions

 EcalURecHitHists (const edm::ParameterSet &)
 
 ~EcalURecHitHists ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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_.

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

Definition at line 80 of file EcalURecHitHists.cc.

81 {
82 }

Member Function Documentation

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

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(), ecalpyutils::hashedIndex(), EBDetId::hashedIndex(), EEDetId::hashedIndex(), EBDetId::ic(), EEDetId::ic(), EcalUncalibratedRecHit::id(), edm::EventBase::id(), initHists(), EcalUncalibratedRecHit::jitter(), LogDebug, maskedChannels_, maskedFEDs_, query::result, edm::EventID::run(), and runNum_.

92 {
93  int ievt = iEvent.id().event();
96 
97  iEvent.getByLabel(EBUncalibratedRecHitCollection_, EBhits);
98  LogDebug("EcalURecHitHists") << "event " << ievt << " hits collection size " << EBhits->size();
99 
100  iEvent.getByLabel(EEUncalibratedRecHitCollection_, EEhits);
101  LogDebug("EcalURecHitHists") << "event " << ievt << " hits collection size " << EEhits->size();
102 
103  for (EcalUncalibratedRecHitCollection::const_iterator hitItr = EBhits->begin(); hitItr != EBhits->end(); ++hitItr)
104  {
105  EcalUncalibratedRecHit hit = (*hitItr);
106  EBDetId ebDet = hit.id();
107  int ic = ebDet.ic();
108  int hashedIndex = ebDet.hashedIndex();
110  int FEDid = 600+elecId.dccId();
111  float ampli = hit.amplitude();
112 
113  vector<int>::iterator result;
114  result = find(maskedFEDs_.begin(), maskedFEDs_.end(), FEDid);
115  if(result != maskedFEDs_.end())
116  {
117  LogWarning("EcalURecHitHists") << "skipping uncalRecHit for FED " << FEDid << " ; amplitude " << ampli;
118  continue;
119  }
120 
121  result = find(maskedChannels_.begin(), maskedChannels_.end(), hashedIndex);
122  if (result != maskedChannels_.end())
123  {
124  LogWarning("EcalURecHitHists") << "skipping uncalRecHit for channel: " << ic << " with amplitude " << ampli ;
125  continue;
126  }
127 
128  // fill the proper hist
129  TH1F* uRecHist = FEDsAndHists_[FEDid];
130  TH1F* timingHist = FEDsAndTimingHists_[FEDid];
131  if(uRecHist==0)
132  {
133  initHists(FEDid);
134  uRecHist = FEDsAndHists_[FEDid];
135  timingHist = FEDsAndTimingHists_[FEDid];
136  }
137 
138  uRecHist->Fill(ampli);
139  allFedsHist_->Fill(ampli);
140  timingHist->Fill(hit.jitter());
141  allFedsTimingHist_->Fill(hit.jitter());
142  }
143 
144  // Again for the endcap
145  for (EcalUncalibratedRecHitCollection::const_iterator hitItr = EEhits->begin(); hitItr != EEhits->end(); ++hitItr)
146  {
147  EcalUncalibratedRecHit hit = (*hitItr);
148  EEDetId eeDet = hit.id();
149  int ic = eeDet.ic();
150  int hashedIndex = eeDet.hashedIndex();
152  int FEDid = 600+elecId.dccId();
153  float ampli = hit.amplitude();
154 
155  vector<int>::iterator result;
156  result = find(maskedFEDs_.begin(), maskedFEDs_.end(), FEDid);
157  if(result != maskedFEDs_.end())
158  {
159  LogWarning("EcalURecHitHists") << "skipping uncalRecHit for FED " << FEDid << " ; amplitude " << ampli;
160  continue;
161  }
162 
163  result = find(maskedChannels_.begin(), maskedChannels_.end(), hashedIndex);
164  if (result != maskedChannels_.end())
165  {
166  LogWarning("EcalURecHitHists") << "skipping uncalRecHit for channel: " << ic << " with amplitude " << ampli ;
167  continue;
168  }
169 
170  // fill the proper hist
171  TH1F* uRecHist = FEDsAndHists_[FEDid];
172  TH1F* timingHist = FEDsAndTimingHists_[FEDid];
173  if(uRecHist==0)
174  {
175  initHists(FEDid);
176  uRecHist = FEDsAndHists_[FEDid];
177  timingHist = FEDsAndTimingHists_[FEDid];
178  }
179 
180  uRecHist->Fill(ampli);
181  allFedsHist_->Fill(ampli);
182  timingHist->Fill(hit.jitter());
183  allFedsTimingHist_->Fill(hit.jitter());
184  }
185 
186  if(runNum_==-1)
187  {
188  runNum_ = iEvent.id().run();
189  }
190 }
#define LogDebug(id)
const EcalElectronicsMapping * ecalElectronicsMap_
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:73
int ic() const
Definition: EEDetId.cc:340
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:7
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:243
tuple result
Definition: query.py:137
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:94
std::map< int, TH1F * > FEDsAndHists_
int hashedIndex() const
Definition: EEDetId.h:177
std::vector< int > maskedChannels_
std::map< int, TH1F * > FEDsAndTimingHists_
std::vector< int > maskedFEDs_
void EcalURecHitHists::beginRun ( edm::Run const &  ,
edm::EventSetup const &  c 
)
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 219 of file EcalURecHitHists.cc.

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

220 {
222  c.get<EcalMappingRcd>().get(elecHandle);
223  ecalElectronicsMap_ = elecHandle.product();
224 }
const EcalElectronicsMapping * ecalElectronicsMap_
T const * product() const
Definition: ESHandle.h:62
void EcalURecHitHists::endJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 228 of file EcalURecHitHists.cc.

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

229 {
230  using namespace std;
231  fileName_ += "-"+intToString(runNum_)+".graph.root";
232 
233  TFile root_file_(fileName_.c_str() , "RECREATE");
234 
235  for(map<int,TH1F*>::const_iterator itr = FEDsAndHists_.begin();
236  itr != FEDsAndHists_.end(); ++itr)
237  {
238  string dir = fedMap_->getSliceFromFed(itr->first);
239  TDirectory* FEDdir = gDirectory->mkdir(dir.c_str());
240  FEDdir->cd();
241 
242  TH1F* hist = itr->second;
243  if(hist!=0)
244  hist->Write();
245  else
246  {
247  cerr << "EcalPedHists: Error: This shouldn't happen!" << endl;
248  }
249  // Write out timing hist
250  hist = FEDsAndTimingHists_[itr->first];
251  if(hist!=0)
252  hist->Write();
253  else
254  {
255  cerr << "EcalPedHists: Error: This shouldn't happen!" << endl;
256  }
257  root_file_.cd();
258  }
259  allFedsHist_->Write();
260  allFedsTimingHist_->Write();
261  root_file_.Close();
262 
263  std::string channels;
264  for(std::vector<int>::const_iterator itr = maskedChannels_.begin();
265  itr != maskedChannels_.end(); ++itr)
266  {
267  channels+=intToString(*itr);
268  channels+=",";
269  }
270 
271  LogWarning("EcalMipGraphs") << "Masked channels are: " << channels << " and that is all!";
272 }
std::string fileName_
std::string getSliceFromFed(int)
Definition: EcalFedMap.cc:93
std::map< int, TH1F * > FEDsAndHists_
std::vector< int > maskedChannels_
std::map< int, TH1F * > FEDsAndTimingHists_
EcalFedMap * fedMap_
std::string intToString(int num)
dbl *** dir
Definition: mlp_gen.cc:35
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().

195 {
196  using namespace std;
197 
198  string FEDid = intToString(FED);
199  string title1 = "Uncalib Rec Hits (ADC counts) for ";
200  title1.append(fedMap_->getSliceFromFed(FED));
201  string name1 = "URecHitsFED";
202  name1.append(intToString(FED));
203  int numBins = (int)round(histRangeMax_-histRangeMin_)+1;
204  TH1F* hist = new TH1F(name1.c_str(),title1.c_str(), numBins, histRangeMin_, histRangeMax_);
205  FEDsAndHists_[FED] = hist;
206  FEDsAndHists_[FED]->SetDirectory(0);
207 
208  title1 = "Jitter for ";
209  title1.append(fedMap_->getSliceFromFed(FED));
210  name1 = "JitterFED";
211  name1.append(intToString(FED));
212  TH1F* timingHist = new TH1F(name1.c_str(),title1.c_str(),14,-7,7);
213  FEDsAndTimingHists_[FED] = timingHist;
214  FEDsAndTimingHists_[FED]->SetDirectory(0);
215 }
std::string getSliceFromFed(int)
Definition: EcalFedMap.cc:93
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 275 of file EcalURecHitHists.cc.

Referenced by endJob(), and initHists().

276 {
277  using namespace std;
278  ostringstream myStream;
279  myStream << num << flush;
280  return(myStream.str()); //returns the string form of the stringstream object
281 }
long long int num
Definition: procUtils.cc:71

Member Data Documentation

TH1F* EcalURecHitHists::allFedsHist_
private

Definition at line 83 of file EcalURecHitHists.h.

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

TH1F* EcalURecHitHists::allFedsTimingHist_
private

Definition at line 84 of file EcalURecHitHists.h.

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

edm::InputTag EcalURecHitHists::EBUncalibratedRecHitCollection_
private

Definition at line 71 of file EcalURecHitHists.h.

Referenced by analyze().

const EcalElectronicsMapping* EcalURecHitHists::ecalElectronicsMap_
private

Definition at line 88 of file EcalURecHitHists.h.

Referenced by analyze(), and beginRun().

edm::InputTag EcalURecHitHists::EEUncalibratedRecHitCollection_
private

Definition at line 72 of file EcalURecHitHists.h.

Referenced by analyze().

EcalFedMap* EcalURecHitHists::fedMap_
private

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().

double EcalURecHitHists::histRangeMax_
private

Definition at line 74 of file EcalURecHitHists.h.

Referenced by EcalURecHitHists(), and initHists().

double EcalURecHitHists::histRangeMin_
private

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().

int EcalURecHitHists::runNum_
private

Definition at line 73 of file EcalURecHitHists.h.

Referenced by analyze(), and endJob().