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 Attributes
HcalPedestalMCWidths Class Reference

#include <HcalPedestalMCWidths.h>

Inheritance diagram for HcalPedestalMCWidths:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &eventSetup)
 
 HcalPedestalMCWidths (const edm::ParameterSet &ps)
 
virtual ~HcalPedestalMCWidths ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

std::vector< MCWidthsBunchBunches
 
bool firsttime
 
edm::InputTag hbheDigiCollectionTag_
 
TProfile * HBMeans [10]
 
TProfile * HEMeans [10]
 
edm::InputTag hfDigiCollectionTag_
 
TProfile * HFMeans [10]
 
bool histflag
 
edm::InputTag hoDigiCollectionTag_
 
TProfile * HOMeans [10]
 
std::string pedsADCfilename
 
int runnum
 
TFile * theFile
 
const HcalTopologytheTopology
 
std::string widthsfilename
 

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
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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 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

Definition at line 69 of file HcalPedestalMCWidths.h.

Constructor & Destructor Documentation

HcalPedestalMCWidths::HcalPedestalMCWidths ( const edm::ParameterSet ps)

Definition at line 12 of file HcalPedestalMCWidths.cc.

References firsttime, edm::ParameterSet::getUntrackedParameter(), and histflag.

12  :
13  hbheDigiCollectionTag_(ps.getParameter<edm::InputTag>("hbheDigiCollectionTag")),
14  hoDigiCollectionTag_(ps.getParameter<edm::InputTag>("hoDigiCollectionTag")),
15  hfDigiCollectionTag_(ps.getParameter<edm::InputTag>("hfDigiCollectionTag")) {
16 
17  firsttime = true;
18  histflag = ps.getUntrackedParameter<bool>("saveHists",true);
19 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag hbheDigiCollectionTag_
edm::InputTag hoDigiCollectionTag_
edm::InputTag hfDigiCollectionTag_
HcalPedestalMCWidths::~HcalPedestalMCWidths ( )
virtual

Definition at line 22 of file HcalPedestalMCWidths.cc.

References HcalCovarianceMatrices::addValues(), Bunches, gather_cfg::cout, HcalDbASCIIIO::dumpObject(), HcalObjRepresent::Fill(), HBMeans, HEMeans, HFMeans, histflag, HOMeans, i, edm::isNotFinite(), j, gen::k, EdgesToViz::outfile, HcalCovarianceMatrix::setValue(), theFile, theTopology, and widthsfilename.

23 {
25  std::ofstream outfile(widthsfilename.c_str());
26  std::vector<MCWidthsBunch>::iterator bunch_it;
27  for(bunch_it=Bunches.begin(); bunch_it != Bunches.end(); bunch_it++)
28  {
29  if(!bunch_it->usedflag) continue;
30 
31  HcalCovarianceMatrix item(bunch_it->detid.rawId());
32  for(int i = 0; i != 4; i++){
33  for(int j = 0; j != 10; j++){
34  for(int k = 0; k != 10; k++){
35  bunch_it->sig[i][j][k] = (bunch_it->prod[i][j][k]/bunch_it->num[i][j][k]);//-(bunch_it->cap[i]*bunch_it->cap[(i+j)%4]);
36  if(!edm::isNotFinite(bunch_it->sig[i][j][k]))
37  {
38  item.setValue(i,j,k,bunch_it->sig[i][j][k]);
39  }else{
40  item.setValue(i,j,k,0.0);
41  }
42  }
43  }
44  }
45 
46  rawCovItem->addValues(item);
47 
48  if(histflag)
49  {
50  if(bunch_it->detid.subdet() == 1){
51  for(int i = 0; i != 4; i++){
52  for(int j = 0; j != 10; j++){
53  for(int k = j; k != 10; k++)
54  if(!edm::isNotFinite(bunch_it->sig[i][j][k])) HBMeans[j]->Fill(k-j,bunch_it->sig[i][j][k]);
55  }
56  }
57  }
58  if(bunch_it->detid.subdet() == 2){
59  for(int i = 0; i != 4; i++){
60  for(int j = 0; j != 10; j++){
61  for(int k = j; k != 10; k++)
62  if(!edm::isNotFinite(bunch_it->sig[i][j][k])) HEMeans[j]->Fill(k-j,bunch_it->sig[i][j][k]);
63  }
64  }
65  }
66  if(bunch_it->detid.subdet() == 3){
67  for(int i = 0; i != 4; i++){
68  for(int j = 0; j != 10; j++){
69  for(int k = j; k != 10; k++)
70  if(!edm::isNotFinite(bunch_it->sig[i][j][k])) HFMeans[j]->Fill(k-j,bunch_it->sig[i][j][k]);
71  }
72  }
73  }
74  if(bunch_it->detid.subdet() == 4){
75  for(int i = 0; i != 4; i++){
76  for(int j = 0; j != 10; j++){
77  for(int k = j; k != 10; k++)
78  if(!edm::isNotFinite(bunch_it->sig[i][j][k])) HOMeans[j]->Fill(k-j,bunch_it->sig[i][j][k]);
79  }
80  }
81  }
82 
83 
84  }
85  }
86  HcalDbASCIIIO::dumpObject (outfile, (*rawCovItem) );
87 
88  if(histflag)
89  {
90  theFile->cd();
91  std::cout << "Writing histograms..." << std::endl;
92  for(int i = 0; i != 10; i++){
93  HBMeans[i]->Write();
94  HFMeans[i]->Write();
95  HEMeans[i]->Write();
96  HOMeans[i]->Write();
97  }
98  }
99  theFile->Close();
100  std::cout << "ROOT file closed.\n";
101 }
int i
Definition: DBlmapReader.cc:9
std::vector< MCWidthsBunch > Bunches
const HcalTopology * theTopology
list outfile
Definition: EdgesToViz.py:91
bool isNotFinite(T x)
Definition: isFinite.h:10
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
int j
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
void setValue(int capid, int i, int j, float val)
bool addValues(const HcalCovarianceMatrix &myHcalCovarianceMatrix)
bool dumpObject(std::ostream &fOutput, const HcalPedestals &fObject)
tuple cout
Definition: gather_cfg.py:121

Member Function Documentation

void HcalPedestalMCWidths::analyze ( const edm::Event event,
const edm::EventSetup eventSetup 
)
virtual

Implements edm::EDAnalyzer.

Definition at line 105 of file HcalPedestalMCWidths.cc.

References a, HcalQIESample::adc(), HcalElectronicsMap::allPrecisionId(), Bunches, HcalQIESample::capid(), MCWidthsBunch::detid, firsttime, edm::EventSetup::get(), edm::Event::getByLabel(), hbheDigiCollectionTag_, HBMeans, HEMeans, hfDigiCollectionTag_, HFMeans, hoDigiCollectionTag_, HOMeans, i, HFDataFrame::id(), HBHEDataFrame::id(), HODataFrame::id(), edm::EventBase::id(), j, gen::k, MCWidthsBunch::num, MCWidthsBunch::prod, edm::ESHandle< class >::product(), DetId::rawId(), edm::EventID::run(), runnum, HBHEDataFrame::sample(), HFDataFrame::sample(), HODataFrame::sample(), MCWidthsBunch::sig, AlCaHLTBitMon_QueryRunRegistry::string, theFile, theTopology, MCWidthsBunch::usedflag, and widthsfilename.

106 {
107  using namespace edm;
108  using namespace std;
109 
113  edm::ESHandle<HcalDbService> conditions;
114  iSetup.get<HcalDbRecord>().get(conditions);
115 
117  iSetup.get<HcalPedestalsRcd>().get(refPeds);
118  const HcalPedestals* myRefPeds = refPeds.product();
119 
120  if(firsttime)
121  {
122  theTopology=new HcalTopology(*(myRefPeds->topo()));
123  runnum = e.id().run();
124  std::string runnum_string;
125  std::stringstream tempstringout;
126  tempstringout << runnum;
127  runnum_string = tempstringout.str();
128  widthsfilename = runnum_string + "-MCwidths.txt";
129  std::string rootfilename = runnum_string + "-MCwidths.root";
130  theFile = new TFile(rootfilename.c_str(), "RECREATE");
131 
132  for(int i = 0; i!= 10; i++)
133  {
134  tempstringout.str("");
135  tempstringout << i;
136  std::string histname3 = tempstringout.str();
137  std::string histname2 = "Mean covariance TS ";
138  std::string histname1 = "HB ";
139  std::string histname = histname1 + histname2 + histname3;
140  HBMeans[i] = new TProfile(histname.c_str(),histname1.c_str(), 10, -0.50, 9.5);
141  histname1 = "HE ";
142  histname = histname1 + histname2 + histname3;
143  HEMeans[i] = new TProfile(histname.c_str(),histname1.c_str(), 10, -0.50, 9.5);
144  histname1 = "HF ";
145  histname = histname1 + histname2 + histname3;
146  HFMeans[i] = new TProfile(histname.c_str(),histname1.c_str(), 10, -0.50, 9.5);
147  histname1 = "HO ";
148  histname = histname1 + histname2 + histname3;
149  HOMeans[i] = new TProfile(histname.c_str(),histname1.c_str(), 10, -0.50, 9.5);
150  }
151 
153  iSetup.get<HcalElectronicsMapRcd>().get(refEMap);
154  const HcalElectronicsMap* myRefEMap = refEMap.product();
155  std::vector<HcalGenericDetId> listEMap = myRefEMap->allPrecisionId();
156  for (std::vector<HcalGenericDetId>::const_iterator it = listEMap.begin(); it != listEMap.end(); it++)
157  {
158  HcalGenericDetId mygenid(it->rawId());
159  if(mygenid.isHcalDetId())
160  {
162  HcalDetId chanid(mygenid.rawId());
163  a.detid = chanid;
164  a.usedflag = false;
165  for(int i = 0; i != 4; i++)
166  {
167  for(int j = 0; j != 10; j++){
168  for(int k = 0; k != 10; k++)
169  {
170  a.sig[i][j][k] = 0;
171  a.prod[i][j][k] = 0;
172  a.num[i][j][k] = 0;
173  }}
174  }
175  Bunches.push_back(a);
176  }
177  }
178  firsttime = false;
179  }
180 
181  std::vector<MCWidthsBunch>::iterator bunch_it;
182 
183  for(HBHEDigiCollection::const_iterator j = hbhe->begin(); j != hbhe->end(); j++)
184  {
185  const HBHEDataFrame digi = (const HBHEDataFrame)(*j);
186  for(bunch_it = Bunches.begin(); bunch_it != Bunches.end(); bunch_it++)
187  if(bunch_it->detid.rawId() == digi.id().rawId()) break;
188  DetId searchid(digi.id().rawId());
189  const HcalPedestal* peds = (myRefPeds->getValues( searchid ));
190  bunch_it->usedflag = true;
191  int firstcapid = digi.sample(0).capid();
192  for(int ts = 0; ts != 10; ts++)
193  {
194  for(int j = ts; j != 10; j++){
195  bunch_it->num[firstcapid][ts][j] += 1;
196  bunch_it->prod[firstcapid][ts][j] +=
197  ((digi.sample(j).adc()-peds->getValue(firstcapid))
198  *(digi.sample(ts).adc()-peds->getValue(digi.sample(ts).capid())));
199  }
200  }
201  }
202 
203  for(HODigiCollection::const_iterator j = ho->begin(); j != ho->end(); j++)
204  {
205  const HODataFrame digi = (const HODataFrame)(*j);
206  for(bunch_it = Bunches.begin(); bunch_it != Bunches.end(); bunch_it++)
207  if(bunch_it->detid.rawId() == digi.id().rawId()) break;
208  DetId searchid(digi.id().rawId());
209  const HcalPedestal* peds = (myRefPeds->getValues( searchid ));
210  bunch_it->usedflag = true;
211  int firstcapid = digi.sample(0).capid();
212  for(int ts = 0; ts != 10; ts++)
213  {
214  for(int j = ts; j != 10; j++){
215  bunch_it->num[firstcapid][ts][j] += 1;
216  bunch_it->prod[firstcapid][ts][j] +=
217  ((digi.sample(j).adc()-peds->getValue(firstcapid))
218  *(digi.sample(ts).adc()-peds->getValue(digi.sample(ts).capid())));
219  }
220  }
221  }
222 
223  for(HFDigiCollection::const_iterator j = hf->begin(); j != hf->end(); j++)
224  {
225  const HFDataFrame digi = (const HFDataFrame)(*j);
226  for(bunch_it = Bunches.begin(); bunch_it != Bunches.end(); bunch_it++)
227  if(bunch_it->detid.rawId() == digi.id().rawId()) break;
228  DetId searchid(digi.id().rawId());
229  const HcalPedestal* peds = (myRefPeds->getValues( searchid ));
230  bunch_it->usedflag = true;
231  int firstcapid = digi.sample(0).capid();
232  for(int ts = 0; ts != 10; ts++)
233  {
234  for(int j = ts; j != 10; j++){
235  bunch_it->num[firstcapid][ts][j] += 1;
236  bunch_it->prod[firstcapid][ts][j] +=
237  ((digi.sample(j).adc()-peds->getValue(firstcapid))
238  *(digi.sample(ts).adc()-peds->getValue(digi.sample(ts).capid())));
239  }
240  }
241 
242  }
243 //this is the last brace
244 }
int i
Definition: DBlmapReader.cc:9
int num[4][10][10]
edm::InputTag hbheDigiCollectionTag_
edm::InputTag hoDigiCollectionTag_
int adc() const
get the ADC sample
Definition: HcalQIESample.h:24
float sig[4][10][10]
std::vector< T >::const_iterator const_iterator
const HcalQIESample & sample(int i) const
access a sample
Definition: HODataFrame.h:40
const HcalDetId & id() const
Definition: HODataFrame.h:23
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
std::vector< MCWidthsBunch > Bunches
const HcalTopology * theTopology
edm::InputTag hfDigiCollectionTag_
const HcalQIESample & sample(int i) const
access a sample
Definition: HFDataFrame.h:39
int j
Definition: DBlmapReader.cc:9
std::vector< HcalGenericDetId > allPrecisionId() const
int k[5][pyjets_maxn]
Definition: DetId.h:20
int capid() const
get the Capacitor id
Definition: HcalQIESample.h:28
const HcalQIESample & sample(int i) const
access a sample
Definition: HBHEDataFrame.h:39
float prod[4][10][10]
T const * product() const
Definition: ESHandle.h:62
double a
Definition: hdecay.h:121
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
const HcalDetId & id() const
Definition: HFDataFrame.h:22

Member Data Documentation

std::vector<MCWidthsBunch> HcalPedestalMCWidths::Bunches
private

Definition at line 81 of file HcalPedestalMCWidths.h.

Referenced by analyze(), and ~HcalPedestalMCWidths().

bool HcalPedestalMCWidths::firsttime
private

Definition at line 96 of file HcalPedestalMCWidths.h.

Referenced by analyze(), and HcalPedestalMCWidths().

edm::InputTag HcalPedestalMCWidths::hbheDigiCollectionTag_
private

Definition at line 99 of file HcalPedestalMCWidths.h.

Referenced by analyze().

TProfile* HcalPedestalMCWidths::HBMeans[10]
private

Definition at line 88 of file HcalPedestalMCWidths.h.

Referenced by analyze(), and ~HcalPedestalMCWidths().

TProfile* HcalPedestalMCWidths::HEMeans[10]
private

Definition at line 89 of file HcalPedestalMCWidths.h.

Referenced by analyze(), and ~HcalPedestalMCWidths().

edm::InputTag HcalPedestalMCWidths::hfDigiCollectionTag_
private

Definition at line 101 of file HcalPedestalMCWidths.h.

Referenced by analyze().

TProfile* HcalPedestalMCWidths::HFMeans[10]
private

Definition at line 90 of file HcalPedestalMCWidths.h.

Referenced by analyze(), and ~HcalPedestalMCWidths().

bool HcalPedestalMCWidths::histflag
private

Definition at line 97 of file HcalPedestalMCWidths.h.

Referenced by HcalPedestalMCWidths(), and ~HcalPedestalMCWidths().

edm::InputTag HcalPedestalMCWidths::hoDigiCollectionTag_
private

Definition at line 100 of file HcalPedestalMCWidths.h.

Referenced by analyze().

TProfile* HcalPedestalMCWidths::HOMeans[10]
private

Definition at line 91 of file HcalPedestalMCWidths.h.

Referenced by analyze(), and ~HcalPedestalMCWidths().

std::string HcalPedestalMCWidths::pedsADCfilename
private

Definition at line 83 of file HcalPedestalMCWidths.h.

int HcalPedestalMCWidths::runnum
private

Definition at line 86 of file HcalPedestalMCWidths.h.

Referenced by analyze().

TFile* HcalPedestalMCWidths::theFile
private

Definition at line 95 of file HcalPedestalMCWidths.h.

Referenced by analyze(), and ~HcalPedestalMCWidths().

const HcalTopology* HcalPedestalMCWidths::theTopology
private

Definition at line 93 of file HcalPedestalMCWidths.h.

Referenced by analyze(), and ~HcalPedestalMCWidths().

std::string HcalPedestalMCWidths::widthsfilename
private

Definition at line 84 of file HcalPedestalMCWidths.h.

Referenced by analyze(), and ~HcalPedestalMCWidths().